[isidorus-cvs] r604 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets: lib src/us/isidor/gdl/anaToMia/Widgets/base src/us/isidor/gdl/anaToMia/Widgets/environment src/us/isidor/gdl/anaToMia/Widgets/isidorus

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Tue Jul 12 15:16:50 UTC 2011


Author: lgiessmann
Date: Tue Jul 12 08:16:49 2011
New Revision: 604

Log:
gdl-frontend: Widgets: started to implement some methods to get the default-topic-view instance for getting the entry point of the view

Added:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/TopicIdentifierTypes.java
Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/lib/GDL_TopicMaps_Model.jar
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java
   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/TestClass.java
   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/ILoadSchemaCallback.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/lib/GDL_TopicMaps_Model.jar
==============================================================================
Binary file (source and/or target). No diff available.

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -6,12 +6,14 @@
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.GdlErrorTypes;
+import us.isidor.gdl.anaToMia.Widgets.environment.GdlInstantiator;
 import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback;
 import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback;
 import us.isidor.gdl.anaToMia.Widgets.environment.IOnErrorCallback;
 import us.isidor.gdl.anaToMia.Widgets.environment.ILoadSchemaCallback;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidContentException;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
 import us.isidor.gdl.anaToMia.Widgets.view.GdlDefaultTopicView;
 
 import com.google.gwt.event.dom.client.ClickHandler;
@@ -33,10 +35,10 @@
 
 	// If requestedTypes is not null or length != 0, the string values must be treated as topic
 	// identifiers of a topic type. The created GDL view must be a Default-Topic-Creator-View
-	private String[] requestedTypes = new String[]{};
+	private ArrayList<Pair<String, TopicIdentifierTypes>> requestedTypes = new ArrayList<Pair<String, TopicIdentifierTypes>>();
 	// If requestedInstance is not null or != "", the string value must be treated as a topic identifier
 	// of a particular topic instance. The created GDL view must be a Default-Topic-Editor-View
-	private String requestedInstance = "";
+	private Pair<String, TopicIdentifierTypes> requestedInstance = null;
 	
 	// the GWT base for this panel 
 	private AbsolutePanel mainPanel = new AbsolutePanel();
@@ -62,9 +64,9 @@
 	}
 	
 	
