Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/browse/FullEntityRepositoryBean.java @ 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 | b36a57a452a6 |
children |
rev | line source |
---|---|
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1 package de.mpiwg.itgroup.ismi.browse; |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
2 |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
4 import java.util.Collections; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
5 import java.util.Comparator; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
6 import java.util.List; |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
7 |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
8 import org.apache.commons.lang.StringUtils; |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
9 import org.mpi.openmind.cache.WrapperService; |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
10 import org.mpi.openmind.repository.bo.Attribute; |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
11 import org.mpi.openmind.repository.bo.Entity; |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
12 import org.mpi.openmind.repository.bo.Relation; |
207
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
13 import org.mpi.openmind.repository.services.utils.AttributeFilter; |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
14 import org.mpi.openmind.repository.services.utils.RelationFilter; |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
15 |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
16 /** |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
17 * EntityRepositoryBean for full Entities with Attributes and Relations loaded. |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
18 * |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
19 * @author casties |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
20 * |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
21 */ |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
22 public class FullEntityRepositoryBean extends EntityRepositoryBean { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
23 |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
24 private static final long serialVersionUID = 8022526185079972610L; |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
25 |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
26 protected String sortAttributeName; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
27 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
28 protected boolean sortAttributeNumerically = false; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
29 |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
30 /** |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
31 * updateAdvancedEntities() method that makes sure that the current Entities |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
32 * are not lightweight. |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
33 * |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
34 * @see de.mpiwg.itgroup.ismi.browse.AbstractEntityRepositoryBean# |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
35 * updateAdvancedEntities() |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
36 */ |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
37 @Override |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
38 protected void updateAdvancedEntities() { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
39 if (StringUtils.isNotEmpty(getObjectClass())) { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
40 this.advancedPaginator.initCount(); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
41 int startRecord = this.advancedPaginator.getCurrentPage() * this.advancedPaginator.getItemsPerPage(); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
42 if ((this.advancedPaginator.getCurrentPage() + 1) == this.advancedPaginator.getNumberOfPages()) { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
43 int mod = this.entities.size() % advancedPaginator.getItemsPerPage(); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
44 if (mod == 0) { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
45 this.currentEntities = entities.subList(startRecord, |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
46 startRecord + this.advancedPaginator.getItemsPerPage()); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
47 } else { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
48 this.currentEntities = entities.subList(startRecord, startRecord + mod); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
49 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
50 |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
51 } else { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
52 this.currentEntities = entities.subList(startRecord, |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
53 startRecord + this.advancedPaginator.getItemsPerPage()); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
54 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
55 } else { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
56 // empty object_class |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
57 this.currentEntities = new ArrayList<Entity>(); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
58 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
59 // make sure all entities are loaded |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
60 WrapperService store = getWrapper(); |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
61 for (Entity ent : this.currentEntities) { |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
62 if (ent.isLightweight()) { |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
63 store.getEntityContent(ent); |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
64 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
65 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
66 } |
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
67 |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
68 public String actionSortByAttributes() { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
69 try { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
70 this.sortByAttributes(); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
71 } catch (Exception e) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
72 printInternalError(e); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
73 logger.error(e.getMessage(), e); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
74 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
75 return GOTO_ENTITY_REPOSITORY; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
76 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
77 |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
78 /** |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
79 * Loads all entities of this.objectClass and sorts by this.sortAttributeName. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
80 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
81 * Sort attributes as integer if this.sortAttributeNumerically. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
82 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
83 * @throws Exception |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
84 */ |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
85 public void sortByAttributes() throws Exception { |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
86 logger.debug("Start sortByAttributes..."); |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
87 this.resultMode = MODE_ADVANCED; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
88 this.setPage(""); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
89 this.entities = new ArrayList<Entity>(); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
90 this.currentEntities = new ArrayList<Entity>(); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
91 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
92 this.resultSummaryMsg = ""; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
93 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
94 /* |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
95 * run search and sort result (by attribute) |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
96 */ |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
97 List<Entity> resultList = getWrapper().getEntitiesByDef(this.objectClass); |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
98 // sort List (by attribute) |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
99 Collections.sort(resultList, |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
100 getEntityAttributeComparator(this.sortAttributeName, this.sortAttributeNumerically)); |
188
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
101 |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
102 updateEntities(resultList); |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
103 logger.debug("Done sortByAttributes."); |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
104 } |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
105 |
188
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
106 /** |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
107 * Update paginator and summary message with new entities list. |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
108 * |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
109 * @param resultList |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
110 */ |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
111 public void updateEntities(List<Entity> resultList) { |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
112 this.entities = resultList; |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
113 if (resultList.size() > 0) { |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
114 int entitiesCount = this.entities.size(); |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
115 this.resultSummaryMsg = entitiesCount + " items were found!"; |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
116 this.advancedPaginator.setCurrentPage(0); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
117 this.advancedPaginator.resetNumberOfPages(entitiesCount); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
118 this.updateAdvancedEntities(); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
119 } else { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
120 this.resultSummaryMsg = "No items were found!"; |
188
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
121 this.currentEntities = resultList; |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
122 } |
188
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
123 } |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
124 |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
125 /** |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
126 * Returns Comparator for Entities that uses the Attribute attname. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
127 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
128 * Sorts as integer if numerically. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
129 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
130 * @param attName |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
131 * @param numerically |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
132 * @return |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
133 */ |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
134 public Comparator<Entity> getEntityAttributeComparator(final String attName, final boolean numerically) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
135 return new Comparator<Entity>() { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
136 @Override |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
137 public int compare(Entity e1, Entity e2) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
138 if (e1.isLightweight()) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
139 e1 = getWrapper().getEntityContent(e1); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
140 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
141 Attribute att1 = e1.getAttributeByName(attName); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
142 if (e2.isLightweight()) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
143 e2 = getWrapper().getEntityContent(e2); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
144 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
145 Attribute att2 = e2.getAttributeByName(attName); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
146 if (att1 == null && att2 != null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
147 return 1; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
148 } else if (att1 != null && att2 == null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
149 return -1; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
150 } else if (att1 == null && att2 == null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
151 return 0; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
152 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
153 if (numerically) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
154 Integer a1 = null; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
155 Integer a2 = null; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
156 try { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
157 a1 = Integer.parseInt(att1.getValue()); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
158 } catch (Exception e) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
159 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
160 try { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
161 a2 = Integer.parseInt(att2.getValue()); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
162 } catch (Exception e) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
163 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
164 if (a1 == null && a2 != null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
165 return 1; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
166 } else if (a1 != null && a2 == null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
167 return -1; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
168 } else if (a1 == null && a2 == null) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
169 return 0; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
170 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
171 return Integer.compare(a1, a2); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
172 } else { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
173 return att1.getValue().compareTo(att2.getValue()); |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
174 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
175 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
176 }; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
177 } |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
178 |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
179 /** |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
180 * Loads all entities of this.objectClass matching the given RelationFilters. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
181 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
182 * Filters Relations by relObjectClass and either srcObjectClass or tarObjectClass. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
183 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
184 * Requires all RelationFilters to match. |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
185 * |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
186 * @throws Exception |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
187 */ |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
188 public void searchByRelations(List<RelationFilter> relationFilters) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
189 logger.debug("Start searchByRelations..."); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
190 this.resultMode = MODE_ADVANCED; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
191 this.setPage(""); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
192 this.entities = new ArrayList<Entity>(); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
193 this.currentEntities = new ArrayList<Entity>(); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
194 this.resultSummaryMsg = ""; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
195 |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
196 /* |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
197 * get all entities and filter result (by relation) |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
198 */ |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
199 List<Entity> resultList = getWrapper().getEntitiesByDef(this.objectClass); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
200 for (Entity entity : resultList) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
201 if (entity.isLightweight()) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
202 entity = getWrapper().getEntityContent(entity); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
203 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
204 boolean condFailed = false; |
190
b36a57a452a6
new Clean UI to find non-public references and witnesses and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
188
diff
changeset
|
205 for (RelationFilter filter : relationFilters) { |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
206 if (filter.tarObjectClass != null) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
207 List<Relation> rels = entity.getSourceRelations(filter.relObjectClass, filter.tarObjectClass); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
208 if (filter.relationMissing) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
209 // is the relation missing? |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
210 if (!rels.isEmpty()) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
211 condFailed = true; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
212 break; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
213 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
214 } else { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
215 if (rels.isEmpty()) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
216 condFailed = true; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
217 break; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
218 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
219 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
220 } else if (filter.srcObjectClass != null) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
221 List<Relation> rels = entity.getTargetRelations(filter.relObjectClass, filter.srcObjectClass); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
222 if (filter.relationMissing) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
223 // is the relation missing? |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
224 if (!rels.isEmpty()) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
225 condFailed = true; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
226 break; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
227 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
228 } else { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
229 if (rels.isEmpty()) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
230 condFailed = true; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
231 break; |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
232 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
233 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
234 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
235 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
236 if (!condFailed) { |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
237 // all conditions matched |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
238 entities.add(entity); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
239 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
240 } |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
241 |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
242 // sort List (by ownValue) |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
243 Collections.sort(entities); |
188
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
244 |
34ac2e1b323a
new Clean UI to find non-public digitalizations of public codices and make them public.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
180
diff
changeset
|
245 updateEntities(entities); |
180
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
246 logger.debug("Done searchByRelations."); |
0d31c8be7c31
new MissingRelations feature and UI.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
173
diff
changeset
|
247 } |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
248 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
249 /** |
207
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
250 * Loads all entities of this.objectClass matching the given AttributeFilters. |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
251 * |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
252 * Currently filter.name has to be set. |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
253 * |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
254 * Requires all AttributeFilters to match. |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
255 * |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
256 * @throws Exception |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
257 */ |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
258 public void searchByAttributes2(List<AttributeFilter> attributeFilters) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
259 logger.debug("Start searchByAttbitutes2..."); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
260 this.resultMode = MODE_ADVANCED; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
261 this.setPage(""); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
262 this.entities = new ArrayList<Entity>(); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
263 this.currentEntities = new ArrayList<Entity>(); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
264 this.resultSummaryMsg = ""; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
265 |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
266 /* |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
267 * get all entities and filter result (by attribute) |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
268 */ |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
269 List<Entity> resultList = getWrapper().getEntitiesByDef(this.objectClass); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
270 for (Entity entity : resultList) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
271 if (entity.isLightweight()) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
272 entity = getWrapper().getEntityContent(entity); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
273 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
274 boolean condFailed = false; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
275 for (AttributeFilter filter : attributeFilters) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
276 if (filter.name != null) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
277 Attribute att = entity.getAttributeByName(filter.name); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
278 if (att != null && StringUtils.isNotBlank(att.getValue())) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
279 // attribute has a value |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
280 if (filter.attributeMissing) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
281 condFailed = true; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
282 break; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
283 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
284 if (filter.ownValue != null && ! att.getValue().equals(filter.ownValue)) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
285 condFailed = true; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
286 break; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
287 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
288 } else { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
289 if (!filter.attributeMissing) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
290 condFailed = true; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
291 break; |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
292 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
293 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
294 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
295 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
296 if (!condFailed) { |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
297 // all conditions matched |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
298 entities.add(entity); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
299 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
300 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
301 |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
302 // sort List (by ownValue) |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
303 Collections.sort(entities); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
304 |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
305 updateEntities(entities); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
306 logger.debug("Done searchByAttributes."); |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
307 } |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
308 |
91f177641ec7
New clean actions to delete lost floruit_dates and empty references.
casties
parents:
190
diff
changeset
|
309 /** |
173
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
310 * @return the sortAttributeName |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
311 */ |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
312 public String getSortAttributeName() { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
313 return sortAttributeName; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
314 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
315 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
316 /** |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
317 * @param sortAttributeName |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
318 * the sortAttributeName to set |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
319 */ |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
320 public void setSortAttributeName(String sortAttributeName) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
321 this.sortAttributeName = sortAttributeName; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
322 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
323 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
324 /** |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
325 * @return the sortAttributeNumerical |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
326 */ |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
327 public boolean isSortAttributeNumerically() { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
328 return sortAttributeNumerically; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
329 } |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
330 |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
331 /** |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
332 * @param sortAttributeNumerical |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
333 * the sortAttributeNumerical to set |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
334 */ |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
335 public void setSortAttributeNumerically(boolean sortAttributeNumerical) { |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
336 this.sortAttributeNumerically = sortAttributeNumerical; |
aa564b1b5e1f
publicByAuthor feature ui for selecting texts ready.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
169
diff
changeset
|
337 } |
169
0b5d02012299
more work on publicByAuthor feature.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
338 } |