[isidorus-cvs] r493 - in branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine: Base TopicMaps jtmsBasedEngine

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Tue Jun 21 15:10:10 UTC 2011


Author: lgiessmann
Date: Tue Jun 21 08:10:09 2011
New Revision: 493

Log:
gdl-frontend: TmEngine: added a method for dynamical type-checking, since the GWT JavascriptObject, which is the base type of all TopicMap classes prevents virtual methods etc.; started to implement the ectual Topic Maps engine

Added:
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMapsTypes.java
Modified:
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/Base/TmEngine.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Association.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/DatatypeAware.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Locator.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Name.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Occurrence.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Role.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Topic.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMap.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Variant.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngine.java
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/TestClass.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/Base/TmEngine.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/Base/TmEngine.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/Base/TmEngine.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -1,10 +1,11 @@
 package us.isidor.gdl.anaToMia.TmEngine.Base;
 
-import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.Locator;
 import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.TopicMap;
 
-public interface TmEngine {
-	public TopicMap read(String jtm_1_0, TopicMap tm);
+public interface TmEngine{
+	public TopicMap read(String tmData, TopicMap tm);
 	public String write(TopicMap tm);
-	public TopicMap createTopicMap(Locator locator);
+	public TopicMap createTopicMap(String tmLocator);
+	public TopicMap getTopicMap(String tmLocator);
+	public TopicMap[] getTopicMaps();
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Association.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Association.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Association.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -81,4 +81,9 @@
 	public final native void setType(Topic type) /*-{
 		this.setType(type);
 	}-*/;
+	
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Association;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/DatatypeAware.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/DatatypeAware.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/DatatypeAware.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -17,13 +17,13 @@
 		public BigInteger integerValue();
 		public int intValue();
 		public Locator locatorValue();
-		//public long longValue(); //long is not supported by JSNI
+		public Long longValue(); //long is not supported by JSNI
 		public void setValue(BigDecimal value);
 		public void setValue(BigInteger value);
 		public void setValue(float value);
 		public void setValue(int value);
 		public void setValue(Locator value);
-		//public void setValue(long value); //long is not supported by JSNI
+		public void setValue(Long value); //long is not supported by JSNI
 		public void setValue(String value);
 		public void setValue(String value, Locator datatype);
 	*/

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Locator.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Locator.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Locator.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -4,23 +4,23 @@
 
 public class Locator extends JavaScriptObject{
 	protected Locator() {};
-	
+
 	public final native boolean equal(Object other) /*-{
 		return this.equals(other);
 	}-*/;
-	
-	
+
+
 	public final native String getReference() /*-{
 		return this.getReference();
 	}-*/;
-	
-	
+
+
 	public final native Locator resolve(String reference) /*-{
 		return this.resolve(reference);
 	}-*/;
 	
 	
-	static public final native Locator create(Construct parent, String reference) /*-{
-		return new Locator(parent, reference);
-	}-*/;
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Locator;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Name.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Name.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Name.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -107,4 +107,8 @@
 		return this.getScope();
 	}-*/;
 
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Name;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Occurrence.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Occurrence.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Occurrence.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -113,6 +113,11 @@
 	public final native Locator locatorValue() /*-{
 		return this.locatorValue();
 	}-*/;
+	
+	
+	public final native Long longValue() /*-{
+	 	this.longValue();
+	}-*/;
 
 
 	public final native void setValue(BigDecimal value) /*-{
@@ -138,6 +143,11 @@
 	public final native void setValue(Locator value) /*-{
 		this.setValue(value);
 	}-*/;
+	
+	
+	public final native Long setValue(Long value) /*-{
+	 	this.setValue(value);
+	}-*/;
 
 
 	public final native void setValue(String value) /*-{
@@ -148,4 +158,9 @@
 	public final native void setValue(String value, Locator datatype) /*-{
 		this.setValue(value);
 	}-*/;
+	
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Occurrence;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Role.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Role.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Role.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -52,19 +52,28 @@
 		this.removeItemIdentifier(itemIdentifier);		
 	}-*/;
 
+	
 	public final native Topic getType() /*-{
 		return this.getType();
 	}-*/;
+	
 
 	public final native void setType(Topic type) /*-{
 		this.setType(type);
 	}-*/;
+	
 
 	public final native Topic getReifier() /*-{
 		return this.getReifier();
 	}-*/;
+	
 
 	public final native void setReifier(Topic reifier) /*-{
 		this.setReifier(reifier);
 	}-*/;
+	
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Role;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Topic.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Topic.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Topic.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -156,4 +156,9 @@
 	public final native void removeItemIdentifier(Locator itemIdentifier) /*-{
 		this.removeItemIdentifier(itemIdentifier);
 	}-*/;
+	
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Topic;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMap.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMap.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMap.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -122,4 +122,14 @@
 	public final native void setReifier(Topic reifier) /*-{
 		this.setReifier(reifier);
 	}-*/;
+	
+	
+	public final native Locator createLocator(String reference) /*-{
+		return this.createLocator(reference);
+	}-*/;
+	
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.TopicMap;
+	}
 }

