Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-19466

Clean up default property value behavior

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.0, 7.10-HF07, 8.2
    • Fix Version/s: 9.1
    • Component/s: Schema
    • Backlog priority:
      700
    • Impact type:
      API change
    • Upgrade notes:
      Hide

      Setting a property value to null now always sets it to the default value if a default value is configured for the schema field.

      Getting the value for a simple list property whose schema field doesn't specify a default value now always returns null instead of an empty array when there is no value (i.e. empty array is considered the same as null and normalized to null).

      Show
      Setting a property value to null now always sets it to the default value if a default value is configured for the schema field. Getting the value for a simple list property whose schema field doesn't specify a default value now always returns null instead of an empty array when there is no value (i.e. empty array is considered the same as null and normalized to null).
    • Sprint:
      NOS-18, nxFG 8.4.2, nxFG 8.10.2, nxFG 9.1.4, nxFG 9.1.5, nxFG 9.1.6
    • Story Points:
      3

      Description

      Default value of a multi-valued string property is not taken into account when a document is created using an XML importer or the REST API. But it is taken into account when using the Nuxeo UI.

      How to reproduce:

      • in Studio, define a new document type with
        • a multi-valued string property with a default value value1 value2
        • a string property with default value value3
      • define the creation layout, view layout accordingly
      • deploy
      • use the REST API or an XML importer (see documentation Scan Documents Importer) to create this type of document

      The multi-valued string property of the created document is not populated with the defined default value, but the string property is populated with its default value value3.
      Using the Nuxeo UI, the creation layout populates correctly the multi-valued string property with 2 entries initialized with values value1 and value2 respectively.

      It is possible that other means to create this type of document may also suffers from this bug.

      REST API

      Consider NXP19466 being the document type. Update URL according

      POST http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/NXP19466 { "entity-type": "document", "name":"NXP19466_rest2", "type": "NXP19466","properties": { "dc:title": "NXP19466_rest2", "dc:description": "Created via a so cool and simple REST API", "common:icon": "/icons/file.gif", "common:icon-expanded": null, "common:size": null}}
      

      XML importer

      Consider NXP19466 being the document type. Update folders' paths to match your Nuxeo instance file system.

      configuration
      <!-- http://www.nuxeo.com/blog/monday-dev-heaven-multithreaded-transactional-documents-import-nuxeo/ -->
      
      <extension target="org.nuxeo.ecm.platform.scanimporter.service.ScannedFileMapperComponent" point="config">
      
        <!-- define here importer configuration -->
        <importerConfig>
          <!-- folder that holds the data to be imported-->
          <sourcePath>/home/vdutat/Workspaces/scan-importer/in</sourcePath>
          <!-- folder where xml files will be moved when processed (files will be deleted if directory is not set or does not exist-->
          <processedPath>/home/vdutat/Workspaces/scan-importer/processed</processedPath>
          <!-- number of threads used by the importer : keep it to 1 if using H2 or you will break H2’s lucene index-->
          <nbThreads>1</nbThreads>
          <!-- define how many documents are imported between 2 commit-->
          <batchSize>10</batchSize>
          <!-- Specify the path of the root document where you want to import your documents-->
          <targetPath>/default-domain/workspaces/scan-importer</targetPath>
          <!-- default to true -->
          <createInitialFolder>false</createInitialFolder>
          <!-- default to false -->
          <mergeInitialFolder>false</mergeInitialFolder>
          <!-- Looks for XML file and use mapping configuration, default to true. -->
          <useXMLMapping>true</useXMLMapping>
        </importerConfig>
      
      </extension>
      
      <!-- define scheduler event to trigger the import -->
      <extension
      target="org.nuxeo.ecm.core.scheduler.SchedulerService"
        point="schedule">
        <schedule id="scanImporter">
          <username>Administrator</username>
          <password>Administrator</password>
          <eventId>ScanIngestionStart</eventId>
          <eventCategory>default</eventCategory>
          <!-- every 30 seconds -->
          <!-- only edit this part !!! -->
          <cronExpression>*/30 * * * * ?</cronExpression>
        </schedule>
      </extension>
      
      <extension target="org.nuxeo.ecm.platform.importer.xml.parser.XMLImporterComponent" point="documentMapping">
          <docConfig tagName="nxp19466">
            <docType>NXP19466</docType>
          </docConfig>
      </extension>
      
      <extension target="org.nuxeo.ecm.platform.importer.xml.parser.XMLImporterComponent" point="attributeMapping">
        <attributeConfig tagName="title" docProperty="dc:title" xmlPath="@value"/>
        <attributeConfig tagName="source" docProperty="dc:source" xmlPath="@value"/>
        <!--
        <attributeConfig tagName="supplier" docProperty="invoice:supplier" xmlPath="@value"/>
        <attributeConfig tagName="total_incl_taxes" docProperty="invoice:amount" xmlPath="@value"/>
        <attributeConfig tagName="order_date" docProperty="invoice:orderdate" xmlPath="@value"/>
        <attributeConfig tagName="planned_delivery_date" docProperty="invoice:planneddeliverydate" xmlPath="@value"/>
        
        <attributeConfig tagName="file" docProperty="file:content">
              <mapping documentProperty="filename">@name</mapping>
              <mapping documentProperty="content">@name</mapping>
          </attributeConfig>
            
          <attributeConfig tagName="item" docProperty="invoice:items">
             <mapping documentProperty="ref">ref/text()</mapping>
          <mapping documentProperty="description">desc/text()</mapping>
          <mapping documentProperty="amount">amount/text()</mapping>
          <mapping documentProperty="deliverydate">
                  <![CDATA[ #{
                      String date = currentElement.selectNodes('delivery_date/text()')[0].getText().trim();
                    return Fn.parseDate(date, 'yyyy.MM.dd')
              }]]>
              </mapping>
        </attributeConfig>
      -->
      </extension>
      
      XML file
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <nxp19466>
          <title value="NXP19466 document 1"/>
      </nxp19466>
      

      Unit Tests which must pass

      CORE: org.nuxeo.ecm.core.TestSQLRepositoryDefaultValues
      REST API: org.nuxeo.ecm.restapi.test.DocWithDefaultValuesTest

      Test which works but must be checked as well: org.nuxeo.ecm.core.io.marshallers.json.document.DocumentModelJsonReaderTest

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day
                  1d