use of org.apache.chemistry.opencmis.commons.data.CmisExtensionElement in project alfresco-repository by Alfresco.
the class CMISConnector method createAspectPropertyExtension.
/**
* Creates a property extension element.
*/
@SuppressWarnings("rawtypes")
private CmisExtensionElement createAspectPropertyExtension(PropertyDefinition<?> propertyDefinition, Object value) {
String name;
switch(propertyDefinition.getPropertyType()) {
case BOOLEAN:
name = "propertyBoolean";
break;
case DATETIME:
name = "propertyDateTime";
break;
case DECIMAL:
name = "propertyDecimal";
break;
case INTEGER:
name = "propertyInteger";
break;
case ID:
name = "propertyId";
break;
default:
name = "propertyString";
}
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("propertyDefinitionId", propertyDefinition.getId());
attributes.put("queryName", propertyDefinition.getQueryName());
// optional value
if (propertyDefinition.getDisplayName() != null && propertyDefinition.getDisplayName().trim().length() > 0) {
attributes.put("displayName", propertyDefinition.getDisplayName());
}
// optional value
if (propertyDefinition.getLocalName() != null && propertyDefinition.getLocalName().trim().length() > 0) {
attributes.put("localName", propertyDefinition.getLocalName());
}
List<CmisExtensionElement> propertyValues = new ArrayList<CmisExtensionElement>();
if (value != null) {
if (value instanceof List) {
for (Object o : ((List) value)) {
if (o != null) {
propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null, convertAspectPropertyValue(o)));
} else {
logger.warn("Unexpected null entry in list value for property " + propertyDefinition.getDisplayName() + ", value = " + value);
}
}
} else {
propertyValues.add(new CmisExtensionElementImpl(CMIS_NAMESPACE, "value", null, convertAspectPropertyValue(value)));
}
}
return new CmisExtensionElementImpl(CMIS_NAMESPACE, name, attributes, propertyValues);
}
Aggregations