-	protected GdlPanel(String instanceIdentifier){
+	protected GdlPanel(Pair<String, TopicIdentifierTypes> instanceIdentifier){
 		this();
-		if(instanceIdentifier != null){
+		if(instanceIdentifier != null && instanceIdentifier.getFirst() != null && instanceIdentifier.getSecond() != null){
 			this.requestedInstance = instanceIdentifier;
 		}
 		
@@ -72,19 +74,19 @@
 	}
 		
 	
-	public GdlPanel(String instanceIdentifier, int width, int height){
+	public GdlPanel(Pair<String, TopicIdentifierTypes> instanceIdentifier, int width, int height){
 		this(instanceIdentifier);
 		this.setPixelSize(width, height);
 	}
 	
 	
-	public GdlPanel(String instanceIdentifier, String width, String height){
+	public GdlPanel(Pair<String, TopicIdentifierTypes> instanceIdentifier, String width, String height){
 		this(instanceIdentifier);
 		this.setSize(width, height);
 	}
 	
 	
-	protected GdlPanel(String[] typeIdentifiers){
+	protected GdlPanel(ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers){
 		this();
 		if(typeIdentifiers != null){
 			requestedTypes = typeIdentifiers;
@@ -94,13 +96,13 @@
 	}
 	
 	
-	public GdlPanel(String[] typeIdentifiers, int width, int height){
+	public GdlPanel(ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers, int width, int height){
 		this(typeIdentifiers);
 		this.setPixelSize(width, height);
 	}
 	
 	
-	public GdlPanel(String[] typeIdentifiers, String width, String height){
+	public GdlPanel(ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers, String width, String height){
 		this(typeIdentifiers);
 		this.setSize(width, height);
 	}
@@ -280,11 +282,8 @@
 	// Creates the actual view from the requested topic map
 	public void createView(){
 		try{
-			// TODO: Implement
-			// search for an instance of default-[editor|creator]-topic-view (only one of those must be existent)
-			// use gdl instaiator
-			
-			
+			view = GdlInstantiator.instantiateDefaultEditorOrCreatorView(requestedInstance, requestedTypes, this.requestedSchemaTm);
+			mainPanel.add(view);
 			for (Pair<ClickHandler, String> item : this.buttonCallbacks) {
 				view.registerButtonCallback(item.getFirst(), item.getSecond());
 			}

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	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -1,6 +1,19 @@
 package us.isidor.gdl.anaToMia.Widgets.base;
 
+import java.util.ArrayList;
+import com.google.gwt.core.client.JsArray;
+
+import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role;
+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.Widgets.environment.GdlInstantiator;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
 
 public class GdlPsis {
 	public final static String gdl = "http://psi.isidor.us/gdl/";
@@ -201,7 +214,7 @@
 		public final static String gdlNthPosition = gdl + "nth-position";
 		public final static String gdlButtonPosition = gdl + "button-position";
 		public final static String gdlTmBinding = gdl + "tm-binding";
-		public final static String gdlViewBinding = gdl + "view-binding";
+		public final static String gdlTopicViewBinding = gdl + "topic-view-binding";
 	}
 	
 	
@@ -216,6 +229,7 @@
 		public final static String gdlNthElement = gdl + "nth-element";
 		public final static String gdlHiddenValue = gdl + "hidden-value";
 		public final static String gdlValueGroup = gdl + "value-group";
+		public final static String gdlTmValue = gdl + "tm-value";
 	}
 	
 	
@@ -227,6 +241,45 @@
 	}
 	
 	
+	// a helper that returns the topic bound to the identifier via a subject identifier
+	public static Topic getTopicByPsi(String subjectIdentifier, TopicMap tm){
+		if(subjectIdentifier == null || tm == null) return null;
+		
+		Locator loc = tm.createLocator(subjectIdentifier);
+		return tm.getTopicBySubjectIdentifier(loc);
+	}
+	
+	
+	// a helper that returns the topic bound to the identifier via a subject locator
+	public static Topic getTopicBySl(String subjectLocator, TopicMap tm){
+		if(subjectLocator == null || tm == null) return null;
+		
+		Locator loc = tm.createLocator(subjectLocator);
+		return tm.getTopicBySubjectLocator(loc);
+	}
+	
+	
+	// a helper that returns the topic bound to the identifier via an item identifier
+	public static Topic getTopicByIi(String itemIdentifier, TopicMap tm){
+		if(itemIdentifier == null || tm == null) return null;
+		
+		Locator loc = tm.createLocator(itemIdentifier);
+		return (Topic)tm.getConstructByItemIdentifier(loc);
+	}
+	
+	
+	// returns a topic that is identified by ref
+	public static Topic getTopicByAnyIdentifier(Pair<String, TopicIdentifierTypes> ref, TopicMap tm){
+		if(ref.getSecond() == TopicIdentifierTypes.ItemIdentifier){
+			return getTopicByIi(ref.getFirst(), tm);
+		}else if(ref.getSecond() == TopicIdentifierTypes.SubjectLocator){
+			return getTopicBySl(ref.getFirst(), tm);
+		}else {
+			return getTopicByPsi(ref.getFirst(), tm);
+		}
+	}	
+	
+	
 	// a helper method to return any identifier string of the topic
 	public static String getAnyIdOfTopic(Topic topic){
 		if(topic.getSubjectIdentifiers().length() != 0){
@@ -239,4 +292,147 @@
 			return null;
 		}
 	}
+	
+	
+	// returns all instances of the topic type
+	public static ArrayList<Topic> getInstanceOf(Topic type, boolean multipleTypesAllowed){
+		ArrayList<Topic> result = new ArrayList<Topic>();
+		TopicMap tm = type.getTopicMap();
+		
+		for(int i = 0; i != tm.getTopics().length(); ++i){
+			if(multipleTypesAllowed){
+				if(isInstanceOf(tm.getTopics().get(i), type)) result.add(tm.getTopics().get(i));
+			} else {
+				if(isInstanceOf(tm.getTopics().get(i), type) && tm.getTopics().get(i).getTypes().length() == 1) result.add(tm.getTopics().get(i));
+			}
+		}
+		
+		return result;
+	}
+	
+	
+	// returns true if the topic instance if an instance of the topic type
+	public static boolean isInstanceOf(Topic instance, Topic type){
+		if(instance == null || type == null) return false;
+
+		JsArray<Topic> types = instance.getTypes();
+		for(int i = 0; i != types.length(); ++i){
+			ArrayList<Topic> superTypes = getAllSuperTypes(types.get(i), null);
+			superTypes.add(types.get(i));
+			if(superTypes.contains(type)) return true;
+		}
+
+		return false;
+	}
+	
+	
+	// returns an array list with all direct and indirect supertypes of top
+	public static ArrayList<Topic> getAllSuperTypes(Topic top, ArrayList<Topic> collectedSupertypes){
+		if(top == null) return new ArrayList<Topic>();
+		
+		ArrayList<Topic> localCollectedSuperTypes = new ArrayList<Topic>();
+		if(collectedSupertypes != null) localCollectedSuperTypes = collectedSupertypes;
+		
+		
+		
+		// TODO: implement
+		return null;
+	}
+	
+	
+	// returns the other player of an assocition with two roles and the correct values
+	public static ArrayList<Topic> getOtherPlayer(Topic thisTopic, Topic thisRoleType, Topic assocType, ArrayList<Topic> scope, Topic otherRoleType){
+		ArrayList<Topic> result = new ArrayList<Topic>();
+		if(thisTopic == null || thisRoleType == null || assocType == null || otherRoleType == null) return result;
+		
+		JsArray<Role> roles = thisTopic.getRolesPlayed(thisRoleType, assocType);
+		for(int i = 0; i != roles.length(); ++i){
+			Association parent = roles.get(i).getParent();
+			if(parent.getRoles(otherRoleType).length() == 1) result.add(parent.getRoles(otherRoleType).get(0).getPlayer());
+		}
+		return result;
+	}
+	
+	
+	// returns true if the instance topic is an instance of the topic bound to typeSubectIdentifier
+	public static boolean isInstanceOf(Topic instance, String typeSubjectIdentifier){
+		TopicMap tm = instance.getTopicMap();
+		Topic type = tm.getTopicBySubjectIdentifier(tm.createLocator(typeSubjectIdentifier));
+		return isInstanceOf(instance, type);
+	}
+	
+	
+	// returns true if the passed association has exactly the corresponding roles to
+	// the array list rolePlayersAndTypes
+	public static boolean hasRoles(Association assoc, ArrayList<Pair<Topic, Topic>> rolePlayertypesAndTypes){
+		if(assoc == null) return false;
+		if(assoc.getRoles().length() == 0 && rolePlayertypesAndTypes == null) return true;
+		if(assoc.getRoles().length() != rolePlayertypesAndTypes.size()) return false;
+		
+		for (Pair<Topic, Topic> pair : rolePlayertypesAndTypes) {
+			JsArray<Role> selection = assoc.getRoles(pair.getSecond());
+			int i = 0;
+			for(; i != selection.length(); ++i){
+				if(isInstanceOf(selection.get(i).getPlayer(), pair.getFirst())) break;
+			}
+			
+			if(i == selection.length()) return false;
+		}
+		
+		return true;
+	}
+	
+	
+	// returns true if the topics of themes are all equal to the scope of construct
+	public static boolean hasThemes(Construct construct, ArrayList<Topic> themes){
+		if(construct == null) return false;
+		
+		ScopedStub scoped = (ScopedStub)construct;
+		if(scoped.getScope().length() != 0 && (themes == null || themes.size() == 0)) return false;
+		if(scoped.getScope().length() != themes.size()) return false;
+		
+		for(int i = 0; i != scoped.getScope().length(); ++i){
+			if(!themes.contains(scoped.getScope().get(i))) return false;
+		}
+		
+		return true;
+	}
+	
+	
+	// returns all topics that are instances if tm-value, which are also bound to this
+	// topic via a gdl:tm-binding association
+	public static ArrayList<Topic> getTmValues(Topic top){
+		ArrayList<Topic> result = new ArrayList<Topic>();
+		if(top == null) return result;
+		TopicMap tm = top.getTopicMap();
+		Topic descriptor = getTopicByPsi(RoleType.gdlDescriptor, tm);
+		Topic tmBinding = getTopicByPsi(AssociationType.gdlTmBinding, tm);
+		Topic tmValue = getTopicByPsi(TopicType.gdlTmValue, tm);
+		
+		JsArray<Role> roles = top.getRolesPlayed(descriptor, tmBinding);
+		for(int i = 0; i != roles.length(); ++i){
+			Association parent = roles.get(i).getParent();
+			if(parent.getRoles().length() == 2 && parent.getRoles(descriptor).length() == 1 &&
+					isInstanceOf(parent.getRoles(descriptor).get(0).getPlayer(), tmValue))
+				result.add(parent.getRoles(descriptor).get(0).getPlayer());
+		}
+		return result;
+	}
+	
+	
+	// returns the associations that are bound to the topic "topic" and have the passed scope and roles
+	public static ArrayList<Association> getAssociationsOfTopic(Topic topic, Topic roleType, Topic assocType, ArrayList<Topic> scope, ArrayList<Pair<Topic, Topic>> rolePlayertypesAndTypes){
+		ArrayList<Association> result = new ArrayList<Association>();
+		if(topic == null || assocType == null || rolePlayertypesAndTypes == null || rolePlayertypesAndTypes.size() == 0) return result;
+		
+		ArrayList<Association> allPotentialAssocs = new ArrayList<Association>();
+		for(int i = 0; i != topic.getRolesPlayed(roleType, assocType).length(); ++i) allPotentialAssocs.add(topic.getRolesPlayed(roleType, assocType).get(i).getParent());
+		
+		ArrayList<Association> assocsWoScope = new ArrayList<Association>();
+		for (Association assoc : allPotentialAssocs) if(hasRoles(assoc, rolePlayertypesAndTypes)) assocsWoScope.add(assoc);
+		
+		for (Association assoc : assocsWoScope) if(hasThemes(assoc, scope)) result.add(assoc);
+		
+		return result;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -12,6 +12,7 @@
 import us.isidor.gdl.anaToMia.Widgets.container.GdlUnit;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
 import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
 import us.isidor.gdl.anaToMia.Widgets.value.CursorValue;
 import us.isidor.gdl.anaToMia.Widgets.view.GdlView;
@@ -38,7 +39,7 @@
 			mainPanel.setBorderWidth(1);
 			mainPanel.setPixelSize(500, 500);
 			
-			gdlPanel = new GdlPanel("");
+			gdlPanel = new GdlPanel(new Pair<String, TopicIdentifierTypes>("http://mytop/psi-1", TopicIdentifierTypes.SubjectIdentifier));
 			gdlPanel.setPixelSize(100, 100);
 			DOM.setStyleAttribute(gdlPanel.getElement(), "backgroundColor", "yellow");
 			mainPanel.add(gdlPanel);
@@ -51,7 +52,7 @@
 				public void onClick(ClickEvent event) {
 					LoadSchemaCallback callback = new LoadSchemaCallback();
 					try{
-						callback.loadSchema(gdlPanel, "", new String[]{});
+						callback.loadSchema(gdlPanel, null, new ArrayList<Pair<String,TopicIdentifierTypes>>());
 					}catch(Exception e){
 						Window.alert("cought error: " + e.getLocalizedMessage());
 					}

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	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -1,8 +1,7 @@
 package us.isidor.gdl.anaToMia.Widgets.environment;
 
 
-import com.google.gwt.core.client.JsArray;
-import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator;
+import java.util.ArrayList;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
 import us.isidor.gdl.anaToMia.Widgets.base.GdlLineBreak;
@@ -37,88 +36,63 @@
 import us.isidor.gdl.anaToMia.Widgets.view.GdlSpecialEditorTopicView;
 
 
-public class GdlInstantiator {
-	// a helper that returns the topic bound to the identifier via a subject identifier
-	private static Topic getTopicByPsi(String subjectIdentifier, TopicMap tm){
-		if(subjectIdentifier == null || tm == null) return null;
-		
-		Locator loc = tm.createLocator(subjectIdentifier);
-		return tm.getTopicBySubjectIdentifier(loc);
-	}
-	
-	
-	// returns true if the passed topic instance is a subtype of the topic bound to the passed
-	// type subjectIdenifier; the instance must have only one type, otherwise the result is false
-	private static boolean isInstanceOf(Topic instance, String typeSubjectIdentifier){
-		TopicMap tm = instance.getTopicMap();
-		
-		JsArray<Topic> types = instance.getTypes();
-		if(types.length() != 1){
-			return false;
-		}else{
-			Topic type = getTopicByPsi(typeSubjectIdentifier, tm);
-			if(type == null) return false;
-			else return types.get(0).equals(type);
-		}
-	}
-	
-	
+public class GdlInstantiator {	
 	// returns a java instance of a GdlVisibleObject that corresponds to the
 	// set topic type of the passed topic instance
 	public static GdlVisibleObject instantiate(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
-		if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlLineBreak)){
+		if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlLineBreak)){
 			return new GdlLineBreak(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlInfo)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlInfo)){
 			return new GdlInfo(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlTitle)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlTitle)){
 			return new GdlTitle(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlReference)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlReference)){
 			return new GdlReference(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlRadioButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlRadioButton)){
 			return new GdlRadioButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCheckBox)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCheckBox)){
 			return new GdlCheckBox(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlActionButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlActionButton)){
 			return new GdlActionButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlValidateButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlValidateButton)){
 			return new GdlValidateButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCreateButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCreateButton)){
 			return new GdlCreateButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDeleteButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDeleteButton)){
 			return new GdlDeleteButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCommitButton)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCommitButton)){
 			return new GdlCommitButton(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlImage)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlImage)){
 			return new GdlImage(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlVideo)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlVideo)){
 			return new GdlVideo(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlAudio)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlAudio)){
 			return new GdlAudio(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDatePicker)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDatePicker)){
 			return new GdlDatePicker(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlTimePicker)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlTimePicker)){
 			return new GdlTimePicker(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDateTimePicker)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDateTimePicker)){
 			return new GdlDateTimePicker(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlUnit)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlUnit)){
 			return new GdlUnit(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlText)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlText)){
 			return new GdlText(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlList)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlList)){
 			return new GdlList(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlListBox)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlListBox)){
 			return new GdlListBox(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDefaultCreatorTopicView)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDefaultCreatorTopicView)){
 			return new GdlDefaultCreatorTopicView(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDefaultEditorTopicView)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlDefaultEditorTopicView)){
 			return new GdlDefaultEditorTopicView(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlSpecialCreatorTopicView)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlSpecialCreatorTopicView)){
 			return new GdlSpecialCreatorTopicView(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlSpecialEditorTopicView)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlSpecialEditorTopicView)){
 			return new GdlSpecialEditorTopicView(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCreatorAssociationview)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlCreatorAssociationview)){
 			return new GdlCreatorAssociationView(tmRepresentative);
-		}else if(isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlEditorAssociationView)){
+		}else if(GdlPsis.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlEditorAssociationView)){
 			return new GdlEditorAssociationView(tmRepresentative);
 		}else{
 			String values = "";
@@ -134,19 +108,38 @@
 	}
 
 
