From d453caac6241d20aeb256a4eaf351cc525bd1a86 Mon Sep 17 00:00:00 2001 From: Gustavo Durand Date: Wed, 30 Apr 2014 12:45:33 -0400 Subject: [PATCH 01/31] chamged replication data for logic to be client side only --- .../webapp/datasetFieldForEditFragment.xhtml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/datasetFieldForEditFragment.xhtml b/src/main/webapp/datasetFieldForEditFragment.xhtml index 2f5394c972a..85cc1cf1e6b 100644 --- a/src/main/webapp/datasetFieldForEditFragment.xhtml +++ b/src/main/webapp/datasetFieldForEditFragment.xhtml @@ -6,7 +6,8 @@ xmlns:p="http://primefaces.org/ui"> - - - - - + + + + + + + \ No newline at end of file From e15a9bdcb3b1c2e6c945188929f1e88d9a42d3c2 Mon Sep 17 00:00:00 2001 From: Eleni Castro Date: Wed, 30 Apr 2014 12:55:01 -0400 Subject: [PATCH 02/31] Fixed missing field types and metadatablock_id --- scripts/api/data/metadatablocks/astrophysics.tsv | 13 ++++++------- scripts/api/data/metadatablocks/general.tsv | 8 ++++---- scripts/api/data/metadatablocks/social_science.tsv | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/scripts/api/data/metadatablocks/astrophysics.tsv b/scripts/api/data/metadatablocks/astrophysics.tsv index 6557aba45ae..e252c68be95 100644 --- a/scripts/api/data/metadatablocks/astrophysics.tsv +++ b/scripts/api/data/metadatablocks/astrophysics.tsv @@ -4,15 +4,15 @@ astroType Type The nature or genre of the content of the files in the dataset. text 0 TRUE TRUE TRUE TRUE FALSE FALSE astrophysics astroFacility Facility The observatory or facility where the data was obtained. text 1 TRUE TRUE TRUE TRUE FALSE FALSE astrophysics astroInstrument Instrument The instrument used to collect the data. text 2 TRUE TRUE TRUE TRUE FALSE FALSE astrophysics - resolution.Spatial Spatial Resolution The spatial (angular) resolution that is typical of the observations, in decimal degrees. float 3 TRUE FALSE FALSE TRUE FALSE FALSE astrophysics - resolution.Spectral Spectral Resolution The spectral resolution that is typical of the observations, given as the ratio λ/Δλ. float 4 TRUE FALSE FALSE TRUE FALSE FALSE astrophysics + resolution.Spatial Spatial Resolution The spatial (angular) resolution that is typical of the observations, in decimal degrees. float 3 TRUE FALSE TRUE TRUE FALSE FALSE astrophysics + resolution.Spectral Spectral Resolution The spectral resolution that is typical of the observations, given as the ratio λ/Δλ. float 4 TRUE FALSE TRUE TRUE FALSE FALSE astrophysics resolution.Temporal Time Resolution The temporal resolution that is typical of the observations, given in seconds. float 5 FALSE FALSE FALSE FALSE FALSE FALSE astrophysics - coverage.Spectral.Bandpass Bandpass Conventional bandpass name text 6 TRUE TRUE FALSE TRUE FALSE FALSE astrophysics + coverage.Spectral.Bandpass Bandpass Conventional bandpass name text 6 TRUE TRUE TRUE TRUE FALSE FALSE astrophysics coverage.Spectral.CentralWavelength Central Wavelength (m) The central wavelength of the spectral bandpass, in meters. float 7 TRUE FALSE TRUE TRUE FALSE FALSE astrophysics - coverage.Spectral.Wavelength Wavelength Range The minimum and maximum wavelength of the spectral bandpass. 8 FALSE FALSE TRUE FALSE FALSE FALSE astrophysics + coverage.Spectral.Wavelength Wavelength Range The minimum and maximum wavelength of the spectral bandpass. float 8 FALSE FALSE TRUE FALSE FALSE FALSE astrophysics coverage.Spectral.MinimumWavelength Minimum (m) The minimum wavelength of the spectral bandpass, in meters. float 9 TRUE FALSE FALSE TRUE FALSE FALSE coverage.Spectral.Wavelength astrophysics coverage.Spectral.MaximumWavelength Maximum (m) The maximum wavelength of the spectral bandpass, in meters. float 10 TRUE FALSE FALSE TRUE FALSE FALSE coverage.Spectral.Wavelength astrophysics - coverage.Temporal Dataset Date Range Time period covered by the data. 11 TRUE FALSE FALSE FALSE FALSE FALSE + coverage.Temporal Dataset Date Range Time period covered by the data. date 11 TRUE FALSE TRUE FALSE FALSE FALSE astrophysics coverage.Temporal.StartTime Start Dataset Start Date YYYY-MM-DD date 12 FALSE FALSE FALSE TRUE FALSE FALSE coverage.Temporal astrophysics coverage.Temporal.StopTime End Dataset End Date YYYY-MM-DD date 13 FALSE FALSE FALSE TRUE FALSE FALSE coverage.Temporal astrophysics coverage.Spatial Sky Coverage The sky coverage of the data object. text 14 FALSE FALSE FALSE FALSE FALSE FALSE astrophysics @@ -23,10 +23,9 @@ coverage.Polarization Polarization The polarization coverage text 19 FALSE FALSE FALSE FALSE FALSE FALSE astrophysics redshiftType RedshiftType RedshiftType string C "Redshift"; or "Optical" or "Radio" definitions of Doppler velocity used in the data object. text 20 FALSE FALSE FALSE FALSE FALSE FALSE astrophysics resolution.Redshift Redshift Resolution The resolution in redshift (unitless) or Doppler velocity (km/s) in the data object. float 21 FALSE FALSE FALSE FALSE FALSE FALSE astrophysics - coverage.RedshiftValue Redshift Value The value of the redshift (unitless) or Doppler velocity (km/s in the data object. 22 FALSE FALSE TRUE FALSE FALSE FALSE astrophysics + coverage.RedshiftValue Redshift Value The value of the redshift (unitless) or Doppler velocity (km/s in the data object. float 22 FALSE FALSE TRUE FALSE FALSE FALSE astrophysics coverage.Redshift.MinimumValue Minimum The minimum value of the redshift (unitless) or Doppler velocity (km/s in the data object. float 23 FALSE FALSE FALSE FALSE FALSE FALSE coverage.RedshiftValue astrophysics coverage.Redshift.MaximumValue Maximum The maximum value of the redshift (unitless) or Doppler velocity (km/s in the data object. float 24 FALSE FALSE FALSE FALSE FALSE FALSE coverage.RedshiftValue astrophysics - ucd UCD (Unified Content Descriptors) A list of the UCDs (Unified Content Descriptors) represented in the data object. text 25 FALSE TRUE TRUE FALSE FALSE FALSE astrophysics #controlledVocabulary DatasetField Value displayOrder type Image 0 type Mosaic 1 diff --git a/scripts/api/data/metadatablocks/general.tsv b/scripts/api/data/metadatablocks/general.tsv index 80409aabfb0..524eda86bf9 100644 --- a/scripts/api/data/metadatablocks/general.tsv +++ b/scripts/api/data/metadatablocks/general.tsv @@ -10,22 +10,22 @@ keyword Keyword Key terms that describe important aspects of the Dataset. text 6 TRUE FALSE TRUE TRUE TRUE FALSE citation subject Subject Domain-specific Subjects that are topically relevant to the Dataset. text 7 TRUE TRUE TRUE TRUE TRUE TRUE citation notesText Notes Additional important information about the Dataset textbox 8 FALSE FALSE FALSE FALSE TRUE FALSE citation - otherId Other ID Another unique identifier that identifies this dataset (e.g., producer's or another repository's number). 9 FALSE FALSE TRUE FALSE FALSE FALSE citation + otherId Other ID Another unique identifier that identifies this dataset (e.g., producer's or another repository's number). text 9 FALSE FALSE TRUE FALSE FALSE FALSE citation otherIdValue Identifier Other identifier that corresponds to this Dataset. text 10 FALSE FALSE FALSE FALSE FALSE FALSE otherId citation otherIdAgency Agency Name of agency which generated this identifier. text 11 FALSE FALSE FALSE FALSE FALSE FALSE otherId citation - publication Related Publication Publications that use the data from this Dataset. 12 FALSE FALSE TRUE FALSE FALSE FALSE citation + publication Related Publication Publications that use the data from this Dataset. text 12 FALSE FALSE TRUE FALSE FALSE FALSE citation publicationCitation Publication Citation The full bibliographic citation for this related publication. textbox 13 FALSE FALSE FALSE FALSE FALSE FALSE publication citation publicationIDType ID Type The type of digital identifier used for this publication (e.g., Digital Object Identifier (DOI)). text 14 FALSE TRUE FALSE FALSE FALSE FALSE publication citation publicationIDNumber ID Number The identifier for the selected ID type. text 15 FALSE FALSE FALSE FALSE FALSE FALSE publication citation publicationURL URL Link to the publication web page (e.g., journal article page, archive record page, or other). url 16 FALSE FALSE FALSE FALSE FALSE FALSE publication citation - contributor Contributor The organization or person responsible for either collecting, managing, distributing, or otherwise contributing in some form to the development of the resource. 17 FALSE FALSE TRUE FALSE FALSE FALSE citation + contributor Contributor The organization or person responsible for either collecting, managing, distributing, or otherwise contributing in some form to the development of the resource. text 17 FALSE FALSE TRUE FALSE FALSE FALSE citation contributorType Type The type of contributor of the resource. text 18 TRUE TRUE FALSE TRUE FALSE FALSE contributor citation contributorName Name The Family Name, Given Name or organization name of the contributor. FamilyName, GivenName or Organization text 19 TRUE FALSE FALSE TRUE FALSE FALSE contributor citation contributorAffiliation Affiliation The organization which the contributor is affiliated with. text 20 FALSE FALSE FALSE FALSE FALSE FALSE contributor citation contributorAbbreviation Abbreviation The abbreviation by which the contributor's affiliation is commonly known (e.g., IQSS, ICPSR, etc). text 21 FALSE FALSE FALSE FALSE FALSE FALSE contributor citation productionDate Production Date Date when the data collection or other materials were produced (not distributed, released or archived). date 22 TRUE FALSE FALSE TRUE FALSE FALSE citation productionPlace Production Place The location where the data collection and any other related materials were produced. text 23 FALSE FALSE FALSE FALSE FALSE FALSE citation - grantNumber Grant Information Grant Information 24 FALSE FALSE TRUE FALSE FALSE FALSE citation + grantNumber Grant Information Grant Information text 24 FALSE FALSE TRUE FALSE FALSE FALSE citation grantNumberValue Grant Number The grant or contract number of the project that sponsored the effort. text 25 FALSE FALSE FALSE FALSE FALSE FALSE grantNumber citation grantNumberAgency Grant Agency Grant Number Agency text 26 FALSE TRUE FALSE FALSE FALSE FALSE grantNumber citation depositor Depositor The person (Family Name, Given Name) or the name of the organization that deposited this Dataset to the repository. text 27 FALSE FALSE FALSE FALSE FALSE FALSE citation diff --git a/scripts/api/data/metadatablocks/social_science.tsv b/scripts/api/data/metadatablocks/social_science.tsv index 7370a02124e..9ae4be6ca32 100644 --- a/scripts/api/data/metadatablocks/social_science.tsv +++ b/scripts/api/data/metadatablocks/social_science.tsv @@ -1,17 +1,17 @@ #metadataBlock name displayName socialscience Social Science and Humanities Metadata #datasetField name title description watermark fieldType displayOrder advancedSearchField allowControlledVocabulary allowmultiples facetable showabovefold required parent metadatablock_id - topicClassification Topic Classification The classification field indicates the broad important topic(s) and subjects that the data cover. Library of Congress subject terms may be used here. 0 FALSE FALSE TRUE FALSE FALSE FALSE socialscience + topicClassification Topic Classification The classification field indicates the broad important topic(s) and subjects that the data cover. Library of Congress subject terms may be used here. text 0 FALSE FALSE TRUE FALSE FALSE FALSE socialscience topicClassValue Term Topic or Subject term that is relevant to this Dataset. text 1 TRUE FALSE FALSE TRUE FALSE FALSE topicClassification socialscience topicClassVocab Vocabulary Provided for specification of the controlled vocabulary in use, e.g., LCSH, MeSH, etc. text 2 FALSE FALSE FALSE FALSE FALSE FALSE topicClassification socialscience topicClassVocabURI URL Specifies the URL location for the full controlled vocabulary. url 3 FALSE FALSE FALSE FALSE FALSE FALSE topicClassification socialscience - software Software Information about the software used to generate the Dataset. 4 FALSE FALSE TRUE FALSE FALSE FALSE socialscience + software Software Information about the software used to generate the Dataset. text 4 FALSE FALSE TRUE FALSE FALSE FALSE socialscience softwareName Name Name of software used to generate the Dataset. text 5 FALSE TRUE FALSE FALSE FALSE FALSE software socialscience softwareVersion Version Version of the software used to generate the Dataset. text 6 FALSE FALSE FALSE FALSE FALSE FALSE software socialscience - series Series Information about the codebook series. 7 FALSE FALSE FALSE FALSE FALSE FALSE socialscience + series Series Information about the codebook series. text 7 FALSE FALSE FALSE FALSE FALSE FALSE socialscience seriesName Name Name of the codebook series to which the codebook belongs. text 8 FALSE FALSE FALSE FALSE FALSE FALSE series socialscience seriesInformation Information History of the series and summary of those features that apply to the series as a whole. text 9 FALSE FALSE FALSE FALSE FALSE FALSE series socialscience - timePeriodCovered Time Period Covered Time period to which the data refer. This item reflects the time period covered by the data, not the dates of coding or making documents machine-readable or the dates the data were collected. Also known as span. 10 FALSE FALSE TRUE FALSE FALSE FALSE socialscience + timePeriodCovered Time Period Covered Time period to which the data refer. This item reflects the time period covered by the data, not the dates of coding or making documents machine-readable or the dates the data were collected. Also known as span. date 10 FALSE FALSE TRUE FALSE FALSE FALSE socialscience timePeriodCoveredStart Start Start date which reflects the time period covered by the data, not the dates of coding or making documents machine-readable or the dates the data were collected. YYYY-MM-DD date 11 TRUE FALSE FALSE TRUE FALSE FALSE timePeriodCovered socialscience timePeriodCoveredEnd End End date which reflects the time period covered by the data, not the dates of coding or making documents machine-readable or the dates the data were collected. YYYY-MM-DD date 12 TRUE FALSE FALSE TRUE FALSE FALSE timePeriodCovered socialscience dateOfCollection Date of Collection Contains the date(s) when the data were collected. 13 FALSE FALSE TRUE FALSE FALSE FALSE socialscience From 3c8061b60f92aa403c8a46b07df1408ccb1505a6 Mon Sep 17 00:00:00 2001 From: Michael Bar-Sinai Date: Wed, 30 Apr 2014 13:13:53 -0400 Subject: [PATCH 03/31] Fixed GF issue with the ui:repeat tag (closes #3903) --- .../java/edu/harvard/iq/dataverse/SampleCommandPage.java | 1 + src/main/webapp/resources/iqbs/messages.xhtml | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/SampleCommandPage.java b/src/main/java/edu/harvard/iq/dataverse/SampleCommandPage.java index 8ddb4db5ec2..debf05fdfe8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SampleCommandPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/SampleCommandPage.java @@ -76,6 +76,7 @@ public void init() { selectedDvObjectId = objects.get(0).getId(); } } + JH.addMessage(FacesMessage.SEVERITY_FATAL, "FATAL Sample! " + getMessage(), "Such useful details! Oh My!"); } diff --git a/src/main/webapp/resources/iqbs/messages.xhtml b/src/main/webapp/resources/iqbs/messages.xhtml index 4e87f151c7a..84fd4ec46d3 100644 --- a/src/main/webapp/resources/iqbs/messages.xhtml +++ b/src/main/webapp/resources/iqbs/messages.xhtml @@ -1,19 +1,16 @@ - - - - + #{level = fn:split(msg.severity,' ')[0]; "" } #{bsClass = (level eq 'INFO' ? 'info' : (level eq 'WARN' ? 'warning' : 'danger')); ""}
From 9ee864799e0da04bb2f9eb1875a40204b26f0414 Mon Sep 17 00:00:00 2001 From: sekmiller Date: Wed, 30 Apr 2014 14:59:58 -0400 Subject: [PATCH 04/31] Restrict unprivileged users from seeing unpublished dataset versions Also, use jQuery for DV desc counter --- .../edu/harvard/iq/dataverse/DatasetPage.java | 75 ++++++++++--------- .../harvard/iq/dataverse/DataversePage.java | 32 -------- src/main/webapp/dataset.xhtml | 5 +- src/main/webapp/dataverse.xhtml | 50 +++++++++---- 4 files changed, 79 insertions(+), 83 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index d9d58b7e96d..99588b16ea6 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -74,6 +74,8 @@ public enum DisplayMode { @EJB DataFileServiceBean datafileService; @EJB + PermissionServiceBean permissionServiceBean; + @EJB DataverseServiceBean dataverseService; @EJB DatasetFieldServiceBean fieldService; @@ -199,10 +201,15 @@ public void init() { if (dataset.getId() != null) { // view mode for a dataset dataset = datasetService.find(dataset.getId()); if (versionId == null) { - displayVersion = dataset.getLatestVersion(); + if (canIssueUpdateCommand()){ + displayVersion = dataset.getLatestVersion(); + } else { + displayVersion = dataset.getReleasedVersion(); + } } else { displayVersion = datasetVersionService.find(versionId); - } + } + ownerId = dataset.getOwner().getId(); //displayVersion.setDatasetFields(displayVersion.initDatasetFields()); if (dataset.getReleasedVersion() != null) { @@ -220,6 +227,8 @@ public void init() { } else { displayCitation = ""; } + + setVersionTabList(resetVersionTabList()); } else if (ownerId != null) { // create mode for a new child dataset @@ -333,10 +342,6 @@ public String save() { dataset.setProtocol("doi"); dataset.setAuthority("10.5072/FK2"); dataset.setIdentifier("5555"); - //TODO update title in page itself - if (replicationFor) { - updateTitle(); - } /* * Save and/or ingest files, if there are any: @@ -656,41 +661,43 @@ public DatasetVersionUI getDatasetVersionUI() { return datasetVersionUI; } - //boolean for adding "Replication for" to title - private boolean replicationFor; + private List versionTabList = new ArrayList(); - public boolean isReplicationFor() { - return replicationFor; + public List getVersionTabList() { + return versionTabList; } - public void setReplicationFor(boolean replicationFor) { - this.replicationFor = replicationFor; + public void setVersionTabList(List versionTabList) { + this.versionTabList = versionTabList; } - - private void updateTitle() { - System.out.print(replicationFor); - - Iterator dsfIt = dataset.getEditVersion().getDatasetFields().iterator(); - while (dsfIt.hasNext()) { - - DatasetField toUpdate = dsfIt.next(); - if (toUpdate.getDatasetFieldType().getName().equals(DatasetFieldConstant.title)) { - //dsfIt.s + + private boolean canIssueUpdateCommand(){ + try { + if (permissionServiceBean.on(dataset).canIssueCommand("UpdateDatasetCommand")) { + return true; + } else { + return false; } + } catch (ClassNotFoundException ex) { } - int i = 0; - for (DatasetField dsf : editVersion.getDatasetFields()) { - if (dsf.getDatasetFieldType().getName().equals(DatasetFieldConstant.title)) { - ArrayList valList = new ArrayList(); - DatasetFieldValue dsfv = new DatasetFieldValue(dsf); - String origVal = dsf.getValue(); - dsfv.setValue("Replication for: " + origVal); - valList.add(dsfv); - editVersion.getDatasetFields().get(i).setDatasetFieldValues(valList); - } - i++; - } + return false; } + + private List resetVersionTabList() { + List retList = new ArrayList(); + if (canIssueUpdateCommand()) { + return dataset.getVersions(); + } else { + for(DatasetVersion version: dataset.getVersions()){ + if (version.isReleased()){ + retList.add(version); + } + } + return retList; + + } + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java index 22977f579ac..fde6c4dcec1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java @@ -102,7 +102,6 @@ public void init() { if (dataverse.getId() != null) { // view mode for a dataverse dataverse = dataverseService.find(dataverse.getId()); ownerId = dataverse.getOwner() != null ? dataverse.getOwner().getId() : null; - setDataverseDescriptionPage(dataverse.getDescription()); } else if (ownerId != null) { // create mode for a new child dataverse editMode = EditMode.INFO; dataverse.setOwner(dataverseService.find(ownerId)); @@ -144,8 +143,6 @@ public List getContents() { public void edit(EditMode editMode) { this.editMode = editMode; - setDataverseDescriptionPage(dataverse.getDescription()); - updateCountDisplay(); if (editMode == EditMode.INFO) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Edit Dataverse", " - Edit your dataverse and click Save. Asterisks indicate required fields.")); } else if (editMode == EditMode.SETUP) { @@ -156,7 +153,6 @@ public void edit(EditMode editMode) { public String save() { Command cmd = null; //TODO change to Create - for now the page is expecting INFO instead. - dataverse.setDescription(dataverseDescriptionPage); if (dataverse.getId() == null) { dataverse.setOwner(ownerId != null ? dataverseService.find(ownerId) : null); cmd = new CreateDataverseCommand(dataverse, session.getUser()); @@ -241,34 +237,6 @@ public String releaseDataverse() { return "/dataverse.xhtml?id=" + dataverse.getId() + "&faces-redirect=true"; } - public void updateCountDisplay() { - setDescriptionSize(new Integer(dataverseDescriptionPage.length())); - } - - private String dataverseDescriptionPage; - - public String getDataverseDescriptionPage() { - return dataverseDescriptionPage; - } - - public void setDataverseDescriptionPage(String dataverseDescriptionPage) { - this.dataverseDescriptionPage = dataverseDescriptionPage; - } - - private Integer descriptionSize = new Integer(0); - - public Integer getDescriptionSize() { - return descriptionSize; - } - - public void setDescriptionSize(Integer descriptionSize) { - this.descriptionSize = descriptionSize; - } - - public String getCountString() { - return new Integer(1000 - descriptionSize.intValue()).toString() + " characters remaining"; - } - public String getMetadataBlockPreview(MetadataBlock mdb, int numberOfItems) { /// for beta, we will just preview the first n fields StringBuilder mdbPreview = new StringBuilder(); diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 8dd80a36f76..0020fbb424f 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -82,7 +82,8 @@
- +
  • @@ -422,7 +423,7 @@ - + diff --git a/src/main/webapp/dataverse.xhtml b/src/main/webapp/dataverse.xhtml index e1ed8f4c40c..df3d4f3ad43 100644 --- a/src/main/webapp/dataverse.xhtml +++ b/src/main/webapp/dataverse.xhtml @@ -13,12 +13,34 @@ - + + - + @@ -225,19 +247,17 @@
    - - - + autoResize="false"> - + @@ -277,7 +297,7 @@ - + @@ -291,31 +311,31 @@ - + - + - + - + - + - + - + From 162e4c8958696da69b67719752455e38cc0c3000 Mon Sep 17 00:00:00 2001 From: sekmiller Date: Wed, 30 Apr 2014 15:52:50 -0400 Subject: [PATCH 05/31] Make value column in dataset field value a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also display “in draft” tag in dataset page whenever DS version is in draft - not just if the DS itself has never been released. --- .../java/edu/harvard/iq/dataverse/DatasetFieldValue.java | 2 ++ src/main/java/edu/harvard/iq/dataverse/DatasetPage.java | 5 +++++ src/main/webapp/dataset.xhtml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java index 905695cbdd4..69fd1e87b3f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java @@ -8,6 +8,7 @@ import java.io.Serializable; import java.util.Comparator; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -46,6 +47,7 @@ public DatasetFieldValue(DatasetField aField, String aValue) { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "value", columnDefinition = "TEXT") private String value; private int displayOrder; diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 99588b16ea6..40773fce7b5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -218,6 +218,7 @@ public void init() { + new Integer(dataset.getReleasedVersion().getMinorVersionNumber().intValue() + 1).toString(); } datasetVersionUI = new DatasetVersionUI(displayVersion); + /* if (!dataset.isReleased() || (dataset.isReleased() && displayVersion.equals(dataset.getLatestVersion()) && !displayVersion.isDraft())) { displayCitation = dataset.getCitation(false, displayVersion); } else if (dataset.isReleased() && displayVersion.isDraft()) { @@ -227,6 +228,10 @@ public void init() { } else { displayCitation = ""; } + */ + // show citation for current display version if draft note it on page + + displayCitation = dataset.getCitation(false, displayVersion); setVersionTabList(resetVersionTabList()); diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 0020fbb424f..f6bbec596ae 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -186,7 +186,7 @@ #{DatasetPage.displayCitation} - +
    In Draft From e481f822f4a1cb1ac772b199806c54bb0d67eb5c Mon Sep 17 00:00:00 2001 From: sekmiller Date: Wed, 30 Apr 2014 16:22:53 -0400 Subject: [PATCH 06/31] Remove Text from datasetfieldvalue pending investigation --- src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java index 69fd1e87b3f..a2fb1dbd93e 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java @@ -47,7 +47,6 @@ public DatasetFieldValue(DatasetField aField, String aValue) { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "value", columnDefinition = "TEXT") private String value; private int displayOrder; From bb178ceaa4aba8c23656dc2057cf0f7e28346f6d Mon Sep 17 00:00:00 2001 From: Eleni Castro Date: Wed, 30 Apr 2014 17:57:50 -0400 Subject: [PATCH 07/31] Fixed mismatched type vs astroType CV DatasetFieldValue in astrophysics.tsv Also removed #controlledVocabulart from social_science.tsv since there is none. --- .../api/data/metadatablocks/astrophysics.tsv | 48 +++++++++---------- .../data/metadatablocks/social_science.tsv | 3 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/scripts/api/data/metadatablocks/astrophysics.tsv b/scripts/api/data/metadatablocks/astrophysics.tsv index e252c68be95..2c89f0fdb06 100644 --- a/scripts/api/data/metadatablocks/astrophysics.tsv +++ b/scripts/api/data/metadatablocks/astrophysics.tsv @@ -27,27 +27,27 @@ coverage.Redshift.MinimumValue Minimum The minimum value of the redshift (unitless) or Doppler velocity (km/s in the data object. float 23 FALSE FALSE FALSE FALSE FALSE FALSE coverage.RedshiftValue astrophysics coverage.Redshift.MaximumValue Maximum The maximum value of the redshift (unitless) or Doppler velocity (km/s in the data object. float 24 FALSE FALSE FALSE FALSE FALSE FALSE coverage.RedshiftValue astrophysics #controlledVocabulary DatasetField Value displayOrder - type Image 0 - type Mosaic 1 - type EventList 2 - type Spectrum 3 - type Cube 4 - type Table 5 - type Catalog 6 - type LightCurve 7 - type Simulation 8 - type Figure 9 - type Artwork 10 - type Animation 11 - type PrettyPicture 12 - type Documentation 13 - type Other 14 - type Library 15 - type Press Release 16 - type Facsimile 17 - type Historical 18 - type Observation 19 - type Object 20 - type Value 21 - type ValuePair 22 - type Survey 23 \ No newline at end of file + astroType Image 0 + astroType Mosaic 1 + astroType EventList 2 + astroType Spectrum 3 + astroType Cube 4 + astroType Table 5 + astroType Catalog 6 + astroType LightCurve 7 + astroType Simulation 8 + astroType Figure 9 + astroType Artwork 10 + astroType Animation 11 + astroType PrettyPicture 12 + astroType Documentation 13 + astroType Other 14 + astroType Library 15 + astroType Press Release 16 + astroType Facsimile 17 + astroType Historical 18 + astroType Observation 19 + astroType Object 20 + astroType Value 21 + astroType ValuePair 22 + astroType Survey 23 \ No newline at end of file diff --git a/scripts/api/data/metadatablocks/social_science.tsv b/scripts/api/data/metadatablocks/social_science.tsv index 9ae4be6ca32..e09ede50952 100644 --- a/scripts/api/data/metadatablocks/social_science.tsv +++ b/scripts/api/data/metadatablocks/social_science.tsv @@ -49,5 +49,4 @@ datasetLevelErrorNotes Study Level Error Notes Note element used for any information annotating or clarifying the methodology and processing of the study. text 45 FALSE FALSE FALSE FALSE FALSE FALSE socialscience responseRate Response Rate Percentage of sample members who provided information. text 46 FALSE FALSE FALSE FALSE FALSE FALSE socialscience samplingErrorEstimates Estimates of Sampling Error Measure of how precisely one can estimate a population value from a given sample. text 47 FALSE FALSE FALSE FALSE FALSE FALSE socialscience - otherDataAppraisal Other Forms of Data Appraisal Other issues pertaining to the data appraisal. Describe issues such as response variance, nonresponse rate and testing for bias, interviewer and response bias, confidence levels, question bias, or similar. text 48 FALSE FALSE FALSE FALSE FALSE FALSE socialscience -#controlledVocabulary DatasetField Value displayOrder \ No newline at end of file + otherDataAppraisal Other Forms of Data Appraisal Other issues pertaining to the data appraisal. Describe issues such as response variance, nonresponse rate and testing for bias, interviewer and response bias, confidence levels, question bias, or similar. text 48 FALSE FALSE FALSE FALSE FALSE FALSE socialscience \ No newline at end of file From f0b5e95915d55f997084ad7f5bf619150100b6a3 Mon Sep 17 00:00:00 2001 From: sekmiller Date: Thu, 1 May 2014 10:53:21 -0400 Subject: [PATCH 08/31] Add a catch of NPE if user lands on an unreleased DS draft without permission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also make DSFV value a “text” field --- .../harvard/iq/dataverse/DatasetFieldValue.java | 1 + .../java/edu/harvard/iq/dataverse/DatasetPage.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java index a2fb1dbd93e..69fd1e87b3f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java @@ -47,6 +47,7 @@ public DatasetFieldValue(DatasetField aField, String aValue) { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "value", columnDefinition = "TEXT") private String value; private int displayOrder; diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 40773fce7b5..0c4f6854f44 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -217,7 +217,8 @@ public void init() { datasetNextMinorVersion = new Integer(dataset.getReleasedVersion().getVersionNumber().intValue()).toString() + "." + new Integer(dataset.getReleasedVersion().getMinorVersionNumber().intValue() + 1).toString(); } - datasetVersionUI = new DatasetVersionUI(displayVersion); + + /* if (!dataset.isReleased() || (dataset.isReleased() && displayVersion.equals(dataset.getLatestVersion()) && !displayVersion.isDraft())) { displayCitation = dataset.getCitation(false, displayVersion); @@ -230,9 +231,14 @@ public void init() { } */ // show citation for current display version if draft note it on page - - displayCitation = dataset.getCitation(false, displayVersion); - + try { + datasetVersionUI = new DatasetVersionUI(displayVersion); + displayCitation = dataset.getCitation(false, displayVersion); + } catch (NullPointerException npe){ + //This will happen when solr is down and will allow any link to be displayed. + throw new RuntimeException("You do not have permission to view this dataset version."); // improve error handling + } + setVersionTabList(resetVersionTabList()); } else if (ownerId != null) { From 2ce1c4f7876af206913df36f4703e38026cb7596 Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Thu, 1 May 2014 11:04:09 -0400 Subject: [PATCH 09/31] bring Solr schema.xml up to date with bb178ce #3900 --- conf/solr/4.6.0/schema.xml | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/conf/solr/4.6.0/schema.xml b/conf/solr/4.6.0/schema.xml index ee13003283b..9d109cd2ec3 100644 --- a/conf/solr/4.6.0/schema.xml +++ b/conf/solr/4.6.0/schema.xml @@ -268,6 +268,9 @@ + + + @@ -282,26 +285,27 @@ - - - - - + + + + - - - + + + + + - + @@ -310,7 +314,6 @@ - @@ -318,7 +321,6 @@ - @@ -340,11 +342,10 @@ - - + - + @@ -364,6 +365,7 @@ + @@ -371,8 +373,6 @@ - - @@ -446,6 +446,9 @@ + + + @@ -460,26 +463,27 @@ - + - + + - + @@ -488,7 +492,6 @@ - @@ -496,7 +499,6 @@ - @@ -518,7 +520,6 @@ - @@ -542,6 +543,7 @@ + @@ -549,8 +551,6 @@ - - From 31b52d5e93d4c29a6917c48363ccd1f9fad0cdaa Mon Sep 17 00:00:00 2001 From: mheppler Date: Thu, 1 May 2014 13:38:15 -0400 Subject: [PATCH 10/31] moved description up, cleaned up metadata block config - also fixed header display issue --- src/main/webapp/dataverse.xhtml | 415 ++++++++++---------- src/main/webapp/resources/css/structure.css | 15 +- 2 files changed, 223 insertions(+), 207 deletions(-) diff --git a/src/main/webapp/dataverse.xhtml b/src/main/webapp/dataverse.xhtml index df3d4f3ad43..3fd7fa2a443 100644 --- a/src/main/webapp/dataverse.xhtml +++ b/src/main/webapp/dataverse.xhtml @@ -13,35 +13,35 @@ - - + //]]> + - + @@ -61,7 +61,7 @@ - + @@ -87,219 +87,224 @@ - - - +
    +
    +
    - - +
    +
    - + - - +
    +
    - - +
    +
    - + - - +
    +
    - - +
    +
    - + +
    +
    +
    +
    + +
    +
    + + +
    characters remaining
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + - -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    - - - - - - -
    - - - - - - - - -
    + + + + + + + - - + + - + - + - - + - - + + - - + @@ -349,7 +352,7 @@ - + diff --git a/src/main/webapp/resources/css/structure.css b/src/main/webapp/resources/css/structure.css index 4c4999484bb..5640a0def8a 100644 --- a/src/main/webapp/resources/css/structure.css +++ b/src/main/webapp/resources/css/structure.css @@ -36,7 +36,7 @@ .rightClass {text-align: right;} /* REMOVE */ /* -------- HEADER -------- */ -#dataverseHeader {margin:0 auto .5em auto; background:#F5F5F5;} +#dataverseHeader {margin:50px auto .5em auto; background:#F5F5F5;} #dataverseHeader .dataverseHeaderBlock {display:table-row;} #dataverseHeader .dataverseHeaderCell {display:table-cell;} #dataverseHeader .dataverseHeaderLogo {text-align:center;} @@ -86,6 +86,19 @@ button[id$='breadcrumbBtn2'] .ui-button-icon-left {left:1em;} #footer {padding-bottom:4em;} +/* -------- DATAVERSE -------- */ +form[id$='dataverseForm'] .panelLayoutBlock .form-horizontal table.ui-panelgrid.ui-widget, +form[id$='dataverseForm'] .panelLayoutBlock .form-horizontal table.ui-panelgrid.ui-widget tr, +form[id$='dataverseForm'] .panelLayoutBlock .form-horizontal table.ui-panelgrid.ui-widget td {border:0;} + +form[id$='dataverseForm'] .panelLayoutBlock .form-horizontal div.form-group {vertical-align: middle;} + +div.ui-chkbox.metadata-blocks-default div.ui-chkbox-box {margin: 4px 10px;} +div.ui-chkbox.metadata-blocks-default span.ui-chkbox-label {margin: 1px 10px 4px 10px;} + +table.ui-selectmanycheckbox.metadata-blocks-select label {font-weight:normal; margin-top:1px;} +table.ui-selectmanycheckbox.metadata-blocks-select label.ui-state-disabled {background:inherit;} + /* -------- SEARCH -------- */ .panelLayoutBlock.panelSerchForm > .ui-widget-content {border:0;} From 6544e8c8bff37846c3da621df02215043a3b3f91 Mon Sep 17 00:00:00 2001 From: Raman Prasad Date: Thu, 1 May 2014 15:14:18 -0400 Subject: [PATCH 11/31] javascript function "setCount" fix If src was undefined .js was throwing an error and stopping the script (on firefox) --- src/main/webapp/dataverse.xhtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/webapp/dataverse.xhtml b/src/main/webapp/dataverse.xhtml index 3fd7fa2a443..32a5695ca81 100644 --- a/src/main/webapp/dataverse.xhtml +++ b/src/main/webapp/dataverse.xhtml @@ -24,6 +24,9 @@ setCount(this, elem); }); function setCount(src, elem) { + if (typeof src === "undefined") { + return; + } var chars = src.value.length; elem.html(limit - chars); } From 554e8821ae6ad1c2c6774ec3315dba13f516b618 Mon Sep 17 00:00:00 2001 From: Michael Bar-Sinai Date: Thu, 1 May 2014 17:12:52 -0400 Subject: [PATCH 12/31] More work on dataset insertion api --- .../dataset-bad-missingInitialVersion.json | 5 + scripts/api/data/dataset-sample1.json | 98 +++++++++++++++ .../edu/harvard/iq/dataverse/Dataset.java | 3 - .../iq/dataverse/api/AbstractApiBean.java | 50 +++++++- .../harvard/iq/dataverse/api/Dataverses.java | 71 +++++++++++ .../command/impl/CreateDatasetCommand.java | 9 +- .../iq/dataverse/util/json/JsonParser.java | 114 ++++++++++-------- .../iq/dataverse/util/json/JsonPrinter.java | 72 ++++++----- 8 files changed, 325 insertions(+), 97 deletions(-) create mode 100644 scripts/api/data/dataset-bad-missingInitialVersion.json create mode 100644 scripts/api/data/dataset-sample1.json diff --git a/scripts/api/data/dataset-bad-missingInitialVersion.json b/scripts/api/data/dataset-bad-missingInitialVersion.json new file mode 100644 index 00000000000..caa698d3713 --- /dev/null +++ b/scripts/api/data/dataset-bad-missingInitialVersion.json @@ -0,0 +1,5 @@ +{ + "authority":"anAuthority", + "identifier":"dataset-one", + "protocol":"chadham-house-rule" +} \ No newline at end of file diff --git a/scripts/api/data/dataset-sample1.json b/scripts/api/data/dataset-sample1.json new file mode 100644 index 00000000000..79d35126ab2 --- /dev/null +++ b/scripts/api/data/dataset-sample1.json @@ -0,0 +1,98 @@ +{ + "authority": "anAuthority", + "identifier": "dataset-one", + "protocol": "chadham-house-rule", + "initialVersion": { + "authors": [ + { + "displayOrder": 0, + "affiliation": { + "value": "IQSS" + }, + "name": { + "value": "Castro, Eleni" + } + } + ], + "UNF": "UNF", + "title": "Replication Data for: Building a Bridge Between Journal Articles and Research Data", + "distributionDate": "Distribution Date", + "productionDate": "Production Date", + "metadataBlocks": { + "citation": { + "fields": [ + { + "value": "Replication Data for: Building a Bridge Between Journal Articles and Research Data", + "typeClass": "primitive", + "multiple": false, + "typeName": "title" + }, + { + "value": [ + [ + { + "value": "Castro, Eleni", + "typeClass": "primitive", + "multiple": false, + "typeName": "authorName" + }, + { + "value": "IQSS", + "typeClass": "primitive", + "multiple": false, + "typeName": "authorAffiliation" + } + ] + ], + "typeClass": "compound", + "multiple": true, + "typeName": "author" + }, + { + "value": [ + "ecastro@fas.harvard.edu" + ], + "typeClass": "primitive", + "multiple": true, + "typeName": "distributorContact" + }, + { + "value": "Research dataset for my publication on connecting journal articles and their underlying research data. Includes an analysis of current data publication practices.", + "typeClass": "primitive", + "multiple": false, + "typeName": "description" + }, + { + "value": [ + "data publication" + ], + "typeClass": "primitive", + "multiple": true, + "typeName": "keyword" + }, + { + "value": [ + "Social Sciences" + ], + "typeClass": "controlledVocabulary", + "multiple": true, + "typeName": "subject" + }, + { + "value": "Privileged, Pete", + "typeClass": "primitive", + "multiple": false, + "typeName": "depositor" + }, + { + "value": "2014-05-01", + "typeClass": "primitive", + "multiple": false, + "typeName": "dateOfDeposit" + } + ], + "displayName": "Citation Metadata" + } + } + } +} \ No newline at end of file diff --git a/src/main/java/edu/harvard/iq/dataverse/Dataset.java b/src/main/java/edu/harvard/iq/dataverse/Dataset.java index 4c4d6a972b3..cc459605175 100644 --- a/src/main/java/edu/harvard/iq/dataverse/Dataset.java +++ b/src/main/java/edu/harvard/iq/dataverse/Dataset.java @@ -7,8 +7,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -17,7 +15,6 @@ import javax.persistence.Entity; import javax.persistence.OneToMany; import javax.persistence.OrderBy; -import javax.validation.constraints.Size; import org.hibernate.validator.constraints.NotBlank; //import org.springframework.format.annotation.DateTimeFormat; diff --git a/src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java b/src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java index 13471f06dee..ec0916cedd5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java @@ -13,7 +13,10 @@ import edu.harvard.iq.dataverse.engine.command.Command; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import edu.harvard.iq.dataverse.engine.command.exception.PermissionException; -import edu.harvard.iq.dataverse.engine.command.impl.UpdateDataverseMetadataBlocksCommand; +import edu.harvard.iq.dataverse.util.json.JsonParser; +import java.util.concurrent.Callable; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.ejb.EJB; import javax.json.Json; import javax.json.JsonArray; @@ -51,8 +54,14 @@ public abstract class AbstractApiBean { @EJB DataverseRoleServiceBean rolesSvc; - - + + private final LazyRef jsonParserRef = new LazyRef<>(new Callable() { + @Override + public JsonParser call() throws Exception { + return new JsonParser(datasetFieldSvc, metadataBlockSvc); + } + }); + protected DataverseUser findUser( String userIdtf ) { return isNumeric(userIdtf) ? engineSvc.getContext().users().find(Long.parseLong(userIdtf)) @@ -118,6 +127,10 @@ protected Response accepted() { ).build(); } + protected JsonParser jsonParser() { + return jsonParserRef.get(); + } + protected Response notFound( String msg ) { return errorResponse(Status.NOT_FOUND, msg); } @@ -149,8 +162,8 @@ protected Response execute( Command c ) { return errorResponse(Status.INTERNAL_SERVER_ERROR, ce.getLocalizedMessage()); } } - - protected boolean isNumeric( String str ) { return Util.isNumeric(str); }; + + protected boolean isNumeric( String str ) { return Util.isNumeric(str); }; protected String error( String msg ) { return Util.error(msg); } protected String ok( String msg ) { return Util.ok(msg); } protected String ok( JsonObject jo ) { return Util.ok(jo); } @@ -158,3 +171,30 @@ protected Response execute( Command c ) { protected String ok( JsonObjectBuilder jo ) { return ok(jo.build()); } protected String ok( JsonArrayBuilder jo ) { return ok(jo.build()); } } + +class LazyRef { + private interface Ref { + T get(); + } + + private Ref ref; + + public LazyRef( final Callable initer ) { + ref = new Ref(){ + @Override + public T get() { + try { + final T t = initer.call(); + ref = new Ref(){ @Override public T get() { return t;} }; + return ref.get(); + } catch (Exception ex) { + Logger.getLogger(LazyRef.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + }}; + } + + public T get() { + return ref.get(); + } +} \ No newline at end of file diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java b/src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java index 45b99076989..8684997b5d3 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java @@ -2,6 +2,7 @@ import edu.harvard.iq.dataverse.DataFile; import edu.harvard.iq.dataverse.Dataset; +import edu.harvard.iq.dataverse.DatasetVersion; import edu.harvard.iq.dataverse.Dataverse; import edu.harvard.iq.dataverse.DataverseRole; import edu.harvard.iq.dataverse.DataverseUser; @@ -14,14 +15,19 @@ import static edu.harvard.iq.dataverse.util.json.JsonPrinter.brief; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import edu.harvard.iq.dataverse.engine.command.impl.AssignRoleCommand; +import edu.harvard.iq.dataverse.engine.command.impl.CreateDatasetCommand; import edu.harvard.iq.dataverse.engine.command.impl.CreateDataverseCommand; import edu.harvard.iq.dataverse.engine.command.impl.CreateRoleCommand; import edu.harvard.iq.dataverse.engine.command.impl.DeleteDataverseCommand; import edu.harvard.iq.dataverse.engine.command.impl.ListDataverseContentCommand; import edu.harvard.iq.dataverse.engine.command.impl.ListRoleAssignments; import edu.harvard.iq.dataverse.engine.command.impl.UpdateDataverseMetadataBlocksCommand; +import edu.harvard.iq.dataverse.util.json.JsonParseException; +import java.io.StringReader; +import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; @@ -30,7 +36,9 @@ import javax.ws.rs.Path; import javax.json.Json; import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; import javax.json.JsonString; +import javax.json.stream.JsonParsingException; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.ws.rs.DELETE; @@ -39,6 +47,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; /** * A REST API for dataverses. To be unified with {@link Dataverses}. @@ -49,6 +58,7 @@ public class Dataverses extends AbstractApiBean { private static final Logger logger = Logger.getLogger(Dataverses.class.getName()); + @GET public String list() { JsonArrayBuilder bld = Json.createArrayBuilder(); @@ -103,6 +113,67 @@ public String addDataverse( Dataverse d, @PathParam("identifier") String parentI return error(sb.toString()); } } + + @POST + @Path("{identifier}/datasets/") + @Produces("application/json") + public Response createDataset( @PathParam("identifier") String parentIdtf, String jsonBody, @QueryParam("key") String apiKey ) { + DataverseUser u = userSvc.findByUserName(apiKey); + if ( u == null ) return errorResponse( Response.Status.UNAUTHORIZED, "Invalid apikey '" + apiKey + "'"); + + Dataverse owner = findDataverse(parentIdtf); + if ( owner == null ) { + return errorResponse( Response.Status.NOT_FOUND, "Can't find dataverse with identifier='" + parentIdtf + "'"); + } + + JsonObject json; + try ( StringReader rdr = new StringReader(jsonBody) ) { + json = Json.createReader(rdr).readObject(); + } catch ( JsonParsingException jpe ) { + return errorResponse( Status.BAD_REQUEST, "Error parsing Json: " + jpe.getMessage() ); + } + + Dataset ds = new Dataset(); + ds.setOwner(owner); + ds.setIdentifier( json.getString("identifier")); + ds.setAuthority( json.getString("authority")); + ds.setProtocol( json.getString("protocol")); + JsonObject jsonVersion = json.getJsonObject("initialVersion"); + if ( jsonVersion == null) { + return errorResponse(Status.BAD_REQUEST, "Json POST data are missing initialVersion object."); + } + try { + try { + DatasetVersion version = jsonParser().parseDatasetVersion(jsonVersion); + + // force "initial version" properties + version.setMinorVersionNumber(0l); + version.setVersion(1l); + version.setVersionNumber(1l); + version.setVersionState(DatasetVersion.VersionState.DRAFT); + + ds.setVersions( Collections.singletonList(version) ); + } catch ( javax.ejb.TransactionRolledbackLocalException rbe ) { + throw rbe.getCausedByException(); + } + } catch (JsonParseException ex) { + logger.log( Level.INFO, "Error parsing dataset version from Json", ex); + return errorResponse(Status.BAD_REQUEST, "Error parsing initialVersion: " + ex.getMessage() ); + } catch ( Exception e ) { + logger.log( Level.WARNING, "Error parsing dataset version from Json", e); + return errorResponse(Status.INTERNAL_SERVER_ERROR, "Error parsing initialVersion: " + e.getMessage() ); + } + + try { + Dataset managedDs = engineSvc.submit( new CreateDatasetCommand(ds, u)); + return okResponse( Json.createObjectBuilder().add("id", managedDs.getId()) ); + + } catch (CommandException ex) { + String incidentId = UUID.randomUUID().toString(); + logger.log(Level.SEVERE, "Error creating new dataset: " + ex.getMessage() + " incidentId:" + incidentId, ex); + return errorResponse(Status.INTERNAL_SERVER_ERROR, "Error executing command. More data in the server logs. Incident id is " + incidentId); + } + } @GET @Path("{identifier}") diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetCommand.java index 25d3a14ab46..d53843c81a6 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetCommand.java @@ -2,8 +2,6 @@ import edu.harvard.iq.dataverse.Dataset; import edu.harvard.iq.dataverse.DatasetField; -import edu.harvard.iq.dataverse.DatasetFieldConstant; -import edu.harvard.iq.dataverse.DatasetFieldValue; import edu.harvard.iq.dataverse.DataverseRole; import edu.harvard.iq.dataverse.DataverseUser; import edu.harvard.iq.dataverse.RoleAssignment; @@ -13,11 +11,11 @@ import edu.harvard.iq.dataverse.engine.command.RequiredPermissions; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import java.sql.Timestamp; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.EnumSet; import java.util.Iterator; import java.util.Objects; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -59,12 +57,13 @@ public Dataset save(CommandContext ctxt) { theDataset.getEditVersion().setCreateTime(new Timestamp(new Date().getTime())); Dataset savedDataset = ctxt.em().merge(theDataset); String indexingResult = ctxt.index().indexDataset(savedDataset); - logger.info("during dataset save, indexing result was: " + indexingResult); + logger.log(Level.INFO, "during dataset save, indexing result was: {0}", indexingResult); + DataverseRole manager = new DataverseRole(); manager.addPermissions(EnumSet.allOf(Permission.class)); manager.setAlias("manager"); manager.setName("Dataset Manager"); - manager.setDescription("Auto-generated role for the creator of this dataverse"); + manager.setDescription("Auto-generated role for the creator of this dataset"); manager.setOwner(savedDataset); ctxt.roles().save(manager); ctxt.roles().save(new RoleAssignment(manager, getUser(), savedDataset)); diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java index 8a01b3b7b9b..ab60018a4a3 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java @@ -2,6 +2,7 @@ import edu.harvard.iq.dataverse.ControlledVocabularyValue; import edu.harvard.iq.dataverse.DatasetAuthor; +import edu.harvard.iq.dataverse.DatasetDistributor; import edu.harvard.iq.dataverse.DatasetField; import edu.harvard.iq.dataverse.DatasetFieldCompoundValue; import edu.harvard.iq.dataverse.DatasetFieldServiceBean; @@ -21,6 +22,7 @@ import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonString; +import javax.persistence.NoResultException; /** * Parses JSON objects into domain objects. @@ -41,23 +43,25 @@ public JsonParser(DatasetFieldServiceBean datasetFieldSvc, MetadataBlockServiceB public DatasetVersion parseDatasetVersion( JsonObject obj ) throws JsonParseException { try { DatasetVersion dsv = new DatasetVersion(); + + String archiveNote = obj.getString("archiveNote", null); + if ( archiveNote != null ) dsv.setArchiveNote( archiveNote ); - dsv.setArchiveNote( obj.getString("archiveNote", null) ); dsv.setDeaccessionLink( obj.getString("deaccessionLink", null) ); - dsv.setVersion( parseLong(obj.getString("version")) ); - dsv.setVersionNumber( parseLong(obj.getString("versionNumber")) ); - dsv.setMinorVersionNumber( parseLong(obj.getString("minorVersionNumber")) ); - dsv.setId( parseLong(obj.getString("id")) ); + dsv.setVersion( parseLong(obj.getString("version", null)) ); + dsv.setVersionNumber( parseLong(obj.getString("versionNumber", null)) ); + dsv.setMinorVersionNumber( parseLong(obj.getString("minorVersionNumber", null)) ); + dsv.setId( parseLong(obj.getString("id", null)) ); - String versionStateStr = obj.getString("versionState"); + String versionStateStr = obj.getString("versionState", null); if ( versionStateStr != null ) { dsv.setVersionState( DatasetVersion.VersionState.valueOf(versionStateStr) ); } - dsv.setReleaseTime( parseDate(obj.getString("releaseDate")) ); - dsv.setLastUpdateTime( parseDate(obj.getString("lastUpdateTime")) ); - dsv.setCreateTime( parseDate(obj.getString("createTime")) ); - dsv.setArchiveTime( parseDate(obj.getString("archiveTime")) ); + dsv.setReleaseTime( parseDate(obj.getString("releaseDate", null)) ); + dsv.setLastUpdateTime( parseDate(obj.getString("lastUpdateTime", null)) ); + dsv.setCreateTime( parseDate(obj.getString("createTime", null)) ); + dsv.setArchiveTime( parseDate(obj.getString("archiveTime", null)) ); dsv.setDatasetFields( parseMetadataBlocks(obj.getJsonObject("metadataBlocks")) ); @@ -67,9 +71,9 @@ public DatasetVersion parseDatasetVersion( JsonObject obj ) throws JsonParseExce for ( JsonObject authorJson : authorsJson.getValuesAs(JsonObject.class) ) { DatasetAuthor author = new DatasetAuthor(); author.setAffiliation( parseField( authorJson.getJsonObject("affiliation")) ); - author.setIdType( authorJson.getString("idType") ); - author.setIdValue( authorJson.getString("idValue")); - author.setDisplayOrder( parsePrimitiveInt(authorJson.getString("displayOrder"), 0) ); + author.setIdType( authorJson.getString("idType", null) ); + author.setIdValue( authorJson.getString("idValue", null)); + author.setDisplayOrder( parsePrimitiveInt(authorJson.getString("displayOrder", null), 0) ); author.setName( parseField( authorJson.getJsonObject("name")) ); authors.add( author ); @@ -78,7 +82,22 @@ public DatasetVersion parseDatasetVersion( JsonObject obj ) throws JsonParseExce dsv.setDatasetAuthors(authors); // parse distributors - // CONTPOINT + JsonArray distrosJson = obj.getJsonArray("distributors"); + if ( distrosJson != null ) { + List distros = new ArrayList<>(distrosJson.size()); + for ( JsonObject distJson : distrosJson.getValuesAs(JsonObject.class) ) { + DatasetDistributor distr = new DatasetDistributor(); + distr.setDisplayOrder( distJson.getInt("displayOrder", 0)); + distr.setVersion( Long.valueOf(distJson.getInt("version", 0)) ); + distr.setAbbreviation( parseField(distJson.getJsonObject("abbreviation"))); + distr.setAffiliation( parseField(distJson.getJsonObject("affiliation"))); + distr.setLogo( parseField(distJson.getJsonObject("logo"))); + distr.setName( parseField(distJson.getJsonObject("name"))); + distr.setUrl( parseField(distJson.getJsonObject("url"))); + } + dsv.setDatasetDistributors(distros); + } + return dsv; @@ -94,7 +113,6 @@ public List parseMetadataBlocks( JsonObject json ) throws JsonPars List fields = new LinkedList<>(); for ( String blockName : keys ) { - blockService.findByName(blockName); JsonObject blockJson = json.getJsonObject(blockName); JsonArray fieldsJson = blockJson.getJsonArray("fields"); for ( JsonObject fieldJson : fieldsJson.getValuesAs(JsonObject.class) ) { @@ -107,38 +125,40 @@ public List parseMetadataBlocks( JsonObject json ) throws JsonPars public DatasetField parseField( JsonObject json ) throws JsonParseException { if ( json == null ) return null; - DatasetField ret = new DatasetField(); - DatasetFieldType type = datasetFieldSvc.findByName(json.getString("typeName")); - if ( type == null ) { - throw new JsonParseException("Can't find field type named '" + json.getString("typeName") + "'"); - } - ret.setDatasetFieldType(type); - - - if ( type.isCompound() ) { - List vals = parseCompoundValue(type, json); - for ( DatasetFieldCompoundValue dsfcv : vals ) { - dsfcv.setParentDatasetField(ret); - } - ret.setDatasetFieldCompoundValues(vals); - - } else if ( type.isControlledVocabulary() ) { - List vals = parseControlledVocabularyValue(type, json); - for ( ControlledVocabularyValue cvv : vals ) { - cvv.setDatasetFieldType(type); - } - ret.setControlledVocabularyValues(vals); - - } else { - // primitive - List values = parsePrimitiveValue( json ); - for ( DatasetFieldValue val : values ) { - val.setDatasetField(ret); + try { + DatasetField ret = new DatasetField(); + DatasetFieldType type = datasetFieldSvc.findByName(json.getString("typeName","")); + + ret.setDatasetFieldType(type); + + + if ( type.isCompound() ) { + List vals = parseCompoundValue(type, json); + for ( DatasetFieldCompoundValue dsfcv : vals ) { + dsfcv.setParentDatasetField(ret); + } + ret.setDatasetFieldCompoundValues(vals); + + } else if ( type.isControlledVocabulary() ) { + List vals = parseControlledVocabularyValue(type, json); + for ( ControlledVocabularyValue cvv : vals ) { + cvv.setDatasetFieldType(type); + } + ret.setControlledVocabularyValues(vals); + + } else { + // primitive + List values = parsePrimitiveValue( json ); + for ( DatasetFieldValue val : values ) { + val.setDatasetField(ret); + } + ret.setDatasetFieldValues(values); } - ret.setDatasetFieldValues(values); + + return ret; + } catch ( NoResultException nre ) { + throw new JsonParseException("Can't find field type named '" + json.getString("typeName","") + "'"); } - - return ret; } public List parseCompoundValue( DatasetFieldType compoundType, JsonObject json ) throws JsonParseException { @@ -187,7 +207,7 @@ public List parsePrimitiveValue( JsonObject json ) throws Jso } else { DatasetFieldValue datasetFieldValue = new DatasetFieldValue(); - datasetFieldValue.setValue( json.getString("value") ); + datasetFieldValue.setValue( json.getString("value", "") ); vals.add(datasetFieldValue); } @@ -208,7 +228,7 @@ public List parseControlledVocabularyValue( DatasetFi return vals; } else { - String strValue = json.getString("value"); + String strValue = json.getString("value", ""); ControlledVocabularyValue cvv = cvvType.getControlledVocabularyValue( strValue ); if ( cvv==null ) { throw new JsonParseException("Value '" + strValue + "' does not exist in type '" + cvvType.getName() + "'"); diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java index 596399d8fa3..0ddb264ab73 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java @@ -33,7 +33,6 @@ import java.util.Deque; import java.util.LinkedList; import java.util.Map; -import javax.json.JsonObject; /** * Convert objects to Json. @@ -122,7 +121,6 @@ public static JsonObjectBuilder json( Dataset ds ) { .add("latest", brief.json(ds.getLatestVersion())) .add("edit", brief.json(ds.getEditVersion())) ); - } public static JsonObjectBuilder json( DatasetVersion dsv ) { @@ -344,44 +342,44 @@ public void startField(DatasetField f) { } } - @Override - public void endField(DatasetField f) { - if ( f.getDatasetFieldType().isAllowMultiples() ) { - objectStack.peek().add("value", valueArrStack.pop()); - } - fieldAggregator.peek().add(objectStack.pop()); - } + @Override + public void endField(DatasetField f) { + if ( f.getDatasetFieldType().isAllowMultiples() ) { + objectStack.peek().add("value", valueArrStack.pop()); + } + fieldAggregator.peek().add(objectStack.pop()); + } - @Override - public void primitiveValue(DatasetFieldValue dsfv) { - if ( dsfv.getDatasetField().getDatasetFieldType().isAllowMultiples() ) { - valueArrStack.peek().add( dsfv.getValue() ); - } else { - objectStack.peek().add("value", dsfv.getValue()); - } - } + @Override + public void primitiveValue(DatasetFieldValue dsfv) { + if ( dsfv.getDatasetField().getDatasetFieldType().isAllowMultiples() ) { + valueArrStack.peek().add( dsfv.getValue() ); + } else { + objectStack.peek().add("value", dsfv.getValue()); + } + } - @Override - public void controledVocabularyValue(ControlledVocabularyValue cvv) { - if ( cvv.getDatasetFieldType().isAllowMultiples() ) { - valueArrStack.peek().add( cvv.getStrValue() ); - } else { - objectStack.peek().add("value", cvv.getStrValue()); - } - } + @Override + public void controledVocabularyValue(ControlledVocabularyValue cvv) { + if ( cvv.getDatasetFieldType().isAllowMultiples() ) { + valueArrStack.peek().add( cvv.getStrValue() ); + } else { + objectStack.peek().add("value", cvv.getStrValue()); + } + } - @Override - public void startCompoundValue(DatasetFieldCompoundValue dsfcv) { - fieldAggregator.push( Json.createArrayBuilder() ); - } + @Override + public void startCompoundValue(DatasetFieldCompoundValue dsfcv) { + fieldAggregator.push( Json.createArrayBuilder() ); + } - @Override - public void endCompoundValue(DatasetFieldCompoundValue dsfcv) { - if ( dsfcv.getParentDatasetField().getDatasetFieldType().isAllowMultiples() ) { - valueArrStack.peek().add( fieldAggregator.pop() ); - } else { - objectStack.peek().add("value", fieldAggregator.pop() ); - } - } + @Override + public void endCompoundValue(DatasetFieldCompoundValue dsfcv) { + if ( dsfcv.getParentDatasetField().getDatasetFieldType().isAllowMultiples() ) { + valueArrStack.peek().add( fieldAggregator.pop() ); + } else { + objectStack.peek().add("value", fieldAggregator.pop() ); + } + } } } From 837664bcec80c8b006e15bf490eaebbea567ddec Mon Sep 17 00:00:00 2001 From: mheppler Date: Thu, 1 May 2014 17:26:00 -0400 Subject: [PATCH 13/31] Minor UI clean up on the dataverse pg, and search include. Moved some of the inline styles to the stylesheet. Converted some Primefaces layout components to Bootstrap styled plain HTML markup. --- src/main/webapp/dataverse.xhtml | 8 +- src/main/webapp/dataverse_template.xhtml | 4 - src/main/webapp/resources/css/structure.css | 27 +- src/main/webapp/search-include-fragment.xhtml | 1222 ++++++++--------- 4 files changed, 632 insertions(+), 629 deletions(-) diff --git a/src/main/webapp/dataverse.xhtml b/src/main/webapp/dataverse.xhtml index 3fd7fa2a443..ca33bf73bde 100644 --- a/src/main/webapp/dataverse.xhtml +++ b/src/main/webapp/dataverse.xhtml @@ -160,7 +160,7 @@ -
    +
    -