1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.kuali.student.enrollment.class1.lpr.service.impl; |
9 | |
|
10 | |
import java.util.ArrayList; |
11 | |
import java.util.Date; |
12 | |
import java.util.List; |
13 | |
|
14 | |
import javax.jws.WebService; |
15 | |
|
16 | |
import org.apache.commons.lang.StringUtils; |
17 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
18 | |
import org.kuali.student.common.util.UUIDHelper; |
19 | |
import org.kuali.student.enrollment.class1.lpr.dao.LprDao; |
20 | |
import org.kuali.student.enrollment.class1.lpr.dao.LprRosterDao; |
21 | |
import org.kuali.student.enrollment.class1.lpr.dao.LprRosterEntryDao; |
22 | |
import org.kuali.student.enrollment.class1.lpr.dao.LprTransactionDao; |
23 | |
import org.kuali.student.enrollment.class1.lpr.dao.LprTransactionItemDao; |
24 | |
import org.kuali.student.enrollment.class1.lpr.model.LprRichTextEntity; |
25 | |
import org.kuali.student.enrollment.class1.lpr.model.LprRosterAttributeEntity; |
26 | |
import org.kuali.student.enrollment.class1.lpr.model.LprRosterEntity; |
27 | |
import org.kuali.student.enrollment.class1.lpr.model.LprRosterEntryAttributeEntity; |
28 | |
import org.kuali.student.enrollment.class1.lpr.model.LprRosterEntryEntity; |
29 | |
import org.kuali.student.enrollment.class1.lpr.model.LprTransactionEntity; |
30 | |
import org.kuali.student.enrollment.class1.lpr.model.LprTransactionItemEntity; |
31 | |
import org.kuali.student.enrollment.class1.lpr.model.LuiPersonRelationEntity; |
32 | |
import org.kuali.student.enrollment.lpr.dto.LprRosterEntryInfo; |
33 | |
import org.kuali.student.enrollment.lpr.dto.LprRosterInfo; |
34 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionInfo; |
35 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionItemInfo; |
36 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionItemResultInfo; |
37 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo; |
38 | |
import org.kuali.student.enrollment.lpr.service.LuiPersonRelationService; |
39 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
40 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
41 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
42 | |
import org.kuali.student.r2.common.exceptions.AlreadyExistsException; |
43 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
44 | |
import org.kuali.student.r2.common.exceptions.DisabledIdentifierException; |
45 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
46 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
47 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
48 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
49 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
50 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
51 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
52 | |
import org.kuali.student.r2.common.util.constants.LuiPersonRelationServiceConstants; |
53 | |
import org.springframework.transaction.annotation.Transactional; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
@Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
59 | 0 | public class LuiPersonRelationServiceImpl implements LuiPersonRelationService { |
60 | |
|
61 | |
private LprDao lprDao; |
62 | |
private LprRosterDao lprRosterDao; |
63 | |
private LprTransactionDao lprTransDao; |
64 | |
private LprTransactionItemDao lprTransItemDao; |
65 | |
private LprRosterEntryDao lprRosterEntryDao; |
66 | |
|
67 | |
public void setLprTransItemDao(LprTransactionItemDao lprTransItemDao) { |
68 | 0 | this.lprTransItemDao = lprTransItemDao; |
69 | 0 | } |
70 | |
|
71 | |
public LprTransactionDao getLprTransDao() { |
72 | 0 | return lprTransDao; |
73 | |
} |
74 | |
|
75 | |
public void setLprTransDao(LprTransactionDao lprTransDao) { |
76 | 0 | this.lprTransDao = lprTransDao; |
77 | 0 | } |
78 | |
|
79 | |
public LprDao getLprDao() { |
80 | 0 | return lprDao; |
81 | |
} |
82 | |
|
83 | |
public LprRosterEntryDao getLprRosterEntryDao() { |
84 | 0 | return lprRosterEntryDao; |
85 | |
} |
86 | |
|
87 | |
public void setLprRosterEntryDao(LprRosterEntryDao lprRosterEntryDao) { |
88 | 0 | this.lprRosterEntryDao = lprRosterEntryDao; |
89 | 0 | } |
90 | |
|
91 | |
public void setLprDao(LprDao lprDao) { |
92 | 0 | this.lprDao = lprDao; |
93 | 0 | } |
94 | |
|
95 | |
public void setLprRosterDao(LprRosterDao lprRosterDao) { |
96 | 0 | this.lprRosterDao = lprRosterDao; |
97 | 0 | } |
98 | |
|
99 | |
private List<LuiPersonRelationInfo> getLprsByLuiPersonAndState(String personId, String luiId, String stateKey, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
100 | 0 | List<LuiPersonRelationInfo> lprs = this.getLprsByPersonAndLui(personId, luiId, context); |
101 | 0 | List<LuiPersonRelationInfo> list = new ArrayList<LuiPersonRelationInfo>(lprs.size()); |
102 | 0 | for (LuiPersonRelationInfo lpr : lprs) { |
103 | 0 | if (lpr.getStateKey().equals(stateKey)) { |
104 | 0 | list.add(lpr); |
105 | |
} |
106 | |
} |
107 | 0 | return list; |
108 | |
} |
109 | |
|
110 | |
|
111 | |
|
112 | |
@Transactional(readOnly = false) |
113 | |
private String createLprFromLprTransactionItem(LprTransactionItemInfo lprTransactionItemInfo, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
114 | 0 | LuiPersonRelationInfo luiPersonRelation = new LuiPersonRelationInfo(); |
115 | 0 | luiPersonRelation.setCommitmentPercent(100.00F); |
116 | 0 | luiPersonRelation.setEffectiveDate(new Date()); |
117 | 0 | luiPersonRelation.setLuiId(lprTransactionItemInfo.getNewLuiId()); |
118 | 0 | luiPersonRelation.setPersonId(lprTransactionItemInfo.getPersonId()); |
119 | 0 | luiPersonRelation.setStateKey(LuiPersonRelationServiceConstants.REGISTERED_STATE_KEY); |
120 | 0 | luiPersonRelation.setTypeKey(LuiPersonRelationServiceConstants.REGISTRANT_TYPE_KEY); |
121 | |
String createdLpr; |
122 | |
try { |
123 | 0 | createdLpr = createLpr(lprTransactionItemInfo.getPersonId(), lprTransactionItemInfo.getNewLuiId(), LuiPersonRelationServiceConstants.REGISTRANT_TYPE_KEY, luiPersonRelation, context); |
124 | |
|
125 | 0 | } catch (DisabledIdentifierException e) { |
126 | 0 | throw new OperationFailedException(e.getMessage(), e); |
127 | 0 | } catch (ReadOnlyException e) { |
128 | 0 | throw new OperationFailedException(e.getMessage(), e); |
129 | 0 | } |
130 | |
|
131 | 0 | return createdLpr; |
132 | |
} |
133 | |
|
134 | |
private void _checkForMissingParameter(Object param, String paramName) throws MissingParameterException { |
135 | 0 | if (null == param) { |
136 | 0 | throw new MissingParameterException("Parameter '" + paramName + "' cannot be null"); |
137 | |
} |
138 | 0 | } |
139 | |
|
140 | |
@Override |
141 | |
public List<LuiPersonRelationInfo> getLprsByLui(String luiId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
142 | 0 | List<LuiPersonRelationEntity> luiPersonRelations = lprDao.getByLuiId(luiId); |
143 | 0 | List<LuiPersonRelationInfo> dtos = new ArrayList<LuiPersonRelationInfo>(); |
144 | 0 | for (LuiPersonRelationEntity entity : luiPersonRelations) { |
145 | 0 | dtos.add(entity.toDto()); |
146 | |
} |
147 | 0 | return dtos; |
148 | |
} |
149 | |
|
150 | |
@Override |
151 | |
@Transactional |
152 | |
public List<String> createBulkRelationshipsForPerson(String personId, List<String> luiIds, String relationState, String luiPersonRelationTypeKey, LuiPersonRelationInfo luiPersonRelationInfo, ContextInfo context) throws AlreadyExistsException, DataValidationErrorException, DisabledIdentifierException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
153 | |
String lprId; |
154 | 0 | List<String> lprIds = new ArrayList<String>(); |
155 | 0 | for (String luiId : luiIds) { |
156 | 0 | lprId = createLpr(personId, luiId, luiPersonRelationTypeKey, luiPersonRelationInfo, context); |
157 | 0 | lprIds.add(lprId); |
158 | |
} |
159 | 0 | return lprIds; |
160 | |
} |
161 | |
|
162 | |
@Override |
163 | |
public LuiPersonRelationInfo getLpr(String luiPersonRelationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
164 | 0 | LuiPersonRelationEntity lpr = lprDao.find(luiPersonRelationId); |
165 | 0 | return null != lpr ? lpr.toDto() : null; |
166 | |
} |
167 | |
|
168 | |
@Override |
169 | |
public List<LuiPersonRelationInfo> getLprsByIds(List<String> luiPersonRelationIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
170 | 0 | List<LuiPersonRelationInfo> lprInfos = new ArrayList<LuiPersonRelationInfo>(); |
171 | 0 | List<LuiPersonRelationEntity> lprEntities = lprDao.findByIds(luiPersonRelationIds); |
172 | 0 | for (LuiPersonRelationEntity lprEntity : lprEntities) { |
173 | 0 | LuiPersonRelationInfo lprInfo = lprEntity.toDto(); |
174 | 0 | lprInfos.add(lprInfo); |
175 | 0 | } |
176 | 0 | return lprInfos; |
177 | |
} |
178 | |
|
179 | |
@Override |
180 | |
public List<String> getLuiIdsByPersonAndTypeAndState(String personId, String luiPersonRelationType, String relationState, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
181 | |
|
182 | 0 | return null; |
183 | |
} |
184 | |
|
185 | |
@Override |
186 | |
public List<String> getPersonIdsByLuiAndTypeAndState(String luiId, String luiPersonRelationType, String relationState, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
187 | 0 | List<String> returnVals = new ArrayList<String>(); |
188 | |
|
189 | 0 | returnVals.addAll(lprDao.getPersonIdsByLui(luiId, luiPersonRelationType, relationState)); |
190 | 0 | return returnVals; |
191 | |
|
192 | |
} |
193 | |
|
194 | |
@Override |
195 | |
public List<LuiPersonRelationInfo> getLprsByPersonAndLui(String personId, String luiId, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
196 | |
|
197 | 0 | List<LuiPersonRelationEntity> entityList = lprDao.getLprByLuiAndPerson(personId, luiId); |
198 | |
|
199 | 0 | List<LuiPersonRelationInfo> infoList = new ArrayList<LuiPersonRelationInfo>(); |
200 | |
|
201 | 0 | if (entityList != null && !entityList.isEmpty()) { |
202 | 0 | for (LuiPersonRelationEntity entity : entityList) { |
203 | 0 | infoList.add(entity.toDto()); |
204 | |
} |
205 | |
|
206 | |
} |
207 | 0 | return infoList; |
208 | |
|
209 | |
} |
210 | |
|
211 | |
@Override |
212 | |
public List<String> getLprIdsByPersonAndLui(String personId, String luiId, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
213 | 0 | List<String> returnVals = new ArrayList<String>(); |
214 | |
|
215 | 0 | returnVals.addAll(lprDao.getLprIdsByLuiAndPerson(personId, luiId)); |
216 | 0 | return returnVals; |
217 | |
} |
218 | |
|
219 | |
@Override |
220 | |
public List<LuiPersonRelationInfo> getLprsByPerson(String personId, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
221 | 0 | List<LuiPersonRelationEntity> entityList = lprDao.getLprsByPerson(personId); |
222 | |
|
223 | 0 | List<LuiPersonRelationInfo> infoList = new ArrayList<LuiPersonRelationInfo>(); |
224 | 0 | if (entityList != null && !entityList.isEmpty()) { |
225 | 0 | for (LuiPersonRelationEntity entity : entityList) { |
226 | 0 | infoList.add(entity.toDto()); |
227 | |
} |
228 | |
|
229 | |
} |
230 | 0 | return infoList; |
231 | |
} |
232 | |
|
233 | |
@Override |
234 | |
public List<String> getLprIdsByPerson(String personId, ContextInfo context) throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
235 | |
|
236 | 0 | return null; |
237 | |
} |
238 | |
|
239 | |
@Override |
240 | |
public List<String> getLprIdsByLui(String luiId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
241 | |
|
242 | 0 | return null; |
243 | |
} |
244 | |
|
245 | |
@Override |
246 | |
public List<ValidationResultInfo> validateLpr(String validationType, LuiPersonRelationInfo luiPersonRelationInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
247 | |
|
248 | 0 | return null; |
249 | |
} |
250 | |
|
251 | |
@Override |
252 | |
public List<String> searchForLprIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
253 | 0 | throw new UnsupportedOperationException("Operation not supported"); |
254 | |
} |
255 | |
|
256 | |
@Override |
257 | |
@Transactional |
258 | |
public String createLpr(String personId, String luiId, String luiPersonRelationType, LuiPersonRelationInfo luiPersonRelationInfo, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, DisabledIdentifierException, ReadOnlyException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
259 | |
|
260 | |
|
261 | 0 | luiPersonRelationInfo.setPersonId(personId); |
262 | 0 | luiPersonRelationInfo.setLuiId(luiId); |
263 | 0 | luiPersonRelationInfo.setTypeKey(luiPersonRelationType); |
264 | |
|
265 | 0 | LuiPersonRelationEntity lpr = new LuiPersonRelationEntity(luiPersonRelationInfo); |
266 | 0 | lprDao.persist(lpr); |
267 | 0 | return lpr.getId(); |
268 | |
} |
269 | |
|
270 | |
@Override |
271 | |
public List<String> createBulkRelationshipsForLui(String luiId, List<String> personIds, String relationState, String luiPersonRelationType, LuiPersonRelationInfo luiPersonRelationInfo, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, DisabledIdentifierException, ReadOnlyException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
272 | |
|
273 | 0 | return null; |
274 | |
} |
275 | |
|
276 | |
@Override |
277 | |
@Transactional |
278 | |
public LuiPersonRelationInfo updateLpr(String luiPersonRelationId, LuiPersonRelationInfo luiPersonRelationInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, ReadOnlyException, OperationFailedException, PermissionDeniedException { |
279 | 0 | LuiPersonRelationEntity lprEntity = lprDao.find(luiPersonRelationId); |
280 | |
|
281 | 0 | if (lprEntity != null) { |
282 | 0 | LuiPersonRelationEntity modifiedLpr = new LuiPersonRelationEntity(luiPersonRelationInfo); |
283 | |
|
284 | 0 | if (luiPersonRelationInfo.getStateKey() != null) { |
285 | 0 | modifiedLpr.setPersonRelationStateId(luiPersonRelationInfo.getStateKey()); |
286 | |
} |
287 | |
|
288 | 0 | if (luiPersonRelationInfo.getTypeKey() != null) { |
289 | 0 | modifiedLpr.setPersonRelationTypeId(luiPersonRelationInfo.getTypeKey()); |
290 | |
} |
291 | |
|
292 | 0 | lprDao.merge(modifiedLpr); |
293 | 0 | return lprDao.find(modifiedLpr.getId()).toDto(); |
294 | |
} else { |
295 | 0 | throw new DoesNotExistException(luiPersonRelationId); |
296 | |
} |
297 | |
} |
298 | |
|
299 | |
@Override |
300 | |
@Transactional(readOnly = false) |
301 | |
public StatusInfo deleteLpr(String luiPersonRelationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
302 | 0 | _checkForMissingParameter(luiPersonRelationId, "luiPersonRelationId"); |
303 | 0 | LuiPersonRelationEntity lprEntity = lprDao.find(luiPersonRelationId); |
304 | 0 | lprEntity.setPersonRelationStateId(LuiPersonRelationServiceConstants.DROPPED_STATE_KEY); |
305 | 0 | lprDao.merge(lprEntity); |
306 | 0 | StatusInfo status = new StatusInfo(); |
307 | 0 | status.setSuccess(Boolean.TRUE); |
308 | 0 | return status; |
309 | |
} |
310 | |
|
311 | |
@Override |
312 | |
public List<LuiPersonRelationInfo> searchForLprs(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
313 | 0 | throw new UnsupportedOperationException(); |
314 | |
} |
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
@Override |
323 | |
public LprTransactionInfo getLprTransaction(String lprTransactionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
324 | |
|
325 | 0 | LprTransactionEntity transactionEntity = lprTransDao.find(lprTransactionId); |
326 | |
|
327 | 0 | return transactionEntity.toDto(); |
328 | |
} |
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
@Override |
337 | |
@Transactional(readOnly = false) |
338 | |
public StatusInfo deleteLprTransaction(String lprTransactionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
339 | |
|
340 | 0 | StatusInfo status = new StatusInfo(); |
341 | |
|
342 | 0 | LprTransactionEntity lprTrans = lprTransDao.find(lprTransactionId); |
343 | 0 | if (null != lprTrans) { |
344 | |
|
345 | 0 | lprTransDao.remove(lprTrans); |
346 | |
|
347 | 0 | status.setSuccess(Boolean.TRUE); |
348 | |
|
349 | |
} else { |
350 | 0 | status.setSuccess(Boolean.FALSE); |
351 | |
} |
352 | |
|
353 | 0 | return status; |
354 | |
} |
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
@Override |
363 | |
public List<LuiPersonRelationInfo> getLprsByPersonForAtp(String personId, String atpId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
364 | |
|
365 | 0 | return null; |
366 | |
} |
367 | |
|
368 | |
@Override |
369 | |
@Transactional(readOnly = false) |
370 | |
public LprRosterInfo updateLprRoster(String lprRosterId, LprRosterInfo lprRosterInfo, ContextInfo context) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, ReadOnlyException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
371 | |
|
372 | 0 | LprRosterEntity lprRosterEntity = lprRosterDao.find(lprRosterId); |
373 | |
|
374 | 0 | if (lprRosterEntity == null) { |
375 | 0 | throw new DoesNotExistException(lprRosterId); |
376 | |
} |
377 | |
|
378 | 0 | LprRosterEntity modifiedLprRoster = new LprRosterEntity(lprRosterInfo); |
379 | 0 | if (lprRosterInfo.getAssociatedLuiIds() != null && !lprRosterInfo.getAssociatedLuiIds().isEmpty()) { |
380 | |
|
381 | |
|
382 | |
} |
383 | |
|
384 | 0 | if (lprRosterInfo.getStateKey() != null) { |
385 | 0 | modifiedLprRoster.setLprRosterState(lprRosterInfo.getStateKey()); |
386 | |
} |
387 | |
|
388 | 0 | if (lprRosterInfo.getTypeKey() != null) { |
389 | 0 | modifiedLprRoster.setLprRosterType(lprRosterInfo.getTypeKey()); |
390 | |
} |
391 | |
|
392 | 0 | lprRosterDao.merge(modifiedLprRoster); |
393 | |
|
394 | 0 | LprRosterEntity entity = lprRosterDao.find(modifiedLprRoster.getId()); |
395 | 0 | LprRosterInfo info = entity.toDto(); |
396 | 0 | return info; |
397 | |
} |
398 | |
|
399 | |
@Override |
400 | |
@Transactional(readOnly = false) |
401 | |
public String createLprRoster(LprRosterInfo lprRosterInfo, ContextInfo context) throws DataValidationErrorException, AlreadyExistsException, DoesNotExistException, DisabledIdentifierException, ReadOnlyException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
402 | |
|
403 | 0 | LprRosterEntity rosterEntity = new LprRosterEntity(lprRosterInfo); |
404 | 0 | rosterEntity.setId(UUIDHelper.genStringUUID()); |
405 | |
|
406 | 0 | if (lprRosterInfo.getStateKey() != null) { |
407 | 0 | rosterEntity.setLprRosterState(lprRosterInfo.getStateKey()); |
408 | |
} |
409 | 0 | if (lprRosterInfo.getTypeKey() != null) { |
410 | 0 | rosterEntity.setLprRosterType(lprRosterInfo.getTypeKey()); |
411 | |
} |
412 | |
|
413 | 0 | if (lprRosterInfo.getAssociatedLuiIds() != null) { |
414 | |
|
415 | |
|
416 | |
} |
417 | |
|
418 | 0 | if (rosterEntity.getAttributes() != null) { |
419 | 0 | for (LprRosterAttributeEntity attribute : rosterEntity.getAttributes()) { |
420 | 0 | if (StringUtils.isEmpty(attribute.getId())) { |
421 | 0 | attribute.setId(UUIDHelper.genStringUUID()); |
422 | |
} |
423 | |
} |
424 | |
} |
425 | |
|
426 | 0 | lprRosterDao.persist(rosterEntity); |
427 | |
|
428 | 0 | rosterEntity = lprRosterDao.find(rosterEntity.getId()); |
429 | |
|
430 | 0 | return rosterEntity.getId(); |
431 | |
} |
432 | |
|
433 | |
@Override |
434 | |
@Transactional(readOnly = false) |
435 | |
public StatusInfo deleteLprRoster(String lprRosterId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
436 | |
|
437 | 0 | StatusInfo status = new StatusInfo(); |
438 | |
|
439 | 0 | LprRosterEntity entity = lprRosterDao.find(lprRosterId); |
440 | |
|
441 | 0 | if (entity != null) { |
442 | 0 | status.setSuccess(true); |
443 | |
} else { |
444 | 0 | status.setSuccess(false); |
445 | |
} |
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | 0 | lprRosterDao.remove(entity); |
451 | 0 | return status; |
452 | |
} |
453 | |
|
454 | |
@Override |
455 | |
public List<LprRosterEntryInfo> getLprRosterEntriesForRoster(String lprRosterId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
456 | |
|
457 | 0 | List<LprRosterEntryEntity> entities = lprRosterEntryDao.getLprRosterEntriesForLprRoster(lprRosterId); |
458 | |
|
459 | 0 | List<LprRosterEntryInfo> infos = new ArrayList<LprRosterEntryInfo>(); |
460 | 0 | if (entities != null) { |
461 | 0 | for (LprRosterEntryEntity entry : entities) { |
462 | 0 | infos.add(entry.toDto()); |
463 | |
} |
464 | |
} |
465 | |
|
466 | 0 | return infos; |
467 | |
|
468 | |
} |
469 | |
|
470 | |
@Override |
471 | |
public List<LprRosterEntryInfo> getLprRosterEntriesByIds(List<String> lprRosterEntryIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
472 | |
|
473 | 0 | List<LprRosterEntryEntity> entities = lprRosterEntryDao.findByIds(lprRosterEntryIds); |
474 | |
|
475 | 0 | List<LprRosterEntryInfo> infos = new ArrayList<LprRosterEntryInfo>(); |
476 | 0 | if (entities != null) { |
477 | 0 | for (LprRosterEntryEntity entry : entities) { |
478 | 0 | infos.add(entry.toDto()); |
479 | |
} |
480 | |
} |
481 | |
|
482 | 0 | return infos; |
483 | |
} |
484 | |
|
485 | |
@Override |
486 | |
public List<LprRosterInfo> getLprRostersByLuiAndType(String luiId, String lprRosterTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
487 | |
|
488 | 0 | List<LprRosterEntity> entities = lprRosterDao.getLprRostersByLuiAndRosterType(luiId, lprRosterTypeKey); |
489 | 0 | List<LprRosterInfo> lprRosterInfoList = new ArrayList(); |
490 | 0 | if (entities != null) { |
491 | 0 | for (LprRosterEntity lprRosterEntity : entities) { |
492 | 0 | lprRosterInfoList.add(lprRosterEntity.toDto()); |
493 | |
} |
494 | |
} |
495 | |
|
496 | 0 | return lprRosterInfoList; |
497 | |
} |
498 | |
|
499 | |
@Override |
500 | |
public List<LprRosterInfo> getLprRostersByLui(String luiId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
501 | |
|
502 | 0 | List<LprRosterEntity> entities = lprRosterDao.getLprRostersByLui(luiId); |
503 | 0 | List<LprRosterInfo> lprRosterInfoList = new ArrayList(); |
504 | 0 | if (entities != null) { |
505 | 0 | for (LprRosterEntity lprRosterEntity : entities) { |
506 | 0 | lprRosterInfoList.add(lprRosterEntity.toDto()); |
507 | |
} |
508 | |
} |
509 | |
|
510 | 0 | return lprRosterInfoList; |
511 | |
} |
512 | |
|
513 | |
@Override |
514 | |
public LprRosterInfo getLprRoster(String lprRosterId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
515 | |
|
516 | 0 | LprRosterEntity entity = lprRosterDao.find(lprRosterId); |
517 | 0 | if (entity == null) { |
518 | 0 | return null; |
519 | |
} |
520 | |
|
521 | 0 | return entity.toDto(); |
522 | |
} |
523 | |
|
524 | |
@Override |
525 | |
@Transactional(readOnly = false) |
526 | |
public String createLprRosterEntry(LprRosterEntryInfo lprRosterEntryInfo, ContextInfo context) throws DataValidationErrorException, AlreadyExistsException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
527 | |
|
528 | 0 | LprRosterEntryEntity rosterEntity = new LprRosterEntryEntity(lprRosterEntryInfo); |
529 | 0 | rosterEntity.setId(UUIDHelper.genStringUUID()); |
530 | 0 | rosterEntity.setEffectiveDate(lprRosterEntryInfo.getEffectiveDate()); |
531 | 0 | rosterEntity.setExpirationDate(lprRosterEntryInfo.getExpirationDate()); |
532 | 0 | rosterEntity.setLprId(lprRosterEntryInfo.getLprId()); |
533 | 0 | rosterEntity.setLprRosterId(lprRosterEntryInfo.getLprRosterId()); |
534 | |
|
535 | 0 | if (lprRosterEntryInfo.getStateKey() != null) { |
536 | 0 | rosterEntity.setLprEntryRelationState(lprRosterEntryInfo.getStateKey()); |
537 | |
} |
538 | 0 | if (lprRosterEntryInfo.getTypeKey() != null) { |
539 | 0 | rosterEntity.setLprEntryRelationType(lprRosterEntryInfo.getTypeKey()); |
540 | |
} |
541 | |
|
542 | 0 | if (rosterEntity.getAttributes() != null) { |
543 | 0 | for (LprRosterEntryAttributeEntity attribute : rosterEntity.getAttributes()) { |
544 | 0 | if (StringUtils.isEmpty(attribute.getId())) { |
545 | 0 | attribute.setId(UUIDHelper.genStringUUID()); |
546 | |
} |
547 | 0 | if (attribute.getOwner() == null) { |
548 | 0 | attribute.setOwner(rosterEntity); |
549 | |
} |
550 | |
} |
551 | |
} |
552 | |
|
553 | 0 | lprRosterEntryDao.persist(rosterEntity); |
554 | |
|
555 | 0 | rosterEntity = lprRosterEntryDao.find(rosterEntity.getId()); |
556 | |
|
557 | 0 | return rosterEntity.getId(); |
558 | |
|
559 | |
} |
560 | |
|
561 | |
@Override |
562 | |
@Transactional(readOnly = false) |
563 | |
public StatusInfo deleteLprRosterEntry(String lprRosterEntryId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
564 | |
|
565 | 0 | StatusInfo status = new StatusInfo(); |
566 | |
|
567 | 0 | LprRosterEntryEntity entity = lprRosterEntryDao.find(lprRosterEntryId); |
568 | |
|
569 | 0 | if (entity != null) { |
570 | 0 | status.setSuccess(true); |
571 | |
} else { |
572 | 0 | status.setSuccess(false); |
573 | |
} |
574 | |
|
575 | 0 | lprRosterEntryDao.remove(entity); |
576 | 0 | return status; |
577 | |
} |
578 | |
|
579 | |
@Override |
580 | |
public StatusInfo insertLprRosterEntryInPosition(String lprRosterEntryId, Integer position, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
581 | |
|
582 | 0 | return null; |
583 | |
} |
584 | |
|
585 | |
@Override |
586 | |
public StatusInfo reorderLprRosterEntries(List<String> lprRosterEntryIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
587 | |
|
588 | 0 | return null; |
589 | |
} |
590 | |
|
591 | |
@Override |
592 | |
@Transactional(readOnly = false) |
593 | |
public LprTransactionInfo createLprTransaction(String lprTransactionType, LprTransactionInfo lprTransactionInfo, ContextInfo context) throws DataValidationErrorException, AlreadyExistsException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
594 | |
|
595 | 0 | LprTransactionEntity lprTransactionEntity = new LprTransactionEntity(lprTransactionInfo); |
596 | 0 | if (lprTransactionEntity.getId() == null) { |
597 | 0 | lprTransactionEntity.setId(UUIDHelper.genStringUUID()); |
598 | |
} |
599 | 0 | if (null != lprTransactionInfo.getStateKey()) { |
600 | 0 | lprTransactionEntity.setLprTransState(lprTransactionInfo.getStateKey()); |
601 | |
} |
602 | |
|
603 | 0 | if (null != lprTransactionInfo.getTypeKey()) { |
604 | 0 | lprTransactionEntity.setLprTransType(lprTransactionInfo.getTypeKey()); |
605 | |
} |
606 | 0 | if (null != lprTransactionInfo.getDescr()) { |
607 | 0 | lprTransactionEntity.setDescr(new LprRichTextEntity(lprTransactionInfo.getDescr())); |
608 | |
} |
609 | |
|
610 | 0 | List<LprTransactionItemEntity> lprTransItemEntities = new ArrayList<LprTransactionItemEntity>(); |
611 | |
|
612 | 0 | for (LprTransactionItemInfo lprTransItemInfo : lprTransactionInfo.getLprTransactionItems()) { |
613 | |
|
614 | 0 | LprTransactionItemEntity lprTransItemEntity = createLprTransactionItem(lprTransItemInfo, context); |
615 | |
|
616 | 0 | lprTransItemEntities.add(lprTransItemEntity); |
617 | 0 | } |
618 | |
|
619 | 0 | lprTransactionEntity.setLprTransactionItems(lprTransItemEntities); |
620 | 0 | LprTransactionEntity existing = lprTransDao.find(lprTransactionEntity.getId()); |
621 | |
|
622 | 0 | if (existing != null) { |
623 | 0 | throw new AlreadyExistsException(); |
624 | |
} |
625 | |
|
626 | 0 | lprTransDao.persist(lprTransactionEntity); |
627 | |
|
628 | 0 | LprTransactionEntity retrived = lprTransDao.find(lprTransactionEntity.getId()); |
629 | |
|
630 | 0 | LprTransactionInfo info = null; |
631 | 0 | if (retrived != null) { |
632 | 0 | info = retrived.toDto(); |
633 | |
} |
634 | |
|
635 | 0 | return info; |
636 | |
|
637 | |
} |
638 | |
|
639 | |
@Override |
640 | |
@Transactional(readOnly = false) |
641 | |
public LprTransactionInfo createLprTransactionFromExisting(String lprTransactionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
642 | |
|
643 | 0 | LprTransactionEntity existingLprTransactionEntity = lprTransDao.find(lprTransactionId); |
644 | 0 | LprTransactionEntity newLprTransactionEntity = new LprTransactionEntity(); |
645 | 0 | if (existingLprTransactionEntity != null) { |
646 | 0 | newLprTransactionEntity.setId(UUIDHelper.genStringUUID()); |
647 | 0 | newLprTransactionEntity.setAttributes(existingLprTransactionEntity.getAttributes()); |
648 | 0 | newLprTransactionEntity.setDescr(existingLprTransactionEntity.getDescr()); |
649 | 0 | List<LprTransactionItemEntity> newItems = new ArrayList(existingLprTransactionEntity.getLprTransactionItems().size()); |
650 | 0 | for (LprTransactionItemEntity existingItem : existingLprTransactionEntity.getLprTransactionItems()) { |
651 | 0 | LprTransactionItemEntity newItem = new LprTransactionItemEntity(); |
652 | 0 | newItem.setId(UUIDHelper.genStringUUID()); |
653 | 0 | newItem.setExistingLuiId(lprTransactionId); |
654 | 0 | newItem.setLprTransactionItemState(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_NEW_STATE_KEY); |
655 | 0 | newItem.setLprTransactionItemType(existingItem.getLprTransactionItemType()); |
656 | 0 | newItem.setNewLuiId(existingItem.getNewLuiId()); |
657 | 0 | newItem.setPersonId(existingItem.getPersonId()); |
658 | 0 | newItem.setDescr(existingItem.getDescr()); |
659 | 0 | } |
660 | 0 | newLprTransactionEntity.setLprTransactionItems(newItems); |
661 | 0 | newLprTransactionEntity.setLprTransState(LuiPersonRelationServiceConstants.LPRTRANS_NEW_STATE_KEY); |
662 | 0 | newLprTransactionEntity.setLprTransType(existingLprTransactionEntity.getLprTransType()); |
663 | 0 | newLprTransactionEntity.setRequestingPersonId(existingLprTransactionEntity.getRequestingPersonId()); |
664 | 0 | lprTransDao.persist(newLprTransactionEntity); |
665 | |
|
666 | 0 | } else { |
667 | 0 | throw new DoesNotExistException("Could not find any LPR Transaction for id : " + lprTransactionId); |
668 | |
} |
669 | 0 | LprTransactionEntity retrived = lprTransDao.find(newLprTransactionEntity.getId()); |
670 | 0 | LprTransactionInfo info = null; |
671 | 0 | if (retrived != null) { |
672 | 0 | info = retrived.toDto(); |
673 | |
} else { |
674 | 0 | throw new OperationFailedException(""); |
675 | |
} |
676 | 0 | return info; |
677 | |
} |
678 | |
|
679 | |
@Override |
680 | |
public List<LprTransactionInfo> getLprTransactionsWithItemsByPersonAndLui(String personId, String luiId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
681 | |
|
682 | 0 | return null; |
683 | |
} |
684 | |
|
685 | |
@Override |
686 | |
public List<ValidationResultInfo> validateLprTransaction(String lprTransactionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
687 | |
|
688 | 0 | return null; |
689 | |
} |
690 | |
|
691 | |
@Override |
692 | |
@Transactional(readOnly = false) |
693 | |
public LprTransactionInfo processLprTransaction(String lprTransactionId, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
694 | 0 | LprTransactionInfo lprTransaction = getLprTransaction(lprTransactionId, context); |
695 | |
|
696 | 0 | for (LprTransactionItemInfo lprTransactionItemInfo : lprTransaction.getLprTransactionItems()) { |
697 | 0 | LprTransactionItemResultInfo lprTransResultInfo = new LprTransactionItemResultInfo(); |
698 | 0 | if (lprTransactionItemInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TYPE_KEY) || lprTransactionItemInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TO_WAITLIST_TYPE_KEY)) { |
699 | 0 | String lprCreated = createLprFromLprTransactionItem(lprTransactionItemInfo, context); |
700 | |
|
701 | 0 | lprTransResultInfo.setResultingLprId(lprCreated); |
702 | |
|
703 | 0 | } else if (lprTransactionItemInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_DROP_TYPE_KEY)) { |
704 | |
|
705 | |
|
706 | |
|
707 | |
|
708 | |
|
709 | |
|
710 | |
|
711 | |
|
712 | |
|
713 | |
|
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | |
|
719 | |
List<LuiPersonRelationInfo> toBeDroppedLPRs; |
720 | |
try { |
721 | 0 | toBeDroppedLPRs = getLprsByLuiPersonAndState(lprTransactionItemInfo.getPersonId(), lprTransactionItemInfo.getExistingLuiId(), LuiPersonRelationServiceConstants.REGISTERED_STATE_KEY, context); |
722 | 0 | } catch (DisabledIdentifierException ex) { |
723 | 0 | throw new OperationFailedException("unexpected", ex); |
724 | 0 | } |
725 | |
|
726 | 0 | if (toBeDroppedLPRs.size() > 1) { |
727 | 0 | throw new OperationFailedException("Multiple LuiPersonRelations between person:" + lprTransactionItemInfo.getPersonId() + " and lui:" + lprTransactionItemInfo.getExistingLuiId() + "; unimplemented functionality required to deal with this scenario is currentluy unimplemented"); |
728 | |
} |
729 | 0 | for (LuiPersonRelationInfo lprInfo : toBeDroppedLPRs) { |
730 | |
|
731 | |
|
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | 0 | deleteLpr(lprInfo.getId(), context); |
737 | 0 | lprTransResultInfo.setResultingLprId(lprInfo.getId()); |
738 | |
} |
739 | |
|
740 | 0 | } else if (lprTransactionItemInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_SWAP_TYPE_KEY)) { |
741 | |
|
742 | |
List<LuiPersonRelationInfo> toBeDroppedLPRs; |
743 | |
try { |
744 | 0 | toBeDroppedLPRs = getLprsByLuiPersonAndState(lprTransactionItemInfo.getPersonId(), lprTransactionItemInfo.getExistingLuiId(), LuiPersonRelationServiceConstants.REGISTERED_STATE_KEY, context); |
745 | 0 | } catch (DisabledIdentifierException ex) { |
746 | 0 | throw new OperationFailedException("unexpected", ex); |
747 | 0 | } |
748 | 0 | if (toBeDroppedLPRs.size() > 1) { |
749 | 0 | throw new OperationFailedException("Multiple LuiPersonRelations between person:" + lprTransactionItemInfo.getPersonId() + " and lui:" + lprTransactionItemInfo.getExistingLuiId() + "; unimplemented functionality required to deal with this scenario is currentluy unimplemented"); |
750 | |
} |
751 | 0 | for (LuiPersonRelationInfo lprInfo : toBeDroppedLPRs) { |
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | 0 | deleteLpr(lprInfo.getId(), context); |
759 | 0 | String lprCreated = createLprFromLprTransactionItem(lprTransactionItemInfo, context); |
760 | |
|
761 | 0 | lprTransResultInfo.setResultingLprId(lprCreated); |
762 | 0 | } |
763 | 0 | } else { |
764 | |
|
765 | 0 | throw new OperationFailedException("The LPR Transaction Item did not have one of the supported type "); |
766 | |
} |
767 | 0 | lprTransResultInfo.setStatus("SUCCESS"); |
768 | 0 | lprTransactionItemInfo.setStateKey(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_SUCCEEDED_STATE_KEY); |
769 | 0 | lprTransactionItemInfo.setLprTransactionItemResult(lprTransResultInfo); |
770 | |
|
771 | 0 | } |
772 | |
try { |
773 | 0 | lprTransaction.setStateKey(LuiPersonRelationServiceConstants.LPRTRANS_SUCCEEDED_STATE_KEY); |
774 | 0 | updateLprTransaction(lprTransactionId, lprTransaction, context); |
775 | 0 | } catch (DataValidationErrorException ex) { |
776 | 0 | throw new OperationFailedException(ex.getMessage()); |
777 | 0 | } |
778 | 0 | return lprTransaction; |
779 | |
} |
780 | |
|
781 | |
@Override |
782 | |
public List<String> getLprTransactionIdsByStateWithItemsByPerson(String personId, List<String> lprTypes, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
783 | |
|
784 | 0 | return null; |
785 | |
} |
786 | |
|
787 | |
@Override |
788 | |
public List<LprTransactionInfo> getLprTransactionsByIds(List<String> lprIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
789 | |
|
790 | 0 | return null; |
791 | |
} |
792 | |
|
793 | |
@Override |
794 | |
public List<LprTransactionInfo> getLprTransactionsByRequestingPersonAndAtp(String personId, |
795 | |
String atpId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
796 | |
|
797 | |
|
798 | 0 | List<LprTransactionItemEntity> lprTransItems = lprTransItemDao.getLprTransactionItemByPerson(personId); |
799 | 0 | List<LprTransactionInfo> lprTransInfos = new ArrayList<LprTransactionInfo>(); |
800 | |
|
801 | 0 | for (LprTransactionItemEntity lprTransItem : lprTransItems) { |
802 | |
String luiId; |
803 | 0 | if (lprTransItem.getNewLuiId() != null) { |
804 | 0 | luiId = lprTransItem.getNewLuiId(); |
805 | |
} else { |
806 | 0 | luiId = lprTransItem.getExistingLuiId(); |
807 | |
} |
808 | |
|
809 | |
|
810 | |
|
811 | 0 | LprTransactionEntity lprTransEntity = lprTransDao.getByLprTransactionItemId(lprTransItem.getId()); |
812 | |
|
813 | |
|
814 | 0 | lprTransInfos.add(lprTransEntity.toDto()); |
815 | |
|
816 | 0 | } |
817 | |
|
818 | 0 | return lprTransInfos; |
819 | |
} |
820 | |
|
821 | |
@Override |
822 | |
public List<LprTransactionInfo> getLprTransactionsWithItemsByResultingLpr(String lprId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
823 | |
|
824 | 0 | List<LprTransactionItemEntity> lprTransItems = lprTransItemDao.getLprTransactionItemsByLpr(lprId); |
825 | 0 | List<LprTransactionEntity> lprTrans = new ArrayList<LprTransactionEntity>(); |
826 | 0 | for (LprTransactionItemEntity lprTransItem : lprTransItems) { |
827 | |
|
828 | 0 | lprTrans.add(lprTransDao.getByLprTransactionItemId(lprTransItem.getId())); |
829 | |
} |
830 | 0 | List<LprTransactionInfo> lprTransInfos = new ArrayList<LprTransactionInfo>(); |
831 | |
|
832 | 0 | for (LprTransactionEntity lprTransEntity : lprTrans) { |
833 | 0 | lprTransInfos.add(lprTransEntity.toDto()); |
834 | |
} |
835 | 0 | return lprTransInfos; |
836 | |
} |
837 | |
|
838 | |
@Override |
839 | |
public List<LprTransactionInfo> getLprTransactionsWithItemsByLui(String luiId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
840 | |
|
841 | 0 | return null; |
842 | |
} |
843 | |
|
844 | |
@Transactional(readOnly = false) |
845 | |
@Override |
846 | |
public LprTransactionInfo updateLprTransaction(String lprTransactionId, LprTransactionInfo lprTransactionInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
847 | 0 | LprTransactionEntity lprTrans = lprTransDao.find(lprTransactionId); |
848 | |
|
849 | 0 | if (null != lprTrans) { |
850 | 0 | LprTransactionEntity modifiedLprTrans = new LprTransactionEntity(lprTransactionInfo); |
851 | 0 | if (lprTransactionInfo.getStateKey() != null) { |
852 | 0 | modifiedLprTrans.setLprTransState(lprTransactionInfo.getStateKey()); |
853 | |
} |
854 | 0 | if (lprTransactionInfo.getTypeKey() != null) { |
855 | 0 | modifiedLprTrans.setLprTransType(lprTransactionInfo.getTypeKey()); |
856 | |
} |
857 | |
|
858 | 0 | List<LprTransactionItemEntity> lprTransItemEntityList = processLprTransactionItemsModification(lprTransactionInfo, lprTrans, context); |
859 | |
|
860 | 0 | modifiedLprTrans.setLprTransactionItems(lprTransItemEntityList); |
861 | 0 | lprTransDao.merge(modifiedLprTrans); |
862 | 0 | return lprTransDao.find(modifiedLprTrans.getId()).toDto(); |
863 | |
|
864 | |
} else { |
865 | 0 | throw new DoesNotExistException(lprTransactionId); |
866 | |
} |
867 | |
} |
868 | |
|
869 | |
@Transactional(readOnly = false) |
870 | |
private List<LprTransactionItemEntity> processLprTransactionItemsModification(LprTransactionInfo modifiedTransactionInfo, LprTransactionEntity originalLprTransEntity, ContextInfo context) { |
871 | 0 | List<LprTransactionItemEntity> modifiedLprTransItemEntities = new ArrayList<LprTransactionItemEntity>(); |
872 | 0 | LprTransactionInfo originalLprTransInfo = originalLprTransEntity.toDto(); |
873 | 0 | List<String> deletedItems = new ArrayList<String>(); |
874 | |
|
875 | 0 | for (LprTransactionItemInfo originalLprTransItemInfo : originalLprTransInfo.getLprTransactionItems()) { |
876 | 0 | deletedItems.add(originalLprTransItemInfo.getId()); |
877 | |
} |
878 | |
|
879 | 0 | for (LprTransactionItemInfo modifiedTransactionItemInfo : modifiedTransactionInfo.getLprTransactionItems()) { |
880 | 0 | boolean existingItem = false; |
881 | 0 | if (modifiedTransactionItemInfo.getId() != null) { |
882 | 0 | for (LprTransactionItemInfo originalLprTransItemInfo : originalLprTransInfo.getLprTransactionItems()) { |
883 | 0 | if (originalLprTransItemInfo.getId().equals(modifiedTransactionItemInfo.getId())) { |
884 | 0 | existingItem = true; |
885 | 0 | deletedItems.remove(originalLprTransItemInfo.getId()); |
886 | |
} |
887 | |
} |
888 | 0 | if (existingItem) { |
889 | |
|
890 | 0 | modifiedLprTransItemEntities.add(updateLprTransactionItem(modifiedTransactionItemInfo, context)); |
891 | |
} |
892 | |
} |
893 | |
|
894 | 0 | if (!existingItem || modifiedTransactionItemInfo.getId() == null) { |
895 | 0 | modifiedLprTransItemEntities.add(createLprTransactionItem(modifiedTransactionItemInfo, context)); |
896 | |
} |
897 | 0 | } |
898 | |
|
899 | 0 | for (String id : deletedItems) { |
900 | 0 | lprTransItemDao.remove(lprTransItemDao.find(id)); |
901 | |
} |
902 | |
|
903 | 0 | return modifiedLprTransItemEntities; |
904 | |
|
905 | |
} |
906 | |
|
907 | |
private LprTransactionItemEntity updateLprTransactionItem(LprTransactionItemInfo modifiedTransactionItemInfo, ContextInfo context) { |
908 | 0 | LprTransactionItemEntity modifiedLprItemEntity = new LprTransactionItemEntity(modifiedTransactionItemInfo); |
909 | 0 | if (null != modifiedTransactionItemInfo.getStateKey()) { |
910 | 0 | modifiedLprItemEntity.setLprTransactionItemState(modifiedTransactionItemInfo.getStateKey()); |
911 | |
} |
912 | 0 | if (null != modifiedTransactionItemInfo.getTypeKey()) { |
913 | 0 | modifiedLprItemEntity.setLprTransactionItemType(modifiedTransactionItemInfo.getTypeKey()); |
914 | |
} |
915 | 0 | if (null != modifiedTransactionItemInfo.getDescr()) { |
916 | 0 | modifiedLprItemEntity.setDescr(new LprRichTextEntity(modifiedTransactionItemInfo.getDescr())); |
917 | |
} |
918 | 0 | lprTransItemDao.merge(modifiedLprItemEntity); |
919 | 0 | return modifiedLprItemEntity; |
920 | |
} |
921 | |
|
922 | |
@Transactional(readOnly = false) |
923 | |
private LprTransactionItemEntity createLprTransactionItem(LprTransactionItemInfo lprTransactionItemInfo, ContextInfo context) { |
924 | 0 | LprTransactionItemEntity lprTransItemEntity = new LprTransactionItemEntity(lprTransactionItemInfo); |
925 | 0 | if (lprTransItemEntity.getId() == null) { |
926 | 0 | lprTransItemEntity.setId(UUIDHelper.genStringUUID()); |
927 | |
} |
928 | 0 | if (null != lprTransactionItemInfo.getStateKey()) { |
929 | 0 | lprTransItemEntity.setLprTransactionItemState(lprTransactionItemInfo.getStateKey()); |
930 | |
} |
931 | |
|
932 | 0 | if (null != lprTransactionItemInfo.getTypeKey()) { |
933 | 0 | lprTransItemEntity.setLprTransactionItemType(lprTransactionItemInfo.getTypeKey()); |
934 | |
} |
935 | 0 | if (null != lprTransactionItemInfo.getDescr()) { |
936 | 0 | lprTransItemEntity.setDescr(new LprRichTextEntity(lprTransactionItemInfo.getDescr())); |
937 | |
} |
938 | |
|
939 | 0 | lprTransItemDao.persist(lprTransItemEntity); |
940 | |
|
941 | 0 | return lprTransItemDao.find(lprTransItemEntity.getId()); |
942 | |
} |
943 | |
|
944 | |
@Override |
945 | |
public List<LprTransactionInfo> searchForLprTransactions(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
946 | 0 | throw new UnsupportedOperationException("Operation not implemented"); |
947 | |
} |
948 | |
|
949 | |
@Override |
950 | |
public List<String> searchForLprTransactionIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
951 | 0 | throw new UnsupportedOperationException("Operation not implemented"); |
952 | |
} |
953 | |
|
954 | |
@Override |
955 | |
public List<LprRosterInfo> searchForLprRosters(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
956 | 0 | throw new UnsupportedOperationException("Operation not implemented"); |
957 | |
} |
958 | |
|
959 | |
@Override |
960 | |
public List<String> searchForLprRosterIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
961 | 0 | throw new UnsupportedOperationException("Operation not implemented"); |
962 | |
|
963 | |
} |
964 | |
|
965 | |
@Override |
966 | |
public List<LuiPersonRelationInfo> getLprsByPersonAndTypeForAtp(String personId, String atpId, String typeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
967 | |
|
968 | 0 | List<LuiPersonRelationEntity> entityList = lprDao.getLprsByPersonAndType(personId, typeKey); |
969 | 0 | List<LuiPersonRelationInfo> infoList = new ArrayList<LuiPersonRelationInfo>(); |
970 | 0 | for (LuiPersonRelationEntity entity : entityList) { |
971 | |
|
972 | |
|
973 | |
|
974 | 0 | infoList.add(entity.toDto()); |
975 | |
|
976 | |
} |
977 | |
|
978 | 0 | return infoList; |
979 | |
} |
980 | |
|
981 | |
@Override |
982 | |
public List<LuiPersonRelationInfo> getLprsByPersonForAtpAndLuiType(String personId, String atpId, String luiTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
983 | 0 | List<LuiPersonRelationEntity> entityList = lprDao.getLprsByPerson(personId); |
984 | |
|
985 | 0 | List<LuiPersonRelationInfo> infoList = new ArrayList<LuiPersonRelationInfo>(); |
986 | 0 | for (LuiPersonRelationEntity entity : entityList) { |
987 | |
|
988 | |
|
989 | 0 | infoList.add(entity.toDto()); |
990 | |
|
991 | |
} |
992 | |
|
993 | 0 | return infoList; |
994 | |
} |
995 | |
|
996 | |
@Override |
997 | |
public List<LuiPersonRelationInfo> getLprsByLuiAndType(String luiId, String typeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
998 | |
|
999 | 0 | return null; |
1000 | |
} |
1001 | |
|
1002 | |
@Override |
1003 | |
public List<LuiPersonRelationInfo> getLprsByPersonAndLuiType(String personId, String luiTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
1004 | 0 | List<LuiPersonRelationEntity> entityList = lprDao.getLprsByPerson(personId); |
1005 | |
|
1006 | 0 | List<LuiPersonRelationInfo> infoList = new ArrayList<LuiPersonRelationInfo>(); |
1007 | 0 | for (LuiPersonRelationEntity entity : entityList) { |
1008 | |
|
1009 | |
|
1010 | 0 | infoList.add(entity.toDto()); |
1011 | |
|
1012 | |
} |
1013 | |
|
1014 | 0 | return infoList; |
1015 | |
} |
1016 | |
|
1017 | |
@Override |
1018 | |
public LprRosterInfo updateLprRosterEntry(String lprRosterEntryId, LprRosterEntryInfo lprRosterEntryInfo, ContextInfo context) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, ReadOnlyException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
1019 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
1020 | |
} |
1021 | |
} |