Search in sources :

Example 1 with Form

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;
}
Also used : Form(org.alfresco.repo.forms.Form)

Example 2 with 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());
}
Also used : Form(org.alfresco.repo.forms.Form)

Example 3 with Form

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());
}
Also used : Item(org.alfresco.repo.forms.Item) Form(org.alfresco.repo.forms.Form)

Example 4 with Form

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());
}
Also used : Item(org.alfresco.repo.forms.Item) Form(org.alfresco.repo.forms.Form)

Example 5 with Form

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());
}
Also used : FormData(org.alfresco.repo.forms.FormData) Serializable(java.io.Serializable) Form(org.alfresco.repo.forms.Form)

Aggregations

Form (org.alfresco.repo.forms.Form)20 Serializable (java.io.Serializable)7 Item (org.alfresco.repo.forms.Item)5 FormData (org.alfresco.repo.forms.FormData)2 Locale (java.util.Locale)1 AssociationFieldDefinition (org.alfresco.repo.forms.AssociationFieldDefinition)1 FieldDefinition (org.alfresco.repo.forms.FieldDefinition)1 PropertyFieldDefinition (org.alfresco.repo.forms.PropertyFieldDefinition)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 WorkflowTransition (org.alfresco.service.cmr.workflow.WorkflowTransition)1 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)1 Test (org.junit.Test)1