Commit 81566ba3 authored by Ådne Karstad's avatar Ådne Karstad

[minor] Add simple AQL validations

parent 8377520b
......@@ -10,11 +10,9 @@
name="Lektor i realfag"
duration="IntegratedMasters">
<semesters
year="1"
selectedCourses="//@institutes.0/@courses.0"/>
<semesters
season="Spring"
year="1"
selectedCourses="//@institutes.0/@courses.4 //@institutes.1/@courses.1"/>
<semesters
season="Spring"
......@@ -23,8 +21,13 @@
<semesters
year="4"
selectedCourses="//@institutes.0/@courses.1 //@institutes.0/@courses.2"/>
<semesters
year="2"
selectedCourses="//@institutes.1/@courses.2"/>
<mandatoryCourses
courses="//@institutes.0/@courses.0 //@institutes.0/@courses.3"/>
courses="//@institutes.0/@courses.0 //@institutes.0/@courses.3 //@institutes.0/@courses.4 //@institutes.1/@courses.0 //@institutes.1/@courses.1 //@institutes.1/@courses.2"/>
<electiveCourses
courses="//@institutes.0/@courses.1 //@institutes.0/@courses.2"/>
</programs>
<institutes
name="Institutt for datateknologi og informatikk">
......@@ -65,5 +68,10 @@
name="Grunnkurs i analyse II"
credits="7.5"
season="Spring"/>
<courses
code="TMA4135"
name="Matematikk 4D"
credits="7.5"
level="ThirdYearCourse"/>
</institutes>
</spp:University>
......@@ -2,6 +2,9 @@
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="spp" nsURI="platform:/plugin/tdt4250.spp.model/model/spp.ecore"
nsPrefix="spp">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
<details key="validationDelegates" value="http://www.eclipse.org/acceleo/query/1.0"/>
</eAnnotations>
<eClassifiers xsi:type="ecore:EClass" name="University">
<eStructuralFeatures xsi:type="ecore:EReference" name="programs" upperBound="-1"
eType="#//Program" containment="true"/>
......@@ -36,7 +39,10 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Semester">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
<details key="constraints" value="needsEnoughCredits"/>
<details key="constraints" value="needsEnoughCredits coursesNeedsToBeMandatoryOrElectiveCourses"/>
</eAnnotations>
<eAnnotations source="http://www.eclipse.org/acceleo/query/1.0">
<details key="coursesNeedsToBeMandatoryOrElectiveCourses" value="(self.selectedCourses->intersection(self.eContainer().mandatoryCourses.courses))->notEmpty() or (self.selectedCourses->intersection(self.eContainer().electiveCourses.courses))->notEmpty()"/>
</eAnnotations>
<eOperations name="getCredits" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="season" eType="#//SeasonType"/>
......@@ -63,6 +69,12 @@
eOpposite="#//Program/specialisation"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="MandatoryCourses">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
<details key="constraints" value="needsToHaveEmptyIntersectionWithElectiveCourses"/>
</eAnnotations>
<eAnnotations source="http://www.eclipse.org/acceleo/query/1.0">
<details key="needsToHaveEmptyIntersectionWithElectiveCourses" value="self.eContainer().electiveCourses.courses->intersection(self.courses)->isEmpty()"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="program" eType="#//Program"
eOpposite="#//Program/mandatoryCourses"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="courses" upperBound="-1"
......
......@@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.EObject;
*
* @see tdt4250.spp.SppPackage#getSemester()
* @model annotation="http://www.eclipse.org/emf/2002/Ecore constraints='needsEnoughCredits'"
* annotation="http://www.eclipse.org/acceleo/query/1.0 coursesNeedsToBeMandatoryOrElectiveCourses='(self.selectedCourses-&gt;intersection(self.eContainer().mandatoryCourses.courses))-&gt;notEmpty() or (self.selectedCourses-&gt;intersection(self.eContainer().electiveCourses.courses))-&gt;notEmpty()'"
* @generated
*/
public interface Semester extends EObject {
......
......@@ -24,6 +24,7 @@ import org.eclipse.emf.ecore.EReference;
* <!-- end-user-doc -->
* @see tdt4250.spp.SppFactory
* @model kind="package"
* annotation="http://www.eclipse.org/emf/2002/Ecore validationDelegates='http://www.eclipse.org/acceleo/query/1.0'"
* @generated
*/
public interface SppPackage extends EPackage {
......
......@@ -266,9 +266,6 @@ public class SppFactoryImpl extends EFactoryImpl implements SppFactory {
* @generated
*/
public String createCourseCodeFromString(EDataType eDataType, String initialValue) {
if (! initialValue.matches("[A-Z]{2,4}[0-9]{4}")) {
throw new IllegalArgumentException("Course code must have the format [A-Z]{2,4}[0-9]{4}, e.g. TDT4250");
}
return (String)super.createFromString(eDataType, initialValue);
}
......
......@@ -810,6 +810,8 @@ public class SppPackageImpl extends EPackageImpl implements SppPackage {
// Create annotations
// http://www.eclipse.org/emf/2002/Ecore
createEcoreAnnotations();
// http://www.eclipse.org/acceleo/query/1.0
create_1Annotations();
}
/**
......@@ -820,6 +822,12 @@ public class SppPackageImpl extends EPackageImpl implements SppPackage {
*/
protected void createEcoreAnnotations() {
String source = "http://www.eclipse.org/emf/2002/Ecore";
addAnnotation
(this,
source,
new String[] {
"validationDelegates", "http://www.eclipse.org/acceleo/query/1.0"
});
addAnnotation
(programEClass,
source,
......@@ -834,4 +842,20 @@ public class SppPackageImpl extends EPackageImpl implements SppPackage {
});
}
/**
* Initializes the annotations for <b>http://www.eclipse.org/acceleo/query/1.0</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void create_1Annotations() {
String source = "http://www.eclipse.org/acceleo/query/1.0";
addAnnotation
(semesterEClass,
source,
new String[] {
"coursesNeedsToBeMandatoryOrElectiveCourses", "(self.selectedCourses->intersection(self.eContainer().mandatoryCourses.courses))->notEmpty() or (self.selectedCourses->intersection(self.eContainer().electiveCourses.courses))->notEmpty()"
});
}
} //SppPackageImpl
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment