Search in sources :

Example 6 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project records-management by Alfresco.

the class RecordMetaDataAspectsGet method executeImpl.

/*
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
     */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    // Get the nodeRef and confirm it is valid
    NodeRef nodeRef = null;
    String nodeRefValue = req.getParameter(PARAM_NODEREF);
    if (nodeRefValue == null || nodeRefValue.trim().length() == 0) {
        // get the file plan if a node ref hasn't been specified
        // TODO will need to remove when multi file plans supported
        nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
    } else {
        nodeRef = new NodeRef(nodeRefValue);
    }
    // Get the details of all the aspects
    Set<QName> aspectQNames = recordService.getRecordMetadataAspects(nodeRef);
    List<Map<String, Object>> aspects = new ArrayList<Map<String, Object>>(aspectQNames.size() + 1);
    for (QName aspectQName : aspectQNames) {
        // Get the prefix aspect and default the label to the localname
        String prefixString = aspectQName.toPrefixString(namespaceService);
        String label = aspectQName.getLocalName();
        Map<String, Object> aspect = new HashMap<String, Object>(2);
        aspect.put("id", prefixString);
        // Try and get the aspect definition
        AspectDefinition aspectDefinition = dictionaryService.getAspect(aspectQName);
        if (aspectDefinition != null) {
            // Fet the label from the aspect definition
            label = aspectDefinition.getTitle(dictionaryService);
        }
        aspect.put("value", label);
        // Add the aspect details to the aspects list
        aspects.add(aspect);
    }
    // create model object with the lists model
    Map<String, Object> model = new HashMap<String, Object>(1);
    model.put("aspects", aspects);
    return model;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project records-management by Alfresco.

the class RMSearchPropertiesGet method executeImpl.

/**
 * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
 */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>(13);
    List<Group> groups = new ArrayList<Group>(5);
    // get the file plan
    // TODO the file plan should be passed to this web script
    NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
    // get the record metadata aspects
    Set<QName> aspects = recordService.getRecordMetadataAspects(filePlan);
    for (QName aspect : aspects) {
        Map<QName, PropertyDefinition> properties = dictionaryService.getPropertyDefs(aspect);
        Property[] propObjs = new Property[properties.size()];
        int index = 0;
        for (PropertyDefinition propertyDefinition : properties.values()) {
            Property propObj = new Property(propertyDefinition);
            propObjs[index] = propObj;
            index++;
        }
        AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect);
        Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(dictionaryService), propObjs);
        groups.add(group);
    }
    Map<QName, PropertyDefinition> customProps = adminService.getCustomPropertyDefinitions();
    Property[] propObjs = new Property[customProps.size()];
    int index = 0;
    for (PropertyDefinition propertyDefinition : customProps.values()) {
        Property propObj = new Property(propertyDefinition);
        propObjs[index] = propObj;
        index++;
    }
    Group group = new Group("rmcustom", "Custom", propObjs);
    groups.add(group);
    model.put("groups", groups);
    return model;
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef)

Example 8 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project records-management by Alfresco.

the class ApplyCustomTypeAction method addParameterDefinitions.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
 */
@Override
protected final void addParameterDefinitions(List<ParameterDefinition> paramList) {
    AspectDefinition aspectDef = getDictionaryService().getAspect(customTypeAspect);
    for (PropertyDefinition propDef : aspectDef.getProperties().values()) {
        QName propName = propDef.getName();
        QName propType = propDef.getDataType().getName();
        paramList.add(new ParameterDefinitionImpl(propName.toPrefixString(), propType, propDef.isMandatory(), null));
    }
}
Also used : QName(org.alfresco.service.namespace.QName) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) ParameterDefinitionImpl(org.alfresco.repo.action.ParameterDefinitionImpl)

Example 9 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project records-management by Alfresco.

the class RecordsManagementAdminServiceImpl method getCustomPropertyDefinitions.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomPropertyDefinitions(org.alfresco.module.org_alfresco_module_rm.CustomisableRmElement)
 */
public Map<QName, PropertyDefinition> getCustomPropertyDefinitions(QName customisableType) {
    mandatory("customisableType", customisableType);
    Map<QName, PropertyDefinition> propDefns = null;
    QName relevantAspectQName = getCustomAspect(customisableType);
    AspectDefinition aspectDefn = getDictionaryService().getAspect(relevantAspectQName);
    if (aspectDefn != null) {
        propDefns = aspectDefn.getProperties();
    }
    return propDefns;
}
Also used : QName(org.alfresco.service.namespace.QName) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 10 with AspectDefinition

use of org.alfresco.service.cmr.dictionary.AspectDefinition in project records-management by Alfresco.

the class DodCustomTypesGet method executeImpl.

@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    List<AspectDefinition> customTypeAspectDefinitions = new ArrayList<AspectDefinition>(4);
    for (QName aspectQName : CUSTOM_TYPE_ASPECTS) {
        AspectDefinition nextAspectDef = dictionaryService.getAspect(aspectQName);
        customTypeAspectDefinitions.add(nextAspectDef);
    }
    model.put("dodCustomTypes", customTypeAspectDefinitions);
    return model;
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition)

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