NIHVIVO-1491 Move property list building routines into an object that will define methods to get and remove specific properties
This commit is contained in:
parent
0b1e24b7e9
commit
f03b69f309
3 changed files with 58 additions and 56 deletions
|
@ -7,7 +7,6 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -27,31 +26,25 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
||||
|
||||
/**
|
||||
* Build the list of ontology properties for display on an individual profile page.
|
||||
* @author rjy7
|
||||
*
|
||||
/* This class extends ArrayList rather than BaseTemplateModel so the template can simply
|
||||
* call individual.propertyList. Otherwise, the class must declare a member list object
|
||||
* and the template must call individual.propertyList.groups, which is semantically awkward.
|
||||
* But if we need the methods in BaseTemplateModel we'll have to do that.
|
||||
*/
|
||||
public class GroupedPropertyList extends ArrayList<PropertyGroupTemplateModel> {
|
||||
|
||||
// RY We may not need this class. Logic for building the list can be moved to GroupedPropertyList.java.
|
||||
// Wait and see how much code remains here - if little, just put in IndividualTemplateModel.
|
||||
public class PropertyListBuilder {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PropertyListBuilder.class);
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
||||
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
||||
|
||||
protected Individual subject;
|
||||
protected VitroRequest vreq;
|
||||
protected WebappDaoFactory wdf;
|
||||
private Individual subject;
|
||||
private VitroRequest vreq;
|
||||
private WebappDaoFactory wdf;
|
||||
|
||||
PropertyListBuilder(Individual individual, VitroRequest vreq) {
|
||||
this.subject = individual;
|
||||
GroupedPropertyList(Individual subject, VitroRequest vreq) {
|
||||
this.subject = subject;
|
||||
this.vreq = vreq;
|
||||
this.wdf = vreq.getWebappDaoFactory();
|
||||
}
|
||||
|
||||
// RY Create the list here first to get it working. Then consider moving to GroupedPropertyList constructor.
|
||||
protected List<PropertyGroupTemplateModel> getPropertyList() {
|
||||
|
||||
// Determine whether we're editing or not.
|
||||
boolean userCanEditThisProfile = getEditingStatus();
|
||||
|
@ -97,21 +90,20 @@ public class PropertyListBuilder {
|
|||
sort(propertyList); //*** Does this do data and obj props, or just obj props??
|
||||
|
||||
// Put the list into groups
|
||||
List<PropertyGroup> groupList = addPropertiesToGroups(propertyList);
|
||||
List<PropertyGroup> propertyGroupList = 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(vreq, pg, subject));
|
||||
//groups = new ArrayList<PropertyGroupTemplateModel>(propertyGroupList.size());
|
||||
for (PropertyGroup pg : propertyGroupList) {
|
||||
add(new PropertyGroupTemplateModel(vreq, pg, subject));
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true iff the user is editing.
|
||||
* These tests may change once self-editing issues are straightened out. What we really need to know
|
||||
* is whether the user can edit this profile, not whether in general they are an editor.
|
||||
* is whether the user can edit this profile, not whether in general he/she is an editor.
|
||||
*/
|
||||
private boolean getEditingStatus() {
|
||||
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
||||
|
@ -382,4 +374,15 @@ public class PropertyListBuilder {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Access methods for templates */
|
||||
|
||||
public PropertyTemplateModel get(String propertyUri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PropertyTemplateModel getAndRemoveFromList(String propertyUri) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,9 +122,8 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
return models;
|
||||
}
|
||||
|
||||
public List<PropertyGroupTemplateModel> getPropertyList() {
|
||||
PropertyListBuilder propListBuilder = new PropertyListBuilder(individual, vreq);
|
||||
return propListBuilder.getPropertyList();
|
||||
public GroupedPropertyList getPropertyList() {
|
||||
return new GroupedPropertyList(individual, vreq);
|
||||
}
|
||||
|
||||
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
<nav role="navigation">
|
||||
<ul id ="individual-tools-people" role="list">
|
||||
<li role="listitem"><a class="picto-font picto-uri" href="#">j</a></li>
|
||||
<li role="listitem"><a class="picto-font picto-pdf" href="#">F</a></li>
|
||||
<li role="listitem"><a class="picto-font picto-share" href="#">R</a></li>
|
||||
<li role="listitem"><a class="picto-font picto-uri" href="#">j</a></li>
|
||||
<li role="listitem"><a class="picto-font picto-pdf" href="#">F</a></li>
|
||||
<li role="listitem"><a class="picto-font picto-share" href="#">R</a></li>
|
||||
<li role="listitem"><a class="icon-rdf" href="#">RDF</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
Loading…
Add table
Reference in a new issue