Skip to content

Commit

Permalink
don't create add url if neither of 'select from existing' nor 'provid…
Browse files Browse the repository at this point in the history
…e selection' options set (#385)

Co-authored-by: Georgy Litvinov <georgy.litvinov@tib.eu>
  • Loading branch information
litvinovg and litvinovg committed Apr 27, 2023
1 parent 2535750 commit 6c9e215
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public String toString() {
}
}

protected void setAddUrl(Property property) {
protected void setAddUrl(ObjectProperty property) {
// Is the add link suppressed for this property?
if (property.isAddLinkSuppressed()) {
return;
Expand All @@ -125,6 +125,10 @@ protected void setAddUrl(Property property) {
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return;
}

if (isNotAllowedToCreateOrSelect(property)) {
return;
}

String rangeUri = (property instanceof ObjectProperty)
? ((ObjectProperty) property).getRangeVClassURI()
Expand Down Expand Up @@ -152,6 +156,10 @@ protected void setAddUrl(Property property) {
}
}

private boolean isNotAllowedToCreateOrSelect(ObjectProperty property) {
return !property.getSelectFromExisting() && !property.getOfferCreateNewOption();
}

/**
* Pull this into a protected method so we can stub it out in the unit tests.
* Other options:
Expand Down

0 comments on commit 6c9e215

Please sign in to comment.