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.
This commit is contained in:
Jim Blake 2017-01-03 12:16:38 -05:00 committed by GitHub
parent 877b54f4a6
commit 15638f6ac1

View file

@ -104,31 +104,19 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
this.rdfService = models.getRDFService(); 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) { public void setLabel(String l) {
label = 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) { public void setIncomingProperty(String incomingUri) {
if (incomingPropertyUri == null) { incomingPropertyUri = incomingUri;
incomingPropertyUri = incomingUri;
} else {
throw new IllegalStateException(
"Configuration includes multiple declarations for hasIncomingProperty: "
+ incomingPropertyUri + ", and " + 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) { public void setOutgoingProperty(String outgoingUri) {
if (outgoingPropertyUri == null) { outgoingPropertyUri = outgoingUri;
outgoingPropertyUri = outgoingUri;
} else {
throw new IllegalStateException(
"Configuration includes multiple declarations for hasOutgoingProperty: "
+ outgoingPropertyUri + ", and " + outgoingUri);
}
} }
@Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasTypeRestriction") @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasTypeRestriction")
@ -149,14 +137,6 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
formatRestrictions(typeRestrictions), formatRestrictions(typeRestrictions),
formatRestrictions(contextNodeClasses)); 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<String> uris) { private String formatRestrictions(Set<String> uris) {