Merge to trunk. Adding filtering to EntityMergedPropertyListcontroller NIHVIVO-984
This commit is contained in:
parent
2be346ee67
commit
0b186aaf20
2 changed files with 45 additions and 11 deletions
|
@ -125,10 +125,6 @@
|
|||
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
|
||||
</listener>
|
||||
|
||||
<listener>
|
||||
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.setup.VivoPolicySetup</listener-class>
|
||||
</listener>
|
||||
|
||||
<!--<listener>
|
||||
<listener-class>
|
||||
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
|
||||
|
@ -185,7 +181,6 @@
|
|||
</listener>
|
||||
-->
|
||||
|
||||
|
||||
<!-- Filters ********************************************************** -->
|
||||
<!-- in 2.4 spec, filter chain order is first by filter-mapping <url-pattern> order in web.xml,
|
||||
then filter-mapping <servlet-name> order in web.xml -->
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -78,6 +79,7 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
|||
throw new HelpException("EntityMergedPropertyListController requires request.attribute 'entity' to be of"
|
||||
+" type " + Individual.class.getName() );
|
||||
Individual subject =(Individual)obj;
|
||||
subject = filterFromContext( subject );
|
||||
|
||||
// determine whether are just displaying populated properties or also interleaving unpopulated ones
|
||||
boolean editMode = false;
|
||||
|
@ -114,10 +116,13 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
|||
List<Property> mergedPropertyList = new ArrayList<Property>();
|
||||
// now 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,8 +239,10 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
|||
if (entityPropertyListFilter != null) {
|
||||
mergedPropertyList = entityPropertyListFilter.fn(mergedPropertyList);
|
||||
}
|
||||
|
||||
req.setAttribute("mergedList",mergedPropertyList);
|
||||
}
|
||||
|
||||
req.setAttribute("entity",subject);
|
||||
|
||||
RequestDispatcher rd = req.getRequestDispatcher(groupedMode ? Controllers.ENTITY_MERGED_PROP_LIST_GROUPED_JSP : Controllers.ENTITY_MERGED_PROP_LIST_UNGROUPED_JSP);
|
||||
|
@ -251,6 +258,8 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException,IOException {
|
||||
doGet(request, response);
|
||||
|
@ -539,4 +548,34 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
|||
return directClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for filter in servlet context and filter properties with it if there is one.
|
||||
*
|
||||
* This allows a vitro instance to have specialized filtering for display. It was originally
|
||||
* created to deal with problems caused by custom short views.
|
||||
* *
|
||||
* @param objectPropertyList
|
||||
* @param wdf
|
||||
* @return
|
||||
*/
|
||||
private Individual filterFromContext(Individual ind ) {
|
||||
try{
|
||||
UnaryFunctor<Individual,Individual> filter = getMergedPropertyListFilter(getServletContext());
|
||||
if( filter == null )
|
||||
return ind;
|
||||
else
|
||||
return filter.fn(ind);
|
||||
}catch(Throwable t){
|
||||
log.error(t,t);
|
||||
}
|
||||
return ind;
|
||||
}
|
||||
|
||||
public static void setMergedPropertyListFilter( UnaryFunctor<Individual,Individual>fn, ServletContext sc){
|
||||
sc.setAttribute("EntityMergedPropertyListController.toFilteringIndividual", fn);
|
||||
}
|
||||
|
||||
public static UnaryFunctor<Individual,Individual> getMergedPropertyListFilter( ServletContext sc){
|
||||
return(UnaryFunctor<Individual,Individual>)sc.getAttribute("EntityMergedPropertyListController.toFilteringIndividual");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue