Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java @ 169:0b5d02012299 public_by_author
more work on publicByAuthor feature.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 31 May 2018 20:26:10 +0200 |
parents | e9ab943ec528 |
children | 8604b368ec19 |
comparison
equal
deleted
inserted
replaced
168:e9ab943ec528 | 169:0b5d02012299 |
---|---|
1 package de.mpiwg.itgroup.ismi.merge; | 1 package de.mpiwg.itgroup.ismi.merge; |
2 | 2 |
3 import java.io.Serializable; | 3 import java.io.Serializable; |
4 import java.util.ArrayList; | |
5 import java.util.List; | |
4 | 6 |
5 import javax.faces.event.ActionEvent; | 7 import javax.faces.event.ActionEvent; |
6 import javax.faces.event.ValueChangeEvent; | 8 import javax.faces.event.ValueChangeEvent; |
7 | 9 |
8 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
11 import org.mpi.openmind.repository.bo.Entity; | |
12 import org.mpi.openmind.repository.bo.Relation; | |
9 | 13 |
10 import de.mpiwg.itgroup.ismi.browse.EntityRepositoryBean; | 14 import de.mpiwg.itgroup.ismi.browse.EntityRepositoryBean; |
15 import de.mpiwg.itgroup.ismi.browse.FullEntityRepositoryBean; | |
11 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | 16 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; |
12 | 17 |
13 public class PublicByAuthorBean extends AbstractISMIBean implements Serializable{ | 18 public class PublicByAuthorBean extends AbstractISMIBean implements Serializable{ |
14 | 19 |
15 private static Logger logger = Logger.getLogger(PublicByAuthorBean.class); | 20 private static Logger logger = Logger.getLogger(PublicByAuthorBean.class); |
16 | 21 |
17 private static final long serialVersionUID = 1L; | 22 private static final long serialVersionUID = 1L; |
18 | 23 |
19 private String findAuthorName = ""; | 24 private String findAuthorName = ""; |
20 private long timeExecution; | 25 protected Long selectedPersonId = 0l; |
21 | 26 |
27 protected Entity selectedPerson; | |
28 protected List<Entity> selectedPersonTexts; | |
29 protected List<Entity> selectedPersonSubjects; | |
30 | |
31 | |
22 private EntityRepositoryBean browseBean; | 32 private EntityRepositoryBean browseBean; |
23 | 33 |
24 | 34 |
25 public PublicByAuthorBean(){ | 35 public PublicByAuthorBean(){ |
26 //logger.info("AdvancedSearchBean"); | 36 //logger.info("AdvancedSearchBean"); |
27 this.reset(); | 37 this.reset(); |
28 } | 38 } |
29 | 39 |
30 public void reset(){ | 40 public void reset(){ |
31 //logger.info("AdvancedSearchBean.reset()"); | 41 //logger.info("AdvancedSearchBean.reset()"); |
32 browseBean = new EntityRepositoryBean(); | 42 browseBean = new FullEntityRepositoryBean(); |
33 browseBean.setObjectClass("PERSON"); | 43 browseBean.setObjectClass("PERSON"); |
44 | |
45 selectedPersonTexts = new ArrayList<Entity>(); | |
34 } | 46 } |
35 | 47 |
36 public void listenerChange(ValueChangeEvent event){ | 48 public void listenerAuthorIdSearch(ActionEvent event) { |
37 /* | 49 setSelectedPersonById(); |
38 logger.info(event.getOldValue()); | |
39 logger.info(event.getNewValue()); | |
40 */ | |
41 } | 50 } |
51 | |
52 private void setSelectedPersonById() { | |
53 Entity ent = getWrapper().getEntityById(selectedPersonId); | |
54 if (ent != null) { | |
55 ent = getWrapper().getEntityContent(ent); | |
56 selectedPerson = ent; | |
57 updateSelectedPerson(); | |
58 } | |
59 } | |
42 | 60 |
43 public void listenerFindAuthorSearch(ActionEvent event){ | 61 |
44 try { | |
45 long start = System.currentTimeMillis(); | |
46 this.search(); | |
47 long end = System.currentTimeMillis(); | |
48 this.timeExecution = end - start; | |
49 logger.info(toString() + " time execution=" + (timeExecution)); | |
50 } catch (Exception e) { | |
51 logger.error(e.getMessage(), e); | |
52 printInternalError(e); | |
53 } | |
54 | 62 |
63 public void updateSelectedPerson() { | |
64 // load all texts by this author | |
65 selectedPersonTexts = new ArrayList<Entity>(); | |
66 List<Relation> textRels = selectedPerson.getTargetRelations("was_created_by", "TEXT"); | |
67 for (Relation rel : textRels) { | |
68 Long textID = rel.getSourceId(); | |
69 Entity text = getWrapper().getEntityByIdWithContent(textID); | |
70 selectedPersonTexts.add(text); | |
71 } | |
55 } | 72 } |
56 | 73 |
57 | 74 |
75 public String actionSelectPerson() { | |
76 Entity entity = (Entity) getRequestBean("entity"); | |
77 selectedPersonId = entity.getId(); | |
78 setSelectedPersonById(); | |
79 // switch tab | |
80 getSessionBean().setSelectedPublicByAuthorTab("02"); | |
81 return null; | |
82 } | |
58 | 83 |
59 public String actionSearch(){ | 84 public String actionSearch(){ |
60 this.search(); | 85 this.search(); |
61 return null; | 86 return null; |
62 } | 87 } |
63 | 88 |
64 public void search(){ | 89 public void search(){ |
88 */ | 113 */ |
89 public EntityRepositoryBean getBrowseBean() { | 114 public EntityRepositoryBean getBrowseBean() { |
90 return browseBean; | 115 return browseBean; |
91 } | 116 } |
92 | 117 |
118 /** | |
119 * @return the selectedPersonId | |
120 */ | |
121 public long getSelectedPersonId() { | |
122 return selectedPersonId; | |
123 } | |
124 | |
125 /** | |
126 * @param selectedPersonId the selectedPersonId to set | |
127 */ | |
128 public void setSelectedPersonId(long selectedPersonId) { | |
129 this.selectedPersonId = selectedPersonId; | |
130 } | |
131 /** | |
132 * @return the selectedPerson | |
133 */ | |
134 public Entity getSelectedPerson() { | |
135 return selectedPerson; | |
136 } | |
137 | |
138 /** | |
139 * @return the selectedPersonTexts | |
140 */ | |
141 public List<Entity> getSelectedPersonTexts() { | |
142 return selectedPersonTexts; | |
143 } | |
144 | |
145 /** | |
146 * @return the selectedPersonSubjects | |
147 */ | |
148 public List<Entity> getSelectedPersonSubjects() { | |
149 return selectedPersonSubjects; | |
150 } | |
151 | |
152 /** | |
153 * @param selectedPersonId the selectedPersonId to set | |
154 */ | |
155 public void setSelectedPersonId(Long selectedPersonId) { | |
156 this.selectedPersonId = selectedPersonId; | |
157 } | |
158 | |
93 } | 159 } |