Search in sources :

Example 6 with ResourceOpenedEvent

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

the class DRLTextEditorServiceImpl method constructContent.

@Override
protected DrlModelContent constructContent(Path path, Overview overview) {
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final String[] fullyQualifiedClassNames = DataModelOracleUtilities.getFactTypes(oracle);
    final List<DSLSentence> dslConditions = oracle.getExtensions(DSLConditionSentence.INSTANCE);
    final List<DSLSentence> dslActions = oracle.getExtensions(DSLActionSentence.INSTANCE);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new DrlModelContent(load(path), overview, Arrays.asList(fullyQualifiedClassNames), dslConditions, dslActions);
}
Also used : DrlModelContent(org.drools.workbench.screens.drltext.model.DrlModelContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) DSLSentence(org.drools.workbench.models.datamodel.rule.DSLSentence)

Example 7 with ResourceOpenedEvent

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

the class DSLTextEditorServiceImpl method load.

@Override
public String load(final Path path) {
    try {
        final String content = ioService.readAllString(Paths.convert(path));
        // Signal opening to interested parties
        resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
        return content;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) DSLMappingParseException(org.drools.compiler.lang.dsl.DSLMappingParseException) IOException(java.io.IOException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 8 with ResourceOpenedEvent

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

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

the class GuidedScoreCardEditorServiceImpl method constructContent.

@Override
protected ScoreCardModelContent constructContent(Path path, Overview overview) {
    final ScoreCardModel model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    final GuidedScoreCardModelVisitor visitor = new GuidedScoreCardModelVisitor(model);
    DataModelOracleUtilities.populateDataModel(oracle, dataModel, visitor.getConsumedModelClasses());
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new ScoreCardModelContent(model, overview, dataModel);
}
Also used : ScoreCardModelContent(org.drools.workbench.screens.guided.scorecard.model.ScoreCardModelContent) ScoreCardModel(org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Example 10 with ResourceOpenedEvent

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

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