| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.lum.lu.service.impl; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.Collections; |
| 20 | |
import java.util.Comparator; |
| 21 | |
import java.util.Date; |
| 22 | |
import java.util.HashMap; |
| 23 | |
import java.util.HashSet; |
| 24 | |
import java.util.Iterator; |
| 25 | |
import java.util.List; |
| 26 | |
import java.util.Map; |
| 27 | |
import java.util.Map.Entry; |
| 28 | |
import java.util.Set; |
| 29 | |
|
| 30 | |
import javax.jws.WebService; |
| 31 | |
import javax.persistence.NoResultException; |
| 32 | |
|
| 33 | |
import org.apache.log4j.Logger; |
| 34 | |
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
| 35 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
| 36 | |
import org.kuali.student.common.dto.CurrencyAmountInfo; |
| 37 | |
import org.kuali.student.common.dto.DtoConstants; |
| 38 | |
import org.kuali.student.common.dto.StatusInfo; |
| 39 | |
import org.kuali.student.common.entity.Amount; |
| 40 | |
import org.kuali.student.common.entity.TimeAmount; |
| 41 | |
import org.kuali.student.common.entity.Version; |
| 42 | |
import org.kuali.student.common.entity.VersionEntity; |
| 43 | |
import org.kuali.student.common.exceptions.AlreadyExistsException; |
| 44 | |
import org.kuali.student.common.exceptions.CircularRelationshipException; |
| 45 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
| 46 | |
import org.kuali.student.common.exceptions.DependentObjectsExistException; |
| 47 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 48 | |
import org.kuali.student.common.exceptions.IllegalVersionSequencingException; |
| 49 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
| 50 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
| 51 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
| 52 | |
import org.kuali.student.common.exceptions.PermissionDeniedException; |
| 53 | |
import org.kuali.student.common.exceptions.UnsupportedActionException; |
| 54 | |
import org.kuali.student.common.exceptions.VersionMismatchException; |
| 55 | |
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
| 56 | |
import org.kuali.student.common.search.dto.SearchParam; |
| 57 | |
import org.kuali.student.common.search.dto.SearchRequest; |
| 58 | |
import org.kuali.student.common.search.dto.SearchResult; |
| 59 | |
import org.kuali.student.common.search.dto.SearchResultCell; |
| 60 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
| 61 | |
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
| 62 | |
import org.kuali.student.common.search.dto.SearchTypeInfo; |
| 63 | |
import org.kuali.student.common.search.service.SearchDispatcher; |
| 64 | |
import org.kuali.student.common.search.service.SearchManager; |
| 65 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 66 | |
import org.kuali.student.common.validator.Validator; |
| 67 | |
import org.kuali.student.common.validator.ValidatorFactory; |
| 68 | |
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
| 69 | |
import org.kuali.student.lum.lu.dao.LuDao; |
| 70 | |
import org.kuali.student.lum.lu.dto.AccreditationInfo; |
| 71 | |
import org.kuali.student.lum.lu.dto.AdminOrgInfo; |
| 72 | |
import org.kuali.student.lum.lu.dto.AffiliatedOrgInfo; |
| 73 | |
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
| 74 | |
import org.kuali.student.lum.lu.dto.CluFeeRecordInfo; |
| 75 | |
import org.kuali.student.lum.lu.dto.CluIdentifierInfo; |
| 76 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
| 77 | |
import org.kuali.student.lum.lu.dto.CluInstructorInfo; |
| 78 | |
import org.kuali.student.lum.lu.dto.CluLoRelationInfo; |
| 79 | |
import org.kuali.student.lum.lu.dto.CluLoRelationTypeInfo; |
| 80 | |
import org.kuali.student.lum.lu.dto.CluPublicationInfo; |
| 81 | |
import org.kuali.student.lum.lu.dto.CluResultInfo; |
| 82 | |
import org.kuali.student.lum.lu.dto.CluResultTypeInfo; |
| 83 | |
import org.kuali.student.lum.lu.dto.CluSetInfo; |
| 84 | |
import org.kuali.student.lum.lu.dto.CluSetTreeViewInfo; |
| 85 | |
import org.kuali.student.lum.lu.dto.CluSetTypeInfo; |
| 86 | |
import org.kuali.student.lum.lu.dto.DeliveryMethodTypeInfo; |
| 87 | |
import org.kuali.student.lum.lu.dto.FieldInfo; |
| 88 | |
import org.kuali.student.lum.lu.dto.InstructionalFormatTypeInfo; |
| 89 | |
import org.kuali.student.lum.lu.dto.LuCodeInfo; |
| 90 | |
import org.kuali.student.lum.lu.dto.LuCodeTypeInfo; |
| 91 | |
import org.kuali.student.lum.lu.dto.LuLuRelationTypeInfo; |
| 92 | |
import org.kuali.student.lum.lu.dto.LuPublicationTypeInfo; |
| 93 | |
import org.kuali.student.lum.lu.dto.LuTypeInfo; |
| 94 | |
import org.kuali.student.lum.lu.dto.LuiInfo; |
| 95 | |
import org.kuali.student.lum.lu.dto.LuiLuiRelationInfo; |
| 96 | |
import org.kuali.student.lum.lu.dto.MembershipQueryInfo; |
| 97 | |
import org.kuali.student.lum.lu.dto.ResultOptionInfo; |
| 98 | |
import org.kuali.student.lum.lu.dto.ResultUsageTypeInfo; |
| 99 | |
import org.kuali.student.lum.lu.entity.Clu; |
| 100 | |
import org.kuali.student.lum.lu.entity.CluAccounting; |
| 101 | |
import org.kuali.student.lum.lu.entity.CluAccountingAttribute; |
| 102 | |
import org.kuali.student.lum.lu.entity.CluAccreditation; |
| 103 | |
import org.kuali.student.lum.lu.entity.CluAccreditationAttribute; |
| 104 | |
import org.kuali.student.lum.lu.entity.CluAdminOrg; |
| 105 | |
import org.kuali.student.lum.lu.entity.CluAdminOrgAttribute; |
| 106 | |
import org.kuali.student.lum.lu.entity.CluAtpTypeKey; |
| 107 | |
import org.kuali.student.lum.lu.entity.CluAttribute; |
| 108 | |
import org.kuali.student.lum.lu.entity.CluCampusLocation; |
| 109 | |
import org.kuali.student.lum.lu.entity.CluCluRelation; |
| 110 | |
import org.kuali.student.lum.lu.entity.CluCluRelationAttribute; |
| 111 | |
import org.kuali.student.lum.lu.entity.CluFee; |
| 112 | |
import org.kuali.student.lum.lu.entity.CluIdentifier; |
| 113 | |
import org.kuali.student.lum.lu.entity.CluInstructor; |
| 114 | |
import org.kuali.student.lum.lu.entity.CluInstructorAttribute; |
| 115 | |
import org.kuali.student.lum.lu.entity.CluLoRelation; |
| 116 | |
import org.kuali.student.lum.lu.entity.CluLoRelationAttribute; |
| 117 | |
import org.kuali.student.lum.lu.entity.CluLoRelationType; |
| 118 | |
import org.kuali.student.lum.lu.entity.CluPublication; |
| 119 | |
import org.kuali.student.lum.lu.entity.CluPublicationAttribute; |
| 120 | |
import org.kuali.student.lum.lu.entity.CluPublicationType; |
| 121 | |
import org.kuali.student.lum.lu.entity.CluPublicationVariant; |
| 122 | |
import org.kuali.student.lum.lu.entity.CluResult; |
| 123 | |
import org.kuali.student.lum.lu.entity.CluResultType; |
| 124 | |
import org.kuali.student.lum.lu.entity.CluSet; |
| 125 | |
import org.kuali.student.lum.lu.entity.CluSetAttribute; |
| 126 | |
import org.kuali.student.lum.lu.entity.CluSetJoinVersionIndClu; |
| 127 | |
import org.kuali.student.lum.lu.entity.CluSetType; |
| 128 | |
import org.kuali.student.lum.lu.entity.DeliveryMethodType; |
| 129 | |
import org.kuali.student.lum.lu.entity.InstructionalFormatType; |
| 130 | |
import org.kuali.student.lum.lu.entity.LuCode; |
| 131 | |
import org.kuali.student.lum.lu.entity.LuCodeAttribute; |
| 132 | |
import org.kuali.student.lum.lu.entity.LuCodeType; |
| 133 | |
import org.kuali.student.lum.lu.entity.LuLuRelationType; |
| 134 | |
import org.kuali.student.lum.lu.entity.LuPublicationType; |
| 135 | |
import org.kuali.student.lum.lu.entity.LuRichText; |
| 136 | |
import org.kuali.student.lum.lu.entity.LuType; |
| 137 | |
import org.kuali.student.lum.lu.entity.Lui; |
| 138 | |
import org.kuali.student.lum.lu.entity.LuiAttribute; |
| 139 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelation; |
| 140 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelationAttribute; |
| 141 | |
import org.kuali.student.lum.lu.entity.MembershipQuery; |
| 142 | |
import org.kuali.student.lum.lu.entity.ResultOption; |
| 143 | |
import org.kuali.student.lum.lu.entity.ResultUsageType; |
| 144 | |
import org.kuali.student.lum.lu.service.LuService; |
| 145 | |
import org.kuali.student.lum.lu.service.LuServiceConstants; |
| 146 | |
import org.springframework.beans.BeanUtils; |
| 147 | |
import org.springframework.transaction.annotation.Transactional; |
| 148 | |
|
| 149 | |
@WebService(endpointInterface = "org.kuali.student.lum.lu.service.LuService", serviceName = "LuService", portName = "LuService", targetNamespace = "http://student.kuali.org/wsdl/lu") |
| 150 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
| 151 | 8 | public class LuServiceImpl implements LuService { |
| 152 | |
|
| 153 | |
private static final String SEARCH_KEY_DEPENDENCY_ANALYSIS = "lu.search.dependencyAnalysis"; |
| 154 | |
private static final String SEARCH_KEY_BROWSE_PROGRAM = "lu.search.browseProgram"; |
| 155 | |
private static final String SEARCH_KEY_BROWSE_VARIATIONS = "lu.search.browseVariations"; |
| 156 | |
private static final String SEARCH_KEY_RESULT_COMPONENT = "lrc.search.resultComponent"; |
| 157 | |
|
| 158 | 8 | final Logger logger = Logger.getLogger(LuServiceImpl.class); |
| 159 | |
|
| 160 | |
private LuDao luDao; |
| 161 | |
private SearchManager searchManager; |
| 162 | |
private SearchDispatcher searchDispatcher; |
| 163 | |
private DictionaryService dictionaryServiceDelegate; |
| 164 | |
private ValidatorFactory validatorFactory; |
| 165 | |
|
| 166 | |
public void setSearchManager(SearchManager searchManager) { |
| 167 | 4 | this.searchManager = searchManager; |
| 168 | 4 | } |
| 169 | |
|
| 170 | |
public void setDictionaryServiceDelegate( |
| 171 | |
DictionaryService dictionaryServiceDelegate) { |
| 172 | 3 | this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
| 173 | 3 | } |
| 174 | |
|
| 175 | |
public DictionaryService getDictionaryServiceDelegate() { |
| 176 | 0 | return dictionaryServiceDelegate; |
| 177 | |
} |
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
@Override |
| 185 | |
public List<DeliveryMethodTypeInfo> getDeliveryMethodTypes() |
| 186 | |
throws OperationFailedException { |
| 187 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfos(luDao |
| 188 | |
.find(DeliveryMethodType.class)); |
| 189 | |
} |
| 190 | |
|
| 191 | |
@Override |
| 192 | |
public DeliveryMethodTypeInfo getDeliveryMethodType( |
| 193 | |
String deliveryMethodTypeKey) throws DoesNotExistException, |
| 194 | |
InvalidParameterException, MissingParameterException, |
| 195 | |
OperationFailedException { |
| 196 | |
|
| 197 | 0 | checkForMissingParameter(deliveryMethodTypeKey, "deliveryMethodTypeKey"); |
| 198 | |
|
| 199 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfo(luDao.fetch( |
| 200 | |
DeliveryMethodType.class, deliveryMethodTypeKey)); |
| 201 | |
} |
| 202 | |
|
| 203 | |
@Override |
| 204 | |
public List<InstructionalFormatTypeInfo> getInstructionalFormatTypes() |
| 205 | |
throws OperationFailedException { |
| 206 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfos(luDao |
| 207 | |
.find(InstructionalFormatType.class)); |
| 208 | |
} |
| 209 | |
|
| 210 | |
@Override |
| 211 | |
public InstructionalFormatTypeInfo getInstructionalFormatType( |
| 212 | |
String instructionalFormatTypeKey) throws DoesNotExistException, |
| 213 | |
InvalidParameterException, MissingParameterException, |
| 214 | |
OperationFailedException { |
| 215 | 0 | checkForMissingParameter(instructionalFormatTypeKey, |
| 216 | |
"instructionalFormatTypeKey"); |
| 217 | |
|
| 218 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfo(luDao.fetch( |
| 219 | |
InstructionalFormatType.class, instructionalFormatTypeKey)); |
| 220 | |
} |
| 221 | |
|
| 222 | |
@Override |
| 223 | |
public List<LuTypeInfo> getLuTypes() throws OperationFailedException { |
| 224 | 0 | return LuServiceAssembler.toLuTypeInfos(luDao.find(LuType.class)); |
| 225 | |
} |
| 226 | |
|
| 227 | |
@Override |
| 228 | |
public LuTypeInfo getLuType(String luTypeKey) throws DoesNotExistException, |
| 229 | |
InvalidParameterException, MissingParameterException, |
| 230 | |
OperationFailedException { |
| 231 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 232 | |
|
| 233 | 0 | return LuServiceAssembler.toLuTypeInfo(luDao.fetch(LuType.class, |
| 234 | |
luTypeKey)); |
| 235 | |
} |
| 236 | |
|
| 237 | |
@Override |
| 238 | |
public LuCodeTypeInfo getLuCodeType(String luCodeTypeKey) |
| 239 | |
throws DoesNotExistException, InvalidParameterException, |
| 240 | |
MissingParameterException, OperationFailedException { |
| 241 | 0 | checkForMissingParameter(luCodeTypeKey, "luCodeTypeKey"); |
| 242 | 0 | return LuServiceAssembler.toLuCodeTypeInfo(luDao.fetch( |
| 243 | |
LuCodeType.class, luCodeTypeKey)); |
| 244 | |
} |
| 245 | |
|
| 246 | |
@Override |
| 247 | |
public List<LuCodeTypeInfo> getLuCodeTypes() |
| 248 | |
throws OperationFailedException { |
| 249 | 0 | return LuServiceAssembler.toLuCodeTypeInfos(luDao |
| 250 | |
.find(LuCodeType.class)); |
| 251 | |
} |
| 252 | |
|
| 253 | |
@Override |
| 254 | |
public List<LuLuRelationTypeInfo> getLuLuRelationTypes() |
| 255 | |
throws OperationFailedException { |
| 256 | 1 | return LuServiceAssembler.toLuLuRelationTypeInfos(luDao |
| 257 | |
.find(LuLuRelationType.class)); |
| 258 | |
} |
| 259 | |
|
| 260 | |
@Override |
| 261 | |
public LuLuRelationTypeInfo getLuLuRelationType(String luLuRelationTypeKey) |
| 262 | |
throws OperationFailedException, MissingParameterException, |
| 263 | |
DoesNotExistException { |
| 264 | 4 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 265 | |
|
| 266 | 3 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
| 267 | |
luLuRelationTypeKey); |
| 268 | 2 | return LuServiceAssembler.toLuLuRelationTypeInfo(luLuRelationType); |
| 269 | |
} |
| 270 | |
|
| 271 | |
@Override |
| 272 | |
public List<String> getAllowedLuLuRelationTypesForLuType(String luTypeKey, |
| 273 | |
String relatedLuTypeKey) throws DoesNotExistException, |
| 274 | |
InvalidParameterException, MissingParameterException, |
| 275 | |
OperationFailedException { |
| 276 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 277 | 0 | checkForMissingParameter(relatedLuTypeKey, "relatedLuTypeKey"); |
| 278 | |
|
| 279 | 0 | return luDao.getAllowedLuLuRelationTypesForLuType(luTypeKey, |
| 280 | |
relatedLuTypeKey); |
| 281 | |
} |
| 282 | |
|
| 283 | |
@Override |
| 284 | |
public List<LuPublicationTypeInfo> getLuPublicationTypes() |
| 285 | |
throws OperationFailedException { |
| 286 | 0 | return LuServiceAssembler.toLuPublicationTypeInfos(luDao |
| 287 | |
.find(LuPublicationType.class)); |
| 288 | |
} |
| 289 | |
|
| 290 | |
@Override |
| 291 | |
public LuPublicationTypeInfo getLuPublicationType( |
| 292 | |
String luPublicationTypeKey) throws DoesNotExistException, |
| 293 | |
InvalidParameterException, MissingParameterException, |
| 294 | |
OperationFailedException { |
| 295 | 0 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
| 296 | |
|
| 297 | 0 | return LuServiceAssembler.toLuPublicationTypeInfo(luDao.fetch( |
| 298 | |
LuPublicationType.class, luPublicationTypeKey)); |
| 299 | |
} |
| 300 | |
|
| 301 | |
@Override |
| 302 | |
public List<String> getLuPublicationTypesForLuType(String luTypeKey) |
| 303 | |
throws DoesNotExistException, InvalidParameterException, |
| 304 | |
MissingParameterException, OperationFailedException { |
| 305 | 0 | throw new UnsupportedOperationException("getLuPublicationTypesForLuType"); |
| 306 | |
} |
| 307 | |
|
| 308 | |
@Override |
| 309 | |
public List<CluResultTypeInfo> getCluResultTypes() |
| 310 | |
throws OperationFailedException { |
| 311 | 0 | return LuServiceAssembler.toCluResultTypeInfos(luDao |
| 312 | |
.find(CluResultType.class)); |
| 313 | |
} |
| 314 | |
|
| 315 | |
@Override |
| 316 | |
public CluResultTypeInfo getCluResultType(String cluResultTypeKey) |
| 317 | |
throws DoesNotExistException, InvalidParameterException, |
| 318 | |
MissingParameterException, OperationFailedException { |
| 319 | 0 | return LuServiceAssembler.toCluResultTypeInfo(luDao.fetch( |
| 320 | |
CluResultType.class, cluResultTypeKey)); |
| 321 | |
} |
| 322 | |
|
| 323 | |
@Override |
| 324 | |
public List<CluResultTypeInfo> getCluResultTypesForLuType(String luTypeKey) |
| 325 | |
throws DoesNotExistException, InvalidParameterException, |
| 326 | |
MissingParameterException, OperationFailedException { |
| 327 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 328 | 0 | return LuServiceAssembler.toCluResultTypeInfos((luDao |
| 329 | |
.getAllowedCluResultTypesForLuType(luTypeKey))); |
| 330 | |
} |
| 331 | |
|
| 332 | |
@Override |
| 333 | |
public List<ResultUsageTypeInfo> getResultUsageTypes() |
| 334 | |
throws OperationFailedException { |
| 335 | 1 | return LuServiceAssembler.toResultUsageTypeInfos(luDao |
| 336 | |
.find(ResultUsageType.class)); |
| 337 | |
} |
| 338 | |
|
| 339 | |
@Override |
| 340 | |
public ResultUsageTypeInfo getResultUsageType(String resultUsageTypeKey) |
| 341 | |
throws DoesNotExistException, InvalidParameterException, |
| 342 | |
MissingParameterException, OperationFailedException { |
| 343 | 1 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
| 344 | 1 | return LuServiceAssembler.toResultUsageTypeInfo(luDao.fetch( |
| 345 | |
ResultUsageType.class, resultUsageTypeKey)); |
| 346 | |
} |
| 347 | |
|
| 348 | |
@Override |
| 349 | |
public List<String> getAllowedResultUsageTypesForLuType(String luTypeKey) |
| 350 | |
throws DoesNotExistException, InvalidParameterException, |
| 351 | |
MissingParameterException, OperationFailedException { |
| 352 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 353 | |
|
| 354 | 0 | return luDao.getAllowedResultUsageTypesForLuType(luTypeKey); |
| 355 | |
} |
| 356 | |
|
| 357 | |
@Override |
| 358 | |
public List<String> getAllowedResultComponentTypesForResultUsageType( |
| 359 | |
String resultUsageTypeKey) throws DoesNotExistException, |
| 360 | |
InvalidParameterException, MissingParameterException, |
| 361 | |
OperationFailedException { |
| 362 | |
|
| 363 | 0 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
| 364 | |
|
| 365 | 0 | return luDao |
| 366 | |
.getAllowedResultComponentTypesForResultUsageType(resultUsageTypeKey); |
| 367 | |
} |
| 368 | |
|
| 369 | |
@Override |
| 370 | |
public CluLoRelationTypeInfo getCluLoRelationType( |
| 371 | |
String cluLoRelationTypeKey) throws DoesNotExistException, |
| 372 | |
InvalidParameterException, MissingParameterException, |
| 373 | |
OperationFailedException { |
| 374 | 0 | checkForMissingParameter(cluLoRelationTypeKey, "cluLoRelationTypeKey"); |
| 375 | |
|
| 376 | 0 | CluLoRelationType cluLoRelationType = luDao.fetch( |
| 377 | |
CluLoRelationType.class, cluLoRelationTypeKey); |
| 378 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfo(cluLoRelationType); |
| 379 | |
} |
| 380 | |
|
| 381 | |
@Override |
| 382 | |
public List<CluLoRelationTypeInfo> getCluLoRelationTypes() |
| 383 | |
throws OperationFailedException { |
| 384 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfos(luDao |
| 385 | |
.find(CluLoRelationType.class)); |
| 386 | |
} |
| 387 | |
|
| 388 | |
@Override |
| 389 | |
public List<String> getAllowedCluLoRelationTypesForLuType(String luTypeKey) |
| 390 | |
throws DoesNotExistException, InvalidParameterException, |
| 391 | |
MissingParameterException, OperationFailedException { |
| 392 | |
|
| 393 | 0 | checkForMissingParameter(luTypeKey, luTypeKey); |
| 394 | |
|
| 395 | 0 | return luDao.getAllowedCluLoRelationTypesForLuType(luTypeKey); |
| 396 | |
} |
| 397 | |
|
| 398 | |
@Override |
| 399 | |
public List<CluSetTypeInfo> getCluSetTypes() |
| 400 | |
throws OperationFailedException { |
| 401 | 0 | return LuServiceAssembler.toCluSetTypeInfos(luDao |
| 402 | |
.find(CluSetType.class)); |
| 403 | |
} |
| 404 | |
|
| 405 | |
@Override |
| 406 | |
public CluSetTypeInfo getCluSetType(String cluSetTypeKey) |
| 407 | |
throws DoesNotExistException, InvalidParameterException, |
| 408 | |
MissingParameterException, OperationFailedException { |
| 409 | 0 | checkForMissingParameter(cluSetTypeKey, "cluSetTypeKey"); |
| 410 | 0 | return LuServiceAssembler.toCluSetTypeInfo(luDao.fetch( |
| 411 | |
CluSetType.class, cluSetTypeKey)); |
| 412 | |
} |
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
@Override |
| 420 | |
public CluInfo getClu(String cluId) throws DoesNotExistException, |
| 421 | |
InvalidParameterException, MissingParameterException, |
| 422 | |
OperationFailedException { |
| 423 | |
|
| 424 | 179 | checkForMissingParameter(cluId, "cluId"); |
| 425 | |
|
| 426 | 178 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 427 | 173 | return LuServiceAssembler.toCluInfo(clu); |
| 428 | |
} |
| 429 | |
|
| 430 | |
@Override |
| 431 | |
public List<CluInfo> getClusByIdList(List<String> cluIdList) |
| 432 | |
throws DoesNotExistException, InvalidParameterException, |
| 433 | |
MissingParameterException, OperationFailedException { |
| 434 | 3 | checkForMissingParameter(cluIdList, "cluIdList"); |
| 435 | 2 | checkForEmptyList(cluIdList, "cluIdList"); |
| 436 | 2 | List<Clu> clus = luDao.getClusByIdList(cluIdList); |
| 437 | 2 | return LuServiceAssembler.toCluInfos(clus); |
| 438 | |
} |
| 439 | |
|
| 440 | |
@Override |
| 441 | |
public List<CluInfo> getClusByLuType(String luTypeKey, String luState) |
| 442 | |
throws DoesNotExistException, InvalidParameterException, |
| 443 | |
MissingParameterException, OperationFailedException { |
| 444 | 5 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 445 | 4 | checkForMissingParameter(luState, "lustate"); |
| 446 | 3 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
| 447 | 3 | return LuServiceAssembler.toCluInfos(clus); |
| 448 | |
} |
| 449 | |
|
| 450 | |
@Override |
| 451 | |
public List<String> getCluIdsByLuType(String luTypeKey, String luState) |
| 452 | |
throws DoesNotExistException, InvalidParameterException, |
| 453 | |
MissingParameterException, OperationFailedException { |
| 454 | 5 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 455 | 4 | checkForMissingParameter(luState, "luState"); |
| 456 | 3 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
| 457 | 3 | List<String> ids = new ArrayList<String>(clus.size()); |
| 458 | 3 | for (Clu clu : clus) { |
| 459 | 1 | ids.add(clu.getId()); |
| 460 | |
} |
| 461 | 3 | return ids; |
| 462 | |
} |
| 463 | |
|
| 464 | |
|
| 465 | |
|
| 466 | |
@Override |
| 467 | |
public List<String> getAllowedLuLuRelationTypesByCluId(String cluId, |
| 468 | |
String relatedCluId) throws DoesNotExistException, |
| 469 | |
InvalidParameterException, MissingParameterException, |
| 470 | |
OperationFailedException { |
| 471 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 472 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 473 | |
|
| 474 | 0 | return luDao.getAllowedLuLuRelationTypesByCluId(cluId, relatedCluId); |
| 475 | |
} |
| 476 | |
|
| 477 | |
@Override |
| 478 | |
public List<CluInfo> getClusByRelation(String relatedCluId, |
| 479 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 480 | |
InvalidParameterException, MissingParameterException, |
| 481 | |
OperationFailedException { |
| 482 | 5 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 483 | 4 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 484 | |
|
| 485 | 3 | List<Clu> clus = luDao.getClusByRelation(relatedCluId, |
| 486 | |
luLuRelationTypeKey); |
| 487 | 3 | List<CluInfo> result = LuServiceAssembler.toCluInfos(clus); |
| 488 | 3 | return result; |
| 489 | |
|
| 490 | |
} |
| 491 | |
|
| 492 | |
@Override |
| 493 | |
public List<String> getCluIdsByRelation(String relatedCluId, |
| 494 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 495 | |
InvalidParameterException, MissingParameterException, |
| 496 | |
OperationFailedException { |
| 497 | 19 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 498 | 18 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 499 | |
|
| 500 | 17 | List<String> cluIds = luDao.getCluIdsByRelatedCluId(relatedCluId, luLuRelationTypeKey); |
| 501 | 17 | return cluIds; |
| 502 | |
} |
| 503 | |
|
| 504 | |
@Override |
| 505 | |
public List<CluInfo> getRelatedClusByCluId(String cluId, |
| 506 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 507 | |
InvalidParameterException, MissingParameterException, |
| 508 | |
OperationFailedException { |
| 509 | 64 | checkForMissingParameter(cluId, "cluId"); |
| 510 | 64 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 511 | 64 | List<Clu> relatedClus = luDao.getRelatedClusByCluId(cluId, |
| 512 | |
luLuRelationTypeKey); |
| 513 | 64 | return LuServiceAssembler.toCluInfos(relatedClus); |
| 514 | |
} |
| 515 | |
|
| 516 | |
@Override |
| 517 | |
public List<String> getRelatedCluIdsByCluId(String cluId, |
| 518 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 519 | |
InvalidParameterException, MissingParameterException, |
| 520 | |
OperationFailedException { |
| 521 | 85 | checkForMissingParameter(cluId, "cluId"); |
| 522 | 85 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 523 | 85 | List<String> relatedCluIds = luDao.getRelatedCluIdsByCluId(cluId, |
| 524 | |
luLuRelationTypeKey); |
| 525 | 85 | return relatedCluIds; |
| 526 | |
} |
| 527 | |
|
| 528 | |
@Override |
| 529 | |
public CluCluRelationInfo getCluCluRelation(String cluCluRelationId) |
| 530 | |
throws DoesNotExistException, InvalidParameterException, |
| 531 | |
MissingParameterException, OperationFailedException { |
| 532 | 2 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 533 | 2 | return LuServiceAssembler.toCluCluRelationInfo(luDao.fetch( |
| 534 | |
CluCluRelation.class, cluCluRelationId)); |
| 535 | |
} |
| 536 | |
|
| 537 | |
@Override |
| 538 | |
public List<CluCluRelationInfo> getCluCluRelationsByClu(String cluId) |
| 539 | |
throws DoesNotExistException, InvalidParameterException, |
| 540 | |
MissingParameterException, OperationFailedException { |
| 541 | 81 | checkForMissingParameter(cluId, "cluId"); |
| 542 | 80 | List<CluCluRelation> cluCluRelations = luDao |
| 543 | |
.getCluCluRelationsByClu(cluId); |
| 544 | 80 | return LuServiceAssembler.toCluCluRelationInfos(cluCluRelations); |
| 545 | |
} |
| 546 | |
|
| 547 | |
|
| 548 | |
@Override |
| 549 | |
public List<CluPublicationInfo> getCluPublicationsByCluId(String cluId) |
| 550 | |
throws DoesNotExistException, InvalidParameterException, |
| 551 | |
MissingParameterException, OperationFailedException { |
| 552 | 185 | checkForMissingParameter(cluId, "cluId"); |
| 553 | 185 | List<CluPublication> cluPublications = luDao.getCluPublicationsByCluId(cluId); |
| 554 | 185 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
| 555 | |
} |
| 556 | |
|
| 557 | |
@Override |
| 558 | |
public List<CluPublicationInfo> getCluPublicationsByType( |
| 559 | |
String luPublicationTypeKey) throws DoesNotExistException, |
| 560 | |
InvalidParameterException, MissingParameterException, |
| 561 | |
OperationFailedException { |
| 562 | 1 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
| 563 | 1 | List<CluPublication> cluPublications = luDao.getCluPublicationsByType(luPublicationTypeKey); |
| 564 | 1 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
| 565 | |
} |
| 566 | |
|
| 567 | |
@Override |
| 568 | |
public CluPublicationInfo getCluPublication(String cluPublicationId) |
| 569 | |
throws DoesNotExistException, InvalidParameterException, |
| 570 | |
MissingParameterException, OperationFailedException { |
| 571 | 1 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 572 | 1 | CluPublication cluPublication = luDao.fetch(CluPublication.class, cluPublicationId); |
| 573 | 1 | return LuServiceAssembler.toCluPublicationInfo(cluPublication); |
| 574 | |
} |
| 575 | |
|
| 576 | |
|
| 577 | |
|
| 578 | |
@Override |
| 579 | |
public CluResultInfo getCluResult(String cluResultId) |
| 580 | |
throws DoesNotExistException, InvalidParameterException, |
| 581 | |
MissingParameterException, OperationFailedException { |
| 582 | |
|
| 583 | 4 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 584 | |
|
| 585 | 4 | CluResult cluResult = luDao.fetch(CluResult.class, cluResultId); |
| 586 | 4 | return LuServiceAssembler.toCluResultInfo(cluResult); |
| 587 | |
} |
| 588 | |
|
| 589 | |
@Override |
| 590 | |
public List<CluResultInfo> getCluResultByClu(String cluId) |
| 591 | |
throws DoesNotExistException, InvalidParameterException, |
| 592 | |
MissingParameterException, OperationFailedException { |
| 593 | |
|
| 594 | 124 | checkForMissingParameter(cluId, "cluId"); |
| 595 | |
|
| 596 | 124 | return LuServiceAssembler.toCluResultInfos(luDao |
| 597 | |
.getCluResultByClu(cluId)); |
| 598 | |
} |
| 599 | |
|
| 600 | |
@Override |
| 601 | |
public List<String> getCluIdsByResultUsageType(String resultUsageTypeKey) |
| 602 | |
throws DoesNotExistException, InvalidParameterException, |
| 603 | |
MissingParameterException, OperationFailedException { |
| 604 | 0 | return luDao.getCluIdsByResultUsageType(resultUsageTypeKey); |
| 605 | |
} |
| 606 | |
|
| 607 | |
@Override |
| 608 | |
public List<String> getCluIdsByResultComponent(String resultComponentId) |
| 609 | |
throws DoesNotExistException, InvalidParameterException, |
| 610 | |
MissingParameterException, OperationFailedException { |
| 611 | 0 | return luDao.getCluIdsByResultComponentId(resultComponentId); |
| 612 | |
} |
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
@Override |
| 617 | |
public CluLoRelationInfo getCluLoRelation(String cluLoRelationId) |
| 618 | |
throws DoesNotExistException, InvalidParameterException, |
| 619 | |
MissingParameterException, OperationFailedException, |
| 620 | |
PermissionDeniedException { |
| 621 | |
|
| 622 | 1 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 623 | |
|
| 624 | 1 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 625 | 1 | return LuServiceAssembler.toCluLoRelationInfo(reltn); |
| 626 | |
|
| 627 | |
} |
| 628 | |
|
| 629 | |
@Override |
| 630 | |
public List<CluLoRelationInfo> getCluLoRelationsByClu(String cluId) |
| 631 | |
throws DoesNotExistException, InvalidParameterException, |
| 632 | |
MissingParameterException, OperationFailedException { |
| 633 | |
|
| 634 | 184 | checkForMissingParameter(cluId, "cluId"); |
| 635 | 184 | List<CluLoRelation> cluLoRelations = luDao |
| 636 | |
.getCluLoRelationsByClu(cluId); |
| 637 | 184 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
| 638 | |
|
| 639 | |
} |
| 640 | |
|
| 641 | |
@Override |
| 642 | |
public List<CluLoRelationInfo> getCluLoRelationsByLo(String loId) |
| 643 | |
throws DoesNotExistException, InvalidParameterException, |
| 644 | |
MissingParameterException, OperationFailedException { |
| 645 | 1 | checkForMissingParameter(loId, "loId"); |
| 646 | 1 | List<CluLoRelation> cluLoRelations = luDao.getCluLoRelationsByLo(loId); |
| 647 | 1 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
| 648 | |
} |
| 649 | |
|
| 650 | |
|
| 651 | |
|
| 652 | |
@Override |
| 653 | |
public List<String> getResourceRequirementsForCluId(String cluId) |
| 654 | |
throws DoesNotExistException, InvalidParameterException, |
| 655 | |
MissingParameterException, OperationFailedException { |
| 656 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 657 | |
} |
| 658 | |
|
| 659 | |
|
| 660 | |
|
| 661 | |
@Override |
| 662 | |
public CluSetInfo getCluSetInfo(String cluSetId) |
| 663 | |
throws DoesNotExistException, InvalidParameterException, |
| 664 | |
MissingParameterException, OperationFailedException, |
| 665 | |
PermissionDeniedException { |
| 666 | 111 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 667 | 110 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 668 | 96 | CluSetInfo cluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
| 669 | 96 | setMembershipQuerySearchResult(cluSetInfo); |
| 670 | 96 | return cluSetInfo; |
| 671 | |
} |
| 672 | |
|
| 673 | |
@Override |
| 674 | |
public CluSetTreeViewInfo getCluSetTreeView(String cluSetId) |
| 675 | |
throws DoesNotExistException, InvalidParameterException, |
| 676 | |
MissingParameterException, OperationFailedException, |
| 677 | |
PermissionDeniedException { |
| 678 | |
|
| 679 | 36 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 680 | 35 | CluSetInfo cluSet = getCluSetInfo(cluSetId); |
| 681 | 34 | if (cluSet == null) { |
| 682 | 0 | return null; |
| 683 | |
} |
| 684 | |
|
| 685 | 34 | CluSetTreeViewInfo cluSetTreeView = new CluSetTreeViewInfo(); |
| 686 | 34 | getCluSetTreeViewHelper(cluSet, cluSetTreeView); |
| 687 | 34 | return cluSetTreeView; |
| 688 | |
} |
| 689 | |
|
| 690 | |
|
| 691 | |
|
| 692 | |
|
| 693 | |
|
| 694 | |
|
| 695 | |
|
| 696 | |
|
| 697 | |
|
| 698 | |
|
| 699 | |
|
| 700 | |
|
| 701 | |
|
| 702 | |
private void getCluSetTreeViewHelper(CluSetInfo cluSetInfo, |
| 703 | |
CluSetTreeViewInfo cluSetTreeViewInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 704 | 38 | cluSetTreeViewInfo.setName(cluSetInfo.getName()); |
| 705 | 38 | cluSetTreeViewInfo.setDescr(cluSetInfo.getDescr()); |
| 706 | 38 | cluSetTreeViewInfo.setEffectiveDate(cluSetInfo.getEffectiveDate()); |
| 707 | 38 | cluSetTreeViewInfo.setExpirationDate(cluSetInfo.getExpirationDate()); |
| 708 | 38 | cluSetTreeViewInfo.setAdminOrg(cluSetInfo.getAdminOrg()); |
| 709 | 38 | cluSetTreeViewInfo.setIsReusable(cluSetInfo.getIsReusable()); |
| 710 | 38 | cluSetTreeViewInfo.setIsReferenceable(cluSetInfo.getIsReferenceable()); |
| 711 | 38 | cluSetTreeViewInfo.setMetaInfo(cluSetInfo.getMetaInfo()); |
| 712 | 38 | cluSetTreeViewInfo.setAttributes(cluSetInfo.getAttributes()); |
| 713 | 38 | cluSetTreeViewInfo.setType(cluSetInfo.getType()); |
| 714 | 38 | cluSetTreeViewInfo.setState(cluSetInfo.getState()); |
| 715 | 38 | cluSetTreeViewInfo.setId(cluSetInfo.getId()); |
| 716 | |
|
| 717 | 38 | if (!cluSetInfo.getCluSetIds().isEmpty()) { |
| 718 | 2 | for (String cluSetId : cluSetInfo.getCluSetIds()) { |
| 719 | 4 | CluSetInfo subCluSet = getCluSetInfo(cluSetId); |
| 720 | 4 | List<CluSetTreeViewInfo> cluSets = |
| 721 | |
cluSetTreeViewInfo.getCluSets() == null ? |
| 722 | |
new ArrayList<CluSetTreeViewInfo>(0) : cluSetTreeViewInfo.getCluSets(); |
| 723 | |
|
| 724 | 4 | CluSetTreeViewInfo subCluSetTreeViewInfo = new CluSetTreeViewInfo(); |
| 725 | 4 | getCluSetTreeViewHelper(subCluSet, subCluSetTreeViewInfo); |
| 726 | 4 | cluSets.add(subCluSetTreeViewInfo); |
| 727 | |
|
| 728 | 4 | cluSetTreeViewInfo.setCluSets(cluSets); |
| 729 | 4 | } |
| 730 | |
} |
| 731 | 38 | List<CluInfo> clus = new ArrayList<CluInfo>(); |
| 732 | 38 | for (String cluId : cluSetInfo.getCluIds()) { |
| 733 | 171 | if(cluId!=null){ |
| 734 | |
|
| 735 | |
|
| 736 | 171 | Clu clu = luDao.getCurrentCluVersion(cluId); |
| 737 | 171 | CluInfo cluInfo = new CluInfo(); |
| 738 | 171 | cluInfo.setId(clu.getId()); |
| 739 | 171 | cluInfo.setType(clu.getLuType().getId()); |
| 740 | 171 | cluInfo.setOfficialIdentifier(LuServiceAssembler.toCluIdentifierInfo(clu.getOfficialIdentifier())); |
| 741 | 171 | clus.add(cluInfo); |
| 742 | 171 | } |
| 743 | |
} |
| 744 | 38 | cluSetTreeViewInfo.setClus(clus); |
| 745 | 38 | } |
| 746 | |
|
| 747 | |
@Override |
| 748 | |
public List<CluSetInfo> getCluSetInfoByIdList(List<String> cluSetIdList) |
| 749 | |
throws DoesNotExistException, InvalidParameterException, |
| 750 | |
MissingParameterException, OperationFailedException, |
| 751 | |
PermissionDeniedException { |
| 752 | 5 | checkForMissingParameter(cluSetIdList, "cluSetIdList"); |
| 753 | 4 | checkForEmptyList(cluSetIdList, "cluSetIdList"); |
| 754 | 4 | List<CluSet> cluSets = luDao.getCluSetInfoByIdList(cluSetIdList); |
| 755 | 4 | return LuServiceAssembler.toCluSetInfos(cluSets); |
| 756 | |
} |
| 757 | |
|
| 758 | |
@Override |
| 759 | |
public List<String> getCluSetIdsFromCluSet(String cluSetId) |
| 760 | |
throws DoesNotExistException, InvalidParameterException, |
| 761 | |
MissingParameterException, OperationFailedException, |
| 762 | |
PermissionDeniedException { |
| 763 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 764 | 0 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 765 | 0 | List<String> ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
| 766 | 0 | if(cluSet.getCluSets()!=null){ |
| 767 | 0 | for (CluSet cluSet2 : cluSet.getCluSets()) { |
| 768 | 0 | ids.add(cluSet2.getId()); |
| 769 | |
} |
| 770 | |
} |
| 771 | 0 | return ids; |
| 772 | |
} |
| 773 | |
|
| 774 | |
@Override |
| 775 | |
public Boolean isCluSetDynamic(String cluSetId) |
| 776 | |
throws DoesNotExistException, InvalidParameterException, |
| 777 | |
MissingParameterException, OperationFailedException, |
| 778 | |
PermissionDeniedException { |
| 779 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 780 | |
} |
| 781 | |
|
| 782 | |
@Override |
| 783 | |
public List<CluInfo> getClusFromCluSet(String cluSetId) |
| 784 | |
throws DoesNotExistException, InvalidParameterException, |
| 785 | |
MissingParameterException, OperationFailedException, |
| 786 | |
PermissionDeniedException { |
| 787 | 3 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 788 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 789 | 1 | List<CluInfo> clus = new ArrayList<CluInfo>(cluSet.getCluVerIndIds().size()); |
| 790 | 1 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
| 791 | 2 | clus.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluSetJnClu.getCluVersionIndId()))); |
| 792 | |
} |
| 793 | 1 | return clus; |
| 794 | |
} |
| 795 | |
|
| 796 | |
@Override |
| 797 | |
public List<String> getCluIdsFromCluSet(String cluSetId) |
| 798 | |
throws DoesNotExistException, InvalidParameterException, |
| 799 | |
MissingParameterException, OperationFailedException, |
| 800 | |
PermissionDeniedException { |
| 801 | 3 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 802 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 803 | 1 | List<String> ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
| 804 | 1 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
| 805 | 2 | ids.add(cluSetJnClu.getCluVersionIndId()); |
| 806 | |
} |
| 807 | 1 | return ids; |
| 808 | |
} |
| 809 | |
|
| 810 | |
@Override |
| 811 | |
public List<CluInfo> getAllClusInCluSet(String cluSetId) |
| 812 | |
throws DoesNotExistException, InvalidParameterException, |
| 813 | |
MissingParameterException, OperationFailedException, |
| 814 | |
PermissionDeniedException { |
| 815 | 2 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 816 | 2 | List<String> cluIndIds = new ArrayList<String>(); |
| 817 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 818 | 2 | findClusInCluSet(cluIndIds, cluSet); |
| 819 | 2 | List<CluInfo> infos = new ArrayList<CluInfo>(cluIndIds.size()); |
| 820 | 2 | for (String cluIndId : cluIndIds) { |
| 821 | 5 | infos.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluIndId))); |
| 822 | |
} |
| 823 | 2 | return infos; |
| 824 | |
} |
| 825 | |
|
| 826 | |
@Override |
| 827 | |
public List<String> getAllCluIdsInCluSet(String cluSetId) |
| 828 | |
throws DoesNotExistException, InvalidParameterException, |
| 829 | |
MissingParameterException, OperationFailedException, |
| 830 | |
PermissionDeniedException { |
| 831 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 832 | 0 | List<String> ids = new ArrayList<String>(); |
| 833 | 0 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 834 | 0 | findClusInCluSet(ids, cluSet); |
| 835 | 0 | return ids; |
| 836 | |
} |
| 837 | |
|
| 838 | |
@Override |
| 839 | |
public Boolean isCluInCluSet(String cluId, String cluSetId) |
| 840 | |
throws DoesNotExistException, InvalidParameterException, |
| 841 | |
MissingParameterException, OperationFailedException, |
| 842 | |
PermissionDeniedException { |
| 843 | 6 | checkForMissingParameter(cluId, "cluId"); |
| 844 | 5 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 845 | 4 | return luDao.isCluInCluSet(cluId, cluSetId); |
| 846 | |
} |
| 847 | |
|
| 848 | |
|
| 849 | |
|
| 850 | |
|
| 851 | |
@Override |
| 852 | |
public LuiInfo getLui(String luiId) throws DoesNotExistException, |
| 853 | |
InvalidParameterException, MissingParameterException, |
| 854 | |
OperationFailedException { |
| 855 | |
|
| 856 | 4 | checkForMissingParameter(luiId, "luiId"); |
| 857 | |
|
| 858 | 3 | Lui lui = luDao.fetch(Lui.class, luiId); |
| 859 | 2 | return LuServiceAssembler.toLuiInfo(lui); |
| 860 | |
} |
| 861 | |
|
| 862 | |
@Override |
| 863 | |
public List<LuiInfo> getLuisByIdList(List<String> luiIdList) |
| 864 | |
throws DoesNotExistException, InvalidParameterException, |
| 865 | |
MissingParameterException, OperationFailedException { |
| 866 | 3 | checkForMissingParameter(luiIdList, "luiIdList"); |
| 867 | 2 | checkForEmptyList(luiIdList, "luiIdList"); |
| 868 | 2 | List<Lui> luis = luDao.getLuisByIdList(luiIdList); |
| 869 | 2 | return LuServiceAssembler.toLuiInfos(luis); |
| 870 | |
} |
| 871 | |
|
| 872 | |
@Override |
| 873 | |
public List<LuiInfo> getLuisInAtpByCluId(String cluId, String atpKey) |
| 874 | |
throws DoesNotExistException, InvalidParameterException, |
| 875 | |
MissingParameterException, OperationFailedException { |
| 876 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 877 | |
} |
| 878 | |
|
| 879 | |
@Override |
| 880 | |
public List<String> getLuiIdsByCluId(String cluId) |
| 881 | |
throws DoesNotExistException, InvalidParameterException, |
| 882 | |
MissingParameterException, OperationFailedException { |
| 883 | |
|
| 884 | 4 | checkForMissingParameter(cluId, "cluId"); |
| 885 | |
|
| 886 | 3 | return luDao.getLuiIdsByCluId(cluId); |
| 887 | |
} |
| 888 | |
|
| 889 | |
@Override |
| 890 | |
public List<String> getLuiIdsInAtpByCluId(String cluId, String atpKey) |
| 891 | |
throws DoesNotExistException, InvalidParameterException, |
| 892 | |
MissingParameterException, OperationFailedException { |
| 893 | |
|
| 894 | 6 | checkForMissingParameter(cluId, "cluId"); |
| 895 | 5 | checkForMissingParameter(atpKey, "atpKey"); |
| 896 | 4 | return luDao.getLuiIdsInAtpByCluId(cluId, atpKey); |
| 897 | |
} |
| 898 | |
|
| 899 | |
|
| 900 | |
|
| 901 | |
@Override |
| 902 | |
public List<String> getAllowedLuLuRelationTypesByLuiId(String luiId, |
| 903 | |
String relatedLuiId) throws DoesNotExistException, |
| 904 | |
InvalidParameterException, MissingParameterException, |
| 905 | |
OperationFailedException { |
| 906 | |
|
| 907 | 0 | checkForMissingParameter(luiId, "luiId"); |
| 908 | 0 | checkForMissingParameter(relatedLuiId, "relatedLuiId"); |
| 909 | |
|
| 910 | 0 | return luDao.getAllowedLuLuRelationTypesByLuiId(luiId, relatedLuiId); |
| 911 | |
} |
| 912 | |
|
| 913 | |
@Override |
| 914 | |
public List<LuiInfo> getLuisByRelation(String luiId, |
| 915 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 916 | |
InvalidParameterException, MissingParameterException, |
| 917 | |
OperationFailedException { |
| 918 | 2 | checkForMissingParameter(luiId, "luiId"); |
| 919 | 2 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 920 | |
|
| 921 | 2 | return LuServiceAssembler.toLuiInfos(luDao.getLuisByRelationType(luiId, |
| 922 | |
luLuRelationTypeKey)); |
| 923 | |
} |
| 924 | |
|
| 925 | |
@Override |
| 926 | |
public List<String> getLuiIdsByRelation(String luiId, |
| 927 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 928 | |
InvalidParameterException, MissingParameterException, |
| 929 | |
OperationFailedException { |
| 930 | 2 | checkForMissingParameter(luiId, "luiId"); |
| 931 | 2 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 932 | |
|
| 933 | 2 | return luDao.getLuiIdsByRelationType(luiId, luLuRelationTypeKey); |
| 934 | |
} |
| 935 | |
|
| 936 | |
@Override |
| 937 | |
public List<LuiInfo> getRelatedLuisByLuiId(String luiId, |
| 938 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 939 | |
InvalidParameterException, MissingParameterException, |
| 940 | |
OperationFailedException { |
| 941 | 1 | checkForMissingParameter(luiId, "luiId"); |
| 942 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 943 | 1 | List<Lui> relatedLuis = luDao.getRelatedLuisByLuiId(luiId, |
| 944 | |
luLuRelationTypeKey); |
| 945 | 1 | return LuServiceAssembler.toLuiInfos(relatedLuis); |
| 946 | |
} |
| 947 | |
|
| 948 | |
@Override |
| 949 | |
public List<String> getRelatedLuiIdsByLuiId(String luiId, |
| 950 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
| 951 | |
InvalidParameterException, MissingParameterException, |
| 952 | |
OperationFailedException { |
| 953 | 1 | checkForMissingParameter(luiId, "luiId"); |
| 954 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 955 | 1 | List<String> relatedLuiIds = luDao.getRelatedLuiIdsByLuiId(luiId, |
| 956 | |
luLuRelationTypeKey); |
| 957 | 1 | return relatedLuiIds; |
| 958 | |
} |
| 959 | |
|
| 960 | |
@Override |
| 961 | |
public LuiLuiRelationInfo getLuiLuiRelation(String luiLuiRelationId) |
| 962 | |
throws DoesNotExistException, InvalidParameterException, |
| 963 | |
MissingParameterException, OperationFailedException { |
| 964 | 2 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
| 965 | 2 | LuiLuiRelation luiLuiRelation = luDao.fetch(LuiLuiRelation.class, |
| 966 | |
luiLuiRelationId); |
| 967 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(luiLuiRelation); |
| 968 | |
} |
| 969 | |
|
| 970 | |
@Override |
| 971 | |
public List<LuiLuiRelationInfo> getLuiLuiRelationsByLui(String luiId) |
| 972 | |
throws DoesNotExistException, InvalidParameterException, |
| 973 | |
MissingParameterException, OperationFailedException { |
| 974 | 3 | checkForMissingParameter(luiId, "luiId"); |
| 975 | 3 | List<LuiLuiRelation> entities = luDao.getLuiLuiRelations(luiId); |
| 976 | 3 | return LuServiceAssembler.toLuiLuiRelationInfos(entities); |
| 977 | |
} |
| 978 | |
|
| 979 | |
|
| 980 | |
|
| 981 | |
|
| 982 | |
|
| 983 | |
@Override |
| 984 | |
public List<ValidationResultInfo> validateClu(String validationType, |
| 985 | |
CluInfo cluInfo) throws DoesNotExistException, |
| 986 | |
InvalidParameterException, MissingParameterException, |
| 987 | |
OperationFailedException { |
| 988 | 240 | checkForMissingParameter(validationType, "validationType"); |
| 989 | 240 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 990 | |
|
| 991 | 240 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluInfo.class.getName()); |
| 992 | 240 | Validator defaultValidator = validatorFactory.getValidator(); |
| 993 | 240 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluInfo, objStructure); |
| 994 | |
|
| 995 | 240 | return validationResults; |
| 996 | |
} |
| 997 | |
|
| 998 | |
@Override |
| 999 | |
@Transactional(readOnly=false) |
| 1000 | |
public CluInfo createClu(String luTypeKey, CluInfo cluInfo) |
| 1001 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1002 | |
DoesNotExistException, InvalidParameterException, |
| 1003 | |
MissingParameterException, OperationFailedException, |
| 1004 | |
PermissionDeniedException { |
| 1005 | 171 | Clu clu = toCluForCreate(luTypeKey,cluInfo); |
| 1006 | |
|
| 1007 | 171 | if(clu.getVersion() == null){ |
| 1008 | 171 | clu.setVersion(new Version()); |
| 1009 | |
} |
| 1010 | 171 | clu.getVersion().setCurrentVersionStart(new Date()); |
| 1011 | 171 | luDao.create(clu); |
| 1012 | 171 | return LuServiceAssembler.toCluInfo(clu); |
| 1013 | |
} |
| 1014 | |
|
| 1015 | |
public Clu toCluForCreate(String luTypeKey, CluInfo cluInfo) |
| 1016 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1017 | |
DoesNotExistException, InvalidParameterException, |
| 1018 | |
MissingParameterException, OperationFailedException, |
| 1019 | |
PermissionDeniedException { |
| 1020 | 189 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 1021 | 189 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 1022 | |
|
| 1023 | |
|
| 1024 | 189 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo); |
| 1025 | 189 | if(null != val && val.size() > 0) { |
| 1026 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1027 | |
} |
| 1028 | |
|
| 1029 | 189 | Clu clu = new Clu(); |
| 1030 | |
|
| 1031 | 189 | LuType luType = luDao.fetch(LuType.class, luTypeKey); |
| 1032 | 189 | clu.setLuType(luType); |
| 1033 | |
|
| 1034 | 189 | if (cluInfo.getOfficialIdentifier() != null) { |
| 1035 | 57 | clu.setOfficialIdentifier(LuServiceAssembler.createOfficialIdentifier(cluInfo, luDao)); |
| 1036 | |
} |
| 1037 | 189 | clu.setAlternateIdentifiers(LuServiceAssembler.createAlternateIdentifiers(cluInfo, luDao)); |
| 1038 | 189 | if (cluInfo.getDescr() != null) { |
| 1039 | 57 | LuRichText descr = LuServiceAssembler.toRichText(LuRichText.class, cluInfo.getDescr()); |
| 1040 | 57 | if (descr.getPlain() != null || descr.getFormatted() != null) { |
| 1041 | 57 | clu.setDescr(descr); |
| 1042 | |
} |
| 1043 | |
} |
| 1044 | |
|
| 1045 | 189 | if (clu.getAdminOrgs() == null) { |
| 1046 | 189 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>(0)); |
| 1047 | |
} |
| 1048 | 189 | List<CluAdminOrg> adminOrgs = clu.getAdminOrgs(); |
| 1049 | 189 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
| 1050 | 484 | CluAdminOrg instructor = new CluAdminOrg(); |
| 1051 | 484 | BeanUtils.copyProperties(orgInfo, instructor, |
| 1052 | |
new String[] { "attributes" }); |
| 1053 | 484 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1054 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
| 1055 | |
instructor, luDao)); |
| 1056 | 484 | instructor.setClu(clu); |
| 1057 | 484 | adminOrgs.add(instructor); |
| 1058 | 484 | } |
| 1059 | |
|
| 1060 | 189 | if (cluInfo.getPrimaryInstructor() != null) { |
| 1061 | 26 | CluInstructor primaryInstructor = new CluInstructor(); |
| 1062 | 26 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), |
| 1063 | |
primaryInstructor, new String[] { "attributes" }); |
| 1064 | 26 | primaryInstructor.setAttributes(LuServiceAssembler |
| 1065 | |
.toGenericAttributes(CluInstructorAttribute.class, cluInfo |
| 1066 | |
.getPrimaryInstructor().getAttributes(), |
| 1067 | |
primaryInstructor, luDao)); |
| 1068 | 26 | clu.setPrimaryInstructor(primaryInstructor); |
| 1069 | |
} |
| 1070 | |
|
| 1071 | 189 | if (clu.getInstructors() == null) { |
| 1072 | 189 | clu.setInstructors(new ArrayList<CluInstructor>(0)); |
| 1073 | |
} |
| 1074 | 189 | List<CluInstructor> instructors = clu.getInstructors(); |
| 1075 | 189 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
| 1076 | 62 | CluInstructor instructor = new CluInstructor(); |
| 1077 | 62 | BeanUtils.copyProperties(instructorInfo, instructor, |
| 1078 | |
new String[] { "attributes" }); |
| 1079 | 62 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1080 | |
CluInstructorAttribute.class, instructorInfo |
| 1081 | |
.getAttributes(), instructor, luDao)); |
| 1082 | 62 | instructors.add(instructor); |
| 1083 | 62 | } |
| 1084 | |
|
| 1085 | 189 | if (cluInfo.getStdDuration() != null) { |
| 1086 | 169 | clu.setStdDuration(LuServiceAssembler.toTimeAmount(cluInfo |
| 1087 | |
.getStdDuration())); |
| 1088 | |
} |
| 1089 | |
|
| 1090 | 189 | if (clu.getLuCodes() == null) { |
| 1091 | 189 | clu.setLuCodes(new ArrayList<LuCode>(0)); |
| 1092 | |
} |
| 1093 | 189 | List<LuCode> luCodes = clu.getLuCodes(); |
| 1094 | 189 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
| 1095 | 101 | LuCode luCode = new LuCode(); |
| 1096 | 101 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1097 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
| 1098 | |
luDao)); |
| 1099 | 101 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[] { |
| 1100 | |
"attributes", "metaInfo" }); |
| 1101 | 101 | luCode.setDescr(luCodeInfo.getDescr()); |
| 1102 | 101 | luCode.setClu(clu); |
| 1103 | 101 | luCodes.add(luCode); |
| 1104 | 101 | } |
| 1105 | |
|
| 1106 | 189 | if (clu.getOfferedAtpTypes() == null) { |
| 1107 | 189 | clu.setOfferedAtpTypes(new ArrayList<CluAtpTypeKey>(0)); |
| 1108 | |
} |
| 1109 | 189 | List<CluAtpTypeKey> offeredAtpTypes = clu.getOfferedAtpTypes(); |
| 1110 | 189 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
| 1111 | 137 | CluAtpTypeKey cluAtpTypeKey = new CluAtpTypeKey(); |
| 1112 | 137 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
| 1113 | 137 | cluAtpTypeKey.setClu(clu); |
| 1114 | 137 | offeredAtpTypes.add(cluAtpTypeKey); |
| 1115 | 137 | } |
| 1116 | |
|
| 1117 | |
|
| 1118 | 189 | if (cluInfo.getFeeInfo() != null) { |
| 1119 | 26 | CluFee cluFee = null; |
| 1120 | |
try { |
| 1121 | 26 | cluFee = LuServiceAssembler.toCluFee(clu, false, cluInfo |
| 1122 | |
.getFeeInfo(), luDao); |
| 1123 | 0 | } catch (VersionMismatchException e) { |
| 1124 | |
|
| 1125 | 26 | } |
| 1126 | 26 | clu.setFee(cluFee); |
| 1127 | |
} |
| 1128 | |
|
| 1129 | 189 | if (cluInfo.getAccountingInfo() != null) { |
| 1130 | 26 | CluAccounting cluAccounting = new CluAccounting(); |
| 1131 | 26 | cluAccounting.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1132 | |
CluAccountingAttribute.class, cluInfo.getAccountingInfo() |
| 1133 | |
.getAttributes(), cluAccounting, luDao)); |
| 1134 | 26 | cluAccounting.setAffiliatedOrgs(LuServiceAssembler |
| 1135 | |
.toAffiliatedOrgs(false, cluAccounting.getAffiliatedOrgs(), |
| 1136 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
| 1137 | |
luDao)); |
| 1138 | 26 | clu.setAccounting(cluAccounting); |
| 1139 | |
} |
| 1140 | |
|
| 1141 | 189 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1142 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
| 1143 | |
|
| 1144 | |
|
| 1145 | 189 | if (cluInfo.getIntensity() != null) { |
| 1146 | 126 | clu.setIntensity(LuServiceAssembler |
| 1147 | |
.toAmount(cluInfo.getIntensity())); |
| 1148 | |
} |
| 1149 | |
|
| 1150 | 189 | if (clu.getCampusLocations() == null) { |
| 1151 | 189 | clu.setCampusLocations(new ArrayList<CluCampusLocation>(0)); |
| 1152 | |
} |
| 1153 | 189 | List<CluCampusLocation> locations = clu.getCampusLocations(); |
| 1154 | 189 | for (String locationName : cluInfo.getCampusLocations()) { |
| 1155 | 84 | CluCampusLocation location = new CluCampusLocation(); |
| 1156 | 84 | location.setCampusLocation(locationName); |
| 1157 | 84 | location.setClu(clu); |
| 1158 | 84 | locations.add(location); |
| 1159 | 84 | } |
| 1160 | |
|
| 1161 | 189 | if (clu.getAccreditations() == null) { |
| 1162 | 189 | clu.setAccreditations(new ArrayList<CluAccreditation>(0)); |
| 1163 | |
} |
| 1164 | 189 | List<CluAccreditation> accreditations = clu.getAccreditations(); |
| 1165 | 189 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
| 1166 | 18 | CluAccreditation accreditation = new CluAccreditation(); |
| 1167 | 18 | BeanUtils.copyProperties(accreditationInfo, accreditation, |
| 1168 | |
new String[] { "attributes" }); |
| 1169 | 18 | accreditation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1170 | |
CluAccreditationAttribute.class, accreditationInfo |
| 1171 | |
.getAttributes(), accreditation, luDao)); |
| 1172 | 18 | accreditations.add(accreditation); |
| 1173 | 18 | } |
| 1174 | |
|
| 1175 | |
|
| 1176 | 189 | BeanUtils.copyProperties(cluInfo, clu, new String[] { "luType", |
| 1177 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
| 1178 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
| 1179 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
| 1180 | |
"metaInfo", "versionInfo", "intensity", |
| 1181 | |
"campusLocations", "accreditations", |
| 1182 | |
"adminOrgs" }); |
| 1183 | |
|
| 1184 | 189 | return clu; |
| 1185 | |
} |
| 1186 | |
|
| 1187 | |
@Override |
| 1188 | |
@Transactional(readOnly=false) |
| 1189 | |
public CluInfo updateClu(String cluId, CluInfo cluInfo) |
| 1190 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1191 | |
InvalidParameterException, MissingParameterException, |
| 1192 | |
OperationFailedException, PermissionDeniedException, |
| 1193 | |
VersionMismatchException { |
| 1194 | |
|
| 1195 | 50 | checkForMissingParameter(cluId, "cluId"); |
| 1196 | 50 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 1197 | |
|
| 1198 | |
|
| 1199 | 50 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo); |
| 1200 | 50 | if(null != val && val.size() > 0) { |
| 1201 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1202 | |
} |
| 1203 | |
|
| 1204 | 50 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 1205 | |
|
| 1206 | 50 | if (!String.valueOf(clu.getVersionNumber()).equals( |
| 1207 | |
cluInfo.getMetaInfo().getVersionInd())) { |
| 1208 | 2 | throw new VersionMismatchException( |
| 1209 | |
"Clu to be updated is not the current version"); |
| 1210 | |
} |
| 1211 | |
|
| 1212 | 48 | LuType luType = luDao.fetch(LuType.class, cluInfo.getType()); |
| 1213 | 48 | clu.setLuType(luType); |
| 1214 | |
|
| 1215 | 48 | if (cluInfo.getOfficialIdentifier() != null) { |
| 1216 | 46 | LuServiceAssembler.updateOfficialIdentifier(clu, cluInfo, luDao); |
| 1217 | 2 | } else if (clu.getOfficialIdentifier() != null) { |
| 1218 | 0 | luDao.delete(clu.getOfficialIdentifier()); |
| 1219 | |
} |
| 1220 | |
|
| 1221 | |
|
| 1222 | |
|
| 1223 | |
|
| 1224 | 48 | Map<String, CluIdentifier> oldAltIdMap = new HashMap<String, CluIdentifier>(); |
| 1225 | 48 | LuServiceAssembler.updateAlternateIdentifier(oldAltIdMap, clu, cluInfo, luDao); |
| 1226 | |
|
| 1227 | 48 | for (Entry<String, CluIdentifier> entry : oldAltIdMap.entrySet()) { |
| 1228 | 1 | luDao.delete(entry.getValue()); |
| 1229 | |
} |
| 1230 | |
|
| 1231 | 48 | if (cluInfo.getDescr() != null && (cluInfo.getDescr().getPlain() != null || cluInfo.getDescr().getFormatted() != null)) { |
| 1232 | 46 | if (clu.getDescr() == null) { |
| 1233 | 0 | clu.setDescr(new LuRichText()); |
| 1234 | |
} |
| 1235 | 46 | BeanUtils.copyProperties(cluInfo.getDescr(), clu.getDescr()); |
| 1236 | 2 | } else if (clu.getDescr() != null) { |
| 1237 | 0 | luDao.delete(clu.getDescr()); |
| 1238 | 0 | clu.setDescr(null); |
| 1239 | |
} |
| 1240 | |
|
| 1241 | 48 | if (cluInfo.getPrimaryInstructor() != null) { |
| 1242 | 36 | if (clu.getPrimaryInstructor() == null) { |
| 1243 | 0 | clu.setPrimaryInstructor(new CluInstructor()); |
| 1244 | |
} |
| 1245 | 36 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), clu |
| 1246 | |
.getPrimaryInstructor(), new String[] { "attributes" }); |
| 1247 | 36 | clu.getPrimaryInstructor().setAttributes( |
| 1248 | |
LuServiceAssembler.toGenericAttributes( |
| 1249 | |
CluInstructorAttribute.class, cluInfo |
| 1250 | |
.getPrimaryInstructor().getAttributes(), |
| 1251 | |
clu.getPrimaryInstructor(), luDao)); |
| 1252 | 12 | } else if (clu.getPrimaryInstructor() != null) { |
| 1253 | 0 | luDao.delete(clu.getPrimaryInstructor()); |
| 1254 | |
} |
| 1255 | |
|
| 1256 | |
|
| 1257 | |
|
| 1258 | |
|
| 1259 | 48 | Map<String, CluInstructor> oldInstructorMap = new HashMap<String, CluInstructor>(); |
| 1260 | 48 | for (CluInstructor cluInstructor : clu.getInstructors()) { |
| 1261 | 30 | oldInstructorMap.put(cluInstructor.getOrgId() + "_" |
| 1262 | |
+ cluInstructor.getPersonId(), cluInstructor); |
| 1263 | |
} |
| 1264 | 48 | clu.getInstructors().clear(); |
| 1265 | |
|
| 1266 | |
|
| 1267 | |
|
| 1268 | |
|
| 1269 | 48 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
| 1270 | 30 | CluInstructor cluInstructor = oldInstructorMap |
| 1271 | |
.remove(instructorInfo.getOrgId() + "_" |
| 1272 | |
+ instructorInfo.getPersonId()); |
| 1273 | 30 | if (cluInstructor == null) { |
| 1274 | 3 | cluInstructor = new CluInstructor(); |
| 1275 | |
} |
| 1276 | |
|
| 1277 | 30 | BeanUtils.copyProperties(instructorInfo, cluInstructor, |
| 1278 | |
new String[] { "attributes" }); |
| 1279 | 30 | cluInstructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1280 | |
CluInstructorAttribute.class, instructorInfo |
| 1281 | |
.getAttributes(), cluInstructor, luDao)); |
| 1282 | 30 | clu.getInstructors().add(cluInstructor); |
| 1283 | 30 | } |
| 1284 | |
|
| 1285 | |
|
| 1286 | 48 | for (Entry<String, CluInstructor> entry : oldInstructorMap.entrySet()) { |
| 1287 | 1 | luDao.delete(entry.getValue()); |
| 1288 | |
} |
| 1289 | |
|
| 1290 | 48 | if (cluInfo.getStdDuration() != null) { |
| 1291 | 37 | if (clu.getStdDuration() == null) { |
| 1292 | 0 | clu.setStdDuration(new TimeAmount()); |
| 1293 | |
} |
| 1294 | 37 | BeanUtils.copyProperties(cluInfo.getStdDuration(), clu |
| 1295 | |
.getStdDuration()); |
| 1296 | 11 | } else if (clu.getStdDuration() != null) { |
| 1297 | 0 | luDao.delete(clu.getStdDuration()); |
| 1298 | |
} |
| 1299 | |
|
| 1300 | |
|
| 1301 | |
|
| 1302 | |
|
| 1303 | 48 | Map<String, LuCode> oldLuCodeMap = new HashMap<String, LuCode>(); |
| 1304 | 48 | for (LuCode luCode : clu.getLuCodes()) { |
| 1305 | 138 | oldLuCodeMap.put(luCode.getId(), luCode); |
| 1306 | |
} |
| 1307 | 48 | clu.getLuCodes().clear(); |
| 1308 | |
|
| 1309 | |
|
| 1310 | |
|
| 1311 | |
|
| 1312 | 48 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
| 1313 | 136 | LuCode luCode = oldLuCodeMap.remove(luCodeInfo.getId()); |
| 1314 | 136 | if (luCode == null) { |
| 1315 | 135 | luCode = new LuCode(); |
| 1316 | |
} else { |
| 1317 | 1 | if (!String.valueOf(luCode.getVersionNumber()).equals( |
| 1318 | |
luCodeInfo.getMetaInfo().getVersionInd())) { |
| 1319 | 0 | throw new VersionMismatchException( |
| 1320 | |
"LuCode to be updated is not the current version"); |
| 1321 | |
} |
| 1322 | |
} |
| 1323 | |
|
| 1324 | 136 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1325 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
| 1326 | |
luDao)); |
| 1327 | 136 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[] { |
| 1328 | |
"attributes", "metaInfo" }); |
| 1329 | 136 | luCode.setDescr(luCodeInfo.getDescr()); |
| 1330 | 136 | luCode.setClu(clu); |
| 1331 | 136 | clu.getLuCodes().add(luCode); |
| 1332 | 136 | } |
| 1333 | |
|
| 1334 | |
|
| 1335 | 48 | for (Entry<String, LuCode> entry : oldLuCodeMap.entrySet()) { |
| 1336 | 137 | luDao.delete(entry.getValue()); |
| 1337 | |
} |
| 1338 | |
|
| 1339 | |
|
| 1340 | |
|
| 1341 | |
|
| 1342 | 48 | Map<String, CluAtpTypeKey> oldOfferedAtpTypesMap = new HashMap<String, CluAtpTypeKey>(); |
| 1343 | 48 | for (CluAtpTypeKey cluAtpTypeKey : clu.getOfferedAtpTypes()) { |
| 1344 | 22 | oldOfferedAtpTypesMap.put(cluAtpTypeKey.getAtpTypeKey(), |
| 1345 | |
cluAtpTypeKey); |
| 1346 | |
} |
| 1347 | 48 | clu.getOfferedAtpTypes().clear(); |
| 1348 | |
|
| 1349 | |
|
| 1350 | |
|
| 1351 | |
|
| 1352 | 48 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
| 1353 | 22 | CluAtpTypeKey cluAtpTypeKey = oldOfferedAtpTypesMap |
| 1354 | |
.remove(atpTypeKey); |
| 1355 | 22 | if (cluAtpTypeKey == null) { |
| 1356 | 1 | cluAtpTypeKey = new CluAtpTypeKey(); |
| 1357 | |
} |
| 1358 | |
|
| 1359 | 22 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
| 1360 | 22 | cluAtpTypeKey.setClu(clu); |
| 1361 | 22 | clu.getOfferedAtpTypes().add(cluAtpTypeKey); |
| 1362 | 22 | } |
| 1363 | |
|
| 1364 | |
|
| 1365 | 48 | for (Entry<String, CluAtpTypeKey> entry : oldOfferedAtpTypesMap |
| 1366 | |
.entrySet()) { |
| 1367 | 1 | luDao.delete(entry.getValue()); |
| 1368 | |
} |
| 1369 | |
|
| 1370 | 48 | if (cluInfo.getFeeInfo() != null) { |
| 1371 | 10 | if (clu.getFee() == null) { |
| 1372 | 0 | clu.setFee(LuServiceAssembler.toCluFee(clu, false, cluInfo |
| 1373 | |
.getFeeInfo(), luDao)); |
| 1374 | |
} else { |
| 1375 | 10 | clu.setFee(LuServiceAssembler.toCluFee(clu, true, cluInfo |
| 1376 | |
.getFeeInfo(), luDao)); |
| 1377 | |
} |
| 1378 | 38 | } else if (clu.getFee() != null) { |
| 1379 | 0 | luDao.delete(clu.getFee()); |
| 1380 | 0 | clu.setFee(null); |
| 1381 | |
} |
| 1382 | |
|
| 1383 | 48 | if (cluInfo.getAccountingInfo() != null) { |
| 1384 | 10 | if (clu.getAccounting() == null) { |
| 1385 | 0 | clu.setAccounting(new CluAccounting()); |
| 1386 | |
} |
| 1387 | 10 | clu.getAccounting().setAttributes( |
| 1388 | |
LuServiceAssembler.toGenericAttributes( |
| 1389 | |
CluAccountingAttribute.class, cluInfo |
| 1390 | |
.getAccountingInfo().getAttributes(), clu |
| 1391 | |
.getAccounting(), luDao)); |
| 1392 | 10 | clu.getAccounting().setAffiliatedOrgs(LuServiceAssembler |
| 1393 | |
.toAffiliatedOrgs(true, clu.getAccounting().getAffiliatedOrgs(), |
| 1394 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
| 1395 | |
luDao)); |
| 1396 | |
|
| 1397 | 38 | } else if (clu.getAccounting() != null) { |
| 1398 | 0 | clu.setAccounting(null); |
| 1399 | |
} |
| 1400 | |
|
| 1401 | 48 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1402 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
| 1403 | |
|
| 1404 | 48 | if (cluInfo.getIntensity() != null) { |
| 1405 | 36 | if (clu.getIntensity() == null) { |
| 1406 | 0 | clu.setIntensity(new Amount()); |
| 1407 | |
} |
| 1408 | 36 | BeanUtils |
| 1409 | |
.copyProperties(cluInfo.getIntensity(), clu.getIntensity()); |
| 1410 | 12 | } else if (clu.getIntensity() != null) { |
| 1411 | 0 | luDao.delete(clu.getIntensity()); |
| 1412 | |
} |
| 1413 | |
|
| 1414 | |
|
| 1415 | |
|
| 1416 | |
|
| 1417 | 48 | Map<String, CluCampusLocation> oldLocationsMap = new HashMap<String, CluCampusLocation>(); |
| 1418 | 48 | for (CluCampusLocation campus : clu.getCampusLocations()) { |
| 1419 | 75 | oldLocationsMap.put(campus.getCampusLocation(), campus); |
| 1420 | |
} |
| 1421 | 48 | clu.getCampusLocations().clear(); |
| 1422 | |
|
| 1423 | |
|
| 1424 | |
|
| 1425 | |
|
| 1426 | 48 | for (String locationName : cluInfo.getCampusLocations()) { |
| 1427 | 77 | CluCampusLocation location = oldLocationsMap.remove(locationName); |
| 1428 | 77 | if (location == null) { |
| 1429 | 4 | location = new CluCampusLocation(); |
| 1430 | |
} |
| 1431 | |
|
| 1432 | 77 | location.setCampusLocation(locationName); |
| 1433 | 77 | location.setClu(clu); |
| 1434 | 77 | clu.getCampusLocations().add(location); |
| 1435 | 77 | } |
| 1436 | |
|
| 1437 | |
|
| 1438 | 48 | for (Entry<String, CluCampusLocation> entry : oldLocationsMap |
| 1439 | |
.entrySet()) { |
| 1440 | 2 | luDao.delete(entry.getValue()); |
| 1441 | |
} |
| 1442 | |
|
| 1443 | |
|
| 1444 | |
|
| 1445 | |
|
| 1446 | 48 | Map<String, CluAccreditation> oldAccreditationMap = new HashMap<String, CluAccreditation>(); |
| 1447 | 48 | for (CluAccreditation cluAccreditation : clu.getAccreditations()) { |
| 1448 | 12 | oldAccreditationMap.put(cluAccreditation.getId(), |
| 1449 | |
cluAccreditation); |
| 1450 | |
} |
| 1451 | 48 | clu.getAccreditations().clear(); |
| 1452 | |
|
| 1453 | |
|
| 1454 | |
|
| 1455 | |
|
| 1456 | 48 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
| 1457 | 13 | CluAccreditation cluAccreditation = null; |
| 1458 | 13 | if(accreditationInfo.getId()!=null){ |
| 1459 | 11 | cluAccreditation = oldAccreditationMap.remove(accreditationInfo.getId()); |
| 1460 | |
} |
| 1461 | |
|
| 1462 | 13 | if (cluAccreditation == null) { |
| 1463 | 2 | cluAccreditation = new CluAccreditation(); |
| 1464 | |
} |
| 1465 | |
|
| 1466 | 13 | BeanUtils.copyProperties(accreditationInfo, cluAccreditation, |
| 1467 | |
new String[] { "attributes" }); |
| 1468 | 13 | cluAccreditation.setAttributes(LuServiceAssembler |
| 1469 | |
.toGenericAttributes(CluAccreditationAttribute.class, |
| 1470 | |
accreditationInfo.getAttributes(), |
| 1471 | |
cluAccreditation, luDao)); |
| 1472 | 13 | clu.getAccreditations().add(cluAccreditation); |
| 1473 | 13 | } |
| 1474 | |
|
| 1475 | |
|
| 1476 | 48 | for (Entry<String, CluAccreditation> entry : oldAccreditationMap |
| 1477 | |
.entrySet()) { |
| 1478 | 1 | luDao.delete(entry.getValue()); |
| 1479 | |
} |
| 1480 | |
|
| 1481 | |
|
| 1482 | |
|
| 1483 | |
|
| 1484 | 48 | Map<String, CluAdminOrg> oldAdminOrgsMap = new HashMap<String, CluAdminOrg>(); |
| 1485 | 48 | if(clu.getAdminOrgs()!=null){ |
| 1486 | 48 | for (CluAdminOrg cluOrg : clu.getAdminOrgs()) { |
| 1487 | 413 | oldAdminOrgsMap.put(cluOrg.getId(), cluOrg); |
| 1488 | |
} |
| 1489 | |
} |
| 1490 | 48 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>()); |
| 1491 | |
|
| 1492 | |
|
| 1493 | |
|
| 1494 | |
|
| 1495 | 48 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
| 1496 | 412 | CluAdminOrg cluOrg = null; |
| 1497 | 412 | if(orgInfo.getId() != null){ |
| 1498 | 2 | cluOrg = oldAdminOrgsMap.remove(orgInfo.getId()); |
| 1499 | |
} |
| 1500 | |
|
| 1501 | 412 | if (cluOrg == null) { |
| 1502 | 410 | cluOrg = new CluAdminOrg(); |
| 1503 | |
} |
| 1504 | |
|
| 1505 | |
|
| 1506 | 412 | BeanUtils.copyProperties(orgInfo, cluOrg, |
| 1507 | |
new String[] { "attributes","id" }); |
| 1508 | 412 | cluOrg.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1509 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
| 1510 | |
cluOrg, luDao)); |
| 1511 | 412 | cluOrg.setClu(clu); |
| 1512 | 412 | clu.getAdminOrgs().add(cluOrg); |
| 1513 | 412 | } |
| 1514 | |
|
| 1515 | 48 | for (Entry<String, CluAdminOrg> entry : oldAdminOrgsMap.entrySet()) { |
| 1516 | 411 | luDao.delete(entry.getValue()); |
| 1517 | |
} |
| 1518 | |
|
| 1519 | |
|
| 1520 | 48 | BeanUtils.copyProperties(cluInfo, clu, new String[] { "luType", |
| 1521 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
| 1522 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
| 1523 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
| 1524 | |
"metaInfo","intensity", |
| 1525 | |
"campusLocations", "accreditations", |
| 1526 | |
"adminOrgs" }); |
| 1527 | 48 | Clu updated = null; |
| 1528 | |
try { |
| 1529 | 48 | updated = luDao.update(clu); |
| 1530 | 0 | } catch (Exception e) { |
| 1531 | 0 | logger.error("Exception occured: ", e); |
| 1532 | 48 | } |
| 1533 | 48 | return LuServiceAssembler.toCluInfo(updated); |
| 1534 | |
} |
| 1535 | |
|
| 1536 | |
@Override |
| 1537 | |
@Transactional(readOnly=false) |
| 1538 | |
public StatusInfo deleteClu(String cluId) throws DoesNotExistException, |
| 1539 | |
InvalidParameterException, MissingParameterException, |
| 1540 | |
DependentObjectsExistException, OperationFailedException, |
| 1541 | |
PermissionDeniedException { |
| 1542 | 14 | checkForMissingParameter(cluId, "cluId"); |
| 1543 | |
|
| 1544 | 14 | luDao.delete(Clu.class, cluId); |
| 1545 | |
|
| 1546 | 14 | StatusInfo statusInfo = new StatusInfo(); |
| 1547 | 14 | statusInfo.setSuccess(true); |
| 1548 | |
|
| 1549 | 14 | return statusInfo; |
| 1550 | |
} |
| 1551 | |
|
| 1552 | |
@Override |
| 1553 | |
@Transactional(readOnly=false) |
| 1554 | |
public CluInfo updateCluState(String cluId, String luState) |
| 1555 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1556 | |
InvalidParameterException, MissingParameterException, |
| 1557 | |
OperationFailedException, PermissionDeniedException { |
| 1558 | |
|
| 1559 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1560 | 0 | checkForMissingParameter(luState, "luState"); |
| 1561 | 0 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 1562 | 0 | clu.setState(luState); |
| 1563 | 0 | Clu updated = luDao.update(clu); |
| 1564 | 0 | return LuServiceAssembler.toCluInfo(updated); |
| 1565 | |
} |
| 1566 | |
|
| 1567 | |
@Override |
| 1568 | |
public List<ValidationResultInfo> validateCluCluRelation( |
| 1569 | |
String validationType, CluCluRelationInfo cluCluRelationInfo) |
| 1570 | |
throws DoesNotExistException, InvalidParameterException, |
| 1571 | |
MissingParameterException, OperationFailedException { |
| 1572 | 184 | checkForMissingParameter(validationType, "validationType"); |
| 1573 | 184 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1574 | |
|
| 1575 | 184 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluCluRelationInfo.class.getName()); |
| 1576 | 184 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1577 | 184 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluCluRelationInfo, objStructure); |
| 1578 | |
|
| 1579 | 184 | return validationResults; |
| 1580 | |
} |
| 1581 | |
|
| 1582 | |
@Override |
| 1583 | |
@Transactional(readOnly=false) |
| 1584 | |
public CluCluRelationInfo createCluCluRelation(String cluId, |
| 1585 | |
String relatedCluId, String luLuRelationTypeKey, |
| 1586 | |
CluCluRelationInfo cluCluRelationInfo) |
| 1587 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1588 | |
DoesNotExistException, InvalidParameterException, |
| 1589 | |
MissingParameterException, OperationFailedException, |
| 1590 | |
PermissionDeniedException, CircularRelationshipException { |
| 1591 | 182 | checkForMissingParameter(cluId, "cluId"); |
| 1592 | 182 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 1593 | 182 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 1594 | 182 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1595 | |
|
| 1596 | 182 | if (cluId.equals(relatedCluId)) { |
| 1597 | 0 | throw new CircularRelationshipException( |
| 1598 | |
"Can not relate a Clu to itself"); |
| 1599 | |
} |
| 1600 | |
|
| 1601 | |
|
| 1602 | 182 | List<ValidationResultInfo> val = validateCluCluRelation("SYSTEM", cluCluRelationInfo); |
| 1603 | 182 | if(null != val && val.size() > 0) { |
| 1604 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1605 | |
} |
| 1606 | |
|
| 1607 | |
|
| 1608 | 182 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 1609 | 182 | Clu relatedClu = luDao.fetch(Clu.class, relatedCluId); |
| 1610 | |
|
| 1611 | 182 | CluCluRelation cluCluRelation = new CluCluRelation(); |
| 1612 | 182 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
| 1613 | |
new String[] { "cluId", "relatedCluId", |
| 1614 | |
"isCluRelationRequired", "attributes", "metaInfo" }); |
| 1615 | |
|
| 1616 | 182 | cluCluRelation.setClu(clu); |
| 1617 | 182 | cluCluRelation.setRelatedClu(relatedClu); |
| 1618 | 182 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo |
| 1619 | |
.getIsCluRelationRequired() == null ? true : cluCluRelationInfo |
| 1620 | |
.getIsCluRelationRequired()); |
| 1621 | |
|
| 1622 | 182 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1623 | |
CluCluRelationAttribute.class, cluCluRelationInfo |
| 1624 | |
.getAttributes(), cluCluRelation, luDao)); |
| 1625 | |
|
| 1626 | 182 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
| 1627 | |
luLuRelationTypeKey); |
| 1628 | |
|
| 1629 | 182 | cluCluRelation.setLuLuRelationType(luLuRelationType); |
| 1630 | |
|
| 1631 | 182 | luDao.create(cluCluRelation); |
| 1632 | |
|
| 1633 | 182 | return LuServiceAssembler.toCluCluRelationInfo(cluCluRelation); |
| 1634 | |
} |
| 1635 | |
|
| 1636 | |
@Override |
| 1637 | |
@Transactional(readOnly=false) |
| 1638 | |
public CluCluRelationInfo updateCluCluRelation( |
| 1639 | |
final String cluCluRelationId, |
| 1640 | |
final CluCluRelationInfo cluCluRelationInfo) |
| 1641 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1642 | |
InvalidParameterException, MissingParameterException, |
| 1643 | |
OperationFailedException, PermissionDeniedException, |
| 1644 | |
VersionMismatchException { |
| 1645 | 2 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 1646 | 2 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1647 | |
|
| 1648 | |
|
| 1649 | 2 | List<ValidationResultInfo> val = validateCluCluRelation("SYSTEM", cluCluRelationInfo); |
| 1650 | 2 | if(null != val && val.size() > 0) { |
| 1651 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1652 | |
} |
| 1653 | |
|
| 1654 | 2 | final CluCluRelation cluCluRelation = luDao.fetch(CluCluRelation.class, |
| 1655 | |
cluCluRelationId); |
| 1656 | 2 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
| 1657 | |
new String[] { "cluId", "relatedCluId", |
| 1658 | |
"isCluRelationRequired", "attributes", "metaInfo" }); |
| 1659 | |
|
| 1660 | 2 | cluCluRelation.setClu(luDao.fetch(Clu.class, cluCluRelationInfo |
| 1661 | |
.getCluId())); |
| 1662 | 2 | cluCluRelation.setRelatedClu(luDao.fetch(Clu.class, cluCluRelationInfo |
| 1663 | |
.getRelatedCluId())); |
| 1664 | 2 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo |
| 1665 | |
.getIsCluRelationRequired() == null ? true : cluCluRelationInfo |
| 1666 | |
.getIsCluRelationRequired()); |
| 1667 | |
|
| 1668 | 2 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1669 | |
CluCluRelationAttribute.class, cluCluRelationInfo |
| 1670 | |
.getAttributes(), cluCluRelation, luDao)); |
| 1671 | |
|
| 1672 | 2 | cluCluRelation.setLuLuRelationType(luDao.fetch(LuLuRelationType.class, |
| 1673 | |
cluCluRelationInfo.getType())); |
| 1674 | |
|
| 1675 | 2 | final CluCluRelation update = luDao.update(cluCluRelation); |
| 1676 | |
|
| 1677 | 2 | return LuServiceAssembler.toCluCluRelationInfo(update); |
| 1678 | |
} |
| 1679 | |
|
| 1680 | |
@Override |
| 1681 | |
@Transactional(readOnly=false) |
| 1682 | |
public StatusInfo deleteCluCluRelation(String cluCluRelationId) |
| 1683 | |
throws DoesNotExistException, InvalidParameterException, |
| 1684 | |
MissingParameterException, OperationFailedException, |
| 1685 | |
PermissionDeniedException { |
| 1686 | 20 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 1687 | |
|
| 1688 | 20 | luDao.delete(CluCluRelation.class, cluCluRelationId); |
| 1689 | |
|
| 1690 | 20 | StatusInfo statusInfo = new StatusInfo(); |
| 1691 | 20 | statusInfo.setSuccess(true); |
| 1692 | |
|
| 1693 | 20 | return statusInfo; |
| 1694 | |
} |
| 1695 | |
|
| 1696 | |
@Override |
| 1697 | |
public List<ValidationResultInfo> validateCluPublication( |
| 1698 | |
String validationType, CluPublicationInfo cluPublicationInfo) |
| 1699 | |
throws DoesNotExistException, InvalidParameterException, |
| 1700 | |
MissingParameterException, OperationFailedException { |
| 1701 | |
|
| 1702 | 79 | checkForMissingParameter(validationType, "validationType"); |
| 1703 | 79 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1704 | |
|
| 1705 | 79 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluPublicationInfo.class.getName()); |
| 1706 | 79 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1707 | 79 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluPublicationInfo, objStructure); |
| 1708 | 79 | return validationResults; |
| 1709 | |
} |
| 1710 | |
|
| 1711 | |
@Override |
| 1712 | |
@Transactional(readOnly=false) |
| 1713 | |
public CluPublicationInfo createCluPublication(String cluId, |
| 1714 | |
String luPublicationType, CluPublicationInfo cluPublicationInfo) |
| 1715 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1716 | |
InvalidParameterException, MissingParameterException, |
| 1717 | |
OperationFailedException, PermissionDeniedException { |
| 1718 | 58 | checkForMissingParameter(cluId, "cluId"); |
| 1719 | 58 | checkForMissingParameter(luPublicationType, "luPublicationType"); |
| 1720 | 58 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1721 | |
|
| 1722 | |
|
| 1723 | |
List<ValidationResultInfo> val; |
| 1724 | |
try { |
| 1725 | 58 | val = validateCluPublication("SYSTEM", cluPublicationInfo); |
| 1726 | 58 | if(null != val && val.size() > 0) { |
| 1727 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1728 | |
} |
| 1729 | 0 | } catch (DoesNotExistException e) { |
| 1730 | 0 | throw new OperationFailedException("Error creating clu",e); |
| 1731 | 58 | } |
| 1732 | |
|
| 1733 | |
|
| 1734 | 58 | CluPublication cluPub = new CluPublication(); |
| 1735 | |
Clu clu; |
| 1736 | |
try { |
| 1737 | 58 | clu = luDao.fetch(Clu.class, cluId); |
| 1738 | 0 | } catch (DoesNotExistException e) { |
| 1739 | 0 | throw new InvalidParameterException("Clu does not exist for id:"+cluId); |
| 1740 | 58 | } |
| 1741 | |
|
| 1742 | |
CluPublicationType type; |
| 1743 | |
try{ |
| 1744 | 58 | type = luDao.fetch(CluPublicationType.class, luPublicationType); |
| 1745 | 0 | } catch (DoesNotExistException e) { |
| 1746 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + luPublicationType); |
| 1747 | 58 | } |
| 1748 | |
|
| 1749 | 58 | cluPub.setClu(clu); |
| 1750 | 58 | cluPub.setId(cluPublicationInfo.getId()); |
| 1751 | 58 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
| 1752 | 58 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
| 1753 | 58 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
| 1754 | 58 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
| 1755 | 58 | cluPub.setState(cluPublicationInfo.getState()); |
| 1756 | 58 | cluPub.setType(type); |
| 1757 | 58 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
| 1758 | 58 | cluPub.setVariants(LuServiceAssembler.toCluPublicationVariants(cluPublicationInfo.getVariants(), cluPub, luDao)); |
| 1759 | |
|
| 1760 | 58 | luDao.create(cluPub); |
| 1761 | |
|
| 1762 | 58 | return LuServiceAssembler.toCluPublicationInfo(cluPub); |
| 1763 | |
} |
| 1764 | |
|
| 1765 | |
@Override |
| 1766 | |
@Transactional(readOnly=false) |
| 1767 | |
public CluPublicationInfo updateCluPublication(String cluPublicationId, |
| 1768 | |
CluPublicationInfo cluPublicationInfo) |
| 1769 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1770 | |
InvalidParameterException, MissingParameterException, |
| 1771 | |
OperationFailedException, PermissionDeniedException, |
| 1772 | |
VersionMismatchException { |
| 1773 | 21 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 1774 | 21 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1775 | |
|
| 1776 | |
|
| 1777 | |
List<ValidationResultInfo> val; |
| 1778 | |
try { |
| 1779 | 21 | val = validateCluPublication("SYSTEM", cluPublicationInfo); |
| 1780 | 21 | if(null != val && val.size() > 0) { |
| 1781 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1782 | |
} |
| 1783 | 0 | } catch (DoesNotExistException e) { |
| 1784 | 0 | throw new OperationFailedException("Error creating clu",e); |
| 1785 | 21 | } |
| 1786 | |
|
| 1787 | 21 | CluPublication cluPub = luDao.fetch(CluPublication.class, cluPublicationId); |
| 1788 | |
|
| 1789 | 21 | if (!String.valueOf(cluPub.getVersionNumber()).equals( |
| 1790 | |
cluPublicationInfo.getMetaInfo().getVersionInd())) { |
| 1791 | 1 | throw new VersionMismatchException( |
| 1792 | |
"CluPublication to be updated is not the current version"); |
| 1793 | |
} |
| 1794 | |
|
| 1795 | |
Clu clu; |
| 1796 | |
try { |
| 1797 | 20 | clu = luDao.fetch(Clu.class, cluPublicationInfo.getCluId()); |
| 1798 | 0 | } catch (DoesNotExistException e) { |
| 1799 | 0 | throw new InvalidParameterException("Clu does not exist for id:"+cluPublicationInfo.getCluId()); |
| 1800 | 20 | } |
| 1801 | |
|
| 1802 | |
CluPublicationType type; |
| 1803 | |
try{ |
| 1804 | 20 | type = luDao.fetch(CluPublicationType.class, cluPublicationInfo.getType()); |
| 1805 | 0 | } catch (DoesNotExistException e) { |
| 1806 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + cluPublicationInfo.getType()); |
| 1807 | 20 | } |
| 1808 | |
|
| 1809 | |
|
| 1810 | |
|
| 1811 | |
|
| 1812 | 20 | Map<String, CluPublicationVariant> oldVariantMap = new HashMap<String, CluPublicationVariant>(); |
| 1813 | 20 | for (CluPublicationVariant variant : cluPub.getVariants()) { |
| 1814 | 21 | oldVariantMap.put(variant.getKey(), variant); |
| 1815 | |
} |
| 1816 | 20 | cluPub.getVariants().clear(); |
| 1817 | |
|
| 1818 | |
|
| 1819 | |
|
| 1820 | 20 | CluPublicationVariant variant = null; |
| 1821 | 20 | for (FieldInfo fieldInfo : cluPublicationInfo.getVariants()) { |
| 1822 | 21 | if (!oldVariantMap.containsKey(fieldInfo.getId())) { |
| 1823 | |
|
| 1824 | 2 | variant = new CluPublicationVariant(); |
| 1825 | 2 | variant.setKey(fieldInfo.getId()); |
| 1826 | 2 | variant.setValue(fieldInfo.getValue()); |
| 1827 | |
} else { |
| 1828 | |
|
| 1829 | 19 | variant = oldVariantMap.get(fieldInfo.getId()); |
| 1830 | 19 | variant.setValue(fieldInfo.getValue()); |
| 1831 | 19 | oldVariantMap.remove(fieldInfo.getId()); |
| 1832 | |
} |
| 1833 | |
|
| 1834 | 21 | cluPub.getVariants().add(variant); |
| 1835 | |
} |
| 1836 | |
|
| 1837 | |
|
| 1838 | 20 | for (Entry<String, CluPublicationVariant> entry : oldVariantMap.entrySet()) { |
| 1839 | 2 | luDao.delete(entry.getValue()); |
| 1840 | |
} |
| 1841 | |
|
| 1842 | 20 | cluPub.setClu(clu); |
| 1843 | 20 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
| 1844 | 20 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
| 1845 | 20 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
| 1846 | 20 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
| 1847 | 20 | cluPub.setState(cluPublicationInfo.getState()); |
| 1848 | 20 | cluPub.setType(type); |
| 1849 | 20 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
| 1850 | |
|
| 1851 | 20 | CluPublication updated = luDao.update(cluPub); |
| 1852 | |
|
| 1853 | 20 | return LuServiceAssembler.toCluPublicationInfo(updated); |
| 1854 | |
} |
| 1855 | |
|
| 1856 | |
@Override |
| 1857 | |
@Transactional(readOnly=false) |
| 1858 | |
public StatusInfo deleteCluPublication(String cluPublicationId) |
| 1859 | |
throws DoesNotExistException, InvalidParameterException, |
| 1860 | |
MissingParameterException, DependentObjectsExistException, |
| 1861 | |
OperationFailedException, PermissionDeniedException { |
| 1862 | 0 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 1863 | |
|
| 1864 | 0 | luDao.delete(CluPublication.class, cluPublicationId); |
| 1865 | |
|
| 1866 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 1867 | 0 | statusInfo.setSuccess(true); |
| 1868 | |
|
| 1869 | 0 | return statusInfo; } |
| 1870 | |
|
| 1871 | |
@Override |
| 1872 | |
public List<ValidationResultInfo> validateCluResult(String validationType, |
| 1873 | |
CluResultInfo cluResultInfo) throws DoesNotExistException, |
| 1874 | |
InvalidParameterException, MissingParameterException, |
| 1875 | |
OperationFailedException { |
| 1876 | 110 | checkForMissingParameter(validationType, "validationType"); |
| 1877 | 110 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1878 | |
|
| 1879 | 110 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluResultInfo.class.getName()); |
| 1880 | 110 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1881 | 110 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluResultInfo, objStructure); |
| 1882 | 110 | return validationResults; |
| 1883 | |
} |
| 1884 | |
|
| 1885 | |
@Override |
| 1886 | |
@Transactional(readOnly=false) |
| 1887 | |
public CluResultInfo createCluResult(String cluId, String cluResultTypeKey, |
| 1888 | |
CluResultInfo cluResultInfo) throws AlreadyExistsException, |
| 1889 | |
DataValidationErrorException, InvalidParameterException, |
| 1890 | |
MissingParameterException, OperationFailedException, |
| 1891 | |
PermissionDeniedException, DoesNotExistException { |
| 1892 | |
|
| 1893 | 89 | checkForMissingParameter(cluId, "cluId"); |
| 1894 | 89 | checkForMissingParameter(cluResultTypeKey, "cluResultTypeKey"); |
| 1895 | 89 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1896 | |
|
| 1897 | |
|
| 1898 | 89 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", cluResultInfo); |
| 1899 | 89 | if(null != val && val.size() > 0) { |
| 1900 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1901 | |
} |
| 1902 | |
|
| 1903 | 89 | cluResultInfo.setType(cluResultTypeKey); |
| 1904 | 89 | cluResultInfo.setCluId(cluId); |
| 1905 | |
|
| 1906 | 89 | List<ResultOption> resOptList = new ArrayList<ResultOption>(); |
| 1907 | 89 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
| 1908 | 125 | ResultOption resOpt = new ResultOption(); |
| 1909 | 125 | BeanUtils.copyProperties(resOptInfo, resOpt, new String[] { "id", |
| 1910 | |
"metaInfo", "resultUsageType", "desc" }); |
| 1911 | |
|
| 1912 | 125 | if(resOptInfo.getResultUsageTypeKey() != null) { |
| 1913 | 0 | ResultUsageType resUsageType = luDao.fetch(ResultUsageType.class, |
| 1914 | |
resOptInfo.getResultUsageTypeKey()); |
| 1915 | 0 | resOpt.setResultUsageType(resUsageType); |
| 1916 | |
} |
| 1917 | 125 | resOpt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDesc())); |
| 1918 | 125 | luDao.create(resOpt); |
| 1919 | 125 | resOptList.add(resOpt); |
| 1920 | 125 | } |
| 1921 | |
|
| 1922 | 89 | CluResult cluResult = new CluResult(); |
| 1923 | 89 | BeanUtils.copyProperties(cluResultInfo, cluResult, new String[] { "id", |
| 1924 | |
"desc", "resultOptions", "metaInfo" }); |
| 1925 | |
|
| 1926 | 89 | cluResult.setDesc(LuServiceAssembler |
| 1927 | |
.toRichText(LuRichText.class, cluResultInfo.getDesc())); |
| 1928 | 89 | cluResult.setResultOptions(resOptList); |
| 1929 | |
|
| 1930 | 89 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 1931 | 89 | cluResult.setClu(clu); |
| 1932 | |
|
| 1933 | 89 | CluResultType type = luDao.fetch(CluResultType.class, cluResultTypeKey); |
| 1934 | 89 | cluResult.setCluResultType(type); |
| 1935 | |
|
| 1936 | 89 | luDao.create(cluResult); |
| 1937 | |
|
| 1938 | 89 | return LuServiceAssembler.toCluResultInfo(cluResult); |
| 1939 | |
} |
| 1940 | |
|
| 1941 | |
@Override |
| 1942 | |
@Transactional(readOnly=false) |
| 1943 | |
public CluResultInfo updateCluResult(String cluResultId, |
| 1944 | |
CluResultInfo cluResultInfo) throws DataValidationErrorException, |
| 1945 | |
DoesNotExistException, InvalidParameterException, |
| 1946 | |
MissingParameterException, OperationFailedException, |
| 1947 | |
PermissionDeniedException, VersionMismatchException { |
| 1948 | |
|
| 1949 | 21 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 1950 | 21 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1951 | |
|
| 1952 | |
|
| 1953 | 21 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", cluResultInfo); |
| 1954 | 21 | if(null != val && val.size() > 0) { |
| 1955 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1956 | |
} |
| 1957 | |
|
| 1958 | 21 | CluResult result = luDao.fetch(CluResult.class, cluResultId); |
| 1959 | 21 | if (!String.valueOf(result.getVersionNumber()).equals( |
| 1960 | |
cluResultInfo.getMetaInfo().getVersionInd())) { |
| 1961 | 0 | throw new VersionMismatchException( |
| 1962 | |
"CluResult to be updated is not the current version"); |
| 1963 | |
} |
| 1964 | |
|
| 1965 | |
|
| 1966 | |
|
| 1967 | |
|
| 1968 | 21 | Map<String, ResultOption> oldResultOptionMap = new HashMap<String, ResultOption>(); |
| 1969 | 21 | for (ResultOption opt : result.getResultOptions()) { |
| 1970 | 28 | oldResultOptionMap.put(opt.getId(), opt); |
| 1971 | |
} |
| 1972 | 21 | result.getResultOptions().clear(); |
| 1973 | |
|
| 1974 | |
|
| 1975 | |
|
| 1976 | 21 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
| 1977 | 27 | ResultOption opt = oldResultOptionMap.remove(resOptInfo.getId()); |
| 1978 | 27 | if (opt == null) { |
| 1979 | |
|
| 1980 | 1 | opt = new ResultOption(); |
| 1981 | |
|
| 1982 | 1 | BeanUtils.copyProperties(resOptInfo, opt, new String[] { |
| 1983 | |
"resultUsageType", "desc" }); |
| 1984 | |
} else { |
| 1985 | |
|
| 1986 | 26 | opt = luDao.fetch(ResultOption.class, resOptInfo.getId()); |
| 1987 | |
|
| 1988 | 26 | BeanUtils.copyProperties(resOptInfo, opt, new String[] { |
| 1989 | |
"id", "resultUsageType", "desc" }); |
| 1990 | |
} |
| 1991 | 27 | if(resOptInfo.getResultUsageTypeKey() != null && !resOptInfo.getResultUsageTypeKey().isEmpty()) { |
| 1992 | 1 | ResultUsageType resUsageType = luDao.fetch(ResultUsageType.class, |
| 1993 | |
resOptInfo.getResultUsageTypeKey()); |
| 1994 | 1 | opt.setResultUsageType(resUsageType); |
| 1995 | |
} |
| 1996 | 27 | opt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDesc())); |
| 1997 | 27 | result.getResultOptions().add(opt); |
| 1998 | 27 | } |
| 1999 | |
|
| 2000 | |
|
| 2001 | 21 | for (Entry<String, ResultOption> entry : oldResultOptionMap.entrySet()) { |
| 2002 | 2 | luDao.delete(entry.getValue()); |
| 2003 | |
} |
| 2004 | |
|
| 2005 | 21 | BeanUtils.copyProperties(cluResultInfo, result, new String[] { "id", |
| 2006 | |
"desc", "resultOptions" }); |
| 2007 | |
|
| 2008 | 21 | result.setDesc(LuServiceAssembler.toRichText(LuRichText.class, cluResultInfo.getDesc())); |
| 2009 | 21 | CluResultType type = luDao.fetch(CluResultType.class, cluResultInfo.getType()); |
| 2010 | 21 | result.setCluResultType(type); |
| 2011 | |
|
| 2012 | 21 | CluResult updated = luDao.update(result); |
| 2013 | |
|
| 2014 | 21 | return LuServiceAssembler.toCluResultInfo(updated); |
| 2015 | |
} |
| 2016 | |
|
| 2017 | |
@Override |
| 2018 | |
@Transactional(readOnly=false) |
| 2019 | |
public StatusInfo deleteCluResult(String cluResultId) |
| 2020 | |
throws DoesNotExistException, InvalidParameterException, |
| 2021 | |
MissingParameterException, DependentObjectsExistException, |
| 2022 | |
OperationFailedException, PermissionDeniedException { |
| 2023 | |
|
| 2024 | 4 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 2025 | |
|
| 2026 | 4 | luDao.delete(CluResult.class, cluResultId); |
| 2027 | |
|
| 2028 | 4 | StatusInfo statusInfo = new StatusInfo(); |
| 2029 | 4 | statusInfo.setSuccess(true); |
| 2030 | |
|
| 2031 | 4 | return statusInfo; |
| 2032 | |
} |
| 2033 | |
|
| 2034 | |
@Override |
| 2035 | |
public List<ValidationResultInfo> validateCluLoRelation( |
| 2036 | |
String validationType, CluLoRelationInfo cluLoRelationInfo) |
| 2037 | |
throws DoesNotExistException, InvalidParameterException, |
| 2038 | |
MissingParameterException, OperationFailedException { |
| 2039 | |
|
| 2040 | 104 | checkForMissingParameter(validationType, "validationType"); |
| 2041 | 104 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2042 | |
|
| 2043 | 104 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluLoRelation.class.getName()); |
| 2044 | 104 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2045 | 104 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluLoRelationInfo, objStructure); |
| 2046 | 104 | return validationResults; |
| 2047 | |
} |
| 2048 | |
|
| 2049 | |
@Override |
| 2050 | |
@Transactional(readOnly=false) |
| 2051 | |
public CluLoRelationInfo createCluLoRelation(String cluId, String loId, |
| 2052 | |
String cluLoRelationType, CluLoRelationInfo cluLoRelationInfo) |
| 2053 | |
throws AlreadyExistsException, DoesNotExistException, |
| 2054 | |
InvalidParameterException, MissingParameterException, |
| 2055 | |
OperationFailedException, PermissionDeniedException, DataValidationErrorException { |
| 2056 | 103 | checkForMissingParameter(loId, "loId"); |
| 2057 | 103 | checkForMissingParameter(cluId, "cluId"); |
| 2058 | 103 | checkForEmptyList(cluLoRelationType, "cluLoRelationType"); |
| 2059 | 103 | checkForEmptyList(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2060 | |
|
| 2061 | |
|
| 2062 | 103 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", cluLoRelationInfo); |
| 2063 | 103 | if(null != val && val.size() > 0) { |
| 2064 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2065 | |
} |
| 2066 | |
|
| 2067 | 103 | Clu clu = luDao.fetch(Clu.class, cluId); |
| 2068 | 102 | if (clu == null) { |
| 2069 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
| 2070 | |
+ cluId); |
| 2071 | |
} |
| 2072 | |
|
| 2073 | 102 | CluLoRelationType cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationType); |
| 2074 | 102 | if (cluLoRelationTypeEntity == null) { |
| 2075 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
| 2076 | |
+ cluLoRelationType); |
| 2077 | |
} |
| 2078 | |
|
| 2079 | |
|
| 2080 | 102 | List<CluLoRelation> reltns = luDao.getCluLoRelationsByCludIdAndLoId( |
| 2081 | |
cluId, loId); |
| 2082 | 102 | if (reltns.size() > 0) { |
| 2083 | 1 | throw new AlreadyExistsException( |
| 2084 | |
"Relation already exists for cluId:" + cluId + " and Lo:" |
| 2085 | |
+ loId); |
| 2086 | |
} |
| 2087 | |
|
| 2088 | 101 | CluLoRelation cluLoRelation = new CluLoRelation(); |
| 2089 | 101 | BeanUtils.copyProperties(cluLoRelationInfo, cluLoRelation, |
| 2090 | |
new String[] { "cluId", "attributes", "metaInfo", "type" }); |
| 2091 | |
|
| 2092 | 101 | cluLoRelation.setClu(clu); |
| 2093 | 101 | cluLoRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2094 | |
CluLoRelationAttribute.class, |
| 2095 | |
cluLoRelationInfo.getAttributes(), cluLoRelation, luDao)); |
| 2096 | 101 | cluLoRelation.setType(cluLoRelationTypeEntity); |
| 2097 | |
|
| 2098 | 101 | luDao.create(cluLoRelation); |
| 2099 | |
|
| 2100 | 101 | return LuServiceAssembler.toCluLoRelationInfo(cluLoRelation); |
| 2101 | |
} |
| 2102 | |
|
| 2103 | |
@Override |
| 2104 | |
@Transactional(readOnly=false) |
| 2105 | |
public CluLoRelationInfo updateCluLoRelation(String cluLoRelationId, |
| 2106 | |
CluLoRelationInfo cluLoRelationInfo) |
| 2107 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2108 | |
InvalidParameterException, MissingParameterException, |
| 2109 | |
OperationFailedException, PermissionDeniedException, |
| 2110 | |
VersionMismatchException { |
| 2111 | 1 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 2112 | 1 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2113 | |
|
| 2114 | |
|
| 2115 | 1 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", cluLoRelationInfo); |
| 2116 | 1 | if(null != val && val.size() > 0) { |
| 2117 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2118 | |
} |
| 2119 | |
|
| 2120 | 1 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 2121 | |
|
| 2122 | 1 | if (!String.valueOf(reltn.getVersionNumber()).equals( |
| 2123 | |
cluLoRelationInfo.getMetaInfo().getVersionInd())) { |
| 2124 | 0 | throw new VersionMismatchException( |
| 2125 | |
"CluLoRelation to be updated is not the current version"); |
| 2126 | |
} |
| 2127 | |
|
| 2128 | 1 | Clu clu = luDao.fetch(Clu.class, cluLoRelationInfo.getCluId()); |
| 2129 | 1 | if (clu == null) { |
| 2130 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
| 2131 | |
+ cluLoRelationInfo.getCluId()); |
| 2132 | |
} |
| 2133 | |
|
| 2134 | 1 | CluLoRelationType cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationInfo.getType()); |
| 2135 | 1 | if (cluLoRelationTypeEntity == null) { |
| 2136 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
| 2137 | |
+ cluLoRelationInfo.getType()); |
| 2138 | |
} |
| 2139 | |
|
| 2140 | 1 | BeanUtils.copyProperties(cluLoRelationInfo, reltn, new String[] { |
| 2141 | |
"cluId", "attributes", "metaInfo", "type"}); |
| 2142 | |
|
| 2143 | 1 | reltn.setClu(clu); |
| 2144 | 1 | reltn.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2145 | |
CluLoRelationAttribute.class, |
| 2146 | |
cluLoRelationInfo.getAttributes(), reltn, luDao)); |
| 2147 | 1 | reltn.setType(cluLoRelationTypeEntity); |
| 2148 | 1 | CluLoRelation updated = luDao.update(reltn); |
| 2149 | |
|
| 2150 | 1 | return LuServiceAssembler.toCluLoRelationInfo(updated); |
| 2151 | |
} |
| 2152 | |
|
| 2153 | |
@Override |
| 2154 | |
@Transactional(readOnly=false) |
| 2155 | |
public StatusInfo deleteCluLoRelation(String cluLoRelationId) |
| 2156 | |
throws DoesNotExistException, InvalidParameterException, |
| 2157 | |
MissingParameterException, OperationFailedException, |
| 2158 | |
PermissionDeniedException { |
| 2159 | 7 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 2160 | |
|
| 2161 | 7 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 2162 | 7 | if (reltn == null) { |
| 2163 | 0 | throw new DoesNotExistException( |
| 2164 | |
"CluLoRelation does not exist for id: " + cluLoRelationId); |
| 2165 | |
} |
| 2166 | |
|
| 2167 | 7 | luDao.delete(CluLoRelation.class, cluLoRelationId); |
| 2168 | |
|
| 2169 | 7 | StatusInfo statusInfo = new StatusInfo(); |
| 2170 | 7 | statusInfo.setSuccess(true); |
| 2171 | |
|
| 2172 | 7 | return statusInfo; |
| 2173 | |
} |
| 2174 | |
|
| 2175 | |
@Override |
| 2176 | |
@Transactional(readOnly=false) |
| 2177 | |
public StatusInfo addCluResourceRequirement(String resourceTypeKey, |
| 2178 | |
String cluId) throws AlreadyExistsException, DoesNotExistException, |
| 2179 | |
InvalidParameterException, MissingParameterException, |
| 2180 | |
OperationFailedException, PermissionDeniedException { |
| 2181 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 2182 | |
} |
| 2183 | |
|
| 2184 | |
@Override |
| 2185 | |
@Transactional(readOnly=false) |
| 2186 | |
public StatusInfo removeCluResourceRequirement(String resourceTypeKey, |
| 2187 | |
String cluId) throws DoesNotExistException, |
| 2188 | |
InvalidParameterException, MissingParameterException, |
| 2189 | |
OperationFailedException, PermissionDeniedException { |
| 2190 | |
|
| 2191 | 0 | return null; |
| 2192 | |
} |
| 2193 | |
|
| 2194 | |
@Override |
| 2195 | |
public List<ValidationResultInfo> validateCluSet(String validationType, |
| 2196 | |
CluSetInfo cluSetInfo) throws DoesNotExistException, |
| 2197 | |
InvalidParameterException, MissingParameterException, |
| 2198 | |
OperationFailedException { |
| 2199 | 46 | checkForMissingParameter(validationType, "validationType"); |
| 2200 | 46 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2201 | |
|
| 2202 | 46 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluSetInfo.class.getName()); |
| 2203 | 46 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2204 | 46 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluSetInfo, objStructure); |
| 2205 | 46 | return validationResults; |
| 2206 | |
} |
| 2207 | |
|
| 2208 | |
@Override |
| 2209 | |
@Transactional(readOnly=false) |
| 2210 | |
public CluSetInfo createCluSet(String cluSetType, CluSetInfo cluSetInfo) |
| 2211 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 2212 | |
InvalidParameterException, MissingParameterException, |
| 2213 | |
OperationFailedException, PermissionDeniedException, |
| 2214 | |
UnsupportedActionException { |
| 2215 | |
|
| 2216 | 39 | checkForMissingParameter(cluSetType, "cluSetType"); |
| 2217 | 39 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2218 | |
|
| 2219 | 39 | cluSetInfo.setType(cluSetType); |
| 2220 | |
|
| 2221 | 39 | validateCluSet(cluSetInfo); |
| 2222 | |
|
| 2223 | |
|
| 2224 | |
List<ValidationResultInfo> val; |
| 2225 | |
try { |
| 2226 | 36 | val = validateCluSet("SYSTEM", cluSetInfo); |
| 2227 | 0 | } catch (DoesNotExistException e) { |
| 2228 | 0 | throw new DataValidationErrorException("Validation error! " + e.getMessage()); |
| 2229 | 36 | } |
| 2230 | 36 | if(null != val && val.size() > 0) { |
| 2231 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2232 | |
} |
| 2233 | |
|
| 2234 | 36 | List<String> cluIdList = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2235 | |
|
| 2236 | 36 | CluSet cluSet = null; |
| 2237 | |
try { |
| 2238 | 36 | cluSet = LuServiceAssembler.toCluSetEntity(cluSetInfo, this.luDao); |
| 2239 | 0 | } catch (DoesNotExistException e) { |
| 2240 | 0 | throw new DataValidationErrorException("Creating CluSet entity failed. Clu or CluSet does not exist: " + e.getMessage()); |
| 2241 | 36 | } |
| 2242 | |
|
| 2243 | 36 | cluSet = luDao.create(cluSet); |
| 2244 | |
|
| 2245 | 36 | CluSetInfo newCluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
| 2246 | |
|
| 2247 | 36 | if(cluIdList != null) { |
| 2248 | 6 | newCluSetInfo.getCluIds().addAll(cluIdList); |
| 2249 | |
} |
| 2250 | |
|
| 2251 | 36 | return newCluSetInfo; |
| 2252 | |
} |
| 2253 | |
|
| 2254 | |
private void setMembershipQuerySearchResult(CluSetInfo cluSetInfo) throws MissingParameterException { |
| 2255 | 96 | if(cluSetInfo.getMembershipQuery() == null) { |
| 2256 | 91 | return; |
| 2257 | |
} |
| 2258 | 5 | List<String> cluIds = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2259 | 5 | cluSetInfo.getCluIds().addAll(cluIds); |
| 2260 | 5 | } |
| 2261 | |
|
| 2262 | |
private List<String> getMembershipQuerySearchResult(MembershipQueryInfo query) throws MissingParameterException { |
| 2263 | 51 | if(query == null) { |
| 2264 | 39 | return null; |
| 2265 | |
} |
| 2266 | 12 | SearchRequest sr = new SearchRequest(); |
| 2267 | 12 | sr.setSearchKey(query.getSearchTypeKey()); |
| 2268 | 12 | sr.setParams(query.getQueryParamValueList()); |
| 2269 | |
|
| 2270 | 12 | SearchResult result = search(sr); |
| 2271 | |
|
| 2272 | 12 | Set<String> cluIds = new HashSet<String>(); |
| 2273 | 12 | List<SearchResultRow> rows = result.getRows(); |
| 2274 | 12 | for(SearchResultRow row : rows) { |
| 2275 | 827 | List<SearchResultCell> cells = row.getCells(); |
| 2276 | 827 | for(SearchResultCell cell : cells) { |
| 2277 | 2481 | if(cell.getKey().equals("lu.resultColumn.luOptionalVersionIndId")&&cell.getValue()!=null) { |
| 2278 | 799 | cluIds.add(cell.getValue()); |
| 2279 | |
} |
| 2280 | |
} |
| 2281 | 827 | } |
| 2282 | 12 | return new ArrayList<String>(cluIds); |
| 2283 | |
} |
| 2284 | |
|
| 2285 | |
private void validateCluSet(CluSetInfo cluSetInfo) throws UnsupportedActionException { |
| 2286 | 49 | MembershipQueryInfo mqInfo = cluSetInfo.getMembershipQuery(); |
| 2287 | |
|
| 2288 | 49 | if (cluSetInfo.getType() == null) { |
| 2289 | 0 | throw new UnsupportedActionException("CluSet type cannot be null. CluSet id="+cluSetInfo.getId()); |
| 2290 | |
} |
| 2291 | 49 | else if(mqInfo != null && mqInfo.getSearchTypeKey() != null && !mqInfo.getSearchTypeKey().isEmpty() && |
| 2292 | |
(cluSetInfo.getCluIds().size() > 0 || cluSetInfo.getCluSetIds().size() > 0)) { |
| 2293 | 2 | throw new UnsupportedActionException("Dynamic CluSet cannot contain Clus and/or CluSets. CluSet id="+cluSetInfo.getId()); |
| 2294 | |
} |
| 2295 | 47 | else if (cluSetInfo.getCluIds().size() > 0 && cluSetInfo.getCluSetIds().size() > 0) { |
| 2296 | 1 | throw new UnsupportedActionException("CluSet cannot contain both Clus and CluSets. CluSet id="+cluSetInfo.getId()); |
| 2297 | |
} |
| 2298 | 46 | } |
| 2299 | |
|
| 2300 | |
@Override |
| 2301 | |
@Transactional(readOnly=false) |
| 2302 | |
public CluSetInfo updateCluSet(String cluSetId, CluSetInfo cluSetInfo) |
| 2303 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2304 | |
InvalidParameterException, MissingParameterException, |
| 2305 | |
OperationFailedException, PermissionDeniedException, |
| 2306 | |
VersionMismatchException, CircularRelationshipException, |
| 2307 | |
UnsupportedActionException { |
| 2308 | |
|
| 2309 | |
|
| 2310 | 10 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2311 | 10 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2312 | |
|
| 2313 | |
|
| 2314 | 10 | List<ValidationResultInfo> val = validateCluSet("SYSTEM", cluSetInfo); |
| 2315 | 10 | if(null != val && val.size() > 0) { |
| 2316 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2317 | |
} |
| 2318 | |
|
| 2319 | 10 | cluSetInfo.setId(cluSetId); |
| 2320 | |
|
| 2321 | 10 | validateCluSet(cluSetInfo); |
| 2322 | |
|
| 2323 | 10 | List<String> cluIdList = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2324 | |
|
| 2325 | 10 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2326 | |
|
| 2327 | 10 | if (!cluSetInfo.getType().equals(cluSet.getType())) { |
| 2328 | 0 | throw new UnsupportedActionException("CluSet type is set at creation time and cannot be updated. CluSet id="+cluSetId); |
| 2329 | |
} |
| 2330 | |
|
| 2331 | 10 | if (!String.valueOf(cluSet.getVersionNumber()).equals( |
| 2332 | |
cluSetInfo.getMetaInfo().getVersionInd())) { |
| 2333 | 1 | throw new VersionMismatchException( |
| 2334 | |
"CluSet (id=" + cluSetId + |
| 2335 | |
") to be updated is not the current version " + |
| 2336 | |
"(version=" + cluSetInfo.getMetaInfo().getVersionInd() + |
| 2337 | |
"), current version="+cluSet.getVersionNumber()); |
| 2338 | |
} |
| 2339 | |
|
| 2340 | |
|
| 2341 | 9 | Map<String, CluSetJoinVersionIndClu> oldClus = new HashMap<String, CluSetJoinVersionIndClu>(); |
| 2342 | 9 | for(CluSetJoinVersionIndClu join:cluSet.getCluVerIndIds()){ |
| 2343 | 8 | oldClus.put(join.getCluVersionIndId(), join); |
| 2344 | |
} |
| 2345 | |
|
| 2346 | 9 | cluSet.getCluVerIndIds().clear(); |
| 2347 | |
|
| 2348 | 9 | for (String newCluId : cluSetInfo.getCluIds()) { |
| 2349 | 6 | CluSetJoinVersionIndClu join = oldClus.remove(newCluId); |
| 2350 | 6 | if (join == null) { |
| 2351 | 2 | join = new CluSetJoinVersionIndClu(); |
| 2352 | 2 | join.setCluSet(cluSet); |
| 2353 | 2 | join.setCluVersionIndId(newCluId); |
| 2354 | |
} |
| 2355 | 6 | cluSet.getCluVerIndIds().add(join); |
| 2356 | 6 | } |
| 2357 | |
|
| 2358 | |
|
| 2359 | 9 | for (Entry<String, CluSetJoinVersionIndClu> entry : oldClus.entrySet()) { |
| 2360 | 4 | luDao.delete(entry.getValue()); |
| 2361 | |
} |
| 2362 | |
|
| 2363 | |
|
| 2364 | 9 | if (cluSetInfo.getId() != null) { |
| 2365 | 9 | CluSetInfo originalCluSet = getCluSetInfo(cluSetInfo.getId()); |
| 2366 | 9 | List<CluSetInfo> origSubCSs = null; |
| 2367 | 9 | List<String> origSubCSIds = originalCluSet.getCluSetIds(); |
| 2368 | 9 | if (origSubCSIds != null && !origSubCSIds.isEmpty()) { |
| 2369 | 2 | origSubCSs = getCluSetInfoByIdList(origSubCSIds); |
| 2370 | |
} |
| 2371 | 9 | if (origSubCSs != null) { |
| 2372 | 2 | for (CluSetInfo origSubCS : origSubCSs) { |
| 2373 | 6 | if (!origSubCS.getIsReusable()) { |
| 2374 | 0 | deleteCluSet(origSubCS.getId()); |
| 2375 | |
} |
| 2376 | |
} |
| 2377 | |
} |
| 2378 | |
} |
| 2379 | |
|
| 2380 | |
|
| 2381 | 9 | if(cluSet.getCluSets()==null){ |
| 2382 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
| 2383 | |
} |
| 2384 | 9 | cluSet.setCluSets(null); |
| 2385 | 9 | if(!cluSetInfo.getCluSetIds().isEmpty()) { |
| 2386 | 3 | Set<String> newCluSetIds = new HashSet<String>(cluSetInfo.getCluSetIds()); |
| 2387 | 3 | if(cluSet.getCluSets()!=null){ |
| 2388 | 0 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
| 2389 | 0 | if (!newCluSetIds.remove(i.next().getId())) { |
| 2390 | 0 | i.remove(); |
| 2391 | |
} |
| 2392 | |
} |
| 2393 | |
} |
| 2394 | 3 | List<CluSet> cluSetList = luDao.getCluSetInfoByIdList(new ArrayList<String>(newCluSetIds)); |
| 2395 | 3 | cluSet.setCluSets(cluSetList); |
| 2396 | |
} |
| 2397 | |
|
| 2398 | 9 | BeanUtils.copyProperties(cluSetInfo, cluSet, new String[] { "descr", |
| 2399 | |
"attributes", "metaInfo", "membershipQuery" }); |
| 2400 | 9 | cluSet.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2401 | |
CluSetAttribute.class, cluSetInfo.getAttributes(), cluSet, luDao)); |
| 2402 | 9 | cluSet.setDescr(LuServiceAssembler.toRichText(LuRichText.class, cluSetInfo.getDescr())); |
| 2403 | |
|
| 2404 | 9 | MembershipQuery mq = LuServiceAssembler.toMembershipQueryEntity(cluSetInfo.getMembershipQuery()); |
| 2405 | 9 | cluSet.setMembershipQuery(mq); |
| 2406 | |
|
| 2407 | 9 | CluSet updated = luDao.update(cluSet); |
| 2408 | |
|
| 2409 | 9 | CluSetInfo updatedCluSetInfo = LuServiceAssembler.toCluSetInfo(updated); |
| 2410 | |
|
| 2411 | 9 | if(cluIdList != null) { |
| 2412 | 1 | updatedCluSetInfo.getCluIds().addAll(cluIdList); |
| 2413 | |
} |
| 2414 | |
|
| 2415 | 9 | return updatedCluSetInfo; |
| 2416 | |
} |
| 2417 | |
|
| 2418 | |
@Override |
| 2419 | |
@Transactional(readOnly=false) |
| 2420 | |
public StatusInfo deleteCluSet(String cluSetId) |
| 2421 | |
throws DoesNotExistException, InvalidParameterException, |
| 2422 | |
MissingParameterException, OperationFailedException, |
| 2423 | |
PermissionDeniedException { |
| 2424 | |
|
| 2425 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2426 | |
|
| 2427 | 1 | luDao.delete(CluSet.class, cluSetId); |
| 2428 | |
|
| 2429 | 1 | StatusInfo statusInfo = new StatusInfo(); |
| 2430 | 1 | statusInfo.setSuccess(true); |
| 2431 | |
|
| 2432 | 1 | return statusInfo; |
| 2433 | |
} |
| 2434 | |
|
| 2435 | |
@Override |
| 2436 | |
@Transactional(readOnly=false) |
| 2437 | |
public StatusInfo addCluSetToCluSet(String cluSetId, String addedCluSetId) |
| 2438 | |
throws DoesNotExistException, InvalidParameterException, |
| 2439 | |
MissingParameterException, OperationFailedException, |
| 2440 | |
PermissionDeniedException, UnsupportedActionException, |
| 2441 | |
CircularRelationshipException { |
| 2442 | 27 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2443 | 27 | checkForMissingParameter(addedCluSetId, "addedCluSetId"); |
| 2444 | |
|
| 2445 | 27 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2446 | |
|
| 2447 | 27 | checkCluSetAlreadyAdded(cluSet, addedCluSetId); |
| 2448 | |
|
| 2449 | 25 | CluSet addedCluSet = luDao.fetch(CluSet.class, addedCluSetId); |
| 2450 | |
|
| 2451 | 23 | checkCluSetCircularReference(addedCluSet, cluSetId); |
| 2452 | |
|
| 2453 | 19 | if(cluSet.getCluSets()==null){ |
| 2454 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
| 2455 | |
} |
| 2456 | 19 | cluSet.getCluSets().add(addedCluSet); |
| 2457 | |
|
| 2458 | 19 | luDao.update(cluSet); |
| 2459 | |
|
| 2460 | 19 | StatusInfo statusInfo = new StatusInfo(); |
| 2461 | 19 | statusInfo.setSuccess(true); |
| 2462 | |
|
| 2463 | 19 | return statusInfo; |
| 2464 | |
} |
| 2465 | |
|
| 2466 | |
@Override |
| 2467 | |
@Transactional(readOnly=false) |
| 2468 | |
public StatusInfo removeCluSetFromCluSet(String cluSetId, |
| 2469 | |
String removedCluSetId) throws DoesNotExistException, |
| 2470 | |
InvalidParameterException, MissingParameterException, |
| 2471 | |
OperationFailedException, PermissionDeniedException, |
| 2472 | |
UnsupportedActionException { |
| 2473 | |
|
| 2474 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2475 | 1 | checkForMissingParameter(removedCluSetId, "removedCluSetId"); |
| 2476 | |
|
| 2477 | 1 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2478 | 1 | if(cluSet.getCluSets()!=null){ |
| 2479 | 1 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
| 2480 | 2 | CluSet childCluSet = i.next(); |
| 2481 | 2 | if (childCluSet.getId().equals(removedCluSetId)) { |
| 2482 | 1 | i.remove(); |
| 2483 | 1 | luDao.update(cluSet); |
| 2484 | 1 | StatusInfo statusInfo = new StatusInfo(); |
| 2485 | 1 | statusInfo.setSuccess(true); |
| 2486 | |
|
| 2487 | 1 | return statusInfo; |
| 2488 | |
} |
| 2489 | 1 | } |
| 2490 | |
} |
| 2491 | |
|
| 2492 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2493 | 0 | statusInfo.setSuccess(false); |
| 2494 | 0 | statusInfo.setMessage("CluSet does not contain CluSet:" |
| 2495 | |
+ removedCluSetId); |
| 2496 | |
|
| 2497 | 0 | return statusInfo; |
| 2498 | |
} |
| 2499 | |
|
| 2500 | |
@Override |
| 2501 | |
@Transactional(readOnly=false) |
| 2502 | |
public StatusInfo addCluToCluSet(String cluId, String cluSetId) |
| 2503 | |
throws DoesNotExistException, InvalidParameterException, |
| 2504 | |
MissingParameterException, OperationFailedException, |
| 2505 | |
PermissionDeniedException, UnsupportedActionException { |
| 2506 | |
|
| 2507 | 14 | checkForMissingParameter(cluId, "cluId"); |
| 2508 | 14 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2509 | |
|
| 2510 | 14 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2511 | |
|
| 2512 | 13 | checkCluAlreadyAdded(cluSet, cluId); |
| 2513 | |
|
| 2514 | |
try{ |
| 2515 | 11 | luDao.getCurrentCluVersionInfo(cluId, LuServiceConstants.CLU_NAMESPACE_URI); |
| 2516 | 1 | }catch(NoResultException e){ |
| 2517 | 1 | throw new DoesNotExistException(); |
| 2518 | 10 | } |
| 2519 | |
|
| 2520 | 10 | CluSetJoinVersionIndClu join = new CluSetJoinVersionIndClu(); |
| 2521 | 10 | join.setCluSet(cluSet); |
| 2522 | 10 | join.setCluVersionIndId(cluId); |
| 2523 | |
|
| 2524 | 10 | cluSet.getCluVerIndIds().add(join); |
| 2525 | |
|
| 2526 | 10 | luDao.update(cluSet); |
| 2527 | |
|
| 2528 | 10 | StatusInfo statusInfo = new StatusInfo(); |
| 2529 | 10 | statusInfo.setSuccess(true); |
| 2530 | |
|
| 2531 | 10 | return statusInfo; |
| 2532 | |
} |
| 2533 | |
|
| 2534 | |
@Override |
| 2535 | |
@Transactional(readOnly=false) |
| 2536 | |
public StatusInfo removeCluFromCluSet(String cluId, String cluSetId) |
| 2537 | |
throws DoesNotExistException, InvalidParameterException, |
| 2538 | |
MissingParameterException, OperationFailedException, |
| 2539 | |
PermissionDeniedException, UnsupportedActionException { |
| 2540 | |
|
| 2541 | 1 | checkForMissingParameter(cluId, "cluId"); |
| 2542 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2543 | |
|
| 2544 | 1 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2545 | |
|
| 2546 | 1 | for (Iterator<CluSetJoinVersionIndClu> i = cluSet.getCluVerIndIds().iterator(); i.hasNext();) { |
| 2547 | 2 | CluSetJoinVersionIndClu join = i.next(); |
| 2548 | 2 | if (join.getCluVersionIndId().equals(cluId)) { |
| 2549 | 1 | i.remove(); |
| 2550 | 1 | luDao.delete(join); |
| 2551 | 1 | luDao.update(cluSet); |
| 2552 | 1 | StatusInfo statusInfo = new StatusInfo(); |
| 2553 | 1 | statusInfo.setSuccess(true); |
| 2554 | |
|
| 2555 | 1 | return statusInfo; |
| 2556 | |
} |
| 2557 | 1 | } |
| 2558 | |
|
| 2559 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2560 | 0 | statusInfo.setSuccess(false); |
| 2561 | 0 | statusInfo.setMessage("Clu set does not contain Clu:" + cluId); |
| 2562 | |
|
| 2563 | 0 | return statusInfo; |
| 2564 | |
} |
| 2565 | |
|
| 2566 | |
@Override |
| 2567 | |
public List<ValidationResultInfo> validateLui(String validationType, |
| 2568 | |
LuiInfo luiInfo) throws DoesNotExistException, |
| 2569 | |
InvalidParameterException, MissingParameterException, |
| 2570 | |
OperationFailedException { |
| 2571 | 4 | checkForMissingParameter(validationType, "validationType"); |
| 2572 | 4 | checkForMissingParameter(luiInfo, "luiInfo"); |
| 2573 | |
|
| 2574 | 4 | ObjectStructureDefinition objStructure = this.getObjectStructure(LuiInfo.class.getName()); |
| 2575 | 4 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2576 | 4 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(luiInfo, objStructure); |
| 2577 | 4 | return validationResults; |
| 2578 | |
} |
| 2579 | |
|
| 2580 | |
@Override |
| 2581 | |
@Transactional(readOnly=false) |
| 2582 | |
public LuiInfo createLui(String cluId, String atpKey, LuiInfo luiInfo) |
| 2583 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 2584 | |
DoesNotExistException, InvalidParameterException, |
| 2585 | |
MissingParameterException, OperationFailedException, |
| 2586 | |
PermissionDeniedException { |
| 2587 | 2 | checkForMissingParameter(cluId, "cludId"); |
| 2588 | 2 | checkForMissingParameter(atpKey, "atpKey"); |
| 2589 | 2 | checkForMissingParameter(luiInfo, "luiInfo"); |
| 2590 | |
|
| 2591 | |
|
| 2592 | 2 | List<ValidationResultInfo> val = validateLui("SYSTEM", luiInfo); |
| 2593 | 2 | if(null != val && val.size() > 0) { |
| 2594 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2595 | |
} |
| 2596 | |
|
| 2597 | 2 | Lui lui = new Lui(); |
| 2598 | 2 | luiInfo.setCluId(cluId); |
| 2599 | 2 | luiInfo.setAtpId(atpKey); |
| 2600 | |
|
| 2601 | |
try { |
| 2602 | 2 | lui = LuServiceAssembler.toLui(false, luiInfo, luDao); |
| 2603 | 0 | } catch (VersionMismatchException vme) { |
| 2604 | 2 | } |
| 2605 | |
|
| 2606 | 2 | luDao.create(lui); |
| 2607 | |
|
| 2608 | 2 | return LuServiceAssembler.toLuiInfo(lui); |
| 2609 | |
} |
| 2610 | |
|
| 2611 | |
@Override |
| 2612 | |
@Transactional(readOnly=false) |
| 2613 | |
public LuiInfo updateLui(String luiId, LuiInfo luiInfo) |
| 2614 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2615 | |
InvalidParameterException, MissingParameterException, |
| 2616 | |
OperationFailedException, PermissionDeniedException, |
| 2617 | |
VersionMismatchException { |
| 2618 | |
|
| 2619 | 2 | checkForMissingParameter(luiId, "luiId"); |
| 2620 | 2 | checkForMissingParameter(luiInfo, "luiInfo"); |
| 2621 | |
|
| 2622 | |
|
| 2623 | 2 | List<ValidationResultInfo> val = validateLui("SYSTEM", luiInfo); |
| 2624 | 2 | if(null != val && val.size() > 0) { |
| 2625 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2626 | |
} |
| 2627 | |
|
| 2628 | 2 | Lui lui = luDao.fetch(Lui.class, luiId); |
| 2629 | |
|
| 2630 | 2 | if (!String.valueOf(lui.getVersionNumber()).equals( |
| 2631 | |
luiInfo.getMetaInfo().getVersionInd())) { |
| 2632 | 1 | throw new VersionMismatchException( |
| 2633 | |
"Lui to be updated is not the current version"); |
| 2634 | |
} |
| 2635 | |
|
| 2636 | 1 | Clu clu = luDao.fetch(Clu.class, luiInfo.getCluId()); |
| 2637 | 1 | lui.setClu(clu); |
| 2638 | |
|
| 2639 | 1 | lui.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2640 | |
LuiAttribute.class, luiInfo.getAttributes(), lui, luDao)); |
| 2641 | |
|
| 2642 | |
|
| 2643 | 1 | BeanUtils.copyProperties(luiInfo, lui, new String[] { "cluId", |
| 2644 | |
"attributes" }); |
| 2645 | |
|
| 2646 | 1 | Lui updated = luDao.update(lui); |
| 2647 | |
|
| 2648 | 1 | return LuServiceAssembler.toLuiInfo(updated); |
| 2649 | |
} |
| 2650 | |
|
| 2651 | |
@Override |
| 2652 | |
@Transactional(readOnly=false) |
| 2653 | |
public StatusInfo deleteLui(String luiId) |
| 2654 | |
throws DependentObjectsExistException, DoesNotExistException, |
| 2655 | |
InvalidParameterException, MissingParameterException, |
| 2656 | |
OperationFailedException, PermissionDeniedException { |
| 2657 | |
|
| 2658 | 3 | checkForMissingParameter(luiId, "luiId"); |
| 2659 | |
|
| 2660 | 3 | luDao.delete(Lui.class, luiId); |
| 2661 | |
|
| 2662 | 2 | StatusInfo statusInfo = new StatusInfo(); |
| 2663 | 2 | statusInfo.setSuccess(true); |
| 2664 | |
|
| 2665 | 2 | return statusInfo; |
| 2666 | |
} |
| 2667 | |
|
| 2668 | |
@Override |
| 2669 | |
@Transactional(readOnly=false) |
| 2670 | |
public LuiInfo updateLuiState(String luiId, String luiState) |
| 2671 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2672 | |
InvalidParameterException, MissingParameterException, |
| 2673 | |
OperationFailedException, PermissionDeniedException { |
| 2674 | |
|
| 2675 | |
|
| 2676 | 3 | checkForMissingParameter(luiId, "luiId"); |
| 2677 | 2 | checkForMissingParameter(luiState, "luiState"); |
| 2678 | 1 | Lui lui = luDao.fetch(Lui.class, luiId); |
| 2679 | 1 | lui.setState(luiState); |
| 2680 | 1 | Lui updated = luDao.update(lui); |
| 2681 | 1 | return LuServiceAssembler.toLuiInfo(updated); |
| 2682 | |
} |
| 2683 | |
|
| 2684 | |
@Override |
| 2685 | |
public List<ValidationResultInfo> validateLuiLuiRelation( |
| 2686 | |
String validationType, LuiLuiRelationInfo luiLuiRelationInfo) |
| 2687 | |
throws DoesNotExistException, InvalidParameterException, |
| 2688 | |
MissingParameterException, OperationFailedException { |
| 2689 | 3 | checkForMissingParameter(validationType, "validationType"); |
| 2690 | 3 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
| 2691 | |
|
| 2692 | 3 | ObjectStructureDefinition objStructure = this.getObjectStructure(LuiLuiRelation.class.getName()); |
| 2693 | 3 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2694 | 3 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(luiLuiRelationInfo, objStructure); |
| 2695 | 3 | return validationResults; |
| 2696 | |
} |
| 2697 | |
|
| 2698 | |
@Override |
| 2699 | |
@Transactional(readOnly=false) |
| 2700 | |
public LuiLuiRelationInfo createLuiLuiRelation(String luiId, |
| 2701 | |
String relatedLuiId, String luLuRelationTypeKey, |
| 2702 | |
LuiLuiRelationInfo luiLuiRelationInfo) |
| 2703 | |
throws AlreadyExistsException, CircularRelationshipException, |
| 2704 | |
DataValidationErrorException, DoesNotExistException, |
| 2705 | |
InvalidParameterException, MissingParameterException, |
| 2706 | |
OperationFailedException, PermissionDeniedException { |
| 2707 | 1 | checkForMissingParameter(luiId, "luiId"); |
| 2708 | 1 | checkForMissingParameter(relatedLuiId, "relatedLuiId"); |
| 2709 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 2710 | 1 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
| 2711 | |
|
| 2712 | |
|
| 2713 | 1 | List<ValidationResultInfo> val = validateLuiLuiRelation("SYSTEM", luiLuiRelationInfo); |
| 2714 | 1 | if(null != val && val.size() > 0) { |
| 2715 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2716 | |
} |
| 2717 | |
|
| 2718 | 1 | if (luiId.equals(relatedLuiId)) { |
| 2719 | 0 | throw new CircularRelationshipException( |
| 2720 | |
"Can not relate a Lui to itself"); |
| 2721 | |
} |
| 2722 | |
|
| 2723 | 1 | Lui lui = luDao.fetch(Lui.class, luiId); |
| 2724 | 1 | Lui relatedLui = luDao.fetch(Lui.class, relatedLuiId); |
| 2725 | |
|
| 2726 | 1 | LuiLuiRelation luiLuiRelation = new LuiLuiRelation(); |
| 2727 | 1 | BeanUtils.copyProperties(luiLuiRelationInfo, luiLuiRelation, |
| 2728 | |
new String[] { "luiId", "relatedLuiId", "attributes", |
| 2729 | |
"metaInfo" }); |
| 2730 | |
|
| 2731 | 1 | luiLuiRelation.setLui(lui); |
| 2732 | 1 | luiLuiRelation.setRelatedLui(relatedLui); |
| 2733 | 1 | luiLuiRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2734 | |
LuiLuiRelationAttribute.class, luiLuiRelationInfo |
| 2735 | |
.getAttributes(), luiLuiRelation, luDao)); |
| 2736 | |
|
| 2737 | 1 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
| 2738 | |
luLuRelationTypeKey); |
| 2739 | |
|
| 2740 | 1 | luiLuiRelation.setLuLuRelationType(luLuRelationType); |
| 2741 | |
|
| 2742 | 1 | luDao.create(luiLuiRelation); |
| 2743 | |
|
| 2744 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(luiLuiRelation); |
| 2745 | |
} |
| 2746 | |
|
| 2747 | |
@Override |
| 2748 | |
@Transactional(readOnly=false) |
| 2749 | |
public LuiLuiRelationInfo updateLuiLuiRelation(String luiLuiRelationId, |
| 2750 | |
LuiLuiRelationInfo luiLuiRelationInfo) |
| 2751 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2752 | |
InvalidParameterException, MissingParameterException, |
| 2753 | |
OperationFailedException, PermissionDeniedException, |
| 2754 | |
VersionMismatchException { |
| 2755 | |
|
| 2756 | 2 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
| 2757 | 2 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
| 2758 | |
|
| 2759 | |
|
| 2760 | 2 | List<ValidationResultInfo> val = validateLuiLuiRelation("SYSTEM", luiLuiRelationInfo); |
| 2761 | 2 | if(null != val && val.size() > 0) { |
| 2762 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2763 | |
} |
| 2764 | |
|
| 2765 | 2 | LuiLuiRelation luiLuiRelation = luDao.fetch(LuiLuiRelation.class, |
| 2766 | |
luiLuiRelationId); |
| 2767 | |
|
| 2768 | 2 | if (!String.valueOf(luiLuiRelation.getVersionNumber()).equals( |
| 2769 | |
luiLuiRelationInfo.getMetaInfo().getVersionInd())) { |
| 2770 | 1 | throw new VersionMismatchException( |
| 2771 | |
"LuiLuiRelation to be updated is not the current version"); |
| 2772 | |
} |
| 2773 | |
|
| 2774 | 1 | BeanUtils.copyProperties(luiLuiRelationInfo, luiLuiRelation, |
| 2775 | |
new String[] { "luiId", "relatedLuiId", "attributes", |
| 2776 | |
"metaInfo" }); |
| 2777 | |
|
| 2778 | 1 | if (!luiLuiRelationInfo.getLuiId().equals( |
| 2779 | |
luiLuiRelation.getLui().getId())) { |
| 2780 | 1 | luiLuiRelation.setLui(luDao.fetch(Lui.class, luiLuiRelationInfo |
| 2781 | |
.getLuiId())); |
| 2782 | |
} |
| 2783 | |
|
| 2784 | 1 | if (!luiLuiRelationInfo.getRelatedLuiId().equals( |
| 2785 | |
luiLuiRelation.getRelatedLui().getId())) { |
| 2786 | 1 | luiLuiRelation.setRelatedLui(luDao.fetch(Lui.class, |
| 2787 | |
luiLuiRelationInfo.getRelatedLuiId())); |
| 2788 | |
} |
| 2789 | |
|
| 2790 | 1 | luiLuiRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2791 | |
LuiLuiRelationAttribute.class, luiLuiRelationInfo |
| 2792 | |
.getAttributes(), luiLuiRelation, luDao)); |
| 2793 | |
|
| 2794 | 1 | if (!luiLuiRelationInfo.getType().equals( |
| 2795 | |
luiLuiRelation.getLuLuRelationType().getId())) { |
| 2796 | 1 | luiLuiRelation.setLuLuRelationType(luDao.fetch( |
| 2797 | |
LuLuRelationType.class, luiLuiRelationInfo.getType())); |
| 2798 | |
} |
| 2799 | |
|
| 2800 | 1 | LuiLuiRelation updated = luDao.update(luiLuiRelation); |
| 2801 | |
|
| 2802 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(updated); |
| 2803 | |
} |
| 2804 | |
|
| 2805 | |
@Override |
| 2806 | |
@Transactional(readOnly=false) |
| 2807 | |
public StatusInfo deleteLuiLuiRelation(String luiLuiRelationId) |
| 2808 | |
throws DoesNotExistException, InvalidParameterException, |
| 2809 | |
MissingParameterException, OperationFailedException, |
| 2810 | |
PermissionDeniedException { |
| 2811 | |
|
| 2812 | 1 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
| 2813 | |
|
| 2814 | 1 | luDao.delete(LuiLuiRelation.class, luiLuiRelationId); |
| 2815 | |
|
| 2816 | 1 | StatusInfo statusInfo = new StatusInfo(); |
| 2817 | 1 | statusInfo.setSuccess(true); |
| 2818 | |
|
| 2819 | 1 | return statusInfo; |
| 2820 | |
} |
| 2821 | |
|
| 2822 | |
|
| 2823 | |
|
| 2824 | |
|
| 2825 | |
|
| 2826 | |
@Override |
| 2827 | |
public SearchCriteriaTypeInfo getSearchCriteriaType( |
| 2828 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
| 2829 | |
InvalidParameterException, MissingParameterException, |
| 2830 | |
OperationFailedException { |
| 2831 | |
|
| 2832 | 0 | return searchManager.getSearchCriteriaType(searchCriteriaTypeKey); |
| 2833 | |
} |
| 2834 | |
|
| 2835 | |
@Override |
| 2836 | |
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
| 2837 | |
throws OperationFailedException { |
| 2838 | 0 | return searchManager.getSearchCriteriaTypes(); |
| 2839 | |
} |
| 2840 | |
|
| 2841 | |
@Override |
| 2842 | |
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
| 2843 | |
throws DoesNotExistException, InvalidParameterException, |
| 2844 | |
MissingParameterException, OperationFailedException { |
| 2845 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
| 2846 | 0 | return searchManager.getSearchResultType(searchResultTypeKey); |
| 2847 | |
} |
| 2848 | |
|
| 2849 | |
@Override |
| 2850 | |
public List<SearchResultTypeInfo> getSearchResultTypes() |
| 2851 | |
throws OperationFailedException { |
| 2852 | 0 | return searchManager.getSearchResultTypes(); |
| 2853 | |
} |
| 2854 | |
|
| 2855 | |
@Override |
| 2856 | |
public SearchTypeInfo getSearchType(String searchTypeKey) |
| 2857 | |
throws DoesNotExistException, InvalidParameterException, |
| 2858 | |
MissingParameterException, OperationFailedException { |
| 2859 | 0 | checkForMissingParameter(searchTypeKey, "searchTypeKey"); |
| 2860 | 0 | return searchManager.getSearchType(searchTypeKey); |
| 2861 | |
} |
| 2862 | |
|
| 2863 | |
@Override |
| 2864 | |
public List<SearchTypeInfo> getSearchTypes() |
| 2865 | |
throws OperationFailedException { |
| 2866 | 0 | return searchManager.getSearchTypes(); |
| 2867 | |
} |
| 2868 | |
|
| 2869 | |
@Override |
| 2870 | |
public List<SearchTypeInfo> getSearchTypesByCriteria( |
| 2871 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
| 2872 | |
InvalidParameterException, MissingParameterException, |
| 2873 | |
OperationFailedException { |
| 2874 | 0 | checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey"); |
| 2875 | 0 | return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey); |
| 2876 | |
} |
| 2877 | |
|
| 2878 | |
@Override |
| 2879 | |
public List<SearchTypeInfo> getSearchTypesByResult( |
| 2880 | |
String searchResultTypeKey) throws DoesNotExistException, |
| 2881 | |
InvalidParameterException, MissingParameterException, |
| 2882 | |
OperationFailedException { |
| 2883 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
| 2884 | 0 | return searchManager.getSearchTypesByResult(searchResultTypeKey); |
| 2885 | |
} |
| 2886 | |
|
| 2887 | |
private void checkCluAlreadyAdded(CluSet cluSet, String cluId) |
| 2888 | |
throws OperationFailedException { |
| 2889 | 13 | for (CluSetJoinVersionIndClu join : cluSet.getCluVerIndIds()) { |
| 2890 | 13 | if (join.getCluVersionIndId().equals(cluId)) { |
| 2891 | 2 | throw new OperationFailedException("CluSet already contains Clu (id='" + cluId + "')"); |
| 2892 | |
} |
| 2893 | |
} |
| 2894 | 11 | } |
| 2895 | |
|
| 2896 | |
private void checkCluSetAlreadyAdded(CluSet cluSet, String cluSetIdToAdd) |
| 2897 | |
throws OperationFailedException { |
| 2898 | 27 | if(cluSet.getCluSets()!=null){ |
| 2899 | 27 | for (CluSet childCluSet : cluSet.getCluSets()) { |
| 2900 | 20 | if (childCluSet.getId().equals(cluSetIdToAdd)) { |
| 2901 | 2 | throw new OperationFailedException("CluSet (id=" + cluSet.getId() + |
| 2902 | |
") already contains CluSet (id='" + cluSetIdToAdd + "')"); |
| 2903 | |
} |
| 2904 | |
} |
| 2905 | |
} |
| 2906 | 25 | } |
| 2907 | |
|
| 2908 | |
private void checkCluSetCircularReference(CluSet addedCluSet, String hostCluSetId) |
| 2909 | |
throws CircularRelationshipException { |
| 2910 | 77 | if (addedCluSet.getId().equals(hostCluSetId)) { |
| 2911 | 2 | throw new CircularRelationshipException( |
| 2912 | |
"Cannot add a CluSet (id=" + hostCluSetId + ") to ifself"); |
| 2913 | |
} |
| 2914 | 75 | if(addedCluSet.getCluSets()!=null){ |
| 2915 | 75 | for (CluSet childSet : addedCluSet.getCluSets()) { |
| 2916 | 56 | if (childSet.getId().equals(hostCluSetId)) { |
| 2917 | 2 | throw new CircularRelationshipException( |
| 2918 | |
"CluSet (id=" + hostCluSetId + |
| 2919 | |
") already contains this CluSet (id=" + |
| 2920 | |
childSet.getId() + ")"); |
| 2921 | |
} |
| 2922 | 54 | checkCluSetCircularReference(childSet, hostCluSetId); |
| 2923 | |
} |
| 2924 | |
} |
| 2925 | 71 | } |
| 2926 | |
|
| 2927 | |
private void findClusInCluSet(List<String> clus, CluSet parentCluSet) |
| 2928 | |
throws DoesNotExistException { |
| 2929 | 2 | List<String> processedCluSetIds = new ArrayList<String>(); |
| 2930 | 2 | doFindClusInCluSet(processedCluSetIds, clus, parentCluSet); |
| 2931 | 2 | } |
| 2932 | |
|
| 2933 | |
private void doFindClusInCluSet(List<String> processedCluSetIds, |
| 2934 | |
List<String> clus, CluSet parentCluSet) { |
| 2935 | 4 | for (CluSetJoinVersionIndClu join : parentCluSet.getCluVerIndIds()) { |
| 2936 | 7 | if (!clus.contains(join.getCluVersionIndId())) { |
| 2937 | 5 | clus.add(join.getCluVersionIndId()); |
| 2938 | |
} |
| 2939 | |
} |
| 2940 | 4 | if(parentCluSet.getCluSets()!=null){ |
| 2941 | 4 | for (CluSet cluSet : parentCluSet.getCluSets()) { |
| 2942 | |
|
| 2943 | 2 | if (!processedCluSetIds.contains(cluSet.getId())) { |
| 2944 | 2 | processedCluSetIds.add(cluSet.getId()); |
| 2945 | 2 | doFindClusInCluSet(processedCluSetIds, clus, cluSet); |
| 2946 | |
} |
| 2947 | |
} |
| 2948 | |
} |
| 2949 | 4 | } |
| 2950 | |
|
| 2951 | |
@Override |
| 2952 | |
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
| 2953 | 770 | return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
| 2954 | |
} |
| 2955 | |
|
| 2956 | |
@Override |
| 2957 | |
public List<String> getObjectTypes() { |
| 2958 | 0 | return dictionaryServiceDelegate.getObjectTypes(); |
| 2959 | |
} |
| 2960 | |
|
| 2961 | |
public LuDao getLuDao() { |
| 2962 | 0 | return luDao; |
| 2963 | |
} |
| 2964 | |
|
| 2965 | |
public void setLuDao(LuDao luDao) { |
| 2966 | 4 | this.luDao = luDao; |
| 2967 | 4 | } |
| 2968 | |
|
| 2969 | |
@Override |
| 2970 | |
public SearchResult search(SearchRequest searchRequest) throws MissingParameterException { |
| 2971 | 18 | checkForMissingParameter(searchRequest, "searchRequest"); |
| 2972 | |
|
| 2973 | 18 | if(SEARCH_KEY_DEPENDENCY_ANALYSIS.equals(searchRequest.getSearchKey())){ |
| 2974 | 0 | String cluId = null; |
| 2975 | 0 | for(SearchParam param:searchRequest.getParams()){ |
| 2976 | 0 | if("lu.queryParam.luOptionalCluId".equals(param.getKey())){ |
| 2977 | 0 | cluId = (String)param.getValue(); |
| 2978 | 0 | break; |
| 2979 | |
} |
| 2980 | |
} |
| 2981 | |
try { |
| 2982 | 0 | return doDependencyAnalysisSearch(cluId); |
| 2983 | 0 | } catch (DoesNotExistException e) { |
| 2984 | 0 | throw new RuntimeException("Error performing search"); |
| 2985 | |
} |
| 2986 | 18 | }else if(SEARCH_KEY_BROWSE_PROGRAM.equals(searchRequest.getSearchKey())){ |
| 2987 | 0 | return doBrowseProgramSearch(); |
| 2988 | |
} |
| 2989 | 18 | return searchManager.search(searchRequest, luDao); |
| 2990 | |
} |
| 2991 | |
|
| 2992 | |
private SearchResult doBrowseProgramSearch() throws MissingParameterException { |
| 2993 | |
|
| 2994 | 0 | SearchResult programSearchResults = searchManager.search(new SearchRequest(SEARCH_KEY_BROWSE_PROGRAM), luDao); |
| 2995 | |
|
| 2996 | |
|
| 2997 | 0 | SearchResult variationSearchResults = searchManager.search(new SearchRequest(SEARCH_KEY_BROWSE_VARIATIONS), luDao); |
| 2998 | |
|
| 2999 | |
|
| 3000 | 0 | Map<String,List<String>> variationMapping = new HashMap<String,List<String>>(); |
| 3001 | 0 | for(SearchResultRow row:variationSearchResults.getRows()){ |
| 3002 | 0 | String programId = null; |
| 3003 | 0 | String variationLongName = null; |
| 3004 | 0 | for(SearchResultCell cell:row.getCells()){ |
| 3005 | 0 | if("lu.resultColumn.cluId".equals(cell.getKey())){ |
| 3006 | 0 | programId = cell.getValue(); |
| 3007 | 0 | }else if("lu.resultColumn.luOptionalLongName".equals(cell.getKey())){ |
| 3008 | 0 | variationLongName = cell.getValue(); |
| 3009 | |
} |
| 3010 | |
} |
| 3011 | 0 | List<String> variationLongNames = variationMapping.get(programId); |
| 3012 | 0 | if(variationLongNames == null){ |
| 3013 | 0 | variationLongNames = new ArrayList<String>(); |
| 3014 | 0 | variationMapping.put(programId, variationLongNames); |
| 3015 | |
} |
| 3016 | 0 | variationLongNames.add(variationLongName); |
| 3017 | 0 | } |
| 3018 | |
|
| 3019 | |
|
| 3020 | |
|
| 3021 | 0 | SearchRequest resultComponentSearchRequest = new SearchRequest(SEARCH_KEY_RESULT_COMPONENT); |
| 3022 | 0 | resultComponentSearchRequest.addParam("lrc.queryParam.resultComponent.type", "kuali.resultComponentType.degree"); |
| 3023 | 0 | SearchResult resultComponentSearchResults = searchDispatcher.dispatchSearch(resultComponentSearchRequest); |
| 3024 | |
|
| 3025 | |
|
| 3026 | 0 | Map<String,String> resultComponentMapping = new HashMap<String,String>(); |
| 3027 | 0 | for(SearchResultRow row:resultComponentSearchResults.getRows()){ |
| 3028 | 0 | String resultComponentTypeId = null; |
| 3029 | 0 | String resultComponentTypeName = null; |
| 3030 | 0 | for(SearchResultCell cell:row.getCells()){ |
| 3031 | 0 | if("lrc.resultColumn.resultComponent.id".equals(cell.getKey())){ |
| 3032 | 0 | resultComponentTypeId = cell.getValue(); |
| 3033 | 0 | }else if("lrc.resultColumn.resultComponent.name".equals(cell.getKey())){ |
| 3034 | 0 | resultComponentTypeName = cell.getValue(); |
| 3035 | |
} |
| 3036 | |
} |
| 3037 | 0 | resultComponentMapping.put(resultComponentTypeId, resultComponentTypeName); |
| 3038 | 0 | } |
| 3039 | |
|
| 3040 | 0 | Map<String, Set<SearchResultCell>> orgIdToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
| 3041 | 0 | Map<String, Set<SearchResultCell>> resultComponentToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
| 3042 | 0 | Map<String, Set<SearchResultCell>> campusToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
| 3043 | 0 | Map<String, SearchResultCell> progIdToOrgCellMapping = new HashMap<String, SearchResultCell>(); |
| 3044 | 0 | Map<String, SearchResultCell> progIdToResultComponentCellMapping = new HashMap<String, SearchResultCell>(); |
| 3045 | 0 | Map<String, SearchResultCell> progIdToCampusCellMapping = new HashMap<String, SearchResultCell>(); |
| 3046 | |
|
| 3047 | |
|
| 3048 | |
|
| 3049 | 0 | for(Iterator<SearchResultRow> rowIter = programSearchResults.getRows().iterator();rowIter.hasNext();){ |
| 3050 | 0 | SearchResultRow row = rowIter.next(); |
| 3051 | 0 | String programId = null; |
| 3052 | 0 | String orgId = null; |
| 3053 | 0 | String resultComponentName = null; |
| 3054 | 0 | String campusCode = null; |
| 3055 | 0 | SearchResultCell orgCell = null; |
| 3056 | 0 | SearchResultCell resultComponentCell = null; |
| 3057 | 0 | SearchResultCell variationCell = null; |
| 3058 | 0 | SearchResultCell campusLocationCell = null; |
| 3059 | |
|
| 3060 | 0 | for(SearchResultCell cell:row.getCells()){ |
| 3061 | 0 | if("lu.resultColumn.cluId".equals(cell.getKey())){ |
| 3062 | 0 | programId = cell.getValue(); |
| 3063 | 0 | }else if("lu.resultColumn.luOptionalAdminOrg".equals(cell.getKey())){ |
| 3064 | 0 | orgId = cell.getValue(); |
| 3065 | 0 | orgCell = cell; |
| 3066 | 0 | }else if("lu.resultColumn.resultComponentId".equals(cell.getKey())){ |
| 3067 | 0 | resultComponentName = resultComponentMapping.get(cell.getValue()); |
| 3068 | 0 | resultComponentCell = cell; |
| 3069 | 0 | }else if("lu.resultColumn.variationId".equals(cell.getKey())){ |
| 3070 | 0 | variationCell = cell; |
| 3071 | 0 | }else if("lu.resultColumn.luOptionalCampusLocation".equals(cell.getKey())){ |
| 3072 | 0 | campusLocationCell = cell; |
| 3073 | 0 | campusCode = cell.getValue(); |
| 3074 | |
} |
| 3075 | |
} |
| 3076 | 0 | if(!progIdToOrgCellMapping.containsKey(programId)){ |
| 3077 | |
|
| 3078 | 0 | List<String> variations = variationMapping.get(programId); |
| 3079 | 0 | variationCell.setValue(""); |
| 3080 | 0 | if(variations!=null){ |
| 3081 | 0 | for(Iterator<String> variationIter = variations.iterator();variationIter.hasNext();){ |
| 3082 | 0 | String variation = variationIter.next(); |
| 3083 | 0 | if(variationIter.hasNext()){ |
| 3084 | 0 | variation += "<br/>"; |
| 3085 | |
} |
| 3086 | 0 | variationCell.setValue(variationCell.getValue()+variation); |
| 3087 | 0 | } |
| 3088 | |
} |
| 3089 | |
|
| 3090 | |
|
| 3091 | 0 | Set<SearchResultCell> orgCells = orgIdToCellMapping.get(orgId); |
| 3092 | 0 | if(orgCells == null){ |
| 3093 | 0 | orgCells = new HashSet<SearchResultCell>(); |
| 3094 | 0 | orgIdToCellMapping.put(orgId, orgCells); |
| 3095 | |
} |
| 3096 | 0 | orgCells.add(orgCell); |
| 3097 | 0 | orgCell.setValue(null); |
| 3098 | |
|
| 3099 | |
|
| 3100 | |
|
| 3101 | 0 | Set<SearchResultCell> campusCells = campusToCellMapping.get(campusCode); |
| 3102 | 0 | if(campusCells == null){ |
| 3103 | 0 | campusCells = new HashSet<SearchResultCell>(); |
| 3104 | 0 | campusToCellMapping.put(campusCode, campusCells); |
| 3105 | |
} |
| 3106 | 0 | campusCells.add(campusLocationCell); |
| 3107 | 0 | campusLocationCell.setValue(null); |
| 3108 | |
|
| 3109 | |
|
| 3110 | 0 | Set<SearchResultCell> resultCells = resultComponentToCellMapping.get(resultComponentName); |
| 3111 | 0 | if(resultCells == null){ |
| 3112 | 0 | resultCells = new HashSet<SearchResultCell>(); |
| 3113 | 0 | resultComponentToCellMapping.put(resultComponentName, resultCells); |
| 3114 | |
} |
| 3115 | 0 | resultCells.add(resultComponentCell); |
| 3116 | 0 | resultComponentCell.setValue(null); |
| 3117 | |
|
| 3118 | 0 | progIdToOrgCellMapping.put(programId, orgCell); |
| 3119 | 0 | progIdToResultComponentCellMapping.put(programId, resultComponentCell); |
| 3120 | 0 | progIdToCampusCellMapping.put(programId, campusLocationCell); |
| 3121 | 0 | }else{ |
| 3122 | |
|
| 3123 | |
|
| 3124 | 0 | Set<SearchResultCell> resultCells = resultComponentToCellMapping.get(resultComponentName); |
| 3125 | 0 | if(resultCells == null){ |
| 3126 | 0 | resultCells = new HashSet<SearchResultCell>(); |
| 3127 | 0 | resultComponentToCellMapping.put(resultComponentName, resultCells); |
| 3128 | |
} |
| 3129 | 0 | resultCells.add(progIdToResultComponentCellMapping.get(programId)); |
| 3130 | |
|
| 3131 | |
|
| 3132 | 0 | Set<SearchResultCell> orgCells = orgIdToCellMapping.get(orgId); |
| 3133 | 0 | if(orgCells == null){ |
| 3134 | 0 | orgCells = new HashSet<SearchResultCell>(); |
| 3135 | 0 | orgIdToCellMapping.put(orgId, orgCells); |
| 3136 | |
} |
| 3137 | 0 | orgCells.add(progIdToOrgCellMapping.get(programId)); |
| 3138 | |
|
| 3139 | |
|
| 3140 | 0 | Set<SearchResultCell> campusCells = campusToCellMapping.get(campusCode); |
| 3141 | 0 | if(campusCells == null){ |
| 3142 | 0 | campusCells = new HashSet<SearchResultCell>(); |
| 3143 | 0 | campusToCellMapping.put(campusCode, campusCells); |
| 3144 | |
} |
| 3145 | 0 | campusCells.add(progIdToCampusCellMapping.get(programId)); |
| 3146 | |
|
| 3147 | |
|
| 3148 | 0 | rowIter.remove(); |
| 3149 | |
} |
| 3150 | 0 | } |
| 3151 | |
|
| 3152 | 0 | if(!resultComponentToCellMapping.isEmpty()){ |
| 3153 | 0 | List<String> resultComponentNames = new ArrayList<String>(resultComponentToCellMapping.keySet()); |
| 3154 | 0 | Collections.sort(resultComponentNames); |
| 3155 | 0 | for(String resultComponentName:resultComponentNames){ |
| 3156 | |
|
| 3157 | 0 | Set<SearchResultCell> cells = resultComponentToCellMapping.get(resultComponentName); |
| 3158 | 0 | if(cells!=null){ |
| 3159 | 0 | for(SearchResultCell cell:cells){ |
| 3160 | 0 | if(cell.getValue()==null){ |
| 3161 | 0 | cell.setValue(resultComponentName); |
| 3162 | |
}else{ |
| 3163 | 0 | cell.setValue(cell.getValue()+"<br/>"+resultComponentName); |
| 3164 | |
} |
| 3165 | |
} |
| 3166 | |
} |
| 3167 | 0 | } |
| 3168 | |
} |
| 3169 | |
|
| 3170 | 0 | if(!campusToCellMapping.isEmpty()){ |
| 3171 | 0 | List<String> campusCodes = new ArrayList<String>(campusToCellMapping.keySet()); |
| 3172 | 0 | Collections.sort(campusCodes); |
| 3173 | 0 | for(String campusCode:campusCodes){ |
| 3174 | |
|
| 3175 | 0 | Set<SearchResultCell> cells = campusToCellMapping.get(campusCode); |
| 3176 | 0 | if(cells!=null){ |
| 3177 | 0 | for(SearchResultCell cell:cells){ |
| 3178 | 0 | if(cell.getValue()==null){ |
| 3179 | 0 | cell.setValue(campusCode); |
| 3180 | |
}else{ |
| 3181 | 0 | cell.setValue(cell.getValue()+"<br/>"+campusCode); |
| 3182 | |
} |
| 3183 | |
} |
| 3184 | |
} |
| 3185 | 0 | } |
| 3186 | |
} |
| 3187 | |
|
| 3188 | |
|
| 3189 | 0 | if(!orgIdToCellMapping.isEmpty()){ |
| 3190 | |
|
| 3191 | 0 | SearchRequest orgIdTranslationSearchRequest = new SearchRequest("org.search.generic"); |
| 3192 | 0 | orgIdTranslationSearchRequest.addParam("org.queryParam.orgOptionalIds", new ArrayList<String>(orgIdToCellMapping.keySet())); |
| 3193 | 0 | orgIdTranslationSearchRequest.setSortColumn("org.resultColumn.orgShortName"); |
| 3194 | 0 | SearchResult orgIdTranslationSearchResult = searchDispatcher.dispatchSearch(orgIdTranslationSearchRequest); |
| 3195 | |
|
| 3196 | |
|
| 3197 | 0 | for(SearchResultRow row:orgIdTranslationSearchResult.getRows()){ |
| 3198 | |
|
| 3199 | |
|
| 3200 | 0 | String orgId=""; |
| 3201 | 0 | String orgName=""; |
| 3202 | 0 | for(SearchResultCell cell:row.getCells()){ |
| 3203 | 0 | if("org.resultColumn.orgId".equals(cell.getKey())){ |
| 3204 | 0 | orgId = cell.getValue(); |
| 3205 | 0 | continue; |
| 3206 | 0 | }else if("org.resultColumn.orgShortName".equals(cell.getKey())){ |
| 3207 | 0 | orgName = cell.getValue(); |
| 3208 | |
} |
| 3209 | |
} |
| 3210 | |
|
| 3211 | |
|
| 3212 | 0 | Set<SearchResultCell> cells = orgIdToCellMapping.get(orgId); |
| 3213 | 0 | if(cells!=null){ |
| 3214 | 0 | for(SearchResultCell cell:cells){ |
| 3215 | 0 | if(cell.getValue()==null){ |
| 3216 | 0 | cell.setValue(orgName); |
| 3217 | |
}else{ |
| 3218 | 0 | cell.setValue(cell.getValue()+"<br/>"+orgName); |
| 3219 | |
} |
| 3220 | |
} |
| 3221 | |
} |
| 3222 | 0 | } |
| 3223 | |
} |
| 3224 | |
|
| 3225 | 0 | return programSearchResults; |
| 3226 | |
} |
| 3227 | |
|
| 3228 | |
private SearchResult doDependencyAnalysisSearch(String cluId) throws MissingParameterException, DoesNotExistException { |
| 3229 | |
|
| 3230 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 3231 | |
|
| 3232 | 0 | Clu triggerClu = luDao.fetch(Clu.class, cluId); |
| 3233 | |
|
| 3234 | 0 | List<String> cluVersionIndIds = new ArrayList<String>(); |
| 3235 | 0 | cluVersionIndIds.add(triggerClu.getVersion().getVersionIndId()); |
| 3236 | |
|
| 3237 | |
|
| 3238 | 0 | List<CluSet> cluSets = luDao.getCluSetsByCluVersionIndId(cluVersionIndIds); |
| 3239 | |
|
| 3240 | |
|
| 3241 | 0 | Map<String, CluSet> cluSetMap = new HashMap<String, CluSet>(); |
| 3242 | 0 | if(cluSets!=null){ |
| 3243 | 0 | for(CluSet cluSet:cluSets){ |
| 3244 | 0 | cluSetMap.put(cluSet.getId(), cluSet); |
| 3245 | |
} |
| 3246 | |
} |
| 3247 | |
|
| 3248 | |
|
| 3249 | 0 | List<CluSet> dynamicCluSets = luDao.getAllDynamicCluSets(); |
| 3250 | 0 | if(dynamicCluSets!=null){ |
| 3251 | 0 | for(CluSet cluSet:dynamicCluSets){ |
| 3252 | 0 | MembershipQueryInfo queryInfo = LuServiceAssembler.toMembershipQueryInfo(cluSet.getMembershipQuery()); |
| 3253 | 0 | List<String> memberCluVersionIndIds = getMembershipQuerySearchResult(queryInfo); |
| 3254 | 0 | if(memberCluVersionIndIds!=null){ |
| 3255 | 0 | for(String cluVersionIndId:cluVersionIndIds){ |
| 3256 | 0 | if(memberCluVersionIndIds.contains(cluVersionIndId)){ |
| 3257 | 0 | cluSetMap.put(cluSet.getId(),cluSet); |
| 3258 | 0 | break; |
| 3259 | |
} |
| 3260 | |
} |
| 3261 | |
} |
| 3262 | 0 | } |
| 3263 | |
} |
| 3264 | |
|
| 3265 | |
|
| 3266 | |
|
| 3267 | |
|
| 3268 | |
|
| 3269 | |
|
| 3270 | 0 | SearchRequest statementSearchRequest = new SearchRequest("stmt.search.dependencyAnalysis"); |
| 3271 | |
|
| 3272 | 0 | statementSearchRequest.addParam("stmt.queryParam.cluSetIds", new ArrayList<String>(cluSetMap.keySet())); |
| 3273 | 0 | statementSearchRequest.addParam("stmt.queryParam.cluVersionIndIds", cluVersionIndIds); |
| 3274 | |
|
| 3275 | 0 | SearchResult statementSearchResult = searchDispatcher.dispatchSearch(statementSearchRequest); |
| 3276 | |
|
| 3277 | |
|
| 3278 | 0 | SearchResult searchResult = new SearchResult(); |
| 3279 | |
|
| 3280 | 0 | Map<String,List<SearchResultCell>> orgIdToCellMapping = new HashMap<String,List<SearchResultCell>>(); |
| 3281 | |
|
| 3282 | |
|
| 3283 | |
|
| 3284 | |
|
| 3285 | 0 | Set<String> processed = new HashSet<String>(); |
| 3286 | 0 | for(SearchResultRow stmtRow:statementSearchResult.getRows()){ |
| 3287 | |
|
| 3288 | |
|
| 3289 | 0 | String refObjId = null; |
| 3290 | 0 | String statementType = null; |
| 3291 | 0 | String statementTypeName = null; |
| 3292 | 0 | String rootId = null; |
| 3293 | 0 | String requirementComponentIds = null; |
| 3294 | |
|
| 3295 | 0 | for(SearchResultCell stmtCell:stmtRow.getCells()){ |
| 3296 | 0 | if("stmt.resultColumn.refObjId".equals(stmtCell.getKey())){ |
| 3297 | 0 | refObjId = stmtCell.getValue(); |
| 3298 | 0 | continue; |
| 3299 | 0 | }else if("stmt.resultColumn.statementTypeId".equals(stmtCell.getKey())){ |
| 3300 | 0 | statementType = stmtCell.getValue(); |
| 3301 | 0 | continue; |
| 3302 | 0 | }else if("stmt.resultColumn.statementTypeName".equals(stmtCell.getKey())){ |
| 3303 | 0 | statementTypeName = stmtCell.getValue(); |
| 3304 | 0 | continue; |
| 3305 | 0 | }else if("stmt.resultColumn.rootId".equals(stmtCell.getKey())){ |
| 3306 | 0 | rootId = stmtCell.getValue(); |
| 3307 | 0 | continue; |
| 3308 | 0 | }else if("stmt.resultColumn.requirementComponentIds".equals(stmtCell.getKey())){ |
| 3309 | 0 | requirementComponentIds = stmtCell.getValue(); |
| 3310 | |
} |
| 3311 | |
} |
| 3312 | |
|
| 3313 | |
|
| 3314 | 0 | Clu clu = luDao.fetch(Clu.class, refObjId); |
| 3315 | |
|
| 3316 | |
|
| 3317 | 0 | if("kuali.lu.type.Requirement".equals(clu.getLuType().getId())){ |
| 3318 | |
|
| 3319 | 0 | List<Clu> clus = luDao.getClusByRelatedCluId(clu.getId(), "kuali.lu.lu.relation.type.hasProgramRequirement"); |
| 3320 | |
|
| 3321 | 0 | rootId = clu.getId(); |
| 3322 | |
|
| 3323 | 0 | if(clus==null||clus.size()==0){ |
| 3324 | 0 | throw new RuntimeException("Statement Dependency clu found, but no parent Program exists"); |
| 3325 | 0 | }else if(clus.size()>1){ |
| 3326 | 0 | throw new RuntimeException("Statement Dependency clu can only have one parent Program relation"); |
| 3327 | |
} |
| 3328 | 0 | clu = clus.get(0); |
| 3329 | |
} |
| 3330 | |
|
| 3331 | |
|
| 3332 | 0 | String rowId = clu.getId()+"|"+statementType+"|"+rootId; |
| 3333 | |
|
| 3334 | 0 | if("Active".equals(clu.getState()) && !processed.contains(rowId)){ |
| 3335 | |
|
| 3336 | 0 | processed.add(rowId); |
| 3337 | |
|
| 3338 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
| 3339 | |
|
| 3340 | |
|
| 3341 | 0 | resultRow.addCell("lu.resultColumn.cluId",clu.getId()); |
| 3342 | 0 | resultRow.addCell("lu.resultColumn.cluType",clu.getLuType().getId()); |
| 3343 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode",clu.getOfficialIdentifier().getCode()); |
| 3344 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName",clu.getOfficialIdentifier().getShortName()); |
| 3345 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName",clu.getOfficialIdentifier().getLongName()); |
| 3346 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType",statementType); |
| 3347 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName",statementTypeName); |
| 3348 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRootId",rootId); |
| 3349 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRequirementComponentIds",requirementComponentIds); |
| 3350 | |
|
| 3351 | |
|
| 3352 | 0 | SearchResultCell orgIdsCell = new SearchResultCell("lu.resultColumn.luOptionalOversightCommitteeIds",null); |
| 3353 | 0 | resultRow.getCells().add(orgIdsCell); |
| 3354 | |
|
| 3355 | |
|
| 3356 | 0 | SearchResultCell orgNamesCell = new SearchResultCell("lu.resultColumn.luOptionalOversightCommitteeNames",null); |
| 3357 | 0 | resultRow.getCells().add(orgNamesCell); |
| 3358 | |
|
| 3359 | |
|
| 3360 | |
|
| 3361 | |
|
| 3362 | 0 | boolean differentAdminOrg = true; |
| 3363 | 0 | for(CluAdminOrg adminOrg:clu.getAdminOrgs()){ |
| 3364 | 0 | if("kuali.adminOrg.type.CurriculumOversight".equals(adminOrg.getType()) || |
| 3365 | |
"kuali.adminOrg.type.CurriculumOversightUnit".equals(adminOrg.getType())){ |
| 3366 | |
|
| 3367 | |
|
| 3368 | 0 | List<SearchResultCell> cells = orgIdToCellMapping.get(adminOrg.getOrgId()); |
| 3369 | 0 | if(cells == null){ |
| 3370 | 0 | cells = new ArrayList<SearchResultCell>(); |
| 3371 | 0 | orgIdToCellMapping.put(adminOrg.getOrgId(), cells); |
| 3372 | |
} |
| 3373 | 0 | cells.add(orgNamesCell); |
| 3374 | |
|
| 3375 | |
|
| 3376 | 0 | if(orgIdsCell.getValue()==null){ |
| 3377 | 0 | orgIdsCell.setValue(adminOrg.getId()); |
| 3378 | |
}else{ |
| 3379 | 0 | orgIdsCell.setValue(orgIdsCell.getValue()+","+adminOrg.getId()); |
| 3380 | |
} |
| 3381 | |
|
| 3382 | 0 | for(CluAdminOrg triggerAdminOrg:triggerClu.getAdminOrgs()){ |
| 3383 | 0 | if(triggerAdminOrg.getOrgId().equals(adminOrg.getOrgId())){ |
| 3384 | 0 | differentAdminOrg = false; |
| 3385 | |
} |
| 3386 | |
} |
| 3387 | 0 | } |
| 3388 | |
} |
| 3389 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRequirementDifferentAdminOrg", String.valueOf(differentAdminOrg)); |
| 3390 | |
|
| 3391 | |
|
| 3392 | 0 | searchResult.getRows().add(resultRow); |
| 3393 | |
} |
| 3394 | 0 | } |
| 3395 | |
|
| 3396 | |
|
| 3397 | 0 | if(!orgIdToCellMapping.isEmpty()){ |
| 3398 | |
|
| 3399 | 0 | SearchRequest orgIdTranslationSearchRequest = new SearchRequest("org.search.generic"); |
| 3400 | 0 | orgIdTranslationSearchRequest.addParam("org.queryParam.orgOptionalIds", new ArrayList<String>(orgIdToCellMapping.keySet())); |
| 3401 | 0 | SearchResult orgIdTranslationSearchResult = searchDispatcher.dispatchSearch(orgIdTranslationSearchRequest); |
| 3402 | |
|
| 3403 | |
|
| 3404 | 0 | for(SearchResultRow row:orgIdTranslationSearchResult.getRows()){ |
| 3405 | |
|
| 3406 | |
|
| 3407 | 0 | String orgId=""; |
| 3408 | 0 | String orgName=""; |
| 3409 | 0 | for(SearchResultCell cell:row.getCells()){ |
| 3410 | 0 | if("org.resultColumn.orgId".equals(cell.getKey())){ |
| 3411 | 0 | orgId = cell.getValue(); |
| 3412 | 0 | continue; |
| 3413 | 0 | }else if("org.resultColumn.orgShortName".equals(cell.getKey())){ |
| 3414 | 0 | orgName = cell.getValue(); |
| 3415 | |
} |
| 3416 | |
} |
| 3417 | |
|
| 3418 | |
|
| 3419 | 0 | List<SearchResultCell> cells = orgIdToCellMapping.get(orgId); |
| 3420 | 0 | if(cells!=null){ |
| 3421 | 0 | for(SearchResultCell cell:cells){ |
| 3422 | 0 | if(cell.getValue()==null){ |
| 3423 | 0 | cell.setValue(orgName); |
| 3424 | |
}else{ |
| 3425 | 0 | cell.setValue(cell.getValue()+", "+orgName); |
| 3426 | |
} |
| 3427 | |
} |
| 3428 | |
} |
| 3429 | 0 | } |
| 3430 | |
} |
| 3431 | |
|
| 3432 | |
|
| 3433 | 0 | for(CluSet cluSet:cluSetMap.values()){ |
| 3434 | 0 | if(!"AdHock".equals(cluSet.getName())){ |
| 3435 | |
|
| 3436 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
| 3437 | |
|
| 3438 | 0 | resultRow.addCell("lu.resultColumn.cluId",cluSet.getId()); |
| 3439 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName",cluSet.getName()); |
| 3440 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName",cluSet.getName()); |
| 3441 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType","cluSet"); |
| 3442 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "Course Set"); |
| 3443 | |
|
| 3444 | 0 | searchResult.getRows().add(resultRow); |
| 3445 | 0 | } |
| 3446 | |
} |
| 3447 | |
|
| 3448 | |
|
| 3449 | 0 | List<Clu> joints = luDao.getClusByRelation(cluId,"kuali.lu.relation.type.co-located"); |
| 3450 | 0 | if(joints!=null){ |
| 3451 | 0 | for(Clu clu:joints){ |
| 3452 | |
|
| 3453 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
| 3454 | |
|
| 3455 | 0 | resultRow.addCell("lu.resultColumn.cluId", clu.getId()); |
| 3456 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode", clu.getOfficialIdentifier().getCode()); |
| 3457 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName", clu.getOfficialIdentifier().getShortName()); |
| 3458 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName", clu.getOfficialIdentifier().getLongName()); |
| 3459 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType", "joint"); |
| 3460 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "jointly offered"); |
| 3461 | |
|
| 3462 | 0 | searchResult.getRows().add(resultRow); |
| 3463 | 0 | } |
| 3464 | |
} |
| 3465 | |
|
| 3466 | |
|
| 3467 | 0 | for(CluIdentifier altId:triggerClu.getAlternateIdentifiers()){ |
| 3468 | 0 | if("kuali.lu.type.CreditCourse.identifier.crosslisting".equals(altId.getType())){ |
| 3469 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
| 3470 | |
|
| 3471 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode", altId.getCode()); |
| 3472 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName", altId.getShortName()); |
| 3473 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName", altId.getLongName()); |
| 3474 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType", "crossListed"); |
| 3475 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "cross-listed"); |
| 3476 | |
|
| 3477 | 0 | searchResult.getRows().add(resultRow); |
| 3478 | 0 | } |
| 3479 | |
} |
| 3480 | |
|
| 3481 | |
|
| 3482 | 0 | Collections.sort(searchResult.getRows(), new SearchResultRowComparator("lu.resultColumn.luOptionalCode")); |
| 3483 | |
|
| 3484 | 0 | return searchResult; |
| 3485 | |
} |
| 3486 | |
|
| 3487 | 8 | public class SearchResultRowComparator implements Comparator<SearchResultRow>{ |
| 3488 | |
private String sortColumn; |
| 3489 | |
|
| 3490 | 0 | SearchResultRowComparator(String sortColumn){ |
| 3491 | 0 | super(); |
| 3492 | 0 | this.sortColumn = sortColumn; |
| 3493 | 0 | } |
| 3494 | |
|
| 3495 | |
@Override |
| 3496 | |
public int compare(SearchResultRow o1, SearchResultRow o2) { |
| 3497 | 0 | String o1SortValue = null; |
| 3498 | 0 | String o2SortValue = null; |
| 3499 | 0 | for(SearchResultCell cell:o1.getCells()){ |
| 3500 | 0 | if(sortColumn.equals(cell.getKey())){ |
| 3501 | 0 | o1SortValue = cell.getValue(); |
| 3502 | 0 | break; |
| 3503 | |
} |
| 3504 | |
} |
| 3505 | 0 | for(SearchResultCell cell:o2.getCells()){ |
| 3506 | 0 | if(sortColumn.equals(cell.getKey())){ |
| 3507 | 0 | o2SortValue = cell.getValue(); |
| 3508 | 0 | break; |
| 3509 | |
} |
| 3510 | |
} |
| 3511 | 0 | if(o1SortValue!=null){ |
| 3512 | 0 | if(o2SortValue==null){ |
| 3513 | 0 | return 1; |
| 3514 | |
} |
| 3515 | 0 | return o1SortValue.compareTo(o2SortValue); |
| 3516 | 0 | }if(o2SortValue==null){ |
| 3517 | 0 | return 0; |
| 3518 | |
} |
| 3519 | 0 | return -1; |
| 3520 | |
} |
| 3521 | |
|
| 3522 | |
} |
| 3523 | |
|
| 3524 | |
|
| 3525 | |
|
| 3526 | |
|
| 3527 | |
|
| 3528 | |
|
| 3529 | |
|
| 3530 | |
|
| 3531 | |
|
| 3532 | |
private void checkForMissingParameter(Object param, String paramName) |
| 3533 | |
throws MissingParameterException { |
| 3534 | 5124 | if (param == null) { |
| 3535 | 27 | throw new MissingParameterException(paramName + " can not be null"); |
| 3536 | |
} |
| 3537 | 5097 | } |
| 3538 | |
|
| 3539 | |
|
| 3540 | |
|
| 3541 | |
|
| 3542 | |
|
| 3543 | |
|
| 3544 | |
private void checkForEmptyList(Object param, String paramName) |
| 3545 | |
throws MissingParameterException { |
| 3546 | 214 | if (param != null && param instanceof List<?> |
| 3547 | |
&& ((List<?>) param).size() == 0) { |
| 3548 | 0 | throw new MissingParameterException(paramName |
| 3549 | |
+ " can not be an empty list"); |
| 3550 | |
} |
| 3551 | 214 | } |
| 3552 | |
|
| 3553 | |
@Override |
| 3554 | |
@Transactional(readOnly=false) |
| 3555 | |
public StatusInfo addCluSetsToCluSet(String cluSetId, List<String> cluSetIdList) |
| 3556 | |
throws CircularRelationshipException, |
| 3557 | |
DoesNotExistException, InvalidParameterException, |
| 3558 | |
MissingParameterException, OperationFailedException, |
| 3559 | |
PermissionDeniedException, UnsupportedActionException { |
| 3560 | |
|
| 3561 | 7 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 3562 | 7 | checkForMissingParameter(cluSetIdList, "cluSetIdList"); |
| 3563 | |
|
| 3564 | |
|
| 3565 | 7 | luDao.fetch(CluSet.class, cluSetId); |
| 3566 | |
|
| 3567 | 7 | for(String cluSetIdToAdd : cluSetIdList) { |
| 3568 | 19 | StatusInfo status = addCluSetToCluSet(cluSetId, cluSetIdToAdd); |
| 3569 | 15 | if (!status.getSuccess()) { |
| 3570 | 0 | return status; |
| 3571 | |
} |
| 3572 | 15 | } |
| 3573 | |
|
| 3574 | 3 | StatusInfo statusInfo = new StatusInfo(); |
| 3575 | 3 | statusInfo.setSuccess(true); |
| 3576 | |
|
| 3577 | 3 | return statusInfo; |
| 3578 | |
} |
| 3579 | |
|
| 3580 | |
@Override |
| 3581 | |
@Transactional(readOnly=false) |
| 3582 | |
public StatusInfo addClusToCluSet(List<String> cluIdList, String cluSetId) |
| 3583 | |
throws DoesNotExistException, InvalidParameterException, |
| 3584 | |
MissingParameterException, OperationFailedException, |
| 3585 | |
PermissionDeniedException, UnsupportedActionException { |
| 3586 | |
|
| 3587 | 4 | checkForMissingParameter(cluIdList, "cluIdList"); |
| 3588 | 4 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 3589 | |
|
| 3590 | 4 | for(String cluId : cluIdList) { |
| 3591 | 11 | StatusInfo status = addCluToCluSet(cluId, cluSetId); |
| 3592 | 8 | if (!status.getSuccess()) { |
| 3593 | 0 | return status; |
| 3594 | |
} |
| 3595 | 8 | } |
| 3596 | |
|
| 3597 | 1 | StatusInfo statusInfo = new StatusInfo(); |
| 3598 | 1 | statusInfo.setSuccess(true); |
| 3599 | |
|
| 3600 | 1 | return statusInfo; |
| 3601 | |
} |
| 3602 | |
|
| 3603 | |
public ValidatorFactory getValidatorFactory() { |
| 3604 | 0 | return validatorFactory; |
| 3605 | |
} |
| 3606 | |
|
| 3607 | |
public void setValidatorFactory(ValidatorFactory validatorFactory) { |
| 3608 | 3 | this.validatorFactory = validatorFactory; |
| 3609 | 3 | } |
| 3610 | |
|
| 3611 | |
|
| 3612 | |
|
| 3613 | |
@Override |
| 3614 | |
@Transactional(readOnly=false) |
| 3615 | |
public CluInfo createNewCluVersion(String versionIndCluId, String versionComment) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 3616 | |
Clu latestClu; |
| 3617 | |
Clu currentClu; |
| 3618 | |
try{ |
| 3619 | 18 | latestClu = luDao.getLatestCluVersion(versionIndCluId); |
| 3620 | 0 | }catch(NoResultException e){ |
| 3621 | 0 | throw new DoesNotExistException("There are no matching versions of this clu", e); |
| 3622 | 18 | } |
| 3623 | |
try{ |
| 3624 | 18 | currentClu = luDao.getCurrentCluVersion(versionIndCluId); |
| 3625 | 0 | }catch(NoResultException e){ |
| 3626 | 0 | throw new DoesNotExistException("There is no current version of this clu. Only current clus can be versioned. Use setCurrentCluVersion to make a clu current.", e); |
| 3627 | 18 | } |
| 3628 | |
|
| 3629 | 18 | CluInfo cluInfo = LuServiceAssembler.toCluInfo(currentClu); |
| 3630 | |
|
| 3631 | |
|
| 3632 | 18 | clearCluIds(cluInfo); |
| 3633 | |
|
| 3634 | |
|
| 3635 | 18 | CluInfo newClu = null; |
| 3636 | |
|
| 3637 | |
try { |
| 3638 | 18 | Clu clu = toCluForCreate(cluInfo.getType(), cluInfo); |
| 3639 | |
|
| 3640 | 18 | Version version = new Version(); |
| 3641 | 18 | version.setSequenceNumber(latestClu.getVersion().getSequenceNumber() + 1); |
| 3642 | 18 | version.setVersionIndId(versionIndCluId); |
| 3643 | 18 | version.setCurrentVersionStart(null); |
| 3644 | 18 | version.setCurrentVersionEnd(null); |
| 3645 | 18 | version.setVersionComment(versionComment); |
| 3646 | 18 | version.setVersionedFromId(currentClu.getId()); |
| 3647 | 18 | clu.setVersion(version); |
| 3648 | 18 | luDao.create(clu); |
| 3649 | 18 | newClu = LuServiceAssembler.toCluInfo(clu); |
| 3650 | 0 | } catch (AlreadyExistsException e) { |
| 3651 | 0 | throw new OperationFailedException("Error creating a new clu version", e); |
| 3652 | 18 | } |
| 3653 | |
|
| 3654 | 18 | return newClu; |
| 3655 | |
} |
| 3656 | |
|
| 3657 | |
private void clearCluIds(CluInfo clu) { |
| 3658 | |
|
| 3659 | 18 | clu.setState(DtoConstants.STATE_DRAFT); |
| 3660 | 18 | clu.setId(null); |
| 3661 | |
|
| 3662 | 18 | if(clu.getAccountingInfo()!=null){ |
| 3663 | 10 | clu.getAccountingInfo().setId(null); |
| 3664 | |
|
| 3665 | 10 | for(AffiliatedOrgInfo affiliatedOrg:clu.getAccountingInfo().getAffiliatedOrgs()){ |
| 3666 | 16 | affiliatedOrg.setId(null); |
| 3667 | |
} |
| 3668 | |
} |
| 3669 | 18 | for(AccreditationInfo accredation:clu.getAccreditations()){ |
| 3670 | 8 | accredation.setId(null); |
| 3671 | |
} |
| 3672 | 18 | for(AdminOrgInfo adminOrg:clu.getAdminOrgs()){ |
| 3673 | 174 | adminOrg.setId(null); |
| 3674 | |
} |
| 3675 | 18 | for(CluIdentifierInfo alternateIdentifier:clu.getAlternateIdentifiers()){ |
| 3676 | 34 | alternateIdentifier.setId(null); |
| 3677 | |
} |
| 3678 | 18 | if(clu.getFeeInfo()!=null){ |
| 3679 | 10 | clu.getFeeInfo().setId(null); |
| 3680 | 10 | for(CluFeeRecordInfo cluFeeRecord:clu.getFeeInfo().getCluFeeRecords()){ |
| 3681 | 36 | cluFeeRecord.setId(null); |
| 3682 | 36 | for(AffiliatedOrgInfo affiliatedOrg:cluFeeRecord.getAffiliatedOrgs()){ |
| 3683 | 40 | affiliatedOrg.setId(null); |
| 3684 | |
} |
| 3685 | 36 | for(CurrencyAmountInfo feeAmount:cluFeeRecord.getFeeAmounts()){ |
| 3686 | 38 | feeAmount.setId(null); |
| 3687 | |
} |
| 3688 | |
} |
| 3689 | |
} |
| 3690 | 18 | for(LuCodeInfo luCode:clu.getLuCodes()){ |
| 3691 | 36 | luCode.setId(null); |
| 3692 | |
} |
| 3693 | 18 | if(clu.getOfficialIdentifier()!=null){ |
| 3694 | 18 | clu.getOfficialIdentifier().setId(null); |
| 3695 | |
} |
| 3696 | 18 | } |
| 3697 | |
|
| 3698 | |
|
| 3699 | |
|
| 3700 | |
|
| 3701 | |
|
| 3702 | |
|
| 3703 | |
|
| 3704 | |
@Override |
| 3705 | |
@Transactional(readOnly=false) |
| 3706 | |
public StatusInfo setCurrentCluVersion(String cluVersionId, Date currentVersionStart) throws DoesNotExistException, InvalidParameterException, MissingParameterException, IllegalVersionSequencingException, OperationFailedException, PermissionDeniedException { |
| 3707 | |
|
| 3708 | 8 | Date currentDbDate = new Date(); |
| 3709 | 8 | if(currentVersionStart!=null&¤tVersionStart.compareTo(currentDbDate)<0){ |
| 3710 | 1 | throw new InvalidParameterException("currentVersionStart must be in the future."); |
| 3711 | |
} |
| 3712 | |
|
| 3713 | 7 | if(currentVersionStart==null){ |
| 3714 | 5 | currentVersionStart = currentDbDate; |
| 3715 | |
} |
| 3716 | |
|
| 3717 | |
|
| 3718 | 7 | Clu clu = luDao.fetch(Clu.class, cluVersionId); |
| 3719 | 7 | String versionIndId = clu.getVersion().getVersionIndId(); |
| 3720 | |
|
| 3721 | 7 | Clu oldClu = null; |
| 3722 | |
try{ |
| 3723 | 7 | oldClu = luDao.getCurrentCluVersion(versionIndId); |
| 3724 | 7 | }catch(NoResultException e){} |
| 3725 | |
|
| 3726 | |
|
| 3727 | 7 | if(oldClu!=null){ |
| 3728 | 7 | if(clu.getVersion().getSequenceNumber()<=oldClu.getVersion().getSequenceNumber()){ |
| 3729 | 0 | throw new OperationFailedException("Clu to make current must have been versioned from the current Clu"); |
| 3730 | |
} |
| 3731 | |
}else{ |
| 3732 | |
|
| 3733 | 0 | currentVersionStart = currentDbDate; |
| 3734 | |
} |
| 3735 | |
|
| 3736 | |
|
| 3737 | |
|
| 3738 | 7 | List<VersionDisplayInfo> versionsInFuture = luDao.getVersionsInDateRange(versionIndId, null, currentDbDate, null); |
| 3739 | 7 | for(VersionDisplayInfo versionInFuture:versionsInFuture){ |
| 3740 | 0 | if(oldClu==null || !versionInFuture.getId().equals(oldClu.getId())){ |
| 3741 | 0 | VersionEntity futureClu = luDao.fetch(Clu.class, versionInFuture.getId()); |
| 3742 | 0 | futureClu.getVersion().setCurrentVersionStart(null); |
| 3743 | 0 | futureClu.getVersion().setCurrentVersionEnd(null); |
| 3744 | 0 | futureClu = luDao.update(futureClu); |
| 3745 | 0 | } |
| 3746 | |
} |
| 3747 | |
|
| 3748 | |
|
| 3749 | 7 | if(oldClu!=null){ |
| 3750 | 7 | oldClu.getVersion().setCurrentVersionEnd(currentVersionStart); |
| 3751 | 7 | oldClu = luDao.update(oldClu); |
| 3752 | |
} |
| 3753 | |
|
| 3754 | |
|
| 3755 | 7 | clu.getVersion().setCurrentVersionStart(currentVersionStart); |
| 3756 | 7 | clu.getVersion().setCurrentVersionEnd(null); |
| 3757 | 7 | clu = luDao.update(clu); |
| 3758 | |
|
| 3759 | 7 | StatusInfo statusInfo = new StatusInfo(); |
| 3760 | 7 | statusInfo.setSuccess(true); |
| 3761 | 7 | return statusInfo; |
| 3762 | |
} |
| 3763 | |
|
| 3764 | |
@Override |
| 3765 | |
public VersionDisplayInfo getLatestVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3766 | 0 | VersionDisplayInfo versionInfo = null; |
| 3767 | 0 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3768 | |
try{ |
| 3769 | 0 | versionInfo = luDao.getLatestVersion(refObjectId, refObjectTypeURI); |
| 3770 | 0 | }catch(NoResultException e){ |
| 3771 | 0 | throw new DoesNotExistException(); |
| 3772 | 0 | } |
| 3773 | |
}else{ |
| 3774 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3775 | |
} |
| 3776 | 0 | return versionInfo; |
| 3777 | |
} |
| 3778 | |
|
| 3779 | |
@Override |
| 3780 | |
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3781 | 25 | VersionDisplayInfo versionInfo = null; |
| 3782 | 25 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3783 | |
try{ |
| 3784 | 25 | versionInfo = luDao.getCurrentCluVersionInfo(refObjectId, refObjectTypeURI); |
| 3785 | 2 | }catch(NoResultException e){ |
| 3786 | 2 | throw new DoesNotExistException(); |
| 3787 | 23 | } |
| 3788 | |
}else{ |
| 3789 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3790 | |
} |
| 3791 | 23 | return versionInfo; |
| 3792 | |
} |
| 3793 | |
|
| 3794 | |
@Override |
| 3795 | |
public VersionDisplayInfo getCurrentVersionOnDate(String refObjectTypeURI, String refObjectId, Date date) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3796 | 3 | VersionDisplayInfo versionInfo = null; |
| 3797 | 3 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3798 | |
try{ |
| 3799 | 3 | versionInfo = luDao.getCurrentVersionOnDate(refObjectId, refObjectTypeURI, date); |
| 3800 | 0 | }catch(NoResultException e){ |
| 3801 | 0 | throw new DoesNotExistException(); |
| 3802 | 3 | } |
| 3803 | |
}else{ |
| 3804 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3805 | |
} |
| 3806 | 3 | return versionInfo; |
| 3807 | |
} |
| 3808 | |
|
| 3809 | |
@Override |
| 3810 | |
public VersionDisplayInfo getFirstVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3811 | 1 | VersionDisplayInfo versionInfo = null; |
| 3812 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3813 | |
try{ |
| 3814 | 1 | versionInfo = luDao.getFirstVersion(refObjectId, refObjectTypeURI); |
| 3815 | 0 | }catch(NoResultException e){ |
| 3816 | 0 | throw new DoesNotExistException(); |
| 3817 | 1 | } |
| 3818 | |
}else{ |
| 3819 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3820 | |
} |
| 3821 | 1 | return versionInfo; |
| 3822 | |
} |
| 3823 | |
|
| 3824 | |
@Override |
| 3825 | |
public VersionDisplayInfo getVersionBySequenceNumber(String refObjectTypeURI, String refObjectId, Long sequence) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3826 | 1 | VersionDisplayInfo versionInfo = null; |
| 3827 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3828 | |
try{ |
| 3829 | 1 | versionInfo = luDao.getVersionBySequenceNumber(refObjectId, refObjectTypeURI, sequence); |
| 3830 | 0 | }catch(NoResultException e){ |
| 3831 | 0 | throw new DoesNotExistException(); |
| 3832 | 1 | } |
| 3833 | |
}else{ |
| 3834 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3835 | |
} |
| 3836 | 1 | return versionInfo; |
| 3837 | |
} |
| 3838 | |
|
| 3839 | |
@Override |
| 3840 | |
public List<VersionDisplayInfo> getVersions(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3841 | 2 | List<VersionDisplayInfo> versionInfos = null; |
| 3842 | 2 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3843 | 2 | versionInfos = luDao.getVersions(refObjectId, refObjectTypeURI); |
| 3844 | 2 | if(versionInfos==null){ |
| 3845 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
| 3846 | |
} |
| 3847 | |
}else{ |
| 3848 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3849 | |
} |
| 3850 | 2 | return versionInfos; |
| 3851 | |
} |
| 3852 | |
|
| 3853 | |
@Override |
| 3854 | |
public List<VersionDisplayInfo> getVersionsInDateRange(String refObjectTypeURI, String refObjectId, Date from, Date to) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3855 | 1 | List<VersionDisplayInfo> versionInfos = null; |
| 3856 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
| 3857 | 1 | versionInfos = luDao.getVersionsInDateRange(refObjectId, refObjectTypeURI, from, to); |
| 3858 | 1 | if(versionInfos==null){ |
| 3859 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
| 3860 | |
} |
| 3861 | |
}else{ |
| 3862 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
| 3863 | |
} |
| 3864 | 1 | return versionInfos; |
| 3865 | |
} |
| 3866 | |
|
| 3867 | |
public void setSearchDispatcher(SearchDispatcher searchDispatcher) { |
| 3868 | 1 | this.searchDispatcher = searchDispatcher; |
| 3869 | 1 | } |
| 3870 | |
} |