Mule 4 / DW 2.0 - проблема с зацикливанием внутри карты

вот образец JSON. Логика преобразования DW 2.0, которую я пробовал, а также ожидаемый xml, приведены ниже. Проблема в том, что включены все эпизоды каждого сезона. > Бизнес-логика: у каждого show_id есть несколько серий, у каждой серии есть несколько сезонов, у каждого сезона есть несколько эпизодов. Пожалуйста, дайте мне знать, если потребуется дополнительная информация.

Входной JSON:> Входной массив представляет собой массив объектов JSON

[
 {
   "uniqueid": "(ASSSIM0001,Simulcast,English)",
      "genres": "Action/Adventure,Comedy,Sci Fi",
      "quality_quality": "HD",
      "show_detail_box_art_phone": 
      "season_sequence_number": "1",
      "videos_id": "74052",
      "videos_ratings": "PS-RTE,14-TV-US,14-CBSC,12-zw-movies",
      "show_id": "ASS",
      "videos_alpha_external_id": "ASSSIM0001",
      "purchase_type": "AVOD",
      "territory": "Canada - English speaking",
      "videos_episode_number": "1           ",
      "series_name": "Assassination Classroom",
      "title": "Assassination Time English Simulcast",
      "title_category": "Episode",
      "episode_id": "19467"
},
{
      "uniqueid": "(ASSSIM0001,Simulcast,Japanese)",
      "genres": "Action/Adventure,Comedy,Sci Fi",
      "quality_quality": "HD",
      "show_detail_box_art_phone": 
      "season_sequence_number": "1",
      "videos_id": "19468",
      "videos_ratings": "PS-RTE,14-TV-US,14-CBSC,12-zw-movies",
      "show_id": "ASS",
      "videos_alpha_external_id": "ASSSIM0001",
      "purchase_type": "SVOD",
      "territory": "Canada - English speaking",
      "videos_episode_number": "1           ",
      "series_name": "Assassination Classroom",
      "title": "Assassination Time Japanese Simulcast",
      "title_category": "Episode",
      "episode_id": "19467"
    },
    {
      "uniqueid": "(ASSSIM0023,Simulcast,English)",
      "genres": "Action/Adventure,Comedy,Sci Fi",
      "quality_quality": "HD",
      "show_detail_box_art_phone":           
      "season_sequence_number": "2",
      "videos_id": "91325",
      "videos_ratings": "14-TV-US,PS-RTE,14-CBSC,12-zw-movies",
      "show_id": "ASS",
      "videos_alpha_external_id": "ASSSIM0023",
      "purchase_type": "AVOD",
      "territory": "Canada - English speaking",
      "firstname_lastname_charactername_spokenlanguage": "",
      "videos_episode_number": "23          ",
      "series_name": "Assassination Classroom",
      "title": "Summer Festival Time English Simulcast",
      "title_category": "Episode",
      "firstname_lastname_capacity_spokenlanguage": "",
      "episode_id": "91324"
    },
    {
      "uniqueid": "(ASSSIM0023,Simulcast,Japanese)",
      "genres": "Action/Adventure,Comedy,Sci Fi",
      "quality_quality": "HD",
      "show_detail_box_art_phone":           
      "season_sequence_number": "2",
      "videos_id": "91350",
      "videos_ratings": "14-TV-US,PS-RTE,14-CBSC,12-zw-movies",
      "show_id": "ASS",
      "videos_alpha_external_id": "ASSSIM0023",
      "purchase_type": "AVOD",
      "territory": "Canada - English speaking",
      "firstname_lastname_charactername_spokenlanguage": "",
      "videos_episode_number": "23          ",
      "series_name": "Assassination Classroom",
      "title": "Summer Festival Time Japanese Simulcast",
      "title_category": "Episode",
      "firstname_lastname_capacity_spokenlanguage": "",
      "episode_id": "91324"
    }
    ]

Код DW 2.0:

