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() ); }
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(); }
@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)); }
@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)); }
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; }
@Test public void checkCreate() { final Path context = mock(Path.class); final String fileName = "filename." + dtGraphResourceType.getSuffix(); final GuidedDecisionTableEditorGraphModel content = new GuidedDecisionTableEditorGraphModel(); final String comment = "comment"; when(context.toURI()).thenReturn("default://project/src/main/resources/mypackage"); final Path p = service.create(context, fileName, content, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(CommentedOption.class)); assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtGraphResourceType.getSuffix())); }
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; }
@Test public void checkCreate() { final Path context = mock(Path.class); final String fileName = "filename." + dtGraphResourceType.getSuffix(); final GuidedDecisionTableEditorGraphModel content = new GuidedDecisionTableEditorGraphModel(); final String comment = "comment"; when(context.toURI()).thenReturn("default://project/src/main/resources/mypackage"); final Path p = service.create(context, fileName, content, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(CommentedOption.class)); assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtGraphResourceType.getSuffix())); }
when( path.toURI() ).thenReturn( "default://test/dtable.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) );
when( path.toURI() ).thenReturn( "default://test/dtable.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) );
@Override public void create( final Package pkg, final String baseFileName, final NewResourcePresenter presenter ) { busyIndicatorView.showBusyIndicator( CommonConstants.INSTANCE.Saving() ); graphService.call( getSuccessCallback( presenter ), new HasBusyIndicatorDefaultErrorCallback( busyIndicatorView ) ).create( pkg.getPackageMainResourcesPath(), buildFileName( baseFileName, resourceType ), new GuidedDecisionTableEditorGraphModel(), "" ); }
@Override public void create( final Package pkg, final String baseFileName, final NewResourcePresenter presenter ) { busyIndicatorView.showBusyIndicator( CommonConstants.INSTANCE.Saving() ); graphService.call( getSuccessCallback( presenter ), new HasBusyIndicatorDefaultErrorCallback( busyIndicatorView ) ).create( pkg.getPackageMainResourcesPath(), buildFileName( baseFileName, resourceType ), new GuidedDecisionTableEditorGraphModel(), "" ); }
when( destination.toURI() ).thenReturn( "default://test/dtable-renamed.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( source, source ) );
when( destination.toURI() ).thenReturn( "default://test/dtable-renamed.gdst" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( source, source ) );
@Test public void checkMarshallingModelWithoutEntryPosition() { final Path path = PathFactory.newPath( "path", "default://path" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) ); final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal( model ); assertNotNull( xml ); assertEqualsIgnoreWhitespace( "<graph>\n" + " <entries>\n" + " <entry>\n" + " <pathHead class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\">\n" + " <uri>default://path</uri>\n" + " <fileName>path</fileName>\n" + " <attributes/>\n" + " <hasVersionSupport>false</hasVersionSupport>\n" + " </pathHead>\n" + " <pathVersion class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\" reference=\"../pathHead\"/>\n" + " </entry>\n" + " </entries>\n" + "</graph>", xml ); }
@Test public void checkMarshallingModelWithoutEntryPosition() { final Path path = PathFactory.newPath( "path", "default://path" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path ) ); final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal( model ); assertNotNull( xml ); assertEqualsIgnoreWhitespace( "<graph>\n" + " <entries>\n" + " <entry>\n" + " <pathHead class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\">\n" + " <uri>default://path</uri>\n" + " <fileName>path</fileName>\n" + " <attributes/>\n" + " <hasVersionSupport>false</hasVersionSupport>\n" + " </pathHead>\n" + " <pathVersion class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\" reference=\"../pathHead\"/>\n" + " </entry>\n" + " </entries>\n" + "</graph>", xml ); }
@Test public void checkMarshallingModelWithEntryPosition() { final Path path = PathFactory.newPath( "path", "default://path" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path, 100.0, 200.0 ) ); final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal( model ); assertNotNull( xml ); assertEqualsIgnoreWhitespace( "<graph>\n" + " <entries>\n" + " <entry>\n" + " <pathHead class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\">\n" + " <uri>default://path</uri>\n" + " <fileName>path</fileName>\n" + " <attributes/>\n" + " <hasVersionSupport>false</hasVersionSupport>\n" + " </pathHead>\n" + " <pathVersion class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\" reference=\"../pathHead\"/>\n" + " <x>100.0</x>\n" + " <y>200.0</y>\n" + " </entry>\n" + " </entries>\n" + "</graph>", xml ); }
@Test public void checkMarshallingModelWithEntryPosition() { final Path path = PathFactory.newPath( "path", "default://path" ); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add( new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry( path, path, 100.0, 200.0 ) ); final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal( model ); assertNotNull( xml ); assertEqualsIgnoreWhitespace( "<graph>\n" + " <entries>\n" + " <entry>\n" + " <pathHead class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\">\n" + " <uri>default://path</uri>\n" + " <fileName>path</fileName>\n" + " <attributes/>\n" + " <hasVersionSupport>false</hasVersionSupport>\n" + " </pathHead>\n" + " <pathVersion class=\"org.uberfire.backend.vfs.PathFactory$PathImpl\" reference=\"../pathHead\"/>\n" + " <x>100.0</x>\n" + " <y>200.0</y>\n" + " </entry>\n" + " </entries>\n" + "</graph>", xml ); }
final org.uberfire.backend.vfs.Path vfsDtable2Path = Paths.convert(dtable2Path); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable1Path, vfsDtable1Path));
final org.uberfire.backend.vfs.Path vfsDtable2Path = Paths.convert(dtable2Path); final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel(); model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable1Path, vfsDtable1Path));