Package com.abstratt.kirra
Interface InstanceManagement
-
- All Known Subinterfaces:
Repository
public interface InstanceManagement
Basic protocol for managing entity instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
InstanceManagement.DataProfile
A full instance loads all values for all properties and relationships available in the data repository.static class
InstanceManagement.Page<T>
static class
InstanceManagement.PageRequest
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Long
countInstances(String namespace, String name)
default Long
countInstances(Map<String,List<Object>> criteria, String namespace, String name, boolean includeSubclasses)
default long
countQueryResults(Operation operation, String externalId, List<?> arguments)
default Blob
createBlob(TypeRef entityRef, String objectId, String blobPropertyName, String contentType, String originalName)
Instance
createInstance(Instance instance)
Persists a transient instance.default Instance
createUser(Instance userInfo)
default void
deleteBlob(TypeRef entityRef, String objectId, String blobPropertyName, String blob)
default void
deleteInstance(Instance instance)
Destroys an instance, persisted or not.void
deleteInstance(String namespace, String name, String id)
Destroys an instance, persisted or not.List<?>
executeOperation(Operation operation, String externalId, List<?> arguments)
default List<?>
executeOperation(Operation operation, String externalId, List<?> arguments, String parameterSet)
Returns a collection of instances or values, never null.default List<?>
executeQuery(Operation operation, String externalId, List<?> arguments)
default List<?>
executeQuery(Operation operation, String externalId, List<?> arguments, boolean full)
default List<?>
executeQuery(Operation operation, String externalId, List<?> arguments, InstanceManagement.PageRequest pageRequest)
default InstanceManagement.Page<Instance>
filterInstances(InstanceManagement.PageRequest pageRequest, Map<String,List<Object>> criteria, String namespace, String name)
default List<Instance>
filterInstances(Map<String,List<Object>> criteria, String namespace, String name, boolean full)
default List<Instance>
filterInstances(Map<String,List<Object>> criteria, String namespace, String name, InstanceManagement.DataProfile dataProfile)
default List<Instance>
filterInstances(Map<String,List<Object>> criteria, String namespace, String name, InstanceManagement.DataProfile dataProfile, boolean includeSubclasses)
default AuthorizationHandler
getAuthorizationHandler()
default Blob
getBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token)
Instance
getCurrentUser()
Returns an instance describing the currently logged-in user/profile.default List<Instance>
getCurrentUserRoles()
Returns a list of instances representing the user roles for the current user.List<Operation>
getEnabledEntityActions(Entity entity)
For an entity, what actions are currently enabled?default EntityCapabilities
getEntityCapabilities(TypeRef entity)
What capabilities are available for the given entity?default Map<TypeRef,EntityCapabilities>
getEntityCapabilities(List<TypeRef> entities)
default Instance
getInstance(InstanceRef ref)
Obtains the instance corresponding to the given reference.default Instance
getInstance(InstanceRef ref, InstanceManagement.DataProfile dataProfile)
Loads the instance corresponding to the given reference using the given data profile.default Instance
getInstance(String namespace, String name, String externalId)
default Instance
getInstance(String namespace, String name, String externalId, boolean full)
Instance
getInstance(String namespace, String name, String externalId, InstanceManagement.DataProfile dataProfile)
Loads an instance with the given identifier.default InstanceCapabilities
getInstanceCapabilities(TypeRef entity, String objectId)
What capabilities are available for thei given instance?default List<Instance>
getInstances(String namespace, String name, boolean full)
default List<Instance>
getInstances(String namespace, String name, boolean full, boolean includeSubclasses)
Loads all instances of the given entity type.default List<Instance>
getInstances(String namespace, String name, InstanceManagement.DataProfile dataProfile)
default List<Instance>
getInstances(String namespace, String name, InstanceManagement.DataProfile dataProfile, boolean includeSubclasses)
default List<Instance>
getInstances(String namespace, String name, InstanceManagement.PageRequest pageRequest)
Loads all instances of the given entity type.List<Instance>
getParameterDomain(Entity entity, String externalId, Operation action, Parameter parameter)
default List<Instance>
getRelatedInstances(Instance anchorInstance, String relationship, boolean full)
default List<Instance>
getRelatedInstances(String namespace, String name, String externalId, String relationship, boolean full)
List<Instance>
getRelatedInstances(String namespace, String name, String externalId, String relationship, InstanceManagement.DataProfile dataProfile)
List<Instance>
getRelationshipDomain(Entity entity, String objectId, Relationship relationship)
default boolean
isRestricted()
void
linkInstances(Relationship relationship, String sourceId, InstanceRef destinationId)
Establishes a link between the two instances through the given relationship.Instance
newInstance(String namespace, String name)
Creates a transient instance of the given type.default InputStream
readBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token)
void
saveContext()
void
unlinkInstances(Relationship relationship, String sourceId, InstanceRef destinationId)
Breaks an existing link between two instances through the given relationship.Instance
updateInstance(Instance instance)
Updates a persistent instance.void
validateInstance(Instance toValidate)
Validates the given instance without saving it.default Blob
writeBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token, InputStream contents)
void
zap()
-
-
-
Method Detail
-
getAuthorizationHandler
default AuthorizationHandler getAuthorizationHandler()
-
createInstance
Instance createInstance(Instance instance)
Persists a transient instance. It is an error to try to invoke create on an already persisted instance.- Parameters:
namespace
-entityName
-
-
deleteInstance
default void deleteInstance(Instance instance)
Destroys an instance, persisted or not.- Parameters:
instance
-
-
deleteInstance
void deleteInstance(String namespace, String name, String id)
Destroys an instance, persisted or not.- Parameters:
namespace
- entity namespacename
- entity nameid
- instance identifier
-
executeOperation
default List<?> executeOperation(Operation operation, String externalId, List<?> arguments, String parameterSet)
Returns a collection of instances or values, never null.
-
executeOperation
List<?> executeOperation(Operation operation, String externalId, List<?> arguments)
-
executeQuery
default List<?> executeQuery(Operation operation, String externalId, List<?> arguments, boolean full)
-
executeQuery
default List<?> executeQuery(Operation operation, String externalId, List<?> arguments)
-
executeQuery
default List<?> executeQuery(Operation operation, String externalId, List<?> arguments, InstanceManagement.PageRequest pageRequest)
-
countQueryResults
default long countQueryResults(Operation operation, String externalId, List<?> arguments)
-
getCurrentUser
Instance getCurrentUser()
Returns an instance describing the currently logged-in user/profile.
-
getCurrentUserRoles
default List<Instance> getCurrentUserRoles()
Returns a list of instances representing the user roles for the current user.
-
getEnabledEntityActions
List<Operation> getEnabledEntityActions(Entity entity)
For an entity, what actions are currently enabled?
-
getEntityCapabilities
default EntityCapabilities getEntityCapabilities(TypeRef entity)
What capabilities are available for the given entity?
-
getEntityCapabilities
default Map<TypeRef,EntityCapabilities> getEntityCapabilities(List<TypeRef> entities)
-
getInstance
default Instance getInstance(InstanceRef ref)
Obtains the instance corresponding to the given reference.
-
getInstance
default Instance getInstance(InstanceRef ref, InstanceManagement.DataProfile dataProfile)
Loads the instance corresponding to the given reference using the given data profile.
-
getInstanceCapabilities
default InstanceCapabilities getInstanceCapabilities(TypeRef entity, String objectId)
What capabilities are available for thei given instance?
-
getInstance
Instance getInstance(String namespace, String name, String externalId, InstanceManagement.DataProfile dataProfile)
Loads an instance with the given identifier.- Parameters:
namespace
-name
-externalId
- the object identifierdataProfile
-- Returns:
- an instance, or
null
if no object exists
-
getInstance
default Instance getInstance(String namespace, String name, String externalId, boolean full)
-
getInstances
default List<Instance> getInstances(String namespace, String name, InstanceManagement.PageRequest pageRequest)
Loads all instances of the given entity type.- Parameters:
namespace
-name
-pageRequest
- optional page request
-
getInstances
default List<Instance> getInstances(String namespace, String name, boolean full, boolean includeSubclasses)
Loads all instances of the given entity type.- Parameters:
namespace
-name
-full
- whether instances should be fully loadedincludeSubclasses
-pageRequest
- optional page request
-
getInstances
default List<Instance> getInstances(String namespace, String name, InstanceManagement.DataProfile dataProfile, boolean includeSubclasses)
-
getInstances
default List<Instance> getInstances(String namespace, String name, InstanceManagement.DataProfile dataProfile)
-
countInstances
default Long countInstances(Map<String,List<Object>> criteria, String namespace, String name, boolean includeSubclasses)
-
filterInstances
default List<Instance> filterInstances(Map<String,List<Object>> criteria, String namespace, String name, InstanceManagement.DataProfile dataProfile)
-
filterInstances
default List<Instance> filterInstances(Map<String,List<Object>> criteria, String namespace, String name, boolean full)
-
filterInstances
default List<Instance> filterInstances(Map<String,List<Object>> criteria, String namespace, String name, InstanceManagement.DataProfile dataProfile, boolean includeSubclasses)
-
filterInstances
default InstanceManagement.Page<Instance> filterInstances(InstanceManagement.PageRequest pageRequest, Map<String,List<Object>> criteria, String namespace, String name)
-
getParameterDomain
List<Instance> getParameterDomain(Entity entity, String externalId, Operation action, Parameter parameter)
-
getRelatedInstances
default List<Instance> getRelatedInstances(String namespace, String name, String externalId, String relationship, boolean full)
-
getRelatedInstances
List<Instance> getRelatedInstances(String namespace, String name, String externalId, String relationship, InstanceManagement.DataProfile dataProfile)
-
getRelatedInstances
default List<Instance> getRelatedInstances(Instance anchorInstance, String relationship, boolean full)
-
getRelationshipDomain
List<Instance> getRelationshipDomain(Entity entity, String objectId, Relationship relationship)
-
newInstance
Instance newInstance(String namespace, String name)
Creates a transient instance of the given type. Default values will have been properly assigned. Transient instances have identities just like persisted instances. However, they are discarded at the end of a session if not saved. Also, transient instances are not visible as part of the entity extent (seegetInstances(String, String, boolean)
).- Parameters:
namespace
- entity namespacename
- entity name- Returns:
- the created instance, with default values assigned
-
saveContext
void saveContext()
-
linkInstances
void linkInstances(Relationship relationship, String sourceId, InstanceRef destinationId)
Establishes a link between the two instances through the given relationship.- Parameters:
relationship
-sourceId
-destinationId
-
-
unlinkInstances
void unlinkInstances(Relationship relationship, String sourceId, InstanceRef destinationId)
Breaks an existing link between two instances through the given relationship.- Parameters:
relationship
-sourceId
-destinationId
-
-
updateInstance
Instance updateInstance(Instance instance)
Updates a persistent instance.- Parameters:
instance
-- Returns:
-
validateInstance
void validateInstance(Instance toValidate)
Validates the given instance without saving it.- Parameters:
toValidate
- instance to be validated- Throws:
KirraException
- if validation fails
-
zap
void zap()
-
deleteBlob
default void deleteBlob(TypeRef entityRef, String objectId, String blobPropertyName, String blob)
-
getBlob
default Blob getBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token)
-
readBlob
default InputStream readBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token)
-
writeBlob
default Blob writeBlob(TypeRef entityRef, String objectId, String blobPropertyName, String token, InputStream contents)
-
createBlob
default Blob createBlob(TypeRef entityRef, String objectId, String blobPropertyName, String contentType, String originalName)
-
isRestricted
default boolean isRestricted()
-
-