Search in sources :

Example 1 with DispositionProperty

use of org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty in project records-management by Alfresco.

the class DispositionPropertiesGet 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) {
    boolean recordLevel = false;
    String recordLevelValue = req.getParameter("recordlevel");
    if (recordLevelValue != null) {
        recordLevel = Boolean.valueOf(recordLevelValue);
    }
    String dispositionAction = req.getParameter("dispositionaction");
    Collection<DispositionProperty> dispositionProperties = dispositionService.getDispositionProperties(recordLevel, dispositionAction);
    List<Map<String, String>> items = new ArrayList<Map<String, String>>(dispositionProperties.size());
    for (DispositionProperty dispositionProperty : dispositionProperties) {
        PropertyDefinition propDef = dispositionProperty.getPropertyDefinition();
        QName propName = dispositionProperty.getQName();
        if (propDef != null) {
            Map<String, String> item = new HashMap<String, String>(2);
            String propTitle = propDef.getTitle(dictionaryService);
            if (propTitle == null || propTitle.length() == 0) {
                propTitle = StringUtils.capitalize(propName.getLocalName());
            }
            item.put("label", propTitle);
            item.put("value", propName.toPrefixString(this.namespaceService));
            items.add(item);
        }
    }
    // create model object with the lists model
    Map<String, Object> model = new HashMap<String, Object>(1);
    model.put("properties", items);
    return model;
}
Also used : DispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with DispositionProperty

use of org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty in project records-management by Alfresco.

the class DispositionServiceImpl method getDispositionProperties.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties(boolean, java.lang.String)
 */
@Override
public Collection<DispositionProperty> getDispositionProperties(boolean isRecordLevel, String dispositionAction) {
    Collection<DispositionProperty> values = dispositionProperties.values();
    List<DispositionProperty> result = new ArrayList<DispositionProperty>(values.size());
    for (DispositionProperty dispositionProperty : values) {
        boolean test = dispositionProperty.applies(isRecordLevel, dispositionAction);
        if (test) {
            result.add(dispositionProperty);
        }
    }
    return result;
}
Also used : DispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) ArrayList(java.util.ArrayList)

Example 3 with DispositionProperty

use of org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty in project records-management by Alfresco.

the class ListOfValuesGet method createPeriodPropertiesModel.

/**
 * Creates the model for the list of period properties.
 *
 * @param baseUrl The base URL of the service
 * @return model of period properties list
 */
protected Map<String, Object> createPeriodPropertiesModel(String baseUrl) {
    // iterate over all period properties and get the label from their type definition
    Collection<DispositionProperty> dispositionProperties = dispositionService.getDispositionProperties();
    List<Map<String, String>> items = new ArrayList<Map<String, String>>(dispositionProperties.size());
    for (DispositionProperty dispositionProperty : dispositionProperties) {
        PropertyDefinition propDef = dispositionProperty.getPropertyDefinition();
        QName propName = dispositionProperty.getQName();
        if (propDef != null) {
            Map<String, String> item = new HashMap<String, String>(2);
            String propTitle = propDef.getTitle(ddService);
            if (propTitle == null || propTitle.length() == 0) {
                propTitle = StringUtils.capitalize(propName.getLocalName());
            }
            item.put("label", propTitle);
            item.put("value", propName.toPrefixString(this.namespaceService));
            items.add(item);
        }
    }
    // create the model
    Map<String, Object> model = new HashMap<String, Object>(2);
    model.put("url", baseUrl + "/periodproperties");
    model.put("items", items);
    return model;
}
Also used : DispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Aggregations

ArrayList (java.util.ArrayList)3 DispositionProperty (org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)2 QName (org.alfresco.service.namespace.QName)2