use of org.alfresco.rest.workflow.api.model.FormModelElement in project alfresco-remote-api by Alfresco.
the class WorkflowRestImpl method getFormModelElements.
/**
* @param type the type to get the elements for
* @param paging Paging
* @return collection with all valid form-model elements for the given type.
*/
public CollectionWithPagingInfo<FormModelElement> getFormModelElements(TypeDefinition type, Paging paging) {
Map<QName, PropertyDefinition> taskProperties = type.getProperties();
Set<QName> typesToExclude = getTypesToExclude(type);
List<FormModelElement> page = new ArrayList<FormModelElement>();
for (Entry<QName, PropertyDefinition> entry : taskProperties.entrySet()) {
String name = entry.getKey().toPrefixString(namespaceService).replace(':', '_');
// Only add properties which are not part of an excluded type
if (!typesToExclude.contains(entry.getValue().getContainerClass().getName()) && excludeModelTypes.contains(name) == false) {
FormModelElement element = new FormModelElement();
element.setName(name);
element.setQualifiedName(entry.getKey().toString());
element.setTitle(entry.getValue().getTitle(dictionaryService));
element.setRequired(entry.getValue().isMandatory());
element.setDataType(entry.getValue().getDataType().getName().toPrefixString(namespaceService));
element.setDefaultValue(entry.getValue().getDefaultValue());
if (entry.getValue().getConstraints() != null) {
for (ConstraintDefinition constraintDef : entry.getValue().getConstraints()) {
Constraint constraint = constraintDef.getConstraint();
if (constraint != null && constraint instanceof ListOfValuesConstraint) {
ListOfValuesConstraint valuesConstraint = (ListOfValuesConstraint) constraint;
if (valuesConstraint.getAllowedValues() != null && valuesConstraint.getAllowedValues().size() > 0) {
element.setAllowedValues(valuesConstraint.getAllowedValues());
}
}
}
}
page.add(element);
}
}
Map<QName, AssociationDefinition> taskAssociations = type.getAssociations();
for (Entry<QName, AssociationDefinition> entry : taskAssociations.entrySet()) {
// Only add associations which are not part of an excluded type
if (!typesToExclude.contains(entry.getValue().getSourceClass().getName())) {
FormModelElement element = new FormModelElement();
element.setName(entry.getKey().toPrefixString(namespaceService).replace(':', '_'));
element.setQualifiedName(entry.getKey().toString());
element.setTitle(entry.getValue().getTitle(dictionaryService));
element.setRequired(entry.getValue().isTargetMandatory());
element.setDataType(entry.getValue().getTargetClass().getName().toPrefixString(namespaceService));
page.add(element);
}
}
return CollectionWithPagingInfo.asPaged(paging, page, false, page.size());
}
Aggregations