Skip to content

Commit

Permalink
Merge branch 'develop' into 10220-thumbnail-size-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jan 25, 2024
2 parents 411f790 + e9215e3 commit 108701c
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 151 deletions.
1 change: 0 additions & 1 deletion doc/release-notes/9686-move-harvesting-client-id.md

This file was deleted.

2 changes: 2 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ services:
volumes:
- ./docker-dev-volumes/app/data:/dv
- ./docker-dev-volumes/app/secrets:/secrets
# Uncomment to map the glassfish applications folder so that we can update webapp resources using scripts/intellij/cpwebapp.sh
# - ./docker-dev-volumes/glassfish/applications:/opt/payara/appserver/glassfish/domains/domain1/applications
# Uncomment for changes to xhtml to be deployed immediately (if supported your IDE or toolchain).
# Replace 6.0 with the current version.
# - ./target/dataverse-6.0:/opt/payara/deployments/dataverse
Expand Down
33 changes: 33 additions & 0 deletions scripts/intellij/cpwebapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
#
# cpwebapp <project dir> <file in webapp>
#
# Usage:
#
# Add a File watcher by importing watchers.xml into IntelliJ IDEA, and let it do the copying whenever you save a
# file under webapp.
#
# https://www.jetbrains.com/help/idea/settings-tools-file-watchers.html
#
# Alternatively, you can add an External tool and trigger via menu or shortcut to do the copying manually:
#
# https://www.jetbrains.com/help/idea/configuring-third-party-tools.html
#

PROJECT_DIR=$1
FILE_TO_COPY=$2
RELATIVE_PATH="${FILE_TO_COPY#$PROJECT_DIR/}"

# Check if RELATIVE_PATH starts with 'src/main/webapp', otherwise ignore
if [[ $RELATIVE_PATH == src/main/webapp* ]]; then
# Get current version. Any other way to do this? A simple VERSION file would help.
VERSION=`perl -ne 'print $1 if /<revision>(.*?)<\/revision>/' ./modules/dataverse-parent/pom.xml`
RELATIVE_PATH_WITHOUT_WEBAPP="${RELATIVE_PATH#src/main/webapp/}"
TARGET_DIR=./docker-dev-volumes/glassfish/applications/dataverse-$VERSION
TARGET_PATH="${TARGET_DIR}/${RELATIVE_PATH_WITHOUT_WEBAPP}"

mkdir -p "$(dirname "$TARGET_PATH")"
cp "$FILE_TO_COPY" "$TARGET_PATH"

echo "File $FILE_TO_COPY copied to $TARGET_PATH"
fi
22 changes: 22 additions & 0 deletions scripts/intellij/watchers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<TaskOptions>
<TaskOptions>
<option name="arguments" value="$ProjectFileDir$ $FilePath$" />
<option name="checkSyntaxErrors" value="false" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="*" />
<option name="immediateSync" value="false" />
<option name="name" value="Dataverse webapp file copy on save" />
<option name="output" value="" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="$ProjectFileDir$/scripts/intellij/cpwebapp.sh" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Current File" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="$ProjectFileDir$" />
<envs />
</TaskOptions>
</TaskOptions>
14 changes: 13 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,21 @@ public void setDatasetExternalCitations(List<DatasetExternalCitations> datasetEx
this.datasetExternalCitations = datasetExternalCitations;
}

@ManyToOne
@JoinColumn(name="harvestingClient_id")
private HarvestingClient harvestedFrom;


public HarvestingClient getHarvestedFrom() {
return this.harvestedFrom;
}

public void setHarvestedFrom(HarvestingClient harvestingClientConfig) {
this.harvestedFrom = harvestingClientConfig;
}

public boolean isHarvested() {
return this.harvestedFrom != null;
}

private String harvestIdentifier;

Expand Down
48 changes: 48 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,54 @@ public Long getDatasetVersionCardImage(Long versionId, User user) {
return null;
}

