Search in sources :

Example 21 with JSITDefinitions

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsClientHelper method getCallback.

private ServiceCallback<Object> getCallback(final String filePath, final Map<String, JSITDefinitions> otherDefinitions, final Promise.PromiseExecutorCallbackFn.ResolveCallbackFn<Void> success) {
    return new ServiceCallback<Object>() {

        @Override
        public void onSuccess(final Object item) {
            final JSITDefinitions def = Js.uncheckedCast(item);
            otherDefinitions.put(filePath, def);
            success.onInvoke(promises.resolve());
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            LOGGER.log(Level.SEVERE, error.getMessage());
        }
    };
}
Also used : ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Example 22 with JSITDefinitions

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions 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 23 with JSITDefinitions

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsClientHelper method getImportedItemDefinitions.

@Override
public List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions) {
    final List<JSITItemDefinition> itemDefinitions = new ArrayList<>();
    for (final Map.Entry<JSITImport, JSITDefinitions> entry : importDefinitions.entrySet()) {
        final JSITImport anImport = Js.uncheckedCast(entry.getKey());
        final JSITDefinitions definitions = Js.uncheckedCast(entry.getValue());
        final List<JSITItemDefinition> items = getItemDefinitionsWithNamespace(definitions, anImport);
        itemDefinitions.addAll(items);
    }
    return itemDefinitions;
}
Also used : ArrayList(java.util.ArrayList) JSITImport(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Example 24 with JSITDefinitions

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions in project kie-wb-common by kiegroup.

the class DMNMarshaller method getExistingNode.

Optional<JSITDRGElement> getExistingNode(final JSITDefinitions definitions, final JSITDRGElement node) {
    final JSITDRGElement[] existingDRGElement = new JSITDRGElement[1];
    forEach(definitions.getDrgElement(), drgElement -> {
        if (Objects.equals(drgElement.getId(), node.getId())) {
            existingDRGElement[0] = drgElement;
        }
    });
    final JSITDRGElement value = Js.uncheckedCast(existingDRGElement[0]);
    return Optional.ofNullable(value);
}
Also used : JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement)

Example 25 with JSITDefinitions

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions in project kie-wb-common by kiegroup.

the class DMNMarshaller method addNodeToDefinitions.

void addNodeToDefinitions(final JSITDRGElement node, final JSITDefinitions definitions) {
    final JSINodeLocalPartName localPart = getLocalPart(node);
    final JSITDRGElement toAdd = getWrappedJSITDRGElement(node, localPart);
    definitions.addDrgElement(toAdd);
}
Also used : JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement)

Aggregations

JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)18 HashMap (java.util.HashMap)14 Map (java.util.Map)13 ArrayList (java.util.ArrayList)12 JSITImport (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport)12 JSITDRGElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement)10 Inject (javax.inject.Inject)8 Js (jsinterop.base.Js)8 JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)8 Objects (java.util.Objects)7 Optional (java.util.Optional)7 QName (javax.xml.namespace.QName)7 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)7 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)7 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)7 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)6 MainJs (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.MainJs)6