org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public Properties getAssocProperties(CMISNodeInfo info, String filter) { PropertiesImpl result = new PropertiesImpl(); Set<String> filterSet = splitFilter(filter); for (PropertyDefinitionWrapper propDefWrap : info.getType().getProperties()) { PropertyDefinition<?> propDef = propDefWrap.getPropertyDefinition(); if ((filterSet != null) && (!filterSet.contains(propDef.getQueryName()))) { // skip properties that are not in the filter continue; } CMISPropertyAccessor cmisPropertyAccessor = propDefWrap.getPropertyAccessor(); Serializable value = cmisPropertyAccessor.getValue(info); PropertyType propType = propDef.getPropertyType(); PropertyData<?> propertyData = getProperty(propType, propDefWrap, value); result.addProperty(propertyData); } return result; }
Example #2
Source File: AbstractTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public void updateProperty(DictionaryService dictionaryService, PropertyDefinitionWrapper propertyDefWrap) { if (propertyDefWrap != null && propertyDefWrap.getPropertyDefinition().getDisplayName() == null) { AbstractPropertyDefinition<?> property = (AbstractPropertyDefinition<?>) propertyDefWrap.getPropertyDefinition(); org.alfresco.service.cmr.dictionary.PropertyDefinition propDef = dictionaryService .getProperty(QName.createQName(property.getLocalNamespace(), property.getLocalName())); if (propDef != null) { String displayName = propDef.getTitle(dictionaryService); String description = propDef.getDescription(dictionaryService); property.setDisplayName(displayName == null ? property.getId() : displayName); property.setDescription(description == null ? property.getDisplayName() : description); } } }
Example #3
Source File: SecondaryTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry, DictionaryService dictionaryService) { PropertyDefinition<?> propertyDefintion; if (parent != null) { for (PropertyDefinitionWrapper propDef : parent.getProperties(false)) { if (propertiesById.containsKey(propDef.getPropertyId())) { continue; } org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty( propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName()); propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(), alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true); if (propertyDefintion != null) { registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder())); } } } List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId()); for (TypeDefinitionWrapper child : children) { if (child instanceof AbstractTypeDefinitionWrapper) { ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry, dictionaryService); } } }
Example #4
Source File: CmisUtils.java From iaf with Apache License 2.0 | 5 votes |
public static XmlBuilder typeDefinition2Xml(ObjectType objectType) { XmlBuilder typeXml = new XmlBuilder("typeDefinition"); typeXml.addAttribute("id", objectType.getId()); typeXml.addAttribute("description", objectType.getDescription()); typeXml.addAttribute("displayName", objectType.getDisplayName()); typeXml.addAttribute("localName", objectType.getLocalName()); typeXml.addAttribute("localNamespace", objectType.getLocalNamespace()); typeXml.addAttribute("baseTypeId", objectType.getBaseTypeId().value()); typeXml.addAttribute("parentTypeId", objectType.getParentTypeId()); typeXml.addAttribute("queryName", objectType.getQueryName()); if(objectType.isControllableAcl() != null) typeXml.addAttribute("controllableACL", objectType.isControllableAcl()); if(objectType.isControllablePolicy() != null) typeXml.addAttribute("controllablePolicy", objectType.isControllablePolicy()); if(objectType.isCreatable() != null) typeXml.addAttribute("creatable", objectType.isCreatable()); if(objectType.isFileable() != null) typeXml.addAttribute("fileable", objectType.isFileable()); if(objectType.isControllableAcl() != null) typeXml.addAttribute("fulltextIndexed", objectType.isFulltextIndexed()); if(objectType.isIncludedInSupertypeQuery() != null) typeXml.addAttribute("includedInSupertypeQuery", objectType.isIncludedInSupertypeQuery()); if(objectType.isQueryable() != null) typeXml.addAttribute("queryable", objectType.isQueryable()); typeXml.addSubElement(CmisUtils.typeMutability2xml(objectType.getTypeMutability())); Map<String, PropertyDefinition<?>> propertyDefinitions = objectType.getPropertyDefinitions(); if(propertyDefinitions != null) { typeXml.addSubElement(CmisUtils.propertyDefintions2Xml(propertyDefinitions)); } return typeXml; }
Example #5
Source File: CmisUtils.java From iaf with Apache License 2.0 | 5 votes |
public static XmlBuilder propertyDefintions2Xml(Map<String, PropertyDefinition<?>> propertyDefinitions) { XmlBuilder propertyDefinitionsXml = new XmlBuilder("propertyDefinitions"); for (Entry<String, PropertyDefinition<?>> entry : propertyDefinitions.entrySet()) { XmlBuilder propertyDefinitionXml = new XmlBuilder("propertyDefinition"); PropertyDefinition<?> definition = entry.getValue(); propertyDefinitionXml.addAttribute("id", definition.getId()); propertyDefinitionXml.addAttribute("displayName", definition.getDisplayName()); propertyDefinitionXml.addAttribute("description", definition.getDescription()); propertyDefinitionXml.addAttribute("localName", definition.getLocalName()); propertyDefinitionXml.addAttribute("localNamespace", definition.getLocalNamespace()); propertyDefinitionXml.addAttribute("queryName", definition.getQueryName()); propertyDefinitionXml.addAttribute("cardinality", definition.getCardinality().toString()); propertyDefinitionXml.addAttribute("propertyType", definition.getPropertyType().value()); propertyDefinitionXml.addAttribute("updatability", definition.getUpdatability().toString()); if(definition.isInherited() != null) propertyDefinitionXml.addAttribute("inherited", definition.isInherited()); if(definition.isOpenChoice() != null) propertyDefinitionXml.addAttribute("openChoice", definition.isOpenChoice()); if(definition.isOrderable() != null) propertyDefinitionXml.addAttribute("orderable", definition.isOrderable()); if(definition.isQueryable() != null) propertyDefinitionXml.addAttribute("queryable", definition.isQueryable()); if(definition.isRequired() != null) propertyDefinitionXml.addAttribute("required", definition.isRequired()); if(definition.getDefaultValue() != null && definition.getDefaultValue().size() > 0) { String defValue = definition.getDefaultValue().get(0).toString(); propertyDefinitionXml.addAttribute("defaultValue", defValue); } if(definition.getChoices() != null && definition.getChoices().size() > 0) { propertyDefinitionXml.addAttribute("choices", "not implemented"); } propertyDefinitionsXml.addSubElement(propertyDefinitionXml); } return propertyDefinitionsXml; }
Example #6
Source File: RelationshipTypeDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry, DictionaryService dictionaryService) { PropertyDefinition<?> propertyDefintion; if (parent != null) { for (PropertyDefinitionWrapper propDef : parent.getProperties(false)) { org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty( propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName()); propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(), alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true); if (propertyDefintion != null) { registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder())); } } } List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId()); for (TypeDefinitionWrapper child : children) { if (child instanceof AbstractTypeDefinitionWrapper) { ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry, dictionaryService); } } }
Example #7
Source File: PolicyTypeDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry, DictionaryService dictionaryService) { PropertyDefinition<?> propertyDefintion; if (parent != null) { for (PropertyDefinitionWrapper propDef : parent.getProperties(false)) { if (propertiesById.containsKey(propDef.getPropertyId())) { continue; } org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty( propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName()); propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(), alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true); if (propertyDefintion != null) { registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder())); } } } List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId()); for (TypeDefinitionWrapper child : children) { if (child instanceof AbstractTypeDefinitionWrapper) { ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry, dictionaryService); } } }
Example #8
Source File: AbstractTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public void updateTypeDefInclProperties() { for (PropertyDefinition<?> property : typeDefInclProperties.getPropertyDefinitions().values()) { if (property.getDisplayName() == null) { typeDefInclProperties.addPropertyDefinition(getPropertyById(property.getId()).getPropertyDefinition()); } } }
Example #9
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds a type to collection with inheriting base type properties * * @param type the type * * @return if the type has been added */ public boolean addType(TypeDefinition type) { if (type == null) { return false; } if (type.getBaseTypeId() == null) { return false; } // find base type TypeDefinition baseType = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { baseType = copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { baseType = copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) { baseType = copyTypeDefintion(types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) { baseType = copyTypeDefintion(types.get(POLICY_TYPE_ID).getTypeDefinition()); } else { return false; } AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type); // copy property definition for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) { ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true); newType.addPropertyDefinition(propDef); } // add it addTypeInteral(newType); log.info("Added type '" + newType.getId() + "'."); return true; }
Example #10
Source File: ShadowTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry, DictionaryService dictionaryService) { PropertyDefinition<?> propertyDefintion; if (parent != null) { for (PropertyDefinitionWrapper propDef : parent.getProperties(false)) { if (propertiesById.containsKey(propDef.getPropertyId())) { continue; } org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty( propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName()); propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(), alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true); if (propertyDefintion != null) { registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder())); } } } List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId()); for (TypeDefinitionWrapper child : children) { if (child instanceof AbstractTypeDefinitionWrapper) { ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry, dictionaryService); } } }
Example #11
Source File: BasePropertyDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public BasePropertyDefintionWrapper(PropertyDefinition<?> propDef, QName alfrescoName, TypeDefinitionWrapper owningType, CMISPropertyAccessor accessor, CMISPropertyLuceneBuilder luceneBuilder) { this.propDef = propDef; this.alfrescoName = alfrescoName; this.owningType = owningType; this.accessor = accessor; this.luceneBuilder = luceneBuilder; }
Example #12
Source File: BasePropertyDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
@Override public PropertyDefinition<?> getPropertyDefinition() { return propDef; }
Example #13
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test to ensure that versioning properties have default values defined in Alfresco content model. * Testing <b>cm:initialVersion</b>, <b>cm:autoVersion</b> and <b>cm:autoVersionOnUpdateProps</b> properties * * @throws Exception */ @Test public void testVersioningPropertiesHaveDefaultValue() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); try { // Create document via CMIS final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>() { @Override public NodeRef execute(CmisService cmisService) { String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId(); String rootNodeId = cmisService.getObjectByPath(repositoryId, "/", null, true, IncludeRelationships.NONE, null, false, true, null).getId(); Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>(); propsList.add(new PropertyStringImpl(PropertyIds.NAME, "Folder-" + GUID.generate())); propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:folder")); String folderId = cmisService.createFolder(repositoryId, new PropertiesImpl(propsList), rootNodeId, null, null, null, null); propsList = new ArrayList<PropertyData<?>>(); propsList.add(new PropertyStringImpl(PropertyIds.NAME, "File-" + GUID.generate())); propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:document")); String nodeId = cmisService.createDocument(repositoryId, new PropertiesImpl(propsList), folderId, null, null, null, null, null, null); return new NodeRef(nodeId.substring(0, nodeId.indexOf(';'))); } }, CmisVersion.CMIS_1_1); // check versioning properties transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>() { @Override public List<Void> execute() throws Throwable { assertTrue(nodeService.exists(documentNodeRef)); assertTrue(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE)); AspectDefinition ad = dictionaryService.getAspect(ContentModel.ASPECT_VERSIONABLE); Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> properties = ad.getProperties(); for (QName qName : new QName[] {ContentModel.PROP_INITIAL_VERSION, ContentModel.PROP_AUTO_VERSION, ContentModel.PROP_AUTO_VERSION_PROPS}) { Serializable property = nodeService.getProperty(documentNodeRef, qName); assertNotNull(property); org.alfresco.service.cmr.dictionary.PropertyDefinition pd = properties.get(qName); assertNotNull(pd.getDefaultValue()); assertEquals(property, Boolean.parseBoolean(pd.getDefaultValue())); } return null; } }); } finally { AuthenticationUtil.popAuthentication(); } }
Example #14
Source File: AbstractTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
/** * Adds all property definitions owned by that type. */ protected void createOwningPropertyDefinitions(CMISMapping cmisMapping, PropertyAccessorMapping propertyAccessorMapping, PropertyLuceneBuilderMapping luceneBuilderMapping, DictionaryService dictionaryService, ClassDefinition cmisClassDef) { PropertyDefinition<?> propertyDefintion; for (org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef : cmisClassDef.getProperties() .values()) { if (!isBaseType()) { if (!alfrescoPropDef.getContainerClass().equals(cmisClassDef)) { continue; } } // compile property id String propertyId = cmisMapping.buildPrefixEncodedString(alfrescoPropDef.getName()); if(propertyId.equals("cmis:secondaryObjectTypeIds") && cmisMapping.getCmisVersion() == CmisVersion.CMIS_1_0) { continue; } // create property definition propertyDefintion = createPropertyDefinition(cmisMapping, propertyId, alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, false); // if the datatype is not supported, the property defintion will be // null if (propertyDefintion != null) { CMISPropertyAccessor propertyAccessor = null; if (propertyAccessorMapping != null) { propertyAccessor = propertyAccessorMapping.getPropertyAccessor(propertyId); if (propertyAccessor == null) { propertyAccessor = propertyAccessorMapping.createDirectPropertyAccessor(propertyId, alfrescoPropDef.getName()); } } CMISPropertyLuceneBuilder luceneBuilder = null; if (luceneBuilderMapping != null) { luceneBuilder = luceneBuilderMapping.getPropertyLuceneBuilder(propertyId); if (luceneBuilder == null) { luceneBuilder = luceneBuilderMapping.createDirectPropertyLuceneBuilder(alfrescoPropDef .getName()); } } registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), this, propertyAccessor, luceneBuilder)); } } }
Example #15
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * ACE-2904 */ @Test public void testACE2904() { // Basic CMIS Types // Additional types from Content Model final String[] types = { "cmis:document", "cmis:relationship", "cmis:folder", "cmis:policy", "cmis:item", "R:cm:replaces", "P:cm:author", "I:cm:cmobject" }; final String[] displayNames = { "Document", "Relationship", "Folder", "Policy", "Item Type", "Replaces", "Author", "Object" }; final String[] descriptions = { "Document Type", "Relationship Type", "Folder Type", "Policy Type", "CMIS Item", "Replaces", "Author", "I:cm:cmobject" }; CmisServiceCallback<String> callback = new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.get(0); String repositoryId = repo.getId(); for (int i = 0; i < types.length; i++) { TypeDefinition def = cmisService.getTypeDefinition(repositoryId, types[i], null); assertNotNull("The " + types[i] + " type is not defined", def); assertNotNull("The display name is incorrect. Please, refer to ACE-2904.", def.getDisplayName()); assertEquals("The display name is incorrect. Please, refer to ACE-2904.", def.getDisplayName(), displayNames[i]); assertEquals("The description is incorrect. Please, refer to ACE-2904.", def.getDescription(), descriptions[i]); for (PropertyDefinition<?> property : def.getPropertyDefinitions().values()) { assertNotNull("Property definition dispaly name is incorrect. Please, refer to ACE-2904.", property.getDisplayName()); assertNotNull("Property definition description is incorrect. Please, refer to ACE-2904.", property.getDescription()); } } return ""; }; }; // Lets test types for cmis 1.1 and cmis 1.0 withCmisService(callback, CmisVersion.CMIS_1_1); withCmisService(callback, CmisVersion.CMIS_1_0); }
Example #16
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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); }
Example #17
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Creates a property definition object. */ private static PropertyDefinition<?> createPropDef(String id, String displayName, String description, PropertyType datatype, Cardinality cardinality, Updatability updateability, boolean inherited, boolean required) { AbstractPropertyDefinition<?> result = null; switch (datatype) { case BOOLEAN: result = new PropertyBooleanDefinitionImpl(); break; case DATETIME: result = new PropertyDateTimeDefinitionImpl(); break; case DECIMAL: result = new PropertyDecimalDefinitionImpl(); break; case HTML: result = new PropertyHtmlDefinitionImpl(); break; case ID: result = new PropertyIdDefinitionImpl(); break; case INTEGER: result = new PropertyIntegerDefinitionImpl(); break; case STRING: result = new PropertyStringDefinitionImpl(); break; case URI: result = new PropertyUriDefinitionImpl(); break; default: throw new RuntimeException("Unknown datatype! Spec change?"); } result.setId(id); result.setLocalName(id); result.setDisplayName(displayName); result.setDescription(description); result.setPropertyType(datatype); result.setCardinality(cardinality); result.setUpdatability(updateability); result.setIsInherited(inherited); result.setIsRequired(required); result.setIsQueryable(false); result.setIsOrderable(false); result.setQueryName(id); return result; }
Example #18
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Adds a type to collection with inheriting base type properties. */ public boolean addType(TypeDefinition type) { if (type == null) { return false; } if (type.getBaseTypeId() == null) { return false; } // find base type TypeDefinition baseType = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { baseType = copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { baseType = copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_ITEM) { baseType = copyTypeDefintion(types.get(ITEM_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) { baseType = copyTypeDefintion(types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) { baseType = copyTypeDefintion(types.get(POLICY_TYPE_ID).getTypeDefinition()); } else { return false; } AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type); // copy property definition for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) { ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true); newType.addPropertyDefinition(propDef); } // add it addTypeInteral(newType); log.info("Added type '" + newType.getId() + "'."); return true; }
Example #19
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Builds aspect extension. */ public List<CmisExtensionElement> getAspectExtensions(CMISNodeInfo info, String filter, Set<String> alreadySetProperties) { List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(); Set<String> propertyIds = new HashSet<String>(alreadySetProperties); List<CmisExtensionElement> propertyExtensionList = new ArrayList<CmisExtensionElement>(); Set<String> filterSet = splitFilter(filter); Set<QName> aspects = info.getNodeAspects(); for (QName aspect : aspects) { TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect); if (aspectType == null) { continue; } AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectProperties = aspectDefinition.getProperties(); extensions.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, APPLIED_ASPECTS, null, aspectType .getTypeId())); for (PropertyDefinitionWrapper propDef : aspectType.getProperties()) { boolean addPropertyToExtensionList = getRequestCmisVersion().equals(CmisVersion.CMIS_1_1) && aspectProperties.keySet().contains(propDef.getAlfrescoName()); // MNT-11876 : add property to extension even if it has been returned (CMIS 1.1) if (propertyIds.contains(propDef.getPropertyId()) && !addPropertyToExtensionList) { // skip properties that have already been added continue; } if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName()))) { // skip properties that are not in the filter continue; } Serializable value = propDef.getPropertyAccessor().getValue(info); propertyExtensionList.add(createAspectPropertyExtension(propDef.getPropertyDefinition(), value)); // mark property as 'added' propertyIds.add(propDef.getPropertyId()); } } if (!propertyExtensionList.isEmpty()) { CmisExtensionElementImpl propertiesExtension = new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, "properties", null, propertyExtensionList); extensions.addAll(Collections.singletonList(propertiesExtension)); } return extensions; }
Example #20
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
/** * Adds the default value of property if defined. */ @SuppressWarnings("unchecked") private static boolean addPropertyDefault(PropertiesImpl props, PropertyDefinition<?> propDef) { if ((props == null) || (props.getProperties() == null)) { throw new IllegalArgumentException("Props must not be null!"); } if (propDef == null) { return false; } List<?> defaultValue = propDef.getDefaultValue(); if ((defaultValue != null) && (!defaultValue.isEmpty())) { switch (propDef.getPropertyType()) { case BOOLEAN: PropertyBooleanImpl p = new PropertyBooleanImpl(propDef.getId(), (List<Boolean>) defaultValue); p.setQueryName(propDef.getId()); props.addProperty(p); break; case DATETIME: PropertyDateTimeImpl p1 = new PropertyDateTimeImpl(propDef.getId(), (List<GregorianCalendar>) defaultValue); p1.setQueryName(propDef.getId()); props.addProperty(p1); break; case DECIMAL: PropertyDecimalImpl p3 = new PropertyDecimalImpl(propDef.getId(), (List<BigDecimal>) defaultValue); p3.setQueryName(propDef.getId()); props.addProperty(p3); break; case HTML: PropertyHtmlImpl p4 = new PropertyHtmlImpl(propDef.getId(), (List<String>) defaultValue); p4.setQueryName(propDef.getId()); props.addProperty(p4); break; case ID: PropertyIdImpl p5 = new PropertyIdImpl(propDef.getId(), (List<String>) defaultValue); p5.setQueryName(propDef.getId()); props.addProperty(p5); break; case INTEGER: PropertyIntegerImpl p6 = new PropertyIntegerImpl(propDef.getId(), (List<BigInteger>) defaultValue); p6.setQueryName(propDef.getId()); props.addProperty(p6); break; case STRING: PropertyStringImpl p7 = new PropertyStringImpl(propDef.getId(), (List<String>) defaultValue); p7.setQueryName(propDef.getId()); props.addProperty(p7); break; case URI: PropertyUriImpl p8 = new PropertyUriImpl(propDef.getId(), (List<String>) defaultValue); p8.setQueryName(propDef.getId()); props.addProperty(p8); break; default: throw new RuntimeException("Unknown datatype! Spec change?"); } return true; } return false; }
Example #21
Source File: PropertyDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | votes |
PropertyDefinition<?> getPropertyDefinition();