Search in sources :

Example 1 with DMN12UnmarshallCallback

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

the class DMNMarshallerImportsService method getDRGElements.

public void getDRGElements(final String dmnXml, final ServiceCallback<List<DRGElement>> callback) {
    final DMN12UnmarshallCallback jsCallback = dmn12 -> {
        final JSITDefinitions dmnDefinitions = Js.uncheckedCast(JsUtils.getUnwrappedElement(dmn12));
        callback.onSuccess(modelToStunnerConverter.makeNodes(dmnDefinitions, new HashMap<>(), false, (a, b) -> {
        /* Nothing. */
        }).stream().map(e -> getDRGElement(e.getNode())).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
    };
    MainJs.unmarshall(dmnXml, "", jsCallback);
}
Also used : MainJs(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.MainJs) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DefinitionsConverter(org.kie.workbench.common.dmn.client.marshaller.converters.DefinitionsConverter) HashMap(java.util.HashMap) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) List(java.util.List) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) Js(jsinterop.base.Js) JsUtils(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils) JSITImport(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport) Map(java.util.Map) Optional(java.util.Optional) NodeEntriesFactory(org.kie.workbench.common.dmn.client.marshaller.unmarshall.nodes.NodeEntriesFactory) ApplicationScoped(javax.enterprise.context.ApplicationScoped) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Node(org.kie.workbench.common.stunner.core.graph.Node) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) Optional(java.util.Optional) HashMap(java.util.HashMap) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Example 2 with DMN12UnmarshallCallback

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

the class DMNMarshallerService method unmarshall.

public void unmarshall(final Metadata metadata, final String xml, final ServiceCallback<Diagram> callback) {
    setOnDiagramLoad(callback);
    setMetadata(metadata);
    try {
        final DMN12UnmarshallCallback jsCallback = dmn12 -> {
            final JSITDefinitions definitions = Js.uncheckedCast(JsUtils.getUnwrappedElement(dmn12));
            dmnUnmarshaller.unmarshall(getMetadata(), definitions).then(graph -> {
                final String fileName = getMetadata().getPath().getFileName();
                onDiagramLoad(dmnDiagramFactory.build(fileName, getMetadata(), graph));
                return promises.resolve();
            });
        };
        MainJs.unmarshall(xml, "", jsCallback);
    } catch (final Exception e) {
        GWT.log(e.getMessage(), e);
        callback.onError(new ClientRuntimeError(new DiagramParsingException(getMetadata(), xml)));
    }
}
Also used : DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) Promises(org.uberfire.client.promise.Promises) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Inject(javax.inject.Inject) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) PathFactory(org.uberfire.backend.vfs.PathFactory) Js(jsinterop.base.Js) JSIName(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JSIName) Map(java.util.Map) Observes(javax.enterprise.event.Observes) DMNShapeSet(org.kie.workbench.common.dmn.client.DMNShapeSet) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Path(org.uberfire.backend.vfs.Path) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) MainJs(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.MainJs) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) DiagramParsingException(org.kie.workbench.common.stunner.core.diagram.DiagramParsingException) JSONString(com.google.gwt.json.client.JSONString) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) DMNUnmarshaller(org.kie.workbench.common.dmn.client.marshaller.unmarshall.DMNUnmarshaller) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) DMNDiagramFactory(org.kie.workbench.common.dmn.api.factory.DMNDiagramFactory) DMN12(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.DMN12) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) JsUtils(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils) Dependent(javax.enterprise.context.Dependent) DMNGraphUtils(org.kie.workbench.common.dmn.client.marshaller.common.DMNGraphUtils) DMNMarshaller(org.kie.workbench.common.dmn.client.marshaller.marshall.DMNMarshaller) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) DRGDiagramUtils(org.kie.workbench.common.dmn.client.docks.navigator.drds.DRGDiagramUtils) QName(javax.xml.namespace.QName) JSONObject(com.google.gwt.json.client.JSONObject) DMNDiagramSelected(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramSelected) StringUtils(org.kie.workbench.common.stunner.core.util.StringUtils) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) DMN12MarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12MarshallCallback) Node(org.kie.workbench.common.stunner.core.graph.Node) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramParsingException(org.kie.workbench.common.stunner.core.diagram.DiagramParsingException) JSONString(com.google.gwt.json.client.JSONString) DiagramParsingException(org.kie.workbench.common.stunner.core.diagram.DiagramParsingException) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Example 3 with DMN12UnmarshallCallback

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

the class DMNMarshallerImportsService method getDMNDefinitions.

public void getDMNDefinitions(final String dmnXml, final ServiceCallback<JSITDefinitions> callback) {
    final DMN12UnmarshallCallback jsCallback = dmn12 -> {
        final JSITDefinitions dmnDefinitions = Js.uncheckedCast(JsUtils.getUnwrappedElement(dmn12));
        callback.onSuccess(dmnDefinitions);
    };
    MainJs.unmarshall(dmnXml, "", jsCallback);
}
Also used : MainJs(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.MainJs) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DefinitionsConverter(org.kie.workbench.common.dmn.client.marshaller.converters.DefinitionsConverter) HashMap(java.util.HashMap) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) List(java.util.List) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) Js(jsinterop.base.Js) JsUtils(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils) JSITImport(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport) Map(java.util.Map) Optional(java.util.Optional) NodeEntriesFactory(org.kie.workbench.common.dmn.client.marshaller.unmarshall.nodes.NodeEntriesFactory) ApplicationScoped(javax.enterprise.context.ApplicationScoped) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Node(org.kie.workbench.common.stunner.core.graph.Node) DMN12UnmarshallCallback(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Aggregations

HashMap (java.util.HashMap)3 Map (java.util.Map)3 Inject (javax.inject.Inject)3 Js (jsinterop.base.Js)3 MainJs (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.MainJs)3 DMN12UnmarshallCallback (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.callbacks.DMN12UnmarshallCallback)3 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)3 JsUtils (org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils)3 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)3 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)3 Node (org.kie.workbench.common.stunner.core.graph.Node)3 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)2 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)2 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)2 DefinitionsConverter (org.kie.workbench.common.dmn.client.marshaller.converters.DefinitionsConverter)2 GWT (com.google.gwt.core.client.GWT)1