mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5175_Complete_record_with_missing_metadata
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -91,7 +91,7 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
if (!getRecordService().isDeclared(actionedUponNodeRef))
|
||||
{
|
||||
List<String> missingProperties = new ArrayList<String>(5);
|
||||
List<String> missingProperties = new ArrayList<>(5);
|
||||
// Aspect not already defined - check mandatory properties then add
|
||||
if (!checkMandatoryPropertiesEnabled ||
|
||||
mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
|
||||
@@ -100,7 +100,7 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
||||
try
|
||||
{
|
||||
// Add the declared aspect
|
||||
Map<QName, Serializable> declaredProps = new HashMap<QName, Serializable>(2);
|
||||
Map<QName, Serializable> declaredProps = new HashMap<>(2);
|
||||
declaredProps.put(PROP_DECLARED_AT, new Date());
|
||||
declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser());
|
||||
this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps);
|
||||
@@ -195,22 +195,33 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
||||
}
|
||||
|
||||
// check for missing mandatory metadata from custom aspect definitions
|
||||
// TODO should not apply record custom metadata for non-electronic and vice versa
|
||||
if (result)
|
||||
{
|
||||
Collection<QName> aspects = this.getDictionaryService().getAspects(RM_CUSTOM_MODEL);
|
||||
for (QName aspect : aspects)
|
||||
QName aspect;
|
||||
if (nodeRefType.equals(TYPE_NON_ELECTRONIC_DOCUMENT))
|
||||
//if (nodeRefType.getLocalName()))
|
||||
{
|
||||
AspectDefinition aspectDef = this.getDictionaryService().getAspect(aspect);
|
||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
||||
{
|
||||
if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null)
|
||||
{
|
||||
logMissingProperty(propDef, missingProperties);
|
||||
aspect = TYPE_NON_ELECTRONIC_DOCUMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
aspect = ASPECT_RECORD;
|
||||
}
|
||||
// get customAspectImpl
|
||||
String localName = aspect.toPrefixString(getNamespaceService()).replace(":", "");
|
||||
localName = MessageFormat.format("{0}CustomProperties", localName);
|
||||
QName customAspect = QName.createQName(RM_CUSTOM_URI, localName);
|
||||
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
AspectDefinition aspectDef = this.getDictionaryService().getAspect(customAspect);
|
||||
|
||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
||||
{
|
||||
if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null)
|
||||
{
|
||||
logMissingProperty(propDef, missingProperties);
|
||||
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user