Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added the engagement types and their enumerations and test cases

  • Loading branch information...
commit efd76b7e078cb5259f9b4df566fe3ea89ddd0d13 1 parent b6ae2ef
scottbw authored January 05, 2012
112  src-test/org/xcri/core/PresentationTest.java
@@ -38,6 +38,9 @@
38 38
 import org.junit.Test;
39 39
 import org.xcri.Namespaces;
40 40
 import org.xcri.exceptions.InvalidElementException;
  41
+import org.xcri.presentation.AttendanceMode;
  42
+import org.xcri.presentation.AttendancePattern;
  43
+import org.xcri.presentation.StudyMode;
41 44
 
42 45
 public class PresentationTest {
43 46
 	
@@ -230,9 +233,44 @@ public void testInheritDescription() throws InvalidElementException, JDOMExcepti
230 233
 	 * 
231 234
 	 * Note: These are mutually exclusive terms, so 'Full time' does not include 'Part of a full time programme'.
232 235
 	 */
  236
+	@Test
  237
+	public void studyModeTest1() throws InvalidElementException, JDOMException, IOException{
  238
+        Logger logger = Logger.getLogger(StudyMode.class.getName());
  239
+
  240
+        Formatter formatter = new SimpleFormatter();
  241
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
  242
+        Handler handler = new StreamHandler(out, formatter);
  243
+        logger.addHandler(handler);
  244
+
  245
+        try {
  246
+        	Catalog catalog = new Catalog();
  247
+    		SAXBuilder builder = new SAXBuilder();
  248
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><studyMode identifier=\"TEST\"></studyMode></presentation></course></provider></catalog>"));
  249
+    		catalog.fromXml(document);
  250
+
  251
+            handler.flush();
  252
+            String logMsg = out.toString();
  253
+
  254
+            assertNotNull(logMsg);
  255
+            assertTrue(logMsg.contains("WARNING: StudyMode : identifier (\"TEST\") is not a member of the recommended vocabulary"));
  256
+
  257
+        } finally {
  258
+            logger.removeHandler(handler);
  259
+        }	
  260
+	}
  261
+	@Test
  262
+	public void studyModeTest2() throws InvalidElementException, JDOMException, IOException{
  263
+
  264
+        	Catalog catalog = new Catalog();
  265
+    		SAXBuilder builder = new SAXBuilder();
  266
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><studyMode identifier=\"FT\"></studyMode></presentation></course></provider></catalog>"));
  267
+    		catalog.fromXml(document);
  268
+
  269
+            assertEquals(StudyMode.StudyModeType.FT, catalog.getProviders()[0].getCourses()[0].getPresentations()[0].getStudyMode().getStudyModeType());
  270
+	}
233 271
 	
234 272
 	/**
235  
-	 * TODO Attendance Mode
  273
+	 * Attendance Mode
236 274
 	 * 
237 275
 	 * Recommended Values: Producers SHOULD use the following values for this element, with the 
238 276
 	 * two-letter code used in the @identifier attribute, and the label in the element content:
@@ -246,9 +284,44 @@ public void testInheritDescription() throws InvalidElementException, JDOMExcepti
246 284
 	 * ON Online (no attendance)
247 285
 	 * WB Work-based
248 286
 	 */
  287
+	@Test
  288
+	public void attenanceModeTest1() throws InvalidElementException, JDOMException, IOException{
  289
+        Logger logger = Logger.getLogger(AttendanceMode.class.getName());
  290
+
  291
+        Formatter formatter = new SimpleFormatter();
  292
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
  293
+        Handler handler = new StreamHandler(out, formatter);
  294
+        logger.addHandler(handler);
  295
+
  296
+        try {
  297
+        	Catalog catalog = new Catalog();
  298
+    		SAXBuilder builder = new SAXBuilder();
  299
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><attendanceMode identifier=\"TEST\"></attendanceMode></presentation></course></provider></catalog>"));
  300
