[isidorus-cvs] r823 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: . base isidorus

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Sep 2 15:30:33 UTC 2011


Author: lgiessmann
Date: Fri Sep  2 08:30:32 2011
New Revision: 823

Log:
gdl-frontend: Widgets: implemented the actual request mechanism for deleting topics

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.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/isidorus/DeleteCallback.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml	Fri Sep  2 03:58:05 2011	(r822)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/GDL_Widgets.gwt.xml	Fri Sep  2 08:30:32 2011	(r823)
@@ -14,9 +14,12 @@
 
   <!-- Other module inherits                                      -->
   <inherits name='us.isidor.gdl.anaToMia.TmEngine.GDL_TmEngine' />	
-
+  <inherits name="com.google.gwt.json.JSON" />
+  <inherits name="com.google.gwt.http.HTTP" />
+  
   <!-- Specify the app entry point class.                         -->
   <entry-point class='us.isidor.gdl.anaToMia.Widgets.base.TestClass'/>
+  
 
   <!-- Specify the paths for translatable code                    -->
   <source path="base"/>

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Sep  2 03:58:05 2011	(r822)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Sep  2 08:30:32 2011	(r823)
@@ -1,5 +1,6 @@
 package us.isidor.gdl.anaToMia.Widgets.base;
 
+
 import java.util.ArrayList;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
@@ -59,7 +60,6 @@
 import com.google.gwt.event.dom.client.MouseUpEvent;
 import com.google.gwt.event.dom.client.MouseUpHandler;
 import com.google.gwt.event.shared.EventHandler;
-import com.google.gwt.i18n.client.Messages.Select;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Window;

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	Fri Sep  2 03:58:05 2011	(r822)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Fri Sep  2 08:30:32 2011	(r823)
@@ -36,7 +36,7 @@
 			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Poet", TopicIdentifierTypes.SubjectIdentifier));
 			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Musician", TopicIdentifierTypes.SubjectIdentifier));
 			
-			//Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/test-env-1", TopicIdentifierTypes.SubjectIdentifier);
+			Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/test-env-1", TopicIdentifierTypes.SubjectIdentifier);
 			//Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/test-hash-2", TopicIdentifierTypes.SubjectIdentifier);
 			GdlPanel.addClickHandler("hash_object_reset_button_id", new ClickHandler() {
 				@Override
@@ -46,7 +46,7 @@
 				}
 			});
 			
-			gdlPanel = new GdlPanel(null, requestedTopicsToCreate);
+			gdlPanel = new GdlPanel(requestedTopicToEdit, null);
 			mainPanel.add(gdlPanel);
 			gdlPanel.setTmEngine(new JtmsTmEngine());
 			gdlPanel.setLoadSchemaCallback(new LoadSchemaCallback());

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java	Fri Sep  2 03:58:05 2011	(r822)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java	Fri Sep  2 08:30:32 2011	(r823)
@@ -1,6 +1,15 @@
 package us.isidor.gdl.anaToMia.Widgets.isidorus;
 
 import java.util.ArrayList;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.URL;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONString;
 import com.google.gwt.user.client.Window;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
@@ -8,7 +17,10 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
 
+
 public class DeleteCallback implements IDeleteCallback {
+	public final String REUQEST_URL = ""; // TODO: set actual URL value
+	
 
 	@Override
 	public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId) {
@@ -23,10 +35,58 @@
 				if(env.getSubjectIdentifiers().length() != 0){
 					String psi = env.getSubjectIdentifiers().get(0).getReference();
 					
-					Window.alert("psi of the topic to be deleted: " + psi);
-					// TODO: send actual delete request
+					JSONObject topObj = new JSONObject();
+					JSONArray psis = new JSONArray();
+					psis.set(0, new JSONString(psi));
+					topObj.put("subjectIdentifiers", psis);
+					
+					JSONObject delObj = new JSONObject();
+					delObj.put("type", new JSONString("Topic"));
+					delObj.put("delete", topObj);
+					
+					
+					String url = URL.encode(this.REUQEST_URL);
+					RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
+
+					try{
+						builder.sendRequest(null, new DeleteRequest(delObj));
+					}catch(RequestException e){
+						
+					}
 				}
 			}
 		}		
 	}
+	
+	
+	private class DeleteRequest implements RequestCallback {
+		private JSONObject objectToBeSend = null;
+		
+		
+		@SuppressWarnings("unused")
+		private DeleteRequest(){}
+		
+		
+		public DeleteRequest(JSONObject objectToBeDeleted){
+			this.objectToBeSend = objectToBeDeleted;
+		}
+		
+		
+		@Override
+		public void onResponseReceived(Request request, Response response) {
+			if (200 == response.getStatusCode()) {
+				Window.alert("delete operation of the object " + this.objectToBeSend + " successed");
+				// TODO: reset the web page
+			} else {
+				Window.alert("delete operation of the object " + this.objectToBeSend + " failed: " + response.getStatusCode() + "(" + response.getStatusText() + ")\n" + response.getText());
+			}
+		}
+		
+
+		@Override
+		public void onError(Request request, Throwable exception) {
+			Window.alert("could not delete the data: " + this.objectToBeSend);
+			
+		}
+	}
 }




More information about the Isidorus-cvs mailing list