use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class FormDefinitionGenerator method maybeArrangeNestedForms.
private void maybeArrangeNestedForms(FormMigrationSummary summary, List<FormMigrationSummary> modelForms) {
final Form originalForm = summary.getOriginalForm().get();
final FormDefinition formDefinition = summary.getNewForm().get();
formDefinition.getFields().stream().filter(fieldDefinition -> fieldDefinition instanceof HasNestedForm).map(fieldDefinition -> (HasNestedForm) fieldDefinition).forEach(hasNestedForm -> {
modelForms.stream().filter(modelSummary -> modelSummary.getOriginalForm().getPath().getFileName().equals(hasNestedForm.getNestedForm())).findFirst().ifPresent(modelSummary -> {
hasNestedForm.setNestedForm(modelSummary.getNewForm().get().getId());
updateNestedFormsModelProperties(formDefinition, (FieldDefinition) hasNestedForm, modelSummary.getOriginalForm().get());
});
});
formDefinition.getFields().stream().filter(fieldDefinition -> fieldDefinition instanceof IsCRUDDefinition).map(fieldDefinition -> (IsCRUDDefinition) fieldDefinition).forEach(crudDefinition -> {
// update Creation Form
updateCrudDefinitionForms(modelForms, modelSummary -> modelSummary.getOriginalForm().getPath().getFileName().equals(crudDefinition.getCreationForm()), modelSummary -> crudDefinition.setCreationForm(modelSummary.getNewForm().get().getId()));
// update Edition Form
updateCrudDefinitionForms(modelForms, modelSummary -> modelSummary.getOriginalForm().getPath().getFileName().equals(crudDefinition.getEditionForm()), modelSummary -> crudDefinition.setEditionForm(modelSummary.getNewForm().get().getId()));
// update Table Columns Form
updateCrudDefinitionForms(modelForms, modelSummary -> {
Field originalField = originalForm.getField(((FieldDefinition) crudDefinition).getName());
return modelSummary.getOriginalForm().getPath().getFileName().equals(StringUtils.defaultIfBlank(originalField.getTableSubform(), originalField.getDefaultSubform()));
}, modelSummary -> {
FormDefinition modelFormDefinition = modelSummary.getNewForm().get();
modelFormDefinition.getFields().forEach(fieldDefinition -> {
if (!(fieldDefinition instanceof EmbedsForm)) {
crudDefinition.getColumnMetas().add(new TableColumnMeta(fieldDefinition.getLabel(), fieldDefinition.getBinding()));
}
});
updateNestedFormsModelProperties(formDefinition, (FieldDefinition) crudDefinition, modelSummary.getOriginalForm().get());
});
});
}
use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class FormDefinitionGenerator method doExecute.
@Override
public void doExecute(MigrationContext migrationContext) {
migrationContext.getSummaries().removeIf(this::basicSummaryCheck);
DataObjectFormAdapter dataObjectAdapter = dataObjectFormAdapterFunction.apply(migrationContext);
List<FormMigrationSummary> possibleDataObjectForms = dataObjectAdapter.migrateSummaries();
if (!possibleDataObjectForms.isEmpty()) {
arrangeNestedForms(possibleDataObjectForms, possibleDataObjectForms);
}
BPMNFormAdapter bpmFormAdapter = bpmFormAdapterFunction.apply(migrationContext);
List<FormMigrationSummary> possibleBPMNForms = bpmFormAdapter.migrateSummaries();
if (!possibleBPMNForms.isEmpty() && !possibleDataObjectForms.isEmpty()) {
arrangeNestedForms(possibleDataObjectForms, possibleDataObjectForms);
}
if (!migrationContext.getExtraSummaries().isEmpty() && !possibleDataObjectForms.isEmpty()) {
arrangeNestedForms(migrationContext.getExtraSummaries(), possibleDataObjectForms);
}
}
Aggregations