@Service
class ComponentVersionService(repository: ComponentVersionRepository, val interfaceSpecificationVersionRepository: InterfaceSpecificationVersionRepository, val nodeRepository: NodeRepository, val componentRepository: ComponentRepository, val templatedNodeService: TemplatedNodeService) : RelationPartnerService<ComponentVersion, ComponentVersionRepository>

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

Parameters

repository

the associated repository used for CRUD functionality

interfaceSpecificationVersionRepository
nodeRepository

used to save/delete any node

componentRepository

used to get Components by id

templatedNodeService

used to update templatedFields

Constructors

Link copied to clipboard
constructor(repository: ComponentVersionRepository, interfaceSpecificationVersionRepository: InterfaceSpecificationVersionRepository, nodeRepository: NodeRepository, componentRepository: ComponentRepository, templatedNodeService: TemplatedNodeService)

Properties

Link copied to clipboard
@Autowired
lateinit var authorizationChecker: AuthorizationChecker

Injected, used for the checkPermission function

Link copied to clipboard
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

Functions

Adds a InterfaceSpecificationVersion to a ComponentVersion as visible/invisible Checks the authorization status Requires that the InterfaceSpecificationVersion is part of the same Component as the ComponentVersion

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

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

Creates a new ComponentVersion based on the provided input on component Does not check the authorization status, does not save the created nodes Validates the input

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

Deletes a ComponentVersion 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
suspend fun getUser(authorizationContext: GropiusAuthorizationContext): GropiusUser

Gets a GropiusUser based on the userId from the authorizationContext

Link copied to clipboard

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

private suspend fun updateInterfaceSpecificationOnComponentVersion(authorizationContext: GropiusAuthorizationContext, componentVersion: ComponentVersion, interfaceSpecificationId: ID, updateFunction: suspend (Component, InterfaceSpecificationVersion) -> Any)

Helper function for addInterfaceSpecificationToComponentVersion and removeInterfaceSpecificationFromComponentVersion Validates the user has ADMIN permission on the ComponentVersion Validates that the ComponentVersion is part of the same Component as the InterfaceSpecificationVersion Creates a ComponentGraphUpdater and calls updateFunction with it Saves the updatedNodes and deletes the deletedNodes