use of org.alfresco.repo.forms.FieldDefinition in project records-management by Alfresco.
the class RecordsManagementNodeFormFilter method protectRecordProperties.
/**
* @param form
* @param nodeRef
*/
protected void protectRecordProperties(Form form, NodeRef nodeRef) {
List<FieldDefinition> fieldDefs = form.getFieldDefinitions();
for (FieldDefinition fieldDef : fieldDefs) {
if (!fieldDef.isProtectedField()) {
String name = fieldDef.getName();
String prefixName = null;
if ("size".equals(name) || "mimetype".equals(name) || "encoding".equals(name)) {
prefixName = "cm:content";
} else {
prefixName = fieldDef.getName();
}
if (logger.isDebugEnabled()) {
logger.debug("Checking property " + prefixName + " is editable by user " + AuthenticationUtil.getFullyAuthenticatedUser());
}
QName qname = QName.createQName(prefixName, namespaceService);
if (!recordService.isPropertyEditable(nodeRef, qname)) {
if (logger.isDebugEnabled()) {
logger.debug(" ... protected property");
}
fieldDef.setProtectedField(true);
}
}
}
}
use of org.alfresco.repo.forms.FieldDefinition in project records-management by Alfresco.
the class RecordsManagementTypeFormFilterUnitTest method testDefaultFormValues.
/**
* Test the default values for certain properties are being set correctly
*/
@Test
public void testDefaultFormValues() {
List<FieldDefinition> defs = new ArrayList<>(3);
FieldDefinition idDef = mockFieldDefinition("rma:identifier");
defs.add(idDef);
FieldDefinition vrDef = mockFieldDefinition("rma:vitalRecordIndicator");
defs.add(vrDef);
FieldDefinition rpDef = mockFieldDefinition("rma:reviewPeriod");
defs.add(rpDef);
when(mockForm.getFieldDefinitions()).thenReturn(defs);
typeFormFilter.afterGenerate(mockTypeDefinition, null, null, mockForm, null);
verify(mockedIdentifierService).generateIdentifier(any(QName.class), any(NodeRef.class));
verify(idDef).setDefaultValue(anyString());
verify(vrDef).setDefaultValue(Boolean.FALSE.toString());
verify(rpDef).setDefaultValue("none|0");
}
use of org.alfresco.repo.forms.FieldDefinition in project records-management by Alfresco.
the class RecordsManagementTypeFormFilterUnitTest method mockFieldDefinition.
/**
* Helper to mock field definition
*/
private FieldDefinition mockFieldDefinition(String name) {
FieldDefinition def = mock(FieldDefinition.class);
when(def.getName()).thenReturn(name);
return def;
}
Aggregations