List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder requestObject
public <T extends JavaScriptObject> JsonpRequest<T> requestObject(String url, AsyncCallback<T> callback)
From source file:net.cbtltd.client.widget.text.TextWidget.java
private void getJsonpText() { if (productField.noValue()) { return;//w ww . j a va 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/*www . j a va2 s . c o 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);/*from w w w.j a v a 2 s . c om*/ 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.ActivityPresenter.java
License:Apache License
@Override public void bind() { userService.checkSession(null, new AsyncCallback<UserSession>() { @Override//from w ww. jav a2s .com 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>" + " " + 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>" /*+" <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 ww. j a v a 2s . co m*/ 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//ww w .jav a2 s . com 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>" + " " + activityString + " was performed on " + 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 + " "; } //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 + " 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() + ","; }// w ww .j ava2 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); } }); }
From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java
License:Apache License
private void getQueryResults(final String searchUrl, final String facets, final SearchInput searchInput, final boolean isAdvanced) { JsonpRequestBuilder rb = new JsonpRequestBuilder(); rb.setTimeout(100000);// w w w. ja v a 2 s .com rb.requestObject(searchUrl, new AsyncCallback<JsModel>() { public void onFailure(Throwable caught) { Util.reportInternalError("Searching", caught); } public void onSuccess(JsModel result) { displaySearchResults(searchUrl, (JsSearchResult) result, facets, searchInput, isAdvanced); Map<String, List<String>> facetsList = //JsFacet.getFacets(); ((JsFacet) result).getFacets(); displayFacets(searchInput, facetsList); } }); }
From source file:org.dataconservancy.dcs.access.client.presenter.RelationsPresenter.java
License:Apache License
static void collectSearchResults(final String query, final int offset, final JsDcp dcp, final AsyncCallback<JsDcp> topcb) { String searchurl = searchURL(query, offset, false, 50); JsonpRequestBuilder rb = new JsonpRequestBuilder(); rb.requestObject(searchurl, new AsyncCallback<JsSearchResult>() { public void onFailure(Throwable caught) { topcb.onFailure(caught);/*from w w w . jav a 2s. com*/ } public void onSuccess(JsSearchResult result) { for (int i = 0; i < result.matches().length(); i++) { Util.add(dcp, result.matches().get(i)); } int nextoffset = offset + result.matches().length(); if (nextoffset == result.total()) { topcb.onSuccess(dcp); } else { collectSearchResults(query, nextoffset, dcp, topcb); } } }); }
From source file:org.dataconservancy.dcs.access.client.Util.java
License:Apache License
public static Widget metadataLinks(JsArrayString ids) { if (ids.length() == 0) { return new Label(); }//from ww w .j a v a 2 s. c om MenuBar top = new MenuBar(); top.setWidth("15ex"); top.setAnimationEnabled(true); final MenuBar refs = new MenuBar(true); top.addItem("View Metadata (" + ids.length() + ")", refs); for (int i = 0; i < ids.length(); i++) { final String id = ids.get(i); JsonpRequestBuilder rb = new JsonpRequestBuilder(); String query = Search.createLiteralQuery("id", id); String searchUrl = Search.searchURL(query, 0, true, Constants.MAX_SEARCH_RESULTS); rb.requestObject(searchUrl, new AsyncCallback<JsSearchResult>() { public void onFailure(Throwable caught) { reportInternalError("Viewing entity", caught); } public void onSuccess(final JsSearchResult result) { final JsMatch m = result.matches().get(0); if (m.getEntityType().equalsIgnoreCase("file")) { final JsArray<JsFormat> formats = ((JsFile) m.getEntity()).getFormats(); if (formats.length() > 0) { refs.addItem(formats.get(0).getFormat(), new Command() { public void execute() { String fileSource = ((JsFile) m.getEntity()).getPrimaryDataLocation() .getLocation(); if (!(fileSource.startsWith("http://") || fileSource.startsWith("https://"))) fileSource = ((JsFile) m.getEntity()).getSource(); MetadataPopupPanel statusPopupPanel = new MetadataPopupPanel(fileSource, formats.get(0).getFormat()); statusPopupPanel.show(); } }); } } } }); } return top; }