Search in sources :

Example 11 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method testGetContentSupplier.

@Test
public void testGetContentSupplier() {
    final GuidedDecisionTableView.Presenter presenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final Overview overview = mock(Overview.class);
    final ObservablePath currentPath = mock(ObservablePath.class);
    final ObservablePath latestPath = mock(ObservablePath.class);
    doReturn(model).when(presenter).getModel();
    doReturn(overview).when(presenter).getOverview();
    doReturn(currentPath).when(presenter).getCurrentPath();
    doReturn(latestPath).when(presenter).getLatestPath();
    doReturn(asSet(presenter)).when(this.presenter).getAvailableDecisionTables();
    final List<GuidedDecisionTableEditorContent> content = this.presenter.getContentSupplier().get();
    final GuidedDecisionTableEditorContent firstContent = content.get(0);
    assertEquals(1, content.size());
    assertEquals(model, firstContent.getModel());
    assertEquals(overview, firstContent.getOverview());
    assertEquals(currentPath, firstContent.getCurrentPath());
    assertEquals(latestPath, firstContent.getLatestPath());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 12 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedRuleEditorServiceImpl method constructContent.

@Override
protected GuidedEditorContent constructContent(Path path, Overview overview) {
    final RuleModel model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    // Get FQCN's used by model
    final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(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);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedEditorContent(model, overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedEditorContent(org.drools.workbench.screens.guided.rule.model.GuidedEditorContent) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) RuleModelDRLPersistenceImpl(org.drools.workbench.models.commons.backend.rule.RuleModelDRLPersistenceImpl) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) 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) Service(org.jboss.errai.bus.server.annotations.Service) SafeSessionInfo(org.guvnor.common.services.backend.config.SafeSessionInfo) SessionInfo(org.uberfire.rpc.SessionInfo) GuidedRuleDSLRResourceTypeDefinition(org.drools.workbench.screens.guided.rule.type.GuidedRuleDSLRResourceTypeDefinition) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) RenameService(org.uberfire.ext.editor.commons.service.RenameService) Instance(javax.enterprise.inject.Instance) GuidedRuleDRLResourceTypeDefinition(org.drools.workbench.screens.guided.rule.type.GuidedRuleDRLResourceTypeDefinition) 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) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) RuleModelIActionPersistenceExtension(org.drools.workbench.models.commons.backend.rule.RuleModelIActionPersistenceExtension) Collection(java.util.Collection) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) Set(java.util.Set) Import(org.kie.soup.project.datamodel.imports.Import) Collectors(java.util.stream.Collectors) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) GenericValidator(org.guvnor.common.services.backend.validation.GenericValidator) List(java.util.List) GuidedRuleEditorService(org.drools.workbench.screens.guided.rule.service.GuidedRuleEditorService) PostConstruct(javax.annotation.PostConstruct) IOService(org.uberfire.io.IOService) ApplicationScoped(javax.enterprise.context.ApplicationScoped) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) CopyService(org.uberfire.ext.editor.commons.service.CopyService) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedEditorContent(org.drools.workbench.screens.guided.rule.model.GuidedEditorContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel)

Example 13 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedRuleTemplateEditorServiceImplTest method checkConstructContentPopulateProjectCollectionTypes.

@Test
public void checkConstructContentPopulateProjectCollectionTypes() {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/rule.template");
    when(dataModelService.getDataModel(any())).thenReturn(oracle);
    when(oracle.getPackageGlobals()).thenReturn(new HashMap<String, String>() {

        {
            put("number", "java.lang.Number");
            put("collection", "java.util.Collection");
        }
    });
    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 GuidedTemplateEditorContent content = service.constructContent(path, overview);
    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) GuidedTemplateEditorContent(org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Overview(org.guvnor.common.services.shared.metadata.model.Overview) Test(org.junit.Test)

Example 14 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorServiceImplTest method checkConstructContent.

@Test
public void checkConstructContent() {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
    final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview);
    verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
    assertNotNull(content.getModel());
    assertEquals(overview, content.getOverview());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) Test(org.junit.Test)

Example 15 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.

protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52() {

        @Override
        public int hashCode() {
            return hashCode;
        }

        @Override
        public boolean equals(Object o) {
            return super.equals(o);
        }
    };
    final Overview overview = mock(Overview.class);
    final Metadata metadata = mock(Metadata.class);
    when(overview.getMetadata()).thenReturn(metadata);
    return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview)

Aggregations

Overview (org.guvnor.common.services.shared.metadata.model.Overview)20 Test (org.junit.Test)11 Path (org.uberfire.backend.vfs.Path)11 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)8 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)8 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)7 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)6 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)6 ObservablePath (org.uberfire.backend.vfs.ObservablePath)6 Set (java.util.Set)5 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)5 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)5 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 PostConstruct (javax.annotation.PostConstruct)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Event (javax.enterprise.event.Event)3