| 1 | |
package org.kuali.student.r2.core.class1.atp.service.impl; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.Date; |
| 5 | |
import java.util.List; |
| 6 | |
|
| 7 | |
|
| 8 | |
import org.kuali.rice.core.api.criteria.GenericQueryResults; |
| 9 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
| 10 | |
import org.kuali.student.r2.common.criteria.CriteriaLookupService; |
| 11 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 12 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 13 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 14 | |
import org.kuali.student.r2.common.exceptions.AlreadyExistsException; |
| 15 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 16 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 17 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 18 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 19 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 20 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 21 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
| 22 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 23 | |
import org.kuali.student.r2.core.atp.dto.AtpAtpRelationInfo; |
| 24 | |
import org.kuali.student.r2.core.atp.dto.AtpInfo; |
| 25 | |
import org.kuali.student.r2.core.atp.dto.MilestoneInfo; |
| 26 | |
import org.kuali.student.r2.core.atp.service.AtpService; |
| 27 | |
import org.kuali.student.r2.core.class1.atp.dao.AtpAtpRelationDao; |
| 28 | |
import org.kuali.student.r2.core.class1.atp.dao.AtpDao; |
| 29 | |
import org.kuali.student.r2.core.class1.atp.dao.AtpMilestoneRelationDao; |
| 30 | |
import org.kuali.student.r2.core.class1.atp.dao.MilestoneDao; |
| 31 | |
import org.kuali.student.r2.core.class1.atp.model.AtpAtpRelationEntity; |
| 32 | |
import org.kuali.student.r2.core.class1.atp.model.AtpEntity; |
| 33 | |
import org.kuali.student.r2.core.class1.atp.model.AtpMilestoneRelationEntity; |
| 34 | |
import org.kuali.student.r2.core.class1.atp.model.MilestoneEntity; |
| 35 | |
import org.springframework.transaction.annotation.Transactional; |
| 36 | |
|
| 37 | |
@Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 38 | 0 | public class AtpServiceImpl implements AtpService { |
| 39 | |
|
| 40 | |
private AtpDao atpDao; |
| 41 | |
private AtpAtpRelationDao atpRelDao; |
| 42 | |
private MilestoneDao milestoneDao; |
| 43 | |
private AtpMilestoneRelationDao atpMilestoneRelationDao; |
| 44 | |
private CriteriaLookupService criteriaLookupService; |
| 45 | |
|
| 46 | |
public AtpDao getAtpDao() { |
| 47 | 0 | return atpDao; |
| 48 | |
} |
| 49 | |
|
| 50 | |
public void setAtpDao(AtpDao atpDao) { |
| 51 | 0 | this.atpDao = atpDao; |
| 52 | 0 | } |
| 53 | |
|
| 54 | |
public AtpAtpRelationDao getAtpRelDao() { |
| 55 | 0 | return atpRelDao; |
| 56 | |
} |
| 57 | |
|
| 58 | |
public void setAtpRelDao(AtpAtpRelationDao atpRelDao) { |
| 59 | 0 | this.atpRelDao = atpRelDao; |
| 60 | 0 | } |
| 61 | |
|
| 62 | |
public MilestoneDao getMilestoneDao() { |
| 63 | 0 | return milestoneDao; |
| 64 | |
} |
| 65 | |
|
| 66 | |
public void setMilestoneDao(MilestoneDao milestoneDao) { |
| 67 | 0 | this.milestoneDao = milestoneDao; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
public AtpMilestoneRelationDao getAtpMilestoneRelationDao() { |
| 71 | 0 | return atpMilestoneRelationDao; |
| 72 | |
} |
| 73 | |
|
| 74 | |
public void setAtpMilestoneRelationDao(AtpMilestoneRelationDao atpMilestoneRelationDao) { |
| 75 | 0 | this.atpMilestoneRelationDao = atpMilestoneRelationDao; |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
public void setCriteriaLookupService(CriteriaLookupService criteriaLookupService) { |
| 79 | 0 | this.criteriaLookupService = criteriaLookupService; |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
public CriteriaLookupService getCriteriaLookupService() { |
| 83 | 0 | return criteriaLookupService; |
| 84 | |
} |
| 85 | |
|
| 86 | |
@Override |
| 87 | |
public AtpInfo getAtp(String atpId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 88 | 0 | AtpEntity atp = atpDao.find(atpId); |
| 89 | 0 | if (null == atp) { |
| 90 | 0 | throw new DoesNotExistException(atpId); |
| 91 | |
} |
| 92 | 0 | return atp.toDto(); |
| 93 | |
} |
| 94 | |
|
| 95 | |
@Override |
| 96 | |
public List<AtpInfo> getAtpsByDate(Date searchDate, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 97 | 0 | List<AtpEntity> atps = atpDao.getByDate(searchDate); |
| 98 | |
|
| 99 | 0 | List<AtpInfo> result = new ArrayList<AtpInfo>(atps.size()); |
| 100 | 0 | if (null != atps) { |
| 101 | 0 | for (AtpEntity entity : atps) { |
| 102 | 0 | result.add(entity.toDto()); |
| 103 | |
} |
| 104 | |
} |
| 105 | 0 | return result; |
| 106 | |
} |
| 107 | |
|
| 108 | |
@Override |
| 109 | |
public List<AtpInfo> getAtpsByDates(Date startDate, Date endDate, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 110 | |
PermissionDeniedException { |
| 111 | 0 | List<AtpEntity> atps = atpDao.getByDates(startDate, endDate); |
| 112 | |
|
| 113 | 0 | List<AtpInfo> result = new ArrayList<AtpInfo>(atps.size()); |
| 114 | 0 | if (null != atps) { |
| 115 | 0 | for (AtpEntity entity : atps) { |
| 116 | 0 | result.add(entity.toDto()); |
| 117 | |
} |
| 118 | |
} |
| 119 | 0 | return result; |
| 120 | |
} |
| 121 | |
|
| 122 | |
@Override |
| 123 | |
@Transactional |
| 124 | |
public List<AtpInfo> getAtpsByDateAndType(Date searchDate, String searchTypeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 125 | |
PermissionDeniedException { |
| 126 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 127 | |
} |
| 128 | |
|
| 129 | |
@Override |
| 130 | |
public List<AtpInfo> getAtpsByDatesAndType(Date startDate, Date endDate, String searchTypeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, |
| 131 | |
OperationFailedException, PermissionDeniedException { |
| 132 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 133 | |
} |
| 134 | |
|
| 135 | |
@Override |
| 136 | |
public List<AtpInfo> getAtpsByStartDateRange(Date searchDateRangeStart, Date searchDateRangeEnd, ContextInfo context) throws InvalidParameterException, MissingParameterException, |
| 137 | |
OperationFailedException, PermissionDeniedException { |
| 138 | 0 | List<AtpEntity> atps = atpDao.getByStartDateRange(searchDateRangeStart, searchDateRangeEnd); |
| 139 | |
|
| 140 | 0 | List<AtpInfo> result = new ArrayList<AtpInfo>(atps.size()); |
| 141 | 0 | if (null != atps) { |
| 142 | 0 | for (AtpEntity entity : atps) { |
| 143 | 0 | result.add(entity.toDto()); |
| 144 | |
} |
| 145 | |
} |
| 146 | 0 | return result; |
| 147 | |
} |
| 148 | |
|
| 149 | |
@Override |
| 150 | |
public List<AtpInfo> getAtpsByStartDateRangeAndType(Date searchDateRangeStart, Date searchDateRangeEnd, String searchTypeKey, ContextInfo context) throws InvalidParameterException, |
| 151 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 152 | 0 | List<AtpEntity> atps = atpDao.getByStartDateRangeAndType(searchDateRangeStart, searchDateRangeEnd, searchTypeKey); |
| 153 | |
|
| 154 | 0 | List<AtpInfo> result = new ArrayList<AtpInfo>(atps.size()); |
| 155 | 0 | if (null != atps) { |
| 156 | 0 | for (AtpEntity entity : atps) { |
| 157 | 0 | result.add(entity.toDto()); |
| 158 | |
} |
| 159 | |
} |
| 160 | 0 | return result; |
| 161 | |
} |
| 162 | |
|
| 163 | |
@Override |
| 164 | |
public List<AtpInfo> getAtpsByCode(String code, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 165 | |
|
| 166 | 0 | return new ArrayList<AtpInfo>(); |
| 167 | |
} |
| 168 | |
|
| 169 | |
@Override |
| 170 | |
public List<AtpInfo> getAtpsByIds(List<String> atpIds, ContextInfo contextInfo) |
| 171 | |
throws DoesNotExistException, InvalidParameterException, |
| 172 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 173 | 0 | List<AtpEntity> atps = atpDao.findByIds(atpIds); |
| 174 | |
|
| 175 | 0 | if (atps == null) { |
| 176 | 0 | throw new DoesNotExistException(); |
| 177 | |
} |
| 178 | |
|
| 179 | 0 | List<AtpInfo> result = new ArrayList<AtpInfo>(atps.size()); |
| 180 | 0 | for (AtpEntity entity : atps) { |
| 181 | 0 | if (entity == null) { |
| 182 | |
|
| 183 | |
|
| 184 | 0 | throw new DoesNotExistException(); |
| 185 | |
} |
| 186 | 0 | result.add(entity.toDto()); |
| 187 | |
} |
| 188 | |
|
| 189 | 0 | return result; |
| 190 | |
} |
| 191 | |
|
| 192 | |
@Override |
| 193 | |
public List<String> getAtpIdsByType(String atpTypeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 194 | |
|
| 195 | 0 | List<AtpEntity> results = atpDao.getByAtpTypeId(atpTypeKey); |
| 196 | |
|
| 197 | 0 | List<String> keys = new ArrayList<String>(results.size()); |
| 198 | |
|
| 199 | 0 | for (AtpEntity atp : results) { |
| 200 | 0 | keys.add(atp.getId()); |
| 201 | |
} |
| 202 | |
|
| 203 | 0 | return keys; |
| 204 | |
} |
| 205 | |
|
| 206 | |
@Override |
| 207 | |
public MilestoneInfo getMilestone(String milestoneId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 208 | |
PermissionDeniedException { |
| 209 | 0 | MilestoneEntity entity = milestoneDao.find(milestoneId); |
| 210 | |
|
| 211 | 0 | if (entity != null) { |
| 212 | 0 | return entity.toDto(); |
| 213 | |
} else { |
| 214 | 0 | throw new DoesNotExistException(milestoneId); |
| 215 | |
} |
| 216 | |
|
| 217 | |
} |
| 218 | |
|
| 219 | |
@Override |
| 220 | |
public List<MilestoneInfo> getMilestonesByIds(List<String> milestoneIds, ContextInfo contextInfo) throws DoesNotExistException, |
| 221 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 222 | 0 | List<MilestoneEntity> milestones = milestoneDao.findByIds(milestoneIds); |
| 223 | |
|
| 224 | 0 | if (milestones == null) { |
| 225 | 0 | throw new DoesNotExistException(); |
| 226 | |
} |
| 227 | |
|
| 228 | 0 | List<MilestoneInfo> result = new ArrayList<MilestoneInfo>(milestones.size()); |
| 229 | 0 | for (MilestoneEntity entity : milestones) { |
| 230 | 0 | if (entity == null) { |
| 231 | |
|
| 232 | |
|
| 233 | 0 | throw new DoesNotExistException(); |
| 234 | |
} |
| 235 | 0 | result.add(entity.toDto()); |
| 236 | |
} |
| 237 | |
|
| 238 | 0 | return result; |
| 239 | |
} |
| 240 | |
|
| 241 | |
@Override |
| 242 | |
public List<String> getMilestoneIdsByType(String milestoneTypeKey, ContextInfo contextInfo) throws InvalidParameterException, |
| 243 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 244 | 0 | List<MilestoneEntity> entities = milestoneDao.getByMilestoneTypeId(milestoneTypeKey); |
| 245 | 0 | List<String> results = new ArrayList<String>(entities.size()); |
| 246 | 0 | for (MilestoneEntity entity : entities) { |
| 247 | 0 | results.add(entity.getId()); |
| 248 | |
} |
| 249 | 0 | return results; |
| 250 | |
} |
| 251 | |
|
| 252 | |
@Override |
| 253 | |
public List<MilestoneInfo> getMilestonesForAtp(String atpId, ContextInfo contextInfo) throws InvalidParameterException, |
| 254 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 255 | 0 | AtpEntity atp = atpDao.find(atpId); |
| 256 | 0 | if (atp == null) { |
| 257 | 0 | throw new InvalidParameterException(atpId); |
| 258 | |
} |
| 259 | 0 | List<String> ids = milestoneDao.getIdsByAtp(atpId); |
| 260 | |
try { |
| 261 | 0 | return this.getMilestonesByIds(ids, contextInfo); |
| 262 | 0 | } catch (DoesNotExistException ex) { |
| 263 | 0 | throw new OperationFailedException("Atp to Milestone relation exists to a milestone that has been deleted", ex); |
| 264 | |
} |
| 265 | |
} |
| 266 | |
|
| 267 | |
@Override |
| 268 | |
public List<MilestoneInfo> getMilestonesByDates(Date startDate, Date endDate, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 269 | |
PermissionDeniedException { |
| 270 | 0 | List<MilestoneEntity> entities = milestoneDao.getByDateRange(startDate, endDate); |
| 271 | 0 | List<MilestoneInfo> results = new ArrayList<MilestoneInfo>(entities.size()); |
| 272 | 0 | for (MilestoneEntity entity : entities) { |
| 273 | 0 | results.add(entity.toDto()); |
| 274 | |
} |
| 275 | 0 | return results; |
| 276 | |
} |
| 277 | |
|
| 278 | |
@Override |
| 279 | |
public List<MilestoneInfo> getMilestonesByDatesForAtp(String atpId, Date startDate, Date endDate, |
| 280 | |
ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 281 | 0 | List<MilestoneEntity> entities = milestoneDao.getByDatesForAtp(atpId, startDate, endDate); |
| 282 | 0 | List<MilestoneInfo> results = new ArrayList<MilestoneInfo>(entities.size()); |
| 283 | 0 | for (MilestoneEntity entity : entities) { |
| 284 | 0 | results.add(entity.toDto()); |
| 285 | |
} |
| 286 | 0 | return results; |
| 287 | |
} |
| 288 | |
|
| 289 | |
@Override |
| 290 | |
public List<MilestoneInfo> getMilestonesByTypeForAtp(String atpId, |
| 291 | |
String milestoneTypeKey, |
| 292 | |
ContextInfo contextInfo) |
| 293 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 294 | 0 | List<MilestoneInfo> list = this.getMilestonesForAtp(atpId, contextInfo); |
| 295 | 0 | List<MilestoneInfo> results = new ArrayList<MilestoneInfo>(list.size()); |
| 296 | 0 | for (MilestoneInfo info : list) { |
| 297 | 0 | results.add(info); |
| 298 | |
} |
| 299 | 0 | return results; |
| 300 | |
} |
| 301 | |
|
| 302 | |
@Override |
| 303 | |
public List<String> searchForAtpIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 304 | |
|
| 305 | 0 | return new ArrayList<String>(); |
| 306 | |
} |
| 307 | |
|
| 308 | |
@Override |
| 309 | |
public List<AtpInfo> searchForAtps(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 310 | |
|
| 311 | 0 | List<AtpInfo> atpInfos = new ArrayList<AtpInfo>(); |
| 312 | 0 | GenericQueryResults<AtpEntity> results = criteriaLookupService.lookup(AtpEntity.class, criteria); |
| 313 | |
|
| 314 | 0 | if (null != results && results.getResults().size() > 0) { |
| 315 | 0 | for (AtpEntity atp : results.getResults()) { |
| 316 | 0 | atpInfos.add(atp.toDto()); |
| 317 | |
} |
| 318 | |
} |
| 319 | |
|
| 320 | 0 | return atpInfos; |
| 321 | |
} |
| 322 | |
|
| 323 | |
@Override |
| 324 | |
public List<ValidationResultInfo> validateAtp(String validationTypeKey, |
| 325 | |
String atpTypeKey, |
| 326 | |
AtpInfo atpInfo, ContextInfo contextInfo) |
| 327 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 328 | |
OperationFailedException, PermissionDeniedException { |
| 329 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 330 | |
} |
| 331 | |
|
| 332 | |
@Override |
| 333 | |
@Transactional(readOnly = false) |
| 334 | |
public AtpInfo createAtp(String atpTypeKey, AtpInfo atpInfo, ContextInfo contextInfo) |
| 335 | |
throws DataValidationErrorException, InvalidParameterException, |
| 336 | |
MissingParameterException, OperationFailedException, |
| 337 | |
PermissionDeniedException, ReadOnlyException { |
| 338 | |
|
| 339 | 0 | AtpEntity entity = new AtpEntity(atpInfo); |
| 340 | 0 | entity.setId(atpInfo.getId()); |
| 341 | 0 | entity.setAtpType(atpTypeKey); |
| 342 | 0 | entity.setCreateId(contextInfo.getPrincipalId()); |
| 343 | 0 | entity.setCreateTime(contextInfo.getCurrentDate()); |
| 344 | 0 | entity.setUpdateId(contextInfo.getPrincipalId()); |
| 345 | 0 | entity.setUpdateTime(contextInfo.getCurrentDate()); |
| 346 | |
|
| 347 | 0 | atpDao.persist(entity); |
| 348 | |
|
| 349 | |
|
| 350 | |
|
| 351 | |
|
| 352 | 0 | return entity.toDto(); |
| 353 | |
} |
| 354 | |
|
| 355 | |
@Override |
| 356 | |
@Transactional(readOnly = false) |
| 357 | |
public AtpInfo updateAtp(String atpId, AtpInfo atpInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 358 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 359 | 0 | AtpEntity entity = atpDao.find(atpId); |
| 360 | 0 | if (entity == null) { |
| 361 | 0 | throw new DoesNotExistException(atpId); |
| 362 | |
} |
| 363 | 0 | entity.fromDTO(atpInfo); |
| 364 | 0 | entity.setUpdateId(context.getPrincipalId()); |
| 365 | 0 | entity.setUpdateTime(context.getCurrentDate()); |
| 366 | 0 | atpDao.merge(entity); |
| 367 | 0 | return entity.toDto(); |
| 368 | |
} |
| 369 | |
|
| 370 | |
@Override |
| 371 | |
@Transactional(readOnly = false) |
| 372 | |
public StatusInfo deleteAtp(String atpId, ContextInfo context) throws DoesNotExistException, |
| 373 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
| 374 | |
PermissionDeniedException { |
| 375 | 0 | AtpEntity entity = atpDao.find(atpId); |
| 376 | 0 | if (null == entity) { |
| 377 | 0 | throw new DoesNotExistException(atpId); |
| 378 | |
} |
| 379 | 0 | List<AtpAtpRelationEntity> aarEntities = atpRelDao.getAtpAtpRelationsByAtp(atpId); |
| 380 | 0 | if (null != aarEntities) { |
| 381 | 0 | for (AtpAtpRelationEntity aarEntity : aarEntities) { |
| 382 | 0 | atpRelDao.remove(aarEntity); |
| 383 | |
} |
| 384 | |
} |
| 385 | 0 | List<AtpMilestoneRelationEntity> amrEntities = atpMilestoneRelationDao.getByAtpId(atpId); |
| 386 | 0 | if (null != amrEntities) { |
| 387 | 0 | for (AtpMilestoneRelationEntity amrEntity : amrEntities) { |
| 388 | 0 | atpMilestoneRelationDao.remove(amrEntity); |
| 389 | |
} |
| 390 | |
} |
| 391 | 0 | atpDao.remove(entity); |
| 392 | 0 | StatusInfo status = new StatusInfo(); |
| 393 | 0 | status.setSuccess(Boolean.TRUE); |
| 394 | 0 | return status; |
| 395 | |
} |
| 396 | |
|
| 397 | |
@Override |
| 398 | |
public List<MilestoneInfo> getImpactedMilestones(String milestoneId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 399 | |
OperationFailedException, PermissionDeniedException { |
| 400 | 0 | List<MilestoneInfo> impactedMilestones = new ArrayList<MilestoneInfo>(); |
| 401 | 0 | for (MilestoneEntity impactedMilestone : milestoneDao.getImpactedMilestones(milestoneId)) { |
| 402 | 0 | impactedMilestones.add(impactedMilestone.toDto()); |
| 403 | |
} |
| 404 | 0 | return impactedMilestones; |
| 405 | |
} |
| 406 | |
|
| 407 | |
@Override |
| 408 | |
public List<String> searchForMilestoneIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, |
| 409 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 410 | 0 | return null; |
| 411 | |
|
| 412 | |
} |
| 413 | |
|
| 414 | |
@Override |
| 415 | |
public List<MilestoneInfo> searchForMilestones(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 416 | |
PermissionDeniedException { |
| 417 | |
|
| 418 | 0 | List<MilestoneInfo> milestoneInfos = new ArrayList<MilestoneInfo>(); |
| 419 | 0 | GenericQueryResults<MilestoneEntity> results = criteriaLookupService.lookup(MilestoneEntity.class, criteria); |
| 420 | |
|
| 421 | 0 | if (null != results && results.getResults().size() > 0) { |
| 422 | 0 | for (MilestoneEntity milestone : results.getResults()) { |
| 423 | 0 | milestoneInfos.add(milestone.toDto()); |
| 424 | |
} |
| 425 | |
} |
| 426 | |
|
| 427 | 0 | return milestoneInfos; |
| 428 | |
} |
| 429 | |
|
| 430 | |
@Override |
| 431 | |
public List<ValidationResultInfo> validateMilestone(String validationType, MilestoneInfo milestoneInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 432 | |
MissingParameterException, OperationFailedException { |
| 433 | |
|
| 434 | 0 | return null; |
| 435 | |
} |
| 436 | |
|
| 437 | |
@Override |
| 438 | |
@Transactional(readOnly = false) |
| 439 | |
public MilestoneInfo createMilestone(String milestoneTypeKey, MilestoneInfo milestoneInfo, ContextInfo contextInfo) |
| 440 | |
throws DataValidationErrorException, |
| 441 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
| 442 | |
PermissionDeniedException, ReadOnlyException { |
| 443 | |
|
| 444 | 0 | if (!milestoneTypeKey.equals(milestoneInfo.getTypeKey())) { |
| 445 | 0 | throw new InvalidParameterException(milestoneTypeKey + " does not match " + milestoneInfo.getTypeKey()); |
| 446 | |
} |
| 447 | 0 | MilestoneEntity entity = new MilestoneEntity(milestoneInfo); |
| 448 | 0 | entity.setId(milestoneInfo.getId()); |
| 449 | 0 | entity.setAtpType(milestoneTypeKey); |
| 450 | 0 | entity.setCreateId(contextInfo.getPrincipalId()); |
| 451 | 0 | entity.setCreateTime(contextInfo.getCurrentDate()); |
| 452 | 0 | entity.setUpdateId(contextInfo.getPrincipalId()); |
| 453 | 0 | entity.setUpdateTime(contextInfo.getCurrentDate()); |
| 454 | 0 | milestoneDao.persist(entity); |
| 455 | 0 | MilestoneInfo result = entity.toDto(); |
| 456 | 0 | return result; |
| 457 | |
} |
| 458 | |
|
| 459 | |
@Override |
| 460 | |
@Transactional(readOnly = false) |
| 461 | |
public MilestoneInfo updateMilestone(String milestoneId, MilestoneInfo milestoneInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
| 462 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 463 | |
|
| 464 | 0 | MilestoneEntity entity = milestoneDao.find(milestoneId); |
| 465 | 0 | if (entity == null) { |
| 466 | 0 | throw new DoesNotExistException(milestoneId); |
| 467 | |
} |
| 468 | 0 | entity.fromDto(milestoneInfo); |
| 469 | 0 | entity.setUpdateId(context.getPrincipalId()); |
| 470 | 0 | entity.setUpdateTime(context.getCurrentDate()); |
| 471 | 0 | milestoneDao.merge(entity); |
| 472 | 0 | return entity.toDto(); |
| 473 | |
} |
| 474 | |
|
| 475 | |
@Override |
| 476 | |
@Transactional(readOnly = false) |
| 477 | |
public StatusInfo deleteMilestone(String milestoneId, ContextInfo context) |
| 478 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 479 | |
OperationFailedException, |
| 480 | |
PermissionDeniedException { |
| 481 | |
|
| 482 | 0 | MilestoneEntity existingEntity = milestoneDao.find(milestoneId); |
| 483 | 0 | if (existingEntity == null) { |
| 484 | 0 | throw new DoesNotExistException(milestoneId); |
| 485 | |
} |
| 486 | 0 | List<AtpMilestoneRelationEntity> amrEntities = atpMilestoneRelationDao.getByMilestoneId(milestoneId); |
| 487 | 0 | if (null != amrEntities) { |
| 488 | 0 | for (AtpMilestoneRelationEntity amrEntity : amrEntities) { |
| 489 | 0 | atpMilestoneRelationDao.remove(amrEntity); |
| 490 | |
} |
| 491 | |
} |
| 492 | 0 | milestoneDao.remove(existingEntity); |
| 493 | 0 | StatusInfo status = new StatusInfo(); |
| 494 | 0 | status.setSuccess(Boolean.TRUE); |
| 495 | 0 | return status; |
| 496 | |
} |
| 497 | |
|
| 498 | |
@Override |
| 499 | |
@Transactional(readOnly = false) |
| 500 | |
public MilestoneInfo calculateMilestone(String milestoneId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 501 | |
PermissionDeniedException { |
| 502 | 0 | throw new OperationFailedException("Method implemented in calculation decorator."); |
| 503 | |
} |
| 504 | |
|
| 505 | |
@Override |
| 506 | |
@Transactional(readOnly = false) |
| 507 | |
public StatusInfo addMilestoneToAtp(String milestoneId, String atpId, ContextInfo contextInfo) |
| 508 | |
throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 509 | |
|
| 510 | 0 | AtpEntity atp = atpDao.find(atpId); |
| 511 | 0 | if (atp == null) { |
| 512 | 0 | throw new DoesNotExistException(atpId); |
| 513 | |
} |
| 514 | 0 | MilestoneEntity milestone = milestoneDao.find(milestoneId); |
| 515 | 0 | if (milestone == null) { |
| 516 | 0 | throw new DoesNotExistException(milestoneId); |
| 517 | |
} |
| 518 | 0 | List<String> ids = atpMilestoneRelationDao.getIdsByAtpAndMilestone(atpId, milestoneId); |
| 519 | 0 | if (!ids.isEmpty()) { |
| 520 | 0 | throw new AlreadyExistsException("Milestone " + milestoneId + " already exists for ATP " + atpId); |
| 521 | |
} |
| 522 | |
|
| 523 | 0 | AtpMilestoneRelationEntity entity = new AtpMilestoneRelationEntity(); |
| 524 | 0 | entity.setAtpId(atpId); |
| 525 | 0 | entity.setMilestoneId(milestoneId); |
| 526 | 0 | entity.setCreateId(contextInfo.getPrincipalId()); |
| 527 | 0 | entity.setCreateTime(contextInfo.getCurrentDate()); |
| 528 | 0 | entity.setUpdateId(contextInfo.getPrincipalId()); |
| 529 | 0 | entity.setUpdateTime(contextInfo.getCurrentDate()); |
| 530 | |
|
| 531 | 0 | atpMilestoneRelationDao.persist(entity); |
| 532 | 0 | StatusInfo info = new StatusInfo(); |
| 533 | 0 | info.setSuccess(true); |
| 534 | |
|
| 535 | 0 | return info; |
| 536 | |
} |
| 537 | |
|
| 538 | |
@Override |
| 539 | |
@Transactional(readOnly = false) |
| 540 | |
public StatusInfo removeMilestoneFromAtp(String milestoneId, String atpId, ContextInfo contextInfo) |
| 541 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 542 | 0 | List<String> ids = atpMilestoneRelationDao.getIdsByAtpAndMilestone(atpId, milestoneId); |
| 543 | 0 | if (ids.isEmpty()) { |
| 544 | 0 | throw new DoesNotExistException("No relationship exists between the atp " + atpId + " and milestone " + milestoneId); |
| 545 | |
} |
| 546 | 0 | if (ids.size() > 1) { |
| 547 | 0 | throw new OperationFailedException("Database error there should only be one relationship record found " + ids.size()); |
| 548 | |
} |
| 549 | 0 | AtpMilestoneRelationEntity entity = atpMilestoneRelationDao.find(ids.get(0)); |
| 550 | 0 | if (entity == null) { |
| 551 | 0 | throw new OperationFailedException("rror there should only be one relationship record found " + ids.size()); |
| 552 | |
} |
| 553 | 0 | atpMilestoneRelationDao.remove(entity); |
| 554 | 0 | StatusInfo status = new StatusInfo(); |
| 555 | 0 | status.setSuccess(true); |
| 556 | 0 | return status; |
| 557 | |
|
| 558 | |
} |
| 559 | |
|
| 560 | |
@Override |
| 561 | |
public AtpAtpRelationInfo getAtpAtpRelation(String atpAtpRelationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 562 | |
OperationFailedException, PermissionDeniedException { |
| 563 | 0 | AtpAtpRelationEntity atpRel = atpRelDao.find(atpAtpRelationId); |
| 564 | 0 | if (null == atpRel) { |
| 565 | 0 | throw new DoesNotExistException(atpAtpRelationId); |
| 566 | |
} |
| 567 | 0 | return atpRel.toDto(); |
| 568 | |
} |
| 569 | |
|
| 570 | |
@Override |
| 571 | |
public List<AtpAtpRelationInfo> getAtpAtpRelationsByIds(List<String> atpAtpRelationIds, |
| 572 | |
ContextInfo contextInfo) |
| 573 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 574 | 0 | return new ArrayList<AtpAtpRelationInfo>(); |
| 575 | |
} |
| 576 | |
|
| 577 | |
@Override |
| 578 | |
public List<String> getAtpAtpRelationIdsByType(String atpAtpRelationTypeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 579 | |
PermissionDeniedException { |
| 580 | 0 | return new ArrayList<String>(); |
| 581 | |
} |
| 582 | |
|
| 583 | |
@Override |
| 584 | |
public List<AtpAtpRelationInfo> getAtpAtpRelationsByAtp(String atpId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 585 | |
PermissionDeniedException { |
| 586 | |
|
| 587 | 0 | List<AtpAtpRelationEntity> relEntities = atpRelDao.getAtpAtpRelationsByAtp(atpId); |
| 588 | 0 | List<AtpAtpRelationInfo> relInfos = new ArrayList<AtpAtpRelationInfo>(); |
| 589 | 0 | for (AtpAtpRelationEntity relEntity : relEntities) { |
| 590 | 0 | AtpAtpRelationInfo relInfo = relEntity.toDto(); |
| 591 | 0 | relInfos.add(relInfo); |
| 592 | 0 | } |
| 593 | |
|
| 594 | 0 | return relInfos; |
| 595 | |
} |
| 596 | |
|
| 597 | |
@Override |
| 598 | |
public List<AtpAtpRelationInfo> getAtpAtpRelationsByAtps(String atpId, |
| 599 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 600 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 601 | 0 | List<AtpAtpRelationEntity> relations = atpRelDao.getAtpAtpRelationsByAtp(atpId); |
| 602 | 0 | List<AtpAtpRelationInfo> relationsDTO = new ArrayList(); |
| 603 | 0 | for (AtpAtpRelationEntity relation : relations) { |
| 604 | 0 | relationsDTO.add(relation.toDto()); |
| 605 | |
} |
| 606 | 0 | return relationsDTO; |
| 607 | |
} |
| 608 | |
|
| 609 | |
@Override |
| 610 | |
public List<AtpAtpRelationInfo> getAtpAtpRelationsByTypeAndAtp(String atpId, |
| 611 | |
String atpRelationTypeKey, |
| 612 | |
ContextInfo contextInfo) |
| 613 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 614 | 0 | List<AtpAtpRelationEntity> rels = atpRelDao.getAtpAtpRelationsByAtpAndRelationType(atpId, atpRelationTypeKey); |
| 615 | 0 | List<AtpAtpRelationInfo> atpRelation = new ArrayList<AtpAtpRelationInfo>(); |
| 616 | 0 | for (AtpAtpRelationEntity rel : rels) { |
| 617 | 0 | atpRelation.add(rel.toDto()); |
| 618 | |
} |
| 619 | 0 | return atpRelation; |
| 620 | |
} |
| 621 | |
|
| 622 | |
@Override |
| 623 | |
public List<String> searchForAtpAtpRelationIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 624 | |
PermissionDeniedException { |
| 625 | |
|
| 626 | 0 | return new ArrayList<String>(); |
| 627 | |
} |
| 628 | |
|
| 629 | |
@Override |
| 630 | |
public List<AtpAtpRelationInfo> searchForAtpAtpRelations(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 631 | |
PermissionDeniedException { |
| 632 | |
|
| 633 | 0 | return new ArrayList<AtpAtpRelationInfo>(); |
| 634 | |
} |
| 635 | |
|
| 636 | |
@Override |
| 637 | |
public List<ValidationResultInfo> validateAtpAtpRelation(String validationTypeKey, |
| 638 | |
String atpId, |
| 639 | |
String atpPeerKey, |
| 640 | |
String atpAtpRelationTypeKey, |
| 641 | |
AtpAtpRelationInfo atpAtpRelationInfo, |
| 642 | |
ContextInfo contextInfo) throws DoesNotExistException, |
| 643 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 644 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 645 | |
} |
| 646 | |
|
| 647 | |
|
| 648 | |
|
| 649 | |
|
| 650 | |
|
| 651 | |
|
| 652 | |
|
| 653 | |
|
| 654 | |
|
| 655 | |
|
| 656 | |
|
| 657 | |
|
| 658 | |
|
| 659 | |
|
| 660 | |
|
| 661 | |
@Override |
| 662 | |
@Transactional(readOnly = false) |
| 663 | |
public AtpAtpRelationInfo createAtpAtpRelation(String atpId, |
| 664 | |
String relatedAtpId, |
| 665 | |
String atpAtpRelationTypeKey, |
| 666 | |
AtpAtpRelationInfo atpAtpRelationInfo, |
| 667 | |
ContextInfo contextInfo) |
| 668 | |
throws DoesNotExistException, |
| 669 | |
DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 670 | |
|
| 671 | 0 | if (!atpId.equals(atpAtpRelationInfo.getAtpId())) { |
| 672 | 0 | throw new InvalidParameterException(atpId + " does not match the " + atpAtpRelationInfo.getAtpId()); |
| 673 | |
} |
| 674 | 0 | if (!relatedAtpId.equals(atpAtpRelationInfo.getRelatedAtpId())) { |
| 675 | 0 | throw new InvalidParameterException(relatedAtpId + " does not match the " + atpAtpRelationInfo.getRelatedAtpId()); |
| 676 | |
} |
| 677 | 0 | if (!atpAtpRelationTypeKey.equals(atpAtpRelationInfo.getTypeKey())) { |
| 678 | 0 | throw new InvalidParameterException(atpAtpRelationTypeKey + " does not match the " + atpAtpRelationInfo.getTypeKey()); |
| 679 | |
} |
| 680 | |
|
| 681 | |
|
| 682 | |
|
| 683 | |
|
| 684 | 0 | AtpAtpRelationEntity entity = new AtpAtpRelationEntity(atpAtpRelationInfo); |
| 685 | 0 | entity.setId(atpAtpRelationInfo.getId()); |
| 686 | 0 | entity.setAtpType(atpAtpRelationTypeKey); |
| 687 | 0 | entity.setAtp(atpDao.find(atpId)); |
| 688 | 0 | if (entity.getAtp() == null) { |
| 689 | 0 | throw new DoesNotExistException(atpId); |
| 690 | |
} |
| 691 | 0 | entity.setRelatedAtp(atpDao.find(relatedAtpId)); |
| 692 | 0 | if (entity.getRelatedAtp() == null) { |
| 693 | 0 | throw new DoesNotExistException(relatedAtpId); |
| 694 | |
} |
| 695 | 0 | entity.setCreateId(contextInfo.getPrincipalId()); |
| 696 | 0 | entity.setCreateTime(contextInfo.getCurrentDate()); |
| 697 | 0 | entity.setUpdateId(contextInfo.getPrincipalId()); |
| 698 | 0 | entity.setUpdateTime(contextInfo.getCurrentDate()); |
| 699 | 0 | atpRelDao.persist(entity); |
| 700 | 0 | return entity.toDto(); |
| 701 | |
} |
| 702 | |
|
| 703 | |
@Override |
| 704 | |
@Transactional(readOnly = false) |
| 705 | |
public AtpAtpRelationInfo updateAtpAtpRelation(String atpAtpRelationId, |
| 706 | |
AtpAtpRelationInfo atpAtpRelationInfo, |
| 707 | |
ContextInfo context) |
| 708 | |
throws DataValidationErrorException, DoesNotExistException, |
| 709 | |
InvalidParameterException, MissingParameterException, |
| 710 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 711 | 0 | AtpAtpRelationEntity entity = atpRelDao.find(atpAtpRelationId); |
| 712 | 0 | if (null == entity) { |
| 713 | 0 | throw new DoesNotExistException(atpAtpRelationId); |
| 714 | |
} |
| 715 | 0 | entity.fromDTO(atpAtpRelationInfo); |
| 716 | 0 | entity.setUpdateId(context.getPrincipalId()); |
| 717 | 0 | entity.setUpdateTime(context.getCurrentDate()); |
| 718 | 0 | atpRelDao.merge(entity); |
| 719 | 0 | return entity.toDto(); |
| 720 | |
} |
| 721 | |
|
| 722 | |
@Override |
| 723 | |
@Transactional(readOnly = false) |
| 724 | |
public StatusInfo deleteAtpAtpRelation(String atpAtpRelationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 725 | |
PermissionDeniedException { |
| 726 | 0 | AtpAtpRelationEntity atpRel = atpRelDao.find(atpAtpRelationId); |
| 727 | 0 | if (atpRel == null) { |
| 728 | 0 | throw new DoesNotExistException(atpAtpRelationId); |
| 729 | |
} |
| 730 | 0 | atpRelDao.remove(atpRel); |
| 731 | 0 | StatusInfo status = new StatusInfo(); |
| 732 | 0 | status.setSuccess(Boolean.TRUE); |
| 733 | 0 | return status; |
| 734 | |
} |
| 735 | |
} |