From 60fd279809ea978f5dee0ec4d80350320d8aae99 Mon Sep 17 00:00:00 2001 From: mderuijter Date: Mon, 9 Dec 2019 10:25:54 +0100 Subject: [PATCH 1/8] Initial commit for #1625 --- scripts/api/data/metadatablocks/citation.tsv | 6 +-- .../dataverse/DatasetFieldCompoundValue.java | 51 ++++++++++++++++--- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/scripts/api/data/metadatablocks/citation.tsv b/scripts/api/data/metadatablocks/citation.tsv index 90326d2e884..0a671eaa928 100644 --- a/scripts/api/data/metadatablocks/citation.tsv +++ b/scripts/api/data/metadatablocks/citation.tsv @@ -12,7 +12,7 @@ authorName Name The author's Family Name, Given Name or the name of the organization responsible for this Dataset. FamilyName, GivenName or Organization text 8 #VALUE TRUE FALSE FALSE TRUE TRUE TRUE author citation authorAffiliation Affiliation The organization with which the author is affiliated. text 9 (#VALUE) TRUE FALSE FALSE TRUE TRUE FALSE author citation authorIdentifierScheme Identifier Scheme Name of the identifier scheme (ORCID, ISNI). text 10 - #VALUE: FALSE TRUE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifierScheme - authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. text 11 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier + authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. text 11 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier datasetContact Contact The contact(s) for this Dataset. none 12 FALSE FALSE TRUE FALSE TRUE FALSE citation datasetContactName Name The contact's Family Name, Given Name or the name of the organization. FamilyName, GivenName or Organization text 13 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation datasetContactAffiliation Affiliation The organization with which the contact is affiliated. text 14 (#VALUE) FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation @@ -128,8 +128,8 @@ contributorType Supervisor 14 contributorType Work Package Leader 15 contributorType Other 16 - authorIdentifierScheme ORCID 0 - authorIdentifierScheme ISNI 1 + authorIdentifierScheme ORCID https://orcid.org/ 0 + authorIdentifierScheme ISNI http://isni.org/isni/ 1 authorIdentifierScheme LCNA 2 authorIdentifierScheme VIAF 3 authorIdentifierScheme GND 4 diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index 86bb270bcae..9dff1dc696b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -8,12 +8,10 @@ import edu.harvard.iq.dataverse.util.BundleUtil; import edu.harvard.iq.dataverse.util.MarkupChecker; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; +import java.util.*; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -35,6 +33,7 @@ public class DatasetFieldCompoundValue implements Serializable { private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(DatasetFieldCompoundValue.class.getName()); public static final Comparator DisplayOrder = new Comparator() { @Override @@ -132,10 +131,40 @@ public DatasetFieldCompoundValue copy(DatasetField parent) { return compoundValue; } + final private static String REGEX_FIELD_NAME = "(#[a-z]+\\w*)"; + static private Map referencesMap = new LinkedHashMap<>(); + + public Map getDisplayValueMap() { // todo - this currently only supports child datasetfields with single values // need to determine how we would want to handle multiple + Map fieldMap = new LinkedHashMap<>(); + Pattern pattern = Pattern.compile(REGEX_FIELD_NAME); + String fieldName = new String(); + String fieldValue = new String(); + + for (DatasetField childDatasetField : childDatasetFields){ + Matcher matcher = pattern.matcher(childDatasetField.getDatasetFieldType().getDisplayFormat()); + while (matcher.find()){ + referencesMap.putIfAbsent(matcher.group(0), null); + } + } + + for (DatasetField childDatasetField : childDatasetFields) { + if (referencesMap.containsKey("#"+childDatasetField.getDatasetFieldType().getName())){ + // temporary, this gets the CVV Identifier instead of the Value if there is an Identifier. + // need a better solution for getting a CVV Identifier instead of normal value + if (childDatasetField.getSingleControlledVocabularyValue() != null){ + if (!StringUtils.isBlank(childDatasetField.getSingleControlledVocabularyValue().getIdentifier())){ + referencesMap.putIfAbsent("#"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getIdentifier()); + } + } else{ + referencesMap.putIfAbsent("#"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getValue()); + } + + } + } for (DatasetField childDatasetField : childDatasetFields) { // skip the value if it is empty or N/A @@ -148,9 +177,18 @@ public Map getDisplayValueMap() { if (!childDatasetField.getDatasetFieldType().isSanitizeHtml() && childDatasetField.getDatasetFieldType().isEscapeOutputText()){ sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue); } + Matcher matcher = pattern.matcher(childDatasetField.getDatasetFieldType().getDisplayFormat()); + while (matcher.find()) { + if (referencesMap.containsKey(matcher.group(0)) && referencesMap.get(matcher.group(0)) != null) { + fieldName = matcher.group(0); + fieldValue = referencesMap.get(fieldName); + } + } + // replace the special values in the format (note: we replace #VALUE last since we don't // want any issues if the value itself has #NAME in it) String displayValue = format + .replaceAll(fieldName+"\\b", fieldValue) .replace("#NAME", childDatasetField.getDatasetFieldType().getTitle()) //todo: this should be handled in more generic way for any other text that can then be internationalized // if we need to use replaceAll for regexp, then make sure to use: java.util.regex.Matcher.quoteReplacement() @@ -158,6 +196,7 @@ public Map getDisplayValueMap() { .replace("#VALUE", sanitizedValue ); fieldMap.put(childDatasetField,displayValue); + } } From 9a03f6cad10980f425bb078da37452dcd058aa51 Mon Sep 17 00:00:00 2001 From: mderuijter Date: Tue, 14 Jan 2020 16:23:23 +0100 Subject: [PATCH 2/8] created new table for cvv urlprefixes and added configurability via citation.tsv --- scripts/api/data/metadatablocks/citation.tsv | 14 ++--- .../dataverse/ControlledVocabularyValue.java | 15 +++++- .../ControlledVocabularyValueDetail.java | 51 +++++++++++++++++++ .../dataverse/DatasetFieldCompoundValue.java | 18 +++---- .../iq/dataverse/DatasetFieldServiceBean.java | 12 +++++ .../dataverse/api/DatasetFieldServiceApi.java | 11 ++++ 6 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java diff --git a/scripts/api/data/metadatablocks/citation.tsv b/scripts/api/data/metadatablocks/citation.tsv index 0a671eaa928..b4c74bcd825 100644 --- a/scripts/api/data/metadatablocks/citation.tsv +++ b/scripts/api/data/metadatablocks/citation.tsv @@ -12,7 +12,7 @@ authorName Name The author's Family Name, Given Name or the name of the organization responsible for this Dataset. FamilyName, GivenName or Organization text 8 #VALUE TRUE FALSE FALSE TRUE TRUE TRUE author citation authorAffiliation Affiliation The organization with which the author is affiliated. text 9 (#VALUE) TRUE FALSE FALSE TRUE TRUE FALSE author citation authorIdentifierScheme Identifier Scheme Name of the identifier scheme (ORCID, ISNI). text 10 - #VALUE: FALSE TRUE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifierScheme - authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. text 11 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier + authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. text 11 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier datasetContact Contact The contact(s) for this Dataset. none 12 FALSE FALSE TRUE FALSE TRUE FALSE citation datasetContactName Name The contact's Family Name, Given Name or the name of the organization. FamilyName, GivenName or Organization text 13 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation datasetContactAffiliation Affiliation The organization with which the contact is affiliated. text 14 (#VALUE) FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation @@ -79,7 +79,7 @@ originOfSources Origin of Sources For historical materials, information about the origin of the sources and the rules followed in establishing the sources should be specified. textbox 75 FALSE FALSE FALSE FALSE FALSE FALSE citation characteristicOfSources Characteristic of Sources Noted Assessment of characteristics and source material. textbox 76 FALSE FALSE FALSE FALSE FALSE FALSE citation accessToSources Documentation and Access to Sources Level of documentation of the original sources. textbox 77 FALSE FALSE FALSE FALSE FALSE FALSE citation -#controlledVocabulary DatasetField Value identifier displayOrder +#controlledVocabulary DatasetField Value identifier displayOrder detail subject Agricultural Sciences D01 0 subject Arts and Humanities D0 1 subject Astronomy and Astrophysics D1 2 @@ -128,11 +128,11 @@ contributorType Supervisor 14 contributorType Work Package Leader 15 contributorType Other 16 - authorIdentifierScheme ORCID https://orcid.org/ 0 - authorIdentifierScheme ISNI http://isni.org/isni/ 1 - authorIdentifierScheme LCNA 2 - authorIdentifierScheme VIAF 3 - authorIdentifierScheme GND 4 + authorIdentifierScheme ORCID 0 https://orcid.org/ + authorIdentifierScheme ISNI 1 http://isni.org/isni/ + authorIdentifierScheme LCNA 2 http://id.loc.gov/authorities/names/ + authorIdentifierScheme VIAF 3 https://viaf.org/viaf/ + authorIdentifierScheme GND 4 https://d-nb.info/gnd/ authorIdentifierScheme DAI 5 authorIdentifierScheme ResearcherID 6 authorIdentifierScheme ScopusID 7 diff --git a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValue.java b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValue.java index 00c264afeb7..a508be3926e 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValue.java @@ -16,15 +16,15 @@ import java.util.Objects; import java.util.MissingResourceException; import javax.persistence.CascadeType; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Index; -import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.Column; +import javax.persistence.OneToOne; import javax.persistence.Table; /** @@ -111,6 +111,17 @@ public void setControlledVocabAlternates(Collection co this.controlledVocabAlternates = controlledVocabAlternates; } + @OneToOne(mappedBy = "controlledVocabularyValue",cascade={ CascadeType.REMOVE, CascadeType.MERGE,CascadeType.PERSIST}, orphanRemoval=true) + private ControlledVocabularyValueDetail controlledVocabularyValueDetail; + + public ControlledVocabularyValueDetail getControlledVocabularyValueDetail() { + return controlledVocabularyValueDetail; + } + + public void setControlledVocabularyValueDetail(ControlledVocabularyValueDetail controlledVocabularyValueDetail) { + this.controlledVocabularyValueDetail = controlledVocabularyValueDetail; + } + public String getLocaleStrValue() { String key = strValue.toLowerCase().replace(" " , "_"); diff --git a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java new file mode 100644 index 00000000000..c56c50ad154 --- /dev/null +++ b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java @@ -0,0 +1,51 @@ +package edu.harvard.iq.dataverse; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.Column; +import javax.persistence.OneToOne; +import javax.persistence.JoinColumn; +import javax.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(indexes = {@Index(columnList="controlledvocabularyvalue_id")}) +public class ControlledVocabularyValueDetail implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + @Column(columnDefinition="TEXT") + private String urlPrefix; + + public String getUrlPrefix() { + return urlPrefix; + } + + public void setUrlPrefix(String urlPrefix) { + this.urlPrefix = urlPrefix; + } + + @OneToOne + @JoinColumn(name = "controlledvocabularyvalue_id", unique = true) + private ControlledVocabularyValue controlledVocabularyValue; + + public ControlledVocabularyValue getControlledVocabularyValue() { + return controlledVocabularyValue; + } + + public void setControlledVocabularyValue(ControlledVocabularyValue controlledVocabularyValue) { + this.controlledVocabularyValue = controlledVocabularyValue; + } +} diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index 9dff1dc696b..57b8691bc26 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -131,7 +131,7 @@ public DatasetFieldCompoundValue copy(DatasetField parent) { return compoundValue; } - final private static String REGEX_FIELD_NAME = "(#[a-z]+\\w*)"; + final private static String REGEX_FIELD_NAME = "(##[a-z]+\\w*)"; static private Map referencesMap = new LinkedHashMap<>(); @@ -147,20 +147,20 @@ public Map getDisplayValueMap() { for (DatasetField childDatasetField : childDatasetFields){ Matcher matcher = pattern.matcher(childDatasetField.getDatasetFieldType().getDisplayFormat()); while (matcher.find()){ - referencesMap.putIfAbsent(matcher.group(0), null); + referencesMap.put(matcher.group(0), null); } } for (DatasetField childDatasetField : childDatasetFields) { - if (referencesMap.containsKey("#"+childDatasetField.getDatasetFieldType().getName())){ - // temporary, this gets the CVV Identifier instead of the Value if there is an Identifier. - // need a better solution for getting a CVV Identifier instead of normal value + if (referencesMap.containsKey("##"+childDatasetField.getDatasetFieldType().getName())){ if (childDatasetField.getSingleControlledVocabularyValue() != null){ - if (!StringUtils.isBlank(childDatasetField.getSingleControlledVocabularyValue().getIdentifier())){ - referencesMap.putIfAbsent("#"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getIdentifier()); + if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix().isEmpty()){ + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix()); + } else { + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getStrValue()); } - } else{ - referencesMap.putIfAbsent("#"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getValue()); + } else { + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getValue()); } } diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java index 03e677a1d74..274aeba1c28 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java @@ -153,6 +153,18 @@ public ControlledVocabAlternate findControlledVocabAlternateByControlledVocabula return (ControlledVocabAlternate) results.get(0); } } + + public ControlledVocabularyValueDetail findControlledVocabularyValueDetailByControlledVocabularyValueAndUrlPrefix(ControlledVocabularyValue cvv, String urlPrefix){ + TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ControlledVocabularyValueDetail AS o WHERE o.urlPrefix = :urlprefix AND o.controlledVocabularyValue = :cvv", ControlledVocabularyValueDetail.class); + typedQuery.setParameter("urlprefix", urlPrefix); + typedQuery.setParameter("cvv", cvv); + try { + ControlledVocabularyValueDetail cvvd = typedQuery.getSingleResult(); + return cvvd; + } catch (NoResultException e){ + return null; + } + } /** * @param dsft The DatasetFieldType in which to look up a diff --git a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java index 8882742d20c..02807174937 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java @@ -2,6 +2,7 @@ import edu.harvard.iq.dataverse.ControlledVocabAlternate; import edu.harvard.iq.dataverse.ControlledVocabularyValue; +import edu.harvard.iq.dataverse.ControlledVocabularyValueDetail; import edu.harvard.iq.dataverse.ControlledVocabularyValueServiceBean; import edu.harvard.iq.dataverse.DatasetField; import edu.harvard.iq.dataverse.DatasetFieldConstant; @@ -411,6 +412,16 @@ private String parseControlledVocabulary(String[] values) { cvv.setStrValue(values[2]); cvv.setIdentifier(values[3]); cvv.setDisplayOrder(Integer.parseInt(values[4])); + + if (values.length >= 6 && values[5] != null && !values[5].isEmpty()) { + ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndUrlPrefix(cvv, values[5]); + if (cvvd == null) { + cvvd = new ControlledVocabularyValueDetail(); + cvvd.setControlledVocabularyValue(cvv); + cvvd.setUrlPrefix(values[5]); + cvv.setControlledVocabularyValueDetail(cvvd); + } + } datasetFieldService.save(cvv); return cvv.getStrValue(); } From 432ed3949822ab4152f95aa6aff441c3a5a3686c Mon Sep 17 00:00:00 2001 From: mderuijter Date: Tue, 14 Jan 2020 16:50:08 +0100 Subject: [PATCH 3/8] merged some conflicting code manually --- .../dataverse/DatasetFieldCompoundValue.java | 43 +++++++++++++++++-- .../dataverse/api/DatasetFieldServiceApi.java | 1 - 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index 57b8691bc26..f3a96a1a4c5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -8,8 +8,13 @@ import edu.harvard.iq.dataverse.util.BundleUtil; import edu.harvard.iq.dataverse.util.MarkupChecker; import java.io.Serializable; -import java.util.*; -import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.persistence.CascadeType; @@ -33,7 +38,6 @@ public class DatasetFieldCompoundValue implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = Logger.getLogger(DatasetFieldCompoundValue.class.getName()); public static final Comparator DisplayOrder = new Comparator() { @Override @@ -138,8 +142,9 @@ public DatasetFieldCompoundValue copy(DatasetField parent) { public Map getDisplayValueMap() { // todo - this currently only supports child datasetfields with single values // need to determine how we would want to handle multiple - Map fieldMap = new LinkedHashMap<>(); + boolean fixTrailingComma = false; + Pattern pattern = Pattern.compile(REGEX_FIELD_NAME); String fieldName = new String(); String fieldValue = new String(); @@ -167,6 +172,7 @@ public Map getDisplayValueMap() { } for (DatasetField childDatasetField : childDatasetFields) { + fixTrailingComma = false; // skip the value if it is empty or N/A if (!StringUtils.isBlank(childDatasetField.getValue()) && !DatasetField.NA_VALUE.equals(childDatasetField.getValue())) { String format = childDatasetField.getDatasetFieldType().getDisplayFormat(); @@ -177,6 +183,9 @@ public Map getDisplayValueMap() { if (!childDatasetField.getDatasetFieldType().isSanitizeHtml() && childDatasetField.getDatasetFieldType().isEscapeOutputText()){ sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue); } + //if a series of child values is comma delimited we want to strip off the final entry's comma + if (format.equals("#VALUE, ")) fixTrailingComma = true; + Matcher matcher = pattern.matcher(childDatasetField.getDatasetFieldType().getDisplayFormat()); while (matcher.find()) { if (referencesMap.containsKey(matcher.group(0)) && referencesMap.get(matcher.group(0)) != null) { @@ -200,6 +209,32 @@ public Map getDisplayValueMap() { } } + if (fixTrailingComma) { + return (removeLastComma(fieldMap)); + } + return fieldMap; } + + private Map removeLastComma(Map mapIn) { + + Iterator> itr = mapIn.entrySet().iterator(); + Map.Entry entry = null; + DatasetField keyVal = null; + String oldValue = null; + + while (itr.hasNext()) { + entry = itr.next(); + keyVal = entry.getKey(); + oldValue = entry.getValue(); + } + + if (keyVal != null && oldValue != null && oldValue.length() >= 2) { + String newValue = oldValue.substring(0, oldValue.length() - 2); + mapIn.replace(keyVal, oldValue, newValue); + } + + return mapIn; + + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java index 02807174937..929a7f4ed1b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java @@ -412,7 +412,6 @@ private String parseControlledVocabulary(String[] values) { cvv.setStrValue(values[2]); cvv.setIdentifier(values[3]); cvv.setDisplayOrder(Integer.parseInt(values[4])); - if (values.length >= 6 && values[5] != null && !values[5].isEmpty()) { ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndUrlPrefix(cvv, values[5]); if (cvvd == null) { From 7f76184e5ef1c4271c91a0adaa156e1926110af9 Mon Sep 17 00:00:00 2001 From: mderuijter Date: Wed, 15 Jan 2020 10:50:40 +0100 Subject: [PATCH 4/8] NullPointer fix if the ControlledVocabularyValueDetail table was empty --- .../edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index f3a96a1a4c5..ce7139e1a18 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -159,7 +159,7 @@ public Map getDisplayValueMap() { for (DatasetField childDatasetField : childDatasetFields) { if (referencesMap.containsKey("##"+childDatasetField.getDatasetFieldType().getName())){ if (childDatasetField.getSingleControlledVocabularyValue() != null){ - if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix().isEmpty()){ + if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix().isEmpty()){ referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix()); } else { referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getStrValue()); @@ -167,7 +167,6 @@ public Map getDisplayValueMap() { } else { referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getValue()); } - } } From b9d84896c37801046d30b8367d34b44369ee31e9 Mon Sep 17 00:00:00 2001 From: mderuijter Date: Mon, 20 Jan 2020 11:55:33 +0100 Subject: [PATCH 5/8] Update citation.tsv --- scripts/api/data/metadatablocks/citation.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api/data/metadatablocks/citation.tsv b/scripts/api/data/metadatablocks/citation.tsv index b4c74bcd825..06b1bfe46d8 100644 --- a/scripts/api/data/metadatablocks/citation.tsv +++ b/scripts/api/data/metadatablocks/citation.tsv @@ -132,7 +132,7 @@ authorIdentifierScheme ISNI 1 http://isni.org/isni/ authorIdentifierScheme LCNA 2 http://id.loc.gov/authorities/names/ authorIdentifierScheme VIAF 3 https://viaf.org/viaf/ - authorIdentifierScheme GND 4 https://d-nb.info/gnd/ + authorIdentifierScheme GND 4 https://d-nb.info/gnd/ authorIdentifierScheme DAI 5 authorIdentifierScheme ResearcherID 6 authorIdentifierScheme ScopusID 7 From 3e340238112e1af3c5b2f6cc50c316e2b086d64a Mon Sep 17 00:00:00 2001 From: mderuijter Date: Tue, 4 Feb 2020 12:07:41 +0100 Subject: [PATCH 6/8] Implemented Two Columns displayFormat + value --- scripts/api/data/metadatablocks/citation.tsv | 12 +++++------ .../ControlledVocabularyValueDetail.java | 21 ++++++++++++------- .../dataverse/DatasetFieldCompoundValue.java | 5 ++--- .../iq/dataverse/DatasetFieldServiceBean.java | 6 +++--- .../dataverse/api/DatasetFieldServiceApi.java | 10 +++++---- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/scripts/api/data/metadatablocks/citation.tsv b/scripts/api/data/metadatablocks/citation.tsv index 9cb1d6f4c88..a0bf025647b 100644 --- a/scripts/api/data/metadatablocks/citation.tsv +++ b/scripts/api/data/metadatablocks/citation.tsv @@ -79,7 +79,7 @@ originOfSources Origin of Sources For historical materials, information about the origin of the sources and the rules followed in establishing the sources should be specified. textbox 75 FALSE FALSE FALSE FALSE FALSE FALSE citation characteristicOfSources Characteristic of Sources Noted Assessment of characteristics and source material. textbox 76 FALSE FALSE FALSE FALSE FALSE FALSE citation accessToSources Documentation and Access to Sources Level of documentation of the original sources. textbox 77 FALSE FALSE FALSE FALSE FALSE FALSE citation -#controlledVocabulary DatasetField Value identifier displayOrder detail +#controlledVocabulary DatasetField Value identifier displayOrder displayFormat detail subject Agricultural Sciences D01 0 subject Arts and Humanities D0 1 subject Astronomy and Astrophysics D1 2 @@ -128,11 +128,11 @@ contributorType Supervisor 14 contributorType Work Package Leader 15 contributorType Other 16 - authorIdentifierScheme ORCID 0 https://orcid.org/ - authorIdentifierScheme ISNI 1 http://isni.org/isni/ - authorIdentifierScheme LCNA 2 http://id.loc.gov/authorities/names/ - authorIdentifierScheme VIAF 3 https://viaf.org/viaf/ - authorIdentifierScheme GND 4 https://d-nb.info/gnd/ + authorIdentifierScheme ORCID 0 urlprefix https://orcid.org/ + authorIdentifierScheme ISNI 1 urlprefix http://isni.org/isni/ + authorIdentifierScheme LCNA 2 urlprefix http://id.loc.gov/authorities/names/ + authorIdentifierScheme VIAF 3 urlprefix https://viaf.org/viaf/ + authorIdentifierScheme GND 4 urlprefix https://d-nb.info/gnd/ authorIdentifierScheme DAI 5 authorIdentifierScheme ResearcherID 6 authorIdentifierScheme ScopusID 7 diff --git a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java index c56c50ad154..bcdf57c5ed8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java +++ b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java @@ -12,7 +12,7 @@ import java.io.Serializable; @Entity -@Table(indexes = {@Index(columnList="controlledvocabularyvalue_id")}) +@Table(indexes = {@Index(columnList = "controlledvocabularyvalue_id")}) public class ControlledVocabularyValueDetail implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -26,15 +26,22 @@ public void setId(Long id) { this.id = id; } - @Column(columnDefinition="TEXT") - private String urlPrefix; + @Column(columnDefinition = "TEXT") + private String displayFormat; - public String getUrlPrefix() { - return urlPrefix; + public String getDisplayFormat() { return displayFormat; } + + public void setDisplayFormat(String displayFormat) { this.displayFormat = displayFormat; } + + @Column(columnDefinition = "TEXT") + private String strValue; + + public String getStrValue() { + return strValue; } - public void setUrlPrefix(String urlPrefix) { - this.urlPrefix = urlPrefix; + public void setStrValue(String strValue) { + this.strValue = strValue; } @OneToOne diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index ce7139e1a18..2e0312dd012 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -14,7 +14,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.persistence.CascadeType; @@ -159,8 +158,8 @@ public Map getDisplayValueMap() { for (DatasetField childDatasetField : childDatasetFields) { if (referencesMap.containsKey("##"+childDatasetField.getDatasetFieldType().getName())){ if (childDatasetField.getSingleControlledVocabularyValue() != null){ - if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix().isEmpty()){ - referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getUrlPrefix()); + if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getDisplayFormat().isEmpty()){ + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getStrValue()); } else { referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getStrValue()); } diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java index 274aeba1c28..b432ffbd3e2 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java @@ -154,9 +154,9 @@ public ControlledVocabAlternate findControlledVocabAlternateByControlledVocabula } } - public ControlledVocabularyValueDetail findControlledVocabularyValueDetailByControlledVocabularyValueAndUrlPrefix(ControlledVocabularyValue cvv, String urlPrefix){ - TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ControlledVocabularyValueDetail AS o WHERE o.urlPrefix = :urlprefix AND o.controlledVocabularyValue = :cvv", ControlledVocabularyValueDetail.class); - typedQuery.setParameter("urlprefix", urlPrefix); + public ControlledVocabularyValueDetail findControlledVocabularyValueDetailByControlledVocabularyValueAndStrValue(ControlledVocabularyValue cvv, String strValue){ + TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ControlledVocabularyValueDetail AS o WHERE o.strValue = :strvalue AND o.controlledVocabularyValue = :cvv", ControlledVocabularyValueDetail.class); + typedQuery.setParameter("strvalue", strValue); typedQuery.setParameter("cvv", cvv); try { ControlledVocabularyValueDetail cvvd = typedQuery.getSingleResult(); diff --git a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java index 929a7f4ed1b..8e128226eb2 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java @@ -33,7 +33,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import static edu.harvard.iq.dataverse.util.json.JsonPrinter.asJsonArray; import edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder; @@ -412,15 +411,18 @@ private String parseControlledVocabulary(String[] values) { cvv.setStrValue(values[2]); cvv.setIdentifier(values[3]); cvv.setDisplayOrder(Integer.parseInt(values[4])); - if (values.length >= 6 && values[5] != null && !values[5].isEmpty()) { - ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndUrlPrefix(cvv, values[5]); + + if (values.length >= 7 && values[5] != null && !values[5].isEmpty() && values[6] != null && !values[6].isEmpty()) { + ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndStrValue(cvv, values[6]); if (cvvd == null) { cvvd = new ControlledVocabularyValueDetail(); cvvd.setControlledVocabularyValue(cvv); - cvvd.setUrlPrefix(values[5]); + cvvd.setDisplayFormat(values[5]); + cvvd.setStrValue(values[6]); cvv.setControlledVocabularyValueDetail(cvvd); } } + datasetFieldService.save(cvv); return cvv.getStrValue(); } From 67f20bd3acabe58f0812c3741b8c88628483d5cd Mon Sep 17 00:00:00 2001 From: mderuijter Date: Wed, 15 Jul 2020 14:06:36 +0200 Subject: [PATCH 7/8] implemented review feedback, cvv stores indepentent displayformat now in citation.tsv --- scripts/api/data/metadatablocks/citation.tsv | 14 +++++++------- .../dataverse/ControlledVocabularyValueDetail.java | 4 ++-- .../iq/dataverse/DatasetFieldCompoundValue.java | 9 ++++++--- .../iq/dataverse/DatasetFieldServiceBean.java | 6 +++--- .../iq/dataverse/api/DatasetFieldServiceApi.java | 7 ++++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/scripts/api/data/metadatablocks/citation.tsv b/scripts/api/data/metadatablocks/citation.tsv index a0bf025647b..6d4041ff999 100644 --- a/scripts/api/data/metadatablocks/citation.tsv +++ b/scripts/api/data/metadatablocks/citation.tsv @@ -12,7 +12,7 @@ authorName Name The author's Family Name, Given Name or the name of the organization responsible for this Dataset. FamilyName, GivenName or Organization text 8 #VALUE TRUE FALSE FALSE TRUE TRUE TRUE author citation authorAffiliation Affiliation The organization with which the author is affiliated. text 9 (#VALUE) TRUE FALSE FALSE TRUE TRUE FALSE author citation authorIdentifierScheme Identifier Scheme Name of the identifier scheme (ORCID, ISNI). text 10 - #VALUE: FALSE TRUE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifierScheme - authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. text 11 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier + authorIdentifier Identifier Uniquely identifies an individual author or organization, according to various schemes. textbox 11 ##authorIdentifierScheme FALSE FALSE FALSE FALSE TRUE FALSE author citation http://purl.org/spar/datacite/AgentIdentifier datasetContact Contact The contact(s) for this Dataset. none 12 FALSE FALSE TRUE FALSE TRUE FALSE citation datasetContactName Name The contact's Family Name, Given Name or the name of the organization. FamilyName, GivenName or Organization text 13 #VALUE FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation datasetContactAffiliation Affiliation The organization with which the contact is affiliated. text 14 (#VALUE) FALSE FALSE FALSE FALSE TRUE FALSE datasetContact citation @@ -79,7 +79,7 @@ originOfSources Origin of Sources For historical materials, information about the origin of the sources and the rules followed in establishing the sources should be specified. textbox 75 FALSE FALSE FALSE FALSE FALSE FALSE citation characteristicOfSources Characteristic of Sources Noted Assessment of characteristics and source material. textbox 76 FALSE FALSE FALSE FALSE FALSE FALSE citation accessToSources Documentation and Access to Sources Level of documentation of the original sources. textbox 77 FALSE FALSE FALSE FALSE FALSE FALSE citation -#controlledVocabulary DatasetField Value identifier displayOrder displayFormat detail +#controlledVocabulary DatasetField Value identifier displayOrder displayFormat subject Agricultural Sciences D01 0 subject Arts and Humanities D0 1 subject Astronomy and Astrophysics D1 2 @@ -128,11 +128,11 @@ contributorType Supervisor 14 contributorType Work Package Leader 15 contributorType Other 16 - authorIdentifierScheme ORCID 0 urlprefix https://orcid.org/ - authorIdentifierScheme ISNI 1 urlprefix http://isni.org/isni/ - authorIdentifierScheme LCNA 2 urlprefix http://id.loc.gov/authorities/names/ - authorIdentifierScheme VIAF 3 urlprefix https://viaf.org/viaf/ - authorIdentifierScheme GND 4 urlprefix https://d-nb.info/gnd/ + authorIdentifierScheme ORCID 0 #VALUE + authorIdentifierScheme ISNI 1 #VALUE + authorIdentifierScheme LCNA 2 #VALUE + authorIdentifierScheme VIAF 3 #VALUE + authorIdentifierScheme GND 4 #VALUE authorIdentifierScheme DAI 5 authorIdentifierScheme ResearcherID 6 authorIdentifierScheme ScopusID 7 diff --git a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java index bcdf57c5ed8..ea747a6a729 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java +++ b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java @@ -33,7 +33,7 @@ public void setId(Long id) { public void setDisplayFormat(String displayFormat) { this.displayFormat = displayFormat; } - @Column(columnDefinition = "TEXT") + /*@Column(columnDefinition = "TEXT") private String strValue; public String getStrValue() { @@ -42,7 +42,7 @@ public String getStrValue() { public void setStrValue(String strValue) { this.strValue = strValue; - } + }*/ @OneToOne @JoinColumn(name = "controlledvocabularyvalue_id", unique = true) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index 2e0312dd012..2ba685b09ca 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -5,6 +5,7 @@ */ package edu.harvard.iq.dataverse; +import edu.harvard.iq.dataverse.api.Access; import edu.harvard.iq.dataverse.util.BundleUtil; import edu.harvard.iq.dataverse.util.MarkupChecker; import java.io.Serializable; @@ -14,6 +15,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.persistence.CascadeType; @@ -159,12 +161,12 @@ public Map getDisplayValueMap() { if (referencesMap.containsKey("##"+childDatasetField.getDatasetFieldType().getName())){ if (childDatasetField.getSingleControlledVocabularyValue() != null){ if (childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail() != null && !childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getDisplayFormat().isEmpty()){ - referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getStrValue()); + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getControlledVocabularyValueDetail().getDisplayFormat()); } else { - referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getSingleControlledVocabularyValue().getStrValue()); + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), "#VALUE"); } } else { - referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), childDatasetField.getValue()); + referencesMap.put("##"+childDatasetField.getDatasetFieldType().getName(), "#VALUE"); } } } @@ -194,6 +196,7 @@ public Map getDisplayValueMap() { // replace the special values in the format (note: we replace #VALUE last since we don't // want any issues if the value itself has #NAME in it) + String displayValue = format .replaceAll(fieldName+"\\b", fieldValue) .replace("#NAME", childDatasetField.getDatasetFieldType().getTitle()) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java index b432ffbd3e2..81dbea746d1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java @@ -154,9 +154,9 @@ public ControlledVocabAlternate findControlledVocabAlternateByControlledVocabula } } - public ControlledVocabularyValueDetail findControlledVocabularyValueDetailByControlledVocabularyValueAndStrValue(ControlledVocabularyValue cvv, String strValue){ - TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ControlledVocabularyValueDetail AS o WHERE o.strValue = :strvalue AND o.controlledVocabularyValue = :cvv", ControlledVocabularyValueDetail.class); - typedQuery.setParameter("strvalue", strValue); + public ControlledVocabularyValueDetail findControlledVocabularyValueDetailByControlledVocabularyValueAndDisplayFormat(ControlledVocabularyValue cvv, String displayFormat){ + TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ControlledVocabularyValueDetail AS o WHERE o.displayFormat = :displayformat AND o.controlledVocabularyValue = :cvv", ControlledVocabularyValueDetail.class); + typedQuery.setParameter("displayformat", displayFormat); typedQuery.setParameter("cvv", cvv); try { ControlledVocabularyValueDetail cvvd = typedQuery.getSingleResult(); diff --git a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java index 0466b30b2fd..166eadedfc9 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApi.java @@ -448,6 +448,7 @@ private String parseDatasetField(String[] values) { private String parseControlledVocabulary(String[] values) { DatasetFieldType dsv = datasetFieldService.findByName(values[1]); + //See if it already exists /* Matching relies on assumption that only one cv value will exist for a given identifier or display value @@ -484,13 +485,13 @@ private String parseControlledVocabulary(String[] values) { cvv.setIdentifier(values[3]); cvv.setDisplayOrder(Integer.parseInt(values[4])); - if (values.length >= 7 && values[5] != null && !values[5].isEmpty() && values[6] != null && !values[6].isEmpty()) { - ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndStrValue(cvv, values[6]); + if (values.length >= 6 && values[5] != null && !values[5].isEmpty()) { + ControlledVocabularyValueDetail cvvd = datasetFieldService.findControlledVocabularyValueDetailByControlledVocabularyValueAndDisplayFormat(cvv, values[5]); if (cvvd == null) { cvvd = new ControlledVocabularyValueDetail(); cvvd.setControlledVocabularyValue(cvv); cvvd.setDisplayFormat(values[5]); - cvvd.setStrValue(values[6]); + //cvvd.setStrValue(values[6]); cvv.setControlledVocabularyValueDetail(cvvd); } } From 600b2422e161b37c179532594d5a9b1d2729f796 Mon Sep 17 00:00:00 2001 From: mderuijter Date: Wed, 15 Jul 2020 14:36:11 +0200 Subject: [PATCH 8/8] removed some commented code --- .../iq/dataverse/ControlledVocabularyValueDetail.java | 11 ----------- .../iq/dataverse/DatasetFieldCompoundValue.java | 1 - 2 files changed, 12 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java index ea747a6a729..b2692de3024 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java +++ b/src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValueDetail.java @@ -33,17 +33,6 @@ public void setId(Long id) { public void setDisplayFormat(String displayFormat) { this.displayFormat = displayFormat; } - /*@Column(columnDefinition = "TEXT") - private String strValue; - - public String getStrValue() { - return strValue; - } - - public void setStrValue(String strValue) { - this.strValue = strValue; - }*/ - @OneToOne @JoinColumn(name = "controlledvocabularyvalue_id", unique = true) private ControlledVocabularyValue controlledVocabularyValue; diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index 2ba685b09ca..bc9dded4775 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -15,7 +15,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.persistence.CascadeType;