diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/FauxProperty.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/FauxProperty.java index c3025b3ab..a7aebf510 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/FauxProperty.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/FauxProperty.java @@ -11,26 +11,36 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.RoleRestrictedProperty; /** * Represents a specialization on an ObjectProperty, only meaningful for * display. - * - * BaseURI is required, may not be null, and may not be modified. - * - * It would be nice to place the same restrictions on rangeURI, but it may be - * null when the FauxProperty is being created, and it may be modified. The DAO - * will need to check rangeURI for validity before accepting an insert or - * modification. - * - * TODO Can we do this more cleanly? Can handle this as two classes FauxProperty - * and NewFauxProperty, and have each class enforce its own internal - * constraints? For example, the range must not be null, must represent a valid - * class, and must be equal to or a subclass of the range of the base property. */ -public class FauxProperty extends BaseResourceBean implements ResourceBean, RoleRestrictedProperty { +public class FauxProperty extends BaseResourceBean implements ResourceBean, + RoleRestrictedProperty { + // Must be null on insert. Must not be null on update. Ignored on delete. + private String contextUri; + // Must be null on insert. Must not be null on update. Ignored on delete. + private String configUri; + + // Must not be null on insert or update. Partial identifier on delete. private String rangeURI; + // May be null. Partial identifier on delete. private String domainURI; private String rangeLabel; private String domainLabel; + private String groupURI; + + private String publicDescription; + + private int displayTier; + private int displayLimit; + + private boolean collateBySubclass; + private boolean selectFromExisting; + private boolean offerCreateNewOption; + + private String customEntryForm; + private String customListView; + /** * Arguments are in this order to mimic the relationship: subject ==> * property ==> object @@ -47,44 +57,150 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean, Role this.rangeURI = rangeURI; this.domainURI = domainURI; } - + public FauxProperty() { // This is required by OperationUtils.cloneBean() } - public void setRangeURI(String rangeURI) { - this.rangeURI = rangeURI; + public String getContextUri() { + return contextUri; + } + + public void setContextUri(String contextUri) { + this.contextUri = contextUri; + } + + public String getConfigUri() { + return configUri; + } + + public void setConfigUri(String configUri) { + this.configUri = configUri; + } + + // BaseURI becomes an alias for URI + public String getBaseURI() { + return getURI(); + } + + public void setBaseURI(String baseURI) { + setURI(baseURI); } public String getRangeURI() { return rangeURI; } - public void setRangeLabel(String rangeLabel) { - this.rangeLabel = rangeLabel; + public void setRangeURI(String rangeURI) { + this.rangeURI = rangeURI; } public String getRangeLabel() { return (rangeLabel == null) ? localName(rangeURI) : rangeLabel; } - public void setDomainURI(String domainURI) { - this.domainURI = domainURI; + public void setRangeLabel(String rangeLabel) { + this.rangeLabel = rangeLabel; } - + public String getDomainURI() { return domainURI; } - public void setDomainLabel(String domainLabel) { - this.domainLabel = domainLabel; + public void setDomainURI(String domainURI) { + this.domainURI = domainURI; } public String getDomainLabel() { return (domainLabel == null) ? (domainURI == null ? "null" : localName(domainURI)) : domainLabel; } - + + public void setDomainLabel(String domainLabel) { + this.domainLabel = domainLabel; + } + + public String getGroupURI() { + return groupURI; + } + + public void setGroupURI(String groupURI) { + this.groupURI = groupURI; + } + + // DisplayName becomes an alias for PickListName + public String getDisplayName() { + return getPickListName(); + } + + public void setDisplayName(String displayName) { + setPickListName(displayName); + } + + public String getPublicDescription() { + return publicDescription; + } + + public void setPublicDescription(String publicDescription) { + this.publicDescription = publicDescription; + } + + public int getDisplayTier() { + return displayTier; + } + + public void setDisplayTier(int displayTier) { + this.displayTier = displayTier; + } + + public int getDisplayLimit() { + return displayLimit; + } + + public void setDisplayLimit(int displayLimit) { + this.displayLimit = displayLimit; + } + + public boolean isCollateBySubclass() { + return collateBySubclass; + } + + public void setCollateBySubclass(boolean collateBySubclass) { + this.collateBySubclass = collateBySubclass; + } + + public boolean isSelectFromExisting() { + return selectFromExisting; + } + + public void setSelectFromExisting(boolean selectFromExisting) { + this.selectFromExisting = selectFromExisting; + } + + public boolean isOfferCreateNewOption() { + return offerCreateNewOption; + } + + public void setOfferCreateNewOption(boolean offerCreateNewOption) { + this.offerCreateNewOption = offerCreateNewOption; + } + + public String getCustomEntryForm() { + return customEntryForm; + } + + public void setCustomEntryForm(String customEntryForm) { + this.customEntryForm = customEntryForm; + } + + public String getCustomListView() { + return customListView; + } + + public void setCustomListView(String customListView) { + this.customListView = customListView; + } + private String localName(String uriString) { try { return createResource(uriString).getLocalName(); @@ -93,4 +209,18 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean, Role } } + @Override + public String toString() { + return "FauxProperty[domainURI=" + domainURI + ", baseUri=" + getURI() + + ", rangeURI=" + rangeURI + ", rangeLabel=" + rangeLabel + + ", domainLabel=" + domainLabel + ", pickListName=" + + getPickListName() + ", groupURI=" + groupURI + + "publicDescription=" + publicDescription + ", displayTier=" + + displayTier + ", displayLimit=" + displayLimit + + ", collateBySubclass=" + collateBySubclass + + ", selectFromExisting=" + selectFromExisting + + ", offerCreateNewOption=" + offerCreateNewOption + + ", customEntryForm=" + customEntryForm + ", customListView=" + + customListView + "]"; + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/FauxPropertyRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/FauxPropertyRetryController.java index fc606ee1f..ad328e240 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/FauxPropertyRetryController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/FauxPropertyRetryController.java @@ -2,8 +2,13 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; +import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.POLICY_NEUTRAL; + +import java.text.Collator; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,12 +26,16 @@ import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.Option; import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vedit.util.FormUtils; +import edu.cornell.mannlib.vedit.validator.Validator; +import edu.cornell.mannlib.vedit.validator.impl.RequiredFieldValidator; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionListener; import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty; import edu.cornell.mannlib.vitro.webapp.beans.Property; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.RoleLevelOptionsSetup; import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; @@ -81,6 +90,8 @@ public class FauxPropertyRetryController extends BaseEditController { private static class EpoPopulator { private final VitroRequest req; private final ServletContext ctx; + private final WebappDaoFactory wadf; + private final EditProcessObject epo; private final FauxPropertyDao fpDao; @@ -91,6 +102,7 @@ public class FauxPropertyRetryController extends BaseEditController { EpoPopulator(HttpServletRequest req, EditProcessObject epo) { this.req = new VitroRequest(req); this.ctx = req.getSession().getServletContext(); + this.wadf = ModelAccess.on(req).getWebappDaoFactory(POLICY_NEUTRAL); this.epo = epo; @@ -114,6 +126,8 @@ public class FauxPropertyRetryController extends BaseEditController { .getObjectPropertyDao() .getObjectPropertyByURI(beanForEditing.getURI()); + setFieldValidators(); + doABunchOfOtherJunk(); } @@ -141,10 +155,13 @@ public class FauxPropertyRetryController extends BaseEditController { return bean; } - private void doABunchOfOtherJunk() { - // set any validators - // TODO NONE YET + private void setFieldValidators() { + epo.getValidatorMap() + .put("RangeURI", + Arrays.asList(new Validator[] { new RequiredFieldValidator() })); + } + private void doABunchOfOtherJunk() { // set up any listeners epo.setChangeListenerList(Collections .singletonList(new PropertyRestrictionListener(ctx))); @@ -183,21 +200,52 @@ public class FauxPropertyRetryController extends BaseEditController { private Map> createOptionsMap() { Map> map = new HashMap<>(); - map.put("DomainVClassURI", + + map.put("GroupURI", createClassGroupOptionList()); + + map.put("DomainURI", createRootedVClassOptionList( baseProperty.getDomainVClassURI(), beanForEditing.getDomainURI())); - map.put("RangeVClassURI", + map.put("RangeURI", createRootedVClassOptionList( baseProperty.getRangeVClassURI(), beanForEditing.getRangeURI())); + + map.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri", + RoleLevelOptionsSetup.getDisplayOptionsList(beanForEditing)); + map.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri", + RoleLevelOptionsSetup.getUpdateOptionsList(beanForEditing)); + map.put("HiddenFromPublishBelowRoleLevelUsingRoleUri", + RoleLevelOptionsSetup.getPublishOptionsList(beanForEditing)); + return map; } + private List