Java code to set a complex property

I have a property that can be multivalue and each value is a complex property that contains two string subproperty.

Can someone give me an example of java code to set this type of property?

0 votes

1 answers

3509 views

ANSWER



For example: To put “wishedValue1” and “wishedValue2” into subfields “fieldName1” and “fieldName2” of “metadataName” (in “schemaPrefix”) which is complex and multivalued:

    List<Map<String, Object>> complexValuesList = new ArrayList<Map<String, Object>>();
    Map<String, Object> complexValue = new HashMap<String, Object>();
    complexValue.put("fieldName1", "wishedValue1");
    complexValue.put("fieldName2", "wishedValue2");
    complexValuesList.add(complexValue);
    customDocType.setPropertyValue("schemaPrefix:metadataName", (Serializable) complexValuesList);

You could find another example there: https://answers.nuxeo.com/general/q/c1d1279ec8b745089bcd0fd06daea3fa/How-to-programatically-populate-Complex-Multivalued-Fields

0 votes