Search in sources :

Example 11 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorServiceImplTest method checkSave.

@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("file://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());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Map(java.util.Map) Test(org.junit.Test)

Example 12 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorGraphRenameHelperTest method checkUpdateReferencesWithDecisionTableGraphs.

@Test
public void checkUpdateReferencesWithDecisionTableGraphs() 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("file://test/dtable-set." + dtableGraphType.getSuffix()));
    when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
    paths.add(dtGraphPath);
    when(source.toURI()).thenReturn("file://test/dtable.gdst");
    when(destination.toURI()).thenReturn("file://test/dtable-renamed.gdst");
    final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
    model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(source, source));
    when(dtableGraphService.load(any(Path.class))).thenReturn(model);
    helper.postProcess(source, destination);
    verify(helper, times(1)).updateGraphElementPath(any(Path.class), 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());
    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(1, newModel.getEntries().size());
    assertEquals(destination.toURI(), newModel.getEntries().iterator().next().getPathHead().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) URI(java.net.URI) Test(org.junit.Test)

Example 13 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.

the class IndexGuidedDecisionTableGraphFileTest method testIndexGuidedDecisionTableGraphEntries.

@Test
public void testIndexGuidedDecisionTableGraphEntries() throws IOException, InterruptedException {
    // Add test files
    final Path path = basePath.resolve("dtable-graph1.gdst-set");
    final Path dtable1Path = basePath.resolve("dtable1.gdst");
    final Path dtable2Path = basePath.resolve("dtable2.gdst");
    final org.uberfire.backend.vfs.Path vfsDtable1Path = Paths.convert(dtable1Path);
    final org.uberfire.backend.vfs.Path vfsDtable2Path = Paths.convert(dtable2Path);
    final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
    model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable1Path, vfsDtable1Path));
    model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable2Path, vfsDtable2Path));
    final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal(model);
    ioService().write(path, xml);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm(vfsDtable1Path.toURI(), PartType.PATH)).build();
        searchFor(index, query, 1, path);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm(vfsDtable2Path.toURI(), PartType.PATH)).build();
        searchFor(index, query, 1, path);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 14 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorGraphDeleteHelper method updateGraphReferences.

void updateGraphReferences(final Path path, final Path graphPath) {
    final GuidedDecisionTableEditorGraphModel dtGraphModel = dtableGraphService.load(graphPath);
    final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> dtGraphEntries = dtGraphModel.getEntries();
    dtGraphEntries.removeIf((e) -> e.getPathHead().equals(path));
    ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("File [" + path.toURI() + "] deleted."));
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)

Example 15 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorServiceImpl method constructContent.

@Override
protected GuidedDecisionTableEditorGraphContent constructContent(final Path path, final Overview overview) {
    final GuidedDecisionTableEditorGraphModel model = load(path);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedDecisionTableEditorGraphContent(model, overview);
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Aggregations

GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)22 Test (org.junit.Test)16 Path (org.uberfire.backend.vfs.Path)9 URI (java.net.URI)3 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 Map (java.util.Map)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)2 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)2 FileExtensionFilter (org.guvnor.common.services.backend.file.FileExtensionFilter)2 Overview (org.guvnor.common.services.shared.metadata.model.Overview)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1