<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic  Why does copyContents() method of documentModelImpl class ignore a metaData change if its value has been removed from the source document. in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314603#M1604</link>
    <description>&lt;H1&gt;Why does copyContents ignore a metaData change if its value has been removed from the source document.&lt;/H1&gt;
&lt;P&gt;&lt;A href="https://github.com/nuxeo/nuxeo/blob/master/nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/impl/DocumentModelImpl.java#L1210" target="test_blank"&gt;https://github.com/nuxeo/nuxeo/blob/master/nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/impl/DocumentModelImpl.java#L1210&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I see that while calling the copyContents method,  if the dataModel encounters a empty or null value, it moves ahead without replacing the destination field with the NULL value.&lt;/P&gt;
&lt;P&gt;Was there any specific reason for doing like this? I thought of modifying the underlying logic. But i m not able to build and replace the NUXEO_CORE_API jar in my local bundles folder.&lt;/P&gt;
&lt;P&gt;Changed copyContents() method can be found below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public static DataModel cloneDataModel(Schema schema, DataModel data) {


DataModel dm = new DataModelImpl(schema.getName());


for (Field field : schema.getFields()) {


String key = field.getName().getLocalName();


Object value;


try {


value = data.getData(key);


} catch (PropertyException e1) {


continue;


}


Object clone =null;


  


if (value != null) {


clone = cloneField(field, key, value);


}


try {


dm.setData(key, clone);


} catch (PropertyException e) {


throw new ClientRuntimeException(e);


}


}


return dm;


}


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 May 2016 21:30:43 GMT</pubDate>
    <dc:creator>Swaminathan_Jay</dc:creator>
    <dc:date>2016-05-13T21:30:43Z</dc:date>
    <item>
      <title>Why does copyContents() method of documentModelImpl class ignore a metaData change if its value has been removed from the source document.</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314603#M1604</link>
      <description>&lt;H1&gt;Why does copyContents ignore a metaData change if its value has been removed from the source document.&lt;/H1&gt;
&lt;P&gt;&lt;A href="https://github.com/nuxeo/nuxeo/blob/master/nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/impl/DocumentModelImpl.java#L1210" target="test_blank"&gt;https://github.com/nuxeo/nuxeo/blob/master/nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/impl/DocumentModelImpl.java#L1210&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I see that while calling the copyContents method,  if the dataModel encounters a empty or null value, it moves ahead without replacing the destination field with the NULL value.&lt;/P&gt;
&lt;P&gt;Was there any specific reason for doing like this? I thought of modifying the underlying logic. But i m not able to build and replace the NUXEO_CORE_API jar in my local bundles folder.&lt;/P&gt;
&lt;P&gt;Changed copyContents() method can be found below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public static DataModel cloneDataModel(Schema schema, DataModel data) {


DataModel dm = new DataModelImpl(schema.getName());


for (Field field : schema.getFields()) {


String key = field.getName().getLocalName();


Object value;


try {


value = data.getData(key);


} catch (PropertyException e1) {


continue;


}


Object clone =null;


  


if (value != null) {


clone = cloneField(field, key, value);


}


try {


dm.setData(key, clone);


} catch (PropertyException e) {


throw new ClientRuntimeException(e);


}


}


return dm;


}


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 May 2016 21:30:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314603#M1604</guid>
      <dc:creator>Swaminathan_Jay</dc:creator>
      <dc:date>2016-05-13T21:30:43Z</dc:date>
    </item>
    <item>
      <title>Re:  Why does copyContents() method of documentModelImpl class ignore a metaData change if its value has been removed from the source document.</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314604#M1605</link>
      <description>&lt;P&gt;Hi. Could you provide a unit test that demonstrates why in your opinion the current behavior is wrong? We use &lt;CODE&gt;copyContent&lt;/CODE&gt; to copy data from an existing &lt;CODE&gt;DocumentModel&lt;/CODE&gt; into a newly-created empty one, so the current behavior is correct in my opinion.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 09:41:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314604#M1605</guid>
      <dc:creator>Florent_Guillau</dc:creator>
      <dc:date>2016-05-18T09:41:46Z</dc:date>
    </item>
    <item>
      <title>Re:  Why does copyContents() method of documentModelImpl class ignore a metaData change if its value has been removed from the source document.</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314605#M1606</link>
      <description>&lt;P&gt;I don't have a unit test handy. You are correct. As per the Current behavior, the data gets copied over without any issues into a new empty document.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 16:46:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-does-copycontents-method-of-documentmodelimpl-class-ignore-a/m-p/314605#M1606</guid>
      <dc:creator>Swaminathan_Jay</dc:creator>
      <dc:date>2016-05-18T16:46:08Z</dc:date>
    </item>
  </channel>
</rss>