Added: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMapsTypes.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/TopicMapsTypes.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -0,0 +1,17 @@
+package us.isidor.gdl.anaToMia.TmEngine.TopicMaps;
+
+public enum TopicMapsTypes {
+	TopicMap,
+	Association,
+	Role,
+	Topic,
+	Name,
+	Variant,
+	Occurrence,
+	Reifiable,
+	Scoped,
+	Typed,
+	Locator,
+	DatatypeAware,
+	Construct
+}

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Variant.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Variant.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/TopicMaps/Variant.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -103,6 +103,11 @@
 		return this.locatorValue();
 	}-*/;
 	
+	
+	public final native Long longValue() /*-{
+		return this.longValue();
+	}-*/;
+	
 
 	public final native void setValue(BigDecimal value) /*-{
 		this.setValue(value);
@@ -127,6 +132,11 @@
 	public final native void setValue(Locator value) /*-{
 		this.setValue(value);
 	}-*/;
+	
+	
+	public final native Long setValue(Long value) /*-{
+	 	this.setValue(value);
+	}-*/;
 
 	
 	public final native void setValue(String value) /*-{
@@ -138,4 +148,8 @@
 		this.setValue(value);
 	}-*/;
 
+	
+	public final TopicMapsTypes classType(){
+		return TopicMapsTypes.Variant;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngine.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngine.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngine.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -1,28 +1,76 @@
 package us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine;
 
+import java.util.ArrayList;
 import us.isidor.gdl.anaToMia.TmEngine.Base.TmEngine;
-import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.Locator;
 import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.TopicMap;
 
 public class JtmsTmEngine implements TmEngine{
+	private ArrayList<TopicMap> tms = new ArrayList<TopicMap>();
+	
+
+	private final native TopicMap jsCreateTopicMap(String tmLocator) /*-{
+		var factory, sys, tmid, tm;
+		factory = $wnd.TopicMapSystemFactory.newInstance();
+		factory.setProperty('com.semanticheadache.tmjs.backend', 'memory');
+		sys = factory.newTopicMapSystem();
+		tmid = sys.createLocator("http://example.org/mytm");
+		tm = sys.createTopicMap(tmid);
+		
+		return tm;
+	}-*/;
 
+	
 	@Override
-	public TopicMap read(String jtm_1_0, TopicMap tm) {
-		// TODO Auto-generated method stub
-		return null;
+	public TopicMap createTopicMap(String tmLocator){
+		TopicMap tm = jsCreateTopicMap(tmLocator);
+		tms.add(tm);
+		return tm;
 	}
 	
 
 	@Override
-	public String write(TopicMap tm) {
-		// TODO Auto-generated method stub
-		return null;
+	public TopicMap getTopicMap(String tmLocator) {
+		TopicMap match = null;
+		
+		for (TopicMap tm : tms) {
+			if(tm.getLocator().getReference().equals(tmLocator)){
+				match = tm;
+				break;
+			}
+		}
+		
+		return match;
+	}
+
+
+	@Override
+	public TopicMap[] getTopicMaps() {
+		TopicMap[] tmsArray = new TopicMap[tms.size()];
+		tms.toArray(tmsArray);
+		return tmsArray;
+	}
+	
+	
+	@Override
+	public TopicMap read(String tmData, TopicMap tm) {
+		return readJtm10(tmData, tm);
 	}
 	
 
 	@Override
-	public TopicMap createTopicMap(Locator locator) {
-		// TODO Auto-generated method stub
+	public String write(TopicMap tm) {
+		return writeJtm10(tm);
+	}
+	
+	
+	private TopicMap readJtm10(String jtm, TopicMap tm){
+		// TODO: implement
+		return null;
+	}
+	
+	
+	private String writeJtm10(TopicMap tm){
+		// TODO: implement
 		return null;
 	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/TestClass.java	Tue Jun 21 06:10:50 2011	(r492)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/src/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/TestClass.java	Tue Jun 21 08:10:09 2011	(r493)
@@ -2,6 +2,8 @@
 
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.user.client.Window;
+import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.Locator;
+import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.Topic;
 import us.isidor.gdl.anaToMia.TmEngine.TopicMaps.TopicMap;
 
 
@@ -9,20 +11,15 @@
 
 	@Override
 	public void onModuleLoad() {
-		Window.alert("TEST !!!");
-		Window.alert(">> " + createTM().getLocator().getReference());
+		Window.alert(">> TEST !!!");
+		
+		JtmsTmEngine tme = new JtmsTmEngine();
+		TopicMap tm = tme.createTopicMap("http://my.tm/tm-1");
+		
+		Window.alert(">> tm reference: " + tm.getLocator().getReference());
+		
+		Locator psi = tm.createLocator("http://this.is.topic.top");
+		Topic top = tm.createTopicBySubjectIdentifier(psi);
+		Window.alert(">> top: " + top.classType());
 	}
-
-
-	
-	public static native TopicMap createTM()/*-{
-		var factory, sys, tmid, tm;
-		factory = $wnd.TopicMapSystemFactory.newInstance();
-		factory.setProperty('com.semanticheadache.tmjs.backend', 'memory');
-		sys = factory.newTopicMapSystem();
-		tmid = sys.createLocator("http://example.org/mytm");
-		tm = sys.createTopicMap(tmid);
-		return tm;
-	}-*/;
-	
 }




More information about the Isidorus-cvs mailing list