Search in sources :

Example 16 with GuidedDecisionTableEditorGraphModel

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

the class GuidedDecisionTableEditorGraphRenameHelper method updateGraphElementPath.

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.forEach((e) -> {
        if (e.getPathHead().equals(source)) {
            e.setPathHead(destination);
            e.setPathVersion(destination);
        }
    });
    ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]."));
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)

Example 17 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel 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() + "]."));
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedDecisionTableEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableEditorService) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Files(org.uberfire.java.nio.file.Files) Paths(org.uberfire.backend.server.util.Paths) PathFactory(org.uberfire.backend.vfs.PathFactory) ExceptionUtilities(org.guvnor.common.services.backend.exceptions.ExceptionUtilities) Overview(org.guvnor.common.services.shared.metadata.model.Overview) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Service(org.jboss.errai.bus.server.annotations.Service) SafeSessionInfo(org.guvnor.common.services.backend.config.SafeSessionInfo) SessionInfo(org.uberfire.rpc.SessionInfo) FileExtensionFilter(org.guvnor.common.services.backend.file.FileExtensionFilter) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) RenameService(org.uberfire.ext.editor.commons.service.RenameService) DeleteService(org.uberfire.ext.editor.commons.service.DeleteService) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) Set(java.util.Set) Collectors(java.util.stream.Collectors) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) GenericValidator(org.guvnor.common.services.backend.validation.GenericValidator) List(java.util.List) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) PostConstruct(javax.annotation.PostConstruct) DirectoryStream(org.uberfire.java.nio.file.DirectoryStream) ApplicationScoped(javax.enterprise.context.ApplicationScoped) GuidedDTableGraphResourceTypeDefinition(org.drools.workbench.screens.guided.dtable.type.GuidedDTableGraphResourceTypeDefinition) CopyService(org.uberfire.ext.editor.commons.service.CopyService) WorkItemsEditorService(org.drools.workbench.screens.workitems.service.WorkItemsEditorService) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Package(org.guvnor.common.services.project.model.Package) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) Path(org.uberfire.backend.vfs.Path) Event(javax.enterprise.event.Event) DataModelService(org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) GuidedDecisionTableGraphEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableGraphEditorService) XLSConversionResult(org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult) IOService(org.uberfire.io.IOService) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) GuidedDTXMLPersistence(org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence) VersionRecordService(org.uberfire.ext.editor.commons.backend.version.VersionRecordService) DecisionTableGuidedToDecisionTableXLSConverter(org.drools.workbench.screens.guided.dtable.backend.server.conversion.DecisionTableGuidedToDecisionTableXLSConverter) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)

Example 18 with GuidedDecisionTableEditorGraphModel

use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel 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("file://test/dtable-set." + dtableGraphType.getSuffix()));
    when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
    paths.add(dtGraphPath);
    when(path.toURI()).thenReturn("file://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());
    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());
}
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 19 with GuidedDecisionTableEditorGraphModel

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

the class GuidedDecisionTableGraphEditorServiceImplTest method checkLoad.

@Test
public void checkLoad() {
    final Path path = mock(Path.class);
    when(path.toURI()).thenReturn("file://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
    when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("");
    final GuidedDecisionTableEditorGraphModel model = service.load(path);
    verify(ioService, times(1)).readAllString(any(org.uberfire.java.nio.file.Path.class));
    assertNotNull(model);
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Test(org.junit.Test)

Example 20 with GuidedDecisionTableEditorGraphModel

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

the class GuidedDTGraphXMLPersistenceTest method checkUnmarshallingEmptyModel.

@Test
public void checkUnmarshallingEmptyModel() {
    final GuidedDecisionTableEditorGraphModel model = GuidedDTGraphXMLPersistence.getInstance().unmarshal(emptyModelXml);
    assertEmptyModel(model);
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Test(org.junit.Test)

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