mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Rule webscripts
- Modified parsing of rule webscripts so an attribute "parameterValues" may contain an empty object - Its now possible to create a rule (however action/conditions with multi parameters will fail on parsing on server: SAIL-306) - Started to use constraints webscripts and removed old testdata webscripts - Made rule-details component on folder rules page display values form server git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18676 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
<webscript>
|
|
||||||
<shortname>Rule constratints testdat</shortname>
|
|
||||||
<description></description>
|
|
||||||
<url>/api/testdata/ruleconstraints</url>
|
|
||||||
</webscript>
|
|
@@ -1,95 +0,0 @@
|
|||||||
{
|
|
||||||
"data" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name" : "scripts",
|
|
||||||
"values" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"value" : "a-script.js",
|
|
||||||
"displayLabel" : "a-script.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "another-script.js",
|
|
||||||
"displayLabel" : "another-script.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "add-tags-script.js",
|
|
||||||
"displayLabel" : "add-tags-script.js"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "aspects",
|
|
||||||
"values" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"value" : "taggable",
|
|
||||||
"displayLabel" : "Taggable"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "versionable",
|
|
||||||
"displayLabel" : "Versionable"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "types",
|
|
||||||
"values" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"value" : "content",
|
|
||||||
"displayLabel" : "Content"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "document",
|
|
||||||
"displayLabel" : "Document"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "manual",
|
|
||||||
"displayLabel" : "Manual"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "property-evaluators",
|
|
||||||
"values" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"value" : "EQUALS",
|
|
||||||
"displayLabel" : "Is equal to"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "CONTAINS",
|
|
||||||
"displayLabel" : "Contains"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "BEGINS",
|
|
||||||
"displayLabel" : "Starts with"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "ENDS",
|
|
||||||
"displayLabel" : "Ends with"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "GREATER_THAN",
|
|
||||||
"displayLabel" : "Greater than"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "LESS_THAN",
|
|
||||||
"displayLabel" : "Less than"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "GREATER_THAN_EQUAL",
|
|
||||||
"displayLabel" : "Greater than or equals"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value" : "LESS_THAN_EQUAL",
|
|
||||||
"displayLabel" : "Less than or equals"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@@ -387,55 +387,58 @@ public abstract class AbstractRuleWebScript extends DeclarativeWebScript
|
|||||||
|
|
||||||
// get parameters names
|
// get parameters names
|
||||||
JSONArray names = jsonParameterValues.names();
|
JSONArray names = jsonParameterValues.names();
|
||||||
|
|
||||||
for (int i = 0; i < names.length(); i++)
|
if (names != null)
|
||||||
{
|
{
|
||||||
String propertyName = names.getString(i);
|
for (int i = 0; i < names.length(); i++)
|
||||||
Object propertyValue = jsonParameterValues.get(propertyName);
|
|
||||||
|
|
||||||
// get parameter repository type
|
|
||||||
QName typeQName = getPropertyType(propertyName);
|
|
||||||
|
|
||||||
if (typeQName == null)
|
|
||||||
{
|
{
|
||||||
if (propertyValue.toString().equals("true") || propertyValue.toString().equals("false"))
|
String propertyName = names.getString(i);
|
||||||
{
|
Object propertyValue = jsonParameterValues.get(propertyName);
|
||||||
typeQName = DataTypeDefinition.BOOLEAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
typeQName = DataTypeDefinition.TEXT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Serializable value = null;
|
// get parameter repository type
|
||||||
|
QName typeQName = getPropertyType(propertyName);
|
||||||
|
|
||||||
if (typeQName.equals(DataTypeDefinition.ANY))
|
if (typeQName == null)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
value = dateFormate.parse(propertyValue.toString());
|
if (propertyValue.toString().equals("true") || propertyValue.toString().equals("false"))
|
||||||
|
{
|
||||||
|
typeQName = DataTypeDefinition.BOOLEAN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
typeQName = DataTypeDefinition.TEXT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
|
||||||
|
Serializable value = null;
|
||||||
|
|
||||||
|
if (typeQName.equals(DataTypeDefinition.ANY))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
value = Long.valueOf(propertyValue.toString());
|
value = dateFormate.parse(propertyValue.toString());
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e1)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
// do nothing
|
try
|
||||||
|
{
|
||||||
|
value = Long.valueOf(propertyValue.toString());
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e1)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
// convert to correct repository type
|
// convert to correct repository type
|
||||||
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(typeQName), propertyValue);
|
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(typeQName), propertyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
parameterValues.put(propertyName, value);
|
parameterValues.put(propertyName, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameterValues;
|
return parameterValues;
|
||||||
|
Reference in New Issue
Block a user