Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCollectionBean.java @ 134:25bfcc9d757c
effort to re-use more relations when saving entities.
new replaceMultipleSourceRelations() and changes to use it.
changes for renamed replaceUniqueSourceRelation().
author | casties |
---|---|
date | Fri, 24 Feb 2017 20:25:33 +0100 |
parents | eee2e0ca4032 |
children | 502ae5b1a07d |
comparison
equal
deleted
inserted
replaced
133:5ccd6e709f95 | 134:25bfcc9d757c |
---|---|
111 } | 111 } |
112 | 112 |
113 this.entity = this.updateEntityAttributes(this.entity); | 113 this.entity = this.updateEntityAttributes(this.entity); |
114 // checking is the identifier is unique for the selected collecion | 114 // checking is the identifier is unique for the selected collecion |
115 Attribute attName = this.entity.getAttributeByName("name"); | 115 Attribute attName = this.entity.getAttributeByName("name"); |
116 String collectionName = (attName == null) ? null : attName | 116 String collectionName = (attName == null) ? null : attName.getValue(); |
117 .getValue(); | |
118 if (StringUtils.isNotEmpty(collectionName)) { | 117 if (StringUtils.isNotEmpty(collectionName)) { |
119 if (!checkUnityCollection(collectionName, | 118 if (!checkUnityCollection(collectionName, (isSelectedSaveAsNew()) ? null : this.entity.getId(), |
120 (isSelectedSaveAsNew()) ? null : this.entity.getId(), | |
121 this.getRepositoryLo().entity)) { | 119 this.getRepositoryLo().entity)) { |
122 this.renderUnityCheckerDialog(); | 120 this.renderUnityCheckerDialog(); |
123 this.setSelectedSaveAsNew(false); | 121 this.setSelectedSaveAsNew(false); |
124 return ""; | 122 return ""; |
125 } | 123 } |
131 | 129 |
132 if (!isCollectionConsistentBeforeSave()) { | 130 if (!isCollectionConsistentBeforeSave()) { |
133 return ""; | 131 return ""; |
134 } | 132 } |
135 | 133 |
136 if (this.getRepositoryLo().entity != null | 134 if (this.getRepositoryLo().entity != null && this.getRepositoryLo().entity.isLightweight()) { |
137 && this.getRepositoryLo().entity.isLightweight()) { | |
138 this.getRepositoryLo().entity = getWrapper() | 135 this.getRepositoryLo().entity = getWrapper() |
139 .getEntityByIdWithContent( | 136 .getEntityByIdWithContent(this.getRepositoryLo().entity.getId()); |
140 this.getRepositoryLo().entity.getId()); | |
141 } | 137 } |
142 this.entity.replaceSourceRelation(this.getRepositoryLo().entity, | 138 this.entity.replaceUniqueSourceRelation(this.getRepositoryLo().entity, REPOSITORY, is_part_of); |
143 REPOSITORY, is_part_of); | |
144 | 139 |
145 // REFERENCE -> is_reference_of -> THIS | 140 // REFERENCE -> is_reference_of -> THIS |
146 this.prepareEndNoteRefs2Save(); | 141 this.prepareEndNoteRefs2Save(); |
147 | 142 |
148 if (isSelectedSaveAsNew()) { | 143 if (isSelectedSaveAsNew()) { |
149 //this.entity.removeAllTargetRelations(is_part_of, CODEX); | 144 // this.entity.removeAllTargetRelations(is_part_of, CODEX); |
150 //this.entity = getWrapper().saveEntityAsNew(this.entity, | 145 // this.entity = getWrapper().saveEntityAsNew(this.entity, |
151 // getSessionUser().getEmail()); | 146 // getSessionUser().getEmail()); |
152 } else { | 147 } else { |
153 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editCollectionIntent); | 148 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editCollectionIntent); |
154 } | 149 } |
155 | 150 |
156 this.updateRelatedOW(this.entity, getSessionUser().getEmail()); | 151 this.updateRelatedOW(this.entity, getSessionUser().getEmail()); |
157 this.setCurrentId(this.entity.getId().toString()); | 152 this.setCurrentId(this.entity.getId().toString()); |
158 | 153 |
159 logger.info("Entity saved - Time = " | 154 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); |
160 + (System.currentTimeMillis() - start) + ", " + entity); | |
161 this.printSuccessSavingEntity(); | 155 this.printSuccessSavingEntity(); |
162 | 156 |
163 this.setSelectedSaveAsNew(false); | 157 this.setSelectedSaveAsNew(false); |
164 | 158 |
165 } catch (Exception e) { | 159 } catch (Exception e) { |