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;
}
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;
}
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());
}
}
}
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;
}
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;
}
Aggregations