1
|
1 package de.mpiwg.itgroup.ismi.entry.beans;
|
|
2
|
|
3 import org.apache.commons.lang.StringUtils;
|
|
4 import org.apache.log4j.Logger;
|
|
5 import org.mpi.openmind.repository.bo.Entity;
|
|
6 import org.mpi.openmind.repository.bo.Node;
|
125
|
7 import org.mpi.openmind.repository.services.utils.EditIntent;
|
1
|
8
|
|
9 public class CurrentRoleBean extends AbstractISMIBean{
|
|
10
|
|
11 /**
|
|
12 *
|
|
13 */
|
|
14 private static final long serialVersionUID = -4934098828218979428L;
|
|
15 private static Logger logger = Logger.getLogger(CurrentRoleBean.class);
|
|
16
|
125
|
17 /** intent to edit all attributes and relations in the form */
|
|
18 public static EditIntent editRoleIntent = new EditIntent(
|
|
19 AbstractISMIBean.ROLE,
|
|
20 // attributes
|
|
21 new String[]{"name"},
|
|
22 // source relations
|
|
23 new String[]{},
|
|
24 // target relations
|
|
25 new String[]{});
|
|
26
|
1
|
27 public CurrentRoleBean(){
|
|
28 this.entity = new Entity(Node.TYPE_ABOX, ROLE, false);
|
|
29 this.setDefObjectClass(ROLE);
|
|
30 }
|
|
31
|
|
32 @Override
|
|
33 public void reset(){
|
|
34 super.reset();
|
|
35 this.entity = new Entity(Node.TYPE_ABOX, ROLE, false);
|
|
36 }
|
|
37
|
|
38 @Override
|
|
39 public void setEntity(Entity role) {
|
|
40 this.reset();
|
|
41 this.entity = role;
|
|
42
|
|
43 if(this.entity != null && this.entity.isPersistent()){
|
|
44 if (this.entity.isLightweight()) {
|
|
45 this.entity = getWrapper().getEntityContent(role);
|
|
46 }
|
|
47 this.loadAttributes(this.entity);//, getDefinition(this.entity));
|
|
48 }
|
|
49 }
|
|
50
|
|
51 @Override
|
|
52 public String save(){
|
|
53 super.save();
|
|
54 try {
|
|
55
|
|
56 if(isConsistent()){
|
|
57 this.entity = updateEntityAttributes(this.entity);
|
125
|
58 this.entity = getWrapper().saveEntity(this.entity, getUserName(), editRoleIntent);
|
1
|
59 getAppBean().setRoleListAsDirty();
|
|
60
|
|
61 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
|
|
62 this.printSuccessSavingEntity();
|
|
63 }
|
|
64
|
|
65 } catch (Exception e) {
|
|
66 logger.error(e.getMessage(), e);
|
|
67 this.printInternalError(e);
|
|
68 }
|
|
69
|
|
70 saveEnd();
|
|
71 return PAGE_EDITOR;
|
|
72 }
|
|
73
|
|
74 private boolean isConsistent(){
|
|
75
|
|
76 if(getAttributes().containsKey("name") &&
|
|
77 StringUtils.isNotEmpty(getAttributes().get("name"))){
|
|
78 return true;
|
|
79
|
|
80 }else{
|
|
81 addErrorMsg("The role has not be saved, because its name can not be empty!");
|
|
82 return false;
|
|
83 }
|
|
84
|
|
85
|
|
86 }
|
|
87 }
|