use of javax.json.JsonArrayBuilder in project dataverse by IQSS.
the class UtilIT method addToGroup.
static Response addToGroup(String dataverseThatGroupBelongsIn, String groupIdentifier, List<String> roleAssigneesToAdd, String apiToken) {
JsonArrayBuilder groupBuilder = Json.createArrayBuilder();
roleAssigneesToAdd.stream().forEach((string) -> {
groupBuilder.add(string);
});
Response response = given().header(API_TOKEN_HTTP_HEADER, apiToken).body(groupBuilder.build().toString()).contentType(ContentType.JSON).post("/api/dataverses/" + dataverseThatGroupBelongsIn + "/groups/" + groupIdentifier + "/roleAssignees");
return response;
}
use of javax.json.JsonArrayBuilder in project dataverse by IQSS.
the class Pager method asJsonObjectBuilderCore.
private JsonObjectBuilder asJsonObjectBuilderCore(boolean useCardTerms) {
JsonObjectBuilder jsonPageInfo = Json.createObjectBuilder();
jsonPageInfo.add("isNecessary", this.isPagerNecessary()).add("numResults", this.numResults).add("numResultsString", this.addCommasToNumber(numResults)).add("docsPerPage", this.docsPerPage).add("selectedPageNumber", this.selectedPageNumber).add("pageCount", this.pageCount).add("hasPreviousPageNumber", this.hasPreviousPageNumber()).add("previousPageNumber", this.previousPageNumber).add("hasNextPageNumber", this.hasNextPageNumber()).add("nextPageNumber", this.nextPageNumber);
if (useCardTerms) {
jsonPageInfo.add("startCardNumber", this.startCardNumber).add("endCardNumber", this.endCardNumber).add("startCardNumberString", this.addCommasToNumber(this.startCardNumber)).add("endCardNumberString", this.addCommasToNumber(this.endCardNumber)).add("remainingCards", this.remainingCards);
} else {
jsonPageInfo.add("startResultNumber", this.startCardNumber).add("endResultNumber", this.endCardNumber).add("startResultNumberString", this.addCommasToNumber(this.startCardNumber)).add("endResultNumberString", this.addCommasToNumber(this.endCardNumber)).add("remainingResults", this.remainingCards);
}
jsonPageInfo.add("numberNextResults", this.numberNextResults);
// --------------------
// pageNumberList
// --------------------
JsonArrayBuilder jsonPageNumberArrayBuilder = Json.createArrayBuilder();
if (this.pageNumberList != null) {
for (int pg : this.pageNumberList) {
jsonPageNumberArrayBuilder.add(pg);
}
jsonPageInfo.add("pageNumberList", jsonPageNumberArrayBuilder);
}
return jsonPageInfo;
}
use of javax.json.JsonArrayBuilder in project dataverse by IQSS.
the class IndexAllServiceBean method indexAllOrSubsetPreview.
public JsonObjectBuilder indexAllOrSubsetPreview(long numPartitions, long partitionId, boolean skipIndexed) {
JsonObjectBuilder response = Json.createObjectBuilder();
JsonObjectBuilder previewOfWorkload = Json.createObjectBuilder();
JsonObjectBuilder dvContainerIds = Json.createObjectBuilder();
List<Long> dataverseIds = dataverseService.findDataverseIdsForIndexing(skipIndexed);
JsonArrayBuilder dataverseIdsJson = Json.createArrayBuilder();
// List<Dataverse> dataverses = dataverseService.findAllOrSubset(numPartitions, partitionId, skipIndexed);
for (Long id : dataverseIds) {
dataverseIdsJson.add(id);
}
List<Long> datasetIds = datasetService.findAllOrSubset(numPartitions, partitionId, skipIndexed);
JsonArrayBuilder datasetIdsJson = Json.createArrayBuilder();
for (Long id : datasetIds) {
datasetIdsJson.add(id);
}
dvContainerIds.add("dataverses", dataverseIdsJson);
dvContainerIds.add("datasets", datasetIdsJson);
previewOfWorkload.add("dvContainerIds", dvContainerIds);
previewOfWorkload.add("dataverseCount", dataverseIds.size());
previewOfWorkload.add("datasetCount", datasetIds.size());
previewOfWorkload.add("partitionId", partitionId);
response.add("previewOfPartitionWorkload", previewOfWorkload);
return response;
}
use of javax.json.JsonArrayBuilder in project dataverse by IQSS.
the class RepositoryStorageAbstractionLayerUtil method getSitesFromDb.
/**
* The reason this in JSON is that it probably makes sense to someday query
* RSAL or some other "big data" component live for a list of remotes sites
* to which a particular dataset is replicated to.
*/
public static JsonArray getSitesFromDb(String replicationSitesInDB) {
JsonArrayBuilder arraybuilder = Json.createArrayBuilder();
if (replicationSitesInDB == null || replicationSitesInDB.isEmpty()) {
return arraybuilder.build();
}
// Right now we have all the data right in the database setting but we should probably query RSAL to get the list.
String[] sites = replicationSitesInDB.split(",");
for (String site : sites) {
String[] parts = site.split(":");
arraybuilder.add(Json.createObjectBuilder().add("fqdn", parts[0]).add("name", parts[1]).add("country", parts[2]));
}
return arraybuilder.build();
}
use of javax.json.JsonArrayBuilder in project dataverse by IQSS.
the class Dataverses method listMetadataBlocks.
@GET
@Path("{identifier}/metadatablocks")
public Response listMetadataBlocks(@PathParam("identifier") String dvIdtf) {
try {
JsonArrayBuilder arr = Json.createArrayBuilder();
final List<MetadataBlock> blocks = execCommand(new ListMetadataBlocksCommand(createDataverseRequest(findUserOrDie()), findDataverseOrDie(dvIdtf)));
for (MetadataBlock mdb : blocks) {
arr.add(brief.json(mdb));
}
return allowCors(ok(arr));
} catch (WrappedResponse we) {
return we.getResponse();
}
}
Aggregations