+    		catalog.fromXml(document);
  301
+
  302
+            handler.flush();
  303
+            String logMsg = out.toString();
  304
+
  305
+            assertNotNull(logMsg);
  306
+            assertTrue(logMsg.contains("WARNING: AttendanceMode : identifier (\"TEST\") is not a member of the recommended vocabulary"));
  307
+
  308
+        } finally {
  309
+            logger.removeHandler(handler);
  310
+        }	
  311
+	}
  312
+	@Test
  313
+	public void attendanceModeTest2() throws InvalidElementException, JDOMException, IOException{
  314
+
  315
+        	Catalog catalog = new Catalog();
  316
+    		SAXBuilder builder = new SAXBuilder();
  317
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><attendanceMode identifier=\"MM\"></attendanceMode></presentation></course></provider></catalog>"));
  318
+    		catalog.fromXml(document);
  319
+
  320
+            assertEquals(AttendanceMode.AttendanceModeType.MM, catalog.getProviders()[0].getCourses()[0].getPresentations()[0].getAttendanceMode().getAttendanceModeType());
  321
+	}
249 322
 	
250 323
 	/**
251  
-	 * TODO Attendance Pattern
  324
+	 * Attendance Pattern
252 325
 	 * 
253 326
 	 * Recommended Values: Producers SHOULD use the following values for this element, with 
254 327
 	 * the two-letter code used in the @identifier attribute, and the label in the element content:
@@ -260,6 +333,41 @@ public void testInheritDescription() throws InvalidElementException, JDOMExcepti
260 333
 	 * WE Weekend
261 334
 	 * CS Customised
262 335
 	 */
  336
+	@Test
  337
+	public void attenancePatternTest1() throws InvalidElementException, JDOMException, IOException{
  338
+        Logger logger = Logger.getLogger(AttendancePattern.class.getName());
  339
+
  340
+        Formatter formatter = new SimpleFormatter();
  341
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
  342
+        Handler handler = new StreamHandler(out, formatter);
  343
+        logger.addHandler(handler);
  344
+
  345
+        try {
  346
+        	Catalog catalog = new Catalog();
  347
+    		SAXBuilder builder = new SAXBuilder();
  348
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><attendancePattern identifier=\"TEST\"></attendancePattern></presentation></course></provider></catalog>"));
  349
+    		catalog.fromXml(document);
  350
+
  351
+            handler.flush();
  352
+            String logMsg = out.toString();
  353
+
  354
+            assertNotNull(logMsg);
  355
+            assertTrue(logMsg.contains("WARNING: AttendancePattern : identifier (\"TEST\") is not a member of the recommended vocabulary"));
  356
+
  357
+        } finally {
  358
+            logger.removeHandler(handler);
  359
+        }	
  360
+	}
  361
+	@Test
  362
+	public void attendancePattern2() throws InvalidElementException, JDOMException, IOException{
  363
+
  364
+        	Catalog catalog = new Catalog();
  365
+    		SAXBuilder builder = new SAXBuilder();
  366
+    		Document document = builder.build(new StringReader("<catalog xmlns=\""+Namespaces.XCRI_NAMESPACE+"\" xmlns:mlo=\""+Namespaces.MLO_NAMESPACE+"\" xmlns:dc=\""+Namespaces.DC_NAMESPACE+"\" xmlns:xsi=\""+Namespaces.XSI_NAMESPACE+"\"><provider><course><presentation><attendancePattern identifier=\"EV\"></attendancePattern></presentation></course></provider></catalog>"));
  367
+    		catalog.fromXml(document);
  368
+
  369
+            assertEquals(AttendancePattern.AttendancePatternType.EV, catalog.getProviders()[0].getCourses()[0].getPresentations()[0].getAttendancePattern().getAttendancePatternType());
  370
+	}
263 371
 	
