Example usage for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder

List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder

Introduction

In this page you can find the example usage for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder.

Prototype

JsonpRequestBuilder

Source Link

Usage

From source file:net.cbtltd.client.widget.route.RouteWidget.java

private void getJsonpProductNameIds(String productid) {

    JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
    String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.NAMEID + "&pos=" + pos + "&model="
            + NameId.Type.Product.name() + "&id=" + productid;

    loader.setVisible(true);//from   ww w.java2 s  .c o  m
    jsonp.requestObject(url, new AsyncCallback<NameIdWidgetItems>() {

        @Override
        public void onFailure(Throwable x) {
            loader.setVisible(false);
            throw new RuntimeException(Error.product_json.getMessage() + " " + x.getMessage());
        }

        @Override
        public void onSuccess(NameIdWidgetItems response) {
            loader.setVisible(false);
            if (response != null && response.getItems() != null && response.getItems().length() > 0) {
                ArrayList<NameId> items = new ArrayList<NameId>();
                for (int index = 0; index < response.getItems().length(); index++) {
                    items.add(new NameId(response.getItems().get(index).getName(),
                            response.getItems().get(index).getId()));
                }
                productField.setItems(items);
            }
        }
    });
}

From source file:net.cbtltd.client.widget.text.TextWidget.java

private void getJsonpText() {

    if (productField.noValue()) {
        return;// w ww  . j a  v  a 2  s .  co  m
    }

    JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
    String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.TEXT + "&pos=" + pos + "&model="
            + NameId.Type.Product.name() + "&id=" + productField.getValue() + "&language="
            + labelField.getLanguage() + "&type=" + RazorWidget.getParameter("text");

    loader.setVisible(true);
    jsonp.requestObject(url, new AsyncCallback<TextWidgetItem>() {

        @Override
        public void onFailure(Throwable x) {
            loader.setVisible(false);
            throw new RuntimeException(Error.widget_text.getMessage() + " " + x.getMessage());
        }

        @Override
        public void onSuccess(TextWidgetItem response) {
            loader.setVisible(false);
            if (response == null) {
                AbstractField.addMessage(Level.ERROR, CONSTANTS.productError(), labelField);
            } else {
                labelField.setValue(response.getMessage());
            }
        }
    });
}

From source file:org.cruxframework.crux.widgets.client.slideshow.data.picasa.PicasaService.java

License:Apache License

