use of org.alfresco.repo.forms.FieldDefinition in project alfresco-repository by Alfresco.
the class TransientFieldProcessor method generateTypedField.
/* (non-Javadoc)
* @see org.alfresco.repo.forms.processor.AbstractFieldProcessor#generateTypedField(java.lang.String, org.alfresco.repo.forms.processor.node.FormCreationData, java.lang.Object)
*/
@Override
protected Field generateTypedField(String fieldName, FormCreationData formData, TransientValueGetter typedData) {
FieldDefinition transientPropDef = makeTransientFieldDefinition();
Field fieldInfo = null;
Object value = getValue(fieldName, typedData);
if (transientPropDef != null) {
fieldInfo = new ContentModelField(transientPropDef, value);
}
return fieldInfo;
}
use of org.alfresco.repo.forms.FieldDefinition 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);
}
}
use of org.alfresco.repo.forms.FieldDefinition in project records-management by Alfresco.
the class RecordsManagementTypeFormFilter method afterGenerate.
/*
* @see
* org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object,
* java.util.List, java.util.List, org.alfresco.repo.forms.Form,
* java.util.Map)
*/
public void afterGenerate(TypeDefinition type, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context) {
QName typeName = type.getName();
if (rmAdminService.isCustomisable(typeName)) {
addCustomRMProperties(typeName, form);
}
// What about any mandatory aspects?
Set<QName> aspects = type.getDefaultAspectNames();
for (QName aspect : aspects) {
if (rmAdminService.isCustomisable(aspect)) {
addCustomRMProperties(aspect, form);
}
}
// set the id
List<FieldDefinition> fieldDefs = form.getFieldDefinitions();
for (FieldDefinition fieldDef : fieldDefs) {
String prefixName = fieldDef.getName();
if (prefixName.equals("rma:identifier")) {
String defaultId = identifierService.generateIdentifier(typeName, null);
fieldDef.setDefaultValue(defaultId);
} else // NOTE: we set these defaults in the form for backwards compatibility reasons (RM-753)
if (prefixName.equals("rma:vitalRecordIndicator")) {
fieldDef.setDefaultValue(Boolean.FALSE.toString());
} else if (prefixName.equals("rma:reviewPeriod")) {
fieldDef.setDefaultValue("none|0");
}
}
}
use of org.alfresco.repo.forms.FieldDefinition in project records-management by Alfresco.
the class RecordsManagementNodeFormFilter method protectEmailExtractedFields.
/**
* Marks all the fields that contain data extracted from an email
* as protected fields.
*
* @param form The Form instance to add the property to
* @param nodeRef The node the form is being generated for
*/
protected void protectEmailExtractedFields(Form form, NodeRef nodeRef) {
// iterate round existing fields and set email fields as protected
List<FieldDefinition> fieldDefs = form.getFieldDefinitions();
for (FieldDefinition fieldDef : fieldDefs) {
String prefixName = fieldDef.getName();
// check the value of the property, if empty then do not mark property
// as read only
QName qname = QName.createQName(prefixName, namespaceService);
Serializable value = nodeService.getProperty(nodeRef, qname);
if (value != null && (prefixName.equals("cm:title") || prefixName.equals("cm:author") || prefixName.equals("dod:originator") || prefixName.equals("dod:publicationDate") || prefixName.equals("dod:dateReceived") || prefixName.equals("dod:address") || prefixName.equals("dod:otherAddress"))) {
fieldDef.setProtectedField(true);
}
}
if (logger.isDebugEnabled()) {
logger.debug("Set email related fields to be protected");
}
}
use of org.alfresco.repo.forms.FieldDefinition in project alfresco-repository by Alfresco.
the class FormProcessorTest method checkSingleField.
protected void checkSingleField(Form form, String fieldName, Serializable fieldData, String expDataKey) {
List<FieldDefinition> fieldDefs = form.getFieldDefinitions();
assertEquals(1, fieldDefs.size());
FieldDefinition fieldDef = fieldDefs.get(0);
assertEquals(fieldName, fieldDef.getName());
String dataKey = fieldDef.getDataKeyName();
assertEquals(expDataKey, dataKey);
FieldData data = form.getFormData().getFieldData(dataKey);
if (fieldData != null && data != null) {
assertEquals(fieldData, data.getValue());
} else {
assertNull(data);
}
}
Aggregations