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

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Wed Jul 13 18:02:47 UTC 2011


Author: lgiessmann
Date: Wed Jul 13 11:02:47 2011
New Revision: 611

Log:
gdl-frontend: Widgets: implemted the loading of Gdl Default Views

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/environment/GdlInstantiator.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/TmHelper.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Wed Jul 13 08:18:43 2011	(r610)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Wed Jul 13 11:02:47 2011	(r611)
@@ -15,9 +15,9 @@
 import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis.TopicType;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
 import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
-
 import com.google.gwt.core.client.JsArray;
 
+
 public class TmHelper {
 	
 	
@@ -132,10 +132,17 @@
 		for (Topic topic : localCollectedSuperTypes) direcSupertypes.remove(topic); //avoid duplicates
 		for (Topic topic : direcSupertypes)localCollectedSuperTypes.add(topic);
 		
-		for (Topic topic : direcSupertypes){
-			ArrayList<Topic> tmp = getAllSuperTypes(topic, localCollectedSuperTypes);
-			for (Topic tmpTopic : tmp) localCollectedSuperTypes.add(tmpTopic);
+		ArrayList<Topic> collectedIndirectSupertypes = new ArrayList<Topic>();
+		for (Topic directSuperType : direcSupertypes) {
+			ArrayList<Topic> indirectSuperTypes = getAllSuperTypes(directSuperType, localCollectedSuperTypes);
+			for (Topic indirectSupertype : indirectSuperTypes)
+				if(!collectedIndirectSupertypes.contains(indirectSupertype)) collectedIndirectSupertypes.add(indirectSupertype);
 		}
+		
+		for (Topic collectedIndirectSupertype : collectedIndirectSupertypes)
+			if(!localCollectedSuperTypes.contains(collectedIndirectSupertype)) localCollectedSuperTypes.add(collectedIndirectSupertype);
+		
+		
 		return localCollectedSuperTypes;
 	}
 	
@@ -154,7 +161,7 @@
 		JsArray<Role> validRoles = top.getRolesPlayed(subtype, supertypeSubtype);
 		for(int i = 0; i != validRoles.length(); ++i){
 			Association parent = validRoles.get(i).getParent();
-			if(parent.getRoles().length() == 2 && parent.getRoles(supertype).length() == 1)result.add(parent.getRoles(supertypeSubtype).get(0).getPlayer());
+			if(parent.getRoles().length() == 2 && parent.getRoles(supertype).length() == 1)result.add(parent.getRoles(supertype).get(0).getPlayer());
 		}
 		return result;
 	}

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java	Wed Jul 13 08:18:43 2011	(r610)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java	Wed Jul 13 11:02:47 2011	(r611)
@@ -2,6 +2,9 @@
 
 
 import java.util.ArrayList;
+
+import com.google.gwt.user.client.Window;
+
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
 import us.isidor.gdl.anaToMia.Widgets.base.GdlLineBreak;
@@ -109,7 +112,7 @@
 	}
 
 	
-	// returns a GdlDefaultCreatorTopicView tha corresponds to the passed arguements
+	// returns a GdlDefaultCreatorTopicView that corresponds to the passed arguments
 	public static GdlDefaultCreatorTopicView instantiateDefaultCreatorTopicView(ArrayList<Pair<String, TopicIdentifierTypes>> requestedTopics, TopicMap schemaTm) throws InvalidGdlSchemaException, ExecutionException{
 		ArrayList<Topic> views = getViewTopics(requestedTopics, TmHelper.getTopicByPsi(GdlPsis.TopicType.gdlDefaultCreatorTopicView, schemaTm), schemaTm);
 		
@@ -117,11 +120,12 @@
 			String values = "";
 			for (Pair<String, TopicIdentifierTypes> pair : requestedTopics)
 				values += ", " + pair.getFirst();
-			values = values.substring(2);
+			if(values.length() >= 2 )values = values.substring(2);
 			String bindings = "";
 			for (Topic top : views)
 				bindings += ", " + TmHelper.getAnyIdOfTopic(top);
-			bindings = bindings.substring(2);
+			if(bindings.length() >= 2)bindings = bindings.substring(2);
+			else bindings = "[]";
 			throw new InvalidGdlSchemaException("the combination of topics requested (" + values + ") must be bound exactly once to a " + GdlPsis.TopicType.gdlDefaultCreatorTopicView + " but is bound to " + bindings);
 		}
 		
