mirror of
https://github.com/eMoflon/emoflon-neo.git
synced 2024-05-21 04:00:37 +00:00
Added interface for reporting inconsistencies.
This commit is contained in:
parent
f86dfff644
commit
e74bd3a328
|
@ -23,6 +23,7 @@ import org.emoflon.neo.engine.api.constraints.IConstraint;
|
|||
import org.emoflon.neo.engine.api.patterns.IMatch;
|
||||
import org.emoflon.neo.engine.api.rules.IRule;
|
||||
import org.emoflon.neo.engine.generator.MatchContainer;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.generator.modules.IMonitor;
|
||||
import org.emoflon.neo.engine.generator.modules.IUpdatePolicy;
|
||||
import org.emoflon.neo.engine.ilp.BinaryILPProblem;
|
||||
|
@ -59,9 +60,11 @@ public abstract class ILPBasedOperationalStrategy implements IUpdatePolicy<NeoMa
|
|||
|
||||
protected String sourceModel;
|
||||
protected String targetModel;
|
||||
|
||||
protected IInconsistencyReporter inconsistencyReporter;
|
||||
|
||||
protected SupportedILPSolver solver;
|
||||
|
||||
|
||||
public ILPBasedOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
Collection<NeoRule> genRules, //
|
||||
|
@ -69,7 +72,20 @@ public abstract class ILPBasedOperationalStrategy implements IUpdatePolicy<NeoMa
|
|||
Collection<IConstraint> negativeConstraints, //
|
||||
NeoCoreBuilder builder, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
String targetModel //
|
||||
) {
|
||||
this(solver, genRules, opRules, negativeConstraints, null, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public ILPBasedOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter, //
|
||||
NeoCoreBuilder builder, //
|
||||
String sourceModel, //
|
||||
String targetModel //
|
||||
) {
|
||||
this.sourceModel = sourceModel;
|
||||
this.targetModel = targetModel;
|
||||
|
@ -81,6 +97,8 @@ public abstract class ILPBasedOperationalStrategy implements IUpdatePolicy<NeoMa
|
|||
elementToDependentMatches = new HashMap<>();
|
||||
|
||||
this.solver = solver;
|
||||
|
||||
this.inconsistencyReporter = inconsistencyReporter;
|
||||
|
||||
this.genRules = new HashMap<>();
|
||||
genRules.forEach(tr -> this.genRules.put(tr.getName(), tr));
|
||||
|
@ -565,6 +583,11 @@ public abstract class ILPBasedOperationalStrategy implements IUpdatePolicy<NeoMa
|
|||
var inconsistentElements = determineInconsistentElements();
|
||||
logger.info(inconsistentElements.size() + " elements of your triple are inconsistent!");
|
||||
logger.debug("Inconsistent element IDs: " + inconsistentElements);
|
||||
if (inconsistencyReporter != null) {
|
||||
Collection<Long> inconsistentNodeIds = inconsistentElements.stream().filter(x -> x >= 0).toList();
|
||||
Collection<Long> inconsistentRelationshipIds = inconsistentElements.stream().filter(x -> x < 0).map(x -> x*-1).toList();
|
||||
inconsistencyReporter.reportInconsistencies(inconsistentNodeIds, inconsistentRelationshipIds);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.emoflon.neo.cypher.models.NeoCoreBuilder;
|
|||
import org.emoflon.neo.cypher.rules.NeoRule;
|
||||
import org.emoflon.neo.engine.api.constraints.IConstraint;
|
||||
import org.emoflon.neo.engine.generator.modules.ICleanupModule;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPBasedOperationalStrategy;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPFactory.SupportedILPSolver;
|
||||
|
||||
|
@ -21,6 +22,19 @@ public class BackwardTransformationOperationalStrategy extends ILPBasedOperation
|
|||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public BackwardTransformationOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
NeoCoreBuilder builder, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, inconsistencyReporter, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.emoflon.neo.engine.api.constraints.IConstraint;
|
|||
import org.emoflon.neo.engine.api.rules.IRule;
|
||||
import org.emoflon.neo.engine.generator.MatchContainer;
|
||||
import org.emoflon.neo.engine.generator.modules.ICleanupModule;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.generator.modules.IMonitor;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPBasedOperationalStrategy;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPFactory.SupportedILPSolver;
|
||||
|
@ -24,11 +25,24 @@ public class CheckOnlyOperationalStrategy extends ILPBasedOperationalStrategy im
|
|||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter,
|
||||
NeoCoreBuilder builder, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, builder, sourceModel, targetModel);
|
||||
super(solver, genRules, opRules, negativeConstraints, inconsistencyReporter, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public CheckOnlyOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
NeoCoreBuilder builder, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, null, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.emoflon.neo.cypher.models.NeoCoreBuilder;
|
|||
import org.emoflon.neo.cypher.rules.NeoRule;
|
||||
import org.emoflon.neo.engine.api.constraints.IConstraint;
|
||||
import org.emoflon.neo.engine.generator.modules.ICleanupModule;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPBasedOperationalStrategy;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPFactory.SupportedILPSolver;
|
||||
|
||||
|
@ -21,6 +22,19 @@ public class CorrCreationOperationalStrategy extends ILPBasedOperationalStrategy
|
|||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public CorrCreationOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
NeoCoreBuilder builder, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, inconsistencyReporter, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.emoflon.neo.cypher.models.NeoCoreBuilder;
|
|||
import org.emoflon.neo.cypher.rules.NeoRule;
|
||||
import org.emoflon.neo.engine.api.constraints.IConstraint;
|
||||
import org.emoflon.neo.engine.generator.modules.ICleanupModule;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPBasedOperationalStrategy;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPFactory.SupportedILPSolver;
|
||||
|
||||
|
@ -21,6 +22,19 @@ public class ForwardTransformationOperationalStrategy extends ILPBasedOperationa
|
|||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public ForwardTransformationOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
NeoCoreBuilder builder, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, inconsistencyReporter, builder, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.emoflon.neo.engine.api.constraints.IConstraint;
|
|||
import org.emoflon.neo.engine.api.rules.IRule;
|
||||
import org.emoflon.neo.engine.generator.MatchContainer;
|
||||
import org.emoflon.neo.engine.generator.modules.ICleanupModule;
|
||||
import org.emoflon.neo.engine.generator.modules.IInconsistencyReporter;
|
||||
import org.emoflon.neo.engine.generator.modules.IMonitor;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPBasedOperationalStrategy;
|
||||
import org.emoflon.neo.engine.modules.ilp.ILPFactory.SupportedILPSolver;
|
||||
|
@ -29,7 +30,7 @@ public class ModelIntegrationOperationalStrategy extends ILPBasedOperationalStra
|
|||
private static double alpha; // delete-delta
|
||||
private static double beta; // create-delta
|
||||
private static double gamma; // added elements
|
||||
|
||||
|
||||
public ModelIntegrationOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
NeoCoreBuilder builder, //
|
||||
|
@ -39,7 +40,20 @@ public class ModelIntegrationOperationalStrategy extends ILPBasedOperationalStra
|
|||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, builder, sourceModel, targetModel);
|
||||
this(solver, builder, genRules, opRules, negativeConstraints, null, sourceModel, targetModel);
|
||||
}
|
||||
|
||||
public ModelIntegrationOperationalStrategy(//
|
||||
SupportedILPSolver solver, //
|
||||
NeoCoreBuilder builder, //
|
||||
Collection<NeoRule> genRules, //
|
||||
Collection<NeoRule> opRules, //
|
||||
Collection<IConstraint> negativeConstraints, //
|
||||
IInconsistencyReporter inconsistencyReporter, //
|
||||
String sourceModel, //
|
||||
String targetModel//
|
||||
) {
|
||||
super(solver, genRules, opRules, negativeConstraints, inconsistencyReporter, builder, sourceModel, targetModel);
|
||||
setWeightings(builder.getAlpha(), builder.getBeta(), builder.getGamma());
|
||||
opRuleNameToGenRule = new HashMap<>();
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package org.emoflon.neo.engine.generator.modules;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IInconsistencyReporter {
|
||||
void reportInconsistencies(Collection<Long> inconsistentNodeIds, Collection<Long> inconsistentRelationshipIds);
|
||||
}
|
Loading…
Reference in a new issue