Search in sources :

Example 6 with Item

use of org.alfresco.repo.forms.Item 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 Item

use of org.alfresco.repo.forms.Item 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)

Example 8 with Item

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

the class ScriptFormService method getForm.

/**
 * Returns a form representation of the given item consisting
 * only of the given fields.
 *
 * @param itemKind The kind of item to retrieve a form for
 * @param itemId The identifier of the item to retrieve a form for
 * @param fields String array of fields to include, null
 *               indicates all possible fields for the item
 *               should be included
 * @param forcedFields List of field names from 'fields' list
 *                     that should be forcibly included, it is
 *                     up to the form processor implementation
 *                     to determine how to enforce this
 * @return The form
 */
public ScriptForm getForm(String itemKind, String itemId, String[] fields, String[] forcedFields) {
    // create List<String> representations of field params if necessary
    List<String> fieldsList = null;
    List<String> forcedFieldsList = null;
    if (fields != null) {
        fieldsList = Arrays.asList(fields);
    }
    if (forcedFields != null) {
        forcedFieldsList = Arrays.asList(forcedFields);
    }
    Form result = formService.getForm(new Item(itemKind, itemId), fieldsList, forcedFieldsList);
    return result == null ? null : new ScriptForm(result);
}
Also used : Item(org.alfresco.repo.forms.Item) Form(org.alfresco.repo.forms.Form)

Example 9 with Item

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

the class FilteredFormProcessor method internalGenerate.

/**
 * Generates the form.
 *
 * @param item The object to generate a form for
 * @param fields Restricted list of fields to include
 * @param forcedFields List of fields to forcibly include
 * @param form The form object being generated
 * @param context Map representing optional context that can be used during
 *            retrieval of the form
 */
protected void internalGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context) {
    Log log = getLogger();
    if (log.isDebugEnabled())
        log.debug("Generating form for: " + item);
    // generate the form type and URI for the item.
    Item formItem = form.getItem();
    formItem.setType(getItemType(item));
    formItem.setUrl(getItemURI(item));
    Object itemData = makeItemData(item);
    FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context);
    populateForm(form, fields, data);
    if (// 
    log.isDebugEnabled())
        log.debug("Generated form: " + form);
}
Also used : Item(org.alfresco.repo.forms.Item) Log(org.apache.commons.logging.Log)

Example 10 with Item

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

the class ActionFormProcessorTest method testRequestFormForNonExistentAction.

@Test
public void testRequestFormForNonExistentAction() throws Exception {
    try {
        this.formService.getForm(new Item(ActionFormProcessor.ITEM_KIND, "noSuchActionBean"));
        fail("Expected FormNotFoundException");
    } catch (FormNotFoundException e) {
    // NOOP
    }
}
Also used : Item(org.alfresco.repo.forms.Item) FormNotFoundException(org.alfresco.repo.forms.FormNotFoundException) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Aggregations

Item (org.alfresco.repo.forms.Item)14 Form (org.alfresco.repo.forms.Form)5 FormNotFoundException (org.alfresco.repo.forms.FormNotFoundException)3 FormData (org.alfresco.repo.forms.FormData)2 DefaultFieldProcessor (org.alfresco.repo.forms.processor.node.DefaultFieldProcessor)2 MockFieldProcessorRegistry (org.alfresco.repo.forms.processor.node.MockFieldProcessorRegistry)2 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)2 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)2 Test (org.junit.Test)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Locale (java.util.Locale)1 Properties (java.util.Properties)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 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)1 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)1