tweaks to make the boolean values work.

This commit is contained in:
Jim Blake 2014-11-06 13:50:16 -05:00
parent daac8c3c4f
commit 1439c2195d
4 changed files with 54 additions and 10 deletions

View file

@ -24,6 +24,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
// May be null. Partial identifier on delete.
private String domainURI;
private String baseLabel;
private String rangeLabel;
private String domainLabel;
@ -95,6 +96,14 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
this.rangeURI = rangeURI;
}
public String getBaseLabel() {
return (baseLabel == null) ? localName(getBaseURI()) : baseLabel;
}
public void setBaseLabel(String baseLabel) {
this.baseLabel = baseLabel;
}
public String getRangeLabel() {
return (rangeLabel == null) ? localName(rangeURI) : rangeLabel;
}
@ -212,13 +221,13 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
@Override
public String toString() {
return "FauxProperty[domainURI=" + domainURI + ", baseUri=" + getURI()
+ ", rangeURI=" + rangeURI + ", rangeLabel=" + rangeLabel
+ ", domainLabel=" + domainLabel + ", pickListName="
+ getPickListName() + ", contextUri=" + contextUri
+ ", configUri=" + configUri + ", groupURI=" + groupURI
+ "publicDescription=" + publicDescription + ", displayTier="
+ displayTier + ", displayLimit=" + displayLimit
+ ", collateBySubclass=" + collateBySubclass
+ ", baseLabel=" + baseLabel + ", rangeURI=" + rangeURI
+ ", rangeLabel=" + rangeLabel + ", domainLabel=" + domainLabel
+ ", pickListName=" + getPickListName() + ", contextUri="
+ contextUri + ", configUri=" + configUri + ", groupURI="
+ groupURI + "publicDescription=" + publicDescription
+ ", displayTier=" + displayTier + ", displayLimit="
+ displayLimit + ", collateBySubclass=" + collateBySubclass
+ ", selectFromExisting=" + selectFromExisting
+ ", offerCreateNewOption=" + offerCreateNewOption
+ ", customEntryForm=" + customEntryForm + ", customListView="

View file

@ -127,12 +127,16 @@ public class FauxPropertyRetryController extends BaseEditController {
this.baseProperty = req.getUnfilteredWebappDaoFactory()
.getObjectPropertyDao()
.getObjectPropertyByURI(beanForEditing.getURI());
addCheckboxValuesToTheRequest();
setFieldValidators();
doABunchOfOtherJunk();
}
private String determineAction() {
return (req.getParameter("create") == null) ? "update" : "insert";
}
@ -170,9 +174,25 @@ public class FauxPropertyRetryController extends BaseEditController {
fp.setHiddenFromDisplayBelowRoleLevel(base.getHiddenFromDisplayBelowRoleLevel());
fp.setHiddenFromPublishBelowRoleLevel(base.getHiddenFromPublishBelowRoleLevel());
fp.setProhibitedFromUpdateBelowRoleLevel(base.getProhibitedFromUpdateBelowRoleLevel());
log.debug("Created new FauxProperty: " + fp);
return fp;
}
private void addCheckboxValuesToTheRequest() {
req.setAttribute("selectFromExisting",beanForEditing.isSelectFromExisting());
req.setAttribute("offerCreateNewOption", beanForEditing.isOfferCreateNewOption());
req.setAttribute("collateBySubclass", beanForEditing.isCollateBySubclass());
// checkboxes on HTML forms are pretty annoying : we don't know if
// someone *unchecked* a box, so we have to default to false on
// updates.
if (beanForEditing.getURI() != null) {
beanForEditing.setSelectFromExisting(false);
beanForEditing.setOfferCreateNewOption(false);
beanForEditing.setCollateBySubclass(false);
}
}
private void setFieldValidators() {
epo.getValidatorMap()
.put("RangeURI",

View file

@ -86,6 +86,15 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
this.models = new LockingOntModelSelector(wadf.getOntModelSelector());
}
/**
* Need to override this, so the boolean convenience methods will work off
* the correct model.
*/
@Override
protected OntModel getOntModel() {
return getOntModelSelector().getDisplayModel();
}
@Override
public List<FauxProperty> getFauxPropertiesForBaseUri(String uri) {
try (LockedOntModel displayModel = models.getDisplayModel().read()) {
@ -110,6 +119,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
fpList.add(fp);
}
}
log.debug("Located " + fpList.size() + " FauxProperties.");
return fpList;
}
}
@ -157,6 +167,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
FauxProperty fp = new FauxProperty(domainUri, baseUri, rangeUri);
fp.setContextUri(contextUri);
populateInstance(fp);
log.debug("Loaded FauxProperty: " + fp);
return fp;
}
}
@ -174,6 +185,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
FauxProperty fp = new FauxProperty(domainUri, baseUri, rangeUri);
fp.setContextUri(contexts.iterator().next().getContextUri());
populateInstance(fp);
log.debug("Loaded FauxProperty: " + fp);
return fp;
}
}
@ -259,6 +271,8 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
@Override
public void updateFauxProperty(FauxProperty fp) {
log.debug("Updating FauxProperty: " + fp);
try (LockedOntModel displayModel = models.getDisplayModel().read()) {
if (fp.getContextUri() == null) {
throw new IllegalStateException("ContextURI may not be null: "
@ -319,7 +333,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
fp.getCustomEntryForm(), displayModel);
updatePropertyStringValue(config, LIST_VIEW_FILE,
fp.getCustomListView(), displayModel);
updatePropertyResourceURIValue(config,
HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT, fp
.getHiddenFromDisplayBelowRoleLevel().getURI());
@ -385,6 +399,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
}
private void populateLabelsFromTBox(FauxProperty fp) {
fp.setBaseLabel(findLabelForClass(fp.getBaseURI()));
fp.setRangeLabel(findLabelForClass(fp.getRangeURI()));
fp.setDomainLabel(findLabelForClass(fp.getDomainURI()));
}
@ -426,7 +441,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
PROPERTY_OFFERCREATENEWOPTIONANNOT)));
fp.setCustomEntryForm(getPropertyStringValue(config,
PROPERTY_CUSTOMENTRYFORMANNOT));
fp.setHiddenFromDisplayBelowRoleLevel(getMostRestrictiveRoleLevel(
config, HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT));
fp.setHiddenFromPublishBelowRoleLevel(getMostRestrictiveRoleLevel(