@Test public void testConstructContent() throws IOException, SourceFormModelNotFoundException { String formContent = IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream("test.frm"))); when(ioService.readAllString(any())).thenReturn(formContent); FormModelerContent content = formEditorService.constructContent(path, overview); verify(modelHandlerManager).getFormModelHandler(any()); verify(dataObjectFormModelHandler).init(any(), any()); verify(dataObjectFormModelHandler).checkSourceModel(); verify(dataObjectFormModelHandler).synchronizeFormModel(); verify(resourceOpenedEvent).fire(any()); assertNotNull(content); assertNull(content.getError()); assertEquals(RenderMode.READ_ONLY_MODE, content.getRenderingContext().getRenderMode()); }
@Override protected FormModelerContent constructContent(Path path, Overview overview) { FormModelerContent formModelConent = new FormModelerContent(); try { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path); FormDefinition form = findForm(kiePath); formModelConent.setDefinition(form); formModelConent.setPath(path); formModelConent.setOverview(overview); FormEditorRenderingContext context = createRenderingContext(form, path); formModelConent.setRenderingContext(context); if (Optional.ofNullable(form.getModel()).isPresent()) { FormModel formModel = form.getModel(); Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form); if (modelHandlerOptional.isPresent()) { try { FormModelHandler formModelHandler = modelHandlerOptional.get(); formModelHandler.init(formModel, path); formModelHandler.checkSourceModel(); FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel(); formModel.getProperties().forEach(property -> { Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName())); if (!fieldOptional.isPresent()) { synchronizationResult.resolveConflict(property.getName()); } }); formModelConent.setSynchronizationResult(synchronizationResult); } catch (SourceFormModelNotFoundException ex) { formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey())); } } } } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] {writer.toString()}, null)); log.warn("Error loading form " + path.toURI(), e); } resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo)); return formModelConent; }
FormEditorServiceImpl extends KieService<FormModelerContent> implements FormEditorService { @Override protected FormModelerContent constructContent(Path path, Overview overview) { FormModelerContent formModelConent = new FormModelerContent(); try { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path); FormDefinition form = findForm(kiePath); formModelConent.setDefinition(form); formModelConent.setPath(path); formModelConent.setOverview(overview); FormEditorRenderingContext context = createRenderingContext(form, path); formModelConent.setRenderingContext(context); if (Optional.ofNullable(form.getModel()).isPresent()) { FormModel formModel = form.getModel(); Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form); if (modelHandlerOptional.isPresent()) { try { FormModelHandler formModelHandler = modelHandlerOptional.get(); formModelHandler.init(formModel, path); formModelHandler.checkSourceModel(); FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel(); formModel.getProperties().forEach(property -> { Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName())); if (!fieldOptional.isPresent()) { synchronizationResult.resolveConflict(property.getName()); } }); formModelConent.setSynchronizationResult(synchronizationResult); } catch (SourceFormModelNotFoundException ex) { formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey())); } } } } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] {writer.toString()}, null)); log.warn("Error loading form " + path.toURI(), e); } resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo)); return formModelConent; } }
FormEditorServiceImpl extends KieService<FormModelerContent> implements FormEditorService { @Override protected FormModelerContent constructContent(Path path, Overview overview) { FormModelerContent formModelConent = new FormModelerContent(); try { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path); FormDefinition form = findForm(kiePath); formModelConent.setDefinition(form); formModelConent.setPath(path); formModelConent.setOverview(overview); FormEditorRenderingContext context = createRenderingContext(form, path); formModelConent.setRenderingContext(context); if (Optional.ofNullable(form.getModel()).isPresent()) { FormModel formModel = form.getModel(); Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form); if (modelHandlerOptional.isPresent()) { try { FormModelHandler formModelHandler = modelHandlerOptional.get(); formModelHandler.init(formModel, path); formModelHandler.checkSourceModel(); FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel(); formModel.getProperties().forEach(property -> { Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName())); if (!fieldOptional.isPresent()) { synchronizationResult.resolveConflict(property.getName()); } }); formModelConent.setSynchronizationResult(synchronizationResult); } catch (SourceFormModelNotFoundException ex) { formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey())); } } } } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] {writer.toString()}, null)); log.warn("Error loading form " + path.toURI(), e); } resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo)); return formModelConent; } @Inject  FormEditorServiceImpl(@Named("ioStrategy") IOService ioService,
                                 SessionInfo sessionInfo,
                                 Event<ResourceOpenedEvent> resourceOpenedEvent,
                                 FieldManager fieldManager,
                                 FormModelHandlerManager modelHandlerManager,
                                 KieModuleService moduleService,
                                 FormDefinitionSerializer formDefinitionSerializer,
                                 ModuleFormFinderService moduleFormFinderService,
                                 DeleteService deleteService,
                                 CommentedOptionFactory commentedOptionFactory,
                                 RenameService renameService,
                                 CopyService copyService); }