@@ -142,7 +146,7 @@
 			if(top == null) throw new InvalidGdlSchemaException("the topic " + topId.getFirst() + " was not found!");
 			if(!requestedTops.contains(top)) requestedTops.add(top);
 		}
-		
+			
 		// get all TM-Values, i.e. TM-Multiple-Type-Value and TM-Single-Type-Value (only if requstedTops.sie() == 1)
 		ArrayList<Topic> tmValues = new ArrayList<Topic>();
 		Topic tmConstruct = TmHelper.getTopicByPsi(GdlPsis.RoleType.gdlTmConstruct, schemaTm);
@@ -159,32 +163,35 @@
 					// if exactly those topics are associated to it through a tm-binding association, which are
 					// requested by the user
 					ArrayList<Topic> allInstanceValues = TmHelper.getOtherPlayerOfBinaryAssociation(tmValue, descriptor, tmBinding, null, tmConstruct);
+					Window.alert("allTmValues >> " + tmValue.getSubjectIdentifiers().get(0).getReference() + " >> " + allInstanceValues.size()); // TODO: remove
 					if(Utils.compareLists(allInstanceValues, requestedTops) && !tmValues.contains(tmValue)) tmValues.add(tmValue);
 				}
 			}
 		}
 		
+		for (Topic topic : tmValues) { // TODO: remove
+			Window.alert("tmValue >> " + topic.getSubjectIdentifiers().get(0).getReference());
+		}
+		
 		// get all views that are bound to the found tm-values
 		ArrayList<Topic> views = new ArrayList<Topic>();
 		Topic tmValueRoleType = TmHelper.getTopicByPsi(GdlPsis.RoleType.gdlTmValue, schemaTm);
 		Topic topicViewBinding = TmHelper.getTopicByPsi(GdlPsis.AssociationType.gdlTopicViewBinding, schemaTm);
 		for (Topic tmValue : tmValues) {
-			ArrayList<Topic> allViews = TmHelper.getOtherPlayerOfBinaryAssociation(tmValue, tmValueRoleType, topicViewBinding, null, descriptor);
-			// filter for allViews
-			if(viewSupertype == null){
-				for (Topic view : allViews)
-					if(!views.contains(view))views.add(view);
-			} else {
-				for (Topic view : allViews)
-					if(!views.contains(view) && TmHelper.isInstanceOf(view, viewSupertype)) views.add(view);
-			}
+			ArrayList<Topic> allViews = TmHelper.getOtherPlayerOfBinaryAssociation(tmValue, tmValueRoleType, topicViewBinding, null, viewSupertype, descriptor);
+			for (Topic view : allViews)
+				if(!views.contains(view) && TmHelper.isInstanceOf(view, viewSupertype)) views.add(view);
+		}
+		
+		for (Topic topic : views) { // TODO: remove
+			Window.alert("view >> " + topic.getSubjectIdentifiers().get(0).getReference());
 		}
 		
 		return views;
 	}
 	
 	
-	
+	// returns a GdlDefaultEditorTopicView that corresponds to the passed arguments
 	public static GdlDefaultEditorTopicView instantiateDefaultEditorTopicView(Pair<String, TopicIdentifierTypes> requestedTopic, TopicMap schemaTm) throws InvalidGdlSchemaException, ExecutionException{
 		if(requestedTopic == null || schemaTm == null) return null;
 		
@@ -215,7 +222,7 @@
 			String bindings = "";
 			for (Topic top : views)
 				bindings += ", " + TmHelper.getAnyIdOfTopic(top);
-			bindings = bindings.substring(2);
+			if(bindings.length() >= 2)bindings = bindings.substring(2);
 			throw new InvalidGdlSchemaException("the topic " + requestedTopic.getFirst() + " requested for editing must be bound to exaclty one " + GdlPsis.TopicType.gdlDefaultEditorTopicView + ", but is bound to " + bindings);
 		}else {
 			
@@ -229,11 +236,11 @@
 				String values = "";
 				for (Pair<String, TopicIdentifierTypes> pair : typesOfRequestedTopic)
 					values += ", " + pair.getFirst();
-				values = values.substring(2);
+				if(values.length() >= 2)values = values.substring(2);
 				String bindings = "";
 				for (Topic top : views)
 					bindings += ", " + TmHelper.getAnyIdOfTopic(top);
-				bindings = bindings.substring(2);
+				if(bindings.length() >= 2)bindings = bindings.substring(2);
 				throw new InvalidGdlSchemaException("the combination of topic types (" + values + ") for the requested topic " + requestedTopic.getFirst() + " must be bound exactly once to a " + GdlPsis.TopicType.gdlDefaultEditorTopicView + " but is bound to " + bindings);
 			}
 			

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	Wed Jul 13 08:18:43 2011	(r610)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Wed Jul 13 11:02:47 2011	(r611)
@@ -9,6 +9,7 @@
            {"subject_identifiers":["[tmcl:role-type]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[tmcl:association-type]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[tmcl:name-type]"], "instance_of":["si:[tmcl:topic-type]"]},
