Added labels for setup code, reviewed labels for FirstToLowerCase

This commit is contained in:
Nils Weidmann 2024-04-06 14:50:52 +00:00
parent d55fdea0d7
commit ef971a5064
2 changed files with 27 additions and 12 deletions

View file

@ -1,9 +1,10 @@
// All boiler plate, setup
// Setup 2
package org.eneo.class2relational;
// Setup 34 (17 * 2)
import java.util.List;
import org.emoflon.neo.api.classtorelational.API_ClassToRelational;
import org.emoflon.neo.api.classtorelational.run.ClassToRelational_FWD_OPT_Run;
import org.emoflon.neo.api.classtorelational.tgg.API_ClassToRelational_FWD_OPT;
@ -21,20 +22,30 @@ import org.emoflon.neo.engine.modules.updatepolicies.ForwardTransformationOperat
import org.emoflon.neo.engine.modules.valueGenerators.LoremIpsumStringValueGenerator;
import org.emoflon.neo.engine.modules.valueGenerators.ModelNameValueGenerator;
// Setup 5
public class ClassToRelational_FWD_OPT_Run_App extends ClassToRelational_FWD_OPT_Run {
// Setup 6
public ClassToRelational_FWD_OPT_Run_App(String srcModelName, String trgModelName) {
// Setup 4
super(srcModelName, trgModelName, SupportedILPSolver.Sat4J);
}
// Setup 5
public NeoGenerator createGenerator(NeoCoreBuilder builder) {
// Setup 5
var api = new API_ClassToRelational(builder);
// Setup 5
var genAPI = new API_ClassToRelational_GEN(builder);
// Setup 5
var fwd_optAPI = new API_ClassToRelational_FWD_OPT(builder);
// Setup 3
var genRules = genAPI.getAllRulesForClassToRelational_GEN();
// Setup 8
var analyser = new TripleRuleAnalyser(new API_ClassToRelational(builder).getTripleRulesOfClassToRelational());
// Setup 4
var choiceOfFwdRules = fwd_optAPI.getAllRulesForClassToRelational_FWD_OPT();
// Setup 11
forwardTransformation = new ForwardTransformationOperationalStrategy(//
solver, //
builder, //
@ -44,7 +55,8 @@ public class ClassToRelational_FWD_OPT_Run_App extends ClassToRelational_FWD_OPT
srcModelName, //
trgModelName//
);
// Setup 27
var gen = new NeoGenerator(//
choiceOfFwdRules, //
new NoOpStartup(), //
@ -57,8 +69,10 @@ public class ClassToRelational_FWD_OPT_Run_App extends ClassToRelational_FWD_OPT
new ModelNameValueGenerator(srcModelName, trgModelName), //
List.of(new LoremIpsumStringValueGenerator()));
// Setup 6
gen.getAttrConstrContainer().addCreator("firstToLowerCase", () -> new FirstToLowerCase());
// Setup 2
return gen;
}
}

View file

@ -6,7 +6,7 @@ import org.emoflon.neo.engine.modules.attributeConstraints.NeoAttributeConstrain
//Setup 2
import org.emoflon.neo.engine.modules.attributeConstraints.NeoAttributeConstraintVariable;
//Setup 4
//Setup 4 (Nils 5)
public class FirstToLowerCase extends NeoAttributeConstraint {
/**
@ -14,16 +14,16 @@ public class FirstToLowerCase extends NeoAttributeConstraint {
*
*/
@Override
// Setup 2
// Setup 2 (Nils 3)
public void solve() {
// Setup 5
if (variables.size() != 2)
// Setup 4
throw new RuntimeException("The CSP -ToLowerCase- needs exactly two variables");
// Setup 3
// Setup 3 (Nils 5)
NeoAttributeConstraintVariable word = variables.get(0);
// Setup 3
// Setup 3 (Nils 5)
NeoAttributeConstraintVariable lowerCase = variables.get(1);
// Setup 5
@ -42,8 +42,9 @@ public class FirstToLowerCase extends NeoAttributeConstraint {
lowerCase.bindToValue(firstToLower(word.getValue().toString()));
// Setup 2
setSatisfied(true);
// Setup 1 (Nils)
} else {
// Setup 5
// Setup 5 (Nils 6)
throw new UnsupportedOperationException(
"This case in the constraint has not been implemented yet: " + bindingStates);
}
@ -51,7 +52,7 @@ public class FirstToLowerCase extends NeoAttributeConstraint {
// Setup 5
private String firstToLower(String s) {
// Transformation 6
// Transformation 6 (Nils 11)
return s.toLowerCase().charAt(0) + s.substring(1, s.length());
}
}