Search in sources :

Example 6 with Form

use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.

the class ActionFormProcessorTest method testGenerateFormWithSpecificLocale.

/**
 * REPO-2253 Community: ALF-21854 Action parameter lookup for "de_DE" falls back to "root" locale instead of "de"
 */
@Test
public void testGenerateFormWithSpecificLocale() {
    final Locale originalLocale = I18NUtil.getLocale();
    try {
        // de-DE
        I18NUtil.setLocale(Locale.GERMANY);
        transactionHelper.doInTransaction(() -> {
            Form form = formService.getForm(new Item(ActionFormProcessor.ITEM_KIND, "transform"));
            // Field definitions keyed by name.
            Map<String, FieldDefinition> fieldDefMap = form.getFieldDefinitions().stream().collect(Collectors.toMap(FieldDefinition::getName, Function.identity()));
            assertEquals("Zielordner", fieldDefMap.get(TransformActionExecuter.PARAM_DESTINATION_FOLDER).getLabel());
            assertEquals("MIME-Type", fieldDefMap.get(TransformActionExecuter.PARAM_MIME_TYPE).getLabel());
            return null;
        });
    } finally {
        I18NUtil.setLocale(originalLocale);
    }
}
Also used : Locale(java.util.Locale) Item(org.alfresco.repo.forms.Item) Form(org.alfresco.repo.forms.Form) AssociationFieldDefinition(org.alfresco.repo.forms.AssociationFieldDefinition) FieldDefinition(org.alfresco.repo.forms.FieldDefinition) PropertyFieldDefinition(org.alfresco.repo.forms.PropertyFieldDefinition) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 7 with Form

use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.

the class TaskFormProcessorTest method testGenerateTransitions.

public void testGenerateTransitions() throws Exception {
    // Check empty transitions
    String fieldName = TransitionFieldProcessor.KEY;
    Form form = processForm(fieldName);
    String transitionValues = "";
    checkSingleProperty(form, fieldName, transitionValues);
    // Set up transitions
    WorkflowTransition transition1 = makeTransition("id1", "title1");
    WorkflowTransition transition2 = makeTransition("id2", "title2");
    WorkflowTransition transition3 = makeTransition("id3", "title3");
    task = makeTask(transition1, transition2, transition3);
    // Hide transition with id3.
    Serializable hiddenValue = (Serializable) Collections.singletonList("id3");
    task.getProperties().put(PROP_HIDDEN_TRANSITIONS, hiddenValue);
    form = processForm(fieldName);
    transitionValues = "id1|title1,id2|title2";
    checkSingleProperty(form, fieldName, transitionValues);
}
Also used : Serializable(java.io.Serializable) Form(org.alfresco.repo.forms.Form) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition)

Example 8 with Form

use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.

the class TaskFormProcessorTest method testGenerateMessage.

public void testGenerateMessage() throws Exception {
    String message = NO_MESSAGE;
    String fieldName = MessageFieldProcessor.KEY;
    Form form = processForm(fieldName);
    checkSingleProperty(form, fieldName, message);
    // add a description to the task and check it comes back
    message = "This is some text the user may have entered";
    this.task.getProperties().put(PROP_DESCRIPTION, message);
    form = processForm(fieldName);
    checkSingleProperty(form, fieldName, message);
    // set the description to the same as the task title
    // and make sure the message comes back as null
    this.task.getProperties().put(PROP_DESCRIPTION, this.task.getTitle());
    form = processForm(fieldName);
    checkSingleProperty(form, fieldName, NO_MESSAGE);
}
Also used : Form(org.alfresco.repo.forms.Form)

Example 9 with Form

use of org.alfresco.repo.forms.Form in project alfresco-repository by Alfresco.

the class TaskFormProcessorTest method testGenerateTaskOwner.

public void testGenerateTaskOwner() throws Exception {
    // check the task owner is null
    String fieldName = TaskOwnerFieldProcessor.KEY;
    Form form = processForm(fieldName);
    checkSingleProperty(form, fieldName, null);
    // set task owner
    this.task.getProperties().put(ContentModel.PROP_OWNER, "admin");
    // check the task owner property is correct
    form = processForm(fieldName);
    checkSingleProperty(form, fieldName, "admin|System|Administrator");
}
Also used : Form(org.alfresco.repo.forms.Form)

Example 10 with Form

use of org.alfresco.repo.forms.Form in project records-management by Alfresco.

the class RM1727Test method testRM1727.

public void testRM1727() {
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            // set read and file permissions for folder
            filePlanPermissionService.setPermission(folder, myUser, RMPermissionModel.FILING);
            return null;
        }
    });
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Item item = new Item("node", folder.toString());
            item.setType("rma:recordFolder");
            form = new Form(item);
            nodeFormFilter.afterGenerate(folder, null, null, form, null);
            return null;
        }
    }, myUser);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Item item = new Item("node", record.toString());
            item.setType("rma:record");
            form = new Form(item);
            nodeFormFilter.afterGenerate(record, null, null, form, null);
            return null;
        }
    }, myUser);
}
Also used : Item(org.alfresco.repo.forms.Item) 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