From 60f01f46ba232ed6416054f0a6115cb2a9b70b4e Mon Sep 17 00:00:00 2001 From: OszkarSemerath Date: Sat, 10 Jun 2017 19:05:05 +0200 Subject: Migrating Additional projects --- .../inf/dslreasoner/ecore2logic/Ecore2Logic.xtend | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Framework/hu.bme.mit.inf.dslreasoner.ecore2logic/src/hu/bme/mit/inf/dslreasoner/ecore2logic/Ecore2Logic.xtend (limited to 'Framework/hu.bme.mit.inf.dslreasoner.ecore2logic/src/hu/bme/mit/inf/dslreasoner/ecore2logic/Ecore2Logic.xtend') diff --git a/Framework/hu.bme.mit.inf.dslreasoner.ecore2logic/src/hu/bme/mit/inf/dslreasoner/ecore2logic/Ecore2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.ecore2logic/src/hu/bme/mit/inf/dslreasoner/ecore2logic/Ecore2Logic.xtend new file mode 100644 index 00000000..cae489e3 --- /dev/null +++ b/Framework/hu.bme.mit.inf.dslreasoner.ecore2logic/src/hu/bme/mit/inf/dslreasoner/ecore2logic/Ecore2Logic.xtend @@ -0,0 +1,98 @@ +package hu.bme.mit.inf.dslreasoner.ecore2logic + +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem +import java.util.List +import org.eclipse.emf.ecore.EAttribute +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EEnum +import org.eclipse.emf.ecore.EEnumLiteral +import org.eclipse.emf.ecore.EReference +import org.eclipse.xtend.lib.annotations.Data +import org.eclipse.xtend.lib.annotations.Delegate +import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput +import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder +import java.util.Set +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.ContainmentHierarchy + +@Data class EcoreMetamodelDescriptor { + val List classes; + val Set concretised; + val boolean isEObjectConcretised; + val List enums; + val List literals; + val List references; + val List attributes; + + def isConcretised(EClass clazz) {concretised.contains(clazz)} +} + +interface Trace {} + +class Ecore2Logic_Trace implements Trace { + public var ContainmentHierarchy containmentHierarchy; + public var Trace classMapperTrace + public var Trace enumMapperTrace + public var Trace referenceMapperTrace + public var Trace containmentMapperTrace + public var Trace attributeMapperTrace +} + +class Ecore2LogicConfiguration { + var public boolean singleRoot = true + var public int numberOfObjects = -1 + public static val Undefined = -1 +} + +class Ecore2LogicScope { + public static val int Unlimited = -1 + public var numberOfObjects = Unlimited +} + +class Ecore2Logic implements EClassMapper, EEnumMapper, EReferenceMapper, ContainmentMapper, EAttributeMapper { + @Delegate protected val EClassMapper classMapper + @Delegate protected val EEnumMapper enumMapper + @Delegate protected val EReferenceMapper referenceMapper + @Delegate protected val ContainmentMapper containmentMapper + @Delegate protected val EAttributeMapper attributeMapper + + public new() { + this.classMapper = new EClassMapper_AllElementAsObject + this.enumMapper = new EEnumMapper_PredefinedClasses + this.referenceMapper = new EReferenceMapper_RelationsOverTypes(this.classMapper) + this.containmentMapper = new ContainmentMapper_ReferenceConjuction(this.classMapper, this.referenceMapper,0) + this.attributeMapper = new EAttributeMapper_RelationsOverTypes(this.classMapper, this.enumMapper) + } + + public new( + EClassMapper classMapper, + EEnumMapper enumMapper, + EReferenceMapper referenceMapper, + ContainmentMapper containmentMapper, + EAttributeMapper attributeMapper) + { + if(classMapper === null || enumMapper === null || referenceMapper === null || containmentMapper === null || + attributeMapper === null) { + throw new IllegalArgumentException('''The mappers should not be null!''') + } + + this.classMapper = classMapper + this.enumMapper = enumMapper + this.referenceMapper = referenceMapper + this.containmentMapper = containmentMapper + this.attributeMapper = attributeMapper + } + + def public TracedOutput transformMetamodel(EcoreMetamodelDescriptor metamodel, Ecore2LogicConfiguration config) { + + + val Ecore2Logic_Trace trace = new Ecore2Logic_Trace + val LogicProblem problem = (new LogicProblemBuilder).createProblem + transformEClasses(trace,problem,metamodel.classes,config.numberOfObjects,metamodel) + transformEEnums(trace,problem,metamodel.enums,config) + transformEReferences(trace,problem,metamodel.references) + transformContainment(trace,problem,metamodel.references, config.singleRoot) + transformEAttributes(trace,problem,metamodel.attributes) + + return new TracedOutput(problem,trace) + } +} -- cgit v1.2.3-54-g00ecf