Search in sources :

Example 66 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsClientHelper method loadNodes.

private Promise<List<DMNIncludedNode>> loadNodes(final Map<String, JSITDefinitions> existingDefinitions, final DMNIncludedModel model, final List<DMNIncludedNode> result) {
    String filePath = "";
    for (final Map.Entry<String, JSITDefinitions> entry : existingDefinitions.entrySet()) {
        filePath = entry.getKey();
        final JSITDefinitions definitions = Js.uncheckedCast(entry.getValue());
        if (Objects.equals(model.getNamespace(), definitions.getNamespace())) {
            break;
        }
    }
    if (isEmpty(filePath)) {
        return promises.resolve();
    }
    final String path = filePath;
    return dmnImportsContentService.loadFile(path).then(content -> promises.create((success, fail) -> dmnImportsService.getDRGElements(content, new ServiceCallback<List<DRGElement>>() {

        @Override
        public void onSuccess(final List<DRGElement> drgElements) {
            final List<DMNIncludedNode> nodes = drgElements.stream().map(node -> includedModelFactory.makeDMNIncludeNode(path, model, node)).collect(Collectors.toList());
            result.addAll(nodes);
            success.onInvoke(nodes);
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            LOGGER.log(Level.SEVERE, error.getMessage());
            fail.onInvoke(error);
        }
    })));
}
Also used : JSITInvocable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocable) Arrays(java.util.Arrays) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) JSITDMNElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElement) Promises(org.uberfire.client.promise.Promises) JSITInputData(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputData) BuiltInTypeUtils.isBuiltInType(org.kie.workbench.common.dmn.api.editors.types.BuiltInTypeUtils.isBuiltInType) HashMap(java.util.HashMap) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) Promise(elemental2.promise.Promise) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Inject(javax.inject.Inject) Js(jsinterop.base.Js) Map(java.util.Map) JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) DMNMarshallerImportsHelper(org.kie.workbench.common.dmn.api.marshalling.DMNMarshallerImportsHelper) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition) StringUtils.isEmpty(org.kie.workbench.common.stunner.core.util.StringUtils.isEmpty) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) FileUtils(org.kie.workbench.common.stunner.core.util.FileUtils) List(java.util.List) ImportedItemDefinitionPropertyConverter(org.kie.workbench.common.dmn.client.marshaller.converters.ImportedItemDefinitionPropertyConverter) JSITImport(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport) DMNImportTypes(org.kie.workbench.common.dmn.api.editors.included.DMNImportTypes) ImportedItemDefinitionPropertyConverter.withNamespace(org.kie.workbench.common.dmn.client.marshaller.converters.ImportedItemDefinitionPropertyConverter.withNamespace) Optional(java.util.Optional) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) IncludedModel(org.kie.workbench.common.dmn.api.editors.included.IncludedModel) QName(javax.xml.namespace.QName) Comparator(java.util.Comparator) Collections(java.util.Collections) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 67 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class PMMLIncludedModelHandlerTest method setupDecisionWithTopLevelFunction.

