| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.lum.lo.service.impl; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.List; |
| 20 |
|
|
| 21 |
|
import org.kuali.student.core.dao.CrudDao; |
| 22 |
|
import org.kuali.student.core.exceptions.DoesNotExistException; |
| 23 |
|
import org.kuali.student.core.exceptions.InvalidParameterException; |
| 24 |
|
import org.kuali.student.core.exceptions.VersionMismatchException; |
| 25 |
|
import org.kuali.student.core.service.impl.BaseAssembler; |
| 26 |
|
import org.kuali.student.lum.lo.dao.LoDao; |
| 27 |
|
import org.kuali.student.lum.lo.dto.LoCategoryInfo; |
| 28 |
|
import org.kuali.student.lum.lo.dto.LoCategoryTypeInfo; |
| 29 |
|
import org.kuali.student.lum.lo.dto.LoInfo; |
| 30 |
|
import org.kuali.student.lum.lo.dto.LoLoRelationInfo; |
| 31 |
|
import org.kuali.student.lum.lo.dto.LoLoRelationTypeInfo; |
| 32 |
|
import org.kuali.student.lum.lo.dto.LoRepositoryInfo; |
| 33 |
|
import org.kuali.student.lum.lo.dto.LoTypeInfo; |
| 34 |
|
import org.kuali.student.lum.lo.entity.Lo; |
| 35 |
|
import org.kuali.student.lum.lo.entity.LoAttribute; |
| 36 |
|
import org.kuali.student.lum.lo.entity.LoCategory; |
| 37 |
|
import org.kuali.student.lum.lo.entity.LoCategoryAttribute; |
| 38 |
|
import org.kuali.student.lum.lo.entity.LoCategoryType; |
| 39 |
|
import org.kuali.student.lum.lo.entity.LoCategoryTypeAttribute; |
| 40 |
|
import org.kuali.student.lum.lo.entity.LoLoRelation; |
| 41 |
|
import org.kuali.student.lum.lo.entity.LoLoRelationAttribute; |
| 42 |
|
import org.kuali.student.lum.lo.entity.LoLoRelationType; |
| 43 |
|
import org.kuali.student.lum.lo.entity.LoRepository; |
| 44 |
|
import org.kuali.student.lum.lo.entity.LoRichText; |
| 45 |
|
import org.kuali.student.lum.lo.entity.LoType; |
| 46 |
|
import org.springframework.beans.BeanUtils; |
| 47 |
|
|
|
|
|
| 49% |
Uncovered Elements: 98 (192) |
Complexity: 39 |
Complexity Density: 0.28 |
|
| 48 |
|
public class LearningObjectiveServiceAssembler extends BaseAssembler { |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
651
|
public static Lo toLo(boolean isUpdate, LoInfo dto, CrudDao dao) throws InvalidParameterException, DoesNotExistException, VersionMismatchException {... |
| 51 |
651
|
return toLo(isUpdate, new Lo(), dto, dao); |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 70.6% |
Uncovered Elements: 10 (34) |
Complexity: 7 |
Complexity Density: 0.32 |
|
| 54 |
672
|
public static Lo toLo(boolean isUpdate, Lo entity, LoInfo dto, CrudDao dao) throws InvalidParameterException, DoesNotExistException, VersionMismatchException {... |
| 55 |
672
|
if(null == dto) { |
| 56 |
0
|
return null; |
| 57 |
|
} |
| 58 |
672
|
Lo lo; |
| 59 |
|
|
| 60 |
672
|
if (isUpdate) { |
| 61 |
21
|
lo = dao.fetch(Lo.class, dto.getId()); |
| 62 |
21
|
if (lo == null) { |
| 63 |
0
|
throw new DoesNotExistException((new StringBuilder()).append("Lo does not exist for id: ").append(dto.getId()).toString()); |
| 64 |
|
} |
| 65 |
21
|
if ( ! String.valueOf(lo.getVersionNumber()).equals(dto.getMetaInfo().getVersionInd()) ) { |
| 66 |
0
|
throw new VersionMismatchException("Lo to be updated is not the current version"); |
| 67 |
|
} |
| 68 |
|
} else { |
| 69 |
651
|
lo = new Lo(); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
672
|
BeanUtils.copyProperties(dto, lo, new String[] { "desc", "loRepository", "loType", "attributes", "metaInfo" }); |
| 73 |
|
|
| 74 |
672
|
lo.setAttributes(toGenericAttributes(LoAttribute.class, dto.getAttributes(), lo, dao)); |
| 75 |
672
|
lo.setDescr(toRichText(LoRichText.class, dto.getDesc())); |
| 76 |
|
|
| 77 |
672
|
LoRepository repository = dao.fetch(LoRepository.class, dto.getLoRepositoryKey()); |
| 78 |
672
|
if(null == repository) { |
| 79 |
0
|
throw new InvalidParameterException((new StringBuilder()).append("LoRepository does not exist for id: ").append(dto.getLoRepositoryKey()).toString()); |
| 80 |
|
} |
| 81 |
672
|
lo.setLoRepository(repository); |
| 82 |
|
|
| 83 |
672
|
LoType type = dao.fetch(LoType.class, dto.getType()); |
| 84 |
672
|
if(null == type) { |
| 85 |
0
|
throw new InvalidParameterException((new StringBuilder()).append("LoType does not exist for id: ").append(dto.getType()).toString()); |
| 86 |
|
} |
| 87 |
672
|
lo.setLoType(type); |
| 88 |
|
|
| 89 |
672
|
return lo; |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 92 |
1059
|
public static LoInfo toLoInfo(Lo entity) {... |
| 93 |
1059
|
LoInfo dto = new LoInfo(); |
| 94 |
|
|
| 95 |
1059
|
BeanUtils.copyProperties(entity, dto, |
| 96 |
|
new String[] { "desc", "attributes", "type" }); |
| 97 |
1059
|
dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 98 |
1059
|
dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 99 |
1059
|
dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 100 |
1059
|
dto.setType(entity.getLoType().getId()); |
| 101 |
1059
|
dto.setLoRepositoryKey(entity.getLoRepository() == null? null: entity.getLoRepository().getId()); |
| 102 |
1059
|
return dto; |
| 103 |
|
} |
| 104 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 105 |
0
|
public static LoCategory toLoCategory(LoCategoryInfo dto, LoDao dao) throws InvalidParameterException, DoesNotExistException {... |
| 106 |
0
|
return toLoCategory(new LoCategory(), dto, dao); |
| 107 |
|
} |
| 108 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 109 |
0
|
public static LoCategory toLoCategory(LoCategory entity, LoCategoryInfo dto, LoDao dao) throws InvalidParameterException, DoesNotExistException {... |
| 110 |
0
|
if(entity == null) |
| 111 |
0
|
entity = new LoCategory(); |
| 112 |
0
|
BeanUtils.copyProperties(dto, entity, |
| 113 |
|
new String[] { "desc", "attributes", "metaInfo", "loRepository", "type", "id"}); |
| 114 |
0
|
entity.setDesc(toRichText(LoRichText.class, dto.getDesc())); |
| 115 |
0
|
entity.setAttributes(toGenericAttributes(LoCategoryAttribute.class, dto.getAttributes(), entity, dao)); |
| 116 |
0
|
entity.setLoRepository(dao.fetch(LoRepository.class, dto.getLoRepository())); |
| 117 |
0
|
entity.setLoCategoryType(dao.fetch(LoCategoryType.class, dto.getType())); |
| 118 |
0
|
return entity; |
| 119 |
|
} |
| 120 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 121 |
775
|
public static LoCategoryInfo toLoCategoryInfo(LoCategory entity) {... |
| 122 |
775
|
LoCategoryInfo dto = new LoCategoryInfo(); |
| 123 |
|
|
| 124 |
775
|
BeanUtils.copyProperties(entity, dto, |
| 125 |
|
new String[] { "desc", "attributes", "loRepository", "loCategoryType" }); |
| 126 |
775
|
dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 127 |
775
|
dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 128 |
775
|
dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 129 |
775
|
dto.setLoRepository(entity.getLoRepository().getId()); |
| 130 |
775
|
dto.setType(entity.getLoCategoryType().getId()); |
| 131 |
|
|
| 132 |
775
|
return dto; |
| 133 |
|
} |
| 134 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 135 |
0
|
public static LoRepositoryInfo toLoRepositoryInfo(LoRepository entity) {... |
| 136 |
0
|
LoRepositoryInfo dto = new LoRepositoryInfo(); |
| 137 |
|
|
| 138 |
0
|
BeanUtils.copyProperties(entity, dto, |
| 139 |
|
new String[] { "desc", "attributes", "rootLo" }); |
| 140 |
0
|
dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 141 |
0
|
dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 142 |
0
|
dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 143 |
0
|
dto.setRootLoId(entity.getRootLo() == null? null :entity.getRootLo().getId()); |
| 144 |
0
|
return dto; |
| 145 |
|
} |
| 146 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 147 |
0
|
public static LoTypeInfo toLoTypeInfo(LoType entity) {... |
| 148 |
0
|
LoTypeInfo dto = new LoTypeInfo(); |
| 149 |
|
|
| 150 |
0
|
BeanUtils.copyProperties(entity, dto, |
| 151 |
|
new String[] { "attributes" }); |
| 152 |
0
|
dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 153 |
0
|
return dto; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 157 |
387
|
public static List<LoInfo> toLoInfos(List<Lo> los) {... |
| 158 |
387
|
List<LoInfo> list = new ArrayList<LoInfo>(); |
| 159 |
387
|
for (Lo lo : los) { |
| 160 |
304
|
list.add(toLoInfo(lo)); |
| 161 |
|
} |
| 162 |
387
|
return list; |
| 163 |
|
} |
| 164 |
|
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 165 |
439
|
public static List<LoCategoryInfo> toLoCategoryInfos(List<LoCategory> categories) {... |
| 166 |
439
|
if (null == categories) { |
| 167 |
0
|
return new ArrayList<LoCategoryInfo>(0); |
| 168 |
|
} |
| 169 |
439
|
List<LoCategoryInfo> list = new ArrayList<LoCategoryInfo>(categories.size()); |
| 170 |
439
|
for (LoCategory loCategory : categories) { |
| 171 |
775
|
list.add(toLoCategoryInfo(loCategory)); |
| 172 |
|
} |
| 173 |
439
|
return list; |
| 174 |
|
} |
| 175 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 176 |
0
|
public static List<LoRepositoryInfo> toLoRepositoryInfos(List<LoRepository> repositories) {... |
| 177 |
0
|
List<LoRepositoryInfo> list = new ArrayList<LoRepositoryInfo>(); |
| 178 |
0
|
for (LoRepository loRepository : repositories) { |
| 179 |
0
|
list.add(toLoRepositoryInfo(loRepository)); |
| 180 |
|
} |
| 181 |
0
|
return list; |
| 182 |
|
} |
| 183 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 184 |
0
|
public static List<LoTypeInfo> toLoTypeInfos(List<LoType> find) {... |
| 185 |
0
|
List<LoTypeInfo> list = new ArrayList<LoTypeInfo>(); |
| 186 |
0
|
for (LoType loType : find) { |
| 187 |
0
|
list.add(toLoTypeInfo(loType)); |
| 188 |
|
} |
| 189 |
0
|
return list; |
| 190 |
|
} |
| 191 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 192 |
0
|
public static List<LoLoRelationTypeInfo> toLoLoRelationTypeInfos(List<LoLoRelationType> find) {... |
| 193 |
0
|
List<LoLoRelationTypeInfo> list = new ArrayList<LoLoRelationTypeInfo>(); |
| 194 |
0
|
for (LoLoRelationType loType : find) { |
| 195 |
0
|
list.add(toLoLoRelationTypeInfo(loType)); |
| 196 |
|
} |
| 197 |
0
|
return list; |
| 198 |
|
} |
| 199 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 200 |
0
|
public static LoLoRelationTypeInfo toLoLoRelationTypeInfo(LoLoRelationType loLoRelType) {... |
| 201 |
0
|
LoLoRelationTypeInfo dto = new LoLoRelationTypeInfo(); |
| 202 |
0
|
BeanUtils.copyProperties(loLoRelType, dto, |
| 203 |
|
new String[] { "attributes" }); |
| 204 |
0
|
dto.setAttributes(toAttributeMap(loLoRelType.getAttributes())); |
| 205 |
0
|
return dto; |
| 206 |
|
} |
| 207 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 208 |
552
|
public static LoLoRelation toLoLoRelation(boolean isUpdate, LoLoRelationInfo dto, CrudDao dao) throws DoesNotExistException, VersionMismatchException, InvalidParameterException {... |
| 209 |
552
|
return toLoLoRelation(isUpdate, null, dto, dao); |
| 210 |
|
} |
| 211 |
|
|
|
|
|
| 52.8% |
Uncovered Elements: 17 (36) |
Complexity: 8 |
Complexity Density: 0.33 |
|
| 212 |
552
|
public static LoLoRelation toLoLoRelation(boolean isUpdate, LoLoRelation entity, LoLoRelationInfo dto, CrudDao dao) throws DoesNotExistException, VersionMismatchException, InvalidParameterException {... |
| 213 |
552
|
if(null == dto) { |
| 214 |
0
|
return null; |
| 215 |
|
} |
| 216 |
552
|
LoLoRelation llRelation; |
| 217 |
|
|
| 218 |
552
|
if (isUpdate) { |
| 219 |
0
|
llRelation = dao.fetch(LoLoRelation.class, dto.getId()); |
| 220 |
0
|
if (llRelation == null) { |
| 221 |
0
|
throw new DoesNotExistException((new StringBuilder()).append("LoLoRelation does not exist for id: ").append(dto.getId()).toString()); |
| 222 |
|
} |
| 223 |
0
|
if ( ! String.valueOf(llRelation.getVersionNumber()).equals(dto.getMetaInfo().getVersionInd()) ) { |
| 224 |
0
|
throw new VersionMismatchException("LoLoRelation to be updated is not the current version"); |
| 225 |
|
} |
| 226 |
|
} else { |
| 227 |
552
|
llRelation = new LoLoRelation(); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
552
|
BeanUtils.copyProperties(dto, llRelation, new String[] { "lo", "relatedLo", "attributes", "metaInfo" }); |
| 231 |
|
|
| 232 |
552
|
llRelation.setAttributes(toGenericAttributes(LoLoRelationAttribute.class, dto.getAttributes(), llRelation, dao)); |
| 233 |
|
|
| 234 |
552
|
Lo lo = null; |
| 235 |
552
|
Lo relatedLo = null; |
| 236 |
552
|
LoLoRelationType relationType = null; |
| 237 |
552
|
try { |
| 238 |
552
|
lo = dao.fetch(Lo.class, dto.getLoId()); |
| 239 |
552
|
relatedLo = dao.fetch(Lo.class, dto.getRelatedLoId()); |
| 240 |
552
|
relationType = dao.fetch(LoLoRelationType.class, dto.getType()); |
| 241 |
|
} catch (DoesNotExistException dnee) { |
| 242 |
0
|
throw new DoesNotExistException((null == lo ? "Lo" : (null == relatedLo ? "Related Lo" : "Lo-Lo relation type")) + |
| 243 |
|
" does not exist when creating LoLoRelation", dnee); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
552
|
llRelation.setLo(lo); |
| 247 |
552
|
llRelation.setRelatedLo(relatedLo); |
| 248 |
552
|
llRelation.setLoLoRelationType(relationType); |
| 249 |
|
|
| 250 |
552
|
return llRelation; |
| 251 |
|
} |
| 252 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 253 |
618
|
public static LoLoRelationInfo toLoLoRelationInfo(LoLoRelation entity) {... |
| 254 |
618
|
LoLoRelationInfo dto = new LoLoRelationInfo(); |
| 255 |
|
|
| 256 |
618
|
BeanUtils.copyProperties(entity, dto, |
| 257 |
|
new String[] { "lo", "relatedLo", "type", "attributes" }); |
| 258 |
618
|
dto.setLoId(entity.getLo().getId()); |
| 259 |
618
|
dto.setRelatedLoId(entity.getRelatedLo().getId()); |
| 260 |
618
|
dto.setType(entity.getLoLoRelationType().getId()); |
| 261 |
618
|
dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 262 |
618
|
dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 263 |
618
|
return dto; |
| 264 |
|
} |
| 265 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 266 |
0
|
public static LoCategoryType toLoCategoryType(LoCategoryType entity, LoCategoryTypeInfo dto, LoDao dao) throws InvalidParameterException {... |
| 267 |
0
|
if(entity == null) |
| 268 |
0
|
entity = new LoCategoryType(); |
| 269 |
0
|
BeanUtils.copyProperties(dto, entity, |
| 270 |
|
new String[] { "attributes", "metaInfo" }); |
| 271 |
0
|
entity.setAttributes(toGenericAttributes(LoCategoryTypeAttribute.class, dto.getAttributes(), entity, dao)); |
| 272 |
0
|
entity.setDescr(dto.getDesc()); |
| 273 |
0
|
return entity; |
| 274 |
|
} |
| 275 |
|
|
| 276 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 277 |
0
|
public static LoCategoryTypeInfo toLoCategoryTypeInfo( LoCategoryType loCatType) {... |
| 278 |
0
|
LoCategoryTypeInfo dto = new LoCategoryTypeInfo(); |
| 279 |
0
|
BeanUtils.copyProperties(loCatType, dto, new String[] { "attributes" }); |
| 280 |
0
|
dto.setAttributes(toAttributeMap(loCatType.getAttributes())); |
| 281 |
0
|
dto.setDesc(loCatType.getDescr()); |
| 282 |
0
|
return dto; |
| 283 |
|
} |
| 284 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 285 |
0
|
public static List<LoCategoryTypeInfo> toLoCategoryTypeInfos(List<LoCategoryType> categoryTypes) {... |
| 286 |
0
|
ArrayList<LoCategoryTypeInfo> list = new ArrayList<LoCategoryTypeInfo>(); |
| 287 |
0
|
for (LoCategoryType catType : categoryTypes) { |
| 288 |
0
|
list.add(toLoCategoryTypeInfo(catType)); |
| 289 |
|
} |
| 290 |
0
|
return list; |
| 291 |
|
} |
| 292 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 293 |
52
|
public static List<LoLoRelationInfo> toLoLoRelationInfos( List<LoLoRelation> llRelations) {... |
| 294 |
52
|
List<LoLoRelationInfo> llRelInfos = new ArrayList<LoLoRelationInfo>(); |
| 295 |
52
|
for (LoLoRelation llRelation : llRelations) { |
| 296 |
66
|
llRelInfos.add(toLoLoRelationInfo(llRelation)); |
| 297 |
|
} |
| 298 |
52
|
return llRelInfos; |
| 299 |
|
} |
| 300 |
|
} |