[isidorus-cvs] r697 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets/base war/gdl_widgets

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Aug 1 08:30:00 UTC 2011


Author: lgiessmann
Date: Mon Aug  1 01:29:59 2011
New Revision: 697

Log:
gdl-frontend: Widgets: implemented the method GdlText.getTmValueForScopeConstraint()

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java	Sun Jul 31 09:19:10 2011	(r696)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java	Mon Aug  1 01:29:59 2011	(r697)
@@ -11,7 +11,6 @@
 		public final static String supertype = tmdm + "supertype";
 		public final static String subtype = tmdm + "subtype";
 		public final static String supertypeSubtype = tmdm + "supertype-subtype";
-		
 	}
 
 	
@@ -37,6 +36,7 @@
 		public final static String tmclAllows = tmcl + "allows";
 		public final static String tmclAllowed = tmcl + "allowed";
 		public final static String tmclAllowedReifier = tmcl + "allowed-reifier";
+		public final static String tmclConstrainedScope = tmcl + "constrained-scope";
 	}
 	
 	

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Sun Jul 31 09:19:10 2011	(r696)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Mon Aug  1 01:29:59 2011	(r697)
@@ -748,11 +748,22 @@
 
 	
 	// returns the topic that can be used to satisfy the passed role-player-constraint.
-	public static ArrayList<Topic> getTmValuesForScopeConstraint(Topic scopeConstraint){
+	public static ArrayList<Topic> getTmValuesForScopeConstraint(Topic scopeConstraint) throws InvalidGdlSchemaException {
 		ArrayList<Topic> result = new ArrayList<Topic>();
 		if(scopeConstraint == null) return result;
-		// TODO: implement
-		
+
+		TopicMap tm = scopeConstraint.getTopicMap();
+		Topic constraintRoleType = getTopicByPsi(GdlPsis.TMCL.tmclConstraint, tm);
+		Topic constrainedScopeAssocType = getTopicByPsi(GdlPsis.TMCL.tmclConstrainedScope, tm);
+		Topic constrainedRoleType = getTopicByPsi(GdlPsis.TMCL.tmclConstrained, tm);
+		ArrayList<Topic> scopeTypes = getOtherPlayerOfBinaryAssociation(scopeConstraint, constraintRoleType, constrainedScopeAssocType, null, constrainedRoleType);
+				
+		if(scopeTypes.size() != 1){
+			throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(scopeConstraint) + " must be bound to exaclty one topic type that is used as scope-type, but is: " + scopeTypes.size());
+		} else {
+			JsArray<Topic> allTopics = tm.getTopics();
+			for(int i = 0; i != allTopics.length(); ++i) if(isInstanceOf(allTopics.get(i), scopeTypes.get(0))) result.add(allTopics.get(i));
+		}
 		return result;
 	}
 	
