[isidorus-cvs] r1029 - trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Wed Oct 26 17:07:01 UTC 2011


Author: lgiessmann
Date: Wed Oct 26 10:06:49 2011
New Revision: 1029

Log:
gdl-frontend: Widgets: implemented the gdlt:Datatype semantics for generating content entered in GdlVisibleObject

Modified:
   trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java

Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Oct 26 09:56:05 2011	(r1028)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Oct 26 10:06:49 2011	(r1029)
@@ -2858,7 +2858,29 @@
 	// handles the getContent call for a Datatye value
 	// handles the getContent call for scope topics
 	private void getDatatypeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
-		// TODO: implement
+		if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
+
+		Construct owner = null;
+		TopicMapsTypes ownerType = null;
+		if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){
+			ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
+			if(variants.size() != 0){
+				owner = variants.get(0);
+				variants.get(0).setValue(variants.get(0).getValue(), variants.get(0).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)));
+				ownerType = TopicMapsTypes.Variant;
+			}
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclOccurrenceConstraint)){
+			Topic occType = TmHelper.getConstrainedStatement(this.getRootConstraint());
+			JsArray<Occurrence> occs = ((Topic)this.receivedData).getOccurrences(occType);
+			if(occs.length() != 0){
+				owner = occs.get(0);
+				occs.get(0).setValue(occs.get(0).getValue(), occs.get(0).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)));
+				ownerType = TopicMapsTypes.Occurrence;
+			}
+		} else {
+			throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + " or " + PSIs.TMCL.tmclOccurrenceConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
+		}		
+		contents.add(new Pair<Object, TopicMapsTypes>(owner, ownerType));
 	}
 	
 	




More information about the Isidorus-cvs mailing list