private List<Decision> setupDecisionWithTopLevelFunction() {
    final List<DRGElement> drgElements = new ArrayList<>();
    final Decision decision1 = new Decision();
    decision1.setExpression(new LiteralExpression());
    final Decision decision2 = new Decision();
    decision2.setExpression(makeTopLevelPMMLFunctionDefinition(DOCUMENT_NAME_ORIGINAL, MODEL_NAME));
    final Decision decision3 = new Decision();
    decision3.setExpression(makeTopLevelPMMLFunctionDefinition(UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL));
    decision1.getId().setValue(NODE1_UUID);
    decision2.getId().setValue(NODE2_UUID);
    decision3.getId().setValue(NODE3_UUID);
    drgElements.add(decision1);
    drgElements.add(decision2);
    drgElements.add(decision3);
    when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
    return Arrays.asList(decision1, decision2, decision3);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ArrayList(java.util.ArrayList) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 68 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class PMMLIncludedModelHandlerTest method setupDecisionWithNestedFunction.

private List<Decision> setupDecisionWithNestedFunction() {
    final List<DRGElement> drgElements = new ArrayList<>();
    final Decision decision1 = new Decision();
    decision1.setExpression(makeNestedLiteralExpression());
    final Decision decision2 = new Decision();
    decision2.setExpression(makeNestedPMMLFunctionDefinition(DOCUMENT_NAME_ORIGINAL, MODEL_NAME));
    final Decision decision3 = new Decision();
    decision3.setExpression(makeNestedPMMLFunctionDefinition(UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL));
    drgElements.add(decision1);
    drgElements.add(decision2);
    drgElements.add(decision3);
    when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
    return Arrays.asList(decision1, decision2, decision3);
}
Also used : ArrayList(java.util.ArrayList) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 69 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class PMMLIncludedModelHandlerTest method setupBusinessKnowledgeModelWithNestedFunction.

private List<BusinessKnowledgeModel> setupBusinessKnowledgeModelWithNestedFunction() {
    final List<DRGElement> drgElements = new ArrayList<>();
    final BusinessKnowledgeModel bkm1 = new BusinessKnowledgeModel();
    final FunctionDefinition bkm1Function = new FunctionDefinition();
    bkm1Function.setKind(FunctionDefinition.Kind.FEEL);
    bkm1Function.setExpression(makeNestedLiteralExpression());
    bkm1.setEncapsulatedLogic(bkm1Function);
    final BusinessKnowledgeModel bkm2 = new BusinessKnowledgeModel();
    final FunctionDefinition bkm2Function = new FunctionDefinition();
    bkm2Function.setKind(FunctionDefinition.Kind.FEEL);
    bkm2Function.setExpression(makeNestedPMMLFunctionDefinition(DOCUMENT_NAME_ORIGINAL, MODEL_NAME));
    bkm2.setEncapsulatedLogic(bkm2Function);
    final BusinessKnowledgeModel bkm3 = new BusinessKnowledgeModel();
    final FunctionDefinition bkm3Function = new FunctionDefinition();
    bkm3Function.setKind(FunctionDefinition.Kind.FEEL);
    bkm3Function.setExpression(makeNestedPMMLFunctionDefinition(UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL));
    bkm3.setEncapsulatedLogic(bkm3Function);
    drgElements.add(bkm1);
    drgElements.add(bkm2);
    drgElements.add(bkm3);
    when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
    return Arrays.asList(bkm1, bkm2, bkm3);
}
Also used : BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) ArrayList(java.util.ArrayList) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 70 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class PMMLIncludedModelHandlerTest method setupBusinessKnowledgeModelWithTopLevelFunction.

private List<BusinessKnowledgeModel> setupBusinessKnowledgeModelWithTopLevelFunction() {
    final List<DRGElement> drgElements = new ArrayList<>();
    final BusinessKnowledgeModel bkm1 = new BusinessKnowledgeModel();
    final FunctionDefinition bkm1Function = new FunctionDefinition();
    bkm1Function.setKind(FunctionDefinition.Kind.FEEL);
    bkm1Function.setExpression(new LiteralExpression());
    bkm1.setEncapsulatedLogic(bkm1Function);
    final BusinessKnowledgeModel bkm2 = new BusinessKnowledgeModel();
    bkm2.setEncapsulatedLogic(makeTopLevelPMMLFunctionDefinition(DOCUMENT_NAME_ORIGINAL, MODEL_NAME));
    final BusinessKnowledgeModel bkm3 = new BusinessKnowledgeModel();
    bkm3.setEncapsulatedLogic(makeTopLevelPMMLFunctionDefinition(UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL));
    bkm1.getId().setValue(NODE1_UUID);
    bkm2.getId().setValue(NODE2_UUID);
    bkm3.getId().setValue(NODE3_UUID);
    drgElements.add(bkm1);
    drgElements.add(bkm2);
    drgElements.add(bkm3);
    when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
    return Arrays.asList(bkm1, bkm2, bkm3);
}
Also used : BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ArrayList(java.util.ArrayList) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Aggregations

DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)72 Test (org.junit.Test)45 Node (org.kie.workbench.common.stunner.core.graph.Node)27 ArrayList (java.util.ArrayList)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)17 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 List (java.util.List)15 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)15 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)15 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)15 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)10 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 Import (org.kie.workbench.common.dmn.api.definition.model.Import)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)8 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 Optional (java.util.Optional)6