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