annotate src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java @ 216:93d33f138c9e default tip

update medeniyet image server URL.
author casties
date Wed, 26 Jan 2022 16:39:32 +0100
parents 502ae5b1a07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
jurzua
parents:
diff changeset
1 package de.mpiwg.itgroup.ismi.util.guiComponents;
jurzua
parents:
diff changeset
2
jurzua
parents:
diff changeset
3 import java.util.ArrayList;
jurzua
parents:
diff changeset
4 import java.util.List;
jurzua
parents:
diff changeset
5
jurzua
parents:
diff changeset
6 import javax.faces.event.ActionEvent;
jurzua
parents:
diff changeset
7
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
8 import org.apache.log4j.Logger;
1
jurzua
parents:
diff changeset
9 import org.mpi.openmind.repository.bo.Entity;
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
10 import org.mpi.openmind.repository.bo.Relation;
1
jurzua
parents:
diff changeset
11
jurzua
parents:
diff changeset
12 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
jurzua
parents:
diff changeset
13 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean;
jurzua
parents:
diff changeset
14 import de.mpiwg.itgroup.ismi.utils.SelectableObject;
jurzua
parents:
diff changeset
15
116
ca36b24a22f7 add misattribution to displayAuthor. small cleanups.
casties
parents: 91
diff changeset
16 public class MisattributionTable extends AbstractISMIBean {
1
jurzua
parents:
diff changeset
17 private static final long serialVersionUID = -2756216426560705499L;
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
18 private static Logger logger = Logger.getLogger(MisattributionTable.class);
1
jurzua
parents:
diff changeset
19
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
20 private List<SelectableObject<Misattribution>> list = new ArrayList<SelectableObject<Misattribution>>();
1
jurzua
parents:
diff changeset
21
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
22 private Misattribution misatt;
1
jurzua
parents:
diff changeset
23
jurzua
parents:
diff changeset
24 private ListenerObject lo = new ListenerObject(PERSON, "name_translit");
jurzua
parents:
diff changeset
25 //private String attName;
jurzua
parents:
diff changeset
26 //private String oc;
jurzua
parents:
diff changeset
27
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
28 public MisattributionTable(){
1
jurzua
parents:
diff changeset
29 /*
jurzua
parents:
diff changeset
30 this.attName = attName;
jurzua
parents:
diff changeset
31 this.oc = oc;
jurzua
parents:
diff changeset
32 */
jurzua
parents:
diff changeset
33 }
jurzua
parents:
diff changeset
34
jurzua
parents:
diff changeset
35 public void listenerRemove(ActionEvent event){
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
36 List<SelectableObject<Misattribution>> toDelete = new ArrayList<SelectableObject<Misattribution>>();
1
jurzua
parents:
diff changeset
37
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
38 for(SelectableObject<Misattribution> so : this.list){
1
jurzua
parents:
diff changeset
39 if(so.isSelected()){
jurzua
parents:
diff changeset
40 toDelete.add(so);
jurzua
parents:
diff changeset
41 }
jurzua
parents:
diff changeset
42 }
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
43 for(SelectableObject<Misattribution> so : toDelete){
1
jurzua
parents:
diff changeset
44 this.list.remove(so);
jurzua
parents:
diff changeset
45 }
jurzua
parents:
diff changeset
46 }
jurzua
parents:
diff changeset
47
jurzua
parents:
diff changeset
48 public void listenerEditRef(ActionEvent event){
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
49 SelectableObject<Misattribution> so =
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
50 (SelectableObject<Misattribution>)getRequestBean("item");
1
jurzua
parents:
diff changeset
51 if(so != null){
jurzua
parents:
diff changeset
52 this.misatt = so.getObj();
jurzua
parents:
diff changeset
53 }
jurzua
parents:
diff changeset
54 }
jurzua
parents:
diff changeset
55
jurzua
parents:
diff changeset
56 public void listenerSaveRef(ActionEvent event){
jurzua
parents:
diff changeset
57 this.misatt = null;
jurzua
parents:
diff changeset
58 }
jurzua
parents:
diff changeset
59
jurzua
parents:
diff changeset
60 public void listenerCancel(ActionEvent event){
jurzua
parents:
diff changeset
61 //@TODO
jurzua
parents:
diff changeset
62 }
jurzua
parents:
diff changeset
63
jurzua
parents:
diff changeset
64 public void listenerCreate(ActionEvent event){
jurzua
parents:
diff changeset
65 if(this.lo.entity != null & this.lo.entity.isPersistent()){
jurzua
parents:
diff changeset
66 this.create(this.lo.entity);
jurzua
parents:
diff changeset
67 }
jurzua
parents:
diff changeset
68 }
jurzua
parents:
diff changeset
69
jurzua
parents:
diff changeset
70 public void load(Entity misattEntity){
jurzua
parents:
diff changeset
71 if(!containsEntity(misattEntity)){
jurzua
parents:
diff changeset
72 //TODO sort
jurzua
parents:
diff changeset
73 //Collections.sort(this.misattList);
jurzua
parents:
diff changeset
74 try {
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
75 this.list.add(new SelectableObject<Misattribution>(Misattribution.load(misattEntity, getWrapper(), getUserName())));
1
jurzua
parents:
diff changeset
76 } catch (Exception e) {
jurzua
parents:
diff changeset
77 addErrorMsg(e.getMessage());
jurzua
parents:
diff changeset
78 e.printStackTrace();
jurzua
parents:
diff changeset
79 }
jurzua
parents:
diff changeset
80 }else{
jurzua
parents:
diff changeset
81 addGeneralMsg("This entity has been already inserted!");
jurzua
parents:
diff changeset
82 }
jurzua
parents:
diff changeset
83 }
jurzua
parents:
diff changeset
84
jurzua
parents:
diff changeset
85 public void create(Entity person){
jurzua
parents:
diff changeset
86 try {
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
87 this.list.add(new SelectableObject<Misattribution>(Misattribution.create(person, getWrapper(), getUserName())));
1
jurzua
parents:
diff changeset
88 } catch (Exception e) {
jurzua
parents:
diff changeset
89 addErrorMsg(e.getMessage());
jurzua
parents:
diff changeset
90 e.printStackTrace();
jurzua
parents:
diff changeset
91 }
jurzua
parents:
diff changeset
92 }
jurzua
parents:
diff changeset
93
jurzua
parents:
diff changeset
94 private boolean containsEntity(Entity ent){
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
95 for(SelectableObject<Misattribution> so : this.list){
1
jurzua
parents:
diff changeset
96 if(so.getObj().getPerson() != null && so.getObj().getPerson().getId().equals(ent.getId())){
jurzua
parents:
diff changeset
97 return true;
jurzua
parents:
diff changeset
98 }
jurzua
parents:
diff changeset
99 }
jurzua
parents:
diff changeset
100 return false;
jurzua
parents:
diff changeset
101 }
jurzua
parents:
diff changeset
102
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
103 /**
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
104 * Save all misattributions on this text.
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
105 *
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
106 * Deletes removed misattributions.
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
107 *
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
108 * @param text
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
109 * @return
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
110 * @throws Exception
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
111 */
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
112 public Entity saveMisattributions(Entity text) throws Exception {
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
113 // remember old misattributions
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
114 List<Relation> oldRels = text.getSourceRelations(Misattribution.HAS_AUTHOR_MISATT, Misattribution.MISATT);
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
115 List<Entity> misatts = new ArrayList<Entity>();
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
116 // save new misattributions
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
117 for (Misattribution misatt : this.getMisattList()) {
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
118 misatt.saveMisattribution(text);
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
119 misatts.add(misatt.getMisatt());
1
jurzua
parents:
diff changeset
120 }
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
121 // update relations
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
122 this.replaceMultipleSourceRelations(text, misatts, Misattribution.MISATT, Misattribution.HAS_AUTHOR_MISATT);
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
123 // check for orphaned old misattributions
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
124 for (Relation rel : oldRels) {
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
125 boolean found = false;
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
126 for (Entity miEnt : misatts) {
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
127 if (miEnt != null && rel.getTargetId() == miEnt.getId()) {
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
128 found = true;
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
129 break;
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
130 }
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
131 }
136
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
132 if (!found) {
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
133 Entity miEnt = getWrapper().getEntityById(rel.getTargetId());
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
134 logger.warn("Orphaned MISATTRIBUTION will be deleted: " + miEnt);
502ae5b1a07d fixing bugs from re-use efforts. misc cleanups.
casties
parents: 128
diff changeset
135 getWrapper().removeCurrentVersionEntity(miEnt, getUserName());
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
136 }
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
137 }
1
jurzua
parents:
diff changeset
138 return text;
128
aef031e76278 105: MISATTRIBUTION should be deleted when detached
casties
parents: 116
diff changeset
139 }
1
jurzua
parents:
diff changeset
140
116
ca36b24a22f7 add misattribution to displayAuthor. small cleanups.
casties
parents: 91
diff changeset
141 private List<Misattribution> getMisattList() {
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
142 List<Misattribution> list = new ArrayList<Misattribution>();
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
143 for(SelectableObject<Misattribution> so : this.list){
1
jurzua
parents:
diff changeset
144 list.add(so.getObj());
jurzua
parents:
diff changeset
145 }
jurzua
parents:
diff changeset
146 return list;
jurzua
parents:
diff changeset
147 }
jurzua
parents:
diff changeset
148
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
149 public List<SelectableObject<Misattribution>> getList() {
1
jurzua
parents:
diff changeset
150 return list;
jurzua
parents:
diff changeset
151 }
jurzua
parents:
diff changeset
152
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
153 public void setList(List<SelectableObject<Misattribution>> list) {
1
jurzua
parents:
diff changeset
154 this.list = list;
jurzua
parents:
diff changeset
155 }
jurzua
parents:
diff changeset
156
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
157 public Misattribution getMisatt() {
1
jurzua
parents:
diff changeset
158 return misatt;
jurzua
parents:
diff changeset
159 }
jurzua
parents:
diff changeset
160
91
d172201d24ad more comments and refactorings.
casties
parents: 1
diff changeset
161 public void setMisatt(Misattribution misatt) {
1
jurzua
parents:
diff changeset
162 this.misatt = misatt;
jurzua
parents:
diff changeset
163 }
jurzua
parents:
diff changeset
164
jurzua
parents:
diff changeset
165 public ListenerObject getLo() {
jurzua
parents:
diff changeset
166 return lo;
jurzua
parents:
diff changeset
167 }
jurzua
parents:
diff changeset
168
jurzua
parents:
diff changeset
169 public void setLo(ListenerObject lo) {
jurzua
parents:
diff changeset
170 this.lo = lo;
jurzua
parents:
diff changeset
171 }
jurzua
parents:
diff changeset
172 }