Search in sources :

Example 1 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImpl method constructContent.

@Override
protected TestScenarioModelContent constructContent(Path path, Overview overview) {
    final Scenario scenario = load(path);
    final String packageName = moduleService.resolvePackage(path).getPackageName();
    final PackageDataModelOracle dataModelOracle = getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    final Set<String> usedFullyQualifiedClassNames = getUsedFullyQualifiedClassNames(scenario, dataModelOracle);
    DataModelOracleUtilities.populateDataModel(dataModelOracle, dataModel, usedFullyQualifiedClassNames);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new TestScenarioModelContent(scenario, overview, packageName, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) TestScenarioModelContent(org.drools.workbench.screens.testscenario.model.TestScenarioModelContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Example 2 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.

the class WorkItemsEditorServiceImpl method constructContent.

@Override
protected WorkItemsModelContent constructContent(Path path, Overview overview) {
    final String definition = load(path);
    final List<String> workItemImages = loadWorkItemImages(path);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new WorkItemsModelContent(definition, overview, workItemImages);
}
Also used : WorkItemsModelContent(org.drools.workbench.screens.workitems.model.WorkItemsModelContent) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Example 3 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImpl method constructContent.

@Override
protected GuidedDecisionTableEditorContent constructContent(Path path, Overview overview) {
    final GuidedDecisionTable52 model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    // Get FQCN's used by model
    final GuidedDecisionTableModelVisitor visitor = new GuidedDecisionTableModelVisitor(model);
    final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
    // Get FQCN's used by Globals
    consumedFQCNs.addAll(oracle.getPackageGlobals().values());
    // Get FQCN's of collections defined in project settings
    // they can be used in From Collect expressions
    consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
    DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
    final Set<PortableWorkDefinition> workItemDefinitions = workItemsService.loadWorkItemDefinitions(path);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dataModel);
}
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) WorkItemsEditorService(org.drools.workbench.screens.workitems.service.WorkItemsEditorService) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Files(org.uberfire.java.nio.file.Files) Package(org.guvnor.common.services.project.model.Package) Paths(org.uberfire.backend.server.util.Paths) HashSet(java.util.HashSet) Inject(javax.inject.Inject) PathFactory(org.uberfire.backend.vfs.PathFactory) ExceptionUtilities(org.guvnor.common.services.backend.exceptions.ExceptionUtilities) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) 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) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) RenameService(org.uberfire.ext.editor.commons.service.RenameService) Path(org.uberfire.backend.vfs.Path) DeleteService(org.uberfire.ext.editor.commons.service.DeleteService) Event(javax.enterprise.event.Event) DataModelService(org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) Set(java.util.Set) Collectors(java.util.stream.Collectors) GuidedDecisionTableGraphEditorService(org.drools.workbench.screens.guided.dtable.service.GuidedDecisionTableGraphEditorService) 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) IOService(org.uberfire.io.IOService) ApplicationScoped(javax.enterprise.context.ApplicationScoped) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) GuidedDTXMLPersistence(org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence) GuidedDTableGraphResourceTypeDefinition(org.drools.workbench.screens.guided.dtable.type.GuidedDTableGraphResourceTypeDefinition) VersionRecordService(org.uberfire.ext.editor.commons.backend.version.VersionRecordService) CopyService(org.uberfire.ext.editor.commons.service.CopyService) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Example 4 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method checkConstructContent.

@Test
public void checkConstructContent() {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
    when(oracle.getModuleCollectionTypes()).thenReturn(new HashMap<String, Boolean>() {

        {
            put("java.util.List", true);
            put("java.util.Set", true);
            put("java.util.Collection", true);
            put("java.util.UnknownCollection", false);
        }
    });
    final Set<PortableWorkDefinition> workItemDefinitions = new HashSet<>();
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
    when(dataModelService.getDataModel(eq(path))).thenReturn(oracle);
    when(workItemsService.loadWorkItemDefinitions(eq(path))).thenReturn(workItemDefinitions);
    final GuidedDecisionTableEditorContent content = service.constructContent(path, overview);
    verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
    assertNotNull(content.getModel());
    assertNotNull(content.getDataModel());
    assertNotNull(content.getWorkItemDefinitions());
    assertEquals(overview, content.getOverview());
    assertEquals(3, content.getDataModel().getCollectionTypes().size());
    assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection"));
    assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List"));
    assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set"));
}
Also used : Path(org.uberfire.backend.vfs.Path) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.

the class GlobalsEditorServiceImpl method constructContent.

@Override
protected GlobalsEditorContent constructContent(Path path, Overview overview) {
    // De-serialize model
    final GlobalsModel model = load(path);
    final ModuleDataModelOracle oracle = dataModelService.getModuleDataModel(path);
    final String[] fullyQualifiedClassNames = new String[oracle.getModuleModelFields().size()];
    oracle.getModuleModelFields().keySet().toArray(fullyQualifiedClassNames);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GlobalsEditorContent(model, overview, Arrays.asList(fullyQualifiedClassNames));
}
Also used : GlobalsEditorContent(org.drools.workbench.screens.globals.model.GlobalsEditorContent) GlobalsModel(org.drools.workbench.screens.globals.model.GlobalsModel) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Aggregations

ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)17 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)8 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)6 Overview (org.guvnor.common.services.shared.metadata.model.Overview)5 Path (org.uberfire.backend.vfs.Path)5 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)5 IOException (java.io.IOException)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 PostConstruct (javax.annotation.PostConstruct)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Event (javax.enterprise.event.Event)3 Inject (javax.inject.Inject)3 Named (javax.inject.Named)3 SafeSessionInfo (org.guvnor.common.services.backend.config.SafeSessionInfo)3 ExceptionUtilities (org.guvnor.common.services.backend.exceptions.ExceptionUtilities)3 CommentedOptionFactory (org.guvnor.common.services.backend.util.CommentedOptionFactory)3 GenericValidator (org.guvnor.common.services.backend.validation.GenericValidator)3 Package (org.guvnor.common.services.project.model.Package)3