NIHVIVO-1333 Initial version of class definitions used for individual ontology property display
This commit is contained in:
parent
c1372d5cc2
commit
150b8e1de2
14 changed files with 337 additions and 92 deletions
|
@ -0,0 +1,23 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CollatedObjectProperty extends ObjectPropertyTemplateModel {
|
||||||
|
|
||||||
|
private List<SubclassList> subclassList = null;
|
||||||
|
|
||||||
|
CollatedObjectProperty(String predicateUri) {
|
||||||
|
super(predicateUri);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubclassList> getSubclassList() {
|
||||||
|
return subclassList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubclassList> getStatements() {
|
||||||
|
return subclassList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
public class DataPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(DataPropertyStatementTemplateModel.class);
|
||||||
|
|
||||||
|
// not sure whether we want the objects or the uris here
|
||||||
|
//protected DataProperty property = null;
|
||||||
|
protected String predicateUri = null;
|
||||||
|
protected String data = null;
|
||||||
|
|
||||||
|
DataPropertyStatementTemplateModel(String subjectUri, String predicateUri, String data) {
|
||||||
|
this.subjectUri = subjectUri;
|
||||||
|
this.predicateUri = predicateUri;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
|
|
||||||
|
DataPropertyTemplateModel(String predicateUri) {
|
||||||
|
super(predicateUri);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
|
|
||||||
|
public class DummyPropertyGroupTemplateModel extends
|
||||||
|
PropertyGroupTemplateModel {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
DummyPropertyGroupTemplateModel(String name) {
|
||||||
|
super(null);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
|
/** The entire grouped property list for the subject.
|
||||||
|
* If there are no groups defined or populated, use a dummy group so that the
|
||||||
|
* display logic in the templates is the same whether or not there are groups.
|
||||||
|
* @author rjy7
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
||||||
|
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
||||||
|
|
||||||
|
/** Don't include these properties in the list. */
|
||||||
|
private static final Collection<String> SUPPRESSED_OBJECT_PROPERTIES = Collections
|
||||||
|
.unmodifiableCollection(Arrays
|
||||||
|
.asList(new String[] { VitroVocabulary.IND_MAIN_IMAGE }));
|
||||||
|
|
||||||
|
// RY Do we really want to store subject and vreq as members? Could just pass around.
|
||||||
|
private Individual subject;
|
||||||
|
private VitroRequest vreq;
|
||||||
|
|
||||||
|
private List<PropertyGroupTemplateModel> groups;
|
||||||
|
|
||||||
|
GroupedPropertyList(Individual subject, VitroRequest vreq) {
|
||||||
|
// RY Do we really want to store these as members? Could just pass around.
|
||||||
|
this.subject = subject;
|
||||||
|
this.vreq = vreq;
|
||||||
|
|
||||||
|
// Get the property groups
|
||||||
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
|
PropertyGroupDao pgDao = wdf.getPropertyGroupDao();
|
||||||
|
List<PropertyGroup> groupList = pgDao.getPublicGroups(false); // may be returned empty but not null
|
||||||
|
|
||||||
|
List<PropertyGroupTemplateModel> groups = new ArrayList<PropertyGroupTemplateModel>(groupList.size());
|
||||||
|
for (PropertyGroup g : groupList) {
|
||||||
|
groups.add(new PropertyGroupTemplateModel(g));
|
||||||
|
// Properties unassigned to any group go in a dummy group with name an empty string. Templates
|
||||||
|
// must test for <#if ! group.name?has_content> or <#if group.name == ""> or <#if group.name?length == 0>
|
||||||
|
groups.add(new DummyPropertyGroupTemplateModel(""));
|
||||||
|
}
|
||||||
|
// If there are no groups, create a dummy group, so that the template display logic is the same
|
||||||
|
// in both cases. Name is null. Templates must test for <#if ! group.name??>
|
||||||
|
if (groups.isEmpty()) {
|
||||||
|
groups.add(new DummyPropertyGroupTemplateModel(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true iff the user is editing.
|
||||||
|
*/
|
||||||
|
private boolean getEditingStatus() {
|
||||||
|
// These tests may change once self-editing issues are straightened out.
|
||||||
|
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
||||||
|
boolean isCurator = LoginStatusBean.getBean(vreq).isLoggedInAtLeast(LoginStatusBean.CURATOR);
|
||||||
|
return isSelfEditing || isCurator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public getters for templates
|
||||||
|
*/
|
||||||
|
|
||||||
|
public List<PropertyGroupTemplateModel> getGroups() {
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -152,17 +152,19 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Object> getPropertyList() {
|
public GroupedPropertyList getPropertyList() {
|
||||||
PropertyListBuilder propListBuilder = new PropertyListBuilder(individual, vreq);
|
// PropertyListBuilder propListBuilder = new PropertyListBuilder(individual, vreq);
|
||||||
return propListBuilder.getPropertyList();
|
// return propListBuilder.getPropertyList();
|
||||||
|
return new GroupedPropertyList(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These methods simply forward to the Individual methods. It would be desirable to implement a scheme
|
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to
|
||||||
for proxying or delegation so that the methods don't need to be simply listed here.
|
* implement a scheme for proxying or delegation so that the methods don't need to be simply listed here.
|
||||||
A Ruby-style method missing method would be ideal.
|
* A Ruby-style method missing method would be ideal.
|
||||||
Update: DynamicProxy doesn't work because the proxied object is of type Individual, so we cannot
|
* Update: DynamicProxy doesn't work because the proxied object is of type Individual, so we cannot
|
||||||
declare new methods here that are not declared in the Individual interface.
|
* declare new methods here that are not declared in the Individual interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return individual.getName();
|
return individual.getName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
public class ObjectPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(ObjectPropertyStatementTemplateModel.class);
|
||||||
|
|
||||||
|
// not sure whether we want the objects or the uris here
|
||||||
|
//protected ObjectProperty property = null;
|
||||||
|
protected String predicateUri = null;
|
||||||
|
//protected Individual object = null;
|
||||||
|
protected String objectUri = null;
|
||||||
|
|
||||||
|
ObjectPropertyStatementTemplateModel(String subjectUri, String predicateUri, String objectUri) {
|
||||||
|
this.subjectUri = subjectUri;
|
||||||
|
this.predicateUri = predicateUri;
|
||||||
|
this.objectUri = objectUri;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
|
|
||||||
|
ObjectPropertyTemplateModel(String predicateUri) {
|
||||||
|
super(predicateUri);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
|
public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
|
protected PropertyGroup group;
|
||||||
|
protected List<PropertyTemplateModel> properties;
|
||||||
|
|
||||||
|
PropertyGroupTemplateModel() { }
|
||||||
|
|
||||||
|
PropertyGroupTemplateModel(PropertyGroup group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return group.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PropertyTemplateModel> getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,83 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
|
||||||
|
|
||||||
public class PropertyListBuilder {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(PropertyListBuilder.class);
|
|
||||||
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
|
||||||
|
|
||||||
// Don't include these properties in the list.
|
|
||||||
private static final Collection<String> SUPPRESSED_OBJECT_PROPERTIES = Collections
|
|
||||||
.unmodifiableCollection(Arrays
|
|
||||||
.asList(new String[] { VitroVocabulary.IND_MAIN_IMAGE }));
|
|
||||||
|
|
||||||
protected Individual subject;
|
|
||||||
protected VitroRequest vreq;
|
|
||||||
|
|
||||||
PropertyListBuilder(Individual individual, VitroRequest vreq) {
|
|
||||||
this.subject = individual;
|
|
||||||
this.vreq = vreq;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<Object> getPropertyList() {
|
|
||||||
|
|
||||||
// Determine whether we're editing or not.
|
|
||||||
// These tests may change once self-editing issues are straightened out.
|
|
||||||
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
|
||||||
boolean isCurator = LoginStatusBean.getBean(vreq).isLoggedInAtLeast(LoginStatusBean.CURATOR);
|
|
||||||
boolean isEditing = isSelfEditing || isCurator;
|
|
||||||
|
|
||||||
// Determine whether to return a grouped or ungrouped property list.
|
|
||||||
// If the call specified ungrouped, use ungrouped.
|
|
||||||
// If the call specified grouped:
|
|
||||||
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
PropertyGroupDao pgDao = wdf.getPropertyGroupDao();
|
|
||||||
List <PropertyGroup> groupsList = pgDao.getPublicGroups(false); // may be returned empty but not null
|
|
||||||
// Use ungrouped if no property groups are defined
|
|
||||||
|
|
||||||
// If < 2 property groups are populated, we also want ungrouped, but we won't know that until we
|
|
||||||
// get the property list.
|
|
||||||
|
|
||||||
|
|
||||||
// Assemble the property list
|
|
||||||
List<Property> mergedPropertyList = new ArrayList<Property>();
|
|
||||||
// First get the properties this entity actually has, presumably populated with statements
|
|
||||||
List<ObjectProperty> objectPropertyList = subject.getObjectPropertyList();
|
|
||||||
|
|
||||||
for (ObjectProperty op : objectPropertyList) {
|
|
||||||
if (!SUPPRESSED_OBJECT_PROPERTIES.contains(op)) {
|
|
||||||
op.setEditLabel(op.getDomainPublic());
|
|
||||||
mergedPropertyList.add(op);
|
|
||||||
}else{
|
|
||||||
log.debug("suppressed " + op.getURI());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If < 2 property groups populated, we want ungrouped.
|
|
||||||
// This can just be handled by not including a group, or using an "empty" group with no name.
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
|
public abstract class PropertyStatementTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(PropertyStatementTemplateModel.class);
|
||||||
|
|
||||||
|
protected Individual subject = null; // not sure whether we want subject, or subject uri
|
||||||
|
protected String subjectUri = null;
|
||||||
|
|
||||||
|
|
||||||
|
public String getEditLink() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeleteLink() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the property statement list for a single property of an individual.
|
||||||
|
*/
|
||||||
|
public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
|
// Not sure whether we need the property or the uri.
|
||||||
|
protected String predicateUri = null;
|
||||||
|
|
||||||
|
PropertyTemplateModel(String predicateUri) {
|
||||||
|
this.predicateUri = predicateUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddLink() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** List of object property statements for an individual, where the objects belong to a single subclass **/
|
||||||
|
|
||||||
|
public class SubclassList {
|
||||||
|
|
||||||
|
String name = null;
|
||||||
|
List<ObjectPropertyStatementTemplateModel> statements = null;
|
||||||
|
|
||||||
|
SubclassList(String name, List<ObjectPropertyStatementTemplateModel> statements) {
|
||||||
|
this.name = name;
|
||||||
|
this.statements = statements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ObjectPropertyStatementTemplateModel> getStatements() {
|
||||||
|
return statements;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UncollatedObjectProperty extends ObjectPropertyTemplateModel {
|
||||||
|
|
||||||
|
private List<ObjectPropertyStatementTemplateModel> statements = null;
|
||||||
|
|
||||||
|
UncollatedObjectProperty(String predicateUri) {
|
||||||
|
super(predicateUri);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ObjectPropertyStatementTemplateModel> getStatements() {
|
||||||
|
return statements;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue