diff --git a/.classpath b/.classpath index 22f30643cba38503dfc820a64bc4225fd8c743ba..213e409f908b6040f5359a3ff26f43473fd84b0b 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="xtend-gen"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/.project b/.project index cdcd0187afb04928c4181a0c7ed7ae75346f494e..fed0ee24ee8035b6977cae9055875063c032e9bf 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ <projects> </projects> <buildSpec> + <buildCommand> + <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> + <arguments> + </arguments> + </buildCommand> <buildCommand> <name>org.eclipse.ocl.pivot.ui.oclbuilder</name> <arguments> @@ -46,5 +51,6 @@ <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.ocl.pivot.ui.oclnature</nature> + <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> </natures> </projectDescription> diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 81be62eaf909cfc33f842fd721f0f41e958889d7..cb9c3a65a7635e686fea1ecdd96d8a3404cc803e 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -12,5 +12,12 @@ Export-Package: coursePage, coursePage.impl, coursePage.util Require-Bundle: org.eclipse.core.runtime, - org.eclipse.emf.ecore;visibility:=reexport + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.ecore.xmi;visibility:=reexport, + com.google.guava, + org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib, + org.eclipse.xtend.lib.macro, + org.w3c.xhtml1;bundle-version="0.1.0" Bundle-ActivationPolicy: lazy + diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..cc296370a7a9adc34803116a229143b076dac4f8 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +#Transformation + +##Plugin and extensions +Plug-in added to Plug-In dependencies: **org.w3c.xhtml1** +Extension used in Course2HTML.xtend: **Xhtml1Factory** and **XhtmlUtil** + +**Xhtml1Factory** +With this extension we can implement methods to generate html tags/types like createH1Type and createH2Type + +**XhtmlUtil** +Utilize methods from Xhtml1Factory. + + +##Transformation + +In this model i have done a Model 2 Text transformation. + +Source model : xmi +Target model: Text in html format + +To run the the sample provided in the transformation +1. Open Course2HTML.xtend in /tdt4250.web/src/tdt4250/transformation/Course2HTML.xtend +2. Right Click, Run As > Java Application +3. Console will display the output of the transfomration diff --git a/bin/coursePage/Slot.class b/bin/coursePage/Slot.class index 8948891dd115d35b37d8ca3f56b8a381d761ca7e..d05ea552ca35df67f394c8636d68936d99718051 100644 Binary files a/bin/coursePage/Slot.class and b/bin/coursePage/Slot.class differ diff --git a/bin/coursePage/impl/CoursePagePackageImpl.class b/bin/coursePage/impl/CoursePagePackageImpl.class index 416d445a20385eeb0b9d70c29621d7e91964a2a8..408d0278a105c53256b292a6fe391094fc3223fe 100644 Binary files a/bin/coursePage/impl/CoursePagePackageImpl.class and b/bin/coursePage/impl/CoursePagePackageImpl.class differ diff --git a/bin/coursePage/impl/EvaluationFormImpl.class b/bin/coursePage/impl/EvaluationFormImpl.class deleted file mode 100644 index 6dfb015cc70ed0dc559e2fa6236882ba1779c3b9..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/EvaluationFormImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/EventImpl.class b/bin/coursePage/impl/EventImpl.class deleted file mode 100644 index 2b04296f01629da0777e61e0464fb5ef32ec1c3e..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/EventImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/InformationImpl.class b/bin/coursePage/impl/InformationImpl.class deleted file mode 100644 index c9f8627eccd2ea83254eb9af4e9589ce8d0d6962..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/InformationImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/LabImpl.class b/bin/coursePage/impl/LabImpl.class deleted file mode 100644 index fde3fcf8f08fb63bf538a9681aac8109f08509bc..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/LabImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/LectureImpl.class b/bin/coursePage/impl/LectureImpl.class deleted file mode 100644 index d033e44b3e84972bae43a4e3c87f858ac3a5019c..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/LectureImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/OrganizationImpl.class b/bin/coursePage/impl/OrganizationImpl.class deleted file mode 100644 index edf4388c970706e4773b6b8d70ff31f372b4c5d2..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/OrganizationImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/RelationToOtherCoursesImpl.class b/bin/coursePage/impl/RelationToOtherCoursesImpl.class deleted file mode 100644 index 71b91b89648c5fbdde3bafeb903aabc61c3d9480..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/RelationToOtherCoursesImpl.class and /dev/null differ diff --git a/bin/coursePage/impl/SlotImpl.class b/bin/coursePage/impl/SlotImpl.class index 696211bf24b77260bd0782fde476c3195bc70c90..779060ef53a47f0a46b908c6d761dd5d841be900 100644 Binary files a/bin/coursePage/impl/SlotImpl.class and b/bin/coursePage/impl/SlotImpl.class differ diff --git a/bin/coursePage/impl/creditsImpl.class b/bin/coursePage/impl/creditsImpl.class deleted file mode 100644 index 6fb7e2794d05a920259301308e06675e25bbdbc4..0000000000000000000000000000000000000000 Binary files a/bin/coursePage/impl/creditsImpl.class and /dev/null differ diff --git a/bin/coursePage/util/CoursePageResourceFactoryImpl.class b/bin/coursePage/util/CoursePageResourceFactoryImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..c1521ebf4f1db810b3873bb1ef4f87257db3c83b Binary files /dev/null and b/bin/coursePage/util/CoursePageResourceFactoryImpl.class differ diff --git a/bin/coursePage/util/CoursePageResourceImpl.class b/bin/coursePage/util/CoursePageResourceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..6f37983c59184f3de3bed2d6d81a887fa3e87401 Binary files /dev/null and b/bin/coursePage/util/CoursePageResourceImpl.class differ diff --git a/bin/tdt4250/transformation/.Course2HTML.java._trace b/bin/tdt4250/transformation/.Course2HTML.java._trace new file mode 100644 index 0000000000000000000000000000000000000000..45b2449d975603ae77fb547cc8683d5a903a561d Binary files /dev/null and b/bin/tdt4250/transformation/.Course2HTML.java._trace differ diff --git a/bin/tdt4250/transformation/.Course2HTML.xtendbin b/bin/tdt4250/transformation/.Course2HTML.xtendbin new file mode 100644 index 0000000000000000000000000000000000000000..ea966ac41758aa9d1eb6d525f9338c8b8ce4ec1c Binary files /dev/null and b/bin/tdt4250/transformation/.Course2HTML.xtendbin differ diff --git a/bin/tdt4250/transformation/.XhtmlUtil.java._trace b/bin/tdt4250/transformation/.XhtmlUtil.java._trace new file mode 100644 index 0000000000000000000000000000000000000000..b11a4a6d7ecd69df8ed67cdc288801edad29ecff Binary files /dev/null and b/bin/tdt4250/transformation/.XhtmlUtil.java._trace differ diff --git a/bin/tdt4250/transformation/.XhtmlUtil.xtendbin b/bin/tdt4250/transformation/.XhtmlUtil.xtendbin new file mode 100644 index 0000000000000000000000000000000000000000..7f14767d8a52b5e21951f926aa9f7cec8033f2a4 Binary files /dev/null and b/bin/tdt4250/transformation/.XhtmlUtil.xtendbin differ diff --git a/bin/tdt4250/transformation/Course.xmi b/bin/tdt4250/transformation/Course.xmi new file mode 100644 index 0000000000000000000000000000000000000000..d740ed458f904fdd0b4d17db77b66ec87e0e578f --- /dev/null +++ b/bin/tdt4250/transformation/Course.xmi @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<coursePage:Course + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:coursePage="platform:/resource/tdt4250.web/model/coursePage.ecore" + code="TDT4100" + name="OOP" + content="content" + credits="7.5"> + <timetable> + <table starteTime="1415" + endTime="1600" + hours="5.0"/> + <table day="Tuesday" + room="EL6" + lectureType="lecture" + starteTime="1215" + endTime="1400" + hours="5.0"/> + </timetable> + <relation + creditsReduction="3.0"/> + <grading points="70.0"/> + <courseWork + lectureHours="5.0" + labHours="5.0"/> + <hasBeenTaught + semester="V16" + credits="7.5"/> + <courseStaff> + <inTheStaff + name="Hallvard Trætteberg"> + <role/> + <isCC/> + </inTheStaff> + <inTheStaff + name="Alf Inge"> + <role + role="assistant"/> + </inTheStaff> + </courseStaff> +</coursePage:Course> diff --git a/bin/tdt4250/transformation/Course2HTML.class b/bin/tdt4250/transformation/Course2HTML.class new file mode 100644 index 0000000000000000000000000000000000000000..ee452b8edd48d92d21a92d550d39f7f1f1a9e4dc Binary files /dev/null and b/bin/tdt4250/transformation/Course2HTML.class differ diff --git a/bin/tdt4250/transformation/XhtmlUtil.class b/bin/tdt4250/transformation/XhtmlUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..6aea8b798cc65f3140180c80d82f8dba1b576aec Binary files /dev/null and b/bin/tdt4250/transformation/XhtmlUtil.class differ diff --git a/model/Course.xmi b/model/Course.xmi index 02255e2382fadf89a5c36187cb3115f553922927..c8a876fa424a4f1684fc4e7b8e044164a0b53005 100644 --- a/model/Course.xmi +++ b/model/Course.xmi @@ -8,10 +8,14 @@ content="content" credits="7.5"> <timetable> - <table hours="5.0"/> + <table starteTime="1415" + endTime=""1600"" + hours="5.0"/> <table day="Tuesday" room="EL6" lectureType="lecture" + starteTime=""1215"" + endTime=""1400"" hours="5.0"/> </timetable> <relation diff --git a/model/Course1.xmi b/model/Course1.xmi new file mode 100644 index 0000000000000000000000000000000000000000..7dbfc5b4b59a0ca7b7d7bb8ea63b14c88475d234 --- /dev/null +++ b/model/Course1.xmi @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<coursePage:Course xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:coursePage="platform:/resource/tdt4250.web/model/coursePage.ecore"/> diff --git a/model/StudyProgram.xmi b/model/StudyProgram.xmi new file mode 100644 index 0000000000000000000000000000000000000000..9ad19e93d1467a63eaee46660004c5ab642685a5 --- /dev/null +++ b/model/StudyProgram.xmi @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<coursePage:StudyProgram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:coursePage="platform:/resource/tdt4250.web/model/coursePage.ecore"/> diff --git a/model/coursePage.ecore b/model/coursePage.ecore index 456144c0251d5a02c38dc4ba1b7861f1a21cfa1a..ebc4ca025d4ead1badae4d64002ce3c155dd9e0c 100644 --- a/model/coursePage.ecore +++ b/model/coursePage.ecore @@ -78,8 +78,8 @@ <eStructuralFeatures xsi:type="ecore:EAttribute" name="day" eType="#//Day"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="room" eType="#//Room"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="lectureType" eType="#//LectureType"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="starteTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="endTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="starteTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="endTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EReference" name="scheduleFor" lowerBound="1" upperBound="-1" eType="#//StudyProgram"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="hours" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/> diff --git a/model/coursePage.genmodel b/model/coursePage.genmodel index 24715aa498508172903c3ab330fd3da5ce499d73..b6df41f629705e5d3177f88ff4b11bcf7862c9db 100644 --- a/model/coursePage.genmodel +++ b/model/coursePage.genmodel @@ -4,7 +4,8 @@ rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false" operationReflection="true" importOrganizing="true"> <foreignModel>coursePage.ecore</foreignModel> - <genPackages prefix="CoursePage" disposableProviderFactory="true" ecorePackage="coursePage.ecore#/"> + <genPackages prefix="CoursePage" resource="XMI" disposableProviderFactory="true" + ecorePackage="coursePage.ecore#/"> <genEnums typeSafeEnumCompatible="false" ecoreEnum="coursePage.ecore#//Role"> <genEnumLiterals ecoreEnumLiteral="coursePage.ecore#//Role/lecturer"/> <genEnumLiterals ecoreEnumLiteral="coursePage.ecore#//Role/assistant"/> diff --git a/plugin.xml b/plugin.xml index 8a9ca1c596e6b2eec3b1aae340dbfab735225324..2fe8d954d5ce5566fb5f03bd3acd07e4101a2f49 100644 --- a/plugin.xml +++ b/plugin.xml @@ -14,4 +14,11 @@ genModel="model/coursePage.genmodel"/> </extension> + <extension point="org.eclipse.emf.ecore.extension_parser"> + <!-- @generated coursePage --> + <parser + type="coursepage" + class="coursePage.util.CoursePageResourceFactoryImpl"/> + </extension> + </plugin> diff --git a/src/coursePage/Slot.java b/src/coursePage/Slot.java index b6d3ca0f4d6a552342efa789fb18a00d089630a5..5e701ede0a76fb001ac46c906ad852f148e5eefd 100644 --- a/src/coursePage/Slot.java +++ b/src/coursePage/Slot.java @@ -2,8 +2,6 @@ */ package coursePage; -import java.util.Date; - import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; @@ -127,12 +125,12 @@ public interface Slot extends EObject { * </p> * <!-- end-user-doc --> * @return the value of the '<em>Starte Time</em>' attribute. - * @see #setStarteTime(Date) + * @see #setStarteTime(String) * @see coursePage.CoursePagePackage#getSlot_StarteTime() * @model * @generated */ - Date getStarteTime(); + String getStarteTime(); /** * Sets the value of the '{@link coursePage.Slot#getStarteTime <em>Starte Time</em>}' attribute. @@ -142,7 +140,7 @@ public interface Slot extends EObject { * @see #getStarteTime() * @generated */ - void setStarteTime(Date value); + void setStarteTime(String value); /** * Returns the value of the '<em><b>End Time</b></em>' attribute. @@ -153,12 +151,12 @@ public interface Slot extends EObject { * </p> * <!-- end-user-doc --> * @return the value of the '<em>End Time</em>' attribute. - * @see #setEndTime(Date) + * @see #setEndTime(String) * @see coursePage.CoursePagePackage#getSlot_EndTime() * @model * @generated */ - Date getEndTime(); + String getEndTime(); /** * Sets the value of the '{@link coursePage.Slot#getEndTime <em>End Time</em>}' attribute. @@ -168,7 +166,7 @@ public interface Slot extends EObject { * @see #getEndTime() * @generated */ - void setEndTime(Date value); + void setEndTime(String value); /** * Returns the value of the '<em><b>Schedule For</b></em>' reference list. diff --git a/src/coursePage/impl/CoursePagePackageImpl.java b/src/coursePage/impl/CoursePagePackageImpl.java index cec0bf496feb143b20837b276604aafb70971ffe..e0f149798dab706c309866a1f2fcc463a8953415 100644 --- a/src/coursePage/impl/CoursePagePackageImpl.java +++ b/src/coursePage/impl/CoursePagePackageImpl.java @@ -1031,8 +1031,8 @@ public class CoursePagePackageImpl extends EPackageImpl implements CoursePagePac initEAttribute(getSlot_Day(), this.getDay(), "day", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getSlot_Room(), this.getRoom(), "room", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getSlot_LectureType(), this.getLectureType(), "lectureType", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getSlot_StarteTime(), ecorePackage.getEDate(), "starteTime", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getSlot_EndTime(), ecorePackage.getEDate(), "endTime", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getSlot_StarteTime(), ecorePackage.getEString(), "starteTime", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getSlot_EndTime(), ecorePackage.getEString(), "endTime", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getSlot_ScheduleFor(), this.getStudyProgram(), null, "scheduleFor", null, 1, -1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getSlot_Hours(), ecorePackage.getEDouble(), "hours", null, 0, 1, Slot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); diff --git a/src/coursePage/impl/EvaluationFormImpl.java b/src/coursePage/impl/EvaluationFormImpl.java deleted file mode 100644 index 5edcbe6deb12ccd0cdcf99c4fe6cfd7f0fc03c75..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/EvaluationFormImpl.java +++ /dev/null @@ -1,265 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.EvaluationForm; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Evaluation Form</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.EvaluationFormImpl#getExam <em>Exam</em>}</li> - * <li>{@link coursePage.impl.EvaluationFormImpl#getProject <em>Project</em>}</li> - * <li>{@link coursePage.impl.EvaluationFormImpl#getAssignment <em>Assignment</em>}</li> - * </ul> - * - * @generated - */ -public class EvaluationFormImpl extends MinimalEObjectImpl.Container implements EvaluationForm { - /** - * The default value of the '{@link #getExam() <em>Exam</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getExam() - * @generated - * @ordered - */ - protected static final double EXAM_EDEFAULT = 0.0; - /** - * The cached value of the '{@link #getExam() <em>Exam</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getExam() - * @generated - * @ordered - */ - protected double exam = EXAM_EDEFAULT; - /** - * The default value of the '{@link #getProject() <em>Project</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getProject() - * @generated - * @ordered - */ - protected static final double PROJECT_EDEFAULT = 0.0; - /** - * The cached value of the '{@link #getProject() <em>Project</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getProject() - * @generated - * @ordered - */ - protected double project = PROJECT_EDEFAULT; - /** - * The default value of the '{@link #getAssignment() <em>Assignment</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getAssignment() - * @generated - * @ordered - */ - protected static final double ASSIGNMENT_EDEFAULT = 0.0; - /** - * The cached value of the '{@link #getAssignment() <em>Assignment</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getAssignment() - * @generated - * @ordered - */ - protected double assignment = ASSIGNMENT_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EvaluationFormImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.EVALUATION_FORM; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getExam() { - return exam; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setExam(double newExam) { - double oldExam = exam; - exam = newExam; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVALUATION_FORM__EXAM, oldExam, exam)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getProject() { - return project; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setProject(double newProject) { - double oldProject = project; - project = newProject; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVALUATION_FORM__PROJECT, oldProject, project)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getAssignment() { - return assignment; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setAssignment(double newAssignment) { - double oldAssignment = assignment; - assignment = newAssignment; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVALUATION_FORM__ASSIGNMENT, oldAssignment, assignment)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.EVALUATION_FORM__EXAM: - return getExam(); - case CoursePagePackage.EVALUATION_FORM__PROJECT: - return getProject(); - case CoursePagePackage.EVALUATION_FORM__ASSIGNMENT: - return getAssignment(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.EVALUATION_FORM__EXAM: - setExam((Double)newValue); - return; - case CoursePagePackage.EVALUATION_FORM__PROJECT: - setProject((Double)newValue); - return; - case CoursePagePackage.EVALUATION_FORM__ASSIGNMENT: - setAssignment((Double)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.EVALUATION_FORM__EXAM: - setExam(EXAM_EDEFAULT); - return; - case CoursePagePackage.EVALUATION_FORM__PROJECT: - setProject(PROJECT_EDEFAULT); - return; - case CoursePagePackage.EVALUATION_FORM__ASSIGNMENT: - setAssignment(ASSIGNMENT_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.EVALUATION_FORM__EXAM: - return exam != EXAM_EDEFAULT; - case CoursePagePackage.EVALUATION_FORM__PROJECT: - return project != PROJECT_EDEFAULT; - case CoursePagePackage.EVALUATION_FORM__ASSIGNMENT: - return assignment != ASSIGNMENT_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (exam: "); - result.append(exam); - result.append(", project: "); - result.append(project); - result.append(", assignment: "); - result.append(assignment); - result.append(')'); - return result.toString(); - } - -} //EvaluationFormImpl diff --git a/src/coursePage/impl/EventImpl.java b/src/coursePage/impl/EventImpl.java deleted file mode 100644 index 257d4133b7158585acd7eb95aa4e476667d7499e..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/EventImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.Event; -import coursePage.StudyProgram; - -import java.util.Collection; -import java.util.Date; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; - -import org.eclipse.emf.ecore.util.EObjectResolvingEList; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Event</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.EventImpl#getDay <em>Day</em>}</li> - * <li>{@link coursePage.impl.EventImpl#getTime <em>Time</em>}</li> - * <li>{@link coursePage.impl.EventImpl#getDate <em>Date</em>}</li> - * <li>{@link coursePage.impl.EventImpl#getRoom <em>Room</em>}</li> - * <li>{@link coursePage.impl.EventImpl#getStudyprogram <em>Studyprogram</em>}</li> - * </ul> - * - * @generated - */ -public class EventImpl extends MinimalEObjectImpl.Container implements Event { - /** - * The default value of the '{@link #getDay() <em>Day</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDay() - * @generated - * @ordered - */ - protected static final String DAY_EDEFAULT = null; - - /** - * The cached value of the '{@link #getDay() <em>Day</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDay() - * @generated - * @ordered - */ - protected String day = DAY_EDEFAULT; - - /** - * The default value of the '{@link #getTime() <em>Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getTime() - * @generated - * @ordered - */ - protected static final int TIME_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getTime() <em>Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getTime() - * @generated - * @ordered - */ - protected int time = TIME_EDEFAULT; - - /** - * The default value of the '{@link #getDate() <em>Date</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDate() - * @generated - * @ordered - */ - protected static final Date DATE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getDate() <em>Date</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDate() - * @generated - * @ordered - */ - protected Date date = DATE_EDEFAULT; - - /** - * The default value of the '{@link #getRoom() <em>Room</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRoom() - * @generated - * @ordered - */ - protected static final String ROOM_EDEFAULT = null; - - /** - * The cached value of the '{@link #getRoom() <em>Room</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRoom() - * @generated - * @ordered - */ - protected String room = ROOM_EDEFAULT; - - /** - * The cached value of the '{@link #getStudyprogram() <em>Studyprogram</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getStudyprogram() - * @generated - * @ordered - */ - protected EList<StudyProgram> studyprogram; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EventImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.EVENT; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getDay() { - return day; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDay(String newDay) { - String oldDay = day; - day = newDay; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVENT__DAY, oldDay, day)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public int getTime() { - return time; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setTime(int newTime) { - int oldTime = time; - time = newTime; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVENT__TIME, oldTime, time)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Date getDate() { - return date; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDate(Date newDate) { - Date oldDate = date; - date = newDate; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVENT__DATE, oldDate, date)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getRoom() { - return room; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setRoom(String newRoom) { - String oldRoom = room; - room = newRoom; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.EVENT__ROOM, oldRoom, room)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<StudyProgram> getStudyprogram() { - if (studyprogram == null) { - studyprogram = new EObjectResolvingEList<StudyProgram>(StudyProgram.class, this, CoursePagePackage.EVENT__STUDYPROGRAM); - } - return studyprogram; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.EVENT__DAY: - return getDay(); - case CoursePagePackage.EVENT__TIME: - return getTime(); - case CoursePagePackage.EVENT__DATE: - return getDate(); - case CoursePagePackage.EVENT__ROOM: - return getRoom(); - case CoursePagePackage.EVENT__STUDYPROGRAM: - return getStudyprogram(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.EVENT__DAY: - setDay((String)newValue); - return; - case CoursePagePackage.EVENT__TIME: - setTime((Integer)newValue); - return; - case CoursePagePackage.EVENT__DATE: - setDate((Date)newValue); - return; - case CoursePagePackage.EVENT__ROOM: - setRoom((String)newValue); - return; - case CoursePagePackage.EVENT__STUDYPROGRAM: - getStudyprogram().clear(); - getStudyprogram().addAll((Collection<? extends StudyProgram>)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.EVENT__DAY: - setDay(DAY_EDEFAULT); - return; - case CoursePagePackage.EVENT__TIME: - setTime(TIME_EDEFAULT); - return; - case CoursePagePackage.EVENT__DATE: - setDate(DATE_EDEFAULT); - return; - case CoursePagePackage.EVENT__ROOM: - setRoom(ROOM_EDEFAULT); - return; - case CoursePagePackage.EVENT__STUDYPROGRAM: - getStudyprogram().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.EVENT__DAY: - return DAY_EDEFAULT == null ? day != null : !DAY_EDEFAULT.equals(day); - case CoursePagePackage.EVENT__TIME: - return time != TIME_EDEFAULT; - case CoursePagePackage.EVENT__DATE: - return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date); - case CoursePagePackage.EVENT__ROOM: - return ROOM_EDEFAULT == null ? room != null : !ROOM_EDEFAULT.equals(room); - case CoursePagePackage.EVENT__STUDYPROGRAM: - return studyprogram != null && !studyprogram.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (day: "); - result.append(day); - result.append(", time: "); - result.append(time); - result.append(", date: "); - result.append(date); - result.append(", room: "); - result.append(room); - result.append(')'); - return result.toString(); - } - -} //EventImpl diff --git a/src/coursePage/impl/InformationImpl.java b/src/coursePage/impl/InformationImpl.java deleted file mode 100644 index df2c4e30b28d911553e23cfdb69c099b215ccf5e..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/InformationImpl.java +++ /dev/null @@ -1,442 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.Day; -import coursePage.Information; -import coursePage.LectureType; -import coursePage.Room; -import coursePage.StudyProgram; - -import java.util.Collection; -import java.util.Date; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; - -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Information</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.InformationImpl#getDay <em>Day</em>}</li> - * <li>{@link coursePage.impl.InformationImpl#getRoom <em>Room</em>}</li> - * <li>{@link coursePage.impl.InformationImpl#getPlannedFor <em>Planned For</em>}</li> - * <li>{@link coursePage.impl.InformationImpl#getLectureType <em>Lecture Type</em>}</li> - * <li>{@link coursePage.impl.InformationImpl#getStarteTime <em>Starte Time</em>}</li> - * <li>{@link coursePage.impl.InformationImpl#getEndTime <em>End Time</em>}</li> - * </ul> - * - * @generated - */ -public class InformationImpl extends MinimalEObjectImpl.Container implements Information { - /** - * The default value of the '{@link #getDay() <em>Day</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDay() - * @generated - * @ordered - */ - protected static final Day DAY_EDEFAULT = Day.MONDAY; - - /** - * The cached value of the '{@link #getDay() <em>Day</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getDay() - * @generated - * @ordered - */ - protected Day day = DAY_EDEFAULT; - - /** - * The default value of the '{@link #getRoom() <em>Room</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRoom() - * @generated - * @ordered - */ - protected static final Room ROOM_EDEFAULT = Room.ROOM; - - /** - * The cached value of the '{@link #getRoom() <em>Room</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRoom() - * @generated - * @ordered - */ - protected Room room = ROOM_EDEFAULT; - - /** - * The cached value of the '{@link #getPlannedFor() <em>Planned For</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPlannedFor() - * @generated - * @ordered - */ - protected EList<StudyProgram> plannedFor; - - /** - * The default value of the '{@link #getLectureType() <em>Lecture Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLectureType() - * @generated - * @ordered - */ - protected static final LectureType LECTURE_TYPE_EDEFAULT = LectureType.LAB; - - /** - * The cached value of the '{@link #getLectureType() <em>Lecture Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLectureType() - * @generated - * @ordered - */ - protected LectureType lectureType = LECTURE_TYPE_EDEFAULT; - - /** - * The default value of the '{@link #getStarteTime() <em>Starte Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getStarteTime() - * @generated - * @ordered - */ - protected static final Date STARTE_TIME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getStarteTime() <em>Starte Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getStarteTime() - * @generated - * @ordered - */ - protected Date starteTime = STARTE_TIME_EDEFAULT; - - /** - * The default value of the '{@link #getEndTime() <em>End Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getEndTime() - * @generated - * @ordered - */ - protected static final Date END_TIME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getEndTime() <em>End Time</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getEndTime() - * @generated - * @ordered - */ - protected Date endTime = END_TIME_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected InformationImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.INFORMATION; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Day getDay() { - return day; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setDay(Day newDay) { - Day oldDay = day; - day = newDay == null ? DAY_EDEFAULT : newDay; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.INFORMATION__DAY, oldDay, day)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Room getRoom() { - return room; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setRoom(Room newRoom) { - Room oldRoom = room; - room = newRoom == null ? ROOM_EDEFAULT : newRoom; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.INFORMATION__ROOM, oldRoom, room)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<StudyProgram> getPlannedFor() { - if (plannedFor == null) { - plannedFor = new EObjectContainmentEList<StudyProgram>(StudyProgram.class, this, CoursePagePackage.INFORMATION__PLANNED_FOR); - } - return plannedFor; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public LectureType getLectureType() { - return lectureType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setLectureType(LectureType newLectureType) { - LectureType oldLectureType = lectureType; - lectureType = newLectureType == null ? LECTURE_TYPE_EDEFAULT : newLectureType; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.INFORMATION__LECTURE_TYPE, oldLectureType, lectureType)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Date getStarteTime() { - return starteTime; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStarteTime(Date newStarteTime) { - Date oldStarteTime = starteTime; - starteTime = newStarteTime; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.INFORMATION__STARTE_TIME, oldStarteTime, starteTime)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Date getEndTime() { - return endTime; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setEndTime(Date newEndTime) { - Date oldEndTime = endTime; - endTime = newEndTime; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.INFORMATION__END_TIME, oldEndTime, endTime)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case CoursePagePackage.INFORMATION__PLANNED_FOR: - return ((InternalEList<?>)getPlannedFor()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.INFORMATION__DAY: - return getDay(); - case CoursePagePackage.INFORMATION__ROOM: - return getRoom(); - case CoursePagePackage.INFORMATION__PLANNED_FOR: - return getPlannedFor(); - case CoursePagePackage.INFORMATION__LECTURE_TYPE: - return getLectureType(); - case CoursePagePackage.INFORMATION__STARTE_TIME: - return getStarteTime(); - case CoursePagePackage.INFORMATION__END_TIME: - return getEndTime(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.INFORMATION__DAY: - setDay((Day)newValue); - return; - case CoursePagePackage.INFORMATION__ROOM: - setRoom((Room)newValue); - return; - case CoursePagePackage.INFORMATION__PLANNED_FOR: - getPlannedFor().clear(); - getPlannedFor().addAll((Collection<? extends StudyProgram>)newValue); - return; - case CoursePagePackage.INFORMATION__LECTURE_TYPE: - setLectureType((LectureType)newValue); - return; - case CoursePagePackage.INFORMATION__STARTE_TIME: - setStarteTime((Date)newValue); - return; - case CoursePagePackage.INFORMATION__END_TIME: - setEndTime((Date)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.INFORMATION__DAY: - setDay(DAY_EDEFAULT); - return; - case CoursePagePackage.INFORMATION__ROOM: - setRoom(ROOM_EDEFAULT); - return; - case CoursePagePackage.INFORMATION__PLANNED_FOR: - getPlannedFor().clear(); - return; - case CoursePagePackage.INFORMATION__LECTURE_TYPE: - setLectureType(LECTURE_TYPE_EDEFAULT); - return; - case CoursePagePackage.INFORMATION__STARTE_TIME: - setStarteTime(STARTE_TIME_EDEFAULT); - return; - case CoursePagePackage.INFORMATION__END_TIME: - setEndTime(END_TIME_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.INFORMATION__DAY: - return day != DAY_EDEFAULT; - case CoursePagePackage.INFORMATION__ROOM: - return room != ROOM_EDEFAULT; - case CoursePagePackage.INFORMATION__PLANNED_FOR: - return plannedFor != null && !plannedFor.isEmpty(); - case CoursePagePackage.INFORMATION__LECTURE_TYPE: - return lectureType != LECTURE_TYPE_EDEFAULT; - case CoursePagePackage.INFORMATION__STARTE_TIME: - return STARTE_TIME_EDEFAULT == null ? starteTime != null : !STARTE_TIME_EDEFAULT.equals(starteTime); - case CoursePagePackage.INFORMATION__END_TIME: - return END_TIME_EDEFAULT == null ? endTime != null : !END_TIME_EDEFAULT.equals(endTime); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (day: "); - result.append(day); - result.append(", room: "); - result.append(room); - result.append(", lectureType: "); - result.append(lectureType); - result.append(", starteTime: "); - result.append(starteTime); - result.append(", endTime: "); - result.append(endTime); - result.append(')'); - return result.toString(); - } - -} //InformationImpl diff --git a/src/coursePage/impl/LabImpl.java b/src/coursePage/impl/LabImpl.java deleted file mode 100644 index de28c0b8c6204f2ccafea72a6a07be5ecbc9e0fb..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/LabImpl.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.Event; -import coursePage.Lab; - -import java.util.Collection; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Lab</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.LabImpl#getLabTime <em>Lab Time</em>}</li> - * </ul> - * - * @generated - */ -public class LabImpl extends MinimalEObjectImpl.Container implements Lab { - /** - * The cached value of the '{@link #getLabTime() <em>Lab Time</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLabTime() - * @generated - * @ordered - */ - protected EList<Event> labTime; - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected LabImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.LAB; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<Event> getLabTime() { - if (labTime == null) { - labTime = new EObjectContainmentEList<Event>(Event.class, this, CoursePagePackage.LAB__LAB_TIME); - } - return labTime; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case CoursePagePackage.LAB__LAB_TIME: - return ((InternalEList<?>)getLabTime()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.LAB__LAB_TIME: - return getLabTime(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.LAB__LAB_TIME: - getLabTime().clear(); - getLabTime().addAll((Collection<? extends Event>)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.LAB__LAB_TIME: - getLabTime().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.LAB__LAB_TIME: - return labTime != null && !labTime.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //LabImpl diff --git a/src/coursePage/impl/LectureImpl.java b/src/coursePage/impl/LectureImpl.java deleted file mode 100644 index 8a07de6e461108b15b5f74d4336337387188712c..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/LectureImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.Event; -import coursePage.Lecture; - -import java.util.Collection; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Lecture</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.LectureImpl#getLectureTime <em>Lecture Time</em>}</li> - * </ul> - * - * @generated - */ -public class LectureImpl extends MinimalEObjectImpl.Container implements Lecture { - /** - * The cached value of the '{@link #getLectureTime() <em>Lecture Time</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getLectureTime() - * @generated - * @ordered - */ - protected EList<Event> lectureTime; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected LectureImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.LECTURE; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<Event> getLectureTime() { - if (lectureTime == null) { - lectureTime = new EObjectContainmentEList<Event>(Event.class, this, CoursePagePackage.LECTURE__LECTURE_TIME); - } - return lectureTime; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case CoursePagePackage.LECTURE__LECTURE_TIME: - return ((InternalEList<?>)getLectureTime()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.LECTURE__LECTURE_TIME: - return getLectureTime(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.LECTURE__LECTURE_TIME: - getLectureTime().clear(); - getLectureTime().addAll((Collection<? extends Event>)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.LECTURE__LECTURE_TIME: - getLectureTime().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.LECTURE__LECTURE_TIME: - return lectureTime != null && !lectureTime.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //LectureImpl diff --git a/src/coursePage/impl/OrganizationImpl.java b/src/coursePage/impl/OrganizationImpl.java deleted file mode 100644 index 36414d368634363c4ab7ae2f7285ebf93433d402..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/OrganizationImpl.java +++ /dev/null @@ -1,296 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.Course; -import coursePage.CoursePagePackage; -import coursePage.Employee; -import coursePage.Organization; - -import java.util.Collection; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Organization</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.OrganizationImpl#getName <em>Name</em>}</li> - * <li>{@link coursePage.impl.OrganizationImpl#getHas <em>Has</em>}</li> - * <li>{@link coursePage.impl.OrganizationImpl#getResponsibleFor <em>Responsible For</em>}</li> - * </ul> - * - * @generated - */ -public class OrganizationImpl extends MinimalEObjectImpl.Container implements Organization { - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = null; - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - /** - * The cached value of the '{@link #getHas() <em>Has</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getHas() - * @generated - * @ordered - */ - protected EList<Employee> has; - /** - * The cached value of the '{@link #getResponsibleFor() <em>Responsible For</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getResponsibleFor() - * @generated - * @ordered - */ - protected Course responsibleFor; - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected OrganizationImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.ORGANIZATION; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getName() { - return name; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.ORGANIZATION__NAME, oldName, name)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<Employee> getHas() { - if (has == null) { - has = new EObjectContainmentWithInverseEList<Employee>(Employee.class, this, CoursePagePackage.ORGANIZATION__HAS, CoursePagePackage.EMPLOYEE__WORKS_FOR); - } - return has; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Course getResponsibleFor() { - return responsibleFor; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain basicSetResponsibleFor(Course newResponsibleFor, NotificationChain msgs) { - Course oldResponsibleFor = responsibleFor; - responsibleFor = newResponsibleFor; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR, oldResponsibleFor, newResponsibleFor); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setResponsibleFor(Course newResponsibleFor) { - if (newResponsibleFor != responsibleFor) { - NotificationChain msgs = null; - if (responsibleFor != null) - msgs = ((InternalEObject)responsibleFor).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR, null, msgs); - if (newResponsibleFor != null) - msgs = ((InternalEObject)newResponsibleFor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR, null, msgs); - msgs = basicSetResponsibleFor(newResponsibleFor, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR, newResponsibleFor, newResponsibleFor)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__HAS: - return ((InternalEList<InternalEObject>)(InternalEList<?>)getHas()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__HAS: - return ((InternalEList<?>)getHas()).basicRemove(otherEnd, msgs); - case CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR: - return basicSetResponsibleFor(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__NAME: - return getName(); - case CoursePagePackage.ORGANIZATION__HAS: - return getHas(); - case CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR: - return getResponsibleFor(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__NAME: - setName((String)newValue); - return; - case CoursePagePackage.ORGANIZATION__HAS: - getHas().clear(); - getHas().addAll((Collection<? extends Employee>)newValue); - return; - case CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR: - setResponsibleFor((Course)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__NAME: - setName(NAME_EDEFAULT); - return; - case CoursePagePackage.ORGANIZATION__HAS: - getHas().clear(); - return; - case CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR: - setResponsibleFor((Course)null); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.ORGANIZATION__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case CoursePagePackage.ORGANIZATION__HAS: - return has != null && !has.isEmpty(); - case CoursePagePackage.ORGANIZATION__RESPONSIBLE_FOR: - return responsibleFor != null; - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(')'); - return result.toString(); - } - -} //OrganizationImpl diff --git a/src/coursePage/impl/RelationToOtherCoursesImpl.java b/src/coursePage/impl/RelationToOtherCoursesImpl.java deleted file mode 100644 index 6d1197e5f9fa519b8813d7cc2a4c7f18c7245329..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/RelationToOtherCoursesImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.RelationToOtherCourses; -import coursePage.credits; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Relation To Other Courses</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.RelationToOtherCoursesImpl#getRelation <em>Relation</em>}</li> - * </ul> - * - * @generated - */ -public class RelationToOtherCoursesImpl extends MinimalEObjectImpl.Container implements RelationToOtherCourses { - /** - * The cached value of the '{@link #getRelation() <em>Relation</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getRelation() - * @generated - * @ordered - */ - protected credits relation; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected RelationToOtherCoursesImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.RELATION_TO_OTHER_COURSES; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public credits getRelation() { - if (relation != null && relation.eIsProxy()) { - InternalEObject oldRelation = (InternalEObject)relation; - relation = (credits)eResolveProxy(oldRelation); - if (relation != oldRelation) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION, oldRelation, relation)); - } - } - return relation; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public credits basicGetRelation() { - return relation; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setRelation(credits newRelation) { - credits oldRelation = relation; - relation = newRelation; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION, oldRelation, relation)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION: - if (resolve) return getRelation(); - return basicGetRelation(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION: - setRelation((credits)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION: - setRelation((credits)null); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.RELATION_TO_OTHER_COURSES__RELATION: - return relation != null; - } - return super.eIsSet(featureID); - } - -} //RelationToOtherCoursesImpl diff --git a/src/coursePage/impl/SlotImpl.java b/src/coursePage/impl/SlotImpl.java index 9e82dbd564936213d4bfee6b4119e27d979d12a5..b1afd23a4c64e59e0d9ed01032a7e945f8c980ae 100644 --- a/src/coursePage/impl/SlotImpl.java +++ b/src/coursePage/impl/SlotImpl.java @@ -10,8 +10,6 @@ import coursePage.Slot; import coursePage.StudyProgram; import java.util.Collection; -import java.util.Date; - import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.EList; @@ -111,7 +109,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * @generated * @ordered */ - protected static final Date STARTE_TIME_EDEFAULT = null; + protected static final String STARTE_TIME_EDEFAULT = null; /** * The cached value of the '{@link #getStarteTime() <em>Starte Time</em>}' attribute. @@ -121,7 +119,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * @generated * @ordered */ - protected Date starteTime = STARTE_TIME_EDEFAULT; + protected String starteTime = STARTE_TIME_EDEFAULT; /** * The default value of the '{@link #getEndTime() <em>End Time</em>}' attribute. @@ -131,7 +129,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * @generated * @ordered */ - protected static final Date END_TIME_EDEFAULT = null; + protected static final String END_TIME_EDEFAULT = null; /** * The cached value of the '{@link #getEndTime() <em>End Time</em>}' attribute. @@ -141,7 +139,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * @generated * @ordered */ - protected Date endTime = END_TIME_EDEFAULT; + protected String endTime = END_TIME_EDEFAULT; /** * The cached value of the '{@link #getScheduleFor() <em>Schedule For</em>}' reference list. @@ -260,7 +258,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * <!-- end-user-doc --> * @generated */ - public Date getStarteTime() { + public String getStarteTime() { return starteTime; } @@ -269,8 +267,8 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * <!-- end-user-doc --> * @generated */ - public void setStarteTime(Date newStarteTime) { - Date oldStarteTime = starteTime; + public void setStarteTime(String newStarteTime) { + String oldStarteTime = starteTime; starteTime = newStarteTime; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.SLOT__STARTE_TIME, oldStarteTime, starteTime)); @@ -281,7 +279,7 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * <!-- end-user-doc --> * @generated */ - public Date getEndTime() { + public String getEndTime() { return endTime; } @@ -290,8 +288,8 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { * <!-- end-user-doc --> * @generated */ - public void setEndTime(Date newEndTime) { - Date oldEndTime = endTime; + public void setEndTime(String newEndTime) { + String oldEndTime = endTime; endTime = newEndTime; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.SLOT__END_TIME, oldEndTime, endTime)); @@ -375,10 +373,10 @@ public class SlotImpl extends MinimalEObjectImpl.Container implements Slot { setLectureType((LectureType)newValue); return; case CoursePagePackage.SLOT__STARTE_TIME: - setStarteTime((Date)newValue); + setStarteTime((String)newValue); return; case CoursePagePackage.SLOT__END_TIME: - setEndTime((Date)newValue); + setEndTime((String)newValue); return; case CoursePagePackage.SLOT__SCHEDULE_FOR: getScheduleFor().clear(); diff --git a/src/coursePage/impl/creditsImpl.java b/src/coursePage/impl/creditsImpl.java deleted file mode 100644 index 1824de136367117554b65be4d1c0ea50c4c5b641..0000000000000000000000000000000000000000 --- a/src/coursePage/impl/creditsImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - */ -package coursePage.impl; - -import coursePage.CoursePagePackage; -import coursePage.credits; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>credits</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * </p> - * <ul> - * <li>{@link coursePage.impl.creditsImpl#getPoints <em>Points</em>}</li> - * </ul> - * - * @generated - */ -public class creditsImpl extends MinimalEObjectImpl.Container implements credits { - /** - * The default value of the '{@link #getPoints() <em>Points</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPoints() - * @generated - * @ordered - */ - protected static final double POINTS_EDEFAULT = 0.0; - - /** - * The cached value of the '{@link #getPoints() <em>Points</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getPoints() - * @generated - * @ordered - */ - protected double points = POINTS_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected creditsImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return CoursePagePackage.Literals.CREDITS; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public double getPoints() { - return points; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setPoints(double newPoints) { - double oldPoints = points; - points = newPoints; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CoursePagePackage.CREDITS__POINTS, oldPoints, points)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case CoursePagePackage.CREDITS__POINTS: - return getPoints(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case CoursePagePackage.CREDITS__POINTS: - setPoints((Double)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case CoursePagePackage.CREDITS__POINTS: - setPoints(POINTS_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case CoursePagePackage.CREDITS__POINTS: - return points != POINTS_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (points: "); - result.append(points); - result.append(')'); - return result.toString(); - } - -} //creditsImpl diff --git a/src/coursePage/util/CoursePageResourceFactoryImpl.java b/src/coursePage/util/CoursePageResourceFactoryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..da7cbded47a0d876e069f0efbaf1eab32a93b195 --- /dev/null +++ b/src/coursePage/util/CoursePageResourceFactoryImpl.java @@ -0,0 +1,41 @@ +/** + */ +package coursePage.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; + +/** + * <!-- begin-user-doc --> + * The <b>Resource Factory</b> associated with the package. + * <!-- end-user-doc --> + * @see coursePage.util.CoursePageResourceImpl + * @generated + */ +public class CoursePageResourceFactoryImpl extends ResourceFactoryImpl { + /** + * Creates an instance of the resource factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public CoursePageResourceFactoryImpl() { + super(); + } + + /** + * Creates an instance of the resource. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Resource createResource(URI uri) { + Resource result = new CoursePageResourceImpl(uri); + return result; + } + +} //CoursePageResourceFactoryImpl diff --git a/src/coursePage/util/CoursePageResourceImpl.java b/src/coursePage/util/CoursePageResourceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c77cb7b9449c81fe33458fa38ee91ac2bc8e3a5b --- /dev/null +++ b/src/coursePage/util/CoursePageResourceImpl.java @@ -0,0 +1,32 @@ +/** + */ +package coursePage.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; + +/** + * <!-- begin-user-doc --> + * The <b>Resource </b> associated with the package. + * <!-- end-user-doc --> + * @see coursePage.util.CoursePageResourceFactoryImpl + * @generated + */ +public class CoursePageResourceImpl extends XMIResourceImpl { + /** + * Creates an instance of the resource. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param uri the URI of the new resource. + * @generated + */ + public CoursePageResourceImpl(URI uri) { + super(uri); + } + + CoursePageResourceImpl() { + throw new UnsupportedOperationException("TODO: auto-generated method stub"); + } + +} //CoursePageResourceImpl diff --git a/src/tdt4250/transformation/Course.xmi b/src/tdt4250/transformation/Course.xmi new file mode 100644 index 0000000000000000000000000000000000000000..d740ed458f904fdd0b4d17db77b66ec87e0e578f --- /dev/null +++ b/src/tdt4250/transformation/Course.xmi @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<coursePage:Course + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:coursePage="platform:/resource/tdt4250.web/model/coursePage.ecore" + code="TDT4100" + name="OOP" + content="content" + credits="7.5"> + <timetable> + <table starteTime="1415" + endTime="1600" + hours="5.0"/> + <table day="Tuesday" + room="EL6" + lectureType="lecture" + starteTime="1215" + endTime="1400" + hours="5.0"/> + </timetable> + <relation + creditsReduction="3.0"/> + <grading points="70.0"/> + <courseWork + lectureHours="5.0" + labHours="5.0"/> + <hasBeenTaught + semester="V16" + credits="7.5"/> + <courseStaff> + <inTheStaff + name="Hallvard Trætteberg"> + <role/> + <isCC/> + </inTheStaff> + <inTheStaff + name="Alf Inge"> + <role + role="assistant"/> + </inTheStaff> + </courseStaff> +</coursePage:Course> diff --git a/src/tdt4250/transformation/Course2HTML.xtend b/src/tdt4250/transformation/Course2HTML.xtend new file mode 100644 index 0000000000000000000000000000000000000000..9c34400505e4687e128c276cbe2d3f01cca85427 --- /dev/null +++ b/src/tdt4250/transformation/Course2HTML.xtend @@ -0,0 +1,179 @@ +package tdt4250.transformation + +import org.w3c.xhtml1.util.Xhtml1ResourceFactoryImpl +import org.w3c.xhtml1.Xhtml1Factory +import coursePage.Course +import org.w3c.xhtml1.HtmlType +import org.eclipse.emf.ecore.xmi.XMLResource +import java.io.ByteArrayOutputStream +import org.eclipse.emf.common.util.URI +import java.io.IOException +import java.util.Arrays +import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl +import coursePage.CoursePagePackage +import org.eclipse.emf.ecore.EObject +import coursePage.util.CoursePageResourceImpl +import coursePage.util.CoursePageResourceFactoryImpl + +class Course2HTML { + + Xhtml1ResourceFactoryImpl xhtml1ResourceFactoryImpl = new Xhtml1ResourceFactoryImpl + + def String generateHtml(Course course) { + val encoding = "UTF-8" + val html = generateHtmlType(course); + val root = XMLNamespaceFactory.eINSTANCE.createXMLNamespaceDocumentRoot += html + //val fileName = (if (course.name !== null) course.name.replace('.', '/') else "quiz")+ '.html' + val fileName = "Course" + '.html' + + val resource = xhtml1ResourceFactoryImpl.createResource(URI.createFileURI(fileName)) as XMLResource + resource.getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING, encoding); + resource.contents += html + val outputStream = new ByteArrayOutputStream(4096) + resource.save(outputStream, null) + val originalOutput = outputStream.toString(encoding) + originalOutput.cleanHtml + } + + def cleanHtml(String html) { + html + .replace("xhtml:", "") + .replace("html_._type", "html") + .replace("xmlns:xhtml=", "xmlns=") + .replace("<", "<") + .replace(">", ">") + .replace("&", "&") + .replace(""", "'") + } + + extension Xhtml1Factory xhtml1Factory = Xhtml1Factory.eINSTANCE + extension XhtmlUtil xhtmlUtil = new XhtmlUtil + + def HtmlType generateHtmlType(Course course) { + val html = createHtmlType => [ + head = createHeadType => [ + title = createTitleType => [ + it += ("TITLE") + ] + meta += createMetaType => [ + httpEquiv = "content-type" + content = "text/html; charset=UTF-8" + ] + ] + body = createBodyType => [ + it +=createH1Type => [ + it += course.code + " " + course.name + ] + + it += createPType => [ + it += "This page contains all information about this course" + ] + + it += createPType => [ + it += "name: " + course.code + " " + course.name + ] + + it += createPType => [ + it += "credits: " + course.credits + ] + + it += createH2Type => [ + it += "TimeTable" + ] + for(slot: course.timetable.table){ + it += createPType =>[ + it += slot.day.toString + " " + slot.room.toString + " " +slot.starteTime + "-" +slot.endTime + + " " + slot.lectureType + ] + } + + + it += createH2Type => [ + it += "Evaluation" + ] + it += createPType => [ + for(evaluation : course.grading){ + it += evaluation.evaluation.toString + + " " + evaluation.points+ "/" + "100" + + } + ] + + it += createH2Type => [ + it += "Course Work" + ] + + it += createPType => [ + it += "Lecture Hours" + " " + course.courseWork.lectureHours.toString + ] + + + it += createPType => [ + it += "Lab Hours" + " " + course.courseWork.labHours.toString + ] + + it += createH2Type => [ + it += "Course Reduction" + ] + + for(ocourse :course.relation ){ + it += createPType =>[ + it+= ocourse.course.toString + " " + "Reduction:" + ocourse.creditsReduction.toString + ] + } + it += createH2Type => [ + it += "Course Staff" + ] + + for(person: course.courseStaff.get(0).inTheStaff){ + it += createPType =>[ + it += person.name + " " + person.role + ] + } + + + ] + ] + html +// fsa.generateFile(quiz.name.replace('.', '/') + '.html', stringBuilder); + } + + def static void main(String[] args) throws IOException { + val argsAsList = Arrays.asList(args) + val course = if (argsAsList.size > 0) getCourse(argsAsList.get(0)) else getSampleCourse(); + val html = new Course2HTML().generateHtml(course); + System.out.println(html); + } + + def static Course getSampleCourse() { + try { + return getCourse(Course2HTML.getResource("Course.xmi").toString()); + } + catch (IOException e) { + println(); + System.err.println(e); + return null; + } + } + + def static Course getCourse(String uriString) throws IOException { + val resSet = new ResourceSetImpl(); + resSet.getPackageRegistry().put(CoursePagePackage.eNS_URI, CoursePagePackage.eINSTANCE); + resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new CoursePageResourceFactoryImpl()); + val resource = resSet.getResource(URI.createURI(uriString), true); + for (EObject eObject : resource.getContents()) { + if (eObject instanceof Course) { + return eObject as Course; + } + } + return null; + } + + + + + + + +} \ No newline at end of file diff --git a/src/tdt4250/transformation/XhtmlUtil.xtend b/src/tdt4250/transformation/XhtmlUtil.xtend new file mode 100644 index 0000000000000000000000000000000000000000..810bdf37665664ac61ddc240675206571027c72d --- /dev/null +++ b/src/tdt4250/transformation/XhtmlUtil.xtend @@ -0,0 +1,135 @@ +package tdt4250.transformation + +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EDataType +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.EcorePackage +import org.eclipse.emf.ecore.util.EcoreUtil +import org.eclipse.emf.ecore.util.FeatureMap +import org.eclipse.emf.ecore.util.FeatureMapUtil +import org.w3c.xhtml1.Xhtml1Package + +class XhtmlUtil { + + def tag(String tagName) { + val typeName = tagName + "Type" + for (eClass : Xhtml1Package.eINSTANCE.EClassifiers.filter(EClass)) { + val className = eClass.name + if (className.equalsIgnoreCase(tagName) || className.equalsIgnoreCase(typeName)) { + return eClass + } + } + } + + def create(EClass tag) { + EcoreUtil.create(tag) + } + + def create(String tagName) { + val tag = tag(tagName) + if (tag !== null) { + create(tag) + } + } + + def attr(EObject eObject, String attrName) { + eObject.eClass.EAllStructuralFeatures.findFirst[name == attrName] + } + + def operator_add(EObject eObject, Pair<String, String> attr) { + val feature = attr(eObject, attr.key) + if (feature !== null) { + val featureType = feature.EType as EDataType + val value = featureType.EPackage.EFactoryInstance.createFromString(featureType, attr.value) + if (feature.many) { +// (eObject.eGet(feature) as EList<?>).add(value) + } else { + eObject.eSet(feature, value) + } + } + } + + def featureMap(EObject featureMapOwner) { + for (feature : featureMapOwner.eClass.EAllStructuralFeatures) { + if (feature.EType == EcorePackage.eINSTANCE.EFeatureMapEntry) { + return featureMapOwner.eGet(feature) as FeatureMap + } + } + } + + def operator_add(EObject featureMapOwner, EObject eObject) { + val featureMap = featureMap(featureMapOwner) + if (featureMap !== null) { + for (feature : featureMapOwner.eClass.EAllStructuralFeatures) { + if (feature.EType.isInstance(eObject)) { + featureMap.add(feature, eObject) + return featureMapOwner + } + } + System.err.println("Didn't find feature for " + eObject.eClass.name + " in " + featureMapOwner.eClass.name) + } + featureMapOwner + } + + def operator_add(EObject featureMapOwner, Iterable<? extends EObject> eObjects) { + for (eObject : eObjects) { + featureMapOwner += eObject + } + featureMapOwner + } + + def operator_add(FeatureMap featureMap, CharSequence text) { + if (featureMap !== null) { + FeatureMapUtil.addText(featureMap, if (text !== null) text.toString else "") + } + featureMap + } + + def operator_add(EObject featureMapOwner, CharSequence text) { + val featureMap = featureMap(featureMapOwner) + if (featureMap !== null) { + featureMap += text + } + featureMapOwner + } + +// def operator_add(Block block, EObject eObject) { +// add(block, block.group, eObject) +// } +// def operator_add(Block block, Iterable<? extends EObject> eObjects) { +// for (eObject : eObjects) { +// add(block, block.group, eObject) +// } +// } +// +// def operator_add(FormContent form, EObject eObject) { +// add(form, form.group, eObject) +// } +// def operator_add(FormContent form, Iterable<? extends EObject> eObjects) { +// for (eObject : eObjects) { +// add(form, form.group, eObject) +// } +// } +// +// def operator_add(Flow flow, EObject eObject) { +// add(flow, flow.group, eObject) +// } +// def operator_add(Inline inline, EObject eObject) { +// add(inline, inline.group, eObject) +// } +// def operator_add(ScriptType script, CharSequence text) { +// script.mixed += text +// } +// def operator_add(ButtonContent button, CharSequence text) { +// button.mixed += text +// } +// def operator_add(SelectType select, EObject eObject) { +// add(select, select.group, eObject) +// } + + // + + def StringBuilder operator_doubleLessThan(StringBuilder stringBuilder, Object o) { + return stringBuilder.append(o); + } +} diff --git a/xtend-gen/tdt4250/transformation/.Course2HTML.java._trace b/xtend-gen/tdt4250/transformation/.Course2HTML.java._trace new file mode 100644 index 0000000000000000000000000000000000000000..45b2449d975603ae77fb547cc8683d5a903a561d Binary files /dev/null and b/xtend-gen/tdt4250/transformation/.Course2HTML.java._trace differ diff --git a/xtend-gen/tdt4250/transformation/.Course2HTML.xtendbin b/xtend-gen/tdt4250/transformation/.Course2HTML.xtendbin new file mode 100644 index 0000000000000000000000000000000000000000..ea966ac41758aa9d1eb6d525f9338c8b8ce4ec1c Binary files /dev/null and b/xtend-gen/tdt4250/transformation/.Course2HTML.xtendbin differ diff --git a/xtend-gen/tdt4250/transformation/.XhtmlUtil.java._trace b/xtend-gen/tdt4250/transformation/.XhtmlUtil.java._trace new file mode 100644 index 0000000000000000000000000000000000000000..b11a4a6d7ecd69df8ed67cdc288801edad29ecff Binary files /dev/null and b/xtend-gen/tdt4250/transformation/.XhtmlUtil.java._trace differ diff --git a/xtend-gen/tdt4250/transformation/.XhtmlUtil.xtendbin b/xtend-gen/tdt4250/transformation/.XhtmlUtil.xtendbin new file mode 100644 index 0000000000000000000000000000000000000000..7f14767d8a52b5e21951f926aa9f7cec8033f2a4 Binary files /dev/null and b/xtend-gen/tdt4250/transformation/.XhtmlUtil.xtendbin differ diff --git a/xtend-gen/tdt4250/transformation/Course2HTML.java b/xtend-gen/tdt4250/transformation/Course2HTML.java new file mode 100644 index 0000000000000000000000000000000000000000..8df57108cccfd624988cf1780be30ef18d0e2d8a --- /dev/null +++ b/xtend-gen/tdt4250/transformation/Course2HTML.java @@ -0,0 +1,307 @@ +package tdt4250.transformation; + +import coursePage.Course; +import coursePage.CoursePagePackage; +import coursePage.Employee; +import coursePage.Evaluation; +import coursePage.LectureType; +import coursePage.Lecturer; +import coursePage.RelationToCourse; +import coursePage.Slot; +import coursePage.util.CoursePageResourceFactoryImpl; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot; +import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.InputOutput; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.w3c.xhtml1.BodyType; +import org.w3c.xhtml1.H1Type; +import org.w3c.xhtml1.H2Type; +import org.w3c.xhtml1.HeadType; +import org.w3c.xhtml1.HtmlType; +import org.w3c.xhtml1.MetaType; +import org.w3c.xhtml1.PType; +import org.w3c.xhtml1.TitleType; +import org.w3c.xhtml1.Xhtml1Factory; +import org.w3c.xhtml1.util.Xhtml1ResourceFactoryImpl; +import tdt4250.transformation.XhtmlUtil; + +@SuppressWarnings("all") +public class Course2HTML { + private Xhtml1ResourceFactoryImpl xhtml1ResourceFactoryImpl = new Xhtml1ResourceFactoryImpl(); + + public String generateHtml(final Course course) { + try { + String _xblockexpression = null; + { + final String encoding = "UTF-8"; + final HtmlType html = this.generateHtmlType(course); + XMLNamespaceDocumentRoot _createXMLNamespaceDocumentRoot = XMLNamespaceFactory.eINSTANCE.createXMLNamespaceDocumentRoot(); + final EObject root = this.xhtmlUtil.operator_add(_createXMLNamespaceDocumentRoot, html); + final String fileName = ("Course" + ".html"); + Resource _createResource = this.xhtml1ResourceFactoryImpl.createResource(URI.createFileURI(fileName)); + final XMLResource resource = ((XMLResource) _createResource); + resource.getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING, encoding); + EList<EObject> _contents = resource.getContents(); + _contents.add(html); + final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(4096); + resource.save(outputStream, null); + final String originalOutput = outputStream.toString(encoding); + _xblockexpression = this.cleanHtml(originalOutput); + } + return _xblockexpression; + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + public String cleanHtml(final String html) { + return html.replace("xhtml:", "").replace("html_._type", "html").replace("xmlns:xhtml=", "xmlns=").replace("<", "<").replace(">", ">").replace("&", "&").replace(""", "\'"); + } + + @Extension + private Xhtml1Factory xhtml1Factory = Xhtml1Factory.eINSTANCE; + + @Extension + private XhtmlUtil xhtmlUtil = new XhtmlUtil(); + + public HtmlType generateHtmlType(final Course course) { + HtmlType _xblockexpression = null; + { + HtmlType _createHtmlType = this.xhtml1Factory.createHtmlType(); + final Procedure1<HtmlType> _function = (HtmlType it) -> { + HeadType _createHeadType = this.xhtml1Factory.createHeadType(); + final Procedure1<HeadType> _function_1 = (HeadType it_1) -> { + TitleType _createTitleType = this.xhtml1Factory.createTitleType(); + final Procedure1<TitleType> _function_2 = (TitleType it_2) -> { + this.xhtmlUtil.operator_add(it_2, "TITLE"); + }; + TitleType _doubleArrow = ObjectExtensions.<TitleType>operator_doubleArrow(_createTitleType, _function_2); + it_1.setTitle(_doubleArrow); + EList<MetaType> _meta = it_1.getMeta(); + MetaType _createMetaType = this.xhtml1Factory.createMetaType(); + final Procedure1<MetaType> _function_3 = (MetaType it_2) -> { + it_2.setHttpEquiv("content-type"); + it_2.setContent("text/html; charset=UTF-8"); + }; + MetaType _doubleArrow_1 = ObjectExtensions.<MetaType>operator_doubleArrow(_createMetaType, _function_3); + _meta.add(_doubleArrow_1); + }; + HeadType _doubleArrow = ObjectExtensions.<HeadType>operator_doubleArrow(_createHeadType, _function_1); + it.setHead(_doubleArrow); + BodyType _createBodyType = this.xhtml1Factory.createBodyType(); + final Procedure1<BodyType> _function_2 = (BodyType it_1) -> { + H1Type _createH1Type = this.xhtml1Factory.createH1Type(); + final Procedure1<H1Type> _function_3 = (H1Type it_2) -> { + String _code = course.getCode(); + String _plus = (_code + " "); + String _name = course.getName(); + String _plus_1 = (_plus + _name); + this.xhtmlUtil.operator_add(it_2, _plus_1); + }; + H1Type _doubleArrow_1 = ObjectExtensions.<H1Type>operator_doubleArrow(_createH1Type, _function_3); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_1); + PType _createPType = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_4 = (PType it_2) -> { + this.xhtmlUtil.operator_add(it_2, "This page contains all information about this course"); + }; + PType _doubleArrow_2 = ObjectExtensions.<PType>operator_doubleArrow(_createPType, _function_4); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_2); + PType _createPType_1 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_5 = (PType it_2) -> { + String _code = course.getCode(); + String _plus = ("name: " + _code); + String _plus_1 = (_plus + " "); + String _name = course.getName(); + String _plus_2 = (_plus_1 + _name); + this.xhtmlUtil.operator_add(it_2, _plus_2); + }; + PType _doubleArrow_3 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_1, _function_5); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_3); + PType _createPType_2 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_6 = (PType it_2) -> { + double _credits = course.getCredits(); + String _plus = ("credits: " + Double.valueOf(_credits)); + this.xhtmlUtil.operator_add(it_2, _plus); + }; + PType _doubleArrow_4 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_2, _function_6); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_4); + H2Type _createH2Type = this.xhtml1Factory.createH2Type(); + final Procedure1<H2Type> _function_7 = (H2Type it_2) -> { + this.xhtmlUtil.operator_add(it_2, "TimeTable"); + }; + H2Type _doubleArrow_5 = ObjectExtensions.<H2Type>operator_doubleArrow(_createH2Type, _function_7); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_5); + EList<Slot> _table = course.getTimetable().getTable(); + for (final Slot slot : _table) { + PType _createPType_3 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_8 = (PType it_2) -> { + String _string = slot.getDay().toString(); + String _plus = (_string + " "); + String _string_1 = slot.getRoom().toString(); + String _plus_1 = (_plus + _string_1); + String _plus_2 = (_plus_1 + " "); + String _starteTime = slot.getStarteTime(); + String _plus_3 = (_plus_2 + _starteTime); + String _plus_4 = (_plus_3 + "-"); + String _endTime = slot.getEndTime(); + String _plus_5 = (_plus_4 + _endTime); + String _plus_6 = (_plus_5 + " "); + LectureType _lectureType = slot.getLectureType(); + String _plus_7 = (_plus_6 + _lectureType); + this.xhtmlUtil.operator_add(it_2, _plus_7); + }; + PType _doubleArrow_6 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_3, _function_8); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_6); + } + H2Type _createH2Type_1 = this.xhtml1Factory.createH2Type(); + final Procedure1<H2Type> _function_9 = (H2Type it_2) -> { + this.xhtmlUtil.operator_add(it_2, "Evaluation"); + }; + H2Type _doubleArrow_7 = ObjectExtensions.<H2Type>operator_doubleArrow(_createH2Type_1, _function_9); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_7); + PType _createPType_4 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_10 = (PType it_2) -> { + EList<Evaluation> _grading = course.getGrading(); + for (final Evaluation evaluation : _grading) { + String _string = evaluation.getEvaluation().toString(); + String _plus = (_string + " "); + double _points = evaluation.getPoints(); + String _plus_1 = (_plus + Double.valueOf(_points)); + String _plus_2 = (_plus_1 + "/"); + String _plus_3 = (_plus_2 + "100"); + this.xhtmlUtil.operator_add(it_2, _plus_3); + } + }; + PType _doubleArrow_8 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_4, _function_10); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_8); + H2Type _createH2Type_2 = this.xhtml1Factory.createH2Type(); + final Procedure1<H2Type> _function_11 = (H2Type it_2) -> { + this.xhtmlUtil.operator_add(it_2, "Course Work"); + }; + H2Type _doubleArrow_9 = ObjectExtensions.<H2Type>operator_doubleArrow(_createH2Type_2, _function_11); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_9); + PType _createPType_5 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_12 = (PType it_2) -> { + String _string = Double.valueOf(course.getCourseWork().getLectureHours()).toString(); + String _plus = (("Lecture Hours" + " ") + _string); + this.xhtmlUtil.operator_add(it_2, _plus); + }; + PType _doubleArrow_10 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_5, _function_12); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_10); + PType _createPType_6 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_13 = (PType it_2) -> { + String _string = Double.valueOf(course.getCourseWork().getLabHours()).toString(); + String _plus = (("Lab Hours" + " ") + _string); + this.xhtmlUtil.operator_add(it_2, _plus); + }; + PType _doubleArrow_11 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_6, _function_13); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_11); + H2Type _createH2Type_3 = this.xhtml1Factory.createH2Type(); + final Procedure1<H2Type> _function_14 = (H2Type it_2) -> { + this.xhtmlUtil.operator_add(it_2, "Course Reduction"); + }; + H2Type _doubleArrow_12 = ObjectExtensions.<H2Type>operator_doubleArrow(_createH2Type_3, _function_14); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_12); + EList<RelationToCourse> _relation = course.getRelation(); + for (final RelationToCourse ocourse : _relation) { + PType _createPType_7 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_15 = (PType it_2) -> { + String _string = ocourse.getCourse().toString(); + String _plus = (_string + " "); + String _plus_1 = (_plus + "Reduction:"); + String _string_1 = Double.valueOf(ocourse.getCreditsReduction()).toString(); + String _plus_2 = (_plus_1 + _string_1); + this.xhtmlUtil.operator_add(it_2, _plus_2); + }; + PType _doubleArrow_13 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_7, _function_15); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_13); + } + H2Type _createH2Type_4 = this.xhtml1Factory.createH2Type(); + final Procedure1<H2Type> _function_16 = (H2Type it_2) -> { + this.xhtmlUtil.operator_add(it_2, "Course Staff"); + }; + H2Type _doubleArrow_14 = ObjectExtensions.<H2Type>operator_doubleArrow(_createH2Type_4, _function_16); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_14); + EList<Employee> _inTheStaff = course.getCourseStaff().get(0).getInTheStaff(); + for (final Employee person : _inTheStaff) { + PType _createPType_8 = this.xhtml1Factory.createPType(); + final Procedure1<PType> _function_17 = (PType it_2) -> { + String _name = person.getName(); + String _plus = (_name + " "); + EList<Lecturer> _role = person.getRole(); + String _plus_1 = (_plus + _role); + this.xhtmlUtil.operator_add(it_2, _plus_1); + }; + PType _doubleArrow_15 = ObjectExtensions.<PType>operator_doubleArrow(_createPType_8, _function_17); + this.xhtmlUtil.operator_add(it_1, _doubleArrow_15); + } + }; + BodyType _doubleArrow_1 = ObjectExtensions.<BodyType>operator_doubleArrow(_createBodyType, _function_2); + it.setBody(_doubleArrow_1); + }; + final HtmlType html = ObjectExtensions.<HtmlType>operator_doubleArrow(_createHtmlType, _function); + _xblockexpression = html; + } + return _xblockexpression; + } + + public static void main(final String[] args) throws IOException { + final List<String> argsAsList = Arrays.<String>asList(args); + Course _xifexpression = null; + int _size = argsAsList.size(); + boolean _greaterThan = (_size > 0); + if (_greaterThan) { + _xifexpression = Course2HTML.getCourse(argsAsList.get(0)); + } else { + _xifexpression = Course2HTML.getSampleCourse(); + } + final Course course = _xifexpression; + final String html = new Course2HTML().generateHtml(course); + System.out.println(html); + } + + public static Course getSampleCourse() { + try { + return Course2HTML.getCourse(Course2HTML.class.getResource("Course.xmi").toString()); + } catch (final Throwable _t) { + if (_t instanceof IOException) { + final IOException e = (IOException)_t; + InputOutput.println(); + System.err.println(e); + return null; + } else { + throw Exceptions.sneakyThrow(_t); + } + } + } + + public static Course getCourse(final String uriString) throws IOException { + final ResourceSetImpl resSet = new ResourceSetImpl(); + resSet.getPackageRegistry().put(CoursePagePackage.eNS_URI, CoursePagePackage.eINSTANCE); + Map<String, Object> _extensionToFactoryMap = resSet.getResourceFactoryRegistry().getExtensionToFactoryMap(); + CoursePageResourceFactoryImpl _coursePageResourceFactoryImpl = new CoursePageResourceFactoryImpl(); + _extensionToFactoryMap.put("xmi", _coursePageResourceFactoryImpl); + final Resource resource = resSet.getResource(URI.createURI(uriString), true); + EList<EObject> _contents = resource.getContents(); + for (final EObject eObject : _contents) { + if ((eObject instanceof Course)) { + return ((Course) eObject); + } + } + return null; + } +} diff --git a/xtend-gen/tdt4250/transformation/XhtmlUtil.java b/xtend-gen/tdt4250/transformation/XhtmlUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..c229e2ff6bd2db961c96bfc4669246dd0958e277 --- /dev/null +++ b/xtend-gen/tdt4250/transformation/XhtmlUtil.java @@ -0,0 +1,170 @@ +package tdt4250.transformation; + +import com.google.common.base.Objects; +import com.google.common.collect.Iterables; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; +import org.eclipse.xtext.xbase.lib.Pair; +import org.w3c.xhtml1.Xhtml1Package; + +@SuppressWarnings("all") +public class XhtmlUtil { + public EClass tag(final String tagName) { + final String typeName = (tagName + "Type"); + Iterable<EClass> _filter = Iterables.<EClass>filter(Xhtml1Package.eINSTANCE.getEClassifiers(), EClass.class); + for (final EClass eClass : _filter) { + { + final String className = eClass.getName(); + if ((className.equalsIgnoreCase(tagName) || className.equalsIgnoreCase(typeName))) { + return eClass; + } + } + } + return null; + } + + public EObject create(final EClass tag) { + return EcoreUtil.create(tag); + } + + public EObject create(final String tagName) { + EObject _xblockexpression = null; + { + final EClass tag = this.tag(tagName); + EObject _xifexpression = null; + if ((tag != null)) { + _xifexpression = this.create(tag); + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } + + public EStructuralFeature attr(final EObject eObject, final String attrName) { + final Function1<EStructuralFeature, Boolean> _function = (EStructuralFeature it) -> { + String _name = it.getName(); + return Boolean.valueOf(Objects.equal(_name, attrName)); + }; + return IterableExtensions.<EStructuralFeature>findFirst(eObject.eClass().getEAllStructuralFeatures(), _function); + } + + public Object operator_add(final EObject eObject, final Pair<String, String> attr) { + Object _xblockexpression = null; + { + final EStructuralFeature feature = this.attr(eObject, attr.getKey()); + Object _xifexpression = null; + if ((feature != null)) { + Object _xblockexpression_1 = null; + { + EClassifier _eType = feature.getEType(); + final EDataType featureType = ((EDataType) _eType); + final Object value = featureType.getEPackage().getEFactoryInstance().createFromString(featureType, attr.getValue()); + Object _xifexpression_1 = null; + boolean _isMany = feature.isMany(); + if (_isMany) { + _xifexpression_1 = null; + } else { + eObject.eSet(feature, value); + } + _xblockexpression_1 = _xifexpression_1; + } + _xifexpression = _xblockexpression_1; + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } + + public FeatureMap featureMap(final EObject featureMapOwner) { + EList<EStructuralFeature> _eAllStructuralFeatures = featureMapOwner.eClass().getEAllStructuralFeatures(); + for (final EStructuralFeature feature : _eAllStructuralFeatures) { + EClassifier _eType = feature.getEType(); + EDataType _eFeatureMapEntry = EcorePackage.eINSTANCE.getEFeatureMapEntry(); + boolean _equals = Objects.equal(_eType, _eFeatureMapEntry); + if (_equals) { + Object _eGet = featureMapOwner.eGet(feature); + return ((FeatureMap) _eGet); + } + } + return null; + } + + public EObject operator_add(final EObject featureMapOwner, final EObject eObject) { + EObject _xblockexpression = null; + { + final FeatureMap featureMap = this.featureMap(featureMapOwner); + if ((featureMap != null)) { + EList<EStructuralFeature> _eAllStructuralFeatures = featureMapOwner.eClass().getEAllStructuralFeatures(); + for (final EStructuralFeature feature : _eAllStructuralFeatures) { + boolean _isInstance = feature.getEType().isInstance(eObject); + if (_isInstance) { + featureMap.add(feature, eObject); + return featureMapOwner; + } + } + String _name = eObject.eClass().getName(); + String _plus = ("Didn\'t find feature for " + _name); + String _plus_1 = (_plus + " in "); + String _name_1 = featureMapOwner.eClass().getName(); + String _plus_2 = (_plus_1 + _name_1); + System.err.println(_plus_2); + } + _xblockexpression = featureMapOwner; + } + return _xblockexpression; + } + + public EObject operator_add(final EObject featureMapOwner, final Iterable<? extends EObject> eObjects) { + EObject _xblockexpression = null; + { + for (final EObject eObject : eObjects) { + this.operator_add(featureMapOwner, eObject); + } + _xblockexpression = featureMapOwner; + } + return _xblockexpression; + } + + public FeatureMap operator_add(final FeatureMap featureMap, final CharSequence text) { + FeatureMap _xblockexpression = null; + { + if ((featureMap != null)) { + String _xifexpression = null; + if ((text != null)) { + _xifexpression = text.toString(); + } else { + _xifexpression = ""; + } + FeatureMapUtil.addText(featureMap, _xifexpression); + } + _xblockexpression = featureMap; + } + return _xblockexpression; + } + + public EObject operator_add(final EObject featureMapOwner, final CharSequence text) { + EObject _xblockexpression = null; + { + final FeatureMap featureMap = this.featureMap(featureMapOwner); + if ((featureMap != null)) { + this.operator_add(featureMap, text); + } + _xblockexpression = featureMapOwner; + } + return _xblockexpression; + } + + public StringBuilder operator_doubleLessThan(final StringBuilder stringBuilder, final Object o) { + return stringBuilder.append(o); + } +}