264 372
 	/**
265 373
 	 * TODO Places
106  src/org/xcri/core/Presentation.java
@@ -29,9 +29,13 @@
29 29
 import org.xcri.presentation.ApplyFrom;
30 30
 import org.xcri.presentation.ApplyTo;
31 31
 import org.xcri.presentation.ApplyUntil;
  32
+import org.xcri.presentation.AttendanceMode;
  33
+import org.xcri.presentation.AttendancePattern;
32 34
 import org.xcri.presentation.Duration;
33 35
 import org.xcri.presentation.End;
  36
+import org.xcri.presentation.Engagement;
34 37
 import org.xcri.presentation.Start;
  38
+import org.xcri.presentation.StudyMode;
35 39
 import org.xcri.types.CommonDescriptiveType;
36 40
 import org.xcri.types.CommonType;
37 41
 
@@ -45,6 +49,16 @@
45 49
 	private ApplyFrom applyFrom;
46 50
 	private ApplyUntil applyUntil;
47 51
 	private ApplyTo applyTo;
  52
+	private Engagement[] engagements;
  53
+	private StudyMode studyMode;
  54
+	private AttendanceMode attendanceMode;
  55
+	private AttendancePattern attendancePattern;
  56
+	// TODO languageOfINstruction
  57
+	// TODO languageOfAssessment
  58
+	// TODO places
  59
+	// TODO cost
  60
+	// TODO age
  61
+	// TODO venue
48 62
 
49 63
 	/* (non-Javadoc)
50 64
 	 * @see org.xcri.types.CommonType#toXml()
@@ -55,6 +69,12 @@ public Element toXml() {
55 69
 		if (this.getStart() != null) element.addContent(this.getStart().toXml());
56 70
 		if (this.getEnd() != null) element.addContent(this.getEnd().toXml());
57 71
 		if (this.getDuration() != null) element.addContent(this.getDuration().toXml());
  72
+		if (this.getApplyFrom() != null) element.addContent(this.getApplyFrom().toXml());
  73
+		if (this.getApplyUntil() != null) element.addContent(this.getApplyUntil().toXml());
  74
+		if (this.getApplyTo() != null) element.addContent(this.getApplyTo().toXml());
  75
+		// TODO Engagement
  76
+		if (this.getStudyMode() != null) element.addContent(this.getStudyMode().toXml());
  77
+		if (this.getAttendanceMode() != null) element.addContent(this.getAttendanceMode().toXml());
58 78
 		return element;
59 79
 	}
60 80
 
@@ -138,6 +158,36 @@ public void fromXml(Element element) throws InvalidElementException {
138 158
 			}
139 159
 		}
140 160
 		
  161
+		// TODO engagement
  162
+		
  163
+		if (element.getChild("studyMode", Namespaces.XCRI_NAMESPACE_NS)!=null){
  164
+			StudyMode studyMode = new StudyMode();
  165
+			try {
  166
+				studyMode.fromXml(element.getChild("studyMode", Namespaces.XCRI_NAMESPACE_NS));
  167
+				this.setStudyMode(studyMode);
  168
+			} catch (InvalidElementException e) {
  169
+				log.warn("presentation : skipping invalid studyMode element: "+e.getMessage());
  170
+			}
  171
+		}
  172
+		if (element.getChild("attendanceMode", Namespaces.XCRI_NAMESPACE_NS)!=null){
  173
+			AttendanceMode attendanceMode = new AttendanceMode();
  174
+			try {
  175
+				attendanceMode.fromXml(element.getChild("attendanceMode", Namespaces.XCRI_NAMESPACE_NS));
  176
+				this.setAttendanceMode(attendanceMode);
  177
+			} catch (InvalidElementException e) {
  178
+				log.warn("presentation : skipping invalid attendanceMode element: "+e.getMessage());
  179
+			}
  180
+		}
  181
+		if (element.getChild("attendancePattern", Namespaces.XCRI_NAMESPACE_NS)!=null){
  182
+			AttendancePattern attendancePattern = new AttendancePattern();
  183
+			try {
  184
+				attendancePattern.fromXml(element.getChild("attendancePattern", Namespaces.XCRI_NAMESPACE_NS));
  185
+				this.setAttendancePattern(attendancePattern);
  186
+			} catch (InvalidElementException e) {
  187
+				log.warn("presentation : skipping invalid attendancePattern element: "+e.getMessage());
  188
+			}
  189
+		}
  190
+		
141 191
 	}
142 192
 
143 193
 	/* (non-Javadoc)
@@ -252,6 +302,62 @@ public ApplyTo getApplyTo() {
252 302
 	public void setApplyTo(ApplyTo applyTo) {
253 303
 		this.applyTo = applyTo;
254 304
 	}
  305
+
  306
+	/**
  307
+	 * @return the engagements
  308
+	 */
  309
