1
|
1 package de.mpiwg.itgroup.ismi.entry.beans;
|
|
2
|
|
3 import java.io.Serializable;
|
|
4 import java.util.List;
|
|
5
|
84
|
6 import javax.faces.event.ActionEvent;
|
|
7
|
1
|
8 import org.apache.log4j.Logger;
|
|
9 import org.mpi.openmind.repository.bo.Entity;
|
|
10 import org.mpi.openmind.repository.bo.Node;
|
|
11 import org.mpi.openmind.security.bo.User;
|
|
12
|
84
|
13 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
|
|
14
|
1
|
15 public class CurrentDigitalizationBean extends CodexEditorTemplate implements Serializable{
|
|
16
|
|
17 private static final long serialVersionUID = 4910425502556948216L;
|
|
18
|
|
19 private static Logger logger = Logger.getLogger(CurrentDigitalizationBean.class);
|
|
20
|
|
21
|
|
22 public CurrentDigitalizationBean(){
|
|
23 super();
|
|
24 this.entity = new Entity(Node.TYPE_ABOX, DIGITALIZATION, false);
|
|
25 setDefObjectClass(DIGITALIZATION);
|
|
26 }
|
|
27
|
|
28 @Override
|
|
29 public void reset(){
|
|
30 super.reset();
|
|
31 this.entity = new Entity(Node.TYPE_ABOX, DIGITALIZATION, false);
|
|
32 }
|
|
33
|
|
34 @Override
|
|
35 public void setEntity(Entity digi){
|
|
36 this.reset();
|
|
37 this.entity = digi;
|
|
38
|
|
39 if(this.entity.isPersistent()){
|
|
40 if (entity.isLightweight()) {
|
|
41 entity = getWrapper().getEntityContent(digi);
|
|
42 }
|
|
43 }
|
|
44
|
|
45 this.loadAttributes(this.entity);
|
|
46
|
|
47 List<Entity> list = getWrapper().getTargetsForSourceRelation(entity, is_digitalization_of, CODEX, -1);
|
|
48 if(list.size() > 0){
|
|
49 this.setCodex(list.get(0));
|
|
50 }
|
|
51 }
|
|
52
|
|
53
|
|
54 public void setCodex(Entity codex){
|
|
55 this.getCodexLo().setEntityAndAttribute(codex, "identifier");
|
|
56
|
|
57 if(this.getCodexLo().entity != null && this.getCodexLo().entity.isPersistent()){
|
|
58
|
|
59 List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1);
|
|
60 if(list.size() > 0){
|
|
61 this.setCollection(list.get(0));
|
|
62 }
|
|
63 }
|
|
64 }
|
|
65
|
84
|
66 public void unsetCodex(ActionEvent event){
|
|
67 this.setCodexLo(new ListenerObject());
|
|
68 //this.getCodexLo().setEntityAndAttribute(null, null);
|
|
69 }
|
|
70
|
1
|
71 @Override
|
|
72 public String save() {
|
|
73 super.save();
|
|
74 try {
|
|
75 User user = getSessionUser();
|
|
76
|
|
77 this.entity = this.updateEntityAttributes(this.entity);
|
|
78
|
|
79 // DIGITALIZATION -> is_digitalization_of -> CODEX
|
|
80 this.entity.replaceSourceRelation(getCodexLo().entity, CODEX, is_digitalization_of);
|
|
81
|
|
82 this.entity = getWrapper().saveEntity(this.entity, user.getEmail());
|
|
83
|
|
84 this.setEntity(this.entity);
|
|
85
|
|
86 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
|
|
87
|
|
88 this.printSuccessSavingEntity();
|
|
89
|
|
90 } catch (Exception e) {
|
|
91 logger.error(e.getMessage(), e);
|
|
92 e.printStackTrace();
|
|
93 this.printInternalError(e);
|
|
94 }
|
|
95 saveEnd();
|
|
96 return PAGE_EDITOR;
|
|
97 }
|
|
98
|
|
99
|
|
100 }
|