Search in sources :

Example 11 with ResourceOpenedEvent

use of org.uberfire.workbench.events.ResourceOpenedEvent 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 12 with ResourceOpenedEvent

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

the class GuidedDecisionTreeEditorServiceImpl method constructContent.

@Override
protected GuidedDecisionTreeEditorContent constructContent(Path path, Overview overview) {
    final GuidedDecisionTree model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    // Get FQCN's used by model
    final GuidedDecisionTreeModelVisitor visitor = new GuidedDecisionTreeModelVisitor(model);
    final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
    // Get FQCN's used by Globals
    consumedFQCNs.addAll(oracle.getPackageGlobals().values());
    DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedDecisionTreeEditorContent(model, overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) GuidedDecisionTreeEditorContent(org.drools.workbench.screens.guided.dtree.model.GuidedDecisionTreeEditorContent)

Example 13 with ResourceOpenedEvent

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

the class GuidedRuleTemplateEditorServiceImpl method constructContent.

@Override
protected GuidedTemplateEditorContent constructContent(Path path, Overview overview) {
    final TemplateModel 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 GuidedTemplateEditorContent(model, overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Level(org.guvnor.common.services.shared.message.Level) 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) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) GuidedRuleTemplateResourceTypeDefinition(org.drools.workbench.screens.guided.template.type.GuidedRuleTemplateResourceTypeDefinition) 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) GuidedRuleTemplateEditorService(org.drools.workbench.screens.guided.template.service.GuidedRuleTemplateEditorService) 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) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) 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) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) Set(java.util.Set) Collectors(java.util.stream.Collectors) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) RuleTemplateModelXMLPersistenceImpl(org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl) GenericValidator(org.guvnor.common.services.backend.validation.GenericValidator) List(java.util.List) GuidedTemplateEditorContent(org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) 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) GuidedTemplateEditorContent(org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Example 14 with ResourceOpenedEvent

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

the class ScoreCardXLSServiceImpl method load.

@Override
public InputStream load(final Path path, final String sessionId) {
    try {
        final InputStream inputStream = ioService.newInputStream(Paths.convert(path), StandardOpenOption.READ);
        // Signal opening to interested parties
        resourceOpenedEvent.fire(new ResourceOpenedEvent(path, getSessionInfo(sessionId)));
        return inputStream;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : InputStream(java.io.InputStream) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) IOException(java.io.IOException)

Example 15 with ResourceOpenedEvent

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

the class DecisionTableXLSServiceImpl method load.

@Override
public InputStream load(final Path path, final String sessionId) {
    try {
        final InputStream inputStream = ioService.newInputStream(Paths.convert(path), StandardOpenOption.READ);
        // Signal opening to interested parties
        resourceOpenedEvent.fire(new ResourceOpenedEvent(path, getSessionInfo(sessionId)));
        return inputStream;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) IOException(java.io.IOException) DecisionTableParseException(org.drools.template.parser.DecisionTableParseException)

Aggregations

ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)15 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 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 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3