@Override
protected void doLoad() {
    JsonpRequestBuilder request = new JsonpRequestBuilder();
    String url = getRequestURL();
    request.requestObject(url, new AsyncCallback<Feed>() {
        @Override/*from w w w.  j ava2s  .  co m*/
        public void onFailure(Throwable t) {
            errorLoading(t);
        }

        @Override
        public void onSuccess(Feed feed) {
            PhotoAlbum album = extractAlbum(feed, userID, albumID);
            completeLoading(album);
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.model.JsFile.java

License:Apache License

public Widget display() {
    FlowPanel panel = new FlowPanel();

    if (!getSource().isEmpty()) {

        Button b = new Button("Download");
        panel.add(b);// www. ja  v a2 s. co  m

        b.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String source = SeadApp.datastreamURLnoEncoding(getId().replace(":", "%3A"));

                String strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
                Window.open(source, "_blank", strWindowFeatures);
            }
        });

        //panel.add(new Anchor("Download", false, getSource(), "_blank"));
    }

    final FlexTable table = Util.createTable(//"Id",
            "Entity type", "Name", "Appears in Collections", "Size", "Valid", "Extant", "Metadata refs",
            "Alternate Ids", "Primary Location", "ACR Location");

    Util.addColumn(table,
            // null,
            "File", getName(), null, "" + getSizeBytes() + " bytes",
            getValid() == null ? "Unknown" : "" + getValid(), "" + isExtant());

    // table.setWidget(0, 1, Util.entityLink(getId()));

    JsonpRequestBuilder rb = new JsonpRequestBuilder();
    String parentdu = SeadApp.accessurl + SeadApp.queryPath + "?q=" + "id:(\"" + getParent() + "\")"
            + "&offset=0&max=200";
    rb.requestObject(parentdu, new AsyncCallback<JsSearchResult>() {

        public void onFailure(Throwable caught) {
            Window.alert("Failed");
        }

        public void onSuccess(JsSearchResult dus) {

            FlowPanel desc = new FlowPanel();

            for (int i = 0; i < dus.matches().length(); i++) {
                JsMatch m = dus.matches().get(i);

                JsDeliverableUnit entity = (JsDeliverableUnit) m.getEntity();

                //System.out.println("Title="+entity.getCoreMd().getTitle());
                desc.add(new Hyperlink(" " + entity.getCoreMd().getTitle(), true,
                        SeadState.ENTITY.toToken(entity.getId())));
            }
            table.setWidget(2, 1, desc);
        }
    });

    if (getMetadataRefs() != null) {
        table.setWidget(6, 1, Util.entityLinks(getMetadataRefs()));
    }

    FlowPanel primaryLocPanel = new FlowPanel();

    if (getPrimaryDataLocation() != null)
        primaryLocPanel.add(getPrimaryDataLocation().display());

    if (getAlternateIds() != null) {
        final JsArray<JsAlternateId> altIds = getAlternateIds();
        FlowPanel altIdPanel = new FlowPanel();
        final FlowPanel altLocPanel = new FlowPanel();

        for (int i = 0; i < altIds.length(); i++) {

            final String type = altIds.get(i).getTypeId();
            final String value = altIds.get(i).getIdValue();
            AsyncCallback<List<MediciInstance>> callback = new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {
                    for (MediciInstance instance : result) {
                        if (instance.getType().equalsIgnoreCase(type)) {
                            final String finalLink = instance.getUrl() + "/#dataset?id=" + value;
                            String altIdStr = getName();

                            Label altIdLabel = Util.label(altIdStr, "Hyperlink");
                            altIdLabel.addClickHandler(new ClickHandler() {
                                @Override
                                public void onClick(ClickEvent event) {
                                    Window.open(finalLink, "_blank", "");

                                }
                            });
                            altLocPanel.add(altIdLabel);
                            break;
                        }

                    }

                }

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

                }
            };
            MediciIngestPresenter.mediciService.getAcrInstances(callback);

        }
        table.setWidget(7, 1, altIdPanel);
        table.setWidget(8, 1, primaryLocPanel);
        table.setWidget(9, 1, altLocPanel);
    }

    //belongs to dataset
    panel.add(table);

    if (getFormats() != null && getFormats().length() > 0) {
        panel.add(Util.label("Formats", "SubSectionHeader"));
        JsFormat.display(panel, getFormats());
    }

    if (getMetadata() != null && getMetadata().length() > 0) {
        panel.add(Util.label("Additional metadata", "SubSectionHeader"));
        JsMetadata.display(panel, getMetadata());
    }

    if (getFixity() != null && getFixity().length() > 0) {
        panel.add(Util.label("Fixity", "SubSectionHeader"));
        JsFixity.display(panel, getFixity());
    }

    return panel;
}

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

License:Apache License

