Class ServiceDefinitionDao


public class ServiceDefinitionDao extends AbstractDao
Provides a DAO for the ServiceDefinition entity.
See Also:
  • Constructor Details

    • ServiceDefinitionDao

      public ServiceDefinitionDao()
  • Method Details

    • getServiceDefinitionForPK

      public ServiceDefinition getServiceDefinitionForPK(Object id)
      Return the service definition with the specified OID
      Parameters:
      id - the OID
      Returns:
      the matching service definition, or null if not found
    • getServiceDefinitionList

      public List<ServiceDefinition> getServiceDefinitionList()
      Return the full list of service definitions, ordered by type, then name
      Returns:
      the list of service definitions
    • getActiveServiceDefinitionList

      public List<ServiceDefinition> getActiveServiceDefinitionList()
      Return the full list of active service definitions, ordered by name and version number
      Returns:
      the list of active service definitions
    • getServiceDefinitionListForClient

      public List<ServiceDefinition> getServiceDefinitionListForClient(Client client)
      Return the list of service definitions for a client, ordered by type, then name
      Parameters:
      client - the client (optional)
      Returns:
      the list of service definitions
    • getServiceDefinitionListForClient

      public List<ServiceDefinition> getServiceDefinitionListForClient(Client client, boolean activeServicesOnly)
      Return the list of service definitions for a client, ordered by type, then name and version number
      Parameters:
      client - the client (optional)
      activeServicesOnly - whether to return only services with the active flag set
      Returns:
      the list of service definitions
      Since:
      4.0.0
    • getServiceDefinitionForName

      @Deprecated public ServiceDefinition getServiceDefinitionForName(String serviceName) throws ApplicationException
      Deprecated.
      use getClientService(Long, String, Integer) instead
      Return the service definition for the given service name
      Parameters:
      serviceName - the non-null service name
      Returns:
      the matching service definition
      Throws:
      ApplicationException - if no service definition with this name exists
    • getServiceForNameAndVersion

      @Deprecated public ServiceDefinition getServiceForNameAndVersion(String serviceName, Integer versionNumber)
      Deprecated.
      use getServiceForClientNameAndVersion instead
      Return the service with the given name and version number, or null if none was found.
      Parameters:
      serviceName - the full service name (required)
      versionNumber - the version number (optional; if null, this method will retrieve the current version)
      Returns:
      the matching service, or null if none was found
      Since:
      4.3.0
    • getClientServiceWithFallback

      @Deprecated public ServiceDefinition getClientServiceWithFallback(Client client, String serviceName, Integer versionNumber)
      Deprecated.
      Return the service for the given client, service name and version number, or null if none was found. If no client is passed in, only global services will be considered. If a client is passed in, the client is searched for a matching service; if none is found but a matching global service exists, the global service is returned. If you do not want to fall back to the global service, use getClientService(Long, Integer) instead.
      Parameters:
      client - the client the service belongs to (optional; see above)
      serviceName - the full service name (required)
      versionNumber - the version number (optional; if null, this method will retrieve the current version)
      Returns:
      the matching service, or null if none was found
      Since:
      5.0.0
    • getClientServiceWithFallback

      public ServiceDefinition getClientServiceWithFallback(Client client, String serviceName)
      Return the current version service for the given client, service name, or null if none was found. If no client is passed in, only global services will be considered. If a client is passed in, the client is searched for a matching service; if none is found but a matching global service exists, the global service is returned. If you do not want to fall back to the global service, use getClientService(Long, Integer) instead.
      Parameters:
      client - the client the service belongs to (optional; see above)
      serviceName - the full service name (required)
      Returns:
      the matching service, or null if none was found
      Since:
      17.10.0
    • getClientServiceWithFallback

      public ServiceDefinition getClientServiceWithFallback(Client client, String serviceName, String version)
      Return the service for the given client, service name and version number, or null if none was found. If no client is passed in, only global services will be considered. If a client is passed in, the client is searched for a matching service; if none is found but a matching global service exists, the global service is returned. If you do not want to fall back to the global service, use getClientService(Long, Integer) instead.
      Parameters:
      client - the client the service belongs to (optional; see above)
      serviceName - the full service name (required)
      version - the version (optional; if null, this method will retrieve the current version)
      Returns:
      the matching service, or null if none was found
      Since:
      17.10.0
    • getClientService

      @Deprecated public ServiceDefinition getClientService(Long clientId, String serviceName, Integer versionNumber)
      Deprecated.
      Return the service for the given client, service name and version number, or null if none was found. Note: This method does NOT fall back to global services. Use getServiceForClientNameAndVersion if you need that.
      Parameters:
      clientId - the OID of the client the service belongs to (optional; if not set, only global services will be considered)
      serviceName - the full service name (required)
      versionNumber - the version number (optional; if null, this method will retrieve the current version)
      Returns:
      the matching client/global service, or null if none was found
      Since:
      5.0.0
    • getClientService

      public ServiceDefinition getClientService(Long clientId, String serviceName)
      Return the current version service for the given client, service name, or null if none was found. Note: This method does NOT fall back to global services. Use getServiceForClientNameAndVersion if you need that.
      Parameters:
      clientId - the OID of the client the service belongs to (optional; if not set, only global services will be considered)
      serviceName - the full service name (required)
      Returns:
      the matching client/global service, or null if none was found
      Since:
      17.10.0
    • getClientService

      public ServiceDefinition getClientService(Long clientId, String serviceName, String version)
      Return the service for the given client, service name and version, or null if none was found. Note: This method does NOT fall back to global services. Use getServiceForClientNameAndVersion if you need that.
      Parameters:
      clientId - the OID of the client the service belongs to (optional; if not set, only global services will be considered)
      serviceName - the full service name (required)
      version - the version (optional; if null, this method will retrieve the current version)
      Returns:
      the matching client/global service, or null if none was found
      Since:
      17.10.0
    • getServiceVersionsForName

      public List<ServiceDefinition> getServiceVersionsForName(Long clientId, String serviceName)
      Return all service definitions with the given client and name (but different version numbers)
      Parameters:
      clientId - the OID of the client (optional; if not set, only global services will be considered)
      serviceName - the service name (required)
      Returns:
      the list of service definitions ordered ascending by version number
      Since:
      5.0.0
    • getServiceVersionsForName

      @Deprecated public List<ServiceDefinition> getServiceVersionsForName(String serviceName)
      Deprecated.
      use getServiceVersionsForName(Long, String) instead
      Return all service definitions with the given name (but different version numbers)
      Parameters:
      serviceName - the service name (required)
      Returns:
      the list of service definitions ordered ascending by version number
      Since:
      4.3.0
    • getServiceDefinitionListForApplication

      public List<ServiceDefinition> getServiceDefinitionListForApplication(String applicationId)
      Return the service definition for the given application package
      Parameters:
      applicationId - the OID of the application package (required)
      Returns:
      the list of matching service definitions
      Since:
      4.0.0
    • getOptionalServiceDefinitionForName

      @Deprecated public ServiceDefinition getOptionalServiceDefinitionForName(String serviceName)
      Deprecated.
      use getClientService(Long, String, Integer) or ServiceDefinitionDao#getClientServiceWithFallback(Long, String, Integer) instead
      Return the service definition for the given service name that is marked as the current version.
      Parameters:
      serviceName - the non-null service name
      Returns:
      the matching service definition, or null if no such service exists
    • getServiceDefinitionDefaultForType

      public ServiceDefinition getServiceDefinitionDefaultForType(String serviceType) throws ApplicationException
      Return the default service definition for the given service type
      Parameters:
      serviceType - the service type
      Returns:
      the default service definition for the given type
      Throws:
      ApplicationException - if no or multiple default services were found
    • getDefaultServiceDefinitionList

      public List<ServiceDefinition> getDefaultServiceDefinitionList()
      Return the list of default service definitions
      Returns:
      the default service definition list
    • hasDefaultServiceDefinitionForType

      public boolean hasDefaultServiceDefinitionForType(String serviceType)
      Return whether there is a default service definition for the given type
      Parameters:
      serviceType - the non-null service type
      Returns:
      true if there is a default service definition
    • hasServiceDefinitionForName

      @Deprecated public boolean hasServiceDefinitionForName(String serviceName)
      Deprecated.
      Return whether there is at least one service definition with the given name Note: Since 4.3.0, the name is no longer guaranteed to be unique (instead the combination of name + version number is unique).
      Parameters:
      serviceName - the non-null name
      Returns:
      true if there is a service definition with the given name
    • hasServiceDefinition

      public boolean hasServiceDefinition(Client client, String serviceName)
      Return whether there is at least one service definition with the given name Note: This method does not fall back to a global service if a clientId is specified.
      Parameters:
      client - the client (optional; if not set, only global services are considered)
      serviceName - the non-null name
      Returns:
      true if there is a service definition with the given name
      Since:
      5.0.0
    • canCreateService

      public boolean canCreateService(Client targetClient, String name)
      Check whether a service with the specified client and name can be created without conflict. Conflicts occur when a service with the same name already exists on the global level (if targetClient was specified) or for any client (if targetClient was null) If this method returns false, this means that the specified name/client combination is not valid and cannot be used for a service. NOTE: This method does not check if a service with the specified name and client already exists. It only checks is such a service is theoretically possible.
      Parameters:
      targetClient - the client with which the new service will be associated (optional; leave it null to denote a global service)
      name - the desired service name (required)
      Returns:
      true if such a service can be created, false if a conflict was found
      Since:
      5.0.0
    • getServiceDefinitionList

      @Deprecated public Iterable<ServiceDefinition> getServiceDefinitionList(String keyword, String type, boolean activeOnly, boolean userIsFormDeveloper)
      Deprecated.
      Deprecated. Use ServiceDefinitionDao#getServiceDefinitionList(Object, String, String, String, boolean, boolean) instead.
      Parameters:
      keyword - the search keyword
      type - a substring of the service type (optional)
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
    • getServiceDefinitionList

      public List<ServiceDefinition> getServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      3.6.0
    • getServiceDefinitionList

      public List<ServiceDefinition> getServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean groovyServiceOnly, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      groovyServiceOnly - the flag to only includes services with a Groovy script parameter
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      4.3.0
    • getServiceDefinitionList

      public List<ServiceDefinition> getServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean groovyServiceOnly, boolean clientOnly, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      groovyServiceOnly - the flag to only includes services with a Groovy script parameter
      clientOnly - the flag to show only client scope services.
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      5.1.0
    • getGlobalCoreServiceDefinitionList

      public List<ServiceDefinition> getGlobalCoreServiceDefinitionList(String keyword, String type, boolean groovyServiceOnly, boolean activeOnly)
      Return the list of core service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      keyword - the search keyword
      type - a substring of the service type (optional)
      groovyServiceOnly - the flag to only includes services with a Groovy script parameter
      activeOnly - the flag to only include active service definitions
      Returns:
      the list of matching service definitions
      Since:
      5.0.0
    • getFormServiceDefinitionList

      public List<ServiceDefinition> getFormServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean groovyServiceOnly, boolean activeOnly)
      Return the list of form service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      groovyServiceOnly - the flag to only includes services with a Groovy script parameter
      activeOnly - the flag to only include active service definitions
      Returns:
      the list of matching service definitions
      Since:
      4.3.1
    • getFluentFunctionService

      public List<ServiceDefinition> getFluentFunctionService(String clientId, String keyword, String type, String applicationPackageId, boolean clientOnly, boolean activeOnly)
      Return the list of fluent function service definitions matching the specified search criteria, ordered by service type and name.
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      clientOnly - the flag to only include client services
      activeOnly - the flag to only include active service definitions
      Returns:
      the list of matching service definitions
      Since:
      17.10.0
    • getFormServiceDefinitionList

      public List<ServiceDefinition> getFormServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean groovyServiceOnly, boolean clientOnly, boolean activeOnly)
      Return the list of form service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      groovyServiceOnly - the flag to only includes services with a Groovy script parameter
      clientOnly - the flag to only include client services
      activeOnly - the flag to only include active service definitions
      Returns:
      the list of matching service definitions
      Since:
      5.1.0
    • getUnitTestServices

      public List<ServiceDefinition> getUnitTestServices(String clientId, boolean userIsFormDeveloper)
      Return the list of service definitions with unit testing enabled.
      Parameters:
      clientId - the client id
      userIsFormDeveloper - is user a form developer
      Returns:
      the list of service definitions with unit testing enabled
      Since:
      4.3.0
    • getTestSuiteServices

      public List<ServiceDefinition> getTestSuiteServices()
      Return the list of Test Suite service definitions.
      Returns:
      the list of Test Suite service definitions.
      Since:
      4.3.0
    • getJobsServiceDefinitionList

      public List<ServiceDefinition> getJobsServiceDefinitionList(String clientId, String keyword, String type, String applicationPackageId, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of job related service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      applicationPackageId - the ID of an application package associated with the service (optional)
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      4.1.0
    • getJobsServiceDefinitionList

      public List<ServiceDefinition> getJobsServiceDefinitionList(String clientId, String keyword, String type, String appPackageId, boolean groovyServicesOnly, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of job related service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      appPackageId - the ID of an application package associated with the service (optional)
      groovyServicesOnly - the flag to only include Groovy script based services
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      4.3.0
    • getJobsServiceDefinitionList

      public List<ServiceDefinition> getJobsServiceDefinitionList(String clientId, String keyword, String type, String appPackageId, boolean groovyServicesOnly, boolean clientOnly, boolean activeOnly, boolean userIsFormDeveloper)
      Return the list of job related service definitions matching the specified search criteria, ordered by service type and name
      Parameters:
      clientId - the OID of the client to filter on (optional)
      keyword - the search keyword
      type - a substring of the service type (optional)
      appPackageId - the ID of an application package associated with the service (optional)
      groovyServicesOnly - the flag to only include Groovy script based services
      clientOnly - the flag to specify show only client services
      activeOnly - the flag to only include active service definitions
      userIsFormDeveloper - indicates that the user is a form developer and does not have access to all service types
      Returns:
      the list of matching service definitions
      Since:
      5.1.0
    • getServiceDefinitionListForType

      public List<ServiceDefinition> getServiceDefinitionListForType(String type, boolean includeInactiveServices)
      Return the service definitions for the given type, sorted by type and name
      Parameters:
      type - the service type (optional)
      includeInactiveServices - whether to include inactive services in the list of results
      Returns:
      the list of matching service definitions
    • getServiceDefinitionListForType

      public List<ServiceDefinition> getServiceDefinitionListForType(String type, Client client, boolean includeInactiveServices)
      Return the service definitions for the given type, sorted by type and name. If a client is specified, services belonging to other clients are excluded from the result.
      Parameters:
      type - the service type (optional)
      includeInactiveServices - whether to include inactive services in the list of results
      client - if set, only global services and those belonging to the client will be returned - services belonging to other clients are excluded
      Returns:
      the list of matching service definitions
    • getServiceDefinitionListForUserAndType

      public List<ServiceDefinition> getServiceDefinitionListForUserAndType(String type, UserAccount userAccount, boolean includeInactiveServices)
      Return the service definitions for the given type, and filtered based on user account access
      Parameters:
      type - the service type (optional)
      userAccount - user account parameter
      includeInactiveServices - whether to include inactive services in the list of results
      Returns:
      the list of matching service definitions
      Since:
      18.11.4
    • setCurrentVersion

      public void setCurrentVersion(ServiceDefinition sd)
      Set a specified service definition to be the default of its service type, unsetting the default flag from all other service definitions of the same type
      Parameters:
      sd - the non-null service definition
      Since:
      4.3.0
    • setDefaultType

      public void setDefaultType(ServiceDefinition sd)
      Set a specified service definition to be the default of its service type, unsetting the default flag from all other service definitions of the same type
      Parameters:
      sd - the non-null service definition
    • getAllServiceTypes

      public List<String> getAllServiceTypes()
      Return the full list of service types, consisting of the hard-coded core service types and any project-specific types occurring in the db-config files
      Returns:
      a list of service types, sorted ascending and case-insensitive
    • getAvailableServiceTypes

      public List<String> getAvailableServiceTypes()
      Return an ordered set of available service types.
      Returns:
      an ordered set of available service types
      Since:
      4.3.0
    • getAvailableGlobalCoreServiceTypes

      public List<String> getAvailableGlobalCoreServiceTypes()
      Return an ordered set of available global core service types.
      Returns:
      an ordered set of available global core service types
      Since:
      5.0.0
    • generateUniqueServiceName

      @Deprecated public String generateUniqueServiceName(String serviceName)
      Deprecated.
      use generateUniqueServiceName(Long, String) instead
      Generates a globally unique service name based on a suggested service name.
      Parameters:
      serviceName - the suggested service name
      Returns:
      a globally unique service name that does not equal any of the service names existing in the database
      Since:
      3.6.0
    • generateUniqueServiceName

      public String generateUniqueServiceName(Client client, String serviceName)
      Generates a unique (to the specified client) service name based on a suggested service name.
      Parameters:
      client - the client (optional; if not set, only global services will be considered)
      serviceName - the suggested service name
      Returns:
      a service name that does not equal any of the service names existing for the client (or if no client was passed in, a service name that does not match the name of any other global service)
      Since:
      5.0.0
    • doesServiceNameExistForOtherServiceTypes

      public boolean doesServiceNameExistForOtherServiceTypes(String serviceName, String serviceType)
      Find out whether a given service name is used in service types other than the specified one. This is used during service creation to avoid multiple services with the same name but different service types.
      Parameters:
      serviceName - the service name to search for (required)
      serviceType - the service type to exclude (required)
      Returns:
      true if a service with the same name exists for different service types
      Since:
      4.3.0
    • getServiceWithHighestVersionNumber

      public ServiceDefinition getServiceWithHighestVersionNumber(Long clientId, String serviceName)
      Return the active service with the highest version number for a specific client and service name.
      Parameters:
      clientId - the OID of the client (optional; if not set, only global services will be considered)
      serviceName - the service name (required)
      Returns:
      the service definition with the given name that has the highest version number, or null if none was found
      Since:
      5.0.0
    • getServiceWithHighestVersionNumber

      public ServiceDefinition getServiceWithHighestVersionNumber(Long clientId, String serviceName, boolean activeServicesOnly)
      Return the service with the highest version number for a specific client and service name.
      Parameters:
      clientId - the OID of the client (optional; if not set, only global services will be considered)
      serviceName - the service name (required)
      activeServicesOnly - whether to limit the search to active services, or include active and inactive services
      Returns:
      the service definition with the given name that has the highest version number, or null if none was found
      Since:
      19.11.0
    • getServiceWithHighestVersionNumber

      public ServiceDefinition getServiceWithHighestVersionNumber(String serviceName)
      Deprecated.
      use getServiceWithHighestVersionNumber(Long, String) instead
      Return the service with the highest version number for a specific service name.
      Parameters:
      serviceName - the service name (required)
      Returns:
      the service definition with the given name that has the highest version number, or null if none was found
      Since:
      4.3.0
    • parseCompositeNameVersionString

      public Pair<String,String> parseCompositeNameVersionString(String compositeString)
      Return the service name and version number components parsed from a composite string in the format "name|version" If the string is not in a suitable format, it is assumed that it merely contains the service name, not the version number. Examples:
       "My Service|1" -> <"My Service", 1>
       "Test|Prod Service|2" -> <"Test|Prod Service", 2>
       "Test|Prod Service" -> <"Test|Prod Service", null>
       "Forms Render Receipt" -> <"Forms Render Receipt", null>
       
      Parameters:
      compositeString - the composite string that may contain a version number along with the service name (required)
      Returns:
      A pair of the service name and the version number. If no specific version number could be parsed, null will be returned. TM will generally used the version marked as the current version for such requests.
      Since:
      4.3.0
    • getScheduledServicesByName

      public List<ServiceDefinition> getScheduledServicesByName(String serviceName)
      Return the list of scheduled services and test suites (current version only) with the given name. Because no client is specified, there may be several matching services. This method is used for backward compatibility support in scheduled service resolution. Note: This method is for internal use only and may change without notice. Do not use.
      Parameters:
      serviceName - the service name (required)
      Returns:
      the list of matching service definitions
      Since:
      5.0.0
    • getServiceListIds

      public List<ServiceDefinition> getServiceListIds(List<Long> serviceIds, UserAccount userAccount)
      Return the list of services for the given service IDs filtered for the users access.
      Parameters:
      serviceIds - the list of service IDs (required)
      userAccount - the logged in user account (required)
      Returns:
      the list of services for the given service IDs
      Since:
      5.0.0