Skip to content

Commit

Permalink
Merge 0bfe267 into da96cd1
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Feb 12, 2019
2 parents da96cd1 + 0bfe267 commit 51ffcb1
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 139 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,6 @@ 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}"
Sequence sequence = permissionService.checkPermissions(inputObject, PermissionEnum.WRITE)
boolean suppressEvents = false
if (inputObject.has(FeatureStringEnum.SUPPRESS_EVENTS.value)) {
Expand Down
3 changes: 0 additions & 3 deletions src/gwt/org/bbop/apollo/gwt/client/Annotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
Expand All @@ -14,7 +12,6 @@
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.storage.client.Storage;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import org.bbop.apollo.gwt.client.rest.RestService;
import org.bbop.apollo.gwt.shared.ClientTokenGenerator;
Expand Down
68 changes: 64 additions & 4 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 All @@ -43,6 +42,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 All @@ -52,6 +52,7 @@
import org.gwtbootstrap3.client.ui.ListBox;
import org.gwtbootstrap3.client.ui.TextBox;
import org.gwtbootstrap3.extras.bootbox.client.Bootbox;
import org.gwtbootstrap3.extras.bootbox.client.callback.ConfirmCallback;

import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -124,6 +125,8 @@ interface AnnotatorPanelUiBinder extends UiBinder<com.google.gwt.user.client.ui.
Container northPanelContainer;
@UiField
static Button gotoAnnotation;
@UiField
static Button deleteAnnotation;

private static AnnotationInfo selectedAnnotationInfo;
private MultiWordSuggestOracle sequenceOracle = new ReferenceSequenceOracle();
Expand Down Expand Up @@ -259,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 @@ -664,9 +667,11 @@ public void onSelectionChange(SelectionChangeEvent event) {
if (selectedAnnotationInfo != null) {
exonDetailPanel.updateData(selectedAnnotationInfo);
gotoAnnotation.setEnabled(true);
deleteAnnotation.setEnabled(true);
} else {
exonDetailPanel.updateData();
gotoAnnotation.setEnabled(false);
deleteAnnotation.setEnabled(false);
}
}
});
Expand Down Expand Up @@ -729,9 +734,61 @@ void gotoAnnotation(ClickEvent clickEvent) {
MainPanel.updateGenomicViewerForLocation(selectedAnnotationInfo.getSequence(), min, max, false, false);
}

@UiHandler("deleteAnnotation")
void deleteAnnotation(ClickEvent clickEvent) {
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());
}
}

@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) {
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 All @@ -747,6 +804,7 @@ public void enableGoto(int geneIndex, String uniqueName) {
exonDetailPanel.updateData(selectedAnnotationInfo);
updateAnnotationInfo(selectedAnnotationInfo);
gotoAnnotation.setEnabled(true);
deleteAnnotation.setEnabled(true);
selectedChildUniqueName = selectedAnnotationInfo.getUniqueName();
}

Expand All @@ -758,6 +816,7 @@ public void displayTranscript(int geneIndex, String uniqueName) {
selectedAnnotationInfo = getChildAnnotation(annotationInfo, uniqueName);
exonDetailPanel.updateData(selectedAnnotationInfo);
gotoAnnotation.setEnabled(true);
deleteAnnotation.setEnabled(true);
selectedChildUniqueName = selectedAnnotationInfo.getUniqueName();

// for some reason doesn't like call gotoAnnotation
Expand All @@ -777,6 +836,7 @@ public void displayFeature(int featureIndex) {
exonDetailPanel.updateData(annotationInfo);
}
gotoAnnotation.setEnabled(true);
deleteAnnotation.setEnabled(true);
Integer min = selectedAnnotationInfo.getMin() - 50;
Integer max = selectedAnnotationInfo.getMax() + 50;
min = min < 0 ? 0 : min;
Expand Down Expand Up @@ -804,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
Loading

0 comments on commit 51ffcb1

Please sign in to comment.