NIHVIVO-1333 Continued work on ontology property display on individual profile page.
This commit is contained in:
parent
4f909b3a6e
commit
bfd81d1327
10 changed files with 106 additions and 205 deletions
|
@ -8,8 +8,10 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
|
|
||||||
private static final String TYPE = "data";
|
private static final String TYPE = "data";
|
||||||
|
|
||||||
DataPropertyTemplateModel(DataProperty property) {
|
DataPropertyTemplateModel(DataProperty dp) {
|
||||||
super(property);
|
super(dp);
|
||||||
|
|
||||||
|
// get the data property statements from the db via sparql query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,4 +21,25 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String addLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String editLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String deleteLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,180 +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.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
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;
|
|
||||||
|
|
||||||
private List<PropertyGroupTemplateModel> groups;
|
|
||||||
private DummyPropertyGroupTemplateModel ungroupedGroup;
|
|
||||||
|
|
||||||
GroupedPropertyList(WebappDaoFactory wdf, PropertyList propertyList) {
|
|
||||||
|
|
||||||
// Get the property groups
|
|
||||||
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>
|
|
||||||
ungroupedGroup = 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()) {
|
|
||||||
ungroupedGroup = new DummyPropertyGroupTemplateModel(null);
|
|
||||||
}
|
|
||||||
groups.add(ungroupedGroup);
|
|
||||||
|
|
||||||
|
|
||||||
// if (groupedMode) {
|
|
||||||
// int groupsCount=0;
|
|
||||||
// try {
|
|
||||||
// groupsCount = populateGroupListWithProperties(pgDao,groupList,propertyList); //,groupForUngroupedProperties);
|
|
||||||
// } catch (Exception ex) {
|
|
||||||
// log.error("Exception on trying to populate groups list with properties: "+ex.getMessage());
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// int removedCount = pgDao.removeUnpopulatedGroups(groupList);
|
|
||||||
// if (removedCount == 0) {
|
|
||||||
// log.warn("Of "+groupsCount+" groups, none removed by removeUnpopulatedGroups");
|
|
||||||
// /* } else {
|
|
||||||
// log.warn("Of "+groupsCount+" groups, "+removedCount+" removed by removeUnpopulatedGroups"); */
|
|
||||||
// }
|
|
||||||
// groupsCount -= removedCount;
|
|
||||||
// //req.setAttribute("groupsCount", new Integer(groupsCount));
|
|
||||||
// if (groupsCount > 0) { //still
|
|
||||||
// for (PropertyGroup g : groupList) {
|
|
||||||
// int statementCount=0;
|
|
||||||
// if (g.getPropertyList()!=null && g.getPropertyList().size()>0) {
|
|
||||||
// for (Property p : g.getPropertyList()) {
|
|
||||||
// if (p instanceof ObjectProperty) {
|
|
||||||
// ObjectProperty op = (ObjectProperty)p;
|
|
||||||
// List<ObjectPropertyStatement> opStmts = op.getObjectPropertyStatements();
|
|
||||||
// if (op.getObjectPropertyStatements()!=null && opStmts.size()>0) {
|
|
||||||
// statementCount += opStmts.size();
|
|
||||||
//
|
|
||||||
// // If not collated, we need to apply custom sorting now.
|
|
||||||
// //applyCustomSortToUncollatedProperty(op, opStmts);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// g.setStatementCount(statementCount);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (Exception ex) {
|
|
||||||
// log.error("Exception on trying to prune groups list with properties: "+ex.getMessage());
|
|
||||||
// }
|
|
||||||
// propertyList.clear();
|
|
||||||
|
|
||||||
// } else { // ungrouped mode
|
|
||||||
// for (Property p : mergedPropertyList) {
|
|
||||||
// if (p instanceof ObjectProperty) {
|
|
||||||
// ObjectProperty op = (ObjectProperty)p;
|
|
||||||
// applyCustomSortToUncollatedProperty(op, op.getObjectPropertyStatements());
|
|
||||||
// }
|
|
||||||
// } }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// private int populateGroupListWithProperties(PropertyGroupDao pgDao, List<PropertyGroup> groupList, PropertyList propertyList) {//, String unassignedGroupName) {
|
|
||||||
// int count = groupList.size();
|
|
||||||
// PropertyGroup tempGroup = null;
|
|
||||||
// String unassignedGroupName = ""; //temp, for compilation
|
|
||||||
// if (unassignedGroupName!=null) {
|
|
||||||
// tempGroup = pgDao.createTempPropertyGroup(unassignedGroupName,MAX_GROUP_DISPLAY_RANK);
|
|
||||||
// log.debug("creating temp property group "+unassignedGroupName+" for any unassigned properties");
|
|
||||||
// }
|
|
||||||
// switch (count) {
|
|
||||||
// case 0: log.warn("groupsList has no groups on entering populateGroupsListWithProperties(); will create a new group \"other\"");
|
|
||||||
// break;
|
|
||||||
// case 1: break;
|
|
||||||
// default: try {
|
|
||||||
// Collections.sort(groupList);
|
|
||||||
// } catch (Exception ex) {
|
|
||||||
// log.error("Exception on sorting groupList in populateGroupListWithProperties()");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (count==0 && unassignedGroupName!=null) {
|
|
||||||
// groupList.add(tempGroup);
|
|
||||||
// }
|
|
||||||
// for (PropertyGroup pg : groupList) {
|
|
||||||
// if (pg.getPropertyList().size()>0) {
|
|
||||||
// pg.getPropertyList().clear();
|
|
||||||
// }
|
|
||||||
// List<PropertyTemplateModel> properties = propertyList.getProperties();
|
|
||||||
// for (PropertyTemplateModel ptm : properties) {
|
|
||||||
//
|
|
||||||
// Property p = ptm.getProperty();
|
|
||||||
// if (p.getURI() == null) {
|
|
||||||
// log.error("Property p has null URI in populateGroupsListWithProperties()");
|
|
||||||
// } else if (p.getGroupURI()==null) {
|
|
||||||
// if (tempGroup!=null) { // not assigned any group yet and are creating a group for unassigned properties
|
|
||||||
// if (!alreadyOnPropertyList(tempGroup.getPropertyList(),p)) {
|
|
||||||
// tempGroup.getPropertyList().add(p);
|
|
||||||
// log.debug("adding property "+p.getEditLabel()+" to members of temp group "+unassignedGroupName);
|
|
||||||
// }
|
|
||||||
// } // otherwise don't put that property on the list
|
|
||||||
// } else if (p.getGroupURI().equals(pg.getURI())) {
|
|
||||||
// if (!alreadyOnPropertyList(pg.getPropertyList(),p)) {
|
|
||||||
// pg.getPropertyList().add(p);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (pg.getPropertyList().size()>1) {
|
|
||||||
// try {
|
|
||||||
// Collections.sort(pg.getPropertyList(),new Property.DisplayComparatorIgnoringPropertyGroup());
|
|
||||||
// } catch (Exception ex) {
|
|
||||||
// log.error("Exception sorting property group "+pg.getName()+" property list: "+ex.getMessage());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (count>0 && tempGroup!=null && tempGroup.getPropertyList().size()>0) {
|
|
||||||
// groupList.add(tempGroup);
|
|
||||||
// }
|
|
||||||
// count = groupList.size();
|
|
||||||
// return count;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Public getters for templates
|
|
||||||
*/
|
|
||||||
|
|
||||||
public List<PropertyGroupTemplateModel> getGroups() {
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -153,10 +153,9 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PropertyGroup> getPropertyList() {
|
public List<PropertyGroupTemplateModel> 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 methods of the wrapped individual. It would be desirable to
|
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to
|
||||||
|
|
|
@ -21,4 +21,23 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
|
|
||||||
public abstract boolean getIsCollatedBySubtype();
|
public abstract boolean getIsCollatedBySubtype();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String addLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String editLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String deleteLink() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,43 @@
|
||||||
|
|
||||||
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.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
|
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.beans.PropertyGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
protected PropertyGroup group;
|
private String name;
|
||||||
protected List<PropertyTemplateModel> properties;
|
private List<PropertyTemplateModel> properties;
|
||||||
|
|
||||||
PropertyGroupTemplateModel() { }
|
PropertyGroupTemplateModel() { }
|
||||||
|
|
||||||
PropertyGroupTemplateModel(PropertyGroup group) {
|
PropertyGroupTemplateModel(PropertyGroup group) {
|
||||||
this.group = group;
|
this.name = group.getName();
|
||||||
|
|
||||||
|
List<Property> propertyList = group.getPropertyList();
|
||||||
|
properties = new ArrayList<PropertyTemplateModel>(propertyList.size());
|
||||||
|
for (Property p : propertyList) {
|
||||||
|
if (p instanceof ObjectProperty) {
|
||||||
|
ObjectProperty op = (ObjectProperty)p;
|
||||||
|
if (op.getCollateBySubclass()) {
|
||||||
|
properties.add(new CollatedObjectProperty(op));
|
||||||
|
} else {
|
||||||
|
properties.add(new UncollatedObjectProperty(op));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
properties.add(new DataPropertyTemplateModel((DataProperty)p));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return group.getName();
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PropertyTemplateModel> getProperties() {
|
public List<PropertyTemplateModel> getProperties() {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class PropertyListBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RY Create the list here first to get it working. Then consider moving to GroupedPropertyList constructor.
|
// RY Create the list here first to get it working. Then consider moving to GroupedPropertyList constructor.
|
||||||
protected List<PropertyGroup> getPropertyList() {
|
protected List<PropertyGroupTemplateModel> getPropertyList() {
|
||||||
|
|
||||||
// Determine whether we're editing or not.
|
// Determine whether we're editing or not.
|
||||||
boolean userCanEditThisProfile = getEditingStatus();
|
boolean userCanEditThisProfile = getEditingStatus();
|
||||||
|
@ -93,14 +93,19 @@ public class PropertyListBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(propertyList); //*** Does this do data and obj props, or just obj props??
|
sort(propertyList); //*** Does this do data and obj props, or just obj props??
|
||||||
|
|
||||||
|
// Put the list into groups
|
||||||
|
List<PropertyGroup> groupList = addPropertiesToGroups(propertyList);
|
||||||
|
|
||||||
|
// Build the template data model from the groupList
|
||||||
|
List<PropertyGroupTemplateModel> groups = new ArrayList<PropertyGroupTemplateModel>(groupList.size());
|
||||||
|
for (PropertyGroup pg : groupList) {
|
||||||
|
groups.add(new PropertyGroupTemplateModel(pg));
|
||||||
|
}
|
||||||
// *** ADD collation and statements here ***
|
// *** ADD collation and statements here ***
|
||||||
// Don't include custom sorting, since that will be handled from custom short views
|
// Don't include custom sorting, since that will be handled from custom short views
|
||||||
// We'll populate each item in the property list with its statements or subclass lists
|
// We'll populate each item in the property list with its statements or subclass lists
|
||||||
|
|
||||||
// Put the list into groups
|
|
||||||
//return new GroupedPropertyList(wdf, propertyList);
|
|
||||||
List<PropertyGroup> groups = addPropertiesToGroups(propertyList);
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,14 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
*/
|
*/
|
||||||
public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
|
private String name;
|
||||||
protected Property property;
|
protected Property property;
|
||||||
|
|
||||||
PropertyTemplateModel(Property propertry) {
|
PropertyTemplateModel(Property property) {
|
||||||
|
this.name = property.getLabel();
|
||||||
this.property = property;
|
this.property = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Property getProperty() {
|
|
||||||
return property;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getUri() {
|
|
||||||
return property.getURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
public String getAddLink() {
|
public String getAddLink() {
|
||||||
|
@ -31,5 +25,19 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getType();
|
public abstract String getType();
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// protected String getUri() {
|
||||||
|
// return property.getURI();
|
||||||
|
// }
|
||||||
|
|
||||||
|
public abstract String addLink();
|
||||||
|
|
||||||
|
public abstract String editLink();
|
||||||
|
|
||||||
|
public abstract String deleteLink();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
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.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** List of object property statements for an individual, where the objects belong to a single subclass **/
|
/** List of object property statements for an individual, where the objects belong to a single subclass **/
|
||||||
|
@ -11,10 +12,15 @@ public class SubclassList {
|
||||||
String name = null;
|
String name = null;
|
||||||
List<ObjectPropertyStatementTemplateModel> statements = null;
|
List<ObjectPropertyStatementTemplateModel> statements = null;
|
||||||
|
|
||||||
SubclassList(String name, List<ObjectPropertyStatementTemplateModel> statements) {
|
SubclassList(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.statements = statements;
|
this.statements = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
||||||
|
|
||||||
|
// get the obj property statements for this subclass from the db via sparql query
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Access methods for templates */
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class UncollatedObjectProperty extends ObjectPropertyTemplateModel {
|
||||||
UncollatedObjectProperty(ObjectProperty property) {
|
UncollatedObjectProperty(ObjectProperty property) {
|
||||||
super(property);
|
super(property);
|
||||||
statements = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
statements = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
||||||
|
|
||||||
|
// get the statements from the db via sparql query
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ObjectPropertyStatementTemplateModel> getStatements() {
|
public List<ObjectPropertyStatementTemplateModel> getStatements() {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#-- Now list the properties in the group -->
|
<#-- Now list the properties in the group -->
|
||||||
<p>Number of properties in group: ${group.propertyList?size}</p> <#-- testing -->
|
<p>Number of properties in group: ${group.properties?size}</p> <#-- temporary -->
|
||||||
<#--
|
<#--
|
||||||
<#list group.properties as property>
|
<#list group.properties as property>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue