# HG changeset patch # User casties # Date 1472494684 -7200 # Node ID 0d5d36c83e7758cad656b19046754b85b9f93b83 # Parent 5a2146dea778c3d87310f9cf250fa2d9d6eb1d18 added search for bibliography id attribute for REFERENCEs. diff -r 5a2146dea778 -r 0d5d36c83e77 src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Fri Aug 26 11:54:09 2016 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Mon Aug 29 20:18:04 2016 +0200 @@ -67,6 +67,8 @@ private String subjectType; private List suggestedSubjectTypes = new ArrayList(); + + private String referenceBibIdNo; private String page; private String pageMsg; @@ -209,97 +211,100 @@ } - public void searchByAttributes() throws Exception{ - this.resultMode = MODE_ADVANCED; - this.setPage(""); - this.entities = new ArrayList(); - this.currentEntities = new ArrayList(); - - List filterList = new ArrayList(); + public void searchByAttributes() throws Exception { + this.resultMode = MODE_ADVANCED; + this.setPage(""); + this.entities = new ArrayList(); + this.currentEntities = new ArrayList(); + + List filterList = new ArrayList(); - this.resultSummaryMsg = ""; - Map resultMap = new HashMap(); - if (this.objectClass.equals(TEXT)) { - if (StringUtils.isNotEmpty(textFullTitle)) { - filterList.add(new AttributeFilter("full_title", - this.textFullTitle, TEXT)); - } - if (StringUtils.isNotEmpty(textFullTitleTranslit)) { - filterList.add(new AttributeFilter("full_title_translit", - textFullTitleTranslit, TEXT)); - } - if (StringUtils.isNotEmpty(textShortTitle)) { - List l = getWrapper().searchEntityByAttributeOfTarRelation(TEXT, "is_prime_alias_title_of", ALIAS, "alias", textShortTitle, 20); - for(Entity e : l){ - this.entities.add(e); - } - } - } else if (this.objectClass.equals(WITNESS)) { - //witnessAhlwardtNo - if(StringUtils.isNotEmpty(this.witnessAhlwardtNo)){ - filterList.add(new AttributeFilter("ahlwardt_no", this.witnessAhlwardtNo, - WITNESS)); - } - } else if (this.objectClass.equals(SUBJECT)) { - if(StringUtils.isNotEmpty(this.subjectType)){ - filterList.add(new AttributeFilter("type", this.subjectType, - SUBJECT)); - } - } else if (this.objectClass.equals(ALIAS)) { - if(StringUtils.isNotEmpty(this.aliasAlias)){ - filterList.add(new AttributeFilter("alias", this.aliasAlias, - ALIAS)); - } - } else if (this.objectClass.equals(COLLECTION)) { - if(StringUtils.isNotEmpty(this.collectionName)){ - filterList.add(new AttributeFilter("name", this.collectionName, - COLLECTION)); - } - } else if (this.objectClass.equals(REPOSITORY)) { - if(StringUtils.isNotEmpty(this.repositoryName)){ - filterList.add(new AttributeFilter("name", this.repositoryName, - REPOSITORY)); - } - } else if (this.objectClass.equals(PLACE)) { - if(StringUtils.isNotEmpty(this.placeName)){ - filterList.add(new AttributeFilter("name", this.placeName, - PLACE)); - } - } else if (this.objectClass.equals(CODEX)) { - if(StringUtils.isNotEmpty(this.codexIdentifier)){ - filterList.add(new AttributeFilter("identifier", this.codexIdentifier, - CODEX)); - } - - } else if (this.objectClass.equals(PERSON)) { - if (StringUtils.isNotEmpty(this.personName)) { - filterList.add(new AttributeFilter("name", this.personName, - PERSON)); - } - if (StringUtils.isNotEmpty(this.personNameTranslit)) { - filterList.add(new AttributeFilter("name_translit", - this.personNameTranslit, PERSON)); - } - } - if (filterList.size() > 0) { - resultMap = getWrapper().searchEntityByAttributeFilter( - filterList, 500); - for (Entity ent : resultMap.keySet()) { - this.entities.add(ent); - } - Collections.sort(entities); - } + this.resultSummaryMsg = ""; + Map resultMap = new HashMap(); + + /* + * create list of filters for the selected attributes + */ + if (this.objectClass.equals(TEXT)) { + if (StringUtils.isNotEmpty(textFullTitle)) { + filterList.add(new AttributeFilter("full_title", this.textFullTitle, TEXT)); + } + if (StringUtils.isNotEmpty(textFullTitleTranslit)) { + filterList.add(new AttributeFilter("full_title_translit", textFullTitleTranslit, TEXT)); + } + if (StringUtils.isNotEmpty(textShortTitle)) { + List l = getWrapper().searchEntityByAttributeOfTarRelation(TEXT, "is_prime_alias_title_of", + ALIAS, "alias", textShortTitle, 20); + for (Entity e : l) { + this.entities.add(e); + } + } + } else if (this.objectClass.equals(WITNESS)) { + // witnessAhlwardtNo + if (StringUtils.isNotEmpty(this.witnessAhlwardtNo)) { + filterList.add(new AttributeFilter("ahlwardt_no", this.witnessAhlwardtNo, WITNESS)); + } + } else if (this.objectClass.equals(SUBJECT)) { + if (StringUtils.isNotEmpty(this.subjectType)) { + filterList.add(new AttributeFilter("type", this.subjectType, SUBJECT)); + } + } else if (this.objectClass.equals(ALIAS)) { + if (StringUtils.isNotEmpty(this.aliasAlias)) { + filterList.add(new AttributeFilter("alias", this.aliasAlias, ALIAS)); + } + } else if (this.objectClass.equals(COLLECTION)) { + if (StringUtils.isNotEmpty(this.collectionName)) { + filterList.add(new AttributeFilter("name", this.collectionName, COLLECTION)); + } + } else if (this.objectClass.equals(REPOSITORY)) { + if (StringUtils.isNotEmpty(this.repositoryName)) { + filterList.add(new AttributeFilter("name", this.repositoryName, REPOSITORY)); + } + } else if (this.objectClass.equals(PLACE)) { + if (StringUtils.isNotEmpty(this.placeName)) { + filterList.add(new AttributeFilter("name", this.placeName, PLACE)); + } + } else if (this.objectClass.equals(CODEX)) { + if (StringUtils.isNotEmpty(this.codexIdentifier)) { + filterList.add(new AttributeFilter("identifier", this.codexIdentifier, CODEX)); + } + } else if (this.objectClass.equals(REFERENCE)) { + // search "#bibIdNo\W" as regex in endnote-id attribute + if (StringUtils.isNotEmpty(this.referenceBibIdNo)) { + filterList.add(new AttributeFilter("endnote-id", "#" + this.referenceBibIdNo + "[[:>:]]", REFERENCE, true)); + } + } else if (this.objectClass.equals(PERSON)) { + if (StringUtils.isNotEmpty(this.personName)) { + filterList.add(new AttributeFilter("name", this.personName, PERSON)); + } + if (StringUtils.isNotEmpty(this.personNameTranslit)) { + filterList.add(new AttributeFilter("name_translit", this.personNameTranslit, PERSON)); + } + } + + /* + * run search and sort result (by ownvalue) + */ + if (filterList.size() > 0) { + resultMap = getWrapper().searchEntityByAttributeFilter(filterList, 500); + // pack entities (Map keys) into List + for (Entity ent : resultMap.keySet()) { + this.entities.add(ent); + } + // sort List (by ownvalue) + Collections.sort(entities); + } - if (resultMap.size() > 0) { - this.resultSummaryMsg = resultMap.size() + " items were found!"; - this.advancedPaginator.setCurrentPage(0); - int entitiesCount = this.entities.size(); - this.advancedPaginator.resetNumberOfPages(entitiesCount); - this.updateAdvancedEntities(); - } else { - this.resultSummaryMsg = "No items were found!"; - } - } + if (resultMap.size() > 0) { + this.resultSummaryMsg = resultMap.size() + " items were found!"; + this.advancedPaginator.setCurrentPage(0); + int entitiesCount = this.entities.size(); + this.advancedPaginator.resetNumberOfPages(entitiesCount); + this.updateAdvancedEntities(); + } else { + this.resultSummaryMsg = "No items were found!"; + } + } public boolean isRenderedSearch(){ if(StringUtils.isNotEmpty(this.objectClass) && ( @@ -311,7 +316,8 @@ objectClass.equals(PERSON) || objectClass.equals(CODEX) || objectClass.equals(WITNESS) || - objectClass.equals(PLACE))) { + objectClass.equals(PLACE) || + objectClass.equals(REFERENCE))) { return true; } return false; @@ -526,7 +532,21 @@ this.witnessAhlwardtNo = witnessAhlwardtNo; } - public String getOcTerm() { + /** + * @return the referenceBibIdNo + */ + public String getReferenceBibIdNo() { + return referenceBibIdNo; + } + + /** + * @param referenceBibIdNo the referenceBibIdNo to set + */ + public void setReferenceBibIdNo(String referenceBibIdNo) { + this.referenceBibIdNo = referenceBibIdNo; + } + + public String getOcTerm() { return ocTerm; } diff -r 5a2146dea778 -r 0d5d36c83e77 src/main/webapp/browse/entityRepository.xhtml --- a/src/main/webapp/browse/entityRepository.xhtml Fri Aug 26 11:54:09 2016 +0200 +++ b/src/main/webapp/browse/entityRepository.xhtml Mon Aug 29 20:18:04 2016 +0200 @@ -153,6 +153,15 @@ + + + + + + + +