Skip to content

Commit

Permalink
fixed so will delete multiple annotations from gene
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Feb 12, 2019
1 parent c988cf4 commit 0bfe267
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,6 @@ class RequestHandlingService {
// { "track": "Group1.3", "features": [ { "uniquename": "179e77b9-9329-4633-9f9e-888e3cf9b76a" } ], "operation": "delete_feature" }:
@Timed
def deleteFeature(JSONObject inputObject) {
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
50 changes: 35 additions & 15 deletions src/gwt/org/bbop/apollo/gwt/client/AnnotatorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.cellview.client.*;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.view.client.*;
import org.bbop.apollo.gwt.client.dto.AnnotationInfo;
Expand Down Expand Up @@ -263,7 +262,7 @@ public void execute() {
}
// if a child, we need to get the index I think?
final String thisUniqueName = selectedChildUniqueName;
for (AnnotationInfo annotationInfoChild : annotationInfo.getAnnotationInfoSet()) {
for (AnnotationInfo annotationInfoChild : annotationInfo.getChildAnnotations()) {
GWT.log("next-level: " + annotationInfoChild.getType());
if (annotationInfoChild.getUniqueName().equals(selectedAnnotationInfo.getUniqueName())) {
// selectedAnnotationInfo = annotationInfo;
Expand Down Expand Up @@ -737,38 +736,59 @@ void gotoAnnotation(ClickEvent clickEvent) {

@UiHandler("deleteAnnotation")
void deleteAnnotation(ClickEvent clickEvent) {
String confirmString = "Delete the annotaiton"+selectedAnnotationInfo.getName();
final Set<AnnotationInfo> deletableChildren = getDeletableChildren(selectedAnnotationInfo);
String confirmString = "";
if (deletableChildren.size() > 0) {
confirmString = "Delete the " + deletableChildren.size() + " annotation" + (deletableChildren.size() > 1 ? "s" : "") + " belonging to the " + selectedAnnotationInfo.getType() + " " + selectedAnnotationInfo.getName() + "?";
} else {
confirmString = "Delete the " + selectedAnnotationInfo.getType() + " " + 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());
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.alert("Problem with deletion: " + exception.getMessage());
}
};

Bootbox.confirm(confirmString,new ConfirmCallback() {
Bootbox.confirm(confirmString, new ConfirmCallback() {
@Override
public void callback(boolean result) {
GWT.log("Confirmed? "+result);
if(result){
AnnotationRestService.deleteAnnotation(requestCallback,selectedAnnotationInfo);
if (result) {
if (deletableChildren.size() == 0) {
Set<AnnotationInfo> annotationInfoSet = new HashSet<>();
annotationInfoSet.add(selectedAnnotationInfo);
AnnotationRestService.deleteAnnotations(requestCallback, annotationInfoSet);
} else {
JSONObject jsonObject = AnnotationRestService.deleteAnnotations(requestCallback, deletableChildren);
}
}
}
});
}


private Set<AnnotationInfo> getDeletableChildren(AnnotationInfo selectedAnnotationInfo) {
String type = selectedAnnotationInfo.getType();
GWT.log("type:" + type);
if (type.equalsIgnoreCase(FeatureStringEnum.GENE.getValue()) || type.equalsIgnoreCase(FeatureStringEnum.PSEUDOGENE.getValue())) {
return selectedAnnotationInfo.getChildAnnotations();
}
return new HashSet<>();
}

private static AnnotationInfo getChildAnnotation(AnnotationInfo annotationInfo, String uniqueName) {
for (AnnotationInfo childAnnotation : annotationInfo.getAnnotationInfoSet()) {
for (AnnotationInfo childAnnotation : annotationInfo.getChildAnnotations()) {
if (childAnnotation.getUniqueName().equalsIgnoreCase(uniqueName)) {
return childAnnotation;
}
Expand Down Expand Up @@ -844,7 +864,7 @@ protected void buildRowImpl(AnnotationInfo rowValue, int absRowIndex) {

if (showingTranscripts.contains(rowValue.getUniqueName())) {
// add some random rows
Set<AnnotationInfo> annotationInfoSet = rowValue.getAnnotationInfoSet();
Set<AnnotationInfo> annotationInfoSet = rowValue.getChildAnnotations();
if (annotationInfoSet.size() > 0) {
for (AnnotationInfo annotationInfo : annotationInfoSet) {
buildAnnotationRow(annotationInfo, absRowIndex, true);
Expand Down
7 changes: 2 additions & 5 deletions src/gwt/org/bbop/apollo/gwt/client/ExonDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyCodes;
Expand All @@ -18,7 +17,6 @@
import com.google.gwt.user.cellview.client.ColumnSortEvent;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
Expand All @@ -30,7 +28,6 @@
import org.bbop.apollo.gwt.client.resources.TableResources;
import org.bbop.apollo.gwt.client.rest.AnnotationRestService;
import org.bbop.apollo.gwt.client.rest.RestService;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.Container;
import org.gwtbootstrap3.client.ui.TextBox;
Expand Down Expand Up @@ -202,8 +199,8 @@ public boolean updateData(AnnotationInfo annotationInfo,AnnotationInfo selectedA
//displayAnnotationInfo(annotationInfo);
getAnnotationInfoWithTopLevelFeature(annotationInfo);
annotationInfoList.clear();
GWT.log("sublist: " + annotationInfo.getAnnotationInfoSet().size());
for (AnnotationInfo annotationInfo1 : annotationInfo.getAnnotationInfoSet()) {
GWT.log("sublist: " + annotationInfo.getChildAnnotations().size());
for (AnnotationInfo annotationInfo1 : annotationInfo.getChildAnnotations()) {
GWT.log("adding: " + annotationInfo1.getName());
annotationInfoList.add(annotationInfo1);
}
Expand Down
13 changes: 6 additions & 7 deletions src/gwt/org/bbop/apollo/gwt/client/dto/AnnotationInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;

import java.util.*;

Expand All @@ -15,7 +14,7 @@ public class AnnotationInfo {
private String type;
private Integer min;
private Integer max;
private Set<AnnotationInfo> annotationInfoSet = new HashSet<>();
private Set<AnnotationInfo> childAnnotations = new HashSet<>(); // children
private String symbol;
private String description;
private Integer strand;
Expand Down Expand Up @@ -95,15 +94,15 @@ public void setUniqueName(String uniqueName) {
}

public void addChildAnnotation(AnnotationInfo annotationInfo) {
annotationInfoSet.add(annotationInfo);
childAnnotations.add(annotationInfo);
}

public Set<AnnotationInfo> getAnnotationInfoSet() {
return annotationInfoSet;
public Set<AnnotationInfo> getChildAnnotations() {
return childAnnotations;
}

public void setAnnotationInfoSet(Set<AnnotationInfo> annotationInfoSet) {
this.annotationInfoSet = annotationInfoSet;
public void setChildAnnotations(Set<AnnotationInfo> childAnnotations) {
this.childAnnotations = childAnnotations;
}

public void setSymbol(String symbol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.bbop.apollo.gwt.client.dto.AnnotationInfo;
import org.bbop.apollo.gwt.shared.FeatureStringEnum;

import java.util.Set;

/**
* Created by ndunn on 1/28/15.
*/
Expand Down Expand Up @@ -37,16 +39,18 @@ public static JSONObject convertAnnotationInfoToJSONObject(AnnotationInfo annota
}


public static JSONObject deleteAnnotation(RequestCallback requestCallback, AnnotationInfo annotationInfo){
public static JSONObject deleteAnnotations(RequestCallback requestCallback, Set<AnnotationInfo> annotationInfoSet){
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);

for(AnnotationInfo annotationInfo : annotationInfoSet){
JSONObject uniqueNameObject = new JSONObject();
uniqueNameObject.put(FeatureStringEnum.UNIQUENAME.getValue(),new JSONString(annotationInfo.getUniqueName()));
featuresArray.set(featuresArray.size(),uniqueNameObject);
}

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

}

0 comments on commit 0bfe267

Please sign in to comment.