Search in sources :

Example 1 with BindingsObjectFactory

use of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory in project structr by structr.

the class CMISObjectWrapper method getProperties.

@Override
public Properties getProperties() {
    final FilteredPropertyList properties = new FilteredPropertyList(propertyFilter);
    final BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
    properties.add(objFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID, baseTypeId.value()));
    properties.add(objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, type));
    properties.add(objFactory.createPropertyIdData(PropertyIds.OBJECT_ID, id));
    properties.add(objFactory.createPropertyStringData(PropertyIds.NAME, name));
    properties.add(objFactory.createPropertyStringData(PropertyIds.DESCRIPTION, description));
    properties.add(objFactory.createPropertyStringData(PropertyIds.CREATED_BY, createdBy));
    properties.add(objFactory.createPropertyStringData(PropertyIds.LAST_MODIFIED_BY, lastModifiedBy));
    properties.add(objFactory.createPropertyDateTimeData(PropertyIds.CREATION_DATE, creationDate));
    properties.add(objFactory.createPropertyDateTimeData(PropertyIds.LAST_MODIFICATION_DATE, lastModificationDate));
    // add dynamic properties
    if (dynamicPropertyMap != null) {
        for (final Entry<PropertyKey, Object> entry : dynamicPropertyMap.entrySet()) {
            final PropertyKey key = entry.getKey();
            final PropertyType dataType = key.getDataType();
            if (dataType != null) {
                switch(dataType) {
                    case BOOLEAN:
                        properties.add(objFactory.createPropertyBooleanData(key.jsonName(), (Boolean) entry.getValue()));
                        break;
                    case DATETIME:
                        properties.add(objFactory.createPropertyDateTimeData(key.jsonName(), valueOrNull((Date) entry.getValue())));
                        break;
                    case DECIMAL:
                        properties.add(objFactory.createPropertyDecimalData(key.jsonName(), valueOrNull((Double) entry.getValue())));
                        break;
                    case INTEGER:
                        // INTEGER includes int and long so we have to cover both cases here
                        properties.add(objFactory.createPropertyIntegerData(key.jsonName(), intOrNull(entry.getValue())));
                        break;
                    case STRING:
                        properties.add(objFactory.createPropertyStringData(key.jsonName(), (String) entry.getValue()));
                        break;
                }
            }
        }
    }
    // initialize type-dependent properties
    createProperties(objFactory, properties);
    // filter properties according to filter expression
    return objFactory.createPropertiesData(properties.getList());
}
Also used : BindingsObjectFactoryImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl) BindingsObjectFactory(org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory) GraphObject(org.structr.core.GraphObject) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)1 BindingsObjectFactoryImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl)1 BindingsObjectFactory (org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory)1 GraphObject (org.structr.core.GraphObject)1 PropertyKey (org.structr.core.property.PropertyKey)1