@@ -807,6 +818,9 @@
 			if(typeTopics.size() != 1){
 				throw new InvalidGdlSchemaException("the constraint " + getAnyIdOfTopic(rootConstraint) + " must be bound extactly once to an occurrence or name type, but is: " + typeTopics.size());
 			} else {
+				// add the direct specified type
+				result.add(typeTopics.get(0));
+				
 				// get subtypes of typeTopic
 				JsArray<Topic> allTopics = tm.getTopics();
 				for(int i = 0; i != allTopics.length(); ++i) if(isSupertypeOf(allTopics.get(i), typeTopics.get(0))) result.add(allTopics.get(i));

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Sun Jul 31 09:19:10 2011	(r696)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Mon Aug  1 01:29:59 2011	(r697)
@@ -37,13 +37,17 @@
            {"subject_identifiers":["[tmcl:allows]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[doc:poet-name]"]},
            {"subject_identifiers":["[doc:unused-person-name-reifier]"], "instance_of":["si:[doc:Reifier-Type]"]},
+           {"subject_identifiers":["[doc:unused-person-name-scope]"], "instance_of":["si:[doc:Scope-Type]"]},
            {"subject_identifiers":["[doc:Reifier-Type]"], "instance_of":["si:[tmcl:topic-type]"]},
+           {"subject_identifiers":["[doc:Scope-Type]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[doc:musician-name]"]},
            {"subject_identifiers":["[doc:director-name]"]},
            {"subject_identifiers":["[gdl:Visible-Object]"]},
            {"subject_identifiers":["[tmcl:constraint]"], "instance_of":["si:[tmcl:topic-type]","si:[tmcl:role-type]"]},
            {"subject_identifiers":["[tmcl:reifier-constraint]"], "instance_of":["si:[tmcl:topic-type]"]},
+           {"subject_identifiers":["[tmcl:scope-constraint]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[tmcl:constrained]"], "instance_of":["si:[tmcl:role-type]"]},
+           {"subject_identifiers":["[tmcl:constrained-scope]"], "instance_of":["si:[tmcl:association-type]"]},
            {"subject_identifiers":["[tmcl:constrained-statement]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[tmcl:constrained-topic-type]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[gdl:value]"], "instance_of":["si:[tmcl:role-type]"]},
@@ -109,6 +113,7 @@
            {"subject_identifiers":["[doc:person-name-type-constraint]"], "instance_of":["si:[gdl:Type]"]},
            {"subject_identifiers":["[doc:person-name-constraint]"], "instance_of":["si:[tmcl:topic-name-constraint]"], "occurrences":[{"type":"si:[tmcl:card-min]", "value":"1"}, {"type":"si:[tmcl:card-max]", "value":"1"}]},
            {"subject_identifiers":["[doc:person-name-reifier-constraint]"], "instance_of":["si:[tmcl:reifier-constraint]"], "occurrences":[{"type":"si:[tmcl:card-min]", "value":"1"}, {"type":"si:[tmcl:card-max]", "value":"1"}]},
+           {"subject_identifiers":["[doc:person-name-scope-constraint]"], "instance_of":["si:[tmcl:scope-constraint]"], "occurrences":[{"type":"si:[tmcl:card-min]", "value":"0"}, {"type":"si:[tmcl:card-max]", "value":"2"}]},
            {"subject_identifiers":["[doc:person-name-regexp-constraint]"], "instance_of":["si:[tmcl:regular-expression-constraint]"], "occurrences":[{"type":"si:[tmcl:regexp]", "value":"^[A-Z][a-z]+ [A-Z][a-z]+$"}]},
            {"subject_identifiers":["[doc:unit-1-radio-button]"], "instance_of":["si:[gdl:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_radio_button_id"},{"type":"si:[gdl:content-orientation]", "value":"horizontal"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin-left]", "value":"15pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]},
            {"subject_identifiers":["[doc:unit-1-check-box]"], "instance_of":["si:[gdl:Check-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_check_box_id"},{"type":"si:[gdl:content-orientation]", "value":"vertical"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin]", "value":"30pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]},
@@ -235,6 +240,7 @@
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:Person]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:Musician]"}]},
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:regular-expression-constraint]"}]},
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:reifier-constraint]"}]},
+                 {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:scope-constraint]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-1]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-2]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-editor-topic-view]"}]},
@@ -294,5 +300,6 @@
                  {"type":"si:[tmcl:constrained-topic-type]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:Person]"}]},
                  {"type":"si:[tmcl:constrained-statement]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-regexp-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:person-name]"}]},
                  {"type":"si:[tmcl:constrained-statement]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-reifier-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:person-name]"}]},
-                 {"type":"si:[tmcl:allowed-reifier]", "roles":[{"type":"si:[tmcl:allowed]", "player":"si:[doc:Reifier-Type]"},{"type":"si:[tmcl:allows]", "player":"si:[doc:person-name-reifier-constraint]"}]}
+                 {"type":"si:[tmcl:allowed-reifier]", "roles":[{"type":"si:[tmcl:allowed]", "player":"si:[doc:Reifier-Type]"},{"type":"si:[tmcl:allows]", "player":"si:[doc:person-name-reifier-constraint]"}]},
+                 {"type":"si:[tmcl:constrained-scope]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-scope-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:Scope-Type]"}]}
                 ]}
\ No newline at end of file




More information about the Isidorus-cvs mailing list