Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-98108

Remote Publishing Dynamic Data Lists is not removing removed translations.

    Details

      Description

      0.) Use two vanilla 6.2 bundles with the latest fix pack.

      1.) Create in each system a new site and connect these via remote Staging (please enable all options under Stable Content, for the reported use case Dynamic Data Lists is the most relevant).

      2.) Navigate in the Staging site to Dynamic Data Lists, here select and perform the following:

      • Add to the name field 'Numbers'
      • For Data Definition click select → add, add to the name field 'Numbers' copy to the source the metadata:
        <root available-locales="en_US" default-locale="en_US">
        	<dynamic-element dataType="string" indexType="keyword" localizable="true" name="first" readOnly="false" repeatable="false" required="false" showLabel="true" type="text" width="small">
        		<meta-data locale="en_US">
        			<entry name="label">
        				<![CDATA[First]]>
        			</entry>
        			<entry name="predefinedValue">
        				<![CDATA[]]>
        			</entry>
        			<entry name="tip">
        				<![CDATA[]]>
        			</entry>
        		</meta-data>
        	</dynamic-element>
        	<dynamic-element dataType="string" indexType="keyword" localizable="true" name="second" readOnly="false" repeatable="false" required="false" showLabel="true" type="text" width="small">
        		<meta-data locale="en_US">
        			<entry name="label">
        				<![CDATA[Second]]>
        			</entry>
        			<entry name="predefinedValue">
        				<![CDATA[]]>
        			</entry>
        			<entry name="tip">
        				<![CDATA[]]>
        			</entry>
        		</meta-data>
        	</dynamic-element>
        </root>
        
      • this will create two text fields.
      • save the dynamic data list.

      3.) Click +add Numbers, then fill the fields with English:

      • First: First
      • Second : Second
      • Click save as draft
      • The reopen and add translations for Hungarian and German languages example
        Hungarian:
      • First: FirstHU
      • Second: SecondHU
        German:
        First: FirstGE
        Second: FirstGE
      • Click save as draft

      4.) Publish to remote live with permissions checked.

      5.) After the publication run the groovy script on the Staging an Live:

      import com.liferay.portal.kernel.dao.orm.DynamicQuery;
      import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
      import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
      import com.liferay.portal.kernel.exception.PortalException;
      import com.liferay.portal.kernel.exception.SystemException;
      import com.liferay.portal.kernel.util.ParamUtil;
      import com.liferay.portlet.PortletPreferencesFactoryUtil;
      import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
      import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
      import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
      import com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalServiceUtil;
      
      import com.liferay.portlet.dynamicdatamapping.storage.Field;
      import com.liferay.portlet.dynamicdatamapping.storage.Fields;
      import java.io.IOException;
      import java.io.StringReader;
      import java.util.HashSet;
      import java.util.Iterator;
      import java.util.List;
      import java.util.Locale;
      import java.util.Properties;
      import java.util.Set;
      Set<String> recordSetIds = new HashSet<String>();
      def basename = "Numbers";
      DynamicQuery dq = DynamicQueryFactoryUtil.forClass(DDLRecordSet.class);
      StringBuilder nameForQuery = new StringBuilder("%").append(basename).append("%");
      dq.add(PropertyFactoryUtil.forName("name").like(nameForQuery.toString()));
      try {
      List<DDLRecordSet> recordSets = DDLRecordLocalServiceUtil.dynamicQuery(dq);
      // Gather the IDs from the found DDLRecordSets
      for (DDLRecordSet recordSet : recordSets) {
      out.println("RecordSetId: " + recordSet.getRecordSetId());
      Long recordSetId = Long.valueOf(recordSet.getRecordSetId());
      List<DDLRecord> ddlRecords = DDLRecordLocalServiceUtil.getRecords(recordSetId);
      if (ddlRecords!=null && ddlRecords.size() > 0) {
      for (DDLRecord ddlRecord : ddlRecords) {
      out.println("\t" + ddlRecord);
      List<DDLRecordVersion> ddlRecordVersions =
      DDLRecordLocalServiceUtil.getRecordVersions(ddlRecord.getRecordId(),-1,-1, null);
      out.println("\tFields:");
      Fields fields = ddlRecord.getFields();
      for (Iterator<Field> iter = fields.iterator(); iter.hasNext();) {
      Field field = iter.next();
      for ( Locale locale : field.getAvailableLocales()) {
      out.println("\t\t" + field.getName() + ", " + locale);
      for ( def value : field.getValues(locale)) {
      out.println("\t\t\t" + value.getClass().getName() + ", " +
      value);
      }
      }
      }
      }
      }
      else {
      out.println(ddlRecords);
      }
      }
      } catch (SystemException e) {
      e.printStacktrace(out);
      }
      

      Checkpoint: You should see the below output:

      RecordSetId: 23454
      {uuid=9a05fd12-ba40-d18b-1973-a737b3bb1d6b, recordId=23456, groupId=23434,
      companyId=20155, userId=20199, userName=Test Test, versionUserId=20199,
      versionUserName=Test Test, createDate=2019-06-26 09:39:38.0, modifiedDate=2019-06-26
      10:02:44.0, DDMStorageId=23487, recordSetId=23454, version=4.0, displayIndex=0}
      Fields:
      second, en_US
      java.lang.String, Second
      second, de_DE
      java.lang.String, FirstGE
      second, de_DE
      java.lang.String, SecondGE
      first, en_US
      java.lang.String, First
      first, hu_HU
      java.lang.String, FirstHU
      first, hu_HU
      java.lang.String, SecondHU
      

      6.) Now at Staging environment remove translations from Numbers and save it.

      7.) Make a publication from Staging to Live.

      8.) Run the groovy script again and check the Staging and Live systems output:

      Result Staging:

      RecordSetId: 23454
      {uuid=9a05fd12-ba40-d18b-1973-a737b3bb1d6b, recordId=23456, groupId=23434,
      companyId=20155, userId=20199, userName=Test Test, versionUserId=20199,
      versionUserName=Test Test, createDate=2019-06-26 09:39:38.0, modifiedDate=2019-06-26
      10:02:44.0, DDMStorageId=23487, recordSetId=23454, version=4.0, displayIndex=0}
      Fields:
      second, en_US
      java.lang.String, Second
      first, en_US
      java.lang.String, First
      

      Result Live:

      RecordSetId: 23454
      {uuid=9a05fd12-ba40-d18b-1973-a737b3bb1d6b, recordId=23456, groupId=23434,
      companyId=20155, userId=20199, userName=Test Test, versionUserId=20199,
      versionUserName=Test Test, createDate=2019-06-26 09:39:38.0, modifiedDate=2019-06-26
      10:02:44.0, DDMStorageId=23487, recordSetId=23454, version=4.0, displayIndex=0}
      Fields:
      second, en_US
      java.lang.String, Second
      second, de_DE
      java.lang.String, FirstGE
      second, de_DE
      java.lang.String, SecondGE
      first, en_US
      java.lang.String, First
      first, hu_HU
      java.lang.String, FirstHU
      first, hu_HU
      java.lang.String, SecondHU
      
      • The data on the live site is not updated.

       6.2x @ commit (7c853e4d7fa5d264737e08a92f6c5895d715b2a7) reproduced

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                7 weeks, 3 days ago

                Packages

                Version Package
                6.2.X EE