# HG changeset patch # User Robert Casties # Date 1528311665 -7200 # Node ID aa564b1b5e1f28b00de5c639ccd9abd2e6299323 # Parent 3475b8bea5507a47119d11eac17bbdbab78164cf publicByAuthor feature ui for selecting texts ready. actual changing of public state not yet implemented. diff -r 3475b8bea550 -r aa564b1b5e1f src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/AbstractEntityRepositoryBean.java Wed Jun 06 21:01:05 2018 +0200 @@ -46,6 +46,7 @@ protected String personName; protected String personNameTranslit; + protected String personMamsNr; protected String codexIdentifier; @@ -113,37 +114,37 @@ public String advancedFirst() { this.advancedPaginator.first(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public String advancedLast() { this.advancedPaginator.last(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public String advancedFastForward() { this.advancedPaginator.fastForward(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public String advancedFastRewind() { this.advancedPaginator.fastRewind(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public String advancedPrevious() { this.advancedPaginator.previous(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public String advancedNext() { this.advancedPaginator.next(); this.updateAdvancedEntities(); - return GOTO_ENTITY_REPOSITORY; + return null; //GOTO_ENTITY_REPOSITORY; } public void reset(){ @@ -289,6 +290,9 @@ if (StringUtils.isNotEmpty(this.personNameTranslit)) { filterList.add(new AttributeFilter("name_translit", this.personNameTranslit, PERSON)); } + if (StringUtils.isNotEmpty(this.personMamsNr)) { + filterList.add(new AttributeFilter("mams_number", this.personMamsNr, PERSON)); + } } /* @@ -431,7 +435,21 @@ this.personNameTranslit = personNameTranslit; } - public String getObjectClass() { + /** + * @return the personMamsNr + */ + public String getPersonMamsNr() { + return personMamsNr; + } + + /** + * @param personMamsNr the personMamsNr to set + */ + public void setPersonMamsNr(String personMamsNr) { + this.personMamsNr = personMamsNr; + } + + public String getObjectClass() { return objectClass; } diff -r 3475b8bea550 -r aa564b1b5e1f src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java Wed Jun 06 21:01:05 2018 +0200 @@ -1,9 +1,13 @@ package de.mpiwg.itgroup.ismi.browse; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import org.apache.commons.lang.StringUtils; import org.mpi.openmind.cache.WrapperService; +import org.mpi.openmind.repository.bo.Attribute; import org.mpi.openmind.repository.bo.Entity; /** @@ -16,8 +20,15 @@ private static final long serialVersionUID = 8022526185079972610L; - /* (non-Javadoc) - * @see de.mpiwg.itgroup.ismi.browse.AbstractEntityRepositoryBean#updateAdvancedEntities() + protected String sortAttributeName; + + protected boolean sortAttributeNumerically = false; + + /* + * (non-Javadoc) + * + * @see de.mpiwg.itgroup.ismi.browse.AbstractEntityRepositoryBean# + * updateAdvancedEntities() */ @Override protected void updateAdvancedEntities() { @@ -45,11 +56,121 @@ WrapperService store = getWrapper(); for (Entity ent : this.currentEntities) { if (ent.isLightweight()) { - store.getEntityContent(ent); + store.getEntityContent(ent); } } } - - + public String actionSortByAttributes() { + try { + this.sortByAttributes(); + } catch (Exception e) { + printInternalError(e); + logger.error(e.getMessage(), e); + } + return GOTO_ENTITY_REPOSITORY; + } + + public void sortByAttributes() throws Exception { + this.resultMode = MODE_ADVANCED; + this.setPage(""); + this.entities = new ArrayList(); + this.currentEntities = new ArrayList(); + + this.resultSummaryMsg = ""; + + /* + * run search and sort result (by attribute) + */ + List resultList = getWrapper().getEntitiesByDef(this.objectClass); + // sort List (by ownvalue) + Collections.sort(resultList, + getEntityAttributeComparator(this.sortAttributeName, this.sortAttributeNumerically)); + this.entities = resultList; + + if (resultList.size() > 0) { + this.resultSummaryMsg = resultList.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 Comparator getEntityAttributeComparator(final String attName, final boolean numerically) { + return new Comparator() { + @Override + public int compare(Entity e1, Entity e2) { + if (e1.isLightweight()) { + e1 = getWrapper().getEntityContent(e1); + } + Attribute att1 = e1.getAttributeByName(attName); + if (e2.isLightweight()) { + e2 = getWrapper().getEntityContent(e2); + } + Attribute att2 = e2.getAttributeByName(attName); + if (att1 == null && att2 != null) { + return 1; + } else if (att1 != null && att2 == null) { + return -1; + } else if (att1 == null && att2 == null) { + return 0; + } + if (numerically) { + Integer a1 = null; + Integer a2 = null; + try { + a1 = Integer.parseInt(att1.getValue()); + } catch (Exception e) { + } + try { + a2 = Integer.parseInt(att2.getValue()); + } catch (Exception e) { + } + if (a1 == null && a2 != null) { + return 1; + } else if (a1 != null && a2 == null) { + return -1; + } else if (a1 == null && a2 == null) { + return 0; + } + return Integer.compare(a1, a2); + } else { + return att1.getValue().compareTo(att2.getValue()); + } + } + }; + } + + /** + * @return the sortAttributeName + */ + public String getSortAttributeName() { + return sortAttributeName; + } + + /** + * @param sortAttributeName + * the sortAttributeName to set + */ + public void setSortAttributeName(String sortAttributeName) { + this.sortAttributeName = sortAttributeName; + } + + /** + * @return the sortAttributeNumerical + */ + public boolean isSortAttributeNumerically() { + return sortAttributeNumerically; + } + + /** + * @param sortAttributeNumerical + * the sortAttributeNumerical to set + */ + public void setSortAttributeNumerically(boolean sortAttributeNumerical) { + this.sortAttributeNumerically = sortAttributeNumerical; + } } diff -r 3475b8bea550 -r aa564b1b5e1f src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java Wed Jun 06 21:01:05 2018 +0200 @@ -33,7 +33,7 @@ protected Map> subjectParents; - private EntityRepositoryBean browseBean; + private FullEntityRepositoryBean browseBean; public PublicByAuthorBean(){ @@ -152,23 +152,21 @@ selectedPersonId = entity.getId(); setSelectedPersonById(); // switch tab - getSessionBean().setSelectedPublicByAuthorTab("02"); + getSessionBean().setSelectedPublicByAuthorTab("sub"); return null; } - public String actionSearch(){ - this.search(); - return null; + public void actionAllAuthors() { + browseBean.setObjectClass(PERSON); + browseBean.setSortAttributeName("mams_number"); + browseBean.setSortAttributeNumerically(true); + try { + browseBean.sortByAttributes(); + } catch (Exception e) { + logger.error(e); + } } - public void search(){ - long start = System.currentTimeMillis(); - - long end = System.currentTimeMillis(); - logger.info("execution time [ms] = " + (end - start)); - } - - /** * @return the findAuthorName */ diff -r 3475b8bea550 -r aa564b1b5e1f src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/DataPaginator.java --- a/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/DataPaginator.java Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/DataPaginator.java Wed Jun 06 21:01:05 2018 +0200 @@ -4,7 +4,7 @@ public class DataPaginator { /* This should be parameters or properties stored somewhere */ - private int itemsPerPage = 10; + private int itemsPerPage = 20; private int rewindFastForwardBy = 10; private int currentPage; diff -r 3475b8bea550 -r aa564b1b5e1f src/main/webapp/clean/components/publicFindAuthor.xhtml --- a/src/main/webapp/clean/components/publicFindAuthor.xhtml Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/webapp/clean/components/publicFindAuthor.xhtml Wed Jun 06 21:01:05 2018 +0200 @@ -13,19 +13,20 @@ - + + + + - - - @@ -93,7 +94,7 @@ - diff -r 3475b8bea550 -r aa564b1b5e1f src/main/webapp/clean/components/publicShowSubjects.xhtml --- a/src/main/webapp/clean/components/publicShowSubjects.xhtml Mon Jun 04 20:17:04 2018 +0200 +++ b/src/main/webapp/clean/components/publicShowSubjects.xhtml Wed Jun 06 21:01:05 2018 +0200 @@ -12,15 +12,13 @@ - +

Author: #{Session.publicByAuthor.selectedPerson.ownValue}"

- + activeItem="#{Session.selectedPublicByAuthorTab}"> - - - - - + + + + +