void addGetPubHandler() {

    ir.addChangeHandler(new ChangeHandler() {
        @Override//from  w  ww . ja va 2 s.c  o m
        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. ja  v  a2 s .com*/
        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.ActivityPresenter.java

License:Apache License

@Override
public void bind() {

    userService.checkSession(null, new AsyncCallback<UserSession>() {

        @Override//w w  w. ja  va2 s  .  c  o m
        public void onSuccess(UserSession result) {
            final String agentUrl = result.getRegistryId();
            String queryUrl = SeadApp.roUrl + "resource/agentGraph/" + agentUrl;

            JsonpRequestBuilder rb = new JsonpRequestBuilder();
            rb.setTimeout(100000);
            rb.requestObject(queryUrl, new AsyncCallback<JsProvGraph>() {

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

                @Override
                public void onSuccess(JsProvGraph agentGraph) {

                    JsProvDocument document = agentGraph.getDocument();

                    try {

                        String agentName = document.getAgentName(agentUrl);
                        String agentId = document.getAgentId(agentUrl);

                        JsArray<JsAssociatedWith> activities = document.getActivities(agentId);

                        JsArray<JsGenerated> generatedBys = document.getSafeGeneratedBys();

                        JsArray<JsProvEntity> entities = document.getSafeEntities();

                        TreeMap<Date, List<HTML>> htmlMap = new TreeMap<Date, List<HTML>>(
                                Collections.reverseOrder());

                        for (int i = 0; i < activities.length(); i++) {

                            JsAssociatedWith activity = activities.get(i);
                            String eventType = activity.getEventType();
                            String activityString;
                            if (agentName == null || agentName.contains("null"))
                                activityString = "You ";
                            else
                                activityString = "You (" + agentName + ")  ";

                            if (eventType == null)
                                eventType = "an action";
                            if (eventType.equalsIgnoreCase("Curation-Workflow"))
                                eventType = "Submission-Workflow";

                            activityString += " performed " + eventType + " on  ";

                            JsGenerated gen = null;
                            String activityId = activity.getActivityId();
                            if (activityId == null) {
                                //                             Window.alert("Continuing 1");
                                continue;
                            }
                            for (int k = 0; k < generatedBys.length(); k++) {
                                if (generatedBys.get(k) == null || generatedBys.get(k).getActivityId() == null)
                                    continue;
                                if (generatedBys.get(k).getActivityId().equalsIgnoreCase(activityId)) {
                                    gen = generatedBys.get(k);
                                    break;
                                }
                            }
                            if (gen == null) {
                                //                             Window.alert("Continuing 2");
                                continue;
                            }

                            String entityId = gen.getEntity();

                            JsProvEntity entity = null;
                            //                          Window.alert(entityId);
                            for (int k = 0; k < entities.length(); k++) {
                                if (entities.get(k).getEntityId().equalsIgnoreCase(entityId)) {
                                    entity = entities.get(k);
                                    //                               Window.alert("matched");
                                    break;
                                }
                            }
                            if (entity == null) {
                                //                             Window.alert("Continuing 3");
                                continue;
                            }

                            if (gen.getTimeString() == null || gen.getTimeString().length() < 2) {
                                continue;
                            }

                            String timeString = gen.getTimeString().substring(0,
                                    gen.getTimeString().length() - 2);
                            String entityLink = SeadState.ENTITY.toToken(entity.getEntityUrl());
                            if (activityString.contains("Curation") || activityString.contains("Submission"))
                                entityLink = SeadState.CURATIONOBJECT.toToken(entity.getEntityUrl());

                            HTML html = new HTML("<font color=\"gray\">" + timeString + "</font>"
                                    + "&nbsp;&nbsp;" + activityString + "<a href=\""
                                    + GWT.getModuleName().replace("sead_access",
                                            //                                      "Sead_access.html?gwt.codesvr=127.0.0.1:9997"
                                            "")
                                    + "#" + entityLink + "\"><font color=\"steelblue\">"
                                    + entity.getEntityTitle() + "</font></a>"
                            /*+"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""+ GWT.getModuleName().replace("sead_access",
                            //                                      "Sead_access.html?gwt.codesvr=127.0.0.1:9997"
                                                ""
                                                ) +
                                                            "#"+
                                                            SeadState.PROV.toToken(entity.getEntityUrl())+
                                                            "\"><font color=\"steelblue\">" +
                                                "(View RO provenance) " +
                                                            "</font></a>"*/, true);

                            html.setStyleName("ActivityEntry");

                            DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
                            List<HTML> htmlList;
                            if (htmlMap.containsKey(format.parse(timeString)))
                                htmlList = htmlMap.get(format.parse(timeString));
                            else
                                htmlList = new ArrayList<HTML>();

                            htmlList.add(html);
                            htmlMap.put(format.parse(timeString), htmlList);
                        }

                        display.getActivityContainer().clear();

                        //sort the htmlArray by Date

                        if (htmlMap.values().size() == 0 || htmlMap.size() == 0) {
                            HTML html = new HTML(
                                    "<font color=\"gray\"><center>" + "No Activity Yet" + "</center></font>",
                                    true);
                            html.setStyleName("ActivityEntry");
                            display.getActivityContainer().add(html);
                        } else
                            for (List<HTML> htmlList : htmlMap.values())
                                for (HTML html : htmlList)
                                    display.getActivityContainer().add(html);
                    } catch (Exception e) {
                        display.getActivityContainer().clear();
                        HTML html = new HTML(
                                "<font color=\"gray\"><center>" + "No Activity Yet" + "</center></font>", true);
                        html.setStyleName("ActivityEntry");
                        display.getActivityContainer().add(html);
                    }
                }
            });
        }

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

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

License:Apache License

@Override
public void bind() {
    final String entityurl = this.display.getEntityId();
    final Panel content = this.display.getContentPanel();
    String query = Search.createLiteralQuery("id", entityurl);
    String searchUrl = searchURL(query, 0, true, Constants.MAX_SEARCH_RESULTS);
    JsonpRequestBuilder rb = new JsonpRequestBuilder();
    rb.requestObject(searchUrl, new AsyncCallback<JsSearchResult>() {

        public void onFailure(Throwable caught) {
            //                reportInternalError("Viewing entity", caught);
            new ErrorPopupPanel("Error getting entity: " + caught.getMessage()).show();
        }//from w  w w . j  av  a 2s.com

        public void onSuccess(JsSearchResult result) {
            JsMatch m = result.matches().get(0);
            if (m.getEntityType().equalsIgnoreCase("file")) {
                content.add(((org.dataconservancy.dcs.access.client.model.JsFile) m.getEntity()).display());
            }
            if (m.getEntityType().equalsIgnoreCase("deliverableunit")) {
                content.add(((org.dataconservancy.dcs.access.client.model.JsDeliverableUnit) m.getEntity())
                        .display(null, true));
            }

        }
    });
}

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

License:Apache License

@Override
public void bind() {

    userService.checkSession(null, new AsyncCallback<UserSession>() {

        @Override//from   w  w w.j  a  v a  2s  .c o m
        public void onSuccess(UserSession result) {
            final String entityUrl = display.getEntityId();
            //                  "http://seadva-test.d2i.indiana.edu:5667/sead-wf/entity/192410";
            //"http%3A%2F%2Fseadva-test.d2i.indiana.edu%3A5667%2Fsead-wf%2Fentity%2F189712";
            //                  "agent:f8477e5d-922f-41fb-9496-ba39ff218264";
            //                  "agent:7dd76828-d615-4c76-9f95-427a1dcdf5f4";
            //                  "agent:e4b2ea67-e775-498d-af9e-fcb1a0235f01";
            //                  "agent:4f1e3f38-6fc4-47f8-8e15-4358f80b0986v";
            //             "agent:fb9c6de1-322b-467b-8a88-f6475c6fa0f1";
            String queryUrl = SeadApp.roUrl + "resource/entityGraph/"
                    + entityUrl.replace(":", "%3A").replace("/", "%2F");
            //            queryUrl = "http://seadva-test.d2i.indiana.edu/ro/resource/agentGraph/agent:fb9c6de1-322b-467b-8a88-f6475c6fa0f1";

            JsonpRequestBuilder rb = new JsonpRequestBuilder();
            rb.setTimeout(100000);
            rb.requestObject(queryUrl, new AsyncCallback<JsProvGraph>() {

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

                @Override
                public void onSuccess(JsProvGraph entityGraph) {

                    //Get all activities related to this entity
                    //Get all entities related to this entity
                    //Get all activities related to these entities as well
                    JsProvDocument document = entityGraph.getDocument();

                    JsProvEntity entity = document.getEntity(
                            //"http://seadva-test.d2i.indiana.edu:5667/sead-wf/entity/189712"
                            entityUrl);

                    //  Window.alert(entityId);

                    UtilPopulate populate = new UtilPopulate();
                    populate.populateEntities(entity.getEntityId(), document);
                    JsArrayString entitiesStr = populate.getEArrayString();

                    TreeMap<Date, HTML> htmlMap = new TreeMap<Date, HTML>(Collections.reverseOrder());
                    //  JsArray<JsProvEntity> entities = document.getSafeEntities();
                    String relations = "";
                    for (int j = 0; j < entitiesStr.length(); j++) {
                        String entityLink = "";
                        JsArray<JsGenerated> generatedBys = document
                                .getGeneratedBysByEntity(entitiesStr.get(j));
                        //  Window.alert(generatedBys.length()+" generatedBys");
                        JsArray<JsAssociatedWith> activities = document.getSafeActivities();
                        //  Window.alert(activities.length()+" activities");

                        for (int i = 0; i < generatedBys.length(); i++) {

                            JsGenerated gen = generatedBys.get(i);
                            String activityId = gen.getActivityId();

                            JsAssociatedWith activity = null;
                            //  Window.alert("activityId = " +activityId);

                            for (int k = 0; k < activities.length(); k++) {
                                if (activities.get(k) == null || activities.get(k).getActivityId() == null)
                                    continue;
                                if (activities.get(k).getActivityId().equalsIgnoreCase(activityId)) {
                                    activity = activities.get(k);
                                    break;
                                }
                            }

                            if (activity == null) {
                                Window.alert("Continuing 3");
                                continue;
                            }

                            if (gen.getTimeString() == null || gen.getTimeString().length() < 2) {
                                Window.alert("Continuing 4");
                                continue;
                            }

                            String timeString = gen.getTimeString().substring(0,
                                    gen.getTimeString().length() - 2);

                            String activityString = activity.getEventType();

                            if (activityString.contains("Curation-Workflow"))
                                activityString = "Submission-Workflow";
                            entity = document.getEntityById(entitiesStr.get(j));

                            entityLink = "<a href=\"" + GWT.getModuleName().replace("sead_access",
                                    //                                "Sead_access.html?gwt.codesvr=127.0.0.1:9997"
                                    "") + "#" + SeadState.CURATIONOBJECT.toToken(entity.getEntityUrl())
                                    + "\"><font color=\"steelblue\">" + entity.getEntityTitle() + "</font></a>";

                            HTML html = new HTML(
                                    "<font color=\"gray\">" + timeString + "</font>" + "&nbsp;&nbsp;"
                                            + activityString + "&nbsp; was performed on &nbsp;" + entityLink,
                                    true);

                            html.setStyleName("ActivityEntry");

                            DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
                            htmlMap.put(format.parse(timeString), html);
                        }
                        if (j > 0)
                            relations += ", ";
                        relations += entityLink + "&nbsp;&nbsp;";
                    }

                    //sort the htmlArray by Date

                    if (htmlMap.values().size() == 0 || htmlMap.size() == 0) {
                        HTML html = new HTML(
                                "<font color=\"gray\"><center>" + "No Activity Yet" + "</center></font>", true);
                        html.setStyleName("ActivityEntry");
                        display.getActivityContainer().add(html);
                    } else
                        for (HTML html : htmlMap.values())
                            display.getActivityContainer().add(html);

                    HTML html = new HTML("<font color=\"gray\">" + "Relations" + "</font>", true);
                    html.setStyleName("ActivityEntry");
                    display.getActivityContainer().add(html);
                    html = new HTML(relations + "&nbsp;&nbsp; represent lineage stages of a single RO.", true);
                    display.getActivityContainer().add(html);

                }

            });
        }

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

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

License:Apache License

private void searchFacet(final Search.UserField[] userfields, final String[] userqueries, final int offset,
        final String[] facetField, final String[] facetValue) {
    JsonpRequestBuilder rb = new JsonpRequestBuilder();
    String query = Search.createQuery(userfields, userqueries, facetField, facetValue);
    String facets = "";

    Iterator it = constants.facets.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        facets += pairs.getKey() + ",";
    }//  ww w .j  a v  a 2  s  .  c o  m
    facets = facets.substring(0, facets.length() - 1);

    String searchurl = searchURL(query, 0, false, 1, "_facet.field", facets);
    rb.setTimeout(100000);
    rb.requestObject(searchurl, new AsyncCallback<JsModel>() {

        public void onFailure(Throwable caught) {

            Util.reportInternalError("Viewing entity", caught);
        }

        public void onSuccess(JsModel result) {

            facetPanel.clear();
            Map<String, List<String>> facetsList = ((JsFacet) result).getFacets();

            displayFacets(new SearchInput(userfields, userqueries, offset, facetField, facetValue), facetsList);

        }
    });
}