/**
* Used to identify and properly display Harvested objects on the dataverse page.
*
* @param datasetIds
* @return
*/
public Map<Long, String> getArchiveDescriptionsForHarvestedDatasets(Set<Long> datasetIds){
if (datasetIds == null || datasetIds.size() < 1) {
return null;
}

String datasetIdStr = StringUtils.join(datasetIds, ", ");

String qstr = "SELECT d.id, h.archiveDescription FROM harvestingClient h, dataset d WHERE d.harvestingClient_id = h.id AND d.id IN (" + datasetIdStr + ")";
List<Object[]> searchResults;

try {
searchResults = em.createNativeQuery(qstr).getResultList();
} catch (Exception ex) {
searchResults = null;
}

if (searchResults == null) {
return null;
}

Map<Long, String> ret = new HashMap<>();

for (Object[] result : searchResults) {
Long dsId;
if (result[0] != null) {
try {
dsId = (Long)result[0];
} catch (Exception ex) {
dsId = null;
}
if (dsId == null) {
continue;
}

ret.put(dsId, (String)result[1]);
}
}

return ret;
}



public boolean isDatasetCardImageAvailable(DatasetVersion datasetVersion, User user) {
if (datasetVersion == null) {
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/edu/harvard/iq/dataverse/DvObject.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.harvest.client.HarvestingClient;
import edu.harvard.iq.dataverse.pidproviders.PidUtil;
import edu.harvard.iq.dataverse.storageuse.StorageQuota;

Expand Down Expand Up @@ -372,22 +371,6 @@ public GlobalId getGlobalId() {
return globalId;
}

@ManyToOne
@JoinColumn(name="harvestingClient_id")
private HarvestingClient harvestedFrom;

public HarvestingClient getHarvestedFrom() {
return this.harvestedFrom;
}

public void setHarvestedFrom(HarvestingClient harvestingClientConfig) {
this.harvestedFrom = harvestingClientConfig;
}

public boolean isHarvested() {
return this.harvestedFrom != null;
}

public abstract <T> T accept(Visitor<T> v);

@Override
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,54 +383,6 @@ public Map<Long, String> getObjectPathsByIds(Set<Long> objectIds){
return ret;
}

/**
* Used to identify and properly display Harvested objects on the dataverse page.
*
* @param dvObjectIds
* @return
*/
public Map<Long, String> getArchiveDescriptionsForHarvestedDvObjects(Set<Long> dvObjectIds){

if (dvObjectIds == null || dvObjectIds.size() < 1) {
return null;
}

String dvObjectIsString = StringUtils.join(dvObjectIds, ", ");
String qstr = "SELECT d.id, h.archiveDescription FROM harvestingClient h, DvObject d WHERE d.harvestingClient_id = h.id AND d.id IN (" + dvObjectIsString + ")";
List<Object[]> searchResults;

try {
searchResults = em.createNativeQuery(qstr).getResultList();
} catch (Exception ex) {
searchResults = null;
}

if (searchResults == null) {
return null;
}

Map<Long, String> ret = new HashMap<>();

for (Object[] result : searchResults) {
Long dvObjId;
if (result[0] != null) {
try {
Integer castResult = (Integer) result[0];
dvObjId = Long.valueOf(castResult);
} catch (Exception ex) {
dvObjId = null;
}
if (dvObjId == null) {
continue;
}
ret.put(dvObjId, (String)result[1]);
}
}

return ret;
}


public String generateNewIdentifierByStoredProcedure() {
StoredProcedureQuery query = this.em.createNamedStoredProcedureQuery("Dataset.generateIdentifierFromStoredProcedure");
query.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,6 @@ public Dataset doImportHarvestedDataset(DataverseRequest dataverseRequest, Harve

Dataset existingDs = datasetService.findByGlobalId(ds.getGlobalId().asString());

//adding the harvesting client id to harvested files #9686
for (DataFile df : ds.getFiles()){
df.setHarvestedFrom(harvestingClient);
}

if (existingDs != null) {
// If this dataset already exists IN ANOTHER DATAVERSE
// we are just going to skip it!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ public void recordHarvestJobStatus(Long hcId, Date finishTime, int harvestedCoun

public Long getNumberOfHarvestedDatasetsByAllClients() {
try {
return (Long) em.createNativeQuery("SELECT count(d.id) FROM dvobject d "
+ " WHERE d.harvestingclient_id IS NOT NULL and d.dtype = 'Dataset'").getSingleResult();
return (Long) em.createNativeQuery("SELECT count(d.id) FROM dataset d "
+ " WHERE d.harvestingclient_id IS NOT NULL").getSingleResult();

} catch (Exception ex) {
logger.info("Warning: exception looking up the total number of harvested datasets: " + ex.getMessage());
Expand Down
Loading

0 comments on commit 108701c

Please sign in to comment.