%dw 2.0
output application/xml
---
partnerContent: {
        seriesItems: {
            series: (payload distinctBy $.show_id  map(( seriesitems , seriesindex ) -> {
                titles: {
                    title: seriesitems.series_name
                },
                descriptions: {
                    description: seriesitems.series_short_synopsis
                }
                 ,
                    seasons1: {
                    season:
                    (payload distinctBy $.season_sequence_number map ( seasons , seasonsindex ) -> {
                        seasonNumber: seasons.season_sequence_number,
                    episodes1: {
                        (payload distinctBy $.videos_id map ( episodes , episodeindex ) -> {
                                episode @(id: episodes.videos_id): {
                                    titles: {
                                        title @(language: 'en'): episodes.title
                                    },
                                    descriptions: {
                                        description: episodes.title_short_synopsis
                                    },
                                    episodeNumber: trim(episodes.videos_episode_number)
                                }
                            })  
                    }
                    })
                }
        }))
        }
    }

Текущий выходной XML-файл: В текущем созданном XML-файле печатаются все серии для каждого из 2 сезонов

<?xml version='1.0' encoding='UTF-8'?>
<partnerContent>
  <seriesItems>
    <series>
      <titles>
        <title>Assassination Classroom</title>
      </titles>
      <descriptions>
        <description>Forget about homework and pop quizzes Class 3E has a far more important assignment kill their teacher before the end of the year </description>
      </descriptions>
      <seasons1>
        <season>
          <seasonNumber>1</seasonNumber>
          <episodes1>
            <episode id="74052">
              <titles>
                <title language="en">Assassination Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            <episode id="19468">
              <titles>
                <title language="en">Assassination Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            <episode id="91325">
              <titles>
                <title language="en">Summer Festival Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
            <episode id="91350">
              <titles>
                <title language="en">Summer Festival Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
          </episodes1>
        </season>
        <season>
          <seasonNumber>2</seasonNumber>
          <episodes1>
            <episode id="74052">
              <titles>
                <title language="en">Assassination Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            <episode id="19468">
              <titles>
                <title language="en">Assassination Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            <episode id="91325">
              <titles>
                <title language="en">Summer Festival Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
            <episode id="91350">
              <titles>
                <title language="en">Summer Festival Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
          </episodes1>
        </season>
      </seasons1>
    </series>
  </seriesItems>
</partnerContent>
-------------End of current output xml--------------------------
**Expected output xml**: >*Expected output xml is to show only the first 2 Episodes data in Season 1 
and last 2 Episodes under Season 2*
------------------------Start of Expected output xml-------------------------------------- 
<?xml version='1.0' encoding='UTF-8'?>
<partnerContent>
  <seriesItems>
    <series>
      <titles>
        <title>Assassination Classroom</title>
      </titles>
      <descriptions>
        <description>Forget about homework and pop quizzes Class 3E has a far more important assignment kill their teacher before the end of the year </description>
      </descriptions>
      <seasons1>
        <season>
          <seasonNumber>1</seasonNumber>
          <episodes1>
            <episode id="74052">
              <titles>
                <title language="en">Assassination Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            <episode id="19468">
              <titles>
                <title language="en">Assassination Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
              </descriptions>
              <episodeNumber>1</episodeNumber>
            </episode>
            </episodes1>
        </season>
        <season>
          <seasonNumber>2</seasonNumber>
          <episodes1>
            <episode id="91325">
              <titles>
                <title language="en">Summer Festival Time English Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
            <episode id="91350">
              <titles>
                <title language="en">Summer Festival Time Japanese Simulcast</title>
              </titles>
              <descriptions>
                <description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
              </descriptions>
              <episodeNumber>23</episodeNumber>
            </episode>
          </episodes1>
        </season>
      </seasons1>
    </series>
  </seriesItems>
</partnerContent>

person Mule4DC    schedule 10.01.2020    source источник
comment
Любая помощь @aled плз   -  person Mule4DC    schedule 15.01.2020


Ответы (1)


Каков ожидаемый результат? Какие элементы не следует включать в вывод?

person aled    schedule 13.01.2020
comment
В сезоне 1 должны отображаться только эпизоды - ‹эпизод с идентификатором = 74052› и ‹эпизод с идентификатором = 19468›, а в сезоне 2 должны отображаться только эпизоды - ‹эпизод с идентификатором = 91325› и ‹эпизод с идентификатором = 91350›. В настоящее время все эти 4 отображаются в обоих сезонах - 1 и 2. - person Mule4DC; 13.01.2020