use of org.kie.workbench.common.forms.model.ModelProperty in project kie-wb-common by kiegroup.
the class FormModelSynchronizationUtilImplTest method testRemoveModelProperties.
@Test
public void testRemoveModelProperties() {
ModelProperty name = formModel.getProperty("name");
assertNotNull(name);
formModelSynchronizationResult.getRemovedProperties().add(name);
ModelProperty surname = formModel.getProperty("surname");
assertNotNull(surname);
formModelSynchronizationResult.getRemovedProperties().add(surname);
ModelProperty birthday = formModel.getProperty("birthday");
assertNotNull(birthday);
formModelSynchronizationResult.getRemovedProperties().add(birthday);
synchronizationUtil.init(form, formModelSynchronizationResult);
int originalFormFields = form.getFields().size();
synchronizationUtil.fixRemovedFields();
assertEquals(originalFormFields, form.getFields().size());
assertNull(form.getFieldByBinding(name.getName()));
assertNull(form.getFieldByBinding(surname.getName()));
assertNull(form.getFieldByBinding(birthday.getName()));
FieldDefinition field = form.getFieldByName(name.getName());
assertNotNull(field);
assertNull(field.getBinding());
field = form.getFieldByName(surname.getName());
assertNotNull(field);
assertNull(field.getBinding());
field = form.getFieldByName(birthday.getName());
assertNotNull(field);
assertNull(field.getBinding());
}
use of org.kie.workbench.common.forms.model.ModelProperty in project kie-wb-common by kiegroup.
the class FormEditorHelper method removeField.
public void removeField(String fieldId, boolean addToAvailables) {
FormDefinition formDefinition = content.getDefinition();
FieldDefinition fieldToRemove = formDefinition.getFieldById(fieldId);
if (fieldToRemove != null) {
formDefinition.getFields().remove(fieldToRemove);
if (addToAvailables) {
FieldDefinition originalField = fieldToRemove;
if (fieldToRemove.getBinding() == null) {
return;
}
ModelProperty property = formDefinition.getModel().getProperty(fieldToRemove.getBinding());
fieldToRemove = fieldManager.getDefinitionByModelProperty(property);
fieldToRemove.setId(originalField.getId());
availableFields.put(fieldToRemove.getId(), fieldToRemove);
}
}
}
use of org.kie.workbench.common.forms.model.ModelProperty in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImplTest method checkTaskFormModel.
private void checkTaskFormModel(TaskFormModel formModel, String taskName, boolean readOnly) {
Assertions.assertThat(formModel).hasFieldOrPropertyWithValue("processId", PROCESS_ID).hasFieldOrPropertyWithValue("taskName", taskName);
Assertions.assertThat(formModel.getProperties()).isNotEmpty().hasSize(VARIABLES.size());
VARIABLES.forEach((key, value) -> {
ModelProperty property = formModel.getProperty(key);
assertNotNull(property);
assertEquals(value, property.getTypeInfo().getClassName());
MetaDataEntry readOnlyEntry = property.getMetaData().getEntry(FieldReadOnlyEntry.NAME);
Assertions.assertThat(readOnlyEntry).isNotNull().isInstanceOf(FieldReadOnlyEntry.class).hasFieldOrPropertyWithValue("value", readOnly);
});
}
use of org.kie.workbench.common.forms.model.ModelProperty in project kie-wb-common by kiegroup.
the class FormDefinitionGenerator method updateNestedFormsModelProperties.
private void updateNestedFormsModelProperties(FormDefinition newFormDefinition, FieldDefinition nestedFormField, Form nestedForm) {
nestedFormField.setStandaloneClassName(nestedForm.getHolders().iterator().next().getClassName());
FormModel model = newFormDefinition.getModel();
ModelProperty modelProperty = model.getProperty(nestedFormField.getBinding());
if (modelProperty != null) {
model.getProperties().remove(modelProperty);
ModelPropertyImpl newProperty = new ModelPropertyImpl(nestedFormField.getBinding(), nestedFormField.getFieldTypeInfo());
newProperty.getMetaData().getEntries().addAll(modelProperty.getMetaData().getEntries());
model.getProperties().add(newProperty);
}
}
Aggregations