Author: lgiessmann Date: Fri Sep 2 08:44:57 2011 New Revision: 824
Log: gdl-frontend: Widgets: implemented the actual request mechanism for submitting environment topics
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.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/isidorus/CommitCallback.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Fri Sep 2 08:30:32 2011 (r823) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Fri Sep 2 08:44:57 2011 (r824) @@ -1,13 +1,16 @@ package us.isidor.gdl.anaToMia.Widgets.isidorus;
import java.util.ArrayList; - - import us.isidor.gdl.anaToMia.Widgets.base.PSIs; import us.isidor.gdl.anaToMia.Widgets.base.TmHelper; import us.isidor.gdl.anaToMia.Widgets.environment.Pair; - import com.google.gwt.core.client.JsArray; +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.user.client.Window; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.ExporterException; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; @@ -21,8 +24,11 @@ import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback;
-public class CommitCallback implements ICommitCallback{
+public class CommitCallback implements ICommitCallback{ + public final String REUQEST_URL = ""; // TODO: set actual URL value + + @Override public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { try{ @@ -76,7 +82,16 @@ jtm = tmEngine.exportTm(topics, new ArrayList<Association>()); } - Window.alert(jtm); + String url = URL.encode(this.REUQEST_URL); + RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); + try{ + // a check for an existing environment topic is not necessary, + // since it would be exactly the same topic. + builder.sendRequest(null, new EnvironmentCommitRequest(jtm)); + }catch(RequestException e){ + Window.alert("could not delete the topic: " + jtm + ", because(" + e.getClass() + "): " + e.getMessage()); + } + // TODO: implement actual commit and check if the topic already exists } @@ -140,4 +155,38 @@ Window.alert(jtm); // TODO: implement actual commit and check if the topic already exists } + + + + + private class EnvironmentCommitRequest implements RequestCallback { + private String objectToBeSend = null; + + + @SuppressWarnings("unused") + private EnvironmentCommitRequest(){} + + + public EnvironmentCommitRequest(String objectToBeDeleted){ + this.objectToBeSend = objectToBeDeleted; + } + + + @Override + public void onResponseReceived(Request request, Response response) { + if (200 == response.getStatusCode()) { + Window.alert("commit operation of the object " + this.objectToBeSend + " successed"); + // TODO: reset the web page + } else { + Window.alert("commit 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 commit the data: " + this.objectToBeSend); + } + } + }
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 08:30:32 2011 (r823) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java Fri Sep 2 08:44:57 2011 (r824) @@ -51,7 +51,7 @@ try{ builder.sendRequest(null, new DeleteRequest(delObj)); }catch(RequestException e){ - + Window.alert("could not delete the topic: " + psi + ", because(" + e.getClass() + "): " + e.getMessage()); } } }