Package com.smeup.kokos.service.utils
Class EntityServiceSupport
java.lang.Object
com.smeup.kokos.service.utils.EntityServiceSupport
Shared helper methods for entity-backed services.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordEntity class and its repository resolved together in a single lookup.static final recordResolved entity coordinates extracted from aFunObject. -
Method Summary
Modifier and TypeMethodDescriptionstatic Iterator<AbstractEntity> findAll(EntityRepository<?> repository) Returns an iterator over all entities in the given repository.static Optional<AbstractEntity> findById(EntityRepository<?> repository, String id) Finds an entity by id using the provided repository, suppressing unchecked warningsresolveClassAndRepository(String entityType, String entityParameter) Resolves both the entity class and its repository in a single pass, avoiding two separate calls toEntityManager.static Class<? extends AbstractEntity> resolveEntityClass(String entityType, String entityParameter) Resolves the entity class registered for the given Smeup type and parameter.static EntityRepository<?> Resolves the repository associated with the provided resolved object coordinates.static EntityRepository<?> resolveRepository(String entityType, String entityParameter) Resolves the repository associated with the provided type and parameter.resolveTypeParameterCode(com.smeup.kokos.sdk.fun.FunObject obj1) Resolves entity type, parameter and code from aFunObject, handling the two standard FUN conventions: Case 1 – OG form:1(OG;;CNCOL)or1(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.static voidwriteObjectNotFoundMessage(com.smeup.kokos.sdk.caller.KokosService service, EntityServiceSupport.ResolvedObj obj) Writes a warning message to the service output indicating that the specified object was not found.
-
Method Details
-
resolveTypeParameterCode
public static EntityServiceSupport.ResolvedObj resolveTypeParameterCode(com.smeup.kokos.sdk.fun.FunObject obj1) Resolves entity type, parameter and code from aFunObject, handling the two standard FUN conventions:- Case 1 – OG form:
1(OG;;CNCOL)or1(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.ResolvedObjwith separated type, parameter, code
- Case 1 – OG form:
-
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 toEntityManager. -
resolveRepository
Resolves the repository associated with the provided type and parameter. -
resolveRepository
Resolves the repository associated with the provided resolved object coordinates. -
findAll
Returns an iterator over all entities in the given repository. -
findById
Finds an entity by id using the provided repository, suppressing unchecked warnings- Parameters:
repository- the repository to queryid- 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 toobj- 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
-