Example usage for com.google.gwt.http.client RequestCallback RequestCallback

List of usage examples for com.google.gwt.http.client RequestCallback RequestCallback

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestCallback RequestCallback.

Prototype

RequestCallback

Source Link

Usage

From source file:org.cleanlogic.ol4gwt.showcase.examples.VectorWFSGetFeature.java

License:Apache License

@Override
public void buildPanel() {
    StyleOptions styleOptions = new StyleOptions();
    styleOptions.stroke = StrokeStyle.create(Color.create(0, 0, 255, 1.0), 2);
    VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
    vectorLayerOptions.source = vectorSource;
    //        vectorLayerOptions.style = new Style[] {new Style(styleOptions)};
    VectorLayer vectorLayer = new VectorLayer(vectorLayerOptions);

    BingMapsSourceOptions bingMapsSourceOptions = new BingMapsSourceOptions();
    bingMapsSourceOptions.imagerySet = "Aerial";
    bingMapsSourceOptions.key = "AkGbxXx6tDWf1swIhPJyoAVp06H0s0gDTYslNWWHZ6RoPqMpB9ld5FY1WutX8UoF";
    TileLayer raster = TileLayer.create(new BingMapsSource(bingMapsSourceOptions));

    ViewOptions viewOptions = new ViewOptions();
    viewOptions.center = Coordinate.create(-8908887.277395891, 5381918.072437216);
    viewOptions.maxZoom = 19;/*from  w w  w . j  av  a  2 s . c o  m*/
    viewOptions.zoom = 12;

    MapOptions mapOptions = new MapOptions();
    mapOptions.layers = new Collection<>(new BaseLayer[] { raster, vectorLayer });
    mapOptions.view = new View(viewOptions);

    final MapPanel mapPanel = new MapPanel(mapOptions);
    mapPanel.setHeight("400px");

    Filter filter = FilterUtils.and(new IsLikeFilter("name", "Mississippi*"),
            new EqualToFilter("waterway", "riverbank"));

    GetFeatureOptions getFeatureOptions = new GetFeatureOptions();
    getFeatureOptions.srsName = "EPSG:3857";
    getFeatureOptions.featureNS = "http://openstreemap.org";
    getFeatureOptions.featurePrefix = "osm";
    getFeatureOptions.featureTypes = new String[] { "water_areas" };
    getFeatureOptions.outputFormat = "application/json";
    getFeatureOptions.filter = filter;
    WFSFormat wfsFormat = new WFSFormat();
    Node node = wfsFormat.writeGetFeature(getFeatureOptions);
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST,
            "https://ahocevar.com/geoserver/wfs");
    requestBuilder.setRequestData(new XMLSerializer().serializeToString(node));
    requestBuilder.setCallback(new RequestCallback() {
        @Override
        public void onResponseReceived(Request request, Response response) {
            GeoJSONFormat format = new GeoJSONFormat();
            Feature[] features = format.readFeatures(response.getText());
            vectorSource.addFeatures(features);
            mapPanel.getMap().getView().fit(vectorSource.getExtent());
        }

        @Override
        public void onError(Request request, Throwable throwable) {
            GWT.log(throwable.toString());
        }
    });

    contentPanel.add(new HTML(
            "<p>This example generates a GetFeature request which uses a PropertyIsEqualTo and a PropertyIsLike filter, and then posts the request to load the features that match the query.</p>"));
    contentPanel.add(mapPanel);

    initWidget(contentPanel);
    try {
        requestBuilder.send();
    } catch (RequestException ex) {
        GWT.log(ex.getLocalizedMessage());
    }
}

From source file:org.client.JavaApp2Workbook.java

License:Open Source License

/**
 * Resolve one type of content that a Xholon app can have.
 * @param fileName A local file name, or remote uri (http), or null.
 * @param contentType One of "_xhn" "ih" "cd" "csh" etc.
 *///from w  w w . j  av a2s.c  o m
protected void resolve(String fileName, String contentType) {
    //this.println("trying to resolve " + fileName + " " + contentType);
    if (fileName == null) {
        // app is probably using a ClientBundle
        String txt = app.rcConfig(contentType, (ClientBundleWithLookup) app.findGwtClientBundle());
        resolveDone(txt, contentType);
        return;
    }
    final String _contentType = contentType;
    final String _fileName = fileName;
    final IXholon _this = this;
    try {
        new RequestBuilder(RequestBuilder.GET, fileName).sendRequest("", new RequestCallback() {
            @Override
            public void onResponseReceived(Request req, Response resp) {
                if (resp.getStatusCode() == resp.SC_OK) {
                    resolveDone(resp.getText(), _contentType);
                } else {
                    _this.println("\nrequest: GET " + _fileName);
                    _this.println("status code:" + resp.getStatusCode());
                    _this.println("status text:" + resp.getStatusText());
                    _this.println("text:\n" + resp.getText());
                    resolveDone(null, _contentType);
                }
            }

            @Override
            public void onError(Request req, Throwable e) {
                _this.println("onError:" + e.getMessage());
                resolveDone(null, _contentType);
            }
        });
    } catch (RequestException e) {
        _this.println("RequestException:" + e.getMessage());
        resolveDone(null, _contentType);
    }
}

From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java

License:Open Source License

private void displaySkills(String value, final VerticalPanel panel) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/SearchI2G/render?uri="
            + URL.encodeComponent(value) + "&language=" + URL.encodeComponent(getLanguages()));
    try {/*from w ww . ja  va 2 s  .  com*/
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                Window.alert("Error at rendering: " + exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 != response.getStatusCode()) {
                    Window.alert(
                            "Error " + response.getStatusCode() + " at rendering: " + response.getStatusText());
                    return;
                }
                panel.clear();
                panel.add(new HTML(response.getText()));

            }
        });
    } catch (RequestException e) {
        Window.alert("Error at launching rendering: " + e);
    }
}

From source file:org.dashbuilder.client.navbar.LogoWidgetView.java

License:Apache License

@PostConstruct
public void init() {
    final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "banner/banner.html");
    rb.setCallback(new RequestCallback() {
        @Override/* w ww . j  a v  a2s . c  o  m*/
        public void onResponseReceived(final Request request, final Response response) {
            final HTMLPanel html = new HTMLPanel(response.getText());
            container.setWidget(html);
        }

        @Override
        public void onError(final Request request, final Throwable exception) {
            container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
        }
    });
    try {
        rb.send();
    } catch (RequestException re) {
        container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
    }

    initWidget(container);
}

From source file:org.dashbuilder.client.navbar.TopMenuBar.java

License:Apache License

public void setNavHeaderHtml(String htmlFile) {
    DOMUtil.removeAllChildren(navHeader);

    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, htmlFile);
    rb.setCallback(new RequestCallback() {

        public void onResponseReceived(Request request, Response response) {
            HTMLPanel html = new HTMLPanel(response.getText());
            navHeader.appendChild((Node) html.getElement());
        }//w  w w . j  a v a  2 s . c o m

        public void onError(Request request, Throwable exception) {
            Label label = new Label(AppConstants.INSTANCE.logoBannerError());
            navHeader.appendChild((Node) label.getElement());
        }
    });

    try {
        rb.send();
    } catch (RequestException re) {
        Label label = new Label(AppConstants.INSTANCE.logoBannerError());
        navHeader.appendChild((Node) label.getElement());
    }
}

From source file:org.dataconservancy.dcs.access.client.HttpGet.java

License:Apache License

/**
 * Do multiple http requests and only return success when all complete. May
 * be more than one failure reported./*w w  w. j a  v a  2 s.  com*/
 * 
 * cb.success returns a String[] parallel to urls with the results
 * 
 * @param urls
 * @param cb
 */
