From 15638f6ac10f45fe4165f967a92086bedd37893f Mon Sep 17 00:00:00 2001 From: Jim Blake Date: Tue, 3 Jan 2017 12:16:38 -0500 Subject: [PATCH] VIVO-1247, remove duplicate code used with ConfigurationBeanLoader. (#47) Now that the @Property annotation includes cardinality parameters, we can remove a lot of duplicate code. --- .../extensions/LabelsAcrossContextNodes.java | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/extensions/LabelsAcrossContextNodes.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/extensions/LabelsAcrossContextNodes.java index 90e13034..64d07580 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/extensions/LabelsAcrossContextNodes.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/extensions/LabelsAcrossContextNodes.java @@ -104,31 +104,19 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder, this.rdfService = models.getRDFService(); } - @Property(uri = "http://www.w3.org/2000/01/rdf-schema#label") + @Property(uri = "http://www.w3.org/2000/01/rdf-schema#label", maxOccurs = 1) public void setLabel(String l) { label = l; } - @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasIncomingProperty") + @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasIncomingProperty", minOccurs = 1, maxOccurs = 1) public void setIncomingProperty(String incomingUri) { - if (incomingPropertyUri == null) { - incomingPropertyUri = incomingUri; - } else { - throw new IllegalStateException( - "Configuration includes multiple declarations for hasIncomingProperty: " - + incomingPropertyUri + ", and " + incomingUri); - } + incomingPropertyUri = incomingUri; } - @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasOutgoingProperty") + @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasOutgoingProperty", minOccurs = 1, maxOccurs = 1) public void setOutgoingProperty(String outgoingUri) { - if (outgoingPropertyUri == null) { - outgoingPropertyUri = outgoingUri; - } else { - throw new IllegalStateException( - "Configuration includes multiple declarations for hasOutgoingProperty: " - + outgoingPropertyUri + ", and " + outgoingUri); - } + outgoingPropertyUri = outgoingUri; } @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasTypeRestriction") @@ -149,14 +137,6 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder, formatRestrictions(typeRestrictions), formatRestrictions(contextNodeClasses)); } - if (incomingPropertyUri == null) { - throw new IllegalStateException( - "Configuration did not declare hasIncomingProperty."); - } - if (outgoingPropertyUri == null) { - throw new IllegalStateException( - "Configuration did not declare hasOutgoingProperty."); - } } private String formatRestrictions(Set uris) {