-	public static GdlDefaultTopicView instantiateDefaultEditorOrCreatorView(TopicMap tm) throws InvalidGdlSchemaException, ExecutionException{
+	// returns a DefaultTopicView instance that represents the entry point of this topic map for one of
+	// instanceTopic of typeTopics, i.e. one of the must be null or empty
+	public static GdlDefaultTopicView instantiateDefaultEditorOrCreatorView(Pair<String, TopicIdentifierTypes> instanceTopic, ArrayList<Pair<String, TopicIdentifierTypes>> typeTopics, TopicMap tm) throws InvalidGdlSchemaException, ExecutionException{
 		if(tm == null) return null;
+		if(instanceTopic != null && (typeTopics != null && typeTopics.size() != 0)){
+			String values = instanceTopic.getFirst();
+			for (Pair<String, TopicIdentifierTypes> pair : typeTopics) if(values.length() != 0)values += ", " + pair.getFirst(); 
+			throw new ExecutionException("only one of topic is allowed to be set as the base topic for a " + GdlPsis.TopicType.gdlView + " but found: " + values);
+		}
 		
-		Topic defaultCreatorTopicView = getTopicByPsi(GdlPsis.TopicType.gdlDefaultCreatorTopicView, tm);
-		Topic defaultEditorTopicView = getTopicByPsi(GdlPsis.TopicType.gdlDefaultEditorTopicView, tm);
+		Topic defaultCreatorTopicView = GdlPsis.getTopicByPsi(GdlPsis.TopicType.gdlDefaultCreatorTopicView, tm);
+		Topic defaultEditorTopicView = GdlPsis.getTopicByPsi(GdlPsis.TopicType.gdlDefaultEditorTopicView, tm);
 		if(defaultCreatorTopicView == null && defaultEditorTopicView == null){
 			throw new InvalidGdlSchemaException("the requested GDL schema does not have an entry point defined, either an instance of " + GdlPsis.TopicType.gdlDefaultCreatorTopicView + " or " + GdlPsis.TopicType.gdlDefaultEditorTopicView + " is necessary");
 		}else {
-			// search for an instance of either dctv or detv
+			ArrayList<Topic> topsToDisplay = new ArrayList<Topic>();
+			if(instanceTopic != null){
+				topsToDisplay.add(GdlPsis.getTopicByAnyIdentifier(instanceTopic, tm));
+			}else{
+				for (Pair<String, TopicIdentifierTypes> pair : typeTopics) {
+					topsToDisplay.add(GdlPsis.getTopicByAnyIdentifier(pair, tm));
+				}
+			}
+			
+			// TODO: implement
+			// get tm-values for each topic
+			// reduce tm-values to instances that are shared by all topics to display
+			// filter shared tm-values for default-topic-view associations
+			// return default-topic-view
+			
+			
+			return null;		
 		}
-		return null; // TODO: remove
-		
-		// throw new InvalidGdlSchemaException("the requested GDL schema does not have an entry point defined, either an instance of " + GdlPsis.TopicType.gdlDefaultCreatorTopicView + " or " + GdlPsis.TopicType.gdlDefaultEditorTopicView + " is necessary");
-		// throw new InvalidGdlSchemaException("the requested GDL schema does have multiple entry points defined, only an instance of " + GdlPsis.TopicType.gdlDefaultCreatorTopicView + " or " + GdlPsis.TopicType.gdlDefaultEditorTopicView + " is permitted");
 	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ILoadSchemaCallback.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -1,8 +1,10 @@
 package us.isidor.gdl.anaToMia.Widgets.environment;
 
+import java.util.ArrayList;
+
 import com.google.gwt.http.client.RequestException;
 import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel;
 
 public interface ILoadSchemaCallback {
-	public void loadSchema(GdlPanel panel, String instanceIdentifier, String[] typeIdentifiers)throws RequestException;
+	public void loadSchema(GdlPanel panel, Pair<String, TopicIdentifierTypes> instanceIdentifier, ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers)throws RequestException;
 }

Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/TopicIdentifierTypes.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/TopicIdentifierTypes.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -0,0 +1,7 @@
+package us.isidor.gdl.anaToMia.Widgets.environment;
+
+public enum TopicIdentifierTypes {
+	SubjectIdentifier,
+	SubjectLocator,
+	ItemIdentifier;
+}

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java	Tue Jul 12 06:19:11 2011	(r603)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/LoadSchemaCallback.java	Tue Jul 12 08:16:49 2011	(r604)
@@ -1,5 +1,7 @@
 package us.isidor.gdl.anaToMia.Widgets.isidorus;
 
+import java.util.ArrayList;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
@@ -14,14 +16,16 @@
 import us.isidor.gdl.anaToMia.Widgets.base.GdlPanel;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.ILoadSchemaCallback;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
 
 
 // this class can be used as a callback that requests the Topic Map data
 // addressable by the URI isidorusUrl
 public class LoadSchemaCallback implements ILoadSchemaCallback{
 	private final String isidorusUrl = URL.encode(GWT.getModuleBaseURL() + "test.jtm"); // TODO: replace with the correct URL
-	private String[] typeIdentifiers = new String[]{};
-	private String instanceIdentifier = "";
+	private ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers = new ArrayList<Pair<String,TopicIdentifierTypes>>(); 
+	private Pair<String, TopicIdentifierTypes> instanceIdentifier = null;
 	private RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, isidorusUrl);
 	
 	
@@ -30,7 +34,7 @@
 	
 	// this method is invoked as a callback method
 	@Override
-	public void loadSchema(GdlPanel panel, String instanceIdentifier,	String[] typeIdentifiers) throws RequestException {
+	public void loadSchema(GdlPanel panel, Pair<String, TopicIdentifierTypes> instanceIdentifier, ArrayList<Pair<String, TopicIdentifierTypes>> typeIdentifiers)throws RequestException {
 		this.typeIdentifiers = typeIdentifiers;
 		this.instanceIdentifier = instanceIdentifier;
 		requestBuilder.sendRequest(null, new RequestCallbackImpl(panel));




More information about the Isidorus-cvs mailing list