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
|
@ -124,10 +124,6 @@
|
||||||
<listener>
|
<listener>
|
||||||
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
|
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
<listener>
|
|
||||||
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.setup.VivoPolicySetup</listener-class>
|
|
||||||
</listener>
|
|
||||||
|
|
||||||
<!--<listener>
|
<!--<listener>
|
||||||
<listener-class>
|
<listener-class>
|
||||||
|
@ -184,8 +180,7 @@
|
||||||
</listener-class>
|
</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<!-- Filters ********************************************************** -->
|
<!-- Filters ********************************************************** -->
|
||||||
<!-- in 2.4 spec, filter chain order is first by filter-mapping <url-pattern> order in web.xml,
|
<!-- 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 -->
|
then filter-mapping <servlet-name> order in web.xml -->
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -77,7 +78,8 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
||||||
if( obj == null || !(obj instanceof Individual))
|
if( obj == null || !(obj instanceof Individual))
|
||||||
throw new HelpException("EntityMergedPropertyListController requires request.attribute 'entity' to be of"
|
throw new HelpException("EntityMergedPropertyListController requires request.attribute 'entity' to be of"
|
||||||
+" type " + Individual.class.getName() );
|
+" type " + Individual.class.getName() );
|
||||||
Individual subject =(Individual)obj;
|
Individual subject =(Individual)obj;
|
||||||
|
subject = filterFromContext( subject );
|
||||||
|
|
||||||
// determine whether are just displaying populated properties or also interleaving unpopulated ones
|
// determine whether are just displaying populated properties or also interleaving unpopulated ones
|
||||||
boolean editMode = false;
|
boolean editMode = false;
|
||||||
|
@ -113,11 +115,14 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
||||||
|
|
||||||
List<Property> mergedPropertyList = new ArrayList<Property>();
|
List<Property> mergedPropertyList = new ArrayList<Property>();
|
||||||
// now first get the properties this entity actually has, presumably populated with statements
|
// now first get the properties this entity actually has, presumably populated with statements
|
||||||
List<ObjectProperty> objectPropertyList = subject.getObjectPropertyList();
|
List<ObjectProperty> objectPropertyList = subject.getObjectPropertyList();
|
||||||
|
|
||||||
for (ObjectProperty op : objectPropertyList) {
|
for (ObjectProperty op : objectPropertyList) {
|
||||||
if (!SUPPRESSED_OBJECT_PROPERTIES.contains(op)) {
|
if (!SUPPRESSED_OBJECT_PROPERTIES.contains(op)) {
|
||||||
op.setEditLabel(op.getDomainPublic());
|
op.setEditLabel(op.getDomainPublic());
|
||||||
mergedPropertyList.add(op);
|
mergedPropertyList.add(op);
|
||||||
|
}else{
|
||||||
|
log.debug("suppressed " + op.getURI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,9 +238,11 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
||||||
UnaryFunctor<List<Property>,List<Property>> entityPropertyListFilter = PropertyMaskingSetup.getEntityPropertyListFilter(getServletContext());
|
UnaryFunctor<List<Property>,List<Property>> entityPropertyListFilter = PropertyMaskingSetup.getEntityPropertyListFilter(getServletContext());
|
||||||
if (entityPropertyListFilter != null) {
|
if (entityPropertyListFilter != null) {
|
||||||
mergedPropertyList = entityPropertyListFilter.fn(mergedPropertyList);
|
mergedPropertyList = entityPropertyListFilter.fn(mergedPropertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.setAttribute("mergedList",mergedPropertyList);
|
req.setAttribute("mergedList",mergedPropertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.setAttribute("entity",subject);
|
req.setAttribute("entity",subject);
|
||||||
|
|
||||||
RequestDispatcher rd = req.getRequestDispatcher(groupedMode ? Controllers.ENTITY_MERGED_PROP_LIST_GROUPED_JSP : Controllers.ENTITY_MERGED_PROP_LIST_UNGROUPED_JSP);
|
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)
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException,IOException {
|
throws ServletException,IOException {
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
|
@ -538,5 +547,35 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
return directClasses;
|
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