Coverage Report - org.kuali.student.r2.core.class1.organization.service.impl.OrganizationServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
OrganizationServiceImpl
0%
0/392
0%
0/82
2.027
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
 5  
  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 6  
  * implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 
 9  
 package org.kuali.student.r2.core.class1.organization.service.impl;
 10  
 
 11  
 import java.util.ArrayList;
 12  
 import java.util.HashSet;
 13  
 import java.util.List;
 14  
 import java.util.Set;
 15  
 
 16  
 import javax.jws.WebService;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.core.api.criteria.GenericQueryResults;
 20  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 21  
 import org.kuali.student.common.dictionary.old.dto.ObjectStructure;
 22  
 import org.kuali.student.common.dictionary.service.old.DictionaryService;
 23  
 import org.kuali.student.common.validator.old.Validator;
 24  
 import org.kuali.student.core.organization.dao.OrganizationDao;
 25  
 import org.kuali.student.core.organization.entity.Org;
 26  
 import org.kuali.student.core.organization.entity.OrgHierarchy;
 27  
 import org.kuali.student.core.organization.entity.OrgOrgRelation;
 28  
 import org.kuali.student.core.organization.entity.OrgOrgRelationType;
 29  
 import org.kuali.student.core.organization.entity.OrgPersonRelation;
 30  
 import org.kuali.student.core.organization.entity.OrgPersonRelationType;
 31  
 import org.kuali.student.core.organization.entity.OrgPositionRestriction;
 32  
 import org.kuali.student.core.organization.entity.OrgType;
 33  
 import org.kuali.student.r2.common.criteria.CriteriaLookupService;
 34  
 import org.kuali.student.r2.common.dto.ContextInfo;
 35  
 import org.kuali.student.r2.common.dto.StatusInfo;
 36  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 37  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 38  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 39  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 40  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 41  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 42  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 43  
 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
 44  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 45  
 import org.kuali.student.r2.core.class1.organization.dao.ExtendedOrgDao;
 46  
 import org.kuali.student.r2.core.organization.dto.OrgHierarchyInfo;
 47  
 import org.kuali.student.r2.core.organization.dto.OrgInfo;
 48  
 import org.kuali.student.r2.core.organization.dto.OrgOrgRelationInfo;
 49  
 import org.kuali.student.r2.core.organization.dto.OrgPersonRelationInfo;
 50  
 import org.kuali.student.r2.core.organization.dto.OrgPositionRestrictionInfo;
 51  
 import org.kuali.student.r2.core.organization.dto.OrgTreeInfo;
 52  
 import org.kuali.student.r2.core.organization.service.OrganizationService;
 53  
 import org.kuali.student.r2.core.type.dto.TypeInfo;
 54  
 import org.springframework.transaction.annotation.Transactional;
 55  
 
 56  
 @WebService(endpointInterface = "org.kuali.student.core.organization.service.OrganizationService", serviceName = "OrganizationService", portName = "OrganizationService", targetNamespace = "http://student.kuali.org/wsdl/organization")
 57  
 @Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
 58  0
 public class OrganizationServiceImpl implements OrganizationService {
 59  
 
 60  0
     final Logger logger = Logger.getLogger(OrganizationServiceImpl.class);
 61  
 
 62  
     private OrganizationDao organizationDao;
 63  
     private ExtendedOrgDao extendedOrgDao;
 64  
     private DictionaryService dictionaryServiceDelegate;
 65  
     private Validator validator;
 66  
     private CriteriaLookupService criteriaLookupService;
 67  
 
 68  
     /**
 69  
      * Check for missing parameter and throw localized exception if missing
 70  
      * 
 71  
      * @param param
 72  
      * @param parameter
 73  
      *            name
 74  
      * @throws MissingParameterException
 75  
      */
 76  
     private void checkForMissingParameter(Object param, String paramName) throws MissingParameterException {
 77  0
         if (param == null) {
 78  0
             throw new MissingParameterException(paramName + " can not be null");
 79  
         }
 80  0
     }
 81  
 
 82  
     public DictionaryService getDictionaryServiceDelegate() {
 83  0
         return dictionaryServiceDelegate;
 84  
     }
 85  
 
 86  
     public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {
 87  0
         this.dictionaryServiceDelegate = dictionaryServiceDelegate;
 88  0
     }
 89  
 
 90  
     public Validator getValidator() {
 91  0
         return validator;
 92  
     }
 93  
 
 94  
     public void setValidator(Validator validator) {
 95  0
         this.validator = validator;
 96  0
     }
 97  
 
 98  
     public OrganizationDao getOrganizationDao() {
 99  0
         return organizationDao;
 100  
     }
 101  
 
 102  
     public void setOrganizationDao(OrganizationDao organizationDao) {
 103  0
         this.organizationDao = organizationDao;
 104  0
     }
 105  
 
 106  
     public ExtendedOrgDao getExtendedOrgDao() {
 107  0
         return extendedOrgDao;
 108  
     }
 109  
 
 110  
     public void setExtendedOrgDao(ExtendedOrgDao extendedOrgDao) {
 111  0
         this.extendedOrgDao = extendedOrgDao;
 112  0
     }
 113  
 
 114  
     public void setCriteriaLookupService(CriteriaLookupService criteriaLookupService) {
 115  0
         this.criteriaLookupService = criteriaLookupService;
 116  0
     }
 117  
 
 118  
     public CriteriaLookupService getCriteriaLookupService() {
 119  0
         return criteriaLookupService;
 120  
     }
 121  
 
 122  
     @Override
 123  
     public OrgHierarchyInfo getOrgHierarchy(String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 124  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 125  
 
 126  
         try {
 127  0
             return OrganizationAssembler.toOrgHierarchyInfo(organizationDao.fetch(OrgHierarchy.class, orgHierarchyId));
 128  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 129  0
             throw new DoesNotExistException();
 130  
         }
 131  
     }
 132  
 
 133  
     @Override
 134  
     public List<OrgHierarchyInfo> getOrgHierarchiesByIds(List<String> orgHierarchyIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 135  0
         checkForMissingParameter(orgHierarchyIds, "orgHierarchyIds");
 136  
         
 137  0
         List<OrgHierarchy> orgHierarchies = extendedOrgDao.getOrgHierarchiesByIds(orgHierarchyIds);
 138  0
         return OrganizationAssembler.toOrgHierarchyInfos(orgHierarchies);
 139  
     }
 140  
 
 141  
     @Override
 142  
     public List<String> getOrgHierarchyIdsByType(String orgHierarchyTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 143  0
         checkForMissingParameter(orgHierarchyTypeKey, "orgHierarchyTypeKey");
 144  
         
 145  0
         List<String> orgHierarchyIds = new ArrayList<String>();
 146  0
         List<OrgHierarchy> orgHierarchies = extendedOrgDao.getOrgHierarchiesByType(orgHierarchyTypeKey);
 147  
         
 148  0
         if (orgHierarchies != null){
 149  0
             for (OrgHierarchy orgHierarchy : orgHierarchies){
 150  0
                 orgHierarchyIds.add(orgHierarchy.getId());
 151  
             }
 152  
         }
 153  
                 
 154  0
         return orgHierarchyIds;
 155  
     }
 156  
 
 157  
     @Override
 158  
     public List<OrgHierarchyInfo> getOrgHierarchies(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 159  0
         return OrganizationAssembler.toOrgHierarchyInfos(organizationDao.find(OrgHierarchy.class));
 160  
     }
 161  
 
 162  
     @Override
 163  
     public List<TypeInfo> getOrgTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 164  0
         return OrganizationAssembler.toOrgTypeInfos(organizationDao.find(OrgType.class));
 165  
     }
 166  
 
 167  
     @Override
 168  
     public OrgInfo getOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 169  0
         checkForMissingParameter(orgId, "orgId");
 170  
 
 171  
         try {
 172  0
             return OrganizationAssembler.toOrgInfo(organizationDao.fetch(Org.class, orgId));
 173  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 174  0
             throw new DoesNotExistException();
 175  
         }
 176  
     }
 177  
 
 178  
     @Override
 179  
     public List<OrgInfo> getOrgsByIds(List<String> orgIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 180  0
         checkForMissingParameter(orgIds, "orgIds");
 181  
 
 182  0
         List<Org> orgs = this.organizationDao.getOrganizationsByIdList(orgIds);
 183  0
         return OrganizationAssembler.toOrgInfos(orgs);
 184  
     }
 185  
 
 186  
     @Override
 187  
     public List<String> getOrgIdsByType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 188  0
         checkForMissingParameter(orgTypeKey, "orgTypeKey");
 189  
         
 190  0
         List<String> orgIds = new ArrayList<String>();
 191  0
         List<Org> orgs = extendedOrgDao.getOrgsByType(orgTypeKey);
 192  
         
 193  0
         if (orgs != null){
 194  0
             for (Org org : orgs){
 195  0
                 orgIds.add(org.getId());
 196  
             }
 197  
         }
 198  
         
 199  0
         return orgIds;
 200  
     }
 201  
 
 202  
     @Override
 203  
     public List<String> searchForOrgIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 204  0
         List<String> orgIds = new ArrayList<String>();
 205  0
         List<OrgInfo> orgs = this.searchForOrgs(criteria, contextInfo);
 206  
 
 207  0
         if (orgs != null) {
 208  0
             for (OrgInfo org : orgs) {
 209  0
                 orgIds.add(org.getId());
 210  
             }
 211  
         }
 212  
 
 213  0
         return orgIds;
 214  
     }
 215  
 
 216  
     @Override
 217  
     public List<OrgInfo> searchForOrgs(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 218  0
         List<OrgInfo> orgInfos = new ArrayList<OrgInfo>();
 219  0
         GenericQueryResults<Org> results = criteriaLookupService.lookup(Org.class, criteria);
 220  
 
 221  0
         if (null != results && results.getResults().size() > 0) {
 222  0
             for (Org org : results.getResults()) {
 223  0
                 orgInfos.add(OrganizationAssembler.toOrgInfo(org));
 224  
             }
 225  
         }
 226  
 
 227  0
         return orgInfos;
 228  
     }
 229  
 
 230  
     @Override
 231  
     public List<ValidationResultInfo> validateOrg(String validationTypeKey, String orgTypeKey, OrgInfo orgInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 232  0
         checkForMissingParameter(validationTypeKey, "validationTypeKey");
 233  0
         checkForMissingParameter(orgInfo, "orgInfo");
 234  
 
 235  
         // FIXME redo validation here and for all calls to create/update
 236  
         // return validator.validateTypeStateObject(orgInfo, getObjectStructure("orgInfo"));
 237  
 
 238  0
         return new ArrayList<ValidationResultInfo>(0);
 239  
     }
 240  
 
 241  
     @Override
 242  
     public OrgInfo createOrg(String orgTypeKey, OrgInfo orgInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 243  
         // Check Missing params
 244  0
         checkForMissingParameter(orgTypeKey, "orgTypeKey");
 245  0
         checkForMissingParameter(orgInfo, "orgInfo");
 246  
 
 247  
         // Set all the values on orgInfo
 248  0
         orgInfo.setTypeKey(orgTypeKey);
 249  
 
 250  
         try {
 251  0
             List<ValidationResultInfo> validations = validateOrg("", "", orgInfo, contextInfo);
 252  0
             for (ValidationResultInfo validationResult : validations) {
 253  0
                 if (validationResult.isError())
 254  0
                     throw new DataValidationErrorException(validationResult.toString());
 255  
             }
 256  0
         } catch (DoesNotExistException e1) {
 257  0
             logger.error("Exception occured: ", e1);
 258  0
         }
 259  
 
 260  0
         Org org = null;
 261  
 
 262  
         // Create a new persistence entity from the orgInfo
 263  
         try {
 264  0
             org = OrganizationAssembler.toOrg(false, orgInfo, organizationDao);
 265  0
         } catch (DoesNotExistException e) {
 266  
             // // OrgAssembler should not be throwing this exception for create!
 267  0
             logger.info(e.getMessage(), e);
 268  0
             throw new OperationFailedException(e.getMessage(), e);
 269  0
         } catch (VersionMismatchException e) {
 270  
             // // OrgAssembler should not be throwing this exception for create!
 271  0
             logger.info(e.getMessage(), e);
 272  0
             throw new OperationFailedException(e.getMessage(), e);
 273  0
         }
 274  
 
 275  
         // Persist the org
 276  0
         organizationDao.create(org);
 277  
 
 278  
         // Copy back to an orgInfo and return
 279  0
         OrgInfo createdOrgInfo = OrganizationAssembler.toOrgInfo(org);
 280  0
         return createdOrgInfo;
 281  
     }
 282  
 
 283  
     @Override
 284  
     public OrgInfo updateOrg(String orgId, OrgInfo orgInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 285  
         // Check Missing params
 286  0
         checkForMissingParameter(orgId, "orgId");
 287  0
         checkForMissingParameter(orgInfo, "orgInfo");
 288  
 
 289  
         // Set all the values on orgInfo
 290  0
         orgInfo.setId(orgId);
 291  
 
 292  0
         Org org = null;
 293  
 
 294  
         // Update persistence entity from the orgInfo
 295  0
         org = OrganizationAssembler.toOrg(true, orgInfo, organizationDao);
 296  
 
 297  
         // Update the org
 298  0
         Org updatedOrg = organizationDao.update(org);
 299  
 
 300  
         // Copy back to an orgInfo and return
 301  0
         OrgInfo updatedOrgInfo = OrganizationAssembler.toOrgInfo(updatedOrg);
 302  0
         return updatedOrgInfo;
 303  
     }
 304  
 
 305  
     @Override
 306  
     public StatusInfo deleteOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 307  0
         checkForMissingParameter(orgId, "orgId");
 308  
 
 309  0
         Org org = null;
 310  
         try {
 311  0
             org = organizationDao.fetch(Org.class, orgId);
 312  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 313  0
             throw new DoesNotExistException(e.getMessage());
 314  0
         }
 315  
 
 316  0
         if (org == null) {
 317  0
             throw new DoesNotExistException("Org does not exist for id: " + orgId);
 318  
         }
 319  
 
 320  0
         organizationDao.delete(org);
 321  
 
 322  0
         StatusInfo statusInfo = new StatusInfo();
 323  0
         statusInfo.setSuccess(true);
 324  0
         return statusInfo;
 325  
     }
 326  
 
 327  
     @Override
 328  
     public List<TypeInfo> getOrgOrgRelationTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 329  0
         List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.find(OrgOrgRelationType.class);
 330  0
         return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes);
 331  
     }
 332  
 
 333  
     @Override
 334  
     public List<TypeInfo> getOrgOrgRelationTypesForOrgType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 335  0
         checkForMissingParameter(orgTypeKey, "orgTypeKey");
 336  
 
 337  0
         List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.getOrgOrgRelationTypesForOrgType(orgTypeKey);
 338  0
         return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes);
 339  
     }
 340  
 
 341  
     @Override
 342  
     public List<TypeInfo> getOrgOrgRelationTypesForOrgHierarchy(String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 343  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 344  
 
 345  0
         List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.getOrgOrgRelationTypesForOrgHierarchy(orgHierarchyId);
 346  0
         return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes);
 347  
     }
 348  
 
 349  
     @Override
 350  
     public Boolean hasOrgOrgRelation(String orgId, String comparisonOrgId, String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 351  
         // Check Missing params
 352  0
         checkForMissingParameter(orgId, "orgId");
 353  0
         checkForMissingParameter(comparisonOrgId, "comparisonOrgId");
 354  0
         checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey");
 355  
 
 356  0
         boolean result = organizationDao.hasOrgOrgRelation(orgId, comparisonOrgId, orgOrgRelationTypeKey);
 357  0
         return Boolean.valueOf(result);
 358  
     }
 359  
 
 360  
     @Override
 361  
     public OrgOrgRelationInfo getOrgOrgRelation(String orgOrgRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 362  0
         checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId");
 363  
 
 364  0
         OrgOrgRelationInfo orgOrgRelationInfo = null;
 365  
         try {
 366  0
             orgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(organizationDao.fetch(OrgOrgRelation.class, orgOrgRelationId));
 367  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 368  0
             throw new DoesNotExistException(e.getMessage());
 369  0
         }
 370  0
         return orgOrgRelationInfo;
 371  
     }
 372  
 
 373  
     @Override
 374  
     public List<OrgOrgRelationInfo> getOrgOrgRelationsByIds(List<String> orgOrgRelationIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 375  0
         checkForMissingParameter(orgOrgRelationIds, "orgOrgRelationIds");
 376  
 
 377  0
         List<OrgOrgRelation> orgOrgRelations = organizationDao.getOrgOrgRelationsByIdList(orgOrgRelationIds);
 378  0
         return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations);
 379  
     }
 380  
 
 381  
     @Override
 382  
     public List<String> getOrgOrgRelationIdsByType(String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 383  0
         checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey");
 384  
         
 385  0
         List<String> orgOrgRelationIds = new ArrayList<String>();
 386  0
         List<OrgOrgRelation> orgOrgRelations = extendedOrgDao.getOrgOrgRelationsByType(orgOrgRelationTypeKey);
 387  
         
 388  0
         if (orgOrgRelations != null){
 389  0
             for(OrgOrgRelation orgOrgRelation : orgOrgRelations){
 390  0
                 orgOrgRelationIds.add(orgOrgRelation.getId());
 391  
             }
 392  
         }
 393  
         
 394  0
         return orgOrgRelationIds;
 395  
     }
 396  
 
 397  
     @Override
 398  
     public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrg(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 399  0
         checkForMissingParameter(orgId, "orgId");
 400  
 
 401  0
         List<OrgOrgRelation> orgOrgRelations = organizationDao.getOrgOrgRelationsByOrg(orgId);
 402  0
         return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations);
 403  
     }
 404  
 
 405  
     @Override
 406  
     public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrgs(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 407  0
         return this.getOrgOrgRelationsByOrg(orgId, contextInfo);
 408  
     }
 409  
 
 410  
     @Override
 411  
     public List<OrgOrgRelationInfo> getOrgOrgRelationsByTypeAndOrg(String orgId, String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 412  0
         checkForMissingParameter(orgId, "orgId");
 413  0
         checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey");
 414  
         
 415  0
         List<OrgOrgRelation> orgOrgRelations = extendedOrgDao.getOrgOrgRelationsByTypeAndOrg(orgId, orgOrgRelationTypeKey);
 416  0
         return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations);
 417  
     }
 418  
 
 419  
     @Override
 420  
     public List<String> searchForOrgOrgRelationIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 421  0
         List<String> orgOrgRelationIds = new ArrayList<String>();
 422  0
         List<OrgOrgRelationInfo> orgOrgRelations = this.searchForOrgOrgRelations(criteria, contextInfo);
 423  
 
 424  0
         if (orgOrgRelations != null) {
 425  0
             for (OrgOrgRelationInfo orgOrgRelation : orgOrgRelations) {
 426  0
                 orgOrgRelationIds.add(orgOrgRelation.getId());
 427  
             }
 428  
         }
 429  
 
 430  0
         return orgOrgRelationIds;
 431  
     }
 432  
 
 433  
     @Override
 434  
     public List<OrgOrgRelationInfo> searchForOrgOrgRelations(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 435  0
         List<OrgOrgRelationInfo> OrgOrgRelationInfos = new ArrayList<OrgOrgRelationInfo>();
 436  0
         GenericQueryResults<OrgOrgRelation> results = criteriaLookupService.lookup(OrgOrgRelation.class, criteria);
 437  
 
 438  0
         if (null != results && results.getResults().size() > 0) {
 439  0
             for (OrgOrgRelation orgOrgRelation : results.getResults()) {
 440  0
                 OrgOrgRelationInfos.add(OrganizationAssembler.toOrgOrgRelationInfo(orgOrgRelation));
 441  
             }
 442  
         }
 443  
 
 444  0
         return OrgOrgRelationInfos;
 445  
     }
 446  
 
 447  
     @Override
 448  
     public List<ValidationResultInfo> validateOrgOrgRelation(String validationTypeKey, String orgId, String orgPeerId, String orgOrgRelationTypeKey, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 449  0
         checkForMissingParameter(validationTypeKey, "validationTypeKey");
 450  0
         checkForMissingParameter(orgOrgRelationInfo, "orgOrgRelationInfo");
 451  
 
 452  
         // List<ValidationResultInfo> valResults = validator.validateTypeStateObject(orgOrgRelationInfo,
 453  
         // getObjectStructure("orgOrgRelationInfo"));
 454  
         // return valResults;
 455  0
         return null;
 456  
     }
 457  
 
 458  
     @Override
 459  
     public OrgOrgRelationInfo createOrgOrgRelation(String orgId, String orgPeerId, String orgOrgRelationTypeKey, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 460  
         // Check Missing params
 461  0
         checkForMissingParameter(orgId, "orgId");
 462  0
         checkForMissingParameter(orgPeerId, "orgPeerId");
 463  0
         checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey");
 464  0
         checkForMissingParameter(orgOrgRelationInfo, "orgOrgRelationInfo");
 465  
 
 466  
         // Set all the values on OrgOrgRelationInfo
 467  0
         orgOrgRelationInfo.setOrgId(orgId);
 468  0
         orgOrgRelationInfo.setRelatedOrgId(orgPeerId);
 469  0
         orgOrgRelationInfo.setTypeKey(orgOrgRelationTypeKey);
 470  
 
 471  0
         OrgOrgRelation orgOrgRelation = null;
 472  
 
 473  
         // Create a new persistence entity from the orgInfo
 474  
         try {
 475  0
             orgOrgRelation = OrganizationAssembler.toOrgOrgRelation(false, orgOrgRelationInfo, organizationDao);
 476  0
         } catch (VersionMismatchException e) {}
 477  
 
 478  
         // Persist the orgOrgRelation
 479  0
         organizationDao.create(orgOrgRelation);
 480  
 
 481  
         // Copy back to an OrgOrgRelationInfo and return
 482  0
         OrgOrgRelationInfo createdOrgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(orgOrgRelation);
 483  0
         return createdOrgOrgRelationInfo;
 484  
     }
 485  
 
 486  
     @Override
 487  
     public OrgOrgRelationInfo updateOrgOrgRelation(String orgOrgRelationId, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 488  
         // Check Missing params
 489  0
         checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId");
 490  0
         checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId");
 491  
 
 492  
         // Set all the values on OrgOrgRelationInfo
 493  0
         orgOrgRelationInfo.setId(orgOrgRelationId);
 494  
 
 495  0
         OrgOrgRelation orgOrgRelation = null;
 496  
 
 497  
         // Update the persistence entity from the Info
 498  0
         orgOrgRelation = OrganizationAssembler.toOrgOrgRelation(true, orgOrgRelationInfo, organizationDao);
 499  
 
 500  
         // Update the orgOrgRelation
 501  0
         OrgOrgRelation updatedOrgOrgRelation = organizationDao.update(orgOrgRelation);
 502  
 
 503  
         // Copy back to an OrgOrgRelationInfo and return
 504  0
         OrgOrgRelationInfo updatedOrgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(updatedOrgOrgRelation);
 505  0
         return updatedOrgOrgRelationInfo;
 506  
     }
 507  
 
 508  
     @Override
 509  
     public StatusInfo deleteOrgOrgRelation(String orgOrgRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 510  0
         checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId");
 511  
 
 512  
         try {
 513  0
             organizationDao.delete(OrgOrgRelation.class, orgOrgRelationId);
 514  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 515  0
             throw new DoesNotExistException(e.getMessage());
 516  0
         }
 517  0
         return new StatusInfo();
 518  
     }
 519  
 
 520  
     @Override
 521  
     public List<TypeInfo> getOrgPersonRelationTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 522  0
         List<OrgPersonRelationType> oprts = organizationDao.find(OrgPersonRelationType.class);
 523  0
         return OrganizationAssembler.toOrgPersonRelationTypeInfos(oprts);
 524  
     }
 525  
 
 526  
     @Override
 527  
     public List<TypeInfo> getOrgPersonRelationTypesForOrgType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 528  0
         checkForMissingParameter(orgTypeKey, "orgTypeKey");
 529  
 
 530  0
         List<OrgPersonRelationType> oprts = organizationDao.getOrgPersonRelationTypesForOrgType(orgTypeKey);
 531  0
         return OrganizationAssembler.toOrgPersonRelationTypeInfos(oprts);
 532  
     }
 533  
 
 534  
     @Override
 535  
     public Boolean hasOrgPersonRelation(String orgId, String personId, String orgPersonRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 536  0
         checkForMissingParameter(orgId, "orgId");
 537  0
         checkForMissingParameter(personId, "personId");
 538  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 539  
 
 540  0
         return organizationDao.hasOrgPersonRelation(orgId, personId, orgPersonRelationTypeKey);
 541  
     }
 542  
 
 543  
     @Override
 544  
     public OrgPersonRelationInfo getOrgPersonRelation(String orgPersonRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 545  0
         checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId");
 546  
 
 547  0
         OrgPersonRelation opr = null;
 548  
         try {
 549  0
             opr = organizationDao.fetch(OrgPersonRelation.class, orgPersonRelationId);
 550  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 551  0
             throw new DoesNotExistException(e.getMessage());
 552  0
         }
 553  0
         return OrganizationAssembler.toOrgPersonRelationInfo(opr);
 554  
     }
 555  
 
 556  
     @Override
 557  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByIds(List<String> orgPersonRelationIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 558  0
         checkForMissingParameter(orgPersonRelationIds, "orgPersonRelationIds");
 559  
 
 560  0
         List<OrgPersonRelation> oprts = organizationDao.getOrgPersonRelationsByIdList(orgPersonRelationIds);
 561  0
         return OrganizationAssembler.toOrgPersonRelationInfos(oprts);
 562  
     }
 563  
 
 564  
     @Override
 565  
     public List<String> getOrgPersonRelationIdsByType(String orgPersonRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 566  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 567  
 
 568  0
         List<String> orgPersonRelationIds = new ArrayList<String>();
 569  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByType(orgPersonRelationTypeKey);
 570  0
         if (orgPersonRelations != null) {
 571  0
             for (OrgPersonRelation orgPersonRelation : orgPersonRelations) {
 572  0
                 orgPersonRelationIds.add(orgPersonRelation.getId());
 573  
             }
 574  
         }
 575  
 
 576  0
         return orgPersonRelationIds;
 577  
     }
 578  
 
 579  
     @Override
 580  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrg(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 581  0
         checkForMissingParameter(orgId, "orgId");
 582  
 
 583  0
         List<OrgPersonRelation> relations = organizationDao.getAllOrgPersonRelationsByOrg(orgId);
 584  0
         return OrganizationAssembler.toOrgPersonRelationInfos(relations);
 585  
     }
 586  
 
 587  
     @Override
 588  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndOrg(String orgPersonRelationTypeKey, String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 589  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 590  0
         checkForMissingParameter(orgId, "orgId");
 591  
 
 592  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndOrg(orgPersonRelationTypeKey, orgId);
 593  0
         return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations);
 594  
     }
 595  
 
 596  
     @Override
 597  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByPerson(String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 598  0
         checkForMissingParameter(personId, "personId");
 599  
 
 600  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByPerson(personId);
 601  0
         return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations);
 602  
     }
 603  
 
 604  
     @Override
 605  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndPerson(String orgPersonRelationTypeKey, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 606  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 607  0
         checkForMissingParameter(personId, "personId");
 608  
 
 609  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndPerson(orgPersonRelationTypeKey, personId);
 610  0
         return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations);
 611  
     }
 612  
 
 613  
     @Override
 614  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrgAndPerson(String orgId, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 615  0
         checkForMissingParameter(orgId, "orgId");
 616  0
         checkForMissingParameter(personId, "personId");
 617  
 
 618  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByOrgAndPerson(orgId, personId);
 619  0
         return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations);
 620  
     }
 621  
 
 622  
     @Override
 623  
     public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndOrgAndPerson(String orgPersonRelationTypeKey, String orgId, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 624  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 625  0
         checkForMissingParameter(orgId, "orgId");
 626  0
         checkForMissingParameter(personId, "personId");
 627  
 
 628  0
         List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndOrgAndPerson(orgPersonRelationTypeKey, orgId, personId);
 629  0
         return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations);
 630  
     }
 631  
 
 632  
     @Override
 633  
     public List<String> searchForOrgPersonRelationIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 634  0
         List<String> orgPersonRelationIds = new ArrayList<String>();
 635  0
         List<OrgPersonRelationInfo> orgPersonRelations = this.searchForOrgPersonRelations(criteria, contextInfo);
 636  
 
 637  0
         if (orgPersonRelations != null) {
 638  0
             for (OrgPersonRelationInfo orgPersonRelation : orgPersonRelations) {
 639  0
                 orgPersonRelationIds.add(orgPersonRelation.getId());
 640  
             }
 641  
         }
 642  
 
 643  0
         return orgPersonRelationIds;
 644  
     }
 645  
 
 646  
     @Override
 647  
     public List<OrgPersonRelationInfo> searchForOrgPersonRelations(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 648  0
         List<OrgPersonRelationInfo> orgPersonRelationInfos = new ArrayList<OrgPersonRelationInfo>();
 649  0
         GenericQueryResults<OrgPersonRelation> results = criteriaLookupService.lookup(OrgPersonRelation.class, criteria);
 650  
 
 651  0
         if (null != results && results.getResults().size() > 0) {
 652  0
             for (OrgPersonRelation orgPersonRelation : results.getResults()) {
 653  0
                 orgPersonRelationInfos.add(OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation));
 654  
             }
 655  
         }
 656  
 
 657  0
         return orgPersonRelationInfos;
 658  
     }
 659  
 
 660  
     @Override
 661  
     public List<ValidationResultInfo> validateOrgPersonRelation(String validationTypeKey, String orgId, String personId, String orgPersonRelationTypeKey, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 662  0
         checkForMissingParameter(validationTypeKey, "validationTypeKey");
 663  
 
 664  
         // List<ValidationResultInfo> valResults = validator.validateTypeStateObject(orgPersonRelationInfo,
 665  
         // getObjectStructure("orgPersonRelationInfo"));
 666  
         // return valResults;
 667  0
         return null;
 668  
     }
 669  
 
 670  
     @Override
 671  
     public OrgPersonRelationInfo createOrgPersonRelation(String orgId, String personId, String orgPersonRelationTypeKey, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 672  
         // Check Missing params
 673  0
         checkForMissingParameter(orgId, "orgId");
 674  0
         checkForMissingParameter(personId, "personId");
 675  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 676  0
         checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey");
 677  
 
 678  
         // Make sure that only valid org person relations are done
 679  0
         if (!organizationDao.validatePositionRestriction(orgId, orgPersonRelationTypeKey)) {
 680  0
             throw new InvalidParameterException("There is no Position for this relationship");
 681  
         }
 682  
 
 683  
         // Set all the values on OrgOrgRelationInfo
 684  0
         orgPersonRelationInfo.setOrgId(orgId);
 685  0
         orgPersonRelationInfo.setPersonId(personId);
 686  0
         orgPersonRelationInfo.setTypeKey(orgPersonRelationTypeKey);
 687  
 
 688  0
         OrgPersonRelation orgPersonRelation = null;
 689  
 
 690  
         // Create a new persistence entity from the orgInfo
 691  
         try {
 692  0
             orgPersonRelation = OrganizationAssembler.toOrgPersonRelation(false, orgPersonRelationInfo, organizationDao);
 693  0
         } catch (VersionMismatchException e) {}
 694  
 
 695  
         // Persist the orgPersonRelation
 696  0
         organizationDao.create(orgPersonRelation);
 697  
 
 698  
         // Copy back to an orgPersonRelationInfo and return
 699  0
         OrgPersonRelationInfo createdOrgPersonRelationInfo = OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation);
 700  0
         return createdOrgPersonRelationInfo;
 701  
     }
 702  
 
 703  
     @Override
 704  
     public OrgPersonRelationInfo updateOrgPersonRelation(String orgPersonRelationId, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 705  
         // Check Missing params
 706  0
         checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId");
 707  0
         checkForMissingParameter(orgPersonRelationInfo, "orgPersonRelationInfo");
 708  
 
 709  
         // Make sure that only valid org person relations are done
 710  0
         if (!organizationDao.validatePositionRestriction(orgPersonRelationInfo.getOrgId(), orgPersonRelationInfo.getTypeKey())) {
 711  0
             throw new InvalidParameterException("There is no Position for this relationship");
 712  
         }
 713  
 
 714  
         // Set all the values on OrgPersonRelationInfo
 715  0
         orgPersonRelationInfo.setId(orgPersonRelationId);
 716  
 
 717  0
         OrgPersonRelation orgPersonRelation = null;
 718  
 
 719  
         // Update persistence entity from the orgInfo
 720  0
         orgPersonRelation = OrganizationAssembler.toOrgPersonRelation(true, orgPersonRelationInfo, organizationDao);
 721  
 
 722  
         // Update the orgPersonRelation
 723  0
         orgPersonRelation = organizationDao.update(orgPersonRelation);
 724  
 
 725  
         // Copy back to an orgPersonRelationInfo and return
 726  0
         OrgPersonRelationInfo createdOrgPersonRelationInfo = OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation);
 727  0
         return createdOrgPersonRelationInfo;
 728  
     }
 729  
 
 730  
     @Override
 731  
     public StatusInfo deleteOrgPersonRelation(String orgPersonRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 732  0
         checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId");
 733  
 
 734  
         try {
 735  0
             organizationDao.delete(OrgPersonRelation.class, orgPersonRelationId);
 736  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 737  0
             throw new DoesNotExistException(e.getMessage());
 738  0
         }
 739  0
         return new StatusInfo();
 740  
     }
 741  
 
 742  
     @Override
 743  
     public OrgPositionRestrictionInfo getOrgPositionRestriction(String orgPositionRestrictionId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 744  0
         checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId");
 745  
 
 746  
         OrgPositionRestriction orgPositionRestriction;
 747  
         try {
 748  0
             orgPositionRestriction = organizationDao.fetch(OrgPositionRestriction.class, orgPositionRestrictionId);
 749  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 750  0
             throw new DoesNotExistException(e.getMessage());
 751  0
         }
 752  0
         return OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction);
 753  
     }
 754  
 
 755  
     @Override
 756  
     public List<OrgPositionRestrictionInfo> getOrgPositionRestrictionsByIds(List<String> orgPositionRestrictionIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 757  0
         checkForMissingParameter(orgPositionRestrictionIds, "orgPositionRestrictionIds");
 758  
         
 759  0
         List<OrgPositionRestriction> orgPositionRestrictions = extendedOrgDao.getOrgPositionRestrictionsByIds(orgPositionRestrictionIds);
 760  0
         return OrganizationAssembler.toOrgPositionRestrictionInfos(orgPositionRestrictions);
 761  
     }
 762  
 
 763  
     @Override
 764  
     public List<String> getOrgPositionRestrictionIdsByType(String orgPositionRestrictionTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 765  0
         checkForMissingParameter(orgPositionRestrictionTypeKey, "orgPositionRestrictionTypeKey");
 766  
         
 767  0
         List<String> orgPositionRestrictionIds = new ArrayList<String>();
 768  0
         List<OrgPositionRestriction> orgPositionRestrictions = extendedOrgDao.getOrgPositionRestrictionsByType(orgPositionRestrictionTypeKey);
 769  
         
 770  0
         if (orgPositionRestrictions != null){
 771  0
             for (OrgPositionRestriction orgPositionRestriction : orgPositionRestrictions){
 772  0
                 orgPositionRestrictionIds.add(orgPositionRestriction.getId());
 773  
             }
 774  
         }
 775  
         
 776  0
         return orgPositionRestrictionIds;
 777  
     }
 778  
 
 779  
     @Override
 780  
     public List<String> getOrgPositionRestrictionIdsByOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 781  0
         checkForMissingParameter(orgId, "orgId");
 782  
 
 783  0
         List<OrgPositionRestriction> restrictions = organizationDao.getPositionRestrictionsByOrg(orgId);
 784  
 
 785  0
         List<String> restrictionIds = new ArrayList<String>(restrictions.size());
 786  0
         for (OrgPositionRestriction restriction : restrictions) {
 787  0
             restrictionIds.add(restriction.getId());
 788  
         }
 789  0
         return restrictionIds;
 790  
     }
 791  
 
 792  
     @Override
 793  
     public List<String> searchForOrgPositionRestrictionIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 794  0
         List<String> orgPositionRestrictionIds = new ArrayList<String>();
 795  0
         List<OrgPositionRestrictionInfo> orgPositionRestrictionInfos = this.searchForOrgPositionRestrictions(criteria, contextInfo);
 796  
 
 797  0
         if (orgPositionRestrictionInfos != null) {
 798  0
             for (OrgPositionRestrictionInfo orgPositionRestrictionInfo : orgPositionRestrictionInfos) {
 799  0
                 orgPositionRestrictionIds.add(orgPositionRestrictionInfo.getId());
 800  
             }
 801  
         }
 802  0
         return orgPositionRestrictionIds;
 803  
     }
 804  
 
 805  
     @Override
 806  
     public List<OrgPositionRestrictionInfo> searchForOrgPositionRestrictions(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 807  0
         List<OrgPositionRestrictionInfo> orgPositionRestrictionInfos = new ArrayList<OrgPositionRestrictionInfo>();
 808  0
         GenericQueryResults<OrgPositionRestriction> results = criteriaLookupService.lookup(OrgPositionRestriction.class, criteria);
 809  
 
 810  0
         if (null != results && results.getResults().size() > 0) {
 811  0
             for (OrgPositionRestriction orgPositionRestriction : results.getResults()) {
 812  0
                 orgPositionRestrictionInfos.add(OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction));
 813  
             }
 814  
         }
 815  
 
 816  0
         return orgPositionRestrictionInfos;
 817  
     }
 818  
 
 819  
     @Override
 820  
     public List<ValidationResultInfo> validateOrgPositionRestriction(String validationTypeKey, String orgId, String orgPositionRestrictionTypeKey, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 821  0
         checkForMissingParameter(validationTypeKey, "validationTypeKey");
 822  0
         checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo");
 823  
 
 824  0
         return null;
 825  
     }
 826  
 
 827  
     @Override
 828  
     public OrgPositionRestrictionInfo createOrgPositionRestriction(String orgId, String orgPositionRestrictionTypeKey, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 829  
         // Check Missing params
 830  0
         checkForMissingParameter(orgId, "orgId");
 831  0
         checkForMissingParameter(orgPositionRestrictionTypeKey, "orgPositionRestrictionTypeKey");
 832  0
         checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo");
 833  
 
 834  
         // Set all the values on OrgOrgRelationInfo
 835  0
         orgPositionRestrictionInfo.setOrgId(orgId);
 836  0
         orgPositionRestrictionInfo.setOrgPersonRelationTypeKey(orgPositionRestrictionTypeKey);
 837  
 
 838  0
         OrgPositionRestriction orgPositionRestriction = null;
 839  
 
 840  
         // Create a new persistence entity from the Info
 841  
         try {
 842  0
             orgPositionRestriction = OrganizationAssembler.toOrgPositionRestriction(false, orgPositionRestrictionInfo, organizationDao);
 843  0
         } catch (VersionMismatchException e) {}
 844  
 
 845  
         // Persist the positionRestriction
 846  0
         organizationDao.create(orgPositionRestriction);
 847  
 
 848  
         // Copy back to an OrgOrgRelationInfo and return
 849  0
         OrgPositionRestrictionInfo createdOrgPositionRestrictionInfo = OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction);
 850  0
         return createdOrgPositionRestrictionInfo;
 851  
     }
 852  
 
 853  
     @Override
 854  
     public OrgPositionRestrictionInfo updateOrgPositionRestriction(String orgPositionRestrictionId, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 855  
         // Check Missing params
 856  0
         checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId");
 857  0
         checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo");
 858  
 
 859  
         // Set all the values on OrgOrgRelationInfo
 860  
         // orgPositionRestrictionInfo.setOrgId(orgId);
 861  
         // orgPositionRestrictionInfo.setOrgPersonRelationTypeKey(orgPersonRelationTypeKey);
 862  
 
 863  0
         OrgPositionRestriction orgPositionRestriction = null;
 864  
 
 865  
         // Update persistence entity from the Info
 866  
         try {
 867  0
             orgPositionRestriction = OrganizationAssembler.toOrgPositionRestriction(true, orgPositionRestrictionInfo, organizationDao);
 868  0
         } catch (VersionMismatchException e) {}
 869  
 
 870  
         // Update the positionRestriction
 871  0
         OrgPositionRestriction updated = organizationDao.update(orgPositionRestriction);
 872  
 
 873  
         // Copy back to an OrgOrgRelationInfo and return
 874  0
         OrgPositionRestrictionInfo updatedOrgPositionRestrictionInfo = OrganizationAssembler.toOrgPositionRestrictionInfo(updated);
 875  0
         return updatedOrgPositionRestrictionInfo;
 876  
     }
 877  
 
 878  
     @Override
 879  
     public StatusInfo deleteOrgPositionRestriction(String orgPositionRestrictionId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 880  0
         checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId");
 881  
 
 882  
         try {
 883  0
             organizationDao.delete(OrgPositionRestriction.class, orgPositionRestrictionId);
 884  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 885  0
             throw new DoesNotExistException(e.getMessage());
 886  0
         }
 887  0
         return new StatusInfo();
 888  
     }
 889  
 
 890  
     @Override
 891  
     public Boolean isDescendant(String orgId, String descendantOrgId, String orgHierarchyId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 892  0
         checkForMissingParameter(orgId, "orgId");
 893  0
         checkForMissingParameter(descendantOrgId, "descendantOrgId");
 894  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 895  
 
 896  
         // get ancestors of the descendant, as it will be more efficient in most cases
 897  0
         List<String> ancestors = organizationDao.getAllAncestors(descendantOrgId, orgHierarchyId);
 898  0
         boolean result = ancestors.contains(orgId);
 899  0
         return Boolean.valueOf(result);
 900  
     }
 901  
 
 902  
     @Override
 903  
     public List<String> getAllDescendants(String orgId, String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 904  0
         checkForMissingParameter(orgId, "orgId");
 905  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 906  
 
 907  0
         List<String> descendants = this.organizationDao.getAllDescendants(orgId, orgHierarchyId);
 908  0
         return descendants;
 909  
     }
 910  
 
 911  
     @Override
 912  
     public List<String> getAllAncestors(String orgId, String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 913  0
         checkForMissingParameter(orgId, "orgId");
 914  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 915  
 
 916  0
         List<String> ancestors = this.organizationDao.getAllAncestors(orgId, orgHierarchyId);
 917  0
         return ancestors;
 918  
     }
 919  
 
 920  
     @Override
 921  
     public List<OrgTreeInfo> getOrgTree(String rootOrgId, String orgHierarchyId, int maxLevels, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 922  0
         checkForMissingParameter(rootOrgId, "rootOrgId");
 923  0
         checkForMissingParameter(orgHierarchyId, "orgHierarchyId");
 924  
 
 925  0
         Set<OrgTreeInfo> results = new HashSet<OrgTreeInfo>();
 926  
         try {
 927  0
             Org rootOrg = organizationDao.fetch(Org.class, rootOrgId);
 928  
 
 929  0
             OrgTreeInfo root = new OrgTreeInfo();
 930  0
             root.setOrgId(rootOrgId);
 931  0
             root.setParentId(null);
 932  0
             root.setDisplayName(rootOrg.getLongName());
 933  0
             root.setPositions(this.organizationDao.getOrgMemebershipCount(root.getOrgId()));
 934  0
             root.setOrgHierarchyId(orgHierarchyId);
 935  0
             results.add(root);
 936  0
             if (maxLevels >= 0) {
 937  0
                 results.addAll(parseOrgTree(rootOrgId, orgHierarchyId, maxLevels, 0));
 938  
             }
 939  
 
 940  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 941  0
             throw new DoesNotExistException();
 942  0
         }
 943  
 
 944  0
         return new ArrayList<OrgTreeInfo>(results);
 945  
     }
 946  
 
 947  
     private List<OrgTreeInfo> parseOrgTree(String rootOrgId, String orgHierarchyId, int maxLevels, int currentLevel) {
 948  0
         List<OrgTreeInfo> results = new ArrayList<OrgTreeInfo>();
 949  
 
 950  0
         if (maxLevels == 0 || currentLevel < maxLevels) {
 951  0
             List<org.kuali.student.core.organization.dto.OrgTreeInfo> orgTreeInfos = this.organizationDao.getOrgTreeInfo(rootOrgId, orgHierarchyId);
 952  0
             for (org.kuali.student.core.organization.dto.OrgTreeInfo orgTreeInfo : orgTreeInfos) {
 953  
                 
 954  0
                 OrgTreeInfo treeInfo = new OrgTreeInfo();
 955  0
                 treeInfo.setOrgId(orgTreeInfo.getOrgId());
 956  0
                 treeInfo.setDisplayName(orgTreeInfo.getDisplayName());
 957  0
                 treeInfo.setOrgHierarchyId(orgTreeInfo.getOrgHierarchyId());
 958  0
                 treeInfo.setParentId(orgTreeInfo.getParentId());
 959  0
                 treeInfo.setPersonId(orgTreeInfo.getPersonId());
 960  0
                 treeInfo.setPositionId(orgTreeInfo.getPositionId());
 961  0
                 treeInfo.setRelationTypeKey(orgTreeInfo.getRelationType());
 962  0
                 treeInfo.setPositions(this.organizationDao.getOrgMemebershipCount(orgTreeInfo.getOrgId()));
 963  
                 
 964  0
                 results.add(treeInfo);
 965  
                 
 966  0
                 results.addAll(parseOrgTree(orgTreeInfo.getOrgId(), orgHierarchyId, maxLevels, currentLevel + 1));
 967  0
             }
 968  
         }
 969  
 
 970  0
         return results;
 971  
     }
 972  
 
 973  
     public ObjectStructure getObjectStructure(String objectTypeKey) {
 974  0
         return dictionaryServiceDelegate.getObjectStructure(objectTypeKey);
 975  
     }
 976  
 }