+	public Engagement[] getEngagements() {
  310
+		return engagements;
  311
+	}
  312
+
  313
+	/**
  314
+	 * @param engagements the engagements to set
  315
+	 */
  316
+	public void setEngagements(Engagement[] engagements) {
  317
+		this.engagements = engagements;
  318
+	}
  319
+
  320
+	/**
  321
+	 * @return the studyMode
  322
+	 */
  323
+	public StudyMode getStudyMode() {
  324
+		return studyMode;
  325
+	}
  326
+
  327
+	/**
  328
+	 * @param studyMode the studyMode to set
  329
+	 */
  330
+	public void setStudyMode(StudyMode studyMode) {
  331
+		this.studyMode = studyMode;
  332
+	}
  333
+
  334
+	/**
  335
+	 * @return the attendanceMode
  336
+	 */
  337
+	public AttendanceMode getAttendanceMode() {
  338
+		return attendanceMode;
  339
+	}
  340
+
  341
+	/**
  342
+	 * @param attendanceMode the attendanceMode to set
  343
+	 */
  344
+	public void setAttendanceMode(AttendanceMode attendanceMode) {
  345
+		this.attendanceMode = attendanceMode;
  346
+	}
  347
+
  348
+	/**
  349
+	 * @return the attendancePattern
  350
+	 */
  351
+	public AttendancePattern getAttendancePattern() {
  352
+		return attendancePattern;
  353
+	}
  354
+
  355
+	/**
  356
+	 * @param attendancePattern the attendancePattern to set
  357
+	 */
  358
+	public void setAttendancePattern(AttendancePattern attendancePattern) {
  359
+		this.attendancePattern = attendancePattern;
  360
+	}
255 361
 	
256 362
 	
257 363
 
111  src/org/xcri/presentation/AttendanceMode.java
... ...
@@ -0,0 +1,111 @@
  1
+/**
  2
+ * Copyright (c) 2011 University of Bolton
  3
+ *
  4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this 
  5
+ * software and associated documentation files (the "Software"), to deal in the Software 
  6
+ * without restriction, including without limitation the rights to use, copy, modify, 
  7
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
  8
+ * permit persons to whom the Software is furnished to do so, subject to the following 
  9
+ * conditions:
  10
+ * The above copyright notice and this permission notice shall be included in all copies 
  11
+ * or substantial portions of the Software.
  12
+ *
  13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
  14
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  15
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
  16
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
  17
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
  18
+ * OR OTHER DEALINGS IN THE SOFTWARE.
  19
+ */
  20
+package org.xcri.presentation;
  21
+
  22
+import org.apache.commons.logging.Log;
  23
+import org.apache.commons.logging.LogFactory;
  24
+import org.jdom.Element;
  25
+import org.jdom.Namespace;
  26
+import org.xcri.Namespaces;
  27
+import org.xcri.exceptions.InvalidElementException;
  28
+import org.xcri.types.XcriElement;
  29
+
  30
