Merged 5.0.N (5.0.3) to HEAD (5.1)

109441: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
      109381: Merged DEV to V4.2-BUG-FIX (4.2.5)
         MNT-11472: [PUBLIC-WORKFLOW-API] Processing of Association Properties in Tasks convert incorrect
            - Dictionary service will be used to find association definition, when assoc def is absent for RestVariableHelper. Also, unit test was added.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@109501 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-08-04 09:58:21 +00:00
parent 7ec60dc9c2
commit 8cde3e29eb
6 changed files with 324 additions and 5 deletions

View File

@@ -39,6 +39,7 @@ import org.alfresco.rest.workflow.api.model.VariableScope;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -60,6 +61,8 @@ public class RestVariableHelper
private WorkflowQNameConverter qNameConverter;
private DictionaryService dictionaryService;
public static final Set<String> INTERNAL_PROPERTIES = new HashSet<String>(Arrays.asList(ActivitiConstants.VAR_TENANT_DOMAIN));
public void setNodeService(NodeService nodeService)
@@ -72,6 +75,11 @@ public class RestVariableHelper
this.namespaceService = namespaceService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
protected WorkflowQNameConverter getQNameConverter()
{
if (qNameConverter == null)
@@ -165,7 +173,7 @@ public class RestVariableHelper
protected void setVariableValueAndType(Variable variable, Object value, TypeDefinitionContext context)
{
PropertyDefinition propDef = context.getPropertyDefinition(variable.getName());
if(propDef != null)
if (propDef != null)
{
variable.setValue(getSafePropertyValue(value));
variable.setType(propDef.getDataType().getName().toPrefixString(namespaceService));
@@ -174,7 +182,18 @@ public class RestVariableHelper
{
// Not defined as a property, check if it's an association
AssociationDefinition assocDef = context.getAssociationDefinition(variable.getName());
if(assocDef != null)
if (assocDef == null)
{
// Try to get an association definition through dictionary
String[] prefixLocalName = variable.getName().split("_");
if (prefixLocalName.length == 2)
{
QName qName = QName.createQName(prefixLocalName[0], prefixLocalName[1], namespaceService);
assocDef = dictionaryService.getAssociation(qName);
}
}
if (assocDef != null)
{
// Type of variable is the target class-name
variable.setType(assocDef.getTargetClass().getName().toPrefixString(namespaceService));
@@ -182,8 +201,7 @@ public class RestVariableHelper
}
else
{
// Variable is not a declared property not association on the type-definition. Revert to using the actual raw value
// as base for conversion.
// Variable is not declared as property or association type-def. Use actual raw value as base for conversion.
variable.setValue(getSafePropertyValue(value));
variable.setType(extractTypeStringFromValue(value));
}