Skip to content

Commit

Permalink
Merge pull request IQSS#3408 from IQSS/file-metadata-provenance-2295
Browse files Browse the repository at this point in the history
File metadata provenance 2295
  • Loading branch information
kcondon authored Nov 23, 2016
2 parents 3a89fc8 + 25d0699 commit 17f0eae
Show file tree
Hide file tree
Showing 32 changed files with 3,628 additions and 2,068 deletions.
12 changes: 10 additions & 2 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ dataset.cite.title.released=DRAFT VERSION will be replaced in the citation with
dataset.cite.title.draft=DRAFT VERSION will be replaced in the citation with the selected version once the dataset has been published.
dataset.cite.title.deassessioned=DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available.
dataset.cite.standards.tip=Learn about <a href="http://best-practices.dataverse.org/data-citation/" title="Get Recognition: Data Citation - Dataverse Best Practices" target="_blank">Data Citation Standards</a>.
dataset.cite.downloadBtn=Cite Data
dataset.cite.downloadBtn=Cite Dataset
dataset.cite.downloadBtn.xml=EndNote XML
dataset.cite.downloadBtn.ris=RIS
dataset.cite.downloadBtn.bib=BibTeX
Expand Down Expand Up @@ -1201,6 +1201,7 @@ file.spss-porExtraLabels=Variable Labels
file.spss-porExtraLabels.title=Upload an additional text file with extra variable labels.
file.spss-porExtraLabels.selectToAddBtn=Select File to Add
file.ingestFailed=Tabular Data Ingest Failed
file.explore.twoRavens=TwoRavens
file.mapData=Map Data
file.mapData.viewMap=WorldMap
file.mapData.unpublished.header=Data Not Published
Expand All @@ -1218,7 +1219,7 @@ file.requestAccess.dialog.msg=You need to <a href="/loginpage.xhtml{0}" target="
file.requestAccess.dialog.msg.signup=You need to <a href="/dataverseuser.xhtml{0}&amp;editMode=CREATE" target="{1}" title="Sign Up for a Dataverse Account">Sign Up</a> or <a href="/loginpage.xhtml{0}" target="{1}" title="Log into your Dataverse Account">Log In</a> to request access to this file.
file.accessRequested=Access Requested

file.ingestInproGress=Ingest in progress...
file.ingestInProgress=Ingest in progress...

file.dataFilesTab.metadata.header=Metadata
file.dataFilesTab.metadata.addBtn=Add + Edit Metadata
Expand Down Expand Up @@ -1390,18 +1391,25 @@ dataset.widgets.advanced.success.message=Successfully updated your Personal Webs
dataset.widgets.advanced.failure.message=The dataverse Personal Website URL has not been updated.

# file.xhtml
file.share.fileShare=Share File
file.share.fileShare.tip=Share this file on your favorite social media networks.
file.share.fileShare.shareText=View this file.
file.title.label=Title
file.citation.label=Citation
file.cite.downloadBtn=Cite Data File
file.general.metadata.label=General Metadata
file.description.label=Description
file.tags.label=Tags
file.lastupdated.label=Last Updated

file.metadataTab.fileMetadata.header=File Metadata
file.metadataTab.fileMetadata.persistentid.label=Data File Persistent ID
file.metadataTab.fileMetadata.unf.label=UNF
file.metadataTab.fileMetadata.size.label=Size
file.metadataTab.fileMetadata.type.label=Type
file.metadataTab.fileMetadata.description.label=Description
file.metadataTab.fileMetadata.publicationDate.label=Publication Date
file.metadataTab.fileMetadata.depositDate.label=Deposit Date
file.metadataTab.fitsMetadata.header=FITS Metadata
file.metadataTab.provenance.header=File Provenance
file.metadataTab.provenance.body=File Provenance information coming in a later release...
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Bundle_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ file.downloadBtn.format.original=\u539f\u59cb\u6587\u4ef6\u683c\u5f0f\uff08{0}\u
file.downloadBtn.format.rdata=RDATA\u683c\u5f0f
file.downloadBtn.format.var=\u53ef\u53d8\u5143
file.downloadBtn.format.citation=\u6570\u636e\u6587\u4ef6\u5f15\u7528
file.ingestInproGress=\u6444\u53d6\u4e2d...
file.ingestInProgress=\u6444\u53d6\u4e2d...
file.dataFilesTab.metadata.header=\u5143\u6570\u636e
file.dataFilesTab.metadata.addBtn=\u6dfb\u52a0+\u7f16\u8f91\u5143\u6570\u636e
file.dataFilesTab.terms.header=\u8bb8\u53ef+\u6761\u6b3e
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataCitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public String toString(boolean html) {

// append UNF
if (!StringUtils.isEmpty(UNF)) {
citation.append(" [").append(UNF).append("]");
citation.append(", ").append(UNF);
}

for (DatasetField dsf : optionalValues) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
Expand Down Expand Up @@ -693,4 +694,19 @@ public boolean hasGeospatialTag(){
}
return false;
}

