Search in sources :

Example 1 with AssociationFieldDefinition

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

the class AssociationFieldProcessor method makeAssociationFieldDefinition.

public AssociationFieldDefinition makeAssociationFieldDefinition(final AssociationDefinition assocDef, FieldGroup group) {
    String name = getPrefixedName(assocDef);
    String endpointType = assocDef.getTargetClass().getName().toPrefixString(namespaceService);
    AssociationFieldDefinition fieldDef = new AssociationFieldDefinition(name, endpointType, Direction.TARGET);
    populateFieldDefinition(assocDef, fieldDef, group, ASSOC_DATA_PREFIX);
    fieldDef.setEndpointMandatory(assocDef.isTargetMandatory());
    fieldDef.setEndpointMany(assocDef.isTargetMany());
    return fieldDef;
}
Also used : AssociationFieldDefinition(org.alfresco.repo.forms.AssociationFieldDefinition)

Example 2 with AssociationFieldDefinition

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

the class PackageItemsFieldProcessor method makeTransientFieldDefinition.

/* (non-Javadoc)
     * @see org.alfresco.repo.forms.processor.node.TransientFieldProcessor#makeTransientPropertyDefinition()
     */
@Override
protected FieldDefinition makeTransientFieldDefinition() {
    AssociationFieldDefinition fieldDef = new AssociationFieldDefinition(KEY, KEY, Direction.TARGET);
    fieldDef.setLabel(I18NUtil.getMessage(MSG_LABEL));
    fieldDef.setDescription(I18NUtil.getMessage(MSG_DESCRIPTION));
    fieldDef.setProtectedField(false);
    fieldDef.setEndpointMandatory(false);
    fieldDef.setEndpointMany(true);
    // define the data key name and set
    String dataKey = ASSOC_DATA_PREFIX + KEY;
    fieldDef.setDataKeyName(dataKey);
    return fieldDef;
}
Also used : AssociationFieldDefinition(org.alfresco.repo.forms.AssociationFieldDefinition)

Example 3 with AssociationFieldDefinition

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

the class FieldProcessorTest method testMakeAssociationFieldDefinition.

public void testMakeAssociationFieldDefinition() throws Exception {
    AssociationFieldProcessor processor = new AssociationFieldProcessor();
    processor.setNamespaceService(namespaceService);
    String name1 = ASSOC + ":" + PREFIX + ":" + NAME1;
    Field field = processor.generateField(name1, data);
    AssociationFieldDefinition assocFieldDef = (AssociationFieldDefinition) field.getFieldDefinition();
    assertNotNull(assocFieldDef);
    assertEquals("assoc_" + PREFIX + "_" + NAME1, assocFieldDef.getDataKeyName());
    assertEquals(PREFIX + ":" + NAME1, assocFieldDef.getName());
    assertEquals(PREFIX + ":" + NAME1, assocFieldDef.getLabel());
    assertEquals(Direction.TARGET, assocFieldDef.getEndpointDirection());
    assertEquals(PREFIX + ":Target", assocFieldDef.getEndpointType());
    assertEquals(DESCRIPTION1, assocFieldDef.getDescription());
    assertFalse(assocFieldDef.isProtectedField());
    assertFalse(assocFieldDef.isEndpointMandatory());
    assertFalse(assocFieldDef.isEndpointMany());
    // Repeat using different params to ensuere the fieldDefinition values
    // are dependant on the AssociationDefinition values.
    String name2 = ASSOC + ":" + PREFIX + ":" + NAME2;
    field = processor.generateField(name2, data);
    assocFieldDef = (AssociationFieldDefinition) field.getFieldDefinition();
    assertEquals(TITLE, assocFieldDef.getLabel());
    assertEquals(DESCRIPTION2, assocFieldDef.getDescription());
    assertTrue(assocFieldDef.isProtectedField());
    assertTrue(assocFieldDef.isEndpointMandatory());
    assertTrue(assocFieldDef.isEndpointMany());
}
Also used : Field(org.alfresco.repo.forms.Field) AssociationFieldDefinition(org.alfresco.repo.forms.AssociationFieldDefinition)

Aggregations

AssociationFieldDefinition (org.alfresco.repo.forms.AssociationFieldDefinition)3 Field (org.alfresco.repo.forms.Field)1