use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.
the class FilteredFormProcessor method generate.
/**
* {@inheritDoc}
*/
public Form generate(Item item, List<String> fields, List<String> forcedFields, Map<String, Object> context) {
// get the typed object representing the item
ItemType typedItem = getTypedItem(item);
// create an empty Form
Form form = new Form(item);
// inform all regsitered filters the form is about to be generated
if (this.filterRegistry != null) {
for (Filter<ItemType, PersistType> filter : this.filterRegistry.getFilters()) {
filter.beforeGenerate(typedItem, fields, forcedFields, form, context);
}
}
// perform the actual generation of the form
internalGenerate(typedItem, fields, forcedFields, form, context);
// inform all regsitered filters the form has been generated
if (this.filterRegistry != null) {
for (Filter<ItemType, PersistType> filter : this.filterRegistry.getFilters()) {
filter.afterGenerate(typedItem, fields, forcedFields, form, context);
}
}
return form;
}
use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.
the class WorkflowFormProcessorTest method testIgnoresUnknownFields.
public void testIgnoresUnknownFields() throws Exception {
String fakeFieldName = NamespaceService.BPM_MODEL_PREFIX + ":" + "Fake Field";
String priorityField = PRIORITY_NAME.toPrefixString(namespaceService);
List<String> fields = Arrays.asList(fakeFieldName, priorityField);
Form form = processForm(fields);
checkSingleProperty(form, priorityField, 2);
checkPackageActionGroups(form.getFormData());
}
use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.
the class WorkflowFormProcessorTest method testGenerateSetsItemAndUrl.
public void testGenerateSetsItemAndUrl() throws Exception {
Form form = ((WorkflowFormProcessor) processor).generate(item, null, null, null);
Item formItem = form.getItem();
assertEquals(item.getId(), formItem.getId());
assertEquals(item.getKind(), formItem.getKind());
assertEquals(WF_DEF_NAME, formItem.getType());
assertEquals("api/workflow-definitions/" + definition.getId(), formItem.getUrl());
}
use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.
the class TaskFormProcessorTest method testGenerateSetsItemAndUrl.
public void testGenerateSetsItemAndUrl() throws Exception {
Form form = ((TaskFormProcessor) processor).generate(item, null, null, null);
Item formItem = form.getItem();
assertEquals(item.getId(), formItem.getId());
assertEquals(item.getKind(), formItem.getKind());
String expType = NamespaceService.BPM_MODEL_PREFIX + ":" + TASK_DEF_NAME;
assertEquals(expType, formItem.getType());
assertEquals("api/task-instances/" + TASK_ID, formItem.getUrl());
}
use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.
the class WorkflowFormProcessorTest method testGenerateDefaultForm.
public void testGenerateDefaultForm() throws Exception {
Form form = processForm();
List<String> fieldDefs = form.getFieldDefinitionNames();
assertTrue(fieldDefs.contains(ASSIGNEE_NAME.toPrefixString(namespaceService)));
assertTrue(fieldDefs.contains(PRIORITY_NAME.toPrefixString(namespaceService)));
assertTrue(fieldDefs.contains(PackageItemsFieldProcessor.KEY));
// Check 'default ignored fields' are proerly removed from defaults.
assertFalse(fieldDefs.contains(ACTORS_NAME.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(PROP_PACKAGE_ACTION_GROUP.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(PROP_PACKAGE_ITEM_ACTION_GROUP.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(WorkflowModel.PROP_DESCRIPTION.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(WorkflowModel.PROP_DUE_DATE.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(WorkflowModel.PROP_PRIORITY.toPrefixString(namespaceService)));
assertFalse(fieldDefs.contains(WorkflowModel.PROP_TASK_ID.toPrefixString(namespaceService)));
Serializable fieldData = (Serializable) Collections.emptyList();
FormData formData = form.getFormData();
assertEquals(fieldData, formData.getFieldData("assoc_bpm_assignee").getValue());
checkPackageActionGroups(formData);
assertEquals(2, formData.getFieldData("prop_bpm_workflowPriority").getValue());
}
Aggregations