+public class AttendanceMode extends XcriElement {
  31
+	
  32
+	private Log log = LogFactory.getLog(AttendanceMode.class);
  33
+	
  34
+	public enum AttendanceModeType {
  35
+		CM,
  36
+		DA,
  37
+		DS,
  38
+		NC,
  39
+		MM,
  40
+		ON,
  41
+		WB;
  42
+	}
  43
+	
  44
+	public AttendanceModeType getAttendanceModeType(){
  45
+		try {
  46
+			return AttendanceModeType.valueOf(getIdentifier());
  47
+		} catch (Exception e) {
  48
+			return null;
  49
+		}
  50
+	}
  51
+	
  52
+	private String identifier;
  53
+
  54
+
  55
+	@Override
  56
+	public Namespace getNamespace() {
  57
+		return Namespaces.XCRI_NAMESPACE_NS;
  58
+	}
  59
+
  60
+	@Override
  61
+	public String getName() {
  62
+		return "attendanceMode";
  63
+	}
  64
+
  65
+	@Override
  66
+	public Element toXml() {
  67
+		return super.toXml();
  68
+	}
  69
+
  70
+	@Override
  71
+	public void fromXml(Element element) throws InvalidElementException {
  72
+		super.fromXml(element);
  73
+
  74
+		/**
  75
+		 * Recommended Values: Producers SHOULD use the following values for this element, with the two-letter code used in the @identifier attribute, and the label in the element content:
  76
+		 * The value of this element MUST be one of:
  77
+		 * CM Campus
  78
+		 * DA Distance with attendance
  79
+		 * DS Distance without attendance
  80
+		 * NC Face-to-face non-campus
  81
+		 * MM Mixed mode
  82
+		 * ON Online (no attendance)
  83
+		 * WB Work-based
  84
+		 */
  85
+		
  86
+		String identifier = element.getAttributeValue("identifier");
  87
+		if (identifier != null){
  88
+			this.setIdentifier(identifier);
  89
+			if (this.getAttendanceModeType() == null){
  90
+				log.warn("AttendanceMode : identifier (\""+identifier+"\") is not a member of the recommended vocabulary");
  91
+			}
  92
+		}
  93
+	}
  94
+
  95
+	/**
  96
+	 * @return the identifier
  97
+	 */
  98
+	public String getIdentifier() {
  99
+		return identifier;
  100
+	}
  101
+
  102
+	/**
  103
+	 * @param identifier the identifier to set
  104
+	 */
  105
+	public void setIdentifier(String identifier) {
  106
+		this.identifier = identifier;
  107
+	}
  108
+	
  109
+	
  110
+
  111
+}
108  src/org/xcri/presentation/AttendancePattern.java
... ...
@@ -0,0 +1,108 @@
  1
+/**
  2
+ * Copyright (c) 2011 University of Bolton
  3
+ *
  4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this 
  5
+ * software and associated documentation files (the "Software"), to deal in the Software 
  6
+ * without restriction, including without limitation the rights to use, copy, modify, 
  7
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
  8
+ * permit persons to whom the Software is furnished to do so, subject to the following 
  9
+ * conditions:
  10
+ * The above copyright notice and this permission notice shall be included in all copies 
  11
+ * or substantial portions of the Software.
  12
+ *
  13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
  14
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  15
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
  16
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
  17
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
  18
+ * OR OTHER DEALINGS IN THE SOFTWARE.
  19
+ */
  20
+package org.xcri.presentation;
  21
+
  22
+import org.apache.commons.logging.Log;
  23
+import org.apache.commons.logging.LogFactory;
  24
+import org.jdom.Element;
  25
+import org.jdom.Namespace;
  26
+import org.xcri.Namespaces;
  27
+import org.xcri.exceptions.InvalidElementException;
  28
+import org.xcri.types.XcriElement;
  29
+
  30
