Skip to content

Commit

Permalink
deletes a single annotation from the annotator panel
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Feb 12, 2019
1 parent f2b32c8 commit c988cf4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ class AnnotationEditorController extends AbstractApolloController implements Ann
, @RestApiParam(name = "features", type = "JSONArray", paramType = RestApiParamType.QUERY, description = "JSONArray of features objects to delete defined by unique name {'uniquename':'ABC123'}")
])
def deleteFeature() {
println "delete feature input ${request.JSON} and ${params.data}"
JSONObject inputObject = permissionService.handleInput(request, params)
if (permissionService.hasPermissions(inputObject, PermissionEnum.WRITE)) {
render requestHandlingService.deleteFeature(inputObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ class RequestHandlingService {
// { "track": "Group1.3", "features": [ { "uniquename": "179e77b9-9329-4633-9f9e-888e3cf9b76a" } ], "operation": "delete_feature" }:
@Timed
def deleteFeature(JSONObject inputObject) {
log.debug "in delete feature ${inputObject as JSON}"
println "in delete feature ${inputObject as JSON}"
Sequence sequence = permissionService.checkPermissions(inputObject, PermissionEnum.WRITE)
boolean suppressEvents = false
if (inputObject.has(FeatureStringEnum.SUPPRESS_EVENTS.value)) {
Expand Down
28 changes: 23 additions & 5 deletions src/gwt/org/bbop/apollo/gwt/client/AnnotatorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.bbop.apollo.gwt.client.event.UserChangeEvent;
import org.bbop.apollo.gwt.client.event.UserChangeEventHandler;
import org.bbop.apollo.gwt.client.resources.TableResources;
import org.bbop.apollo.gwt.client.rest.AnnotationRestService;
import org.bbop.apollo.gwt.client.rest.UserRestService;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;
import org.bbop.apollo.gwt.shared.PermissionEnum;
Expand Down Expand Up @@ -737,16 +738,33 @@ void gotoAnnotation(ClickEvent clickEvent) {
@UiHandler("deleteAnnotation")
void deleteAnnotation(ClickEvent clickEvent) {
String confirmString = "Delete the annotaiton"+selectedAnnotationInfo.getName();

final RequestCallback requestCallback = new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
if(response.getStatusCode()==200){
reload();
}
else{
Bootbox.alert("Problem with deletion: "+response.getText());
}
}

@Override
public void onError(Request request, Throwable exception) {
Bootbox.alert("Problem with deletion: "+exception.getMessage());
}
};

Bootbox.confirm(confirmString,new ConfirmCallback() {
@Override
public void callback(boolean result) {
Bootbox.alert("Confirmed? "+result);
GWT.log("Confirmed? "+result);
if(result){
AnnotationRestService.deleteAnnotation(requestCallback,selectedAnnotationInfo);
}
}
});
// Integer min = selectedAnnotationInfo.getMin() - 50;
// Integer max = selectedAnnotationInfo.getMax() + 50;
// min = min < 0 ? 0 : min;
// MainPanel.updateGenomicViewerForLocation(selectedAnnotationInfo.getSequence(), min, max, false, false);
}

private static AnnotationInfo getChildAnnotation(AnnotationInfo annotationInfo, String uniqueName) {
Expand Down
2 changes: 1 addition & 1 deletion src/gwt/org/bbop/apollo/gwt/client/AnnotatorPanel.ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
text="Go to Annotation"
ui:field="gotoAnnotation" enabled="false" addStyleNames="{style.action-buttons}"/>
<b:Button type="DANGER" icon="TRASH_O" title="Go To" iconSize="LARGE"
text="Delete Annotation?"
text="Delete Annotation"
ui:field="deleteAnnotation" enabled="false"
addStyleNames="{style.action-buttons}"/>
</b:ButtonGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.bbop.apollo.gwt.client.rest;

import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
Expand All @@ -10,7 +12,7 @@
/**
* Created by ndunn on 1/28/15.
*/
public class AnnotationRestService {
public class AnnotationRestService extends RestService{

public static JSONObject convertAnnotationInfoToJSONObject(AnnotationInfo annotationInfo){
JSONObject jsonObject = new JSONObject();
Expand All @@ -33,4 +35,18 @@ public static JSONObject convertAnnotationInfoToJSONObject(AnnotationInfo annota
return jsonObject;

}


public static JSONObject deleteAnnotation(RequestCallback requestCallback, AnnotationInfo annotationInfo){
JSONObject jsonObject = new JSONObject();
JSONArray featuresArray = new JSONArray();
JSONObject uniqueNameObject = new JSONObject();
uniqueNameObject.put(FeatureStringEnum.UNIQUENAME.getValue(),new JSONString(annotationInfo.getUniqueName()));
featuresArray.set(0,uniqueNameObject);
jsonObject.put(FeatureStringEnum.FEATURES.getValue(),featuresArray);

sendRequest(requestCallback,"annotationEditor/deleteFeature","data="+jsonObject.toString());
return jsonObject;
}

}

0 comments on commit c988cf4

Please sign in to comment.