public static void request(final String[] urls, final Callback<String[]> cb) {
    final String[] result = new String[urls.length];

    for (int i = 0; i < urls.length; i++) {
        RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, urls[i]);
        final int which = i;

        try {
            rb.sendRequest(null, new RequestCallback() {
                public void onError(Request req, Throwable e) {
                    cb.failure(e.getMessage());
                }

                public void onResponseReceived(Request req, Response resp) {
                    if (resp.getStatusCode() != 200) {
                        cb.failure(resp.getText());
                    } else {
                        result[which] = resp.getText();

                        for (int j = 0; j < result.length; j++) {
                            if (result[j] == null) {
                                return;
                            }
                        }

                        cb.success(result);
                    }
                }
            });
        } catch (RequestException e) {
            cb.failure(e.getMessage());
        }
    }
}

From source file:org.dataconservancy.dcs.access.client.presenter.AcrDataPresenter.java

License:Apache License

void addGetPubHandler() {

    ir.addChangeHandler(new ChangeHandler() {
        @Override// w w w .  jav a 2s. c om
        public void onChange(ChangeEvent event) {
            ROList.clear();
            final StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving", "wait", false);
            mediciWait.show();
            existingFileSets = new HashMap<String, FileTable>();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = ir.getSelectedIndex();

            final String instance = ir.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {

                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;

                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");

                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                Window.alert("Failed");
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        //   leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);

                                                        }

                                                        public void onSuccess(JsSearchResult result) {
                                                            //                                          if(result.matches().length()==0||sparqlEndpoint.equals("http://sead.ncsa.illinois.edu/acr/resteasy/sparql"))
                                                            //                                          {
                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            ROList.addItem(dName
                                                                    .substring(dName.lastIndexOf("/") + 1));
                                                            //                                          }                           
                                                            //                                          else
                                                            //                                              flagHyperlink =0;

                                                            /*          if(flagHyperlink==1){
                                                              dataset.addClickHandler(new ClickHandler() {
                                                                  @Override
                                                                  public void onClick(ClickEvent event) {
                                                                      mediciService.restartIngest((String)pair.getKey(), SeadApp.tmpHome, new AsyncCallback<CheckPointDetail>(){
                                                                    
                                                                          @Override
                                                                          public void onFailure(
                                                                                  Throwable caught) {
                                                                              Window.alert("Error in estimating reingest scenario. \n" + caught.getMessage());
                                                                          }
                                                                    
                                                                          @Override
                                                                          public void onSuccess(
                                                                                  final CheckPointDetail result) {
                                                                              if(!result.isCheckPointed()){
                                                                                  final StatusPopupPanel collectionWait = new StatusPopupPanel("Querying for BagIt Bag","bag",false);
                                                                                  collectionWait.show();
                                                                    
                                                                                          final MultiSelectionModel<CollectionNode> selectionModel = new MultiSelectionModel<CollectionNode>();
                                                                    
                                                                                          mediciService.getBag(
                                                                                                  (String) pair.getKey(), sparqlEndpoint,
                                                                                                  SeadApp.bagIturl, SeadApp.tmpHome,
                                                                                                   new AsyncCallback<String>() {
                                                                                                      @Override
                                                                                                      public void onSuccess(final String bagPath) {
                                                                                                          collectionWait.setValue("Converting to SEAD SIP", "wait");
                                                                    
                                                                                                          final Timer getSIPTimer = new Timer() {
                                                                    
                                                                                                          @Override
                                                                                                          public void run() {
                                                                                                              String tempguid = null;
                                                                                                              if(((String) pair.getKey()).contains("/"))
                                                                                                                  tempguid = ((String) pair.getKey()).split("/")
                                                                                                                  [((String) pair.getKey()).split("/").length-1];
                                                                                                              else
                                                                                                                  tempguid = ((String) pair.getKey()).split(":")
                                                                                                                  [((String) pair.getKey()).split(":").length-1];
                                                                                                              final String guid = tempguid;
                                                                                                              mediciService.getSipFromBag(
                                                                                                                      bagPath,
                                                                                                                  SeadApp.tmpHome+guid+"_sip.xml",
                                                                                                                  SeadApp.bagIturl,
                                                                                                                  new AsyncCallback<String>() {
                                                                    
                                                                                                              @Override
                                                                                                              public void onSuccess(String result) {
                                                                    
                                                                                                                  mediciService.getFileNos(new AsyncCallback<Integer>(){
                                                                                                                      @Override
                                                                                                                      public void onFailure(
                                                                                                                              Throwable caught) {
                                                                                                                          Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                                      }
                                                                    
                                                                                                                      @Override
                                                                                                                      public void onSuccess(Integer size) {
                                                                                                                          if(size>Constants.MAX){
                                                                                                                              Window.alert("This collection has more than "+Constants.MAX+" files.\n"+
                                                                                                                                           "Hence preview is not possible. But you can start the ingest");
                                                                                                                              if(collectionWait.isShowing())
                                                                                                                                  collectionWait.hide();
                                                                                                                              getPub.setEnabled(false);
                                                                                                                              cloudCopy.setEnabled(true);
                                                                                                                              mdCb.setEnabled(true);
                                                                                                                              ingestButton.setEnabled(true);
                                                                                                                              ir.setEnabled(false);
                                                                                                                              ir.setStyleName("greyFont");
                                                                                                                              getPub.setStyleName("greyFont");
                                                                                                                              cloudCopy.setStyleName("greenFont");
                                                                                                                              mdCb.setStyleName("greenFont");
                                                                                                                              ingestButton.setStyleName("greenFont");
                                                                    
                                                                    
                                                                                                                              ingestButton.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onClick(ClickEvent event) {
                                                                                                                                      ingestButton.setEnabled(false);
                                                                                                                                      cloudCopy.setEnabled(false);
                                                                                                                                      ir.setEnabled(false);
                                                                                                                                      getPub.setEnabled(true);
                                                                                                                                      String rootMediciId= (String) pair.getKey();
                                                                    
                                                                    
                                                                                                                                      AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                              @Override
                                                                                                                                              public void onSuccess(Void result) {
                                                                                                                                                  mediciService.addMetadata(metadataSrc,SeadApp.tmpHome+guid+"_sip", new AsyncCallback<Void>() {
                                                                    
                                                                                                                                                      @Override
                                                                                                                                                      public void onSuccess(Void result) {
                                                                    
                                                                    
                                                                                                                                                          mediciService.splitSip(
                                                                                                                                                                  SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                  new AsyncCallback<Integer>() {
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onSuccess(Integer result) {
                                                                                                                                                                  n=result;
                                                                                                                                                                  l++;
                                                                                                                                                                  if(l<=n){
                                                                                                                                                                      mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                          @Override
                                                                                                                                                                          public void onSuccess(final String wfInstanceId) {
                                                                                                                                                                              UserServiceAsync user =
                                                                                                                                                                                      GWT.create(UserService.class);
                                                                                                                                                                              user.checkSession(null,new AsyncCallback<UserSession>() {
                                                                    
                                                                                                                                                                                  @Override
                                                                                                                                                                                  public void onFailure(
                                                                                                                                                                                          Throwable caught) {
                                                                                                                                                                                      // TODO Auto-generated method stub
                                                                    
                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                                  @Override
                                                                                                                                                                                  public void onSuccess(
                                                                                                                                                                                          UserSession result) {
                                                                    
                                                                                                                                                                                      mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                                                                                                              (String) pair.getKey(),
                                                                                                                                                                                              sparqlEndpoint,
                                                                                                                                                                                              SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                                              wfInstanceId,
                                                                                                                                                                                              null,
                                                                                                                                                                                              l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                                                                                                              new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                                                  @Override
                                                                                                                                                                                                  public void onSuccess(final String result) {
                                                                                                                                                                                                      l=-1;
                                                                                                                                                                                                      final Label notify = Util.label("!", "Notification");
                                                                                                                                                                                                      notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                                                                                          @Override
                                                                                                                                                                                                          public void onClick(ClickEvent event) {
                                                                                                                                                                                                              StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving","done",false);
                                                                                                                                                                                                              MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                                                                                                              popUpPanel.show();
                                                                                                                                                                                                              nPanel.remove(notify);
                                                                                                                                                                                                          }
                                                                                                                                                                                                      });
                                                                                                                                                                                                      nPanel.add(notify);
                                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                                                  @Override
                                                                                                                                                                                                  public void onFailure(Throwable caught) {
                                                                                                                                                                                                      Window.alert("Workflow failed.");
                                                                                                                                                                                                  }
                                                                                                                                                                                              });
                                                                    
                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                              });
                                                                                                                                                                          }
                                                                    
                                                                                                                                                                          @Override
                                                                                                                                                                          public void onFailure(
                                                                                                                                                                                  Throwable caught) {
                                                                                                                                                                              // TODO Auto-generated method stub
                                                                    
                                                                                                                                                                          }
                                                                                                                                                                      });
                                                                    
                                                                                                                                                                  }
                                                                                                                                                                  else{
                                                                                                                                                                      Window.alert("This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow");
                                                                                                                                                                  }
                                                                                                                                                              }
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                                                                  // TODO Auto-generated method stub
                                                                    
                                                                                                                                                              }
                                                                                                                                                          });
                                                                                                                                                      }
                                                                    
                                                                                                                                                      @Override
                                                                                                                                                      public void onFailure(Throwable caught) {
                                                                                                                                                          // TODO Auto-generated method stub
                                                                    
                                                                                                                                                      }
                                                                                                                                                  });
                                                                                                                                              }
                                                                    
                                                                                                                                          @Override
                                                                                                                                          public void onFailure(Throwable caught) {
                                                                                                                                              // TODO Auto-generated method stub
                                                                    
                                                                                                                                          }
                                                                                                                                      };
                                                                                                                                      mediciService.toVAmodel(rootMediciId,rootMediciId,sparqlEndpoint, SeadApp.tmpHome, vaModelCb );
                                                                    
                                                                                                                                  }
                                                                                                                              });
                                                                    
                                                                                                                              coverRightPanel.setVisible(true);
                                                                                                                          }
                                                                                                                          else{
                                                                                                                              mediciService.getRelations(new AsyncCallback<DatasetRelation>(){
                                                                    
                                                                    
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onFailure(
                                                                                                                                          Throwable caught) {
                                                                                                                                      Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                                                  }
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onSuccess(
                                                                                                                                          final DatasetRelation relations) {
                                                                    
                                                                    
                                                                    
                                                                                                                                      display.getDatasetLbl().setText("Browse Collection and sub-Collections");
                                                                                                                                      display.getFileLbl().setText("Browse Files");
                                                                                                                                          TreeViewModel model =
                                                                                                                                                  new CollectionTreeViewModel(selectionModel, relations, (String) pair.getKey());
                                                                                                                                          CellTree.Resources resource = GWT.create(TreeResources.class);
                                                                                                                                          CellTree tree = new CellTree(model, null,resource);
                                                                                                                                          //collection select
                                                                                                                                          CollectionSelectEvent.register(EVENT_BUS, new CollectionSelectEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionSelectEvent event) {
                                                                    
                                                                                                                                                      rightPanel.clear();
                                                                                                                                                      rightPanel.add(getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),event.getValue()));
                                                                                                                                                 }
                                                                                                                                          });
                                                                    
                                                                                                                                          //collection click
                                                                                                                                          CollectionClickEvent.register(EVENT_BUS, new CollectionClickEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionClickEvent event) {
                                                                    
                                                                                                                                                     if(existingFileSets.containsKey(event.getCollection().getId())){
                                                                                                                                                          rightPanel.clear();
                                                                                                                                                          rightPanel.add(existingFileSets.get(event.getCollection().getId()).cellTable);
                                                                                                                                                      }
                                                                                                                                                      else{
                                                                    
                                                                                                                                                          rightPanel.clear();
                                                                                                                                                          rightPanel.add(getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),false));
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                              });
                                                                                                                                          //collection passive click
                                                                                                                                          CollectionPassiveSelectEvent.register(EVENT_BUS, new CollectionPassiveSelectEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionPassiveSelectEvent event) {
                                                                    
                                                                                                                                                     CellTable files ;
                                                                                                                                                     if(existingFileSets.containsKey(event.getCollection().getId())){
                                                                                                                                                         files = existingFileSets.get(event.getCollection().getId()).cellTable;
                                                                                                                                                         for(String file:relations.getDuAttrMap().get(event.getCollection().getId()).getSub().get(SubType.File)){
                                                                                                                                                             files.getSelectionModel().setSelected((FileNode)relations.getFileAttrMap().get(file),event.getValue());
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                     else{
                                                                                                                                                         files = (CellTable) getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),event.getValue());
                                                                                                                                                     }
                                                                    
                                                                                                                                                 }
                                                                                                                                              });
                                                                    
                                                                                                                                          collectionWait.hide();
                                                                                                                                          leftPanel.clear();
                                                                                                                                          leftPanel.add(tree);
                                                                    
                                                                                                                                      if(collectionWait.isShowing())
                                                                                                                                          collectionWait.hide();
                                                                                                                                      getPub.setEnabled(false);
                                                                                                                                      cloudCopy.setEnabled(true);
                                                                                                                                      mdCb.setEnabled(true);
                                                                                                                                      ingestButton.setEnabled(true);
                                                                                                                                      ir.setEnabled(false);
                                                                                                                                      ir.setStyleName("greyFont");
                                                                                                                                      getPub.setStyleName("greyFont");
                                                                                                                                      cloudCopy.setStyleName("greenFont");
                                                                                                                                      mdCb.setStyleName("greenFont");
                                                                                                                                      ingestButton.setStyleName("greenFont");
                                                                    
                                                                                                                                      ingestButton.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                          @Override
                                                                                                                                          public void onClick(ClickEvent event) {
                                                                                                                                              ingestButton.setEnabled(false);
                                                                                                                                              cloudCopy.setEnabled(false);
                                                                                                                                              ir.setEnabled(false);
                                                                                                                                              getPub.setEnabled(true);
                                                                                                                                              String rootMediciId= (String) pair.getKey();
                                                                                                                                              CollectionNode root = relations.getDuAttrMap().get(rootMediciId);
                                                                    
                                                                    
                                                                                                                                              AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                      @Override
                                                                                                                                                      public void onSuccess(Void result) {
                                                                                                                                                          mediciService.addMetadata(metadataSrc, SeadApp.tmpHome+guid+"_sip",new AsyncCallback<Void>() {
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onSuccess(Void result) {
                                                                                                                                                                  String tempguid = null;
                                                                                                                                                                  if(((String) pair.getKey()).contains("/"))
                                                                                                                                                                      tempguid = ((String) pair.getKey()).split("/")
                                                                                                                                                                      [((String) pair.getKey()).split("/").length-1];
                                                                                                                                                                  else
                                                                                                                                                                      tempguid = ((String) pair.getKey()).split(":")
                                                                                                                                                                      [((String) pair.getKey()).split(":").length-1];
                                                                                                                                                                  final String guid = tempguid;
                                                                    
                                                                                                                                                                  mediciService.splitSip(
                                                                                                                                                                          SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                          new AsyncCallback<Integer>() {
                                                                    
                                                                                                                                                                      @Override
                                                                                                                                                                      public void onSuccess(Integer result) {
                                                                                                                                                                          n=result;
                                                                                                                                                                          l++;
                                                                    
                                                            //                                                                                                                     Window.alert("Starting ingest of dataset");//. We already have the cached SIP for this dataset.");
                                                                                                                                                                          mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                              @Override
                                                                                                                                                                              public void onSuccess(String wfInstanceId) {
                                                                                                                                                                                  //Open a status panel that self queries the database for changes
                                                                                                                                                                                  WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(submitterId, wfInstanceId);
                                                                                                                                                                                  eventRefresher.show();
                                                                                                                                                                                  mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                                                                                                          (String)pair.getKey(),
                                                                                                                                                                                          sparqlEndpoint,
                                                                                                                                                                                          SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                                          wfInstanceId,
                                                                                                                                                                                          null,
                                                                                                                                                                                          l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                                                                                                          new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                                              @Override
                                                                                                                                                                                              public void onSuccess(final String result) {
                                                                                                                                                                                                  l=-1;
                                                                                                                                                                                                  final Label notify = Util.label("!", "Notification");
                                                                                                                                                                                                  notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                                                                                      @Override
                                                                                                                                                                                                      public void onClick(ClickEvent event) {
                                                                                                                                                                                                          MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                                                                                                          popUpPanel.show();
                                                                                                                                                                                                          nPanel.remove(notify);
                                                                                                                                                                                                      }
                                                                                                                                                                                                  });
                                                            //                                                                                                                                       nPanel.add(notify);
                                                                                                                                                                                              }
                                                                    
                                                                                                                                                                                              @Override
                                                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                    
                                                                                                                                                                                              }
                                                                                                                                                                                          });
                                                                    
                                                                                                                                                                              }
                                                                    
                                                                                                                                                                              @Override
                                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                    
                                                                                                                                                                              }
                                                                                                                                                                          });
                                                                    
                                                                                                                                                                      }
                                                                    
                                                                                                                                                                      @Override
                                                                                                                                                                      public void onFailure(Throwable caught) {
                                                                                                                                                                          Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                                      }
                                                                                                                                                                  });
                                                                                                                                                              }
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                                                                  Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                              }
                                                                                                                                                          });
                                                                                                                                                      }
                                                                    
                                                                                                                                                  @Override
                                                                                                                                                  public void onFailure(Throwable caught) {
                                                                                                                                                      Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                  }
                                                                                                                                              };
                                                                                                                                              mediciService.toVAmodel(rootMediciId,rootMediciId, sparqlEndpoint, SeadApp.tmpHome, vaModelCb );
                                                                    
                                                                                                                                          }
                                                                                                                                      });
                                                                                                                                      coverRightPanel.setVisible(true);
                                                                                                                                  }
                                                                                                                              });
                                                                                                                          }
                                                                                                                      }
                                                                                                                  });
                                                                                                              }
                                                                    
                                                                                                              @Override
                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                  Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                              }
                                                                                                          });
                                                                    
                                                                                                      }
                                                                                                  };
                                                                                                  getSIPTimer.schedule(5000);
                                                                                                      }
                                                                    
                                                                                                      @Override
                                                                                                      public void onFailure(Throwable caught) {
                                                                                                          Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                      }
                                                                                                  });
                                                                    
                                                                              }
                                                                              else{
                                                                                  //restart ingest
                                                                    
                                                                                  n=result.getNumSplitSIPs();
                                                                                  String[] arr = result.getResumeSipPath().split("_");
                                                                                  int sipNumber = Integer.parseInt(arr[arr.length-1].split("\\.")[0]);
                                                                                  l = sipNumber;
                                                                                  if(l<=n){
                                                                    
                                                                                      Window.alert("Starting reingest of dataset. We already have the cached SIP for this dataset.");
                                                                                      mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                          @Override
                                                                                          public void onSuccess(String wfInstanceId) {
                                                                                              mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                      null,
                                                                                                      sparqlEndpoint,
                                                                                                      result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                                                                      wfInstanceId,
                                                                                                      result.getPreviousStatusUrls(),
                                                                                                      l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                      new AsyncCallback<String>() {
                                                                    
                                                                                                          @Override
                                                                                                          public void onSuccess(final String result) {
                                                                                                              l=-1;
                                                                                                              final Label notify = Util.label("!", "Notification");
                                                                                                              notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                  @Override
                                                                                                                  public void onClick(ClickEvent event) {
                                                                                                                      MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                      popUpPanel.show();
                                                                                                                      nPanel.remove(notify);
                                                                                                                  }
                                                                                                              });
                                                                                                              nPanel.add(notify);
                                                                                                          }
                                                                    
                                                                                                          @Override
                                                                                                          public void onFailure(Throwable caught) {
                                                                    
                                                                                                          }
                                                                                                      });
                                                                                              //Open a status panel that self queries the database for changes
                                                                                          WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(submitterId, wfInstanceId);
                                                                                          eventRefresher.show();
                                                                                          }
                                                                    
                                                                                          @Override
                                                                                          public void onFailure(Throwable caught) {
                                                                    
                                                                                          }
                                                                                      });
                                                                    
                                                                                  }
                                                                                  else{
                                                                                      Window.alert("This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow.");
                                                                                  }
                                                                                  //MediciIngestPresenter.EVENT_BUS.fireEvent(new SubmitSipEvent(
                                                            //                                                result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                            //                                                result.getPreviousStatusUrls()
                                                            //                                                ));
                                                                              }
                                                                    
                                                                          }
                                                                      });
                                                                  }
                                                              });
                                                                  }
                                                            */ int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");

                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        //    leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        // TODO Auto-generated method stub

                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });

}

From source file:org.dataconservancy.dcs.access.client.presenter.AcrPublishDataPresenter.java

License:Apache License

void addGetPubHandler() {

    acrProjectList.addChangeHandler(new ChangeHandler() {

        @Override//from   ww  w  . j  av a2s  .c om
        public void onChange(ChangeEvent event) {
            ROList.clear();
            final NotificationPopupPanel mediciWait = new NotificationPopupPanel("Retrieving", false);
            mediciWait.show();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = acrProjectList.getSelectedIndex();
            final String instance = acrProjectList.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {
                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;
                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");
                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                new ErrorPopupPanel("Error:" + exception.getMessage()).show();
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        //   leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();
                                            final String datasetId = (String) pair.getKey();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);
                                                        }

                                                        public void onSuccess(JsSearchResult result) {

                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            ROList.addItem(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    datasetId);

                                                            int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");
                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        //    leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        new ErrorPopupPanel("Error:" + caught.getMessage());
                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        new ErrorPopupPanel("Error:" + e.getMessage());
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    new ErrorPopupPanel("Error:" + caught.getMessage());
                }
            });
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.presenter.MediciIngestPresenter.java

License:Apache License

void addGetPubHandler() {
    getPub.addClickHandler(new ClickHandler() {

        @Override/*from   www  . java 2  s .com*/
        public void onClick(ClickEvent event) {
            final StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving", "wait", false);
            mediciWait.show();
            existingFileSets = new HashMap<String, FileTable>();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = ir.getSelectedIndex();

            final String instance = ir.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {

                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;

                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");

                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                Window.alert("Failed");
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);

                                                        }

                                                        public void onSuccess(JsSearchResult result) {
                                                            //                                          if(result.matches().length()==0||sparqlEndpoint.equals("http://sead.ncsa.illinois.edu/acr/resteasy/sparql"))
                                                            //                                          {
                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            //                                          }                           
                                                            //                                          else
                                                            //                                              flagHyperlink =0;

                                                            if (flagHyperlink == 1) {
                                                                dataset.addClickHandler(new ClickHandler() {
                                                                    @Override
                                                                    public void onClick(ClickEvent event) {
                                                                        mediciService.restartIngest(
                                                                                (String) pair.getKey(),
                                                                                SeadApp.tmpHome,
                                                                                new AsyncCallback<CheckPointDetail>() {

                                                                                    @Override
                                                                                    public void onFailure(
                                                                                            Throwable caught) {
                                                                                        Window.alert(
                                                                                                "Error in estimating reingest scenario. \n"
                                                                                                        + caught.getMessage());
                                                                                    }

                                                                                    @Override
                                                                                    public void onSuccess(
                                                                                            final CheckPointDetail result) {
                                                                                        if (!result
                                                                                                .isCheckPointed()) {
                                                                                            final StatusPopupPanel collectionWait = new StatusPopupPanel(
                                                                                                    "Querying for BagIt Bag",
                                                                                                    "bag",
                                                                                                    false);
                                                                                            collectionWait
                                                                                                    .show();

                                                                                            final MultiSelectionModel<CollectionNode> selectionModel = new MultiSelectionModel<CollectionNode>();

                                                                                            mediciService
                                                                                                    .getBag((String) pair
                                                                                                            .getKey(),
                                                                                                            sparqlEndpoint,
                                                                                                            SeadApp.bagIturl,
                                                                                                            SeadApp.tmpHome,
                                                                                                            new AsyncCallback<String>() {
                                                                                                                @Override
                                                                                                                public void onSuccess(
                                                                                                                        final String bagPath) {
                                                                                                                    collectionWait
                                                                                                                            .setValue(
                                                                                                                                    "Converting to SEAD SIP",
                                                                                                                                    "wait");

                                                                                                                    final Timer getSIPTimer = new Timer() {

                                                                                                                        @Override
                                                                                                                        public void run() {
                                                                                                                            String tempguid = null;
                                                                                                                            if (((String) pair
                                                                                                                                    .getKey())
                                                                                                                                            .contains(
                                                                                                                                                    "/"))
                                                                                                                                tempguid = ((String) pair
                                                                                                                                        .getKey())
                                                                                                                                                .split("/")[((String) pair
                                                                                                                                                        .getKey())
                                                                                                                                                                .split("/").length
                                                                                                                                                        - 1];
                                                                                                                            else
                                                                                                                                tempguid = ((String) pair
                                                                                                                                        .getKey())
                                                                                                                                                .split(":")[((String) pair
                                                                                                                                                        .getKey())
                                                                                                                                                                .split(":").length
                                                                                                                                                        - 1];
                                                                                                                            final String guid = tempguid;
                                                                                                                            mediciService
                                                                                                                                    .getSipFromBag(
                                                                                                                                            bagPath,
                                                                                                                                            SeadApp.tmpHome
                                                                                                                                                    + guid
                                                                                                                                                    + "_sip.xml",
                                                                                                                                            SeadApp.bagIturl,
                                                                                                                                            new AsyncCallback<String>() {

                                                                                                                                                @Override
                                                                                                                                                public void onSuccess(
                                                                                                                                                        String result) {

                                                                                                                                                    mediciService
                                                                                                                                                            .getFileNos(
                                                                                                                                                                    new AsyncCallback<Integer>() {
                                                                                                                                                                        @Override
                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                            Window.alert(
                                                                                                                                                                                    "Failed:"
                                                                                                                                                                                            + caught.getMessage());

                                                                                                                                                                        }

                                                                                                                                                                        @Override
                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                Integer size) {
                                                                                                                                                                            if (size > Constants.MAX) {
                                                                                                                                                                                Window.alert(
                                                                                                                                                                                        "This collection has more than "
                                                                                                                                                                                                + Constants.MAX
                                                                                                                                                                                                + " files.\n"
                                                                                                                                                                                                + "Hence preview is not possible. But you can start the ingest");
                                                                                                                                                                                if (collectionWait
                                                                                                                                                                                        .isShowing())
                                                                                                                                                                                    collectionWait
                                                                                                                                                                                            .hide();
                                                                                                                                                                                getPub.setEnabled(
                                                                                                                                                                                        false);
                                                                                                                                                                                cloudCopy
                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                true);
                                                                                                                                                                                mdCb.setEnabled(
                                                                                                                                                                                        true);
                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                true);
                                                                                                                                                                                ir.setEnabled(
                                                                                                                                                                                        false);
                                                                                                                                                                                ir.setStyleName(
                                                                                                                                                                                        "greyFont");
                                                                                                                                                                                getPub.setStyleName(
                                                                                                                                                                                        "greyFont");
                                                                                                                                                                                cloudCopy
                                                                                                                                                                                        .setStyleName(
                                                                                                                                                                                                "greenFont");
                                                                                                                                                                                mdCb.setStyleName(
                                                                                                                                                                                        "greenFont");
                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .setStyleName(
                                                                                                                                                                                                "greenFont");

                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .addClickHandler(
                                                                                                                                                                                                new ClickHandler() {

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onClick(
                                                                                                                                                                                                            ClickEvent event) {
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        false);
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        false);
                                                                                                                                                                                                        ir.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        getPub.setEnabled(
                                                                                                                                                                                                                true);
                                                                                                                                                                                                        String rootMediciId = (String) pair
                                                                                                                                                                                                                .getKey();

                                                                                                                                                                                                        AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                                                                            @Override
                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                    Void result) {
                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                        .addMetadata(
                                                                                                                                                                                                                                metadataSrc,
                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                new AsyncCallback<Void>() {

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                            Void result) {

                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                .splitSip(
                                                                                                                                                                                                                                                        SeadApp.tmpHome
                                                                                                                                                                                                                                                                + guid
                                                                                                                                                                                                                                                                + "_sip",
                                                                                                                                                                                                                                                        new AsyncCallback<Integer>() {

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                    Integer result) {
                                                                                                                                                                                                                                                                n = result;
                                                                                                                                                                                                                                                                l++;
                                                                                                                                                                                                                                                                if (l <= n) {
                                                                                                                                                                                                                                                                    mediciService
                                                                                                                                                                                                                                                                            .generateWfInstanceId(
                                                                                                                                                                                                                                                                                    new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                                                                                                                                final String wfInstanceId) {
                                                                                                                                                                                                                                                                                            UserServiceAsync user = GWT
                                                                                                                                                                                                                                                                                                    .create(UserService.class);
                                                                                                                                                                                                                                                                                            user.checkSession(
                                                                                                                                                                                                                                                                                                    null,
                                                                                                                                                                                                                                                                                                    new AsyncCallback<UserSession>() {

                                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                                                                                                                                                            // TODO Auto-generated method stub

                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                                                                                                                                                UserSession result) {

                                                                                                                                                                                                                                                                                                            mediciService
                                                                                                                                                                                                                                                                                                                    .submitMultipleSips(
                                                                                                                                                                                                                                                                                                                            SeadApp.deposit_endpoint
                                                                                                                                                                                                                                                                                                                                    + "sip",
                                                                                                                                                                                                                                                                                                                            (String) pair
                                                                                                                                                                                                                                                                                                                                    .getKey(),
                                                                                                                                                                                                                                                                                                                            sparqlEndpoint,
                                                                                                                                                                                                                                                                                                                            SeadApp.tmpHome
                                                                                                                                                                                                                                                                                                                                    + guid
                                                                                                                                                                                                                                                                                                                                    + "_sip",
                                                                                                                                                                                                                                                                                                                            wfInstanceId,
                                                                                                                                                                                                                                                                                                                            null,
                                                                                                                                                                                                                                                                                                                            l,
                                                                                                                                                                                                                                                                                                                            n,
                                                                                                                                                                                                                                                                                                                            "",
                                                                                                                                                                                                                                                                                                                            "",
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            GWT.getModuleBaseURL(),
                                                                                                                                                                                                                                                                                                                            SeadApp.tmpHome,
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                public void onSuccess(
                                                                                                                                                                                                                                                                                                                                        final String result) {
                                                                                                                                                                                                                                                                                                                                    l = -1;
                                                                                                                                                                                                                                                                                                                                    final Label notify = Util
                                                                                                                                                                                                                                                                                                                                            .label("!",
                                                                                                                                                                                                                                                                                                                                                    "Notification");
                                                                                                                                                                                                                                                                                                                                    notify.addClickHandler(
                                                                                                                                                                                                                                                                                                                                            new ClickHandler() {

                                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                                public void onClick(
                                                                                                                                                                                                                                                                                                                                                        ClickEvent event) {
                                                                                                                                                                                                                                                                                                                                                    StatusPopupPanel mediciWait = new StatusPopupPanel(
                                                                                                                                                                                                                                                                                                                                                            "Retrieving",
                                                                                                                                                                                                                                                                                                                                                            "done",
                                                                                                                                                                                                                                                                                                                                                            false);
                                                                                                                                                                                                                                                                                                                                                    MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                                                                                                                                                                                                            result,
                                                                                                                                                                                                                                                                                                                                                            "done",
                                                                                                                                                                                                                                                                                                                                                            true);
                                                                                                                                                                                                                                                                                                                                                    popUpPanel
                                                                                                                                                                                                                                                                                                                                                            .show();
                                                                                                                                                                                                                                                                                                                                                    nPanel.remove(
                                                                                                                                                                                                                                                                                                                                                            notify);
                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                            });
                                                                                                                                                                                                                                                                                                                                    nPanel.add(
                                                                                                                                                                                                                                                                                                                                            notify);
                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                public void onFailure(
                                                                                                                                                                                                                                                                                                                                        Throwable caught) {
                                                                                                                                                                                                                                                                                                                                    Window.alert(
                                                                                                                                                                                                                                                                                                                                            "Workflow failed.");
                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                            });

                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                    });
                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                                                                                                                                            // TODO Auto-generated method stub

                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                    });

                                                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                                                    Window.alert(
                                                                                                                                                                                                                                                                            "This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow");
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                                                                // TODO Auto-generated method stub

                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                        });
                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                        // TODO Auto-generated method stub

                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                });
                                                                                                                                                                                                            }

                                                                                                                                                                                                            @Override
                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                // TODO Auto-generated method stub

                                                                                                                                                                                                            }
                                                                                                                                                                                                        };
                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                .toVAmodel(
                                                                                                                                                                                                                        rootMediciId,
                                                                                                                                                                                                                        rootMediciId,
                                                                                                                                                                                                                        sparqlEndpoint,
                                                                                                                                                                                                                        SeadApp.tmpHome,
                                                                                                                                                                                                                        vaModelCb);

                                                                                                                                                                                                    }
                                                                                                                                                                                                });

                                                                                                                                                                                coverRightPanel
                                                                                                                                                                                        .setVisible(
                                                                                                                                                                                                true);
                                                                                                                                                                            } else {
                                                                                                                                                                                mediciService
                                                                                                                                                                                        .getRelations(
                                                                                                                                                                                                new AsyncCallback<DatasetRelation>() {

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                "Failed:"
                                                                                                                                                                                                                        + caught.getMessage());

                                                                                                                                                                                                    }

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                            final DatasetRelation relations) {

                                                                                                                                                                                                        display.getDatasetLbl()
                                                                                                                                                                                                                .setText(
                                                                                                                                                                                                                        "Browse Collection and sub-Collections");
                                                                                                                                                                                                        display.getFileLbl()
                                                                                                                                                                                                                .setText(
                                                                                                                                                                                                                        "Browse Files");
                                                                                                                                                                                                        TreeViewModel model = new CollectionTreeViewModel(
                                                                                                                                                                                                                selectionModel,
                                                                                                                                                                                                                relations,
                                                                                                                                                                                                                (String) pair
                                                                                                                                                                                                                        .getKey());
                                                                                                                                                                                                        CellTree.Resources resource = GWT
                                                                                                                                                                                                                .create(TreeResources.class);
                                                                                                                                                                                                        CellTree tree = new CellTree(
                                                                                                                                                                                                                model,
                                                                                                                                                                                                                null,
                                                                                                                                                                                                                resource);
                                                                                                                                                                                                        //collection select
                                                                                                                                                                                                        CollectionSelectEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionSelectEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionSelectEvent event) {

                                                                                                                                                                                                                                rightPanel
                                                                                                                                                                                                                                        .clear();
                                                                                                                                                                                                                                rightPanel
                                                                                                                                                                                                                                        .add(getFiles(
                                                                                                                                                                                                                                                relations
                                                                                                                                                                                                                                                        .getDuAttrMap(),
                                                                                                                                                                                                                                                relations
                                                                                                                                                                                                                                                        .getFileAttrMap(),
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId(),
                                                                                                                                                                                                                                                event.getValue()));
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });

                                                                                                                                                                                                        //collection click
                                                                                                                                                                                                        CollectionClickEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionClickEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionClickEvent event) {

                                                                                                                                                                                                                                if (existingFileSets
                                                                                                                                                                                                                                        .containsKey(
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId())) {
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .clear();
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .add(existingFileSets
                                                                                                                                                                                                                                                    .get(event
                                                                                                                                                                                                                                                            .getCollection()
                                                                                                                                                                                                                                                            .getId()).cellTable);
                                                                                                                                                                                                                                } else {

                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .clear();
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .add(getFiles(
                                                                                                                                                                                                                                                    relations
                                                                                                                                                                                                                                                            .getDuAttrMap(),
                                                                                                                                                                                                                                                    relations
                                                                                                                                                                                                                                                            .getFileAttrMap(),
                                                                                                                                                                                                                                                    event.getCollection()
                                                                                                                                                                                                                                                            .getId(),
                                                                                                                                                                                                                                                    false));
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });
                                                                                                                                                                                                        //collection passive click
                                                                                                                                                                                                        CollectionPassiveSelectEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionPassiveSelectEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionPassiveSelectEvent event) {

                                                                                                                                                                                                                                CellTable files;
                                                                                                                                                                                                                                if (existingFileSets
                                                                                                                                                                                                                                        .containsKey(
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId())) {
                                                                                                                                                                                                                                    files = existingFileSets
                                                                                                                                                                                                                                            .get(event
                                                                                                                                                                                                                                                    .getCollection()
                                                                                                                                                                                                                                                    .getId()).cellTable;
                                                                                                                                                                                                                                    for (String file : relations
                                                                                                                                                                                                                                            .getDuAttrMap()
                                                                                                                                                                                                                                            .get(event
                                                                                                                                                                                                                                                    .getCollection()
                                                                                                                                                                                                                                                    .getId())
                                                                                                                                                                                                                                            .getSub()
                                                                                                                                                                                                                                            .get(SubType.File)) {
                                                                                                                                                                                                                                        files.getSelectionModel()
                                                                                                                                                                                                                                                .setSelected(
                                                                                                                                                                                                                                                        (FileNode) relations
                                                                                                                                                                                                                                                                .getFileAttrMap()
                                                                                                                                                                                                                                                                .get(file),
                                                                                                                                                                                                                                                        event.getValue());
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                    files = (CellTable) getFiles(
                                                                                                                                                                                                                                            relations
                                                                                                                                                                                                                                                    .getDuAttrMap(),
                                                                                                                                                                                                                                            relations
                                                                                                                                                                                                                                                    .getFileAttrMap(),
                                                                                                                                                                                                                                            event.getCollection()
                                                                                                                                                                                                                                                    .getId(),
                                                                                                                                                                                                                                            event.getValue());
                                                                                                                                                                                                                                }

                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });

                                                                                                                                                                                                        collectionWait
                                                                                                                                                                                                                .hide();
                                                                                                                                                                                                        leftPanel
                                                                                                                                                                                                                .clear();
                                                                                                                                                                                                        leftPanel
                                                                                                                                                                                                                .add(tree);

                                                                                                                                                                                                        if (collectionWait
                                                                                                                                                                                                                .isShowing())
                                                                                                                                                                                                            collectionWait
                                                                                                                                                                                                                    .hide();
                                                                                                                                                                                                        getPub.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                        mdCb.setEnabled(
                                                                                                                                                                                                                true);
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                        ir.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        ir.setStyleName(
                                                                                                                                                                                                                "greyFont");
                                                                                                                                                                                                        getPub.setStyleName(
                                                                                                                                                                                                                "greyFont");
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setStyleName(
                                                                                                                                                                                                                        "greenFont");
                                                                                                                                                                                                        mdCb.setStyleName(
                                                                                                                                                                                                                "greenFont");
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setStyleName(
                                                                                                                                                                                                                        "greenFont");

                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .addClickHandler(
                                                                                                                                                                                                                        new ClickHandler() {

                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                            public void onClick(
                                                                                                                                                                                                                                    ClickEvent event) {
                                                                                                                                                                                                                                ingestButton
                                                                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                                                                false);
                                                                                                                                                                                                                                cloudCopy
                                                                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                                                                false);
                                                                                                                                                                                                                                ir.setEnabled(
                                                                                                                                                                                                                                        false);
                                                                                                                                                                                                                                getPub.setEnabled(
                                                                                                                                                                                                                                        true);
                                                                                                                                                                                                                                String rootMediciId = (String) pair
                                                                                                                                                                                                                                        .getKey();
                                                                                                                                                                                                                                CollectionNode root = relations
                                                                                                                                                                                                                                        .getDuAttrMap()
                                                                                                                                                                                                                                        .get(rootMediciId);

                                                                                                                                                                                                                                AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                            Void result) {
                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                .addMetadata(
                                                                                                                                                                                                                                                        metadataSrc,
                                                                                                                                                                                                                                                        SeadApp.tmpHome
                                                                                                                                                                                                                                                                + guid
                                                                                                                                                                                                                                                                + "_sip",
                                                                                                                                                                                                                                                        new AsyncCallback<Void>() {

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                    Void result) {
                                                                                                                                                                                                                                                                String tempguid = null;
                                                                                                                                                                                                                                                                if (((String) pair
                                                                                                                                                                                                                                                                        .getKey())
                                                                                                                                                                                                                                                                                .contains(
                                                                                                                                                                                                                                                                                        "/"))
                                                                                                                                                                                                                                                                    tempguid = ((String) pair
                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                    .split("/")[((String) pair
                                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                                    .split("/").length
                                                                                                                                                                                                                                                                                            - 1];
                                                                                                                                                                                                                                                                else
                                                                                                                                                                                                                                                                    tempguid = ((String) pair
                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                    .split(":")[((String) pair
                                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                                    .split(":").length
                                                                                                                                                                                                                                                                                            - 1];
                                                                                                                                                                                                                                                                final String guid = tempguid;

                                                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                                                        .splitSip(
                                                                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                                                                new AsyncCallback<Integer>() {

                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                                                                            Integer result) {
                                                                                                                                                                                                                                                                                        n = result;
                                                                                                                                                                                                                                                                                        l++;

                                                                                                                                                                                                                                                                                        //                                                                                                                     Window.alert("Starting ingest of dataset");//. We already have the cached SIP for this dataset.");
                                                                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                                                                .generateWfInstanceId(
                                                                                                                                                                                                                                                                                                        new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                                                                    String wfInstanceId) {
                                                                                                                                                                                                                                                                                                                //Open a status panel that self queries the database for changes
                                                                                                                                                                                                                                                                                                                WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(
                                                                                                                                                                                                                                                                                                                        submitterId,
                                                                                                                                                                                                                                                                                                                        wfInstanceId);
                                                                                                                                                                                                                                                                                                                eventRefresher
                                                                                                                                                                                                                                                                                                                        .show();
                                                                                                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                                                                                                        .submitMultipleSips(
                                                                                                                                                                                                                                                                                                                                SeadApp.deposit_endpoint
                                                                                                                                                                                                                                                                                                                                        + "sip",
                                                                                                                                                                                                                                                                                                                                (String) pair
                                                                                                                                                                                                                                                                                                                                        .getKey(),
                                                                                                                                                                                                                                                                                                                                sparqlEndpoint,
                                                                                                                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                                                                                                                wfInstanceId,
                                                                                                                                                                                                                                                                                                                                null,
                                                                                                                                                                                                                                                                                                                                l,
                                                                                                                                                                                                                                                                                                                                n,
                                                                                                                                                                                                                                                                                                                                "",
                                                                                                                                                                                                                                                                                                                                "",
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                GWT.getModuleBaseURL(),
                                                                                                                                                                                                                                                                                                                                SeadApp.tmpHome,
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                                                                                                                            final String result) {
                                                                                                                                                                                                                                                                                                                                        l = -1;
                                                                                                                                                                                                                                                                                                                                        final Label notify = Util
                                                                                                                                                                                                                                                                                                                                                .label("!",
                                                                                                                                                                                                                                                                                                                                                        "Notification");
                                                                                                                                                                                                                                                                                                                                        notify.addClickHandler(
                                                                                                                                                                                                                                                                                                                                                new ClickHandler() {

                                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                                    public void onClick(
                                                                                                                                                                                                                                                                                                                                                            ClickEvent event) {
                                                                                                                                                                                                                                                                                                                                                        MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                                                                                                                                                                                                                result,
                                                                                                                                                                                                                                                                                                                                                                "done",
                                                                                                                                                                                                                                                                                                                                                                true);
                                                                                                                                                                                                                                                                                                                                                        popUpPanel
                                                                                                                                                                                                                                                                                                                                                                .show();
                                                                                                                                                                                                                                                                                                                                                        nPanel.remove(
                                                                                                                                                                                                                                                                                                                                                                notify);
                                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                                });
                                                                                                                                                                                                                                                                                                                                        //                                                                                                                                       nPanel.add(notify);
                                                                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                                                                                                                            Throwable caught) {

                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                });

                                                                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                                                                    Throwable caught) {

                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                        });

                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                                                                                                "Failed. \n"
                                                                                                                                                                                                                                                                                                        + caught.getMessage());
                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                });
                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                                                                Window.alert(
                                                                                                                                                                                                                                                                        "Failed. \n"
                                                                                                                                                                                                                                                                                + caught.getMessage());
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                        });
                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                                                "Failed. \n"
                                                                                                                                                                                                                                                        + caught.getMessage());
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                        .toVAmodel(
                                                                                                                                                                                                                                                rootMediciId,
                                                                                                                                                                                                                                                rootMediciId,
                                                                                                                                                                                                                                                sparqlEndpoint,
                                                                                                                                                                                                                                                SeadApp.tmpHome,
                                                                                                                                                                                                                                                vaModelCb);

                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });
                                                                                                                                                                                                        coverRightPanel
                                                                                                                                                                                                                .setVisible(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                    }
                                                                                                                                                                                                });
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    });
                                                                                                                                                }

                                                                                                                                                @Override
                                                                                                                                                public void onFailure(
                                                                                                                                                        Throwable caught) {
                                                                                                                                                    Window.alert(
                                                                                                                                                            "Failed:"
                                                                                                                                                                    + caught.getMessage());

                                                                                                                                                }
                                                                                                                                            });

                                                                                                                        }
                                                                                                                    };
                                                                                                                    getSIPTimer
                                                                                                                            .schedule(
                                                                                                                                    5000);
                                                                                                                }

                                                                                                                @Override
                                                                                                                public void onFailure(
                                                                                                                        Throwable caught) {
                                                                                                                    Window.alert(
                                                                                                                            "Failed:"
                                                                                                                                    + caught.getMessage());

                                                                                                                }
                                                                                                            });

                                                                                        } else {
                                                                                            //restart ingest

                                                                                            n = result
                                                                                                    .getNumSplitSIPs();
                                                                                            String[] arr = result
                                                                                                    .getResumeSipPath()
                                                                                                    .split("_");
                                                                                            int sipNumber = Integer
                                                                                                    .parseInt(
                                                                                                            arr[arr.length
                                                                                                                    - 1].split(
                                                                                                                            "\\.")[0]);
                                                                                            l = sipNumber;
                                                                                            if (l <= n) {

                                                                                                Window.alert(
                                                                                                        "Starting reingest of dataset. We already have the cached SIP for this dataset.");
                                                                                                mediciService
                                                                                                        .generateWfInstanceId(
                                                                                                                new AsyncCallback<String>() {

                                                                                                                    @Override
                                                                                                                    public void onSuccess(
                                                                                                                            String wfInstanceId) {
                                                                                                                        mediciService
                                                                                                                                .submitMultipleSips(
                                                                                                                                        SeadApp.deposit_endpoint
                                                                                                                                                + "sip",
                                                                                                                                        null,
                                                                                                                                        sparqlEndpoint,
                                                                                                                                        result.getResumeSipPath()
                                                                                                                                                .replace(
                                                                                                                                                        "_" + l + ".xml",
                                                                                                                                                        ""),
                                                                                                                                        wfInstanceId,
                                                                                                                                        result.getPreviousStatusUrls(),
                                                                                                                                        l,
                                                                                                                                        n,
                                                                                                                                        "",
                                                                                                                                        "",
                                                                                                                                        false,
                                                                                                                                        GWT.getModuleBaseURL(),
                                                                                                                                        SeadApp.tmpHome,
                                                                                                                                        false,
                                                                                                                                        false,
                                                                                                                                        new AsyncCallback<String>() {

                                                                                                                                            @Override
                                                                                                                                            public void onSuccess(
                                                                                                                                                    final String result) {
                                                                                                                                                l = -1;
                                                                                                                                                final Label notify = Util
                                                                                                                                                        .label("!",
                                                                                                                                                                "Notification");
                                                                                                                                                notify.addClickHandler(
                                                                                                                                                        new ClickHandler() {

                                                                                                                                                            @Override
                                                                                                                                                            public void onClick(
                                                                                                                                                                    ClickEvent event) {
                                                                                                                                                                MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                        result,
                                                                                                                                                                        "done",
                                                                                                                                                                        true);
                                                                                                                                                                popUpPanel
                                                                                                                                                                        .show();
                                                                                                                                                                nPanel.remove(
                                                                                                                                                                        notify);
                                                                                                                                                            }
                                                                                                                                                        });
                                                                                                                                                nPanel.add(
                                                                                                                                                        notify);
                                                                                                                                            }

                                                                                                                                            @Override
                                                                                                                                            public void onFailure(
                                                                                                                                                    Throwable caught) {

                                                                                                                                            }
                                                                                                                                        });
                                                                                                                        //Open a status panel that self queries the database for changes
                                                                                                                        WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(
                                                                                                                                submitterId,
                                                                                                                                wfInstanceId);
                                                                                                                        eventRefresher
                                                                                                                                .show();
                                                                                                                    }

                                                                                                                    @Override
                                                                                                                    public void onFailure(
                                                                                                                            Throwable caught) {

                                                                                                                    }
                                                                                                                });

                                                                                            } else {
                                                                                                Window.alert(
                                                                                                        "This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow.");
                                                                                            }
                                                                                            //MediciIngestPresenter.EVENT_BUS.fireEvent(new SubmitSipEvent(
                                                                                            //                                                result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                                                            //                                                result.getPreviousStatusUrls()
                                                                                            //                                                ));
                                                                                        }

                                                                                    }
                                                                                });
                                                                    }
                                                                });
                                                            }
                                                            int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");

                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        // TODO Auto-generated method stub

                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
}

