use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITKnowledgeSource in project kie-wb-common by kiegroup.
the class KnowledgeSourceConverter method dmnFromNode.
@Override
@SuppressWarnings("unchecked")
public JSITKnowledgeSource dmnFromNode(final Node<View<KnowledgeSource>, ?> node, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
final KnowledgeSource source = (KnowledgeSource) DefinitionUtils.getElementDefinition(node);
final JSITKnowledgeSource result = new JSITKnowledgeSource();
result.setId(source.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
description.ifPresent(result::setDescription);
result.setName(source.getName().getValue());
result.setType(source.getType().getValue());
result.setLocationURI(source.getLocationURI().getValue());
result.setAuthorityRequirement(new ArrayList<>());
DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, result);
// DMN spec table 2: Requirements connection rules
final List<Edge<?, ?>> inEdges = (List<Edge<?, ?>>) node.getInEdges();
for (Edge<?, ?> e : inEdges) {
final Node<?, ?> sourceNode = e.getSourceNode();
if (sourceNode.getContent() instanceof View<?>) {
final View<?> view = (View<?>) sourceNode.getContent();
if (view.getDefinition() instanceof DRGElement) {
final DRGElement drgElement = (DRGElement) view.getDefinition();
if (drgElement instanceof Decision) {
final JSITAuthorityRequirement iReq = new JSITAuthorityRequirement();
iReq.setId(getRawId(e.getUUID()));
final JSITDMNElementReference ri = new JSITDMNElementReference();
ri.setHref(getHref(drgElement));
iReq.setRequiredDecision(ri);
result.addAuthorityRequirement(iReq);
} else if (drgElement instanceof KnowledgeSource) {
final JSITAuthorityRequirement iReq = new JSITAuthorityRequirement();
iReq.setId(getRawId(e.getUUID()));
final JSITDMNElementReference ri = new JSITDMNElementReference();
ri.setHref(getHref(drgElement));
iReq.setRequiredAuthority(ri);
result.addAuthorityRequirement(iReq);
} else if (drgElement instanceof InputData) {
final JSITAuthorityRequirement iReq = new JSITAuthorityRequirement();
iReq.setId(getRawId(e.getUUID()));
final JSITDMNElementReference ri = new JSITDMNElementReference();
ri.setHref(getHref(drgElement));
iReq.setRequiredInput(ri);
result.addAuthorityRequirement(iReq);
} else {
throw new UnsupportedOperationException("wrong model definition.");
}
}
}
}
return result;
}
Aggregations