GuidedDecisionTableEditorGraphModel buildModelFromEditor() { final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); for (GuidedDecisionTableView.Presenter dtPresenter : modeller.getAvailableDecisionTables()) { model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(dtPresenter.getLatestPath(), dtPresenter.getCurrentPath(), dtPresenter.getView().getX(), dtPresenter.getView().getY())); } return model; }
@Override public boolean equals(Object o) { return super.equals(o); } };
private RemoteCallback<GuidedDecisionTableEditorGraphContent> getLoadGraphContentSuccessCallback() { return (content) -> { this.content = content; this.originalGraphHash = content.getModel().hashCode(); this.concurrentUpdateSessionInfo = null; final GuidedDecisionTableEditorGraphModel model = content.getModel(); final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> modelEntries = model.getEntries(); initialiseEditorTabsWhenNoDocuments(); if (modelEntries == null || modelEntries.isEmpty()) { view.hideBusyIndicator(); return; } loadGraphLatch = new LoadGraphLatch(modelEntries.size(), getSelectDecisionTableCommand(modelEntries.iterator().next().getPathHead()), () -> { originalGraphHash = buildModelFromEditor().hashCode(); modeller.getView().getGridPanel().setFocus(true); }); modelEntries.stream().forEach(loadGraphLatch::loadDocumentGraphEntry); }; }
public Set<KProperty<?>> visit() { model.getEntries().stream().forEach(e -> addSharedReference(e.getPathHead().toURI(), PartType.PATH)); results.addAll(builder.build()); return results; } }
public String marshal( final GuidedDecisionTableEditorGraphModel content ) { if ( content == null ) { return xt.toXML( new GuidedDecisionTableEditorGraphModel() ); } try { return xt.toXML( content ); } catch ( Exception e ) { logger.error( "Unable to marshal model. Returning a XML for empty GuidedDecisionTableEditorGraphModel.", e ); } return xt.toXML( new GuidedDecisionTableEditorGraphModel() ); }
int getCurrentHashCode() { return buildModelFromEditor().hashCode(); }
private void versionEntriesPaths(final GuidedDecisionTableEditorGraphModel model) { for (GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry entry : model.getEntries()) { entry.setPathVersion(getLatestVersionPath(entry.getPathHead())); } }
public GuidedDecisionTableEditorGraphModel unmarshal( final String xml ) { if ( xml == null || xml.trim().equals( "" ) ) { return new GuidedDecisionTableEditorGraphModel(); } try { final Object o = xt.fromXML( xml ); return (GuidedDecisionTableEditorGraphModel) o; } catch ( Exception e ) { logger.error( "Unable to unmarshal content. Returning an empty GuidedDecisionTableEditorGraphModel.", e ); } return new GuidedDecisionTableEditorGraphModel(); }
int getCurrentHashCode() { return buildModelFromEditor().hashCode(); }
GuidedDecisionTableEditorGraphModel buildModelFromEditor() { final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); for (GuidedDecisionTableView.Presenter dtPresenter : modeller.getAvailableDecisionTables()) { model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(dtPresenter.getLatestPath(), dtPresenter.getCurrentPath(), dtPresenter.getView().getX(), dtPresenter.getView().getY())); } return model; }
private void assertEmptyModel( final GuidedDecisionTableEditorGraphModel model ) { assertNotNull( model ); assertNotNull( model.getEntries() ); assertEquals( 0, model.getEntries().size() ); }
@Test @SuppressWarnings("unchecked") public void checkSave() { final Path path = mock(Path.class); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); final Metadata metadata = mock(Metadata.class); final String comment = "comment"; when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); service.save(path, model, metadata, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class)); }
private RemoteCallback<GuidedDecisionTableEditorGraphContent> getLoadGraphContentSuccessCallback() { return (content) -> { this.content = content; this.originalGraphHash = content.getModel().hashCode(); this.concurrentUpdateSessionInfo = null; final GuidedDecisionTableEditorGraphModel model = content.getModel(); final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> modelEntries = model.getEntries(); initialiseEditorTabsWhenNoDocuments(); if (modelEntries == null || modelEntries.isEmpty()) { view.hideBusyIndicator(); return; } loadGraphLatch = new LoadGraphLatch(modelEntries.size(), getSelectDecisionTableCommand(modelEntries.iterator().next().getPathHead()), () -> { originalGraphHash = buildModelFromEditor().hashCode(); modeller.getView().getGridPanel().setFocus(true); }); modelEntries.stream().forEach(loadGraphLatch::loadDocumentGraphEntry); }; }
@Override public void callback(final Path path) { editorView.hideBusyIndicator(); versionRecordManager.reloadVersions(path); originalGraphHash = model.hashCode(); concurrentUpdateSessionInfo = null; notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemSavedSuccessfully())); } },
when( path.toURI() ).thenReturn( "default://test/dtable.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) ); when( dtableGraphService.load( any( Path.class ) ) ).thenReturn( model ); final GuidedDecisionTableEditorGraphModel newModel = GuidedDTGraphXMLPersistence.getInstance().unmarshal( modelXml ); assertEquals( 0, newModel.getEntries().size() );
private void assertEmptyModel( final GuidedDecisionTableEditorGraphModel model ) { assertNotNull( model ); assertNotNull( model.getEntries() ); assertEquals( 0, model.getEntries().size() ); }
@Test @SuppressWarnings("unchecked") public void checkSave() { final Path path = mock(Path.class); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); final Metadata metadata = mock(Metadata.class); final String comment = "comment"; when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); service.save(path, model, metadata, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class)); }
@Override public void callback(final Path path) { editorView.hideBusyIndicator(); versionRecordManager.reloadVersions(path); originalGraphHash = model.hashCode(); concurrentUpdateSessionInfo = null; notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemSavedSuccessfully())); } },
when( path.toURI() ).thenReturn( "default://test/dtable.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) ); when( dtableGraphService.load( any( Path.class ) ) ).thenReturn( model ); final GuidedDecisionTableEditorGraphModel newModel = GuidedDTGraphXMLPersistence.getInstance().unmarshal( modelXml ); assertEquals( 0, newModel.getEntries().size() );
private void updateGraphElementPath(final Path source, final Path destination, final Path graphPath) { final GuidedDecisionTableEditorGraphModel dtGraphModel = dtableGraphService.load(graphPath); final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> dtGraphEntries = dtGraphModel.getEntries(); dtGraphEntries.stream().filter((e) -> e.getPathHead().equals(source)).forEach((e) -> e.setPathVersion(destination)); ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("Updated Path version for [" + source.toURI() + "] to [" + destination.toURI() + "].")); }