From source file:org.ebayopensource.turmeric.monitoring.client.model.MetricsQueryServiceImpl.java

License:Open Source License

/**
 * Call the remote server to obtain metrics measurements.
 * /*from  ww  w.j a  v  a  2s  .c om*/
 * @param criteria
 *            the criteria
 * @param resourceCriteria
 *            the resource criteria
 * @param callback
 *            the callback
 * @see org.ebayopensource.turmeric.monitoring.client.model.MetricsQueryService#getMetricData(org.ebayopensource.turmeric.monitoring.client.model.MetricCriteria,
 *      org.ebayopensource.turmeric.monitoring.client.model.MetricResourceCriteria,
 *      com.google.gwt.user.client.rpc.AsyncCallback)
 */
public void getMetricData(final MetricCriteria criteria, final MetricResourceCriteria resourceCriteria,
        final AsyncCallback<MetricData> callback) {

    final String url = URL.encode(MetricsDataRequest.getRestURL(criteria, resourceCriteria));
    GWT.log("calling the getMetricsData =" + url);
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    final MetricData data = new MetricData();
    data.setRestUrl(url);
    data.setMetricCriteria(criteria);
    data.setMetricResourceCriteria(resourceCriteria);

    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable err) {
                callback.onFailure(err);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() != Response.SC_OK) {
                    callback.onFailure(getErrorAsThrowable(response));
                } else if (response.getHeader(ERROR_HEADER) != null
                        && response.getHeader(ERROR_HEADER).length() > 0) {
                    callback.onFailure(getErrorAsThrowable(response));
                } else {
                    String responseText = response.getText();
                    GWT.log("getMetricData. responseText =" + responseText);
                    MetricsDataResponse metricsResponse = MetricsDataResponse.fromJSON(response.getText());
                    if (metricsResponse == null) {
                        GWT.log("bad response: " + response.getText());
                        callback.onFailure(new Throwable(ConsoleUtil.messages.badOrMissingResponseData()));
                    } else {
                        JsArray<MetricGroupDataJS> rows = metricsResponse.getReturnData();
                        List<MetricGroupData> results = new ArrayList<MetricGroupData>();
                        if (rows != null) {
                            for (int i = 0; i < rows.length(); i++) {
                                MetricGroupDataJS js = rows.get(i);
                                results.add(js);
                            }
                        }
                        data.setReturnData(results);
                        callback.onSuccess(data);
                    }
                }
            }
        });
    } catch (RequestException x) {
        callback.onFailure(x);
    }
}