Package org.intermine.api.template
Class TemplateManager
- java.lang.Object
-
- org.intermine.api.template.TemplateManager
-
public class TemplateManager extends java.lang.Object
A TemplateManager provides access to all global and/or user templates and methods to fetch them by type, etc.- Author:
- Richard Smith
-
-
Constructor Summary
Constructors Constructor Description TemplateManager(Profile superProfile)
The TemplateManager references the super user profile to fetch global templates.TemplateManager(Profile superProfile, TemplateTracker templateTracker)
The TemplateManager references the super user profile to fetch global templates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ApiTemplate>
getAspectTemplates(java.lang.String aspect)
Get public templates for a particular aspect.java.util.List<ApiTemplate>
getAspectTemplates(java.lang.String aspectTag, java.lang.Integer size)
Get public templates for a particular aspect.java.util.List<ApiTemplate>
getConversionTemplates()
Return template queries used for converting between types in bag upload and lookup queries, these are Superuser templates that have been tagged with TagNames.IM_CONVERTER.ApiTemplate
getGlobalTemplate(java.lang.String templateName)
Fetch a global template by name.java.util.Map<java.lang.String,ApiTemplate>
getGlobalTemplates()
Return a map from template name to template query containing superuser templates that are tagged as public.java.util.Map<java.lang.String,ApiTemplate>
getGlobalTemplates(boolean filterOutAdmin)
Return a map from template name to template query containing superuser templates that are tagged as public.java.util.List<java.lang.String>
getMostPopularTemplateOrder(java.lang.Integer size)
Return the list of public templates ordered by rank descendant.java.util.List<java.lang.String>
getMostPopularTemplateOrder(java.lang.String userName, java.lang.String sessionId, java.lang.Integer size)
Return the template list ordered by rank descendant for the user/sessionid specified in the inputjava.util.List<ApiTemplate>
getPopularTemplatesByAspect(java.lang.String aspectTag, int size)
Return the template list for a particular aspect given in input, ordered by rank descendantjava.util.List<ApiTemplate>
getPopularTemplatesByAspect(java.lang.String aspectTag, int size, java.lang.String userName, java.lang.String sessionId)
Return the template list for a particular aspect, ordered by rank descendant for the user/sessionid specified in the inputjava.util.List<ApiTemplate>
getReportPageTemplatesForAspect(java.lang.String aspect, java.util.Set<java.lang.String> allClasses)
Get a list of template queries that should appear on report pages for the given type under the specified aspect.java.util.Map<java.lang.String,ApiTemplate>
getSystemTemplates()
Return template queries used for converting between types in bag upload and lookup queries, these are Superuser templates that have been tagged with TagNames.IM_CONVERTER.java.util.List<Tag>
getTags(ApiTemplate template, Profile profile)
For a (public or private) template, return all the tags.ApiTemplate
getTemplate(Profile profile, java.lang.String templateName, java.lang.String scope)
Fetch a template with the scope provided, possible values are defined in Scope class.java.util.Map<java.lang.String,ApiTemplate>
getUserAndGlobalTemplates(Profile profile)
Fetch all user and global templates in a single map for the given user.ApiTemplate
getUserOrGlobalTemplate(Profile profile, java.lang.String templateName)
Fetch a user or global template by name.ApiTemplate
getUserTemplate(Profile profile, java.lang.String templateName)
Fetch a user template by name.java.util.Map<java.lang.String,ApiTemplate>
getValidGlobalTemplates()
Return a map from template name to template query containing superuser templates that are tagged as public and are valid for the current data model.java.util.Map<java.lang.String,ApiTemplate>
getWorkingTemplates()
Fetch all global templates that are valid.java.util.Map<java.lang.String,ApiTemplate>
getWorkingTemplates(Profile profile)
Fetch all user and global templates that are valid.void
invalidateCache()
Empty cache of global valid templates when these change.
-
-
-
Constructor Detail
-
TemplateManager
public TemplateManager(Profile superProfile, TemplateTracker templateTracker)
The TemplateManager references the super user profile to fetch global templates.- Parameters:
superProfile
- the super user profiletemplateTracker
- the template tracker
-
TemplateManager
public TemplateManager(Profile superProfile)
The TemplateManager references the super user profile to fetch global templates.- Parameters:
superProfile
- the super user profile
-
-
Method Detail
-
getGlobalTemplate
public ApiTemplate getGlobalTemplate(java.lang.String templateName)
Fetch a global template by name.- Parameters:
templateName
- name of the template to fetch- Returns:
- the template or null
-
getUserTemplate
public ApiTemplate getUserTemplate(Profile profile, java.lang.String templateName)
Fetch a user template by name.- Parameters:
profile
- the user to fetch the template fromtemplateName
- name of the template to fetch- Returns:
- the template or null
-
getUserOrGlobalTemplate
public ApiTemplate getUserOrGlobalTemplate(Profile profile, java.lang.String templateName)
Fetch a user or global template by name. If there are name collisions the user template take precedence.- Parameters:
profile
- the user to fetch the template fromtemplateName
- name of the template to fetch- Returns:
- the template or null
-
getTemplate
public ApiTemplate getTemplate(Profile profile, java.lang.String templateName, java.lang.String scope)
Fetch a template with the scope provided, possible values are defined in Scope class. If the scope is ALL and there name collisions between user and global templates, the user template takes precedence.- Parameters:
profile
- the user to fetch the template fromtemplateName
- name of the template to fetchscope
- user, global or all templates- Returns:
- the template or null
-
getUserAndGlobalTemplates
public java.util.Map<java.lang.String,ApiTemplate> getUserAndGlobalTemplates(Profile profile)
Fetch all user and global templates in a single map for the given user. If there are naming collisions between user and global templates user templates take precedence.- Parameters:
profile
- the user to fetch templates- Returns:
- a map of template name to template query, the map will be empty if no templates found
-
getWorkingTemplates
public java.util.Map<java.lang.String,ApiTemplate> getWorkingTemplates(Profile profile)
Fetch all user and global templates that are valid. These templates can be expected to work with the mine in their current state.- Parameters:
profile
- The user to fetch templates for.- Returns:
- A map of templates and their names.
-
getWorkingTemplates
public java.util.Map<java.lang.String,ApiTemplate> getWorkingTemplates()
Fetch all global templates that are valid. These templates can be expected to work with the mine in their current state.- Returns:
- A map of templates and their names.
-
getReportPageTemplatesForAspect
public java.util.List<ApiTemplate> getReportPageTemplatesForAspect(java.lang.String aspect, java.util.Set<java.lang.String> allClasses)
Get a list of template queries that should appear on report pages for the given type under the specified aspect.- Parameters:
aspect
- the aspect to fetch templates forallClasses
- the type of report page and superclasses- Returns:
- a list of template queries
-
getAspectTemplates
public java.util.List<ApiTemplate> getAspectTemplates(java.lang.String aspect)
Get public templates for a particular aspect.- Parameters:
aspect
- name of aspect tag- Returns:
- a list of template queries
-
getAspectTemplates
public java.util.List<ApiTemplate> getAspectTemplates(java.lang.String aspectTag, java.lang.Integer size)
Get public templates for a particular aspect.- Parameters:
size
- maximum number of templates to return.aspectTag
- name of aspect tag- Returns:
- a list of template queries
-
getTags
public java.util.List<Tag> getTags(ApiTemplate template, Profile profile)
For a (public or private) template, return all the tags. Used in stepZ to put the template in the right data category. If profile is NULL, uses the superuser profile.- Parameters:
template
- template with tagsprofile
- profile of owner of template- Returns:
- the list of tags for the template of interest
-
getValidGlobalTemplates
public java.util.Map<java.lang.String,ApiTemplate> getValidGlobalTemplates()
Return a map from template name to template query containing superuser templates that are tagged as public and are valid for the current data model.- Returns:
- a map from template name to template query
-
invalidateCache
public void invalidateCache()
Empty cache of global valid templates when these change.
-
getGlobalTemplates
public java.util.Map<java.lang.String,ApiTemplate> getGlobalTemplates()
Return a map from template name to template query containing superuser templates that are tagged as public.- Returns:
- a map from template name to template query
-
getGlobalTemplates
public java.util.Map<java.lang.String,ApiTemplate> getGlobalTemplates(boolean filterOutAdmin)
Return a map from template name to template query containing superuser templates that are tagged as public.- Parameters:
filterOutAdmin
- if true, filter out templates tagged with IM_ADMIN- Returns:
- a map from template name to template query
-
getConversionTemplates
public java.util.List<ApiTemplate> getConversionTemplates()
Return template queries used for converting between types in bag upload and lookup queries, these are Superuser templates that have been tagged with TagNames.IM_CONVERTER.- Returns:
- a list of conversion template queries
-
getSystemTemplates
public java.util.Map<java.lang.String,ApiTemplate> getSystemTemplates()
Return template queries used for converting between types in bag upload and lookup queries, these are Superuser templates that have been tagged with TagNames.IM_CONVERTER.- Returns:
- a map of system templates
-
getMostPopularTemplateOrder
public java.util.List<java.lang.String> getMostPopularTemplateOrder(java.lang.Integer size)
Return the list of public templates ordered by rank descendant.- Parameters:
size
- maximum number of templates to return- Returns:
- List of template names
-
getMostPopularTemplateOrder
public java.util.List<java.lang.String> getMostPopularTemplateOrder(java.lang.String userName, java.lang.String sessionId, java.lang.Integer size)
Return the template list ordered by rank descendant for the user/sessionid specified in the input- Parameters:
userName
- the user namesessionId
- the session idsize
- maximum number of templates to return- Returns:
- List of template names
-
getPopularTemplatesByAspect
public java.util.List<ApiTemplate> getPopularTemplatesByAspect(java.lang.String aspectTag, int size)
Return the template list for a particular aspect given in input, ordered by rank descendant- Parameters:
aspectTag
- name of aspect tagsize
- maximum number of templates to return- Returns:
- List of template names
-
getPopularTemplatesByAspect
public java.util.List<ApiTemplate> getPopularTemplatesByAspect(java.lang.String aspectTag, int size, java.lang.String userName, java.lang.String sessionId)
Return the template list for a particular aspect, ordered by rank descendant for the user/sessionid specified in the input- Parameters:
aspectTag
- name of aspect tagsize
- maximum number of templates to returnuserName
- the user namesessionId
- the session id- Returns:
- List of template names
-
-