Search in sources :

Example 11 with JSITImport

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

the class ImportConverter method dmnFromWb.

static JSITImport dmnFromWb(final Import wb) {
    final JSITImport result = new JSITImport();
    result.setImportType(wb.getImportType());
    result.setLocationURI(wb.getLocationURI().getValue());
    result.setNamespace(wb.getNamespace());
    final Map<javax.xml.namespace.QName, String> otherAttributes = new HashMap<>();
    for (Map.Entry<QName, String> entry : wb.getAdditionalAttributes().entrySet()) {
        QNamePropertyConverter.dmnFromWB(entry.getKey()).ifPresent(qName -> otherAttributes.put(qName, entry.getValue()));
    }
    wb.getNsContext().forEach((k, v) -> {
        // See https://github.com/highsource/jsonix/issues/227
        if (!Objects.equals(k, DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix())) {
            otherAttributes.put(new javax.xml.namespace.QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, k, XMLConstants.DEFAULT_NS_PREFIX), v);
        }
    });
    otherAttributes.remove(new javax.xml.namespace.QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), XMLConstants.DEFAULT_NS_PREFIX));
    result.setId(wb.getId().getValue());
    result.setName(wb.getName().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    result.setOtherAttributes(otherAttributes);
    return result;
}
Also used : HashMap(java.util.HashMap) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) JSITImport(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with JSITImport

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

the class DMNMarshallerImportsClientHelper method getImportedDRGElements.

@Override
public List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions) {
    final List<JSITDRGElement> importedNodes = 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());
        importedNodes.addAll(getDrgElementsWithNamespace(definitions, anImport));
    }
    return importedNodes;
}
Also used : JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) 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) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)

Example 13 with JSITImport

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

the class DMNMarshallerImportsClientHelper method getItemDefinitionsWithNamespace.

private List<JSITItemDefinition> getItemDefinitionsWithNamespace(final JSITDefinitions definitions, final JSITImport anImport) {
    final List<JSITItemDefinition> itemDefinitions = definitions.getItemDefinition();
    final String prefix = anImport.getName();
    final List<JSITItemDefinition> result = new ArrayList<>();
    for (int i = 0; i < itemDefinitions.size(); i++) {
        final JSITItemDefinition itemDefinition = Js.uncheckedCast(itemDefinitions.get(i));
        final JSITItemDefinition item = Js.uncheckedCast(withNamespace(itemDefinition, prefix));
        result.add(item);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)

Example 14 with JSITImport

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

Aggregations

JSITImport (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport)11 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ArrayList (java.util.ArrayList)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)6 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)4 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)3 Promise (elemental2.promise.Promise)2 List (java.util.List)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)2 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)2 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)2