+public class AttendancePattern extends XcriElement {
  31
+	
  32
+	private Log log = LogFactory.getLog(AttendancePattern.class);
  33
+	
  34
+	public enum AttendancePatternType {
  35
+		DT,
  36
+		EV,
  37
+		TW,
  38
+		DR,
  39
+		WE,
  40
+		CS;
  41
+	}
  42
+	
  43
+	public AttendancePatternType getAttendancePatternType(){
  44
+		try {
  45
+			return AttendancePatternType.valueOf(getIdentifier());
  46
+		} catch (Exception e) {
  47
+			return null;
  48
+		}
  49
+	}
  50
+	
  51
+	private String identifier;
  52
+
  53
+
  54
+	@Override
  55
+	public Namespace getNamespace() {
  56
+		return Namespaces.XCRI_NAMESPACE_NS;
  57
+	}
  58
+
  59
+	@Override
  60
+	public String getName() {
  61
+		return "attendancePattern";
  62
+	}
  63
+
  64
+	@Override
  65
+	public Element toXml() {
  66
+		return super.toXml();
  67
+	}
  68
+
  69
+	@Override
  70
+	public void fromXml(Element element) throws InvalidElementException {
  71
+		super.fromXml(element);
  72
+
  73
+		/**
  74
+		 *Recommended Values: Producers SHOULD use the following values for this element, with the two-letter code used in the @identifier attribute, and the label in the element content:
  75
+		 *DT Daytime
  76
+		 *EV Evening
  77
+		 *TW Twilight
  78
+		 *DR Day/Block release
  79
+		 *WE Weekend
  80
+		 *CS Customised
  81
+		 */
  82
+		
  83
+		String identifier = element.getAttributeValue("identifier");
  84
+		if (identifier != null){
  85
+			this.setIdentifier(identifier);
  86
+			if (this.getAttendancePatternType() == null){
  87
+				log.warn("AttendancePattern : identifier (\""+identifier+"\") is not a member of the recommended vocabulary");
  88
+			}
  89
+		}
  90
+	}
  91
+
  92
+	/**
  93
+	 * @return the identifier
  94
+	 */
  95
+	public String getIdentifier() {
  96
+		return identifier;
  97
+	}
  98
+
  99
+	/**
  100
+	 * @param identifier the identifier to set
  101
+	 */
  102
+	public void setIdentifier(String identifier) {
  103
+		this.identifier = identifier;
  104
+	}
  105
+	
  106
+	
  107
+
  108
+}
45  src/org/xcri/presentation/Engagement.java
... ...
@@ -0,0 +1,45 @@
  1
+/**
  2
+ * Copyright (c) 2011 University of Bolton
  3
+ *
  4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this 
  5
+ * software and associated documentation files (the "Software"), to deal in the Software 
  6
+ * without restriction, including without limitation the rights to use, copy, modify, 
  7
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
  8
+ * permit persons to whom the Software is furnished to do so, subject to the following 
  9
+ * conditions:
  10
+ * The above copyright notice and this permission notice shall be included in all copies 
  11
+ * or substantial portions of the Software.
  12
+ *
  13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
  14
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  15
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
  16
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
  17
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
  18
+ * OR OTHER DEALINGS IN THE SOFTWARE.
  19
+ */
  20
+package org.xcri.presentation;
  21
+
  22
+import org.jdom.Namespace;
  23
+import org.xcri.Namespaces;
  24
+import org.xcri.types.XcriElement;
  25
+
  26
+public class Engagement extends XcriElement {
  27
+
  28
+	/* (non-Javadoc)
  29
+	 * @see org.xcri.types.XcriElement#getNamespace()
  30
+	 */
  31
+	@Override
  32
+	public Namespace getNamespace() {
  33
+		return Namespaces.MLO_NAMESPACE_NS;
  34
+	}
  35
+
  36
+	/* (non-Javadoc)
  37
+	 * @see org.xcri.types.XcriElement#getName()
  38
+	 */
  39
+	@Override
  40
+	public String getName() {
  41
+		return "engagement";
  42
+	}
  43
+	
  44
+	
  45
+}
106  src/org/xcri/presentation/StudyMode.java
... ...
@@ -0,0 +1,106 @@
  1
