Search in sources :

Example 1 with GenerationContext

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.GenerationContext in project kie-wb-common by kiegroup.

the class BPMNVFSFormDefinitionGeneratorService method findFormDefinitionForModelType.

@Override
protected FormDefinition findFormDefinitionForModelType(String modelType, GenerationContext<Path> context) {
    FormDefinition form = super.findFormDefinitionForModelType(modelType, context);
    if (form != null) {
        return form;
    }
    List<FormDefinition> foundForms = formFinderService.findFormsForType(modelType, context.getSource());
    Optional<FormDefinition> validForm = foundForms.stream().filter(formDefinition -> !formDefinition.getFields().isEmpty()).findFirst();
    return validForm.orElse(foundForms.stream().findFirst().orElse(null));
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) LoggerFactory(org.slf4j.LoggerFactory) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FieldManager(org.kie.workbench.common.forms.service.shared.FieldManager) Named(javax.inject.Named) GenerationContext(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.GenerationContext) VFSFormFinderService(org.kie.workbench.common.forms.editor.service.shared.VFSFormFinderService) Path(org.uberfire.backend.vfs.Path) Logger(org.slf4j.Logger) UIDGenerator(org.kie.workbench.common.forms.services.backend.util.UIDGenerator) FormModelSynchronizationUtil(org.kie.workbench.common.forms.editor.service.shared.model.FormModelSynchronizationUtil) AbstractBPMNFormGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.AbstractBPMNFormGeneratorService) Collectors(java.util.stream.Collectors) FormModelHandler(org.kie.workbench.common.forms.editor.service.backend.FormModelHandler) List(java.util.List) FormResourceTypeDefinition(org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition) Dependent(javax.enterprise.context.Dependent) IOService(org.uberfire.io.IOService) Optional(java.util.Optional) FormModelSynchronizationResult(org.kie.workbench.common.forms.editor.model.FormModelSynchronizationResult) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Dependent (javax.enterprise.context.Dependent)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 CommentedOptionFactory (org.guvnor.common.services.backend.util.CommentedOptionFactory)1 FormModelSynchronizationResult (org.kie.workbench.common.forms.editor.model.FormModelSynchronizationResult)1 FormModelHandler (org.kie.workbench.common.forms.editor.service.backend.FormModelHandler)1 FormModelHandlerManager (org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager)1 VFSFormFinderService (org.kie.workbench.common.forms.editor.service.shared.VFSFormFinderService)1 FormModelSynchronizationUtil (org.kie.workbench.common.forms.editor.service.shared.model.FormModelSynchronizationUtil)1 FormResourceTypeDefinition (org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition)1 AbstractBPMNFormGeneratorService (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.AbstractBPMNFormGeneratorService)1 GenerationContext (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.GenerationContext)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)1 JavaFormModel (org.kie.workbench.common.forms.model.JavaFormModel)1 FieldManager (org.kie.workbench.common.forms.service.shared.FieldManager)1 FormDefinitionSerializer (org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer)1