Search in sources :

Example 1 with FormDefinitionSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer in project kie-wb-common by kiegroup.

the class AbstractMigrationStep method persist.

private void persist(MigrationContext migrationContext) {
    FormSerializationManager oldFormSerializer = new FormSerializationManagerImpl();
    FormDefinitionSerializer formDefinitionSerializer = migrationContext.getCDIWrapper().getFormDefinitionSerializer();
    Function<Resource<Form>, String> originaldFormSerializationFunction = formResource -> {
        Form originalForm = formResource.get();
        originalForm.setMigrationStep(getStep());
        return oldFormSerializer.generateFormXML(originalForm, migrationContext.getSystem());
    };
    Function<Resource<FormDefinition>, String> newFormSerializationFuncion = formResource -> formDefinitionSerializer.serialize(formResource.get());
    migrationContext.getSummaries().forEach(summary -> {
        if (summary.getResult().isSuccess()) {
            serializeResource(summary.getOriginalForm().getPath(), originaldFormSerializationFunction.apply(summary.getOriginalForm()), migrationContext);
            serializeResource(summary.getNewForm().getPath(), newFormSerializationFuncion.apply(summary.getNewForm()), migrationContext);
        }
    });
    migrationContext.getExtraSummaries().forEach(summary -> {
        serializeResource(summary.getNewForm().getPath(), newFormSerializationFuncion.apply(summary.getNewForm()), migrationContext);
    });
}
Also used : Resource(org.kie.workbench.common.forms.migration.tool.Resource) FormSerializationManager(org.kie.workbench.common.forms.migration.legacy.services.FormSerializationManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) Function(java.util.function.Function) Form(org.kie.workbench.common.forms.migration.legacy.model.Form) Path(org.uberfire.backend.vfs.Path) FormSerializationManagerImpl(org.kie.workbench.common.forms.migration.legacy.services.impl.FormSerializationManagerImpl) Form(org.kie.workbench.common.forms.migration.legacy.model.Form) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) FormSerializationManagerImpl(org.kie.workbench.common.forms.migration.legacy.services.impl.FormSerializationManagerImpl) Resource(org.kie.workbench.common.forms.migration.tool.Resource) FormSerializationManager(org.kie.workbench.common.forms.migration.legacy.services.FormSerializationManager)

Aggregations

Function (java.util.function.Function)1 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)1 FormSerializationManager (org.kie.workbench.common.forms.migration.legacy.services.FormSerializationManager)1 FormSerializationManagerImpl (org.kie.workbench.common.forms.migration.legacy.services.impl.FormSerializationManagerImpl)1 Resource (org.kie.workbench.common.forms.migration.tool.Resource)1 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)1 FormDefinitionSerializer (org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer)1 Path (org.uberfire.backend.vfs.Path)1