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.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep;
|
||||||
|
|
||||||
/**
|
/* This class extends ArrayList rather than BaseTemplateModel so the template can simply
|
||||||
* Build the list of ontology properties for display on an individual profile page.
|
* call individual.propertyList. Otherwise, the class must declare a member list object
|
||||||
* @author rjy7
|
* 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.
|
private static final long serialVersionUID = 1L;
|
||||||
// Wait and see how much code remains here - if little, just put in IndividualTemplateModel.
|
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
||||||
public class PropertyListBuilder {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(PropertyListBuilder.class);
|
|
||||||
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
||||||
|
|
||||||
protected Individual subject;
|
private Individual subject;
|
||||||
protected VitroRequest vreq;
|
private VitroRequest vreq;
|
||||||
protected WebappDaoFactory wdf;
|
private WebappDaoFactory wdf;
|
||||||
|
|
||||||
PropertyListBuilder(Individual individual, VitroRequest vreq) {
|
GroupedPropertyList(Individual subject, VitroRequest vreq) {
|
||||||
this.subject = individual;
|
this.subject = subject;
|
||||||
this.vreq = vreq;
|
this.vreq = vreq;
|
||||||
this.wdf = vreq.getWebappDaoFactory();
|
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.
|
// Determine whether we're editing or not.
|
||||||
boolean userCanEditThisProfile = getEditingStatus();
|
boolean userCanEditThisProfile = getEditingStatus();
|
||||||
|
@ -97,21 +90,20 @@ 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
|
// Put the list into groups
|
||||||
List<PropertyGroup> groupList = addPropertiesToGroups(propertyList);
|
List<PropertyGroup> propertyGroupList = addPropertiesToGroups(propertyList);
|
||||||
|
|
||||||
// Build the template data model from the groupList
|
// Build the template data model from the groupList
|
||||||
List<PropertyGroupTemplateModel> groups = new ArrayList<PropertyGroupTemplateModel>(groupList.size());
|
//groups = new ArrayList<PropertyGroupTemplateModel>(propertyGroupList.size());
|
||||||
for (PropertyGroup pg : groupList) {
|
for (PropertyGroup pg : propertyGroupList) {
|
||||||
groups.add(new PropertyGroupTemplateModel(vreq, pg, subject));
|
add(new PropertyGroupTemplateModel(vreq, pg, subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true iff the user is editing.
|
* Return true iff the user is editing.
|
||||||
* These tests may change once self-editing issues are straightened out. What we really need to know
|
* 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() {
|
private boolean getEditingStatus() {
|
||||||
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
boolean isSelfEditing = VitroRequestPrep.isSelfEditing(vreq);
|
||||||
|
@ -382,4 +374,15 @@ public class PropertyListBuilder {
|
||||||
return 0;
|
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;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PropertyGroupTemplateModel> getPropertyList() {
|
public GroupedPropertyList getPropertyList() {
|
||||||
PropertyListBuilder propListBuilder = new PropertyListBuilder(individual, vreq);
|
return new GroupedPropertyList(individual, vreq);
|
||||||
return propListBuilder.getPropertyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue