[isidorus-cvs] r956 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Wed Sep 21 13:29:29 UTC 2011
Author: lgiessmann
Date: Wed Sep 21 06:29:26 2011
New Revision: 956
Log:
gdl-frontend: Widgets: fixed a bug in the delete operation handler of environment topics
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/HashObjectPsiContainer.java
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 21 06:02:11 2011 (r955)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java Wed Sep 21 06:29:26 2011 (r956)
@@ -89,7 +89,7 @@
DeleteCallback.this.gdlWebPage.resetPage();
} else {
try{
- this.hashObjectPsiContainer = new HashObjectPsiContainer(env);
+ this.hashObjectPsiContainer = new HashObjectPsiContainer(env, DeleteCallback.this.gdlWebPage);
DeleteCallback.this.gdlWebPage.createLoadScreenPanel("Wating for Data", "Requesting all PSIs of instances of " + IsidorusConstants.HASH_OBJECT_PSI + " that are associated with " + env.getSubjectIdentifiers().get(0).getReference() + " from " + url);
builder.sendRequest(this.createTmSparqlQuery(env), new GetHashObjectPsisRequest());
}catch(RequestException e){
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectPsiContainer.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectPsiContainer.java Wed Sep 21 06:02:11 2011 (r955)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/HashObjectPsiContainer.java Wed Sep 21 06:29:26 2011 (r956)
@@ -4,6 +4,7 @@
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.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.base.Utils;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -37,10 +38,12 @@
private CheckBoxClickHandler cbxClickHandler = new CheckBoxClickHandler();
private final String DELETE_URL = IsidorusConstants.DELETE_REQUEST_URL;
private Topic environmentTopic = null;
+ private GdlWebPage gdlWebPage = null;
- public HashObjectPsiContainer(Topic environmentTopic) throws ExecutionException {
- if(environmentTopic == null) throw new ExecutionException("environmentTopic must not be null");
+ public HashObjectPsiContainer(Topic environmentTopic, GdlWebPage gdlWebPage) throws ExecutionException {
+ if(environmentTopic == null || gdlWebPage == null) throw new ExecutionException("environmentTopic and gdlWebPage must not be null");
+ this.gdlWebPage = gdlWebPage;
this.environmentTopic = environmentTopic;
this.initWidget(this.containerPanel);
this.containerPanel.add(this.commitButton);
@@ -73,6 +76,38 @@
}
+ private void deleteHashObject(String psi, DeleteAllHashObjectsRequest reqCallback){
+ if(psi != null || reqCallback != null){
+ Window.alert(">> " + psi);
+ JSONObject delObj = this.createObjectToBeDelete(psi);
+ try{
+ String url = URL.encode(this.DELETE_URL);
+ RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, url);
+ builder.setHeader("Content-type", "application/json");
+
+ builder.sendRequest(delObj.toString(), reqCallback);
+ }catch(RequestException e){
+ Window.alert("could not delete the topic: " + psi + ", because(" + e.getClass() + "): " + e.getMessage());
+ }
+ }
+ }
+
+
+ private JSONObject createObjectToBeDelete(String psi){
+ JSONArray psis = new JSONArray();
+ psis.set(0, new JSONString(psi));
+
+ JSONObject delObj = new JSONObject();
+ delObj.put("type", new JSONString("Topic"));
+
+ String[] pref = Utils.splitUriByLastFragment(psi);
+ JSONValue val = JSONParser.parseStrict("{\"version\":\"1.1\",\"prefixes\":{\"pref\":" + pref[0] + "},\"subject_identifiers\":[\"[pref:" + pref[1] + "]\"]}");
+ delObj.put("delete", val.isObject());
+
+ return delObj;
+ }
+
+
private class CheckBoxClickHandler implements ClickHandler{
@Override
public void onClick(ClickEvent event) {
@@ -107,43 +142,13 @@
if(!allValuesChecked){
Window.alert("to delete the an environment topic, please select explicit all associated hash-object topics to be deleted!");
} else {
+ HashObjectPsiContainer.this.gdlWebPage.createLoadScreenPanel("Wating for Completing a Delete Request", "deleting all associated Hash-Object topics of the Environment Topic " + TmHelper.getAnyIdOfTopic(this.environmentTopic) + " from " + HashObjectPsiContainer.this.DELETE_URL);
DeleteAllHashObjectsRequest reqCallback = new DeleteAllHashObjectsRequest(HashObjectPsiContainer.this.psiCheckBoxes, this.environmentTopic);
for (CheckBox cbx : HashObjectPsiContainer.this.psiCheckBoxes) HashObjectPsiContainer.this.deleteHashObject(cbx.getText(), reqCallback);
}
}
}
-
- private void deleteHashObject(String psi, DeleteAllHashObjectsRequest reqCallback){
- if(psi != null || reqCallback != null){
- JSONObject delObj = this.createObjectToBeDelete(psi);
- try{
- String url = URL.encode(this.DELETE_URL);
- RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, url);
- builder.setHeader("Content-type", "application/json");
-
- builder.sendRequest(delObj.toString(), reqCallback);
- }catch(RequestException e){
- Window.alert("could not delete the topic: " + psi + ", because(" + e.getClass() + "): " + e.getMessage());
- }
- }
- }
-
-
- private JSONObject createObjectToBeDelete(String psi){
- JSONArray psis = new JSONArray();
- psis.set(0, new JSONString(psi));
-
- JSONObject delObj = new JSONObject();
- delObj.put("type", new JSONString("Topic"));
-
- String[] pref = Utils.splitUriByLastFragment(psi);
- JSONValue val = JSONParser.parseStrict("{\"version\":\"1.1\",\"prefixes\":{\"pref\":" + pref[0] + "},\"subject_identifiers\":[\"[pref:" + pref[1] + "]\"]}");
- delObj.put("delete", val.isObject());
-
- return delObj;
- }
-
private class DeleteAllHashObjectsRequest implements RequestCallback {
private ArrayList<String> hashObjectsToDelete = new ArrayList<String>();
More information about the Isidorus-cvs
mailing list