| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.kuali.student.enrollment.class1.lu.service.impl; |
| 16 | |
|
| 17 | |
import java.util.ArrayList; |
| 18 | |
import java.util.Collections; |
| 19 | |
import java.util.Date; |
| 20 | |
import java.util.HashMap; |
| 21 | |
import java.util.HashSet; |
| 22 | |
import java.util.Iterator; |
| 23 | |
import java.util.List; |
| 24 | |
import java.util.Map; |
| 25 | |
import java.util.Map.Entry; |
| 26 | |
import java.util.Set; |
| 27 | |
|
| 28 | |
|
| 29 | |
import javax.persistence.NoResultException; |
| 30 | |
|
| 31 | |
import org.apache.log4j.Logger; |
| 32 | |
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
| 33 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
| 34 | |
import org.kuali.student.common.dto.DtoConstants; |
| 35 | |
import org.kuali.student.common.entity.Amount; |
| 36 | |
import org.kuali.student.common.entity.TimeAmount; |
| 37 | |
import org.kuali.student.common.entity.Version; |
| 38 | |
import org.kuali.student.common.entity.VersionEntity; |
| 39 | |
|
| 40 | |
import org.kuali.student.common.search.dto.SearchRequest; |
| 41 | |
import org.kuali.student.common.search.dto.SearchResult; |
| 42 | |
import org.kuali.student.common.search.service.SearchDispatcher; |
| 43 | |
import org.kuali.student.common.validator.Validator; |
| 44 | |
import org.kuali.student.common.validator.ValidatorFactory; |
| 45 | |
import org.kuali.student.enrollment.class1.lui.service.impl.LuServiceAssembler; |
| 46 | |
import org.kuali.student.enrollment.courseoffering.service.R1ToR2CopyHelper; |
| 47 | |
import org.kuali.student.lum.lu.dao.LuDao; |
| 48 | |
import org.kuali.student.r2.lum.clu.dto.AffiliatedOrgInfo; |
| 49 | |
import org.kuali.student.r2.lum.clu.dto.CluCluRelationInfo; |
| 50 | |
import org.kuali.student.r2.lum.clu.dto.CluFeeRecordInfo; |
| 51 | |
import org.kuali.student.r2.lum.clu.dto.CluIdentifierInfo; |
| 52 | |
import org.kuali.student.r2.lum.clu.dto.CluInfo; |
| 53 | |
import org.kuali.student.r2.lum.clu.dto.CluLoRelationInfo; |
| 54 | |
import org.kuali.student.r2.lum.clu.dto.CluResultInfo; |
| 55 | |
import org.kuali.student.r2.lum.clu.dto.CluSetInfo; |
| 56 | |
import org.kuali.student.r2.lum.clu.dto.CluSetTreeViewInfo; |
| 57 | |
import org.kuali.student.r2.lum.clu.dto.LuCodeInfo; |
| 58 | |
import org.kuali.student.r2.lum.clu.dto.MembershipQueryInfo; |
| 59 | |
import org.kuali.student.r2.lum.clu.dto.ResultOptionInfo; |
| 60 | |
import org.kuali.student.lum.lu.entity.Clu; |
| 61 | |
import org.kuali.student.lum.lu.entity.CluAccounting; |
| 62 | |
import org.kuali.student.lum.lu.entity.CluAccountingAttribute; |
| 63 | |
import org.kuali.student.lum.lu.entity.CluAccreditation; |
| 64 | |
import org.kuali.student.lum.lu.entity.CluAccreditationAttribute; |
| 65 | |
import org.kuali.student.lum.lu.entity.CluAdminOrg; |
| 66 | |
import org.kuali.student.lum.lu.entity.CluAdminOrgAttribute; |
| 67 | |
import org.kuali.student.lum.lu.entity.CluAtpTypeKey; |
| 68 | |
import org.kuali.student.lum.lu.entity.CluAttribute; |
| 69 | |
import org.kuali.student.lum.lu.entity.CluCampusLocation; |
| 70 | |
import org.kuali.student.lum.lu.entity.CluCluRelation; |
| 71 | |
import org.kuali.student.lum.lu.entity.CluCluRelationAttribute; |
| 72 | |
import org.kuali.student.lum.lu.entity.CluFee; |
| 73 | |
import org.kuali.student.lum.lu.entity.CluIdentifier; |
| 74 | |
import org.kuali.student.lum.lu.entity.CluInstructor; |
| 75 | |
import org.kuali.student.lum.lu.entity.CluInstructorAttribute; |
| 76 | |
import org.kuali.student.lum.lu.entity.CluLoRelation; |
| 77 | |
import org.kuali.student.lum.lu.entity.CluLoRelationAttribute; |
| 78 | |
import org.kuali.student.lum.lu.entity.CluLoRelationType; |
| 79 | |
import org.kuali.student.lum.lu.entity.CluPublication; |
| 80 | |
import org.kuali.student.lum.lu.entity.CluPublicationAttribute; |
| 81 | |
import org.kuali.student.lum.lu.entity.CluPublicationType; |
| 82 | |
import org.kuali.student.lum.lu.entity.CluPublicationVariant; |
| 83 | |
import org.kuali.student.lum.lu.entity.CluResult; |
| 84 | |
import org.kuali.student.lum.lu.entity.CluResultType; |
| 85 | |
import org.kuali.student.lum.lu.entity.CluSet; |
| 86 | |
import org.kuali.student.lum.lu.entity.CluSetAttribute; |
| 87 | |
import org.kuali.student.lum.lu.entity.CluSetJoinVersionIndClu; |
| 88 | |
import org.kuali.student.lum.lu.entity.CluSetType; |
| 89 | |
import org.kuali.student.lum.lu.entity.DeliveryMethodType; |
| 90 | |
import org.kuali.student.lum.lu.entity.InstructionalFormatType; |
| 91 | |
import org.kuali.student.lum.lu.entity.LuCode; |
| 92 | |
import org.kuali.student.lum.lu.entity.LuCodeAttribute; |
| 93 | |
import org.kuali.student.lum.lu.entity.LuCodeType; |
| 94 | |
import org.kuali.student.lum.lu.entity.LuLuRelationType; |
| 95 | |
import org.kuali.student.lum.lu.entity.LuPublicationType; |
| 96 | |
import org.kuali.student.lum.lu.entity.LuRichText; |
| 97 | |
import org.kuali.student.lum.lu.entity.LuType; |
| 98 | |
import org.kuali.student.lum.lu.entity.MembershipQuery; |
| 99 | |
import org.kuali.student.lum.lu.entity.ResultOption; |
| 100 | |
import org.kuali.student.lum.lu.entity.ResultUsageType; |
| 101 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 102 | |
import org.kuali.student.r2.common.dto.CurrencyAmountInfo; |
| 103 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 104 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 105 | |
import org.kuali.student.r2.common.exceptions.AlreadyExistsException; |
| 106 | |
import org.kuali.student.r2.common.exceptions.CircularRelationshipException; |
| 107 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 108 | |
import org.kuali.student.r2.common.exceptions.DependentObjectsExistException; |
| 109 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 110 | |
import org.kuali.student.r2.common.exceptions.IllegalVersionSequencingException; |
| 111 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 112 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 113 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 114 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 115 | |
import org.kuali.student.r2.common.exceptions.UnsupportedActionException; |
| 116 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 117 | |
import org.kuali.student.r2.common.util.constants.LuServiceConstants; |
| 118 | |
import org.kuali.student.r2.core.search.dto.SearchRequestInfo; |
| 119 | |
import org.kuali.student.r2.core.search.dto.SearchResultCellInfo; |
| 120 | |
import org.kuali.student.r2.core.search.dto.SearchResultInfo; |
| 121 | |
import org.kuali.student.r2.core.search.dto.SearchResultRowInfo; |
| 122 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
| 123 | |
import org.kuali.student.r2.core.versionmanagement.dto.VersionDisplayInfo; |
| 124 | |
import org.kuali.student.r2.lum.clu.dto.AccreditationInfo; |
| 125 | |
import org.kuali.student.r2.lum.clu.dto.AdminOrgInfo; |
| 126 | |
import org.kuali.student.r2.lum.clu.dto.CluInstructorInfo; |
| 127 | |
import org.kuali.student.r2.lum.clu.dto.CluPublicationInfo; |
| 128 | |
import org.kuali.student.r2.lum.clu.dto.FieldInfo; |
| 129 | |
import org.kuali.student.r2.lum.clu.service.CluService; |
| 130 | |
import org.springframework.beans.BeanUtils; |
| 131 | |
import org.springframework.transaction.annotation.Transactional; |
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | 0 | public class CluServiceImpl implements CluService { |
| 136 | |
|
| 137 | |
private static final String SEARCH_KEY_DEPENDENCY_ANALYSIS = "lu.search.dependencyAnalysis"; |
| 138 | |
private static final String SEARCH_KEY_BROWSE_PROGRAM = "lu.search.browseProgram"; |
| 139 | |
private static final String SEARCH_KEY_BROWSE_VARIATIONS = "lu.search.browseVariations"; |
| 140 | |
private static final String SEARCH_KEY_RESULT_COMPONENT = "lrc.search.resultComponent"; |
| 141 | 0 | final Logger logger = Logger.getLogger(CluServiceImpl.class); |
| 142 | |
private LuDao luDao; |
| 143 | |
private ValidatorFactory validatorFactory; |
| 144 | |
private DictionaryService dictionaryServiceDelegate; |
| 145 | |
private SearchDispatcher searchDispatcher; |
| 146 | |
|
| 147 | |
public void setDictionaryServiceDelegate( |
| 148 | |
DictionaryService dictionaryServiceDelegate) { |
| 149 | 0 | this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
| 150 | 0 | } |
| 151 | |
|
| 152 | |
public DictionaryService getDictionaryServiceDelegate() { |
| 153 | 0 | return dictionaryServiceDelegate; |
| 154 | |
} |
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
@Override |
| 160 | |
public List<TypeInfo> getDeliveryMethodTypes(ContextInfo context) |
| 161 | |
throws OperationFailedException { |
| 162 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfos(luDao.find(DeliveryMethodType.class)); |
| 163 | |
} |
| 164 | |
|
| 165 | |
@Override |
| 166 | |
public TypeInfo getDeliveryMethodType( |
| 167 | |
String deliveryMethodTypeKey, ContextInfo context) throws DoesNotExistException, |
| 168 | |
InvalidParameterException, MissingParameterException, |
| 169 | |
OperationFailedException { |
| 170 | |
|
| 171 | 0 | checkForMissingParameter(deliveryMethodTypeKey, "deliveryMethodTypeKey"); |
| 172 | |
try { |
| 173 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfo(luDao.fetch( |
| 174 | |
DeliveryMethodType.class, deliveryMethodTypeKey)); |
| 175 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 176 | 0 | throw new DoesNotExistException(deliveryMethodTypeKey); |
| 177 | |
} |
| 178 | |
} |
| 179 | |
|
| 180 | |
@Override |
| 181 | |
public List<TypeInfo> getInstructionalFormatTypes(ContextInfo context) |
| 182 | |
throws OperationFailedException { |
| 183 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfos(luDao.find(InstructionalFormatType.class)); |
| 184 | |
} |
| 185 | |
|
| 186 | |
@Override |
| 187 | |
public TypeInfo getInstructionalFormatType( |
| 188 | |
String instructionalFormatTypeKey, ContextInfo context) throws DoesNotExistException, |
| 189 | |
InvalidParameterException, MissingParameterException, |
| 190 | |
OperationFailedException { |
| 191 | 0 | checkForMissingParameter(instructionalFormatTypeKey, |
| 192 | |
"instructionalFormatTypeKey"); |
| 193 | |
try { |
| 194 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfo(luDao.fetch( |
| 195 | |
InstructionalFormatType.class, instructionalFormatTypeKey)); |
| 196 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 197 | 0 | throw new DoesNotExistException(instructionalFormatTypeKey); |
| 198 | |
} |
| 199 | |
} |
| 200 | |
|
| 201 | |
@Override |
| 202 | |
public List<TypeInfo> getLuTypes(ContextInfo context) throws OperationFailedException { |
| 203 | 0 | return LuServiceAssembler.toLuTypeInfos(luDao.find(LuType.class)); |
| 204 | |
} |
| 205 | |
|
| 206 | |
@Override |
| 207 | |
public TypeInfo getLuType(String luTypeKey, ContextInfo context) throws DoesNotExistException, |
| 208 | |
InvalidParameterException, MissingParameterException, |
| 209 | |
OperationFailedException { |
| 210 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 211 | |
try { |
| 212 | 0 | return LuServiceAssembler.toLuTypeInfo(luDao.fetch(LuType.class, |
| 213 | |
luTypeKey)); |
| 214 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 215 | 0 | throw new DoesNotExistException(luTypeKey); |
| 216 | |
} |
| 217 | |
} |
| 218 | |
|
| 219 | |
@Override |
| 220 | |
public TypeInfo getLuCodeType(String luCodeTypeKey, ContextInfo context) |
| 221 | |
throws DoesNotExistException, InvalidParameterException, |
| 222 | |
MissingParameterException, OperationFailedException { |
| 223 | |
try { |
| 224 | 0 | checkForMissingParameter(luCodeTypeKey, "luCodeTypeKey"); |
| 225 | 0 | return LuServiceAssembler.toLuCodeTypeInfo(luDao.fetch( |
| 226 | |
LuCodeType.class, luCodeTypeKey)); |
| 227 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 228 | 0 | throw new DoesNotExistException(luCodeTypeKey); |
| 229 | |
} |
| 230 | |
} |
| 231 | |
|
| 232 | |
@Override |
| 233 | |
public List<TypeInfo> getLuCodeTypes(ContextInfo context) |
| 234 | |
throws OperationFailedException { |
| 235 | 0 | return LuServiceAssembler.toLuCodeTypeInfos(luDao.find(LuCodeType.class)); |
| 236 | |
} |
| 237 | |
|
| 238 | |
@Override |
| 239 | |
public List<TypeInfo> getCluCluRelationTypes(ContextInfo context) |
| 240 | |
throws OperationFailedException { |
| 241 | 0 | return LuServiceAssembler.toLuLuRelationTypeInfos(luDao.find(LuLuRelationType.class)); |
| 242 | |
} |
| 243 | |
|
| 244 | |
@Override |
| 245 | |
public TypeInfo getLuLuRelationType(String luLuRelationTypeKey, ContextInfo context) |
| 246 | |
throws OperationFailedException, MissingParameterException, |
| 247 | |
DoesNotExistException { |
| 248 | 0 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 249 | |
|
| 250 | |
LuLuRelationType luLuRelationType; |
| 251 | |
try { |
| 252 | 0 | luLuRelationType = luDao.fetch(LuLuRelationType.class, |
| 253 | |
luLuRelationTypeKey); |
| 254 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 255 | 0 | throw new DoesNotExistException(luLuRelationTypeKey); |
| 256 | 0 | } |
| 257 | 0 | return LuServiceAssembler.toLuLuRelationTypeInfo(luLuRelationType); |
| 258 | |
} |
| 259 | |
|
| 260 | |
@Override |
| 261 | |
public List<String> getAllowedLuLuRelationTypesForLuType(String luTypeKey, |
| 262 | |
String relatedLuTypeKey, ContextInfo context) throws DoesNotExistException, |
| 263 | |
InvalidParameterException, MissingParameterException, |
| 264 | |
OperationFailedException { |
| 265 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 266 | 0 | checkForMissingParameter(relatedLuTypeKey, "relatedLuTypeKey"); |
| 267 | |
|
| 268 | 0 | return luDao.getAllowedLuLuRelationTypesForLuType(luTypeKey, |
| 269 | |
relatedLuTypeKey); |
| 270 | |
} |
| 271 | |
|
| 272 | |
@Override |
| 273 | |
public List<TypeInfo> getLuPublicationTypes(ContextInfo context) |
| 274 | |
throws OperationFailedException { |
| 275 | 0 | return LuServiceAssembler.toLuPublicationTypeInfos(luDao.find(LuPublicationType.class)); |
| 276 | |
} |
| 277 | |
|
| 278 | |
@Override |
| 279 | |
public TypeInfo getLuPublicationType( |
| 280 | |
String luPublicationTypeKey, ContextInfo context) throws DoesNotExistException, |
| 281 | |
InvalidParameterException, MissingParameterException, |
| 282 | |
OperationFailedException { |
| 283 | 0 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
| 284 | |
try { |
| 285 | 0 | return LuServiceAssembler.toLuPublicationTypeInfo(luDao.fetch( |
| 286 | |
LuPublicationType.class, luPublicationTypeKey)); |
| 287 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 288 | 0 | throw new DoesNotExistException(luPublicationTypeKey); |
| 289 | |
} |
| 290 | |
} |
| 291 | |
|
| 292 | |
@Override |
| 293 | |
public List<String> getLuPublicationTypesForLuType(String luTypeKey, ContextInfo context) |
| 294 | |
throws DoesNotExistException, InvalidParameterException, |
| 295 | |
MissingParameterException, OperationFailedException { |
| 296 | 0 | throw new UnsupportedOperationException("getLuPublicationTypesForLuType"); |
| 297 | |
} |
| 298 | |
|
| 299 | |
@Override |
| 300 | |
public List<TypeInfo> getCluResultTypes(ContextInfo context) |
| 301 | |
throws OperationFailedException { |
| 302 | 0 | return LuServiceAssembler.toCluResultTypeInfos(luDao.find(CluResultType.class)); |
| 303 | |
} |
| 304 | |
|
| 305 | |
@Override |
| 306 | |
public TypeInfo getCluResultType(String cluResultTypeKey, ContextInfo context) |
| 307 | |
throws DoesNotExistException, InvalidParameterException, |
| 308 | |
MissingParameterException, OperationFailedException { |
| 309 | |
try { |
| 310 | 0 | return LuServiceAssembler.toCluResultTypeInfo(luDao.fetch( |
| 311 | |
CluResultType.class, cluResultTypeKey)); |
| 312 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 313 | 0 | throw new DoesNotExistException(cluResultTypeKey); |
| 314 | |
} |
| 315 | |
} |
| 316 | |
|
| 317 | |
@Override |
| 318 | |
public List<TypeInfo> getCluResultTypesForLuType(String luTypeKey, ContextInfo context) |
| 319 | |
throws DoesNotExistException, InvalidParameterException, |
| 320 | |
MissingParameterException, OperationFailedException { |
| 321 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 322 | 0 | return LuServiceAssembler.toCluResultTypeInfos((luDao.getAllowedCluResultTypesForLuType(luTypeKey))); |
| 323 | |
} |
| 324 | |
|
| 325 | |
@Override |
| 326 | |
public List<TypeInfo> getResultUsageTypes(ContextInfo context) |
| 327 | |
throws OperationFailedException { |
| 328 | 0 | return LuServiceAssembler.toResultUsageTypeInfos(luDao.find(ResultUsageType.class)); |
| 329 | |
} |
| 330 | |
|
| 331 | |
@Override |
| 332 | |
public TypeInfo getResultUsageType(String resultUsageTypeKey, ContextInfo context) |
| 333 | |
throws DoesNotExistException, InvalidParameterException, |
| 334 | |
MissingParameterException, OperationFailedException { |
| 335 | 0 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
| 336 | |
try { |
| 337 | 0 | return LuServiceAssembler.toResultUsageTypeInfo(luDao.fetch( |
| 338 | |
ResultUsageType.class, resultUsageTypeKey)); |
| 339 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 340 | 0 | throw new DoesNotExistException(resultUsageTypeKey); |
| 341 | |
} |
| 342 | |
} |
| 343 | |
|
| 344 | |
@Override |
| 345 | |
public List<String> getAllowedResultUsageTypesForLuType(String luTypeKey, ContextInfo context) |
| 346 | |
throws DoesNotExistException, InvalidParameterException, |
| 347 | |
MissingParameterException, OperationFailedException { |
| 348 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 349 | |
|
| 350 | 0 | return luDao.getAllowedResultUsageTypesForLuType(luTypeKey); |
| 351 | |
} |
| 352 | |
|
| 353 | |
@Override |
| 354 | |
public List<String> getAllowedResultComponentTypesForResultUsageType( |
| 355 | |
String resultUsageTypeKey, ContextInfo context) throws DoesNotExistException, |
| 356 | |
InvalidParameterException, MissingParameterException, |
| 357 | |
OperationFailedException { |
| 358 | |
|
| 359 | 0 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
| 360 | |
|
| 361 | 0 | return luDao.getAllowedResultComponentTypesForResultUsageType(resultUsageTypeKey); |
| 362 | |
} |
| 363 | |
|
| 364 | |
@Override |
| 365 | |
public TypeInfo getCluLoRelationType( |
| 366 | |
String cluLoRelationTypeKey, ContextInfo context) throws DoesNotExistException, |
| 367 | |
InvalidParameterException, MissingParameterException, |
| 368 | |
OperationFailedException { |
| 369 | 0 | checkForMissingParameter(cluLoRelationTypeKey, "cluLoRelationTypeKey"); |
| 370 | |
|
| 371 | |
CluLoRelationType cluLoRelationType; |
| 372 | |
try { |
| 373 | 0 | cluLoRelationType = luDao.fetch( |
| 374 | |
CluLoRelationType.class, cluLoRelationTypeKey); |
| 375 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 376 | 0 | throw new DoesNotExistException(cluLoRelationTypeKey); |
| 377 | 0 | } |
| 378 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfo(cluLoRelationType); |
| 379 | |
} |
| 380 | |
|
| 381 | |
@Override |
| 382 | |
public List<TypeInfo> getCluLoRelationTypes(ContextInfo context) |
| 383 | |
throws OperationFailedException { |
| 384 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfos(luDao.find(CluLoRelationType.class)); |
| 385 | |
} |
| 386 | |
|
| 387 | |
@Override |
| 388 | |
public List<String> getAllowedCluLoRelationTypesForLuType(String luTypeKey, ContextInfo context) |
| 389 | |
throws DoesNotExistException, InvalidParameterException, |
| 390 | |
MissingParameterException, OperationFailedException { |
| 391 | |
|
| 392 | 0 | checkForMissingParameter(luTypeKey, luTypeKey); |
| 393 | |
|
| 394 | 0 | return luDao.getAllowedCluLoRelationTypesForLuType(luTypeKey); |
| 395 | |
} |
| 396 | |
|
| 397 | |
@Override |
| 398 | |
public List<TypeInfo> getCluSetTypes(ContextInfo context) |
| 399 | |
throws OperationFailedException { |
| 400 | 0 | return LuServiceAssembler.toCluSetTypeInfos(luDao.find(CluSetType.class)); |
| 401 | |
} |
| 402 | |
|
| 403 | |
@Override |
| 404 | |
public TypeInfo getCluSetType(String cluSetTypeKey, ContextInfo context) |
| 405 | |
throws DoesNotExistException, InvalidParameterException, |
| 406 | |
MissingParameterException, OperationFailedException { |
| 407 | 0 | checkForMissingParameter(cluSetTypeKey, "cluSetTypeKey"); |
| 408 | |
try { |
| 409 | 0 | return LuServiceAssembler.toCluSetTypeInfo(luDao.fetch( |
| 410 | |
CluSetType.class, cluSetTypeKey)); |
| 411 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 412 | 0 | throw new DoesNotExistException(cluSetTypeKey); |
| 413 | |
} |
| 414 | |
} |
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
|
| 420 | |
@Override |
| 421 | |
public CluInfo getClu(String cluId, ContextInfo context) throws DoesNotExistException, |
| 422 | |
InvalidParameterException, MissingParameterException, |
| 423 | |
OperationFailedException { |
| 424 | |
|
| 425 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 426 | |
|
| 427 | |
Clu clu; |
| 428 | |
try { |
| 429 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 430 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 431 | 0 | throw new DoesNotExistException(cluId); |
| 432 | 0 | } |
| 433 | 0 | return LuServiceAssembler.toCluInfo(clu); |
| 434 | |
} |
| 435 | |
|
| 436 | |
@Override |
| 437 | |
public List<CluInfo> getClusByIds(List<String> cluIds, ContextInfo context) |
| 438 | |
throws DoesNotExistException, InvalidParameterException, |
| 439 | |
MissingParameterException, OperationFailedException { |
| 440 | 0 | checkForMissingParameter(cluIds, "cluIds"); |
| 441 | 0 | checkForEmptyList(cluIds, "cluIds"); |
| 442 | 0 | List<Clu> clus = luDao.getClusByIdList(cluIds); |
| 443 | 0 | return LuServiceAssembler.toCluInfos(clus); |
| 444 | |
} |
| 445 | |
|
| 446 | |
@Override |
| 447 | |
public List<CluInfo> getClusByLuType(String luTypeKey, String luState, ContextInfo context) |
| 448 | |
throws DoesNotExistException, InvalidParameterException, |
| 449 | |
MissingParameterException, OperationFailedException { |
| 450 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 451 | 0 | checkForMissingParameter(luState, "lustate"); |
| 452 | 0 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
| 453 | 0 | return LuServiceAssembler.toCluInfos(clus); |
| 454 | |
} |
| 455 | |
|
| 456 | |
@Override |
| 457 | |
public List<String> getCluIdsByLuType(String luTypeKey, String luState, ContextInfo context) |
| 458 | |
throws DoesNotExistException, InvalidParameterException, |
| 459 | |
MissingParameterException, OperationFailedException { |
| 460 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 461 | 0 | checkForMissingParameter(luState, "luState"); |
| 462 | 0 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
| 463 | 0 | List<String> Ids = new ArrayList<String>(clus.size()); |
| 464 | 0 | for (Clu clu : clus) { |
| 465 | 0 | Ids.add(clu.getId()); |
| 466 | |
} |
| 467 | 0 | return Ids; |
| 468 | |
} |
| 469 | |
|
| 470 | |
|
| 471 | |
@Override |
| 472 | |
public List<String> getAllowedCluCluRelationTypesByClu(String cluId, |
| 473 | |
String relatedCluId, ContextInfo context) throws DoesNotExistException, |
| 474 | |
InvalidParameterException, MissingParameterException, |
| 475 | |
OperationFailedException { |
| 476 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 477 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 478 | |
|
| 479 | 0 | return luDao.getAllowedLuLuRelationTypesByCluId(cluId, relatedCluId); |
| 480 | |
} |
| 481 | |
|
| 482 | |
@Override |
| 483 | |
public List<CluInfo> getClusByRelatedCluAndRelationType(String relatedCluId, |
| 484 | |
String luLuRelationTypeKey, ContextInfo context) throws DoesNotExistException, |
| 485 | |
InvalidParameterException, MissingParameterException, |
| 486 | |
OperationFailedException { |
| 487 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 488 | 0 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 489 | |
|
| 490 | 0 | List<Clu> clus = luDao.getClusByRelation(relatedCluId, |
| 491 | |
luLuRelationTypeKey); |
| 492 | 0 | List<CluInfo> result = LuServiceAssembler.toCluInfos(clus); |
| 493 | 0 | return result; |
| 494 | |
|
| 495 | |
} |
| 496 | |
|
| 497 | |
@Override |
| 498 | |
public List<String> getCluIdsByRelatedCluAndRelationType(String relatedCluId, |
| 499 | |
String cluCluRelationTypeKey, |
| 500 | |
ContextInfo contextInfo) |
| 501 | |
throws DoesNotExistException, |
| 502 | |
InvalidParameterException, |
| 503 | |
MissingParameterException, |
| 504 | |
OperationFailedException, |
| 505 | |
PermissionDeniedException { |
| 506 | |
|
| 507 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 508 | 0 | checkForMissingParameter(cluCluRelationTypeKey, "cluCluRelationTypeKey"); |
| 509 | |
|
| 510 | 0 | List<String> cluIds = luDao.getCluIdsByRelatedCluId(relatedCluId, cluCluRelationTypeKey); |
| 511 | 0 | return cluIds; |
| 512 | |
} |
| 513 | |
|
| 514 | |
@Override |
| 515 | |
public List<CluInfo> getRelatedClusByCluAndRelationType(String relatedCluId, |
| 516 | |
String cluCLuRelationTypeKey, |
| 517 | |
ContextInfo contextInfo) |
| 518 | |
throws DoesNotExistException, |
| 519 | |
InvalidParameterException, |
| 520 | |
MissingParameterException, |
| 521 | |
OperationFailedException, |
| 522 | |
PermissionDeniedException { |
| 523 | 0 | checkForMissingParameter(relatedCluId, "cluId"); |
| 524 | 0 | checkForMissingParameter(cluCLuRelationTypeKey, "cluCLuRelationTypeKey"); |
| 525 | 0 | List<Clu> relatedClus = luDao.getRelatedClusByCluId(relatedCluId, |
| 526 | |
cluCLuRelationTypeKey); |
| 527 | 0 | return LuServiceAssembler.toCluInfos(relatedClus); |
| 528 | |
} |
| 529 | |
|
| 530 | |
@Override |
| 531 | |
public List<String> getRelatedCluIdsByCluAndRelationType(String cluId, |
| 532 | |
String luLuRelationTypeKey, ContextInfo context) throws DoesNotExistException, |
| 533 | |
InvalidParameterException, MissingParameterException, |
| 534 | |
OperationFailedException { |
| 535 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 536 | 0 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 537 | 0 | List<String> relatedCluIds = luDao.getRelatedCluIdsByCluId(cluId, |
| 538 | |
luLuRelationTypeKey); |
| 539 | 0 | return relatedCluIds; |
| 540 | |
} |
| 541 | |
|
| 542 | |
@Override |
| 543 | |
public CluCluRelationInfo getCluCluRelation(String cluCluRelationId, ContextInfo context) |
| 544 | |
throws DoesNotExistException, InvalidParameterException, |
| 545 | |
MissingParameterException, OperationFailedException { |
| 546 | 0 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 547 | |
try { |
| 548 | 0 | return LuServiceAssembler.toCluCluRelationInfo(luDao.fetch( |
| 549 | |
CluCluRelation.class, cluCluRelationId)); |
| 550 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 551 | 0 | throw new DoesNotExistException(cluCluRelationId); |
| 552 | |
} |
| 553 | |
} |
| 554 | |
|
| 555 | |
@Override |
| 556 | |
public List<CluCluRelationInfo> getCluCluRelationsByClu(String cluId, ContextInfo context) |
| 557 | |
throws DoesNotExistException, InvalidParameterException, |
| 558 | |
MissingParameterException, OperationFailedException { |
| 559 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 560 | 0 | List<CluCluRelation> cluCluRelations = luDao.getCluCluRelationsByClu(cluId); |
| 561 | 0 | return LuServiceAssembler.toCluCluRelationInfos(cluCluRelations); |
| 562 | |
} |
| 563 | |
|
| 564 | |
|
| 565 | |
@Override |
| 566 | |
public List<CluPublicationInfo> getCluPublicationsByClu(String cluId, ContextInfo context) |
| 567 | |
throws DoesNotExistException, InvalidParameterException, |
| 568 | |
MissingParameterException, OperationFailedException { |
| 569 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 570 | 0 | List<CluPublication> cluPublications = luDao.getCluPublicationsByCluId(cluId); |
| 571 | 0 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
| 572 | |
} |
| 573 | |
|
| 574 | |
@Override |
| 575 | |
public List<CluPublicationInfo> getCluPublicationsByType( |
| 576 | |
String luPublicationTypeKey, ContextInfo context) throws DoesNotExistException, |
| 577 | |
InvalidParameterException, MissingParameterException, |
| 578 | |
OperationFailedException { |
| 579 | 0 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
| 580 | 0 | List<CluPublication> cluPublications = luDao.getCluPublicationsByType(luPublicationTypeKey); |
| 581 | 0 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
| 582 | |
} |
| 583 | |
|
| 584 | |
@Override |
| 585 | |
public CluPublicationInfo getCluPublication(String cluPublicationId, ContextInfo context) |
| 586 | |
throws DoesNotExistException, InvalidParameterException, |
| 587 | |
MissingParameterException, OperationFailedException { |
| 588 | 0 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 589 | |
CluPublication cluPublication; |
| 590 | |
try { |
| 591 | 0 | cluPublication = luDao.fetch(CluPublication.class, cluPublicationId); |
| 592 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 593 | 0 | throw new DoesNotExistException(cluPublicationId); |
| 594 | 0 | } |
| 595 | 0 | return LuServiceAssembler.toCluPublicationInfo(cluPublication); |
| 596 | |
} |
| 597 | |
|
| 598 | |
|
| 599 | |
@Override |
| 600 | |
public CluResultInfo getCluResult(String cluResultId, ContextInfo context) |
| 601 | |
throws DoesNotExistException, InvalidParameterException, |
| 602 | |
MissingParameterException, OperationFailedException { |
| 603 | |
|
| 604 | 0 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 605 | |
|
| 606 | |
CluResult cluResult; |
| 607 | |
try { |
| 608 | 0 | cluResult = luDao.fetch(CluResult.class, cluResultId); |
| 609 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 610 | 0 | throw new DoesNotExistException(cluResultId); |
| 611 | 0 | } |
| 612 | 0 | return LuServiceAssembler.toCluResultInfo(cluResult); |
| 613 | |
} |
| 614 | |
|
| 615 | |
@Override |
| 616 | |
public List<CluResultInfo> getCluResultByClu(String cluId, ContextInfo context) |
| 617 | |
throws DoesNotExistException, InvalidParameterException, |
| 618 | |
MissingParameterException, OperationFailedException { |
| 619 | |
|
| 620 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 621 | |
|
| 622 | 0 | return LuServiceAssembler.toCluResultInfos(luDao.getCluResultByClu(cluId)); |
| 623 | |
} |
| 624 | |
|
| 625 | |
@Override |
| 626 | |
public List<String> getCluIdsByResultUsageType(String resultUsageTypeKey, ContextInfo context) |
| 627 | |
throws DoesNotExistException, InvalidParameterException, |
| 628 | |
MissingParameterException, OperationFailedException { |
| 629 | 0 | return luDao.getCluIdsByResultUsageType(resultUsageTypeKey); |
| 630 | |
} |
| 631 | |
|
| 632 | |
@Override |
| 633 | |
public List<String> getCluIdsByResultComponent(String resultComponentId, ContextInfo context) |
| 634 | |
throws DoesNotExistException, InvalidParameterException, |
| 635 | |
MissingParameterException, OperationFailedException { |
| 636 | 0 | return luDao.getCluIdsByResultComponentId(resultComponentId); |
| 637 | |
} |
| 638 | |
|
| 639 | |
|
| 640 | |
@Override |
| 641 | |
public CluLoRelationInfo getCluLoRelation(String cluLoRelationId, ContextInfo context) |
| 642 | |
throws DoesNotExistException, InvalidParameterException, |
| 643 | |
MissingParameterException, OperationFailedException, |
| 644 | |
PermissionDeniedException { |
| 645 | |
|
| 646 | 0 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 647 | |
|
| 648 | |
CluLoRelation reltn; |
| 649 | |
try { |
| 650 | 0 | reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 651 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 652 | 0 | throw new DoesNotExistException(cluLoRelationId); |
| 653 | 0 | } |
| 654 | 0 | return LuServiceAssembler.toCluLoRelationInfo(reltn); |
| 655 | |
|
| 656 | |
} |
| 657 | |
|
| 658 | |
@Override |
| 659 | |
public List<CluLoRelationInfo> getCluLoRelationsByClu(String cluId, ContextInfo context) |
| 660 | |
throws DoesNotExistException, InvalidParameterException, |
| 661 | |
MissingParameterException, OperationFailedException { |
| 662 | |
|
| 663 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 664 | 0 | List<CluLoRelation> cluLoRelations = luDao.getCluLoRelationsByClu(cluId); |
| 665 | 0 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
| 666 | |
|
| 667 | |
} |
| 668 | |
|
| 669 | |
@Override |
| 670 | |
public List<CluLoRelationInfo> getCluLoRelationsByLo(String loId, ContextInfo context) |
| 671 | |
throws DoesNotExistException, InvalidParameterException, |
| 672 | |
MissingParameterException, OperationFailedException { |
| 673 | 0 | checkForMissingParameter(loId, "loId"); |
| 674 | 0 | List<CluLoRelation> cluLoRelations = luDao.getCluLoRelationsByLo(loId); |
| 675 | 0 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
| 676 | |
} |
| 677 | |
|
| 678 | |
|
| 679 | |
@Override |
| 680 | |
public List<String> getResourceRequirementsForClu(String cluId, ContextInfo context) |
| 681 | |
throws DoesNotExistException, InvalidParameterException, |
| 682 | |
MissingParameterException, OperationFailedException { |
| 683 | 0 | return new ArrayList<String>(); |
| 684 | |
} |
| 685 | |
|
| 686 | |
|
| 687 | |
@Override |
| 688 | |
public CluSetInfo getCluSet(String cluSetId, ContextInfo context) |
| 689 | |
throws DoesNotExistException, InvalidParameterException, |
| 690 | |
MissingParameterException, OperationFailedException, |
| 691 | |
PermissionDeniedException { |
| 692 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 693 | |
CluSet cluSet; |
| 694 | |
try { |
| 695 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 696 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 697 | 0 | throw new DoesNotExistException(cluSetId); |
| 698 | 0 | } |
| 699 | 0 | CluSetInfo cluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
| 700 | 0 | setMembershipQuerySearchResult(cluSetInfo); |
| 701 | 0 | return cluSetInfo; |
| 702 | |
} |
| 703 | |
|
| 704 | |
@Override |
| 705 | |
public CluSetTreeViewInfo getCluSetTreeView(String cluSetId, ContextInfo context) |
| 706 | |
throws DoesNotExistException, InvalidParameterException, |
| 707 | |
MissingParameterException, OperationFailedException, |
| 708 | |
PermissionDeniedException { |
| 709 | |
|
| 710 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 711 | 0 | CluSetInfo cluSet = getCluSet(cluSetId, context); |
| 712 | 0 | if (cluSet == null) { |
| 713 | 0 | return null; |
| 714 | |
} |
| 715 | |
|
| 716 | 0 | CluSetTreeViewInfo cluSetTreeView = new CluSetTreeViewInfo(); |
| 717 | 0 | getCluSetTreeViewHelper(cluSet, cluSetTreeView, context); |
| 718 | 0 | return cluSetTreeView; |
| 719 | |
} |
| 720 | |
|
| 721 | |
|
| 722 | |
|
| 723 | |
|
| 724 | |
|
| 725 | |
|
| 726 | |
|
| 727 | |
|
| 728 | |
|
| 729 | |
|
| 730 | |
|
| 731 | |
|
| 732 | |
|
| 733 | |
private void getCluSetTreeViewHelper(CluSetInfo cluSetInfo, |
| 734 | |
CluSetTreeViewInfo cluSetTreeViewInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 735 | 0 | cluSetTreeViewInfo.setName(cluSetInfo.getName()); |
| 736 | 0 | cluSetTreeViewInfo.setDescr(cluSetInfo.getDescr()); |
| 737 | 0 | cluSetTreeViewInfo.setEffectiveDate(cluSetInfo.getEffectiveDate()); |
| 738 | 0 | cluSetTreeViewInfo.setExpirationDate(cluSetInfo.getExpirationDate()); |
| 739 | 0 | cluSetTreeViewInfo.setAdminOrg(cluSetInfo.getAdminOrg()); |
| 740 | 0 | cluSetTreeViewInfo.setIsReusable(cluSetInfo.getIsReusable()); |
| 741 | 0 | cluSetTreeViewInfo.setIsReferenceable(cluSetInfo.getIsReferenceable()); |
| 742 | 0 | cluSetTreeViewInfo.setMeta(cluSetInfo.getMeta()); |
| 743 | 0 | cluSetTreeViewInfo.setAttributes(cluSetInfo.getAttributes()); |
| 744 | 0 | cluSetTreeViewInfo.setTypeKey(cluSetInfo.getTypeKey()); |
| 745 | 0 | cluSetTreeViewInfo.setStateKey(cluSetInfo.getStateKey()); |
| 746 | 0 | cluSetTreeViewInfo.setId(cluSetInfo.getId()); |
| 747 | |
|
| 748 | 0 | if (!cluSetInfo.getCluSetIds().isEmpty()) { |
| 749 | 0 | for (String cluSetId : cluSetInfo.getCluSetIds()) { |
| 750 | 0 | CluSetInfo subCluSet = getCluSet(cluSetId, context); |
| 751 | 0 | List<CluSetTreeViewInfo> cluSets = |
| 752 | |
cluSetTreeViewInfo.getCluSets() == null |
| 753 | |
? new ArrayList<CluSetTreeViewInfo>(0) : cluSetTreeViewInfo.getCluSets(); |
| 754 | |
|
| 755 | 0 | CluSetTreeViewInfo subCluSetTreeViewInfo = new CluSetTreeViewInfo(); |
| 756 | 0 | getCluSetTreeViewHelper(subCluSet, subCluSetTreeViewInfo, context); |
| 757 | 0 | cluSets.add(subCluSetTreeViewInfo); |
| 758 | |
|
| 759 | 0 | cluSetTreeViewInfo.setCluSets(cluSets); |
| 760 | 0 | } |
| 761 | |
} |
| 762 | 0 | List<CluInfo> clus = new ArrayList<CluInfo>(); |
| 763 | 0 | for (String cluId : cluSetInfo.getCluIds()) { |
| 764 | 0 | if (cluId != null) { |
| 765 | |
|
| 766 | |
|
| 767 | 0 | Clu clu = luDao.getCurrentCluVersion(cluId); |
| 768 | 0 | CluInfo cluInfo = new CluInfo(); |
| 769 | 0 | cluInfo.setId(clu.getId()); |
| 770 | 0 | cluInfo.setType(clu.getLuType().getId()); |
| 771 | 0 | cluInfo.setOfficialIdentifier(LuServiceAssembler.toCluIdentifierInfo(clu.getOfficialIdentifier())); |
| 772 | 0 | clus.add(cluInfo); |
| 773 | 0 | } |
| 774 | |
} |
| 775 | 0 | cluSetTreeViewInfo.setClus(clus); |
| 776 | 0 | } |
| 777 | |
|
| 778 | |
@Override |
| 779 | |
public List<CluSetInfo> getCluSetsByIds(List<String> cluSetIds, ContextInfo context) |
| 780 | |
throws DoesNotExistException, InvalidParameterException, |
| 781 | |
MissingParameterException, OperationFailedException, |
| 782 | |
PermissionDeniedException { |
| 783 | 0 | checkForMissingParameter(cluSetIds, "cluSetIds"); |
| 784 | 0 | checkForEmptyList(cluSetIds, "cluSetIds"); |
| 785 | 0 | List<CluSet> cluSets = luDao.getCluSetInfoByIdList(cluSetIds); |
| 786 | 0 | return LuServiceAssembler.toCluSetInfos(cluSets); |
| 787 | |
} |
| 788 | |
|
| 789 | |
@Override |
| 790 | |
public List<String> getCluSetIdsFromCluSet(String cluSetId, ContextInfo context) |
| 791 | |
throws DoesNotExistException, InvalidParameterException, |
| 792 | |
MissingParameterException, OperationFailedException, |
| 793 | |
PermissionDeniedException { |
| 794 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 795 | |
CluSet cluSet; |
| 796 | |
try { |
| 797 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 798 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 799 | 0 | throw new DoesNotExistException(cluSetId); |
| 800 | 0 | } |
| 801 | 0 | List<String> Ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
| 802 | 0 | if (cluSet.getCluSets() != null) { |
| 803 | 0 | for (CluSet cluSet2 : cluSet.getCluSets()) { |
| 804 | 0 | Ids.add(cluSet2.getId()); |
| 805 | |
} |
| 806 | |
} |
| 807 | 0 | return Ids; |
| 808 | |
} |
| 809 | |
|
| 810 | |
@Override |
| 811 | |
public Boolean isCluSetDynamic(String cluSetId, ContextInfo context) |
| 812 | |
throws DoesNotExistException, InvalidParameterException, |
| 813 | |
MissingParameterException, OperationFailedException, |
| 814 | |
PermissionDeniedException { |
| 815 | 0 | return null; |
| 816 | |
} |
| 817 | |
|
| 818 | |
@Override |
| 819 | |
public List<CluInfo> getClusFromCluSet(String cluSetId, ContextInfo context) |
| 820 | |
throws DoesNotExistException, InvalidParameterException, |
| 821 | |
MissingParameterException, OperationFailedException, |
| 822 | |
PermissionDeniedException { |
| 823 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 824 | |
CluSet cluSet; |
| 825 | |
try { |
| 826 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 827 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 828 | 0 | throw new DoesNotExistException(cluSetId); |
| 829 | 0 | } |
| 830 | 0 | List<CluInfo> clus = new ArrayList<CluInfo>(cluSet.getCluVerIndIds().size()); |
| 831 | 0 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
| 832 | 0 | clus.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluSetJnClu.getCluVersionIndId()))); |
| 833 | |
} |
| 834 | 0 | return clus; |
| 835 | |
} |
| 836 | |
|
| 837 | |
@Override |
| 838 | |
public List<String> getCluIdsFromCluSet(String cluSetId, ContextInfo context) |
| 839 | |
throws DoesNotExistException, InvalidParameterException, |
| 840 | |
MissingParameterException, OperationFailedException, |
| 841 | |
PermissionDeniedException { |
| 842 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 843 | |
CluSet cluSet; |
| 844 | |
try { |
| 845 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 846 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 847 | 0 | throw new DoesNotExistException(cluSetId); |
| 848 | 0 | } |
| 849 | 0 | List<String> Ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
| 850 | 0 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
| 851 | 0 | Ids.add(cluSetJnClu.getCluVersionIndId()); |
| 852 | |
} |
| 853 | 0 | return Ids; |
| 854 | |
} |
| 855 | |
|
| 856 | |
@Override |
| 857 | |
public List<CluInfo> getAllClusInCluSet(String cluSetId, ContextInfo context) |
| 858 | |
throws DoesNotExistException, InvalidParameterException, |
| 859 | |
MissingParameterException, OperationFailedException, |
| 860 | |
PermissionDeniedException { |
| 861 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 862 | 0 | List<String> cluIndIds = new ArrayList<String>(); |
| 863 | |
CluSet cluSet; |
| 864 | |
try { |
| 865 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 866 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 867 | 0 | throw new DoesNotExistException(cluSetId); |
| 868 | 0 | } |
| 869 | 0 | findClusInCluSet(cluIndIds, cluSet); |
| 870 | 0 | List<CluInfo> infos = new ArrayList<CluInfo>(cluIndIds.size()); |
| 871 | 0 | for (String cluIndId : cluIndIds) { |
| 872 | 0 | infos.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluIndId))); |
| 873 | |
} |
| 874 | 0 | return infos; |
| 875 | |
} |
| 876 | |
|
| 877 | |
private void findClusInCluSet(List<String> clus, CluSet parentCluSet) |
| 878 | |
throws DoesNotExistException { |
| 879 | 0 | List<String> processedCluSetIds = new ArrayList<String>(); |
| 880 | 0 | doFindClusInCluSet(processedCluSetIds, clus, parentCluSet); |
| 881 | 0 | } |
| 882 | |
|
| 883 | |
private void doFindClusInCluSet(List<String> processedCluSetIds, |
| 884 | |
List<String> clus, CluSet parentCluSet) { |
| 885 | 0 | for (CluSetJoinVersionIndClu join : parentCluSet.getCluVerIndIds()) { |
| 886 | 0 | if (!clus.contains(join.getCluVersionIndId())) { |
| 887 | 0 | clus.add(join.getCluVersionIndId()); |
| 888 | |
} |
| 889 | |
} |
| 890 | 0 | if (parentCluSet.getCluSets() != null) { |
| 891 | 0 | for (CluSet cluSet : parentCluSet.getCluSets()) { |
| 892 | |
|
| 893 | 0 | if (!processedCluSetIds.contains(cluSet.getId())) { |
| 894 | 0 | processedCluSetIds.add(cluSet.getId()); |
| 895 | 0 | doFindClusInCluSet(processedCluSetIds, clus, cluSet); |
| 896 | |
} |
| 897 | |
} |
| 898 | |
} |
| 899 | 0 | } |
| 900 | |
|
| 901 | |
@Override |
| 902 | |
public List<String> getAllCluIdsInCluSet(String cluSetId, ContextInfo context) |
| 903 | |
throws DoesNotExistException, InvalidParameterException, |
| 904 | |
MissingParameterException, OperationFailedException, |
| 905 | |
PermissionDeniedException { |
| 906 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 907 | 0 | List<String> Ids = new ArrayList<String>(); |
| 908 | |
CluSet cluSet; |
| 909 | |
try { |
| 910 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 911 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 912 | 0 | throw new DoesNotExistException(cluSetId); |
| 913 | 0 | } |
| 914 | 0 | findClusInCluSet(Ids, cluSet); |
| 915 | 0 | return Ids; |
| 916 | |
} |
| 917 | |
|
| 918 | |
@Override |
| 919 | |
public Boolean isCluInCluSet(String cluId, String cluSetId, ContextInfo context) |
| 920 | |
throws DoesNotExistException, InvalidParameterException, |
| 921 | |
MissingParameterException, OperationFailedException, |
| 922 | |
PermissionDeniedException { |
| 923 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 924 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 925 | 0 | return luDao.isCluInCluSet(cluId, cluSetId); |
| 926 | |
} |
| 927 | |
|
| 928 | |
|
| 929 | |
|
| 930 | |
|
| 931 | |
@Override |
| 932 | |
public List<ValidationResultInfo> validateClu(String validationType, |
| 933 | |
CluInfo cluInfo, ContextInfo context) throws DoesNotExistException, |
| 934 | |
InvalidParameterException, MissingParameterException, |
| 935 | |
OperationFailedException { |
| 936 | 0 | checkForMissingParameter(validationType, "validationType"); |
| 937 | 0 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 938 | |
|
| 939 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluInfo.class.getName()); |
| 940 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 941 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = defaultValidator.validateObject(cluInfo, objStructure); |
| 942 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 943 | 0 | return r2vrs; |
| 944 | |
} |
| 945 | |
|
| 946 | |
@Override |
| 947 | |
@Transactional(readOnly = false) |
| 948 | |
public CluInfo createClu(String luTypeKey, CluInfo cluInfo, ContextInfo context) |
| 949 | |
throws DataValidationErrorException, |
| 950 | |
DoesNotExistException, InvalidParameterException, |
| 951 | |
MissingParameterException, OperationFailedException, |
| 952 | |
PermissionDeniedException { |
| 953 | |
Clu clu; |
| 954 | |
try { |
| 955 | 0 | clu = toCluForCreate(luTypeKey, cluInfo, context); |
| 956 | 0 | } catch (AlreadyExistsException ex) { |
| 957 | 0 | throw new OperationFailedException(ex.getMessage(), ex); |
| 958 | 0 | } |
| 959 | |
|
| 960 | 0 | if (clu.getVersion() == null) { |
| 961 | 0 | clu.setVersion(new Version()); |
| 962 | |
} |
| 963 | 0 | clu.getVersion().setCurrentVersionStart(new Date()); |
| 964 | 0 | luDao.create(clu); |
| 965 | 0 | return LuServiceAssembler.toCluInfo(clu); |
| 966 | |
} |
| 967 | |
|
| 968 | |
public Clu toCluForCreate(String luTypeKey, CluInfo cluInfo, ContextInfo context) |
| 969 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 970 | |
DoesNotExistException, InvalidParameterException, |
| 971 | |
MissingParameterException, OperationFailedException, |
| 972 | |
PermissionDeniedException { |
| 973 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
| 974 | 0 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 975 | |
|
| 976 | |
|
| 977 | 0 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo, context); |
| 978 | 0 | if (null != val && val.size() > 0) { |
| 979 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 980 | |
} |
| 981 | |
|
| 982 | 0 | Clu clu = new Clu(); |
| 983 | |
|
| 984 | |
LuType luType; |
| 985 | |
try { |
| 986 | 0 | luType = luDao.fetch(LuType.class, luTypeKey); |
| 987 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 988 | 0 | throw new DoesNotExistException(luTypeKey); |
| 989 | 0 | } |
| 990 | 0 | clu.setLuType(luType); |
| 991 | |
|
| 992 | 0 | if (cluInfo.getOfficialIdentifier() != null) { |
| 993 | 0 | clu.setOfficialIdentifier(LuServiceAssembler.createOfficialIdentifier(cluInfo, luDao)); |
| 994 | |
} |
| 995 | 0 | clu.setAlternateIdentifiers(LuServiceAssembler.createAlternateIdentifiers(cluInfo, luDao)); |
| 996 | 0 | if (cluInfo.getDescr() != null) { |
| 997 | 0 | LuRichText descr = LuServiceAssembler.toRichText(LuRichText.class, cluInfo.getDescr()); |
| 998 | 0 | if (descr.getPlain() != null || descr.getFormatted() != null) { |
| 999 | 0 | clu.setDescr(descr); |
| 1000 | |
} |
| 1001 | |
} |
| 1002 | |
|
| 1003 | 0 | if (clu.getAdminOrgs() == null) { |
| 1004 | 0 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>(0)); |
| 1005 | |
} |
| 1006 | 0 | List<CluAdminOrg> adminOrgs = clu.getAdminOrgs(); |
| 1007 | 0 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
| 1008 | 0 | CluAdminOrg instructor = new CluAdminOrg(); |
| 1009 | 0 | BeanUtils.copyProperties(orgInfo, instructor, |
| 1010 | |
new String[]{"attributes"}); |
| 1011 | 0 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1012 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
| 1013 | |
instructor, luDao)); |
| 1014 | 0 | instructor.setClu(clu); |
| 1015 | 0 | adminOrgs.add(instructor); |
| 1016 | 0 | } |
| 1017 | |
|
| 1018 | 0 | if (cluInfo.getPrimaryInstructor() != null) { |
| 1019 | 0 | CluInstructor primaryInstructor = new CluInstructor(); |
| 1020 | 0 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), |
| 1021 | |
primaryInstructor, new String[]{"attributes"}); |
| 1022 | 0 | primaryInstructor.setAttributes(LuServiceAssembler.toGenericAttributes(CluInstructorAttribute.class, cluInfo.getPrimaryInstructor().getAttributes(), |
| 1023 | |
primaryInstructor, luDao)); |
| 1024 | 0 | clu.setPrimaryInstructor(primaryInstructor); |
| 1025 | |
} |
| 1026 | |
|
| 1027 | 0 | if (clu.getInstructors() == null) { |
| 1028 | 0 | clu.setInstructors(new ArrayList<CluInstructor>(0)); |
| 1029 | |
} |
| 1030 | 0 | List<CluInstructor> instructors = clu.getInstructors(); |
| 1031 | 0 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
| 1032 | 0 | CluInstructor instructor = new CluInstructor(); |
| 1033 | 0 | BeanUtils.copyProperties(instructorInfo, instructor, |
| 1034 | |
new String[]{"attributes"}); |
| 1035 | 0 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1036 | |
CluInstructorAttribute.class, instructorInfo.getAttributes(), instructor, luDao)); |
| 1037 | 0 | instructors.add(instructor); |
| 1038 | 0 | } |
| 1039 | |
|
| 1040 | 0 | if (cluInfo.getStdDuration() != null) { |
| 1041 | 0 | clu.setStdDuration(LuServiceAssembler.toTimeAmount(cluInfo.getStdDuration())); |
| 1042 | |
} |
| 1043 | |
|
| 1044 | 0 | if (clu.getLuCodes() == null) { |
| 1045 | 0 | clu.setLuCodes(new ArrayList<LuCode>(0)); |
| 1046 | |
} |
| 1047 | 0 | List<LuCode> luCodes = clu.getLuCodes(); |
| 1048 | 0 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
| 1049 | 0 | LuCode luCode = new LuCode(); |
| 1050 | 0 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1051 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
| 1052 | |
luDao)); |
| 1053 | 0 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[]{ |
| 1054 | |
"attributes", "meta"}); |
| 1055 | 0 | if (luCodeInfo.getDescr() != null) { |
| 1056 | 0 | luCode.setDescr(luCodeInfo.getDescr().getPlain()); |
| 1057 | |
} |
| 1058 | 0 | luCode.setClu(clu); |
| 1059 | 0 | luCodes.add(luCode); |
| 1060 | 0 | } |
| 1061 | |
|
| 1062 | 0 | if (clu.getOfferedAtpTypes() == null) { |
| 1063 | 0 | clu.setOfferedAtpTypes(new ArrayList<CluAtpTypeKey>(0)); |
| 1064 | |
} |
| 1065 | 0 | List<CluAtpTypeKey> offeredAtpTypes = clu.getOfferedAtpTypes(); |
| 1066 | 0 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
| 1067 | 0 | CluAtpTypeKey cluAtpTypeKey = new CluAtpTypeKey(); |
| 1068 | 0 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
| 1069 | 0 | cluAtpTypeKey.setClu(clu); |
| 1070 | 0 | offeredAtpTypes.add(cluAtpTypeKey); |
| 1071 | 0 | } |
| 1072 | |
|
| 1073 | |
|
| 1074 | 0 | if (cluInfo.getFeeInfo() != null) { |
| 1075 | 0 | CluFee cluFee = null; |
| 1076 | |
try { |
| 1077 | 0 | cluFee = LuServiceAssembler.toCluFee(clu, false, cluInfo.getFeeInfo(), luDao); |
| 1078 | 0 | } catch (VersionMismatchException e) { |
| 1079 | |
|
| 1080 | 0 | } |
| 1081 | 0 | clu.setFee(cluFee); |
| 1082 | |
} |
| 1083 | |
|
| 1084 | 0 | if (cluInfo.getAccountingInfo() != null) { |
| 1085 | 0 | CluAccounting cluAccounting = new CluAccounting(); |
| 1086 | 0 | cluAccounting.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1087 | |
CluAccountingAttribute.class, cluInfo.getAccountingInfo().getAttributes(), cluAccounting, luDao)); |
| 1088 | 0 | cluAccounting.setAffiliatedOrgs(LuServiceAssembler.toAffiliatedOrgs(false, cluAccounting.getAffiliatedOrgs(), |
| 1089 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
| 1090 | |
luDao)); |
| 1091 | 0 | clu.setAccounting(cluAccounting); |
| 1092 | |
} |
| 1093 | |
|
| 1094 | 0 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1095 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
| 1096 | |
|
| 1097 | |
|
| 1098 | 0 | if (cluInfo.getIntensity() != null) { |
| 1099 | 0 | clu.setIntensity(LuServiceAssembler.toAmount(cluInfo.getIntensity())); |
| 1100 | |
} |
| 1101 | |
|
| 1102 | 0 | if (clu.getCampusLocations() == null) { |
| 1103 | 0 | clu.setCampusLocations(new ArrayList<CluCampusLocation>(0)); |
| 1104 | |
} |
| 1105 | 0 | List<CluCampusLocation> locations = clu.getCampusLocations(); |
| 1106 | 0 | for (String locationName : cluInfo.getCampusLocations()) { |
| 1107 | 0 | CluCampusLocation location = new CluCampusLocation(); |
| 1108 | 0 | location.setCampusLocation(locationName); |
| 1109 | 0 | location.setClu(clu); |
| 1110 | 0 | locations.add(location); |
| 1111 | 0 | } |
| 1112 | |
|
| 1113 | 0 | if (clu.getAccreditations() == null) { |
| 1114 | 0 | clu.setAccreditations(new ArrayList<CluAccreditation>(0)); |
| 1115 | |
} |
| 1116 | 0 | List<CluAccreditation> accreditations = clu.getAccreditations(); |
| 1117 | 0 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
| 1118 | 0 | CluAccreditation accreditation = new CluAccreditation(); |
| 1119 | 0 | BeanUtils.copyProperties(accreditationInfo, accreditation, |
| 1120 | |
new String[]{"attributes"}); |
| 1121 | 0 | accreditation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1122 | |
CluAccreditationAttribute.class, accreditationInfo.getAttributes(), accreditation, luDao)); |
| 1123 | 0 | accreditations.add(accreditation); |
| 1124 | 0 | } |
| 1125 | |
|
| 1126 | |
|
| 1127 | 0 | BeanUtils.copyProperties(cluInfo, clu, new String[]{"luType", |
| 1128 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
| 1129 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
| 1130 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
| 1131 | |
"meta", "versionInfo", "intensity", |
| 1132 | |
"campusLocations", "accreditations", |
| 1133 | |
"adminOrgs"}); |
| 1134 | |
|
| 1135 | 0 | return clu; |
| 1136 | |
} |
| 1137 | |
|
| 1138 | |
@Override |
| 1139 | |
@Transactional(readOnly = false) |
| 1140 | |
public CluInfo updateClu(String cluId, CluInfo cluInfo, ContextInfo context) |
| 1141 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1142 | |
InvalidParameterException, MissingParameterException, |
| 1143 | |
OperationFailedException, PermissionDeniedException, |
| 1144 | |
VersionMismatchException { |
| 1145 | |
|
| 1146 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1147 | 0 | checkForMissingParameter(cluInfo, "cluInfo"); |
| 1148 | |
|
| 1149 | |
|
| 1150 | 0 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo, context); |
| 1151 | 0 | if (null != val && val.size() > 0) { |
| 1152 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1153 | |
} |
| 1154 | |
|
| 1155 | |
Clu clu; |
| 1156 | |
try { |
| 1157 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 1158 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1159 | 0 | throw new DoesNotExistException(cluId); |
| 1160 | 0 | } |
| 1161 | |
|
| 1162 | 0 | if (!String.valueOf(clu.getVersionNumber()).equals( |
| 1163 | |
cluInfo.getMeta().getVersionInd())) { |
| 1164 | 0 | throw new VersionMismatchException( |
| 1165 | |
"Clu to be updated is not the current version"); |
| 1166 | |
} |
| 1167 | |
|
| 1168 | |
LuType luType; |
| 1169 | |
try { |
| 1170 | 0 | luType = luDao.fetch(LuType.class, cluInfo.getTypeKey()); |
| 1171 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1172 | 0 | throw new DoesNotExistException(cluInfo.getTypeKey()); |
| 1173 | 0 | } |
| 1174 | 0 | clu.setLuType(luType); |
| 1175 | |
|
| 1176 | 0 | if (cluInfo.getOfficialIdentifier() != null) { |
| 1177 | 0 | LuServiceAssembler.updateOfficialIdentifier(clu, cluInfo, luDao); |
| 1178 | 0 | } else if (clu.getOfficialIdentifier() != null) { |
| 1179 | 0 | luDao.delete(clu.getOfficialIdentifier()); |
| 1180 | |
} |
| 1181 | |
|
| 1182 | |
|
| 1183 | |
|
| 1184 | |
|
| 1185 | 0 | Map<String, CluIdentifier> oldAltIdMap = new HashMap<String, CluIdentifier>(); |
| 1186 | 0 | LuServiceAssembler.updateAlternateIdentifier(oldAltIdMap, clu, cluInfo, luDao); |
| 1187 | |
|
| 1188 | 0 | for (Entry<String, CluIdentifier> entry : oldAltIdMap.entrySet()) { |
| 1189 | 0 | luDao.delete(entry.getValue()); |
| 1190 | |
} |
| 1191 | |
|
| 1192 | 0 | if (cluInfo.getDescr() != null && (cluInfo.getDescr().getPlain() != null || cluInfo.getDescr().getFormatted() != null)) { |
| 1193 | 0 | if (clu.getDescr() == null) { |
| 1194 | 0 | clu.setDescr(new LuRichText()); |
| 1195 | |
} |
| 1196 | 0 | BeanUtils.copyProperties(cluInfo.getDescr(), clu.getDescr()); |
| 1197 | 0 | } else if (clu.getDescr() != null) { |
| 1198 | 0 | luDao.delete(clu.getDescr()); |
| 1199 | 0 | clu.setDescr(null); |
| 1200 | |
} |
| 1201 | |
|
| 1202 | 0 | if (cluInfo.getPrimaryInstructor() != null) { |
| 1203 | 0 | if (clu.getPrimaryInstructor() == null) { |
| 1204 | 0 | clu.setPrimaryInstructor(new CluInstructor()); |
| 1205 | |
} |
| 1206 | 0 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), clu.getPrimaryInstructor(), new String[]{"attributes"}); |
| 1207 | 0 | clu.getPrimaryInstructor().setAttributes( |
| 1208 | |
LuServiceAssembler.toGenericAttributes( |
| 1209 | |
CluInstructorAttribute.class, cluInfo.getPrimaryInstructor().getAttributes(), |
| 1210 | |
clu.getPrimaryInstructor(), luDao)); |
| 1211 | 0 | } else if (clu.getPrimaryInstructor() != null) { |
| 1212 | 0 | luDao.delete(clu.getPrimaryInstructor()); |
| 1213 | |
} |
| 1214 | |
|
| 1215 | |
|
| 1216 | |
|
| 1217 | |
|
| 1218 | 0 | Map<String, CluInstructor> oldInstructorMap = new HashMap<String, CluInstructor>(); |
| 1219 | 0 | for (CluInstructor cluInstructor : clu.getInstructors()) { |
| 1220 | 0 | oldInstructorMap.put(cluInstructor.getOrgId() + "_" |
| 1221 | |
+ cluInstructor.getPersonId(), cluInstructor); |
| 1222 | |
} |
| 1223 | 0 | clu.getInstructors().clear(); |
| 1224 | |
|
| 1225 | |
|
| 1226 | |
|
| 1227 | |
|
| 1228 | 0 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
| 1229 | 0 | CluInstructor cluInstructor = oldInstructorMap.remove(instructorInfo.getOrgId() + "_" |
| 1230 | |
+ instructorInfo.getPersonId()); |
| 1231 | 0 | if (cluInstructor == null) { |
| 1232 | 0 | cluInstructor = new CluInstructor(); |
| 1233 | |
} |
| 1234 | |
|
| 1235 | 0 | BeanUtils.copyProperties(instructorInfo, cluInstructor, |
| 1236 | |
new String[]{"attributes"}); |
| 1237 | 0 | cluInstructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1238 | |
CluInstructorAttribute.class, instructorInfo.getAttributes(), cluInstructor, luDao)); |
| 1239 | 0 | clu.getInstructors().add(cluInstructor); |
| 1240 | 0 | } |
| 1241 | |
|
| 1242 | |
|
| 1243 | 0 | for (Entry<String, CluInstructor> entry : oldInstructorMap.entrySet()) { |
| 1244 | 0 | luDao.delete(entry.getValue()); |
| 1245 | |
} |
| 1246 | |
|
| 1247 | 0 | if (cluInfo.getStdDuration() != null) { |
| 1248 | 0 | if (clu.getStdDuration() == null) { |
| 1249 | 0 | clu.setStdDuration(new TimeAmount()); |
| 1250 | |
} |
| 1251 | 0 | BeanUtils.copyProperties(cluInfo.getStdDuration(), clu.getStdDuration()); |
| 1252 | 0 | } else if (clu.getStdDuration() != null) { |
| 1253 | 0 | luDao.delete(clu.getStdDuration()); |
| 1254 | |
} |
| 1255 | |
|
| 1256 | |
|
| 1257 | |
|
| 1258 | |
|
| 1259 | 0 | Map<String, LuCode> oldLuCodeMap = new HashMap<String, LuCode>(); |
| 1260 | 0 | for (LuCode luCode : clu.getLuCodes()) { |
| 1261 | 0 | oldLuCodeMap.put(luCode.getId(), luCode); |
| 1262 | |
} |
| 1263 | 0 | clu.getLuCodes().clear(); |
| 1264 | |
|
| 1265 | |
|
| 1266 | |
|
| 1267 | |
|
| 1268 | 0 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
| 1269 | 0 | LuCode luCode = oldLuCodeMap.remove(luCodeInfo.getId()); |
| 1270 | 0 | if (luCode == null) { |
| 1271 | 0 | luCode = new LuCode(); |
| 1272 | |
} else { |
| 1273 | 0 | if (!String.valueOf(luCode.getVersionNumber()).equals( |
| 1274 | |
luCodeInfo.getMeta().getVersionInd())) { |
| 1275 | 0 | throw new VersionMismatchException( |
| 1276 | |
"LuCode to be updated is not the current version"); |
| 1277 | |
} |
| 1278 | |
} |
| 1279 | |
|
| 1280 | 0 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1281 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
| 1282 | |
luDao)); |
| 1283 | 0 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[]{ |
| 1284 | |
"attributes", "meta"}); |
| 1285 | 0 | if (luCodeInfo.getDescr() != null) { |
| 1286 | 0 | luCode.setDescr(luCodeInfo.getDescr().getPlain()); |
| 1287 | |
} |
| 1288 | 0 | luCode.setClu(clu); |
| 1289 | 0 | clu.getLuCodes().add(luCode); |
| 1290 | 0 | } |
| 1291 | |
|
| 1292 | |
|
| 1293 | 0 | for (Entry<String, LuCode> entry : oldLuCodeMap.entrySet()) { |
| 1294 | 0 | luDao.delete(entry.getValue()); |
| 1295 | |
} |
| 1296 | |
|
| 1297 | |
|
| 1298 | |
|
| 1299 | |
|
| 1300 | 0 | Map<String, CluAtpTypeKey> oldOfferedAtpTypesMap = new HashMap<String, CluAtpTypeKey>(); |
| 1301 | 0 | for (CluAtpTypeKey cluAtpTypeKey : clu.getOfferedAtpTypes()) { |
| 1302 | 0 | oldOfferedAtpTypesMap.put(cluAtpTypeKey.getAtpTypeKey(), |
| 1303 | |
cluAtpTypeKey); |
| 1304 | |
} |
| 1305 | 0 | clu.getOfferedAtpTypes().clear(); |
| 1306 | |
|
| 1307 | |
|
| 1308 | |
|
| 1309 | |
|
| 1310 | 0 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
| 1311 | 0 | CluAtpTypeKey cluAtpTypeKey = oldOfferedAtpTypesMap.remove(atpTypeKey); |
| 1312 | 0 | if (cluAtpTypeKey == null) { |
| 1313 | 0 | cluAtpTypeKey = new CluAtpTypeKey(); |
| 1314 | |
} |
| 1315 | |
|
| 1316 | 0 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
| 1317 | 0 | cluAtpTypeKey.setClu(clu); |
| 1318 | 0 | clu.getOfferedAtpTypes().add(cluAtpTypeKey); |
| 1319 | 0 | } |
| 1320 | |
|
| 1321 | |
|
| 1322 | 0 | for (Entry<String, CluAtpTypeKey> entry : oldOfferedAtpTypesMap.entrySet()) { |
| 1323 | 0 | luDao.delete(entry.getValue()); |
| 1324 | |
} |
| 1325 | |
|
| 1326 | 0 | if (cluInfo.getFeeInfo() != null) { |
| 1327 | 0 | if (clu.getFee() == null) { |
| 1328 | 0 | clu.setFee(LuServiceAssembler.toCluFee(clu, false, cluInfo.getFeeInfo(), luDao)); |
| 1329 | |
} else { |
| 1330 | 0 | clu.setFee(LuServiceAssembler.toCluFee(clu, true, cluInfo.getFeeInfo(), luDao)); |
| 1331 | |
} |
| 1332 | 0 | } else if (clu.getFee() != null) { |
| 1333 | 0 | luDao.delete(clu.getFee()); |
| 1334 | 0 | clu.setFee(null); |
| 1335 | |
} |
| 1336 | |
|
| 1337 | 0 | if (cluInfo.getAccountingInfo() != null) { |
| 1338 | 0 | if (clu.getAccounting() == null) { |
| 1339 | 0 | clu.setAccounting(new CluAccounting()); |
| 1340 | |
} |
| 1341 | 0 | clu.getAccounting().setAttributes( |
| 1342 | |
LuServiceAssembler.toGenericAttributes( |
| 1343 | |
CluAccountingAttribute.class, cluInfo.getAccountingInfo().getAttributes(), clu.getAccounting(), luDao)); |
| 1344 | 0 | clu.getAccounting().setAffiliatedOrgs(LuServiceAssembler.toAffiliatedOrgs(true, clu.getAccounting().getAffiliatedOrgs(), |
| 1345 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
| 1346 | |
luDao)); |
| 1347 | |
|
| 1348 | 0 | } else if (clu.getAccounting() != null) { |
| 1349 | 0 | clu.setAccounting(null); |
| 1350 | |
} |
| 1351 | |
|
| 1352 | 0 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1353 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
| 1354 | |
|
| 1355 | 0 | if (cluInfo.getIntensity() != null) { |
| 1356 | 0 | if (clu.getIntensity() == null) { |
| 1357 | 0 | clu.setIntensity(new Amount()); |
| 1358 | |
} |
| 1359 | 0 | BeanUtils.copyProperties(cluInfo.getIntensity(), clu.getIntensity()); |
| 1360 | 0 | } else if (clu.getIntensity() != null) { |
| 1361 | 0 | luDao.delete(clu.getIntensity()); |
| 1362 | |
} |
| 1363 | |
|
| 1364 | |
|
| 1365 | |
|
| 1366 | |
|
| 1367 | 0 | Map<String, CluCampusLocation> oldLocationsMap = new HashMap<String, CluCampusLocation>(); |
| 1368 | 0 | for (CluCampusLocation campus : clu.getCampusLocations()) { |
| 1369 | 0 | oldLocationsMap.put(campus.getCampusLocation(), campus); |
| 1370 | |
} |
| 1371 | 0 | clu.getCampusLocations().clear(); |
| 1372 | |
|
| 1373 | |
|
| 1374 | |
|
| 1375 | |
|
| 1376 | 0 | for (String locationName : cluInfo.getCampusLocations()) { |
| 1377 | 0 | CluCampusLocation location = oldLocationsMap.remove(locationName); |
| 1378 | 0 | if (location == null) { |
| 1379 | 0 | location = new CluCampusLocation(); |
| 1380 | |
} |
| 1381 | |
|
| 1382 | 0 | location.setCampusLocation(locationName); |
| 1383 | 0 | location.setClu(clu); |
| 1384 | 0 | clu.getCampusLocations().add(location); |
| 1385 | 0 | } |
| 1386 | |
|
| 1387 | |
|
| 1388 | 0 | for (Entry<String, CluCampusLocation> entry : oldLocationsMap.entrySet()) { |
| 1389 | 0 | luDao.delete(entry.getValue()); |
| 1390 | |
} |
| 1391 | |
|
| 1392 | |
|
| 1393 | |
|
| 1394 | |
|
| 1395 | 0 | Map<String, CluAccreditation> oldAccreditationMap = new HashMap<String, CluAccreditation>(); |
| 1396 | 0 | for (CluAccreditation cluAccreditation : clu.getAccreditations()) { |
| 1397 | 0 | oldAccreditationMap.put(cluAccreditation.getId(), |
| 1398 | |
cluAccreditation); |
| 1399 | |
} |
| 1400 | 0 | clu.getAccreditations().clear(); |
| 1401 | |
|
| 1402 | |
|
| 1403 | |
|
| 1404 | |
|
| 1405 | 0 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
| 1406 | 0 | CluAccreditation cluAccreditation = null; |
| 1407 | 0 | if (accreditationInfo.getId() != null) { |
| 1408 | 0 | cluAccreditation = oldAccreditationMap.remove(accreditationInfo.getId()); |
| 1409 | |
} |
| 1410 | |
|
| 1411 | 0 | if (cluAccreditation == null) { |
| 1412 | 0 | cluAccreditation = new CluAccreditation(); |
| 1413 | |
} |
| 1414 | |
|
| 1415 | 0 | BeanUtils.copyProperties(accreditationInfo, cluAccreditation, |
| 1416 | |
new String[]{"attributes"}); |
| 1417 | 0 | cluAccreditation.setAttributes(LuServiceAssembler.toGenericAttributes(CluAccreditationAttribute.class, |
| 1418 | |
accreditationInfo.getAttributes(), |
| 1419 | |
cluAccreditation, luDao)); |
| 1420 | 0 | clu.getAccreditations().add(cluAccreditation); |
| 1421 | 0 | } |
| 1422 | |
|
| 1423 | |
|
| 1424 | 0 | for (Entry<String, CluAccreditation> entry : oldAccreditationMap.entrySet()) { |
| 1425 | 0 | luDao.delete(entry.getValue()); |
| 1426 | |
} |
| 1427 | |
|
| 1428 | |
|
| 1429 | |
|
| 1430 | |
|
| 1431 | 0 | Map<String, CluAdminOrg> oldAdminOrgsMap = new HashMap<String, CluAdminOrg>(); |
| 1432 | 0 | if (clu.getAdminOrgs() != null) { |
| 1433 | 0 | for (CluAdminOrg cluOrg : clu.getAdminOrgs()) { |
| 1434 | 0 | oldAdminOrgsMap.put(cluOrg.getId(), cluOrg); |
| 1435 | |
} |
| 1436 | |
} |
| 1437 | 0 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>()); |
| 1438 | |
|
| 1439 | |
|
| 1440 | |
|
| 1441 | |
|
| 1442 | 0 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
| 1443 | 0 | CluAdminOrg cluOrg = null; |
| 1444 | 0 | if (orgInfo.getId() != null) { |
| 1445 | 0 | cluOrg = oldAdminOrgsMap.remove(orgInfo.getId()); |
| 1446 | |
} |
| 1447 | |
|
| 1448 | 0 | if (cluOrg == null) { |
| 1449 | 0 | cluOrg = new CluAdminOrg(); |
| 1450 | |
} |
| 1451 | |
|
| 1452 | |
|
| 1453 | 0 | BeanUtils.copyProperties(orgInfo, cluOrg, |
| 1454 | |
new String[]{"attributes", "id"}); |
| 1455 | 0 | cluOrg.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1456 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
| 1457 | |
cluOrg, luDao)); |
| 1458 | 0 | cluOrg.setClu(clu); |
| 1459 | 0 | clu.getAdminOrgs().add(cluOrg); |
| 1460 | 0 | } |
| 1461 | |
|
| 1462 | 0 | for (Entry<String, CluAdminOrg> entry : oldAdminOrgsMap.entrySet()) { |
| 1463 | 0 | luDao.delete(entry.getValue()); |
| 1464 | |
} |
| 1465 | |
|
| 1466 | |
|
| 1467 | 0 | BeanUtils.copyProperties(cluInfo, clu, new String[]{"luType", |
| 1468 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
| 1469 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
| 1470 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
| 1471 | |
"meta", "intensity", |
| 1472 | |
"campusLocations", "accreditations", |
| 1473 | |
"adminOrgs"}); |
| 1474 | 0 | Clu updated = null; |
| 1475 | |
try { |
| 1476 | 0 | updated = luDao.update(clu); |
| 1477 | 0 | } catch (Exception e) { |
| 1478 | 0 | logger.error("Exception occured: ", e); |
| 1479 | 0 | } |
| 1480 | 0 | return LuServiceAssembler.toCluInfo(updated); |
| 1481 | |
} |
| 1482 | |
|
| 1483 | |
@Override |
| 1484 | |
@Transactional(readOnly = false) |
| 1485 | |
public StatusInfo deleteClu(String cluId, ContextInfo context) throws DoesNotExistException, |
| 1486 | |
InvalidParameterException, MissingParameterException, |
| 1487 | |
DependentObjectsExistException, OperationFailedException, |
| 1488 | |
PermissionDeniedException { |
| 1489 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1490 | |
try { |
| 1491 | 0 | luDao.delete(Clu.class, cluId); |
| 1492 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1493 | 0 | throw new DoesNotExistException(cluId); |
| 1494 | 0 | } |
| 1495 | |
|
| 1496 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 1497 | 0 | statusInfo.setSuccess(true); |
| 1498 | |
|
| 1499 | 0 | return statusInfo; |
| 1500 | |
} |
| 1501 | |
|
| 1502 | |
@Override |
| 1503 | |
@Transactional(readOnly = false) |
| 1504 | |
public CluInfo updateCluState(String cluId, String luState, ContextInfo context) |
| 1505 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1506 | |
InvalidParameterException, MissingParameterException, |
| 1507 | |
OperationFailedException, PermissionDeniedException { |
| 1508 | |
|
| 1509 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1510 | 0 | checkForMissingParameter(luState, "luState"); |
| 1511 | |
Clu clu; |
| 1512 | |
try { |
| 1513 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 1514 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1515 | 0 | throw new DoesNotExistException(cluId); |
| 1516 | 0 | } |
| 1517 | 0 | clu.setState(luState); |
| 1518 | 0 | Clu updated = luDao.update(clu); |
| 1519 | 0 | return LuServiceAssembler.toCluInfo(updated); |
| 1520 | |
} |
| 1521 | |
|
| 1522 | |
@Override |
| 1523 | |
public List<ValidationResultInfo> validateCluCluRelation(String validationTypeKey, |
| 1524 | |
String cluId, String relatedCluId, |
| 1525 | |
String cluCluRelationTypeKey, |
| 1526 | |
CluCluRelationInfo cluCluRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1527 | |
|
| 1528 | 0 | checkForMissingParameter(validationTypeKey, "validationTypeKey"); |
| 1529 | 0 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1530 | |
|
| 1531 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluCluRelationInfo.class.getName()); |
| 1532 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1533 | |
|
| 1534 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = defaultValidator.validateObject(cluCluRelationInfo, objStructure); |
| 1535 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 1536 | 0 | return r2vrs; |
| 1537 | |
} |
| 1538 | |
|
| 1539 | |
@Override |
| 1540 | |
@Transactional(readOnly = false) |
| 1541 | |
public CluCluRelationInfo createCluCluRelation(String cluId, |
| 1542 | |
String relatedCluId, String luLuRelationTypeKey, |
| 1543 | |
CluCluRelationInfo cluCluRelationInfo, ContextInfo context) |
| 1544 | |
throws DataValidationErrorException, |
| 1545 | |
DoesNotExistException, InvalidParameterException, |
| 1546 | |
MissingParameterException, OperationFailedException, |
| 1547 | |
PermissionDeniedException, CircularRelationshipException { |
| 1548 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1549 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
| 1550 | 0 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
| 1551 | 0 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1552 | |
|
| 1553 | 0 | if (cluId.equals(relatedCluId)) { |
| 1554 | 0 | throw new CircularRelationshipException( |
| 1555 | |
"Can not relate a Clu to itself"); |
| 1556 | |
} |
| 1557 | |
|
| 1558 | |
|
| 1559 | 0 | List<ValidationResultInfo> val = |
| 1560 | |
validateCluCluRelation("SYSTEM", cluId, relatedCluId, luLuRelationTypeKey, cluCluRelationInfo, context); |
| 1561 | 0 | if (null != val && val.size() > 0) { |
| 1562 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1563 | |
} |
| 1564 | |
|
| 1565 | |
|
| 1566 | |
Clu clu; |
| 1567 | |
try { |
| 1568 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 1569 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1570 | 0 | throw new DoesNotExistException(cluId); |
| 1571 | 0 | } |
| 1572 | |
Clu relatedClu; |
| 1573 | |
try { |
| 1574 | 0 | relatedClu = luDao.fetch(Clu.class, relatedCluId); |
| 1575 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1576 | 0 | throw new DoesNotExistException(relatedCluId); |
| 1577 | 0 | } |
| 1578 | |
|
| 1579 | 0 | CluCluRelation cluCluRelation = new CluCluRelation(); |
| 1580 | 0 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
| 1581 | |
new String[]{"cluId", "relatedCluId", |
| 1582 | |
"isCluRelationRequired", "attributes", "meta"}); |
| 1583 | |
|
| 1584 | 0 | cluCluRelation.setClu(clu); |
| 1585 | 0 | cluCluRelation.setRelatedClu(relatedClu); |
| 1586 | 0 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo.getIsCluRelationRequired() == null ? true : cluCluRelationInfo.getIsCluRelationRequired()); |
| 1587 | |
|
| 1588 | 0 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1589 | |
CluCluRelationAttribute.class, cluCluRelationInfo.getAttributes(), cluCluRelation, luDao)); |
| 1590 | |
|
| 1591 | |
LuLuRelationType luLuRelationType; |
| 1592 | |
try { |
| 1593 | 0 | luLuRelationType = luDao.fetch(LuLuRelationType.class, |
| 1594 | |
luLuRelationTypeKey); |
| 1595 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1596 | 0 | throw new DoesNotExistException(luLuRelationTypeKey); |
| 1597 | 0 | } |
| 1598 | |
|
| 1599 | 0 | cluCluRelation.setLuLuRelationType(luLuRelationType); |
| 1600 | |
|
| 1601 | 0 | luDao.create(cluCluRelation); |
| 1602 | |
|
| 1603 | 0 | return LuServiceAssembler.toCluCluRelationInfo(cluCluRelation); |
| 1604 | |
} |
| 1605 | |
|
| 1606 | |
@Override |
| 1607 | |
@Transactional(readOnly = false) |
| 1608 | |
public CluCluRelationInfo updateCluCluRelation( |
| 1609 | |
final String cluCluRelationId, |
| 1610 | |
final CluCluRelationInfo cluCluRelationInfo, ContextInfo context) |
| 1611 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1612 | |
InvalidParameterException, MissingParameterException, |
| 1613 | |
OperationFailedException, PermissionDeniedException, |
| 1614 | |
VersionMismatchException { |
| 1615 | 0 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 1616 | 0 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
| 1617 | |
|
| 1618 | |
|
| 1619 | 0 | List<ValidationResultInfo> val = |
| 1620 | |
validateCluCluRelation("SYSTEM", |
| 1621 | |
cluCluRelationInfo.getCluId(), |
| 1622 | |
cluCluRelationInfo.getRelatedCluId(), |
| 1623 | |
cluCluRelationInfo.getTypeKey(), |
| 1624 | |
cluCluRelationInfo, |
| 1625 | |
context); |
| 1626 | 0 | if (null != val && val.size() > 0) { |
| 1627 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1628 | |
} |
| 1629 | |
|
| 1630 | |
final CluCluRelation cluCluRelation; |
| 1631 | |
try { |
| 1632 | 0 | cluCluRelation = luDao.fetch(CluCluRelation.class, |
| 1633 | |
cluCluRelationId); |
| 1634 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1635 | 0 | throw new DoesNotExistException(cluCluRelationId); |
| 1636 | 0 | } |
| 1637 | 0 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
| 1638 | |
new String[]{"cluId", "relatedCluId", |
| 1639 | |
"isCluRelationRequired", "attributes", "meta"}); |
| 1640 | |
try { |
| 1641 | 0 | cluCluRelation.setClu(luDao.fetch(Clu.class, cluCluRelationInfo.getCluId())); |
| 1642 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1643 | 0 | throw new DoesNotExistException(cluCluRelationInfo.getCluId()); |
| 1644 | 0 | } |
| 1645 | |
try { |
| 1646 | 0 | cluCluRelation.setRelatedClu(luDao.fetch(Clu.class, cluCluRelationInfo.getRelatedCluId())); |
| 1647 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1648 | 0 | throw new DoesNotExistException(cluCluRelationInfo.getRelatedCluId()); |
| 1649 | 0 | } |
| 1650 | 0 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo.getIsCluRelationRequired() == null ? true : cluCluRelationInfo.getIsCluRelationRequired()); |
| 1651 | |
|
| 1652 | 0 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 1653 | |
CluCluRelationAttribute.class, cluCluRelationInfo.getAttributes(), cluCluRelation, luDao)); |
| 1654 | |
try { |
| 1655 | 0 | cluCluRelation.setLuLuRelationType(luDao.fetch(LuLuRelationType.class, |
| 1656 | |
cluCluRelationInfo.getTypeKey())); |
| 1657 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1658 | 0 | throw new DoesNotExistException(cluCluRelationInfo.getTypeKey()); |
| 1659 | 0 | } |
| 1660 | |
|
| 1661 | 0 | final CluCluRelation update = luDao.update(cluCluRelation); |
| 1662 | |
|
| 1663 | 0 | return LuServiceAssembler.toCluCluRelationInfo(update); |
| 1664 | |
} |
| 1665 | |
|
| 1666 | |
@Override |
| 1667 | |
@Transactional(readOnly = false) |
| 1668 | |
public StatusInfo deleteCluCluRelation(String cluCluRelationId, ContextInfo context) |
| 1669 | |
throws DoesNotExistException, InvalidParameterException, |
| 1670 | |
MissingParameterException, OperationFailedException, |
| 1671 | |
PermissionDeniedException { |
| 1672 | 0 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
| 1673 | |
try { |
| 1674 | 0 | luDao.delete(CluCluRelation.class, cluCluRelationId); |
| 1675 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1676 | 0 | throw new DoesNotExistException(cluCluRelationId); |
| 1677 | 0 | } |
| 1678 | |
|
| 1679 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 1680 | 0 | statusInfo.setSuccess(true); |
| 1681 | |
|
| 1682 | 0 | return statusInfo; |
| 1683 | |
} |
| 1684 | |
|
| 1685 | |
@Override |
| 1686 | |
public List<ValidationResultInfo> validateCluPublication( |
| 1687 | |
String validationType, String cluId, String luPublicationTypeKey, |
| 1688 | |
CluPublicationInfo cluPublicationInfo, ContextInfo context) |
| 1689 | |
throws DoesNotExistException, InvalidParameterException, |
| 1690 | |
MissingParameterException, OperationFailedException { |
| 1691 | |
|
| 1692 | 0 | checkForMissingParameter(validationType, "validationType"); |
| 1693 | 0 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1694 | |
|
| 1695 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluPublicationInfo.class.getName()); |
| 1696 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1697 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = |
| 1698 | |
defaultValidator.validateObject(cluPublicationInfo, objStructure); |
| 1699 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 1700 | 0 | return r2vrs; |
| 1701 | |
} |
| 1702 | |
|
| 1703 | |
@Override |
| 1704 | |
@Transactional(readOnly = false) |
| 1705 | |
public CluPublicationInfo createCluPublication(String cluId, |
| 1706 | |
String luPublicationType, CluPublicationInfo cluPublicationInfo, ContextInfo context) |
| 1707 | |
throws DataValidationErrorException, |
| 1708 | |
InvalidParameterException, MissingParameterException, |
| 1709 | |
OperationFailedException, PermissionDeniedException { |
| 1710 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1711 | 0 | checkForMissingParameter(luPublicationType, "luPublicationType"); |
| 1712 | 0 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1713 | |
|
| 1714 | |
|
| 1715 | |
List<ValidationResultInfo> val; |
| 1716 | |
try { |
| 1717 | 0 | val = validateCluPublication("SYSTEM", cluId, luPublicationType, cluPublicationInfo, context); |
| 1718 | 0 | if (null != val && val.size() > 0) { |
| 1719 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1720 | |
} |
| 1721 | 0 | } catch (DoesNotExistException e) { |
| 1722 | 0 | throw new OperationFailedException("Error creating clu", e); |
| 1723 | 0 | } |
| 1724 | |
|
| 1725 | |
|
| 1726 | 0 | CluPublication cluPub = new CluPublication(); |
| 1727 | |
Clu clu; |
| 1728 | |
try { |
| 1729 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 1730 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
| 1731 | 0 | throw new InvalidParameterException("Clu does not exist for id:" + cluId); |
| 1732 | 0 | } |
| 1733 | |
|
| 1734 | |
CluPublicationType type; |
| 1735 | |
try { |
| 1736 | 0 | type = luDao.fetch(CluPublicationType.class, luPublicationType); |
| 1737 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
| 1738 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + luPublicationType); |
| 1739 | 0 | } |
| 1740 | |
|
| 1741 | 0 | cluPub.setClu(clu); |
| 1742 | 0 | cluPub.setId(cluPublicationInfo.getId()); |
| 1743 | 0 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
| 1744 | 0 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
| 1745 | 0 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
| 1746 | 0 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
| 1747 | 0 | cluPub.setState(cluPublicationInfo.getState()); |
| 1748 | 0 | cluPub.setType(type); |
| 1749 | 0 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
| 1750 | 0 | cluPub.setVariants(LuServiceAssembler.toCluPublicationVariants(cluPublicationInfo.getVariants(), cluPub, luDao)); |
| 1751 | |
|
| 1752 | 0 | luDao.create(cluPub); |
| 1753 | |
|
| 1754 | 0 | return LuServiceAssembler.toCluPublicationInfo(cluPub); |
| 1755 | |
} |
| 1756 | |
|
| 1757 | |
@Override |
| 1758 | |
@Transactional(readOnly = false) |
| 1759 | |
public CluPublicationInfo updateCluPublication(String cluPublicationId, |
| 1760 | |
CluPublicationInfo cluPublicationInfo, ContextInfo context) |
| 1761 | |
throws DataValidationErrorException, DoesNotExistException, |
| 1762 | |
InvalidParameterException, MissingParameterException, |
| 1763 | |
OperationFailedException, PermissionDeniedException, |
| 1764 | |
VersionMismatchException { |
| 1765 | 0 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 1766 | 0 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
| 1767 | |
|
| 1768 | |
|
| 1769 | |
List<ValidationResultInfo> val; |
| 1770 | |
|
| 1771 | 0 | val = validateCluPublication("SYSTEM", |
| 1772 | |
cluPublicationInfo.getCluId(), |
| 1773 | |
cluPublicationInfo.getTypeKey(), |
| 1774 | |
cluPublicationInfo, context); |
| 1775 | 0 | if (null != val && val.size() > 0) { |
| 1776 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1777 | |
} |
| 1778 | |
|
| 1779 | |
CluPublication cluPub; |
| 1780 | |
try { |
| 1781 | 0 | cluPub = luDao.fetch(CluPublication.class, cluPublicationId); |
| 1782 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1783 | 0 | throw new DoesNotExistException(ex.getMessage(), ex); |
| 1784 | 0 | } |
| 1785 | |
|
| 1786 | 0 | if (!String.valueOf(cluPub.getVersionNumber()).equals( |
| 1787 | |
cluPublicationInfo.getMeta().getVersionInd())) { |
| 1788 | 0 | throw new VersionMismatchException( |
| 1789 | |
"CluPublication to be updated is not the current version"); |
| 1790 | |
} |
| 1791 | |
|
| 1792 | |
Clu clu; |
| 1793 | |
try { |
| 1794 | 0 | clu = luDao.fetch(Clu.class, cluPublicationInfo.getCluId()); |
| 1795 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
| 1796 | 0 | throw new InvalidParameterException("Clu does not exist for id:" + cluPublicationInfo.getCluId()); |
| 1797 | 0 | } |
| 1798 | |
|
| 1799 | |
CluPublicationType type; |
| 1800 | |
try { |
| 1801 | 0 | type = luDao.fetch(CluPublicationType.class, cluPublicationInfo.getType()); |
| 1802 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
| 1803 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + cluPublicationInfo.getType()); |
| 1804 | 0 | } |
| 1805 | |
|
| 1806 | |
|
| 1807 | |
|
| 1808 | |
|
| 1809 | 0 | Map<String, CluPublicationVariant> oldVariantMap = new HashMap<String, CluPublicationVariant>(); |
| 1810 | 0 | for (CluPublicationVariant variant : cluPub.getVariants()) { |
| 1811 | 0 | oldVariantMap.put(variant.getKey(), variant); |
| 1812 | |
} |
| 1813 | 0 | cluPub.getVariants().clear(); |
| 1814 | |
|
| 1815 | |
|
| 1816 | |
|
| 1817 | 0 | CluPublicationVariant variant = null; |
| 1818 | 0 | for (FieldInfo fieldInfo : cluPublicationInfo.getVariants()) { |
| 1819 | 0 | if (!oldVariantMap.containsKey(fieldInfo.getId())) { |
| 1820 | |
|
| 1821 | 0 | variant = new CluPublicationVariant(); |
| 1822 | 0 | variant.setKey(fieldInfo.getId()); |
| 1823 | 0 | variant.setValue(fieldInfo.getValue()); |
| 1824 | |
} else { |
| 1825 | |
|
| 1826 | 0 | variant = oldVariantMap.get(fieldInfo.getId()); |
| 1827 | 0 | variant.setValue(fieldInfo.getValue()); |
| 1828 | 0 | oldVariantMap.remove(fieldInfo.getId()); |
| 1829 | |
} |
| 1830 | |
|
| 1831 | 0 | cluPub.getVariants().add(variant); |
| 1832 | |
} |
| 1833 | |
|
| 1834 | |
|
| 1835 | 0 | for (Entry<String, CluPublicationVariant> entry : oldVariantMap.entrySet()) { |
| 1836 | 0 | luDao.delete(entry.getValue()); |
| 1837 | |
} |
| 1838 | |
|
| 1839 | 0 | cluPub.setClu(clu); |
| 1840 | 0 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
| 1841 | 0 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
| 1842 | 0 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
| 1843 | 0 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
| 1844 | 0 | cluPub.setState(cluPublicationInfo.getState()); |
| 1845 | 0 | cluPub.setType(type); |
| 1846 | 0 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
| 1847 | |
|
| 1848 | 0 | CluPublication updated = luDao.update(cluPub); |
| 1849 | |
|
| 1850 | 0 | return LuServiceAssembler.toCluPublicationInfo(updated); |
| 1851 | |
} |
| 1852 | |
|
| 1853 | |
@Override |
| 1854 | |
@Transactional(readOnly = false) |
| 1855 | |
public StatusInfo deleteCluPublication(String cluPublicationId, ContextInfo context) |
| 1856 | |
throws DoesNotExistException, InvalidParameterException, |
| 1857 | |
MissingParameterException, DependentObjectsExistException, |
| 1858 | |
OperationFailedException, PermissionDeniedException { |
| 1859 | 0 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
| 1860 | |
try { |
| 1861 | 0 | luDao.delete(CluPublication.class, cluPublicationId); |
| 1862 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1863 | 0 | throw new DoesNotExistException(cluPublicationId); |
| 1864 | 0 | } |
| 1865 | |
|
| 1866 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 1867 | 0 | statusInfo.setSuccess(true); |
| 1868 | |
|
| 1869 | 0 | return statusInfo; |
| 1870 | |
} |
| 1871 | |
|
| 1872 | |
@Override |
| 1873 | |
public List<ValidationResultInfo> validateCluResult(String validationType, |
| 1874 | |
String cluId, String cluResultTypeKey, |
| 1875 | |
CluResultInfo cluResultInfo, ContextInfo context) |
| 1876 | |
throws DoesNotExistException, |
| 1877 | |
InvalidParameterException, MissingParameterException, |
| 1878 | |
OperationFailedException { |
| 1879 | 0 | checkForMissingParameter(validationType, "validationType"); |
| 1880 | 0 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1881 | |
|
| 1882 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluResultInfo.class.getName()); |
| 1883 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 1884 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = defaultValidator.validateObject(cluResultInfo, objStructure); |
| 1885 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 1886 | 0 | return r2vrs; |
| 1887 | |
} |
| 1888 | |
|
| 1889 | |
@Override |
| 1890 | |
@Transactional(readOnly = false) |
| 1891 | |
public CluResultInfo createCluResult(String cluId, String cluResultTypeKey, |
| 1892 | |
CluResultInfo cluResultInfo, ContextInfo context) throws |
| 1893 | |
DataValidationErrorException, InvalidParameterException, |
| 1894 | |
MissingParameterException, OperationFailedException, |
| 1895 | |
PermissionDeniedException, DoesNotExistException { |
| 1896 | |
|
| 1897 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 1898 | 0 | checkForMissingParameter(cluResultTypeKey, "cluResultTypeKey"); |
| 1899 | 0 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1900 | |
|
| 1901 | |
|
| 1902 | 0 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", |
| 1903 | |
cluResultInfo.getCluId(), |
| 1904 | |
cluResultInfo.getTypeKey(), |
| 1905 | |
cluResultInfo, context); |
| 1906 | 0 | if (null != val && val.size() > 0) { |
| 1907 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1908 | |
} |
| 1909 | |
|
| 1910 | 0 | cluResultInfo.setType(cluResultTypeKey); |
| 1911 | 0 | cluResultInfo.setCluId(cluId); |
| 1912 | |
|
| 1913 | 0 | List<ResultOption> resOptList = new ArrayList<ResultOption>(); |
| 1914 | 0 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
| 1915 | 0 | ResultOption resOpt = new ResultOption(); |
| 1916 | 0 | BeanUtils.copyProperties(resOptInfo, resOpt, new String[]{"id", |
| 1917 | |
"meta", "resultUsageType", "desc"}); |
| 1918 | |
|
| 1919 | 0 | if (resOptInfo.getResultUsageTypeKey() != null) { |
| 1920 | |
ResultUsageType resUsageType; |
| 1921 | |
try { |
| 1922 | 0 | resUsageType = luDao.fetch(ResultUsageType.class, |
| 1923 | |
resOptInfo.getResultUsageTypeKey()); |
| 1924 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1925 | 0 | throw new DoesNotExistException(resOptInfo.getResultUsageTypeKey()); |
| 1926 | 0 | } |
| 1927 | 0 | resOpt.setResultUsageType(resUsageType); |
| 1928 | |
} |
| 1929 | 0 | resOpt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDescr())); |
| 1930 | 0 | luDao.create(resOpt); |
| 1931 | 0 | resOptList.add(resOpt); |
| 1932 | 0 | } |
| 1933 | |
|
| 1934 | 0 | CluResult cluResult = new CluResult(); |
| 1935 | 0 | BeanUtils.copyProperties(cluResultInfo, cluResult, new String[]{"id", |
| 1936 | |
"desc", "resultOptions", "meta"}); |
| 1937 | |
|
| 1938 | 0 | cluResult.setDesc(LuServiceAssembler.toRichText(LuRichText.class, cluResultInfo.getDescr())); |
| 1939 | 0 | cluResult.setResultOptions(resOptList); |
| 1940 | |
|
| 1941 | |
Clu clu; |
| 1942 | |
try { |
| 1943 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 1944 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1945 | 0 | throw new DoesNotExistException(cluId); |
| 1946 | 0 | } |
| 1947 | 0 | cluResult.setClu(clu); |
| 1948 | |
|
| 1949 | |
CluResultType type; |
| 1950 | |
try { |
| 1951 | 0 | type = luDao.fetch(CluResultType.class, cluResultTypeKey); |
| 1952 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1953 | 0 | throw new DoesNotExistException(cluResultTypeKey); |
| 1954 | 0 | } |
| 1955 | 0 | cluResult.setCluResultType(type); |
| 1956 | |
|
| 1957 | 0 | luDao.create(cluResult); |
| 1958 | |
|
| 1959 | 0 | return LuServiceAssembler.toCluResultInfo(cluResult); |
| 1960 | |
} |
| 1961 | |
|
| 1962 | |
@Override |
| 1963 | |
@Transactional(readOnly = false) |
| 1964 | |
public CluResultInfo updateCluResult(String cluResultId, |
| 1965 | |
CluResultInfo cluResultInfo, ContextInfo context) throws DataValidationErrorException, |
| 1966 | |
DoesNotExistException, InvalidParameterException, |
| 1967 | |
MissingParameterException, OperationFailedException, |
| 1968 | |
PermissionDeniedException, VersionMismatchException { |
| 1969 | |
|
| 1970 | 0 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 1971 | 0 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
| 1972 | |
|
| 1973 | |
|
| 1974 | 0 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", |
| 1975 | |
cluResultInfo.getCluId(), |
| 1976 | |
cluResultInfo.getTypeKey(), |
| 1977 | |
cluResultInfo, |
| 1978 | |
context); |
| 1979 | 0 | if (null != val && val.size() > 0) { |
| 1980 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 1981 | |
} |
| 1982 | |
|
| 1983 | |
CluResult result; |
| 1984 | |
try { |
| 1985 | 0 | result = luDao.fetch(CluResult.class, cluResultId); |
| 1986 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 1987 | 0 | throw new DoesNotExistException(cluResultId); |
| 1988 | 0 | } |
| 1989 | 0 | if (!String.valueOf(result.getVersionNumber()).equals( |
| 1990 | |
cluResultInfo.getMeta().getVersionInd())) { |
| 1991 | 0 | throw new VersionMismatchException( |
| 1992 | |
"CluResult to be updated is not the current version"); |
| 1993 | |
} |
| 1994 | |
|
| 1995 | |
|
| 1996 | |
|
| 1997 | |
|
| 1998 | 0 | Map<String, ResultOption> oldResultOptionMap = new HashMap<String, ResultOption>(); |
| 1999 | 0 | for (ResultOption opt : result.getResultOptions()) { |
| 2000 | 0 | oldResultOptionMap.put(opt.getId(), opt); |
| 2001 | |
} |
| 2002 | 0 | result.getResultOptions().clear(); |
| 2003 | |
|
| 2004 | |
|
| 2005 | |
|
| 2006 | 0 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
| 2007 | 0 | ResultOption opt = oldResultOptionMap.remove(resOptInfo.getId()); |
| 2008 | 0 | if (opt == null) { |
| 2009 | |
|
| 2010 | 0 | opt = new ResultOption(); |
| 2011 | |
|
| 2012 | 0 | BeanUtils.copyProperties(resOptInfo, opt, new String[]{ |
| 2013 | |
"resultUsageType", "desc"}); |
| 2014 | |
} else { |
| 2015 | |
try { |
| 2016 | |
|
| 2017 | 0 | opt = luDao.fetch(ResultOption.class, resOptInfo.getId()); |
| 2018 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2019 | 0 | throw new DoesNotExistException(resOptInfo.getId()); |
| 2020 | 0 | } |
| 2021 | |
|
| 2022 | 0 | BeanUtils.copyProperties(resOptInfo, opt, new String[]{ |
| 2023 | |
"id", "resultUsageType", "desc"}); |
| 2024 | |
} |
| 2025 | 0 | if (resOptInfo.getResultUsageTypeKey() != null && !resOptInfo.getResultUsageTypeKey().isEmpty()) { |
| 2026 | |
ResultUsageType resUsageType; |
| 2027 | |
try { |
| 2028 | 0 | resUsageType = luDao.fetch(ResultUsageType.class, |
| 2029 | |
resOptInfo.getResultUsageTypeKey()); |
| 2030 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2031 | 0 | throw new DoesNotExistException(resOptInfo.getResultUsageTypeKey()); |
| 2032 | 0 | } |
| 2033 | 0 | opt.setResultUsageType(resUsageType); |
| 2034 | |
} |
| 2035 | 0 | opt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDescr())); |
| 2036 | 0 | result.getResultOptions().add(opt); |
| 2037 | 0 | } |
| 2038 | |
|
| 2039 | |
|
| 2040 | 0 | for (Entry<String, ResultOption> entry : oldResultOptionMap.entrySet()) { |
| 2041 | 0 | luDao.delete(entry.getValue()); |
| 2042 | |
} |
| 2043 | |
|
| 2044 | 0 | BeanUtils.copyProperties(cluResultInfo, result, new String[]{"id", |
| 2045 | |
"desc", "resultOptions"}); |
| 2046 | |
|
| 2047 | 0 | result.setDesc(LuServiceAssembler.toRichText(LuRichText.class, cluResultInfo.getDescr())); |
| 2048 | |
CluResultType type; |
| 2049 | |
try { |
| 2050 | 0 | type = luDao.fetch(CluResultType.class, cluResultInfo.getTypeKey()); |
| 2051 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2052 | 0 | throw new DoesNotExistException(cluResultInfo.getTypeKey()); |
| 2053 | 0 | } |
| 2054 | 0 | result.setCluResultType(type); |
| 2055 | |
|
| 2056 | 0 | CluResult updated = luDao.update(result); |
| 2057 | |
|
| 2058 | 0 | return LuServiceAssembler.toCluResultInfo(updated); |
| 2059 | |
} |
| 2060 | |
|
| 2061 | |
@Override |
| 2062 | |
@Transactional(readOnly = false) |
| 2063 | |
public StatusInfo deleteCluResult(String cluResultId, ContextInfo context) |
| 2064 | |
throws DoesNotExistException, InvalidParameterException, |
| 2065 | |
MissingParameterException, DependentObjectsExistException, |
| 2066 | |
OperationFailedException, PermissionDeniedException { |
| 2067 | |
|
| 2068 | 0 | checkForMissingParameter(cluResultId, "cluResultId"); |
| 2069 | |
try { |
| 2070 | 0 | luDao.delete(CluResult.class, cluResultId); |
| 2071 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2072 | 0 | throw new DoesNotExistException(cluResultId); |
| 2073 | 0 | } |
| 2074 | |
|
| 2075 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2076 | 0 | statusInfo.setSuccess(true); |
| 2077 | |
|
| 2078 | 0 | return statusInfo; |
| 2079 | |
} |
| 2080 | |
|
| 2081 | |
@Override |
| 2082 | |
public List<ValidationResultInfo> validateCluLoRelation( |
| 2083 | |
String validationType, |
| 2084 | |
String cluId, |
| 2085 | |
String loId, |
| 2086 | |
String cluLoRelationType, |
| 2087 | |
CluLoRelationInfo cluLoRelationInfo, ContextInfo context) |
| 2088 | |
throws DoesNotExistException, InvalidParameterException, |
| 2089 | |
MissingParameterException, OperationFailedException { |
| 2090 | |
|
| 2091 | 0 | checkForMissingParameter(validationType, "validationType"); |
| 2092 | 0 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2093 | |
|
| 2094 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluLoRelation.class.getName()); |
| 2095 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2096 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = defaultValidator.validateObject(cluLoRelationInfo, objStructure); |
| 2097 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 2098 | 0 | return r2vrs; |
| 2099 | |
} |
| 2100 | |
|
| 2101 | |
@Override |
| 2102 | |
@Transactional(readOnly = false) |
| 2103 | |
public CluLoRelationInfo createCluLoRelation(String cluId, String loId, |
| 2104 | |
String cluLoRelationType, CluLoRelationInfo cluLoRelationInfo, ContextInfo context) |
| 2105 | |
throws DoesNotExistException, |
| 2106 | |
InvalidParameterException, MissingParameterException, |
| 2107 | |
OperationFailedException, PermissionDeniedException, DataValidationErrorException { |
| 2108 | 0 | checkForMissingParameter(loId, "loId"); |
| 2109 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 2110 | 0 | checkForEmptyList(cluLoRelationType, "cluLoRelationType"); |
| 2111 | 0 | checkForEmptyList(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2112 | |
|
| 2113 | |
|
| 2114 | 0 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", cluId, loId, cluLoRelationType, cluLoRelationInfo, context); |
| 2115 | 0 | if (null != val && val.size() > 0) { |
| 2116 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2117 | |
} |
| 2118 | |
|
| 2119 | |
Clu clu; |
| 2120 | |
try { |
| 2121 | 0 | clu = luDao.fetch(Clu.class, cluId); |
| 2122 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2123 | 0 | throw new DoesNotExistException(cluId); |
| 2124 | 0 | } |
| 2125 | 0 | if (clu == null) { |
| 2126 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
| 2127 | |
+ cluId); |
| 2128 | |
} |
| 2129 | |
|
| 2130 | |
CluLoRelationType cluLoRelationTypeEntity; |
| 2131 | |
try { |
| 2132 | 0 | cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationType); |
| 2133 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2134 | 0 | throw new DoesNotExistException(cluLoRelationType); |
| 2135 | 0 | } |
| 2136 | 0 | if (cluLoRelationTypeEntity == null) { |
| 2137 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
| 2138 | |
+ cluLoRelationType); |
| 2139 | |
} |
| 2140 | |
|
| 2141 | |
|
| 2142 | 0 | List<CluLoRelation> reltns = luDao.getCluLoRelationsByCludIdAndLoId( |
| 2143 | |
cluId, loId); |
| 2144 | 0 | if (reltns.size() > 0) { |
| 2145 | |
|
| 2146 | |
|
| 2147 | |
|
| 2148 | |
|
| 2149 | 0 | throw new OperationFailedException( |
| 2150 | |
"Relation already exists for cluId:" + cluId + " and Lo:" |
| 2151 | |
+ loId); |
| 2152 | |
} |
| 2153 | |
|
| 2154 | 0 | CluLoRelation cluLoRelation = new CluLoRelation(); |
| 2155 | 0 | BeanUtils.copyProperties(cluLoRelationInfo, cluLoRelation, |
| 2156 | |
new String[]{"cluId", "attributes", "meta", "type"}); |
| 2157 | |
|
| 2158 | 0 | cluLoRelation.setClu(clu); |
| 2159 | 0 | cluLoRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2160 | |
CluLoRelationAttribute.class, |
| 2161 | |
cluLoRelationInfo.getAttributes(), cluLoRelation, luDao)); |
| 2162 | 0 | cluLoRelation.setType(cluLoRelationTypeEntity); |
| 2163 | |
|
| 2164 | 0 | luDao.create(cluLoRelation); |
| 2165 | |
|
| 2166 | 0 | return LuServiceAssembler.toCluLoRelationInfo(cluLoRelation); |
| 2167 | |
} |
| 2168 | |
|
| 2169 | |
@Override |
| 2170 | |
@Transactional(readOnly = false) |
| 2171 | |
public CluLoRelationInfo updateCluLoRelation(String cluLoRelationId, |
| 2172 | |
CluLoRelationInfo cluLoRelationInfo, ContextInfo context) |
| 2173 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2174 | |
InvalidParameterException, MissingParameterException, |
| 2175 | |
OperationFailedException, PermissionDeniedException, |
| 2176 | |
VersionMismatchException { |
| 2177 | 0 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 2178 | 0 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
| 2179 | |
|
| 2180 | |
|
| 2181 | 0 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", |
| 2182 | |
cluLoRelationInfo.getCluId(), |
| 2183 | |
cluLoRelationInfo.getLoId(), |
| 2184 | |
cluLoRelationInfo.getTypeKey(), |
| 2185 | |
cluLoRelationInfo, context); |
| 2186 | 0 | if (null != val && val.size() > 0) { |
| 2187 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2188 | |
} |
| 2189 | |
|
| 2190 | |
CluLoRelation reltn; |
| 2191 | |
try { |
| 2192 | 0 | reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 2193 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2194 | 0 | throw new DoesNotExistException(cluLoRelationId); |
| 2195 | 0 | } |
| 2196 | |
|
| 2197 | 0 | if (!String.valueOf(reltn.getVersionNumber()).equals( |
| 2198 | |
cluLoRelationInfo.getMeta().getVersionInd())) { |
| 2199 | 0 | throw new VersionMismatchException( |
| 2200 | |
"CluLoRelation to be updated is not the current version"); |
| 2201 | |
} |
| 2202 | |
|
| 2203 | |
Clu clu; |
| 2204 | |
try { |
| 2205 | 0 | clu = luDao.fetch(Clu.class, cluLoRelationInfo.getCluId()); |
| 2206 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2207 | 0 | throw new DoesNotExistException(cluLoRelationInfo.getCluId()); |
| 2208 | 0 | } |
| 2209 | 0 | if (clu == null) { |
| 2210 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
| 2211 | |
+ cluLoRelationInfo.getCluId()); |
| 2212 | |
} |
| 2213 | |
|
| 2214 | |
CluLoRelationType cluLoRelationTypeEntity; |
| 2215 | |
try { |
| 2216 | 0 | cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationInfo.getTypeKey()); |
| 2217 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2218 | 0 | throw new DoesNotExistException(cluLoRelationInfo.getTypeKey()); |
| 2219 | 0 | } |
| 2220 | 0 | if (cluLoRelationTypeEntity == null) { |
| 2221 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
| 2222 | |
+ cluLoRelationInfo.getType()); |
| 2223 | |
} |
| 2224 | |
|
| 2225 | 0 | BeanUtils.copyProperties(cluLoRelationInfo, reltn, new String[]{ |
| 2226 | |
"cluId", "attributes", "meta", "type"}); |
| 2227 | |
|
| 2228 | 0 | reltn.setClu(clu); |
| 2229 | 0 | reltn.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2230 | |
CluLoRelationAttribute.class, |
| 2231 | |
cluLoRelationInfo.getAttributes(), reltn, luDao)); |
| 2232 | 0 | reltn.setType(cluLoRelationTypeEntity); |
| 2233 | 0 | CluLoRelation updated = luDao.update(reltn); |
| 2234 | |
|
| 2235 | 0 | return LuServiceAssembler.toCluLoRelationInfo(updated); |
| 2236 | |
} |
| 2237 | |
|
| 2238 | |
@Override |
| 2239 | |
@Transactional(readOnly = false) |
| 2240 | |
public StatusInfo deleteCluLoRelation(String cluLoRelationId, ContextInfo context) |
| 2241 | |
throws DoesNotExistException, InvalidParameterException, |
| 2242 | |
MissingParameterException, OperationFailedException, |
| 2243 | |
PermissionDeniedException { |
| 2244 | 0 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
| 2245 | |
|
| 2246 | |
CluLoRelation reltn; |
| 2247 | |
try { |
| 2248 | 0 | reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
| 2249 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2250 | 0 | throw new DoesNotExistException(cluLoRelationId); |
| 2251 | 0 | } |
| 2252 | 0 | if (reltn == null) { |
| 2253 | 0 | throw new DoesNotExistException( |
| 2254 | |
"CluLoRelation does not exist for id: " + cluLoRelationId); |
| 2255 | |
} |
| 2256 | |
try { |
| 2257 | 0 | luDao.delete(CluLoRelation.class, cluLoRelationId); |
| 2258 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2259 | 0 | throw new DoesNotExistException(cluLoRelationId); |
| 2260 | 0 | } |
| 2261 | |
|
| 2262 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2263 | 0 | statusInfo.setSuccess(true); |
| 2264 | |
|
| 2265 | 0 | return statusInfo; |
| 2266 | |
} |
| 2267 | |
|
| 2268 | |
@Override |
| 2269 | |
@Transactional(readOnly = false) |
| 2270 | |
public StatusInfo addCluResourceRequirement(String resourceTypeKey, |
| 2271 | |
String cluId, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, |
| 2272 | |
InvalidParameterException, MissingParameterException, |
| 2273 | |
OperationFailedException, PermissionDeniedException { |
| 2274 | 0 | throw new OperationFailedException("not yet implemented"); |
| 2275 | |
} |
| 2276 | |
|
| 2277 | |
@Override |
| 2278 | |
@Transactional(readOnly = false) |
| 2279 | |
public StatusInfo removeCluResourceRequirement(String resourceTypeKey, |
| 2280 | |
String cluId, ContextInfo context) throws DoesNotExistException, |
| 2281 | |
InvalidParameterException, MissingParameterException, |
| 2282 | |
OperationFailedException, PermissionDeniedException { |
| 2283 | 0 | return null; |
| 2284 | |
} |
| 2285 | |
|
| 2286 | |
@Override |
| 2287 | |
public List<ValidationResultInfo> validateCluSet(String validationType, |
| 2288 | |
String cluSetType, |
| 2289 | |
CluSetInfo cluSetInfo, ContextInfo context) throws DoesNotExistException, |
| 2290 | |
InvalidParameterException, MissingParameterException, |
| 2291 | |
OperationFailedException { |
| 2292 | 0 | checkForMissingParameter(validationType, "validationType"); |
| 2293 | 0 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2294 | |
|
| 2295 | 0 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluSetInfo.class.getName()); |
| 2296 | 0 | Validator defaultValidator = validatorFactory.getValidator(); |
| 2297 | 0 | List<org.kuali.student.common.validation.dto.ValidationResultInfo> r1vrs = defaultValidator.validateObject(cluSetInfo, objStructure); |
| 2298 | 0 | List<ValidationResultInfo> r2vrs = new R1ToR2CopyHelper().copyValidationResultList(r1vrs); |
| 2299 | 0 | return r2vrs; |
| 2300 | |
} |
| 2301 | |
|
| 2302 | |
@Override |
| 2303 | |
@Transactional(readOnly = false) |
| 2304 | |
public CluSetInfo createCluSet(String cluSetType, |
| 2305 | |
CluSetInfo cluSetInfo, |
| 2306 | |
ContextInfo context) |
| 2307 | |
throws DataValidationErrorException, |
| 2308 | |
InvalidParameterException, MissingParameterException, |
| 2309 | |
OperationFailedException, PermissionDeniedException, |
| 2310 | |
UnsupportedActionException { |
| 2311 | |
|
| 2312 | 0 | checkForMissingParameter(cluSetType, "cluSetType"); |
| 2313 | 0 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2314 | |
|
| 2315 | 0 | cluSetInfo.setType(cluSetType); |
| 2316 | |
|
| 2317 | 0 | validateCluSet(cluSetInfo); |
| 2318 | |
|
| 2319 | |
|
| 2320 | |
List<ValidationResultInfo> val; |
| 2321 | |
try { |
| 2322 | 0 | val = validateCluSet("SYSTEM", |
| 2323 | |
cluSetInfo.getTypeKey(), |
| 2324 | |
cluSetInfo, context); |
| 2325 | 0 | } catch (DoesNotExistException e) { |
| 2326 | 0 | throw new DataValidationErrorException("Validation error! " + e.getMessage()); |
| 2327 | 0 | } |
| 2328 | 0 | if (null != val && val.size() > 0) { |
| 2329 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2330 | |
} |
| 2331 | |
|
| 2332 | 0 | List<String> cluIds = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2333 | |
|
| 2334 | 0 | CluSet cluSet = null; |
| 2335 | |
try { |
| 2336 | 0 | cluSet = LuServiceAssembler.toCluSetEntity(cluSetInfo, this.luDao); |
| 2337 | 0 | } catch (DoesNotExistException e) { |
| 2338 | 0 | throw new DataValidationErrorException("Creating CluSet entity failed. Clu or CluSet does not exist: " + e.getMessage()); |
| 2339 | 0 | } |
| 2340 | |
|
| 2341 | 0 | cluSet = luDao.create(cluSet); |
| 2342 | |
|
| 2343 | 0 | CluSetInfo newCluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
| 2344 | |
|
| 2345 | 0 | if (cluIds != null) { |
| 2346 | 0 | newCluSetInfo.getCluIds().addAll(cluIds); |
| 2347 | |
} |
| 2348 | |
|
| 2349 | 0 | return newCluSetInfo; |
| 2350 | |
} |
| 2351 | |
|
| 2352 | |
private void setMembershipQuerySearchResult(CluSetInfo cluSetInfo) throws MissingParameterException { |
| 2353 | 0 | if (cluSetInfo.getMembershipQuery() == null) { |
| 2354 | 0 | return; |
| 2355 | |
} |
| 2356 | 0 | List<String> cluIds = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2357 | 0 | cluSetInfo.getCluIds().addAll(cluIds); |
| 2358 | 0 | } |
| 2359 | |
|
| 2360 | |
private List<String> getMembershipQuerySearchResult(MembershipQueryInfo query) throws MissingParameterException { |
| 2361 | 0 | if (query == null) { |
| 2362 | 0 | return null; |
| 2363 | |
} |
| 2364 | 0 | SearchRequestInfo sr = new SearchRequestInfo(); |
| 2365 | 0 | sr.setSearchKey(query.getSearchTypeKey()); |
| 2366 | 0 | sr.setParams(query.getQueryParamValues()); |
| 2367 | |
|
| 2368 | |
|
| 2369 | 0 | SearchRequest r1Request = null; |
| 2370 | 0 | SearchResult r1Result = this.searchDispatcher.dispatchSearch(r1Request); |
| 2371 | |
|
| 2372 | 0 | SearchResultInfo result = null; |
| 2373 | |
|
| 2374 | 0 | Set<String> cluIds = new HashSet<String>(); |
| 2375 | 0 | List<SearchResultRowInfo> rows = result.getRows(); |
| 2376 | 0 | for (SearchResultRowInfo row : rows) { |
| 2377 | 0 | List<SearchResultCellInfo> cells = row.getCells(); |
| 2378 | 0 | for (SearchResultCellInfo cell : cells) { |
| 2379 | 0 | if (cell.getKey().equals("lu.resultColumn.luOptionalVersionIndId") && cell.getValue() != null) { |
| 2380 | 0 | cluIds.add(cell.getValue()); |
| 2381 | |
} |
| 2382 | |
} |
| 2383 | 0 | } |
| 2384 | 0 | return new ArrayList<String>(cluIds); |
| 2385 | |
} |
| 2386 | |
|
| 2387 | |
private void validateCluSet(CluSetInfo cluSetInfo) throws UnsupportedActionException { |
| 2388 | 0 | MembershipQueryInfo mqInfo = cluSetInfo.getMembershipQuery(); |
| 2389 | |
|
| 2390 | 0 | if (cluSetInfo.getTypeKey() == null) { |
| 2391 | 0 | throw new UnsupportedActionException("CluSet type cannot be null. CluSet id=" + cluSetInfo.getId()); |
| 2392 | 0 | } else if (mqInfo != null && mqInfo.getSearchTypeKey() != null && !mqInfo.getSearchTypeKey().isEmpty() |
| 2393 | |
&& (cluSetInfo.getCluIds().size() > 0 || cluSetInfo.getCluSetIds().size() > 0)) { |
| 2394 | 0 | throw new UnsupportedActionException("Dynamic CluSet cannot contain Clus and/or CluSets. CluSet id=" + cluSetInfo.getId()); |
| 2395 | 0 | } else if (cluSetInfo.getCluIds().size() > 0 && cluSetInfo.getCluSetIds().size() > 0) { |
| 2396 | 0 | throw new UnsupportedActionException("CluSet cannot contain both Clus and CluSets. CluSet id=" + cluSetInfo.getId()); |
| 2397 | |
} |
| 2398 | 0 | } |
| 2399 | |
|
| 2400 | |
@Override |
| 2401 | |
@Transactional(readOnly = false) |
| 2402 | |
public CluSetInfo updateCluSet(String cluSetId, CluSetInfo cluSetInfo, ContextInfo context) |
| 2403 | |
throws DataValidationErrorException, DoesNotExistException, |
| 2404 | |
InvalidParameterException, MissingParameterException, |
| 2405 | |
OperationFailedException, PermissionDeniedException, |
| 2406 | |
VersionMismatchException, CircularRelationshipException, |
| 2407 | |
UnsupportedActionException { |
| 2408 | |
|
| 2409 | |
|
| 2410 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2411 | 0 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
| 2412 | |
|
| 2413 | |
|
| 2414 | 0 | List<ValidationResultInfo> val = validateCluSet("SYSTEM", |
| 2415 | |
cluSetInfo.getTypeKey(), |
| 2416 | |
cluSetInfo, |
| 2417 | |
context); |
| 2418 | 0 | if (null != val && val.size() > 0) { |
| 2419 | 0 | throw new DataValidationErrorException("Validation error!", val); |
| 2420 | |
} |
| 2421 | |
|
| 2422 | 0 | cluSetInfo.setId(cluSetId); |
| 2423 | |
|
| 2424 | 0 | validateCluSet(cluSetInfo); |
| 2425 | |
|
| 2426 | 0 | List<String> cluIds = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
| 2427 | |
|
| 2428 | |
CluSet cluSet; |
| 2429 | |
try { |
| 2430 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2431 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2432 | 0 | throw new DoesNotExistException(cluSetId); |
| 2433 | 0 | } |
| 2434 | |
|
| 2435 | 0 | if (!cluSetInfo.getType().equals(cluSet.getType())) { |
| 2436 | 0 | throw new UnsupportedActionException("CluSet type is set at creation time and cannot be updated. CluSet id=" + cluSetId); |
| 2437 | |
} |
| 2438 | |
|
| 2439 | 0 | if (!String.valueOf(cluSet.getVersionNumber()).equals( |
| 2440 | |
cluSetInfo.getMeta().getVersionInd())) { |
| 2441 | 0 | throw new VersionMismatchException( |
| 2442 | |
"CluSet (id=" + cluSetId |
| 2443 | |
+ ") to be updated is not the current version " |
| 2444 | |
+ "(version=" + cluSetInfo.getMeta().getVersionInd() |
| 2445 | |
+ "), current version=" + cluSet.getVersionNumber()); |
| 2446 | |
} |
| 2447 | |
|
| 2448 | |
|
| 2449 | 0 | Map<String, CluSetJoinVersionIndClu> oldClus = new HashMap<String, CluSetJoinVersionIndClu>(); |
| 2450 | 0 | for (CluSetJoinVersionIndClu join : cluSet.getCluVerIndIds()) { |
| 2451 | 0 | oldClus.put(join.getCluVersionIndId(), join); |
| 2452 | |
} |
| 2453 | |
|
| 2454 | 0 | cluSet.getCluVerIndIds().clear(); |
| 2455 | |
|
| 2456 | 0 | for (String newCluId : cluSetInfo.getCluIds()) { |
| 2457 | 0 | CluSetJoinVersionIndClu join = oldClus.remove(newCluId); |
| 2458 | 0 | if (join == null) { |
| 2459 | 0 | join = new CluSetJoinVersionIndClu(); |
| 2460 | 0 | join.setCluSet(cluSet); |
| 2461 | 0 | join.setCluVersionIndId(newCluId); |
| 2462 | |
} |
| 2463 | 0 | cluSet.getCluVerIndIds().add(join); |
| 2464 | 0 | } |
| 2465 | |
|
| 2466 | |
|
| 2467 | 0 | for (Entry<String, CluSetJoinVersionIndClu> entry : oldClus.entrySet()) { |
| 2468 | 0 | luDao.delete(entry.getValue()); |
| 2469 | |
} |
| 2470 | |
|
| 2471 | |
|
| 2472 | 0 | if (cluSetInfo.getId() != null) { |
| 2473 | 0 | CluSetInfo originalCluSet = getCluSet(cluSetInfo.getId(), context); |
| 2474 | 0 | List<CluSetInfo> origSubCSs = null; |
| 2475 | 0 | List<String> origSubCSIds = originalCluSet.getCluSetIds(); |
| 2476 | 0 | if (origSubCSIds != null && !origSubCSIds.isEmpty()) { |
| 2477 | 0 | origSubCSs = getCluSetsByIds(origSubCSIds, context); |
| 2478 | |
} |
| 2479 | 0 | if (origSubCSs != null) { |
| 2480 | 0 | for (CluSetInfo origSubCS : origSubCSs) { |
| 2481 | 0 | if (!origSubCS.getIsReusable()) { |
| 2482 | 0 | deleteCluSet(origSubCS.getId(), context); |
| 2483 | |
} |
| 2484 | |
} |
| 2485 | |
} |
| 2486 | |
} |
| 2487 | |
|
| 2488 | |
|
| 2489 | 0 | if (cluSet.getCluSets() == null) { |
| 2490 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
| 2491 | |
} |
| 2492 | 0 | cluSet.setCluSets(null); |
| 2493 | 0 | if (!cluSetInfo.getCluSetIds().isEmpty()) { |
| 2494 | 0 | Set<String> newCluSetIds = new HashSet<String>(cluSetInfo.getCluSetIds()); |
| 2495 | 0 | if (cluSet.getCluSets() != null) { |
| 2496 | 0 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
| 2497 | 0 | if (!newCluSetIds.remove(i.next().getId())) { |
| 2498 | 0 | i.remove(); |
| 2499 | |
} |
| 2500 | |
} |
| 2501 | |
} |
| 2502 | 0 | List<CluSet> cluSetList = luDao.getCluSetInfoByIdList(new ArrayList<String>(newCluSetIds)); |
| 2503 | 0 | cluSet.setCluSets(cluSetList); |
| 2504 | |
} |
| 2505 | |
|
| 2506 | 0 | BeanUtils.copyProperties(cluSetInfo, cluSet, new String[]{"descr", |
| 2507 | |
"attributes", "meta", "membershipQuery"}); |
| 2508 | 0 | cluSet.setAttributes(LuServiceAssembler.toGenericAttributes( |
| 2509 | |
CluSetAttribute.class, cluSetInfo.getAttributes(), cluSet, luDao)); |
| 2510 | 0 | cluSet.setDescr(LuServiceAssembler.toRichText(LuRichText.class, cluSetInfo.getDescr())); |
| 2511 | |
|
| 2512 | 0 | MembershipQuery mq = LuServiceAssembler.toMembershipQueryEntity(cluSetInfo.getMembershipQuery()); |
| 2513 | 0 | cluSet.setMembershipQuery(mq); |
| 2514 | |
|
| 2515 | 0 | CluSet updated = luDao.update(cluSet); |
| 2516 | |
|
| 2517 | 0 | CluSetInfo updatedCluSetInfo = LuServiceAssembler.toCluSetInfo(updated); |
| 2518 | |
|
| 2519 | 0 | if (cluIds != null) { |
| 2520 | 0 | updatedCluSetInfo.getCluIds().addAll(cluIds); |
| 2521 | |
} |
| 2522 | |
|
| 2523 | 0 | return updatedCluSetInfo; |
| 2524 | |
} |
| 2525 | |
|
| 2526 | |
@Override |
| 2527 | |
@Transactional(readOnly = false) |
| 2528 | |
public StatusInfo deleteCluSet(String cluSetId, ContextInfo context) |
| 2529 | |
throws DoesNotExistException, InvalidParameterException, |
| 2530 | |
MissingParameterException, OperationFailedException, |
| 2531 | |
PermissionDeniedException { |
| 2532 | |
|
| 2533 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2534 | |
try { |
| 2535 | 0 | luDao.delete(CluSet.class, cluSetId); |
| 2536 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2537 | 0 | throw new DoesNotExistException(cluSetId); |
| 2538 | 0 | } |
| 2539 | |
|
| 2540 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2541 | 0 | statusInfo.setSuccess(true); |
| 2542 | |
|
| 2543 | 0 | return statusInfo; |
| 2544 | |
} |
| 2545 | |
|
| 2546 | |
@Override |
| 2547 | |
@Transactional(readOnly = false) |
| 2548 | |
public StatusInfo addCluSetToCluSet(String cluSetId, String addedCluSetId, ContextInfo context) |
| 2549 | |
throws DoesNotExistException, InvalidParameterException, |
| 2550 | |
MissingParameterException, OperationFailedException, |
| 2551 | |
PermissionDeniedException, UnsupportedActionException, |
| 2552 | |
CircularRelationshipException { |
| 2553 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2554 | 0 | checkForMissingParameter(addedCluSetId, "addedCluSetId"); |
| 2555 | |
|
| 2556 | |
CluSet cluSet; |
| 2557 | |
try { |
| 2558 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2559 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2560 | 0 | throw new DoesNotExistException(cluSetId); |
| 2561 | 0 | } |
| 2562 | |
|
| 2563 | 0 | checkCluSetAlreadyAdded(cluSet, addedCluSetId); |
| 2564 | |
|
| 2565 | |
CluSet addedCluSet; |
| 2566 | |
try { |
| 2567 | 0 | addedCluSet = luDao.fetch(CluSet.class, addedCluSetId); |
| 2568 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2569 | 0 | throw new DoesNotExistException(addedCluSetId); |
| 2570 | 0 | } |
| 2571 | |
|
| 2572 | 0 | checkCluSetCircularReference(addedCluSet, cluSetId); |
| 2573 | |
|
| 2574 | 0 | if (cluSet.getCluSets() == null) { |
| 2575 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
| 2576 | |
} |
| 2577 | 0 | cluSet.getCluSets().add(addedCluSet); |
| 2578 | |
|
| 2579 | 0 | luDao.update(cluSet); |
| 2580 | |
|
| 2581 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2582 | 0 | statusInfo.setSuccess(true); |
| 2583 | |
|
| 2584 | 0 | return statusInfo; |
| 2585 | |
} |
| 2586 | |
|
| 2587 | |
private void checkCluSetAlreadyAdded(CluSet cluSet, String cluSetIdToAdd) |
| 2588 | |
throws OperationFailedException { |
| 2589 | 0 | if (cluSet.getCluSets() != null) { |
| 2590 | 0 | for (CluSet childCluSet : cluSet.getCluSets()) { |
| 2591 | 0 | if (childCluSet.getId().equals(cluSetIdToAdd)) { |
| 2592 | 0 | throw new OperationFailedException("CluSet (id=" + cluSet.getId() |
| 2593 | |
+ ") already contains CluSet (id='" + cluSetIdToAdd + "')"); |
| 2594 | |
} |
| 2595 | |
} |
| 2596 | |
} |
| 2597 | 0 | } |
| 2598 | |
|
| 2599 | |
private void checkCluSetCircularReference(CluSet addedCluSet, String hostCluSetId) |
| 2600 | |
throws CircularRelationshipException { |
| 2601 | 0 | if (addedCluSet.getId().equals(hostCluSetId)) { |
| 2602 | 0 | throw new CircularRelationshipException( |
| 2603 | |
"Cannot add a CluSet (id=" + hostCluSetId + ") to ifself"); |
| 2604 | |
} |
| 2605 | 0 | if (addedCluSet.getCluSets() != null) { |
| 2606 | 0 | for (CluSet childSet : addedCluSet.getCluSets()) { |
| 2607 | 0 | if (childSet.getId().equals(hostCluSetId)) { |
| 2608 | 0 | throw new CircularRelationshipException( |
| 2609 | |
"CluSet (id=" + hostCluSetId |
| 2610 | |
+ ") already contains this CluSet (id=" |
| 2611 | |
+ childSet.getId() + ")"); |
| 2612 | |
} |
| 2613 | 0 | checkCluSetCircularReference(childSet, hostCluSetId); |
| 2614 | |
} |
| 2615 | |
} |
| 2616 | 0 | } |
| 2617 | |
|
| 2618 | |
@Override |
| 2619 | |
@Transactional(readOnly = false) |
| 2620 | |
public StatusInfo removeCluSetFromCluSet(String cluSetId, |
| 2621 | |
String removedCluSetId, ContextInfo context) throws DoesNotExistException, |
| 2622 | |
InvalidParameterException, MissingParameterException, |
| 2623 | |
OperationFailedException, PermissionDeniedException, |
| 2624 | |
UnsupportedActionException { |
| 2625 | |
|
| 2626 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2627 | 0 | checkForMissingParameter(removedCluSetId, "removedCluSetId"); |
| 2628 | |
|
| 2629 | |
CluSet cluSet; |
| 2630 | |
try { |
| 2631 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2632 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2633 | 0 | throw new DoesNotExistException(cluSetId); |
| 2634 | 0 | } |
| 2635 | 0 | if (cluSet.getCluSets() != null) { |
| 2636 | 0 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
| 2637 | 0 | CluSet childCluSet = i.next(); |
| 2638 | 0 | if (childCluSet.getId().equals(removedCluSetId)) { |
| 2639 | 0 | i.remove(); |
| 2640 | 0 | luDao.update(cluSet); |
| 2641 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2642 | 0 | statusInfo.setSuccess(true); |
| 2643 | |
|
| 2644 | 0 | return statusInfo; |
| 2645 | |
} |
| 2646 | 0 | } |
| 2647 | |
} |
| 2648 | |
|
| 2649 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2650 | 0 | statusInfo.setSuccess(false); |
| 2651 | 0 | statusInfo.setMessage("CluSet does not contain CluSet:" |
| 2652 | |
+ removedCluSetId); |
| 2653 | |
|
| 2654 | 0 | return statusInfo; |
| 2655 | |
} |
| 2656 | |
|
| 2657 | |
@Override |
| 2658 | |
@Transactional(readOnly = false) |
| 2659 | |
public StatusInfo addCluToCluSet(String cluId, String cluSetId, ContextInfo context) |
| 2660 | |
throws DoesNotExistException, InvalidParameterException, |
| 2661 | |
MissingParameterException, OperationFailedException, |
| 2662 | |
PermissionDeniedException, UnsupportedActionException { |
| 2663 | |
|
| 2664 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 2665 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2666 | |
|
| 2667 | |
CluSet cluSet; |
| 2668 | |
try { |
| 2669 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2670 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2671 | 0 | throw new DoesNotExistException(cluSetId); |
| 2672 | 0 | } |
| 2673 | |
|
| 2674 | 0 | checkCluAlreadyAdded(cluSet, cluId); |
| 2675 | |
|
| 2676 | |
try { |
| 2677 | 0 | luDao.getCurrentCluVersionInfo(cluId, LuServiceConstants.CLU_NAMESPACE_URI); |
| 2678 | 0 | } catch (NoResultException e) { |
| 2679 | 0 | throw new DoesNotExistException(); |
| 2680 | 0 | } |
| 2681 | |
|
| 2682 | 0 | CluSetJoinVersionIndClu join = new CluSetJoinVersionIndClu(); |
| 2683 | 0 | join.setCluSet(cluSet); |
| 2684 | 0 | join.setCluVersionIndId(cluId); |
| 2685 | |
|
| 2686 | 0 | cluSet.getCluVerIndIds().add(join); |
| 2687 | |
|
| 2688 | 0 | luDao.update(cluSet); |
| 2689 | |
|
| 2690 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2691 | 0 | statusInfo.setSuccess(true); |
| 2692 | |
|
| 2693 | 0 | return statusInfo; |
| 2694 | |
} |
| 2695 | |
|
| 2696 | |
private void checkCluAlreadyAdded(CluSet cluSet, String cluId) |
| 2697 | |
throws OperationFailedException { |
| 2698 | 0 | for (CluSetJoinVersionIndClu join : cluSet.getCluVerIndIds()) { |
| 2699 | 0 | if (join.getCluVersionIndId().equals(cluId)) { |
| 2700 | 0 | throw new OperationFailedException("CluSet already contains Clu (id='" + cluId + "')"); |
| 2701 | |
} |
| 2702 | |
} |
| 2703 | 0 | } |
| 2704 | |
|
| 2705 | |
@Override |
| 2706 | |
@Transactional(readOnly = false) |
| 2707 | |
public StatusInfo removeCluFromCluSet(String cluId, String cluSetId, ContextInfo context) |
| 2708 | |
throws DoesNotExistException, InvalidParameterException, |
| 2709 | |
MissingParameterException, OperationFailedException, |
| 2710 | |
PermissionDeniedException, UnsupportedActionException { |
| 2711 | |
|
| 2712 | 0 | checkForMissingParameter(cluId, "cluId"); |
| 2713 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2714 | |
|
| 2715 | |
CluSet cluSet; |
| 2716 | |
try { |
| 2717 | 0 | cluSet = luDao.fetch(CluSet.class, cluSetId); |
| 2718 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2719 | 0 | throw new DoesNotExistException(cluSetId); |
| 2720 | 0 | } |
| 2721 | |
|
| 2722 | 0 | for (Iterator<CluSetJoinVersionIndClu> i = cluSet.getCluVerIndIds().iterator(); i.hasNext();) { |
| 2723 | 0 | CluSetJoinVersionIndClu join = i.next(); |
| 2724 | 0 | if (join.getCluVersionIndId().equals(cluId)) { |
| 2725 | 0 | i.remove(); |
| 2726 | 0 | luDao.delete(join); |
| 2727 | 0 | luDao.update(cluSet); |
| 2728 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2729 | 0 | statusInfo.setSuccess(true); |
| 2730 | |
|
| 2731 | 0 | return statusInfo; |
| 2732 | |
} |
| 2733 | 0 | } |
| 2734 | |
|
| 2735 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2736 | 0 | statusInfo.setSuccess(false); |
| 2737 | 0 | statusInfo.setMessage("Clu set does not contain Clu:" + cluId); |
| 2738 | |
|
| 2739 | 0 | return statusInfo; |
| 2740 | |
} |
| 2741 | |
|
| 2742 | |
public LuDao getLuDao() { |
| 2743 | 0 | return luDao; |
| 2744 | |
} |
| 2745 | |
|
| 2746 | |
public void setLuDao(LuDao luDao) { |
| 2747 | 0 | this.luDao = luDao; |
| 2748 | 0 | } |
| 2749 | |
|
| 2750 | |
|
| 2751 | |
|
| 2752 | |
|
| 2753 | |
|
| 2754 | |
|
| 2755 | |
|
| 2756 | |
|
| 2757 | |
|
| 2758 | |
private void checkForMissingParameter(Object param, String paramName) |
| 2759 | |
throws MissingParameterException { |
| 2760 | 0 | if (param == null) { |
| 2761 | 0 | throw new MissingParameterException(paramName + " can not be null"); |
| 2762 | |
} |
| 2763 | 0 | } |
| 2764 | |
|
| 2765 | |
|
| 2766 | |
|
| 2767 | |
|
| 2768 | |
|
| 2769 | |
|
| 2770 | |
private void checkForEmptyList(Object param, String paramName) |
| 2771 | |
throws MissingParameterException { |
| 2772 | 0 | if (param != null && param instanceof List<?> |
| 2773 | |
&& ((List<?>) param).size() == 0) { |
| 2774 | 0 | throw new MissingParameterException(paramName |
| 2775 | |
+ " can not be an empty list"); |
| 2776 | |
} |
| 2777 | 0 | } |
| 2778 | |
|
| 2779 | |
@Override |
| 2780 | |
@Transactional(readOnly = false) |
| 2781 | |
public StatusInfo addCluSetsToCluSet(String cluSetId, List<String> cluSetIds, ContextInfo context) |
| 2782 | |
throws CircularRelationshipException, |
| 2783 | |
DoesNotExistException, InvalidParameterException, |
| 2784 | |
MissingParameterException, OperationFailedException, |
| 2785 | |
PermissionDeniedException, UnsupportedActionException { |
| 2786 | |
|
| 2787 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2788 | 0 | checkForMissingParameter(cluSetIds, "cluSetIds"); |
| 2789 | |
try { |
| 2790 | |
|
| 2791 | 0 | luDao.fetch(CluSet.class, cluSetId); |
| 2792 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2793 | 0 | throw new DoesNotExistException(cluSetId); |
| 2794 | 0 | } |
| 2795 | |
|
| 2796 | 0 | for (String cluSetIdToAdd : cluSetIds) { |
| 2797 | 0 | StatusInfo status = addCluSetToCluSet(cluSetId, cluSetIdToAdd, context); |
| 2798 | 0 | if (!status.getIsSuccess()) { |
| 2799 | 0 | return status; |
| 2800 | |
} |
| 2801 | 0 | } |
| 2802 | |
|
| 2803 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2804 | 0 | statusInfo.setSuccess(true); |
| 2805 | |
|
| 2806 | 0 | return statusInfo; |
| 2807 | |
} |
| 2808 | |
|
| 2809 | |
@Override |
| 2810 | |
@Transactional(readOnly = false) |
| 2811 | |
public StatusInfo addClusToCluSet(List<String> cluIds, String cluSetId, ContextInfo context) |
| 2812 | |
throws DoesNotExistException, InvalidParameterException, |
| 2813 | |
MissingParameterException, OperationFailedException, |
| 2814 | |
PermissionDeniedException, UnsupportedActionException { |
| 2815 | |
|
| 2816 | 0 | checkForMissingParameter(cluIds, "cluIds"); |
| 2817 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
| 2818 | |
|
| 2819 | 0 | for (String cluId : cluIds) { |
| 2820 | 0 | StatusInfo status = addCluToCluSet(cluId, cluSetId, context); |
| 2821 | 0 | if (!status.getIsSuccess()) { |
| 2822 | 0 | return status; |
| 2823 | |
} |
| 2824 | 0 | } |
| 2825 | |
|
| 2826 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 2827 | 0 | statusInfo.setSuccess(true); |
| 2828 | |
|
| 2829 | 0 | return statusInfo; |
| 2830 | |
} |
| 2831 | |
|
| 2832 | |
public ValidatorFactory getValidatorFactory() { |
| 2833 | 0 | return validatorFactory; |
| 2834 | |
} |
| 2835 | |
|
| 2836 | |
public void setValidatorFactory(ValidatorFactory validatorFactory) { |
| 2837 | 0 | this.validatorFactory = validatorFactory; |
| 2838 | 0 | } |
| 2839 | |
|
| 2840 | |
|
| 2841 | |
@Override |
| 2842 | |
@Transactional(readOnly = false) |
| 2843 | |
public CluInfo createNewCluVersion(String versionIndCluId, |
| 2844 | |
String versionComment, |
| 2845 | |
ContextInfo context) |
| 2846 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
| 2847 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 2848 | |
Clu latestClu; |
| 2849 | |
Clu currentClu; |
| 2850 | |
try { |
| 2851 | 0 | latestClu = luDao.getLatestCluVersion(versionIndCluId); |
| 2852 | 0 | } catch (NoResultException e) { |
| 2853 | 0 | throw new DoesNotExistException("There are no matching versions of this clu", e); |
| 2854 | 0 | } |
| 2855 | |
try { |
| 2856 | 0 | currentClu = luDao.getCurrentCluVersion(versionIndCluId); |
| 2857 | 0 | } catch (NoResultException e) { |
| 2858 | 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); |
| 2859 | 0 | } |
| 2860 | |
|
| 2861 | 0 | CluInfo cluInfo = LuServiceAssembler.toCluInfo(currentClu); |
| 2862 | |
|
| 2863 | |
|
| 2864 | 0 | clearCluIds(cluInfo); |
| 2865 | |
|
| 2866 | |
|
| 2867 | 0 | CluInfo newClu = null; |
| 2868 | |
|
| 2869 | |
try { |
| 2870 | 0 | Clu clu = toCluForCreate(cluInfo.getType(), cluInfo, context); |
| 2871 | |
|
| 2872 | 0 | Version version = new Version(); |
| 2873 | 0 | version.setSequenceNumber(latestClu.getVersion().getSequenceNumber() + 1); |
| 2874 | 0 | version.setVersionIndId(versionIndCluId); |
| 2875 | 0 | version.setCurrentVersionStart(null); |
| 2876 | 0 | version.setCurrentVersionEnd(null); |
| 2877 | 0 | version.setVersionComment(versionComment); |
| 2878 | 0 | version.setVersionedFromId(currentClu.getId()); |
| 2879 | 0 | clu.setVersion(version); |
| 2880 | 0 | luDao.create(clu); |
| 2881 | 0 | newClu = LuServiceAssembler.toCluInfo(clu); |
| 2882 | 0 | } catch (AlreadyExistsException e) { |
| 2883 | 0 | throw new OperationFailedException("Error creating a new clu version", e); |
| 2884 | 0 | } |
| 2885 | |
|
| 2886 | 0 | return newClu; |
| 2887 | |
} |
| 2888 | |
|
| 2889 | |
private void clearCluIds(CluInfo clu) { |
| 2890 | |
|
| 2891 | 0 | clu.setStateKey(DtoConstants.STATE_DRAFT); |
| 2892 | 0 | clu.setId(null); |
| 2893 | |
|
| 2894 | 0 | if (clu.getAccountingInfo() != null) { |
| 2895 | 0 | clu.getAccountingInfo().setId(null); |
| 2896 | |
|
| 2897 | 0 | for (AffiliatedOrgInfo affiliatedOrg : clu.getAccountingInfo().getAffiliatedOrgs()) { |
| 2898 | 0 | affiliatedOrg.setId(null); |
| 2899 | |
} |
| 2900 | |
} |
| 2901 | 0 | for (AccreditationInfo accredation : clu.getAccreditations()) { |
| 2902 | 0 | accredation.setId(null); |
| 2903 | |
} |
| 2904 | 0 | for (AdminOrgInfo adminOrg : clu.getAdminOrgs()) { |
| 2905 | 0 | adminOrg.setId(null); |
| 2906 | |
} |
| 2907 | 0 | for (CluIdentifierInfo alternateIdentifier : clu.getAlternateIdentifiers()) { |
| 2908 | 0 | alternateIdentifier.setId(null); |
| 2909 | |
} |
| 2910 | 0 | if (clu.getFeeInfo() != null) { |
| 2911 | 0 | clu.getFeeInfo().setId(null); |
| 2912 | 0 | for (CluFeeRecordInfo cluFeeRecord : clu.getFeeInfo().getCluFeeRecords()) { |
| 2913 | 0 | cluFeeRecord.setId(null); |
| 2914 | 0 | for (AffiliatedOrgInfo affiliatedOrg : cluFeeRecord.getAffiliatedOrgs()) { |
| 2915 | 0 | affiliatedOrg.setId(null); |
| 2916 | |
} |
| 2917 | |
} |
| 2918 | |
} |
| 2919 | 0 | for (LuCodeInfo luCode : clu.getLuCodes()) { |
| 2920 | 0 | luCode.setId(null); |
| 2921 | |
} |
| 2922 | 0 | if (clu.getOfficialIdentifier() != null) { |
| 2923 | 0 | clu.getOfficialIdentifier().setId(null); |
| 2924 | |
} |
| 2925 | 0 | } |
| 2926 | |
|
| 2927 | |
|
| 2928 | |
|
| 2929 | |
|
| 2930 | |
|
| 2931 | |
|
| 2932 | |
|
| 2933 | |
@Override |
| 2934 | |
@Transactional(readOnly = false) |
| 2935 | |
public StatusInfo setCurrentCluVersion(String cluVersionId, Date currentVersionStart, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, IllegalVersionSequencingException, OperationFailedException, PermissionDeniedException { |
| 2936 | |
|
| 2937 | 0 | Date currentDbDate = new Date(); |
| 2938 | 0 | if (currentVersionStart != null && currentVersionStart.compareTo(currentDbDate) < 0) { |
| 2939 | 0 | throw new InvalidParameterException("currentVersionStart must be in the future."); |
| 2940 | |
} |
| 2941 | |
|
| 2942 | 0 | if (currentVersionStart == null) { |
| 2943 | 0 | currentVersionStart = currentDbDate; |
| 2944 | |
} |
| 2945 | |
|
| 2946 | |
|
| 2947 | |
Clu clu; |
| 2948 | |
try { |
| 2949 | 0 | clu = luDao.fetch(Clu.class, cluVersionId); |
| 2950 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2951 | 0 | throw new DoesNotExistException(cluVersionId); |
| 2952 | 0 | } |
| 2953 | 0 | String versionIndId = clu.getVersion().getVersionIndId(); |
| 2954 | |
|
| 2955 | 0 | Clu oldClu = null; |
| 2956 | |
try { |
| 2957 | 0 | oldClu = luDao.getCurrentCluVersion(versionIndId); |
| 2958 | 0 | } catch (NoResultException e) { |
| 2959 | 0 | } |
| 2960 | |
|
| 2961 | |
|
| 2962 | 0 | if (oldClu != null) { |
| 2963 | 0 | if (clu.getVersion().getSequenceNumber() <= oldClu.getVersion().getSequenceNumber()) { |
| 2964 | 0 | throw new OperationFailedException("Clu to make current must have been versioned from the current Clu"); |
| 2965 | |
} |
| 2966 | |
} else { |
| 2967 | |
|
| 2968 | 0 | currentVersionStart = currentDbDate; |
| 2969 | |
} |
| 2970 | |
|
| 2971 | |
|
| 2972 | |
|
| 2973 | 0 | List<VersionDisplayInfo> versionsInFuture = new R1ToR2CopyHelper().copyVersionDisplays(luDao.getVersionsInDateRange(versionIndId, null, currentDbDate, null)); |
| 2974 | 0 | for (VersionDisplayInfo versionInFuture : versionsInFuture) { |
| 2975 | 0 | if (oldClu == null || !versionInFuture.getId().equals(oldClu.getId())) { |
| 2976 | |
VersionEntity futureClu; |
| 2977 | |
try { |
| 2978 | 0 | futureClu = luDao.fetch(Clu.class, versionInFuture.getId()); |
| 2979 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
| 2980 | 0 | throw new DoesNotExistException(versionInFuture.getId()); |
| 2981 | 0 | } |
| 2982 | 0 | futureClu.getVersion().setCurrentVersionStart(null); |
| 2983 | 0 | futureClu.getVersion().setCurrentVersionEnd(null); |
| 2984 | 0 | futureClu = luDao.update(futureClu); |
| 2985 | 0 | } |
| 2986 | |
} |
| 2987 | |
|
| 2988 | |
|
| 2989 | 0 | if (oldClu != null) { |
| 2990 | 0 | oldClu.getVersion().setCurrentVersionEnd(currentVersionStart); |
| 2991 | 0 | oldClu = luDao.update(oldClu); |
| 2992 | |
} |
| 2993 | |
|
| 2994 | |
|
| 2995 | 0 | clu.getVersion().setCurrentVersionStart(currentVersionStart); |
| 2996 | 0 | clu.getVersion().setCurrentVersionEnd(null); |
| 2997 | 0 | clu = luDao.update(clu); |
| 2998 | |
|
| 2999 | 0 | StatusInfo statusInfo = new StatusInfo(); |
| 3000 | 0 | statusInfo.setSuccess(true); |
| 3001 | 0 | return statusInfo; |
| 3002 | |
} |
| 3003 | |
|
| 3004 | |
@Override |
| 3005 | |
public VersionDisplayInfo getLatestVersion(String refObjectTypeURI, String refObjectId, ContextInfo context) |
| 3006 | |
throws DoesNotExistException, InvalidParameterException, |
| 3007 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3008 | 0 | VersionDisplayInfo versionInfo = null; |
| 3009 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3010 | |
try { |
| 3011 | 0 | versionInfo = this.getLatestVersion(refObjectId, refObjectTypeURI, context); |
| 3012 | 0 | } catch (NoResultException e) { |
| 3013 | 0 | throw new DoesNotExistException(); |
| 3014 | 0 | } |
| 3015 | |
} else { |
| 3016 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3017 | |
} |
| 3018 | 0 | return versionInfo; |
| 3019 | |
} |
| 3020 | |
|
| 3021 | |
@Override |
| 3022 | |
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId, ContextInfo context) |
| 3023 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3024 | 0 | VersionDisplayInfo versionInfo = null; |
| 3025 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3026 | |
try { |
| 3027 | 0 | versionInfo = new R1ToR2CopyHelper().copyVersionDisplay(luDao.getCurrentCluVersionInfo(refObjectId, refObjectTypeURI)); |
| 3028 | 0 | } catch (NoResultException e) { |
| 3029 | 0 | throw new DoesNotExistException(); |
| 3030 | 0 | } |
| 3031 | |
} else { |
| 3032 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3033 | |
} |
| 3034 | 0 | return versionInfo; |
| 3035 | |
} |
| 3036 | |
|
| 3037 | |
@Override |
| 3038 | |
public VersionDisplayInfo getCurrentVersionOnDate(String refObjectTypeURI, String refObjectId, Date date, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3039 | 0 | VersionDisplayInfo versionInfo = null; |
| 3040 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3041 | |
try { |
| 3042 | 0 | versionInfo = new R1ToR2CopyHelper().copyVersionDisplay(luDao.getCurrentVersionOnDate(refObjectId, refObjectTypeURI, date)); |
| 3043 | 0 | } catch (NoResultException e) { |
| 3044 | 0 | throw new DoesNotExistException(); |
| 3045 | 0 | } |
| 3046 | |
} else { |
| 3047 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3048 | |
} |
| 3049 | 0 | return versionInfo; |
| 3050 | |
} |
| 3051 | |
|
| 3052 | |
@Override |
| 3053 | |
public VersionDisplayInfo getFirstVersion(String refObjectTypeURI, String refObjectId, ContextInfo context) |
| 3054 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3055 | 0 | VersionDisplayInfo versionInfo = null; |
| 3056 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3057 | |
try { |
| 3058 | 0 | versionInfo = new R1ToR2CopyHelper().copyVersionDisplay(luDao.getFirstVersion(refObjectId, refObjectTypeURI)); |
| 3059 | 0 | } catch (NoResultException e) { |
| 3060 | 0 | throw new DoesNotExistException(); |
| 3061 | 0 | } |
| 3062 | |
} else { |
| 3063 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3064 | |
} |
| 3065 | 0 | return versionInfo; |
| 3066 | |
} |
| 3067 | |
|
| 3068 | |
@Override |
| 3069 | |
public VersionDisplayInfo getVersionBySequenceNumber(String refObjectTypeURI, String refObjectId, |
| 3070 | |
Long sequence, ContextInfo context) |
| 3071 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3072 | 0 | VersionDisplayInfo versionInfo = null; |
| 3073 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3074 | |
try { |
| 3075 | 0 | versionInfo = new R1ToR2CopyHelper().copyVersionDisplay(luDao.getVersionBySequenceNumber(refObjectId, refObjectTypeURI, sequence)); |
| 3076 | 0 | } catch (NoResultException e) { |
| 3077 | 0 | throw new DoesNotExistException(); |
| 3078 | 0 | } |
| 3079 | |
} else { |
| 3080 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3081 | |
} |
| 3082 | 0 | return versionInfo; |
| 3083 | |
} |
| 3084 | |
|
| 3085 | |
@Override |
| 3086 | |
public List<VersionDisplayInfo> getVersions(String refObjectTypeURI, String refObjectId, ContextInfo context) |
| 3087 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3088 | 0 | List<VersionDisplayInfo> versionInfos = null; |
| 3089 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3090 | 0 | versionInfos = new R1ToR2CopyHelper().copyVersionDisplays(luDao.getVersions(refObjectId, refObjectTypeURI)); |
| 3091 | 0 | if (versionInfos == null) { |
| 3092 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
| 3093 | |
} |
| 3094 | |
} else { |
| 3095 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3096 | |
} |
| 3097 | 0 | return versionInfos; |
| 3098 | |
} |
| 3099 | |
|
| 3100 | |
@Override |
| 3101 | |
public List<VersionDisplayInfo> getVersionsInDateRange(String refObjectTypeURI, |
| 3102 | |
String refObjectId, |
| 3103 | |
Date from, |
| 3104 | |
Date to, |
| 3105 | |
ContextInfo context) |
| 3106 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 3107 | 0 | List<VersionDisplayInfo> versionInfos = null; |
| 3108 | 0 | if (LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)) { |
| 3109 | 0 | versionInfos = new R1ToR2CopyHelper().copyVersionDisplays(luDao.getVersionsInDateRange(refObjectId, refObjectTypeURI, from, to)); |
| 3110 | 0 | if (versionInfos == null) { |
| 3111 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
| 3112 | |
} |
| 3113 | |
} else { |
| 3114 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:" + refObjectTypeURI); |
| 3115 | |
} |
| 3116 | 0 | return versionInfos; |
| 3117 | |
} |
| 3118 | |
|
| 3119 | |
public void setSearchDispatcher(SearchDispatcher searchDispatcher) { |
| 3120 | 0 | this.searchDispatcher = searchDispatcher; |
| 3121 | 0 | } |
| 3122 | |
|
| 3123 | |
private ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
| 3124 | 0 | return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
| 3125 | |
} |
| 3126 | |
} |