Mercurial > hg > ismi-richfaces
changeset 207:91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
author | casties |
---|---|
date | Mon, 26 Aug 2019 16:06:55 +0200 |
parents | 111fc1d17019 |
children | c1f509c69e9d |
files | src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java src/main/java/de/mpiwg/itgroup/ismi/merge/MissingRelationsBean.java src/main/webapp/clean/components/emptyReference.xhtml src/main/webapp/clean/components/lostFloruit.xhtml src/main/webapp/clean/missingRelations.xhtml |
diffstat | 6 files changed, 451 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Mon Aug 05 19:45:39 2019 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Mon Aug 26 16:06:55 2019 +0200 @@ -218,13 +218,15 @@ } - public void searchByAttributes() throws Exception { + public void searchByAttributes(List<AttributeFilter> filterList) throws Exception { this.resultMode = MODE_ADVANCED; this.setPage(""); this.entities = new ArrayList<Entity>(); this.currentEntities = new ArrayList<Entity>(); - List<AttributeFilter> filterList = new ArrayList<AttributeFilter>(); + if (filterList == null) { + filterList = new ArrayList<AttributeFilter>(); + } this.resultSummaryMsg = ""; Map<Entity, Attribute> resultMap = new HashMap<Entity, Attribute>(); @@ -356,7 +358,7 @@ public String actionSearchByAttributes() { try { - this.searchByAttributes(); + this.searchByAttributes(null); } catch (Exception e) { printInternalError(e); logger.error(e.getMessage(), e);
--- a/src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java Mon Aug 05 19:45:39 2019 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java Mon Aug 26 16:06:55 2019 +0200 @@ -10,6 +10,7 @@ import org.mpi.openmind.repository.bo.Attribute; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.bo.Relation; +import org.mpi.openmind.repository.services.utils.AttributeFilter; import org.mpi.openmind.repository.services.utils.RelationFilter; /** @@ -246,6 +247,66 @@ } /** + * Loads all entities of this.objectClass matching the given AttributeFilters. + * + * Currently filter.name has to be set. + * + * Requires all AttributeFilters to match. + * + * @throws Exception + */ + public void searchByAttributes2(List<AttributeFilter> attributeFilters) { + logger.debug("Start searchByAttbitutes2..."); + this.resultMode = MODE_ADVANCED; + this.setPage(""); + this.entities = new ArrayList<Entity>(); + this.currentEntities = new ArrayList<Entity>(); + this.resultSummaryMsg = ""; + + /* + * get all entities and filter result (by attribute) + */ + List<Entity> resultList = getWrapper().getEntitiesByDef(this.objectClass); + for (Entity entity : resultList) { + if (entity.isLightweight()) { + entity = getWrapper().getEntityContent(entity); + } + boolean condFailed = false; + for (AttributeFilter filter : attributeFilters) { + if (filter.name != null) { + Attribute att = entity.getAttributeByName(filter.name); + if (att != null && StringUtils.isNotBlank(att.getValue())) { + // attribute has a value + if (filter.attributeMissing) { + condFailed = true; + break; + } + if (filter.ownValue != null && ! att.getValue().equals(filter.ownValue)) { + condFailed = true; + break; + } + } else { + if (!filter.attributeMissing) { + condFailed = true; + break; + } + } + } + } + if (!condFailed) { + // all conditions matched + entities.add(entity); + } + } + + // sort List (by ownValue) + Collections.sort(entities); + + updateEntities(entities); + logger.debug("Done searchByAttributes."); + } + + /** * @return the sortAttributeName */ public String getSortAttributeName() {
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/MissingRelationsBean.java Mon Aug 05 19:45:39 2019 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/MissingRelationsBean.java Mon Aug 26 16:06:55 2019 +0200 @@ -6,6 +6,7 @@ import org.apache.log4j.Logger; import org.mpi.openmind.repository.bo.Entity; +import org.mpi.openmind.repository.services.utils.AttributeFilter; import org.mpi.openmind.repository.services.utils.RelationFilter; import org.richfaces.event.ItemChangeEvent; @@ -13,7 +14,7 @@ import de.mpiwg.itgroup.ismi.browse.FullEntityRepositoryBean; import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; -public class MissingRelationsBean extends AbstractISMIBean implements Serializable{ +public class MissingRelationsBean extends AbstractISMIBean implements Serializable { private static Logger logger = Logger.getLogger(MissingRelationsBean.class); @@ -209,11 +210,32 @@ logger.debug("Done findLostAlias."); } + public void actionFindLostFloruit() { + logger.debug("Start findLostFloruit..."); + List<RelationFilter> relFilters = new ArrayList<RelationFilter>(); + /* + * find FLORUIT_DATE without relation + */ + browseBean = new FullEntityRepositoryBean(); + browseBean.setObjectClass(FLORUIT_DATE); + RelationFilter relFilter = new RelationFilter(); + relFilter.relObjectClass = "*"; + relFilter.tarObjectClass = "*"; + relFilter.relationMissing = true; + relFilters.add(relFilter); + try { + browseBean.searchByRelations(relFilters); + } catch (Exception e) { + logger.error(e); + } + logger.debug("Done findLostFloruit."); + } + public void actionFindLostReference() { logger.debug("Start findLostReference..."); List<RelationFilter> relFilters = new ArrayList<RelationFilter>(); /* - * find ALIAS without relation + * find REFERENCE without relation */ browseBean = new FullEntityRepositoryBean(); browseBean.setObjectClass(REFERENCE); @@ -230,6 +252,27 @@ logger.debug("Done findLostReference."); } + public void actionFindEmptyReference() { + logger.debug("Start findEmptyReference..."); + ArrayList<AttributeFilter> filters = new ArrayList<AttributeFilter>(); + /* + * find REFERENCE without endnote-id + */ + browseBean = new FullEntityRepositoryBean(); + browseBean.setObjectClass(REFERENCE); + AttributeFilter filter = new AttributeFilter(); + filter.entObjectClass = REFERENCE; + filter.name = "endnote-id"; + filter.attributeMissing = true; + filters.add(filter); + try { + browseBean.searchByAttributes2(filters); + } catch (Exception e) { + logger.error(e); + } + logger.debug("Done findEmptyReference."); + } + /** * Delete the selected Entities. * @return
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/clean/components/emptyReference.xhtml Mon Aug 26 16:06:55 2019 +0200 @@ -0,0 +1,166 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich"> + +<body> + <ui:composition> + + <h2 style="color:black">References without endnode-id</h2> + + <h:panelGrid columns="3" styleClass="displayPanel" + columnClasses="displayPanelColumn01,displayPanelColumn02"> + + <a4j:commandButton value="Show references without endnote-id" + actionListener="#{Session.missingRelations.actionFindEmptyReference}" + render="showEReferencePanel,emptyReferenceButton" /> + <h:outputText/> + <h:outputText/> + + </h:panelGrid> + + <h:panelGrid id="showEReferencePanel" columns="1" + style="margin-left: auto; margin-right: auto; text-align: center; width: 100%;"> + + <h:outputText + value="#{Session.missingRelations.browseBean.resultSummaryMsg}" + rendered="#{!empty Session.missingRelations.browseBean.resultSummaryMsg}" + styleClass="summaryMsg" /> + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:outputText value="go to page" styleClass="sumaryMsg" /> + <h:inputText value="#{Session.missingRelations.browseBean.page}" + size="4" /> + <h:commandButton value="submit" + actionListener="#{Session.missingRelations.browseBean.actionGoToPageAdvancedResult}" /> + <h:outputText value=" #{Session.missingRelations.browseBean.pageMsg}" + rendered="#{!empty Session.missingRelations.browseBean.pageMsg}" + style="color:red" /> + </h:column> + + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:panelGroup> + <h:commandButton + image="/resources/css/xp/css-images/arrow-first.gif" + style="border:none;" title="First Page" + action="#{Session.missingRelations.browseBean.advancedFirst}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-fr.gif" + style="border:none;" title="Fast Backwards" + action="#{Session.missingRelations.browseBean.advancedFastRewind}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-previous.gif" + style="border:none;" title="Previous Page" + action="#{Session.missingRelations.browseBean.advancedPrevious}" /> + + <h:outputText + value="#{Session.missingRelations.browseBean.advancedPaginator.recordStatus}" + styleClass="sumaryMsg" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-next.gif" + style="border:none;" title="Next Page" + action="#{Session.missingRelations.browseBean.advancedNext}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-ff.gif" + style="border:none;" title="Fast Forward" + action="#{Session.missingRelations.browseBean.advancedFastForward}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-last.gif" + style="border:none;" title="Last Page" + action="#{Session.missingRelations.browseBean.advancedLast}" /> + </h:panelGroup> + </h:column> + + <rich:dataTable id="EReferenceDataTable" rows="30" + value="#{Session.missingRelations.browseBean.currentEntities}" + rendered="#{!empty Session.missingRelations.browseBean.currentEntities}" + var="entity" styleClass="rsPanel" columnClasses="rsPanelColumn"> + <h:column style="text-align:left"> + <f:facet name="header">Reference</f:facet> + <h:outputLink target="_blank" + value="#{ApplicationBean1.root}/browse/entityDetails.xhtml?eid=#{entity.id}"> + <h:outputText + value="#{entity.ownValue} [#{entity.id}]" /> + </h:outputLink> + <h:commandButton + action="#{Session.missingRelations.browseBean.actionEdit}" + rendered="#{Session.canEdit}" + image="/resources/css/xp/css-images/edit16.gif" + title="Edit this entity" /> + </h:column> + <h:column style="text-align:left"> + <f:facet name="header">State</f:facet> + <h:outputText value="#{entity.privacity}" /> + </h:column> + </rich:dataTable> + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:panelGroup> + <h:commandButton + image="/resources/css/xp/css-images/arrow-first.gif" + style="border:none;" title="First Page" + action="#{Session.missingRelations.browseBean.advancedFirst}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-fr.gif" + style="border:none;" title="Fast Backwards" + action="#{Session.missingRelations.browseBean.advancedFastRewind}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-previous.gif" + style="border:none;" title="Previous Page" + action="#{Session.missingRelations.browseBean.advancedPrevious}" /> + + <h:outputText + value="#{Session.missingRelations.browseBean.advancedPaginator.recordStatus}" + styleClass="sumaryMsg" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-next.gif" + style="border:none;" title="Next Page" + action="#{Session.missingRelations.browseBean.advancedNext}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-ff.gif" + style="border:none;" title="Fast Forward" + action="#{Session.missingRelations.browseBean.advancedFastForward}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-last.gif" + style="border:none;" title="Last Page" + action="#{Session.missingRelations.browseBean.advancedLast}" /> + </h:panelGroup> + </h:column> + + <h:column rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:commandButton value="download all as CSV" + actionListener="#{Session.missingRelations.browseBean.downloadAdvancedCsv}" /> + </h:column> + + </h:panelGrid> + + <h:panelGrid columns="3" styleClass="displayPanel" id="emptyReferenceButton" + columnClasses="displayPanelColumn01,displayPanelColumn02"> + + <a4j:commandButton value="Delete all these references" + rendered="#{Session.canDelete and (!empty Session.missingRelations.browseBean.entities)}" + onclick="if(!confirm('Do you really want to delete all selected references?')){ return; };" + actionListener="#{Session.missingRelations.actionDeleteSelectedEntities}" + render="showEReferencePanel,emptyReferenceButton" /> + <h:outputText/> + <h:outputText/> + + </h:panelGrid> + + + </ui:composition> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/clean/components/lostFloruit.xhtml Mon Aug 26 16:06:55 2019 +0200 @@ -0,0 +1,166 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich"> + +<body> + <ui:composition> + + <h2 style="color:black">Floruit dates without relations</h2> + + <h:panelGrid columns="3" styleClass="displayPanel" + columnClasses="displayPanelColumn01,displayPanelColumn02"> + + <a4j:commandButton value="Show floruit dates without relations" + actionListener="#{Session.missingRelations.actionFindLostFloruit}" + render="showFloruitPanel,lostFloruitButton" /> + <h:outputText/> + <h:outputText/> + + </h:panelGrid> + + <h:panelGrid id="showFloruitPanel" columns="1" + style="margin-left: auto; margin-right: auto; text-align: center; width: 100%;"> + + <h:outputText + value="#{Session.missingRelations.browseBean.resultSummaryMsg}" + rendered="#{!empty Session.missingRelations.browseBean.resultSummaryMsg}" + styleClass="summaryMsg" /> + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:outputText value="go to page" styleClass="sumaryMsg" /> + <h:inputText value="#{Session.missingRelations.browseBean.page}" + size="4" /> + <h:commandButton value="submit" + actionListener="#{Session.missingRelations.browseBean.actionGoToPageAdvancedResult}" /> + <h:outputText value=" #{Session.missingRelations.browseBean.pageMsg}" + rendered="#{!empty Session.missingRelations.browseBean.pageMsg}" + style="color:red" /> + </h:column> + + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:panelGroup> + <h:commandButton + image="/resources/css/xp/css-images/arrow-first.gif" + style="border:none;" title="First Page" + action="#{Session.missingRelations.browseBean.advancedFirst}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-fr.gif" + style="border:none;" title="Fast Backwards" + action="#{Session.missingRelations.browseBean.advancedFastRewind}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-previous.gif" + style="border:none;" title="Previous Page" + action="#{Session.missingRelations.browseBean.advancedPrevious}" /> + + <h:outputText + value="#{Session.missingRelations.browseBean.advancedPaginator.recordStatus}" + styleClass="sumaryMsg" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-next.gif" + style="border:none;" title="Next Page" + action="#{Session.missingRelations.browseBean.advancedNext}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-ff.gif" + style="border:none;" title="Fast Forward" + action="#{Session.missingRelations.browseBean.advancedFastForward}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-last.gif" + style="border:none;" title="Last Page" + action="#{Session.missingRelations.browseBean.advancedLast}" /> + </h:panelGroup> + </h:column> + + <rich:dataTable id="FloruitDataTable" rows="30" + value="#{Session.missingRelations.browseBean.currentEntities}" + rendered="#{!empty Session.missingRelations.browseBean.currentEntities}" + var="entity" styleClass="rsPanel" columnClasses="rsPanelColumn"> + <h:column style="text-align:left"> + <f:facet name="header">Floruit dates</f:facet> + <h:outputLink target="_blank" + value="#{ApplicationBean1.root}/browse/entityDetails.xhtml?eid=#{entity.id}"> + <h:outputText + value="#{entity.ownValue} [#{entity.id}]" /> + </h:outputLink> + <h:commandButton + action="#{Session.missingRelations.browseBean.actionEdit}" + rendered="#{Session.canEdit}" + image="/resources/css/xp/css-images/edit16.gif" + title="Edit this entity" /> + </h:column> + <h:column style="text-align:left"> + <f:facet name="header">State</f:facet> + <h:outputText value="#{entity.privacity}" /> + </h:column> + </rich:dataTable> + + <h:column + rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:panelGroup> + <h:commandButton + image="/resources/css/xp/css-images/arrow-first.gif" + style="border:none;" title="First Page" + action="#{Session.missingRelations.browseBean.advancedFirst}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-fr.gif" + style="border:none;" title="Fast Backwards" + action="#{Session.missingRelations.browseBean.advancedFastRewind}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-previous.gif" + style="border:none;" title="Previous Page" + action="#{Session.missingRelations.browseBean.advancedPrevious}" /> + + <h:outputText + value="#{Session.missingRelations.browseBean.advancedPaginator.recordStatus}" + styleClass="sumaryMsg" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-next.gif" + style="border:none;" title="Next Page" + action="#{Session.missingRelations.browseBean.advancedNext}" /> + + <h:commandButton image="/resources/css/xp/css-images/arrow-ff.gif" + style="border:none;" title="Fast Forward" + action="#{Session.missingRelations.browseBean.advancedFastForward}" /> + + <h:commandButton + image="/resources/css/xp/css-images/arrow-last.gif" + style="border:none;" title="Last Page" + action="#{Session.missingRelations.browseBean.advancedLast}" /> + </h:panelGroup> + </h:column> + + <h:column rendered="#{!empty Session.missingRelations.browseBean.entities}"> + <h:commandButton value="download all as CSV" + actionListener="#{Session.missingRelations.browseBean.downloadAdvancedCsv}" /> + </h:column> + + </h:panelGrid> + + <h:panelGrid columns="3" styleClass="displayPanel" id="lostFloruitButton" + columnClasses="displayPanelColumn01,displayPanelColumn02"> + + <a4j:commandButton value="Delete all these floruit dates" + rendered="#{Session.canDelete and (!empty Session.missingRelations.browseBean.entities)}" + onclick="if(!confirm('Do you really want to delete all selected floruit dates?')){ return; };" + actionListener="#{Session.missingRelations.actionDeleteSelectedEntities}" + render="showFloruitPanel,lostFloruitButton" /> + <h:outputText/> + <h:outputText/> + + </h:panelGrid> + + + </ui:composition> +</body> +</html>
--- a/src/main/webapp/clean/missingRelations.xhtml Mon Aug 05 19:45:39 2019 +0200 +++ b/src/main/webapp/clean/missingRelations.xhtml Mon Aug 26 16:06:55 2019 +0200 @@ -51,9 +51,17 @@ <ui:include src="components/lostAlias.xhtml" /> </rich:tab> + <rich:tab header="Lost Floruit" name="flo"> + <ui:include src="components/lostFloruit.xhtml" /> + </rich:tab> + <rich:tab header="Lost Reference" name="ref"> <ui:include src="components/lostReference.xhtml" /> </rich:tab> + + <rich:tab header="Empty Reference" name="eref"> + <ui:include src="components/emptyReference.xhtml" /> + </rich:tab> </rich:tabPanel> </h:panelGrid>