Class EntityServiceSupport

java.lang.Object
com.smeup.kokos.service.utils.EntityServiceSupport

public final class EntityServiceSupport extends Object
Shared helper methods for entity-backed services.
  • Method Details

    • resolveTypeParameterCode

      public static EntityServiceSupport.ResolvedObj resolveTypeParameterCode(com.smeup.kokos.sdk.fun.FunObject obj1)
      Resolves entity type, parameter and code from a FunObject, handling the two standard FUN conventions:
      • Case 1 – OG form: 1(OG;;CNCOL) or 1(OG;;OKAHD) where type + parameter are packed in K and code is empty.
      • Case 2 – direct T;P;K: 1(CN;COL;BONMAI) where T is type, P is parameter, K is code.
      Parameters:
      obj1 - the first object from the parsed FUN
      Returns:
      a EntityServiceSupport.ResolvedObj with separated type, parameter, code
    • resolveEntityClass

      public static Class<? extends AbstractEntity> resolveEntityClass(String entityType, String entityParameter)
      Resolves the entity class registered for the given Smeup type and parameter.
      Throws:
      RepositoryNotFoundException - if no matching entity class is registered
    • resolveClassAndRepository

      public static EntityServiceSupport.ClassAndRepository resolveClassAndRepository(String entityType, String entityParameter)
      Resolves both the entity class and its repository in a single pass, avoiding two separate calls to EntityManager.
    • resolveRepository

      public static EntityRepository<?> resolveRepository(String entityType, String entityParameter)
      Resolves the repository associated with the provided type and parameter.
    • resolveRepository

      public static EntityRepository<?> resolveRepository(EntityServiceSupport.ResolvedObj obj)
      Resolves the repository associated with the provided resolved object coordinates.
    • findAll

      public static Iterator<AbstractEntity> findAll(EntityRepository<?> repository)
      Returns an iterator over all entities in the given repository.
    • findById

      public static Optional<AbstractEntity> findById(EntityRepository<?> repository, String id)
      Finds an entity by id using the provided repository, suppressing unchecked warnings
      Parameters:
      repository - the repository to query
      id - the id of the entity to find
      Returns:
      an Optional containing the found entity, or empty if not found
    • writeObjectNotFoundMessage

      public static void writeObjectNotFoundMessage(com.smeup.kokos.sdk.caller.KokosService service, EntityServiceSupport.ResolvedObj obj) throws Exception
      Writes a warning message to the service output indicating that the specified object was not found.
      Parameters:
      service - the KokosService to write the message to
      obj - the ResolvedObj containing the type, parameter, and code of the object that was not found
      Throws:
      Exception - if an error occurs while writing the message