diff --git a/src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/SchemaCmdParser.kt b/src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/SchemaCmdParser.kt index 97f1123fb6ec9ab6682253d9c6a5e6ca5876b48a..c65fb94d0d71b4b13486072c46637812c26aa392 100644 --- a/src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/SchemaCmdParser.kt +++ b/src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/SchemaCmdParser.kt @@ -12,10 +12,26 @@ object SchemaCmdParser { } fun parseFunctionals(tableName: String,setExpression: String): Set<Constraint> { + return parseConstraint(setExpression, tableName, Constraint.TYPE.FUNCTIONAL.name) + } + + fun parseMultivalued(tableName: String,setExpression: String): Set<Constraint> { + return parseConstraint(setExpression, tableName, Constraint.TYPE.MULTIVALUED.name) + } + + fun parseInclusion(tableName: String,setExpression: String): Set<Constraint> { + return parseConstraint(setExpression, tableName, Constraint.TYPE.INCLUSION.name) + } + + fun parseDoubleInclusion(tableName: String,setExpression: String): Set<Constraint> { + return parseConstraint(setExpression, tableName, Constraint.TYPE.DOUBLE_INCLUSION.name) + } + + private fun parseConstraint(setExpression: String, tableName: String, type:String): Set<Constraint> { val constraintsToAdd = Constraint.set(setExpression) for (constraint in constraintsToAdd) { - constraint.name = tableName + ".functional" - constraint.type = Constraint.TYPE.FUNCTIONAL.name + constraint.name = "$tableName.$type" + constraint.type = type constraint.source.table = tableName constraint.target.table = tableName }