org.alfresco.service.cmr.dictionary.AspectDefinition Java Examples
The following examples show how to use
org.alfresco.service.cmr.dictionary.AspectDefinition.
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: SecondaryTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateDefinition(DictionaryService dictionaryService) { AspectDefinition aspectDef = dictionaryService.getAspect(alfrescoName); if (aspectDef != null) { setTypeDefDisplayName(aspectDef.getTitle(dictionaryService)); setTypeDefDescription(aspectDef.getDescription(dictionaryService)); } else { super.updateDefinition(dictionaryService); } updateTypeDefInclProperties(); }
Example #2
Source File: AbstractDictionaryRegistry.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
protected AspectDefinition getAspectImpl(QName aspectName) { AspectDefinition aspect = null; if(aspectName != null) { List<CompiledModel> models = uriToModels.get(aspectName.getNamespaceURI()); if(models != null && models.size() > 0) { for (CompiledModel model : models) { aspect = model.getAspect(aspectName); if(aspect != null) { break; } } } } return aspect; }
Example #3
Source File: SOLRTrackingComponentImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private Set<QName> getNodeAspects(Long nodeId) { Set<QName> aspects = new HashSet<QName>(); if (null == nodeId) { return aspects; } Set<QName> sourceAspects = nodeDAO.getNodeAspects(nodeId); for(QName aspectQName : sourceAspects) { AspectDefinition aspect = dictionaryService.getAspect(aspectQName); if(aspect != null) { aspects.add(aspectQName); } } return aspects; }
Example #4
Source File: SOLRTrackingComponentImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private boolean isCategorised(AspectDefinition aspDef) { if(aspDef == null) { return false; } AspectDefinition current = aspDef; while (current != null) { if (current.getName().equals(ContentModel.ASPECT_CLASSIFIABLE)) { return true; } else { QName parentName = current.getParentName(); if (parentName == null) { break; } current = dictionaryService.getAspect(parentName); } } return false; }
Example #5
Source File: M2AnonymousTypeDefinition.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
/** * Construct * * @param type the primary type * @param aspects the aspects to combine with the type */ /*package*/ M2AnonymousTypeDefinition(TypeDefinition type, Collection<AspectDefinition> aspects) { this.type = type; // Combine features of type and aspects properties.putAll(type.getProperties()); associations.putAll(type.getAssociations()); childassociations.putAll(type.getChildAssociations()); for (AspectDefinition aspect : aspects) { properties.putAll(aspect.getProperties()); associations.putAll(aspect.getAssociations()); childassociations.putAll(aspect.getChildAssociations()); } }
Example #6
Source File: ViewParser.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Process aspect definition * * @param xpp XmlPullParser * @param aspectDef AspectDefinition * @param parserContext ParserContext * @throws XmlPullParserException * @throws IOException */ private void processAspect(XmlPullParser xpp, AspectDefinition aspectDef, ParserContext parserContext) throws XmlPullParserException, IOException { NodeContext node = peekNodeContext(parserContext.elementStack); node.addAspect(aspectDef); int eventType = xpp.next(); if (eventType != XmlPullParser.END_TAG) { throw new ImporterException("Aspect " + aspectDef.getName() + " definition is not valid - it cannot contain any elements"); } if (logger.isDebugEnabled()) logger.debug(indentLog("Processed aspect " + aspectDef.getName(), parserContext.elementStack.size())); }
Example #7
Source File: CustomModelServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testListTypesAspects_Empty() throws Exception { final String modelName = makeUniqueName("testCustomModel"); Pair<String, String> namespacePair = getTestNamespacePrefixPair(); final M2Model model = M2Model.createModel(namespacePair.getSecond() + QName.NAMESPACE_PREFIX + modelName); model.createNamespace(namespacePair.getFirst(), namespacePair.getSecond()); createModel(model, false); // Retrieve the created model CustomModelDefinition modelDefinition = getModel(modelName); assertNotNull(modelDefinition); assertEquals(modelName, modelDefinition.getName().getLocalName()); // List all of the model's types Collection<TypeDefinition> types = modelDefinition.getTypeDefinitions(); assertEquals(0, types.size()); // List all of the model's aspects Collection<AspectDefinition> aspects = modelDefinition.getAspectDefinitions(); assertEquals(0, aspects.size()); }
Example #8
Source File: PolicyTypeDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateDefinition(DictionaryService dictionaryService) { AspectDefinition aspectDef = dictionaryService.getAspect(alfrescoName); if (aspectDef != null) { setTypeDefDisplayName(aspectDef.getTitle(dictionaryService)); setTypeDefDescription(aspectDef.getDescription(dictionaryService)); } else { super.updateDefinition(dictionaryService); } updateTypeDefInclProperties(); }
Example #9
Source File: DictionaryDAOImpl.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public TypeDefinition getAnonymousType(QName type, Collection<QName> aspects) { TypeDefinition typeDef = getType(type); if (typeDef == null) { throw new DictionaryException( "d_dictionary.model.err.type_not_found", type); } Collection<AspectDefinition> aspectDefs = new ArrayList<AspectDefinition>(); if (aspects != null) { for (QName aspect : aspects) { AspectDefinition aspectDef = getAspect(aspect); if (aspectDef == null) { throw new DictionaryException( "d_dictionary.model.err.aspect_not_found", aspect); } aspectDefs.add(aspectDef); } } return new M2AnonymousTypeDefinition(typeDef, aspectDefs); }
Example #10
Source File: NodesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
public Set<QName> mapToNodeAspects(List<String> aspectNames) { Set<QName> nodeAspects = new HashSet<>(aspectNames.size()); for (String aspectName : aspectNames) { QName aspectQName = createQName(aspectName); AspectDefinition ad = dictionaryService.getAspect(aspectQName); if (ad != null) { nodeAspects.add(aspectQName); } else { throw new InvalidArgumentException("Unknown aspect: " + aspectName); } } return nodeAspects; }
Example #11
Source File: CustomModelsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override public CustomAspect getCustomAspect(String modelName, String aspectName, Parameters parameters) { if(aspectName == null) { throw new InvalidArgumentException(ASPECT_NAME_NULL_ERR); } final CustomModelDefinition modelDef = getCustomModelImpl(modelName); QName aspectQname = QName.createQName(modelDef.getName().getNamespaceURI(), aspectName); AspectDefinition customAspectDef = customModelService.getCustomAspect(aspectQname); if (customAspectDef == null) { throw new EntityNotFoundException(aspectName); } // Check if inherited properties have been requested boolean includeInheritedProps = hasSelectProperty(parameters, SELECT_ALL_PROPS); return convertToCustomAspect(customAspectDef, includeInheritedProps); }
Example #12
Source File: PermissionModel.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Support to add permissions for aspects. * * @param type QName * @param permissions Set<PermissionReference> * @param exposedOnly boolean */ private void addAspectPermissions(QName type, Set<PermissionReference> permissions, boolean exposedOnly) { AspectDefinition aspectDef = dictionaryService.getAspect(type); if (aspectDef == null) { // the aspect definition is no longer in the dictionary - ignore return; } if (aspectDef.getParentName() != null) { PermissionSet permissionSet = permissionSets.get(type); if (!exposedOnly || (permissionSet == null) || permissionSet.exposeAll()) { addAspectPermissions(aspectDef.getParentName(), permissions, exposedOnly); } } mergePermissions(permissions, type, exposedOnly, true); }
Example #13
Source File: PermissionModel.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Support to add permissions for types * * @param type QName * @param permissions Set<PermissionReference> * @param exposedOnly boolean */ private void addTypePermissions(QName type, Set<PermissionReference> permissions, boolean exposedOnly) { TypeDefinition typeDef = dictionaryService.getType(type); if (typeDef == null) { // the type definition is no longer in the dictionary - ignore return; } if (typeDef.getParentName() != null) { PermissionSet permissionSet = permissionSets.get(type); if (!exposedOnly || (permissionSet == null) || permissionSet.exposeAll()) { addTypePermissions(typeDef.getParentName(), permissions, exposedOnly); } } for (AspectDefinition ad : typeDef.getDefaultAspects()) { addAspectPermissions(ad.getName(), permissions, exposedOnly); } mergePermissions(permissions, type, exposedOnly, true); }
Example #14
Source File: TenantDictionaryRegistryImpl.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public AspectDefinition getAspect(QName aspectName) { AspectDefinition aspect = getAspectImpl(aspectName); if(aspect == null) { // try parent aspect = getParent().getAspect(aspectName); } return aspect; }
Example #15
Source File: QueryParserUtils.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public static AspectDefinition matchAspectDefinition(String defaultNameSpaceUri, NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService, String string) { QName search = QName.createQName(expandQName(defaultNameSpaceUri, namespacePrefixResolver, string)); AspectDefinition aspectDefinition = dictionaryService.getAspect(QName.createQName(expandQName(defaultNameSpaceUri, namespacePrefixResolver, string))); QName match = null; if (aspectDefinition == null) { for (QName definition : dictionaryService.getAllAspects()) { if (definition.getNamespaceURI().equalsIgnoreCase(search.getNamespaceURI())) { if (definition.getLocalName().equalsIgnoreCase(search.getLocalName())) { if (match == null) { match = definition; } else { throw new DictionaryException("Ambiguous data datype " + string); } } } } } else { return aspectDefinition; } if (match == null) { return null; } else { return dictionaryService.getAspect(match); } }
Example #16
Source File: DelegateModelQuery.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public AspectDefinition getAspect(QName name) { AspectDefinition def = query.getAspect(name); if (def == null) { def = delegate.getAspect(name); } return def; }
Example #17
Source File: DictionaryComponent.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public Collection<QName> getAspects(QName model) { Collection<AspectDefinition> aspects = dictionaryDAO.getAspects(model); Collection<QName> qnames = new ArrayList<QName>(aspects.size()); for (AspectDefinition def : aspects) { qnames.add(def.getName()); } return qnames; }
Example #18
Source File: DictionaryComponent.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
/** * * {@inheritDoc} */ public TypeDefinition getAnonymousType(QName name) { TypeDefinition typeDef = getType(name); List<AspectDefinition> aspects = typeDef.getDefaultAspects(true); List<QName> aspectNames = new ArrayList<QName>(aspects.size()); getMandatoryAspects(typeDef, aspectNames); return getAnonymousType(typeDef.getName(), aspectNames); }
Example #19
Source File: DictionaryDAOImpl.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public AspectDefinition getAspect(QName aspectName) { AspectDefinition aspectDef = null; if (aspectName != null) { aspectDef = getTenantDictionaryRegistry().getAspect(aspectName); } return aspectDef; }
Example #20
Source File: DictionaryComponent.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
/** * Gets a flattened list of all mandatory aspects for a given class * * @param classDef the class * @param aspects a list to hold the mandatory aspects */ private void getMandatoryAspects(ClassDefinition classDef, List<QName> aspects) { for (AspectDefinition aspect : classDef.getDefaultAspects()) { QName aspectName = aspect.getName(); if (!aspects.contains(aspectName)) { aspects.add(aspect.getName()); getMandatoryAspects(aspect, aspects); } } }
Example #21
Source File: ParentContext.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Construct * * @param elementName QName * @param parent NodeContext * @param assocDef AssociationDefinition */ public ParentContext(QName elementName, NodeContext parent, AssociationDefinition assocDef) { this(elementName, parent); TypeDefinition typeDef = parent.getTypeDefinition(); if (typeDef != null) { // // Ensure association type is valid for node parent // // Build complete Type Definition Set<QName> allAspects = new HashSet<QName>(); for (AspectDefinition typeAspect : parent.getTypeDefinition().getDefaultAspects()) { allAspects.add(typeAspect.getName()); } allAspects.addAll(parent.getNodeAspects()); TypeDefinition anonymousType = getDictionaryService().getAnonymousType(parent.getTypeDefinition().getName(), allAspects); // Determine if Association is valid for Type Definition Map<QName, AssociationDefinition> nodeAssociations = anonymousType.getAssociations(); if (nodeAssociations.containsKey(assocDef.getName()) == false) { throw new ImporterException("Association " + assocDef.getName() + " is not valid for node " + parent.getTypeDefinition().getName()); } } parentRef = parent.getNodeRef(); assocType = assocDef.getName(); }
Example #22
Source File: AbstractDictionaryRegistry.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Collection<QName> getAspects(boolean includeInherited) { Collection<QName> types = new ArrayList<QName>(100); for (QName model : getCompiledModels(includeInherited).keySet()) { for(AspectDefinition aspectDef : getModel(model).getAspects()) { types.add(aspectDef.getName()); } } return types; }
Example #23
Source File: CustomModelServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public PagingResults<AspectDefinition> getAllCustomAspects(PagingRequest pagingRequest) { ParameterCheck.mandatory("pagingRequest", pagingRequest); List<AspectDefinition> result = new ArrayList<>(); List<CompiledModel> list = getAllCustomM2Models(false); for (CompiledModel model : list) { result.addAll(model.getAspects()); } return wrapResult(pagingRequest, result); }
Example #24
Source File: CMISMapping.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
/** * Is this a valid CMIS secondary type? * * @param typeQName QName * @return boolean */ public boolean isValidCmisSecondaryType(QName typeQName) { if(isExcluded(typeQName)) { return false; } if (typeQName == null) { return false; } if (typeQName.equals(SECONDARY_TYPES_QNAME)) { return true; } AspectDefinition aspectDef = dictionaryService.getAspect(typeQName); if (aspectDef == null) { return false; } // Anything derived from the aspects here would at some point have to linked up with an invalid parent so exclude these aspects // AND any that are derived from them. if ( dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_VERSIONABLE) || dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_AUDITABLE) || dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_REFERENCEABLE)) { return false; } return true; }
Example #25
Source File: CMISMapping.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
/** * Is this a valid CMIS policy type? * * @param typeQName QName * @return boolean */ public boolean isValidCmisPolicy(QName typeQName) { if (typeQName == null) { return false; } if (typeQName.equals(POLICY_QNAME)) { return true; } if(cmisVersion.equals(CmisVersion.CMIS_1_0)) { if (typeQName.equals(ASPECTS_QNAME)) { return true; } AspectDefinition aspectDef = dictionaryService.getAspect(typeQName); if (aspectDef == null) { return false; } // Anything derived from the aspects here would at some point have to linked up with an invalid parent so exclude these aspects // AND any that are derived from them. if ( dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_VERSIONABLE) || dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_AUDITABLE) || dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_REFERENCEABLE)) { return false; } return true; } else { return false; } }
Example #26
Source File: CMISDictionaryRegistryImpl.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
private void addTypeExtensions(TypeDefinitionWrapper td) { QName classQName = td.getAlfrescoClass(); ClassDefinition classDef = dictionaryService.getClass(classQName); if(classDef != null) { // add mandatory/default aspects List<AspectDefinition> defaultAspects = classDef.getDefaultAspects(true); if(defaultAspects != null && defaultAspects.size() > 0) { List<CmisExtensionElement> mandatoryAspectsExtensions = new ArrayList<CmisExtensionElement>(); for(AspectDefinition aspectDef : defaultAspects) { QName aspectQName = aspectDef.getName(); TypeDefinitionWrapper aspectType = getTypeDefByQName(cmisMapping.getCmisType(aspectQName)); if (aspectType == null) { continue; } mandatoryAspectsExtensions.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, MANDATORY_ASPECT, null, aspectType.getTypeId())); } if(!mandatoryAspectsExtensions.isEmpty()) { td.getTypeDefinition(true).setExtensions( Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, MANDATORY_ASPECTS, null, mandatoryAspectsExtensions))); } } } }
Example #27
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
private boolean atLeastOneAspectSupportsChildren(Set<QName> aspects) { return notNullOrEmpty(aspects).stream() .map(aspect -> dataModel.getDictionaryService(CMISStrictDictionaryService.DEFAULT).getAspect(aspect)) .filter(Objects::nonNull) .map(AspectDefinition::getChildAssociations) .filter(Objects::nonNull) .anyMatch(associations -> !associations.isEmpty()); }
Example #28
Source File: CustomAspect.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public CustomAspect(AspectDefinition aspectDefinition, MessageLookup messageLookup, List<CustomModelProperty> properties) { this.name = aspectDefinition.getName().getLocalName(); this.prefixedName = aspectDefinition.getName().toPrefixString(); this.title = aspectDefinition.getTitle(messageLookup); this.description = aspectDefinition.getDescription(messageLookup); this.parentName = getParentNameAsString(aspectDefinition.getParentName()); this.properties = setList(properties); }
Example #29
Source File: CustomModelsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CollectionWithPagingInfo<CustomAspect> getCustomAspects(String modelName, Parameters parameters) { CustomModelDefinition modelDef = getCustomModelImpl(modelName); Collection<AspectDefinition> aspectDefinitions = modelDef.getAspectDefinitions(); // TODO Should we support paging? Paging paging = Paging.DEFAULT; List<CustomAspect> customAspects = convertToCustomAspects(aspectDefinitions, false); return CollectionWithPagingInfo.asPaged(paging, customAspects, false, aspectDefinitions.size()); }
Example #30
Source File: CustomModelsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private List<CustomAspect> convertToCustomAspects(Collection<AspectDefinition> aspectDefinitions, boolean includeInheritedProps) { // Convert a collection of AspectDefinitions into a list of CustomAspect List<CustomAspect> customAspects = new ArrayList<>(aspectDefinitions.size()); for (AspectDefinition ad : aspectDefinitions) { customAspects.add(convertToCustomAspect(ad, includeInheritedProps)); } return customAspects; }