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());
}
};
}
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);
}
})));
}
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;
}
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);
}
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);
}
Aggregations