Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6781 my data render #6802

Merged
merged 4 commits into from Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Expand Up @@ -424,6 +424,15 @@ public DatasetVersion getReleasedVersion() {
}
return null;
}

public DatasetVersion getVersionFromId(Long datasetVersionId) {
for (DatasetVersion version : this.getVersions()) {
if (datasetVersionId == version.getId().longValue()) {
return version;
}
}
return null;
}

public List<DataFileCategory> getCategories() {
return dataFileCategories;
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/edu/harvard/iq/dataverse/search/SolrSearchResult.java
Expand Up @@ -560,17 +560,12 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
}

if (this.entity == null) {

} else {
if (this.entity.isInstanceofDataset()) {
nullSafeJsonBuilder.add("storageIdentifier", this.entity.getStorageIdentifier());
Dataset ds = (Dataset) this.entity;
DatasetVersion dv;
if (this.isDraftState()) {
dv = ds.getLatestVersion();
} else {
dv = ds.getReleasedVersion();
}
DatasetVersion dv = ds.getVersionFromId(this.datasetVersionId);

if (!dv.getKeywords().isEmpty()) {
JsonArrayBuilder keyWords = Json.createArrayBuilder();
Expand All @@ -579,6 +574,7 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
}
nullSafeJsonBuilder.add("keywords", keyWords);
}

JsonArrayBuilder subjects = Json.createArrayBuilder();
for (String subject : dv.getDatasetSubjects()) {
subjects.add(subject);
Expand All @@ -587,13 +583,14 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
nullSafeJsonBuilder.add("fileCount", dv.getFileMetadatas().size());
nullSafeJsonBuilder.add("versionId", dv.getId());
nullSafeJsonBuilder.add("versionState", dv.getVersionState().toString());
if(this.isPublishedState()){
if (this.isPublishedState()) {
nullSafeJsonBuilder.add("majorVersion", dv.getVersionNumber());
nullSafeJsonBuilder.add("minorVersion", dv.getMinorVersionNumber());
}

nullSafeJsonBuilder.add("createdAt", ds.getCreateDate());
nullSafeJsonBuilder.add("updatedAt", ds.getModificationTime());

if (!dv.getDatasetContacts().isEmpty()) {
JsonArrayBuilder contacts = Json.createArrayBuilder();
NullSafeJsonBuilder nullSafeJsonBuilderInner = jsonObjectBuilder();
Expand All @@ -604,7 +601,7 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
}
nullSafeJsonBuilder.add("contacts", contacts);
}
if(!dv.getRelatedPublications().isEmpty()){
if (!dv.getRelatedPublications().isEmpty()) {
JsonArrayBuilder relPub = Json.createArrayBuilder();
NullSafeJsonBuilder inner = jsonObjectBuilder();
for (DatasetRelPublication dsRelPub : dv.getRelatedPublications()) {
Expand All @@ -613,24 +610,24 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
inner.add("url", dsRelPub.getUrl());
relPub.add(inner);
}
nullSafeJsonBuilder.add("publications", relPub);
nullSafeJsonBuilder.add("publications", relPub);
}

if (!dv.getDatasetProducers().isEmpty()) {
JsonArrayBuilder producers = Json.createArrayBuilder();
for (String[] producer : dv.getDatasetProducers()) {
producers.add(producer[0]);
}
nullSafeJsonBuilder.add("producers", producers);
}
if (!dv.getRelatedMaterial().isEmpty()) {
if (!dv.getRelatedMaterial().isEmpty()) {
JsonArrayBuilder relatedMaterials = Json.createArrayBuilder();
for (String relatedMaterial : dv.getRelatedMaterial()) {
relatedMaterials.add(relatedMaterial);
}
nullSafeJsonBuilder.add("relatedMaterial", relatedMaterials);
}

if (!dv.getGeographicCoverage().isEmpty()) {
JsonArrayBuilder geoCov = Json.createArrayBuilder();
NullSafeJsonBuilder inner = jsonObjectBuilder();
Expand All @@ -642,7 +639,7 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
geoCov.add(inner);
}
nullSafeJsonBuilder.add("geographicCoverage", geoCov);
}
}
if (!dv.getDataSource().isEmpty()) {
JsonArrayBuilder dataSources = Json.createArrayBuilder();
for (String dsource : dv.getDataSource()) {
Expand All @@ -652,7 +649,7 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
}
}
}

if (showApiUrls) {
/**
* @todo We should probably have a metadata_url or api_url concept
Expand Down