@Service
class RelationService(repository: RelationRepository, val relationPartnerRepository: RelationPartnerRepository, val relationTemplateRepository: RelationTemplateRepository, val templatedNodeService: TemplatedNodeService, val interfacePartRepository: InterfacePartRepository, val nodeRepository: NodeRepository, val templateService: TemplateService) : NodeService<Relation, RelationRepository>

Service for Relations. Provides functions to create, update and delete

Parameters

repository

the associated repository used for CRUD functionality

relationPartnerRepository

used to get start and end of a Relation by id

relationTemplateRepository

used to get the RelationTemplate by id

templatedNodeService

service used to update templatedFields

interfacePartRepository

used to get InterfaceParts by id

nodeRepository

used to save/delete any node

Constructors

Link copied to clipboard
constructor(repository: RelationRepository, relationPartnerRepository: RelationPartnerRepository, relationTemplateRepository: RelationTemplateRepository, templatedNodeService: TemplatedNodeService, interfacePartRepository: InterfacePartRepository, nodeRepository: NodeRepository, templateService: TemplateService)

Properties

Link copied to clipboard
@Autowired
lateinit var authorizationChecker: AuthorizationChecker

Injected, used for the checkPermission function

Link copied to clipboard

Injected, used to get a user based on a GropiusAuthorizationContext

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Creates multiple Relations based on the provided input Checks the authorization status

Link copied to clipboard
suspend fun checkIsAdmin(authorizationContext: GropiusAuthorizationContext, errorMessage: String)

Checks if the user defined by authorizationContext is a global admin

Link copied to clipboard
suspend fun checkPermission(node: Node, permission: Permission, errorMessage: String)

Checks if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard
private suspend fun checkRelationAuthorization(start: RelationPartner, end: RelationPartner, authorizationContext: GropiusAuthorizationContext)

Checks that the user has the permission to relate from start and relate to end

Link copied to clipboard
suspend fun createRelation(authorizationContext: GropiusAuthorizationContext, input: CreateRelationInput): Relation

Creates a new Relation based on the provided input Checks the authorization status

Link copied to clipboard
suspend fun deleteRelation(authorizationContext: GropiusAuthorizationContext, input: DeleteNodeInput)

Deletes a Relation by id Checks the authorization status

Link copied to clipboard
suspend fun evaluatePermission(node: Node, permission: Permission): Boolean

Evaluates if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard
private suspend fun getInterfaceParts(relationPartner: RelationPartner, partIds: List<ID>): Set<InterfacePart>

Helper used to get InterfaceParts based on a list of ids for a RelationPartner The relationPartner must be a Interface, if a non-empty list of ids is provided Each InterfacePart must be active on the InterfaceSpecificationVersion related to the Interface

Link copied to clipboard
suspend fun getUser(authorizationContext: GropiusAuthorizationContext): GropiusUser

Gets a GropiusUser based on the userId from the authorizationContext

Link copied to clipboard
suspend fun updateRelation(authorizationContext: GropiusAuthorizationContext, input: UpdateRelationInput): Relation

Updates a Relation based on the provided input Checks the authorization status

Link copied to clipboard
private suspend fun updateRelationTemplate(input: UpdateRelationInput, relation: Relation, updateContext: NodeBatchUpdateContext)

Updates the template of an relation, if provided via the input Does not check the authorization status

Link copied to clipboard

Validates that a start, end and relationPartner combination is valid This includes checking that a relation is not created in the context of the same ComponentVersion