use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.
the class BeanPropertiesProviderTest method testGetModelProperties.
protected void testGetModelProperties(String... columns) {
field = new MultipleSubFormFieldDefinition();
for (String column : columns) {
field.getColumnMetas().add(new TableColumnMeta(column, column));
}
List<String> bannedColumns = new ArrayList<>(Arrays.asList(columns));
if (!StringUtils.isEmpty(currentEditedMeta.getProperty())) {
bannedColumns.remove(currentEditedMeta.getProperty());
}
field.setStandaloneClassName(TYPE_NAME);
parentContext = new FormEditorRenderingContext(path);
parentContext.setModel(field);
context.setParentContext(parentContext);
expectedFields = DATA_OBJECT_VALID_FIELDS - bannedColumns.size();
SelectorData data = provider.getSelectorData(context);
verify(service).getDataObjectProperties(any(), any());
assertNotNull(data);
assertNotNull(data.getValues());
assertNull(data.getSelectedValue());
assertFalse(data.getValues().isEmpty());
assertEquals(expectedFields, data.getValues().size());
for (String column : bannedColumns) {
assertNull(data.getValues().get(column));
}
assertNull(data.getValues().get(DataObjectFormModelHandler.SERIAL_VERSION_UID));
assertNull(data.getValues().get(PERSISTENCE_ID_PROPERTY));
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.
the class DataObjectFormModelHandlerTest method multipleSubformHasCorrectProperties.
@Test
public void multipleSubformHasCorrectProperties() {
formModel = handler.createFormModel(dataObject, path);
MultipleSubFormFieldDefinition multipleSubform = (MultipleSubFormFieldDefinition) checkCommonProperties("address_list");
assertEquals(null, multipleSubform.getCreationForm());
assertEquals(null, multipleSubform.getEditionForm());
assertEquals(Collections.emptyList(), multipleSubform.getColumnMetas());
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method generateModelDefinition.
protected Map<String, PropertyType> generateModelDefinition(FormDefinition form, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) {
if (availableModels.containsKey(form.getId())) {
return availableModels.get(form.getId());
}
Map<String, PropertyType> formTypes = new HashMap<>();
availableModels.put(form.getId(), formTypes);
form.getFields().forEach(field -> {
PropertyType propertyType = null;
if (basicProperties.containsKey(field.getStandaloneClassName())) {
propertyType = new PropertyType(basicProperties.get(field.getStandaloneClassName()));
} else if (propertiesGenerator.containsKey(field.getClass())) {
PropertyGenerator generator = propertiesGenerator.get(field.getClass());
propertyType = generator.generatePropertyType(field);
} else if (field instanceof SubFormFieldDefinition) {
propertyType = getModeldefinitionFor((SubFormFieldDefinition) field, context, availableModels);
} else if (field instanceof MultipleSubFormFieldDefinition) {
propertyType = new PropertyType(List.class);
}
if (propertyType != null) {
formTypes.put(field.getBinding(), propertyType);
}
});
return formTypes;
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.
the class BeanPropertiesProvider method getSelectorData.
@Override
public SelectorData getSelectorData(FormRenderingContext context) {
HashMap<String, String> values = new HashMap<>();
if (context instanceof FormEditorRenderingContext && context.getParentContext() != null) {
if (context.getParentContext().getModel() instanceof MultipleSubFormFieldDefinition) {
FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
if (context.getParentContext() != null) {
MultipleSubFormFieldDefinition subForm = (MultipleSubFormFieldDefinition) context.getParentContext().getModel();
Path path = editorContext.getFormPath();
String typeName = subForm.getStandaloneClassName();
final TableColumnMeta currentMeta = (TableColumnMeta) context.getModel();
Set<String> unavailableProperties = subForm.getColumnMetas().stream().map(TableColumnMeta::getProperty).collect(Collectors.toSet());
if (currentMeta != null && !StringUtils.isEmpty(currentMeta.getProperty())) {
unavailableProperties.remove(currentMeta.getProperty());
}
dataObjectFinderService.getDataObjectProperties(typeName, path).stream().filter(property -> !unavailableProperties.contains(property.getName())).forEachOrdered(property -> values.put(property.getName(), property.getName()));
}
}
}
return new SelectorData(values, null);
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method testExpenseForm.
protected void testExpenseForm(FormDefinition form) {
assertEquals(4, form.getFields().size());
IntegerBoxFieldDefinition id = (IntegerBoxFieldDefinition) form.getFieldByBinding("id");
assertNotNull(id);
assertEquals(Long.class.getName(), id.getStandaloneClassName());
DatePickerFieldDefinition date = (DatePickerFieldDefinition) form.getFieldByBinding("date");
assertNotNull(date);
assertEquals(Date.class.getName(), date.getStandaloneClassName());
SubFormFieldDefinition client = (SubFormFieldDefinition) form.getFieldByBinding("client");
assertNotNull(client);
assertNotNull(client.getNestedForm());
assertEquals(Client.class.getName(), client.getStandaloneClassName());
MultipleSubFormFieldDefinition lines = (MultipleSubFormFieldDefinition) form.getFieldByBinding("lines");
assertNotNull(lines);
assertNotNull(lines.getCreationForm());
assertNotNull(lines.getEditionForm());
assertEquals(lines.getEditionForm(), lines.getCreationForm());
assertFalse(lines.getColumnMetas().isEmpty());
assertEquals(Line.class.getName(), lines.getStandaloneClassName());
}
Aggregations