From ba0c291ccd8fe68fc17b5bbe07b27a93e586888c Mon Sep 17 00:00:00 2001 From: Jim Blake Date: Wed, 1 Jun 2016 09:27:53 -0400 Subject: [PATCH] VIVO-1247, remove duplicate code used with ConfigurationBeanLoader. 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 c1d8c7f9..5ebb2fde 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) {