Search in sources :

Example 16 with PropertyDefinition

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

the class RecordServiceImpl method isProtectedProperty.

/**
 * Helper method to determine whether a property is protected at a dictionary definition
 * level.
 *
 * @param property  property qualified name
 * @return booelan  true if protected, false otherwise
 */
private boolean isProtectedProperty(QName property) {
    boolean result = false;
    PropertyDefinition def = dictionaryService.getProperty(property);
    if (def != null) {
        result = def.isProtected();
    }
    return result;
}
Also used : PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 17 with PropertyDefinition

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

the class RecordServiceImpl method isRecordMetadata.

/**
 * Helper method that indicates whether a property is considered record metadata or not.
 *
 * @param property  property
 * @return boolea   true if record metadata, false otherwise
 */
private boolean isRecordMetadata(NodeRef filePlan, QName property) {
    boolean result = false;
    // grab the information about the properties parent type
    ClassDefinition parent = null;
    PropertyDefinition def = dictionaryService.getProperty(property);
    if (def != null) {
        parent = def.getContainerClass();
    }
    // TODO move non-electronic record support to a separate model namespace
    if (parent != null && TYPE_NON_ELECTRONIC_DOCUMENT.equals(parent.getName())) {
        result = false;
    } else {
        // check the URI's
        result = RECORD_MODEL_URIS.contains(property.getNamespaceURI());
        // check the custom model
        if (!result && !ArrayUtils.contains(NON_RECORD_MODEL_URIS, property.getNamespaceURI())) {
            if (parent != null && parent.isAspect()) {
                result = getRecordMetadataAspects(filePlan).contains(parent.getName());
            }
        }
    }
    return result;
}
Also used : ClassDefinition(org.alfresco.service.cmr.dictionary.ClassDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 18 with PropertyDefinition

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

the class RecordServiceImpl method checkDefinitionMandatoryPropsSet.

/**
 * Helper method to check whether all the definition mandatory properties of the node have been set
 *
 * @param classDef          the ClassDefinition defining the properties to be checked
 * @param nodeRefProps      the properties of the node to be checked
 * @param missingProperties the list of mandatory properties found to be missing (currently only the first one)
 * @return boolean true if all mandatory properties are set, false otherwise
 */
private void checkDefinitionMandatoryPropsSet(final ClassDefinition classDef, final Map<QName, Serializable> nodeRefProps, final List<String> missingProperties) {
    for (PropertyDefinition propDef : classDef.getProperties().values()) {
        if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null) {
            if (LOGGER.isWarnEnabled()) {
                StringBuilder msg = new StringBuilder();
                msg.append("Mandatory property missing: ").append(propDef.getName());
                LOGGER.warn(msg.toString());
            }
            missingProperties.add(propDef.getName().toString());
        }
    }
}
Also used : PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 19 with PropertyDefinition

use of org.alfresco.service.cmr.dictionary.PropertyDefinition 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 20 with PropertyDefinition

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

the class NodeParameterProcessor method process.

/**
 * @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public String process(String value, NodeRef actionedUponNodeRef) {
    // the default position is to return the value un-changed
    String result = value;
    // strip the processor name from the value
    value = stripName(value);
    if (!value.isEmpty()) {
        QName qname = QName.createQName(value, namespaceService);
        PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname);
        if (propertyDefinition == null) {
            throw new AlfrescoRuntimeException("The property " + value + " does not have a property definition.");
        }
        QName type = propertyDefinition.getDataType().getName();
        if (ArrayUtils.contains(supportedDataTypes, type)) {
            Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname);
            if (propertyValue != null) {
                result = propertyValue.toString();
            } else {
                // set the result to the empty string
                result = "";
            }
        } else {
            throw new AlfrescoRuntimeException("The property " + value + " is of type " + type.toString() + " which is not supported by parameter substitution.");
        }
    }
    return result;
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Aggregations

PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)77 QName (org.alfresco.service.namespace.QName)51 HashMap (java.util.HashMap)25 ArrayList (java.util.ArrayList)24 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 Map (java.util.Map)15 Serializable (java.io.Serializable)14 AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)11 ClassDefinition (org.alfresco.service.cmr.dictionary.ClassDefinition)11 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)9 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)9 Collection (java.util.Collection)7 List (java.util.List)7 AspectDefinition (org.alfresco.service.cmr.dictionary.AspectDefinition)7 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)7 BooleanQuery (org.apache.lucene.search.BooleanQuery)7 Builder (org.apache.lucene.search.BooleanQuery.Builder)7 Constraint (org.alfresco.service.cmr.dictionary.Constraint)6 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)6 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)6