Class TemplateWrapper
- java.lang.Object
-
- uk.ac.warwick.dcs.sherlock.module.web.data.wrappers.TemplateWrapper
-
public class TemplateWrapper extends java.lang.Object
The wrapper that manages the job templates
-
-
Constructor Summary
Constructors Constructor Description TemplateWrapper(long id, Account account, TemplateRepository templateRepository)
Initialise the template wrapper using an id to find one in the databaseTemplateWrapper(Template template, Account account)
Initialise the template wrapper using an existing templateTemplateWrapper(TemplateForm templateForm, Account account, TemplateRepository templateRepository, TDetectorRepository tDetectorRepository)
Initialise the wrapper using the form to create a new template
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Template
copy(AccountWrapper account, TemplateRepository templateRepository, TDetectorRepository tDetectorRepository, TParameterRepository tParameterRepository)
Make a copy the templatevoid
delete(TemplateRepository templateRepository)
Delete the templatestatic java.util.List<TemplateWrapper>
findByAccountAndPublic(Account account, TemplateRepository templateRepository)
Get the list of templates that are public or owned by the userstatic 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 suppliedjava.util.List<DetectorWrapper>
getDetectors()
Get the list of detector wrappers active in the templatejava.lang.String
getOwnerName()
Get the name of the ownerTemplate
getTemplate()
Get the templateboolean
isOwner()
Whether or not the template is owned by the current userboolean
isPublic()
Whether or not the template is publicvoid
setOwner(boolean owner)
Update the isOwned propertyvoid
setTemplate(Template template)
Set the templatevoid
update(TemplateForm templateForm, TemplateRepository templateRepository, TDetectorRepository templateDetectorRepository)
Update the template using the form supplied
-
-
-
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 useaccount
- the account of current usertemplateRepository
- the database repositorytDetectorRepository
- 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 templateaccount
- the account of the current usertemplateRepository
- the database repository- Throws:
TemplateNotFound
- if the template was not found
-
-
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 usetemplateRepository
- the database repositorytemplateDetectorRepository
- 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 usertemplateRepository
- the database repositorytDetectorRepository
- the database repositorytParameterRepository
- the database repository- Returns:
- the new template
-
delete
public void delete(TemplateRepository templateRepository) throws NotTemplateOwner
Delete the template- Parameters:
templateRepository
- the database repository- Throws:
NotTemplateOwner
- if the user is not the template owner
-
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 usertemplateRepository
- 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 usertemplateRepository
- the database repositorylanguage
- the language to filter by- Returns:
- the list of templates
-
-