+/**
  2
+ * Copyright (c) 2011 University of Bolton
  3
+ *
  4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this 
  5
+ * software and associated documentation files (the "Software"), to deal in the Software 
  6
+ * without restriction, including without limitation the rights to use, copy, modify, 
  7
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
  8
+ * permit persons to whom the Software is furnished to do so, subject to the following 
  9
+ * conditions:
  10
+ * The above copyright notice and this permission notice shall be included in all copies 
  11
+ * or substantial portions of the Software.
  12
+ *
  13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
  14
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  15
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
  16
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
  17
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
  18
+ * OR OTHER DEALINGS IN THE SOFTWARE.
  19
+ */
  20
+package org.xcri.presentation;
  21
+
  22
+import org.apache.commons.logging.Log;
  23
+import org.apache.commons.logging.LogFactory;
  24
+import org.jdom.Element;
  25
+import org.jdom.Namespace;
  26
+import org.xcri.Namespaces;
  27
+import org.xcri.exceptions.InvalidElementException;
  28
+import org.xcri.types.XcriElement;
  29
+
  30
+public class StudyMode extends XcriElement {
  31
+	
  32
+	private Log log = LogFactory.getLog(StudyMode.class);
  33
+	
  34
+	public enum StudyModeType {
  35
+		NK,
  36
+		FL,
  37
+		PT,
  38
+		PF,
  39
+		FT
  40
+	}
  41
+	
  42
+	public StudyModeType getStudyModeType(){
  43
+		try {
  44
+			return StudyModeType.valueOf(getIdentifier());
  45
+		} catch (Exception e) {
  46
+			return null;
  47
+		}
  48
+	}
  49
+	
  50
+	private String identifier;
  51
+
  52
+
  53
+	@Override
  54
+	public Namespace getNamespace() {
  55
+		return Namespaces.XCRI_NAMESPACE_NS;
  56
+	}
  57
+
  58
+	@Override
  59
+	public String getName() {
  60
+		return "studyMode";
  61
+	}
  62
+
  63
+	@Override
  64
+	public Element toXml() {
  65
+		return super.toXml();
  66
+	}
  67
+
  68
+	@Override
  69
+	public void fromXml(Element element) throws InvalidElementException {
  70
+		super.fromXml(element);
  71
+		
  72
+		/**
  73
+		 * Recommended Values: Producers SHOULD use the following values for this element, with the two-letter code used in the @identifier attribute, and the label in the element content:
  74
+		 * NK Not known [DEFAULT] The provider has not supplied the information.
  75
+		 * FL Flexible Could be full time or part time dependent on the learner.
  76
+		 * FT Full time The learning opportunity is the learner's main activity.
  77
+		 * PF Part of a full time programme The learning opportunity is a component of a set of learning opportunities that form the learner's main activity.
  78
+		 * PT Part time The learning opportunity is not the learner's main activity
  79
+		 * Note: These are mutually exclusive terms, so 'Full time' does not include 'Part of a full time programme'.
  80
+		 */
  81
+		String identifier = element.getAttributeValue("identifier");
  82
+		if (identifier != null){
  83
+			this.setIdentifier(identifier);
  84
+			if (this.getStudyModeType() == null){
  85
+				log.warn("StudyMode : identifier (\""+identifier+"\") is not a member of the recommended vocabulary");
  86
+			}
  87
+		}
  88
+	}
  89
+
  90
+	/**
  91
+	 * @return the identifier
  92
+	 */
  93
+	public String getIdentifier() {
  94
+		return identifier;
  95
+	}
  96
+
  97
+	/**
  98
+	 * @param identifier the identifier to set
  99
+	 */
  100
+	public void setIdentifier(String identifier) {
  101
+		this.identifier = identifier;
  102
+	}
  103
+	
  104
+	
  105
+
  106
+}

0 notes on commit efd76b7

Please sign in to comment.
Something went wrong with that request. Please try again.