Skip to content

Commit

Permalink
Use 2nd-generation API for get_all_users call
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuhn committed Sep 25, 2024
1 parent da6a015 commit 72c4024
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ private QueryApiAccess() {} // no instances allowed
load("RAvL7pe2ppsfq4mVWTdJjssYGsjrmliNd_sZO2ytLvg1Y/get-most-used-templates-last30d");
load("RANn4Mu8r8bqJA9KJMGXTQAEGAEvtNKGFsuhRIC6BRIOo/get-latest-nanopubs-by-type");
load("RAiRsB2YywxjsBMkVRTREJBooXhf2ZOHoUs5lxciEl37I/get-latest-version-of-np");
load("RA5i5-o05hg5KlZocCvKlQAV_CcJn3ToW3AGK7TbrCkVM/get-all-user-intros");
}

private static void load(String queryId) {
queryIds.put(queryId.substring(46), queryId);
}

public static ApiResponse get(String queryName) {
return get(queryName, new HashMap<>());
}

public static ApiResponse get(String queryName, Map<String,String> params) {
if (!queryIds.containsKey(queryName)) {
throw new IllegalArgumentException("Query name not known: " + queryName);
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/knowledgepixels/nanodash/UserData.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,8 @@ public void handleNanopub(Nanopub np) {
}

// Get latest introductions for all users, including unapproved ones:
try {
for (ApiResponseEntry entry : ApiAccess.getAll("get_all_users", null).getData()) {
register(entry.get("intronp"), false);
}
} catch (IOException|CsvValidationException ex) {
ex.printStackTrace();
for (ApiResponseEntry entry : QueryApiAccess.get("get-all-user-intros").getData()) {
register(entry.get("intronp"), false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.nanopub.Nanopub;
import org.nanopub.extra.services.ApiAccess;
import org.nanopub.extra.services.ApiResponse;
import org.nanopub.extra.services.ApiResponseEntry;

Expand Down Expand Up @@ -119,15 +118,8 @@ public NanopubPage(final PageParameters parameters) {
add(new WebMarkupContainer("technical-editor-actions").setVisible(false));
}

HashMap<String,String> newerVersionParams = new HashMap<>();
newerVersionParams.put("np", np.getUri().stringValue());
String latest = null;
try {
ApiResponse newerVersionResponse = ApiAccess.getAll(ApiAccess.MAIN_GRLC_API_GENERIC_URL, "get_latest_version", newerVersionParams);
if (newerVersionResponse.getData().size() == 1) latest = newerVersionResponse.getData().get(0).get("latest");
} catch (Exception ex) {
ex.printStackTrace();
}
String latest = QueryApiAccess.getLatestVersionId(np.getUri().stringValue());

WebMarkupContainer newerVersionText = new WebMarkupContainer("newer-version");
if (latest == null || latest.equals(np.getUri().stringValue())) {
newerVersionText.add(new Label("newer-version-link"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import org.eclipse.rdf4j.model.vocabulary.RDFS;
import org.nanopub.Nanopub;
import org.nanopub.SimpleCreatorPattern;
import org.nanopub.extra.services.ApiAccess;

import com.knowledgepixels.nanodash.NanodashPreferences;
import com.knowledgepixels.nanodash.QueryApiAccess;
import com.knowledgepixels.nanodash.User;
import com.knowledgepixels.nanodash.Utils;

Expand Down

0 comments on commit 72c4024

Please sign in to comment.