Mercurial > hg > ismi-richfaces
changeset 81:0d5d36c83e77
added search for bibliography id attribute for REFERENCEs.
author | casties |
---|---|
date | Mon, 29 Aug 2016 20:18:04 +0200 |
parents | 5a2146dea778 |
children | c000b4b386bc |
files | src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java src/main/webapp/browse/entityRepository.xhtml |
diffstat | 2 files changed, 120 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- 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<SelectItem> suggestedSubjectTypes = new ArrayList<SelectItem>(); + + 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<Entity>(); - this.currentEntities = new ArrayList<Entity>(); - - List<AttributeFilter> filterList = new ArrayList<AttributeFilter>(); + public void searchByAttributes() throws Exception { + this.resultMode = MODE_ADVANCED; + this.setPage(""); + this.entities = new ArrayList<Entity>(); + this.currentEntities = new ArrayList<Entity>(); + + List<AttributeFilter> filterList = new ArrayList<AttributeFilter>(); - this.resultSummaryMsg = ""; - Map<Entity, Attribute> resultMap = new HashMap<Entity, Attribute>(); - 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<Entity> 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<Entity, Attribute> resultMap = new HashMap<Entity, Attribute>(); + + /* + * 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<Entity> 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; }
--- 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 @@ </h:selectOneMenu> </h:column> </h:panelGrid> + <h:panelGrid columns="2" + rendered="#{EntityRepository.objectClass == 'REFERENCE'}"> + <h:column> + <h:outputText value="Bibliography (Endnote) ID number" /> + </h:column> + <h:column> + <h:inputText value="#{EntityRepository.referenceBibIdNo}" /> + </h:column> + </h:panelGrid> <a4j:commandButton value="Submit" rendered="#{EntityRepository.renderedSearch}" action="#{EntityRepository.actionSearchByAttributes}" styleClass="button"