Class TemplateWrapper


  • public class TemplateWrapper
    extends java.lang.Object
    The wrapper that manages the job templates
    • Constructor Detail

      • TemplateWrapper

        public TemplateWrapper​(TemplateForm templateForm,
                               Account account,
                               TemplateRepository templateRepository,
                               TDetectorRepository tDetectorRepository)
                        throws NotTemplateOwner
        Initialise the wrapper using the form to create a new template
        Parameters:
        templateForm - the form to use
        account - the account of current user
        templateRepository - the database repository
        tDetectorRepository - the database repository
        Throws:
        NotTemplateOwner - if the user is not the owner of the template
      • TemplateWrapper

        public TemplateWrapper​(long id,
                               Account account,
                               TemplateRepository templateRepository)
                        throws TemplateNotFound
        Initialise the template wrapper using an id to find one in the database
        Parameters:
        id - the id of the template
        account - the account of the current user
        templateRepository - the database repository
        Throws:
        TemplateNotFound - if the template was not found
      • TemplateWrapper

        public TemplateWrapper​(Template template,
                               Account account)
        Initialise the template wrapper using an existing template
        Parameters:
        template - the template to manage
        account - the account of the current user
    • Method Detail

      • getTemplate

        public Template getTemplate()
        Get the template
        Returns:
        the template
      • setTemplate

        public void setTemplate​(Template template)
        Set the template
        Parameters:
        template - the new template
      • isOwner

        public boolean isOwner()
        Whether or not the template is owned by the current user
        Returns:
        the result
      • setOwner

        public void setOwner​(boolean owner)
        Update the isOwned property
        Parameters:
        owner - the new value
      • getOwnerName

        public java.lang.String getOwnerName()
        Get the name of the owner
        Returns:
        the name
      • isPublic

        public boolean isPublic()
        Whether or not the template is public
        Returns:
        the result
      • getDetectors

        public java.util.List<DetectorWrapper> getDetectors()
        Get the list of detector wrappers active in the template
        Returns:
        the list
      • update

        public void update​(TemplateForm templateForm,
                           TemplateRepository templateRepository,
                           TDetectorRepository templateDetectorRepository)
                    throws NotTemplateOwner
        Update the template using the form supplied
        Parameters:
        templateForm - the form to use
        templateRepository - the database repository
        templateDetectorRepository - the database repository
        Throws:
        NotTemplateOwner - if the user is not the template owner
      • copy

        public Template copy​(AccountWrapper account,
                             TemplateRepository templateRepository,
                             TDetectorRepository tDetectorRepository,
                             TParameterRepository tParameterRepository)
        Make a copy the template
        Parameters:
        account - the account of the current user
        templateRepository - the database repository
        tDetectorRepository - the database repository
        tParameterRepository - the database repository
        Returns:
        the new template
      • findByAccountAndPublic

        public static java.util.List<TemplateWrapper> findByAccountAndPublic​(Account account,
                                                                             TemplateRepository templateRepository)
        Get the list of templates that are public or owned by the user
        Parameters:
        account - the account of the current user
        templateRepository - the database repository
        Returns:
        the list of templates
      • findByAccountAndPublicAndLanguage

        public static java.util.List<TemplateWrapper> findByAccountAndPublicAndLanguage​(Account account,
                                                                                        TemplateRepository templateRepository,
                                                                                        java.lang.String language)
        Get the list of templates that are public, owned by the user and filter by the language supplied
        Parameters:
        account - the account of the current user
        templateRepository - the database repository
        language - the language to filter by
        Returns:
        the list of templates