Search in sources :

Example 1 with GuidedRuleModelVisitor

use of org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor in project drools-wb by kiegroup.

the class GuidedDecisionTableModelVisitor method getActionFactTypesFromRuleModel.

private Set<String> getActionFactTypesFromRuleModel(final List<IAction> definition) {
    final RuleModel rm = new RuleModel();
    rm.setPackageName(model.getPackageName());
    rm.setImports(model.getImports());
    for (IAction a : definition) {
        rm.addRhsItem(a);
    }
    final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(rm);
    return visitor.getConsumedModelClasses();
}
Also used : IAction(org.drools.workbench.models.datamodel.rule.IAction) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel)

Example 2 with GuidedRuleModelVisitor

use of org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor in project drools-wb by kiegroup.

the class GuidedDecisionTableModelVisitor method getConditionFactTypesFromRuleModel.

private Set<String> getConditionFactTypesFromRuleModel(final List<IPattern> definition) {
    final RuleModel rm = new RuleModel();
    rm.setPackageName(model.getPackageName());
    rm.setImports(model.getImports());
    for (IPattern p : definition) {
        rm.addLhsItem(p);
    }
    final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(rm);
    return visitor.getConsumedModelClasses();
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel)

Example 3 with GuidedRuleModelVisitor

use of org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor 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)

Aggregations

GuidedRuleModelVisitor (org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor)3 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 IAction (org.drools.workbench.models.datamodel.rule.IAction)1 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)1 RuleTemplateModelXMLPersistenceImpl (org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl)1 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)1 GuidedTemplateEditorContent (org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent)1 GuidedRuleTemplateEditorService (org.drools.workbench.screens.guided.template.service.GuidedRuleTemplateEditorService)1 GuidedRuleTemplateResourceTypeDefinition (org.drools.workbench.screens.guided.template.type.GuidedRuleTemplateResourceTypeDefinition)1 SafeSessionInfo (org.guvnor.common.services.backend.config.SafeSessionInfo)1 ExceptionUtilities (org.guvnor.common.services.backend.exceptions.ExceptionUtilities)1