Class CdsServiceUtils

java.lang.Object
com.sap.cds.services.impl.utils.CdsServiceUtils

public class CdsServiceUtils extends Object
Utility class for CDS Services
  • Constructor Details

    • CdsServiceUtils

      public CdsServiceUtils()
  • Method Details

    • getDefaultPersistenceService

      public static PersistenceService getDefaultPersistenceService(EventContext context)
      Returns the default persistence service.
      Parameters:
      context - the current context
      Returns:
      the default persistence service
    • getServiceSPI

      public static ServiceSPI getServiceSPI(Service service)
      Returns the Service casted to the ServiceSPI
      Parameters:
      service - the Service to be casted
      Returns:
      the Service casted to the ServiceSPI, or null
    • getServiceType

      public static Class<?> getServiceType(Service service)
      Returns the non-dynamic type of the Service, if possible. If the service is a typed proxy, the generated interface is returned.
      Parameters:
      service - the Service
      Returns:
      the best guess type of the Service
    • getEntities

      public static List<Map<String,Object>> getEntities(EventContext context)
      Returns the list of entity maps present in the EventContext. It inspects the CQN of the event and returns the entity data from it.
      Parameters:
      context - the EventContext
      Returns:
      the list of entity maps available in the CQN of the EventContext
    • getEntitiesResolved

      public static List<Map<String,Object>> getEntitiesResolved(EventContext context)
      Returns the list of entity maps present in the EventContext. It inspects the CQN of the events and returns the entity data from it. In contrast to {link getEntities(EventContext) the data also contains the resolved foreign keys from parent entities in path expressions.
      Parameters:
      context - the EventContext
      Returns:
      the list of entity maps available in the CQN of the EventContext
    • getResult

      public static com.sap.cds.Result getResult(EventContext context)
      Returns the Result present in the EventContext.
      Parameters:
      context - the EventContext
      Returns:
      the Result present in the EventContext
    • getEventContextSPI

      public static EventContextSPI getEventContextSPI(EventContext eventContext)
      Returns the EventContext casted to the EventContextSPI
      Parameters:
      eventContext - the EventContext to be casted
      Returns:
      the Service casted to the EventContextSPI, or null