Coverage Report - org.kuali.student.enrollment.lpr.service.adapter.federator.LuiPersonRelationFederatingAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
LuiPersonRelationFederatingAdapter
0%
0/60
0%
0/22
2.231
 
 1  
 /*
 2  
  * Copyright 2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.0 (the
 5  
  * "License"); you may not use this file except in compliance with the
 6  
  * License.  You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 13  
  * implied.  See the License for the specific language governing
 14  
  * permissions and limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.student.enrollment.lpr.service.adapter.federator;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.HashSet;
 21  
 import java.util.List;
 22  
 import java.util.Set;
 23  
 
 24  
 import org.kuali.student.common.dto.ContextInfo;
 25  
 import org.kuali.student.common.dto.CriteriaInfo;
 26  
 import org.kuali.student.common.exceptions.DisabledIdentifierException;
 27  
 import org.kuali.student.common.exceptions.DoesNotExistException;
 28  
 import org.kuali.student.common.exceptions.InvalidParameterException;
 29  
 import org.kuali.student.common.exceptions.MissingParameterException;
 30  
 import org.kuali.student.common.exceptions.OperationFailedException;
 31  
 import org.kuali.student.common.exceptions.PermissionDeniedException;
 32  
 import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo;
 33  
 import org.kuali.student.enrollment.lpr.mock.LuiPersonRelationServiceAdapter;
 34  
 import org.kuali.student.enrollment.lpr.service.LuiPersonRelationService;
 35  
 
 36  
 
 37  
 /**
 38  
  * An adapter to federate internal and external services. Only one
 39  
  * service may be designated an internal service in which creates and
 40  
  * updates occur. The external services are used to bring in data from
 41  
  * outside sources. Isn't this fun?
 42  
  *
 43  
  * @Author Tom
 44  
  */
 45  
 
 46  0
 public class LuiPersonRelationFederatingAdapter
 47  
         extends LuiPersonRelationServiceAdapter
 48  
        {
 49  
 
 50  
     private List<LuiPersonRelationService> externalServices;
 51  
 
 52  
 
 53  
     /**
 54  
      * Gets the underlying service provider.
 55  
      *
 56  
      * @return the underlying provider
 57  
      */
 58  
 
 59  
     protected List<LuiPersonRelationService> getExternalProviders() {
 60  0
         return (this.externalServices);
 61  
     }
 62  
 
 63  
 
 64  
     /**
 65  
      * Sets all the external providers.
 66  
      *
 67  
      * @param externalProviders a list of external service providers
 68  
      */
 69  
 
 70  
     protected void setExternalProviders(List<LuiPersonRelationService> externalProviders) {
 71  0
         this.externalServices = externalProviders;
 72  0
         return;
 73  
     }
 74  
 
 75  
 
 76  
     /**
 77  
      * Retrieves the Relation for the specified LUI Person Relation
 78  
      *
 79  
      * @param luiPersonRelationId Identifier for the LUI Person Relation
 80  
      * @param context             Context information containing the principalId
 81  
      *                            and locale information about the caller of service
 82  
      *                            operation
 83  
      * @return LUI Person Relation information
 84  
      * @throws DoesNotExistException     luiPersonRelationId not found
 85  
      * @throws InvalidParameterException invalid luiPersonRelationId
 86  
      * @throws MissingParameterException missing luiPersonRelationId
 87  
      * @throws OperationFailedException  unable to complete request
 88  
      * @throws PermissionDeniedException authorization failure
 89  
      */
 90  
 
 91  
     @Override
 92  
     public LuiPersonRelationInfo fetchLuiPersonRelation(String luiPersonRelationId, ContextInfo context)
 93  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 94  
 
 95  
         try {
 96  0
             return (getLprService().fetchLuiPersonRelation(luiPersonRelationId, context));
 97  0
         } catch (DoesNotExistException dne) {
 98  
         }
 99  
 
 100  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 101  
             try {
 102  0
                 return (getLprService().fetchLuiPersonRelation(luiPersonRelationId, context));
 103  0
             } catch (DoesNotExistException dne) {
 104  0
             }
 105  
         }
 106  
 
 107  0
         throw new DoesNotExistException(luiPersonRelationId + " not found");
 108  
     }
 109  
 
 110  
 
 111  
     /**
 112  
      * Retrieves the Relation for the specified list of LUI Person
 113  
      * Relation Ids.
 114  
      *
 115  
      * @param luiPersonRelationIdList List of identifiers for LUI
 116  
      *                                Person Relations
 117  
      * @param context                 Context information containing the principalId
 118  
      *                                and locale information about the caller of service
 119  
      *                                operation
 120  
      * @return List of LUI Person Relation information
 121  
      * @throws DoesNotExistException     One or more luiPersonRelationIds not found
 122  
      * @throws InvalidParameterException One or more invalid
 123  
      *                                   luiPersonRelationIds
 124  
      * @throws MissingParameterException missing luiPersonRelationIdList
 125  
      * @throws OperationFailedException  unable to complete request
 126  
      * @throws PermissionDeniedException authorization failure
 127  
      */
 128  
 
 129  
     @Override
 130  
     public List<LuiPersonRelationInfo> findLuiPersonRelationsByIdList(List<String> luiPersonRelationIdList, ContextInfo context)
 131  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 132  
 
 133  0
         List<LuiPersonRelationInfo> lprs = new ArrayList<LuiPersonRelationInfo>();
 134  
 
 135  0
         for (String id : luiPersonRelationIdList) {
 136  0
             lprs.add(fetchLuiPersonRelation(id, context));
 137  
         }
 138  
 
 139  0
         return (lprs);
 140  
     }
 141  
 
 142  
 
 143  
     /**
 144  
      * Retrieves the LUI Ids for Person related to LUI.
 145  
      *
 146  
      * @param personId              Identifier for the LUI Person Relation
 147  
      * @param luiPersonRelationType Type of LUI Person Relation
 148  
      * @param relationState         Relation State
 149  
      * @param context               Context information containing the principalId
 150  
      *                              and locale information about the caller of service
 151  
      *                              operation
 152  
      * @return Simple list of LUI Ids
 153  
      * @throws DoesNotExistException       personId, luiPersonRelationType,
 154  
      *                                     relationState, person to LUI relationship not found
 155  
      * @throws DisabledIdentifierException personId found, but has been
 156  
      *                                     retired
 157  
      * @throws InvalidParameterException   invalid personId,
 158  
      *                                     luiPersonRelationType, relationState
 159  
      * @throws MissingParameterException   missing personId,
 160  
      *                                     luiPersonRelationType, relationState
 161  
      * @throws OperationFailedException    unable to complete request
 162  
      * @throws PermissionDeniedException   authorization failure
 163  
      */
 164  
 
 165  
     @Override
 166  
     public List<String> findLuiIdsRelatedToPerson(String personId, String luiPersonRelationType, String relationState, ContextInfo context)
 167  
             throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 168  
 
 169  0
         Set<String> ids = new HashSet<String>();
 170  
 
 171  0
         ids.addAll(getLprService().findLuiIdsRelatedToPerson(personId, luiPersonRelationType, relationState, context));
 172  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 173  0
             ids.addAll(provider.findLuiIdsRelatedToPerson(personId, luiPersonRelationType, relationState, context));
 174  
         }
 175  
 
 176  0
         return (new ArrayList<String>(ids));
 177  
     }
 178  
 
 179  
 
 180  
     /**
 181  
      * Retrieves Person Ids related to the specified LUI.
 182  
      *
 183  
      * @param luiId                 Identifier for the LUI
 184  
      * @param luiPersonRelationType Type of LUI Person Relation
 185  
      * @param relationState         Relation State
 186  
      * @param context               Context information containing the principalId
 187  
      *                              and locale information about the caller of service
 188  
      *                              operation
 189  
      * @return Simple list of Person Ids
 190  
      * @throws DoesNotExistException     luiId, luiPersonRelationType,
 191  
      *                                   relationState, LUI to person relationship not found
 192  
      * @throws InvalidParameterException invalid luiId,
 193  
      *                                   luiPersonRelationType, relationState
 194  
      * @throws MissingParameterException missing luiId,
 195  
      *                                   luiPersonRelationType, relationState
 196  
      * @throws OperationFailedException  unable to complete request
 197  
      * @throws PermissionDeniedException authorization failure
 198  
      */
 199  
 
 200  
     @Override
 201  
     public List<String> findPersonIdsRelatedToLui(String luiId, String luiPersonRelationType, String relationState, ContextInfo context)
 202  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 203  
 
 204  
 
 205  0
         Set<String> ids = new HashSet<String>();
 206  
 
 207  0
         ids.addAll(getLprService().findPersonIdsRelatedToLui(luiId, luiPersonRelationType, relationState, context));
 208  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 209  0
             ids.addAll(provider.findPersonIdsRelatedToLui(luiId, luiPersonRelationType, relationState, context));
 210  
         }
 211  
 
 212  0
         return (new ArrayList<String>(ids));
 213  
     }
 214  
 
 215  
 
 216  
   
 217  
 
 218  
 
 219  
     /**
 220  
      * Retrieves Person Relation for LUI.
 221  
      *
 222  
      * @param personId Identifier for person
 223  
      * @param luiId    Identifier for LUI
 224  
      * @param context  Context information containing the principalId
 225  
      *                 and locale information about the caller of service
 226  
      *                 operation
 227  
      * @return List of LUI Person Relation info
 228  
      * @throws DoesNotExistException       personId, luiId not found
 229  
      * @throws DisabledIdentifierException personId found, but has been retired
 230  
      * @throws InvalidParameterException   invalid personId, luiId
 231  
      * @throws MissingParameterException   missing personId, luiId
 232  
      * @throws OperationFailedException    unable to complete request
 233  
      * @throws PermissionDeniedException   authorization failure
 234  
      */
 235  
 
 236  
     @Override
 237  
     public List<LuiPersonRelationInfo> findLuiPersonRelations(String personId, String luiId, ContextInfo context)
 238  
             throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 239  
 
 240  0
         List<LuiPersonRelationInfo> lprs = new ArrayList<LuiPersonRelationInfo>();
 241  
 
 242  0
         lprs.addAll(getLprService().findLuiPersonRelations(personId, luiId, context));
 243  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 244  0
             lprs.addAll(provider.findLuiPersonRelations(personId, luiId, context));
 245  
         }
 246  
 
 247  0
         return (lprs);
 248  
     }
 249  
 
 250  
 
 251  
     /**
 252  
      * Retrieves LUI Person Relation Ids.
 253  
      *
 254  
      * @param personId Identifier for person
 255  
      * @param luiId    Identifier for LUI
 256  
      * @param context  Context information containing the principalId
 257  
      *                 and locale information about the caller of service
 258  
      *                 operation
 259  
      * @return List of LUI Person Relation display info
 260  
      * @throws DoesNotExistException       personId, luiId not found
 261  
      * @throws DisabledIdentifierException personId found, but has been retired
 262  
      * @throws InvalidParameterException   invalid personId, luiId
 263  
      * @throws MissingParameterException   missing personId, luiId
 264  
      * @throws OperationFailedException    unable to complete request
 265  
      * @throws PermissionDeniedException   authorization failure
 266  
      */
 267  
 
 268  
     @Override
 269  
     public List<String> findLuiPersonRelationIds(String personId, String luiId, ContextInfo context)
 270  
             throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 271  
 
 272  0
         Set<String> ids = new HashSet<String>();
 273  
 
 274  0
         ids.addAll(getLprService().findLuiPersonRelationIds(personId, luiId, context));
 275  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 276  0
             ids.addAll(provider.findLuiPersonRelationIds(personId, luiId, context));
 277  
         }
 278  
 
 279  0
         return (new ArrayList<String>(ids));
 280  
     }
 281  
 
 282  
 
 283  
     /**
 284  
      * Retrieves LUI Person Relation for Person.
 285  
      *
 286  
      * @param personId Identifier for person
 287  
      * @param context  Context information containing the principalId
 288  
      *                 and locale information about the caller of service
 289  
      *                 operation
 290  
      * @return List of LUI Person Relation info
 291  
      * @throws DoesNotExistException       personId not found
 292  
      * @throws DisabledIdentifierException personId found, but has
 293  
      *                                     been retired
 294  
      * @throws InvalidParameterException   invalid personId
 295  
      * @throws MissingParameterException   missing personId
 296  
      * @throws OperationFailedException    unable to complete request
 297  
      * @throws PermissionDeniedException   authorization failure
 298  
      */
 299  
 
 300  
     @Override
 301  
     public List<LuiPersonRelationInfo> findLuiPersonRelationsForPerson(String personId, ContextInfo context)
 302  
             throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 303  
 
 304  0
         List<LuiPersonRelationInfo> lprs = new ArrayList<LuiPersonRelationInfo>();
 305  
 
 306  0
         lprs.addAll(getLprService().findLuiPersonRelationsForPerson(personId, context));
 307  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 308  0
             lprs.addAll(provider.findLuiPersonRelationsForPerson(personId, context));
 309  
         }
 310  
 
 311  0
         return (lprs);
 312  
     }
 313  
 
 314  
 
 315  
     /**
 316  
      * Retrieves LUI Person Relation Ids for Person.
 317  
      *
 318  
      * @param personId Identifier for person
 319  
      * @param context  Context information containing the principalId
 320  
      *                 and locale information about the caller of service
 321  
      *                 operation
 322  
      * @return Simple list of person relation identifiers
 323  
      * @throws DoesNotExistException       personId not found
 324  
      * @throws DisabledIdentifierException personId found, but has been retired
 325  
      * @throws InvalidParameterException   invalid personId
 326  
      * @throws MissingParameterException   missing personId
 327  
      * @throws OperationFailedException    unable to complete request
 328  
      * @throws PermissionDeniedException   authorization failure
 329  
      */
 330  
 
 331  
     @Override
 332  
     public List<String> findLuiPersonRelationIdsForPerson(String personId, ContextInfo context)
 333  
             throws DoesNotExistException, DisabledIdentifierException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 334  
 
 335  0
         Set<String> ids = new HashSet<String>();
 336  
 
 337  0
         ids.addAll(getLprService().findLuiPersonRelationIdsForPerson(personId, context));
 338  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 339  0
             ids.addAll(provider.findLuiPersonRelationIdsForPerson(personId, context));
 340  
         }
 341  
 
 342  0
         return (new ArrayList<String>(ids));
 343  
     }
 344  
 
 345  
 
 346  
     /**
 347  
      * Retrieves LUI Person Relation for a specified LUI.
 348  
      *
 349  
      * @param luiId   Identifier for LUI
 350  
      * @param context Context information containing the principalId
 351  
      *                and locale information about the caller of service
 352  
      *                operation
 353  
      * @return List of LUI Person Relation info
 354  
      * @throws DoesNotExistException     luiId not found
 355  
      * @throws InvalidParameterException invalid luiId
 356  
      * @throws MissingParameterException missing luiId
 357  
      * @throws OperationFailedException  unable to complete request
 358  
      * @throws PermissionDeniedException authorization failure
 359  
      */
 360  
 
 361  
     @Override
 362  
     public List<LuiPersonRelationInfo> findLuiPersonRelationsForLui(String luiId, ContextInfo context)
 363  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 364  
 
 365  0
         List<LuiPersonRelationInfo> lprs = new ArrayList<LuiPersonRelationInfo>();
 366  
 
 367  0
         lprs.addAll(getLprService().findLuiPersonRelationsForLui(luiId, context));
 368  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 369  0
             lprs.addAll(provider.findLuiPersonRelationsForLui(luiId, context));
 370  
         }
 371  
 
 372  0
         return (lprs);
 373  
     }
 374  
 
 375  
 
 376  
     /**
 377  
      * Retrieves LUIPersonRelation for LUI.
 378  
      *
 379  
      * @param luiId   Identifier for LUI
 380  
      * @param context Context information containing the principalId
 381  
      *                and locale information about the caller of service
 382  
      *                operation
 383  
      * @return Simple list of LUI Person Relation identifiers
 384  
      * @throws DoesNotExistException     luiId not found
 385  
      * @throws InvalidParameterException invalid luiId
 386  
      * @throws MissingParameterException missing luiId
 387  
      * @throws OperationFailedException  unable to complete request
 388  
      * @throws PermissionDeniedException authorization failure
 389  
      */
 390  
 
 391  
     @Override
 392  
     public List<String> findLuiPersonRelationIdsForLui(String luiId, ContextInfo context)
 393  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 394  
 
 395  0
         Set<String> ids = new HashSet<String>();
 396  
 
 397  0
         ids.addAll(getLprService().findLuiPersonRelationIdsForLui(luiId, context));
 398  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 399  0
             ids.addAll(provider.findLuiPersonRelationIdsForLui(luiId, context));
 400  
         }
 401  
 
 402  0
         return (new ArrayList<String>(ids));
 403  
     }
 404  
 
 405  
     /**
 406  
      * Retrieves detail of LUI Person Relation Ids.
 407  
      *
 408  
      * @param luiPersonRelationCriteria Criteria to be used for
 409  
      *                                  retrieval of multiple LUI Person Relation identifiers
 410  
      * @param context                   Context information containing the principalId
 411  
      *                                  and locale information about the caller of service
 412  
      *                                  operation
 413  
      * @return Simple list of LUI Person Relation identifiers
 414  
      * @throws InvalidParameterException invalid relation criteria
 415  
      * @throws MissingParameterException missing relation criteria
 416  
      * @throws OperationFailedException  unable to complete request
 417  
      * @throws PermissionDeniedException authorization failure
 418  
      */
 419  
 
 420  
     @Override
 421  
     public List<String> searchForLuiPersonRelationIds(CriteriaInfo criteria, ContextInfo context)
 422  
             throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 423  
 
 424  0
         Set<String> ids = new HashSet<String>();
 425  
 
 426  0
         ids.addAll(getLprService().searchForLuiPersonRelationIds(criteria, context));
 427  0
         for (LuiPersonRelationService provider : getExternalProviders()) {
 428  0
             ids.addAll(provider.searchForLuiPersonRelationIds(criteria, context));
 429  
         }
 430  
 
 431  0
         return (new ArrayList<String>(ids));
 432  
     }
 433  
 }