FormEditorServiceImpl extends KieService<FormModelerContent> implements FormEditorService { @Override protected FormModelerContent constructContent(Path path, Overview overview) { FormModelerContent formModelConent = new FormModelerContent(); try { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path); FormDefinition form = findForm(kiePath); formModelConent.setDefinition(form); formModelConent.setPath(path); formModelConent.setOverview(overview); FormEditorRenderingContext context = createRenderingContext(form, path); formModelConent.setRenderingContext(context); if (Optional.ofNullable(form.getModel()).isPresent()) { FormModel formModel = form.getModel(); Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form); if (modelHandlerOptional.isPresent()) { try { FormModelHandler formModelHandler = modelHandlerOptional.get(); formModelHandler.init(formModel, path); formModelHandler.checkSourceModel(); FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel(); formModel.getProperties().forEach(property -> { Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName())); if (!fieldOptional.isPresent()) { synchronizationResult.resolveConflict(property.getName()); } }); formModelConent.setSynchronizationResult(synchronizationResult); } catch (SourceFormModelNotFoundException ex) { formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey())); } } } } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] {writer.toString()}, null)); log.warn("Error loading form " + path.toURI(), e); } resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo)); return formModelConent; } @Inject  FormEditorServiceImpl(@Named("ioStrategy") IOService ioService,
                                 SessionInfo sessionInfo,
                                 Event<ResourceOpenedEvent> resourceOpenedEvent,
                                 FieldManager fieldManager,
                                 FormModelHandlerManager modelHandlerManager,
                                 KieModuleService moduleService,
                                 FormDefinitionSerializer formDefinitionSerializer,
                                 ModuleFormFinderService moduleFormFinderService,
                                 DeleteService deleteService,
                                 CommentedOptionFactory commentedOptionFactory,
                                 RenameService renameService,
                                 CopyService copyService); @Override FormModelerContent loadContent(Path path); @Override Path createForm(Path path,
                           String formName,
                           FormModel formModel); @Override void delete(Path path,
                       String comment); @Override Path save(Path path,
                     FormModelerContent content,
                     Metadata metadata,
                     String comment); @Override FormModelerContent rename(Path path,
                                     String newFileName,
                                     String commitMessage,
                                     boolean saveBeforeRenaming,
                                     FormModelerContent content,
                                     Metadata metadata); @Override void copy(Path path,
                     String newFileName,
                     String commitMessage,
                     boolean saveBeforeCopying,
                     FormModelerContent content,
                     Metadata metadata); }
FormEditorServiceImpl extends KieService<FormModelerContent> implements FormEditorService { @Override protected FormModelerContent constructContent(Path path, Overview overview) { FormModelerContent formModelConent = new FormModelerContent(); try { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path); FormDefinition form = findForm(kiePath); formModelConent.setDefinition(form); formModelConent.setPath(path); formModelConent.setOverview(overview); FormEditorRenderingContext context = createRenderingContext(form, path); formModelConent.setRenderingContext(context); if (Optional.ofNullable(form.getModel()).isPresent()) { FormModel formModel = form.getModel(); Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form); if (modelHandlerOptional.isPresent()) { try { FormModelHandler formModelHandler = modelHandlerOptional.get(); formModelHandler.init(formModel, path); formModelHandler.checkSourceModel(); FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel(); formModel.getProperties().forEach(property -> { Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName())); if (!fieldOptional.isPresent()) { synchronizationResult.resolveConflict(property.getName()); } }); formModelConent.setSynchronizationResult(synchronizationResult); } catch (SourceFormModelNotFoundException ex) { formModelConent.setError(new FormModelerContentError(ex.getShortKey(), ex.getShortKeyParams(), ex.getLongKey(), ex.getLongKeyParams(), ex.getModelSourceKey())); } } } } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); formModelConent.setError(new FormModelerContentError(SHORT_KEY, null, LONG_KEY, new String[] {writer.toString()}, null)); log.warn("Error loading form " + path.toURI(), e); } resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo)); return formModelConent; } @Inject  FormEditorServiceImpl(@Named("ioStrategy") IOService ioService,
                                 SessionInfo sessionInfo,
                                 Event<ResourceOpenedEvent> resourceOpenedEvent,
                                 FieldManager fieldManager,
                                 FormModelHandlerManager modelHandlerManager,
                                 KieModuleService moduleService,
                                 FormDefinitionSerializer formDefinitionSerializer,
                                 ModuleFormFinderService moduleFormFinderService,
                                 DeleteService deleteService,
                                 CommentedOptionFactory commentedOptionFactory,
                                 RenameService renameService,
                                 CopyService copyService); @Override FormModelerContent loadContent(Path path); @Override Path createForm(Path path,
                           String formName,
                           FormModel formModel); @Override void delete(Path path,
                       String comment); @Override Path save(Path path,
                     FormModelerContent content,
                     Metadata metadata,
                     String comment); @Override FormModelerContent rename(Path path,
                                     String newFileName,
                                     String commitMessage,
                                     boolean saveBeforeRenaming,
                                     FormModelerContent content,
                                     Metadata metadata); @Override void copy(Path path,
                     String newFileName,
                     String commitMessage,
                     boolean saveBeforeCopying,
                     FormModelerContent content,
                     Metadata metadata); static final String SHORT_KEY; static final String LONG_KEY; }