Search in sources :

Example 6 with JSITItemDefinition

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

the class ItemDefinitionPropertyConverter method setUnaryTests.

static void setUnaryTests(final ItemDefinition wb, final JSITItemDefinition dmn) {
    final JSITUnaryTests dmnAllowedValues = dmn.getAllowedValues();
    final Optional<UnaryTests> wbUnaryTests = ofNullable(UnaryTestsPropertyConverter.wbFromDMN(dmnAllowedValues));
    wbUnaryTests.ifPresent(unaryTests -> {
        wb.setAllowedValues(unaryTests);
        unaryTests.setParent(wb);
    });
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)

Example 7 with JSITItemDefinition

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

the class ItemDefinitionPropertyConverter method setItemComponent.

static void setItemComponent(final ItemDefinition wb, final JSITItemDefinition dmn) {
    final List<JSITItemDefinition> jsiItemDefinitions = dmn.getItemComponent();
    if (Objects.nonNull(jsiItemDefinitions)) {
        for (int i = 0; i < jsiItemDefinitions.size(); i++) {
            final JSITItemDefinition jsiItemDefinition = Js.uncheckedCast(jsiItemDefinitions.get(i));
            wb.getItemComponent().add(wbChildFromDMN(wb, jsiItemDefinition));
        }
    }
}
Also used : JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)

Example 8 with JSITItemDefinition

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

the class ItemDefinitionPropertyConverter method dmnFromWB.

public static JSITItemDefinition dmnFromWB(final ItemDefinition wb) {
    if (Objects.isNull(wb)) {
        return null;
    }
    final JSITItemDefinition result = new JSITItemDefinition();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    result.setName(wb.getName().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    result.setTypeLanguage(wb.getTypeLanguage());
    result.setIsCollection(wb.isIsCollection());
    final JSITUnaryTests utConverted = UnaryTestsPropertyConverter.dmnFromWB(wb.getAllowedValues());
    result.setAllowedValues(utConverted);
    for (ItemDefinition child : wb.getItemComponent()) {
        final JSITItemDefinition convertedChild = ItemDefinitionPropertyConverter.dmnFromWB(child);
        result.addItemComponent(convertedChild);
    }
    return result;
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)

Example 9 with JSITItemDefinition

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

the class DMNUnmarshaller method getWbImportedItemDefinitions.

private List<ItemDefinition> getWbImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions) {
    final List<ItemDefinition> definitions = new ArrayList<>();
    final List<JSITItemDefinition> importedDefinitions = dmnMarshallerImportsHelper.getImportedItemDefinitions(importDefinitions);
    for (int i = 0; i < importedDefinitions.size(); i++) {
        final JSITItemDefinition definition = Js.uncheckedCast(importedDefinitions.get(i));
        final ItemDefinition converted = ItemDefinitionPropertyConverter.wbFromDMN(definition);
        if (converted != null) {
            converted.setAllowOnlyVisualChange(true);
            definitions.add(converted);
        }
    }
    return definitions;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition) ArrayList(java.util.ArrayList) JSITItemDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)

Example 10 with JSITItemDefinition

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

Aggregations

JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)10 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)7 ArrayList (java.util.ArrayList)4 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)4 JSITImport (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport)4 HashMap (java.util.HashMap)3 QName (javax.xml.namespace.QName)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)2 Import (org.kie.workbench.common.dmn.api.definition.model.Import)2 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)2 Promise (elemental2.promise.Promise)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1