Skip to content

Commit

Permalink
[#651] Annotations: Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
opatrascoiu committed Apr 10, 2024
1 parent 5a11030 commit c93509e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Pair<DMNModelRepository, List<TestLab>> transform(DMNModelRepository repo
}

private DMNModelRepository cleanRuleDescription(DMNModelRepository repository, BuildLogger logger) {
logger.debug("Clean rule descriptions ...");
RuleDescriptionVisitor dmnVisitor = new RuleDescriptionVisitor(this.errorHandler, this.logger);
TransformationContext context = new TransformationContext(repository);
for (TDefinitions definitions: repository.getAllDefinitions()) {
Expand Down Expand Up @@ -101,7 +102,7 @@ public DMNBaseElement visit(TDecision element, TransformationContext context) {
TExpression expression = repository.expression(element);
if (expression instanceof TDecisionTable) {
logger.debug(String.format("Process decision table in decision '%s'", element.getName()));
((TDecisionTable) expression).accept(this, context);
expression.accept(this, context);
}
return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@
import com.gs.dmn.transformation.basic.BasicDMNToNativeTransformer;
import com.gs.dmn.transformation.lazy.LazyEvaluationDetector;
import com.gs.dmn.transformation.native_.statement.Statement;
import com.gs.dmn.transformation.proto.ProtoBufferJavaFactory;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -58,11 +55,6 @@ public BasicSignavioDMNToJavaTransformer(DMNDialectDefinition<?, ?, ?, ?, ?, ?>
this.dmnModelRepository = (SignavioDMNModelRepository) super.getDMNModelRepository();
}

@Override
protected void setProtoBufferFactory(BasicDMNToJavaTransformer transformer) {
this.protoFactory = new ProtoBufferJavaFactory(this);
}

@Override
protected void setDMNEnvironmentFactory(BasicDMNToNativeTransformer<Type, DMNContext> transformer) {
this.dmnEnvironmentFactory = new SignavioDMNEnvironmentFactory(transformer);
Expand Down Expand Up @@ -156,11 +148,8 @@ protected List<Pair<String, Type>> bkmParameters(DRGElementReference<TBusinessKn
TBusinessKnowledgeModel bkm = reference.getElement();
TFunctionDefinition encapsulatedLogic = bkm.getEncapsulatedLogic();
if (encapsulatedLogic == null) {
List<FormalParameter<Type>> parameters = new ArrayList<>();
TDecision outputDecision = this.dmnModelRepository.getOutputDecision(bkm);
DRGElementReference<TDecision> outputReference = this.dmnModelRepository.makeDRGElementReference(outputDecision);
List<Pair<String, Type>> paramaters = this.drgElementTypeSignature(outputDecision);
return paramaters;
return this.drgElementTypeSignature(outputDecision);
} else {
return super.bkmParameters(reference, nameProducer);
}
Expand Down Expand Up @@ -300,50 +289,6 @@ public String iterationExpressionToNative(TDecision decision, String iterationEx
return literalExpressionToNative(decision, iterationExpression);
}

private String iterationSignature(TDecision decision) {
List<DRGElementReference<? extends TDRGElement>> dmnReferences = collectIterationInputs(decision);
List<Pair<String, String>> parameters = new ArrayList<>();
for (DRGElementReference<? extends TDRGElement> reference : dmnReferences) {
TDRGElement element = reference.getElement();
String parameterName = iterationParameterName(element);
String parameterNativeType = lazyEvaluationType(element, parameterNativeType(element));
parameters.add(new Pair<>(parameterName, parameterNativeType));
}
String signature = parameters.stream().map(p -> this.nativeFactory.nullableParameter(p.getRight(), p.getLeft())).collect(Collectors.joining(", "));
return augmentSignature(signature);
}

private String iterationArgumentList(TDecision decision) {
List<DRGElementReference<? extends TDRGElement>> dmnReferences = collectIterationInputs(decision);

List<String> arguments = new ArrayList<>();
for (DRGElementReference<? extends TDRGElement> reference: dmnReferences) {
TDRGElement element = reference.getElement();
String argumentName = iterationArgumentName(element);
arguments.add(argumentName);
}
String argumentList = String.join(", ", arguments);
return augmentArgumentList(argumentList);
}

private List<DRGElementReference<? extends TDRGElement>> collectIterationInputs(TDecision decision) {
Set<DRGElementReference<? extends TDRGElement>> elementSet = new LinkedHashSet<>();
DRGElementReference<TDecision> decisionReference = this.dmnModelRepository.makeDRGElementReference(decision);
elementSet.addAll(this.dmnModelRepository.inputDataClosure(decisionReference, this.drgElementFilter));
elementSet.addAll(this.dmnModelRepository.directSubDecisions(decision));
List<DRGElementReference<? extends TDRGElement>> elements = new ArrayList<>(elementSet);
this.dmnModelRepository.sortNamedElementReferences(elements);
return elements;
}

private String iterationParameterName(TDRGElement element) {
return namedElementVariableName(element);
}

private String iterationArgumentName(TDRGElement element) {
return namedElementVariableName(element);
}

//
// Free text LiteralExpression related functions
//
Expand Down

0 comments on commit c93509e

Please sign in to comment.