use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method updateGraphElementPath.
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() + "]."));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final GuidedDecisionTable52 content, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, GuidedDTXMLPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImpl method listDecisionTablesInPackage.
@Override
public List<Path> listDecisionTablesInPackage(final Path path) {
try {
final Package pkg = moduleService.resolvePackage(path);
if (pkg == null) {
return Collections.emptyList();
}
final Path pkgPath = pkg.getPackageMainResourcesPath();
final org.uberfire.java.nio.file.Path nioPkgPath = Paths.convert(pkgPath);
final List<Path> paths = findDecisionTables(nioPkgPath);
return paths;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDTGraphXMLPersistenceTest method checkMarshallingModelWithoutEntryPosition.
@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);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorGraphDeleteHelperTest method checkRemoveReferencesWithDecisionTableGraphs.
@Test
public void checkRemoveReferencesWithDecisionTableGraphs() throws URISyntaxException {
final org.uberfire.java.nio.file.Path dtGraphPath = mock(org.uberfire.java.nio.file.Path.class);
when(dtGraphPath.getFileName()).thenReturn(mock(org.uberfire.java.nio.file.Path.class));
when(dtGraphPath.toUri()).thenReturn(new URI("default://test/dtable-set." + dtableGraphType.getSuffix()));
when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
paths.add(dtGraphPath);
when(path.getFileName()).thenReturn("dtable.gdst");
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);
helper.postProcess(path);
verify(helper, times(1)).updateGraphReferences(any(Path.class), any(Path.class));
final ArgumentCaptor<org.uberfire.java.nio.file.Path> dtGraphPathCaptor = ArgumentCaptor.forClass(org.uberfire.java.nio.file.Path.class);
final ArgumentCaptor<String> modelXmlCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(dtGraphPathCaptor.capture(), modelXmlCaptor.capture(), any(CommentedOption.class));
final org.uberfire.java.nio.file.Path dtGraphPath2 = dtGraphPathCaptor.getValue();
assertEquals(dtGraphPath.toUri().getPath(), dtGraphPath2.toUri().getPath());
final String modelXml = modelXmlCaptor.getValue();
final GuidedDecisionTableEditorGraphModel newModel = GuidedDTGraphXMLPersistence.getInstance().unmarshal(modelXml);
assertEquals(0, newModel.getEntries().size());
}
Aggregations