Author: lgiessmann Date: Wed Sep 7 04:08:40 2011 New Revision: 844
Log: gdl-frontend: Widgets: fixed a bug in the json format of the delete callback
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/TestClass.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java 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/base/GdlPanel.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Sep 7 04:08:40 2011 (r844) @@ -254,7 +254,7 @@ ArrayList<Pair<Construct, TopicMapsTypes>> data = new ArrayList<Pair<Construct,TopicMapsTypes>>(); data.add(new Pair<Construct, TopicMapsTypes>(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); - this.deleteCallback.deleteTmConstruct(data, null); + this.deleteCallback.deleteTmConstruct(data, this.getTmEngine(), null); }catch(Exception e){ for (IOnErrorCallback handler : localOnErrorContainer) handler.onError(GdlErrorTypes.DeleteError, e);
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 Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Wed Sep 7 04:08:40 2011 (r844) @@ -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/button/GdlDeleteButton.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlDeleteButton.java Wed Sep 7 04:08:40 2011 (r844) @@ -38,7 +38,7 @@ public void onClick(ClickEvent event) { try{ IDeleteCallback callback = this.owner.getRoot().getDeleteCallback(); - callback.deleteTmConstruct(this.owner.getGdlParent().getContent(null, false), this.owner.getId()); + callback.deleteTmConstruct(this.owner.getGdlParent().getContent(null, false), this.owner.getRoot().getTmEngine(), this.owner.getId()); }catch(Exception e){ e.printStackTrace(); Window.alert("caught: " + e.getMessage());
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java Wed Sep 7 04:08:40 2011 (r844) @@ -1,11 +1,11 @@ package us.isidor.gdl.anaToMia.Widgets.environment;
import java.util.ArrayList; - +import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
public interface IDeleteCallback { - public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId); + public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId); }
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 Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Wed Sep 7 04:08:40 2011 (r844) @@ -17,8 +17,6 @@ import com.google.gwt.json.client.JSONString; import com.google.gwt.json.client.JSONValue; import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.RootPanel; - import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.ExporterException; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
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 Wed Sep 7 03:48:19 2011 (r843) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java Wed Sep 7 04:08:40 2011 (r844) @@ -9,8 +9,12 @@ 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.JSONParser; import com.google.gwt.json.client.JSONString; +import com.google.gwt.json.client.JSONValue; import com.google.gwt.user.client.Window; +import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.ExporterException; +import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; @@ -23,36 +27,38 @@
@Override - public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId) { - this.deleteTopic(constructs); + public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { + this.deleteTopic(constructs, tmEngine); }
- private void deleteTopic(ArrayList<Pair<Construct, TopicMapsTypes>> constructs){ + private void deleteTopic(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine){ for (Pair<Construct, TopicMapsTypes> pair : constructs) { if(pair.getSecond().equals(TopicMapsTypes.Topic)){ Topic env = (Topic)pair.getFirst(); if(env.getSubjectIdentifiers().length() != 0){ String psi = env.getSubjectIdentifiers().get(0).getReference(); - 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.DELETE, url); - builder.setHeader("Content-type", "application/json"); try{ + JSONValue val = JSONParser.parseStrict(tmEngine.exportTm(env)); + delObj.put("delete", val.isObject()); + + String url = URL.encode(this.REUQEST_URL); + RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, url); + builder.setHeader("Content-type", "application/json"); + + //RootPanel.getBodyElement().setInnerText(delObj.toString()); // TODO: remove builder.sendRequest(delObj.toString(), new DeleteRequest(delObj)); }catch(RequestException e){ Window.alert("could not delete the topic: " + psi + ", because(" + e.getClass() + "): " + e.getMessage()); + }catch(ExporterException e){ + Window.alert("could not delete the topic: " + psi + ", because(" + e.getClass() + "): " + e.getMessage()); } } }