Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentRepositoryBean.java @ 216:93d33f138c9e default tip
update medeniyet image server URL.
author | casties |
---|---|
date | Wed, 26 Jan 2022 16:39:32 +0100 |
parents | 502ae5b1a07d |
children |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.entry.beans; |
2 | |
3 import java.io.Serializable; | |
4 | |
5 import org.apache.commons.lang.StringUtils; | |
6 import org.apache.log4j.Logger; | |
7 import org.mpi.openmind.repository.bo.Attribute; | |
8 import org.mpi.openmind.repository.bo.Entity; | |
9 import org.mpi.openmind.repository.bo.Node; | |
125 | 10 import org.mpi.openmind.repository.services.utils.EditIntent; |
1 | 11 |
12 public class CurrentRepositoryBean extends CodexEditorTemplate implements Serializable{ | |
13 private static final long serialVersionUID = 2926289436446091260L; | |
14 | |
15 private static Logger logger = Logger.getLogger(CurrentRepositoryBean.class); | |
16 | |
17 public static int MAX_PLACES = 100; | |
18 //private Entity repository; | |
19 | |
125 | 20 /** intent to edit all attributes and relations in the form */ |
21 public static EditIntent editRepositoryIntent = new EditIntent( | |
22 AbstractISMIBean.REPOSITORY, | |
23 // attributes | |
24 new String[]{"name"}, | |
25 // source relations | |
26 new String[]{"is_in"}, | |
27 // target relations | |
28 new String[]{"is_reference_of"}); | |
29 | |
1 | 30 @Override |
31 public void reset(){ | |
32 super.reset(); | |
33 this.entity = new Entity(Node.TYPE_ABOX, REPOSITORY, false); | |
34 } | |
35 | |
36 public CurrentRepositoryBean(){ | |
37 this.reset(); | |
38 setDefObjectClass(REPOSITORY); | |
39 registerChecker(getCityLo().statusImage, "City not valid!"); | |
40 registerChecker(getCountryLo().statusImage, "Country is not valid!"); | |
41 } | |
42 | |
43 | |
44 @Override | |
45 public void setEntity(Entity repository) { | |
46 this.reset(); | |
47 this.entity = repository; | |
48 | |
49 if(this.entity != null && this.entity.isPersistent()){ | |
50 if(this.entity.isLightweight()){ | |
51 this.entity = getWrapper().getEntityContent(this.entity); | |
52 } | |
53 | |
54 this.setCurrentId(this.entity.getId().toString()); | |
55 this.loadAttributes(this.entity);//, getDefinition(this.entity)); | |
56 | |
57 //this.loadReferences(this.entity); | |
58 this.loadEndNoteRefs(); | |
59 | |
60 for(Entity city : getWrapper().getTargetsForSourceRelation(this.entity, "is_in", PLACE, 1)){ | |
61 this.setCity(city); | |
62 } | |
63 } | |
64 } | |
65 | |
66 public String saveAsNewEntity(){ | |
67 this.setSelectedSaveAsNew(true); | |
68 return save(); | |
69 } | |
70 | |
71 | |
72 @Override | |
73 public String save(){ | |
74 super.save(); | |
75 try { | |
76 CheckResults cr = getCheckResults(); | |
77 if (cr.hasErrors){ | |
78 getSessionBean().setErrorMessages(cr); | |
79 getSessionBean().setDisplayError(true); | |
80 this.setSelectedSaveAsNew(false); | |
81 return PAGE_EDITOR; | |
82 } | |
83 | |
84 this.entity = this.updateEntityAttributes(this.entity); | |
125 | 85 |
1 | 86 Attribute attName = this.entity.getAttributeByName("name"); |
87 String repositoryName = (attName == null) ? null : attName.getValue(); | |
88 if(StringUtils.isNotEmpty(repositoryName)){ | |
89 if(!checkUnityRepository(repositoryName, (isSelectedSaveAsNew()) ? null : this.entity.getId(), this.getCityLo().entity)){ | |
90 this.renderUnityCheckerDialog(); | |
91 this.setSelectedSaveAsNew(false); | |
92 return PAGE_EDITOR; | |
93 } | |
94 }else{ | |
95 this.addErrorMsg("Ths entity has not been saved, because its name was empty."); | |
96 this.addErrorMsg("You must enter a name."); | |
97 return PAGE_EDITOR; | |
98 } | |
99 | |
100 if(!isRepositoryConsistentBeforeSave()){ | |
101 return PAGE_EDITOR; | |
102 } | |
103 | |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
125
diff
changeset
|
104 this.entity.replaceUniqueSourceRelation(this.getCityLo().getEntity(), PLACE, is_in); |
1 | 105 |
106 //REFERENCE -> is_reference_of -> THIS | |
136 | 107 this.saveReferences(); |
1 | 108 |
109 if(isSelectedSaveAsNew()){ | |
125 | 110 //this.entity.removeAllTargetRelations(is_part_of, COLLECTION); |
111 //this.entity = getWrapper().saveEntityAsNew(this.entity, getSessionUser().getEmail()); | |
1 | 112 }else{ |
125 | 113 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editRepositoryIntent); |
1 | 114 } |
115 | |
91 | 116 this.updateRelatedOW(this.entity, getSessionUser().getEmail()); |
1 | 117 getSessionBean().setEditFormCurrentEntId(this.entity.getId()); |
118 | |
119 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); | |
120 this.printSuccessSavingEntity(); | |
121 | |
122 this.setSelectedSaveAsNew(false); | |
123 } catch (Exception e) { | |
124 logger.error(e.getMessage(), e); | |
125 e.printStackTrace(); | |
126 this.printInternalError(e); | |
127 } | |
128 saveEnd(); | |
129 return PAGE_EDITOR; | |
130 } | |
131 } |