+           {"subject_identifiers":["[tmcl:occurrence-type]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[tmdm:supertype]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[tmdm:subtype]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[tmdm:supertype-subtype]"], "instance_of":["si:[tmcl:association-type]"]},
@@ -27,6 +28,7 @@
            {"subject_identifiers":["[gdl:TM-Instance-Value]"]},
            {"subject_identifiers":["[gdl:TM-Multiple-Type-Value]"]},
            {"subject_identifiers":["[gdl:tm-binding]"], "instance_of":["si:[tmcl:association-type]"]},
+           {"subject_identifiers":["[gdl:id]"], "instance_of":["si:[tmcl:occurrence-type]"]},
            {"subject_identifiers":["[gdl:topic-view-binding]"], "instance_of":["si:[tmcl:association-type]"]},
            {"subject_identifiers":["[gdl:tm-construct]"], "instance_of":["si:[tmcl:role-type]"]},
            {"subject_identifiers":["[gdl:descriptor]"], "instance_of":["si:[tmcl:role-type]"]},
@@ -42,10 +44,12 @@
            {"subject_identifiers":["[gdl:Default-Creator-Topic-View]"]},
            {"subject_identifiers":["[gdl:Default-Editor-Topic-View]"]},
            {"subject_identifiers":["[gdl:Special-Creator-Topic-View]"]},
-           {"subject_identifiers":["[doc:default-creator-topic-view-1]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 1", "type":"si:[gdl:view-name]"}]},
-           {"subject_identifiers":["[doc:default-creator-topic-view-2]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 2", "type":"si:[gdl:view-name]"}]},
-           {"subject_identifiers":["[doc:default-editor-topic-view]"], "instance_of":["si:[gdl:Default-Editor-Topic-View]"], "names":[{"value": "Def. Editor View", "type":"si:[gdl:view-name]"}]},
-           {"subject_identifiers":["[doc:special-creator-topic-view]"], "instance_of":["si:[gdl:Special-Creator-Topic-View]"], "names":[{"value": "Spec. Creator View", "type":"si:[gdl:view-name]"}]},
+           
+           {"subject_identifiers":["[doc:default-creator-topic-view-1]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 1", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"default_creator_topic_view_1_id", "datatype":"[xsd:ID]"}]},
+           {"subject_identifiers":["[doc:default-creator-topic-view-2]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 2", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"default_creator_topic_view_2_id", "datatype":"[xsd:ID]"}]},
+           {"subject_identifiers":["[doc:default-editor-topic-view]"], "instance_of":["si:[gdl:Default-Editor-Topic-View]"], "names":[{"value": "Def. Editor View", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"default_editor_topic_view_id", "datatype":"[xsd:ID]"}]},
+           {"subject_identifiers":["[doc:special-creator-topic-view]"], "instance_of":["si:[gdl:Special-Creator-Topic-View]"], "names":[{"value": "Spec. Creator View", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"special_creator_topic_view_id", "datatype":"[xsd:ID]"}]},
+           
            {"subject_identifiers":["[doc:Poet]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[doc:Musician]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[doc:Director]"], "instance_of":["si:[tmcl:topic-type]"]}




More information about the Isidorus-cvs mailing list