|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LoDaoImpl | Line # 38 | 69 | 0% | 21 | 9 | 90.2% |
0.90217394
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (48) | |||
| Result | |||
|
0.47826087
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse
|
1 PASS | |
|
0.47826087
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse
|
1 PASS | |
|
0.45652175
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory
|
1 PASS | |
|
0.26086956
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testAddRemoveLoCategoryToFromLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testAddRemoveLoCategoryToFromLo
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions
|
1 PASS | |
|
0.25
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions
|
1 PASS | |
|
0.17391305
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline
|
1 PASS | |
|
0.17391305
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline
|
1 PASS | |
|
0.17391305
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline
|
1 PASS | |
|
0.17391305
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram
|
1 PASS | |
|
0.17391305
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline
|
1 PASS | |
|
0.16304348
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse
|
1 PASS | |
|
0.13043478
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetVariationsByMajorDisciplineId
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetVariationsByMajorDisciplineId
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testUpdateLoCategoryDuplicationCaseInsensitive
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testUpdateLoCategoryDuplicationCaseInsensitive
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetCoreProgram
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetCoreProgram
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplication
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplication
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetMajorDiscipline
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetMajorDiscipline
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testGetProgramRequirement
|
1 PASS | |
|
0.11956522
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplicationCaseInsensitive
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryDuplicationCaseInsensitive
|
1 PASS | |
|
0.10869565
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement
|
1 PASS | |
|
0.06521739
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetRelatedLosByLoId
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetRelatedLosByLoId
|
1 PASS | |
|
0.06521739
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetAllowedLoLoRelationTypesForLoType
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetAllowedLoLoRelationTypesForLoType
|
1 PASS | |
|
0.06521739
|
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.testGetRelatedLosByLoId
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.testGetRelatedLosByLoId
|
1 PASS | |
|
0.06521739
|
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.testGetLosByRelatedLoId
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.testGetLosByRelatedLoId
|
1 PASS | |
|
0.054347824
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoByIdList
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoByIdList
|
1 PASS | |
|
0.054347824
|
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.getLoByIdList
org.kuali.student.lum.lo.dao.impl.TestLoDaoImpl.getLoByIdList
|
1 PASS | |
|
0.054347824
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategories
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategories
|
1 PASS | |
|
0.054347824
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoriesForLo
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testGetLoCategoriesForLo
|
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.dao.impl; | |
| 17 | ||
| 18 | import java.util.List; | |
| 19 | ||
| 20 | import javax.persistence.EntityManager; | |
| 21 | import javax.persistence.PersistenceContext; | |
| 22 | import javax.persistence.Query; | |
| 23 | ||
| 24 | import org.kuali.student.core.dao.impl.AbstractSearchableCrudDaoImpl; | |
| 25 | import org.kuali.student.core.exceptions.DependentObjectsExistException; | |
| 26 | import org.kuali.student.core.exceptions.DoesNotExistException; | |
| 27 | import org.kuali.student.core.exceptions.UnsupportedActionException; | |
| 28 | import org.kuali.student.lum.lo.dao.LoDao; | |
| 29 | import org.kuali.student.lum.lo.entity.Lo; | |
| 30 | import org.kuali.student.lum.lo.entity.LoCategory; | |
| 31 | import org.kuali.student.lum.lo.entity.LoLoCategoryJoin; | |
| 32 | import org.kuali.student.lum.lo.entity.LoLoRelation; | |
| 33 | ||
| 34 | /** | |
| 35 | * @author Kuali Student Team | |
| 36 | * | |
| 37 | */ | |
| 38 | public class LoDaoImpl extends AbstractSearchableCrudDaoImpl implements LoDao { | |
| 39 | 7 |
@PersistenceContext(unitName = "Lo") |
| 40 | @Override | |
| 41 | public void setEm(EntityManager em) { | |
| 42 | 7 | super.setEm(em); |
| 43 | } | |
| 44 | ||
| 45 | /* (non-Javadoc) | |
| 46 | * @see org.kuali.student.lum.lo.dao.LoDao#addLoCategoryToLo(java.lang.String, java.lang.String) | |
| 47 | */ | |
| 48 | 1265 |
@Override |
| 49 | public boolean addLoCategoryToLo(String loCategoryId, String loId) throws UnsupportedActionException, DoesNotExistException { | |
| 50 | 1265 | Lo lo = fetch(Lo.class, loId); |
| 51 | 1265 | LoCategory loCategory = fetch(LoCategory.class, loCategoryId); |
| 52 | 1265 | String loRepoId = lo.getLoRepository().getId(); |
| 53 | 1265 | String loCategoryRepoId = loCategory.getLoRepository().getId(); |
| 54 | ||
| 55 | 1265 | if ( ! loRepoId.equals(loCategoryRepoId) ) { |
| 56 | 0 | throw new UnsupportedActionException("The learning objective category is not associated with the learning objective's repository"); |
| 57 | } | |
| 58 | 1265 | LoLoCategoryJoin join = new LoLoCategoryJoin(); |
| 59 | 1265 | join.setLo(lo); |
| 60 | 1265 | join.setLoCategory(loCategory); |
| 61 | 1265 | create(join); |
| 62 | 1265 | return true; |
| 63 | } | |
| 64 | ||
| 65 | /* (non-Javadoc) | |
| 66 | * @see org.kuali.student.lum.lo.dao.LoDao#removeLoCategoryFromLo(java.lang.String, java.lang.String) | |
| 67 | */ | |
| 68 | 46 |
@Override |
| 69 | public boolean removeLoCategoryFromLo(String loCategoryId, String loId) throws DoesNotExistException { | |
| 70 | 46 | Query query = em.createNamedQuery("Lo.getLoCategoryJoin"); |
| 71 | 46 | query.setParameter("loCategoryId", loCategoryId); |
| 72 | 46 | query.setParameter("loId", loId); |
| 73 | 46 | LoLoCategoryJoin join = (LoLoCategoryJoin) query.getSingleResult(); |
| 74 | 46 | delete(join); |
| 75 | 46 | return true; |
| 76 | } | |
| 77 | ||
| 78 | /* (non-Javadoc) | |
| 79 | * @see org.kuali.student.lum.lo.dao.LoDao#getLoByIdList(java.util.List) | |
| 80 | */ | |
| 81 | 2 |
@Override |
| 82 | public List<Lo> getLoByIdList(List<String> loIds) { | |
| 83 | 2 | Query query = em.createNamedQuery("Lo.findLosByIdList"); |
| 84 | 2 | query.setParameter("idList", loIds); |
| 85 | 2 | @SuppressWarnings("unchecked") |
| 86 | List<Lo> resultList = query.getResultList(); | |
| 87 | 2 | return resultList; |
| 88 | } | |
| 89 | ||
| 90 | /* (non-Javadoc) | |
| 91 | * @see org.kuali.student.lum.lo.dao.LoDao#deleteLo(java.lang.String) | |
| 92 | */ | |
| 93 | 25 |
@Override |
| 94 | public boolean deleteLo(String loId) throws DoesNotExistException, DependentObjectsExistException { | |
| 95 | //Lo child = fetch(Lo.class, loId); | |
| 96 | 25 | if ( ! getIncludedLos(loId).isEmpty() ) { |
| 97 | 1 | throw new DependentObjectsExistException("Lo(" + |
| 98 | loId+ | |
| 99 | ") cannot be deleted without orphaning child Lo(s)."); | |
| 100 | } | |
| 101 | // TODO - will need more general logic here when we have relationships other than "includes" | |
| 102 | // hopefully dictionary-driven | |
| 103 | // List<Lo> parents = getIncludingLos(loId); | |
| 104 | // for (Lo parent : parents) { | |
| 105 | // parent.getRelatedLos().remove(child); | |
| 106 | // update(parent); | |
| 107 | // } | |
| 108 | 24 | delete(Lo.class, loId); |
| 109 | 24 | return true; |
| 110 | } | |
| 111 | ||
| 112 | /* (non-Javadoc) | |
| 113 | * @see org.kuali.student.lum.lo.dao.LoDao#getLoChildren(java.lang.String) | |
| 114 | */ | |
| 115 | 25 |
private List<Lo> getIncludedLos(String loId) throws DoesNotExistException { |
| 116 | 25 | return getRelatedLosByLoId(loId, "kuali.lo.relation.type.includes"); // TODO - gotta be a constant somewhere, or perhaps pull from dictionary |
| 117 | } | |
| 118 | ||
| 119 | /* (non-Javadoc) | |
| 120 | * @see org.kuali.student.lum.lo.dao.LoDao#getLoParents(java.lang.String) | |
| 121 | */ | |
| 122 | 0 |
private List<Lo> getIncludingLos(String loId) throws DoesNotExistException { |
| 123 | 0 | return getLosByRelatedLoId(loId, "kuali.lo.relation.type.includes"); // TODO - gotta be a constant somewhere, or perhaps pull from dictionary |
| 124 | } | |
| 125 | ||
| 126 | /* (non-Javadoc) | |
| 127 | * @see org.kuali.student.lum.lo.dao.LoDao#getLosByLoCategory(java.lang.String) | |
| 128 | */ | |
| 129 | 12 |
@Override |
| 130 | public List<Lo> getLosByLoCategory(String loCategoryId) { | |
| 131 | 12 | Query query = em.createNamedQuery("Lo.getLosByLoCategory"); |
| 132 | 12 | query.setParameter("loCategoryId", loCategoryId); |
| 133 | 12 | @SuppressWarnings("unchecked") |
| 134 | List<Lo> resultList = query.getResultList(); | |
| 135 | 12 | return resultList; |
| 136 | } | |
| 137 | ||
| 138 | /* (non-Javadoc) | |
| 139 | * @see org.kuali.student.lum.lo.dao.LoDao#getLoCategories(java.lang.String) | |
| 140 | */ | |
| 141 | 3 |
@Override |
| 142 | public List<LoCategory> getLoCategories(String loRepositoryKey) { | |
| 143 | 3 | Query query = em.createNamedQuery("Lo.getLoCategories"); |
| 144 | 3 | query.setParameter("repositoryId", loRepositoryKey); |
| 145 | 3 | @SuppressWarnings("unchecked") |
| 146 | List<LoCategory> resultList = query.getResultList(); | |
| 147 | 3 | return resultList; |
| 148 | } | |
| 149 | ||
| 150 | /* (non-Javadoc) | |
| 151 | * @see org.kuali.student.lum.lo.dao.LoDao#deleteLoCategory(java.lang.String) | |
| 152 | */ | |
| 153 | 6 |
@Override |
| 154 | public boolean deleteLoCategory(String loCategoryId) throws DoesNotExistException, DependentObjectsExistException { | |
| 155 | 6 | List<Lo> los = getLosByLoCategory(loCategoryId); |
| 156 | 6 | if (null != los && !los.isEmpty()) { |
| 157 | 1 | throw new DependentObjectsExistException("LoCategory(" + loCategoryId + ") still has " + los.size() + " Learning Objective(s) associated with it."); |
| 158 | } | |
| 159 | 5 | delete(LoCategory.class, loCategoryId); |
| 160 | 5 | return true; |
| 161 | } | |
| 162 | ||
| 163 | 400 |
@Override |
| 164 | public List<Lo> getRelatedLosByLoId(String loId, String loLoRelationTypeId) | |
| 165 | throws DoesNotExistException { | |
| 166 | 400 | Query query = em.createNamedQuery("Lo.getRelatedLosByLoId"); |
| 167 | 400 | query.setParameter("loId", loId); |
| 168 | 400 | query.setParameter("loLoRelationTypeId", loLoRelationTypeId); |
| 169 | 400 | @SuppressWarnings("unchecked") |
| 170 | List<Lo> resultList = query.getResultList(); | |
| 171 | 400 | return resultList; |
| 172 | } | |
| 173 | ||
| 174 | 1 |
@Override |
| 175 | public List<Lo> getLosByRelatedLoId(String relatedLoId, | |
| 176 | String loLoRelationTypeId) throws DoesNotExistException { | |
| 177 | 1 | Query query = em.createNamedQuery("Lo.getLosByRelatedLoId"); |
| 178 | 1 | query.setParameter("relatedLoId", relatedLoId); |
| 179 | 1 | query.setParameter("loLoRelationTypeId", loLoRelationTypeId); |
| 180 | 1 | @SuppressWarnings("unchecked") |
| 181 | List<Lo> resultList = query.getResultList(); | |
| 182 | 1 | return resultList; |
| 183 | } | |
| 184 | ||
| 185 | 18 |
@Override |
| 186 | public void deleteLoLoRelation(String loLoRelationId) throws DoesNotExistException { | |
| 187 | ||
| 188 | // // make sure we don't orphan an LO (and potentially its children) | |
| 189 | // LoLoRelation llRelation = fetch(LoLoRelation.class, loLoRelationId); | |
| 190 | // if (getIncludingLos(llRelation.getRelatedLo().getId()).size() == 1) { | |
| 191 | // // TODO - "&& [not a top-level LO for another CLU]" when LO's are reused | |
| 192 | // throw new DependentObjectsExistException("LoLoRelation(" + | |
| 193 | // loLoRelationId + | |
| 194 | // ") cannot be deleted without orphaning Lo(s)."); | |
| 195 | // } | |
| 196 | 18 | delete(LoLoRelation.class, loLoRelationId); |
| 197 | } | |
| 198 | ||
| 199 | 432 |
@Override |
| 200 | public List<LoCategory> getLoCategoriesForLo(String loId) { | |
| 201 | 432 | Query query = em.createNamedQuery("Lo.getLoCategoriesForLo"); |
| 202 | 432 | query.setParameter("loId", loId); |
| 203 | // @SuppressWarnings("unchecked") | |
| 204 | 432 | List<LoCategory> resultList = query.getResultList(); |
| 205 | 432 | return resultList; |
| 206 | } | |
| 207 | ||
| 208 | 2 |
@Override |
| 209 | public List<String> getAllowedLoLoRelationTypesForLoType(String loTypeKey, String relatedLoTypeKey) { | |
| 210 | 2 | Query query = em.createNamedQuery("Lo.getAllowedLoLoRelationTypes"); |
| 211 | 2 | query.setParameter("loTypeKey", loTypeKey); |
| 212 | 2 | query.setParameter("relatedLoTypeKey", relatedLoTypeKey); |
| 213 | 2 | @SuppressWarnings("unchecked") |
| 214 | List<String> resultList = query.getResultList(); | |
| 215 | 2 | return resultList; |
| 216 | } | |
| 217 | ||
| 218 | 0 |
@Override |
| 219 | public List<Lo> getLosByRepository(String loRepositoryId) { | |
| 220 | 0 | Query query = em.createNamedQuery("Lo.getLosByRepository"); |
| 221 | 0 | query.setParameter("loRepositoryId", loRepositoryId); |
| 222 | 0 | @SuppressWarnings("unchecked") |
| 223 | List<Lo> resultList = query.getResultList(); | |
| 224 | 0 | return resultList; |
| 225 | } | |
| 226 | ||
| 227 | 52 |
@Override |
| 228 | public List<LoLoRelation> getLoLoRelationsByLoId(String loId) { | |
| 229 | 52 | Query query = em.createNamedQuery("Lo.getLoLoRelationsByLoId"); |
| 230 | 52 | query.setParameter("loId", loId); |
| 231 | 52 | @SuppressWarnings("unchecked") |
| 232 | List<LoLoRelation> resultList = query.getResultList(); | |
| 233 | 52 | return resultList; |
| 234 | } | |
| 235 | ||
| 236 | // These are left over from when Lo's were in parent-child hierarchies, and there | |
| 237 | // was a concept of 'equivalent' LO's | |
| 238 | // TODO - remove when logic has been completely pilfered as appropriate | |
| 239 | /* (non-Javadoc) | |
| 240 | * @see org.kuali.student.lum.lo.dao.LoDao#getAllDescendantLoIds(java.lang.String) | |
| 241 | @Override | |
| 242 | public List<String> getAllDescendantLoIds(String loId) { | |
| 243 | Query query = em.createNamedQuery("Lo.getLoChildrenIds"); | |
| 244 | query.setParameter("parentId", loId); | |
| 245 | return getAllLevels(query, "parentId", loId); | |
| 246 | } | |
| 247 | ||
| 248 | /* (non-Javadoc) | |
| 249 | * @see org.kuali.student.lum.lo.dao.LoDao#getAncestors(java.lang.String) | |
| 250 | * | |
| 251 | * Get the id's of _all_ ancestors of the specified Lo | |
| 252 | @Override | |
| 253 | public List<String> getAncestors(String loId) { | |
| 254 | Query query = em.createNamedQuery("Lo.getAncestors"); | |
| 255 | query.setParameter("childId", loId); | |
| 256 | return getAllLevels(query, "childId", loId); | |
| 257 | } | |
| 258 | ||
| 259 | /* Recurse a query | |
| 260 | private List<String> getAllLevels(Query query, String paramName, String paramValue) { | |
| 261 | // Eliminate dup's by using a set | |
| 262 | Set<String> valSet = new TreeSet<String>(); | |
| 263 | query.setParameter(paramName, paramValue); | |
| 264 | @SuppressWarnings("unchecked") | |
| 265 | List<String> nextLevelList = query.getResultList(); | |
| 266 | valSet.addAll(nextLevelList); | |
| 267 | for (String resultStr : nextLevelList) { | |
| 268 | valSet.addAll(getAllLevels(query, paramName, resultStr)); | |
| 269 | } | |
| 270 | return new ArrayList<String>(valSet); | |
| 271 | } | |
| 272 | ||
| 273 | /* (non-Javadoc) | |
| 274 | * @see org.kuali.student.lum.lo.dao.LoDao#getLoEquivalents(java.lang.String) | |
| 275 | * Retrieves all learning objectives that have an equivalence reference to the specified LO. | |
| 276 | * Note: Equivalency of learning objectives is uni-directional, and we're navigating to those | |
| 277 | * LO's pointing to loId's | |
| 278 | @Override | |
| 279 | public List<Lo> getLoEquivalents(String loId) { | |
| 280 | Query query = em.createNamedQuery("Lo.getLoEquivalents"); | |
| 281 | query.setParameter("loId", loId); | |
| 282 | @SuppressWarnings("unchecked") | |
| 283 | List<Lo> los = query.getResultList(); | |
| 284 | return los; | |
| 285 | } | |
| 286 | ||
| 287 | /* (non-Javadoc) | |
| 288 | * @see org.kuali.student.lum.lo.dao.LoDao#getEquivalentLos(java.lang.String) | |
| 289 | * /** | |
| 290 | * Retrieves all equivalent learning objectives of a learning objective. | |
| 291 | * Note: Equivalency of learning objectives is uni-directional, and we're navigating to those | |
| 292 | * LO's that loId's LO points to as equivalent | |
| 293 | @Override | |
| 294 | public List<Lo> getEquivalentLos(String loId) { | |
| 295 | Query query = em.createNamedQuery("Lo.getEquivalentLos"); | |
| 296 | query.setParameter("loId", loId); | |
| 297 | @SuppressWarnings("unchecked") | |
| 298 | List<Lo> los = query.getResultList(); | |
| 299 | return los; | |
| 300 | } | |
| 301 | ||
| 302 | /* (non-Javadoc) | |
| 303 | * @see org.kuali.student.lum.lo.dao.LoDao#isEquivalent(java.lang.String, java.lang.String) | |
| 304 | @Override | |
| 305 | public boolean isEquivalent(String equivLoId, String loId) { | |
| 306 | Query query = em.createNamedQuery("Lo.getEquivalentLosIds"); | |
| 307 | query.setParameter("loId", loId); | |
| 308 | @SuppressWarnings("unchecked") | |
| 309 | List<String> losIds = query.getResultList(); | |
| 310 | return losIds.contains(equivLoId); | |
| 311 | } | |
| 312 | ||
| 313 | /* (non-Javadoc) | |
| 314 | * @see org.kuali.student.lum.lo.dao.LoDao#removeChildLoFromLo(java.lang.String, java.lang.String) | |
| 315 | @Override | |
| 316 | public boolean removeChildLoFromLo(String loId, String parentLoId) throws DependentObjectsExistException, DoesNotExistException { | |
| 317 | Lo parentLo = null; | |
| 318 | Lo lo = null; | |
| 319 | if (getLoParents(loId).size() <= 1) { | |
| 320 | throw new DependentObjectsExistException(); | |
| 321 | } | |
| 322 | try { | |
| 323 | parentLo = fetch(Lo.class, parentLoId); | |
| 324 | lo = fetch(Lo.class, loId); | |
| 325 | } catch (DoesNotExistException e) { | |
| 326 | return false; | |
| 327 | } | |
| 328 | List<Lo> children = parentLo.getChildLos(); | |
| 329 | int index = children.indexOf(lo); | |
| 330 | if (-1 == index) { | |
| 331 | throw new DoesNotExistException("Lo(" + loId + ") is not a child of Lo(" + parentLoId + ")."); | |
| 332 | } | |
| 333 | children.remove(index); | |
| 334 | // TODO - null out hierarchy | |
| 335 | return true; | |
| 336 | } | |
| 337 | ||
| 338 | /* (non-Javadoc) | |
| 339 | * @see org.kuali.student.lum.lo.dao.LoDao#removeEquivalentLoFromLo(java.lang.String, java.lang.String) | |
| 340 | @Override | |
| 341 | public boolean removeEquivalentLoFromLo(String loId, String equivalentLoId) { | |
| 342 | Lo lo = null; | |
| 343 | Lo equivLo = null; | |
| 344 | try { | |
| 345 | lo = fetch(Lo.class, loId); | |
| 346 | equivLo = fetch(Lo.class, equivalentLoId); | |
| 347 | } catch (DoesNotExistException e) { | |
| 348 | return false; | |
| 349 | } | |
| 350 | List<Lo> equivs = lo.getEquivalentLos(); | |
| 351 | int index = equivs.indexOf(equivLo); | |
| 352 | equivs.remove(index); | |
| 353 | return true; | |
| 354 | } | |
| 355 | ||
| 356 | /* (non-Javadoc) | |
| 357 | * @see org.kuali.student.lum.lo.dao.LoDao#isDescendant(java.lang.String, java.lang.String) | |
| 358 | @Override | |
| 359 | public boolean isDescendant(String loId, String descendantLoId) { | |
| 360 | List<Lo> los = getLoChildren(loId); | |
| 361 | Lo child = null; | |
| 362 | try { | |
| 363 | child = fetch(Lo.class, descendantLoId); | |
| 364 | } catch (DoesNotExistException e) { | |
| 365 | return false; | |
| 366 | } | |
| 367 | return los.contains(child); | |
| 368 | } | |
| 369 | */ | |
| 370 | } | |
|
||||||||||||