Package org.intermine.api.template
Class TemplateHelper
- java.lang.Object
-
- org.intermine.api.template.TemplateHelper
-
public final class TemplateHelper extends java.lang.Object
Static helper routines related to templates.- Author:
- Thomas Riley, Richard Smith
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
apiTemplateMapToJson(InterMineAPI im, java.util.Map<java.lang.String,ApiTemplate> templates, Profile profile)
Helper routine for serialising a map of templates to JSON.static java.lang.String
apiTemplateMapToXml(java.util.Map<java.lang.String,ApiTemplate> templates, int version)
Serialse a map of templates to XML.static TemplateQuery
removeDirectAttributesFromView(TemplateQuery tq)
Removed from the view all the direct attributes that aren't editable constraintsstatic java.lang.String
templateMapToXml(java.util.Map<java.lang.String,TemplateQuery> templates, int version)
Given a Map of TemplateQueries (mapping from template name to TemplateQuery) return a string containing each template seriaised as XML.static java.util.Map<java.lang.String,ApiTemplate>
upcast(java.util.Map<java.lang.String,TemplateQuery> templates)
Transform a map of templates into a map of API templates.static java.util.Map<java.lang.String,TemplateQuery>
xmlToTemplateMap(java.lang.String xml, java.util.Map<java.lang.String,InterMineBag> savedBags, int version)
Parse templates in XML format and return a map from template name to TemplateQuery.
-
-
-
Method Detail
-
templateMapToXml
public static java.lang.String templateMapToXml(java.util.Map<java.lang.String,TemplateQuery> templates, int version)
Given a Map of TemplateQueries (mapping from template name to TemplateQuery) return a string containing each template seriaised as XML. The root element will be atemplate-queries
element.- Parameters:
templates
- map from template name to TemplateQueryversion
- the version number of the XML format- Returns:
- all template queries serialised as XML
- See Also:
TemplateQuery
-
removeDirectAttributesFromView
public static TemplateQuery removeDirectAttributesFromView(TemplateQuery tq)
Removed from the view all the direct attributes that aren't editable constraints- Parameters:
tq
- The template to remove attributes from.- Returns:
- altered template query
-
apiTemplateMapToXml
public static java.lang.String apiTemplateMapToXml(java.util.Map<java.lang.String,ApiTemplate> templates, int version)
Serialse a map of templates to XML.- Parameters:
templates
- The templates to serialise.version
- The UserProfile version to use.- Returns:
- An XML serialise.
-
upcast
public static java.util.Map<java.lang.String,ApiTemplate> upcast(java.util.Map<java.lang.String,TemplateQuery> templates)
Transform a map of templates into a map of API templates.- Parameters:
templates
- The original, non-api templates.- Returns:
- templates brought into the realm of the API.
-
apiTemplateMapToJson
public static java.lang.String apiTemplateMapToJson(InterMineAPI im, java.util.Map<java.lang.String,ApiTemplate> templates, Profile profile)
Helper routine for serialising a map of templates to JSON.- Parameters:
templates
- The map of templates to serialise.im
- intermine APIprofile
- user that owns these templates. Could be NULL- Returns:
- A JSON string.
-
xmlToTemplateMap
public static java.util.Map<java.lang.String,TemplateQuery> xmlToTemplateMap(java.lang.String xml, java.util.Map<java.lang.String,InterMineBag> savedBags, int version) throws java.lang.Exception
Parse templates in XML format and return a map from template name to TemplateQuery.- Parameters:
xml
- the template queries in xml formatsavedBags
- Map from bag name to bagversion
- the version of the xml format, an attribute on ProfileManager- Returns:
- Map from template name to TemplateQuery
- Throws:
java.lang.Exception
- when a parse exception occurs (wrapped in a RuntimeException)
-
-