use of org.kie.workbench.common.forms.migration.tool.pipelines.basic.UnSupportedFieldAdapter in project kie-wb-common by kiegroup.
the class AbstractFormAdapter method migrateFields.
protected void migrateFields(final Set<Field> fields, final FormDefinition newForm, final FormMigrationSummary formSummary) {
LayoutHelper helper = new LayoutHelper();
fields.forEach(originalField -> {
if (!StringUtils.isEmpty(originalField.getMovedToForm())) {
return;
}
if (!Boolean.TRUE.equals(originalField.getGroupWithPrevious())) {
helper.newRow();
}
String originalTypeCode = originalField.getFieldType().getCode();
FieldAdapter adapter = adaptersRegistry.get(originalTypeCode);
if (adapter == null) {
// trying a backup adapter
UnSupportedFieldAdapter unSupportedFieldAdapter = unSupportedAdapters.get(originalTypeCode);
if (unSupportedFieldAdapter != null) {
warn("Problems migrating field '" + originalField.getFieldName() + "': the original field has an unsupported field type '" + originalTypeCode + "'. It will be added on the new Form as a '" + unSupportedFieldAdapter.getNewFieldType() + "'");
unSupportedFieldAdapter.parseField(originalField, formSummary, newForm, helper::add);
} else {
warn("Cannot migrate field '" + originalField.getFieldName() + "': Unsupported field type '" + originalTypeCode + "'");
Formatter formatter = new Formatter();
formatter.format(FormsMigrationConstants.UNSUPORTED_FIELD_HTML_TEMPLATE, originalField.getFieldName(), originalTypeCode);
LayoutComponent component = new LayoutComponent(FormsMigrationConstants.HTML_COMPONENT);
component.addProperty(FormsMigrationConstants.HTML_CODE_PARAMETER, formatter.toString());
formatter.close();
helper.add(component);
}
} else {
try {
adapter.parseField(originalField, formSummary, newForm, helper::add);
} catch (Exception ex) {
warn("Cannot migrate field '" + originalField.getFieldName() + "': Unexpected error, see message for details");
ex.printStackTrace(migrationContext.getSystem().err());
}
}
});
newForm.setLayoutTemplate(helper.build());
}
use of org.kie.workbench.common.forms.migration.tool.pipelines.basic.UnSupportedFieldAdapter in project kie-wb-common by kiegroup.
the class AbstractFormAdapter method registerAdapter.
protected void registerAdapter(final FieldAdapter adapter) {
Stream.of(adapter.getLegacyFieldTypeCodes()).forEach(code -> adaptersRegistry.put(code, adapter));
if (adapter instanceof UnSupportedFieldAdapter) {
UnSupportedFieldAdapter unSupportedFieldAdapter = (UnSupportedFieldAdapter) adapter;
Stream.of(unSupportedFieldAdapter.getLegacySupportedFieldTypeCodes()).forEach(code -> unSupportedAdapters.put(code, unSupportedFieldAdapter));
}
}
Aggregations