Class InstanceMakerManager


  • public class InstanceMakerManager
    extends Object
    Logic to manage model sharing
    Author:
    mikkelvestergaard
    • Constructor Detail

      • InstanceMakerManager

        public InstanceMakerManager()
    • Method Detail

      • assertAndGetInstanceMaker

        public InstanceMaker assertAndGetInstanceMaker​(Long instanceMakerId)
        Retrieve the instanceMaker. If not found, throw a HttpErrorMessage
        Parameters:
        instanceMakerId - the id of the instanceMaker
        Returns:
        the instanceMaker found
        Throws:
        ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage - if the instanceMaker was not found
      • getInstanceMakersForProject

        public List<InstanceMaker> getInstanceMakersForProject​(Long projectId)
        Retrieve all instanceMakers for a project
        Parameters:
        projectId - the id of the project
        Returns:
        list of instanceMakers
      • getUsersForProject

        public List<User> getUsersForProject​(Long projectId)
        Retrieve all users of the instanceMakers
        Parameters:
        projectId - the id of the project
        Returns:
        list of users
      • shareModel

        public InstanceMaker shareModel​(Long modelId,
                                        String email)
        Send a token by email to grant access to use the model.
        Parameters:
        modelId - the id of the model
        email - the address to send the sharing token to
        Returns:
        the pending potential instance maker
      • addAndPersistInstanceMaker

        public InstanceMaker addAndPersistInstanceMaker​(Project model,
                                                        User user)
        Create an instance maker for the model and the user and then persist it in database
        Parameters:
        user - the user
        model - the model
        Returns:
        the brand-new potential instance maker
      • addInstanceMaker

        public InstanceMaker addInstanceMaker​(Project model,
                                              User user)
        Create an instance maker for the model and the user
        Parameters:
        user - the user
        model - the model
        Returns:
        the brand-new potential instance maker
      • findInstanceMakerByProjectAndUser

        public InstanceMaker findInstanceMakerByProjectAndUser​(Project project,
                                                               User user)
        Find the instance maker linked to the given project and the given user.
        Parameters:
        project - the project
        user - the user
        Returns:
        the matching instance makers
      • deleteInstanceMaker

        public void deleteInstanceMaker​(Long instanceMakerId)
        Delete instanceMaker
        Parameters:
        instanceMakerId - id of instanceMaker to delete