protected List < ContractSummaryBean > getClientContractsInternal ( String organizationId , String clientId , String version ) throws StorageException { List < ContractSummaryBean > rval = new ArrayList <> ( ) ; EntityManager entityManager = getActiveEntityManager ( ) ; String jpql = "SELECT c from ContractBean c " + " JOIN c.client clientv " + " JOIN clientv.client client " + " JOIN client.organization aorg" + " WHERE client.id = :clientId " + " AND aorg.id = :orgId " + " AND clientv.version = :version " + " ORDER BY aorg.id, client.id ASC" ; Query query = entityManager . createQuery ( jpql ) ; query . setParameter ( "orgId" , organizationId ) ; //$NON-NLS-1$ query . setParameter ( "clientId" , clientId ) ; //$NON-NLS-1$ query . setParameter ( "version" , version ) ; //$NON-NLS-1$ List < ContractBean > contracts = query . getResultList ( ) ; for ( ContractBean contractBean : contracts ) { ClientBean client = contractBean . getClient ( ) . getClient ( ) ; ApiBean api = contractBean . getApi ( ) . getApi ( ) ; PlanBean plan = contractBean . getPlan ( ) . getPlan ( ) ; OrganizationBean clientOrg = entityManager . find ( OrganizationBean . class , client . getOrganization ( ) . getId ( ) ) ; OrganizationBean apiOrg = entityManager . find ( OrganizationBean . class , api . getOrganization ( ) . getId ( ) ) ; ContractSummaryBean csb = new ContractSummaryBean ( ) ; csb . setClientId ( client . getId ( ) ) ; csb . setClientOrganizationId ( client . getOrganization ( ) . getId ( ) ) ; csb . setClientOrganizationName ( clientOrg . getName ( ) ) ; csb . setClientName ( client . getName ( ) ) ; csb . setClientVersion ( contractBean . getClient ( ) . getVersion ( ) ) ; csb . setContractId ( contractBean . getId ( ) ) ; csb . setCreatedOn ( contractBean . getCreatedOn ( ) ) ; csb . setPlanId ( plan . getId ( ) ) ; csb . setPlanName ( plan . getName ( ) ) ; csb . setPlanVersion ( contractBean . getPlan ( ) . getVersion ( ) ) ; csb . setApiDescription ( api . getDescription ( ) ) ; csb . setApiId ( api . getId ( ) ) ; csb . setApiName ( api . getName ( ) ) ; csb . setApiOrganizationId ( apiOrg . getId ( ) ) ; csb . setApiOrganizationName ( apiOrg . getName ( ) ) ; csb . setApiVersion ( contractBean . getApi ( ) . getVersion ( ) ) ; rval . add ( csb ) ; } return rval ; }
Returns a list of all contracts for the given client .