|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LearningObjectiveServiceAssembler | Line # 48 | 137 | 0% | 39 | 42 | 78.1% |
0.78125
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (53) | |||
| Result | |||
|
0.48958334
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse
|
1 PASS | |
|
0.45833334
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions
|
1 PASS | |
|
0.43229166
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning
|
1 PASS | |
|
0.35416666
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse
|
1 PASS | |
|
0.32291666
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram
|
1 PASS | |
|
0.31770834
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule
|
1 PASS | |
|
0.296875
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline
|
1 PASS | |
|
0.296875
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline
|
1 PASS | |
|
0.296875
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline
|
1 PASS | |
|
0.296875
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline
|
1 PASS | |
|
0.24479167
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement
|
1 PASS | |
|
0.24479167
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram
|
1 PASS | |
|
0.234375
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement
|
1 PASS | |
|
0.21875
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory
|
1 PASS | |
|
0.21354167
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement
|
1 PASS | |
|
0.21354167
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement
|
1 PASS | |
|
0.16145833
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testCreateLoLoRelation
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testCreateLoLoRelation
|
1 PASS | |
|
0.16145833
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetProgramRequirement
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetMajorDiscipline
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetVariationsByMajorDisciplineId
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetVariationsByMajorDisciplineId
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplication
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplication
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testUpdateLoCategoryDuplicationCaseInsensitive
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testUpdateLoCategoryDuplicationCaseInsensitive
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetCoreProgram
|
1 PASS | |
|
0.104166664
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplicationCaseInsensitive
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplicationCaseInsensitive
|
1 PASS | |
|
0.083333336
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategories
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategories
|
1 PASS | |
|
0.083333336
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testAddRemoveLoCategoryToFromLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testAddRemoveLoCategoryToFromLo
|
1 PASS | |
|
0.083333336
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoriesForLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoriesForLo
|
1 PASS | |
|
0.078125
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetRelatedLosByLoId
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetRelatedLosByLoId
|
1 PASS | |
|
0.078125
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoByIdList
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoByIdList
|
1 PASS | |
|
0.072916664
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoRepositories
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoRepositories
|
1 PASS | |
|
0.057291668
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoryTypes
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoryTypes
|
1 PASS | |
|
0.052083332
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelationTypes
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelationTypes
|
1 PASS | |
|
0.052083332
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoTypesAndGetLoType
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoTypesAndGetLoType
|
1 PASS | |
|
0.046875
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelation
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelation
|
1 PASS | |
|
0.046875
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoRepository
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoRepository
|
1 PASS | |
|
0.026041666
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelationType
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoLoRelationType
|
1 PASS | |
| 1 | /** | |
| 2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 | * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 | * not use this file except in compliance with the License. You may | |
| 5 | * obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, | |
| 10 | * software distributed under the License is distributed on an "AS IS" | |
| 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 | * or implied. See the License for the specific language governing | |
| 13 | * permissions and limitations under the License. | |
| 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.common.dao.CrudDao; | |
| 22 | import org.kuali.student.common.exceptions.DoesNotExistException; | |
| 23 | import org.kuali.student.common.exceptions.InvalidParameterException; | |
| 24 | import org.kuali.student.common.exceptions.VersionMismatchException; | |
| 25 | import org.kuali.student.common.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 | ||
| 48 | public class LearningObjectiveServiceAssembler extends BaseAssembler { | |
| 49 | ||
| 50 | 652 |
public static Lo toLo(boolean isUpdate, LoInfo dto, CrudDao dao) throws InvalidParameterException, DoesNotExistException, VersionMismatchException { |
| 51 | 652 | return toLo(isUpdate, new Lo(), dto, dao); |
| 52 | } | |
| 53 | ||
| 54 | 674 |
public static Lo toLo(boolean isUpdate, Lo entity, LoInfo dto, CrudDao dao) throws InvalidParameterException, DoesNotExistException, VersionMismatchException { |
| 55 | 674 | if(null == dto) { |
| 56 | 0 | return null; |
| 57 | } | |
| 58 | 674 | Lo lo; |
| 59 | ||
| 60 | 674 | if (isUpdate) { |
| 61 | 22 | lo = dao.fetch(Lo.class, dto.getId()); |
| 62 | 22 | if (lo == null) { |
| 63 | 0 | throw new DoesNotExistException((new StringBuilder()).append("Lo does not exist for id: ").append(dto.getId()).toString()); |
| 64 | } | |
| 65 | 22 | 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 | 652 | lo = new Lo(); |
| 70 | } | |
| 71 | ||
| 72 | 674 | BeanUtils.copyProperties(dto, lo, new String[] { "desc", "loRepository", "loType", "attributes", "metaInfo" }); |
| 73 | ||
| 74 | 674 | lo.setAttributes(toGenericAttributes(LoAttribute.class, dto.getAttributes(), lo, dao)); |
| 75 | 674 | lo.setDescr(toRichText(LoRichText.class, dto.getDesc())); |
| 76 | ||
| 77 | 674 | LoRepository repository = dao.fetch(LoRepository.class, dto.getLoRepositoryKey()); |
| 78 | 674 | if(null == repository) { |
| 79 | 0 | throw new InvalidParameterException((new StringBuilder()).append("LoRepository does not exist for id: ").append(dto.getLoRepositoryKey()).toString()); |
| 80 | } | |
| 81 | 674 | lo.setLoRepository(repository); |
| 82 | ||
| 83 | 674 | LoType type = dao.fetch(LoType.class, dto.getType()); |
| 84 | 674 | if(null == type) { |
| 85 | 0 | throw new InvalidParameterException((new StringBuilder()).append("LoType does not exist for id: ").append(dto.getType()).toString()); |
| 86 | } | |
| 87 | 674 | lo.setLoType(type); |
| 88 | ||
| 89 | 674 | return lo; |
| 90 | } | |
| 91 | ||
| 92 | 1073 |
public static LoInfo toLoInfo(Lo entity) { |
| 93 | 1073 | LoInfo dto = new LoInfo(); |
| 94 | ||
| 95 | 1073 | BeanUtils.copyProperties(entity, dto, |
| 96 | new String[] { "desc", "attributes", "type" }); | |
| 97 | 1073 | dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 98 | 1073 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 99 | 1073 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 100 | 1073 | dto.setType(entity.getLoType().getId()); |
| 101 | 1073 | dto.setLoRepositoryKey(entity.getLoRepository() == null? null: entity.getLoRepository().getId()); |
| 102 | 1073 | return dto; |
| 103 | } | |
| 104 | ||
| 105 | 5 |
public static LoCategory toLoCategory(LoCategoryInfo dto, LoDao dao) throws InvalidParameterException, DoesNotExistException { |
| 106 | 5 | return toLoCategory(new LoCategory(), dto, dao); |
| 107 | } | |
| 108 | ||
| 109 | 5 |
public static LoCategory toLoCategory(LoCategory entity, LoCategoryInfo dto, LoDao dao) throws InvalidParameterException, DoesNotExistException { |
| 110 | 5 | if(entity == null) |
| 111 | 0 | entity = new LoCategory(); |
| 112 | 5 | BeanUtils.copyProperties(dto, entity, |
| 113 | new String[] { "desc", "attributes", "metaInfo", "loRepository", "type", "id"}); | |
| 114 | 5 | entity.setDesc(toRichText(LoRichText.class, dto.getDesc())); |
| 115 | 5 | entity.setAttributes(toGenericAttributes(LoCategoryAttribute.class, dto.getAttributes(), entity, dao)); |
| 116 | 5 | entity.setLoRepository(dao.fetch(LoRepository.class, dto.getLoRepository())); |
| 117 | 5 | entity.setLoCategoryType(dao.fetch(LoCategoryType.class, dto.getType())); |
| 118 | 5 | return entity; |
| 119 | } | |
| 120 | ||
| 121 | 800 |
public static LoCategoryInfo toLoCategoryInfo(LoCategory entity) { |
| 122 | 800 | LoCategoryInfo dto = new LoCategoryInfo(); |
| 123 | ||
| 124 | 800 | BeanUtils.copyProperties(entity, dto, |
| 125 | new String[] { "desc", "attributes", "loRepository", "loCategoryType" }); | |
| 126 | 800 | dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 127 | 800 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 128 | 800 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 129 | 800 | dto.setLoRepository(entity.getLoRepository().getId()); |
| 130 | 800 | dto.setType(entity.getLoCategoryType().getId()); |
| 131 | ||
| 132 | 800 | return dto; |
| 133 | } | |
| 134 | ||
| 135 | 4 |
public static LoRepositoryInfo toLoRepositoryInfo(LoRepository entity) { |
| 136 | 4 | LoRepositoryInfo dto = new LoRepositoryInfo(); |
| 137 | ||
| 138 | 4 | BeanUtils.copyProperties(entity, dto, |
| 139 | new String[] { "desc", "attributes", "rootLo" }); | |
| 140 | 4 | dto.setDesc(toRichTextInfo(entity.getDescr())); |
| 141 | 4 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 142 | 4 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 143 | 4 | dto.setRootLoId(entity.getRootLo() == null? null :entity.getRootLo().getId()); |
| 144 | 4 | return dto; |
| 145 | } | |
| 146 | ||
| 147 | 4 |
public static LoTypeInfo toLoTypeInfo(LoType entity) { |
| 148 | 4 | LoTypeInfo dto = new LoTypeInfo(); |
| 149 | ||
| 150 | 4 | BeanUtils.copyProperties(entity, dto, |
| 151 | new String[] { "attributes" }); | |
| 152 | 4 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 153 | 4 | return dto; |
| 154 | } | |
| 155 | ||
| 156 | ||
| 157 | 394 |
public static List<LoInfo> toLoInfos(List<Lo> los) { |
| 158 | 394 | List<LoInfo> list = new ArrayList<LoInfo>(); |
| 159 | 394 | for (Lo lo : los) { |
| 160 | 314 | list.add(toLoInfo(lo)); |
| 161 | } | |
| 162 | 394 | return list; |
| 163 | } | |
| 164 | ||
| 165 | 449 |
public static List<LoCategoryInfo> toLoCategoryInfos(List<LoCategory> categories) { |
| 166 | 449 | if (null == categories) { |
| 167 | 0 | return new ArrayList<LoCategoryInfo>(0); |
| 168 | } | |
| 169 | 449 | List<LoCategoryInfo> list = new ArrayList<LoCategoryInfo>(categories.size()); |
| 170 | 449 | for (LoCategory loCategory : categories) { |
| 171 | 791 | list.add(toLoCategoryInfo(loCategory)); |
| 172 | } | |
| 173 | 449 | return list; |
| 174 | } | |
| 175 | ||
| 176 | 1 |
public static List<LoRepositoryInfo> toLoRepositoryInfos(List<LoRepository> repositories) { |
| 177 | 1 | List<LoRepositoryInfo> list = new ArrayList<LoRepositoryInfo>(); |
| 178 | 1 | for (LoRepository loRepository : repositories) { |
| 179 | 3 | list.add(toLoRepositoryInfo(loRepository)); |
| 180 | } | |
| 181 | 1 | return list; |
| 182 | } | |
| 183 | ||
| 184 | 1 |
public static List<LoTypeInfo> toLoTypeInfos(List<LoType> find) { |
| 185 | 1 | List<LoTypeInfo> list = new ArrayList<LoTypeInfo>(); |
| 186 | 1 | for (LoType loType : find) { |
| 187 | 2 | list.add(toLoTypeInfo(loType)); |
| 188 | } | |
| 189 | 1 | return list; |
| 190 | } | |
| 191 | ||
| 192 | 1 |
public static List<LoLoRelationTypeInfo> toLoLoRelationTypeInfos(List<LoLoRelationType> find) { |
| 193 | 1 | List<LoLoRelationTypeInfo> list = new ArrayList<LoLoRelationTypeInfo>(); |
| 194 | 1 | for (LoLoRelationType loType : find) { |
| 195 | 2 | list.add(toLoLoRelationTypeInfo(loType)); |
| 196 | } | |
| 197 | 1 | return list; |
| 198 | } | |
| 199 | ||
| 200 | 3 |
public static LoLoRelationTypeInfo toLoLoRelationTypeInfo(LoLoRelationType loLoRelType) { |
| 201 | 3 | LoLoRelationTypeInfo dto = new LoLoRelationTypeInfo(); |
| 202 | 3 | BeanUtils.copyProperties(loLoRelType, dto, |
| 203 | new String[] { "attributes" }); | |
| 204 | 3 | dto.setAttributes(toAttributeMap(loLoRelType.getAttributes())); |
| 205 | 3 | return dto; |
| 206 | } | |
| 207 | ||
| 208 | 554 |
public static LoLoRelation toLoLoRelation(boolean isUpdate, LoLoRelationInfo dto, CrudDao dao) throws DoesNotExistException, VersionMismatchException, InvalidParameterException { |
| 209 | 554 | return toLoLoRelation(isUpdate, null, dto, dao); |
| 210 | } | |
| 211 | ||
| 212 | 554 |
public static LoLoRelation toLoLoRelation(boolean isUpdate, LoLoRelation entity, LoLoRelationInfo dto, CrudDao dao) throws DoesNotExistException, VersionMismatchException, InvalidParameterException { |
| 213 | 554 | if(null == dto) { |
| 214 | 0 | return null; |
| 215 | } | |
| 216 | 554 | LoLoRelation llRelation; |
| 217 | ||
| 218 | 554 | 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 | 554 | llRelation = new LoLoRelation(); |
| 228 | } | |
| 229 | ||
| 230 | 554 | BeanUtils.copyProperties(dto, llRelation, new String[] { "lo", "relatedLo", "attributes", "metaInfo" }); |
| 231 | ||
| 232 | 554 | llRelation.setAttributes(toGenericAttributes(LoLoRelationAttribute.class, dto.getAttributes(), llRelation, dao)); |
| 233 | ||
| 234 | 554 | Lo lo = null; |
| 235 | 554 | Lo relatedLo = null; |
| 236 | 554 | LoLoRelationType relationType = null; |
| 237 | 554 | try { |
| 238 | 554 | lo = dao.fetch(Lo.class, dto.getLoId()); |
| 239 | 554 | relatedLo = dao.fetch(Lo.class, dto.getRelatedLoId()); |
| 240 | 554 | 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 | 554 | llRelation.setLo(lo); |
| 247 | 554 | llRelation.setRelatedLo(relatedLo); |
| 248 | 554 | llRelation.setLoLoRelationType(relationType); |
| 249 | ||
| 250 | 554 | return llRelation; |
| 251 | } | |
| 252 | ||
| 253 | 623 |
public static LoLoRelationInfo toLoLoRelationInfo(LoLoRelation entity) { |
| 254 | 623 | LoLoRelationInfo dto = new LoLoRelationInfo(); |
| 255 | ||
| 256 | 623 | BeanUtils.copyProperties(entity, dto, |
| 257 | new String[] { "lo", "relatedLo", "type", "attributes" }); | |
| 258 | 623 | dto.setLoId(entity.getLo().getId()); |
| 259 | 623 | dto.setRelatedLoId(entity.getRelatedLo().getId()); |
| 260 | 623 | dto.setType(entity.getLoLoRelationType().getId()); |
| 261 | 623 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
| 262 | 623 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
| 263 | 623 | return dto; |
| 264 | } | |
| 265 | ||
| 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 | ||
| 277 | 3 |
public static LoCategoryTypeInfo toLoCategoryTypeInfo( LoCategoryType loCatType) { |
| 278 | 3 | LoCategoryTypeInfo dto = new LoCategoryTypeInfo(); |
| 279 | 3 | BeanUtils.copyProperties(loCatType, dto, new String[] { "attributes" }); |
| 280 | 3 | dto.setAttributes(toAttributeMap(loCatType.getAttributes())); |
| 281 | 3 | dto.setDesc(loCatType.getDescr()); |
| 282 | 3 | return dto; |
| 283 | } | |
| 284 | ||
| 285 | 1 |
public static List<LoCategoryTypeInfo> toLoCategoryTypeInfos(List<LoCategoryType> categoryTypes) { |
| 286 | 1 | ArrayList<LoCategoryTypeInfo> list = new ArrayList<LoCategoryTypeInfo>(); |
| 287 | 1 | for (LoCategoryType catType : categoryTypes) { |
| 288 | 3 | list.add(toLoCategoryTypeInfo(catType)); |
| 289 | } | |
| 290 | 1 | return list; |
| 291 | } | |
| 292 | ||
| 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 | } | |
|
||||||||||||