diff --git a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderRulesConfigurationImpl.java b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderRulesConfigurationImpl.java index 09ee9e930fa..0c90262aa28 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderRulesConfigurationImpl.java +++ b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderRulesConfigurationImpl.java @@ -46,6 +46,7 @@ import org.kie.internal.builder.conf.ParallelRulesBuildThresholdOption; import org.kie.internal.builder.conf.ProcessStringEscapesOption; import org.kie.internal.builder.conf.PropertySpecificOption; +import org.kie.internal.builder.conf.ReproducibleExecutableModelGenerationOption; import org.kie.internal.builder.conf.SingleValueKieBuilderOption; import org.kie.internal.builder.conf.TrimCellsInDTableOption; import org.kie.internal.conf.CompositeConfiguration; @@ -99,6 +100,8 @@ public class KnowledgeBuilderRulesConfigurationImpl extends BaseConfiguration T getOption(OptionKey option) case ParallelLambdaExternalizationOption.PROPERTY_NAME: { return (T) (parallelLambdaExternalization ? ParallelLambdaExternalizationOption.ENABLED : ParallelLambdaExternalizationOption.DISABLED); } + case ReproducibleExecutableModelGenerationOption.PROPERTY_NAME: { + return (T) (reproducibleExecutableModelGeneration ? ReproducibleExecutableModelGenerationOption.ENABLED : ReproducibleExecutableModelGenerationOption.DISABLED); + } case ParallelRulesBuildThresholdOption.PROPERTY_NAME: { return (T) parallelRulesBuildThreshold; } @@ -524,6 +546,10 @@ public void setOption(T option) { this.parallelLambdaExternalization = ((ParallelLambdaExternalizationOption) option).isLambdaExternalizationParallel(); break; } + case ReproducibleExecutableModelGenerationOption.PROPERTY_NAME: { + this.reproducibleExecutableModelGeneration = ((ReproducibleExecutableModelGenerationOption) option).isReproducibleExecutableModelGeneration(); + break; + } case ParallelRulesBuildThresholdOption.PROPERTY_NAME: { this.parallelRulesBuildThreshold = (ParallelRulesBuildThresholdOption)option; break; diff --git a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/processors/IteratingPhase.java b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/processors/IteratingPhase.java index ac5b5d8e804..3e5af144b42 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/builder/impl/processors/IteratingPhase.java +++ b/drools-compiler/src/main/java/org/drools/compiler/builder/impl/processors/IteratingPhase.java @@ -49,9 +49,7 @@ public IteratingPhase(Collection packages, PackageRegistr public void process() { for (CompositePackageDescr compositePackageDescr : packages) { PackageRegistry packageRegistry = pkgRegistryManager.getOrCreatePackageRegistry(compositePackageDescr); - CompilationPhase phase = phaseFactory.create( - packageRegistry, - compositePackageDescr); + CompilationPhase phase = phaseFactory.create( packageRegistry, compositePackageDescr ); phase.process(); this.results.addAll(phase.getResults()); if (this.results.hasErrors()) { diff --git a/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieProject.java b/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieProject.java index ed3466a805e..7d8c399bea8 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieProject.java +++ b/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieProject.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.function.Predicate; @@ -222,7 +223,7 @@ public KnowledgeBuilder buildKnowledgePackages( KieBaseModelImpl kBaseModel, Bui public KnowledgeBuilder buildKnowledgePackages( KieBaseModelImpl kBaseModel, BuildContext buildContext, Predicate buildFilter ) { boolean useFolders = useFolders( kBaseModel ); - Set assets = new HashSet<>(); + Set assets = new LinkedHashSet<>(); boolean allIncludesAreValid = true; for (String include : getTransitiveIncludes(kBaseModel)) { @@ -361,5 +362,10 @@ public int hashCode() { result = 31 * result + name.hashCode(); return result; } + + @Override + public String toString() { + return "Asset: " + name; + } } } diff --git a/drools-compiler/src/main/java/org/drools/compiler/lang/DescrDumper.java b/drools-compiler/src/main/java/org/drools/compiler/lang/DescrDumper.java index 812215bc027..b3f40adbb8a 100644 --- a/drools-compiler/src/main/java/org/drools/compiler/lang/DescrDumper.java +++ b/drools-compiler/src/main/java/org/drools/compiler/lang/DescrDumper.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.compiler.lang; import java.util.ArrayList; @@ -579,4 +566,4 @@ protected String evaluatorSufix(final boolean isNegated) { private DumperContext createContext() { return new DumperContext(); } -} \ No newline at end of file +} diff --git a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java index 002feeb0ede..51365d30d7c 100644 --- a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java @@ -28,6 +28,7 @@ import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.factmodel.traits.TraitTypeEnum; import org.drools.base.rule.EntryPointId; import org.drools.core.WorkingMemoryEntryPoint; @@ -369,10 +370,6 @@ public void addLastLeftTuple( TupleImpl leftTuple ) { linkedTuples.addLastLeftTuple( leftTuple ); } - public void addTupleInPosition( TupleImpl tuple ) { - linkedTuples.addTupleInPosition( tuple ); - } - public void removeLeftTuple( TupleImpl leftTuple ) { linkedTuples.removeLeftTuple( leftTuple ); } @@ -510,48 +507,6 @@ public void addLastLeftTuple( TupleImpl leftTuple) { lastLeftTuple = leftTuple; } - @Override - public void addTupleInPosition( TupleImpl tuple ) { - boolean left = tuple.isLeftTuple(); - ObjectTypeNodeId otnId = tuple.getInputOtnId(); - if (otnId == null) { // can happen only in tests // @FIXME fix this - addLastTuple( tuple, left ); - return; - } - - TupleImpl previous = left ? lastLeftTuple : lastRightTuple; - if ( previous == null ) { - // no other LeftTuples, just add. - tuple.setHandlePrevious( null ); - tuple.setHandleNext( null ); - setFirstTuple( tuple, left ); - setLastTuple( tuple, left ); - return; - } else if (previous.getSink() == null || !otnId.before(previous.getInputOtnId()) ) { - // the last LeftTuple comes before the new one so just add it at the end - tuple.setHandlePrevious( previous ); - tuple.setHandleNext( null ); - previous.setHandleNext( tuple ); - setLastTuple( tuple, left ); - return; - } - - TupleImpl next = previous; - previous = previous.getHandlePrevious(); - while (previous != null && otnId.before( previous.getInputOtnId()) ) { - next = previous; - previous = previous.getHandlePrevious(); - } - tuple.setHandleNext( next ); - next.setHandlePrevious( tuple ); - tuple.setHandlePrevious( previous ); - if ( previous != null ) { - previous.setHandleNext( tuple ); - } else { - setFirstTuple( tuple, left ); - } - } - private void addLastTuple(TupleImpl tuple, boolean left) { if (left) { addLastLeftTuple(tuple); @@ -715,6 +670,82 @@ public TupleImpl getFirstRightTuple(int partition) { TupleImpl getFirstRightTuple() { return firstRightTuple; } + + public TupleImpl detachLeftTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + TupleImpl tuple = lastLeftTuple; + TupleImpl detached = null; + // Find the first Tuple that comes after the current ID, so it can be detached. + while (tuple != null && otnId.before(tuple.getInputOtnId())) { + detached = tuple; + tuple = tuple.getHandlePrevious(); + } + + if (detached != null) { + if (firstLeftTuple == detached) { + firstLeftTuple = null; + } + + if (lastLeftTuple == detached) { + lastLeftTuple = null; + } + + if (detached.getHandlePrevious() != null) { + lastLeftTuple = detached.getHandlePrevious(); + detached.setHandlePrevious(null); + lastLeftTuple.setHandleNext(null); + } + } + + return detached; + } + + public TupleImpl detachRightTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + TupleImpl tuple = lastRightTuple; + TupleImpl detached = null; + // Find the first Tuple that comes after the current ID, so it can be detached. + while (tuple != null && otnId.before(tuple.getInputOtnId())) { + detached = tuple; + tuple = tuple.getHandlePrevious(); + } + + if (detached != null) { + if (firstRightTuple == detached) { + firstRightTuple = null; + } + + if (lastRightTuple == detached) { + lastRightTuple = null; + } + + if (detached.getHandlePrevious() != null) { + lastRightTuple = detached.getHandlePrevious(); + detached.setHandlePrevious(null); + lastRightTuple.setHandleNext(null); + } + } + + return detached; + } + + public void reattachToLeft(TupleImpl tuple) { + if (lastLeftTuple == null) { + lastLeftTuple = tuple; + } else { + lastLeftTuple.setHandleNext(tuple); + tuple.setHandlePrevious(lastLeftTuple); + lastLeftTuple = tuple; + } + } + + public void reattachToRight(TupleImpl tuple) { + if (lastRightTuple == null) { + lastRightTuple = tuple; + } else { + lastRightTuple.setHandleNext(tuple); + tuple.setHandlePrevious(lastRightTuple); + lastRightTuple = tuple; + } + } } public static class CompositeLinkedTuples implements LinkedTuples { @@ -780,11 +811,6 @@ public void addLastLeftTuple( TupleImpl leftTuple ) { getOrCreatePartitionedTuple(leftTuple).addLastLeftTuple( leftTuple ); } - @Override - public void addTupleInPosition( TupleImpl tuple ) { - getOrCreatePartitionedTuple(tuple).addTupleInPosition( tuple ); - } - @Override public void removeLeftTuple( TupleImpl leftTuple ) { getPartitionedTuple(leftTuple).removeLeftTuple( leftTuple ); @@ -807,6 +833,26 @@ public void removeRightTuple( TupleImpl rightTuple ) { } } + @Override + public TupleImpl detachLeftTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + return getOrCreatePartitionedTuple(partitionId.getId()).detachLeftTupleAfter(partitionId, otnId); + } + + @Override + public TupleImpl detachRightTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + return getOrCreatePartitionedTuple(partitionId.getId()).detachRightTupleAfter(partitionId, otnId); + } + + @Override + public void reattachToLeft(TupleImpl tuple) { + getOrCreatePartitionedTuple(tuple).reattachToLeft(tuple); + } + + @Override + public void reattachToRight(TupleImpl tuple) { + getOrCreatePartitionedTuple(tuple).reattachToRight(tuple); + } + @Override public void clearLeftTuples() { for (int i = 0; i < partitionedTuples.length; i++) { @@ -900,11 +946,6 @@ public void addLastLeftTuple(TupleImpl leftTuple) { throw new UnsupportedOperationException(); } - @Override - public void addTupleInPosition(TupleImpl tuple) { - throw new UnsupportedOperationException(); - } - @Override public void removeLeftTuple(TupleImpl leftTuple) { throw new UnsupportedOperationException(); diff --git a/drools-core/src/main/java/org/drools/core/common/DisconnectedFactHandle.java b/drools-core/src/main/java/org/drools/core/common/DisconnectedFactHandle.java index 46546638a0d..e9a44b27354 100644 --- a/drools-core/src/main/java/org/drools/core/common/DisconnectedFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/DisconnectedFactHandle.java @@ -363,10 +363,6 @@ public void addLastRightTuple(TupleImpl rightTuple) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_ERROR_MESSAGE); } - public void addTupleInPosition(TupleImpl rightTuple) { - throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_ERROR_MESSAGE); - } - public void removeRightTuple(TupleImpl rightTuple) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_ERROR_MESSAGE); } diff --git a/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java b/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java index d83f0940c8e..d8a4af38dff 100644 --- a/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java @@ -26,6 +26,7 @@ import org.drools.base.factmodel.traits.TraitTypeEnum; import org.drools.base.rule.EntryPointId; import org.drools.core.WorkingMemoryEntryPoint; +import org.drools.core.reteoo.ObjectTypeNodeId; import org.drools.core.reteoo.TupleImpl; import org.kie.api.runtime.rule.FactHandle; @@ -112,8 +113,6 @@ default String getEntryPointName() { void removeRightTuple( TupleImpl rightTuple); - void addTupleInPosition( TupleImpl tuple); - boolean isNegated(); void setNegated(boolean negated); @@ -142,9 +141,7 @@ interface LinkedTuples extends Serializable { void addFirstLeftTuple( TupleImpl leftTuple); void addLastLeftTuple( TupleImpl leftTuple); - - void addTupleInPosition( TupleImpl tuple); - + void removeLeftTuple( TupleImpl leftTuple); void addFirstRightTuple( TupleImpl rightTuple); @@ -171,6 +168,22 @@ default TupleImpl getFirstLeftTuple(RuleBasePartitionId partitionId) { default TupleImpl getFirstRightTuple(RuleBasePartitionId partitionId) { return getFirstRightTuple( partitionId.getParallelEvaluationSlot() ); } + + default TupleImpl detachLeftTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + throw new UnsupportedOperationException(); + } + + default TupleImpl detachRightTupleAfter(RuleBasePartitionId partitionId, ObjectTypeNodeId otnId) { + throw new UnsupportedOperationException(); + } + + default void reattachToLeft(TupleImpl tuple) { + throw new UnsupportedOperationException(); + } + + default void reattachToRight(TupleImpl tuple) { + throw new UnsupportedOperationException(); + } } static InternalFactHandle dummyFactHandleOf(Object object) { @@ -345,11 +358,6 @@ public void removeRightTuple( TupleImpl rightTuple) { throw new UnsupportedOperationException(); } - @Override - public void addTupleInPosition( TupleImpl tuple) { - throw new UnsupportedOperationException(); - } - @Override public boolean isNegated() { throw new UnsupportedOperationException(); diff --git a/drools-core/src/main/java/org/drools/core/common/QueryElementFactHandle.java b/drools-core/src/main/java/org/drools/core/common/QueryElementFactHandle.java index 26227b0d460..cb985191262 100644 --- a/drools-core/src/main/java/org/drools/core/common/QueryElementFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/QueryElementFactHandle.java @@ -250,10 +250,6 @@ public void addLastRightTuple( TupleImpl rightTuple ) { throw new UnsupportedOperationException( "QueryElementFactHandle does not support this method" ); } - public void addTupleInPosition( TupleImpl rightTuple ) { - throw new UnsupportedOperationException( "QueryElementFactHandle does not support this method" ); - } - public void removeRightTuple( TupleImpl rightTuple ) { throw new UnsupportedOperationException( "QueryElementFactHandle does not support this method" ); } diff --git a/drools-core/src/main/java/org/drools/core/phreak/DetachedTuple.java b/drools-core/src/main/java/org/drools/core/phreak/DetachedTuple.java new file mode 100644 index 00000000000..f3ecf2cddf7 --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/phreak/DetachedTuple.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.drools.core.phreak; + +import org.drools.core.common.DefaultFactHandle; +import org.drools.core.reteoo.TupleImpl; + +public class DetachedTuple { + private DefaultFactHandle fh; + private TupleImpl tuple; + + public DetachedTuple(DefaultFactHandle fh, TupleImpl tuple) { + this.fh = fh; + this.tuple = tuple; + } + + public void reattachToLeft() { + fh.getLinkedTuples().reattachToLeft(tuple); + } + + public void reattachToRight() { + fh.getLinkedTuples().reattachToRight(tuple); + } +} diff --git a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java index e53afd9935b..a4d37f49d32 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java +++ b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java @@ -46,9 +46,10 @@ import org.drools.core.reteoo.AlphaTerminalNode; import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.BetaNode; +import org.drools.core.reteoo.BetaNode.RightTupleSinkAdapter; import org.drools.core.reteoo.FromNode.FromMemory; import org.drools.core.reteoo.LeftInputAdapterNode; -import org.drools.core.reteoo.LeftInputAdapterNode.RightTupleSinkAdapter; +import org.drools.core.reteoo.LeftInputAdapterNode.LeftTupleSinkAdapter; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleNode; import org.drools.core.reteoo.LeftTupleSinkNode; @@ -268,11 +269,26 @@ public static void insertLiaFacts(LeftTupleNode startNode, InternalWorkingMemory final PropagationContext pctx = pctxFactory.createPropagationContext(wm.getNextPropagationIdCounter(), PropagationContext.Type.RULE_ADDITION, null, null, null); LeftInputAdapterNode lian = (LeftInputAdapterNode) startNode; if (allBranches && visited.add(lian.getId()) || lian.getAssociatedTerminalsSize() == 1 ) { - RightTupleSinkAdapter liaAdapter = new RightTupleSinkAdapter(lian); - lian.getObjectSource().updateSink(liaAdapter, pctx, wm); + attachAdapterAndPropagate(wm, lian, pctx); } } + public static void attachAdapterAndPropagate(InternalWorkingMemory wm, LeftInputAdapterNode lian, PropagationContext pctx) { + List detachedTuples = new ArrayList<>(); + LeftTupleSinkAdapter liaAdapter = new LeftTupleSinkAdapter(lian, detachedTuples); + lian.getObjectSource().updateSink(liaAdapter, pctx, wm); + detachedTuples.forEach(d -> d.reattachToLeft()); + } + + public static void attachAdapterAndPropagate(InternalWorkingMemory wm, BetaNode bn) { + PropagationContextFactory pctxFactory = RuntimeComponentFactory.get().getPropagationContextFactory(); + final PropagationContext pctx = pctxFactory.createPropagationContext(wm.getNextPropagationIdCounter(), PropagationContext.Type.RULE_ADDITION, null, null, null); + List detachedTuples = new ArrayList<>(); + RightTupleSinkAdapter bnAdapter = new RightTupleSinkAdapter(bn, detachedTuples); + bn.getRightInput().updateSink(bnAdapter, pctx, wm); + detachedTuples.forEach(d -> d.reattachToRight()); + } + public static SegmentPrototype processSplit(LeftTupleNode splitNode, InternalRuleBase kbase, Collection wms, Set smemsToNotify) { LeftTupleNode segmentRoot = BuildtimeSegmentUtilities.findSegmentRoot(splitNode); SegmentPrototype proto1 = kbase.getSegmentPrototype(segmentRoot); @@ -326,9 +342,7 @@ public static void insertFacts(TerminalNode tn, InternalWorkingMemory wm, Set wms) { @@ -730,9 +729,7 @@ private static void insertFacts(PathEndNodes endNodes, Collection detachedTuples; + + public RightTupleSinkAdapter(BetaNode bnNode, List detachedTuples) { + this.bnNode = bnNode; + this.detachedTuples = detachedTuples; + } + + /** + * Do not use this constructor. It should be used just by deserialization. + */ + public RightTupleSinkAdapter() { + } + + public void assertObject(final InternalFactHandle factHandle, + final PropagationContext context, + final ReteEvaluator reteEvaluator) { + ObjectTypeNodeId otnId = bnNode.getRightInputOtnId(); + TupleImpl detached = factHandle.getLinkedTuples().detachRightTupleAfter(getPartitionId(), otnId); + if (detached != null) { + detachedTuples.add(new DetachedTuple((DefaultFactHandle) factHandle, detached)); + } + + bnNode.assertObject(factHandle, context, reteEvaluator); + } + + public void modifyObject(InternalFactHandle factHandle, + ModifyPreviousTuples modifyPreviousTuples, + PropagationContext context, + ReteEvaluator reteEvaluator) { + throw new UnsupportedOperationException( "ObjectSinkAdapter onlys supports assertObject method calls" ); + } + + public int getId() { + return 0; + } + + public RuleBasePartitionId getPartitionId() { + return bnNode.getPartitionId(); + } + + public void byPassModifyToBetaNode(InternalFactHandle factHandle, + ModifyPreviousTuples modifyPreviousTuples, + PropagationContext context, + ReteEvaluator reteEvaluator) { + throw new UnsupportedOperationException(); + } + + public int getType() { + return NodeTypeEnums.LeftInputAdapterNode; + } + + @Override public Rule[] getAssociatedRules() { + return bnNode.getAssociatedRules(); + } + + public boolean isAssociatedWith(Rule rule) { + return bnNode.isAssociatedWith( rule ); + } + + @Override + public NetworkNode[] getSinks() { + return new NetworkNode[0]; + } + + @Override + public void addAssociatedTerminal(BaseTerminalNode terminalNode) { + bnNode.addAssociatedTerminal(terminalNode); + } + + @Override + public void removeAssociatedTerminal(BaseTerminalNode terminalNode) { + bnNode.removeAssociatedTerminal(terminalNode); + } + + @Override + public int getAssociatedTerminalsSize() { + return bnNode.getAssociatedTerminalsSize(); + } + + @Override + public boolean hasAssociatedTerminal(BaseTerminalNode terminalNode) { + return bnNode.hasAssociatedTerminal(terminalNode); + } + } } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/LeftInputAdapterNode.java b/drools-core/src/main/java/org/drools/core/reteoo/LeftInputAdapterNode.java index e2f73f70cf9..793d0ff3303 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/LeftInputAdapterNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/LeftInputAdapterNode.java @@ -31,7 +31,7 @@ import org.drools.base.reteoo.NodeTypeEnums; import org.drools.base.rule.Pattern; import org.drools.core.RuleBaseConfiguration; -import org.drools.core.common.BaseNode; +import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.Memory; import org.drools.core.common.MemoryFactory; @@ -40,6 +40,7 @@ import org.drools.core.common.SuperCacheFixer; import org.drools.core.common.TupleSets; import org.drools.core.common.UpdateContext; +import org.drools.core.phreak.DetachedTuple; import org.drools.core.phreak.RuntimeSegmentUtilities; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.rule.consequence.InternalMatch; @@ -595,25 +596,33 @@ public void reset() { * Used with the updateSink method, so that the parent ObjectSource * can update the TupleSink */ - public static class RightTupleSinkAdapter + public static class LeftTupleSinkAdapter implements ObjectSink { - private LeftTupleSink sink; private LeftInputAdapterNode liaNode; - public RightTupleSinkAdapter(LeftInputAdapterNode liaNode) { + private List detachedTuples; + + public LeftTupleSinkAdapter(LeftInputAdapterNode liaNode, List detachedTuples) { this.liaNode = liaNode; + this.detachedTuples = detachedTuples; } /** * Do not use this constructor. It should be used just by deserialization. */ - public RightTupleSinkAdapter() { + public LeftTupleSinkAdapter() { } public void assertObject(final InternalFactHandle factHandle, final PropagationContext context, final ReteEvaluator reteEvaluator) { + ObjectTypeNodeId otnId = liaNode.getSinkPropagator().getFirstLeftTupleSink().getLeftInputOtnId(); + TupleImpl detached = factHandle.getLinkedTuples().detachLeftTupleAfter(getPartitionId(), otnId); + if (detached != null) { + detachedTuples.add(new DetachedTuple((DefaultFactHandle) factHandle, detached)); + } + liaNode.assertObject(factHandle, context, reteEvaluator); } @@ -629,7 +638,7 @@ public int getId() { } public RuleBasePartitionId getPartitionId() { - return sink.getPartitionId(); + return liaNode.getPartitionId(); } public void byPassModifyToBetaNode(InternalFactHandle factHandle, @@ -644,11 +653,11 @@ public int getType() { } @Override public Rule[] getAssociatedRules() { - return sink.getAssociatedRules(); + return liaNode.getAssociatedRules(); } public boolean isAssociatedWith(Rule rule) { - return sink.isAssociatedWith( rule ); + return liaNode.isAssociatedWith( rule ); } @Override @@ -658,22 +667,22 @@ public NetworkNode[] getSinks() { @Override public void addAssociatedTerminal(BaseTerminalNode terminalNode) { - sink.addAssociatedTerminal(terminalNode); + liaNode.addAssociatedTerminal(terminalNode); } @Override public void removeAssociatedTerminal(BaseTerminalNode terminalNode) { - sink.removeAssociatedTerminal(terminalNode); + liaNode.removeAssociatedTerminal(terminalNode); } @Override public int getAssociatedTerminalsSize() { - return sink.getAssociatedTerminalsSize(); + return liaNode.getAssociatedTerminalsSize(); } @Override public boolean hasAssociatedTerminal(BaseTerminalNode terminalNode) { - return sink.hasAssociatedTerminal(terminalNode); + return liaNode.hasAssociatedTerminal(terminalNode); } } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java b/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java index 1e53bcd6007..9bb2559d670 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java @@ -48,7 +48,7 @@ public class RuleTerminalNode extends AbstractTerminalNode { protected boolean fireDirect; - protected transient ObjectTypeNodeId leftInputOtnId; + protected transient ObjectTypeNodeId leftInputOtnId = ObjectTypeNodeId.DEFAULT_ID; protected String consequenceName; diff --git a/drools-core/src/main/java/org/drools/core/reteoo/TupleImpl.java b/drools-core/src/main/java/org/drools/core/reteoo/TupleImpl.java index 885fe9a3941..fea2b07301d 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/TupleImpl.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/TupleImpl.java @@ -79,7 +79,7 @@ public TupleImpl(InternalFactHandle factHandle, setSink(sink); this.handle = factHandle; if ( leftTupleMemoryEnabled ) { - factHandle.addTupleInPosition( this ); + factHandle.addLastLeftTuple( this ); } } diff --git a/drools-docs/src/modules/ROOT/nav.adoc b/drools-docs/src/modules/ROOT/nav.adoc index f210e651503..769eff9ce1a 100644 --- a/drools-docs/src/modules/ROOT/nav.adoc +++ b/drools-docs/src/modules/ROOT/nav.adoc @@ -3,6 +3,7 @@ * xref:KIE/index.adoc[leveloffset=+1] * xref:rule-engine/index.adoc[leveloffset=+1] * xref:language-reference/index.adoc[leveloffset=+1] +* xref:language-reference-traditional/index.adoc[leveloffset=+1] * xref:DMN/index.adoc[leveloffset=+1] * xref:pragmatic-ai/index.adoc[leveloffset=+1] * xref:Commands/index.adoc[leveloffset=+1] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_DSL-section.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_DSL-section.adoc new file mode 100644 index 00000000000..f23dc18a02f --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_DSL-section.adoc @@ -0,0 +1,398 @@ += Domain Specific Languages + + +(((Domain Specific Languages))) +Domain Specific Languages (or DSLs) are a way of creating a rule language that is dedicated to your problem domain. +A set of DSL definitions consists of transformations from DSL "sentences" to DRL constructs, which lets you use of all the underlying rule language and engine features. +Given a DSL, you write rules in DSL rule (or DSLR) files, which will be translated into DRL files. + +DSL and DSLR files are plain text files, and you can use any text editor to create and modify them. +But there are also DSL and DSLR editors, both in the IDE as well as in the web based BRMS, and you can use those as well, although they may not provide you with the full DSL functionality. + +== When to Use a DSL + + +DSLs can serve as a layer of separation between rule authoring (and rule authors) and the technical intricacies resulting from the modelling of domain object and the {RULE_ENGINE}'s native language and methods. +If your rules need to be read and validated by domain experts (such as business analysts, for instance) who are not programmers, you should consider using a DSL; it hides implementation details and focuses on the rule logic proper. +DSL sentences can also act as "templates" for conditional elements and consequence actions that are used repeatedly in your rules, possibly with minor variations. +You may define DSL sentences as being mapped to these repeated phrases, with parameters providing a means for accommodating those variations. + +DSLs have no impact on the {RULE_ENGINE} at runtime, they are just a compile time feature, requiring a special parser and transformer. + +== DSL Basics + + +The Drools DSL mechanism allows you to customise conditional expressions and consequence actions. +A global substitution mechanism ("keyword") is also available. + +.Example (((DSL))) DSL mapping +==== +[source] +---- +[when]Something is {colour}=Something(colour=="{colour}") +---- +==== + + +In the preceding example, `[when]` indicates the scope of the expression, i.e., whether it is valid for the LHS or the RHS of a rule. +The part after the bracketed keyword is the expression that you use in the rule; typically a natural language expression, but it doesn't have to be. +The part to the right of the equal sign ("=") is the mapping of the expression into the rule language. +The form of this string depends on its destination, RHS or LHS. +If it is for the LHS, then it ought to be a term according to the regular LHS syntax; if it is for the RHS then it might be a Java statement. + +Whenever the DSL parser matches a line from the rule file written in the DSL with an expression in the DSL definition, it performs three steps of string manipulation. +First, it extracts the string values appearing where the expression contains variable names in braces (here: ``\{colour}``). Then, the values obtained from these captures are then interpolated wherever that name, again enclosed in braces, occurs on the right hand side of the mapping. +Finally, the interpolated string replaces whatever was matched by the entire expression in the line of the DSL rule file. + +Note that the expressions (i.e., the strings on the left hand side of the equal sign) are used as regular expressions in a pattern matching operation against a line of the DSL rule file, matching all or part of a line. +This means you can use (for instance) a '?' to indicate that the preceding character is optional. +One good reason to use this is to overcome variations in natural language phrases of your DSL. +But, given that these expressions are regular expression patterns, this also means that all "magic" characters of Java's pattern syntax have to be escaped with a preceding backslash ('\'). + +It is important to note that the compiler transforms DSL rule files line by line. +In the previous example, all the text after "Something is " to the end of the line is captured as the replacement value for "\{colour}", and this is used for interpolating the target string. +This may not be exactly what you want. +For instance, when you intend to merge different DSL expressions to generate a composite DRL pattern, you need to transform a DSLR line in several independent operations. +The best way to achieve this is to ensure that the captures are surrounded by characteristic text - words or even single characters. +As a result, the matching operation done by the parser plucks out a substring from somewhere within the line. +In the example below, quotes are used as distinctive characters. +Note that the characters that surround the capture are not included during interpolation, just the contents between them. + +As a rule of thumb, use quotes for textual data that a rule editor may want to enter. +You can also enclose the capture with words to ensure that the text is correctly matched. +Both is illustrated by the following example. +Note that a single line such as `Something is "green" and + another solid thing` is now correctly expanded. + +.Example with quotes +==== +[source] +---- +[when]something is "{colour}"=Something(colour=="{colour}") +[when]another {state} thing=OtherThing(state=="{state})" +---- +==== + + +It is a good idea to avoid punctuation (other than quotes or apostrophes) in your DSL expressions as much as possible. +The main reason is that punctuation is easy to forget for rule authors using your DSL. +Another reason is that parentheses, the period and the question mark are magic characters, requiring escaping in the DSL definition. + +In a DSL mapping, the braces "{" and "}" should only be used to enclose a variable definition or reference, resulting in a capture. +If they should occur literally, either in the expression or within the replacement text on the right hand side, they must be escaped with a preceding backslash ("\"): + +[source] +---- +[then]do something= if (foo) \{ doSomething(); \} +---- + +[NOTE] +==== +If braces "{" and "}" should appear in the replacement string of a DSL definition, escape them with a backslash ('\'). +==== + +.Examples of DSL mapping entries +==== +[source] +---- +# This is a comment to be ignored. +[when]There is a person with name of "{name}"=Person(name=="{name}") +[when]Person is at least {age} years old and lives in "{location}"= + Person(age >= {age}, location=="{location}") +[then]Log "{message}"=System.out.println("{message}"); +[when]And = and +---- +==== + + +Given the above DSL examples, the following examples show the expansion of various DSLR snippets: + +.Examples of DSL expansions +==== +[source] +---- +There is a person with name of "Kitty" + ==> Person(name="Kitty") +Person is at least 42 years old and lives in "Atlanta" + ==> Person(age >= 42, location="Atlanta") +Log "boo" + ==> System.out.println("boo"); +There is a person with name of "Bob" And Person is at least 30 years old and lives in "Utah" + ==> Person(name="Bob") and Person(age >= 30, location="Utah") +---- +==== + +[NOTE] +==== +Don't forget that if you are capturing plain text from a DSL rule line and want to use it as a string literal in the expansion, you must provide the quotes on the right hand side of the mapping. +==== + + +You can chain DSL expressions together on one line, as long as it is clear to the parser where one ends and the next one begins and where the text representing a parameter ends. +(Otherwise you risk getting all the text until the end of the line as a parameter value.) The DSL expressions are tried, one after the other, according to their order in the DSL definition file. +After any match, all remaining DSL expressions are investigated, too. + +The resulting DRL text may consist of more than one line. +Line ends are in the replacement text are written as ``\n``. + +== Adding Constraints to Facts + + +A common requirement when writing rule conditions is to be able to add an arbitrary combination of constraints to a pattern. +Given that a fact type may have many fields, having to provide an individual DSL statement for each combination would be plain folly. + +The DSL facility allows you to add constraints to a pattern by a simple convention: if your DSL expression starts with a hyphen (minus character, "-") it is assumed to be a field constraint and, consequently, is is added to the last pattern line preceding it. + +For an example, lets take look at class ``Cheese``, with the following fields: type, price, age and country. +We can express some LHS condition in normal DRL like the following + +[source] +---- +Cheese(age < 5, price == 20, type=="stilton", country=="ch") +---- + + +The DSL definitions given below result in three DSL phrases which may be used to create any combination of constraint involving these fields. + +[source] +---- +[when]There is a Cheese with=Cheese() +[when]- age is less than {age}=age<{age} +[when]- type is '{type}'=type=='{type}' +[when]- country equal to '{country}'=country=='{country}' +---- + + +You can then write rules with conditions like the following: +[source] +---- +There is a Cheese with + - age is less than 42 + - type is 'stilton' +---- + The parser will pick up a line beginning with "-" and add it as a constraint to the preceding pattern, inserting a comma when it is required. +For the preceding example, the resulting DRL is: +[source] +---- +Cheese(age<42, type=='stilton') +---- + +Combining all numeric fields with all relational operators (according to the DSL expression "age is less than..." in the preceding example) produces an unwieldy amount of DSL entries. +But you can define DSL phrases for the various operators and even a generic expression that handles any field constraint, as shown below. +(Notice that the expression definition contains a regular expression in addition to the variable name.) + +[source] +---- +[when][]is less than or equal to=<= +[when][]is less than=< +[when][]is greater than or equal to=>= +[when][]is greater than=> +[when][]is equal to=== +[when][]equals=== +[when][]There is a Cheese with=Cheese() +[when][]- {field:\w*} {operator} {value:\d*}={field} {operator} {value} +---- + + +Given these DSL definitions, you can write rules with conditions such as: + +[source] +---- +There is a Cheese with + - age is less than 42 + - rating is greater than 50 + - type equals 'stilton' +---- + + +In this specific case, a phrase such as "is less than" is replaced by ``<``, and then the line matches the last DSL entry. +This removes the hyphen, but the final result is still added as a constraint to the preceding pattern. +After processing all of the lines, the resulting DRL text is: + +[source] +---- +Cheese(age<42, rating > 50, type=='stilton') +---- + +[NOTE] +==== +The order of the entries in the DSL is important if separate DSL expressions are intended to match the same line, one after the other. +==== + +== Developing a DSL + + +A good way to get started is to write representative samples of the rules your application requires, and to test them as you develop. +This will provide you with a stable framework of conditional elements and their constraints. +Rules, both in DRL and in DSLR, refer to entities according to the data model representing the application data that should be subject to the reasoning process defined in rules. +Notice that writing rules is generally easier if most of the data model's types are facts. + +Given an initial set of rules, it should be possible to identify recurring or similar code snippets and to mark variable parts as parameters. +This provides reliable leads as to what might be a handy DSL entry. +Also, make sure you have a full grasp of the jargon the domain experts are using, and base your DSL phrases on this vocabulary. + +You may postpone implementation decisions concerning conditions and actions during this first design phase by leaving certain conditional elements and actions in their DRL form by prefixing a line with a greater sign (">"). (This is also handy for inserting debugging statements.) + +During the next development phase, you should find that the DSL configuration stabilizes pretty quickly. +New rules can be written by reusing the existing DSL definitions, or by adding a parameter to an existing condition or consequence entry. + +Try to keep the number of DSL entries small. +Using parameters lets you apply the same DSL sentence for similar rule patterns or constraints. +But do not exaggerate: authors using the DSL should still be able to identify DSL phrases by some fixed text. + +== DSL and DSLR Reference + + +A DSL file is a text file in a line-oriented format. +Its entries are used for transforming a DSLR file into a file according to DRL syntax. + +* A line starting with "#" or "//" (with or without preceding white space) is treated as a comment. A comment line starting with "#/" is scanned for words requesting a debug option, see below. +* Any line starting with an opening bracket ("[") is assumed to be the first line of a DSL entry definition. +* Any other line is appended to the preceding DSL entry definition, with the line end replaced by a space. + + +A DSL entry consists of the following four parts: + +* A scope definition, written as one of the keywords "when" or "condition", "then" or "consequence", "*" and "keyword", enclosed in brackets ("[" and "]"). This indicates whether the DSL entry is valid for the condition or the consequence of a rule, or both. A scope indication of "keyword" means that the entry has global significance, i.e., it is recognized anywhere in a DSLR file. +* A type definition, written as a Java class name, enclosed in brackets. This part is optional unless the next part begins with an opening bracket. An empty pair of brackets is valid, too. +* A DSL expression consists of a (Java) regular expression, with any number of embedded _variable definitions,_ terminated by an equal sign ("="). A variable definition is enclosed in braces ("{" and "}"). It consists of a variable name and two optional attachments, separated by colons (":"). If there is one attachment, it is a regular expression for matching text that is to be assigned to the variable; if there are two attachments, the first one is a hint for the GUI editor and the second one the regular expression. ++ +Note that all characters that are "magic" in regular expressions must be escaped with a preceding backslash ("\") if they should occur literally within the expression. +* The remaining part of the line after the delimiting equal sign is the replacement text for any DSLR text matching the regular expression. It may contain variable references, i.e., a variable name enclosed in braces. Optionally, the variable name may be followed by an exclamation mark ("!") and a transformation function, see below. ++ +Note that braces ("{" and "}") must be escaped with a preceding backslash ("\") if they should occur literally within the replacement string. + + +Debugging of DSL expansion can be turned on, selectively, by using a comment line starting with "#/" which may contain one or more words from the table presented below. +The resulting output is written to standard output. + +.Debug options for DSL expansion +[cols="1,1", options="header"] +|=== +| Word +| Description + +|result +|Prints the resulting DRL text, with line numbers. + +|steps +|Prints each expansion step of condition and consequence + lines. + +|keyword +|Dumps the internal representation of all DSL entries with + scope "keyword". + +|when +|Dumps the internal representation of all DSL entries with + scope "when" or "*". + +|then +|Dumps the internal representation of all DSL entries with + scope "then" or "*". + +|usage +|Displays a usage statistic of all DSL entries. +|=== + + +Below are some sample DSL definitions, with comments describing the language features they illustrate. + +[source] +---- +# Comment: DSL examples + +#/ debug: display result and usage + +# keyword definition: replaces "regula" by "rule" +[keyword][]regula=rule + +# conditional element: "T" or "t", "a" or "an", convert matched word +[when][][Tt]here is an? {entity:\w+}= + ${entity!lc}: {entity!ucfirst} () + +# consequence statement: convert matched word, literal braces +[then][]update {entity:\w+}=modify( ${entity!lc} )\{ \} +---- + + +The transformation of a DSLR file proceeds as follows: + +. The text is read into memory. +. Each of the "keyword" entries is applied to the entire text. First, the regular expression from the keyword definition is modified by replacing white space sequences with a pattern matching any number of white space characters, and by replacing variable definitions with a capture made from the regular expression provided with the definition, or with the default (".*?"). Then, the DSLR text is searched exhaustively for occurrences of strings matching the modified regular expression. Substrings of a matching string corresponding to variable captures are extracted and replace variable references in the corresponding replacement text, and this text replaces the matching string in the DSLR text. +. Sections of the DSLR text between "when" and "then", and "then" and "end", respectively, are located and processed in a uniform manner, line by line, as described below. ++ +For a line, each DSL entry pertaining to the line's section is taken in turn, in the order it appears in the DSL file. +Its regular expression part is modified: white space is replaced by a pattern matching any number of white space characters; variable definitions with a regular expression are replaced by a capture with this regular expression, its default being ".*?". If the resulting regular expression matches all or part of the line, the matched part is replaced by the suitably modified replacement text. ++ +Modification of the replacement text is done by replacing variable references with the text corresponding to the regular expression capture. +This text may be modified according to the string transformation function given in the variable reference; see below for details. ++ +If there is a variable reference naming a variable that is not defined in the same entry, the expander substitutes a value bound to a variable of that name, provided it was defined in one of the preceding lines of the current rule. +. If a DSLR line in a condition is written with a leading hyphen, the expanded result is inserted into the last line, which should contain a pattern CE, i.e., a type name followed by a pair of parentheses. if this pair is empty, the expanded line (which should contain a valid constraint) is simply inserted, otherwise a comma (",") is inserted beforehand. ++ +If a DSLR line in a consequence is written with a leading hyphen, the expanded result is inserted into the last line, which should contain a "modify" statement, ending in a pair of braces ("{" and "}"). If this pair is empty, the expanded line (which should contain a valid method call) is simply inserted, otherwise a comma (",") is inserted beforehand. + + +[NOTE] +==== +It is currently _not_ possible to use a line with a leading hyphen to insert text into other conditional element forms (e.g., "accumulate") or it may only work for the first insertion (e.g., "eval"). +==== + + +All string transformation functions are described in the following table. + +.String transformation functions +[cols="1,1", options="header"] +|=== +| Name +| Description + +|uc +|Converts all letters to upper case. + +|lc +|Converts all letters to lower case. + +|ucfirst +|Converts the first letter to upper case, and + all other letters to lower case. + +|num +|Extracts all digits and "-" from the string. If the + last two digits in the original string are preceded by "." or + ",", a decimal period is inserted in the corresponding position. + +|__a__?__b__/__c__ +|Compares the string with string __a__, and if they + are equal, replaces it with __b__, otherwise with + __c__. But _c_ can be another triplet + __a__, __b__, __c__, so + that the entire structure is, in fact, a translation table. +|=== + + +The following DSL examples show how to use string transformation functions. + +[source] +---- +# definitions for conditions +[when][]There is an? {entity}=${entity!lc}: {entity!ucfirst}() +[when][]- with an? {attr} greater than {amount}={attr} <= {amount!num} +[when][]- with a {what} {attr}={attr} {what!positive?>0/negative?%lt;0/zero?==0/ERROR} +---- + + +A file containing a DSL definition has to be put under the resources folder or any of its subfolders like any other drools artifact. +It must have the extension ``$$.$$dsl``, or alternatively be marked with type ``ResourceType.DSL``. +when programmatically added to a ``KieFileSystem``. +For a file using DSL definition, the extension `$$.$$dslr` should be used, while it can be added to a `KieFileSystem` with type ``ResourceType.DSLR``. + +For parsing and expanding a DSLR file the DSL configuration is read and supplied to the parser. +Thus, the parser can "recognize" the DSL expressions and transform them into native rule language expressions. + +ifdef::backend-docbook[] +[index] +== Index +// Generated automatically by the DocBook toolchain. +endif::backend-docbook[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-access-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-access-con.adoc new file mode 100644 index 00000000000..60316ee6216 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-access-con.adoc @@ -0,0 +1,47 @@ +[id='drl-declarations-access-con_{context}'] += Access to DRL declared types in application code + +Declared types in DRL are typically used within the DRL files while Java models are typically used when the model is shared between rules and applications. Because declared types are generated at KIE base compile time, an application cannot access them until application run time. In some cases, an application needs to access and handle facts directly from the declared types, especially when the application wraps the {RULE_ENGINE} and provides higher-level, domain-specific user interfaces for rules management. + +To handle declared types directly from the application code, you can use the `org.drools.definition.type.FactType` API in {PRODUCT}. Through this API, you can instantiate, read, and write fields in the declared fact types. + +The following example code modifies a `Person` fact type directly from an application: + +.Example application code to handle a declared fact type through the FactType API +[source,java] +---- +import java.util.Date; + +import org.kie.api.definition.type.FactType; +import org.kie.api.KieBase; +import org.kie.api.runtime.KieSession; + +... + +// Get a reference to a KIE base with the declared type: +KieBase kbase = ... + +// Get the declared fact type: +FactType personType = kbase.getFactType("org.drools.examples", "Person"); + +// Create instances: +Object bob = personType.newInstance(); + +// Set attribute values: +personType.set(bob, "name", "Bob" ); +personType.set(bob, "dateOfBirth", new Date()); +personType.set(bob, "address", new Address("King's Road","London","404")); + +// Insert the fact into a KIE session: +KieSession ksession = ... +ksession.insert(bob); +ksession.fireAllRules(); + +// Read attributes: +String name = (String) personType.get(bob, "name"); +Date date = (Date) personType.get(bob, "dateOfBirth"); +---- + +The API also includes other helpful methods, such as setting all the attributes at once, reading values from a `Map` collection, or reading all attributes at once into a `Map` collection. + +Although the API behavior is similar to Java reflection, the API does not use reflection and relies on more performant accessors that are implemented with generated bytecode. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-con.adoc new file mode 100644 index 00000000000..2894d191fff --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-con.adoc @@ -0,0 +1,15 @@ +[id='drl-declarations-con_{context}'] += Type declarations and metadata in DRL + +ifdef::DROOLS,JBPM,OP[] +.Type declaration +image::language-reference/type_declaration.png[align="center"] + +.Metadata +image::language-reference/meta_data.png[align="center"] +endif::[] + +Declarations in DRL files define new fact types or metadata for fact types to be used by rules in the DRL file: + +* *New fact types:* The default fact type in the `java.lang` package of {PRODUCT} is `Object`, but you can declare other types in DRL files as needed. Declaring fact types in DRL files enables you to define a new fact model directly in the {RULE_ENGINE}, without creating models in a lower-level language like Java. You can also declare a new type when a domain model is already built and you want to complement this model with additional entities that are used mainly during the reasoning process. +* *Metadata for fact types:* You can associate metadata in the format `@key(value)` with new or existing facts. Metadata can be any kind of data that is not represented by the fact attributes and is consistent among all instances of that fact type. The metadata can be queried at run time by the {RULE_ENGINE} and used in the reasoning process. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-enumerative-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-enumerative-con.adoc new file mode 100644 index 00000000000..d1dc314537f --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-enumerative-con.adoc @@ -0,0 +1,23 @@ +[id='drl-declarations-enumerative-con_{context}'] += Enumerative type declarations in DRL + +DRL supports the declaration of enumerative types in the format `declare enum `, followed by a comma-separated list of values ending with a semicolon. You can then use the enumerative list in the rules in the DRL file. + +For example, the following enumerative type declaration defines days of the week for an employee scheduling rule: + +.Example enumerative type declaration with a scheduling rule +[source] +---- +declare enum DaysOfWeek + SUN("Sunday"),MON("Monday"),TUE("Tuesday"),WED("Wednesday"),THU("Thursday"),FRI("Friday"),SAT("Saturday"); + + fullName : String +end + +rule "Using a declared Enum" +when + $emp : Employee( dayOff == DaysOfWeek.MONDAY ) +then + ... +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-extended-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-extended-con.adoc new file mode 100644 index 00000000000..351d72825e2 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-extended-con.adoc @@ -0,0 +1,23 @@ +[id='drl-declarations-extended-con_{context}'] += Extended type declarations in DRL + +DRL supports type declaration inheritance in the format `declare extends `. To extend a type declared in Java by a subtype declared in DRL, you repeat the parent type in a declaration statement without any fields. + +For example, the following type declarations extend a `Student` type from a top-level `Person` type, and a `LongTermStudent` type from the `Student` subtype: + +.Example extended type declarations +[source] +---- +import org.people.Person + +declare Person end + +declare Student extends Person + school : String +end + +declare LongTermStudent extends Student + years : int + course : String +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-metadata-tags-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-metadata-tags-ref.adoc new file mode 100644 index 00000000000..8327e8e114a --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-metadata-tags-ref.adoc @@ -0,0 +1,297 @@ +[id='drl-declarations-metadata-tags-ref_{context}'] + +ifeval::["{context}" == "decision-engine"] += Metadata tags for events + +The {RULE_ENGINE} uses the following metadata tags for events that are inserted into the working memory of the {RULE_ENGINE}. You can change the default metadata tag values in your Java class or DRL rule file as needed. +endif::[] +ifeval::["{context}" == "drl-rules"] += Metadata tags for fact type and attribute declarations in DRL + +Although you can define custom metadata attributes in DRL declarations, the {RULE_ENGINE} also supports the following predefined metadata tags for declarations of fact types or fact type attributes. +endif::[] + +[NOTE] +==== +The examples in this section that refer to the `VoiceCall` class assume that the sample application domain model includes the following class details: + +.VoiceCall fact class in an example Telecom domain model +[source,java] +---- +public class VoiceCall { + private String originNumber; + private String destinationNumber; + private Date callDateTime; + private long callDuration; // in milliseconds + + // Constructors, getters, and setters +} +---- +==== + +@role:: +This tag determines whether a given fact type is handled as a regular fact or an event in the {RULE_ENGINE} during complex event processing. ++ +-- +Default parameter: `fact` + +Supported parameters: `fact`, `event` + +[source] +---- +@role( fact | event ) +---- + +.Example: Declare VoiceCall as event type +[source] +---- +declare VoiceCall + @role( event ) +end +---- +-- + +@timestamp:: +This tag is automatically assigned to every event in the {RULE_ENGINE}. By default, the time is provided by the session clock and assigned to the event when it is inserted into the working memory of the {RULE_ENGINE}. You can specify a custom time stamp attribute instead of the default time stamp added by the session clock. ++ +-- +Default parameter: The time added by the {RULE_ENGINE} session clock + +Supported parameters: Session clock time or custom time stamp attribute + +[source] +---- +@timestamp( ) +---- + +.Example: Declare VoiceCall timestamp attribute +[source] +---- +declare VoiceCall + @role( event ) + @timestamp( callDateTime ) +end +---- +-- + +@duration:: +This tag determines the duration time for events in the {RULE_ENGINE}. Events can be interval-based events or point-in-time events. Interval-based events have a duration time and persist in the working memory of the {RULE_ENGINE} until their duration time has lapsed. Point-in-time events have no duration and are essentially interval-based events with a duration of zero. By default, every event in the {RULE_ENGINE} has a duration of zero. You can specify a custom duration attribute instead of the default. ++ +-- +Default parameter: Null (zero) + +Supported parameters: Custom duration attribute + +[source] +---- +@duration( ) +---- + +.Example: Declare VoiceCall duration attribute +[source] +---- +declare VoiceCall + @role( event ) + @timestamp( callDateTime ) + @duration( callDuration ) +end +---- +-- + +@expires:: +This tag determines the time duration before an event expires in the working memory of the {RULE_ENGINE}. By default, an event expires when the event can no longer match and activate any of the current rules. You can define an amount of time after which an event should expire. This tag definition also overrides the implicit expiration offset calculated from temporal constraints and sliding windows in the KIE base. This tag is available only when the {RULE_ENGINE} is running in stream mode. ++ +-- +Default parameter: Null (event expires after event can no longer match and activate rules) + +Supported parameters: Custom `timeOffset` attribute in the format `[##d][#h][#m][#s][#[ms]]` +// I had to put two #'s above for it to render only one. Otherwise removed the # from [d]. (Stetson, 28 May 2019) + +[source] +---- +@expires( ) +---- + +.Example: Declare expiration offset for VoiceCall events +[source] +---- +declare VoiceCall + @role( event ) + @timestamp( callDateTime ) + @duration( callDuration ) + @expires( 1h35m ) +end +---- +-- + +ifeval::["{context}" == "drl-rules"] +@typesafe:: +This tab determines whether a given fact type is compiled with or without type safety. By default, all type declarations are compiled with type safety enabled. You can override this behavior to type-unsafe evaluation, where all constraints are generated as MVEL constraints and executed dynamically. This is useful when dealing with collections that do not have any generics or mixed type collections. ++ +-- +Default parameter: `true` + +Supported parameters: `true`, `false` + +[source] +---- +@typesafe( ) +---- + +.Example: Declare VoiceCall for type-unsafe evaluation +[source] +---- +declare VoiceCall + @role( fact ) + @typesafe( false ) +end +---- +-- + +@serialVersionUID:: +This tag defines an identifying `serialVersionUID` value for a serializable class in a fact declaration. If a serializable class does not explicitly declare a `serialVersionUID`, the serialization run time calculates a default `serialVersionUID` value for that class based on various aspects of the class, as described in the https://docs.oracle.com/javase/10/docs/specs/serialization/index.html[Java Object Serialization Specification]. However, for optimal deserialization results and for greater compatibility with serialized KIE sessions, set the `serialVersionUID` as needed in the relevant class or in your DRL declarations. ++ +-- +Default parameter: Null + +Supported parameters: Custom `serialVersionUID` integer + +[source] +---- +@serialVersionUID( ) +---- + +.Example: Declare serialVersionUID for a VoiceCall class +[source] +---- +declare VoiceCall + @serialVersionUID( 42 ) +end +---- +-- + +@key:: +This tag enables a fact type attribute to be used as a key identifier for the fact type. The generated class can then implement the `equals()` and `hashCode()` methods to determine if two instances of the type are equal to each other. The {RULE_ENGINE} can also generate a constructor using all the key attributes as parameters. ++ +-- +Default parameter: None + +Supported parameters: None + +[source] +---- + @key +---- + +.Example: Declare Person type attributes as keys +[source] +---- +declare Person + firstName : String @key + lastName : String @key + age : int +end +---- + +For this example, the {RULE_ENGINE} checks the `firstName` and `lastName` attributes to determine if two instances of `Person` are equal to each other, but it does not check the `age` attribute. The {RULE_ENGINE} also implicitly generates three constructors: one without parameters, one with the `@key` fields, and one with all fields: + +.Example constructors from the key declarations +[source] +---- +Person() // Empty constructor + +Person( String firstName, String lastName ) + +Person( String firstName, String lastName, int age ) +---- + +You can then create instances of the type based on the key constructors, as shown in the following example: + +.Example instance using the key constructor +[source,java] +---- +Person person = new Person( "John", "Doe" ); +---- +-- + +@position:: +This tag determines the position of a declared fact type attribute or field in a positional argument, overriding the default declared order of attributes. You can use this tag to modify positional constraints in patterns while maintaining a consistent format in your type declarations and positional arguments. You can use this tag only for fields in classes on the classpath. If some fields in a single class use this tag and some do not, the attributes without this tag are positioned last, in the declared order. Inheritance of classes is supported, but not interfaces of methods. ++ +-- +Default parameter: None + +Supported parameters: Any integer + +[source] +---- + @position ( ) +---- + +.Example: Declare a fact type and override declared order +[source] +---- +declare Person + firstName : String @position( 1 ) + lastName : String @position( 0 ) + age : int @position( 2 ) + occupation: String +end +---- + +In this example, the attributes are prioritized in positional arguments in the following order: + +. `lastName` +. `firstName` +. `age` +. `occupation` + +In positional arguments, you do not need to specify the field name because the position maps to a known named field. For example, the argument `Person( lastName == "Doe" )` is the same as `Person( "Doe"; )`, where the `lastName` field has the highest position annotation in the DRL declaration. The semicolon `;` indicates that everything before it is a positional argument. You can mix positional and named arguments on a pattern by using the semicolon to separate them. Any variables in a positional argument that have not yet been bound are bound to the field that maps to that position. + +The following example patterns illustrate different ways of constructing positional and named arguments. The patterns have two constraints and a binding, and the semicolon differentiates the positional section from the named argument section. Variables and literals and expressions using only literals are supported in positional arguments, but not variables alone. + +.Example patterns with positional and named arguments +[source] +---- +Person( "Doe", "John", $a; ) + +Person( "Doe", "John"; $a : age ) + +Person( "Doe"; firstName == "John", $a : age ) + +Person( lastName == "Doe"; firstName == "John", $a : age ) +---- + +Positional arguments can be classified as _input arguments_ or _output arguments_. Input arguments contain a previously declared binding and constrain against that binding using unification. Output arguments generate the declaration and bind it to the field represented by the positional argument when the binding does not yet exist. + +In extended type declarations, use caution when defining `@position` annotations because the attribute positions are inherited in subtypes. This inheritance can result in a mixed attribute order that can be confusing in some cases. Two fields can have the same `@position` value and consecutive values do not need to be declared. If a position is repeated, the conflict is solved using inheritance, where position values in the parent type have precedence, and then using the declaration order from the first to last declaration. + +For example, the following extended type declarations result in mixed positional priorities: + +.Example extended fact type with mixed position annotations +[source] +---- +declare Person + firstName : String @position( 1 ) + lastName : String @position( 0 ) + age : int @position( 2 ) + occupation: String +end + +declare Student extends Person + degree : String @position( 1 ) + school : String @position( 0 ) + graduationDate : Date +end +---- + +In this example, the attributes are prioritized in positional arguments in the following order: + +. `lastName` (position 0 in the parent type) +. `school` (position 0 in the subtype) +. `firstName` (position 1 in the parent type) +. `degree` (position 1 in the subtype) +. `age` (position 2 in the parent type) +. `occupation` (first field with no position annotation) +. `graduationDate` (second field with no position annotation) +-- +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-with-metadata-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-with-metadata-con.adoc new file mode 100644 index 00000000000..0a2abb2d26e --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-with-metadata-con.adoc @@ -0,0 +1,43 @@ +[id='drl-declarations-with-metadata-con_{context}'] += Type declarations with metadata in DRL + +You can associate metadata in the format `@key(value)` (the value is optional) with fact types or fact attributes. Metadata can be any kind of data that is not represented by the fact attributes and is consistent among all instances of that fact type. The metadata can be queried at run time by the {RULE_ENGINE} and used in the reasoning process. Any metadata that you declare before the attributes of a fact type are assigned to the fact type, while metadata that you declare after an attribute are assigned to that particular attribute. + +In the following example, the two metadata attributes `@author` and `@dateOfCreation` are declared for the `Person` fact type, and the two metadata items `@key` and `@maxLength` are declared for the `name` attribute. The `@key` metadata attribute has no required value, so the parentheses and the value are omitted. + +.Example metadata declaration for fact types and attributes +[source] +---- +import java.util.Date + +declare Person + @author( Bob ) + @dateOfCreation( 01-Feb-2009 ) + + name : String @key @maxLength( 30 ) + dateOfBirth : Date + address : Address +end +---- + +For declarations of metadata attributes for existing types, you can identify the fully qualified class name as part of the `import` clause for all declarations or as part of the individual `declare` clause: + +.Example metadata declaration for an imported type +[source] +---- +import org.drools.examples.Person + +declare Person + @author( Bob ) + @dateOfCreation( 01-Feb-2009 ) +end +---- + +.Example metadata declaration for a declared type +[source] +---- +declare org.drools.examples.Person + @author( Bob ) + @dateOfCreation( 01-Feb-2009 ) +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-without-metadata-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-without-metadata-con.adoc new file mode 100644 index 00000000000..5bf64f3fa1c --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-declarations-without-metadata-con.adoc @@ -0,0 +1,83 @@ +[id='drl-declarations-without-metadata-con_{context}'] += Type declarations without metadata in DRL + +A declaration of a new fact does not require any metadata, but must include a list of attributes or fields. If a type declaration does not include identifying attributes, the {RULE_ENGINE} searches for an existing fact class in the classpath and raises an error if the class is missing. + +The following example is a declaration of a new fact type `Person` with no metadata in a DRL file: + +.Example declaration of a new fact type with a rule +[source] +---- +declare Person + name : String + dateOfBirth : java.util.Date + address : Address +end + +rule "Using a declared type" + when + $p : Person( name == "James" ) + then // Insert Mark, who is a customer of James. + Person mark = new Person(); + mark.setName( "Mark" ); + insert( mark ); +end +---- + +In this example, the new fact type `Person` has the three attributes `name`, `dateOfBirth`, and `address`. Each attribute has a type that can be any valid Java type, including another class that you create or a fact type that you previously declared. The `dateOfBirth` attribute has the type `java.util.Date`, from the Java API, and the `address` attribute has the previously defined fact type `Address`. + +To avoid writing the fully qualified name of a class every time you declare it, you can define the full class name as part of the `import` clause: + +.Example type declaration with the fully qualified class name in the import +[source] +---- +import java.util.Date + +declare Person + name : String + dateOfBirth : Date + address : Address +end +---- + +When you declare a new fact type, the {RULE_ENGINE} generates at compile time a Java class representing the fact type. The generated Java class is a one-to-one JavaBeans mapping of the type definition. + +For example, the following Java class is generated from the example `Person` type declaration: + +.Generated Java class for the Person fact type declaration +[source,java] +---- +public class Person implements Serializable { + private String name; + private java.util.Date dateOfBirth; + private Address address; + + // Empty constructor + public Person() {...} + + // Constructor with all fields + public Person( String name, Date dateOfBirth, Address address ) {...} + + // If keys are defined, constructor with keys + public Person( ...keys... ) {...} + + // Getters and setters + // `equals` and `hashCode` + // `toString` +} +---- + +You can then use the generated class in your rules like any other fact, as illustrated in the previous rule example with the `Person` type declaration: + +.Example rule that uses the declared Person fact type +[source] +---- +rule "Using a declared type" + when + $p : Person( name == "James" ) + then // Insert Mark, who is a customer of James. + Person mark = new Person(); + mark.setName( "Mark" ); + insert( mark ); +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-functions-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-functions-con.adoc new file mode 100644 index 00000000000..46995f85b37 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-functions-con.adoc @@ -0,0 +1,56 @@ +[id='drl-functions-con_{context}'] += Functions in DRL + +ifdef::DROOLS,JBPM,OP[] +.Function +image::language-reference/function.png[align="center"] +endif::[] + +Functions in DRL files put semantic code in your rule source file instead of in Java classes. Functions are especially useful if an action (`then`) part of a rule is used repeatedly and only the parameters differ for each rule. Above the rules in the DRL file, you can declare the function or import a static method from a helper class as a function, and then use the function by name in an action (`then`) part of the rule. + +The following examples illustrate a function that is either declared or an imported static method in a DRL file: + +.Example function declaration with a rule (option 1) +[source] +---- +function String hello(String applicantName) { + return "Hello " + applicantName + "!"; +} + +rule "Using a function" + when + // Empty + then + System.out.println( hello( "James" ) ); +end +---- + +.Example import a static method of a Java class (option 2) +[source,java] +---- +package org.example.applicant; + +public class MyFunctions { + + public static String hello(String applicantName) { + return "Hello " + applicantName + "!"; + } +} +---- + +[source] +---- +import static org.example.applicant.MyFunctions.hello; + +rule "Using a function" + when + // Empty + then + System.out.println( hello( "James" ) ); +end +---- + +[NOTE] +==== +A function declared in a DRL file cannot be imported to a rule in a different package while a Java static method in a different package can be imported. +==== diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-globals-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-globals-con.adoc new file mode 100644 index 00000000000..d189ff21dbc --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-globals-con.adoc @@ -0,0 +1,43 @@ +[id='drl-globals-con_{context}'] += Global variables in DRL + +ifdef::DROOLS,JBPM,OP[] +.Global +image::language-reference/global.png[align="center"] +endif::[] + +Global variables in DRL files typically provide data or services for the rules, such as application services used in rule consequences, and return data from rules, such as logs or values added in rule consequences. You set the global value in the working memory of the {RULE_ENGINE} through a KIE session configuration or REST operation, declare the global variable above the rules in the DRL file, and then use it in an action (`then`) part of the rule. For multiple global variables, use separate lines in the DRL file. + +The following example illustrates a global variable list configuration for the {RULE_ENGINE} and the corresponding global variable definition in the DRL file: + +.Example global list configuration for the {RULE_ENGINE} +[source] +---- +List list = new ArrayList<>(); +KieSession kieSession = kiebase.newKieSession(); +kieSession.setGlobal( "myGlobalList", list ); +---- + +.Example global variable definition with a rule +[source] +---- +global java.util.List myGlobalList; + +rule "Using a global" + when + // Empty + then + myGlobalList.add( "My global list" ); +end +---- + +[WARNING] +==== +Do not use global variables to establish conditions in rules unless a global variable has a constant immutable value. Global variables are not inserted into the working memory of the {RULE_ENGINE}, so the {RULE_ENGINE} cannot track value changes of variables. + +Do not use global variables to share data between rules. Rules always reason and react to the working memory state, so if you want to pass data from rule to rule, assert the data as facts into the working memory of the {RULE_ENGINE}. +==== + +A use case for a global variable might be an instance of an email service. In your integration code that is calling the {RULE_ENGINE}, you obtain your `emailService` object and then set it in the working memory of the {RULE_ENGINE}. In the DRL file, you declare that you have a global of type `emailService` and give it the name `"email"`, and then in your rule consequences, you can use actions such as `email.sendSMS(number, message)`. + +If you declare global variables with the same identifier in multiple packages, then you must set all the packages with the same type so that they all reference the same global value. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-imports-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-imports-con.adoc new file mode 100644 index 00000000000..ec8277cf632 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-imports-con.adoc @@ -0,0 +1,17 @@ +[id='drl-imports-con_{context}'] += Import statements in DRL + +ifdef::DROOLS,JBPM,OP[] +.Import +image::language-reference/import.png[align="center"] +endif::[] + +Similar to import statements in Java, imports in DRL files identify the fully qualified paths and type names for any objects that you want to use in the rules. You specify the package and data object in the format `packageName.objectName`, with multiple imports on separate lines. The {RULE_ENGINE} automatically imports classes from the Java package with the same name as the DRL package and from the package `java.lang`. + +The following example is an import statement for a loan application object in a mortgage application decision service: + +.Example import statement in a DRL file +[source] +---- +import org.mortgages.LoanApplication; +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operator-precedence-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operator-precedence-ref.adoc new file mode 100644 index 00000000000..25e0fa007a1 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operator-precedence-ref.adoc @@ -0,0 +1,73 @@ +[id='drl-operator-precedence-ref_{context}'] += Operator precedence in DRL pattern constraints + +DRL supports standard Java operator precedence for applicable constraint operators, with some exceptions and with some additional operators that are unique in DRL. The following table lists DRL operator precedence where applicable, from highest to lowest precedence: + +.Operator precedence in DRL pattern constraints +[cols="2,2,3", options="header"] +|=== +|Operator type +|Operators +|Notes + +|Nested or null-safe property access +|`.`, `.()`, `!.` +|Not standard Java semantics + +|`List` or `Map` access +|`[]` +|Not standard Java semantics + +|Constraint binding +|`:` +|Not standard Java semantics + +|Multiplicative +|`*`, `/%` +| + +|Additive +|`+`, `-` +| + +|Shift +|`>>`, `>>>`, `<<` +| + +|Relational +|`<`, `\<=`, `>`, `>=`, `instanceof` +| + +|Equality +|`== !=` +|Uses `equals()` and `!equals()` semantics, not standard Java `same` and `not same` semantics + + +|Non-short-circuiting `AND` +|`&` +| + +| Non-short-circuiting exclusive `OR` +|`^` +| + +|Non-short-circuiting inclusive `OR` +|`\|` +| + +|Logical `AND` +|`&&` +| + +|Logical `OR` +|`\|\|` +| + +|Ternary +|`? :` +| + +|Comma-separated `AND` +|`,` +|Not standard Java semantics +|=== diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operators-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operators-ref.adoc new file mode 100644 index 00000000000..2defce96958 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-operators-ref.adoc @@ -0,0 +1,244 @@ +[id='drl-operators-ref_{context}'] + += Supported operators in DRL pattern constraints + +DRL supports standard Java semantics for operators in pattern constraints, with some exceptions and with some additional operators that are unique in DRL. The following list summarizes the operators that are handled differently in DRL constraints than in standard Java semantics or that are unique in DRL constraints. + +`.()`, `#`:: +Use the `.()` operator to group property accessors to nested objects, and use the `#` operator to cast to a subtype in nested objects. Casting to a subtype makes the getters from the parent type available to the subtype. You can use either the object name or fully qualified class name, and you can cast to one or multiple subtypes. ++ +-- +.Example patterns with nested objects +[source] +---- +// Ungrouped property accessors: +Person( name == "mark", address.city == "london", address.country == "uk" ) + +// Grouped property accessors: +Person( name == "mark", address.( city == "london", country == "uk") ) +---- + +NOTE: The period prefix `.` differentiates the nested object constraints from a method call. + +.Example patterns with inline casting to a subtype +[source] +---- +// Inline casting with subtype name: +Person( name == "mark", address#LongAddress.country == "uk" ) + +// Inline casting with fully qualified class name: +Person( name == "mark", address#org.domain.LongAddress.country == "uk" ) + +// Multiple inline casts: +Person( name == "mark", address#LongAddress.country#DetailedCountry.population > 10000000 ) +---- +-- + +`!.`:: +Use this operator to dereference a property in a null-safe way. The value to the left of the `!.` operator must be not null (interpreted as `!= null`) in order to give a positive result for pattern matching. ++ +-- +.Example constraint with null-safe dereferencing +[source] +---- +Person( $streetName : address!.street ) + +// This is internally rewritten in the following way: + +Person( address != null, $streetName : address.street ) +---- +-- + +`[]`:: +Use this operator to access a `List` value by index or a `Map` value by key. ++ +-- +.Example constraints with `List` and `Map` access +[source] +---- +// The following format is the same as `childList(0).getAge() == 18`: +Person(childList[0].age == 18) + +// The following format is the same as `credentialMap.get("jdoe").isValid()`: +Person(credentialMap["jdoe"].valid) +---- +-- + +`<`, `\<=`, `>`, `>=`:: +Use these operators on properties with natural ordering. For example, for `Date` fields, the `<` operator means _before_, and for `String` fields, the operator means _alphabetically before_. These properties apply only to comparable properties. ++ +-- +.Example constraints with `before` operator +[source] +---- +Person( birthDate < $otherBirthDate ) + +Person( firstName < $otherFirstName ) +---- +-- + +`==`, `!=`:: +Use these operators as `equals()` and `!equals()` methods in constraints, instead of the usual `same` and `not same` semantics. ++ +-- +.Example constraint with null-safe equality +[source] +---- +Person( firstName == "John" ) + +// This is similar to the following formats: + +java.util.Objects.equals(person.getFirstName(), "John") +"John".equals(person.getFirstName()) +---- + +.Example constraint with null-safe not equality +[source] +---- +Person( firstName != "John" ) + +// This is similar to the following format: + +!java.util.Objects.equals(person.getFirstName(), "John") +---- +-- + +`&&`, `||`:: +Use these operators to create an abbreviated combined relation condition that adds more than one restriction on a field. You can group constraints with parentheses `()` to create a recursive syntax pattern. ++ +-- +.Example constraints with abbreviated combined relation +[source] +---- +// Simple abbreviated combined relation condition using a single `&&`: +Person(age > 30 && < 40) + +// Complex abbreviated combined relation using groupings: +Person(age ((> 30 && < 40) || (> 20 && < 25))) + +// Mixing abbreviated combined relation with constraint connectives: +Person(age > 30 && < 40 || location == "london") +---- + +ifdef::DROOLS,JBPM,OP[] +.Abbreviated combined relation condition +image::language-reference/abbreviatedCombinedRelationCondition.png[align="center"] + +.Abbreviated combined relation condition withparentheses +image::language-reference/abbreviatedCombinedRelationConditionGroup.png[align="center"] +endif::[] +-- + +`matches`, `not matches`:: +Use these operators to indicate that a field matches or does not match a specified Java regular expression. Typically, the regular expression is a `String` literal, but variables that resolve to a valid regular expression are also supported. These operators apply only to `String` properties. If you use `matches` against a `null` value, the resulting evaluation is always `false`. If you use `not matches` against a `null` value, the resulting evaluation is always `true`. As in Java, regular expressions that you write as `String` literals must use a double backslash `\\` to escape. ++ +-- +.Example constraint to match or not match a regular expression +[source] +---- +Person( country matches "(USA)?\\S*UK" ) + +Person( country not matches "(USA)?\\S*UK" ) +---- +-- + +`contains`, `not contains`:: +Use these operators to verify whether a field that is an `Array` or a `Collection` contains or does not contain a specified value. These operators apply to `Array` or `Collection` properties, but you can also use these operators in place of `String.contains()` and `!String.contains()` constraints checks. ++ +-- +.Example constraints with `contains` and `not contains` for a Collection +[source] +---- +// Collection with a specified field: +FamilyTree( countries contains "UK" ) + +FamilyTree( countries not contains "UK" ) + + +// Collection with a variable: +FamilyTree( countries contains $var ) + +FamilyTree( countries not contains $var ) +---- + +.Example constraints with `contains` and `not contains` for a String literal +[source] +---- +// Sting literal with a specified field: +Person( fullName contains "Jr" ) + +Person( fullName not contains "Jr" ) + + +// String literal with a variable: +Person( fullName contains $var ) + +Person( fullName not contains $var ) +---- + +NOTE: For backward compatibility, the `excludes` operator is a supported synonym for `not contains`. + +-- + +`memberOf`, `not memberOf`:: +Use these operators to verify whether a field is a member of or is not a member of an `Array` or a `Collection` that is defined as a variable. The `Array` or `Collection` must be a variable. ++ +-- +.Example constraints with `memberOf` and `not memberOf` with a Collection +[source] +---- +FamilyTree( person memberOf $europeanDescendants ) + +FamilyTree( person not memberOf $europeanDescendants ) +---- +-- + +`soundslike`:: +Use this operator to verify whether a word has almost the same sound, using English pronunciation, as the given value (similar to the `matches` operator). This operator uses the Soundex algorithm. ++ +-- +.Example constraint with `soundslike` +[source] +---- +// Match firstName "Jon" or "John": +Person( firstName soundslike "John" ) +---- +-- + +`str`:: +Use this operator to verify whether a field that is a `String` starts with or ends with a specified value. You can also use this operator to verify the length of the `String`. ++ +-- +.Example constraints with `str` +[source] +---- +// Verify what the String starts with: +Message( routingValue str[startsWith] "R1" ) + +// Verify what the String ends with: +Message( routingValue str[endsWith] "R2" ) + +// Verify the length of the String: +Message( routingValue str[length] 17 ) +---- +-- + +`in`, `notin`:: +Use these operators to specify more than one possible value to match in a constraint (compound value restriction). This functionality of compound value restriction is supported only in the `in` and `not in` operators. The second operand of these operators must be a comma-separated list of values enclosed in parentheses. You can provide values as variables, literals, return values, or qualified identifiers. These operators are internally rewritten as a list of multiple restrictions using the operators `==` or `!=`. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.compoundValueRestriction +image::language-reference/compoundValueRestriction.png[align="center"] +endif::[] + +.Example constraints with `in` and `notin` +[source] +---- +Person( $color : favoriteColor ) +Color( type in ( "red", "blue", $color ) ) + +Person( $color : favoriteColor ) +Color( type notin ( "red", "blue", $color ) ) +---- +-- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-packages-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-packages-con.adoc new file mode 100644 index 00000000000..11afed8471d --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-packages-con.adoc @@ -0,0 +1,26 @@ +[id='drl-packages-con_{context}'] += Packages in DRL + +A package is a folder of related assets in {PRODUCT}, such as data objects, DRL files, decision tables, and other asset types. A package also serves as a unique namespace for each group of rules. A single rule base can contain multiple packages. You typically store all the rules for a package in the same file as the package declaration so that the package is self-contained. However, you can import objects from other packages that you want to use in the rules. + +The following example is a package name and namespace for a DRL file in a mortgage application decision service: + +.Example package definition in a DRL file +[source] +---- +package org.mortgages; +---- + +ifdef::DROOLS,JBPM,OP[] +The following railroad diagram shows all the components that may make up a package: + +.Package +image::language-reference/package.png[align="center"] + +Note that a package _must_ have a namespace and be declared using standard Java conventions for package names; i.e., no spaces, unlike rule names which allow spaces. +In terms of the order of elements, they can appear in any order in the rule file, with the exception of the `package` statement, which must be at the top of the file. +In all cases, the semicolons are optional. + +Notice that any rule attribute (as described the section Rule Attributes) may also be written at package level, superseding the attribute's default value. +The modified default may still be replaced by an attribute setting within a rule. +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-queries-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-queries-con.adoc new file mode 100644 index 00000000000..24c9afc4845 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-queries-con.adoc @@ -0,0 +1,162 @@ +[id='drl-queries-con_{context}'] += Queries in DRL + +ifdef::DROOLS,JBPM,OP[] +.Query +image::language-reference/query.png[align="center"] +endif::[] + +Queries in DRL files search the working memory of the {RULE_ENGINE} for facts related to the rules in the DRL file. You add the query definitions in DRL files and then obtain the matching results in your application code. Queries search for a set of defined conditions and do not require `when` or `then` specifications. Query names are global to the KIE base and therefore must be unique among all other rule queries in the project. To return the results of a query, you construct a `QueryResults` definition using `ksession.getQueryResults("name")`, where `"name"` is the query name. This returns a list of query results, which enable you to retrieve the objects that matched the query. You define the query and query results parameters above the rules in the DRL file. + +The following example is a query definition in a DRL file for underage applicants in a mortgage application decision service, with the accompanying application code: + +.Example query definition in a DRL file +[source] +---- +query "people under the age of 21" + $person : Person( age < 21 ) +end +---- + +.Example application code to obtain query results +[source,java] +---- +QueryResults results = ksession.getQueryResults( "people under the age of 21" ); +System.out.println( "we have " + results.size() + " people under the age of 21" ); +---- + +You can also iterate over the returned `QueryResults` using a standard `for` loop. Each element is a `QueryResultsRow` that you can use to access each of the columns in the tuple. + +.Example application code to obtain and iterate over query results +[source,java] +---- +QueryResults results = ksession.getQueryResults( "people under the age of 21" ); +System.out.println( "we have " + results.size() + " people under the age of 21" ); + +System.out.println( "These people are under the age of 21:" ); + +for ( QueryResultsRow row : results ) { + Person person = ( Person ) row.get( "person" ); + System.out.println( person.getName() + "\n" ); +} +---- + +ifdef::DROOLS,JBPM,OP[] +Support for positional syntax has been added for more compact code. +By default the declared type order in the type declaration matches the argument position. +But it possible to override these using the @position annotation. +This allows patterns to be used with positional arguments, instead of the more verbose named arguments. + +[source] +---- +declare Cheese + name : String @position(1) + shop : String @position(2) + price : int @position(0) +end +---- + + +The @Position annotation, in the org.drools.definition.type package, can be used to annotate original pojos on the classpath. +Currently only fields on classes can be annotated. +Inheritance of classes is supported, but not interfaces or methods. +The isContainedIn query below demonstrates the use of positional arguments in a pattern; `Location(x, y;)` instead of `Location( thing == x, location == y).` + +Queries can now call other queries, this combined with optional query arguments provides derivation query style backward chaining. +Positional and named syntax is supported for arguments. +It is also possible to mix both positional and named, but positional must come first, separated by a semi colon. +Literal expressions can be passed as query arguments, but at this stage you cannot mix expressions with variables. +Here is an example of a query that calls another query. +Note that 'z' here will always be an 'out' variable. +The '?' symbol means the query is pull only, once the results are returned you will not receive further results as the underlying data changes. + +[source] +---- +declare Location + thing : String + location : String +end + +query isContainedIn( String x, String y ) + Location(x, y;) + or + ( Location(z, y;) and ?isContainedIn(x, z;) ) +end +---- + + +As previously mentioned you can use live "open" queries to reactively receive changes over time from the query results, as the underlying data it queries against changes. +Notice the "look" rule calls the query without using '?'. + +[source] +---- +query isContainedIn( String x, String y ) + Location(x, y;) + or + ( Location(z, y;) and isContainedIn(x, z;) ) +end + +rule look when + Person( $l : likes ) + isContainedIn( $l, 'office'; ) +then + insertLogical( $l 'is in the office' ); +end +---- + + +Drools supports unification for derivation queries, in short this means that arguments are optional. +It is possible to call queries from Java leaving arguments unspecified using the static field org.drools.core.runtime.rule.Variable.v - note you must use 'v' and not an alternative instance of Variable. +These are referred to as 'out' arguments. +Note that the query itself does not declare at compile time whether an argument is in or an out, this can be defined purely at runtime on each use. +The following example will return all objects contained in the office. + +[source] +---- +results = ksession.getQueryResults( "isContainedIn", new Object[] { Variable.v, "office" } ); +l = new ArrayList>(); +for ( QueryResultsRow r : results ) { + l.add( Arrays.asList( new String[] { (String) r.get( "x" ), (String) r.get( "y" ) } ) ); +} +---- + + +The algorithm uses stacks to handle recursion, so the method stack will not blow up. + +It is also possible to use as input argument for a query both the field of a fact as in: + +[source] +---- +query contains(String $s, String $c) + $s := String( this.contains( $c ) ) +end + +rule PersonNamesWithA when + $p : Person() + contains( $p.name, "a"; ) +then +end +---- + +and more in general any kind of valid expression like in: + +[source] +---- +query checkLength(String $s, int $l) + $s := String( length == $l ) +end + +rule CheckPersonNameLength when + $i : Integer() + $p : Person() + checkLength( $p.name, 1 + $i + $p.age; ) +then +end +---- + + +The following is not yet supported: + +* List and Map unification +* Expression unification - pred( X, X + 1, X * Y / 7 ) +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-advanced-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-advanced-con.adoc new file mode 100644 index 00000000000..bca73b39677 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-advanced-con.adoc @@ -0,0 +1,111 @@ +[id='drl-rules-THEN-advanced-con_{context}'] + += Advanced rule actions with conditional and named consequences + +In general, effective rule actions are small, declarative, and readable. However, in some cases, the limitation of having a single consequence for each rule can be challenging and lead to verbose and repetitive rule syntax, as shown in the following example rules: + +.Example rules with verbose and repetitive syntax +[source] +---- +rule "Give 10% discount to customers older than 60" + when + $customer : Customer( age > 60 ) + then + modify($customer) { setDiscount( 0.1 ) }; +end + +rule "Give free parking to customers older than 60" + when + $customer : Customer( age > 60 ) + $car : Car( owner == $customer ) + then + modify($car) { setFreeParking( true ) }; +end +---- + +A partial solution to the repetition is to make the second rule extend the first rule, as shown in the following modified example: + +.Partially enhanced example rules with an extended condition +[source] +---- +rule "Give 10% discount to customers older than 60" + when + $customer : Customer( age > 60 ) + then + modify($customer) { setDiscount( 0.1 ) }; +end + +rule "Give free parking to customers older than 60" + extends "Give 10% discount to customers older than 60" + when + $car : Car( owner == $customer ) + then + modify($car) { setFreeParking( true ) }; +end +---- + +As a more efficient alternative, you can consolidate the two rules into a single rule with modified conditions and labelled corresponding rule actions, as shown in the following consolidated example: + +.Consolidated example rule with conditional and named consequences +[source] +---- +rule "Give 10% discount and free parking to customers older than 60" + when + $customer : Customer( age > 60 ) + do[giveDiscount] + $car : Car( owner == $customer ) + then + modify($car) { setFreeParking( true ) }; + then[giveDiscount] + modify($customer) { setDiscount( 0.1 ) }; +end +---- + +This example rule uses two actions: the usual default action and another action named `giveDiscount`. The `giveDiscount` action is activated in the condition with the keyword `do` when a customer older than 60 years old is found in the KIE base, regardless of whether or not the customer owns a car. + +You can configure the activation of a named consequence with an additional condition, such as the `if` statement in the following example. The condition in the `if` statement is always evaluated on the pattern that immediately precedes it. + +.Consolidated example rule with an additional condition +[source] +---- +rule "Give free parking to customers older than 60 and 10% discount to golden ones among them" + when + $customer : Customer( age > 60 ) + if ( type == "Golden" ) do[giveDiscount] + $car : Car( owner == $customer ) + then + modify($car) { setFreeParking( true ) }; + then[giveDiscount] + modify($customer) { setDiscount( 0.1 ) }; +end +---- + +You can also evaluate different rule conditions using a nested `if` and `else if` construct, as shown in the following more complex example: + +.Consolidated example rule with more complex conditions +[source] +---- +rule "Give free parking and 10% discount to over 60 Golden customer and 5% to Silver ones" + when + $customer : Customer( age > 60 ) + if ( type == "Golden" ) do[giveDiscount10] + else if ( type == "Silver" ) break[giveDiscount5] + $car : Car( owner == $customer ) + then + modify($car) { setFreeParking( true ) }; + then[giveDiscount10] + modify($customer) { setDiscount( 0.1 ) }; + then[giveDiscount5] + modify($customer) { setDiscount( 0.05 ) }; +end +---- + +This example rule gives a 10% discount and free parking to Golden customers over 60, but only a 5% discount without free parking to Silver customers. The rule activates the consequence named `giveDiscount5` with the keyword `break` instead of `do`. The keyword `do` schedules a consequence in the {RULE_ENGINE} agenda, enabling the remaining part of the rule conditions to continue being evaluated, while `break` blocks any further condition evaluation. If a named consequence does not correspond to any condition with `do` but is activated with `break`, the rule fails to compile because the conditional part of the rule is never reached. + +ifdef::DROOLS,JBPM,OP[] +ifdef::backend-docbook[] +[index] +== Index +// Generated automatically by the DocBook toolchain. +endif::backend-docbook[] +endif::DROOLS,JBPM,OP[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-con.adoc new file mode 100644 index 00000000000..60815d55290 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-con.adoc @@ -0,0 +1,19 @@ +[id='drl-rules-THEN-con_{context}'] += Rule actions in DRL (THEN) + +The `then` part of the rule (also known as the _Right Hand Side (RHS)_ of the rule) contains the actions to be performed when the conditional part of the rule has been met. Actions consist of one or more _methods_ that execute consequences based on the rule conditions and on available data objects in the package. For example, if a bank requires loan applicants to be over 21 years of age (with a rule condition `Applicant( age < 21 )`) and a loan applicant is under 21 years old, the `then` action of an `"Underage"` rule would be `setApproved( false )`, declining the loan because the applicant is under age. + +The main purpose of rule actions is to insert, delete, or modify data in the working memory of the {RULE_ENGINE}. Effective rule actions are small, declarative, and readable. If you need to use imperative or conditional code in rule actions, then divide the rule into multiple smaller and more declarative rules. + +.Example rule for loan application age limit +[source] +---- +rule "Underage" + when + application : LoanApplication() + Applicant( age < 21 ) + then + application.setApproved( false ); + application.setExplanation( "Underage" ); +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-ref.adoc new file mode 100644 index 00000000000..021daebde99 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-ref.adoc @@ -0,0 +1,128 @@ +[id='drl-rules-THEN-methods-ref_{context}'] += Supported rule action methods in DRL + +DRL supports the following rule action methods that you can use in DRL rule actions. You can use these methods to modify the working memory of the {RULE_ENGINE} without having to first reference a working memory instance. These methods act as shortcuts to the methods provided by the `RuleContext` class in your {PRODUCT} distribution. + +For all rule action methods, +ifdef::DM,PAM[] +download the *{PRODUCT_PAM} {PRODUCT_VERSION_LONG} Source Distribution* ZIP file from the https://access.redhat.com/jbossnetwork/restricted/listSoftware.html[Red Hat Customer Portal] and navigate to `~/{PRODUCT_FILE}-sources/src/kie-api-parent-$VERSION/kie-api/src/main/java/org/kie/api/runtime/rule/RuleContext.java`. +endif::[] +ifdef::DROOLS,JBPM,OP[] +see the {PRODUCT} https://github.com/kiegroup/droolsjbpm-knowledge/blob/{COMMUNITY_VERSION_BRANCH}/kie-api/src/main/java/org/kie/api/runtime/rule/RuleContext.java[RuleContext.java] page in GitHub. +endif::[] + +`set`:: +Use this to set the value of a field. ++ +-- +[source,subs="attributes+"] +---- +set ( ) +---- + +.Example rule action to set the values of a loan application approval +[source] +---- +$application.setApproved ( false ); +$application.setExplanation( "has been bankrupt" ); +---- +-- + +`modify`:: +Use this to specify fields to be modified for a fact and to notify the {RULE_ENGINE} of the change. This method provides a structured approach to fact updates. It combines the `update` operation with setter calls to change object fields. ++ +-- +[source] +---- +modify ( ) { + , + , + ... +} +---- + +.Example rule action to modify a loan application amount and approval +[source] +---- +modify( LoanApplication ) { + setAmount( 100 ), + setApproved ( true ) +} +---- +-- + +`update`:: +Use this to specify fields and the entire related fact to be updated and to notify the {RULE_ENGINE} of the change. After a fact has changed, you must call `update` before changing another fact that might be affected by the updated values. To avoid this added step, use the `modify` method instead. ++ +-- +[source,subs="attributes+"] +---- +update ( ) // Informs the {RULE_ENGINE} that an object has changed + +update ( ) // Causes `KieSession` to search for a fact handle of the object +---- + +.Example rule action to update a loan application amount and approval +[source] +---- +LoanApplication.setAmount( 100 ); +update( LoanApplication ); +---- + +NOTE: If you provide property-change listeners, you do not need to call this method when an object changes. For more information about property-change listeners, see +ifdef::DM,PAM[] +{URL_DEVELOPING_DECISION_SERVICES}#property-change-listeners-con_decision-engine[_{RULE_ENGINE_DOC}_]. +endif::[] +ifdef::DROOLS,JBPM,OP[] +xref:property-change-listeners-con_decision-engine[]. +endif::[] + +-- + +`insert`:: +Use this to insert a `new` fact into the working memory of the {RULE_ENGINE} and to define resulting fields and values as needed for the fact. ++ +-- +[source,subs="attributes+"] +---- +insert( new ); +---- + +.Example rule action to insert a new loan applicant object +[source] +---- +insert( new Applicant() ); +---- +-- + +`insertLogical`:: +Use this to insert a `new` fact logically into the {RULE_ENGINE}. The {RULE_ENGINE} is responsible for logical decisions on insertions and retractions of facts. After regular or stated insertions, facts must be retracted explicitly. After logical insertions, the facts that were inserted are automatically retracted when the conditions in the rules that inserted the facts are no longer true. ++ +-- +[source] +---- +insertLogical( new ); +---- + +.Example rule action to logically insert a new loan applicant object +[source] +---- +insertLogical( new Applicant() ); +---- +-- + +`delete`:: +Use this to remove an object from the {RULE_ENGINE}. The keyword `retract` is also supported in DRL and executes the same action, but `delete` is typically preferred in DRL code for consistency with the keyword `insert`. ++ +-- +[source] +---- +delete( ); +---- + +.Example rule action to delete a loan applicant object +[source] +---- +delete( Applicant ); +---- +-- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-variables-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-variables-ref.adoc new file mode 100644 index 00000000000..998feed80ee --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-THEN-methods-variables-ref.adoc @@ -0,0 +1,34 @@ +[id='drl-rules-THEN-methods-variables-ref_{context}'] += Other rule action methods from `drools` variable + +In addition to the standard rule action methods, the {RULE_ENGINE} supports methods in conjunction with the predefined `drools` variable that you can also use in rule actions. + +You can use the `drools` variable to call methods from the `org.kie.api.runtime.rule.RuleContext` class in your {PRODUCT} distribution, which is also the class that the standard rule action methods are based on. For all `drools` rule action options, +ifdef::DM,PAM[] +download the *{PRODUCT_PAM} {PRODUCT_VERSION_LONG} Source Distribution* ZIP file from the https://access.redhat.com/jbossnetwork/restricted/listSoftware.html[Red Hat Customer Portal] and navigate to `~/{PRODUCT_FILE}-sources/src/kie-api-parent-$VERSION/kie-api/src/main/java/org/kie/api/runtime/rule/RuleContext.java`. +endif::[] +ifdef::DROOLS,JBPM,OP[] +see the {PRODUCT} https://github.com/kiegroup/droolsjbpm-knowledge/blob/{COMMUNITY_VERSION_BRANCH}/kie-api/src/main/java/org/kie/api/runtime/rule/RuleContext.java[RuleContext.java] page in GitHub. +endif::[] + +The `drools` variable contains methods that provide information about the firing rule and the set of facts that activated the firing rule: + +* `drools.getRule().getName()`: Returns the name of the currently firing rule. +* `drools.getMatch()`: Returns the `Match` that activated the currently firing rule. It contains information that is useful for logging and debugging purposes, for instance `drools.getMatch().getObjects()` returns the list of objects, enabling rule to fire in the proper tuple order. + +From the `drools` variable, you can also obtain a reference to the `KieRuntime` providing useful methods to interact with the running session, for example: + +* `drools.getKieRuntime().halt()`: Terminates rule execution if a user or application previously called `fireUntilHalt()`. When a user or application calls `fireUntilHalt()` method, the {RULE_ENGINE} starts in `active` mode and evaluates rules until the user or application explicitly calls `halt()` method. Otherwise, by default, the {RULE_ENGINE} runs in `passive` mode and evaluates rules only when a user or an application explicitly calls `fireAllRules()` method. +* `drools.getKieRuntime().getAgenda()`: Returns a reference to the KIE session `Agenda`, and in turn provides access to rule activation groups, rule agenda groups, and ruleflow groups. + +.Example call to access agenda group "CleanUp" and set the focus +[source,java] +---- +drools.getKieRuntime().getAgenda().getAgendaGroup( "CleanUp" ).setFocus(); +---- ++ +This example sets the focus to a specified agenda group to which the rule belongs. + +* `drools.getKieRuntime().setGlobal()`, `~.getGlobal()`, `~.getGlobals()`: Sets or retrieves global variables. +* `drools.getKieRuntime().getEnvironment()`: Returns the runtime `Environment`, similar to your operating system environment. +* `drools.getKieRuntime().getQueryResults( query)`: Runs a query and returns the results. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-con.adoc new file mode 100644 index 00000000000..0fb4c1700b0 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-con.adoc @@ -0,0 +1,377 @@ +[id='drl-rules-WHEN-con_{context}'] += Rule conditions in DRL (WHEN) + +ifdef::DROOLS,JBPM,OP[] +.Rule +image::language-reference/rule.png[align="center"] + +.Conditional element in a rule +image::language-reference/lhs.png[align="center"] +endif::[] + +The `when` part of a DRL rule (also known as the _Left Hand Side (LHS)_ of the rule) contains the conditions that must be met to execute an action. Conditions consist of a series of stated _patterns_ and _constraints_, with optional _bindings_ and supported rule condition elements (keywords), based on the available data objects in the package. For example, if a bank requires loan applicants to have over 21 years of age, then the `when` condition of an `"Underage"` rule would be `Applicant( age < 21 )`. + +NOTE: DRL uses `when` instead of `if` because `if` is typically part of a procedural execution flow during which a condition is checked at a specific point in time. In contrast, `when` indicates that the condition evaluation is not limited to a specific evaluation sequence or point in time, but instead occurs continually at any time. Whenever the condition is met, the actions are executed. + +If the `when` section is empty, then the conditions are considered to be true and the actions in the `then` section are executed the first time a `fireAllRules()` call is made in the {RULE_ENGINE}. This is useful if you want to use rules to set up the {RULE_ENGINE} state. + +The following example rule uses empty conditions to insert a fact every time the rule is executed: + +.Example rule without conditions +[source] +---- +rule "Always insert applicant" + when + // Empty + then // Actions to be executed once + insert( new Applicant() ); +end + +// The rule is internally rewritten in the following way: + +rule "Always insert applicant" + when + eval( true ) + then + insert( new Applicant() ); +end +---- + +If rule conditions use multiple patterns with no defined keyword conjunctions (such as `and`, `or`, or `not`), the default conjunction is `and`: + +.Example rule without keyword conjunctions +[source] +---- +rule "Underage" + when + application : LoanApplication() + Applicant( age < 21 ) + then + // Actions +end + +// The rule is internally rewritten in the following way: + +rule "Underage" + when + application : LoanApplication() + and Applicant( age < 21 ) + then + // Actions +end +---- + +== Patterns and constraints + +A _pattern_ in a DRL rule condition is the segment to be matched by the {RULE_ENGINE}. A pattern can potentially match each fact that is inserted into the working memory of the {RULE_ENGINE}. A pattern can also contain _constraints_ to further define the facts to be matched. + +ifdef::DROOLS,JBPM,OP[] +The railroad diagram below shows the syntax for this: + +.Pattern +image::language-reference/Pattern.png[align="center"] +endif::[] + +In the simplest form, with no constraints, a pattern matches a fact of the given type. In the following example, the type is `Person`, so the pattern will match against all `Person` objects in the working memory of the {RULE_ENGINE}: + +.Example pattern for a single fact type +[source] +---- +Person() +---- + +The type does not need to be the actual class of some fact object. Patterns can refer to superclasses or even interfaces, potentially matching facts from many different classes. For example, the following pattern matches all objects in the working memory of the {RULE_ENGINE}: + +.Example pattern for all objects +[source] +---- +Object() // Matches all objects in the working memory +---- + +The parentheses of a pattern enclose the constraints, such as the following constraint on the person's age: + +.Example pattern with a constraint +[source] +---- +Person( age == 50 ) +---- + +A _constraint_ is an expression that returns `true` or `false`. Pattern constraints in DRL are essentially Java expressions with some enhancements, such as property access, and some differences, such as `equals()` and `!equals()` semantics for `==` and `!=` (instead of the usual `same` and `not same` semantics). + +Any JavaBeans property can be accessed directly from pattern constraints. A bean property is exposed internally using a standard JavaBeans getter that takes no arguments and returns something. For example, the `age` property is written as `age` in DRL instead of the getter `getAge()`: + +.DRL constraint syntax with JavaBeans properties +[source] +---- +Person( age == 50 ) + +// This is the same as the following getter format: + +Person( getAge() == 50 ) +---- + +{PRODUCT} uses the standard JDK `Introspector` class to achieve this mapping, so it follows the standard JavaBeans specification. For optimal {RULE_ENGINE} performance, use the property access format, such as `age`, instead of using getters explicitly, such as `getAge()`. + +[WARNING] +==== +Do not use property accessors to change the state of the object in a way that might affect the rules because the {RULE_ENGINE} caches the results of the match between invocations for higher efficiency. + +For example, do not use property accessors in the following ways: + +[source,java] +---- +public int getAge() { + age++; // Do not do this. + return age; +} +---- + +[source,java] +---- +public int getAge() { + Date now = DateUtil.now(); // Do not do this. + return DateUtil.differenceInYears(now, birthday); +} +---- + +Instead of following the second example, insert a fact that wraps the current date in the working memory and update that fact between `fireAllRules()` as needed. +==== + +However, if the getter of a property cannot be found, the compiler uses the property name as a fallback method name, without arguments: + +.Fallback method if object is not found +[source] +---- +Person( age == 50 ) + +// If `Person.getAge()` does not exist, the compiler uses the following syntax: + +Person( age() == 50 ) +---- + +You can also nest access properties in patterns, as shown in the following example. Nested properties are indexed by the {RULE_ENGINE}. + +.Example pattern with nested property access +[source] +---- +Person( address.houseNumber == 50 ) + +// This is the same as the following format: + +Person( getAddress().getHouseNumber() == 50 ) +---- + +WARNING: In stateful KIE sessions, use nested accessors carefully because the working memory of the {RULE_ENGINE} is not aware of any of the nested values and does not detect when they change. Either consider the nested values immutable while any of their parent references are inserted into the working memory, or, if you want to modify a nested value, mark all of the outer facts as updated. In the previous example, when the `houseNumber` property changes, any `Person` with that `Address` must be marked as updated. + +You can use any Java expression that returns a `boolean` value as a constraint inside the parentheses of a pattern. Java expressions can be mixed with other expression enhancements, such as property access: + +.Example pattern with a constraint using property access and Java expression +[source] +---- +Person( age == 50 ) +---- + +You can change the evaluation priority by using parentheses, as in any logical or mathematical expression: + +.Example evaluation order of constraints +[source] +---- +Person( age > 100 && ( age % 10 == 0 ) ) +---- + +You can also reuse Java methods in constraints, as shown in the following example: + +.Example constraints with reused Java methods +[source] +---- +Person( Math.round( weight / ( height * height ) ) < 25.0 ) +---- + +[WARNING] +==== +Do not use constraints to change the state of the object in a way that might affect the rules because the {RULE_ENGINE} caches the results of the match between invocations for higher efficiency. Any method that is executed on a fact in the rule conditions must be a read-only method. Also, the state of a fact should not change between rule invocations unless those facts are marked as updated in the working memory on every change. + +For example, do not use a pattern constraint in the following ways: + +[source] +---- +Person( incrementAndGetAge() == 10 ) // Do not do this. +---- + +[source] +---- +Person( System.currentTimeMillis() % 1000 == 0 ) // Do not do this. +---- +==== + +Standard Java operator precedence applies to constraint operators in DRL, and DRL operators follow standard Java semantics except for the `==` and `!=` operators. + +The `==` operator uses null-safe `equals()` semantics instead of the usual `same` semantics. For example, the pattern `Person( firstName == "John" )` is similar to `java.util.Objects.equals(person.getFirstName(), "John")`, and because `"John"` is not null, the pattern is also similar to `"John".equals(person.getFirstName())`. + +The `!=` operator uses null-safe `!equals()` semantics instead of the usual `not same` semantics. For example, the pattern `Person( firstName != "John" )` is similar to `!java.util.Objects.equals(person.getFirstName(), "John")`. + +If the field and the value of a constraint are of different types, the {RULE_ENGINE} uses type coercion to resolve the conflict and reduce compilation errors. For instance, if `"ten"` is provided as a string in a numeric evaluator, a compilation error occurs, whereas `"10"` is coerced to a numeric 10. In coercion, the field type always takes precedence over the value type: + +.Example constraint with a value that is coerced +[source] +---- +Person( age == "10" ) // "10" is coerced to 10 +---- + +For groups of constraints, you can use a delimiting comma `,` to use implicit `and` connective semantics: + +.Example patterns with multiple constraints +[source] +---- +// Person is at least 50 years old and weighs at least 80 kilograms: +Person( age > 50, weight > 80 ) + +// Person is at least 50 years old, weighs at least 80 kilograms, and is taller than 2 meters: +Person( age > 50, weight > 80, height > 2 ) +---- + +NOTE: Although the `&&` and `,` operators have the same semantics, they are resolved with different priorities. The `&&` operator precedes the `||` operator, and both the `&&` and `||` operators together precede the `,` operator. Use the comma operator at the top-level constraint for optimal {RULE_ENGINE} performance and human readability. + +You cannot embed a comma operator in a composite constraint expression, such as in parentheses: + +.Example of misused comma in composite constraint expression +[source] +---- +// Do not use the following format: +Person( ( age > 50, weight > 80 ) || height > 2 ) + +// Use the following format instead: +Person( ( age > 50 && weight > 80 ) || height > 2 ) +---- + +== Bound variables in patterns and constraints + +You can bind variables to patterns and constraints to refer to matched objects in other portions of a rule. Bound variables can help you define rules more efficiently or more consistently with how you annotate facts in your data model. To differentiate more easily between variables and fields in a rule, use the standard format `$variable` for variables, especially in complex rules. This convention is helpful but not required in DRL. + +For example, the following DRL rule uses the variable `$p` for a pattern with the `Person` fact: + +.Pattern with a bound variable +[source] +---- +rule "simple rule" + when + $p : Person() + then + System.out.println( "Person " + $p ); +end +---- + +Similarly, you can also bind variables to properties in pattern constraints, as shown in the following example: + +[source] +---- +// Two persons of the same age: +Person( $firstAge : age ) // Binding +Person( age == $firstAge ) // Constraint expression +---- + +[NOTE] +==== +Constraint binding considers only the first atomic expression that follows it. In the following example the pattern only binds the age of the person to the variable `$a`: + +[source] +---- +Person( $a : age * 2 < 100 ) +---- + + +For clearer and more efficient rule definitions, separate constraint bindings and constraint expressions. Although mixed bindings and expressions are supported, which can complicate patterns and affect evaluation efficiency. + +[source] +---- +// Do not use the following format: +Person( $a : age * 2 < 100 ) + +// Use the following format instead: +Person( age * 2 < 100, $a : age ) +---- + +In the preceding example, if you want to bind to the variable `$a` the double of the person's age, you must make it an atomic expression by wrapping it in parentheses as shown in the following example: + +[source] +---- +Person( $a : (age * 2) ) +---- +==== + +The {RULE_ENGINE} does not support bindings to the same declaration, but does support _unification_ of arguments across several properties. While positional arguments are always processed with unification, the unification symbol `:=` exists for named arguments. + +The following example patterns unify the `age` property across two `Person` facts: + +.Example pattern with unification +[source] +---- +Person( $age := age ) +Person( $age := age ) +---- + +Unification declares a binding for the first occurrence and constrains to the same value of the bound field for sequence occurrences. + +== Nested constraints and inline casts + +In some cases, you might need to access multiple properties of a nested object, as shown in the following example: + +.Example pattern to access multiple properties +[source] +---- +Person( name == "mark", address.city == "london", address.country == "uk" ) +---- + +You can group these property accessors to nested objects with the syntax `.( )` for more readable rules, as shown in the following example: + +.Example pattern with grouped constraints +[source] +---- +Person( name == "mark", address.( city == "london", country == "uk") ) +---- + +NOTE: The period prefix `.` differentiates the nested object constraints from a method call. + +When you work with nested objects in patterns, you can use the syntax `#` to cast to a subtype and make the getters from the parent type available to the subtype. You can use either the object name or fully qualified class name, and you can cast to one or multiple subtypes, as shown in the following examples: + +.Example patterns with inline casting to a subtype +[source] +---- +// Inline casting with subtype name: +Person( name == "mark", address#LongAddress.country == "uk" ) + +// Inline casting with fully qualified class name: +Person( name == "mark", address#org.domain.LongAddress.country == "uk" ) + +// Multiple inline casts: +Person( name == "mark", address#LongAddress.country#DetailedCountry.population > 10000000 ) +---- + +These example patterns cast `Address` to `LongAddress`, and additionally to `DetailedCountry` in the last example, making the parent getters available to the subtypes in each case. + +You can use the `instanceof` operator to infer the results of the specified type in subsequent uses of that field with the pattern, as shown in the following example: + +[source] +---- +Person( name == "mark", address instanceof LongAddress, address.country == "uk" ) +---- + +If an inline cast is not possible (for example, if `instanceof` returns `false`), the evaluation is considered `false`. + +== Date literal in constraints + +By default, the {RULE_ENGINE} supports the date format `dd-mmm-yyyy`. You can customize the date format, including a time format mask if needed, by providing an alternative format mask with the system property `drools.dateformat="dd-mmm-yyyy hh:mm"`. You can also customize the date format by changing the language locale with the `drools.defaultlanguage` and `drools.defaultcountry` system properties (for example, the locale of Thailand is set as `drools.defaultlanguage=th` and `drools.defaultcountry=TH`). + +.Example pattern with a date literal restriction +[source] +---- +Person( bornBefore < "27-Oct-2009" ) +---- + +ifdef::DROOLS,JBPM,OP[] +== Auto-boxing and primitive types + +Drools attempts to preserve numbers in their primitive or object wrapper form, so a variable bound to an int primitive when used in a code block or expression will no longer need manual unboxing; unlike early Drools versions where all primitives were autoboxed, requiring manual unboxing. +A variable bound to an object wrapper will remain as an object; the existing JDK 1.5 and JDK 5 rules to handle auto-boxing and unboxing apply in this case. +When evaluating field constraints, the system attempts to coerce one of the values into a comparable format; so a primitive is comparable to an object wrapper. +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-elements-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-elements-ref.adoc new file mode 100644 index 00000000000..8299167b8af --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-WHEN-elements-ref.adoc @@ -0,0 +1,785 @@ +[id='drl-rules-WHEN-elements-ref_{context}'] + += Supported rule condition elements in DRL (keywords) + +DRL supports the following rule condition elements (keywords) that you can use with the patterns that you define in DRL rule conditions: + +`and`:: +Use this to group conditional components into a logical conjunction. Infix and prefix `and` are supported. You can group patterns explicitly with parentheses `()`. By default, all listed patterns are combined with `and` when no conjunction is specified. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.infixAnd +image::language-reference/infixAnd.png[align="center"] + +.prefixAnd +image::language-reference/prefixAnd.png[align="center"] +endif::[] + +.Example patterns with `and` +[source] +---- +//Infix `and`: +Color( colorType : type ) and Person( favoriteColor == colorType ) + +//Infix `and` with grouping: +(Color( colorType : type ) and (Person( favoriteColor == colorType ) or Person( favoriteColor == colorType )) + +// Prefix `and`: +(and Color( colorType : type ) Person( favoriteColor == colorType )) + +// Default implicit `and`: +Color( colorType : type ) +Person( favoriteColor == colorType ) +---- + +[NOTE] +==== +Do not use a leading declaration binding with the `and` keyword (as you can with `or`, for example). A declaration can only reference a single fact at a time, and if you use a declaration binding with `and`, then when `and` is satisfied, it matches both facts and results in an error. + +.Example misuse of `and` +[source] +---- +// Causes compile error: +$person : (Person( name == "Romeo" ) and Person( name == "Juliet")) +---- +==== +-- + +`or`:: +Use this to group conditional components into a logical disjunction. Infix and prefix `or` are supported. You can group patterns explicitly with parentheses `()`. You can also use pattern binding with `or`, but each pattern must be bound separately. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.infixOr +image::language-reference/infixOr.png[align="center"] + +.prefixOr +image::language-reference/prefixOr.png[align="center"] +endif::[] + +.Example patterns with `or` +[source] +---- +//Infix `or`: +Color( colorType : type ) or Person( favoriteColor == colorType ) + +//Infix `or` with grouping: +(Color( colorType : type ) or (Person( favoriteColor == colorType ) and Person( favoriteColor == colorType )) + +// Prefix `or`: +(or Color( colorType : type ) Person( favoriteColor == colorType )) +---- + +.Example patterns with `or` and pattern binding +[source] +---- +pensioner : (Person( sex == "f", age > 60 ) or Person( sex == "m", age > 65 )) + +(or pensioner : Person( sex == "f", age > 60 ) + pensioner : Person( sex == "m", age > 65 )) +---- + +The {RULE_ENGINE} does not directly interpret the `or` element but uses logical transformations to rewrite a rule with `or` as a number of sub-rules. This process ultimately results in a rule that has a single `or` as the root node and one sub-rule for each of its condition elements. Each sub-rule is activated and executed like any normal rule, with no special behavior or interaction between the sub-rules. + +Therefore, consider the `or` condition element a shortcut for generating two or more similar rules that, in turn, can create multiple activations when two or more terms of the disjunction are true. +-- + +`exists`:: +Use this to specify facts and constraints that must exist. This option is triggered on only the first match, not subsequent matches. If you use this element with multiple patterns, enclose the patterns with parentheses `()`. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.Exists +image::language-reference/exists.png[align="center"] +endif::[] + +.Example patterns with `exists` +[source] +---- +exists Person( firstName == "John") + +exists (Person( firstName == "John", age == 42 )) + +exists (Person( firstName == "John" ) and + Person( lastName == "Doe" )) +---- +-- + +`not`:: +Use this to specify facts and constraints that must not exist. If you use this element with multiple patterns, enclose the patterns with parentheses `()`. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.Not +image::language-reference/not.png[align="center"] +endif::[] + +.Example patterns with `not` +[source] +---- +not Person( firstName == "John") + +not (Person( firstName == "John", age == 42 )) + +not (Person( firstName == "John" ) and + Person( lastName == "Doe" )) +---- +-- + +`forall`:: +Use this to verify whether all facts that match the first pattern match all the remaining patterns. When a `forall` construct is satisfied, the rule evaluates to `true`. This element is a scope delimiter, so it can use any previously bound variable, but no variable bound inside of it is available for use outside of it. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.Forall +image::language-reference/forall.png[align="center"] +endif::[] + +.Example rule with `forall` +[source] +---- +rule "All full-time employees have red ID badges" + when + forall( $emp : Employee( type == "fulltime" ) + Employee( this == $emp, badgeColor = "red" ) ) + then + // True, all full-time employees have red ID badges. +end +---- + +In this example, the rule selects all `Employee` objects whose type is `"fulltime"`. For each fact that matches this pattern, the rule evaluates the patterns that follow (badge color) and if they match, the rule evaluates to `true`. + +To state that all facts of a given type in the working memory of the {RULE_ENGINE} must match a set of constraints, you can use `forall` with a single pattern for simplicity. + +.Example rule with `forall` and a single pattern +[source] +---- +rule "All full-time employees have red ID badges" + when + forall( Employee( badgeColor = "red" ) ) + then + // True, all full-time employees have red ID badges. +end +---- + +You can use `forall` constructs with multiple patterns or nest them with other condition elements, such as inside a `not` element construct. + +.Example rule with `forall` and multiple patterns +[source] +---- +rule "All employees have health and dental care programs" + when + forall( $emp : Employee() + HealthCare( employee == $emp ) + DentalCare( employee == $emp ) + ) + then + // True, all employees have health and dental care. +end +---- + +.Example rule with `forall` and `not` +[source] +---- +rule "Not all employees have health and dental care" + when + not ( forall( $emp : Employee() + HealthCare( employee == $emp ) + DentalCare( employee == $emp ) ) + ) + then + // True, not all employees have health and dental care. +end +---- + +NOTE: The format `forall( p1 p2 p3 ...)` is equivalent to `not( p1 and not( and p2 p3 ... ) )`. + +-- + +`from`:: +Use this to specify a data source for a pattern. This enables the {RULE_ENGINE} to reason over data that is not in the working memory. The data source can be a sub-field on a bound variable or the result of a method call. The expression used to define the object source is any expression that follows regular MVEL syntax. Therefore, the `from` element enables you to easily use object property navigation, execute method calls, and access maps and collection elements. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.from +image::language-reference/from.png[align="center"] +endif::[] + +.Example rule with `from` and pattern binding +[source] +---- +rule "Validate zipcode" + when + Person( $personAddress : address ) + Address( zipcode == "23920W" ) from $personAddress + then + // Zip code is okay. +end +---- + +.Example rule with `from` and a graph notation +[source] +---- +rule "Validate zipcode" + when + $p : Person() + $a : Address( zipcode == "23920W" ) from $p.address + then + // Zip code is okay. +end +---- + +.Example rule with `from` to iterate over all objects +[source] +---- +rule "Apply 10% discount to all items over US$ 100 in an order" + when + $order : Order() + $item : OrderItem( value > 100 ) from $order.items + then + // Apply discount to `$item`. +end +---- + +[NOTE] +==== +For large collections of objects, instead of adding an object with a large graph that the {RULE_ENGINE} must iterate over frequently, add the collection directly to the KIE session and then join the collection in the condition, as shown in the following example: + +[source] +---- +when + $order : Order() + OrderItem( value > 100, order == $order ) +---- +==== + +.Example rule with `from` and `lock-on-active` rule attribute +[source] +---- +rule "Assign people in North Carolina (NC) to sales region 1" + ruleflow-group "test" + lock-on-active true + when + $p : Person() + $a : Address( state == "NC" ) from $p.address + then + modify ($p) {} // Assign the person to sales region 1. +end + +rule "Apply a discount to people in the city of Raleigh" + ruleflow-group "test" + lock-on-active true + when + $p : Person() + $a : Address( city == "Raleigh" ) from $p.address + then + modify ($p) {} // Apply discount to the person. +end +---- + +[IMPORTANT] +==== +Using `from` with `lock-on-active` rule attribute can result in rules not being executed. You can address this issue in one of the following ways: + +* Avoid using the `from` element when you can insert all facts into the working memory of the {RULE_ENGINE} or use nested object references in your constraint expressions. +* Place the variable used in the `modify()` block as the last sentence in your rule condition. +* Avoid using the `lock-on-active` rule attribute when you can explicitly manage how rules within the same ruleflow group place activations on one another. +==== + +The pattern that contains a `from` clause cannot be followed by another pattern starting with a parenthesis. The reason for this restriction is that the DRL parser reads the `from` expression as `"from $l (String() or Number())"` and it cannot differentiate this expression from a function call. The simplest workaround to this is to wrap the `from` clause in parentheses, as shown in the following example: + +.Example rules with `from` used incorrectly and correctly +[source] +---- +// Do not use `from` in this way: +rule R + when + $l : List() + String() from $l + (String() or Number()) + then + // Actions +end + +// Use `from` in this way instead: +rule R + when + $l : List() + (String() from $l) + (String() or Number()) + then + // Actions +end +---- +-- + +`entry-point`:: +Use this to define an entry point, or _event stream_, corresponding to a data source for the pattern. This element is typically used with the `from` condition element. You can declare an entry point for events so that the {RULE_ENGINE} uses data from only that entry point to evaluate the rules. You can declare an entry point either implicitly by referencing it in DRL rules or explicitly in your Java application. ++ +-- +.Example rule with `from entry-point` +[source] +---- +rule "Authorize withdrawal" + when + WithdrawRequest( $ai : accountId, $am : amount ) from entry-point "ATM Stream" + CheckingAccount( accountId == $ai, balance > $am ) + then + // Authorize withdrawal. +end +---- + +.Example Java application code with EntryPoint object and inserted facts +[source,java] +---- +import org.kie.api.runtime.KieSession; +import org.kie.api.runtime.rule.EntryPoint; + +// Create your KIE base and KIE session as usual: +KieSession session = ... + +// Create a reference to the entry point: +EntryPoint atmStream = session.getEntryPoint("ATM Stream"); + +// Start inserting your facts into the entry point: +atmStream.insert(aWithdrawRequest); +---- +-- + +`collect`:: +Use this to define a collection of objects that the rule can use as part of the condition. The rule obtains the collection either from a specified source or from the working memory of the {RULE_ENGINE}. The result pattern of the `collect` element can be any concrete class that implements the `java.util.Collection` interface and provides a default no-arg public constructor. You can use Java collections like `List`, `LinkedList`, and `HashSet`, or your own class. If variables are bound before the `collect` element in a condition, you can use the variables to constrain both your source and result patterns. However, any binding made inside the `collect` element is not available for use outside of it. ++ +-- +ifdef::DROOLS,JBPM,OP[] +.Collect +image::language-reference/collect.png[align="center"] +endif::[] + +.Example rule with `collect` +[source] +---- +import java.util.List + +rule "Raise priority when system has more than three pending alarms" + when + $system : System() + $alarms : List( size >= 3 ) + from collect( Alarm( system == $system, status == 'pending' ) ) + then + // Raise priority because `$system` has three or more `$alarms` pending. +end +---- + +In this example, the rule assesses all pending alarms in the working memory of the {RULE_ENGINE} for each given system and groups them in a `List`. If three or more alarms are found for a given system, the rule is executed. + +You can also use the `collect` element with nested `from` elements, as shown in the following example: + +.Example rule with `collect` and nested `from` +[source] +---- +import java.util.LinkedList; + +rule "Send a message to all parents" + when + $town : Town( name == 'Paris' ) + $mothers : LinkedList() + from collect( Person( children > 0 ) + from $town.getPeople() + ) + then + // Send a message to all parents. +end +---- +-- + +`accumulate`:: +Use this to iterate over a collection of objects, execute custom actions for each of the elements, and return one or more result objects (if the constraints evaluate to `true`). This element is a more flexible and powerful form of the `collect` condition element. You can use predefined functions in your `accumulate` conditions or implement custom functions as needed. You can also use the abbreviation `acc` for `accumulate` in rule conditions. ++ +-- +Use the following format to define `accumulate` conditions in rules: + +.Preferred format for `accumulate` +[source] +---- +accumulate( ; [;] ) +---- + +ifdef::DROOLS,JBPM,OP[] +.Accumulate +image::language-reference/accumulate.png[align="center"] +endif::[] + +NOTE: Although the {RULE_ENGINE} supports alternate formats for the `accumulate` element for backward compatibility, this format is preferred for optimal performance in rules and applications. + +The {RULE_ENGINE} supports the following predefined `accumulate` functions. These functions accept any expression as input. + +* `average` +* `min` +* `max` +* `count` +* `sum` +* `collectList` +* `collectSet` + +In the following example rule, `min`, `max`, and `average` are `accumulate` functions that calculate the minimum, maximum, and average temperature values over all the readings for each sensor: + +.Example rule with `accumulate` to calculate temperature values +[source] +---- +rule "Raise alarm" + when + $s : Sensor() + accumulate( Reading( sensor == $s, $temp : temperature ); + $min : min( $temp ), + $max : max( $temp ), + $avg : average( $temp ); + $min < 20, $avg > 70 ) + then + // Raise the alarm. +end +---- + +The following example rule uses the `average` function with `accumulate` to calculate the average profit for all items in an order: + +.Example rule with `accumulate` to calculate average profit +[source] +---- +rule "Average profit" + when + $order : Order() + accumulate( OrderItem( order == $order, $cost : cost, $price : price ); + $avgProfit : average( 1 - $cost / $price ) ) + then + // Average profit for `$order` is `$avgProfit`. +end +---- + +To use custom, domain-specific functions in `accumulate` conditions, create a Java class that implements the `org.kie.api.runtime.rule.AccumulateFunction` interface. For example, the following Java class defines a custom implementation of an `AverageData` function: + +.Example Java class with custom implementation of `average` function +[source,java] +---- +// An implementation of an accumulator capable of calculating average values + +public class AverageAccumulateFunction implements org.kie.api.runtime.rule.AccumulateFunction { + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + + } + + public void writeExternal(ObjectOutput out) throws IOException { + + } + + public static class AverageData implements Externalizable { + public int count = 0; + public double total = 0; + + public AverageData() {} + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + count = in.readInt(); + total = in.readDouble(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(count); + out.writeDouble(total); + } + + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#createContext() + */ + public AverageData createContext() { + return new AverageData(); + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#init(java.io.Serializable) + */ + public void init(AverageData context) { + context.count = 0; + context.total = 0; + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#accumulate(java.io.Serializable, java.lang.Object) + */ + public void accumulate(AverageData context, + Object value) { + context.count++; + context.total += ((Number) value).doubleValue(); + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#reverse(java.io.Serializable, java.lang.Object) + */ + public void reverse(AverageData context, Object value) { + context.count--; + context.total -= ((Number) value).doubleValue(); + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#getResult(java.io.Serializable) + */ + public Object getResult(AverageData context) { + return new Double( context.count == 0 ? 0 : context.total / context.count ); + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#supportsReverse() + */ + public boolean supportsReverse() { + return true; + } + + /* (non-Javadoc) + * @see org.kie.api.runtime.rule.AccumulateFunction#getResultType() + */ + public Class< ? > getResultType() { + return Number.class; + } + +} +---- + +To use the custom function in a DRL rule, import the function using the `import accumulate` statement: + +.Format to import a custom function +[source] +---- +import accumulate +---- + +.Example rule with the imported `average` function +[source] +---- +import accumulate AverageAccumulateFunction.AverageData average + +rule "Average profit" + when + $order : Order() + accumulate( OrderItem( order == $order, $cost : cost, $price : price ); + $avgProfit : average( 1 - $cost / $price ) ) + then + // Average profit for `$order` is `$avgProfit`. +end +---- + +ifdef::DROOLS,JBPM,OP[] +[NOTE] +==== +For backward compatibility, the {RULE_ENGINE} also supports the configuration of `accumulate` functions through configuration files and system properties, but this is a deprecated method. To configure the `average` function from the previous example using the configuration file or system property, set a property as shown in the following example: + +[source] +---- +drools.accumulate.function.average = AverageAccumulateFunction.AverageData +---- + +Note that `drools.accumulate.function` is a required prefix, `average` is how the function is used in the DRL files, and `AverageAccumulateFunction.AverageData` is the fully qualified name of the class that implements the function behavior. +==== +endif::[] +-- + +ifdef::DROOLS,JBPM,OP[] +`accumulate` alternate syntax for a single function with return type:: +The accumulate syntax evolved over time with the goal of becoming more compact and expressive. +Nevertheless, {PRODUCT} still supports previous syntaxes for backward compatibility purposes. ++ +-- +In case the rule is using a single accumulate function on a given accumulate, the author may add a pattern for the result object and use the "from" keyword to link it to the accumulate result. + +Example: a rule to apply a 10% discount on orders over $100 could be written in the following way: + +[source] +---- +rule "Apply 10% discount to orders over US$ 100,00" +when + $order : Order() + $total : Number( doubleValue > 100 ) + from accumulate( OrderItem( order == $order, $value : value ), + sum( $value ) ) +then + // apply discount to $order +end +---- + +In the previous example, the accumulate element is using only one function (sum), and so, the rules author opted to explicitly write a pattern for the result type of the accumulate function (Number) and write the constraints inside it. +There are no problems in using this syntax over the compact syntax presented before, except that is is a bit more verbose. +Also note that it is not allowed to use both the return type and the functions binding in the same accumulate statement. + +Compile-time checks are performed in order to ensure the pattern used with the $$"$$``from``$$"$$ keyword is assignable from the result of the accumulate function used. + +[NOTE] +==== +With this syntax, the $$"$$``from``$$"$$ binds to the single result returned by the accumulate function, and it does not iterate. +==== + +In the previous example, $$"$$``$total``$$"$$ is bound to the result returned by the accumulate sum() function. + +As another example however, if the result of the accumulate function is a collection, $$"$$``from``$$"$$ still binds to the single result and it does not iterate: + +[source] +---- +rule "Person names" +when + $x : Object() from accumulate(MyPerson( $val : name ); + collectList( $val ) ) +then + // $x is a List +end +---- + +The bound $$"$$``$x : Object()``$$"$$ is the List itself, returned by the collectList accumulate function used. + +This is an important distinction to highlight, as the $$"$$``from``$$"$$ keyword can also be used separately of accumulate, to iterate over the elements of a collection: + +[source] +---- +rule "Iterate the numbers" +when + $xs : List() + $x : Integer() from $xs +then + // $x matches and binds to each Integer in the collection +end +---- + +While this syntax is still supported for backward compatibility purposes, for this and other reasons we encourage rule authors to make use instead of the preferred `accumulate` syntax (described previously), to avoid any potential pitfalls. +-- + +`accumulate` with inline custom code:: +Another possible syntax for the `accumulate` is to define inline custom code, instead of using accumulate functions. ++ +-- +[WARNING] +==== +The use of accumulate with inline custom code is not a good practice for several reasons, including difficulties on maintaining and testing rules that use them, as well as the inability of reusing that code. +Implementing your own accumulate functions is very simple and straightforward, they are easy to unit test and to use. +This form of accumulate is supported for backward compatibility only. + +Only limited support for inline accumulate is provided while using the executable model. +For example, you cannot use an external binding in the code while using the MVEL dialect: + +[source] +---- +rule R +dialect "mvel" +when + String( $l : length ) + $sum : Integer() from accumulate ( + Person( age > 18, $age : age ), + init( int sum = 0 * $l; ), + action( sum += $age; ), + reverse( sum -= $age; ), + result( sum ) + ) +---- +==== + +The general syntax of the `accumulate` CE with inline custom code is: + +[source] +---- + from accumulate( , + init( ), + action( ), + reverse( ), + result( ) ) +---- + + +The meaning of each of the elements is the following: + +* ____: the source pattern is a regular pattern that the {RULE_ENGINE} will try to match against each of the source objects. +* ____: this is a semantic block of code in the selected dialect that will be executed once for each tuple, before iterating over the source objects. +* ____: this is a semantic block of code in the selected dialect that will be executed for each of the source objects. +* ____: this is an optional semantic block of code in the selected dialect that if present will be executed for each source object that no longer matches the source pattern. The objective of this code block is to undo any calculation done in the __ block, so that the {RULE_ENGINE} can do decremental calculation when a source object is modified or deleted, hugely improving performance of these operations. +* ____: this is a semantic expression in the selected dialect that is executed after all source objects are iterated. +* ____: this is a regular pattern that the {RULE_ENGINE} tries to match against the object returned from the ____. If it matches, the `accumulate` conditional element evaluates to _true_ and the {RULE_ENGINE} proceeds with the evaluation of the next CE in the rule. If it does not matches, the `accumulate` CE evaluates to _false_ and the {RULE_ENGINE} stops evaluating CEs for that rule. + +It is easier to understand if we look at an example: + +[source] +---- +rule "Apply 10% discount to orders over US$ 100,00" +when + $order : Order() + $total : Number( doubleValue > 100 ) + from accumulate( OrderItem( order == $order, $value : value ), + init( double total = 0; ), + action( total += $value; ), + reverse( total -= $value; ), + result( total ) ) +then + // apply discount to $order +end +---- + +In the previous example, for each `Order` in the Working Memory, the {RULE_ENGINE} will execute the _init + code_ initializing the total variable to zero. +Then it will iterate over all `OrderItem` objects for that order, executing the _action_ for each one (in the example, it will sum the value of all items into the total variable). After iterating over all `OrderItem` objects, it will return the value corresponding to the _result + expression_ (in the previous example, the value of variable ``total``). Finally, the {RULE_ENGINE} will try to match the result with the `Number` pattern, and if the double value is greater than 100, the rule will fire. + +The example used Java as the semantic dialect, and as such, note that the usage of the semicolon as statement delimiter is mandatory in the init, action and reverse code blocks. +The result is an expression and, as such, it does not admit ';'. If the user uses any other dialect, he must comply to that dialect's specific syntax. + +As mentioned before, the _reverse code_ is optional, but it is strongly recommended that the user writes it in order to benefit from the __improved performance on update + and delete__. + +The `accumulate` CE can be used to execute any action on source objects. +The following example instantiates and populates a custom object: + +[source] +---- +rule "Accumulate using custom objects" +when + $person : Person( $likes : likes ) + $cheesery : Cheesery( totalAmount > 100 ) + from accumulate( $cheese : Cheese( type == $likes ), + init( Cheesery cheesery = new Cheesery(); ), + action( cheesery.addCheese( $cheese ); ), + reverse( cheesery.removeCheese( $cheese ); ), + result( cheesery ) ); +then + // do something +end +---- +-- + +`eval`:: +The conditional element `eval` is essentially a catch-all which allows any semantic code (that returns a primitive boolean) to be executed. +This code can refer to variables that were bound in the conditions of the rule and functions in the rule package. +Overuse of `eval` reduces the declarativeness of your rules and can result in a poorly performing {RULE_ENGINE}. +While `eval` can be used anywhere in the patterns, it is typically added as the last conditional element in the conditions of a rule. ++ +-- +.Eval +image::language-reference/eval.png[align="center"] + +Instances of `eval` cannot be indexed and thus are not as efficient as Field Constraints. +However this makes them ideal for being used when functions return values that change over time, which is not allowed within Field Constraints. + +For those who are familiar with {PRODUCT} 2.x lineage, the old {PRODUCT} parameter and condition tags are equivalent to binding a variable to an appropriate type, and then using it in an `eval` node. + +[source] +---- +p1 : Parameter() +p2 : Parameter() +eval( p1.getList().containsKey( p2.getItem() ) ) +---- + +{empty} + +[source] +---- +p1 : Parameter() +p2 : Parameter() +// call function isValid in the LHS +eval( isValid( p1, p2 ) ) +---- +-- +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-comments-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-comments-con.adoc new file mode 100644 index 00000000000..85925b68433 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-comments-con.adoc @@ -0,0 +1,28 @@ +[id='drl-rules-comments-con_{context}'] + += Comments in DRL files + +DRL supports single-line comments prefixed with a double forward slash `//` and multi-line comments enclosed with a forward slash and asterisk `/* ... */`. You can use DRL comments to annotate rules or any related components in DRL files. DRL comments are ignored by the {RULE_ENGINE} when the DRL file is processed. + +.Example rule with comments +[source] +---- +rule "Underage" + // This is a single-line comment. + when + $application : LoanApplication() // This is an in-line comment. + Applicant( age < 21 ) + then + /* This is a multi-line comment + in the rule actions. */ + $application.setApproved( false ); + $application.setExplanation( "Underage" ); +end +---- + +ifdef::DROOLS,JBPM,OP[] +.Multi-line comment +image::language-reference/multi_line_comment.png[align="center"] +endif::[] + +IMPORTANT: The hash symbol `#` is not supported for DRL comments. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-errors-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-errors-ref.adoc new file mode 100644 index 00000000000..b59ec8c9f5c --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-errors-ref.adoc @@ -0,0 +1,207 @@ +[id='drl-rules-errors-ref_{context}'] + += Error messages for DRL troubleshooting + +{PRODUCT} provides standardized messages for DRL errors to help you troubleshoot and resolve problems in your DRL files. The error messages use the following format: + +.Error message format for DRL file problems +image::language-reference/error_message.png[align="center"] + +* *1st Block:* Error code +* *2nd Block:* Line and column in the DRL source where the error occurred +* *3rd Block:* Description of the problem +* *4th Block:* Component in the DRL source (rule, function, query) where the error occurred +* *5th Block:* Pattern in the DRL source where the error occurred (if applicable) + +{PRODUCT} supports the following standardized error messages: + +101: no viable alternative:: +Indicates that the parser reached a decision point but could not identify an alternative. ++ +-- +.Example rule with incorrect spelling +[source] +---- +1: rule "simple rule" +2: when +3: exists Person() +4: exits Student() // Must be `exists` +5: then +6: end +---- + +.Error message +[source] +---- +[ERR 101] Line 4:4 no viable alternative at input 'exits' in rule "simple rule" +---- + +.Example rule without a rule name +[source] +---- +1: package org.drools.examples; +2: rule // Must be `rule "rule name"` (or `rule rule_name` if no spacing) +3: when +4: Object() +5: then +6: System.out.println("A RHS"); +7: end +---- + +.Error message +[source] +---- +[ERR 101] Line 3:2 no viable alternative at input 'when' +---- + +In this example, the parser encountered the keyword `when` but expected the rule name, so it flags `when` as the incorrect expected token. + +.Example rule with incorrect syntax +[source] +---- +1: rule "simple rule" +2: when +3: Student( name == "Andy ) // Must be `"Andy"` +4: then +5: end +---- + +.Error message +[source] +---- +[ERR 101] Line 0:-1 no viable alternative at input '' in rule "simple rule" in pattern Student +---- + +NOTE: A line and column value of `0:-1` means the parser reached the end of the source file (``) but encountered incomplete constructs, usually due to missing quotation marks `"..."`, apostrophes `'...'`, or parentheses `(...)`. + +-- + +102: mismatched input:: +Indicates that the parser expected a particular symbol that is missing at the current input position. ++ +-- +.Example rule with an incomplete rule statement +[source] +---- +1: rule simple_rule +2: when +3: $p : Person( + // Must be a complete rule statement +---- + +.Error message +[source] +---- +[ERR 102] Line 0:-1 mismatched input '' expecting ')' in rule "simple rule" in pattern Person +---- + +NOTE: A line and column value of `0:-1` means the parser reached the end of the source file (``) but encountered incomplete constructs, usually due to missing quotation marks `"..."`, apostrophes `'...'`, or parentheses `(...)`. + +.Example rule with incorrect syntax +[source] +---- +1: package org.drools.examples; +2: +3: rule "Wrong syntax" +4: when +5: not( Car( ( type == "tesla", price == 10000 ) || ( type == "kia", price == 1000 ) ) from $carList ) + // Must use `&&` operators instead of commas `,` +6: then +7: System.out.println("OK"); +8: end +---- + +.Error messages +[source] +---- +[ERR 102] Line 5:36 mismatched input ',' expecting ')' in rule "Wrong syntax" in pattern Car +[ERR 101] Line 5:57 no viable alternative at input 'type' in rule "Wrong syntax" +[ERR 102] Line 5:106 mismatched input ')' expecting 'then' in rule "Wrong syntax" +---- + +In this example, the syntactic problem results in multiple error messages related to each other. The single solution of replacing the commas `,` with `&&` operators resolves all errors. If you encounter multiple errors, resolve one at a time in case errors are consequences of previous errors. +-- + +103: failed predicate:: +Indicates that a validating semantic predicate evaluated to `false`. These semantic predicates are typically used to identify component keywords in DRL files, such as `declare`, `rule`, `exists`, `not`, and others. ++ +-- +.Example rule with an invalid keyword +[source] +---- + 1: package nesting; + 2: + 3: import org.drools.compiler.Person + 4: import org.drools.compiler.Address + 5: + 6: Some text // Must be a valid DRL keyword + 7: + 8: rule "test something" + 9: when +10: $p: Person( name=="Michael" ) +11: then +12: $p.name = "other"; +13: System.out.println(p.name); +14: end +---- + +.Error message +[source] +---- +[ERR 103] Line 6:0 rule 'rule_key' failed predicate: {(validateIdentifierKey(DroolsSoftKeywords.RULE))}? in rule +---- + +The `Some text` line is invalid because it does not begin with or is not a part of a DRL keyword construct, so the parser fails to validate the rest of the DRL file. + +NOTE: This error is similar to `102: mismatched input`, but usually involves DRL keywords. + +-- + +104: trailing semi-colon not allowed:: +Indicates that an `eval()` clause in a rule condition uses a semicolon `;` but must not use one. ++ +-- +.Example rule with `eval()` and trailing semicolon +[source] +---- +1: rule "simple rule" +2: when +3: eval( abc(); ) // Must not use semicolon `;` +4: then +5: end +---- + +.Error message +[source] +---- +[ERR 104] Line 3:4 trailing semi-colon not allowed in rule "simple rule" +---- +-- + +105: did not match anything:: +Indicates that the parser reached a sub-rule in the grammar that must match an alternative at least once, but the sub-rule did not match anything. The parser has entered a branch with no way out. ++ +-- +.Example rule with invalid text in an empty condition +[source] +---- +1: rule "empty condition" +2: when +3: None // Must remove `None` if condition is empty +4: then +5: insert( new Person() ); +6: end +---- + +.Error message +[source] +---- +[ERR 105] Line 2:2 required (...)+ loop did not match anything at input 'WHEN' in rule "empty condition" +---- + +In this example, the condition is intended to be empty but the word `None` is used. This error is resolved by removing `None`, which is not a valid DRL keyword, data type, or pattern construct. +-- + +ifdef::DM,PAM[] +NOTE: If you encounter other DRL error messages that you cannot resolve, contact your Red Hat Technical Account Manager. +endif::[] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-traditional.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-traditional.adoc new file mode 100644 index 00000000000..8e9e55ad8b9 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-rules-traditional.adoc @@ -0,0 +1,5 @@ +[id="con-drl_{context}] += Traditional DRL Syntax + +[role="_abstract"] +This chapter explains the traditional DRL syntax. This syntax can be used instead of the RuleUnit and OOPath based syntax. The traditional syntax is still fully supported. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc new file mode 100644 index 00000000000..6de35c1795d --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc @@ -0,0 +1,173 @@ +[id='drl-timers-calendars-con_{context}'] += Timer and calendar rule attributes in DRL + +Timers and calendars are DRL rule attributes that enable you to apply scheduling and timing constraints to your DRL rules. These attributes require additional configurations depending on the use case. + +The `timer` attribute in DRL rules is a string identifying either `int` (interval) or `cron` timer definitions for scheduling a rule and supports the following formats: + +.Timer attribute formats +[source] +---- +timer ( int: ) + +timer ( cron: ) +---- + +.Example interval timer attributes +[source] +---- +// Run after a 30-second delay +timer ( int: 30s ) + +// Run every 5 minutes after a 30-second delay each time +timer ( int: 30s 5m ) +---- + +.Example cron timer attribute +[source] +---- +// Run every 15 minutes +timer ( cron:* 0/15 * * * ? ) +---- + +Interval timers follow the semantics of `java.util.Timer` objects, with an initial delay and an optional repeat interval. Cron timers follow standard Unix cron expressions. + +The following example DRL rule uses a cron timer to send an SMS text message every 15 minutes: + +.Example DRL rule with a cron timer +[source] +---- +rule "Send SMS message every 15 minutes" + timer ( cron:* 0/15 * * * ? ) + when + $a : Alarm( on == true ) + then + channels[ "sms" ].insert( new Sms( $a.mobileNumber, "The alarm is still on." ); +end +---- + +Generally, a rule that is controlled by a timer becomes active when the rule is triggered and the rule consequence is executed repeatedly, according to the timer settings. The execution stops when the rule condition no longer matches incoming facts. However, the way the {RULE_ENGINE} handles rules with timers depends on whether the {RULE_ENGINE} is in _active mode_ or in _passive mode_. + +By default, the {RULE_ENGINE} runs in _passive mode_ and evaluates rules, according to the defined timer settings, when a user or an application explicitly calls `fireAllRules()`. Conversely, if a user or application calls `fireUntilHalt()`, the {RULE_ENGINE} starts in _active mode_ and evaluates rules continually until the user or application explicitly calls `halt()`. + +When the {RULE_ENGINE} is in active mode, rule consequences are executed even after control returns from a call to `fireUntilHalt()` and the {RULE_ENGINE} remains _reactive_ to any changes made to the working memory. For example, removing a fact that was involved in triggering the timer rule execution causes the repeated execution to terminate, and inserting a fact so that some rule matches causes that rule to be executed. However, the {RULE_ENGINE} is not continually _active_, but is active only after a rule is executed. Therefore, the {RULE_ENGINE} does not react to asynchronous fact insertions until the next execution of a timer-controlled rule. Disposing a KIE session terminates all timer activity. + +When the {RULE_ENGINE} is in passive mode, rule consequences of timed rules are evaluated only when `fireAllRules()` is invoked again. However, you can change the default timer-execution behavior in passive mode by configuring the KIE session with a `TimedRuleExecutionOption` option, as shown in the following example: + +.KIE session configuration to automatically execute timed rules in passive mode +[source,java] +---- +KieSessionConfiguration ksconf = KieServices.Factory.get().newKieSessionConfiguration(); +ksconf.setOption( TimedRuleExecutionOption.YES ); +KSession ksession = kbase.newKieSession(ksconf, null); +---- + +You can additionally set a `FILTERED` specification on the `TimedRuleExecutionOption` option that enables you to define a +callback to filter those rules, as shown in the following example: + +.KIE session configuration to filter which timed rules are automatically executed +[source,java] +---- +KieSessionConfiguration ksconf = KieServices.Factory.get().newKieSessionConfiguration(); +conf.setOption( new TimedRuleExecutionOption.FILTERED(new TimedRuleExecutionFilter() { + public boolean accept(Rule[] rules) { + return rules[0].getName().equals("MyRule"); + } +}) ); +---- + +For interval timers, you can also use an expression timer with `expr` instead of `int` to define both the delay and interval as an expression instead of a fixed value. + +The following example DRL file declares a fact type with a delay and period that are then used in the subsequent rule with an expression timer: + +.Example rule with an expression timer +[source] +---- +declare Bean + delay : String = "30s" + period : long = 60000 +end + +rule "Expression timer" + timer ( expr: $d, $p ) + when + Bean( $d : delay, $p : period ) + then + // Actions +end +---- + +The expressions, such as `$d` and `$p` in this example, can use any variable defined in the pattern-matching part of the rule. The variable can be any `String` value that can be parsed into a time duration or any numeric value that is internally converted in a `long` value for a duration in milliseconds. + +Both interval and expression timers can use the following optional parameters: + +* `start` and `end`: A `Date` or a `String` representing a `Date` or a `long` value. The value can also be a `Number` that is transformed into a Java `Date` in the format `new Date( ((Number) n).longValue() )`. +* `repeat-limit`: An integer that defines the maximum number of repetitions allowed by the timer. If both the `end` and the `repeat-limit` parameters are set, the timer stops when the first of the two is reached. + +.Example timer attribute with optional `start`, `end`, and `repeat-limit` parameters +[source,java] +---- +timer (int: 30s 1h; start=3-JAN-2020, end=4-JAN-2020, repeat-limit=50) +---- + +In this example, the rule is scheduled for every hour, after a delay of 30 seconds each hour, beginning on 3 January 2020 and ending either on 4 January 2020 or when the cycle repeats 50 times. + +If the system is paused (for example, the session is serialized and then later deserialized), the rule is scheduled only one time to recover from missing activations regardless of how many activations were missed during the pause, and then the rule is subsequently scheduled again to continue in sync with the timer setting. + +The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling a rule and supports the following format: + +.Calendar attribute format +[source] +---- +calendars "" +---- + +.Example calendar attributes +[source] +---- +// Exclude non-business hours +calendars "* * 0-7,18-23 ? * *" + +// Weekdays only, as registered in the KIE session +calendars "weekday" +---- + +You can adapt a Quartz calendar based on the Quartz calendar API and then register the calendar in the KIE session, as shown in the following example: + +.Adapting a Quartz Calendar +[source,java] +---- +Calendar weekDayCal = QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal) +---- + +.Registering the calendar in the KIE session +[source,java] +---- +ksession.getCalendars().set( "weekday", weekDayCal ); +---- + +You can use calendars with standard rules and with rules that use timers. The calendar attribute can contain one or more comma-separated calendar names written as `String` literals. + +The following example rules use both calendars and timers to schedule the rules: + +.Example rules with calendars and timers +[source] +---- +rule "Weekdays are high priority" + calendars "weekday" + timer ( int:0 1h ) + when + Alarm() + then + send( "priority high - we have an alarm" ); +end + +rule "Weekends are low priority" + calendars "weekend" + timer ( int:0 4h ) + when + Alarm() + then + send( "priority low - we have an alarm" ); +end +---- diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/index.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/index.adoc new file mode 100644 index 00000000000..aa7ff6ffb11 --- /dev/null +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/index.adoc @@ -0,0 +1,56 @@ +:DROOLS: +include::../_artifacts/document-attributes.adoc[] + +[[_droolslanguagereferencetraditionalchapter]] += Rule Language Reference (Traditional) +:context: drl-rules-traditional + +include::_drl-rules-traditional.adoc[leveloffset=+1] + +include::_drl-packages-con.adoc[leveloffset=+2] + +include::_drl-imports-con.adoc[leveloffset=+2] + +include::_drl-functions-con.adoc[leveloffset=+2] + +include::_drl-queries-con.adoc[leveloffset=+2] + +include::_drl-declarations-con.adoc[leveloffset=+2] + +include::_drl-declarations-without-metadata-con.adoc[leveloffset=+3] + +include::_drl-declarations-enumerative-con.adoc[leveloffset=+3] + +include::_drl-declarations-extended-con.adoc[leveloffset=+3] + +include::_drl-declarations-with-metadata-con.adoc[leveloffset=+3] + +include::_drl-declarations-metadata-tags-ref.adoc[leveloffset=+3] + +include::_drl-declarations-access-con.adoc[leveloffset=+3] + +include::_drl-globals-con.adoc[leveloffset=+2] + +include::_drl-timers-calendars-con.adoc[leveloffset=+3] + +include::_drl-rules-WHEN-con.adoc[leveloffset=+2] + +include::_drl-operators-ref.adoc[leveloffset=+3] + +include::_drl-operator-precedence-ref.adoc[leveloffset=+3] + +include::_drl-rules-WHEN-elements-ref.adoc[leveloffset=+3] + +include::_drl-rules-THEN-con.adoc[leveloffset=+2] + +include::_drl-rules-THEN-methods-ref.adoc[leveloffset=+3] + +include::_drl-rules-THEN-methods-variables-ref.adoc[leveloffset=+3] + +include::_drl-rules-THEN-advanced-con.adoc[leveloffset=+3] + +include::_drl-rules-comments-con.adoc[leveloffset=+2] + +include::_drl-rules-errors-ref.adoc[leveloffset=+2] + +include::_DSL-section.adoc[leveloffset=+1] diff --git a/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc b/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc index 4d5142347e0..07aefbce971 100644 --- a/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc +++ b/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc @@ -70,6 +70,8 @@ rule "Underage" end ---- +For the traditional syntax, please refer to xref:ref-con-drl_drl-rules-traditional[] + [id="con-drl-packages_{context}"] == Packages in DRL diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL5Parser.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL5Parser.java index e722ad27874..3645da2e7cc 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL5Parser.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL5Parser.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; import org.antlr.runtime.CommonToken; diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6Parser.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6Parser.java index 5998110e52e..ebfec99223d 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6Parser.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6Parser.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; import java.util.ArrayList; diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6StrictParser.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6StrictParser.java index be9a34f0366..a99b3f0adc0 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6StrictParser.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DRL6StrictParser.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; import org.antlr.runtime.CommonToken; diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsEditorType.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsEditorType.java index 17ffcbb13fc..65a37e6d111 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsEditorType.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsEditorType.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; /** diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsTree.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsTree.java index 610df67f06b..eee438ac484 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsTree.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/DroolsTree.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; import org.antlr.runtime.Token; diff --git a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/ParserHelper.java b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/ParserHelper.java index f47eeb44ef0..28ac2c7a32c 100644 --- a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/ParserHelper.java +++ b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/lang/ParserHelper.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.drl.parser.lang; import java.util.ArrayDeque; @@ -389,7 +376,7 @@ public boolean hasErrors() { /** * Method that adds a paraphrase type into paraphrases stack. - * + * * @param type * paraphrase type */ @@ -406,7 +393,7 @@ public Map popParaphrases() { /** * Method that sets paraphrase value for a type into paraphrases stack. - * + * * @param type * paraphrase type * @param value diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/PackageModel.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/PackageModel.java index 530b3e9b9c7..121b722bc18 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/PackageModel.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/PackageModel.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -44,7 +45,6 @@ import com.github.javaparser.ast.body.InitializerDeclaration; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.TypeDeclaration; -import com.github.javaparser.ast.comments.JavadocComment; import com.github.javaparser.ast.expr.AssignExpr; import com.github.javaparser.ast.expr.ClassExpr; import com.github.javaparser.ast.expr.Expression; @@ -95,6 +95,7 @@ import org.kie.api.builder.ReleaseId; import org.kie.api.conf.PrototypesOption; import org.kie.api.runtime.rule.AccumulateFunction; +import org.kie.internal.builder.conf.ReproducibleExecutableModelGenerationOption; import org.kie.internal.ruleunit.RuleUnitDescription; import org.kie.internal.ruleunit.RuleUnitVariable; @@ -155,7 +156,7 @@ public class PackageModel { private final List generatedPOJOs = new ArrayList<>(); private final List generatedAccumulateClasses = new ArrayList<>(); - private final Set> domainClasses = new HashSet<>(); + private final Set> domainClasses = new LinkedHashSet<>(); private final Map, ClassDefinition> classDefinitionsMap = new HashMap<>(); private final Set> otnsClasses = new HashSet<>(); @@ -187,7 +188,7 @@ public class PackageModel { private final boolean prototypesAllowed; private PackageModel( ReleaseId releaseId, String name, KnowledgeBuilderConfigurationImpl configuration, DialectCompiletimeRegistry dialectCompiletimeRegistry, DRLIdGenerator exprIdGenerator) { - this(name, configuration, dialectCompiletimeRegistry, exprIdGenerator, getPkgUUID(releaseId, name)); + this(name, configuration, dialectCompiletimeRegistry, exprIdGenerator, getPkgUUID(configuration, releaseId, name)); } public PackageModel(String gav, String name, KnowledgeBuilderConfigurationImpl configuration, DialectCompiletimeRegistry dialectCompiletimeRegistry, DRLIdGenerator exprIdGenerator) { @@ -233,10 +234,21 @@ public static void initPackageModel(TypeDeclarationContext typeDeclarationContex * @param packageName * @return */ - public static String getPkgUUID(ReleaseId releaseId, String packageName) { + public static String getPkgUUID(KnowledgeBuilderConfigurationImpl configuration, ReleaseId releaseId, String packageName) { + if (isReproducibleExecutableModelGeneration(configuration)) { + return StringUtils.getPkgUUID(releaseId != null ? releaseId.toString() : "", packageName); + } return (releaseId != null && !releaseId.isSnapshot()) ? StringUtils.getPkgUUID(releaseId.toString(), packageName) : StringUtils.generateUUID(); } + public boolean isReproducibleExecutableModelGeneration() { + return isReproducibleExecutableModelGeneration(configuration); + } + + private static boolean isReproducibleExecutableModelGeneration(KnowledgeBuilderConfigurationImpl configuration) { + return configuration != null && configuration.getOption(ReproducibleExecutableModelGenerationOption.KEY).isReproducibleExecutableModelGeneration(); + } + public Map getLambdaClasses() { return lambdaClasses; } @@ -741,7 +753,7 @@ private void generateRulesInUnit( String ruleUnitName, RuleUnitMembers ruleUnitM int ruleCount = ruleMethodsInUnit.size(); boolean requiresMultipleRulesLists = ruleCount >= RULES_DECLARATION_PER_CLASS-1; - boolean parallelRulesLoad = ruleCount >= (RULES_DECLARATION_PER_CLASS*3-1); + boolean parallelRulesLoad = !isReproducibleExecutableModelGeneration() && ruleCount >= (RULES_DECLARATION_PER_CLASS*3-1); MethodCallExpr parallelRulesGetter = null; @@ -761,9 +773,7 @@ private void generateRulesInUnit( String ruleUnitName, RuleUnitMembers ruleUnitM ruleMethodsInUnit.parallelStream().forEach( DrlxParseUtil::transformDrlNameExprToNameExpr); - int maxLength = ruleMethodsInUnit - .parallelStream() - .map( MethodDeclaration::toString ).mapToInt( String::length ).max().orElse( 1 ); + int maxLength = ruleMethodsInUnit.parallelStream().map( MethodDeclaration::toString ).mapToInt( String::length ).max().orElse( 1 ); int rulesPerClass = oneClassPerRule ? 1 : Math.max( 50000 / maxLength, 1 ); // each method per Drlx parser result @@ -812,13 +822,6 @@ private void createAndAddGetRulesMethod( ClassOrInterfaceDeclaration rulesClass " }\n" ); rulesClass.addMember( getRulesMethod ); - - StringBuilder sb = new StringBuilder("\n"); - sb.append("With the following expression ID:\n"); - sb.append(exprIdGenerator.toString()); - sb.append("\n"); - JavadocComment exprIdComment = new JavadocComment(sb.toString()); - getRulesMethod.setComment(exprIdComment); } private CompilationUnit createCompilationUnit(RuleSourceResult results ) { diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/ModelGenerator.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/ModelGenerator.java index 517c1c403f3..9c030b7be78 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/ModelGenerator.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/ModelGenerator.java @@ -40,31 +40,24 @@ import com.github.javaparser.ast.expr.VariableDeclarationExpr; import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.stmt.ReturnStmt; -import com.github.javaparser.ast.type.ClassOrInterfaceType; -import com.github.javaparser.ast.type.Type; -import org.drools.compiler.builder.impl.BuildResultCollector; -import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; -import org.drools.compiler.builder.impl.TypeDeclarationContext; -import org.drools.compiler.compiler.DescrBuildError; import org.drools.base.base.CoreComponentsBuilder; import org.drools.base.definitions.InternalKnowledgePackage; import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.base.factmodel.AnnotationDefinition; -import org.drools.core.rule.BehaviorRuntime; -import org.drools.base.time.TimeUtils; +import org.drools.compiler.builder.impl.BuildResultCollector; +import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; +import org.drools.compiler.builder.impl.TypeDeclarationContext; +import org.drools.compiler.compiler.DescrBuildError; import org.drools.drl.ast.descr.AndDescr; import org.drools.drl.ast.descr.AnnotationDescr; import org.drools.drl.ast.descr.AttributeDescr; -import org.drools.drl.ast.descr.BehaviorDescr; import org.drools.drl.ast.descr.PackageDescr; import org.drools.drl.ast.descr.QueryDescr; import org.drools.drl.ast.descr.RuleDescr; import org.drools.model.Rule; -import org.drools.model.Variable; import org.drools.model.codegen.execmodel.PackageModel; import org.drools.model.codegen.execmodel.errors.InvalidExpressionErrorResult; import org.drools.model.codegen.execmodel.errors.ParseExpressionErrorResult; -import org.drools.model.codegen.execmodel.errors.UnknownDeclarationError; import org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyper; import org.drools.model.codegen.execmodel.generator.expressiontyper.ExpressionTyperContext; import org.drools.model.codegen.execmodel.generator.visitor.ModelGeneratorVisitor; @@ -75,24 +68,17 @@ import static com.github.javaparser.StaticJavaParser.parseExpression; import static org.drools.kiesession.session.StatefulKnowledgeSessionImpl.DEFAULT_RULE_UNIT; import static org.drools.model.codegen.execmodel.PackageModel.DATE_TIME_FORMATTER_FIELD; -import static org.drools.model.codegen.execmodel.PackageModel.DOMAIN_CLASSESS_METADATA_FILE_NAME; -import static org.drools.model.codegen.execmodel.PackageModel.DOMAIN_CLASS_METADATA_INSTANCE; -import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.classToReferenceType; import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.generateLambdaWithoutParameters; import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.toClassOrInterfaceType; import static org.drools.model.codegen.execmodel.generator.DrlxParseUtil.toStringLiteral; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.ATTRIBUTE_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.BUILD_CALL; -import static org.drools.model.codegen.execmodel.generator.DslMethodNames.DECLARATION_OF_CALL; -import static org.drools.model.codegen.execmodel.generator.DslMethodNames.ENTRY_POINT_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.METADATA_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.RULE_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.SUPPLY_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.UNIT_CALL; -import static org.drools.model.codegen.execmodel.generator.DslMethodNames.WINDOW_CALL; import static org.drools.model.codegen.execmodel.generator.DslMethodNames.createDslTopLevelMethod; import static org.drools.model.codegen.execmodel.generator.RuleContext.DIALECT_ATTRIBUTE; -import static org.drools.modelcompiler.util.ClassUtil.asJavaSourceName; import static org.drools.modelcompiler.util.StringUtil.toId; import static org.drools.modelcompiler.util.TimerUtil.validateTimer; @@ -134,46 +120,22 @@ public class ModelGenerator { public static final boolean GENERATE_EXPR_ID = true; - public static void generateModel( - KnowledgeBuilderImpl knowledgeBuilder, - InternalKnowledgePackage pkg, - PackageDescr packageDescr, - PackageModel packageModel) { + public static void generateModel( KnowledgeBuilderImpl knowledgeBuilder, InternalKnowledgePackage pkg, PackageDescr packageDescr, PackageModel packageModel) { generateModel(knowledgeBuilder, knowledgeBuilder, pkg, packageDescr, packageModel); } - public static void generateModel( - TypeDeclarationContext typeDeclarationContext, - BuildResultCollector resultCollector, - InternalKnowledgePackage pkg, - PackageDescr packageDescr, - PackageModel packageModel) { - TypeResolver typeResolver = pkg.getTypeResolver(); - - List ruleDescrs = packageDescr.getRules(); - if (ruleDescrs.isEmpty()) { - return; + public static void generateModel( TypeDeclarationContext typeDeclarationContext, BuildResultCollector resultCollector, + InternalKnowledgePackage pkg, PackageDescr packageDescr, PackageModel packageModel) { + if (!packageDescr.getRules().isEmpty()) { + packageModel.addRuleUnits(processRules( typeDeclarationContext, resultCollector, packageDescr, packageModel, pkg.getTypeResolver())); } - - packageModel.addRuleUnits( processRules( - typeDeclarationContext, - resultCollector, - packageDescr, - packageModel, - typeResolver, - ruleDescrs) ); } - private static Set processRules( - TypeDeclarationContext typeDeclarationContext, - BuildResultCollector resultCollector, - PackageDescr packageDescr, - PackageModel packageModel, - TypeResolver typeResolver, - List ruleDescrs) { + private static Set processRules( TypeDeclarationContext typeDeclarationContext, BuildResultCollector resultCollector, + PackageDescr packageDescr, PackageModel packageModel, TypeResolver typeResolver) { Set ruleUnitDescrs = new HashSet<>(); - for (RuleDescr descr : ruleDescrs) { + for (RuleDescr descr : packageDescr.getRules()) { RuleContext context = new RuleContext( typeDeclarationContext, resultCollector, packageModel, typeResolver, descr); if (context.getRuleUnitDescr() != null) { @@ -185,10 +147,7 @@ private static Set processRules( } } - int parallelRulesBuildThreshold = typeDeclarationContext.getBuilderConfiguration().getOption(ParallelRulesBuildThresholdOption.KEY).getParallelRulesBuildThreshold(); - boolean parallelRulesBuild = parallelRulesBuildThreshold != -1 && ruleDescrs.size() > parallelRulesBuildThreshold; - - if (parallelRulesBuild) { + if ( isParallelRulesBuild(typeDeclarationContext, packageDescr, packageModel) ) { List ruleContexts = new ArrayList<>(); int i = 0; for (RuleDescr ruleDescr : packageDescr.getRules()) { @@ -209,6 +168,14 @@ private static Set processRules( return ruleUnitDescrs; } + private static boolean isParallelRulesBuild(TypeDeclarationContext typeDeclarationContext, PackageDescr packageDescr, PackageModel packageModel) { + if ( packageModel.isReproducibleExecutableModelGeneration() ) { + return false; + } + int parallelRulesBuildThreshold = typeDeclarationContext.getBuilderConfiguration().getOption(ParallelRulesBuildThresholdOption.KEY).getParallelRulesBuildThreshold(); + return parallelRulesBuildThreshold != -1 && packageDescr.getRules().size() > parallelRulesBuildThreshold; + } + private static void processRuleDescr(RuleContext context, PackageDescr packageDescr) { if (context.getRuleDescr() instanceof QueryDescr) { QueryGenerator.processQuery(context.getPackageModel(), (QueryDescr) context.getRuleDescr()); diff --git a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/processors/DeclaredTypeCompilationPhase.java b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/processors/DeclaredTypeCompilationPhase.java index 2d0afcf712b..a2755edfbb3 100644 --- a/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/processors/DeclaredTypeCompilationPhase.java +++ b/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/processors/DeclaredTypeCompilationPhase.java @@ -18,22 +18,22 @@ */ package org.drools.model.codegen.execmodel.processors; +import java.util.Collection; +import java.util.List; + import org.drools.compiler.builder.PackageRegistryManager; import org.drools.compiler.builder.impl.BuildResultCollector; import org.drools.compiler.builder.impl.BuildResultCollectorImpl; import org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl; import org.drools.compiler.builder.impl.processors.CompilationPhase; -import org.drools.compiler.builder.impl.processors.SinglePackagePhaseFactory; import org.drools.compiler.builder.impl.processors.IteratingPhase; +import org.drools.compiler.builder.impl.processors.SinglePackagePhaseFactory; import org.drools.compiler.lang.descr.CompositePackageDescr; import org.drools.model.codegen.execmodel.CanonicalModelBuildContext; import org.drools.model.codegen.execmodel.PackageModelManager; import org.drools.model.codegen.execmodel.generator.declaredtype.POJOGenerator; import org.kie.internal.builder.KnowledgeBuilderResult; -import java.util.Collection; -import java.util.List; - import static java.util.Arrays.asList; public class DeclaredTypeCompilationPhase implements CompilationPhase { @@ -45,12 +45,9 @@ public class DeclaredTypeCompilationPhase implements CompilationPhase { private final Collection packages; private final BuildResultCollector results; - public DeclaredTypeCompilationPhase( - PackageModelManager packageModelManager, - PackageRegistryManager pkgRegistryManager, - CanonicalModelBuildContext buildContext, - KnowledgeBuilderConfigurationImpl buildConfiguration, - Collection packages) { + public DeclaredTypeCompilationPhase( PackageModelManager packageModelManager, PackageRegistryManager pkgRegistryManager, + CanonicalModelBuildContext buildContext, KnowledgeBuilderConfigurationImpl buildConfiguration, + Collection packages) { this.packageModelManager = packageModelManager; this.pkgRegistryManager = pkgRegistryManager; this.buildContext = buildContext; diff --git a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/ModelBuilderImplTest.java b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/ModelBuilderImplTest.java index c483cedde16..76adb83215a 100644 --- a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/ModelBuilderImplTest.java +++ b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/ModelBuilderImplTest.java @@ -63,7 +63,7 @@ public void getPackageModelWithoutPkgUUID() { PackageDescr packageDescr = getPackageDescr(null); PackageModel retrieved = modelBuilder.getPackageModel(packageDescr, packageRegistry, internalKnowledgePackage.getName()); assertThat(retrieved).isNotNull(); - String expected = getPkgUUID(RELEASE_ID, internalKnowledgePackage.getName()); + String expected = getPkgUUID(retrieved.getConfiguration(), RELEASE_ID, internalKnowledgePackage.getName()); assertThat(retrieved.getPackageUUID()).isEqualTo(expected); } diff --git a/drools-mvel/src/main/java/org/drools/mvel/DrlDumper.java b/drools-mvel/src/main/java/org/drools/mvel/DrlDumper.java index 5e97e91004a..8d539748007 100644 --- a/drools-mvel/src/main/java/org/drools/mvel/DrlDumper.java +++ b/drools-mvel/src/main/java/org/drools/mvel/DrlDumper.java @@ -16,19 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.drools.mvel; import java.util.HashMap; diff --git a/drools-quarkus-extension/drools-quarkus-deployment/pom.xml b/drools-quarkus-extension/drools-quarkus-deployment/pom.xml index 0b46a52cb8a..f4342cfb36b 100644 --- a/drools-quarkus-extension/drools-quarkus-deployment/pom.xml +++ b/drools-quarkus-extension/drools-quarkus-deployment/pom.xml @@ -178,6 +178,29 @@ + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.1 + + + Run Script + prepare-package + + java + + + org.drools.util.RemoveCommentsMain + + ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties + + + + + diff --git a/drools-quarkus-extension/drools-quarkus/pom.xml b/drools-quarkus-extension/drools-quarkus/pom.xml index 240bc88c395..75ef13e08ac 100644 --- a/drools-quarkus-extension/drools-quarkus/pom.xml +++ b/drools-quarkus-extension/drools-quarkus/pom.xml @@ -147,6 +147,29 @@ io.smallrye jandex-maven-plugin + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.1 + + + Run Script + prepare-package + + java + + + org.drools.util.RemoveCommentsMain + + ${project.basedir}/target/classes/META-INF/quarkus-extension.properties + + + + + diff --git a/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java b/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java new file mode 100644 index 00000000000..014a1b23bf1 --- /dev/null +++ b/drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java @@ -0,0 +1,28 @@ +package org.drools.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Collectors; + +public class RemoveCommentsMain { + + public static void main(String... args) { + for (String fileName : args) { + try { + Files.write(Path.of(fileName), removeComments(fileName).getBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + static String removeComments(String fileName) { + try (var lines = Files.lines(Path.of(fileName))) { + return lines.filter(line -> !line.startsWith("#")).collect(Collectors.joining("\n")); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java b/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java new file mode 100644 index 00000000000..91bbceba3dd --- /dev/null +++ b/drools-util/src/test/java/org/drools/util/RemoveCommentsTest.java @@ -0,0 +1,15 @@ +package org.drools.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class RemoveCommentsTest { + + @Test + public void test() { + String result = RemoveCommentsMain.removeComments("src/test/resources/commented.properties"); + String expected = "provides-capabilities=org.drools.drl\ndeployment-artifact=org.drools\\:drools-quarkus-deployment\\:999-SNAPSHOT"; + assertEquals(expected, result); + } +} diff --git a/drools-util/src/test/resources/commented.properties b/drools-util/src/test/resources/commented.properties new file mode 100644 index 00000000000..5bec8eb63a1 --- /dev/null +++ b/drools-util/src/test/resources/commented.properties @@ -0,0 +1,4 @@ +# Test comment +provides-capabilities=org.drools.drl +# Timestamp: 2024-01-26T15:00:00.000+02:00 +deployment-artifact=org.drools\:drools-quarkus-deployment\:999-SNAPSHOT \ No newline at end of file diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ArtifactConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ArtifactConverter.java new file mode 100644 index 00000000000..25fc33bbdaa --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ArtifactConverter.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; + +public abstract class ArtifactConverter extends DMNElementConverter { + + public ArtifactConverter(XStream xstream) { + super(xstream); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AssociationConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AssociationConverter.java new file mode 100644 index 00000000000..411989b9e7e --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AssociationConverter.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Association; +import org.kie.dmn.model.api.AssociationDirection; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TAssociation; + +public class AssociationConverter extends ArtifactConverter { + public static final String TARGET_REF = "targetRef"; + public static final String SOURCE_REF = "sourceRef"; + public static final String ASSOCIATION_DIRECTION = "associationDirection"; + + public AssociationConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TAssociation(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TAssociation.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Association a = (Association) parent; + + if( SOURCE_REF.equals( nodeName ) ) { + a.setSourceRef( (DMNElementReference) child ); + } else if( TARGET_REF.equals( nodeName ) ) { + a.setTargetRef( (DMNElementReference) child ); + } else { + super.assignChildElement( parent, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Association a = (Association) parent; + + String associationDirectionValue = reader.getAttribute(ASSOCIATION_DIRECTION); + + if (associationDirectionValue != null) a.setAssociationDirection(AssociationDirection.fromValue(associationDirectionValue)); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Association a = (Association) parent; + + writeChildrenNode(writer, context, a.getSourceRef(), SOURCE_REF); + writeChildrenNode(writer, context, a.getTargetRef(), TARGET_REF); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Association a = (Association) parent; + + if (a.getAssociationDirection() != null) writer.addAttribute(ASSOCIATION_DIRECTION, a.getAssociationDirection().value()); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AuthorityRequirementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AuthorityRequirementConverter.java new file mode 100644 index 00000000000..03d76f6b0c7 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/AuthorityRequirementConverter.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TAuthorityRequirement; + +public class AuthorityRequirementConverter extends DMNElementConverter { + public static final String REQUIRED_AUTHORITY = "requiredAuthority"; + public static final String REQUIRED_INPUT = "requiredInput"; + public static final String REQUIRED_DECISION = "requiredDecision"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + AuthorityRequirement ar = (AuthorityRequirement) parent; + + if (REQUIRED_DECISION.equals(nodeName)) { + ar.setRequiredDecision( (DMNElementReference) child ); + } else if (REQUIRED_INPUT.equals(nodeName)) { + ar.setRequiredInput( (DMNElementReference) child ); + } else if (REQUIRED_AUTHORITY.equals(nodeName)) { + ar.setRequiredAuthority( (DMNElementReference) child ); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + AuthorityRequirement ar = (AuthorityRequirement) parent; + + if (ar.getRequiredDecision() != null) writeChildrenNode(writer, context, ar.getRequiredDecision(), REQUIRED_DECISION); + if (ar.getRequiredInput() != null) writeChildrenNode(writer, context, ar.getRequiredInput(), REQUIRED_INPUT); + if (ar.getRequiredAuthority() != null) writeChildrenNode(writer, context, ar.getRequiredAuthority(), REQUIRED_AUTHORITY); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public AuthorityRequirementConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TAuthorityRequirement(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TAuthorityRequirement.class); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BindingConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BindingConverter.java new file mode 100644 index 00000000000..b2c3f79d6c4 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BindingConverter.java @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Binding; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.v1_5.TBinding; + +public class BindingConverter extends DMNModelInstrumentedBaseConverter { + public static final String EXPRESSION = "expression"; + public static final String PARAMETER = "parameter"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Binding b = (Binding) parent; + + if (PARAMETER.equals(nodeName)) { + b.setParameter((InformationItem) child); + } else if (child instanceof Expression) { + b.setExpression((Expression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Binding b = (Binding) parent; + + writeChildrenNode(writer, context, b.getParameter(), PARAMETER); + if (b.getExpression() != null) writeChildrenNode(writer, context, b.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, b.getExpression())); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public BindingConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TBinding(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TBinding.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BoundsConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BoundsConverter.java new file mode 100644 index 00000000000..8119f1c7ccb --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BoundsConverter.java @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.Bounds; + +public class BoundsConverter extends DMNModelInstrumentedBaseConverter { + + + private static final String HEIGHT = "height"; + private static final String WIDTH = "width"; + private static final String Y = "y"; + private static final String X = "x"; + + public BoundsConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Bounds abs = (Bounds) parent; + + abs.setX(Double.valueOf(reader.getAttribute(X))); + abs.setY(Double.valueOf(reader.getAttribute(Y))); + abs.setWidth(Double.valueOf(reader.getAttribute(WIDTH))); + abs.setHeight(Double.valueOf(reader.getAttribute(HEIGHT))); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + Bounds abs = (Bounds) parent; + + writer.addAttribute(X, org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils.manageDouble(abs.getX())); + writer.addAttribute(Y, org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils.manageDouble(abs.getY())); + writer.addAttribute(WIDTH, org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils.manageDouble(abs.getWidth())); + writer.addAttribute(HEIGHT, FormatUtils.manageDouble(abs.getHeight())); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.Bounds(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.Bounds.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessContextElementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessContextElementConverter.java new file mode 100644 index 00000000000..3e9271c2968 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessContextElementConverter.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.BusinessContextElement; + +public abstract class BusinessContextElementConverter extends NamedElementConverter { + public static final String URI = "URI"; + + public BusinessContextElementConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + BusinessContextElement bce = (BusinessContextElement) parent; + + String uri = reader.getAttribute(URI); + + bce.setURI(uri); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + BusinessContextElement bce = (BusinessContextElement) parent; + + if (bce.getURI() != null) writer.addAttribute(URI, bce.getURI()); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessKnowledgeModelConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessKnowledgeModelConverter.java new file mode 100644 index 00000000000..6c661df66ae --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/BusinessKnowledgeModelConverter.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.BusinessKnowledgeModel; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.FunctionDefinition; +import org.kie.dmn.model.api.KnowledgeRequirement; +import org.kie.dmn.model.v1_5.TBusinessKnowledgeModel; + +public class BusinessKnowledgeModelConverter extends InvocableConverter { + public static final String ENCAPSULATED_LOGIC = "encapsulatedLogic"; + public static final String VARIABLE = "variable"; + public static final String KNOWLEDGE_REQUIREMENT = "knowledgeRequirement"; + public static final String AUTHORITY_REQUIREMENT = "authorityRequirement"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) parent; + + if (ENCAPSULATED_LOGIC.equals(nodeName)) { + bkm.setEncapsulatedLogic((FunctionDefinition) child); + } else if (KNOWLEDGE_REQUIREMENT.equals(nodeName)) { + bkm.getKnowledgeRequirement().add((KnowledgeRequirement) child); + } else if (AUTHORITY_REQUIREMENT.equals(nodeName)) { + bkm.getAuthorityRequirement().add((AuthorityRequirement) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) parent; + + if (bkm.getEncapsulatedLogic() != null) writeChildrenNode(writer, context, bkm.getEncapsulatedLogic(), ENCAPSULATED_LOGIC); + // Now as Invocable: if (bkm.getVariable() != null) writeChildrenNode(writer, context, bkm.getVariable(), VARIABLE); + for (KnowledgeRequirement i : bkm.getKnowledgeRequirement()) { + writeChildrenNode(writer, context, i, KNOWLEDGE_REQUIREMENT); + } + for (AuthorityRequirement a : bkm.getAuthorityRequirement()) { + writeChildrenNode(writer, context, a, AUTHORITY_REQUIREMENT); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public BusinessKnowledgeModelConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TBusinessKnowledgeModel(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TBusinessKnowledgeModel.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ChildExpressionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ChildExpressionConverter.java new file mode 100644 index 00000000000..ae0af3d2fd5 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ChildExpressionConverter.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.v1_5.TChildExpression; + +public class ChildExpressionConverter extends DMNModelInstrumentedBaseConverter { + + public static final String ID = "id"; + + public ChildExpressionConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + ChildExpression i = (ChildExpression) parent; + + if (child instanceof Expression) { + i.setExpression((Expression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + String id = reader.getAttribute( ID ); + + if (id != null) { + ((ChildExpression) parent).setId(id); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + ChildExpression e = (ChildExpression) parent; + + if (e.getId() != null) { + writer.addAttribute(ID, e.getId()); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + ChildExpression i = (ChildExpression) parent; + + writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, i.getExpression())); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TChildExpression(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TChildExpression.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ColorConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ColorConverter.java new file mode 100644 index 00000000000..230f5cdcee6 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ColorConverter.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.Color; + +public class ColorConverter extends DMNModelInstrumentedBaseConverter { + + private static final String RED = "red"; + private static final String GREEN = "green"; + private static final String BLUE = "blue"; + + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Color style = (Color) parent; + + style.setRed(Integer.valueOf(reader.getAttribute(RED))); + style.setGreen(Integer.valueOf(reader.getAttribute(GREEN))); + style.setBlue(Integer.valueOf(reader.getAttribute(BLUE))); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Color style = (Color) parent; + + writer.addAttribute(RED, Integer.valueOf(style.getRed()).toString()); + writer.addAttribute(GREEN, Integer.valueOf(style.getGreen()).toString()); + writer.addAttribute(BLUE, Integer.valueOf(style.getBlue()).toString()); + } + + public ColorConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.Color(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(org.kie.dmn.model.v1_5.dmndi.Color.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ConditionalConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ConditionalConverter.java new file mode 100644 index 00000000000..bd64a8b0351 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ConditionalConverter.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Conditional; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TChildExpression; +import org.kie.dmn.model.v1_5.TConditional; + +public class ConditionalConverter extends ExpressionConverter { + + public static final String IF = "if"; + public static final String THEN = "then"; + public static final String ELSE = "else"; + + public ConditionalConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Conditional cond = (Conditional) parent; + + if (IF.equals(nodeName)) { + cond.setIf((ChildExpression) child); + } else if (THEN.equals(nodeName)) { + cond.setThen((ChildExpression) child); + } else if (ELSE.equals(nodeName)) { + cond.setElse((ChildExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Conditional cond = (Conditional) parent; + writeChildrenNode(writer, context, cond.getIf(), IF); + writeChildrenNode(writer, context, cond.getThen(), THEN); + writeChildrenNode(writer, context, cond.getElse(), ELSE); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TConditional(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TConditional.class); + } + + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, IF, TChildExpression.class); + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, THEN, TChildExpression.class); + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, ELSE, TChildExpression.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextConverter.java new file mode 100644 index 00000000000..4cb7d913b31 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextConverter.java @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Context; +import org.kie.dmn.model.api.ContextEntry; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TContext; + +public class ContextConverter extends ExpressionConverter { + public static final String CONTEXT_ENTRY = "contextEntry"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Context c = (Context) parent; + + if (CONTEXT_ENTRY.equals(nodeName)) { + c.getContextEntry().add((ContextEntry) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Context c = (Context) parent; + + for (ContextEntry ce : c.getContextEntry()) { + writeChildrenNode(writer, context, ce, CONTEXT_ENTRY); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public ContextConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TContext(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TContext.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextEntryConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextEntryConverter.java new file mode 100644 index 00000000000..2ec439d0031 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ContextEntryConverter.java @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ContextEntry; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.v1_5.TContextEntry; + +public class ContextEntryConverter extends DMNElementConverter { + public static final String EXPRESSION = "expression"; + public static final String VARIABLE = "variable"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + ContextEntry ce = (ContextEntry) parent; + + if (VARIABLE.equals(nodeName)) { + ce.setVariable((InformationItem) child); + } else if (child instanceof Expression) { + ce.setExpression((Expression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + ContextEntry ce = (ContextEntry) parent; + + if (ce.getVariable() != null) writeChildrenNode(writer, context, ce.getVariable(), VARIABLE); + writeChildrenNode(writer, context, ce.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, ce.getExpression())); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public ContextEntryConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TContextEntry(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TContextEntry.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNBaseConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNBaseConverter.java new file mode 100644 index 00000000000..412c70f6408 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNBaseConverter.java @@ -0,0 +1,105 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.mapper.Mapper; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; + +public abstract class DMNBaseConverter + extends AbstractCollectionConverter { + + public DMNBaseConverter(Mapper mapper) { + super( mapper ); + } + + public void marshal( + Object object, + HierarchicalStreamWriter writer, + MarshallingContext context) { + writeAttributes(writer, object); + writeChildren(writer, context, object); + } + + protected void writeChildrenNode(HierarchicalStreamWriter writer, MarshallingContext context, Object node, String nodeAlias) { + writer.startNode(nodeAlias); + context.convertAnother(node); + writer.endNode(); + } + + protected void writeChildrenNodeAsValue(HierarchicalStreamWriter writer, MarshallingContext context, String nodeValue, String nodeAlias) { + writer.startNode(nodeAlias); + writer.setValue(nodeValue); + writer.endNode(); + } + + protected abstract void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent); + + protected abstract void writeAttributes(HierarchicalStreamWriter writer, Object parent); + + public Object unmarshal( + HierarchicalStreamReader reader, + UnmarshallingContext context) { + DMNModelInstrumentedBase obj = createModelObject(); + assignAttributes( reader, obj ); + parseElements( reader, context, obj ); + return obj; + } + + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + while ( reader.hasMoreChildren() ) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + Object object = readItem( + reader, + context, + null ); + if( object instanceof DMNModelInstrumentedBase ) { + ((DMNModelInstrumentedBase) object).setParent((DMNModelInstrumentedBase) parent); + ((DMNModelInstrumentedBase) parent).addChildren((DMNModelInstrumentedBase) object); + } + reader.moveUp(); + assignChildElement( parent, nodeName, object ); + } + } + + protected abstract DMNModelInstrumentedBase createModelObject(); + + protected abstract void assignChildElement(Object parent, String nodeName, Object child); + + protected abstract void assignAttributes(HierarchicalStreamReader reader, Object parent); + + protected void mvDownConvertAnotherMvUpAssignChildElement(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent, String expectedNodeName, Class type) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + if (!expectedNodeName.equals(nodeName)) throw new IllegalStateException(); + Object object = context.convertAnother(null, type); + if( object instanceof DMNModelInstrumentedBase ) { + ((DMNModelInstrumentedBase) object).setParent((DMNModelInstrumentedBase) parent); + ((DMNModelInstrumentedBase) parent).addChildren((DMNModelInstrumentedBase) object); + } + reader.moveUp(); + assignChildElement( parent, nodeName, object ); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDIConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDIConverter.java new file mode 100644 index 00000000000..e1d71863355 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDIConverter.java @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.DMNDI; +import org.kie.dmn.model.api.dmndi.DMNDiagram; +import org.kie.dmn.model.api.dmndi.DMNStyle; + +public class DMNDIConverter extends DMNModelInstrumentedBaseConverter { + + private static final String DMN_STYLE = "DMNStyle"; + private static final String DMN_DIAGRAM = "DMNDiagram"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNDI list = (DMNDI) parent; + + if (child instanceof DMNDiagram) { + list.getDMNDiagram().add((DMNDiagram) child); + } else if (child instanceof DMNStyle) { + list.getDMNStyle().add((DMNStyle) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNDI list = (DMNDI) parent; + + for (DMNDiagram e : list.getDMNDiagram()) { + writeChildrenNode(writer, context, e, DMN_DIAGRAM); + } + for (DMNStyle e : list.getDMNStyle()) { + writeChildrenNode(writer, context, e, DMN_STYLE); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public DMNDIConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNDI(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(org.kie.dmn.model.v1_5.dmndi.DMNDI.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDecisionServiceDividerLineConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDecisionServiceDividerLineConverter.java new file mode 100644 index 00000000000..dbcdd95ae9d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDecisionServiceDividerLineConverter.java @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; + +public class DMNDecisionServiceDividerLineConverter extends EdgeConverter { + + public DMNDecisionServiceDividerLineConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNDecisionServiceDividerLine(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.DMNDecisionServiceDividerLine.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDiagramConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDiagramConverter.java new file mode 100644 index 00000000000..96a2438ec3d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNDiagramConverter.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.DMNDiagram; +import org.kie.dmn.model.api.dmndi.DiagramElement; +import org.kie.dmn.model.api.dmndi.Dimension; + +public class DMNDiagramConverter extends DiagramConverter { + + private static final String SIZE = "Size"; + private static final String USE_ALTERNATIVE_INPUT_DATA_SHAPE = "useAlternativeInputDataShape"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNDiagram style = (DMNDiagram) parent; + + if (child instanceof Dimension) { + style.setSize((Dimension) child); + } else if (child instanceof DiagramElement) { + style.getDMNDiagramElement().add((DiagramElement) child); + } else { + super.assignChildElement(style, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DMNDiagram id = (DMNDiagram) parent; + id.setUseAlternativeInputDataShape( + Boolean.parseBoolean(reader.getAttribute(USE_ALTERNATIVE_INPUT_DATA_SHAPE))); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNDiagram style = (DMNDiagram) parent; + + if (style.getSize() != null) { + writeChildrenNode(writer, context, style.getSize(), SIZE); + } + for (DiagramElement de : style.getDMNDiagramElement()) { + writeChildrenNode(writer, context, de, de.getClass().getSimpleName()); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DMNDiagram id = (DMNDiagram) parent; + + if (id.getUseAlternativeInputDataShape() != null) { + writer.addAttribute(USE_ALTERNATIVE_INPUT_DATA_SHAPE, id.getUseAlternativeInputDataShape().toString()); + } + } + + public DMNDiagramConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNDiagram(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(org.kie.dmn.model.v1_5.dmndi.DMNDiagram.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNEdgeConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNEdgeConverter.java new file mode 100644 index 00000000000..a64d8b3f6ff --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNEdgeConverter.java @@ -0,0 +1,108 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.DMNEdge; +import org.kie.dmn.model.api.dmndi.DMNLabel; + +public class DMNEdgeConverter extends EdgeConverter { + + private static final String DMN_ELEMENT_REF = "dmnElementRef"; + private static final String SOURCE_ELEMENT = "sourceElement"; + private static final String TARGET_ELEMENT = "targetElement"; + private static final String DMN_LABEL = "DMNLabel"; + + public DMNEdgeConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNEdge concrete = (DMNEdge) parent; + + if (child instanceof DMNLabel) { + concrete.setDMNLabel((DMNLabel) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DMNEdge concrete = (DMNEdge) parent; + + String dmnElementRef = reader.getAttribute(DMN_ELEMENT_REF); + String sourceElement = reader.getAttribute(SOURCE_ELEMENT); + String targetElement = reader.getAttribute(TARGET_ELEMENT); + + if (dmnElementRef != null) { + concrete.setDmnElementRef(org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.parseQNameString(dmnElementRef)); + } + if (sourceElement != null) { + concrete.setSourceElement(org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.parseQNameString(sourceElement)); + } + if (targetElement != null) { + concrete.setTargetElement(org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.parseQNameString(targetElement)); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNEdge concrete = (DMNEdge) parent; + + if (concrete.getDMNLabel() != null) { + writeChildrenNode(writer, context, concrete.getDMNLabel(), DMN_LABEL); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + DMNEdge concrete = (DMNEdge) parent; + if (concrete.getDmnElementRef() != null) { + writer.addAttribute(DMN_ELEMENT_REF, org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.formatQName(concrete.getDmnElementRef(), concrete)); + } + if (concrete.getSourceElement() != null) { + writer.addAttribute(SOURCE_ELEMENT, org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.formatQName(concrete.getSourceElement(), concrete)); + } + if (concrete.getTargetElement() != null) { + writer.addAttribute(TARGET_ELEMENT, MarshallingUtils.formatQName(concrete.getTargetElement(), concrete)); + } + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNEdge(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.DMNEdge.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementConverter.java new file mode 100644 index 00000000000..10dbf0323ea --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementConverter.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElement; + +public abstract class DMNElementConverter + extends DMNModelInstrumentedBaseConverter { + public static final String ID = "id"; + public static final String LABEL = "label"; + public static final String DESCRIPTION = "description"; + public static final String EXTENSION_ELEMENTS = "extensionElements"; + + public DMNElementConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + if ( DESCRIPTION.equals( nodeName ) && child instanceof String ) { + ((DMNElement) parent).setDescription( (String) child ); + } else if(EXTENSION_ELEMENTS.equals(nodeName) + && child instanceof DMNElement.ExtensionElements) { + ((DMNElement)parent).setExtensionElements((DMNElement.ExtensionElements)child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + String id = reader.getAttribute( ID ); + String label = reader.getAttribute( LABEL ); + + DMNElement dmne = (DMNElement) parent; + + dmne.setId( id ); + dmne.setLabel( label ); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNElement e = (DMNElement) parent; + + if (e.getDescription() !=null) { writeChildrenNodeAsValue(writer, context, e.getDescription(), DESCRIPTION); } + if (e.getExtensionElements() != null ) { writeChildrenNode(writer, context, e.getExtensionElements(), EXTENSION_ELEMENTS); } + } + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DMNElement e = (DMNElement) parent; + + if (e.getId() != null) writer.addAttribute( ID , e.getId() ); + if (e.getLabel() != null) writer.addAttribute( LABEL , e.getLabel() ); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementReferenceConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementReferenceConverter.java new file mode 100644 index 00000000000..fdcaa4a2fbf --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNElementReferenceConverter.java @@ -0,0 +1,76 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TDMNElementReference; + +public class DMNElementReferenceConverter + extends DMNModelInstrumentedBaseConverter { + + private static final String HREF = "href"; + + public DMNElementReferenceConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TDMNElementReference.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement( parent, nodeName, child ); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + DMNElementReference er = (DMNElementReference) parent; + + String href = reader.getAttribute( HREF ); + + er.setHref( href ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDMNElementReference(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + // no children nodes. + } + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DMNElementReference er = (DMNElementReference) parent; + + if ( er.getHref() != null ) writer.addAttribute(HREF, er.getHref()); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNLabelConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNLabelConverter.java new file mode 100644 index 00000000000..2377b0f42eb --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNLabelConverter.java @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.DMNLabel; + +public class DMNLabelConverter extends ShapeConverter { + + public static final String TEXT = "Text"; + + public DMNLabelConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNLabel concrete = (DMNLabel) parent; + + if (nodeName.equals(TEXT)) { + concrete.setText((String) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNLabel concrete = (DMNLabel) parent; + + if (concrete.getText() != null) { + writeChildrenNode(writer, context, concrete.getText(), TEXT); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNLabel(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.DMNLabel.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNListConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNListConverter.java new file mode 100644 index 00000000000..fcadabbb8d6 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNListConverter.java @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.List; +import org.kie.dmn.model.v1_5.TList; + +public class DMNListConverter extends ExpressionConverter { + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + List list = (List) parent; + + if (child instanceof Expression) { + list.getExpression().add((Expression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + List list = (List) parent; + + for (Expression e : list.getExpression()) { + writeChildrenNode(writer, context, e, MarshallingUtils.defineExpressionNodeName(xstream, e)); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public DMNListConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TList(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TList.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNModelInstrumentedBaseConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNModelInstrumentedBaseConverter.java new file mode 100644 index 00000000000..e2cb72702ca --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNModelInstrumentedBaseConverter.java @@ -0,0 +1,118 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.CustomStaxReader; +import org.kie.dmn.backend.marshalling.CustomStaxWriter; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TDefinitions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.namespace.QName; +import java.util.Map; +import java.util.Map.Entry; + +public abstract class DMNModelInstrumentedBaseConverter + extends DMNBaseConverter { + + private static final Logger LOG = LoggerFactory.getLogger(DMNModelInstrumentedBaseConverter.class); + + protected XStream xstream; + + public DMNModelInstrumentedBaseConverter(XStream xstream) { + super( xstream.getMapper() ); + this.xstream = xstream; + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + KieDMNModelInstrumentedBase mib = (KieDMNModelInstrumentedBase) parent; + + CustomStaxReader customStaxReader = (CustomStaxReader) reader.underlyingReader(); + + Map currentNSCtx = customStaxReader.getNsContext(); + mib.getNsContext().putAll(currentNSCtx); + + mib.setLocation( customStaxReader.getLocation() ); + + mib.setAdditionalAttributes( customStaxReader.getAdditionalAttributes() ); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + // no call to super as super is abstract method. + } + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + KieDMNModelInstrumentedBase mib = (KieDMNModelInstrumentedBase) parent; + + CustomStaxWriter staxWriter = ((CustomStaxWriter) writer.underlyingWriter()); + for (Entry kv : mib.getNsContext().entrySet()) { + try { + if (KieDMNModelInstrumentedBase.URI_DMN.equals(kv.getValue())) { + // skip as that is the default namespace xmlns<:prefix>=DMN is handled by the stax driver. + } else { + staxWriter.writeNamespace(kv.getKey(), kv.getValue()); + } + } catch (Exception e) { + LOG.warn("The XML driver writer failed to manage writing namespace, namespaces prefixes could be wrong in the resulting file.", e); + } + } + + for ( Entry kv : mib.getAdditionalAttributes().entrySet() ) { + staxWriter.addAttribute(kv.getKey().getPrefix() + ":" + kv.getKey().getLocalPart(), kv.getValue()); + } + + if (parent instanceof TDefinitions) { + TDefinitions tDefinitions = (TDefinitions) parent; + String dmndiPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DMNDI).orElse("dmndi"); + String diPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DI).orElse("di"); + String dcPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DC).orElse("dc"); + + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDI", dmndiPrefix), "DMNDI"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDiagram", dmndiPrefix), "DMNDiagram"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNStyle", dmndiPrefix), "style"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNStyle", dmndiPrefix), "DMNStyle"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNShape", dmndiPrefix), "DMNShape"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNEdge", dmndiPrefix), "DMNEdge"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDecisionServiceDividerLine", dmndiPrefix), "DMNDecisionServiceDividerLine"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNLabel", dmndiPrefix), "DMNLabel"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, DMNLabelConverter.TEXT, dmndiPrefix), DMNLabelConverter.TEXT); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "Size", dmndiPrefix), "Size"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "useAlternativeInputDataShape", dmndiPrefix), "useAlternativeInputDataShape"); + + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "FillColor", dmndiPrefix), "FillColor"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "StrokeColor", dmndiPrefix), "StrokeColor"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "FontColor", dmndiPrefix), "FontColor"); + + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DI, "waypoint", diPrefix), "waypoint"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DI, "extension", diPrefix), "extension"); + staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DC, "Bounds", dcPrefix), "Bounds"); + } + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNShapeConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNShapeConverter.java new file mode 100644 index 00000000000..be45b4af9b8 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNShapeConverter.java @@ -0,0 +1,118 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine; +import org.kie.dmn.model.api.dmndi.DMNLabel; +import org.kie.dmn.model.v1_5.dmndi.DMNShape; + +public class DMNShapeConverter extends ShapeConverter { + + private static final String FILL_COLOR = "FillColor"; + private static final String STROKE_COLOR = "StrokeColor"; + private static final String FONT_COLOR = "FontColor"; + + private static final String FONT_FAMILY = "fontFamily"; + private static final String FONT_SIZE = "fontSize"; + private static final String FONT_ITALIC = "fontItalic"; + private static final String FONT_BOLD = "fontBold"; + private static final String FONT_UNDERLINE = "fontUnderline"; + private static final String FONT_STRIKE_THROUGH = "fontStrikeThrough"; + private static final String LABEL_HORIZONTAL_ALIGNMENT = "labelHorizontalAlignement"; + private static final String LABEL_VERTICAL_ALIGNMENT = "labelVerticalAlignment"; + + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNShape style = (DMNShape) parent; + + if (child instanceof DMNLabel) { + style.setDMNLabel((DMNLabel) child); + } else if (child instanceof DMNDecisionServiceDividerLine) { + style.setDMNDecisionServiceDividerLine((DMNDecisionServiceDividerLine) child); + } else { + super.assignChildElement(style, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DMNShape style = (DMNShape) parent; + + style.setDmnElementRef(org.kie.dmn.backend.marshalling.v1_5.xstream.MarshallingUtils.parseQNameString(reader.getAttribute("dmnElementRef"))); + + String isListedInputData = reader.getAttribute("isListedInputData"); + String isCollapsed = reader.getAttribute("isCollapsed"); + + if (isListedInputData != null) { + style.setIsListedInputData(Boolean.valueOf(isListedInputData)); + } + if (isCollapsed != null) { + style.setIsCollapsed(Boolean.valueOf(isCollapsed)); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNShape style = (DMNShape) parent; + + if (style.getDMNLabel() != null) { + writeChildrenNode(writer, context, style.getDMNLabel(), "DMNLabel"); + } + if (style.getDMNDecisionServiceDividerLine() != null) { + writeChildrenNode(writer, context, style.getDMNDecisionServiceDividerLine(), "DMNDecisionServiceDividerLine"); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DMNShape style = (DMNShape) parent; + + writer.addAttribute("dmnElementRef", MarshallingUtils.formatQName(style.getDmnElementRef(), style)); + + if (style.isIsListedInputData() != null) { + writer.addAttribute("isListedInputData", style.isIsListedInputData().toString()); + } + writer.addAttribute("isCollapsed", Boolean.valueOf(style.isIsCollapsed()).toString()); + } + + public DMNShapeConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new DMNShape(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(DMNShape.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNStyleConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNStyleConverter.java new file mode 100644 index 00000000000..1fb5ce01cab --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DMNStyleConverter.java @@ -0,0 +1,163 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.AlignmentKind; +import org.kie.dmn.model.api.dmndi.Color; +import org.kie.dmn.model.api.dmndi.DMNStyle; + +public class DMNStyleConverter extends StyleConverter { + + private static final String FILL_COLOR = "FillColor"; + private static final String STROKE_COLOR = "StrokeColor"; + private static final String FONT_COLOR = "FontColor"; + + private static final String FONT_FAMILY = "fontFamily"; + private static final String FONT_SIZE = "fontSize"; + private static final String FONT_ITALIC = "fontItalic"; + private static final String FONT_BOLD = "fontBold"; + private static final String FONT_UNDERLINE = "fontUnderline"; + private static final String FONT_STRIKE_THROUGH = "fontStrikeThrough"; + private static final String LABEL_HORIZONTAL_ALIGNMENT = "labelHorizontalAlignement"; + private static final String LABEL_VERTICAL_ALIGNMENT = "labelVerticalAlignment"; + + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DMNStyle style = (DMNStyle) parent; + + if (FILL_COLOR.equals(nodeName)) { + style.setFillColor((Color) child); + } else if (STROKE_COLOR.equals(nodeName)) { + style.setStrokeColor((Color) child); + } else if (FONT_COLOR.equals(nodeName)) { + style.setFontColor((Color) child); + } else { + super.assignChildElement(style, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DMNStyle style = (DMNStyle) parent; + + String fontFamily = reader.getAttribute(FONT_FAMILY ); + String fontSize = reader.getAttribute(FONT_SIZE); + String fontItalic = reader.getAttribute(FONT_ITALIC); + String fontBold = reader.getAttribute(FONT_BOLD); + String fontUnderline = reader.getAttribute(FONT_UNDERLINE); + String fontStrikeThrough = reader.getAttribute(FONT_STRIKE_THROUGH); + String labelHorizontalAlignement = reader.getAttribute(LABEL_HORIZONTAL_ALIGNMENT); + String labelVerticalAlignment = reader.getAttribute(LABEL_VERTICAL_ALIGNMENT); + + if (fontFamily != null) { + style.setFontFamily(fontFamily); + } + if (fontSize != null) { + style.setFontSize(Double.valueOf(fontSize)); + } + if (fontItalic != null) { + style.setFontItalic(Boolean.valueOf(fontItalic)); + } + if (fontBold != null) { + style.setFontBold(Boolean.valueOf(fontBold)); + } + if (fontUnderline != null) { + style.setFontUnderline(Boolean.valueOf(fontUnderline)); + } + if (fontStrikeThrough != null) { + style.setFontStrikeThrough(Boolean.valueOf(fontStrikeThrough)); + } + if (labelHorizontalAlignement != null) { + style.setLabelHorizontalAlignement(AlignmentKind.valueOf(labelHorizontalAlignement)); + } + if (labelVerticalAlignment != null) { + style.setLabelVerticalAlignment(AlignmentKind.valueOf(labelVerticalAlignment)); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DMNStyle style = (DMNStyle) parent; + + if (style.getFillColor() != null) { + writeChildrenNode(writer, context, style.getFillColor(), FILL_COLOR); + } + if (style.getStrokeColor() != null) { + writeChildrenNode(writer, context, style.getStrokeColor(), STROKE_COLOR); + } + if (style.getFontColor() != null) { + writeChildrenNode(writer, context, style.getFontColor(), FONT_COLOR); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DMNStyle style = (DMNStyle) parent; + + if (style.getFontFamily() != null) { + writer.addAttribute(FONT_FAMILY, style.getFontFamily()); + } + if (style.getFontSize() != null) { + writer.addAttribute(FONT_SIZE, FormatUtils.manageDouble(style.getFontSize())); + } + if (style.isFontItalic() != null) { + writer.addAttribute(FONT_ITALIC, style.isFontItalic().toString()); + } + if (style.isFontBold() != null) { + writer.addAttribute(FONT_BOLD, style.isFontBold().toString()); + } + if (style.isFontUnderline() != null) { + writer.addAttribute(FONT_UNDERLINE, style.isFontUnderline().toString()); + } + if (style.isFontStrikeThrough() != null) { + writer.addAttribute(FONT_STRIKE_THROUGH, style.isFontStrikeThrough().toString()); + } + if (style.getLabelHorizontalAlignement() != null) { + writer.addAttribute(LABEL_HORIZONTAL_ALIGNMENT, style.getLabelHorizontalAlignement().toString()); + } + if (style.getLabelVerticalAlignment() != null) { + writer.addAttribute(LABEL_VERTICAL_ALIGNMENT, style.getLabelVerticalAlignment().toString()); + } + } + + public DMNStyleConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.DMNStyle(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(org.kie.dmn.model.v1_5.dmndi.DMNStyle.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DRGElementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DRGElementConverter.java new file mode 100644 index 00000000000..90238ff9fc5 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DRGElementConverter.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; + +public abstract class DRGElementConverter + extends NamedElementConverter { + + public DRGElementConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement( parent, nodeName, child ); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionConverter.java new file mode 100644 index 00000000000..7e1f658999d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionConverter.java @@ -0,0 +1,153 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Decision; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.InformationRequirement; +import org.kie.dmn.model.api.KnowledgeRequirement; +import org.kie.dmn.model.v1_5.TDecision; + +public class DecisionConverter extends DRGElementConverter { + public static final String QUESTION = "question"; + public static final String ALLOWED_ANSWERS = "allowedAnswers"; + public static final String VARIABLE = "variable"; + public static final String INFORMATION_REQUIREMENT = "informationRequirement"; + public static final String KNOWLEDGE_REQUIREMENT = "knowledgeRequirement"; + public static final String AUTHORITY_REQUIREMENT = "authorityRequirement"; + public static final String SUPPORTED_OBJECTIVE = "supportedObjective"; + public static final String IMPACTED_PERFORMANCE_INDICATOR = "impactedPerformanceIndicator"; + public static final String DECISION_MAKER = "decisionMaker"; + public static final String DECISION_OWNER = "decisionOwner"; + public static final String USING_PROCESS = "usingProcess"; + public static final String USING_TASK = "usingTask"; + public static final String EXPRESSION = "expression"; + + public DecisionConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TDecision.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Decision dec = (Decision) parent; + + if (QUESTION.equals(nodeName)) { + dec.setQuestion((String) child); + } else if (ALLOWED_ANSWERS.equals(nodeName)) { + dec.setAllowedAnswers((String) child); + } else if (VARIABLE.equals(nodeName) ) { + dec.setVariable( (InformationItem) child ); + } else if (INFORMATION_REQUIREMENT.equals(nodeName) ) { + dec.getInformationRequirement().add( (InformationRequirement) child ); + } else if (KNOWLEDGE_REQUIREMENT.equals(nodeName) ) { + dec.getKnowledgeRequirement().add((KnowledgeRequirement) child); + } else if (AUTHORITY_REQUIREMENT.equals(nodeName) ) { + dec.getAuthorityRequirement().add((AuthorityRequirement) child); + } else if (SUPPORTED_OBJECTIVE.equals(nodeName) ) { + dec.getSupportedObjective().add((DMNElementReference) child); + } else if (IMPACTED_PERFORMANCE_INDICATOR.equals(nodeName) ) { + dec.getImpactedPerformanceIndicator().add((DMNElementReference) child); + } else if (DECISION_MAKER.equals(nodeName) ) { + dec.getDecisionMaker().add((DMNElementReference) child); + } else if (DECISION_OWNER.equals(nodeName) ) { + dec.getDecisionOwner().add((DMNElementReference) child); + } else if (USING_PROCESS.equals(nodeName) ) { + dec.getUsingProcess().add((DMNElementReference) child); + } else if (USING_TASK.equals(nodeName) ) { + dec.getUsingTask().add((DMNElementReference) child); + } else if ( child instanceof Expression ) { + dec.setExpression( (Expression) child ); + } else { + super.assignChildElement( dec, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + + // no attributes. + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDecision(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Decision dec = (Decision) parent; + + if (dec.getQuestion() != null) writeChildrenNodeAsValue(writer, context, dec.getQuestion(), QUESTION); + if (dec.getAllowedAnswers() != null) writeChildrenNodeAsValue(writer, context, dec.getAllowedAnswers(), ALLOWED_ANSWERS); + if (dec.getVariable() != null) writeChildrenNode(writer, context, dec.getVariable(), VARIABLE); + for ( InformationRequirement ir : dec.getInformationRequirement() ) { + writeChildrenNode(writer, context, ir, INFORMATION_REQUIREMENT); + } + for ( KnowledgeRequirement kr : dec.getKnowledgeRequirement() ) { + writeChildrenNode(writer, context, kr, KNOWLEDGE_REQUIREMENT); + } + for ( AuthorityRequirement ar : dec.getAuthorityRequirement() ) { + writeChildrenNode(writer, context, ar, AUTHORITY_REQUIREMENT); + } + for ( DMNElementReference so : dec.getSupportedObjective() ) { + writeChildrenNode(writer, context, so, SUPPORTED_OBJECTIVE); + } + for ( DMNElementReference ipi : dec.getImpactedPerformanceIndicator() ) { + writeChildrenNode(writer, context, ipi, IMPACTED_PERFORMANCE_INDICATOR); + } + for ( DMNElementReference dm : dec.getDecisionMaker() ) { + writeChildrenNode(writer, context, dm, DECISION_MAKER); + } + for ( DMNElementReference downer : dec.getDecisionOwner() ) { + writeChildrenNode(writer, context, downer, DECISION_OWNER); + } + for ( DMNElementReference up : dec.getUsingProcess() ) { + writeChildrenNode(writer, context, up, USING_PROCESS); + } + for ( DMNElementReference ut : dec.getUsingTask() ) { + writeChildrenNode(writer, context, ut, USING_TASK); + } + if (dec.getExpression() != null) { + Expression e = dec.getExpression(); + String nodeName = MarshallingUtils.defineExpressionNodeName(xstream, e); + writeChildrenNode(writer, context, e, nodeName); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionRuleConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionRuleConverter.java new file mode 100644 index 00000000000..0c65aec1f97 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionRuleConverter.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.DecisionRule; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.RuleAnnotation; +import org.kie.dmn.model.api.UnaryTests; +import org.kie.dmn.model.v1_5.TDecisionRule; + +public class DecisionRuleConverter extends DMNElementConverter { + public static final String OUTPUT_ENTRY = "outputEntry"; + public static final String INPUT_ENTRY = "inputEntry"; + public static final String ANNOTATION_ENTRY = "annotationEntry"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DecisionRule dr = (DecisionRule) parent; + + if (INPUT_ENTRY.equals(nodeName)) { + dr.getInputEntry().add((UnaryTests) child); + } else if (OUTPUT_ENTRY.equals(nodeName)) { + dr.getOutputEntry().add((LiteralExpression) child); + } else if (ANNOTATION_ENTRY.equals(nodeName)) { + dr.getAnnotationEntry().add((RuleAnnotation) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DecisionRule dr = (DecisionRule) parent; + + for (UnaryTests ie : dr.getInputEntry()) { + writeChildrenNode(writer, context, ie, INPUT_ENTRY); + } + for (LiteralExpression oe : dr.getOutputEntry()) { + writeChildrenNode(writer, context, oe, OUTPUT_ENTRY); + } + for (RuleAnnotation a : dr.getAnnotationEntry()) { + writeChildrenNode(writer, context, a, ANNOTATION_ENTRY); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public DecisionRuleConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDecisionRule(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TDecisionRule.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionServiceConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionServiceConverter.java new file mode 100644 index 00000000000..cf602339a81 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionServiceConverter.java @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.DecisionService; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TDMNElementReference; +import org.kie.dmn.model.v1_5.TDecisionService; + +public class DecisionServiceConverter extends InvocableConverter { + + public static final String OUTPUT_DECISION = "outputDecision"; + + public static final String ENCAPSULATED_DECISION = "encapsulatedDecision"; + + public static final String INPUT_DECISION = "inputDecision"; + + public static final String INPUT_DATA = "inputData"; + + public DecisionServiceConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDecisionService(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TDecisionService.class); + } + + @Override + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + while (reader.hasMoreChildren()) { + reader.moveDown(); + Object object; + String nodeName = reader.getNodeName(); + if (nodeName.equals(INPUT_DATA)) { + // Patch because the tag name inputData is used in both decision services and as a DRG Element + DMNElementReference ref = new TDMNElementReference(); + ref.setHref(reader.getAttribute("href")); + object = ref; + } else { + // Default behaviour + object = readItem(reader, context, null); + } + if (object instanceof DMNModelInstrumentedBase) { + ((KieDMNModelInstrumentedBase) object).setParent((KieDMNModelInstrumentedBase) parent); + ((KieDMNModelInstrumentedBase) parent).addChildren((KieDMNModelInstrumentedBase) object); + } + reader.moveUp(); + assignChildElement(parent, nodeName, object); + } + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DecisionService decisionService = (DecisionService) parent; + switch (nodeName) { + case OUTPUT_DECISION: + decisionService.getOutputDecision().add((DMNElementReference) child); + break; + case ENCAPSULATED_DECISION: + decisionService.getEncapsulatedDecision().add((DMNElementReference) child); + break; + case INPUT_DECISION: + decisionService.getInputDecision().add((DMNElementReference) child); + break; + case INPUT_DATA: + decisionService.getInputData().add((DMNElementReference) child); + break; + default: + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DecisionService decisionService = (DecisionService) parent; + + for (DMNElementReference ref : decisionService.getOutputDecision()) { + writeChildrenNode(writer, context, ref, OUTPUT_DECISION); + } + for (DMNElementReference ref : decisionService.getEncapsulatedDecision()) { + writeChildrenNode(writer, context, ref, ENCAPSULATED_DECISION); + } + for (DMNElementReference ref : decisionService.getInputDecision()) { + writeChildrenNode(writer, context, ref, INPUT_DECISION); + } + for (DMNElementReference ref : decisionService.getInputData()) { + writeChildrenNode(writer, context, ref, INPUT_DATA); + } + + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionTableConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionTableConverter.java new file mode 100644 index 00000000000..d9494965f30 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DecisionTableConverter.java @@ -0,0 +1,124 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.BuiltinAggregator; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.DecisionRule; +import org.kie.dmn.model.api.DecisionTable; +import org.kie.dmn.model.api.DecisionTableOrientation; +import org.kie.dmn.model.api.HitPolicy; +import org.kie.dmn.model.api.InputClause; +import org.kie.dmn.model.api.OutputClause; +import org.kie.dmn.model.api.RuleAnnotationClause; +import org.kie.dmn.model.v1_5.TDecisionTable; + +public class DecisionTableConverter extends ExpressionConverter { + public static final String RULE = "rule"; + public static final String OUTPUT = "output"; + public static final String INPUT = "input"; + public static final String HIT_POLICY = "hitPolicy"; + public static final String AGGREGATION = "aggregation"; + public static final String PREFERRED_ORIENTATION = "preferredOrientation"; + public static final String OUTPUT_LABEL = "outputLabel"; + + public static final String ANNOTATION = "annotation"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DecisionTable dt = (DecisionTable) parent; + + if (INPUT.equals(nodeName)) { + dt.getInput().add((InputClause) child); + } else if (OUTPUT.equals(nodeName)) { + dt.getOutput().add((OutputClause) child); + } else if (ANNOTATION.equals(nodeName)) { + dt.getAnnotation().add((RuleAnnotationClause) child); + } else if (RULE.equals(nodeName)) { + dt.getRule().add((DecisionRule) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DecisionTable dt = (DecisionTable) parent; + + String hitPolicyValue = reader.getAttribute(HIT_POLICY); + String aggregationValue = reader.getAttribute(AGGREGATION); + String preferredOrientationValue = reader.getAttribute(PREFERRED_ORIENTATION); + String outputLabel = reader.getAttribute(OUTPUT_LABEL); + + if (hitPolicyValue != null) dt.setHitPolicy(HitPolicy.fromValue(hitPolicyValue)); + if (aggregationValue != null) dt.setAggregation(BuiltinAggregator.fromValue(aggregationValue)); + if (preferredOrientationValue != null) dt.setPreferredOrientation(DecisionTableOrientation.fromValue(preferredOrientationValue)); + dt.setOutputLabel(outputLabel); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DecisionTable dt = (DecisionTable) parent; + + for (InputClause i : dt.getInput()) { + writeChildrenNode(writer, context, i, INPUT); + } + for (OutputClause o : dt.getOutput()) { + writeChildrenNode(writer, context, o, OUTPUT); + } + for (RuleAnnotationClause a : dt.getAnnotation()) { + writeChildrenNode(writer, context, a, ANNOTATION); + } + for (DecisionRule r : dt.getRule()) { + writeChildrenNode(writer, context, r, RULE); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DecisionTable dt = (DecisionTable) parent; + + if (dt.getHitPolicy() != null) writer.addAttribute(HIT_POLICY, dt.getHitPolicy().value()); + if (dt.getAggregation()!= null) writer.addAttribute(AGGREGATION, dt.getAggregation().value()); + if (dt.getPreferredOrientation() != null) writer.addAttribute(PREFERRED_ORIENTATION, dt.getPreferredOrientation().value()); + if (dt.getOutputLabel() != null) writer.addAttribute(OUTPUT_LABEL, dt.getOutputLabel()); + } + + public DecisionTableConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDecisionTable(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TDecisionTable.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DefinitionsConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DefinitionsConverter.java new file mode 100644 index 00000000000..1e111a91d9d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DefinitionsConverter.java @@ -0,0 +1,193 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Artifact; +import org.kie.dmn.model.api.Association; +import org.kie.dmn.model.api.BusinessContextElement; +import org.kie.dmn.model.api.BusinessKnowledgeModel; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.DRGElement; +import org.kie.dmn.model.api.Decision; +import org.kie.dmn.model.api.DecisionService; +import org.kie.dmn.model.api.Definitions; +import org.kie.dmn.model.api.ElementCollection; +import org.kie.dmn.model.api.Group; +import org.kie.dmn.model.api.Import; +import org.kie.dmn.model.api.InputData; +import org.kie.dmn.model.api.ItemDefinition; +import org.kie.dmn.model.api.KnowledgeSource; +import org.kie.dmn.model.api.OrganizationUnit; +import org.kie.dmn.model.api.PerformanceIndicator; +import org.kie.dmn.model.api.TextAnnotation; +import org.kie.dmn.model.api.dmndi.DMNDI; +import org.kie.dmn.model.v1_5.TDefinitions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.XMLConstants; + +public class DefinitionsConverter + extends NamedElementConverter { + + private static final Logger LOG = LoggerFactory.getLogger(DefinitionsConverter.class); + + private static final String EXPRESSION_LANGUAGE = "expressionLanguage"; + private static final String TYPE_LANGUAGE = "typeLanguage"; + private static final String NAMESPACE = "namespace"; + private static final String EXPORTER = "exporter"; + private static final String EXPORTER_VERSION = "exporterVersion"; + + public static final String IMPORT = "import"; + public static final String ITEM_DEFINITION = "itemDefinition"; + public static final String DRG_ELEMENT = "drgElement"; + public static final String ARTIFACT = "artifact"; + public static final String ELEMENT_COLLECTION = "elementCollection"; + public static final String BUSINESS_CONTEXT_ELEMENT = "businessContextElement"; + + public DefinitionsConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TDefinitions.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Definitions def = (Definitions) parent; + if ( IMPORT.equals(nodeName) ) { + def.getImport().add((Import) child); + } else if (ITEM_DEFINITION.equals(nodeName)) { + def.getItemDefinition().add((ItemDefinition) child); + } else if (child instanceof DRGElement) { + def.getDrgElement().add( (DRGElement) child ); + } else if (child instanceof Artifact) { + def.getArtifact().add((Artifact) child); + } else if (ELEMENT_COLLECTION.equals(nodeName)) { + def.getElementCollection().add((ElementCollection) child); + } else if (child instanceof BusinessContextElement ) { + def.getBusinessContextElement().add((BusinessContextElement) child); + } else if (child instanceof DMNDI) { + DMNDI dmndi = (DMNDI) child; + dmndi.normalize(); + def.setDMNDI(dmndi); + } else { + super.assignChildElement( def, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + Definitions def = (Definitions) parent; + + String exprLang = reader.getAttribute( EXPRESSION_LANGUAGE ); + String typeLang = reader.getAttribute( TYPE_LANGUAGE ); + String namespace = reader.getAttribute( NAMESPACE ); + String exporter = reader.getAttribute( EXPORTER ); + String exporterVersion = reader.getAttribute( EXPORTER_VERSION ); + + def.setExpressionLanguage( exprLang ); + def.setTypeLanguage( typeLang ); + def.setNamespace( namespace ); + def.setExporter( exporter ); + def.setExporterVersion( exporterVersion ); + + if (!def.getNsContext().containsKey(XMLConstants.DEFAULT_NS_PREFIX)) { + LOG.warn("This DMN file does not define a default namespace"); + } + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDefinitions(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Definitions def = (Definitions) parent; + + for ( Import i : def.getImport() ) { + writeChildrenNode(writer, context, i, IMPORT); + } + for ( ItemDefinition id : def.getItemDefinition() ) { + writeChildrenNode(writer, context, id, ITEM_DEFINITION); + } + for ( DRGElement e : def.getDrgElement() ) { + String nodeName = DRG_ELEMENT; + if (e instanceof BusinessKnowledgeModel) { + nodeName = "businessKnowledgeModel"; + } else if (e instanceof Decision) { + nodeName = "decision"; + } else if (e instanceof InputData) { + nodeName = "inputData"; + } else if (e instanceof KnowledgeSource) { + nodeName = "knowledgeSource"; + } else if (e instanceof DecisionService) { + nodeName = "decisionService"; + } + writeChildrenNode(writer, context, e, nodeName); + } + for ( Artifact a : def.getArtifact() ) { + String nodeName = ARTIFACT; + if (a instanceof Association) { + nodeName = "association"; + } else if (a instanceof TextAnnotation) { + nodeName = "textAnnotation"; + } else if (a instanceof Group) { + nodeName = "group"; + } + writeChildrenNode(writer, context, a, nodeName); + } + for ( ElementCollection ec : def.getElementCollection() ) { + writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION); + } + for ( BusinessContextElement bce : def.getBusinessContextElement() ) { + String nodeName = BUSINESS_CONTEXT_ELEMENT; + if (bce instanceof OrganizationUnit) { + nodeName = "organizationUnit"; + } else if (bce instanceof PerformanceIndicator) { + nodeName = "performanceIndicator"; + } + writeChildrenNode(writer, context, bce, nodeName); + } + + if (def.getDMNDI() != null) { + writeChildrenNode(writer, context, def.getDMNDI(), "DMNDI"); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Definitions def = (Definitions) parent; + + if (def.getExpressionLanguage() != null) writer.addAttribute( EXPRESSION_LANGUAGE , def.getExpressionLanguage() ); + if (def.getTypeLanguage() != null) writer.addAttribute( TYPE_LANGUAGE, def.getTypeLanguage() ); + if (def.getNamespace() != null) writer.addAttribute( NAMESPACE, def.getNamespace()); + if (def.getExporter() != null) writer.addAttribute( EXPORTER, def.getExporter() ); + if (def.getExporterVersion() != null) writer.addAttribute( EXPORTER_VERSION, def.getExporterVersion()); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramConverter.java new file mode 100644 index 00000000000..63bf5c226dc --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramConverter.java @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.dmndi.Diagram; + +public abstract class DiagramConverter extends DiagramElementConverter { + + private static final String RESOLUTION = "resolution"; + private static final String DOCUMENTATION = "documentation"; + private static final String NAME = "name"; + + public DiagramConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Diagram abs = (Diagram) parent; + + String name = reader.getAttribute(NAME); + String documentation = reader.getAttribute(DOCUMENTATION); + String resolution = reader.getAttribute(RESOLUTION); + + if (name != null) { + abs.setName(name); + } + if (documentation != null) { + abs.setDocumentation(documentation); + } + if (resolution != null) { + abs.setResolution(Double.valueOf(resolution)); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Diagram abs = (Diagram) parent; + + if (abs.getName() != null) { + writer.addAttribute(NAME, abs.getName()); + } + if (abs.getDocumentation() != null) { + writer.addAttribute(DOCUMENTATION, abs.getDocumentation()); + } + if (abs.getResolution() != null) { + writer.addAttribute(RESOLUTION, abs.getResolution().toString()); + } + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementConverter.java new file mode 100644 index 00000000000..240b7a2e353 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementConverter.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.model.api.dmndi.DiagramElement; +import org.kie.dmn.model.api.dmndi.Style; + +public abstract class DiagramElementConverter extends DMNModelInstrumentedBaseConverter { + + private static final String STYLE = "style"; + private static final String SHARED_STYLE = "sharedStyle"; + private static final String EXTENSION = "extension"; + private static final String ID = "id"; + + public DiagramElementConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + DiagramElement abs = (DiagramElement) parent; + + if (child instanceof DiagramElement.Extension) { + abs.setExtension((DiagramElement.Extension) child); + } else if (child instanceof Style) { + abs.setStyle((Style) child); + } else { + super.assignChildElement(abs, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + DiagramElement abs = (DiagramElement) parent; + String id = reader.getAttribute(ID); + if (id != null) { + abs.setId(id); + } + + String sharedStyleXmlSerialization = reader.getAttribute(SHARED_STYLE); + if (sharedStyleXmlSerialization != null) { + abs.setSharedStyle(new org.kie.dmn.model.v1_5.dmndi.Style.IDREFStubStyle(sharedStyleXmlSerialization)); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + DiagramElement abs = (DiagramElement) parent; + + if (abs.getExtension() != null) { + writeChildrenNode(writer, context, abs.getExtension(), EXTENSION); + } + if (abs.getStyle() != null) { + writeChildrenNode(writer, context, abs.getStyle(), STYLE); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + DiagramElement abs = (DiagramElement) parent; + + if (abs.getId() != null) { + writer.addAttribute(ID, abs.getId()); + } + + if (abs.getSharedStyle() != null) { + writer.addAttribute(SHARED_STYLE, abs.getSharedStyle().getId()); + } + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementExtensionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementExtensionConverter.java new file mode 100644 index 00000000000..34919a59461 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DiagramElementExtensionConverter.java @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.mapper.CannotResolveClassException; +import org.kie.dmn.api.marshalling.DMNExtensionRegister; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.dmndi.DiagramElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class DiagramElementExtensionConverter extends DMNModelInstrumentedBaseConverter { + + private static final Logger LOG = LoggerFactory.getLogger(DiagramElementExtensionConverter.class); + + private List extensionRegisters = new ArrayList<>(); + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + // no attributes. + } + + public DiagramElementExtensionConverter(XStream xStream, List extensionRegisters) { + super(xStream); + if (!extensionRegisters.isEmpty()) { + this.extensionRegisters.addAll(extensionRegisters); + } + } + + @Override + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + DMNModelInstrumentedBase obj = createModelObject(); + assignAttributes(reader, obj); + if (extensionRegisters.size() == 0) { + while (reader.hasMoreChildren()) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + // skipping nodeName + reader.moveUp(); + } + } else { + // do as default behavior, but in case cannot unmarshall an extension element child, just skip it. + while (reader.hasMoreChildren()) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + try { + Object object = readItem(reader, context, null); + if (object instanceof DMNModelInstrumentedBase) { + ((KieDMNModelInstrumentedBase) object).setParent(obj); + obj.addChildren((KieDMNModelInstrumentedBase) object); + } + assignChildElement(obj, nodeName, object); + } catch (CannotResolveClassException e) { + // do nothing; I tried to convert the extension element child with the converters, but no converter is registered for this child. + LOG.debug("Tried to convert the extension element child {}, but no converter is registered for this child.", nodeName); + } + reader.moveUp(); + } + } + return obj; + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + if (extensionRegisters.size() == 0) { + return; + } + + org.kie.dmn.model.api.dmndi.DiagramElement.Extension ee = (org.kie.dmn.model.api.dmndi.DiagramElement.Extension) parent; + if (ee.getAny() != null) { + for (Object a : ee.getAny()) { + writeItem(a, context, writer); + } + } + } + + public DiagramElementExtensionConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new DiagramElement.Extension(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(DiagramElement.Extension.class); + } + + @Override + public void assignChildElement(Object parent, String nodeName, Object child) { + org.kie.dmn.model.api.dmndi.DiagramElement.Extension id = (org.kie.dmn.model.api.dmndi.DiagramElement.Extension) parent; + id.getAny().add(child); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DimensionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DimensionConverter.java new file mode 100644 index 00000000000..b154e0a969f --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/DimensionConverter.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.Dimension; + +public class DimensionConverter extends DMNModelInstrumentedBaseConverter { + + + private static final String HEIGHT = "height"; + private static final String WIDTH = "width"; + + public DimensionConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Dimension abs = (Dimension) parent; + + abs.setWidth(Double.valueOf(reader.getAttribute(WIDTH))); + abs.setHeight(Double.valueOf(reader.getAttribute(HEIGHT))); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Dimension abs = (Dimension) parent; + + writer.addAttribute(WIDTH, org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils.manageDouble(abs.getWidth())); + writer.addAttribute(HEIGHT, FormatUtils.manageDouble(abs.getHeight())); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.Dimension(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.Dimension.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EdgeConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EdgeConverter.java new file mode 100644 index 00000000000..7e8df9bbe6a --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EdgeConverter.java @@ -0,0 +1,72 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.dmndi.Edge; +import org.kie.dmn.model.api.dmndi.Point; + +public abstract class EdgeConverter extends DiagramElementConverter { + + private static final String WAYPOINT = "waypoint"; + + public EdgeConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Edge abs = (Edge) parent; + + if (child instanceof Point) { + abs.getWaypoint().add((Point) child); + } else { + super.assignChildElement(abs, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Edge abs = (Edge) parent; + + for (Point pt : abs.getWaypoint()) { + writeChildrenNode(writer, context, pt, WAYPOINT); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ElementCollectionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ElementCollectionConverter.java new file mode 100644 index 00000000000..cd6d5f4560d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ElementCollectionConverter.java @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.ElementCollection; +import org.kie.dmn.model.v1_5.TElementCollection; + +public class ElementCollectionConverter extends NamedElementConverter { + + public static final String DRG_ELEMENT = "drgElement"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + ElementCollection ec = (ElementCollection) parent; + + if (DRG_ELEMENT.equals( nodeName )) { + ec.getDrgElement().add((DMNElementReference) child); + } + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + ElementCollection ec = (ElementCollection) parent; + + for (DMNElementReference e : ec.getDrgElement()) { + writeChildrenNode(writer, context, e, DRG_ELEMENT); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public ElementCollectionConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TElementCollection(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TElementCollection.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EveryConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EveryConverter.java new file mode 100644 index 00000000000..78db4cf5d3f --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/EveryConverter.java @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TEvery; + +public class EveryConverter extends QuantifiedConverter { + + public EveryConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TEvery(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TEvery.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExpressionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExpressionConverter.java new file mode 100644 index 00000000000..f7068d00496 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExpressionConverter.java @@ -0,0 +1,55 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.UnaryTests; + +public abstract class ExpressionConverter + extends DMNElementConverter { + + public static final String TYPE_REF = "typeRef"; + + public ExpressionConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + String typeRef = reader.getAttribute( TYPE_REF ); + + if (typeRef != null) { + ((Expression) parent).setTypeRef(MarshallingUtils.parseQNameString(typeRef)); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Expression e = (Expression) parent; + + if (!(e instanceof UnaryTests) && e.getTypeRef() != null) { + writer.addAttribute(TYPE_REF, MarshallingUtils.formatQName(e.getTypeRef(), e)); + } + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExtensionElementsConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExtensionElementsConverter.java new file mode 100644 index 00000000000..1dce336d38e --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ExtensionElementsConverter.java @@ -0,0 +1,133 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.mapper.CannotResolveClassException; +import org.kie.dmn.api.marshalling.DMNExtensionRegister; +import org.kie.dmn.model.api.DMNElement.ExtensionElements; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TDMNElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class ExtensionElementsConverter extends DMNModelInstrumentedBaseConverter { + + private static final Logger LOG = LoggerFactory.getLogger(ExtensionElementsConverter.class); + + private List extensionRegisters = new ArrayList<>(); + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + // no attributes. + } + + public ExtensionElementsConverter(XStream xStream, List extensionRegisters) { + super(xStream); + if ( !extensionRegisters.isEmpty() ) { + this.extensionRegisters.addAll(extensionRegisters); + } + } + + + @Override + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + DMNModelInstrumentedBase obj = createModelObject(); + assignAttributes( reader, obj ); + if(extensionRegisters.size() == 0) { + while (reader.hasMoreChildren()) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + // skipping nodeName + reader.moveUp(); + } + } else { + // do as default behavior, but in case cannot unmarshall an extension element child, just skip it. + while (reader.hasMoreChildren()) { + reader.moveDown(); + String nodeName = reader.getNodeName(); + try { + Object object = readItem(reader, context, null); + if (object instanceof DMNModelInstrumentedBase) { + ((KieDMNModelInstrumentedBase) object).setParent(obj); + obj.addChildren((KieDMNModelInstrumentedBase) object); + } + assignChildElement(obj, nodeName, object); + } catch (CannotResolveClassException e) { + // do nothing; I tried to convert the extension element child with the converters, but no converter is registered for this child. + LOG.debug("Tried to convert the extension element child {}, but no converter is registered for this child.", nodeName); + } + reader.moveUp(); + } + } + return obj; + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + if(extensionRegisters.size() == 0) { + return; + } + + ExtensionElements ee = (ExtensionElements) parent; + if ( ee.getAny() != null ) { + for ( Object a : ee.getAny() ) { + writeItem(a, context, writer); + } + } + } + + public ExtensionElementsConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TDMNElement.TExtensionElements(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TDMNElement.TExtensionElements.class); + } + + @Override + public void assignChildElement(Object parent, String nodeName, Object child) { + ExtensionElements id = (ExtensionElements)parent; + id.getAny().add(child); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FilterConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FilterConverter.java new file mode 100644 index 00000000000..67d9e4768ac --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FilterConverter.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Filter; +import org.kie.dmn.model.v1_5.TChildExpression; +import org.kie.dmn.model.v1_5.TFilter; + +public class FilterConverter extends ExpressionConverter { + + public static final String IN = "in"; + public static final String MATCH = "match"; + + public FilterConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Filter filter = (Filter) parent; + + if (IN.equals(nodeName)) { + filter.setIn((ChildExpression) child); + } else if (MATCH.equals(nodeName)) { + filter.setMatch((ChildExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Filter filter = (Filter) parent; + writeChildrenNode(writer, context, filter.getIn(), IN); + writeChildrenNode(writer, context, filter.getMatch(), MATCH); + + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TFilter(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TFilter.class); + } + + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, IN, TChildExpression.class); + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, MATCH, TChildExpression.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ForConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ForConverter.java new file mode 100644 index 00000000000..a61895120bd --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ForConverter.java @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.For; +import org.kie.dmn.model.v1_5.TChildExpression; +import org.kie.dmn.model.v1_5.TFor; +import org.kie.dmn.model.v1_5.TTypedChildExpression; + +public class ForConverter extends IteratorConverter { + + public static final String RETURN = "return"; + + public ForConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + For i = (For) parent; + + if (RETURN.equals(nodeName) && child instanceof ChildExpression) { + i.setReturn((ChildExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + For i = (For) parent; + + writeChildrenNode(writer, context, i.getReturn(), RETURN); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TFor(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TFor.class); + } + + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, IN, TTypedChildExpression.class); + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, RETURN, TChildExpression.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FormatUtils.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FormatUtils.java new file mode 100644 index 00000000000..9941be9c7ce --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FormatUtils.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import java.util.Objects; + +public class FormatUtils { + + public static String manageDouble(Double d) { + Objects.requireNonNull(d); + long longValue = d.longValue(); + if (d == longValue) { + return String.format("%d", longValue); + } else { + return String.format("%s", d); + } + } + + private FormatUtils() { + // no constructor for utils class. + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionDefinitionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionDefinitionConverter.java new file mode 100644 index 00000000000..03eb811e186 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionDefinitionConverter.java @@ -0,0 +1,98 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.FunctionDefinition; +import org.kie.dmn.model.api.FunctionKind; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.v1_5.TFunctionDefinition; + +public class FunctionDefinitionConverter extends ExpressionConverter { + + private static final String KIND = "kind"; + public static final String EXPRESSION = "expression"; + public static final String FORMAL_PARAMETER = "formalParameter"; + + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + FunctionDefinition fd = (FunctionDefinition) parent; + + if (FORMAL_PARAMETER.equals(nodeName)) { + fd.getFormalParameter().add((InformationItem) child); + } else if (child instanceof Expression) { + fd.setExpression((Expression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + FunctionDefinition i = (FunctionDefinition) parent; + + String kind = reader.getAttribute(KIND); + if (kind != null) { + i.setKind(FunctionKind.fromValue(kind)); + } + + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + FunctionDefinition fd = (FunctionDefinition) parent; + + for (InformationItem fparam : fd.getFormalParameter()) { + writeChildrenNode(writer, context, fparam, FORMAL_PARAMETER); + } + if (fd.getExpression() != null) writeChildrenNode(writer, context, fd.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, fd.getExpression())); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + FunctionDefinition fd = (FunctionDefinition) parent; + writer.addAttribute(KIND, fd.getKind().value()); + } + + public FunctionDefinitionConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TFunctionDefinition(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TFunctionDefinition.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionItemConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionItemConverter.java new file mode 100644 index 00000000000..23ba6ee1c71 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/FunctionItemConverter.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.FunctionItem; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.v1_5.TFunctionItem; + +public class FunctionItemConverter extends DMNElementConverter { + + private static final String OUTPUT_TYPE_REF = "outputTypeRef"; + private static final String PARAMETERS = "parameters"; + + public FunctionItemConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TFunctionItem.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + FunctionItem ii = (FunctionItem) parent; + + if (PARAMETERS.equals(nodeName)) { + ii.getParameters().add((InformationItem) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + FunctionItem ii = (FunctionItem) parent; + + String typeRef = reader.getAttribute(OUTPUT_TYPE_REF); + ii.setOutputTypeRef(MarshallingUtils.parseQNameString(typeRef)); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TFunctionItem(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + FunctionItem ii = (FunctionItem) parent; + + for (InformationItem ic : ii.getParameters()) { + writeChildrenNode(writer, context, ic, PARAMETERS); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + FunctionItem ii = (FunctionItem) parent; + + if (ii.getOutputTypeRef() != null) { + writer.addAttribute(OUTPUT_TYPE_REF, MarshallingUtils.formatQName(ii.getOutputTypeRef(), ii)); + } + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/GroupConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/GroupConverter.java new file mode 100644 index 00000000000..3b67fb9afa3 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/GroupConverter.java @@ -0,0 +1,66 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Group; +import org.kie.dmn.model.v1_5.TGroup; + +public class GroupConverter extends ArtifactConverter { + + public static final String NAME = "name"; + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Group grp = (Group) parent; + + String name = reader.getAttribute(NAME); + + grp.setName(name); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Group grp = (Group) parent; + + if (grp.getName() != null) { + writer.addAttribute(NAME, grp.getName()); + } + } + + public GroupConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TGroup(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TGroup.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportConverter.java new file mode 100644 index 00000000000..ce6a37281d6 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportConverter.java @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Import; +import org.kie.dmn.model.v1_5.TImport; + +public class ImportConverter extends NamedElementConverter { + public static final String NAMESPACE = "namespace"; + public static final String LOCATION_URI = "locationURI"; + public static final String IMPORT_TYPE = "importType"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Import i = (Import) parent; + + String namespace = reader.getAttribute(NAMESPACE); + String locationUri = reader.getAttribute(LOCATION_URI); + String importType = reader.getAttribute(IMPORT_TYPE); + + i.setNamespace(namespace); + i.setLocationURI(locationUri); + i.setImportType(importType); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Import i = (Import) parent; + + if (i.getNamespace() != null) writer.addAttribute(NAMESPACE, i.getNamespace()); + if (i.getLocationURI() != null) writer.addAttribute(LOCATION_URI, i.getLocationURI()); + if (i.getImportType() != null) writer.addAttribute(IMPORT_TYPE, i.getImportType()); + } + + public ImportConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TImport(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TImport.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportedValuesConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportedValuesConverter.java new file mode 100644 index 00000000000..812504d384f --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ImportedValuesConverter.java @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.ImportedValues; +import org.kie.dmn.model.v1_5.TImportedValues; + +public class ImportedValuesConverter extends ImportConverter { + public static final String IMPORTED_ELEMENT = "importedElement"; + public static final String EXPRESSION_LANGUAGE = "expressionLanguage"; + + public ImportedValuesConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + ImportedValues iv = (ImportedValues) parent; + + if (IMPORTED_ELEMENT.equals(nodeName)) { + iv.setImportedElement((String) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + ImportedValues iv = (ImportedValues) parent; + + String expressionLanguage = reader.getAttribute(EXPRESSION_LANGUAGE); + + iv.setExpressionLanguage(expressionLanguage); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + ImportedValues iv = (ImportedValues) parent; + + writeChildrenNode(writer, context, iv.getImportedElement(), IMPORTED_ELEMENT); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + ImportedValues iv = (ImportedValues) parent; + + if (iv.getExpressionLanguage() != null) writer.addAttribute(EXPRESSION_LANGUAGE, iv.getExpressionLanguage()); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TImportedValues(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TImportedValues.class); + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationItemConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationItemConverter.java new file mode 100644 index 00000000000..590825c1b6b --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationItemConverter.java @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.v1_5.TInformationItem; + +public class InformationItemConverter + extends NamedElementConverter { + private static final String TYPE_REF = "typeRef"; + + public InformationItemConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TInformationItem.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement( parent, nodeName, child ); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + InformationItem ii = (InformationItem) parent; + + String typeRef = reader.getAttribute( TYPE_REF ); + ii.setTypeRef( MarshallingUtils.parseQNameString( typeRef ) ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TInformationItem(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + InformationItem ii = (InformationItem) parent; + + if (ii.getTypeRef() != null) { + writer.addAttribute(TYPE_REF, MarshallingUtils.formatQName(ii.getTypeRef(), ii)); + } + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationRequirementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationRequirementConverter.java new file mode 100644 index 00000000000..5c6e008927f --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InformationRequirementConverter.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.InformationRequirement; +import org.kie.dmn.model.v1_5.TInformationRequirement; + +public class InformationRequirementConverter extends DMNElementConverter { + + private static final String REQUIRED_INPUT = "requiredInput"; + private static final String REQUIRED_DECISION = "requiredDecision"; + + public InformationRequirementConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TInformationRequirement.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + InformationRequirement ir = (InformationRequirement) parent; + + if ( REQUIRED_INPUT.equals( nodeName ) ) { + ir.setRequiredInput( (DMNElementReference) child ); + } else if ( REQUIRED_DECISION.equals( nodeName ) ) { + ir.setRequiredDecision( (DMNElementReference) child ); + } else { + super.assignChildElement( parent, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TInformationRequirement(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + InformationRequirement ir = (InformationRequirement) parent; + + if ( ir.getRequiredDecision() != null ) { + writeChildrenNode(writer, context, ir.getRequiredDecision(), REQUIRED_DECISION); + } + if ( ir.getRequiredInput() != null ) { + writeChildrenNode(writer, context, ir.getRequiredInput(), REQUIRED_INPUT); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputClauseConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputClauseConverter.java new file mode 100644 index 00000000000..70c7485f24d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputClauseConverter.java @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.InputClause; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.UnaryTests; +import org.kie.dmn.model.v1_5.TInputClause; + +public class InputClauseConverter extends DMNElementConverter { + public static final String INPUT_VALUES = "inputValues"; + public static final String INPUT_EXPRESSION = "inputExpression"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + InputClause ic = (InputClause) parent; + + if (INPUT_EXPRESSION.equals(nodeName)) { + ic.setInputExpression((LiteralExpression) child); + } else if (INPUT_VALUES.equals(nodeName)) { + ic.setInputValues((UnaryTests) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + InputClause ic = (InputClause) parent; + + writeChildrenNode(writer, context, ic.getInputExpression(), INPUT_EXPRESSION); + if (ic.getInputValues() != null) writeChildrenNode(writer, context, ic.getInputValues(), INPUT_VALUES); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + } + + public InputClauseConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TInputClause(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TInputClause.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputDataConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputDataConverter.java new file mode 100644 index 00000000000..62d7da68fc5 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InputDataConverter.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.InputData; +import org.kie.dmn.model.v1_5.TInputData; + +public class InputDataConverter + extends DRGElementConverter { + + private static final String VARIABLE = "variable"; + + public InputDataConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TInputData.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + InputData id = (InputData) parent; + + if ( VARIABLE.equals( nodeName ) ) { + id.setVariable( (InformationItem) child ); + } else { + super.assignChildElement( parent, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TInputData(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + InputData id = (InputData) parent; + + if ( id.getVariable() != null ) { + writeChildrenNode(writer, context, id.getVariable(), VARIABLE); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocableConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocableConverter.java new file mode 100644 index 00000000000..c8926f4c335 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocableConverter.java @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.Invocable; + +public abstract class InvocableConverter extends DRGElementConverter { + + public static final String VARIABLE = "variable"; + + public InvocableConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Invocable bkm = (Invocable) parent; + + if (VARIABLE.equals(nodeName)) { + bkm.setVariable((InformationItem) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + Invocable bkm = (Invocable) parent; + + if (bkm.getVariable() != null) { + writeChildrenNode(writer, context, bkm.getVariable(), VARIABLE); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocationConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocationConverter.java new file mode 100644 index 00000000000..32524a67047 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/InvocationConverter.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Binding; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.Invocation; +import org.kie.dmn.model.v1_5.TInvocation; + +public class InvocationConverter extends ExpressionConverter { + public static final String BINDING = "binding"; + public static final String EXPRESSION = "expression"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Invocation i = (Invocation) parent; + + if (child instanceof Expression) { + i.setExpression((Expression) child); + } else if (BINDING.equals(nodeName)) { + i.getBinding().add((Binding) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Invocation i = (Invocation) parent; + + if (i.getExpression() != null) writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, i.getExpression())); + for (Binding b : i.getBinding()) { + writeChildrenNode(writer, context, b, BINDING); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + } + + public InvocationConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TInvocation(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TInvocation.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ItemDefinitionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ItemDefinitionConverter.java new file mode 100644 index 00000000000..5be3295fb71 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ItemDefinitionConverter.java @@ -0,0 +1,118 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.FunctionItem; +import org.kie.dmn.model.api.ItemDefinition; +import org.kie.dmn.model.api.UnaryTests; +import org.kie.dmn.model.v1_5.TItemDefinition; + +import javax.xml.namespace.QName; + +public class ItemDefinitionConverter extends NamedElementConverter { + public static final String ITEM_COMPONENT = "itemComponent"; + public static final String ALLOWED_VALUES = "allowedValues"; + public static final String TYPE_CONSTRAINT = "typeConstraint"; + public static final String TYPE_REF = "typeRef"; + public static final String TYPE_LANGUAGE = "typeLanguage"; + public static final String IS_COLLECTION = "isCollection"; + public static final String FUNCTION_ITEM = "functionItem"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + ItemDefinition id = (ItemDefinition) parent; + + if (TYPE_REF.equals(nodeName)) { + id.setTypeRef((QName) child); + } else if (ALLOWED_VALUES.equals(nodeName)) { + id.setAllowedValues((UnaryTests) child); + } else if (TYPE_CONSTRAINT.equals(nodeName)) { + id.setTypeConstraint((UnaryTests) child); + } else if (ITEM_COMPONENT.equals(nodeName)) { + id.getItemComponent().add((ItemDefinition) child); + } else if (FUNCTION_ITEM.equals(nodeName)) { + id.setFunctionItem((FunctionItem) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + ItemDefinition id = (ItemDefinition) parent; + + String typeLanguage = reader.getAttribute(TYPE_LANGUAGE); + String isCollectionValue = reader.getAttribute(IS_COLLECTION); + + id.setTypeLanguage(typeLanguage); + id.setIsCollection(Boolean.valueOf(isCollectionValue)); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + ItemDefinition id = (ItemDefinition) parent; + + if (id.getTypeRef() != null) { + writeChildrenNode(writer, context, id.getTypeRef(), TYPE_REF); + } + if (id.getAllowedValues() != null) { + writeChildrenNode(writer, context, id.getAllowedValues(), ALLOWED_VALUES); + } + if (id.getTypeConstraint() != null) { + writeChildrenNode(writer, context, id.getTypeConstraint(), TYPE_CONSTRAINT); + } + for ( ItemDefinition ic : id.getItemComponent() ) { + writeChildrenNode(writer, context, ic, ITEM_COMPONENT); + } + if (id.getFunctionItem() != null) { + writeChildrenNode(writer, context, id.getFunctionItem(), FUNCTION_ITEM); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + ItemDefinition id = (ItemDefinition) parent; + + if (id.getTypeLanguage() != null) writer.addAttribute(TYPE_LANGUAGE, id.getTypeLanguage()); + writer.addAttribute(IS_COLLECTION, Boolean.valueOf(id.isIsCollection()).toString()); + } + + public ItemDefinitionConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TItemDefinition(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TItemDefinition.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/IteratorConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/IteratorConverter.java new file mode 100644 index 00000000000..1b5cc192a1e --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/IteratorConverter.java @@ -0,0 +1,76 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.Iterator; +import org.kie.dmn.model.api.TypedChildExpression; + +public abstract class IteratorConverter extends ExpressionConverter { + + public static final String IN = "in"; + public static final String ITERATOR_VARIABLE = "iteratorVariable"; + + public IteratorConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Iterator i = (Iterator) parent; + + if (IN.equals(nodeName) && child instanceof TypedChildExpression) { + i.setIn((TypedChildExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + String iteratorVariable = reader.getAttribute( ITERATOR_VARIABLE ); + + if (iteratorVariable != null) { + ((Iterator) parent).setIteratorVariable(iteratorVariable); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Iterator e = (Iterator) parent; + + if (e.getId() != null) { + writer.addAttribute(ITERATOR_VARIABLE, e.getIteratorVariable()); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Iterator i = (Iterator) parent; + + writeChildrenNode(writer, context, i.getIn(), IN); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeRequirementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeRequirementConverter.java new file mode 100644 index 00000000000..443d92b5fae --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeRequirementConverter.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.KnowledgeRequirement; +import org.kie.dmn.model.v1_5.TKnowledgeRequirement; + +public class KnowledgeRequirementConverter extends DMNElementConverter { + public static final String REQUIRED_KNOWLEDGE = "requiredKnowledge"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + KnowledgeRequirement kr = (KnowledgeRequirement) parent; + + if (REQUIRED_KNOWLEDGE.equals(nodeName)) { + kr.setRequiredKnowledge((DMNElementReference) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + KnowledgeRequirement kr = (KnowledgeRequirement) parent; + + writeChildrenNode(writer, context, kr.getRequiredKnowledge(), REQUIRED_KNOWLEDGE); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public KnowledgeRequirementConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TKnowledgeRequirement(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TKnowledgeRequirement.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeSourceConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeSourceConverter.java new file mode 100644 index 00000000000..8a3181b89bc --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/KnowledgeSourceConverter.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.KnowledgeSource; +import org.kie.dmn.model.v1_5.TKnowledgeSource; + +public class KnowledgeSourceConverter extends DRGElementConverter { + public static final String OWNER = "owner"; + public static final String TYPE = "type"; + public static final String AUTHORITY_REQUIREMENT = "authorityRequirement"; + public static final String LOCATION_URI = "locationURI"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + KnowledgeSource ks = (KnowledgeSource) parent; + + if (AUTHORITY_REQUIREMENT.equals(nodeName)) { + ks.getAuthorityRequirement().add((AuthorityRequirement) child); + } else if (TYPE.equals(nodeName)) { + ks.setType((String) child); + } else if (OWNER.equals(nodeName)) { + ks.setOwner((DMNElementReference) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + KnowledgeSource ks = (KnowledgeSource) parent; + + String locationUri = reader.getAttribute(LOCATION_URI); + + ks.setLocationURI(locationUri); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + KnowledgeSource ks = (KnowledgeSource) parent; + + for ( AuthorityRequirement ar : ks.getAuthorityRequirement() ) { + writeChildrenNode(writer, context, ar, AUTHORITY_REQUIREMENT); + } + if (ks.getType() != null) writeChildrenNode(writer, context, ks.getType(), TYPE); + if (ks.getOwner() != null) writeChildrenNode(writer, context, ks.getOwner(), OWNER); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + KnowledgeSource ks = (KnowledgeSource) parent; + + if (ks.getLocationURI() != null) writer.addAttribute(LOCATION_URI, ks.getLocationURI()); + } + + public KnowledgeSourceConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TKnowledgeSource(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TKnowledgeSource.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/LiteralExpressionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/LiteralExpressionConverter.java new file mode 100644 index 00000000000..27078719af6 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/LiteralExpressionConverter.java @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.ImportedValues; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.v1_5.TLiteralExpression; + +public class LiteralExpressionConverter + extends ExpressionConverter { + + public static final String IMPORTED_VALUES = "importedValues"; + public static final String TEXT = "text"; + public static final String EXPR_LANGUAGE = "expressionLanguage"; + + public LiteralExpressionConverter(XStream xstream) { + super( xstream ); + } + + public boolean canConvert(Class clazz) { + return clazz.equals(TLiteralExpression.class); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + LiteralExpression le = (LiteralExpression)parent; + + if( TEXT.equals( nodeName ) ) { + le.setText( (String) child ); + } else if( IMPORTED_VALUES.equals( nodeName ) ) { + le.setImportedValues( (ImportedValues) child ); + } else { + super.assignChildElement( parent, nodeName, child ); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + LiteralExpression le = (LiteralExpression) parent; + + String exprLanguage = reader.getAttribute( EXPR_LANGUAGE ); + + le.setExpressionLanguage( exprLanguage ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TLiteralExpression(); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + LiteralExpression le = (LiteralExpression) parent; + + if ( le.getText() != null ) writeChildrenNodeAsValue(writer, context, le.getText(), TEXT); + if ( le.getImportedValues() != null ) writeChildrenNode(writer, context, le.getImportedValues(), IMPORTED_VALUES); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + LiteralExpression le = (LiteralExpression) parent; + + if ( le.getExpressionLanguage() != null ) writer.addAttribute(EXPR_LANGUAGE, le.getExpressionLanguage()); + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/MarshallingUtils.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/MarshallingUtils.java new file mode 100644 index 00000000000..47553213fbb --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/MarshallingUtils.java @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.Converter; +import org.kie.dmn.backend.marshalling.v1x.ConverterDefinesExpressionNodeName; +import org.kie.dmn.model.api.Conditional; +import org.kie.dmn.model.api.Context; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.DecisionTable; +import org.kie.dmn.model.api.Every; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.Filter; +import org.kie.dmn.model.api.For; +import org.kie.dmn.model.api.FunctionDefinition; +import org.kie.dmn.model.api.Invocation; +import org.kie.dmn.model.api.List; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.Relation; +import org.kie.dmn.model.api.Some; +import org.kie.dmn.model.api.dmndi.DMNEdge; +import org.kie.dmn.model.api.dmndi.DMNShape; + +import javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public final class MarshallingUtils { + + private final static Pattern QNAME_PAT = Pattern.compile("(\\{([^\\}]*)\\})?(([^:]*):)?(.*)"); + + public static QName parseQNameString(String qns) { + if (qns != null) { + Matcher m = QNAME_PAT.matcher(qns); + if (m.matches()) { + if (m.group(4) != null) { + return new QName(m.group(2), m.group(5), m.group(4)); + } else { + return new QName(m.group(2), m.group(5)); + } + } else { + return new QName(qns); + } + } else { + return null; + } + } + + public static String formatQName(QName qname, DMNModelInstrumentedBase parent) { + if (!XMLConstants.DEFAULT_NS_PREFIX.equals(qname.getPrefix())) { + String nsForPrefix = parent.getNamespaceURI(qname.getPrefix()); + if (parent.getURIFEEL().equals(nsForPrefix)) { + return qname.getLocalPart(); // DMN v1.2 feel comes without a prefix. + } else if (parent instanceof DMNShape || parent instanceof DMNEdge) { + return qname.getPrefix() + ":" + qname.getLocalPart(); + } else { + return qname.getPrefix() + "." + qname.getLocalPart(); // DMN v1.2 namespace typeRef lookup is done with dot. + } + } else { + return qname.toString(); + } + } + + public static String defineExpressionNodeName(XStream xstream, Expression e) { + Converter converter = xstream.getConverterLookup().lookupConverterForType(e.getClass()); + if (converter instanceof ConverterDefinesExpressionNodeName) { + ConverterDefinesExpressionNodeName defines = (ConverterDefinesExpressionNodeName) converter; + return defines.defineExpressionNodeName(e); + } else { + return defineExpressionNodeName(e); + } + } + + private static String defineExpressionNodeName(Expression e) { + String nodeName = "expression"; + if (e instanceof Context) { + nodeName = "context"; + } else if (e instanceof DecisionTable) { + nodeName = "decisionTable"; + } else if (e instanceof FunctionDefinition) { + nodeName = "functionDefinition"; + } else if (e instanceof Invocation) { + nodeName = "invocation"; + } else if (e instanceof LiteralExpression) { + nodeName = "literalExpression"; + } else if (e instanceof Relation) { + nodeName = "relation"; + } else if (e instanceof List) { + nodeName = "list"; + } else if (e instanceof For) { + nodeName = "for"; + } else if (e instanceof Every) { + nodeName = "every"; + } else if (e instanceof Some) { + nodeName = "some"; + } else if (e instanceof Conditional) { + nodeName = "conditional"; + } else if (e instanceof Filter) { + nodeName = "filter"; + } + return nodeName; + } + + private MarshallingUtils() { + // Constructing instances is not allowed for this class + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/NamedElementConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/NamedElementConverter.java new file mode 100644 index 00000000000..94618846ff8 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/NamedElementConverter.java @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.NamedElement; + +public abstract class NamedElementConverter + extends DMNElementConverter { + private static final String NAME = "name"; + + public NamedElementConverter(XStream xstream) { + super( xstream ); + } + + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement( parent, nodeName, child ); + } + + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + String name = reader.getAttribute( NAME ); + ((NamedElement) parent).setName( name ); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + + // no children. + } + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + NamedElement ne = (NamedElement) parent; + + writer.addAttribute( NAME , ne.getName() ); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OrganizationUnitConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OrganizationUnitConverter.java new file mode 100644 index 00000000000..98ea22ac4e8 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OrganizationUnitConverter.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.OrganizationUnit; +import org.kie.dmn.model.v1_5.TOrganizationUnit; + +public class OrganizationUnitConverter extends BusinessContextElementConverter { + public static final String DECISION_OWNED = "decisionOwned"; + public static final String DECISION_MADE = "decisionMade"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + OrganizationUnit ou = (OrganizationUnit) parent; + + if (DECISION_MADE.equals(nodeName)) { + ou.getDecisionMade().add((DMNElementReference) child); + } else if (DECISION_OWNED.equals(nodeName)) { + ou.getDecisionOwned().add((DMNElementReference) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + OrganizationUnit ou = (OrganizationUnit) parent; + + for (DMNElementReference dm : ou.getDecisionMade()) { + writeChildrenNode(writer, context, dm, DECISION_MADE); + } + for (DMNElementReference downed : ou.getDecisionOwned()) { + writeChildrenNode(writer, context, downed, DECISION_OWNED); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public OrganizationUnitConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TOrganizationUnit(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TOrganizationUnit.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OutputClauseConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OutputClauseConverter.java new file mode 100644 index 00000000000..b7c02538c3d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/OutputClauseConverter.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.OutputClause; +import org.kie.dmn.model.api.UnaryTests; +import org.kie.dmn.model.v1_5.TOutputClause; + +public class OutputClauseConverter extends DMNElementConverter { + public static final String DEFAULT_OUTPUT_ENTRY = "defaultOutputEntry"; + public static final String OUTPUT_VALUES = "outputValues"; + public static final String NAME = "name"; + public static final String TYPE_REF ="typeRef"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + OutputClause oc = (OutputClause) parent; + + if (OUTPUT_VALUES.equals(nodeName)) { + oc.setOutputValues((UnaryTests) child); + } else if (DEFAULT_OUTPUT_ENTRY.equals(nodeName)) { + oc.setDefaultOutputEntry((LiteralExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + OutputClause oc = (OutputClause) parent; + + String name = reader.getAttribute(NAME); + String typeRefValue = reader.getAttribute(TYPE_REF); + + oc.setName(name); + if (typeRefValue != null) oc.setTypeRef(MarshallingUtils.parseQNameString(typeRefValue)); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + OutputClause oc = (OutputClause) parent; + + if (oc.getOutputValues() != null) writeChildrenNode(writer, context, oc.getOutputValues(), OUTPUT_VALUES); + if (oc.getDefaultOutputEntry() != null) writeChildrenNode(writer, context, oc.getDefaultOutputEntry(), DEFAULT_OUTPUT_ENTRY); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + OutputClause oc = (OutputClause) parent; + + if (oc.getName() != null) writer.addAttribute(NAME, oc.getName()); + if (oc.getTypeRef() != null) { + writer.addAttribute(TYPE_REF, MarshallingUtils.formatQName(oc.getTypeRef(), oc)); + } + } + + public OutputClauseConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TOutputClause(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TOutputClause.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PerformanceIndicatorConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PerformanceIndicatorConverter.java new file mode 100644 index 00000000000..8bb3a7d6bd5 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PerformanceIndicatorConverter.java @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.PerformanceIndicator; +import org.kie.dmn.model.v1_5.TPerformanceIndicator; + +public class PerformanceIndicatorConverter extends BusinessContextElementConverter { + public static final String IMPACTING_DECISION = "impactingDecision"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + PerformanceIndicator pi = (PerformanceIndicator) parent; + + if (IMPACTING_DECISION.equals(nodeName)) { + pi.getImpactingDecision().add((DMNElementReference) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + PerformanceIndicator pi = (PerformanceIndicator) parent; + + for ( DMNElementReference id : pi.getImpactingDecision() ) { + writeChildrenNode(writer, context, id, IMPACTING_DECISION); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public PerformanceIndicatorConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TPerformanceIndicator(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TPerformanceIndicator.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PointConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PointConverter.java new file mode 100644 index 00000000000..fc63d0f99e2 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/PointConverter.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.dmndi.Point; + +public class PointConverter extends DMNModelInstrumentedBaseConverter { + + + private static final String Y = "y"; + private static final String X = "x"; + + public PointConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Point abs = (Point) parent; + + abs.setX(Double.valueOf(reader.getAttribute(X))); + abs.setY(Double.valueOf(reader.getAttribute(Y))); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + Point abs = (Point) parent; + + writer.addAttribute(X, org.kie.dmn.backend.marshalling.v1_5.xstream.FormatUtils.manageDouble(abs.getX())); + writer.addAttribute(Y, FormatUtils.manageDouble(abs.getY())); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new org.kie.dmn.model.v1_5.dmndi.Point(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(org.kie.dmn.model.v1_5.dmndi.Point.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QNameConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QNameConverter.java new file mode 100644 index 00000000000..b3ee81f480d --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QNameConverter.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; + +import javax.xml.namespace.QName; + +/** + * Please note this does not extend the DMNBaseConverter as it just need access to the node value itself. + */ +public class QNameConverter implements Converter { + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals( QName.class ); + } + + @Override + public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) { + // DMN v1.2 semantic always local part. + QName qname = (QName) object; + writer.setValue(qname.getLocalPart()); + } + + @Override + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + // DMN v1.2 semantic always local part. + QName qname = new QName(reader.getValue()); + return qname; + } + +} \ No newline at end of file diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QuantifiedConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QuantifiedConverter.java new file mode 100644 index 00000000000..72add840996 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/QuantifiedConverter.java @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Quantified; +import org.kie.dmn.model.v1_5.TChildExpression; +import org.kie.dmn.model.v1_5.TTypedChildExpression; + +public abstract class QuantifiedConverter extends IteratorConverter { + + public static final String SATISFIES = "satisfies"; + + public QuantifiedConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Quantified i = (Quantified) parent; + + if (SATISFIES.equals(nodeName) && child instanceof ChildExpression) { + i.setSatisfies((ChildExpression) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Quantified i = (Quantified) parent; + + writeChildrenNode(writer, context, i.getSatisfies(), SATISFIES); + } + + protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) { + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, IN, TTypedChildExpression.class); + mvDownConvertAnotherMvUpAssignChildElement(reader, context, parent, SATISFIES, TChildExpression.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RelationConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RelationConverter.java new file mode 100644 index 00000000000..fb70dd07aab --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RelationConverter.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.Relation; +import org.kie.dmn.model.v1_5.TRelation; + +public class RelationConverter extends ExpressionConverter { + public static final String EXPRESSION = "expression"; + public static final String ROW = "row"; + public static final String COLUMN = "column"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Relation r = (Relation) parent; + + if (COLUMN.equals(nodeName)) { + r.getColumn().add((InformationItem) child); + } else if (ROW.equals(nodeName)) { + r.getRow().add((org.kie.dmn.model.api.List) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Relation r = (Relation) parent; + + for (InformationItem c : r.getColumn()) { + writeChildrenNode(writer, context, c, COLUMN); + } + for (org.kie.dmn.model.api.List row : r.getRow()) { + writeChildrenNode(writer, context, row, ROW); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + public RelationConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TRelation(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TRelation.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationClauseConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationClauseConverter.java new file mode 100644 index 00000000000..5be1dcf9676 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationClauseConverter.java @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.RuleAnnotationClause; +import org.kie.dmn.model.v1_5.TRuleAnnotationClause; + +public class RuleAnnotationClauseConverter extends DMNModelInstrumentedBaseConverter { + + public static final String NAME = "name"; + + public RuleAnnotationClauseConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + + ((RuleAnnotationClause) parent).setName(reader.getAttribute(NAME)); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + RuleAnnotationClause e = (RuleAnnotationClause) parent; + + if (e.getName() != null) { + writer.addAttribute(NAME, e.getName()); + } + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TRuleAnnotationClause(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TRuleAnnotationClause.class); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationConverter.java new file mode 100644 index 00000000000..c5574a8896a --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/RuleAnnotationConverter.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.RuleAnnotation; +import org.kie.dmn.model.v1_5.TRuleAnnotation; + +public class RuleAnnotationConverter extends DMNModelInstrumentedBaseConverter { + + public static final String TEXT = "text"; + + public RuleAnnotationConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + super.assignChildElement(parent, nodeName, child); + RuleAnnotation e = (RuleAnnotation) parent; + + if (TEXT.equals(nodeName)) { + e.setText((String) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + RuleAnnotation r = (RuleAnnotation) parent; + + writeChildrenNode(writer, context, r.getText(), TEXT); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TRuleAnnotation(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TRuleAnnotation.class); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ShapeConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ShapeConverter.java new file mode 100644 index 00000000000..141e8faf404 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/ShapeConverter.java @@ -0,0 +1,72 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.dmndi.Bounds; +import org.kie.dmn.model.api.dmndi.Shape; + +public abstract class ShapeConverter extends DiagramElementConverter { + + private static final String BOUNDS = "Bounds"; + + public ShapeConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Shape abs = (Shape) parent; + + if (child instanceof Bounds) { + abs.setBounds((Bounds) child); + } else { + super.assignChildElement(abs, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + + // no attributes. + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Shape abs = (Shape) parent; + + if (abs.getBounds() != null) { + writeChildrenNode(writer, context, abs.getBounds(), BOUNDS); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + + // no attributes. + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/SomeConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/SomeConverter.java new file mode 100644 index 00000000000..22d5ebffc6a --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/SomeConverter.java @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TSome; + +public class SomeConverter extends QuantifiedConverter { + + public SomeConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TSome(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TSome.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/StyleConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/StyleConverter.java new file mode 100644 index 00000000000..df995a9f255 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/StyleConverter.java @@ -0,0 +1,82 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.backend.marshalling.v1_5.xstream.DMNModelInstrumentedBaseConverter; +import org.kie.dmn.model.api.dmndi.Style; +import org.kie.dmn.model.api.dmndi.Style.Extension; + +public abstract class StyleConverter extends DMNModelInstrumentedBaseConverter { + + private static final String EXTENSION = "extension"; + private static final String ID = "id"; + + public StyleConverter(XStream xstream) { + super(xstream); + } + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + Style style = (Style) parent; + + if (child instanceof Extension) { + style.setExtension((Extension) child); + } else { + super.assignChildElement(style, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + Style style = (Style) parent; + String id = reader.getAttribute(ID); + if (id != null) { + style.setId(id); + } + + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + Style style = (Style) parent; + + if (style.getExtension() != null) { + writeChildrenNode(writer, context, style.getExtension(), EXTENSION); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + Style style = (Style) parent; + + if (style.getId() != null) { + writer.addAttribute(ID, style.getId()); + } + + } + + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TextAnnotationConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TextAnnotationConverter.java new file mode 100644 index 00000000000..2002a5de890 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TextAnnotationConverter.java @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.TextAnnotation; +import org.kie.dmn.model.v1_5.TTextAnnotation; + +public class TextAnnotationConverter extends ArtifactConverter { + public static final String TEXT = "text"; + public static final String TEXT_FORMAT = "textFormat"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + TextAnnotation ta = (TextAnnotation) parent; + + if (TEXT.equals(nodeName)) { + ta.setText((String) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + TextAnnotation ta = (TextAnnotation) parent; + + String textFormat = reader.getAttribute(TEXT_FORMAT); + + ta.setTextFormat(textFormat); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + TextAnnotation ta = (TextAnnotation) parent; + + if (ta.getText() != null) writeChildrenNode(writer, context, ta.getText(), TEXT); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + TextAnnotation ta = (TextAnnotation) parent; + + if (ta.getTextFormat() != null) writer.addAttribute(TEXT_FORMAT, ta.getTextFormat()); + } + + public TextAnnotationConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TTextAnnotation(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TTextAnnotation.class); + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TypedChildExpressionConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TypedChildExpressionConverter.java new file mode 100644 index 00000000000..590fefee26f --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/TypedChildExpressionConverter.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.TypedChildExpression; +import org.kie.dmn.model.v1_5.TTypedChildExpression; + +public class TypedChildExpressionConverter extends ChildExpressionConverter { + + public static final String TYPE_REF = "typeRef"; + + public TypedChildExpressionConverter(XStream xstream) { + super( xstream ); + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes( reader, parent ); + String typeRef = reader.getAttribute( TYPE_REF ); + + if (typeRef != null) { + ((TypedChildExpression) parent).setTypeRef(typeRef); + } + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + TypedChildExpression e = (TypedChildExpression) parent; + + if (e.getTypeRef() != null) { + writer.addAttribute(TYPE_REF, e.getTypeRef()); + } + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TTypedChildExpression(); + } + + @Override + public boolean canConvert(Class type) { + return type.equals(TTypedChildExpression.class); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/UnaryTestsConverter.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/UnaryTestsConverter.java new file mode 100644 index 00000000000..ea826d1ce75 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/UnaryTestsConverter.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.UnaryTests; +import org.kie.dmn.model.v1_5.TUnaryTests; + +public class UnaryTestsConverter extends ExpressionConverter { + public static final String TEXT = "text"; + public static final String EXPRESSION_LANGUAGE = "expressionLanguage"; + + @Override + protected void assignChildElement(Object parent, String nodeName, Object child) { + UnaryTests ut = (UnaryTests) parent; + + if (TEXT.equals(nodeName)) { + ut.setText((String) child); + } else { + super.assignChildElement(parent, nodeName, child); + } + } + + @Override + protected void assignAttributes(HierarchicalStreamReader reader, Object parent) { + super.assignAttributes(reader, parent); + UnaryTests ut = (UnaryTests) parent; + + String expressionLanguage = reader.getAttribute(EXPRESSION_LANGUAGE); + + ut.setExpressionLanguage(expressionLanguage); + } + + @Override + protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) { + super.writeChildren(writer, context, parent); + UnaryTests ut = (UnaryTests) parent; + + writeChildrenNode(writer, context, ut.getText(), TEXT); + } + + @Override + protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) { + super.writeAttributes(writer, parent); + UnaryTests ut = (UnaryTests) parent; + + if (ut.getExpressionLanguage() != null) writer.addAttribute(EXPRESSION_LANGUAGE, ut.getExpressionLanguage()); + } + + public UnaryTestsConverter(XStream xstream) { + super(xstream); + } + + @Override + protected DMNModelInstrumentedBase createModelObject() { + return new TUnaryTests(); + } + + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(TUnaryTests.class); + } +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/XStreamMarshaller.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/XStreamMarshaller.java new file mode 100644 index 00000000000..4f8905b99b2 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_5/xstream/XStreamMarshaller.java @@ -0,0 +1,403 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5.xstream; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.AbstractPullReader; +import com.thoughtworks.xstream.io.xml.QNameMap; +import com.thoughtworks.xstream.io.xml.StaxDriver; +import com.thoughtworks.xstream.io.xml.StaxWriter; +import com.thoughtworks.xstream.security.TypeHierarchyPermission; +import org.kie.dmn.api.marshalling.DMNExtensionRegister; +import org.kie.dmn.api.marshalling.DMNMarshaller; +import org.kie.dmn.backend.marshalling.CustomStaxReader; +import org.kie.dmn.backend.marshalling.CustomStaxWriter; +import org.kie.dmn.backend.marshalling.v1x.DMNXStream; +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.Definitions; +import org.kie.dmn.model.v1_5.dmndi.Bounds; +import org.kie.dmn.model.v1_5.dmndi.Color; +import org.kie.dmn.model.v1_5.dmndi.DMNDI; +import org.kie.dmn.model.v1_5.dmndi.DMNDecisionServiceDividerLine; +import org.kie.dmn.model.v1_5.dmndi.DMNDiagram; +import org.kie.dmn.model.v1_5.dmndi.DMNEdge; +import org.kie.dmn.model.v1_5.dmndi.DMNLabel; +import org.kie.dmn.model.v1_5.dmndi.DMNShape; +import org.kie.dmn.model.v1_5.dmndi.DMNStyle; +import org.kie.dmn.model.v1_5.dmndi.DiagramElement; +import org.kie.dmn.model.v1_5.dmndi.Dimension; +import org.kie.dmn.model.v1_5.dmndi.Point; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.TArtifact; +import org.kie.dmn.model.v1_5.TAssociation; +import org.kie.dmn.model.v1_5.TAuthorityRequirement; +import org.kie.dmn.model.v1_5.TBinding; +import org.kie.dmn.model.v1_5.TBusinessContextElement; +import org.kie.dmn.model.v1_5.TBusinessKnowledgeModel; +import org.kie.dmn.model.v1_5.TConditional; +import org.kie.dmn.model.v1_5.TContext; +import org.kie.dmn.model.v1_5.TContextEntry; +import org.kie.dmn.model.v1_5.TDMNElement; +import org.kie.dmn.model.v1_5.TDMNElementReference; +import org.kie.dmn.model.v1_5.TDecision; +import org.kie.dmn.model.v1_5.TDecisionRule; +import org.kie.dmn.model.v1_5.TDecisionService; +import org.kie.dmn.model.v1_5.TDecisionTable; +import org.kie.dmn.model.v1_5.TDefinitions; +import org.kie.dmn.model.v1_5.TElementCollection; +import org.kie.dmn.model.v1_5.TEvery; +import org.kie.dmn.model.v1_5.TExpression; +import org.kie.dmn.model.v1_5.TFilter; +import org.kie.dmn.model.v1_5.TFor; +import org.kie.dmn.model.v1_5.TFunctionDefinition; +import org.kie.dmn.model.v1_5.TFunctionItem; +import org.kie.dmn.model.v1_5.TGroup; +import org.kie.dmn.model.v1_5.TImport; +import org.kie.dmn.model.v1_5.TImportedValues; +import org.kie.dmn.model.v1_5.TInformationItem; +import org.kie.dmn.model.v1_5.TInformationRequirement; +import org.kie.dmn.model.v1_5.TInputClause; +import org.kie.dmn.model.v1_5.TInputData; +import org.kie.dmn.model.v1_5.TInvocation; +import org.kie.dmn.model.v1_5.TItemDefinition; +import org.kie.dmn.model.v1_5.TKnowledgeRequirement; +import org.kie.dmn.model.v1_5.TKnowledgeSource; +import org.kie.dmn.model.v1_5.TLiteralExpression; +import org.kie.dmn.model.v1_5.TNamedElement; +import org.kie.dmn.model.v1_5.TOrganizationUnit; +import org.kie.dmn.model.v1_5.TOutputClause; +import org.kie.dmn.model.v1_5.TPerformanceIndicator; +import org.kie.dmn.model.v1_5.TRelation; +import org.kie.dmn.model.v1_5.TRuleAnnotation; +import org.kie.dmn.model.v1_5.TRuleAnnotationClause; +import org.kie.dmn.model.v1_5.TSome; +import org.kie.dmn.model.v1_5.TTextAnnotation; +import org.kie.dmn.model.v1_5.TUnaryTests; +import org.kie.utll.xml.XStreamUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class XStreamMarshaller + implements DMNMarshaller { + + private static Logger logger = LoggerFactory.getLogger( XStreamMarshaller.class ); + private List extensionRegisters = new ArrayList<>(); + + + private static StaxDriver staxDriver; + static { + staxDriver = new StaxDriver() { + public AbstractPullReader createStaxReader(XMLStreamReader in) { + return new CustomStaxReader(getQnameMap(), in); + } + + public StaxWriter createStaxWriter(XMLStreamWriter out, boolean writeStartEndDocument) throws XMLStreamException { + return new CustomStaxWriter(newQNameMap(), out, writeStartEndDocument, isRepairingNamespace(), getNameCoder()); + } + + public QNameMap newQNameMap() { + QNameMap qmap = new QNameMap(); + configureQNameMap( qmap ); + return qmap; + } + }; + QNameMap qmap = new QNameMap(); + configureQNameMap( qmap ); + staxDriver.setQnameMap(qmap); + staxDriver.setRepairingNamespace(false); + } + + public static void configureQNameMap( QNameMap qmap ) { + qmap.setDefaultNamespace(KieDMNModelInstrumentedBase.URI_DMN); + } + + public XStreamMarshaller() { + + } + + public XStreamMarshaller (List extensionRegisters) { + this.extensionRegisters.addAll(extensionRegisters); + } + + + @Override + public Definitions unmarshal(String xml) { + return unmarshal( new StringReader( xml ) ); + } + + @Override + public Definitions unmarshal(Reader isr) { + try { + XStream xStream = newXStream(); + + Definitions def = (Definitions) xStream.fromXML( isr ); + + return def; + } catch ( Exception e ) { + logger.error( "Error unmarshalling DMN model from reader.", e ); + } + return null; + } + + @Override + public String marshal(Object o) { + try ( Writer writer = new StringWriter(); + CustomStaxWriter hsWriter = (CustomStaxWriter) staxDriver.createWriter(writer); ) { + XStream xStream = newXStream(); + if ( o instanceof DMNModelInstrumentedBase ) { + KieDMNModelInstrumentedBase base = (KieDMNModelInstrumentedBase) o; + String dmnPrefix = base.getNsContext().entrySet().stream().filter(kv -> KieDMNModelInstrumentedBase.URI_DMN.equals(kv.getValue())).findFirst().map(Map.Entry::getKey).orElse(""); + hsWriter.getQNameMap().setDefaultPrefix( dmnPrefix ); + } + extensionRegisters.forEach( r -> r.beforeMarshal(o, hsWriter.getQNameMap()) ); + xStream.marshal(o, hsWriter); + hsWriter.flush(); + return writer.toString(); + } catch ( Exception e ) { + logger.error( "Error marshalling DMN model to XML.", e ); + } + return null; + } + + @Override + public void marshal(Object o, Writer out) { + try { + out.write( marshal( o ) ); + } catch ( Exception e ) { + logger.error( "Error marshalling DMN model to XML.", e ); + } + } + + private XStream newXStream() { + XStream xStream = XStreamUtils.createNonTrustingXStream(staxDriver, Definitions.class.getClassLoader(), DMNXStream::from); + xStream.addPermission(new TypeHierarchyPermission(QName.class)); + xStream.addPermission(new TypeHierarchyPermission(KieDMNModelInstrumentedBase.class)); + xStream.addPermission(new TypeHierarchyPermission(org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.class)); + + xStream.alias("artifact", TArtifact.class); + xStream.alias("definitions", TDefinitions.class); + xStream.alias("inputData", TInputData.class); + xStream.alias("decision", TDecision.class); + xStream.alias("variable", TInformationItem.class); + xStream.alias("informationRequirement", TInformationRequirement.class); + xStream.alias("requiredInput", TDMNElementReference.class); + xStream.alias("literalExpression", TLiteralExpression.class); + + xStream.alias("DMNElement", TDMNElement.class); + xStream.alias("allowedValues", TUnaryTests.class); + xStream.alias("artifact", TArtifact.class); + xStream.alias("association", TAssociation.class); + xStream.alias("authorityRequirement", TAuthorityRequirement.class); + xStream.alias("binding", TBinding.class); + xStream.alias("businessContextElement", TBusinessContextElement.class); + xStream.alias("businessKnowledgeModel", TBusinessKnowledgeModel.class); + xStream.alias("column", TInformationItem.class); + xStream.alias("context", TContext.class); + xStream.alias("contextEntry", TContextEntry.class); + xStream.alias("decision", TDecision.class); + xStream.alias("decisionMade", TDMNElementReference.class); + xStream.alias("decisionMaker", TDMNElementReference.class); + xStream.alias("decisionOwned", TDMNElementReference.class); + xStream.alias("decisionOwner", TDMNElementReference.class); + xStream.alias("decisionService", TDecisionService.class); + xStream.alias("decisionTable", TDecisionTable.class); + xStream.alias("defaultOutputEntry", TLiteralExpression.class); + xStream.alias("definitions", TDefinitions.class); + xStream.alias("drgElement", TDMNElementReference.class); + xStream.alias("elementCollection", TElementCollection.class); + xStream.alias("encapsulatedDecision", TDMNElementReference.class); + xStream.alias("encapsulatedLogic", TFunctionDefinition.class); + xStream.alias("expression", TExpression.class); + xStream.alias("formalParameter", TInformationItem.class); + xStream.alias("functionItem", TFunctionItem.class); + xStream.alias("functionDefinition", TFunctionDefinition.class); + xStream.alias("group", TGroup.class); + xStream.alias("impactedPerformanceIndicator", TDMNElementReference.class); + xStream.alias("impactingDecision", TDMNElementReference.class); + xStream.alias("import", TImport.class); + xStream.alias("import", TImport.class); + xStream.alias("importedElement", String.class ); // TODO where? + xStream.alias("importedValues", TImportedValues.class); + xStream.alias("informationItem", TInformationItem.class); + xStream.alias("informationRequirement", TInformationRequirement.class); + xStream.alias("input", TInputClause.class); + xStream.alias("inputData", TInputData.class); + xStream.alias("inputDecision", TDMNElementReference.class); + xStream.alias("inputEntry", TUnaryTests.class); + xStream.alias("inputExpression", TLiteralExpression.class); + xStream.alias("inputValues", TUnaryTests.class); + xStream.alias("invocation", TInvocation.class); + xStream.alias("itemComponent", TItemDefinition.class); + xStream.alias("itemDefinition", TItemDefinition.class); + xStream.alias("knowledgeRequirement", TKnowledgeRequirement.class); + xStream.alias("knowledgeSource", TKnowledgeSource.class); + xStream.alias("literalExpression", TLiteralExpression.class); + xStream.alias("namedElement", TNamedElement.class); + xStream.alias("organizationUnit", TOrganizationUnit.class); + xStream.alias("output", TOutputClause.class); + xStream.alias("outputDecision", TDMNElementReference.class); + xStream.alias("outputEntry", TLiteralExpression.class); + xStream.alias("outputValues", TUnaryTests.class); + xStream.alias("owner", TDMNElementReference.class); + xStream.alias("parameter", TInformationItem.class); + xStream.alias("parameters", TInformationItem.class); + xStream.alias("performanceIndicator", TPerformanceIndicator.class); + xStream.alias("relation", TRelation.class); + xStream.alias("requiredAuthority", TDMNElementReference.class); + xStream.alias("requiredDecision", TDMNElementReference.class); + xStream.alias("requiredInput", TDMNElementReference.class); + xStream.alias("requiredKnowledge", TDMNElementReference.class); + xStream.alias("rule", TDecisionRule.class); + xStream.alias("sourceRef", TDMNElementReference.class); + xStream.alias("supportedObjective", TDMNElementReference.class); + xStream.alias("targetRef", TDMNElementReference.class); + xStream.alias("textAnnotation", TTextAnnotation.class); + xStream.alias("type", String.class ); + xStream.alias("typeConstraint", TUnaryTests.class); + xStream.alias("typeRef", QName.class ); + xStream.alias("usingProcess", TDMNElementReference.class); + xStream.alias("usingTask", TDMNElementReference.class); + xStream.alias("useAlternativeInputDataShape", Boolean.class); + xStream.alias("variable", TInformationItem.class); + xStream.alias("row", org.kie.dmn.model.v1_5.TList.class); + xStream.alias("list", org.kie.dmn.model.v1_5.TList.class); + xStream.alias("extensionElements", TDMNElement.TExtensionElements.class); + + // Manually imported TEXT = String + xStream.alias( LiteralExpressionConverter.TEXT, String.class ); + // unnecessary 'text' key repetition: xStream.alias( TextAnnotationConverter.TEXT, String.class ); + // unnecessary 'text' key repetition: xStream.alias( UnaryTestsConverter.TEXT, String.class ); + xStream.alias( DecisionConverter.QUESTION, String.class ); + xStream.alias( DecisionConverter.ALLOWED_ANSWERS, String.class ); + xStream.alias( DMNElementConverter.DESCRIPTION, String.class ); + // unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class ); + // unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class ); + // unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class ); + // xStream.alias("question", xsd:string.class ); + // xStream.alias("allowedAnswers", xsd:string.class ); + // xStream.alias("description", xsd:string.class ); + + // DMN v1.2: + // Note, to comply with NS for XStream need also to adjust entries inside DMNModelInstrumentedBaseConverter + xStream.alias("annotation", TRuleAnnotationClause.class); + xStream.alias("annotationEntry", TRuleAnnotation.class); + xStream.registerConverter(new RuleAnnotationClauseConverter(xStream)); + xStream.registerConverter(new RuleAnnotationConverter(xStream)); + xStream.alias("DMNDI", DMNDI.class); + xStream.registerConverter(new DMNDIConverter(xStream)); + xStream.alias("DMNDiagram", DMNDiagram.class); + xStream.registerConverter(new DMNDiagramConverter(xStream)); + xStream.alias("DMNStyle", DMNStyle.class); + xStream.registerConverter(new DMNStyleConverter(xStream)); + xStream.alias("Size", Dimension.class); + xStream.registerConverter(new DimensionConverter(xStream)); + xStream.alias("DMNShape", DMNShape.class); + xStream.registerConverter(new DMNShapeConverter(xStream)); + xStream.alias("FillColor", Color.class); + xStream.alias("StrokeColor", Color.class); + xStream.alias("FontColor", Color.class); + xStream.registerConverter(new ColorConverter(xStream)); + xStream.alias("Bounds", Bounds.class); + xStream.registerConverter(new BoundsConverter(xStream)); + xStream.alias("DMNLabel", DMNLabel.class); + xStream.registerConverter(new DMNLabelConverter(xStream)); + xStream.alias("DMNEdge", DMNEdge.class); + xStream.registerConverter(new DMNEdgeConverter(xStream)); + xStream.alias("DMNDecisionServiceDividerLine", DMNDecisionServiceDividerLine.class); + xStream.registerConverter(new DMNDecisionServiceDividerLineConverter(xStream)); + xStream.alias("waypoint", Point.class); + xStream.registerConverter(new PointConverter(xStream)); + xStream.alias("extension", DiagramElement.Extension.class); + xStream.alias(DMNLabelConverter.TEXT, String.class); + + xStream.alias("for", TFor.class); + xStream.alias("every", TEvery.class); + xStream.alias("some", TSome.class); + xStream.alias("conditional", TConditional.class); + xStream.alias("filter", TFilter.class); + + xStream.registerConverter(new AssociationConverter( xStream ) ); + xStream.registerConverter(new AuthorityRequirementConverter( xStream ) ); + xStream.registerConverter(new BindingConverter( xStream ) ); + xStream.registerConverter(new BusinessKnowledgeModelConverter( xStream ) ); + xStream.registerConverter(new ContextConverter( xStream ) ); + xStream.registerConverter(new ContextEntryConverter( xStream ) ); + xStream.registerConverter(new DecisionConverter( xStream ) ); + xStream.registerConverter(new DecisionRuleConverter( xStream ) ); + xStream.registerConverter(new DecisionServiceConverter(xStream)); + xStream.registerConverter(new DecisionTableConverter( xStream ) ); + xStream.registerConverter(new DefinitionsConverter( xStream ) ); + xStream.registerConverter(new DMNElementReferenceConverter( xStream ) ); + xStream.registerConverter(new GroupConverter( xStream ) ); + xStream.registerConverter(new FunctionDefinitionConverter( xStream ) ); + xStream.registerConverter(new ImportConverter( xStream ) ); + xStream.registerConverter(new ImportedValuesConverter( xStream ) ); + xStream.registerConverter(new InformationItemConverter( xStream ) ); + xStream.registerConverter(new InformationRequirementConverter( xStream ) ); + xStream.registerConverter(new InputClauseConverter( xStream ) ); + xStream.registerConverter(new InputDataConverter( xStream ) ); + xStream.registerConverter(new InvocationConverter( xStream ) ); + xStream.registerConverter(new ItemDefinitionConverter( xStream ) ); + xStream.registerConverter(new KnowledgeRequirementConverter( xStream ) ); + xStream.registerConverter(new KnowledgeSourceConverter( xStream ) ); + xStream.registerConverter(new LiteralExpressionConverter( xStream ) ); + xStream.registerConverter(new OrganizationUnitConverter( xStream ) ); + xStream.registerConverter(new OutputClauseConverter( xStream ) ); + xStream.registerConverter(new PerformanceIndicatorConverter( xStream ) ); + xStream.registerConverter(new RelationConverter( xStream ) ); + xStream.registerConverter(new TextAnnotationConverter( xStream ) ); + xStream.registerConverter(new UnaryTestsConverter( xStream ) ); + xStream.registerConverter(new FunctionItemConverter( xStream ) ); + + xStream.registerConverter(new ChildExpressionConverter( xStream ) ); + xStream.registerConverter(new TypedChildExpressionConverter( xStream ) ); + xStream.registerConverter(new ForConverter( xStream ) ); + xStream.registerConverter(new EveryConverter( xStream ) ); + xStream.registerConverter(new SomeConverter( xStream ) ); + xStream.registerConverter(new ConditionalConverter( xStream ) ); + xStream.registerConverter(new FilterConverter( xStream ) ); + + xStream.registerConverter(new QNameConverter()); + xStream.registerConverter(new DMNListConverter( xStream ) ); + xStream.registerConverter(new ElementCollectionConverter( xStream ) ); + xStream.registerConverter(new ExtensionElementsConverter( xStream, extensionRegisters ) ); + xStream.registerConverter(new DiagramElementExtensionConverter(xStream, extensionRegisters)); + + + for(DMNExtensionRegister extensionRegister : extensionRegisters) { + extensionRegister.registerExtensionConverters(xStream); + } + + xStream.ignoreUnknownElements(); + return xStream; + } + +} diff --git a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1x/XStreamMarshaller.java b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1x/XStreamMarshaller.java index 5e7f65c8527..469a6a36ad8 100644 --- a/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1x/XStreamMarshaller.java +++ b/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1x/XStreamMarshaller.java @@ -34,6 +34,7 @@ import org.kie.dmn.api.marshalling.DMNMarshaller; import org.kie.dmn.backend.marshalling.CustomStaxReader; import org.kie.dmn.model.api.Definitions; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +46,7 @@ public class XStreamMarshaller implements DMNMarshaller { private final org.kie.dmn.backend.marshalling.v1_2.xstream.XStreamMarshaller xstream12; private final org.kie.dmn.backend.marshalling.v1_3.xstream.XStreamMarshaller xstream13; private final org.kie.dmn.backend.marshalling.v1_4.xstream.XStreamMarshaller xstream14; + private final org.kie.dmn.backend.marshalling.v1_5.xstream.XStreamMarshaller xstream15; private static final StaxDriver staxDriver = new StaxDriver(); public XStreamMarshaller() { @@ -52,6 +54,7 @@ public XStreamMarshaller() { xstream12 = new org.kie.dmn.backend.marshalling.v1_2.xstream.XStreamMarshaller(); xstream13 = new org.kie.dmn.backend.marshalling.v1_3.xstream.XStreamMarshaller(); xstream14 = new org.kie.dmn.backend.marshalling.v1_4.xstream.XStreamMarshaller(); + xstream15 = new org.kie.dmn.backend.marshalling.v1_5.xstream.XStreamMarshaller(); } public XStreamMarshaller (List extensionRegisters) { @@ -60,6 +63,7 @@ public XStreamMarshaller (List extensionRegisters) { xstream12 = new org.kie.dmn.backend.marshalling.v1_2.xstream.XStreamMarshaller(extensionRegisters); xstream13 = new org.kie.dmn.backend.marshalling.v1_3.xstream.XStreamMarshaller(extensionRegisters); xstream14 = new org.kie.dmn.backend.marshalling.v1_4.xstream.XStreamMarshaller(extensionRegisters); + xstream15 = new org.kie.dmn.backend.marshalling.v1_5.xstream.XStreamMarshaller(extensionRegisters); } @Override @@ -79,11 +83,14 @@ public Definitions unmarshal(String xml) { case DMN_v1_3: result = xstream13.unmarshal(secondStringReader); break; - case UNKNOWN: case DMN_v1_4: - default: result = xstream14.unmarshal(secondStringReader); break; + case UNKNOWN: + case DMN_v1_5: + default: + result = xstream15.unmarshal(secondStringReader); + break; } return result; @@ -94,7 +101,7 @@ public Definitions unmarshal(String xml) { } public enum DMN_VERSION { - UNKNOWN, DMN_v1_1, DMN_v1_2, DMN_v1_3, DMN_v1_4; + UNKNOWN, DMN_v1_1, DMN_v1_2, DMN_v1_3, DMN_v1_4, DMN_v1_5; } public static DMN_VERSION inferDMNVersion(Reader from) { @@ -102,13 +109,15 @@ public static DMN_VERSION inferDMNVersion(Reader from) { XMLStreamReader xmlReader = staxDriver.getInputFactory().createXMLStreamReader(from); CustomStaxReader customStaxReader = new CustomStaxReader(new QNameMap(), xmlReader); DMN_VERSION result = DMN_VERSION.UNKNOWN; - if (customStaxReader.getNsContext().values().stream().anyMatch(s -> org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_DMN.equals(s))) { + if (customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_DMN::equals)) { + result = DMN_VERSION.DMN_v1_5; + } else if (customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_DMN::equals)) { result = DMN_VERSION.DMN_v1_4; - } else if (customStaxReader.getNsContext().values().stream().anyMatch(s -> org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_DMN.equals(s))) { + } else if (customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_DMN::equals)) { result = DMN_VERSION.DMN_v1_3; - } else if (customStaxReader.getNsContext().values().stream().anyMatch(s -> org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN.equals(s))) { + } else if (customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN::equals)) { result = DMN_VERSION.DMN_v1_2; - } else if (customStaxReader.getNsContext().values().stream().anyMatch(s -> org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_DMN.equals(s))) { + } else if (customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_DMN::equals)) { result = DMN_VERSION.DMN_v1_1; } xmlReader.close(); @@ -133,7 +142,9 @@ public Definitions unmarshal(Reader isr) { @Override public String marshal(Object o) { - if (o instanceof org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase) { + if (o instanceof org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase) { + return xstream15.marshal(o); + } else if (o instanceof org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase) { return xstream14.marshal(o); } else if (o instanceof org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase) { return xstream13.marshal(o); @@ -148,7 +159,9 @@ public String marshal(Object o) { @Override public void marshal(Object o, Writer out) { - if (o instanceof org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase) { + if (o instanceof org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase) { + xstream15.marshal(o, out); + } else if (o instanceof org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase) { xstream14.marshal(o, out); } else if (o instanceof org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase) { xstream13.marshal(o, out); diff --git a/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java new file mode 100644 index 00000000000..de59347f507 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/java/org/kie/dmn/backend/marshalling/v1_5/UnmarshalMarshalTest.java @@ -0,0 +1,258 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.backend.marshalling.v1_5; + +import org.junit.Test; +import org.kie.dmn.api.marshalling.DMNMarshaller; +import org.kie.dmn.backend.marshalling.v1_3.extensions.TrisoExtensionRegister; +import org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory; +import org.kie.dmn.model.api.Definitions; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Node; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.builder.Input; +import org.xmlunit.diff.ComparisonResult; +import org.xmlunit.diff.ComparisonType; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.DifferenceEvaluators; +import org.xmlunit.validation.Languages; +import org.xmlunit.validation.ValidationProblem; +import org.xmlunit.validation.ValidationResult; +import org.xmlunit.validation.Validator; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +public class UnmarshalMarshalTest { + + private static final StreamSource DMN15_SCHEMA_SOURCE = new StreamSource(UnmarshalMarshalTest.class.getResource("/DMN15.xsd").getFile()); + private static final DMNMarshaller MARSHALLER = new org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller(); + protected static final Logger LOG = LoggerFactory.getLogger(UnmarshalMarshalTest.class); + + @Test + public void testv15_simple() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "simple.dmn"); + } + + @Test + public void testv15_ch11example_asFromOMG() throws Exception { + DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(List.of(new TrisoExtensionRegister())); // as the example from OMG contains example of extension element, preserving (re-using from package of 1.3) + testRoundTrip("org/kie/dmn/backend/marshalling/v1_5/", "Chapter 11 Example.dmn", marshaller, DMN15_SCHEMA_SOURCE); + } + + @Test + public void testv15_financial() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Financial.dmn"); + } + + @Test + public void testv15_loan_info() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Loan info.dmn"); + } + + @Test + public void testv15_recommended_loan_product() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "Recommended Loan Products.dmn"); + } + + @Test + public void testv15_for() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleFor.dmn"); + } + + @Test + public void testv15_quantified() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleQuantified.dmn"); + } + + @Test + public void testv15_conditional() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleConditional.dmn"); + } + + @Test + public void testv15_filter() throws Exception { + testRoundTripV15("org/kie/dmn/backend/marshalling/v1_5/", "sampleFilter.dmn"); + } + + public void testRoundTripV15(String subdir, String xmlfile) throws Exception { + testRoundTrip(subdir, xmlfile, MARSHALLER, DMN15_SCHEMA_SOURCE); + } + + public void testRoundTrip(String subdir, String xmlfile, DMNMarshaller marshaller, Source schemaSource) throws Exception { + + File baseOutputDir = new File("target/test-xmlunit/"); + File testClassesBaseDir = new File("target/test-classes/"); + + File inputXMLFile = new File(testClassesBaseDir, subdir + xmlfile); + + FileInputStream fis = new FileInputStream(inputXMLFile); + + Definitions unmarshal = marshaller.unmarshal(new InputStreamReader(fis)); + + Validator v = Validator.forLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.setSchemaSource(schemaSource); + ValidationResult validateInputResult = v.validateInstance(new StreamSource(inputXMLFile)); + if (!validateInputResult.isValid()) { + for (ValidationProblem p : validateInputResult.getProblems()) { + LOG.error("{}", p); + } + } + assertThat(validateInputResult.isValid()).isTrue(); + + final File subdirFile = new File(baseOutputDir, subdir); + if (!subdirFile.mkdirs()) { + LOG.warn("mkdirs() failed for File: ", subdirFile.getAbsolutePath()); + } + FileOutputStream sourceFos = new FileOutputStream(new File(baseOutputDir, subdir + "a." + xmlfile)); + Files.copy( + new File(testClassesBaseDir, subdir + xmlfile).toPath(), + sourceFos + ); + sourceFos.flush(); + sourceFos.close(); + + LOG.debug("{}", marshaller.marshal(unmarshal)); + File outputXMLFile = new File(baseOutputDir, subdir + "b." + xmlfile); + try (FileWriter targetFos = new FileWriter(outputXMLFile)) { + marshaller.marshal(unmarshal, targetFos); + } + + // Should also validate output XML: + ValidationResult validateOutputResult = v.validateInstance(new StreamSource(outputXMLFile)); + if (!validateOutputResult.isValid()) { + for (ValidationProblem p : validateOutputResult.getProblems()) { + LOG.error("{}", p); + } + } + assertThat(validateOutputResult.isValid()).isTrue(); + + LOG.debug("\n---\nDefault XMLUnit comparison:"); + Source control = Input.fromFile(inputXMLFile).build(); + Source test = Input.fromFile(outputXMLFile).build(); + Diff allDiffsSimilarAndDifferent = DiffBuilder + .compare(control) + .withTest(test) + .build(); + allDiffsSimilarAndDifferent.getDifferences().forEach(m -> LOG.debug("{}", m)); + + LOG.info("XMLUnit comparison with customized similarity for defaults:"); + // in the following a manual DifferenceEvaluator is needed until XMLUnit is configured for properly parsing the XSD linked inside the XML, + // in order to detect the optional+defaultvalue attributes of xml element which might be implicit in source-test, and explicit in test-serialized. + /* + * $ grep -Eo " + + +DMNDIv1.2: + + */ + Set attrWhichCanDefault = new HashSet(); + attrWhichCanDefault.addAll(Arrays.asList(new QName("expressionLanguage"), + new QName("typeLanguage"), + new QName("isCollection"), + new QName("hitPolicy"), + new QName("preferredOrientation"), + new QName("kind"), + new QName("textFormat"), + new QName("associationDirection"), + new QName("isCollapsed"), + new QName("useAlternativeInputDataShape"))); + Set nodeHavingDefaultableAttr = new HashSet<>(); + nodeHavingDefaultableAttr.addAll(Arrays.asList("definitions", "decisionTable", "itemDefinition", "itemComponent", "encapsulatedLogic", "textAnnotation", "association", "DMNShape", "DMNDiagram")); + Diff checkSimilar = DiffBuilder + .compare(control) + .withTest(test) + .withDifferenceEvaluator( + DifferenceEvaluators.chain(DifferenceEvaluators.Default, + ((comparison, outcome) -> { + if (outcome == ComparisonResult.DIFFERENT && comparison.getType() == ComparisonType.ELEMENT_NUM_ATTRIBUTES) { + if (comparison.getControlDetails().getTarget().getNodeName().equals(comparison.getTestDetails().getTarget().getNodeName()) + && nodeHavingDefaultableAttr.contains(safeStripDMNPRefix(comparison.getControlDetails().getTarget()))) { + return ComparisonResult.SIMILAR; + } + } + // DMNDI/DMNDiagram#documentation is actually deserialized escaped with newlines as by the XML JDK infra. + if (outcome == ComparisonResult.DIFFERENT && comparison.getType() == ComparisonType.ATTR_VALUE) { + if (comparison.getControlDetails().getTarget().getNodeName().equals(comparison.getTestDetails().getTarget().getNodeName()) + && comparison.getControlDetails().getTarget().getNodeType() == Node.ATTRIBUTE_NODE + && comparison.getControlDetails().getTarget().getLocalName().equals("documentation")) { + return ComparisonResult.SIMILAR; + } + } + if (outcome == ComparisonResult.DIFFERENT && comparison.getType() == ComparisonType.ATTR_NAME_LOOKUP) { + boolean testIsDefaulableAttribute = false; + QName whichDefaultableAttr = null; + if (comparison.getControlDetails().getValue() == null && attrWhichCanDefault.contains(comparison.getTestDetails().getValue())) { + for (QName a : attrWhichCanDefault) { + boolean check = comparison.getTestDetails().getXPath().endsWith("@" + a); + if (check) { + testIsDefaulableAttribute = true; + whichDefaultableAttr = a; + } + } + } + if (testIsDefaulableAttribute) { + if (comparison.getTestDetails().getXPath().equals(comparison.getControlDetails().getXPath() + "/@" + whichDefaultableAttr)) { + // TODO missing to check the explicited option attribute has value set to the actual default value. + return ComparisonResult.SIMILAR; + } + } + } + return outcome; + }))) + .ignoreWhitespace() + .checkForSimilar() + .build(); + checkSimilar.getDifferences().forEach(m -> LOG.error("{}", m)); + if (!checkSimilar.getDifferences().iterator().hasNext()) { + LOG.info("[ EMPTY - no diffs using customized similarity ]"); + } + assertThat(checkSimilar.hasDifferences()).as("XML are NOT similar: " + checkSimilar.toString()).isFalse(); + } + + private String safeStripDMNPRefix(Node target) { + if (KieDMNModelInstrumentedBase.URI_DMN.equals(target.getNamespaceURI()) || + KieDMNModelInstrumentedBase.URI_DMNDI.equals(target.getNamespaceURI())) { + return target.getLocalName(); + } + return null; + } +} diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/DMN15.xsd b/kie-dmn/kie-dmn-backend/src/test/resources/DMN15.xsd new file mode 100644 index 00000000000..382388d0e7e --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/DMN15.xsd @@ -0,0 +1,587 @@ + + + + + + + Include the DMN Diagram Interchange (DI) schema + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI15.xsd b/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI15.xsd new file mode 100644 index 00000000000..87e84f9cf89 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI15.xsd @@ -0,0 +1,102 @@ + + + + + + + + + + + This element should never be instantiated directly, but rather concrete implementation should. It is placed there only to be referred in the sequence + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Chapter 11 Example.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Chapter 11 Example.dmn new file mode 100644 index 00000000000..5e45b1377ab --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Chapter 11 Example.dmn @@ -0,0 +1,3010 @@ + + + + + + + + + + + + string + + "DECLINE","BUREAU","THROUGH" + + + + string + + "INELIGIBLE","ELIGIBLE" + + + + string + + "FULL","MINI","NONE" + + + + string + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + number + + + string + + "S","M" + + + + string + + "EMPLOYED","SELF-EMPLOYED","STUDENT","UNEMPLOYED" + + + + boolean + + + + number + + + number + + + number + + + + + + boolean + + + number + + [0..999], null + + + + + string + + "DECLINE","REFER","ACCEPT" + + + + + string + + "STANDARD LOAN","SPECIAL LOAN" + + + + number + + + number + + + number + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <p><span lang="JA">Determine if&nbsp;an application requiring adjudication should be accepted or declined given the available application data and supporting documents.</span></p> + Should this application that has been referred for adjudication be accepted? + Yes/No + + + + + + + + + + + + + + + + + + + + + + + <p>The collected wisdom of the credit officers as collected in their best practice wiki.</p> + Expertise + + + + <p>Documents associated with a loan that are not processed electronically but are available for manual adjudication.</p> + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Bureau call type&nbsp;</span></strong><span lang="JA">decision logic&nbsp;invokes the Bureau call type&nbsp;</span>table, passing the output of the Pre-bureau risk category decision as the Pre-Bureau Risk Category parameter.</span></p> + How much data should be requested from the credit bureau for this application? + A value from the explicit list "Full", "Mini", "None" + + + + + + + + + + + + Bureau call type table + + + + + Pre-bureau risk category + + + + + + <p><span style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Strategy&nbsp;</span></strong><span lang="JA">decision logic&nbsp;defines a complete, unique-hit decision table deriving Strategy from&nbsp;</span>Eligibility and Bureau call type.</span></p> + What is the appropriate handling strategy for this application? + A value from the explicit list "Decline", "Bureau", "Through" + + + + + + + + + + + + + + + + Eligibility + + + "INELIGIBLE","ELIGIBLE" + + + + + Bureau call type + + + "FULL","MINI","NONE" + + + + + "DECLINE","BUREAU","THROUGH" + + + + + + "INELIGIBLE" + + + - + + + "DECLINE" + + + + + + + + "ELIGIBLE" + + + "FULL", "MINI" + + + "BUREAU" + + + + + + + + "ELIGIBLE" + + + "NONE" + + + "THROUGH" + + + + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Eligibility&nbsp;</span></strong><span lang="JA">decision logic invokes the Eligibility rules business&nbsp;</span>knowledge model, passing Applicant data.Age as the Age parameter, the output of the Pre-bureau risk category decision as the Pre-Bureau Risk Category parameter, and the output of the Pre-bureau affordability decision as the Pre-Bureau Affordability parameter.</span></p> + Does this applicant appear eligible for the loan they applied for given only their application data? + Value from the explicit list "Eligible", "Not Eligible" + + + + + + + + + + + + + + + + + Eligibility rules + + + + + Applicant data.Age + + + + + + Pre-bureau risk category + + + + + + Pre-bureau affordability + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Eligibility rules&nbsp;</span></strong><span lang="JA">decision logic&nbsp;defines a complete, priority-ordered single hit decision table&nbsp;</span>deriving Eligibility from Pre-Bureau Risk Category, Pre-Bureau Affordability and Age.</span></p> + + + + + + + + + Pre-Bureau Risk Category + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + Pre-Bureau Affordability + + + + + Age + + + + + "INELIGIBLE","ELIGIBLE" + + + + + + "DECLINE" + + + - + + + - + + + "INELIGIBLE" + + + + + + + + - + + + false + + + - + + + "INELIGIBLE" + + + + + + + + - + + + - + + + < 18 + + + "INELIGIBLE" + + + + + + + + - + + + - + + + - + + + "ELIGIBLE" + + + + + + + + + + + + + <p>Definitions of the products, their cost structure and eligibility criteria.</p> + Policy + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Routing Rules&nbsp;</span></strong><span lang="JA">decision logic defines a complete, priority-ordered single hit decision table&nbsp;</span>deriving Routing from Post-Bureau Risk Category, Post-Bureau Affordability, Bankrupt and Credit Score.</span></p> + + + + + + + + + + Post-bureau risk category + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + Post-bureau affordability + + + + + Bankrupt + + + + + Credit score + + + null, [0..999] + + + + + "DECLINE","REFER","ACCEPT" + + + + + + - + + + false + + + - + + + - + + + "DECLINE" + + + + + + + + - + + + - + + + true + + + - + + + "DECLINE" + + + + + + + + "HIGH" + + + - + + + - + + + - + + + "REFER" + + + + + + + + - + + + - + + + - + + + < 580 + + + "REFER" + + + + + + + + - + + + - + + + - + + + - + + + "ACCEPT" + + + + + + + + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Routing&nbsp;</span></strong><span lang="JA">decision logic invokes the Routing rules business&nbsp;</span>knowledge model, passing Bureau data . Bankrupt as the Bankrupt parameter, Bureau data . CreditScore as the Credit Score parameter, the output of the Post-bureau risk category decision as the Post-Bureau Risk Category parameter, and the output of the Post-bureau affordability decision as the Post-Bureau Affordability parameter. Note that if Bureau data is null (due to the THROUGH strategy bypassing the Collect bureau data task) the Bankrupt and Credit Score parameters will be null.</span></p> + How this should this applicant be routed given all available data? + A value from the explicit list "Decline", "Refer for Adjudication", "Accept without Review" + + + + + + + + + + + + + + + + + + + + + Routing rules + + + + + Bureau data.Bankrupt + + + + + + Bureau data.CreditScore + + + + + + Post-bureau risk category + + + + + + Post-bureau affordability + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Bureau call type table&nbsp;</span></strong><span lang="JA">decision logic defines a complete, unique-hit decision table deriving&nbsp;</span>Bureau Call Type from Pre-Bureau Risk Category.</span></p> + + + + + + + Pre-Bureau Risk Category + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + "FULL","MINI","NONE" + + + + + + "HIGH", "MEDIUM" + + + "FULL" + + + + + + + + "LOW" + + + "MINI" + + + + + + + + "VERY LOW", "DECLINE" + + + "NONE" + + + + + + + + + + + + + <p>Overall risk management approach for the financial institution including its approach to&nbsp;application risk, credit contingencies and credit risk scoring.</p> + Policy + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"></span><span lang="JA">The&nbsp;</span><strong><span lang="JA">Credit contingency factor table&nbsp;</span></strong><span lang="JA"><span style="font-size: 10pt; font-family: arial, helvetica, sans-serif;">decision</span> logic defines a complete, unique-hit decision table&nbsp;</span>deriving Credit contingency factor from Risk Category.</p> +<p>&nbsp;</p> + + + + + + + Risk Category + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + + + "HIGH", "DECLINE" + + + 0.6 + + + + + + + + "MEDIUM" + + + 0.7 + + + + + + + + "LOW", "VERY LOW" + + + 0.8 + + + + + + + + + + + + + <p>Internal spreadsheet showing the relationship of income, payments, expenses, risk and affordability.</p> + Policy + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Affordability calculation&nbsp;</span></strong><span lang="JA">decision logic defines a boxed function deriving Affordability from&nbsp;</span>Monthly Income, Monthly Repayments, Monthly Expenses and Required Monthly Installment. One step in this calculation derives Credit contingency factor by invoking the Credit contingency factor table business</span></p> + + + + + + + + + + + + Monthly Income - (Monthly Repayments + Monthly Expenses) + + + + + + + Credit contingency factor table + + + + + Risk Category + + + + + + + + if Disposable Income * Credit Contingency Factor > Required Monthly Installment +then true +else false + + + + + Affordability + + + + + + + + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Pre-bureau affordability&nbsp;</span></strong><span lang="JA">decision logic&nbsp;invokes the&nbsp;</span>Affordability calculation business knowledge model, passing Applicant data.Monthly.Income as the Monthly Income parameter, Applicant data.Monthly.Repayments as the Monthly Repayments parameter, Applicant data.Monthly.Expenses as the Monthly Expenses parameter, the output of the Pre-bureau risk category decision as the Risk Category parameter, and the output of the Required monthly installment decision as the Required Monthly Installment parameter.</span></p> + Can the applicant afford the loan they applied for given only their application data? + Yes/No + + + + + + + + + + + + + + + + + Affordability calculation + + + + + Applicant data.Monthly.Income + + + + + + Applicant data.Monthly.Repayments + + + + + + Applicant data.Monthly.Expenses + + + + + + Pre-bureau risk category + + + + + + Required monthly installment + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Post-bureau affordability&nbsp;</span></strong><span lang="JA">decision logic invokes the&nbsp;</span>Affordability calculation business knowledge model, passing Applicant data.Monthly.Income as the Monthly Income parameter, Applicant data.Monthly.Repayments as the Monthly Repayments parameter, Applicant data.Monthly.Expenses as the Monthly Expenses parameter, the output of the Post-bureau risk category decision as the Risk Category parameter, and the output of the Required monthly installment decision as the Required Monthly Installment parameter.</span></p> + Can the applicant afford the loan they applied for given all available data? + Yes/No + + + + + + + + + + + + + + + + + Affordability calculation + + + + + Applicant data.Monthly.Income + + + + + + Applicant data.Monthly.Repayments + + + + + + Applicant data.Monthly.Expenses + + + + + + Post-bureau risk category + + + + + + Required monthly installment + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Post-bureau risk category&nbsp;</span></strong><span lang="JA">decision logic invokes the Post-bureau&nbsp;</span>risk category business knowledge model, passing Applicant data.ExistingCustomer as the Existing Customer parameter, Bureau data.CreditScore as the Credit Score parameter, and the output of the Application risk score decision as the Application Risk Score parameter. Note that if Bureau data is null (due to the THROUGH strategy bypassing the Collect bureau data task) the Credit Score parameter will be null.</span></p> + Which risk category is most appropriate for this applicant given all available data? + A value from the explicit list "Decline", "High Risk", "Medium Risk", "Low Risk", "Very Low Risk" + + + + + + + + + + + + + + + + + Post-bureau risk category table + + + + + Applicant data.ExistingCustomer + + + + + + Bureau data.CreditScore + + + + + + Application risk score + + + + + + <p>External credit score and bankruptcy information provided by a bureau.</p> + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Post-bureau risk category table&nbsp;</span></strong><span lang="JA">decision logic defines a complete, unique-hit decision table&nbsp;</span>deriving Post-Bureau Risk Category from Existing Customer, Application Risk Score and Credit Score.</span></p> + + + + + + + + + Existing Customer + + + + + Application Risk Score + + + + + Credit Score + + + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + + false + + + < 120 + + + < 590 + + + "HIGH" + + + + + + + + false + + + < 120 + + + [590..610] + + + "MEDIUM" + + + + + + + + false + + + < 120 + + + > 610 + + + "LOW" + + + + + + + + false + + + [120..130] + + + < 600 + + + "HIGH" + + + + + + + + false + + + [120..130] + + + [600..625] + + + "MEDIUM" + + + + + + + + false + + + [120..130] + + + > 625 + + + "LOW" + + + + + + + + false + + + > 130 + + + - + + + "VERY LOW" + + + + + + + + true + + + <= 100 + + + < 580 + + + "HIGH" + + + + + + + + true + + + <= 100 + + + [580..600] + + + "MEDIUM" + + + + + + + + true + + + <= 100 + + + > 600 + + + "LOW" + + + + + + + + true + + + > 100 + + + < 590 + + + "HIGH" + + + + + + + + true + + + > 100 + + + [590..615] + + + "MEDIUM" + + + + + + + + true + + + > 100 + + + > 615 + + + "LOW" + + + + + + + + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Pre-Bureau Risk Category&nbsp;</span></strong><span lang="JA">decision logic&nbsp;invokes the Pre-bureau&nbsp;</span>risk category table business knowledge model, passing Applicant data.ExistingCustomer as the Existing Customer parameter and the output of the Application risk score decision as the Application Risk Score parameter.</span></p> + Which risk category is most appropriate for this applicant given only their application data? + Value from explicit list "Decline", "High Risk", "Medium Risk", "Low Risk", "Very Low Risk" + + + + + + + + + + + + + + Pre-bureau risk category table + + + + + Applicant data.ExistingCustomer + + + + + + Application risk score + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Pre-bureau risk category table&nbsp;</span></strong><span lang="JA">decision logic defines a complete, unique-hit decision table&nbsp;</span>deriving Pre-bureau risk category from Existing Customer and Application Risk Score.</span></p> + + + + + + + + Existing Customer + + + + + Application Risk Score + + + + + "DECLINE","HIGH","MEDIUM","LOW","VERY LOW" + + + + + + false + + + < 100 + + + "HIGH" + + + + + + + + false + + + [100..120) + + + "MEDIUM" + + + + + + + + false + + + [120..130] + + + "LOW" + + + + + + + + false + + + > 130 + + + "VERY LOW" + + + + + + + + true + + + < 80 + + + "DECLINE" + + + + + + + + true + + + [80..90) + + + "HIGH" + + + + + + + + true + + + [90..110] + + + "MEDIUM" + + + + + + + + true + + + > 110 + + + "LOW" + + + + + + + + + + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Application Risk Score&nbsp;</span></strong><span lang="JA">decision logic invokes the Application&nbsp;</span>risk score model business knowledge model, passing Applicant data.Age as the Age parameter, Applicant data.MaritalStatus as the Marital Status parameter and Applicant data.EmploymentStatus as the Employment Status parameter.</span></p> + What is the risk score for this applicant? + A number greater than 70 and less than 150 + + + + + + + + + + + + Application risk score model + + + + + Applicant data.Age + + + + + + Applicant data.MaritalStatus + + + + + + Applicant data.EmploymentStatus + + + + + + <p>Credit risk scorecard analysis to determine the relevant factors for application risk scoring</p> + + + + + + + + + + Analytic Insight + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Application risk score model&nbsp;</span></strong><span lang="JA">decision logic&nbsp;defines a complete, no-order multiple-hit table&nbsp;</span>with aggregation, deriving Application risk score from Age, Marital Status and Employment Status, as the sum of the Partial scores of all matching rows (this is therefore a predictive scorecard represented as a decision table).</span></p> + + + + + + + + + Age + + + [18..120] + + + + + Marital Status + + + "S","M" + + + + + Employment Status + + + "UNEMPLOYED","STUDENT","EMPLOYED","SELF-EMPLOYED" + + + + + + + [18..22) + + + - + + + - + + + 32 + + + + + + + + [22..26) + + + - + + + - + + + 35 + + + + + + + + [26..36) + + + - + + + - + + + 40 + + + + + + + + [36..50) + + + - + + + - + + + 43 + + + + + + + + >=50 + + + - + + + - + + + 48 + + + + + + + + - + + + "S" + + + - + + + 25 + + + + + + + + - + + + "M" + + + - + + + 45 + + + + + + + + - + + + - + + + "UNEMPLOYED" + + + 15 + + + + + + + + - + + + - + + + "STUDENT" + + + 18 + + + + + + + + - + + + - + + + "EMPLOYED" + + + 45 + + + + + + + + - + + + - + + + "SELF-EMPLOYED" + + + 36 + + + + + + + + + + + + + <p>Information about the applicant including personal information, marital status and household income/expenses.</p> + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Required monthly installment&nbsp;</span></strong><span lang="JA">decision logic invokes the&nbsp;</span>Installment calculation business knowledge model, passing Requested product.ProductType as the Product Type parameter, Requested product.Rate as the Rate parameter, Requested product.Term as the Term parameter, and Requested product.Amount as the Amount parameter.</span></p> + What is the minimum monthly installment payment required for this loan product? + A dollar amount greater than zero + + + + + + + + + + + Installment calculation + + + + + Requested product.ProductType + + + + + + Requested product.Rate + + + + + + Requested product.Term + + + + + + Requested product.Amount + + + + + + <p>Details of the loan the applicant has applied for.</p> + + + + <p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><span lang="JA">The&nbsp;</span><strong><span lang="JA">Installment calculation&nbsp;</span></strong><span lang="JA">decision logic&nbsp;defines a boxed function deriving monthly installment&nbsp;</span>from Product Type, Rate, Term and Amount.</span></p> + + + + + + + + + + + if Product Type = "STANDARD LOAN" +then 20.00 +else if Product Type = "SPECIAL LOAN" +then 25.00 +else null + + + + + + Financial.PMT(Rate, Term, Amount) + + + + + Monthly Repayment + Monthly Fee + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <p>Information about historical loan defaults.</p> + + + + The credit risk scorecard is built from past applicants' data and information about those loans that defaulted. It must conform to the overall risk management strategy. + + + <p>Individuals in the Retail Banking organization responsible for manual adjudication of loans.</p> + + + + <p>Organization responsible for defining loan and other banking products, how those products are priced, sold and tracked for profitability.</p> + + + + + + <p>Organization within the bank responsible for defining credit risk strategies and policies and providing tools for managing against these.</p> + + + + + + + + + + <p>Organization responsible for credit risk models and the use of data to predict credit risk for customers and loan applicants.</p> + + + + <p>The percentage of loans accepted in a calendar month.</p> + + + + + + <p>The percentage of loans that did not require a credit officer to review the case in a calendar month.</p> + + + + + <p>The total value of Loans written in a calendar month</p> + + + + + + <p>By end of the current year, have an auto-adjudication rate of at least 90 percent</p> + + + + + <p>The total cost charged by the bureau for all Bureau Data requested while originating Loans in a calendar month.</p> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Financial.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Financial.dmn new file mode 100644 index 00000000000..c8bb039b236 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Financial.dmn @@ -0,0 +1,46 @@ + + + + + + + + + <p><span lang="JA">Standard calculation of monthly installment&nbsp;</span>from Rate, Term and Amount.</p> + + + + + + + (Amount *Rate/12) / (1 - (1 + Rate/12)**-Term) + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Loan info.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Loan info.dmn new file mode 100644 index 00000000000..e551b3de704 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Loan info.dmn @@ -0,0 +1,767 @@ + + + + + string + + + string + + + number + + + number + + + tAssets + + + tLiabilities + + + + + tAssetType + + + string + + + number + + + + tAsset + + + string + + "Checking Savings Brokerage account","Real Estate","Other Liquid","Other Non-Liquid" + + + + + tLiabilityType + + + string + + + number + + + number + + + boolean + + + + tLiability + + + string + + "Credit card","Auto loan","Student loan","Lease","Lien","Real estate loan","Alimony child support","Other" + + + "Credit card","Auto loan","Student loan","Lease","Lien","Real estate loan","Alimony child support","Other" + + + + string + + "Fixed rate","Variable rate" + + + + + string + + + tProductName + + "Fixed30-NoPoints","Fixed30-Standard","Fixed15-NoPoints","Fixed15-Standard","ARM5/1-NoPoints","ARM5/1-Standard" + + + + tAmortizationType + + + tPercent + + + tPercent + + + number + + + number + + + + + + string + + + string + + + string + + + string + + + string + + + + number + + + number + + + number + + + number + + + + number + + + number + + + number + + [300..850] + + + + string + + "Fixed30-NoPoints","Fixed30-Standard","Fixed15-NoPoints","Fixed15-Standard","ARM5/1-NoPoints","ARM5/1-Standard" + + + + + number + + + number + + + tPercent + + + number + + + number + + + tPercent + + + tPercent + + + number + + + number + + + + + tProductName + + "Fixed30-NoPoints","Fixed30-Standard","Fixed15-NoPoints","Fixed15-Standard","ARM5/1-NoPoints","ARM5/1-Standard" + + + + tAmortizationType + + "Fixed rate","Variable rate" + + + + tPercent + + + number + + + tPercent + + + tPercent + + + number + + + number + + + number + + + number + + + number + + + number + + + number + + + number + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + decimal((Property.Purchase Price - Down Payment)*Loan Product.Points Pct/100,2) + + + + + + Property.Purchase Price - Down Payment + Loan Product.Fees Amount + Points Amount + + + + + + decimal(100*Note Amount/Property.Purchase Price,2) + + + + + + decimal(0.02*Note Amount,2) + + + + + + Note Amount - Loan Product.Fees Amount - Points Amount - Closing Costs + + + + + + Loan Product.Best Rate Pct + Rate Adjustment(Credit Score, LTV) + + + + + + if Loan Product.Type="Variable rate" then Interest Rate Percent+2 else Interest Rate Percent + + + + + + + payment + + + + + Note Amount + + + + + + Interest Rate Percent/100 + + + + + + Loan Product.Term + + + + + + + + + payment + + + + + Note Amount + + + + + + Qualifying Rate Percent/100 + + + + + + Loan Product.Term + + + + + + + + + + + + + + + + + + Credit Score + + + [300..850] + + + + + LTV + + + + + + + >=660 + + + <=60 + + + 0 + + + + + + + + [620..660) + + + <=60 + + + 0.125 + + + + + + + + >=700 + + + >60 + + + 0.125 + + + + + + + + [660..700) + + + (60..70] + + + 0.125 + + + + + + + + [620..660) + + + (60..70] + + + 0.25 + + + + + + + + [680..700) + + + >70 + + + 0.25 + + + + + + + + [640..680) + + + >70 + + + 0.375 + + + + + + + + [620..640) + + + (70..80] + + + 0.375 + + + + + + + + [620..640) + + + >80 + + + 0.5 + + + + + + + + <620 + + + - + + + 0.5 + + + + + + + + + + + + + + + + decimal(p*r/12/(1-(1+r/12)**-n),2) + + + + + + + + + + + + + + + + + + + + + + Loan Product.Product Name + + + + + + Loan Product.Type + + + + + + Loan Data.LTV + + + + + + Loan Data.Note Amount + + + + + + Loan Data.Interest Rate Percent + + + + + + Loan Data.Qualifying Rate Percent + + + + + + Loan Data.Monthly Payment + + + + + + Loan Data.Qualifying Payment + + + + + + Loan Data.Points Amount + + + + + + Loan Product.Fees Amount + + + + + + Loan Data.Funds Toward Purchase + + + + + + Down Payment + + + + + + Loan Data.Closing Costs + + + + + + Property.Purchase Price - Funds Toward Purchase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Recommended Loan Products.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Recommended Loan Products.dmn new file mode 100644 index 00000000000..0ad2f5e6a58 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/Recommended Loan Products.dmn @@ -0,0 +1,1421 @@ + + + + + + string + + + string + + + number + + + number + + + tAssets + + + tLiabilities + + + + + tAssetType + + + string + + + number + + + + tAsset + + + string + + "Checking Savings Brokerage account","Real Estate","Other Liquid","Other Non-Liquid" + + + + + tLiabilityType + + + string + + + number + + + number + + + boolean + + + + tLiability + + + string + + "Credit card","Auto loan","Student loan","Lease","Lien","Real estate loan","Alimony child support","Other" + + + + string + + "Fixed rate","Variable rate" + + + + + tAmortizationType + + + number + + + number + + + number + + + number + + + + + + string + + + string + + + string + + + string + + + string + + + + number + + + number + + + number + + + number + + + + number + + + number + + + number + + [300..850] + + + + string + + "Affordable","Marginal","Unaffordable" + + + + string + + "Fixed30-NoPoints","Fixed30-Standard","Fixed15-NoPoints","Fixed15-Standard","ARM5/1-NoPoints","ARM5/1-Standard" + + + + + string + + + tProductName + + "Fixed30-NoPoints","Fixed30-Standard","Fixed30-LowestRate","Fixed15-NoPoints","Fixed15-Standard","ARM5/1-NoPoints","ARM5/1-Standard" + + + + tAmortizationType + + "Fixed rate","Variable rate" + + + + tPercent + + + tPercent + + + number + + + number + + + + tLoanProduct + + + + tProductName + + + tAmortizationType + + + tPercent + + + number + + + tPercent + + + tPercent + + + number + + + number + + + number + + + number + + + number + + + number + + + number + + + number + + + + tLoanInfoRow + + + tTableRow + + + string + + "Low","Medium","High" + + + + + tAffordability + + + number + + + tLTVCategory + + + + + tPercent + + + tAffordability + + "Affordable","Marginal","Unaffordable" + + + + tLTVCategory + + "Low","Medium","High" + + + + number + + + number + + + + + number + + + number + + + number + + + tPercent + + + number + + + number + + + number + + + number + + + + + string + + + number + + [1..5] + + + + + tLenderRating + + + string + + "Best","Good","Not Recommended","Ineligible" + + + + + string + + + number + + + tPercent + + + number + + + tPercent + + + tPercent + + + number + + + number + + + number + + + tCreditScore + + [300..850] + + + + tRecommendation + + "Best","Good","Not Recommended","Ineligible" + + + + + + string + + + string + + + string + + + string + + + string + + + string + + + string + + + string + + + string + + + tCreditScore + + + string + + + + tformattedrow_1 + + + + string + + + string + + + string + + + string + + + string + + + tCreditScore + + [300..850] + + + + string + + + + + + + + + + + + + + + + + + + + + + + + DTI + + + + + LTV + + + + + Reserves + + + + + [300..850] + + + + + + <=36 + + + <=75 + + + >2 + + + 620 + + + + + + + + <=36 + + + <=75 + + + >0 + + + 640 + + + + + + + + <=36 + + + (75..95] + + + >6 + + + 660 + + + + + + + + <=36 + + + (75..95] + + + >0 + + + 680 + + + + + + + + (36..45] + + + <=75 + + + >6 + + + 660 + + + + + + + + (36..45] + + + <=75 + + + >0 + + + 680 + + + + + + + + (36..45] + + + (75..95] + + + >6 + + + 700 + + + + + + + + (36..45] + + + (75..95] + + + >0 + + + 720 + + + + + + + + + + + + + + + + + + + + + "Lender A" + + + "Fixed30-NoPoints" + + + "Fixed rate" + + + 3.95 + + + 0 + + + 1925 + + + 360 + + + + + "Lender C" + + + "Fixed30-Standard" + + + "Fixed rate" + + + 3.75 + + + 0.972 + + + 1975 + + + 360 + + + + + "Lender A" + + + "Fixed15-NoPoints" + + + "Fixed rate" + + + 3.625 + + + 0 + + + 816 + + + 180 + + + + + "Lender C" + + + "Fixed15-Standard" + + + "Fixed rate" + + + 3.25 + + + 0.767 + + + 1975 + + + 180 + + + + + "Lender B" + + + "ARM5/1-NoPoints" + + + "Variable rate" + + + 3.875 + + + 0 + + + 1776 + + + 360 + + + + + "Lender B" + + + "ARM5/1-Standard" + + + "Variable rate" + + + 3.625 + + + 0.667 + + + 1975 + + + 360 + + + + + + + + + + + + + + + + + + + + + + + for x in Loan Products return Services.Loan Info Service(x,Down Payment,Property,Credit Score) + + + + + + + + + + + + + + + + + + + + + + + + + + + for i in 1..count(Loan Products) return Eligibility(Loan Products[i], Borrower, Loan Info Table[i], +Property, Credit Score, Lender Ratings) + + + + + + + + + + + + + + + + Eligibility Parameters(Loan Product, Borrower, Loan Info, +Property, Credit Score) + + + + + + Min Credit Score(Params.DTI Pct, Loan Info.LTV, Params.Reserves) + + + + + + if Required Credit Score != null then +Credit Score >= Required Credit Score else false + + + + + + + + Loan Product + + + + + Eligible + + + + + "Best","Good","Not Recommended","Ineligible" + + + + + + count(Ratings[Lender Name=?.Lender Name and Customer Rating > 4] )>0 + + + true + + + "Best" + + + + + + + + count(Ratings[Lender Name=?.Lender Name and Customer Rating in [3..4]] )>0 + + + true + + + "Good" + + + + + + + + count(Ratings[Lender Name=?.Lender Name and Customer Rating <3] )>0 + + + true + + + "Not Recommended" + + + + + + + + - + + + - + + + "Ineligible" + + + + + + + + + + + + + + Loan Product.Lender Name + " - " + Loan Product.Product Name + + + + + + Loan Info.Note Amount + + + + + + Loan Info.Initial Rate Pct + + + + + + Loan Info.Initial Monthly Payment + + + + + + Loan Info.LTV + + + + + + Params.DTI Pct + + + + + + Loan Info.Cash to Close + + + + + + Params.Liquid Assets After Closing + + + + + + Params.Reserves + + + + + + Required Credit Score + + + + + + Recommendation + + + + + + + Table Row + + + + + + + + + + + + + + + + + + + + + + + + + + + if x.Recommendation != "Ineligible" and y.Recommendation != "Ineligible" +then x.Monthly Payment<y.Monthly Payment +else if x.Recommendation != "Ineligible" and y.Recommendation = "Ineligible" +then true else false + + + + + + + sort(Eligibility Table, precedes) + + + + + for row in Sorted Table return Format Row(row) + + + + + + + + + + + + + + + + + sum([Loan Info.Qualifying Monthly Payment, Property.Monthly Tax Payment, +Property.Monthly Insurance Payment, Property.Monthly HOA Condo Fee][item != null]) + + + + + + sum(Borrower.Liabilities[Type!="Real estate loan" and To be paid off +=false].Monthly payment) + + + + + + sum([Borrower.Employment Income, Borrower.Other Income][item != null]) + + + + + + decimal((Housing Expense+Non-Housing Debt Payments)/Income*100,2) + + + + + + sum(Borrower.Assets[Type="Checking Savings Brokerage account" +or Type="Other Liquid"].Value) + + + + + + sum(Borrower.Liabilities[Type!="Real estate loan" +and To be paid off=true].Balance[item!=null]) + + + + + + Liquid Assets Before Closing - Debts Paid Off By Closing - Loan Info.Cash to Close + + + + + + decimal(Liquid Assets After Closing/Housing Expense,2) + + + + + + + + + + + + + + + + + + + + + + + "java.lang.String" + + + + + + "format( java.lang.String, [Ljava.lang.Object; )" + + + + + + + + + + + + row.Product + + + + + + string format("$%,4.2f", row.Note Amount) + + + + + + string format(" %,4.2f", row.Interest Rate Pct) + + + + + + string format("$%,4.2f", row.Monthly Payment) + + + + + + string format("$%,4.2f", row.Cash to Close) + + + + + + row.Required Credit Score + + + + + + row.Recommendation + + + + + + + formatted row + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleConditional.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleConditional.dmn new file mode 100644 index 00000000000..860467eca9a --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleConditional.dmn @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + 47 > 0 + + + + + "Hello World" + + + + + "wat" + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFilter.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFilter.dmn new file mode 100644 index 00000000000..42ed34e16c6 --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFilter.dmn @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + [1,2,3,4] + + + + + item>2 + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFor.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFor.dmn new file mode 100644 index 00000000000..54669c1dbaa --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleFor.dmn @@ -0,0 +1,47 @@ + + + + + + + + [1,2,3] + + + + + itVal+1 + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleQuantified.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleQuantified.dmn new file mode 100644 index 00000000000..5917ce270bb --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/sampleQuantified.dmn @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + x > 0 + + + + + + + + + + [1,2,3] + + + + + x > 0 + + + + + + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/simple.dmn b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/simple.dmn new file mode 100644 index 00000000000..e0f7a9e340c --- /dev/null +++ b/kie-dmn/kie-dmn-backend/src/test/resources/org/kie/dmn/backend/marshalling/v1_5/simple.dmn @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + "Hello, "+name + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNTypeRegistryV15.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNTypeRegistryV15.java new file mode 100644 index 00000000000..9c17a476005 --- /dev/null +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNTypeRegistryV15.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.core.compiler; + +import org.kie.dmn.api.core.DMNType; +import org.kie.dmn.core.impl.SimpleTypeImpl; +import org.kie.dmn.feel.lang.types.BuiltInType; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +import javax.xml.namespace.QName; +import java.util.Map; + +public class DMNTypeRegistryV15 extends DMNTypeRegistryAbstract { + + private static final DMNType UNKNOWN = new SimpleTypeImpl(KieDMNModelInstrumentedBase.URI_FEEL, + BuiltInType.UNKNOWN.getName(), + null, true, null, null, + BuiltInType.UNKNOWN ); + + public DMNTypeRegistryV15(Map aliases) { + super(aliases); + } + + @Override + public DMNType unknown() { + return UNKNOWN; + } + + @Override + protected String feelNS() { + return KieDMNModelInstrumentedBase.URI_FEEL; + } +} diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/ImportDMNResolverUtil.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/ImportDMNResolverUtil.java index 4a30c066419..4a15ef4d199 100644 --- a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/ImportDMNResolverUtil.java +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/ImportDMNResolverUtil.java @@ -83,6 +83,7 @@ public static ImportType whichImportType(Import _import) { case org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN: case org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_DMN: case org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_DMN: + case org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_DMN: return ImportType.DMN; case NamespaceConsts.PMML_3_0: case NamespaceConsts.PMML_3_1: diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java index d16dc55d9f4..fafcb18b5df 100644 --- a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java @@ -64,6 +64,7 @@ import org.kie.dmn.core.compiler.DMNTypeRegistryV12; import org.kie.dmn.core.compiler.DMNTypeRegistryV13; import org.kie.dmn.core.compiler.DMNTypeRegistryV14; +import org.kie.dmn.core.compiler.DMNTypeRegistryV15; import org.kie.dmn.core.pmml.DMNImportPMMLInfo; import org.kie.dmn.core.util.DefaultDMNMessagesManager; import org.kie.dmn.model.api.DMNModelInstrumentedBase; @@ -124,8 +125,10 @@ private void wireTypeRegistry(Definitions definitions) { types = new DMNTypeRegistryV12(Collections.unmodifiableMap(importAliases)); } else if (definitions instanceof org.kie.dmn.model.v1_3.TDefinitions) { types = new DMNTypeRegistryV13(Collections.unmodifiableMap(importAliases)); - } else { + } else if (definitions instanceof org.kie.dmn.model.v1_4.TDefinitions) { types = new DMNTypeRegistryV14(Collections.unmodifiableMap(importAliases)); + } else { + types = new DMNTypeRegistryV15(Collections.unmodifiableMap(importAliases)); } } diff --git a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/typesafe/DMNTypeUtils.java b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/typesafe/DMNTypeUtils.java index e04f2a4dd34..b177ba51b7b 100644 --- a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/typesafe/DMNTypeUtils.java +++ b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/typesafe/DMNTypeUtils.java @@ -36,7 +36,8 @@ public static boolean isFEELBuiltInType(DMNType dmnType) { return dmnType.getNamespace().equals(org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_FEEL) || dmnType.getNamespace().equals(org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_FEEL) || dmnType.getNamespace().equals(org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_FEEL) || - dmnType.getNamespace().equals(org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_FEEL) + dmnType.getNamespace().equals(org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_FEEL) || + dmnType.getNamespace().equals(org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_FEEL) ; } diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java index fc4344da9f3..b3c8d02b027 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java @@ -294,7 +294,7 @@ public void testDMNInputDataNodeTypeTest() { // DROOLS-1569 final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DMNInputDataNodeTypeTest.dmn", this.getClass()); final String MODEL_NAMESPACE = "http://www.trisotech.com/definitions/_17396034-163a-48aa-9a7f-c6eb17f9cc6c"; - final String FEEL_NAMESPACE = org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_FEEL; + final String FEEL_NAMESPACE = org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_FEEL; final DMNModel dmnModel = runtime.getModel(MODEL_NAMESPACE, "DMNInputDataNodeTypeTest"); assertThat(dmnModel).isNotNull(); assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java index 61df43f1f47..24dc9de7b42 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNStronglyTypedSupportTest.java @@ -70,7 +70,7 @@ public void testDMNInputDataNodeTypeTest() { // DROOLS-1569 final DMNRuntime runtime = createRuntime("DMNInputDataNodeTypeTest.dmn", this.getClass()); final String MODEL_NAMESPACE = "http://www.trisotech.com/definitions/_17396034-163a-48aa-9a7f-c6eb17f9cc6c"; - final String FEEL_NAMESPACE = org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_FEEL; + final String FEEL_NAMESPACE = org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_FEEL; final DMNModel dmnModel = runtime.getModel(MODEL_NAMESPACE, "DMNInputDataNodeTypeTest"); assertThat(dmnModel).isNotNull(); assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java index c14427732cd..3c603b87836 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNTypeTest.java @@ -26,12 +26,12 @@ import org.junit.Test; import org.kie.dmn.api.core.DMNType; import org.kie.dmn.core.compiler.DMNTypeRegistry; -import org.kie.dmn.core.compiler.DMNTypeRegistryV11; +import org.kie.dmn.core.compiler.DMNTypeRegistryV15; import org.kie.dmn.core.impl.CompositeTypeImpl; import org.kie.dmn.core.impl.SimpleTypeImpl; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.types.BuiltInType; -import org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.dmn.core.util.DynamicTypeUtils.entry; @@ -39,7 +39,7 @@ public class DMNTypeTest { - private static final DMNTypeRegistry typeRegistry = new DMNTypeRegistryV11(Collections.emptyMap()); + private static final DMNTypeRegistry typeRegistry = new DMNTypeRegistryV15(Collections.emptyMap()); private static final DMNType FEEL_STRING = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "string"); private static final DMNType FEEL_NUMBER = typeRegistry.resolveType(KieDMNModelInstrumentedBase.URI_FEEL, "number"); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java index c98f39803d6..91a77f011b3 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/incrementalcompilation/WBCompilationTest.java @@ -34,7 +34,7 @@ public class WBCompilationTest { static final String DMN_1 = "\n" + - "\n" + + "\n" + " \n" + " \n" + " \n" + @@ -65,9 +65,9 @@ public class WBCompilationTest { ""; static final String DMN_2 = "\n" + - "\n" + + "\n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java index b6274a70165..e6c0af2648b 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/JavadocTest.java @@ -69,67 +69,67 @@ public void testDateAndTime() throws Exception { String inputSet = sourceMap.get("InputSet"); CompilationUnit cu = StaticJavaParser.parse(inputSet); - assertJavadoc(cu, "dateTimeString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "Timezone", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "oneHour", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); - assertJavadoc(cu, "Month", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Year", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Hours", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "timeString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "dateString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "Seconds", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Day", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Minutes", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "durationString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); + assertJavadoc(cu, "dateTimeString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "Timezone", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "oneHour", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); + assertJavadoc(cu, "Month", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Year", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Hours", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "timeString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "dateString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "Seconds", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Day", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Minutes", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "durationString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); String outputSet = sourceMap.get("OutputSet"); cu = StaticJavaParser.parse(outputSet); - assertJavadoc(cu, "Timezone", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "Date_45Time", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : date and time }"); - assertJavadoc(cu, "Hours", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Time", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : time }"); - assertJavadoc(cu, "Minutes", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Date_45Time2", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : date and time }"); - assertJavadoc(cu, "years", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "dateTimeString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "oneHour", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); - assertJavadoc(cu, "d1seconds", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Month", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "cDay", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "sumDurations", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); - assertJavadoc(cu, "cYear", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "cSecond", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "dateString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "cTimezone", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "durationString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "cHour", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Year", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Time2", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : time }"); - assertJavadoc(cu, "timeString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : string }"); - assertJavadoc(cu, "Time3", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : time }"); - assertJavadoc(cu, "hoursInDuration", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "dtDuration1", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); - assertJavadoc(cu, "Seconds", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "dtDuration2", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); - assertJavadoc(cu, "Day", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "cMonth", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "cMinute", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "ymDuration2", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : days and time duration }"); + assertJavadoc(cu, "Timezone", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "Date_45Time", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : date and time }"); + assertJavadoc(cu, "Hours", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Time", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : time }"); + assertJavadoc(cu, "Minutes", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Date_45Time2", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : date and time }"); + assertJavadoc(cu, "years", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "dateTimeString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "oneHour", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); + assertJavadoc(cu, "d1seconds", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Month", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "cDay", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "sumDurations", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); + assertJavadoc(cu, "cYear", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "cSecond", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "dateString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "cTimezone", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "durationString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "cHour", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Year", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Time2", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : time }"); + assertJavadoc(cu, "timeString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : string }"); + assertJavadoc(cu, "Time3", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : time }"); + assertJavadoc(cu, "hoursInDuration", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "dtDuration1", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); + assertJavadoc(cu, "Seconds", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "dtDuration2", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); + assertJavadoc(cu, "Day", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "cMonth", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "cMinute", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "ymDuration2", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : days and time duration }"); String tDateVariants = sourceMap.get("TDateVariants"); cu = StaticJavaParser.parse(tDateVariants); - assertJavadoc(cu, "fromString", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : date }"); - assertJavadoc(cu, "fromDateTime", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : date }"); - assertJavadoc(cu, "fromYearMonthDay", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : date }"); + assertJavadoc(cu, "fromString", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : date }"); + assertJavadoc(cu, "fromDateTime", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : date }"); + assertJavadoc(cu, "fromYearMonthDay", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : date }"); String tDateTimeComponents = sourceMap.get("TDateTimeComponents"); cu = StaticJavaParser.parse(tDateTimeComponents); - assertJavadoc(cu, "Year", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Month", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Day", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Hour", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Minute", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); - assertJavadoc(cu, "Second", "DMNType{ http://www.omg.org/spec/DMN/20180521/FEEL/ : number }"); + assertJavadoc(cu, "Year", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Month", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Day", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Hour", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Minute", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); + assertJavadoc(cu, "Second", "DMNType{ https://www.omg.org/spec/DMN/20230324/FEEL/ : number }"); } private void assertJavadoc(CompilationUnit cu, String field, String expectedJavadocComment) { diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-filter.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-filter.dmn index aa3d69a4a4c..121f91344f3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-filter.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-filter.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-artificial-attributes.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-artificial-attributes.dmn index 7b469557024..3544d1fabbd 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-artificial-attributes.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-artificial-attributes.dmn @@ -17,10 +17,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-itIT.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-itIT.dmn index d2a600ef5f1..d5f25c09978 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-itIT.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string-itIT.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string.dmn index 9a178f59d0e..10daebf1314 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0001-input-data-string.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number-scientific-notation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number-scientific-notation.dmn index 82b075cdd61..54b84a8c86d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number-scientific-notation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number-scientific-notation.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number.dmn index ed5919beef0..1318dcb01ca 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0002-input-data-number.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0003-input-data-string-allowed-values.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0003-input-data-string-allowed-values.dmn index 9fe78a6b3fb..aa736d23ed4 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0003-input-data-string-allowed-values.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0003-input-data-string-allowed-values.dmn @@ -17,10 +17,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0004-lending.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0004-lending.dmn index 9bae4202045..658400c75f6 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0004-lending.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0004-lending.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-bad-example.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-bad-example.dmn index 8429b2657fa..66d0e2eb1df 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-bad-example.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-bad-example.dmn @@ -2,10 +2,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-singleton-lists.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-singleton-lists.dmn index 00eda8d27e0..6432b57499c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-singleton-lists.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-singleton-lists.dmn @@ -2,10 +2,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-uninterpreted.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-uninterpreted.dmn index 1b894dab66c..46279e8678f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-uninterpreted.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0019-flight-rebooking-uninterpreted.dmn @@ -2,10 +2,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0020-vacation-days.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0020-vacation-days.dmn index a9b6534e5e5..99defc06568 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0020-vacation-days.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/0020-vacation-days.dmn @@ -2,10 +2,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/20180731-pr1997.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/20180731-pr1997.dmn index 60d66fd017b..254b6a5a9e3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/20180731-pr1997.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/20180731-pr1997.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Collect_Hit_Policy.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Collect_Hit_Policy.dmn index 6d7d8566d27..f2c9e8b02da 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Collect_Hit_Policy.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Collect_Hit_Policy.dmn @@ -2,10 +2,10 @@ - + - + date and time("2019-01-01T01:00-09:00").time offset.hours @@ -17,7 +17,7 @@ - + Date and Time Variable.time offset.hours @@ -28,7 +28,7 @@ - + time("19:00:00-11:00").time offset.hours @@ -40,7 +40,7 @@ - + Time Variable.time offset.hours diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DMNInputDataNodeTypeTest.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DMNInputDataNodeTypeTest.dmn index 26027b63e01..21e76d39a43 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DMNInputDataNodeTypeTest.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DMNInputDataNodeTypeTest.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn index 4ede5818d69..0ad97abe0b7 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/DTABLE_NON_PRIORITY_MISSING_OUTVALS.dmn @@ -15,9 +15,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Decide with symbols.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Decide with symbols.dmn index 61153311234..7210877831c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Decide with symbols.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Decide with symbols.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Dinner.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Dinner.dmn index 9e3ad7ddfba..367b735ff04 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Dinner.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Dinner.dmn @@ -2,10 +2,10 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Ex_4_3simplified.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Ex_4_3simplified.dmn index 9e55b38fdad..481dfcccb98 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Ex_4_3simplified.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Ex_4_3simplified.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/First DT not stopping.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/First DT not stopping.dmn index 4407501e291..34a7cae9d55 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/First DT not stopping.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/First DT not stopping.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/FunctionDefinition.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/FunctionDefinition.dmn index e1b1b843d17..7b819b8cefa 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/FunctionDefinition.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/FunctionDefinition.dmn @@ -17,10 +17,10 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/List_of_Vowels.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/List_of_Vowels.dmn index e4482c827d3..2b491fb8b1c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/List_of_Vowels.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/List_of_Vowels.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/OpInNames2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/OpInNames2.dmn index 1701a95a140..6f3750b5a58 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/OpInNames2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/OpInNames2.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Order.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Order.dmn index 36209878d73..14b088fb47b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Order.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Order.dmn @@ -1,5 +1,5 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/PersonListHelloBKM.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/PersonListHelloBKM.dmn index 0a811e802fa..2128248528d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/PersonListHelloBKM.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/PersonListHelloBKM.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/RecommenderHitPolicy1_allowNull_itemDef.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/RecommenderHitPolicy1_allowNull_itemDef.dmn index 5d0933e0efc..bf959f7956a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/RecommenderHitPolicy1_allowNull_itemDef.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/RecommenderHitPolicy1_allowNull_itemDef.dmn @@ -1,5 +1,5 @@ - + number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Recursive.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Recursive.dmn index ab80decfa6a..334883185c6 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Recursive.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Recursive.dmn @@ -17,10 +17,10 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Table61ForAliasFeelType.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Table61ForAliasFeelType.dmn index eb8ea9e8572..29cca27d7c9 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Table61ForAliasFeelType.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Table61ForAliasFeelType.dmn @@ -1,4 +1,4 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/TimeFromDate.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/TimeFromDate.dmn index 4a955361bb5..d004a265053 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/TimeFromDate.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/TimeFromDate.dmn @@ -2,10 +2,10 @@ - diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Union_of_letters.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Union_of_letters.dmn index d92dc0e776f..32c0aee8050 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Union_of_letters.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/Union_of_letters.dmn @@ -2,9 +2,9 @@ - + @@ -20,7 +20,7 @@ - + { m: <<18 }.m(16) @@ -32,7 +32,7 @@ - + { m: <18 }.m(16) diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/WrongConstraintsInItemDefinition.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/WrongConstraintsInItemDefinition.dmn index eb803a27eca..8ae2d3c73cd 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/WrongConstraintsInItemDefinition.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/WrongConstraintsInItemDefinition.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/alphasupport.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/alphasupport.dmn index 9b36e5d206d..1c70fc5885a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/alphasupport.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/alphasupport.dmn @@ -1,5 +1,5 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/an-simpletable-multipletests.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/an-simpletable-multipletests.dmn index 686b2f24154..9b8a907d1b3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/an-simpletable-multipletests.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/alphanetwork/an-simpletable-multipletests.dmn @@ -30,9 +30,9 @@ + xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/"> - + @@ -28,6 +28,6 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/anot.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/anot.dmn index a4904c147a9..d15354e616c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/anot.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/anot.dmn @@ -2,9 +2,9 @@ - + string @@ -8,7 +8,7 @@ "Hello World" - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub1.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub1.dmn index cea52baac68..c8acd0e902d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub1.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub1.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub2.dmn index a2bb46a8a17..b1ca43765d6 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/arithmeticSub2.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/assignNullToAllowedValues.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/assignNullToAllowedValues.dmn index a7e3629bae8..bf23dfeb758 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/assignNullToAllowedValues.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/assignNullToAllowedValues.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/bkmWithDotsInName.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/bkmWithDotsInName.dmn index 36d1b9997bb..4c597f551a5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/bkmWithDotsInName.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/bkmWithDotsInName.dmn @@ -1,5 +1,5 @@ - + model to help test https://issues.redhat.com/browse/DROOLS-5314 diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/business-knowledge-model-required-input.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/business-knowledge-model-required-input.dmn index 08146173bba..2ce2d0b3146 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/business-knowledge-model-required-input.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/business-knowledge-model-required-input.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/cItemDef.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/cItemDef.dmn index e4c787416d3..00c5d111433 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/cItemDef.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/cItemDef.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/calculation1.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/calculation1.dmn index 50705667fae..30d542895e5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/calculation1.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/calculation1.dmn @@ -2,10 +2,10 @@ - + number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Greetings.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Greetings.dmn index 570af623dc8..201b573f472 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Greetings.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Greetings.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Standard Deviation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Standard Deviation.dmn index 32f846b0f7a..e8ef9133a23 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Standard Deviation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/Standard Deviation.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/invokeJavaReturnArrayPrimitives.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/invokeJavaReturnArrayPrimitives.dmn index fd16bb675e7..c3da44560cc 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/invokeJavaReturnArrayPrimitives.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/invokeJavaReturnArrayPrimitives.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/license.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/license.dmn index fdb37df9765..380af12b319 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/license.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/license.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL.dmn index f93509f51b3..d0a25e162ca 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL2.dmn index c7a8d5f6221..f478f19af77 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/personCL2.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/sumWithBKM.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/sumWithBKM.dmn index e28419f51d9..da6cb75cd21 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/sumWithBKM.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/classloader/sumWithBKM.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compilationThrowsNPE.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compilationThrowsNPE.dmn index 8cd99993e9a..ebbaffbc1c1 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compilationThrowsNPE.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compilationThrowsNPE.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/customModelCount.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/customModelCount.dmn index 8d54cef7c5d..a616c576e73 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/customModelCount.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/customModelCount.dmn @@ -1,8 +1,8 @@ - + - + customModelCount() diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/just_47.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/just_47.dmn index 6fb402e7ad1..d5eb166dbfd 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/just_47.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/compiler/profiles/just_47.dmn @@ -2,9 +2,9 @@ \ No newline at end of file + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSWithImportRequiredInput20180920.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSWithImportRequiredInput20180920.dmn index 83ab8868e55..6e1df39e5d9 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSWithImportRequiredInput20180920.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSWithImportRequiredInput20180920.dmn @@ -1,9 +1,9 @@ - + [] - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DStypecheck.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DStypecheck.dmn index 2f5fd6c66ec..c9aca762998 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DStypecheck.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DStypecheck.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSxy.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSxy.dmn index 1acd1d5553c..47a8e1158a3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSxy.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/DSxy.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/Decision-Services-singleton-or-multiple-output-decisions.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/Decision-Services-singleton-or-multiple-output-decisions.dmn index 0fade0b26a0..04b46407967 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/Decision-Services-singleton-or-multiple-output-decisions.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/Decision-Services-singleton-or-multiple-output-decisions.dmn @@ -2,9 +2,9 @@ + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004bkmBoxedInvocation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004bkmBoxedInvocation.dmn index 51a8bee21f6..288df90cdef 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004bkmBoxedInvocation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004bkmBoxedInvocation.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004boxedInvocation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004boxedInvocation.dmn index f05c2c19b4e..f078efbc712 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004boxedInvocation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importing0004boxedInvocation.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDS.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDS.dmn index dd63b194d92..1fe835eb181 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDS.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDS.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSbkmBoxedInvocation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSbkmBoxedInvocation.dmn index 0a6e94d496a..81dafa58037 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSbkmBoxedInvocation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSbkmBoxedInvocation.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSboxedInvocation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSboxedInvocation.dmn index 08e45b1113f..91647310064 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSboxedInvocation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/importingMyHelloDSboxedInvocation.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/mixtype-DS.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/mixtype-DS.dmn index 26a66b96a8f..9d4c65d236a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/mixtype-DS.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisionservices/mixtype-DS.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable-default-value.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable-default-value.dmn index f1db4d2ac32..b7a0b1f9e15 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable-default-value.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable-default-value.dmn @@ -30,9 +30,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable/dtevent.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable/dtevent.dmn index 8360584244f..20178f5d23f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable/dtevent.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/decisiontable/dtevent.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/dmcommunity_challenge_2017_03.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/dmcommunity_challenge_2017_03.dmn index a90577ddad7..ffda1f0b0cf 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/dmcommunity_challenge_2017_03.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/dmcommunity_challenge_2017_03.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools1502-noprefix.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools1502-noprefix.dmn index 730f9fea941..40d13b9516f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools1502-noprefix.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools1502-noprefix.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools2125.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools2125.dmn index bc80b22d418..617e800aeb9 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools2125.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/drools2125.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/duplicate.0001-input-data-string.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/duplicate.0001-input-data-string.dmn index 9a178f59d0e..10daebf1314 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/duplicate.0001-input-data-string.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/duplicate.0001-input-data-string.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/empty_decision.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/empty_decision.dmn index 7c0739dfd55..5546a8cadeb 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/empty_decision.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/empty_decision.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/exceptionInContextEntry.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/exceptionInContextEntry.dmn index 93e63e597b2..0953697f00c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/exceptionInContextEntry.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/exceptionInContextEntry.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Y.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Y.dmn index 093733e2df7..8b7fb6a267f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Y.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Y.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Yboxed.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Yboxed.dmn index 524b8219f77..8cf5bdbad4a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Yboxed.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/Yboxed.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/basicRecursion.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/basicRecursion.dmn index 3a702d8735b..129422c4d7c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/basicRecursion.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/extra/basicRecursion.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/forTypeCheckTest.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/forTypeCheckTest.dmn index 95cdad6ff34..32439dc933b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/forTypeCheckTest.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/forTypeCheckTest.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/habitability.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/habitability.dmn index c60143d047f..5ba2839631e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/habitability.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/habitability.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/hardcoded_function_definition.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/hardcoded_function_definition.dmn index 98862e44a47..7b7fd057106 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/hardcoded_function_definition.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/hardcoded_function_definition.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModel.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModel.dmn index 2512487b07d..212567e6001 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModel.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModel.dmn @@ -1,5 +1,5 @@ - + Returns true if first argument was bigger than second. False otherwise. diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModelNamedWithDots.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModelNamedWithDots.dmn index cf669a79659..34a2a04723b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModelNamedWithDots.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/ComparatorModelNamedWithDots.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Do_invoke_hello_with_2_bkms.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Do_invoke_hello_with_2_bkms.dmn index e43cfaeef15..ef7b234ae51 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Do_invoke_hello_with_2_bkms.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Do_invoke_hello_with_2_bkms.dmn @@ -2,10 +2,10 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_ComparatorModel_and_alias_with_dots.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_ComparatorModel_and_alias_with_dots.dmn index 55dc214bf57..1f96cf76028 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_ComparatorModel_and_alias_with_dots.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_ComparatorModel_and_alias_with_dots.dmn @@ -1,7 +1,7 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_Spell_Greeting.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_Spell_Greeting.dmn index e93541c7655..5676e125bf4 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_Spell_Greeting.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/Import_Spell_Greeting.dmn @@ -2,10 +2,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/L3_Do_say_hello.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/L3_Do_say_hello.dmn index 6af2509738a..7c01756170a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/L3_Do_say_hello.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/L3_Do_say_hello.dmn @@ -2,11 +2,11 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/baseSum.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/baseSum.dmn index 4fff4c31488..f96ddb0204c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/baseSum.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/baseSum.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/importingSum.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/importingSum.dmn index 1b3d9ec7a34..22efbba8c3f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/importingSum.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/importingSum.dmn @@ -1,6 +1,6 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof base model.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof base model.dmn index 553668f7e40..40977f0d67c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof base model.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof base model.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof checks.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof checks.dmn index 06c20e8b474..3ff4875d3ba 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof checks.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/instanceof checks.dmn @@ -1,7 +1,7 @@ - + - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/use join.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/use join.dmn index 4fec1ecd1ca..d693b36383d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/use join.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/imports/use join.dmn @@ -1,7 +1,7 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incomplete_expression.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incomplete_expression.dmn index 4b96f189c85..4a1e940f9c1 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incomplete_expression.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incomplete_expression.dmn @@ -2,9 +2,9 @@ - + - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-100/air-conditioning-data-types.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-100/air-conditioning-data-types.dmn index 7da208f1de0..b2c211d236a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-100/air-conditioning-data-types.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-100/air-conditioning-data-types.dmn @@ -1,5 +1,5 @@ - + number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-control.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-control.dmn index 480ced8e2ea..6d510e1f6fb 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-control.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-control.dmn @@ -1,7 +1,7 @@ - + - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-data-types.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-data-types.dmn index 7da208f1de0..b2c211d236a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-data-types.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/import-itemdef-101/air-conditioning-data-types.dmn @@ -1,5 +1,5 @@ - + number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/v1/20180731-pr1997.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/v1/20180731-pr1997.dmn index 60d66fd017b..254b6a5a9e3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/v1/20180731-pr1997.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/incrementalcompilation/v1/20180731-pr1997.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/comparablePeriod.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/comparablePeriod.dmn index 60215869c33..a8ae7504e47 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/comparablePeriod.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/comparablePeriod.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/numberRESTinLIST.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/numberRESTinLIST.dmn index 84c58419c6c..5dd905eadb5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/numberRESTinLIST.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/internal/utils/numberRESTinLIST.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invalid-variable-names.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invalid-variable-names.dmn index 45089eec591..3a3bcc87be9 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invalid-variable-names.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invalid-variable-names.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokeJavaReturnArray.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokeJavaReturnArray.dmn index 1071a3e8c18..91784eb3b20 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokeJavaReturnArray.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokeJavaReturnArray.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokingAFunctionOnALiteralContext.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokingAFunctionOnALiteralContext.dmn index 656b1542441..04fc4df4b37 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokingAFunctionOnALiteralContext.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/invokingAFunctionOnALiteralContext.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDef-dependency.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDef-dependency.dmn index 4e92eebadbe..4f57cd52055 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDef-dependency.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDef-dependency.dmn @@ -2,9 +2,9 @@ + xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/"> string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDefXmlns_model.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDefXmlns_model.dmn index 3dca7139692..f5635279f5b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDefXmlns_model.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/itemDefXmlns_model.dmn @@ -1,6 +1,6 @@ + xmlns:dmn="https://www.omg.org/spec/DMN/20230324/MODEL/"> string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javaPojoCharUtilDate.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javaPojoCharUtilDate.dmn index 2ec083c80bc..0d3a3db44d1 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javaPojoCharUtilDate.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javaPojoCharUtilDate.dmn @@ -1,5 +1,5 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/java_function_context.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/java_function_context.dmn index 434508584b3..b097340d61f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/java_function_context.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/java_function_context.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocInnerComposite.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocInnerComposite.dmn index 24e0cce5fb1..caac1080e86 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocInnerComposite.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocInnerComposite.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocSimple.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocSimple.dmn index 56569100868..b9c04b77841 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocSimple.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/javadocSimple.dmn @@ -1,4 +1,4 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/just_now.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/just_now.dmn index 06c8a617ea0..e5026bd7ae1 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/just_now.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/just_now.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/list_containment_DT.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/list_containment_DT.dmn index d5aeef5a6de..bb49300c4a6 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/list_containment_DT.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/list_containment_DT.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nestingFnDef.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nestingFnDef.dmn index bdeecaef825..84cad3bef35 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nestingFnDef.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nestingFnDef.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/noExpr.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/noExpr.dmn index 52d6617bb93..1aa9508a943 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/noExpr.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/noExpr.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notInvocable.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notInvocable.dmn index dc3111c8b57..661d9e6d915 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notInvocable.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notInvocable.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notypecheck/sqrtstring.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notypecheck/sqrtstring.dmn index fd3604ef971..4ff2c4e1683 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notypecheck/sqrtstring.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/notypecheck/sqrtstring.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nowGT1970.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nowGT1970.dmn index 203f9fd00ac..8f44c830b8e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nowGT1970.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nowGT1970.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/null_values.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/null_values.dmn index 742542aed38..123201c70b0 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/null_values.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/null_values.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nullrelation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nullrelation.dmn index 1da467b9648..dc5a4a57199 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nullrelation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/nullrelation.dmn @@ -3,8 +3,8 @@ xmlns:dc="http://www.omg.org/spec/DMN/20151101/DC" xmlns:di="http://www.omg.org/spec/DMN/20151101/DI" xmlns:dmndi="http://www.omg.org/spec/DMN/20151101/DMNDI" - xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" - xmlns:semantic="http://www.omg.org/spec/DMN/20180521/MODEL/" + xmlns:feel="https://www.omg.org/spec/DMN/20230324/FEEL/" + xmlns:semantic="https://www.omg.org/spec/DMN/20230324/MODEL/" xmlns:tc="http://www.omg.org/spec/DMN/20160719/testcase" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/out-of-order-items.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/out-of-order-items.dmn index 63b23b64026..31279892151 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/out-of-order-items.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/out-of-order-items.dmn @@ -17,10 +17,10 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/personInReq1.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/personInReq1.dmn index 6c6e5468d1c..c0f54389c61 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/personInReq1.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/personInReq1.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree.dmn index 4f50f4a1822..d35fe32ec52 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree_no_output.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree_no_output.dmn index 1167d936283..516a7516c28 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree_no_output.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml/KiePMMLNewTree_no_output.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml_function_context.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml_function_context.dmn index 7121e4b6931..774733f7f0c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml_function_context.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/pmml_function_context.dmn @@ -2,9 +2,9 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/questionmarkunarytest/qmarkMultivalue.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/questionmarkunarytest/qmarkMultivalue.dmn index 4b285d72a19..379575c03fc 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/questionmarkunarytest/qmarkMultivalue.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/questionmarkunarytest/qmarkMultivalue.dmn @@ -17,9 +17,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/relation_with_empty_cell.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/relation_with_empty_cell.dmn index 8363a5b520d..c0eb0f046fb 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/relation_with_empty_cell.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/relation_with_empty_cell.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/singletonlist_fuction_call.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/singletonlist_fuction_call.dmn index e1f242bf29f..5497b8ed95a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/singletonlist_fuction_call.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/singletonlist_fuction_call.dmn @@ -2,9 +2,9 @@ +xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/"> number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/strictMode.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/strictMode.dmn index 685cd007e08..d9a3bd00f4e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/strictMode.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/strictMode.dmn @@ -2,10 +2,10 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/NSEW.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/NSEW.dmn index 3112b9b61b4..8b8bc24502f 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/NSEW.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/NSEW.dmn @@ -1,4 +1,4 @@ - + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/OneOfEachType.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/OneOfEachType.dmn index b08363988a8..95b02885c95 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/OneOfEachType.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/OneOfEachType.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/Traffic Violation.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/Traffic Violation.dmn index 109d4689e12..b24fed0d258 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/Traffic Violation.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/Traffic Violation.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/a.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/a.dmn index a01314cd630..b0657264b13 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/a.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/a.dmn @@ -1,5 +1,5 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflict.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflict.dmn index 9f870d9073c..7f2cb95ea53 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflict.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflict.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictItemDef.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictItemDef.dmn index 63d25bb39c9..f3bd4062113 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictItemDef.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictItemDef.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictWithInputAndDecision.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictWithInputAndDecision.dmn index 93d2bbada47..db72bb1bb08 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictWithInputAndDecision.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/capitalLetterConflictWithInputAndDecision.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_imported.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_imported.dmn index f408e1172b5..093077c9f88 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_imported.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_imported.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_importing.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_importing.dmn index 901e24c34ae..330e1f3cec0 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_importing.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/class_importing.dmn @@ -1,7 +1,7 @@ - + - + string @@ -18,7 +18,7 @@ - + imported class.L1name + imported class.class.L2name + class.name diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collections.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collections.dmn index d7f95477f38..d5db53bfdb3 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collections.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collections.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collectionsPassTypedObject.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collectionsPassTypedObject.dmn index 994109f5e8a..79e4b413662 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collectionsPassTypedObject.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/collectionsPassTypedObject.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/duplicateName.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/duplicateName.dmn index 295a8fd3641..55c7f43e6a5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/duplicateName.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/duplicateName.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/fixInnerComposite.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/fixInnerComposite.dmn index 1d4b0195ef5..d56dced714c 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/fixInnerComposite.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/fixInnerComposite.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerComposite.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerComposite.dmn index 8a6363420ba..e790591bc3e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerComposite.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerComposite.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerCompositeCollection.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerCompositeCollection.dmn index 9146e328e0a..072944d26f6 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerCompositeCollection.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/innerCompositeCollection.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/inputAny.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/inputAny.dmn index 4f7bafbcde0..b37446dac63 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/inputAny.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/inputAny.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/javaKeywords.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/javaKeywords.dmn index beff850c68c..3b85f95ee89 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/javaKeywords.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/javaKeywords.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/listBasic.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/listBasic.dmn index a898a890279..d1d5ee9930d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/listBasic.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/listBasic.dmn @@ -1,4 +1,4 @@ - + number diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/nextDays.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/nextDays.dmn index b6476ce3157..a9c54cb0a08 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/nextDays.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/nextDays.dmn @@ -1,4 +1,4 @@ - + date diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/recursiveEmployee.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/recursiveEmployee.dmn index 78d05e0030e..ac7ac1f4acc 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/recursiveEmployee.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/recursiveEmployee.dmn @@ -1,5 +1,5 @@ - + string @@ -25,7 +25,7 @@ - + "reports to " + an Employee.manager.full name diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/shareTypeForInputAndOutput.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/shareTypeForInputAndOutput.dmn index e462dee991f..ced5531659a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/shareTypeForInputAndOutput.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/shareTypeForInputAndOutput.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfCol.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfCol.dmn index a1fb348fd03..140fd70ef25 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfCol.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfCol.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfColOfCol.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfColOfCol.dmn index a3c01ca8967..00013059ca5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfColOfCol.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelColOfColOfCol.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelCompositeCollection.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelCompositeCollection.dmn index ae1545921c0..b25c2ac9d57 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelCompositeCollection.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/stronglytyped/topLevelCompositeCollection.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/structure-containtment.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/structure-containtment.dmn index 19ee93f2a91..c21bfbe7f3a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/structure-containtment.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/structure-containtment.dmn @@ -1,5 +1,5 @@ - + tEmployee diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/test20180601.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/test20180601.dmn index 34bbd15764f..920f3f4b3a8 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/test20180601.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/test20180601.dmn @@ -2,9 +2,9 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/testHyphenInPropertyOfCollectionForAccessorMultiple.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/testHyphenInPropertyOfCollectionForAccessorMultiple.dmn index 9f4d653685f..cd7d37b9908 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/testHyphenInPropertyOfCollectionForAccessorMultiple.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/testHyphenInPropertyOfCollectionForAccessorMultiple.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/today_function_test.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/today_function_test.dmn index 4a87b332498..81d2db087f9 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/today_function_test.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/today_function_test.dmn @@ -2,10 +2,10 @@ + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType2.dmn index de4046275df..10585d7a5e2 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType2.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType3.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType3.dmn index 80f7ac0a01c..0dbe3f84373 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType3.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType3.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType4.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType4.dmn index 0a54329a9a8..5cd32905168 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType4.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/bkmWrongFnType4.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/circular3.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/circular3.dmn index 3cd4c876bb3..a520ed1c005 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/circular3.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/circular3.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType.dmn index bf8bf36fa44..ad0334e3d2a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType2.dmn index d5c52812e34..f8acef87f3e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType2.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType3.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType3.dmn index 273ff371017..8e28351b04e 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType3.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType3.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType4.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType4.dmn index 7f62a093571..a97e804c944 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType4.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType4.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType5.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType5.dmn index 3e0f0737a57..67c504f51a7 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType5.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType5.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType6.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType6.dmn index 3955afdec93..039e8882dbf 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType6.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType6.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType7.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType7.dmn index 71d949247ad..66564732edb 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType7.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/dsWrongFnType7.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType1.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType1.dmn index c895578d327..f7a210f044d 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType1.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType1.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType2.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType2.dmn index 1702948fc0c..79bdae3b6e5 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType2.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType2.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType3.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType3.dmn index 9abb069f759..98eb88cd7a8 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType3.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/typeref/wireGenFnType3.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/uniqueNoMatch.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/uniqueNoMatch.dmn index 495b7d46ce8..e619318dbba 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/uniqueNoMatch.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/uniqueNoMatch.dmn @@ -3,9 +3,9 @@ xmlns:activiti="http://activiti.org/schema/1.0/dmn" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" - xmlns:dmndi="http://www.omg.org/spec/DMN/20180521/DMNDI/" - xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" - xmlns:semantic="http://www.omg.org/spec/DMN/20180521/MODEL/" + xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" + xmlns:feel="https://www.omg.org/spec/DMN/20230324/FEEL/" + xmlns:semantic="https://www.omg.org/spec/DMN/20230324/MODEL/" exporter="dmn-js (https://demo.bpmn.io/dmn)" exporterVersion="6.2.1" id="decision-a2c4d313-1b0c-420e-a6b1-7956f9787ab8" diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/unknown_variable1.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/unknown_variable1.dmn index ded95f55bc0..14b0123b61a 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/unknown_variable1.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/unknown_variable1.dmn @@ -2,9 +2,9 @@ diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_app.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_app.dmn index bc9a2673e2e..4577cc5612b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_app.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_app.dmn @@ -1,7 +1,7 @@ - + - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_route.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_route.dmn index 4f3b24850c4..28c9dadcf43 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_route.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/wbcommonservicesbackend_route.dmn @@ -1,5 +1,5 @@ - + diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/weekday-on-date.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/weekday-on-date.dmn index 2ad348136b4..ede7a38562b 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/weekday-on-date.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/weekday-on-date.dmn @@ -2,9 +2,9 @@ + string diff --git a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/yearMonthDuration.dmn b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/yearMonthDuration.dmn index 267e5f09153..673980d2385 100644 --- a/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/yearMonthDuration.dmn +++ b/kie-dmn/kie-dmn-core/src/test/resources/org/kie/dmn/core/yearMonthDuration.dmn @@ -2,9 +2,9 @@ data() { { "(@\"13:20:00@Europe/Rome\").timezone", "Europe/Rome" , null}, { "(@\"13:20:00@Etc/UTC\").timezone", "Etc/UTC" , null}, { "(@\"13:20:00@Etc/GMT\").timezone", "Etc/GMT" , null}, + { "-duration( \"P2Y2M\" )", ComparablePeriod.parse( "-P2Y2M" ) , null}, // comparison operators { "duration( \"P1Y6M\" ) = duration( \"P1Y6M\" )", Boolean.TRUE , null}, @@ -94,6 +95,10 @@ public static Collection data() { { "duration( \"P1Y6M\" ) != null", Boolean.TRUE , null}, { "duration( \"P1Y6M\" ) > null", null , null}, { "duration( \"P1Y6M\" ) < null", null , null}, + { "-duration( \"P1Y6M\" ) = (duration( \"P1Y6M\" )*-1) ", Boolean.TRUE , null}, + { "-duration( \"P1Y8M\" ) < duration( \"P1Y6M\" )", Boolean.TRUE , null}, + { "-duration( \"P1Y8M\" ) < -duration( \"P1Y6M\" )", Boolean.TRUE , null}, + { "-duration( \"P1Y6M\" ) > -duration( \"P1Y8M\" )", Boolean.TRUE , null}, {"time(\"10:30:00@Europe/Rome\") = time(\"10:30:00@Europe/Rome\")", Boolean.TRUE, null}, {"time(\"10:30:00@Europe/Rome\") = time(\"10:30:00@Europe/Paris\")", Boolean.TRUE, null}, {"is(time(\"10:30:00@Europe/Rome\"), time(\"10:30:00@Europe/Paris\"))", Boolean.FALSE, null}, @@ -165,8 +170,10 @@ public static Collection data() { { "duration( \"P1Y1M\" ) + date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of(2017, 8, 29, 5, 48, 23, 0) , null}, { "duration( \"P1DT1H1M\" ) + date and time(\"2016-07-29T05:48:23Z\")", ZonedDateTime.of(2016, 7, 30, 6, 49, 23, 0, ZoneId.of("Z").normalized()) , null}, { "duration( \"P1DT1H1M\" ) + date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of(2016, 7, 30, 6, 49, 23, 0) , null}, + { "-duration( \"P1DT1H1M\" ) + date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of(2016, 7, 28, 4, 47, 23, 0) , null}, { "time(\"22:57:00\") + duration( \"PT1H1M\" )", LocalTime.of(23, 58, 0) , null}, { "duration( \"PT1H1M\" ) + time(\"22:57:00\")", LocalTime.of(23, 58, 0) , null}, + { "-duration( \"PT1H1M\" ) + time(\"22:57:00\")", LocalTime.of(21, 56, 0) , null}, { "time( 22, 57, 00, duration(\"PT5H\")) + duration( \"PT1H1M\" )", OffsetTime.of( 23, 58, 0, 0, ZoneOffset.ofHours( 5 ) ) , null}, { "duration( \"PT1H1M\" ) + time( 22, 57, 00, duration(\"PT5H\"))", OffsetTime.of( 23, 58, 0, 0, ZoneOffset.ofHours( 5 ) ) , null}, @@ -186,11 +193,16 @@ public static Collection data() { { "date and time(\"2016-07-29T05:48:23\") - duration( \"P1DT1H1M\" )", LocalDateTime.of(2016, 7, 28, 4, 47, 23, 0) , null}, { "date(\"2016-07-29\") - duration( \"P1D\" )", LocalDate.of(2016, 7, 28) , null}, { "date(\"2016-07-29\") - duration( \"P1Y1M\" )", LocalDate.of(2015, 6, 29) , null}, + { "date(\"2016-07-29\") + (-duration( \"P1Y1M\" ))", LocalDate.of(2015, 6, 29) , null}, { "time(\"22:57:00\") - duration( \"PT1H1M\" )", LocalTime.of(21, 56, 0) , null}, { "time( 22, 57, 00, duration(\"PT5H\")) - duration( \"PT1H1M\" )", OffsetTime.of( 21, 56, 0, 0, ZoneOffset.ofHours( 5 ) ) , null}, + { "duration( \"P2Y2M\" ) - (-duration( \"P1Y1M\" ))", ComparablePeriod.parse("P3Y3M"), null }, + { "-duration( \"P2Y2M\" ) + duration( \"P1Y1M\" )", ComparablePeriod.parse("-P1Y1M"), null }, { "duration( \"P2Y2M\" ) * 2", ComparablePeriod.parse("P52M"), null }, { "2 * duration( \"P2Y2M\" )", ComparablePeriod.parse("P52M"), null }, + { "-duration( \"P2Y2M\" ) * 2", ComparablePeriod.parse("-P52M"), null }, + { "2 * -duration( \"P2Y2M\" )", ComparablePeriod.parse("-P52M"), null }, { "duration( \"P2Y2M\" ) * duration( \"P2Y2M\" )", null , FEELEvent.Severity.ERROR}, { "duration( \"P2DT20H14M\" ) * 2", Duration.parse( "P4DT40H28M" ) , null}, { "2 * duration( \"P2DT20H14M\" )", Duration.parse( "P4DT40H28M" ) , null}, diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/ItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/ItemDefinition.java index 6c8774399e2..de498f77eee 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/ItemDefinition.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/ItemDefinition.java @@ -38,6 +38,10 @@ public interface ItemDefinition extends NamedElement { void setAllowedValues(UnaryTests value); + UnaryTests getTypeConstraint(); + + void setTypeConstraint(UnaryTests value); + List getItemComponent(); String getTypeLanguage(); diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/dmndi/DMNDiagram.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/dmndi/DMNDiagram.java index c6072e5a397..80160ddf1cc 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/dmndi/DMNDiagram.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/api/dmndi/DMNDiagram.java @@ -23,10 +23,13 @@ public interface DMNDiagram extends Diagram { - public Dimension getSize(); + Dimension getSize(); - public void setSize(Dimension value); + void setSize(Dimension value); - public List getDMNDiagramElement(); + List getDMNDiagramElement(); + Boolean getUseAlternativeInputDataShape(); + + void setUseAlternativeInputDataShape(Boolean value); } diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TItemDefinition.java index 9ca8d6664a0..a017354d89b 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TItemDefinition.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TItemDefinition.java @@ -56,6 +56,16 @@ public void setAllowedValues(final UnaryTests value) { this.allowedValues = value; } + @Override + public UnaryTests getTypeConstraint() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setTypeConstraint(UnaryTests value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + @Override public List getItemComponent() { return this.itemComponent; diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TItemDefinition.java index 2f584fda419..899ca184203 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TItemDefinition.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TItemDefinition.java @@ -58,6 +58,16 @@ public void setAllowedValues(UnaryTests value) { this.allowedValues = value; } + @Override + public UnaryTests getTypeConstraint() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setTypeConstraint(UnaryTests value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + @Override public List getItemComponent() { if (itemComponent == null) { diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java index 5afed613ea2..2de314d38e0 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java @@ -83,4 +83,14 @@ public List getDMNDiagramElement() { return this.dmnDiagramElement; } + @Override + public Boolean getUseAlternativeInputDataShape() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setUseAlternativeInputDataShape(Boolean value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + } diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/TItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/TItemDefinition.java index 06c02feee28..347847b2597 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/TItemDefinition.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/TItemDefinition.java @@ -59,6 +59,16 @@ public void setAllowedValues(UnaryTests value) { this.allowedValues = value; } + @Override + public UnaryTests getTypeConstraint() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setTypeConstraint(UnaryTests value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + @Override public List getItemComponent() { if (itemComponent == null) { diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/dmndi/DMNDiagram.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/dmndi/DMNDiagram.java index 56c12fed1f6..375435be744 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/dmndi/DMNDiagram.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_3/dmndi/DMNDiagram.java @@ -83,4 +83,14 @@ public List getDMNDiagramElement() { return this.dmnDiagramElement; } + @Override + public Boolean getUseAlternativeInputDataShape() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setUseAlternativeInputDataShape(Boolean value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + } diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_4/TItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_4/TItemDefinition.java index c3d11455279..1e414aa0768 100644 --- a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_4/TItemDefinition.java +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_4/TItemDefinition.java @@ -59,6 +59,16 @@ public void setAllowedValues(UnaryTests value) { this.allowedValues = value; } + @Override + public UnaryTests getTypeConstraint() { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + + @Override + public void setTypeConstraint(UnaryTests value) { + throw new UnsupportedOperationException("Since DMNv1.5"); + } + @Override public List getItemComponent() { if (itemComponent == null) { diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/KieDMNModelInstrumentedBase.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/KieDMNModelInstrumentedBase.java new file mode 100644 index 00000000000..eb71defa15d --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/KieDMNModelInstrumentedBase.java @@ -0,0 +1,159 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNModelInstrumentedBase; +import org.kie.dmn.model.api.RowLocation; + +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public abstract class KieDMNModelInstrumentedBase implements DMNModelInstrumentedBase { + + public static final String URI_DMN = "https://www.omg.org/spec/DMN/20230324/MODEL/"; + public static final String URI_FEEL = "https://www.omg.org/spec/DMN/20230324/FEEL/"; + + public static final String URI_KIE = "https://www.drools.org/kie/dmn/1.5"; + public static final String URI_DMNDI = "https://www.omg.org/spec/DMN/20230324/DMNDI/"; + public static final String URI_DI = "http://www.omg.org/spec/DMN/20180521/DI/"; + public static final String URI_DC = "http://www.omg.org/spec/DMN/20180521/DC/"; + + private Map nsContext; + + private DMNModelInstrumentedBase parent; + private final List children = new ArrayList<>(); + private Location location; + private Map additionalAttributes = new HashMap<>(); + + public String getIdentifierString() { + if( this instanceof TNamedElement && ((TNamedElement)this).getName() != null ) { + return ((TNamedElement)this).getName(); + } else if( this instanceof TDMNElement && ((TDMNElement)this).getId() != null ) { + return ((TDMNElement)this).getId(); + } else { + return "[unnamed "+getClass().getSimpleName()+"]"; + } + } + + public DMNModelInstrumentedBase getParentDRDElement() { + if( this instanceof TDRGElement + || (this instanceof TArtifact) + || (this instanceof TItemDefinition && parent != null && parent instanceof TDefinitions)) { + return this; + } else if( parent != null ) { + return parent.getParentDRDElement(); + } else { + return null; + } + } + + @Override + public Map getNsContext() { + if (nsContext == null) { + nsContext = new HashMap<>(); + } + return nsContext; + } + + @Override + public String getNamespaceURI( String prefix ) { + if( this.nsContext != null && this.nsContext.containsKey( prefix ) ) { + return this.nsContext.get( prefix ); + } + if( this.parent != null ) { + return parent.getNamespaceURI( prefix ); + } + return null; + } + + public Optional getPrefixForNamespaceURI( String namespaceURI ) { + if( this.nsContext != null && this.nsContext.containsValue(namespaceURI) ) { + return this.nsContext.entrySet().stream().filter(kv -> kv.getValue().equals(namespaceURI)).findFirst().map(Map.Entry::getKey); + } + if( this.parent != null ) { + return parent.getPrefixForNamespaceURI( namespaceURI ); + } + return Optional.empty(); + } + + public void setAdditionalAttributes(Map additionalAttributes) { + this.additionalAttributes = additionalAttributes; + } + + public Map getAdditionalAttributes() { + return additionalAttributes; + } + + public DMNModelInstrumentedBase getParent() { + return parent; + } + + public void setParent(DMNModelInstrumentedBase parent) { + this.parent = parent; + } + + /* + * children element references are populated during deserialization, enabling fast access for Validation. + */ + public List getChildren() { + return Collections.unmodifiableList(children); + } + + public void addChildren(DMNModelInstrumentedBase child) { + this.children.add(child); + } + + @Override + public void setLocation(Location location) { + this.location = new RowLocation(location); + } + + /** + * Returns an approximated location of the XML origin for this DMN Model node. + */ + @Override + public Location getLocation() { + return location; + } + + @Override + public String getURIFEEL() { + return URI_FEEL; + } + + @Override + public List findAllChildren(Class clazz) { + if (clazz.isInstance(this)) { + T obj = (T) this; + return Collections.singletonList(obj); + } + List results = new ArrayList<>(); + for (DMNModelInstrumentedBase c : getChildren()) { + results.addAll(c.findAllChildren(clazz)); + } + return results; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TArtifact.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TArtifact.java new file mode 100644 index 00000000000..ff9a92b7f34 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TArtifact.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Artifact; + +public class TArtifact extends TDMNElement implements Artifact { + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAssociation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAssociation.java new file mode 100644 index 00000000000..903186e701b --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAssociation.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Association; +import org.kie.dmn.model.api.AssociationDirection; +import org.kie.dmn.model.api.DMNElementReference; + +public class TAssociation extends TArtifact implements Association { + + protected DMNElementReference sourceRef; + protected DMNElementReference targetRef; + protected AssociationDirection associationDirection; + + @Override + public DMNElementReference getSourceRef() { + return sourceRef; + } + + @Override + public void setSourceRef(DMNElementReference value) { + this.sourceRef = value; + } + + @Override + public DMNElementReference getTargetRef() { + return targetRef; + } + + @Override + public void setTargetRef(DMNElementReference value) { + this.targetRef = value; + } + + @Override + public AssociationDirection getAssociationDirection() { + if (associationDirection == null) { + return AssociationDirection.NONE; + } else { + return associationDirection; + } + } + + @Override + public void setAssociationDirection(AssociationDirection value) { + this.associationDirection = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAuthorityRequirement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAuthorityRequirement.java new file mode 100644 index 00000000000..d9fc621f410 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TAuthorityRequirement.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; + +public class TAuthorityRequirement extends TDMNElement implements AuthorityRequirement { + + protected DMNElementReference requiredDecision; + protected DMNElementReference requiredInput; + protected DMNElementReference requiredAuthority; + + @Override + public DMNElementReference getRequiredDecision() { + return requiredDecision; + } + + @Override + public void setRequiredDecision(DMNElementReference value) { + this.requiredDecision = value; + } + + @Override + public DMNElementReference getRequiredInput() { + return requiredInput; + } + + @Override + public void setRequiredInput(DMNElementReference value) { + this.requiredInput = value; + } + + @Override + public DMNElementReference getRequiredAuthority() { + return requiredAuthority; + } + + @Override + public void setRequiredAuthority(DMNElementReference value) { + this.requiredAuthority = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBinding.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBinding.java new file mode 100644 index 00000000000..d081ed16cb9 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBinding.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Binding; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; + +public class TBinding extends KieDMNModelInstrumentedBase implements Binding { + + protected InformationItem parameter; + protected Expression expression; + + @Override + public InformationItem getParameter() { + return parameter; + } + + @Override + public void setParameter(InformationItem value) { + this.parameter = value; + } + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessContextElement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessContextElement.java new file mode 100644 index 00000000000..a26fd7421d5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessContextElement.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.BusinessContextElement; + +public class TBusinessContextElement extends TNamedElement implements BusinessContextElement { + + protected String uri; + + @Override + public String getURI() { + return uri; + } + + @Override + public void setURI(String value) { + this.uri = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessKnowledgeModel.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessKnowledgeModel.java new file mode 100644 index 00000000000..5ef0836398f --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TBusinessKnowledgeModel.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.BusinessKnowledgeModel; +import org.kie.dmn.model.api.FunctionDefinition; +import org.kie.dmn.model.api.KnowledgeRequirement; + +import java.util.ArrayList; +import java.util.List; + +public class TBusinessKnowledgeModel extends TInvocable implements BusinessKnowledgeModel { + + protected FunctionDefinition encapsulatedLogic; + protected List knowledgeRequirement; + protected List authorityRequirement; + + @Override + public FunctionDefinition getEncapsulatedLogic() { + return encapsulatedLogic; + } + + @Override + public void setEncapsulatedLogic(FunctionDefinition value) { + this.encapsulatedLogic = value; + } + + @Override + public List getKnowledgeRequirement() { + if (knowledgeRequirement == null) { + knowledgeRequirement = new ArrayList<>(); + } + return this.knowledgeRequirement; + } + + @Override + public List getAuthorityRequirement() { + if (authorityRequirement == null) { + authorityRequirement = new ArrayList<>(); + } + return this.authorityRequirement; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TChildExpression.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TChildExpression.java new file mode 100644 index 00000000000..62566352106 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TChildExpression.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Expression; + +public class TChildExpression extends KieDMNModelInstrumentedBase implements ChildExpression { + + protected Expression expression; + + protected String id; + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + + public String getId() { + return id; + } + + public void setId(String value) { + this.id = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TConditional.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TConditional.java new file mode 100644 index 00000000000..a727ec9bf10 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TConditional.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Conditional; + +public class TConditional extends TExpression implements Conditional { + + private ChildExpression ifExp; + private ChildExpression thenExp; + private ChildExpression elseExp; + + @Override + public ChildExpression getIf() { + return ifExp; + } + + @Override + public ChildExpression getThen() { + return thenExp; + } + + @Override + public ChildExpression getElse() { + return elseExp; + } + + @Override + public void setIf(ChildExpression value) { + this.ifExp = value; + } + + @Override + public void setThen(ChildExpression value) { + this.thenExp = value; + } + + @Override + public void setElse(ChildExpression value) { + this.elseExp = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContext.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContext.java new file mode 100644 index 00000000000..6a7e3ec0c82 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContext.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Context; +import org.kie.dmn.model.api.ContextEntry; + +import java.util.ArrayList; +import java.util.List; + +public class TContext extends TExpression implements Context { + + protected List contextEntry; + + @Override + public List getContextEntry() { + if (contextEntry == null) { + contextEntry = new ArrayList<>(); + } + return this.contextEntry; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContextEntry.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContextEntry.java new file mode 100644 index 00000000000..0fc35af26ff --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TContextEntry.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ContextEntry; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; + +public class TContextEntry extends TDMNElement implements ContextEntry { + + protected InformationItem variable; + protected Expression expression; + + @Override + public InformationItem getVariable() { + return variable; + } + + @Override + public void setVariable(InformationItem value) { + this.variable = value; + } + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElement.java new file mode 100644 index 00000000000..3b658e185ec --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElement.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElement; + +import java.util.ArrayList; +import java.util.List; + +public class TDMNElement extends KieDMNModelInstrumentedBase implements DMNElement { + + protected String description; + protected ExtensionElements extensionElements; + protected String id; + protected String label; + + @Override + public String getDescription() { + return description; + } + + @Override + public void setDescription(String value) { + this.description = value; + } + + @Override + public ExtensionElements getExtensionElements() { + return extensionElements; + } + + @Override + public void setExtensionElements(ExtensionElements value) { + this.extensionElements = value; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String value) { + this.id = value; + } + + @Override + public String getLabel() { + return label; + } + + @Override + public void setLabel(String value) { + this.label = value; + } + + public static class TExtensionElements extends KieDMNModelInstrumentedBase implements ExtensionElements { + + protected List any; + + @Override + public List getAny() { + if (any == null) { + any = new ArrayList<>(); + } + return this.any; + } + + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElementReference.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElementReference.java new file mode 100644 index 00000000000..8949c60eda3 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDMNElementReference.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; + +public class TDMNElementReference extends KieDMNModelInstrumentedBase implements DMNElementReference { + + private String href; + + @Override + public String getHref() { + return href; + } + + @Override + public void setHref(String value) { + this.href = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDRGElement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDRGElement.java new file mode 100644 index 00000000000..fb04559c85a --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDRGElement.java @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DRGElement; + +public class TDRGElement extends TNamedElement implements DRGElement { + + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecision.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecision.java new file mode 100644 index 00000000000..5042b9ab27d --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecision.java @@ -0,0 +1,160 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.Decision; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.InformationRequirement; +import org.kie.dmn.model.api.KnowledgeRequirement; + +import java.util.ArrayList; +import java.util.List; + +public class TDecision extends TDRGElement implements Decision { + + protected String question; + protected String allowedAnswers; + protected InformationItem variable; + protected List informationRequirement; + protected List knowledgeRequirement; + protected List authorityRequirement; + protected List supportedObjective; + protected List impactedPerformanceIndicator; + protected List decisionMaker; + protected List decisionOwner; + protected List usingProcess; + protected List usingTask; + protected Expression expression; + + @Override + public String getQuestion() { + return question; + } + + @Override + public void setQuestion(String value) { + this.question = value; + } + + @Override + public String getAllowedAnswers() { + return allowedAnswers; + } + + @Override + public void setAllowedAnswers(String value) { + this.allowedAnswers = value; + } + + @Override + public InformationItem getVariable() { + return variable; + } + + @Override + public void setVariable(InformationItem value) { + this.variable = value; + } + + @Override + public List getInformationRequirement() { + if (informationRequirement == null) { + informationRequirement = new ArrayList<>(); + } + return this.informationRequirement; + } + + @Override + public List getKnowledgeRequirement() { + if (knowledgeRequirement == null) { + knowledgeRequirement = new ArrayList<>(); + } + return this.knowledgeRequirement; + } + + @Override + public List getAuthorityRequirement() { + if (authorityRequirement == null) { + authorityRequirement = new ArrayList<>(); + } + return this.authorityRequirement; + } + + @Override + public List getSupportedObjective() { + if (supportedObjective == null) { + supportedObjective = new ArrayList<>(); + } + return this.supportedObjective; + } + + @Override + public List getImpactedPerformanceIndicator() { + if (impactedPerformanceIndicator == null) { + impactedPerformanceIndicator = new ArrayList<>(); + } + return this.impactedPerformanceIndicator; + } + + @Override + public List getDecisionMaker() { + if (decisionMaker == null) { + decisionMaker = new ArrayList<>(); + } + return this.decisionMaker; + } + + @Override + public List getDecisionOwner() { + if (decisionOwner == null) { + decisionOwner = new ArrayList<>(); + } + return this.decisionOwner; + } + + @Override + public List getUsingProcess() { + if (usingProcess == null) { + usingProcess = new ArrayList<>(); + } + return this.usingProcess; + } + + @Override + public List getUsingTask() { + if (usingTask == null) { + usingTask = new ArrayList<>(); + } + return this.usingTask; + } + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionRule.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionRule.java new file mode 100644 index 00000000000..3d975962203 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionRule.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DecisionRule; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.RuleAnnotation; +import org.kie.dmn.model.api.UnaryTests; + +import java.util.ArrayList; +import java.util.List; + +public class TDecisionRule extends TDMNElement implements DecisionRule { + + protected List inputEntry; + protected List outputEntry; + protected List annotationEntry; + + @Override + public List getInputEntry() { + if (inputEntry == null) { + inputEntry = new ArrayList<>(); + } + return this.inputEntry; + } + + @Override + public List getOutputEntry() { + if (outputEntry == null) { + outputEntry = new ArrayList<>(); + } + return this.outputEntry; + } + + @Override + public List getAnnotationEntry() { + if (annotationEntry == null) { + annotationEntry = new ArrayList<>(); + } + return this.annotationEntry; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionService.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionService.java new file mode 100644 index 00000000000..0d43b534a1c --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionService.java @@ -0,0 +1,66 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.DecisionService; + +import java.util.ArrayList; +import java.util.List; + +public class TDecisionService extends TInvocable implements DecisionService { + + protected List outputDecision; + protected List encapsulatedDecision; + protected List inputDecision; + protected List inputData; + + @Override + public List getOutputDecision() { + if (outputDecision == null) { + outputDecision = new ArrayList<>(); + } + return this.outputDecision; + } + + @Override + public List getEncapsulatedDecision() { + if (encapsulatedDecision == null) { + encapsulatedDecision = new ArrayList<>(); + } + return this.encapsulatedDecision; + } + + @Override + public List getInputDecision() { + if (inputDecision == null) { + inputDecision = new ArrayList<>(); + } + return this.inputDecision; + } + + @Override + public List getInputData() { + if (inputData == null) { + inputData = new ArrayList<>(); + } + return this.inputData; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTable.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTable.java new file mode 100644 index 00000000000..01bee2bd5a5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTable.java @@ -0,0 +1,124 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.BuiltinAggregator; +import org.kie.dmn.model.api.DecisionRule; +import org.kie.dmn.model.api.DecisionTable; +import org.kie.dmn.model.api.DecisionTableOrientation; +import org.kie.dmn.model.api.HitPolicy; +import org.kie.dmn.model.api.InputClause; +import org.kie.dmn.model.api.OutputClause; +import org.kie.dmn.model.api.RuleAnnotationClause; + +import java.util.ArrayList; +import java.util.List; + +public class TDecisionTable extends TExpression implements DecisionTable { + + protected List input; + protected List output; + protected List annotation; + protected List rule; + protected HitPolicy hitPolicy; + protected BuiltinAggregator aggregation; + protected DecisionTableOrientation preferredOrientation; + protected String outputLabel; + + @Override + public List getInput() { + if (input == null) { + input = new ArrayList<>(); + } + return this.input; + } + + @Override + public List getOutput() { + if (output == null) { + output = new ArrayList<>(); + } + return this.output; + } + + @Override + public List getAnnotation() { + if (annotation == null) { + annotation = new ArrayList<>(); + } + return this.annotation; + } + + @Override + public List getRule() { + if (rule == null) { + rule = new ArrayList<>(); + } + return this.rule; + } + + @Override + public HitPolicy getHitPolicy() { + if (hitPolicy == null) { + return HitPolicy.UNIQUE; + } else { + return hitPolicy; + } + } + + @Override + public void setHitPolicy(HitPolicy value) { + this.hitPolicy = value; + } + + @Override + public BuiltinAggregator getAggregation() { + return aggregation; + } + + @Override + public void setAggregation(BuiltinAggregator value) { + this.aggregation = value; + } + + @Override + public DecisionTableOrientation getPreferredOrientation() { + if (preferredOrientation == null) { + return DecisionTableOrientation.RULE_AS_ROW; + } else { + return preferredOrientation; + } + } + + @Override + public void setPreferredOrientation(DecisionTableOrientation value) { + this.preferredOrientation = value; + } + + @Override + public String getOutputLabel() { + return outputLabel; + } + + @Override + public void setOutputLabel(String value) { + this.outputLabel = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTableOrientation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTableOrientation.java new file mode 100644 index 00000000000..e748f3ca136 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDecisionTableOrientation.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +public enum TDecisionTableOrientation { + + RULE_AS_ROW("Rule-as-Row"), + RULE_AS_COLUMN("Rule-as-Column"), + CROSS_TABLE("CrossTable"); + private final String value; + + TDecisionTableOrientation(String v) { + value = v; + } + + public String value() { + return value; + } + + public static TDecisionTableOrientation fromValue(String v) { + for (TDecisionTableOrientation c: TDecisionTableOrientation.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDefinitions.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDefinitions.java new file mode 100644 index 00000000000..ea108d1b44e --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TDefinitions.java @@ -0,0 +1,196 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Artifact; +import org.kie.dmn.model.api.BusinessContextElement; +import org.kie.dmn.model.api.DRGElement; +import org.kie.dmn.model.api.DecisionService; +import org.kie.dmn.model.api.Definitions; +import org.kie.dmn.model.api.ElementCollection; +import org.kie.dmn.model.api.Import; +import org.kie.dmn.model.api.ItemDefinition; +import org.kie.dmn.model.api.dmndi.DMNDI; + +import javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class TDefinitions extends TNamedElement implements Definitions { + + public static final String DEFAULT_EXPRESSION_LANGUAGE = URI_FEEL; + + public static final String DEFAULT_TYPE_LANGUAGE = URI_FEEL; + + protected List _import; + protected List itemDefinition; + protected List drgElement; + protected List artifact; + protected List elementCollection; + protected List businessContextElement; + protected DMNDI dmndi; + protected String expressionLanguage; + protected String typeLanguage; + protected String namespace; + protected String exporter; + protected String exporterVersion; + + @Override + public List getImport() { + if (_import == null) { + _import = new ArrayList<>(); + } + return this._import; + } + + @Override + public List getItemDefinition() { + if (itemDefinition == null) { + itemDefinition = new ArrayList<>(); + } + return this.itemDefinition; + } + + @Override + public List getDrgElement() { + if (drgElement == null) { + drgElement = new ArrayList<>(); + } + return this.drgElement; + } + + @Override + public List getArtifact() { + if (artifact == null) { + artifact = new ArrayList<>(); + } + return this.artifact; + } + + @Override + public List getElementCollection() { + if (elementCollection == null) { + elementCollection = new ArrayList<>(); + } + return this.elementCollection; + } + + @Override + public List getBusinessContextElement() { + if (businessContextElement == null) { + businessContextElement = new ArrayList<>(); + } + return this.businessContextElement; + } + + @Override + public DMNDI getDMNDI() { + return dmndi; + } + + @Override + public void setDMNDI(DMNDI value) { + this.dmndi = value; + } + + @Override + public String getExpressionLanguage() { + if (expressionLanguage == null) { + return DEFAULT_EXPRESSION_LANGUAGE; + } else { + return expressionLanguage; + } + } + + @Override + public String getTypeLanguage() { + if (typeLanguage == null) { + return DEFAULT_TYPE_LANGUAGE; + } else { + return typeLanguage; + } + } + + @Override + public void setExpressionLanguage(String value) { + this.expressionLanguage = value; + } + + @Override + public void setTypeLanguage(String value) { + this.typeLanguage = value; + } + + @Override + public String getNamespace() { + return namespace; + } + + @Override + public void setNamespace(String value) { + this.namespace = value; + } + + @Override + public String getExporter() { + return exporter; + } + + @Override + public void setExporter(String value) { + this.exporter = value; + } + + @Override + public String getExporterVersion() { + return exporterVersion; + } + + @Override + public void setExporterVersion(String value) { + this.exporterVersion = value; + } + + /** + * Implementing support for internal model + */ + @Override + public List getDecisionService() { + return drgElement.stream().filter(DecisionService.class::isInstance).map(DecisionService.class::cast).collect(Collectors.toList()); + } + + public void normalize() { + for (ItemDefinition itemDefinition : this.getItemDefinition()) { + processQNameURIs(itemDefinition); + } + } + + private static void processQNameURIs(ItemDefinition iDef) { + final QName typeRef = iDef.getTypeRef(); + if (typeRef != null && XMLConstants.NULL_NS_URI.equals(typeRef.getNamespaceURI())) { + final String namespace = iDef.getNamespaceURI(typeRef.getPrefix()); + iDef.setTypeRef(new QName(namespace, typeRef.getLocalPart(), typeRef.getPrefix())); + } + for (ItemDefinition comp : iDef.getItemComponent()) { + processQNameURIs(comp); + } + } +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TElementCollection.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TElementCollection.java new file mode 100644 index 00000000000..fa3b7ae60f5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TElementCollection.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.ElementCollection; + +import java.util.ArrayList; +import java.util.List; + +public class TElementCollection extends TNamedElement implements ElementCollection { + + protected List drgElement; + + @Override + public List getDrgElement() { + if (drgElement == null) { + drgElement = new ArrayList<>(); + } + return this.drgElement; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TEvery.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TEvery.java new file mode 100644 index 00000000000..473bb73e147 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TEvery.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Every; + +public class TEvery extends TQuantified implements Every { + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TExpression.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TExpression.java new file mode 100644 index 00000000000..1e9584bf337 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TExpression.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Expression; + +import javax.xml.namespace.QName; + +public class TExpression extends TDMNElement implements Expression { + + /** + * align with internal model + */ + protected QName typeRef; + + @Override + public QName getTypeRef() { + return this.typeRef; + } + + @Override + public void setTypeRef(QName value) { + this.typeRef = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFilter.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFilter.java new file mode 100644 index 00000000000..3c0a9efbb30 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFilter.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Filter; + +public class TFilter extends TExpression implements Filter { + + private ChildExpression in; + private ChildExpression match; + + @Override + public ChildExpression getIn() { + return in; + } + + @Override + public ChildExpression getMatch() { + return match; + } + + @Override + public void setIn(ChildExpression value) { + this.in = value; + } + + @Override + public void setMatch(ChildExpression value) { + this.match = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFor.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFor.java new file mode 100644 index 00000000000..1c4a7dd3e0c --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFor.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.For; + +public class TFor extends TIterator implements For { + + protected ChildExpression _return; + + public ChildExpression getReturn() { + return _return; + } + + public void setReturn(ChildExpression value) { + this._return = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionDefinition.java new file mode 100644 index 00000000000..7bb5caa5773 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionDefinition.java @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.FunctionDefinition; +import org.kie.dmn.model.api.FunctionKind; +import org.kie.dmn.model.api.InformationItem; + +import java.util.ArrayList; +import java.util.List; + +public class TFunctionDefinition extends TExpression implements FunctionDefinition { + + protected List formalParameter; + protected Expression expression; + protected FunctionKind kind; + + @Override + public List getFormalParameter() { + if (formalParameter == null) { + formalParameter = new ArrayList<>(); + } + return this.formalParameter; + } + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + + @Override + public FunctionKind getKind() { + if (kind == null) { + return FunctionKind.FEEL; + } else { + return kind; + } + } + + @Override + public void setKind(FunctionKind value) { + this.kind = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionItem.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionItem.java new file mode 100644 index 00000000000..65608b455a8 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TFunctionItem.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.FunctionItem; +import org.kie.dmn.model.api.InformationItem; + +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; + +public class TFunctionItem extends TDMNElement implements FunctionItem { + + protected List parameters; + protected QName outputTypeRef; + + @Override + public List getParameters() { + if (parameters == null) { + parameters = new ArrayList<>(); + } + return this.parameters; + } + + @Override + public QName getOutputTypeRef() { + return outputTypeRef; + } + + @Override + public void setOutputTypeRef(QName value) { + this.outputTypeRef = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TGroup.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TGroup.java new file mode 100644 index 00000000000..5247a94c960 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TGroup.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Group; + +public class TGroup extends TArtifact implements Group { + + protected String name; + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String value) { + this.name = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImport.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImport.java new file mode 100644 index 00000000000..a869dc8a57f --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImport.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Import; + +public class TImport extends TNamedElement implements Import { + + protected String namespace; + protected String locationURI; + protected String importType; + + @Override + public String getNamespace() { + return namespace; + } + + @Override + public void setNamespace(String value) { + this.namespace = value; + } + + @Override + public String getLocationURI() { + return locationURI; + } + + @Override + public void setLocationURI(String value) { + this.locationURI = value; + } + + @Override + public String getImportType() { + return importType; + } + + @Override + public void setImportType(String value) { + this.importType = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImportedValues.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImportedValues.java new file mode 100644 index 00000000000..166901e4a0f --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TImportedValues.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ImportedValues; + +public class TImportedValues extends TImport implements ImportedValues { + + protected String importedElement; + protected String expressionLanguage; + + @Override + public String getImportedElement() { + return importedElement; + } + + @Override + public void setImportedElement(String value) { + this.importedElement = value; + } + + @Override + public String getExpressionLanguage() { + return expressionLanguage; + } + + @Override + public void setExpressionLanguage(String value) { + this.expressionLanguage = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationItem.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationItem.java new file mode 100644 index 00000000000..514128bb3d2 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationItem.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.InformationItem; + +import javax.xml.namespace.QName; + +public class TInformationItem extends TNamedElement implements InformationItem { + + protected QName typeRef; + + @Override + public QName getTypeRef() { + return this.typeRef; + } + + @Override + public void setTypeRef(QName value) { + this.typeRef = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationRequirement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationRequirement.java new file mode 100644 index 00000000000..96edf27b0fe --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInformationRequirement.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.InformationRequirement; + +public class TInformationRequirement extends TDMNElement implements InformationRequirement { + + protected DMNElementReference requiredDecision; + protected DMNElementReference requiredInput; + + @Override + public DMNElementReference getRequiredDecision() { + return requiredDecision; + } + + @Override + public void setRequiredDecision(DMNElementReference value) { + this.requiredDecision = value; + } + + @Override + public DMNElementReference getRequiredInput() { + return requiredInput; + } + + @Override + public void setRequiredInput(DMNElementReference value) { + this.requiredInput = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputClause.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputClause.java new file mode 100644 index 00000000000..98037307685 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputClause.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.InputClause; +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.UnaryTests; + +public class TInputClause extends TDMNElement implements InputClause { + + protected LiteralExpression inputExpression; + protected UnaryTests inputValues; + + @Override + public LiteralExpression getInputExpression() { + return inputExpression; + } + + @Override + public void setInputExpression(LiteralExpression value) { + this.inputExpression = value; + } + + @Override + public UnaryTests getInputValues() { + return inputValues; + } + + @Override + public void setInputValues(UnaryTests value) { + this.inputValues = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputData.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputData.java new file mode 100644 index 00000000000..b037b94f70d --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInputData.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.InputData; + +public class TInputData extends TDRGElement implements InputData { + + protected InformationItem variable; + + @Override + public InformationItem getVariable() { + return variable; + } + + @Override + public void setVariable(InformationItem value) { + this.variable = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocable.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocable.java new file mode 100644 index 00000000000..7f5962857ec --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocable.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.Invocable; + +public class TInvocable extends TDRGElement implements Invocable { + + protected InformationItem variable; + + @Override + public InformationItem getVariable() { + return variable; + } + + @Override + public void setVariable(InformationItem value) { + this.variable = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocation.java new file mode 100644 index 00000000000..608f9507066 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TInvocation.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Binding; +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.Invocation; + +import java.util.ArrayList; +import java.util.List; + +public class TInvocation extends TExpression implements Invocation { + + protected Expression expression; + protected List binding; + + @Override + public Expression getExpression() { + return expression; + } + + @Override + public void setExpression(Expression value) { + this.expression = value; + } + + @Override + public List getBinding() { + if (binding == null) { + binding = new ArrayList<>(); + } + return this.binding; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TItemDefinition.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TItemDefinition.java new file mode 100644 index 00000000000..8c8a61139b3 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TItemDefinition.java @@ -0,0 +1,113 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.FunctionItem; +import org.kie.dmn.model.api.ItemDefinition; +import org.kie.dmn.model.api.UnaryTests; + +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; + +public class TItemDefinition extends TNamedElement implements ItemDefinition { + + /** + * align to internal model + */ + protected QName typeRef; + protected UnaryTests allowedValues; + protected UnaryTests typeConstraint; + protected List itemComponent; + protected FunctionItem functionItem; + protected String typeLanguage; + protected Boolean isCollection; + + @Override + public QName getTypeRef() { + return typeRef; + } + + @Override + public void setTypeRef(final QName value) { + this.typeRef = value; + } + + @Override + public UnaryTests getAllowedValues() { + return allowedValues; + } + + @Override + public void setAllowedValues(UnaryTests value) { + this.allowedValues = value; + } + + @Override + public UnaryTests getTypeConstraint() { + return typeConstraint; + } + + @Override + public void setTypeConstraint(UnaryTests value) { + this.typeConstraint = value; + } + + @Override + public List getItemComponent() { + if (itemComponent == null) { + itemComponent = new ArrayList<>(); + } + return this.itemComponent; + } + + @Override + public String getTypeLanguage() { + return typeLanguage; + } + + @Override + public void setTypeLanguage(String value) { + this.typeLanguage = value; + } + + @Override + public boolean isIsCollection() { + if (isCollection == null) { + return false; + } else { + return isCollection; + } + } + + @Override + public void setIsCollection(Boolean value) { + this.isCollection = value; + } + + @Override + public FunctionItem getFunctionItem() { + return functionItem; + } + + @Override + public void setFunctionItem(FunctionItem value) { + this.functionItem = value; + } +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TIterator.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TIterator.java new file mode 100644 index 00000000000..ee8b9802818 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TIterator.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Iterator; +import org.kie.dmn.model.api.TypedChildExpression; + +public class TIterator extends TExpression implements Iterator { + + protected TypedChildExpression in; + + protected String iteratorVariable; + + public TypedChildExpression getIn() { + return in; + } + + public void setIn(TypedChildExpression value) { + this.in = value; + } + + public String getIteratorVariable() { + return iteratorVariable; + } + + public void setIteratorVariable(String value) { + this.iteratorVariable = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeRequirement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeRequirement.java new file mode 100644 index 00000000000..df277c343e5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeRequirement.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.KnowledgeRequirement; + +public class TKnowledgeRequirement extends TDMNElement implements KnowledgeRequirement { + + protected DMNElementReference requiredKnowledge; + + @Override + public DMNElementReference getRequiredKnowledge() { + return requiredKnowledge; + } + + @Override + public void setRequiredKnowledge(DMNElementReference value) { + this.requiredKnowledge = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeSource.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeSource.java new file mode 100644 index 00000000000..1c0c11c83b9 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TKnowledgeSource.java @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.AuthorityRequirement; +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.KnowledgeSource; + +import java.util.ArrayList; +import java.util.List; + +public class TKnowledgeSource extends TDRGElement implements KnowledgeSource { + + protected List authorityRequirement; + protected String type; + protected DMNElementReference owner; + protected String locationURI; + + @Override + public List getAuthorityRequirement() { + if (authorityRequirement == null) { + authorityRequirement = new ArrayList<>(); + } + return this.authorityRequirement; + } + + @Override + public String getType() { + return type; + } + + @Override + public void setType(String value) { + this.type = value; + } + + @Override + public DMNElementReference getOwner() { + return owner; + } + + @Override + public void setOwner(DMNElementReference value) { + this.owner = value; + } + + @Override + public String getLocationURI() { + return locationURI; + } + + @Override + public void setLocationURI(String value) { + this.locationURI = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TList.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TList.java new file mode 100644 index 00000000000..07a74b541be --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TList.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Expression; +import org.kie.dmn.model.api.List; + +import java.util.ArrayList; + +public class TList extends TExpression implements List { + + protected java.util.List expression; + + @Override + public java.util.List getExpression() { + if (expression == null) { + expression = new ArrayList<>(); + } + return this.expression; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TLiteralExpression.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TLiteralExpression.java new file mode 100644 index 00000000000..96feeaf5011 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TLiteralExpression.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ImportedValues; +import org.kie.dmn.model.api.LiteralExpression; + +public class TLiteralExpression extends TExpression implements LiteralExpression { + + protected String text; + protected ImportedValues importedValues; + protected String expressionLanguage; + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String value) { + this.text = value; + } + + @Override + public ImportedValues getImportedValues() { + return importedValues; + } + + @Override + public void setImportedValues(ImportedValues value) { + this.importedValues = value; + } + + @Override + public String getExpressionLanguage() { + return expressionLanguage; + } + + @Override + public void setExpressionLanguage(String value) { + this.expressionLanguage = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TNamedElement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TNamedElement.java new file mode 100644 index 00000000000..15279df70c6 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TNamedElement.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.NamedElement; + +public class TNamedElement extends TDMNElement implements NamedElement { + + protected String name; + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String value) { + this.name = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOrganizationUnit.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOrganizationUnit.java new file mode 100644 index 00000000000..b3d0d5fd8ed --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOrganizationUnit.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.OrganizationUnit; + +import java.util.ArrayList; +import java.util.List; + +public class TOrganizationUnit extends TBusinessContextElement implements OrganizationUnit { + + protected List decisionMade; + protected List decisionOwned; + + @Override + public List getDecisionMade() { + if (decisionMade == null) { + decisionMade = new ArrayList<>(); + } + return this.decisionMade; + } + + @Override + public List getDecisionOwned() { + if (decisionOwned == null) { + decisionOwned = new ArrayList<>(); + } + return this.decisionOwned; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOutputClause.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOutputClause.java new file mode 100644 index 00000000000..a61a689c5b6 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TOutputClause.java @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.LiteralExpression; +import org.kie.dmn.model.api.OutputClause; +import org.kie.dmn.model.api.UnaryTests; + +import javax.xml.namespace.QName; + +public class TOutputClause extends TDMNElement implements OutputClause { + + protected UnaryTests outputValues; + protected LiteralExpression defaultOutputEntry; + protected String name; + /** + * align to internal model + */ + protected QName typeRef; + + @Override + public UnaryTests getOutputValues() { + return outputValues; + } + + @Override + public void setOutputValues(UnaryTests value) { + this.outputValues = value; + } + + @Override + public LiteralExpression getDefaultOutputEntry() { + return defaultOutputEntry; + } + + @Override + public void setDefaultOutputEntry(LiteralExpression value) { + this.defaultOutputEntry = value; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String value) { + this.name = value; + } + + @Override + public QName getTypeRef() { + return typeRef; + } + + @Override + public void setTypeRef(QName value) { + this.typeRef = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TPerformanceIndicator.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TPerformanceIndicator.java new file mode 100644 index 00000000000..6aaa27a450f --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TPerformanceIndicator.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.DMNElementReference; +import org.kie.dmn.model.api.PerformanceIndicator; + +import java.util.ArrayList; +import java.util.List; + +public class TPerformanceIndicator extends TBusinessContextElement implements PerformanceIndicator { + + protected List impactingDecision; + + @Override + public List getImpactingDecision() { + if (impactingDecision == null) { + impactingDecision = new ArrayList<>(); + } + return this.impactingDecision; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TQuantified.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TQuantified.java new file mode 100644 index 00000000000..0c09e360857 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TQuantified.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.ChildExpression; +import org.kie.dmn.model.api.Quantified; + +public class TQuantified extends TIterator implements Quantified { + + protected ChildExpression satisfies; + + public ChildExpression getSatisfies() { + return satisfies; + } + + public void setSatisfies(ChildExpression value) { + this.satisfies = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRelation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRelation.java new file mode 100644 index 00000000000..b821f70550d --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRelation.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.InformationItem; +import org.kie.dmn.model.api.List; +import org.kie.dmn.model.api.Relation; + +import java.util.ArrayList; + +public class TRelation extends TExpression implements Relation { + + protected java.util.List column; + protected java.util.List row; + + @Override + public java.util.List getColumn() { + if (column == null) { + column = new ArrayList<>(); + } + return this.column; + } + + @Override + public java.util.List getRow() { + if (row == null) { + row = new ArrayList<>(); + } + return this.row; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotation.java new file mode 100644 index 00000000000..e269541166e --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotation.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.RuleAnnotation; + +public class TRuleAnnotation extends KieDMNModelInstrumentedBase implements RuleAnnotation { + + protected String text; + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String value) { + this.text = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotationClause.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotationClause.java new file mode 100644 index 00000000000..9610687fd29 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TRuleAnnotationClause.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.RuleAnnotationClause; + +public class TRuleAnnotationClause extends KieDMNModelInstrumentedBase implements RuleAnnotationClause { + + protected String name; + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String value) { + this.name = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TSome.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TSome.java new file mode 100644 index 00000000000..bc5f72255d5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TSome.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.Some; + +public class TSome extends TQuantified implements Some { + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTextAnnotation.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTextAnnotation.java new file mode 100644 index 00000000000..b0898f3e970 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTextAnnotation.java @@ -0,0 +1,55 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.TextAnnotation; + +public class TTextAnnotation extends TArtifact implements TextAnnotation { + + + private static final String DEFAULT_TEXT_FORMAT = "text/plain"; + + private String text; + private String textFormat; + + @Override + public String getText() { + return text; + } + + @Override + public void setText(final String value) { + this.text = value; + } + + @Override + public String getTextFormat() { + if (textFormat == null) { + return DEFAULT_TEXT_FORMAT; + } else { + return textFormat; + } + } + + @Override + public void setTextFormat(final String value) { + this.textFormat = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTypedChildExpression.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTypedChildExpression.java new file mode 100644 index 00000000000..898f2c2834e --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TTypedChildExpression.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.TypedChildExpression; + +public class TTypedChildExpression extends TChildExpression implements TypedChildExpression { + + protected String typeRef; + + @Override + public String getTypeRef() { + return typeRef; + } + + @Override + public void setTypeRef(String value) { + this.typeRef = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TUnaryTests.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TUnaryTests.java new file mode 100644 index 00000000000..27b99f547e5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/TUnaryTests.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5; + +import org.kie.dmn.model.api.UnaryTests; + +public class TUnaryTests extends TExpression implements UnaryTests { + + protected String text; + protected String expressionLanguage; + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String value) { + this.text = value; + } + + @Override + public String getExpressionLanguage() { + return expressionLanguage; + } + + @Override + public void setExpressionLanguage(String value) { + this.expressionLanguage = value; + } +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Bounds.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Bounds.java new file mode 100644 index 00000000000..e60e04ea7ba --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Bounds.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +public class Bounds extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.Bounds { + + protected double x; + protected double y; + protected double width; + protected double height; + + /** + * Gets the value of the x property. + * + */ + public double getX() { + return x; + } + + /** + * Sets the value of the x property. + * + */ + public void setX(double value) { + this.x = value; + } + + /** + * Gets the value of the y property. + * + */ + public double getY() { + return y; + } + + /** + * Sets the value of the y property. + * + */ + public void setY(double value) { + this.y = value; + } + + /** + * Gets the value of the width property. + * + */ + public double getWidth() { + return width; + } + + /** + * Sets the value of the width property. + * + */ + public void setWidth(double value) { + this.width = value; + } + + /** + * Gets the value of the height property. + * + */ + public double getHeight() { + return height; + } + + /** + * Sets the value of the height property. + * + */ + public void setHeight(double value) { + this.height = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Color.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Color.java new file mode 100644 index 00000000000..c0d48232b0b --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Color.java @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +public class Color extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.Color { + + protected int red; + protected int green; + protected int blue; + + /** + * Gets the value of the red property. + * + */ + public int getRed() { + return red; + } + + /** + * Sets the value of the red property. + * + */ + public void setRed(int value) { + this.red = value; + } + + /** + * Gets the value of the green property. + * + */ + public int getGreen() { + return green; + } + + /** + * Sets the value of the green property. + * + */ + public void setGreen(int value) { + this.green = value; + } + + /** + * Gets the value of the blue property. + * + */ + public int getBlue() { + return blue; + } + + /** + * Sets the value of the blue property. + * + */ + public void setBlue(int value) { + this.blue = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDI.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDI.java new file mode 100644 index 00000000000..5d11abdd2e8 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDI.java @@ -0,0 +1,123 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.api.dmndi.DMNDiagram; +import org.kie.dmn.model.api.dmndi.DMNStyle; +import org.kie.dmn.model.api.dmndi.DiagramElement; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.kie.dmn.model.v1_5.dmndi.Style.IDREFStubStyle; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + + +public class DMNDI extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.DMNDI { + + protected List dmnDiagram; + protected List dmnStyle; + + /** + * Gets the value of the dmnDiagram property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the dmnDiagram property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getDMNDiagram().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link DMNDiagram } + * + * + */ + @Override + public List getDMNDiagram() { + if (dmnDiagram == null) { + dmnDiagram = new ArrayList<>(); + } + return this.dmnDiagram; + } + + /** + * Gets the value of the dmnStyle property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the dmnStyle property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getDMNStyle().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link DMNStyle } + * + * + */ + @Override + public List getDMNStyle() { + if (dmnStyle == null) { + dmnStyle = new ArrayList<>(); + } + return this.dmnStyle; + } + + @Override + public void normalize() { + if (dmnStyle == null || dmnDiagram == null) { + return; + } + Map styleById = dmnStyle.stream().collect(Collectors.toMap(DMNStyle::getId, Function.identity())); + for (DMNDiagram diagram : dmnDiagram) { + for (DiagramElement element : diagram.getDMNDiagramElement()) { + replaceSharedStyleIfStubbed(element, styleById); + if (element instanceof DMNShape) { + DMNShape dmnShape = (DMNShape) element; + replaceSharedStyleIfStubbed(dmnShape.getDMNLabel(), styleById); + } + } + } + } + + private void replaceSharedStyleIfStubbed(DiagramElement element, Map styleById) { + if (element.getSharedStyle() instanceof IDREFStubStyle) { + DMNStyle locatedStyle = styleById.get(element.getSharedStyle().getId()); + element.setSharedStyle(locatedStyle); + } + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDecisionServiceDividerLine.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDecisionServiceDividerLine.java new file mode 100644 index 00000000000..6d94c8f1162 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDecisionServiceDividerLine.java @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +public class DMNDecisionServiceDividerLine extends Edge implements org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine { + + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDiagram.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDiagram.java new file mode 100644 index 00000000000..e78187e0677 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNDiagram.java @@ -0,0 +1,97 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import jakarta.xml.bind.JAXBElement; + +import java.util.ArrayList; +import java.util.List; + +public class DMNDiagram extends Diagram implements org.kie.dmn.model.api.dmndi.DMNDiagram { + + protected org.kie.dmn.model.api.dmndi.Dimension size; + protected List dmnDiagramElement; + protected boolean useAlternativeInputDataShape = false; + + /** + * Gets the value of the size property. + * + * @return + * possible object is + * {@link Dimension } + * + */ + public org.kie.dmn.model.api.dmndi.Dimension getSize() { + return size; + } + + /** + * Sets the value of the size property. + * + * @param value + * allowed object is + * {@link Dimension } + * + */ + public void setSize(org.kie.dmn.model.api.dmndi.Dimension value) { + this.size = value; + } + + /** + * Gets the value of the dmnDiagramElement property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the dmnDiagramElement property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getDMNDiagramElement().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link DMNShape }{@code >} + * {@link JAXBElement }{@code <}{@link DiagramElement }{@code >} + * {@link JAXBElement }{@code <}{@link DMNEdge }{@code >} + * + * + */ + public List getDMNDiagramElement() { + if (dmnDiagramElement == null) { + dmnDiagramElement = new ArrayList<>(); + } + return this.dmnDiagramElement; + } + + @Override + public Boolean getUseAlternativeInputDataShape() { + return useAlternativeInputDataShape; + } + + @Override + public void setUseAlternativeInputDataShape(Boolean value) { + this.useAlternativeInputDataShape = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNEdge.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNEdge.java new file mode 100644 index 00000000000..e1568600033 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNEdge.java @@ -0,0 +1,98 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import javax.xml.namespace.QName; + +public class DMNEdge extends Edge implements org.kie.dmn.model.api.dmndi.DMNEdge { + + protected org.kie.dmn.model.api.dmndi.DMNLabel dmnLabel; + protected QName dmnElementRef; + protected QName sourceElement; + protected QName targetElement; + + /** + * Gets the value of the dmnLabel property. + * + * @return + * possible object is + * {@link DMNLabel } + * + */ + public org.kie.dmn.model.api.dmndi.DMNLabel getDMNLabel() { + return dmnLabel; + } + + /** + * Sets the value of the dmnLabel property. + * + * @param value + * allowed object is + * {@link DMNLabel } + * + */ + public void setDMNLabel(org.kie.dmn.model.api.dmndi.DMNLabel value) { + this.dmnLabel = value; + } + + /** + * Gets the value of the dmnElementRef property. + * + * @return + * possible object is + * {@link QName } + * + */ + public QName getDmnElementRef() { + return dmnElementRef; + } + + /** + * Sets the value of the dmnElementRef property. + * + * @param value + * allowed object is + * {@link QName } + * + */ + public void setDmnElementRef(QName value) { + this.dmnElementRef = value; + } + + @Override + public QName getSourceElement() { + return sourceElement; + } + + @Override + public void setSourceElement(QName value) { + this.sourceElement = value; + } + + @Override + public QName getTargetElement() { + return targetElement; + } + + @Override + public void setTargetElement(QName value) { + this.targetElement = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNLabel.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNLabel.java new file mode 100644 index 00000000000..2845a1bb751 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNLabel.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +public class DMNLabel extends Shape implements org.kie.dmn.model.api.dmndi.DMNLabel { + + protected String text; + + /** + * Gets the value of the text property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getText() { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setText(String value) { + this.text = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNShape.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNShape.java new file mode 100644 index 00000000000..e999af6a711 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNShape.java @@ -0,0 +1,155 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import javax.xml.namespace.QName; + +public class DMNShape extends Shape implements org.kie.dmn.model.api.dmndi.DMNShape { + + protected org.kie.dmn.model.api.dmndi.DMNLabel dmnLabel; + protected org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine dmnDecisionServiceDividerLine; + protected QName dmnElementRef; + protected Boolean isListedInputData; + protected Boolean isCollapsed; + + /** + * Gets the value of the dmnLabel property. + * + * @return + * possible object is + * {@link DMNLabel } + * + */ + public org.kie.dmn.model.api.dmndi.DMNLabel getDMNLabel() { + return dmnLabel; + } + + /** + * Sets the value of the dmnLabel property. + * + * @param value + * allowed object is + * {@link DMNLabel } + * + */ + public void setDMNLabel(org.kie.dmn.model.api.dmndi.DMNLabel value) { + this.dmnLabel = value; + } + + /** + * Gets the value of the dmnDecisionServiceDividerLine property. + * + * @return + * possible object is + * {@link DMNDecisionServiceDividerLine } + * + */ + public org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine getDMNDecisionServiceDividerLine() { + return dmnDecisionServiceDividerLine; + } + + /** + * Sets the value of the dmnDecisionServiceDividerLine property. + * + * @param value + * allowed object is + * {@link DMNDecisionServiceDividerLine } + * + */ + public void setDMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine value) { + this.dmnDecisionServiceDividerLine = value; + } + + /** + * Gets the value of the dmnElementRef property. + * + * @return + * possible object is + * {@link QName } + * + */ + public QName getDmnElementRef() { + return dmnElementRef; + } + + /** + * Sets the value of the dmnElementRef property. + * + * @param value + * allowed object is + * {@link QName } + * + */ + public void setDmnElementRef(QName value) { + this.dmnElementRef = value; + } + + /** + * Gets the value of the isListedInputData property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isIsListedInputData() { + return isListedInputData; + } + + /** + * Sets the value of the isListedInputData property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsListedInputData(Boolean value) { + this.isListedInputData = value; + } + + /** + * Gets the value of the isCollapsed property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public boolean isIsCollapsed() { + if (isCollapsed == null) { + return false; + } else { + return isCollapsed; + } + } + + /** + * Sets the value of the isCollapsed property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsCollapsed(Boolean value) { + this.isCollapsed = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNStyle.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNStyle.java new file mode 100644 index 00000000000..9ac2a453b36 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DMNStyle.java @@ -0,0 +1,301 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.api.dmndi.AlignmentKind; + +public class DMNStyle extends Style implements org.kie.dmn.model.api.dmndi.DMNStyle { + + protected org.kie.dmn.model.api.dmndi.Color fillColor; + protected org.kie.dmn.model.api.dmndi.Color strokeColor; + protected org.kie.dmn.model.api.dmndi.Color fontColor; + protected String fontFamily; + protected Double fontSize; + protected Boolean fontItalic; + protected Boolean fontBold; + protected Boolean fontUnderline; + protected Boolean fontStrikeThrough; + protected AlignmentKind labelHorizontalAlignement; + protected AlignmentKind labelVerticalAlignment; + + /** + * Gets the value of the fillColor property. + * + * @return + * possible object is + * {@link Color } + * + */ + public org.kie.dmn.model.api.dmndi.Color getFillColor() { + return fillColor; + } + + /** + * Sets the value of the fillColor property. + * + * @param value + * allowed object is + * {@link Color } + * + */ + public void setFillColor(org.kie.dmn.model.api.dmndi.Color value) { + this.fillColor = value; + } + + /** + * Gets the value of the strokeColor property. + * + * @return + * possible object is + * {@link Color } + * + */ + public org.kie.dmn.model.api.dmndi.Color getStrokeColor() { + return strokeColor; + } + + /** + * Sets the value of the strokeColor property. + * + * @param value + * allowed object is + * {@link Color } + * + */ + public void setStrokeColor(org.kie.dmn.model.api.dmndi.Color value) { + this.strokeColor = value; + } + + /** + * Gets the value of the fontColor property. + * + * @return + * possible object is + * {@link Color } + * + */ + public org.kie.dmn.model.api.dmndi.Color getFontColor() { + return fontColor; + } + + /** + * Sets the value of the fontColor property. + * + * @param value + * allowed object is + * {@link Color } + * + */ + public void setFontColor(org.kie.dmn.model.api.dmndi.Color value) { + this.fontColor = value; + } + + /** + * Gets the value of the fontFamily property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFontFamily() { + return fontFamily; + } + + /** + * Sets the value of the fontFamily property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFontFamily(String value) { + this.fontFamily = value; + } + + /** + * Gets the value of the fontSize property. + * + * @return + * possible object is + * {@link Double } + * + */ + public Double getFontSize() { + return fontSize; + } + + /** + * Sets the value of the fontSize property. + * + * @param value + * allowed object is + * {@link Double } + * + */ + public void setFontSize(Double value) { + this.fontSize = value; + } + + /** + * Gets the value of the fontItalic property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isFontItalic() { + return fontItalic; + } + + /** + * Sets the value of the fontItalic property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setFontItalic(Boolean value) { + this.fontItalic = value; + } + + /** + * Gets the value of the fontBold property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isFontBold() { + return fontBold; + } + + /** + * Sets the value of the fontBold property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setFontBold(Boolean value) { + this.fontBold = value; + } + + /** + * Gets the value of the fontUnderline property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isFontUnderline() { + return fontUnderline; + } + + /** + * Sets the value of the fontUnderline property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setFontUnderline(Boolean value) { + this.fontUnderline = value; + } + + /** + * Gets the value of the fontStrikeThrough property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isFontStrikeThrough() { + return fontStrikeThrough; + } + + /** + * Sets the value of the fontStrikeThrough property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setFontStrikeThrough(Boolean value) { + this.fontStrikeThrough = value; + } + + /** + * Gets the value of the labelHorizontalAlignement property. + * + * @return + * possible object is + * {@link AlignmentKind } + * + */ + public AlignmentKind getLabelHorizontalAlignement() { + return labelHorizontalAlignement; + } + + /** + * Sets the value of the labelHorizontalAlignement property. + * + * @param value + * allowed object is + * {@link AlignmentKind } + * + */ + public void setLabelHorizontalAlignement(AlignmentKind value) { + this.labelHorizontalAlignement = value; + } + + /** + * Gets the value of the labelVerticalAlignment property. + * + * @return + * possible object is + * {@link AlignmentKind } + * + */ + public AlignmentKind getLabelVerticalAlignment() { + return labelVerticalAlignment; + } + + /** + * Sets the value of the labelVerticalAlignment property. + * + * @param value + * allowed object is + * {@link AlignmentKind } + * + */ + public void setLabelVerticalAlignment(AlignmentKind value) { + this.labelVerticalAlignment = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Diagram.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Diagram.java new file mode 100644 index 00000000000..6d5bc10f809 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Diagram.java @@ -0,0 +1,99 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +public abstract class Diagram extends DiagramElement implements org.kie.dmn.model.api.dmndi.Diagram { + + protected String name; + protected String documentation; + protected Double resolution; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the documentation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDocumentation() { + return documentation; + } + + /** + * Sets the value of the documentation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDocumentation(String value) { + this.documentation = value; + } + + /** + * Gets the value of the resolution property. + * + * @return + * possible object is + * {@link Double } + * + */ + public Double getResolution() { + return resolution; + } + + /** + * Sets the value of the resolution property. + * + * @param value + * allowed object is + * {@link Double } + * + */ + public void setResolution(Double value) { + this.resolution = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DiagramElement.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DiagramElement.java new file mode 100644 index 00000000000..e7e62438c51 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/DiagramElement.java @@ -0,0 +1,147 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import jakarta.xml.bind.JAXBElement; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +import java.util.ArrayList; +import java.util.List; + +public abstract class DiagramElement extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.DiagramElement { + + protected org.kie.dmn.model.api.dmndi.DiagramElement.Extension extension; + protected org.kie.dmn.model.api.dmndi.Style style; + protected org.kie.dmn.model.api.dmndi.Style sharedStyle; + protected String id; + + /** + * Gets the value of the extension property. + * + * @return + * possible object is + * {@link Extension } + * + */ + public org.kie.dmn.model.api.dmndi.DiagramElement.Extension getExtension() { + return extension; + } + + /** + * Sets the value of the extension property. + * + * @param value + * allowed object is + * {@link Extension } + * + */ + public void setExtension(org.kie.dmn.model.api.dmndi.DiagramElement.Extension value) { + this.extension = value; + } + + /** + * an optional locally-owned style for this diagram element. + * + * @return + * possible object is + * {@link JAXBElement }{@code <}{@link DMNStyle }{@code >} + * {@link JAXBElement }{@code <}{@link Style }{@code >} + * + */ + public org.kie.dmn.model.api.dmndi.Style getStyle() { + return style; + } + + /** + * Sets the value of the style property. + * + * @param value + * allowed object is + * {@link JAXBElement }{@code <}{@link DMNStyle }{@code >} + * {@link JAXBElement }{@code <}{@link Style }{@code >} + * + */ + public void setStyle(org.kie.dmn.model.api.dmndi.Style value) { + this.style = value; + } + + /** + * Gets the value of the sharedStyle property. + * + * @return + * possible object is + * {@link Object } + * + */ + public org.kie.dmn.model.api.dmndi.Style getSharedStyle() { + return sharedStyle; + } + + /** + * Sets the value of the sharedStyle property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setSharedStyle(org.kie.dmn.model.api.dmndi.Style value) { + this.sharedStyle = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + + + public static class Extension extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.DiagramElement.Extension { + + protected List any; + + public List getAny() { + if (any == null) { + any = new ArrayList<>(); + } + return this.any; + } + + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Dimension.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Dimension.java new file mode 100644 index 00000000000..de1794410b3 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Dimension.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +public class Dimension extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.Dimension { + + protected double width; + protected double height; + + /** + * Gets the value of the width property. + * + */ + public double getWidth() { + return width; + } + + /** + * Sets the value of the width property. + * + */ + public void setWidth(double value) { + this.width = value; + } + + /** + * Gets the value of the height property. + * + */ + public double getHeight() { + return height; + } + + /** + * Sets the value of the height property. + * + */ + public void setHeight(double value) { + this.height = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Edge.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Edge.java new file mode 100644 index 00000000000..79258c0b6fd --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Edge.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import java.util.ArrayList; +import java.util.List; + +public abstract class Edge extends DiagramElement implements org.kie.dmn.model.api.dmndi.Edge { + + protected List waypoint; + + /** + * Gets the value of the waypoint property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the waypoint property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getWaypoint().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Point } + * + * + */ + public List getWaypoint() { + if (waypoint == null) { + waypoint = new ArrayList<>(); + } + return this.waypoint; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Point.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Point.java new file mode 100644 index 00000000000..52203f24b08 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Point.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +public class Point extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.Point { + + protected double x; + protected double y; + + /** + * Gets the value of the x property. + * + */ + public double getX() { + return x; + } + + /** + * Sets the value of the x property. + * + */ + public void setX(double value) { + this.x = value; + } + + /** + * Gets the value of the y property. + * + */ + public double getY() { + return y; + } + + /** + * Sets the value of the y property. + * + */ + public void setY(double value) { + this.y = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Shape.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Shape.java new file mode 100644 index 00000000000..5088e382d54 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Shape.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +public abstract class Shape extends DiagramElement implements org.kie.dmn.model.api.dmndi.Shape { + + protected org.kie.dmn.model.api.dmndi.Bounds bounds; + + /** + * the optional bounds of the shape relative to the origin of its nesting plane. + * + * @return + * possible object is + * {@link Bounds } + * + */ + public org.kie.dmn.model.api.dmndi.Bounds getBounds() { + return bounds; + } + + /** + * Sets the value of the bounds property. + * + * @param value + * allowed object is + * {@link Bounds } + * + */ + public void setBounds(org.kie.dmn.model.api.dmndi.Bounds value) { + this.bounds = value; + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Style.java b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Style.java new file mode 100644 index 00000000000..393e2e7ccf5 --- /dev/null +++ b/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_5/dmndi/Style.java @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.dmn.model.v1_5.dmndi; + +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; +import org.w3c.dom.Element; + +import java.util.ArrayList; +import java.util.List; + + +public abstract class Style extends KieDMNModelInstrumentedBase implements org.kie.dmn.model.api.dmndi.Style { + + protected org.kie.dmn.model.api.dmndi.Style.Extension extension; + protected String id; + + /** + * Gets the value of the extension property. + * + * @return + * possible object is + * {@link Extension } + * + */ + public org.kie.dmn.model.api.dmndi.Style.Extension getExtension() { + return extension; + } + + /** + * Sets the value of the extension property. + * + * @param value + * allowed object is + * {@link Extension } + * + */ + public void setExtension(org.kie.dmn.model.api.dmndi.Style.Extension value) { + this.extension = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + + public static class Extension implements org.kie.dmn.model.api.dmndi.Style.Extension { + + protected List any; + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getAny().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList<>(); + } + return this.any; + } + + } + + public static class IDREFStubStyle extends Style { + + public IDREFStubStyle(String id) { + this.id = id; + } + } + +} diff --git a/kie-dmn/kie-dmn-model/src/main/resources/META-INF/native-image/org.kie/kie-dmn-model/reflect-config.json b/kie-dmn/kie-dmn-model/src/main/resources/META-INF/native-image/org.kie/kie-dmn-model/reflect-config.json index 5d824efb195..e67c751cd30 100644 --- a/kie-dmn/kie-dmn-model/src/main/resources/META-INF/native-image/org.kie/kie-dmn-model/reflect-config.json +++ b/kie-dmn/kie-dmn-model/src/main/resources/META-INF/native-image/org.kie/kie-dmn-model/reflect-config.json @@ -1969,5 +1969,653 @@ "allPublicMethods": true, "allDeclaredClasses": true, "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Bounds", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Color", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNDI", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNDecisionServiceDividerLine", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNDiagram", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNEdge", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNLabel", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNShape", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DMNStyle", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Diagram", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DiagramElement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.DiagramElement$Extension", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Dimension", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Edge", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Point", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Shape", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Style", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.dmndi.Style$IDREFStubStyle", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TArtifact", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TAssociation", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TAuthorityRequirement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TBinding", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TBusinessContextElement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TBusinessKnowledgeModel", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TChildExpression", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TConditional", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TContext", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TContextEntry", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDMNElement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDMNElement$TExtensionElements", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDMNElementReference", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDRGElement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDecision", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDecisionRule", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDecisionService", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDecisionTable", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TDefinitions", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TElementCollection", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TEvery", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TExpression", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TFilter", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TFor", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TFunctionDefinition", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TFunctionItem", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TGroup", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TImport", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TImportedValues", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInformationItem", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInformationRequirement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInputClause", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInputData", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInvocable", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TInvocation", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TItemDefinition", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TIterator", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TKnowledgeRequirement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TKnowledgeSource", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TList", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TLiteralExpression", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TNamedElement", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TOrganizationUnit", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TOutputClause", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TPerformanceIndicator", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TQuantified", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TRelation", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TRuleAnnotation", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TRuleAnnotationClause", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TSome", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TTextAnnotation", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TTypedChildExpression", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "org.kie.dmn.model.v1_5.TUnaryTests", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true } ] diff --git a/kie-dmn/kie-dmn-validation-bootstrap/src/main/java/org/kie/dmn/validation/bootstrap/GenerateModel.java b/kie-dmn/kie-dmn-validation-bootstrap/src/main/java/org/kie/dmn/validation/bootstrap/GenerateModel.java index adf87fba50e..84b04e932cd 100644 --- a/kie-dmn/kie-dmn-validation-bootstrap/src/main/java/org/kie/dmn/validation/bootstrap/GenerateModel.java +++ b/kie-dmn/kie-dmn-validation-bootstrap/src/main/java/org/kie/dmn/validation/bootstrap/GenerateModel.java @@ -65,8 +65,8 @@ public void generate() throws IOException { kieBuilder.buildAll(ValidationBootstrapProject::new, s -> !s.contains("src/test/java") && !s.contains("src\\test\\java") && - !s.contains("DMNValidator") && // <- to break circularity which is only caused by the KieBuilder trying to early compile everything by itself - !s.contains("dtanalysis")); + !s.contains("DMNValidator") && // <- to break circularity which is only caused by the KieBuilder trying to early compile everything by itself + !s.contains("dtanalysis")); Results results = kieBuilder.getResults(); results.getMessages().forEach(m -> LOG.info("{}", m.toString())); diff --git a/kie-dmn/kie-dmn-validation/pom.xml b/kie-dmn/kie-dmn-validation/pom.xml index 3056ba4025c..1e19a9f2a29 100644 --- a/kie-dmn/kie-dmn-validation/pom.xml +++ b/kie-dmn/kie-dmn-validation/pom.xml @@ -32,6 +32,7 @@ org.kie.dmn.validation + true @@ -212,6 +213,26 @@ + + org.codehaus.mojo + properties-maven-plugin + + + initialize + + set-system-properties + + + + + drools.reproducibleExecutableModelGeneration + ${drools.reproducibleExecutableModelGeneration} + + + + + + diff --git a/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/DMNValidatorImpl.java b/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/DMNValidatorImpl.java index 0a5df20a656..2f7cfb291e2 100644 --- a/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/DMNValidatorImpl.java +++ b/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/DMNValidatorImpl.java @@ -140,6 +140,20 @@ public class DMNValidatorImpl implements DMNValidator { } } + static final Schema schemav1_5; + static { + try { + schemav1_5 = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) + .newSchema(new Source[]{new StreamSource(DMNValidatorImpl.class.getResourceAsStream("org/omg/spec/DMN/20230324/DC.xsd")), + new StreamSource(DMNValidatorImpl.class.getResourceAsStream("org/omg/spec/DMN/20230324/DI.xsd")), + new StreamSource(DMNValidatorImpl.class.getResourceAsStream("org/omg/spec/DMN/20230324/DMNDI15.xsd")), + new StreamSource(DMNValidatorImpl.class.getResourceAsStream("org/omg/spec/DMN/20230324/DMN15.xsd")) + }); + } catch (SAXException e) { + throw new RuntimeException("Unable to initialize correctly DMNValidator.", e); + } + } + private Schema overrideSchema = null; private final List dmnProfiles = new ArrayList<>(); private final DMNCompilerConfiguration dmnCompilerConfig; @@ -549,9 +563,11 @@ private Schema determineSchema(DMN_VERSION dmnVersion) { case DMN_v1_3: return schemav1_3; case DMN_v1_4: + return schemav1_4; + case DMN_v1_5: case UNKNOWN: default: - return schemav1_4; + return schemav1_5; } } diff --git a/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/ValidatorUtil.java b/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/ValidatorUtil.java index 0ba53160bee..020eb45ec9d 100644 --- a/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/ValidatorUtil.java +++ b/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/ValidatorUtil.java @@ -32,9 +32,14 @@ import org.kie.dmn.model.api.ItemDefinition; import org.kie.dmn.model.api.KnowledgeRequirement; import org.kie.dmn.model.api.NamedElement; +import org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase; + +import javax.xml.namespace.QName; public final class ValidatorUtil { + public static final QName KIE_MODEL_NAME_QNAME = new QName(KieDMNModelInstrumentedBase.URI_KIE, "modelName"); + public static String rightOfHash(final String input) { return input.substring(input.indexOf("#") + 1); } diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/DMNv1x/dmn-validation-rules.drl b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/DMNv1x/dmn-validation-rules.drl index e9ab5c9060d..2eed407b5fc 100644 --- a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/DMNv1x/dmn-validation-rules.drl +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/DMNv1x/dmn-validation-rules.drl @@ -25,6 +25,7 @@ import org.kie.dmn.feel.runtime.events.SyntaxErrorEvent; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.core.util.Msg; import org.kie.dmn.core.compiler.ImportDMNResolverUtil; +import org.kie.dmn.validation.ValidatorUtil; import function org.kie.dmn.validation.ValidatorUtil.rightOfHash; import function org.kie.dmn.validation.ValidatorUtil.getRootItemDef; @@ -37,7 +38,7 @@ rule MISSING_IMPORT_p1 when $elemRef : Import( ImportDMNResolverUtil.whichImportType(this) == ImportDMNResolverUtil.ImportType.DMN, $importedNS : namespace, - getAdditionalAttributes().get(org.kie.dmn.model.v1_1.TImport.MODELNAME_QNAME) == null ) + getAdditionalAttributes().get(ValidatorUtil.KIE_MODEL_NAME_QNAME) == null ) not( Definitions( namespace == $importedNS ) from entry-point "DMNImports" ) then reporter.report(DMNMessage.Severity.ERROR, $elemRef, Msg.IMPORT_NOT_FOUND_FOR_NODE, $importedNS, $elemRef.getIdentifierString()); @@ -47,8 +48,8 @@ rule MISSING_IMPORT_p2 when $elemRef : Import( ImportDMNResolverUtil.whichImportType(this) == ImportDMNResolverUtil.ImportType.DMN, $importedNS : namespace, - getAdditionalAttributes().get(org.kie.dmn.model.v1_1.TImport.MODELNAME_QNAME) != null, - $importedName : getAdditionalAttributes().get(org.kie.dmn.model.v1_1.TImport.MODELNAME_QNAME) ) + getAdditionalAttributes().get(ValidatorUtil.KIE_MODEL_NAME_QNAME) != null, + $importedName : getAdditionalAttributes().get(ValidatorUtil.KIE_MODEL_NAME_QNAME) ) not( Definitions( namespace == $importedNS, name == $importedName ) from entry-point "DMNImports" ) then reporter.report(DMNMessage.Severity.ERROR, $elemRef, Msg.IMPORT_NOT_FOUND_FOR_NODE, $importedNS + $importedName, $elemRef.getIdentifierString()); diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DC.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DC.xsd new file mode 100644 index 00000000000..6f7926fb11b --- /dev/null +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DC.xsd @@ -0,0 +1,159 @@ + + + + + + + + + + + Color is a data type that represents a color value in the RGB format. + + + + + + + + + + + + + + + + A Point specifies an location in some x-y coordinate system. + + + + + + + + Dimension specifies two lengths (width and height) along the x and y axes in some x-y coordinate system. + + + + + + + + Bounds specifies a rectangular area in some x-y coordinate system that is defined by a location (x and y) and a size (width and height). + + + + + + + + + + AlignmentKind enumerates the possible options for alignment for layout purposes. + + + + + + + + + + + KnownColor is an enumeration of 17 known colors. + + + + + a color with a value of #800000 + + + + + a color with a value of #FF0000 + + + + + a color with a value of #FFA500 + + + + + a color with a value of #FFFF00 + + + + + a color with a value of #808000 + + + + + a color with a value of #800080 + + + + + a color with a value of #FF00FF + + + + + a color with a value of #FFFFFF + + + + + a color with a value of #00FF00 + + + + + a color with a value of #008000 + + + + + a color with a value of #000080 + + + + + a color with a value of #0000FF + + + + + a color with a value of #00FFFF + + + + + a color with a value of #008080 + + + + + a color with a value of #000000 + + + + + a color with a value of #C0C0C0 + + + + + a color with a value of #808080 + + + + + + diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DI.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DI.xsd new file mode 100644 index 00000000000..a79b4f798d8 --- /dev/null +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DI.xsd @@ -0,0 +1,115 @@ + + + + + + The Diagram Interchange (DI) package enables interchange of graphical information that language users have control over, such as position of nodes and line routing points. Language specifications specialize elements of DI to define diagram interchange elements for a language. + + + + + This element should never be instantiated directly, but rather concrete implementation should. It is placed there only to be referred in the sequence + + + + + + DiagramElement is the abstract super type of all elements in diagrams, including diagrams themselves. When contained in a diagram, diagram elements are laid out relative to the diagram's origin. + + + + + + + + + + + + an optional locally-owned style for this diagram element. + + + + + + a reference to an optional shared style element for this diagram element. + + + + + + + + + + + + the name of the diagram. + + + + + the documentation of the diagram. + + + + + the resolution of the diagram expressed in user units per inch. + + + + + + + + + + + + + the optional bounds of the shape relative to the origin of its nesting plane. + + + + + + + + + + + + + + an optional list of points relative to the origin of the nesting diagram that specifies the connected line segments of the edge + + + + + + + + + + Style contains formatting properties that affect the appearance or style of diagram elements, including diagram themselves. + + + + + + + + + + + + + + + diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMN15.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMN15.xsd new file mode 100644 index 00000000000..382388d0e7e --- /dev/null +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMN15.xsd @@ -0,0 +1,587 @@ + + + + + + + Include the DMN Diagram Interchange (DI) schema + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd new file mode 100644 index 00000000000..87e84f9cf89 --- /dev/null +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd @@ -0,0 +1,102 @@ + + + + + + + + + + + This element should never be instantiated directly, but rather concrete implementation should. It is placed there only to be referred in the sequence + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/DRGELEM_NOT_UNIQUE.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/DRGELEM_NOT_UNIQUE.dmn index 09c0276d042..e1db3e8fe5b 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/DRGELEM_NOT_UNIQUE.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/DRGELEM_NOT_UNIQUE.dmn @@ -17,9 +17,9 @@ - + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/RELATION_DUP_COLUMN.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/RELATION_DUP_COLUMN.dmn index 29354bef73b..4630feeff41 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/RELATION_DUP_COLUMN.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/RELATION_DUP_COLUMN.dmn @@ -17,9 +17,9 @@ - + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/UNKNOWN_VARIABLE.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/UNKNOWN_VARIABLE.dmn index 6301d20c556..cca0810e86b 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/UNKNOWN_VARIABLE.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/UNKNOWN_VARIABLE.dmn @@ -17,9 +17,9 @@ - + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn index 89ed9ed9cf1..e9e1dc8767c 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/businesscontext/ORG_UNIT_DECISION_MADE_WRONG_TYPE.dmn @@ -17,9 +17,9 @@ + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/context/CONTEXT_DUP_ENTRY.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/context/CONTEXT_DUP_ENTRY.dmn index f10de329365..a8b51614c5c 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/context/CONTEXT_DUP_ENTRY.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/context/CONTEXT_DUP_ENTRY.dmn @@ -17,9 +17,9 @@ + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingDecisionInput.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingDecisionInput.dmn index 543f08dc9ab..311bec7253d 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingDecisionInput.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingDecisionInput.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingEncapsulated.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingEncapsulated.dmn index 69f60ae7a31..086e745a8e3 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingEncapsulated.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingEncapsulated.dmn @@ -1,4 +1,4 @@ - + diff --git a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingInputData.dmn b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingInputData.dmn index f9c5e2c67c0..6d047677146 100644 --- a/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingInputData.dmn +++ b/kie-dmn/kie-dmn-validation/src/test/resources/org/kie/dmn/validation/decisionservice/DS1ofEach_missingInputData.dmn @@ -1,4 +1,4 @@ - +