# HG changeset patch # User casties # Date 1566828415 -7200 # Node ID 91f177641ec7e565e83e7df3a19e7f9b61ea82d3 # Parent 111fc1d17019a3f595da3100852c85be2626f7c7 New clean actions to delete lost floruit_dates and empty references. diff -r 111fc1d17019 -r 91f177641ec7 src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java --- 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 filterList) throws Exception { this.resultMode = MODE_ADVANCED; this.setPage(""); this.entities = new ArrayList(); this.currentEntities = new ArrayList(); - List filterList = new ArrayList(); + if (filterList == null) { + filterList = new ArrayList(); + } this.resultSummaryMsg = ""; Map resultMap = new HashMap(); @@ -356,7 +358,7 @@ public String actionSearchByAttributes() { try { - this.searchByAttributes(); + this.searchByAttributes(null); } catch (Exception e) { printInternalError(e); logger.error(e.getMessage(), e); diff -r 111fc1d17019 -r 91f177641ec7 src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java --- 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 attributeFilters) { + logger.debug("Start searchByAttbitutes2..."); + this.resultMode = MODE_ADVANCED; + this.setPage(""); + this.entities = new ArrayList(); + this.currentEntities = new ArrayList(); + this.resultSummaryMsg = ""; + + /* + * get all entities and filter result (by attribute) + */ + List 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() { diff -r 111fc1d17019 -r 91f177641ec7 src/main/java/de/mpiwg/itgroup/ismi/merge/MissingRelationsBean.java --- 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 relFilters = new ArrayList(); + /* + * 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 relFilters = new ArrayList(); /* - * 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 filters = new ArrayList(); + /* + * 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 diff -r 111fc1d17019 -r 91f177641ec7 src/main/webapp/clean/components/emptyReference.xhtml --- /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 @@ + + + + + + +

References without endnode-id

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reference + + + + + + + State + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff -r 111fc1d17019 -r 91f177641ec7 src/main/webapp/clean/components/lostFloruit.xhtml --- /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 @@ + + + + + + +

Floruit dates without relations

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Floruit dates + + + + + + + State + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff -r 111fc1d17019 -r 91f177641ec7 src/main/webapp/clean/missingRelations.xhtml --- 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 @@ + + + + + + + +