Search in sources :

Example 1 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project alfresco-remote-api by Alfresco.

the class CustomModelsImpl method getCustomAspects.

@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());
}
Also used : CustomModelDefinition(org.alfresco.service.cmr.dictionary.CustomModelDefinition) Paging(org.alfresco.rest.framework.resource.parameters.Paging) CustomAspect(org.alfresco.rest.api.model.CustomAspect) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition)

Example 2 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project alfresco-remote-api by Alfresco.

the class CustomModelsImpl method getCustomAspect.

@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);
}
Also used : CustomModelDefinition(org.alfresco.service.cmr.dictionary.CustomModelDefinition) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) QName(org.alfresco.service.namespace.QName) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)

Example 3 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project alfresco-remote-api by Alfresco.

the class NodesImpl method mapToNodeAspects.

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;
}
Also used : InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) QName(org.alfresco.service.namespace.QName) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 4 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project acs-community-packaging by Alfresco.

the class BaseActionWizard method readAspectsConfig.

protected List<SelectItem> readAspectsConfig(FacesContext context, ConfigElement aspectsCfg) {
    List<SelectItem> aspects = new ArrayList<SelectItem>();
    for (ConfigElement child : aspectsCfg.getChildren()) {
        QName idQName = Repository.resolveToQName(child.getAttribute("name"));
        if (idQName != null) {
            // try and get the display label from config
            String label = Utils.getDisplayLabel(context, child);
            // if there wasn't a client based label try and get it from the dictionary
            if (label == null) {
                AspectDefinition aspectDef = this.getDictionaryService().getAspect(idQName);
                if (aspectDef != null) {
                    label = aspectDef.getTitle(this.getDictionaryService());
                } else {
                    label = idQName.getLocalName();
                }
            }
            aspects.add(new SelectItem(idQName.toString(), label));
        } else {
            logger.warn("Failed to resolve aspect '" + child.getAttribute("name") + "'");
        }
    }
    return aspects;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) SelectItem(javax.faces.model.SelectItem) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition)

Example 5 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project acs-community-packaging by Alfresco.

the class AdvancedSearchDialog method getCustomPropertyLookup.

/**
 * Helper map to lookup custom property QName strings against a DataTypeDefinition
 *
 * @return custom property lookup Map
 */
private Map<String, DataTypeDefinition> getCustomPropertyLookup() {
    if ((properties.getCustomPropertyLookup() == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        properties.setCustomPropertyLookup(new HashMap<String, DataTypeDefinition>(7, 1.0f));
        List<CustomProperty> customProps = getSearchConfig().getCustomProperties();
        if (customProps != null) {
            DictionaryService dd = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDictionaryService();
            for (CustomProperty customProp : customProps) {
                PropertyDefinition propDef = null;
                QName propQName = Repository.resolveToQName(customProp.Property);
                if (customProp.Type != null) {
                    QName type = Repository.resolveToQName(customProp.Type);
                    TypeDefinition typeDef = dd.getType(type);
                    propDef = typeDef.getProperties().get(propQName);
                } else if (customProp.Aspect != null) {
                    QName aspect = Repository.resolveToQName(customProp.Aspect);
                    AspectDefinition aspectDef = dd.getAspect(aspect);
                    propDef = aspectDef.getProperties().get(propQName);
                }
                if (propQName != null && propDef != null) {
                    properties.getCustomPropertyLookup().put(propQName.toString(), propDef.getDataType());
                }
            }
        }
    }
    return properties.getCustomPropertyLookup();
}
Also used : DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) QName(org.alfresco.service.namespace.QName) CustomProperty(org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Aggregations

AspectDefinition (org.alfresco.service.cmr.dictionary.AspectDefinition)22 QName (org.alfresco.service.namespace.QName)21 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)7 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 Map (java.util.Map)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 Serializable (java.io.Serializable)3 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)3 HashSet (java.util.HashSet)2 ParameterDefinitionImpl (org.alfresco.repo.action.ParameterDefinitionImpl)2 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)2 AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)2 CustomModelDefinition (org.alfresco.service.cmr.dictionary.CustomModelDefinition)2 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)2 CustomProperty (org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty)2 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 SelectItem (javax.faces.model.SelectItem)1