Search in sources :

Example 1 with TypeDefinitionFactory

use of org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory in project structr by structr.

the class CMISRepositoryService method getSecondaryTypeDefinition.

// ----- private methods -----
private MutableSecondaryTypeDefinition getSecondaryTypeDefinition(final String typeId, final boolean includePropertyDefinitions, final boolean baseType) {
    final TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
    final MutableSecondaryTypeDefinition def = factory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, baseType ? null : BaseTypeId.CMIS_SECONDARY.value());
    def.setIsCreatable(false);
    initializeExtendedType(def, typeId);
    if (!includePropertyDefinitions) {
        def.removeAllPropertyDefinitions();
    }
    return def;
}
Also used : MutableSecondaryTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition) TypeDefinitionFactory(org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)

Example 2 with TypeDefinitionFactory

use of org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory in project structr by structr.

the class CMISRepositoryService method getFolderTypeDefinition.

private MutableFolderTypeDefinition getFolderTypeDefinition(final String typeId, final boolean includePropertyDefinitions, final boolean baseType) {
    final TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
    final MutableFolderTypeDefinition def = factory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, baseType ? null : BaseTypeId.CMIS_FOLDER.value());
    initializeExtendedType(def, typeId);
    if (!includePropertyDefinitions) {
        def.removeAllPropertyDefinitions();
    }
    return def;
}
Also used : MutableFolderTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition) TypeDefinitionFactory(org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)

Example 3 with TypeDefinitionFactory

use of org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory in project structr by structr.

the class CMISRepositoryService method getDocumentTypeDefinition.

private MutableDocumentTypeDefinition getDocumentTypeDefinition(final String typeId, final boolean includePropertyDefinitions, final boolean baseType) {
    final TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
    final MutableDocumentTypeDefinition def = factory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, baseType ? null : BaseTypeId.CMIS_DOCUMENT.value());
    // content is required for Structr documents
    def.setContentStreamAllowed(ContentStreamAllowed.REQUIRED);
    initializeExtendedType(def, typeId);
    if (!includePropertyDefinitions) {
        def.removeAllPropertyDefinitions();
    }
    return def;
}
Also used : MutableDocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition) TypeDefinitionFactory(org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)

Example 4 with TypeDefinitionFactory

use of org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory in project structr by structr.

the class CMISRepositoryService method createProperty.

private MutablePropertyDefinition createProperty(final Class type, final PropertyKey key) {
    // include all dynamic and CMIS-enabled keys in definition
    if (key.isDynamic() || key.isCMISProperty()) {
        // only include primitives here
        final TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
        final PropertyType dataType = key.getDataType();
        if (dataType != null) {
            final String propertyId = key.jsonName();
            final String displayName = propertyId;
            final String description = StringUtils.capitalize(propertyId);
            final Class declaringClass = key.getDeclaringClass();
            final boolean isInherited = !type.getSimpleName().equals(declaringClass.getSimpleName());
            final Cardinality cardinality = Cardinality.SINGLE;
            final Updatability updatability = Updatability.READWRITE;
            final boolean required = key.isNotNull();
            final boolean queryable = key.isIndexed();
            final boolean orderable = key.isIndexed();
            final MutablePropertyDefinition property = factory.createPropertyDefinition(propertyId, displayName, description, dataType, cardinality, updatability, isInherited, required, queryable, orderable);
            // add enum choices if present
            final Class valueType = key.valueType();
            if (valueType != null && valueType.isEnum()) {
                final List<Choice> choices = new LinkedList<>();
                for (final Object option : valueType.getEnumConstants()) {
                    final String optionName = option.toString();
                    choices.add(factory.createChoice(optionName, optionName));
                }
                property.setIsOpenChoice(false);
                property.setChoices(choices);
            }
            return property;
        }
    }
    return null;
}
Also used : Choice(org.apache.chemistry.opencmis.commons.definitions.Choice) Cardinality(org.apache.chemistry.opencmis.commons.enums.Cardinality) MutablePropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition) GraphObject(org.structr.core.GraphObject) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) Updatability(org.apache.chemistry.opencmis.commons.enums.Updatability) LinkedList(java.util.LinkedList) TypeDefinitionFactory(org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)

Example 5 with TypeDefinitionFactory

use of org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory in project structr by structr.

the class CMISRepositoryService method getRelationshipTypeDefinition.

private MutableRelationshipTypeDefinition getRelationshipTypeDefinition(final String typeId, final boolean includePropertyDefinitions, final boolean baseType) {
    final TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
    final MutableRelationshipTypeDefinition def = factory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, baseType ? null : BaseTypeId.CMIS_RELATIONSHIP.value());
    def.setIsCreatable(false);
    initializeExtendedType(def, typeId);
    if (!includePropertyDefinitions) {
        def.removeAllPropertyDefinitions();
    }
    return def;
}
Also used : MutableRelationshipTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition) TypeDefinitionFactory(org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)

Aggregations

TypeDefinitionFactory (org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory)7 LinkedList (java.util.LinkedList)1 Choice (org.apache.chemistry.opencmis.commons.definitions.Choice)1 MutableDocumentTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition)1 MutableFolderTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition)1 MutableItemTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition)1 MutablePolicyTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition)1 MutablePropertyDefinition (org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition)1 MutableRelationshipTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition)1 MutableSecondaryTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition)1 Cardinality (org.apache.chemistry.opencmis.commons.enums.Cardinality)1 PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)1 Updatability (org.apache.chemistry.opencmis.commons.enums.Updatability)1 GraphObject (org.structr.core.GraphObject)1