public String getPublicationDateFormattedYYYYMMDD() {
if (getPublicationDate() != null){
return new SimpleDateFormat("yyyy-MM-dd").format(getPublicationDate());
}
return null;
}

public String getCreateDateFormattedYYYYMMDD() {
if (getCreateDate() != null){
return new SimpleDateFormat("yyyy-MM-dd").format(getCreateDate());
}
return null;
}

}
28 changes: 18 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/DataFileServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public void findFileMetadataOptimizedExperimental(Dataset owner, DatasetVersion

int i = 0;

List<Object[]> dataTableResults = em.createNativeQuery("SELECT t0.ID, t0.DATAFILE_ID, t0.UNF, t0.CASEQUANTITY, t0.VARQUANTITY, t0.ORIGINALFILEFORMAT FROM dataTable t0, dataFile t1, dvObject t2 WHERE ((t0.DATAFILE_ID = t1.ID) AND (t1.ID = t2.ID) AND (t2.OWNER_ID = " + owner.getId() + "))").getResultList();
List<Object[]> dataTableResults = em.createNativeQuery("SELECT t0.ID, t0.DATAFILE_ID, t0.UNF, t0.CASEQUANTITY, t0.VARQUANTITY, t0.ORIGINALFILEFORMAT FROM dataTable t0, dataFile t1, dvObject t2 WHERE ((t0.DATAFILE_ID = t1.ID) AND (t1.ID = t2.ID) AND (t2.OWNER_ID = " + owner.getId() + ")) ORDER BY t0.ID").getResultList();

for (Object[] result : dataTableResults) {
DataTable dataTable = new DataTable();
Expand Down Expand Up @@ -476,7 +476,7 @@ public void findFileMetadataOptimizedExperimental(Dataset owner, DatasetVersion

i = 0;

List<Object[]> fileResults = em.createNativeQuery("SELECT t0.ID, t0.CREATEDATE, t0.INDEXTIME, t0.MODIFICATIONTIME, t0.PERMISSIONINDEXTIME, t0.PERMISSIONMODIFICATIONTIME, t0.PUBLICATIONDATE, t0.CREATOR_ID, t0.RELEASEUSER_ID, t1.CONTENTTYPE, t1.FILESYSTEMNAME, t1.FILESIZE, t1.INGESTSTATUS, t1.CHECKSUMVALUE, t1.RESTRICTED, t1.CHECKSUMTYPE FROM DVOBJECT t0, DATAFILE t1 WHERE ((t0.OWNER_ID = " + owner.getId() + ") AND ((t1.ID = t0.ID) AND (t0.DTYPE = 'DataFile')))").getResultList();
List<Object[]> fileResults = em.createNativeQuery("SELECT t0.ID, t0.CREATEDATE, t0.INDEXTIME, t0.MODIFICATIONTIME, t0.PERMISSIONINDEXTIME, t0.PERMISSIONMODIFICATIONTIME, t0.PUBLICATIONDATE, t0.CREATOR_ID, t0.RELEASEUSER_ID, t1.CONTENTTYPE, t1.FILESYSTEMNAME, t1.FILESIZE, t1.INGESTSTATUS, t1.CHECKSUMVALUE, t1.RESTRICTED, t1.CHECKSUMTYPE FROM DVOBJECT t0, DATAFILE t1 WHERE ((t0.OWNER_ID = " + owner.getId() + ") AND ((t1.ID = t0.ID) AND (t0.DTYPE = 'DataFile'))) ORDER BY t0.ID").getResultList();

for (Object[] result : fileResults) {
Integer file_id = (Integer) result[0];
Expand Down Expand Up @@ -599,7 +599,6 @@ public void findFileMetadataOptimizedExperimental(Dataset owner, DatasetVersion
filesMap.put(dataFile.getId(), i++);
}

owner.setFiles(dataFiles);
fileResults = null;

logger.fine("Retrieved and cached "+i+" datafiles.");
Expand All @@ -613,13 +612,14 @@ public void findFileMetadataOptimizedExperimental(Dataset owner, DatasetVersion
logger.fine("Retreived "+i+" file categories attached to the dataset.");

if (requestedVersion != null) {
requestedVersion.setFileMetadatas(retrieveFileMetadataForVersion(owner, requestedVersion, filesMap, categoryMap));
requestedVersion.setFileMetadatas(retrieveFileMetadataForVersion(owner, requestedVersion, dataFiles, filesMap, categoryMap));
} else {
for (DatasetVersion version : owner.getVersions()) {
version.setFileMetadatas(retrieveFileMetadataForVersion(owner, version, filesMap, categoryMap));
version.setFileMetadatas(retrieveFileMetadataForVersion(owner, version, dataFiles, filesMap, categoryMap));
logger.fine("Retrieved "+version.getFileMetadatas().size()+" filemetadatas for the version "+version.getId());
}
}
owner.setFiles(dataFiles);
}

private List<AuthenticatedUser> retrieveFileAccessRequesters(DataFile fileIn){
Expand All @@ -638,7 +638,7 @@ private List<AuthenticatedUser> retrieveFileAccessRequesters(DataFile fileIn){
return retList;
}

private List<FileMetadata> retrieveFileMetadataForVersion(Dataset dataset, DatasetVersion version, Map<Long, Integer> filesMap, Map<Long, Integer> categoryMap) {
private List<FileMetadata> retrieveFileMetadataForVersion(Dataset dataset, DatasetVersion version, List<DataFile> dataFiles, Map<Long, Integer> filesMap, Map<Long, Integer> categoryMap) {
List<FileMetadata> retList = new ArrayList<>();
Map<Long, Set<Long>> categoryMetaMap = new HashMap<>();

Expand All @@ -656,7 +656,7 @@ private List<FileMetadata> retrieveFileMetadataForVersion(Dataset dataset, Datas
logger.fine("Retrieved and mapped "+i+" file categories attached to files in the version "+version.getId());
categoryResults = null;

List<Object[]> metadataResults = em.createNativeQuery("select id, datafile_id, DESCRIPTION, LABEL, RESTRICTED, DIRECTORYLABEL from FileMetadata where datasetversion_id = "+version.getId()).getResultList();
List<Object[]> metadataResults = em.createNativeQuery("select id, datafile_id, DESCRIPTION, LABEL, RESTRICTED, DIRECTORYLABEL from FileMetadata where datasetversion_id = "+version.getId() + " ORDER BY LABEL").getResultList();

for (Object[] result : metadataResults) {
Integer filemeta_id = (Integer) result[0];
Expand Down Expand Up @@ -688,7 +688,8 @@ private List<FileMetadata> retrieveFileMetadataForVersion(Dataset dataset, Datas

fileMetadata.setDatasetVersion(version);

fileMetadata.setDataFile(dataset.getFiles().get(file_list_id));
//fileMetadata.setDataFile(dataset.getFiles().get(file_list_id));
fileMetadata.setDataFile(dataFiles.get(file_list_id));

String description = (String) result[2];

Expand Down Expand Up @@ -720,7 +721,14 @@ private List<FileMetadata> retrieveFileMetadataForVersion(Dataset dataset, Datas
logger.fine("Retrieved "+retList.size()+" file metadatas for version "+version.getId()+" (inside the retrieveFileMetadataForVersion method).");


Collections.sort(retList, FileMetadata.compareByLabel);
/*
We no longer perform this sort here, just to keep this filemetadata
list as identical as possible to when it's produced by the "traditional"
EJB method. When it's necessary to have the filemetadatas sorted by
FileMetadata.compareByLabel, the DatasetVersion.getFileMetadatasSorted()
method should be called.
Collections.sort(retList, FileMetadata.compareByLabel); */

return retList;
}
Expand Down Expand Up @@ -1226,4 +1234,4 @@ public void populateFileSearchCard(SolrSearchResult solrSearchResult) {
solrSearchResult.setEntity(this.findCheapAndEasy(solrSearchResult.getEntityId()));
}

}
}
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -41,6 +42,7 @@
@Index(columnList = "thumbnailfile_id")},
uniqueConstraints = @UniqueConstraint(columnNames = {"authority,protocol,identifier,doiseparator"}))
public class Dataset extends DvObjectContainer {
private static final Logger logger = Logger.getLogger(Dataset.class.getCanonicalName());

// public static final String REDIRECT_URL = "/dataset.xhtml?persistentId=";
public static final String TARGET_URL = "/citation?persistentId=";
Expand Down Expand Up @@ -185,10 +187,12 @@ public String getGlobalId() {
}

public List<DataFile> getFiles() {
logger.info("getFiles() on dataset "+this.getId());
return files;
}

public void setFiles(List<DataFile> files) {
logger.info("setFiles() on dataset "+this.getId());
this.files = files;
}

Expand Down
Loading

0 comments on commit 17f0eae

Please sign in to comment.