[isidorus-cvs] r1012 - in trunk/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets/base war/gdl_widgets

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Thu Oct 20 07:47:08 UTC 2011


Author: lgiessmann
Date: Thu Oct 20 00:47:07 2011
New Revision: 1012

Log:
gdl-frontend: Widgets: implemented the gdlt:Variant-Identifiers-Scope and gdlt:Datatype semantics for retrieving data

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/PSIs.java
   trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
   trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm

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	Thu Oct 20 00:14:01 2011	(r1011)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Thu Oct 20 00:47:07 2011	(r1012)
@@ -1981,23 +1981,9 @@
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){
 			if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
 
-			Topic nameType = TmHelper.getConstrainedStatement(this.getRootConstraint());
-			JsArray<Name> names = ((Topic)this.receivedData).getNames(nameType);
-			Topic scope = TmHelper.getConstrainedScopeTopic(this.getRootConstraint()); 
-			JsArray<Variant> variants = names.get(0).getVariants();
-
-			for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
-				if(variants.get(varIdx).getScope().length() != 0){
-					JsArray<Topic> scopes = variants.get(varIdx).getScope();
-					int scopeIdx = 0;
-					for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
-
-					if(scopeIdx != scopes.length()){
-						this.addSubItem(variants.get(varIdx).getValue());
-						break;
-					}
-				}
-			}
+			ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getConstraint());
+			if(variants.size() != 0) this.addSubItem(variants.get(0).getValue());
+			else this.addSubItem("");
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclScopeConstraint)){
 			Topic type = TmHelper.getConstrainedStatement(this.getConstraint());
 
@@ -2052,29 +2038,40 @@
 			if(str == null) str = "";
 			this.addSubItem(str);
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlDatatype)){
-			// TODO: implement: Datatype
+			if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
+
+			if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){
+				ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
+				if(variants.size() != 0){
+					this.addSubItem(variants.get(0).getDatatype().getReference());
+				}
+			} 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) this.addSubItem(occs.get(0).getDatatype().getReference());
+			} 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()));
+			}
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameIdentifiers)){
-			// TODO: implement: Variant-Name-Identifiers
+			if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
+			if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
+			
+			ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
+			if(variants.size() != 0){
+				for(int i = 0; i != variants.get(0).getItemIdentifiers().length(); ++i) this.addSubItem(variants.get(0).getItemIdentifiers().get(i).getReference());
+			}
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameReifier)){
+			if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
+			if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
+			
 			// TODO: implement: Variant-Name-Reifier
 		} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameScope)){
 			if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
-
-			Topic nameType = TmHelper.getConstrainedStatement(this.getRootConstraint());
-			JsArray<Name> names = ((Topic)this.receivedData).getNames(nameType);
-			Topic scope = TmHelper.getConstrainedScopeTopic(this.getRootConstraint()); 
-			JsArray<Variant> variants = names.get(0).getVariants();
-
-			for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
-				if(variants.get(varIdx).getScope().length() != 0){
-					JsArray<Topic> scopes = variants.get(varIdx).getScope();
-					int scopeIdx = 0;
-					for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
-
-					if(scopeIdx != scopes.length()){
-						for(int i = 0; i != scopes.length(); ++i) this.addSubItem(this.getTopicRepresentation(scopes.get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
-					}
-				}
+			if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
+			
+			ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
+			if(variants.size() != 0){
+				for(int i = 0; i != variants.get(0).getScope().length(); ++i) this.addSubItem(this.getTopicRepresentation(variants.get(0).getScope().get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
 			}
 		} else {
 			throw new InvalidGdlSchemaException("The constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " is not suported to be bound to the value group instance " + TmHelper.getAnyIdOfTopic(this.getValueGroup()));

Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java
==============================================================================
--- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java	Thu Oct 20 00:14:01 2011	(r1011)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java	Thu Oct 20 00:47:07 2011	(r1012)
@@ -21,6 +21,7 @@
 		public final static String tmclAssociationType = tmcl + "association-type";
 		public final static String tmclRoleType = tmcl + "role-type";
 		public final static String tmclConstraint = tmcl + "constraint";
+		public final static String tmclOccurrenceConstraint = tmcl + "occurrence-constraint";
 		public final static String tmclConstrained = tmcl + "constrained";
 		public final static String tmclConstrainedStatement = tmcl + "constrained-statement";
 		public final static String tmclRegularExpressionConstraint = tmcl + "regular-expression-constraint";

Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
==============================================================================
--- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Thu Oct 20 00:14:01 2011	(r1011)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Thu Oct 20 00:47:07 2011	(r1012)
@@ -12,6 +12,7 @@
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ScopedStub;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Variant;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
@@ -1498,4 +1499,31 @@
 		else if(result.size() == 1) return result.get(0);
 		else return null;
 	}
+
+	
+	// Returns all variants of a topic that satisfies the passed constraint.
+	public static ArrayList<Variant> getVariantsForConstraint(Topic owner, Topic constraint) throws InvalidGdlSchemaException {
+		ArrayList<Variant> result = new ArrayList<Variant>();
+		if(owner == null || constraint == null) return result;
+		
+		Topic nameType = TmHelper.getConstrainedStatement(constraint);
+		JsArray<Name> names = owner.getNames(nameType);
+		Topic scope = TmHelper.getConstrainedScopeTopic(constraint); 
+
+		for(int nameIdx = 0; nameIdx != names.length(); ++nameIdx){
+			JsArray<Variant> variants = names.get(nameIdx).getVariants();
+			for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
+				if(variants.get(varIdx).getScope().length() != 0){
+					JsArray<Topic> scopes = variants.get(varIdx).getScope();
+					int scopeIdx = 0;
+					for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
+
+					if(scopeIdx != scopes.length()) result.add(variants.get(varIdx));
+				}
+			}
+		}
+		
+		return result;
+	}
+
 }

Modified: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm
==============================================================================
--- trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm	Thu Oct 20 00:14:01 2011	(r1011)
+++ trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm	Thu Oct 20 00:47:07 2011	(r1012)
@@ -222,12 +222,12 @@
             {"subject_identifiers":["[model:service-variant-name-scope-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Scope]"]},
             
             {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_ii_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]},
-            {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"430px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
+            {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"450px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
             {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]},
             {"subject_identifiers":["[model:service-variant-name-ii-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Identifiers]"]},
 
 			{"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]},
-            {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"470px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
+            {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
             {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]},
             {"subject_identifiers":["[model:service-variant-name-reifier-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Reifier]"]},
                         




More information about the Isidorus-cvs mailing list