NIHVIVO-1335, NIHVIVO-1510 Working on authorship list view and collated object properties: some reorganization to handle collated properties, but not displaying as collated yet.
This commit is contained in:
parent
1f0140dd2a
commit
6d06c76e05
8 changed files with 118 additions and 29 deletions
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -16,17 +20,24 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateModel {
|
public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateModel {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(CollatedObjectPropertyTemplateModel.class);
|
private static final Log log = LogFactory.getLog(CollatedObjectPropertyTemplateModel.class);
|
||||||
|
|
||||||
private Map<String, List<ObjectPropertyStatementTemplateModel>> subclasses;
|
private SortedMap<String, List<ObjectPropertyStatementTemplateModel>> subclasses;
|
||||||
|
|
||||||
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, VitroRequest vreq) throws Exception {
|
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, VitroRequest vreq) throws Exception {
|
||||||
super(op, subject, vreq);
|
super(op, subject, vreq);
|
||||||
|
|
||||||
|
// RY Temporarily throw an error because collation hasn't been implemented yet.
|
||||||
|
boolean error = true;
|
||||||
|
if (error) {
|
||||||
|
throw new Exception("Collated object property not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
/* Change the approach to collation:
|
/* Change the approach to collation:
|
||||||
* Custom views can get the subclasses in the query. Must use a term ?subclass - throw error if not.
|
* Custom views can get the subclasses in the query. Must use a term ?subclass - throw error if not.
|
||||||
* Default view: we may be able to figure out the class to get subclasses of by inspecting the property.
|
* Default view: we may be able to figure out the class to get subclasses of by inspecting the property.
|
||||||
|
@ -36,27 +47,58 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
* in the query. (The reverse is okay - uncollated property with a subclass term in the query.
|
* in the query. (The reverse is okay - uncollated property with a subclass term in the query.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// RY Temporarily throw an error because collation hasn't been implemented yet.
|
|
||||||
boolean error = true;
|
|
||||||
if (error) {
|
|
||||||
throw new Exception("Collated object property not implemented yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
ObjectPropertyStatementDao opDao = wdf.getObjectPropertyStatementDao();
|
ObjectPropertyStatementDao opDao = wdf.getObjectPropertyStatementDao();
|
||||||
String subjectUri = subject.getURI();
|
String subjectUri = subject.getURI();
|
||||||
String propertyUri = op.getURI();
|
String propertyUri = op.getURI();
|
||||||
List<Map<String, String>> statementData = opDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, getQueryString());
|
List<Map<String, String>> statementData = opDao.getObjectPropertyStatementsForIndividualByProperty(subjectUri, propertyUri, getQueryString());
|
||||||
subclasses = new HashMap<String, List<ObjectPropertyStatementTemplateModel>>(statementData.size());
|
|
||||||
// for (Map<String, Object> map : statementData) {
|
|
||||||
// statements.add(new ObjectPropertyStatementTemplateModel(subjectUri, propertyUri, map, wdf));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (statementData.size() > 0) {
|
Map<String, List<ObjectPropertyStatementTemplateModel>> unsortedSubclasses = hasCustomListView() ?
|
||||||
// String collationTarget = getCollationTarget();
|
collateCustomListView(subjectUri, propertyUri, statementData, vreq) :
|
||||||
// List<VClass> vclasses = getDirectVClasses(collationTarget, statementData);
|
collateDefaultListView(subjectUri, propertyUri, statementData, vreq);
|
||||||
// }
|
|
||||||
|
|
||||||
|
/* Sort by subclass name */
|
||||||
|
Comparator<String> comparer = new Comparator<String>() {
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
return o1.compareTo(o2);
|
||||||
|
}};
|
||||||
|
subclasses = new TreeMap<String, List<ObjectPropertyStatementTemplateModel>>(comparer);
|
||||||
|
subclasses.putAll(unsortedSubclasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, List<ObjectPropertyStatementTemplateModel>> collateCustomListView(String subjectUri,
|
||||||
|
String propertyUri, List<Map<String, String>> statementData, VitroRequest vreq) {
|
||||||
|
|
||||||
|
Map<String, List<ObjectPropertyStatementTemplateModel>> unsortedSubclasses =
|
||||||
|
new HashMap<String, List<ObjectPropertyStatementTemplateModel>>();
|
||||||
|
String currentSubclassUri = null;
|
||||||
|
List<ObjectPropertyStatementTemplateModel> currentList = null;
|
||||||
|
for (Map<String, String> map : statementData) {
|
||||||
|
String subclassUri = map.get("subclass");
|
||||||
|
if (!subclassUri.equals(currentSubclassUri)) {
|
||||||
|
currentSubclassUri = subclassUri;
|
||||||
|
currentList = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
||||||
|
String subclassName = getSubclassName(subclassUri, vreq);
|
||||||
|
unsortedSubclasses.put(subclassName, currentList);
|
||||||
|
}
|
||||||
|
currentList.add(new ObjectPropertyStatementTemplateModel(subjectUri, propertyUri, map));
|
||||||
|
}
|
||||||
|
return unsortedSubclasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, List<ObjectPropertyStatementTemplateModel>> collateDefaultListView(String subjectUri,
|
||||||
|
String propertyUri, List<Map<String, String>> statementData, VitroRequest vreq) {
|
||||||
|
|
||||||
|
Map<String, List<ObjectPropertyStatementTemplateModel>> unsortedSubclasses =
|
||||||
|
new HashMap<String, List<ObjectPropertyStatementTemplateModel>>();
|
||||||
|
return unsortedSubclasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSubclassName(String subclassUri, VitroRequest vreq) {
|
||||||
|
VClassDao vclassDao = vreq.getWebappDaoFactory().getVClassDao();
|
||||||
|
VClass vclass = vclassDao.getVClassByURI(subclassUri);
|
||||||
|
return vclass.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCollationTargetError() {
|
private String getCollationTargetError() {
|
||||||
|
@ -84,7 +126,7 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
public Map<String, List<ObjectPropertyStatementTemplateModel>> getCollatedStatements() {
|
public Map<String, List<ObjectPropertyStatementTemplateModel>> getSubclasses() {
|
||||||
return subclasses;
|
return subclasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,10 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
return config.collationTarget;
|
return config.collationTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean hasCustomListView() {
|
||||||
|
return !config.isDefaultConfig;
|
||||||
|
}
|
||||||
|
|
||||||
protected static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op, Individual subject, VitroRequest vreq) {
|
protected static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op, Individual subject, VitroRequest vreq) {
|
||||||
if (op.getCollateBySubclass()) {
|
if (op.getCollateBySubclass()) {
|
||||||
try {
|
try {
|
||||||
|
@ -92,6 +96,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
private static final String NODE_NAME_COLLATION_TARGET = "collation-target";
|
private static final String NODE_NAME_COLLATION_TARGET = "collation-target";
|
||||||
private static final String NODE_NAME_POSTPROCESSOR = "postprocessor";
|
private static final String NODE_NAME_POSTPROCESSOR = "postprocessor";
|
||||||
|
|
||||||
|
private boolean isDefaultConfig;
|
||||||
private String queryString;
|
private String queryString;
|
||||||
private String templateName;
|
private String templateName;
|
||||||
private String collationTarget;
|
private String collationTarget;
|
||||||
|
@ -134,6 +139,8 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
setValuesFromConfigFile(configFilePath);
|
setValuesFromConfigFile(configFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDefaultConfig = isDefaultConfig(configFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDefaultConfig(String configFileName) {
|
private boolean isDefaultConfig(String configFileName) {
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
?subject and ?property named as such. The object can be given any name, but it must be
|
?subject and ?property named as such. The object can be given any name, but it must be
|
||||||
included in the SELECT terms retrieved by the query. This is the statement that will be edited
|
included in the SELECT terms retrieved by the query. This is the statement that will be edited
|
||||||
from the edit links.
|
from the edit links.
|
||||||
|
- Each assertion or set of optional assertions must reference a different graph variable, so that
|
||||||
|
we do not impose a requirement about which assertions are in the same graph.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<list-view-config>
|
<list-view-config>
|
||||||
|
|
|
@ -37,13 +37,11 @@
|
||||||
<#-- Links -->
|
<#-- Links -->
|
||||||
<nav role="navigation">
|
<nav role="navigation">
|
||||||
<ul id ="individual-urls-people" role="list">
|
<ul id ="individual-urls-people" role="list">
|
||||||
<#if individual.links?has_content>
|
|
||||||
<@l.firstLastList>
|
<@l.firstLastList>
|
||||||
<#list individual.links as link>
|
<#list individual.links as link>
|
||||||
<li role="listitem"><a href="${link.url}">${link.anchor}</a></li>
|
<li role="listitem"><a href="${link.url}">${link.anchor}</a></li>
|
||||||
</#list>
|
</#list>
|
||||||
</@l.firstLastList>
|
</@l.firstLastList>
|
||||||
</#if>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
<#assign groupname = group.name(nameForOtherGroup)>
|
<#assign groupname = group.name(nameForOtherGroup)>
|
||||||
|
|
||||||
<section class="property-group" role="region">
|
<section class="property-group" role="region">
|
||||||
<nav class="scroll-up" role="navigation"><a href="#property-nav"><img src="${urls.images}/individual/scroll-up.png" alt="scroll to property group menus" /></a></nav>
|
<nav class="scroll-up" role="navigation">
|
||||||
|
<a href="#property-nav">
|
||||||
|
<img src="${urls.images}/individual/scroll-up.png" alt="scroll to property group menus" />
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<#-- Display the group heading -->
|
<#-- Display the group heading -->
|
||||||
<#if groupname?has_content>
|
<#if groupname?has_content>
|
||||||
|
@ -24,16 +28,41 @@
|
||||||
<ul class="property-list" role="list">
|
<ul class="property-list" role="list">
|
||||||
<#-- data property -->
|
<#-- data property -->
|
||||||
<#if property.type == "data">
|
<#if property.type == "data">
|
||||||
<#include "dataPropertyList-statements.ftl">
|
<@dataPropertyList property.statements />
|
||||||
|
|
||||||
<#-- object property -->
|
<#-- object property -->
|
||||||
<#elseif property.collatedBySubclass>
|
<#elseif property.collatedBySubclass>
|
||||||
<#include "objectPropertyList-collated.ftl">
|
<@objectPropertySubclassList property />
|
||||||
<#else>
|
<#else>
|
||||||
<#include "objectPropertyList-statements.ftl">
|
<@objectPropertyList property.statements property.template />
|
||||||
</#if>
|
</#if>
|
||||||
</ul>
|
</ul>
|
||||||
</article> <!-- end property -->
|
</article> <!-- end property -->
|
||||||
</#list>
|
</#list>
|
||||||
</section> <!-- end property-group -->
|
</section> <!-- end property-group -->
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
|
<#-----------------------------------------------------------------------------
|
||||||
|
Macros for generating property lists
|
||||||
|
------------------------------------------------------------------------------>
|
||||||
|
|
||||||
|
<#macro dataPropertyList statements>
|
||||||
|
<#list statements as statement>
|
||||||
|
<li role="listitem">${statement.value}</li>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro objectPropertySubclassList property>
|
||||||
|
<#list property.subclasses as subclass>
|
||||||
|
<h3>${subclass}</h3>
|
||||||
|
<@objectPropertyList subclass.statements property.template />
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro objectPropertyList statements template>
|
||||||
|
<#list statements as statement>
|
||||||
|
<li role="listitem">
|
||||||
|
<#include "${template}">
|
||||||
|
</li>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
|
@ -3,3 +3,8 @@
|
||||||
<#-- Template for collated object property statement list -->
|
<#-- Template for collated object property statement list -->
|
||||||
|
|
||||||
<p>Display of collated object property statements is in progress.</p>
|
<p>Display of collated object property statements is in progress.</p>
|
||||||
|
|
||||||
|
<#list property.subclasses as subclass>
|
||||||
|
<h3>${subclass}</h3>
|
||||||
|
<@listStatements subclass.statements />
|
||||||
|
</#list>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<#-- Template to list statements for an object property -->
|
<#-- Template to list statements for an object property -->
|
||||||
|
|
||||||
<#list property.statements as statement>
|
<#list statements as statement>
|
||||||
<li role="listitem">
|
<li role="listitem">
|
||||||
<#include "${property.template}">
|
<#include "${property.template}">
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for uncollated object property statement list -->
|
||||||
|
|
||||||
|
<#assign statements = property.statements>
|
||||||
|
<#include "objectPropertyList-statements.ftl">
|
Loading…
Add table
Reference in a new issue