improvements to GroupedPropertyList : using context dao factory to determine applicable data properties, and then using request-specific dao factory to get language-correct versions of properties when editing
This commit is contained in:
parent
da1ea283ba
commit
c5a849e163
1 changed files with 33 additions and 1 deletions
|
@ -108,6 +108,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
if (editing) {
|
||||
mergeAllPossibleDataProperties(propertyList);
|
||||
propertyList = correctLanguageForProperties(propertyList);
|
||||
}
|
||||
|
||||
sort(propertyList);
|
||||
|
@ -129,6 +130,35 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// Use the language-filtering WebappDaoFactory to get the right version of
|
||||
// each property. When editing, the methods that add to the property list
|
||||
// are blissfully (and intentionally) language-unaware.
|
||||
private List<Property> correctLanguageForProperties(List<Property> properties) {
|
||||
List<Property> languageCorrectedProps = new ArrayList<Property>();
|
||||
for (Property p : properties) {
|
||||
Property correctedProp = null;
|
||||
if (p instanceof ObjectProperty) {
|
||||
ObjectProperty op = (ObjectProperty) p;
|
||||
correctedProp = wdf.getObjectPropertyDao()
|
||||
.getObjectPropertyByURIs(op.getURI(),
|
||||
op.getDomainVClassURI(), op.getRangeVClassURI());
|
||||
} else if (p instanceof DataProperty) {
|
||||
correctedProp = wdf.getDataPropertyDao()
|
||||
.getDataPropertyByURI(((DataProperty) p).getURI());
|
||||
} else {
|
||||
log.warn("Ignoring " + p.getURI() + " which is neither an " +
|
||||
"ObjectProperty nor a DatatypeProperty.");
|
||||
}
|
||||
if (correctedProp != null) {
|
||||
languageCorrectedProps.add(correctedProp);
|
||||
} else {
|
||||
log.error("Unable to retrieve property " + p.getURI() +
|
||||
" using the WebappDaoFactory associated with the request.");
|
||||
}
|
||||
}
|
||||
return languageCorrectedProps;
|
||||
}
|
||||
|
||||
// It's possible that an object property retrieved in the call to getPopulatedObjectPropertyList()
|
||||
// is now empty of statements, because if not editing, some statements without a linked individual
|
||||
|
@ -248,7 +278,9 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
protected void mergeAllPossibleDataProperties(List<Property> propertyList) {
|
||||
DataPropertyDao dpDao = wdf.getDataPropertyDao();
|
||||
// see comments in mergeAllPossibleObjectProperties() for the reason
|
||||
// that we need a neutral WebappDaoFactory here.
|
||||
DataPropertyDao dpDao = vreq.getLanguageNeutralWebappDaoFactory().getDataPropertyDao();
|
||||
Collection<DataProperty> allDatapropColl = dpDao
|
||||
.getAllPossibleDatapropsForIndividual(subject.getURI());
|
||||
if (allDatapropColl != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue