org.intermine.dwr
Class AjaxServices

java.lang.Object
  extended by org.intermine.dwr.AjaxServices

public class AjaxServices
extends java.lang.Object

This class contains the methods called through DWR Ajax


Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
AjaxServices()
           
 
Method Summary
static java.lang.String addTag(java.lang.String tag, java.lang.String taggedObject, java.lang.String type)
          Adds tag and assures that there is only one tag for this combination of tag name, tagged Object and type.
 void addToSortOrder(java.lang.String path, java.lang.String direction)
          Add a Node from the sort order
 java.lang.String changeViewPathDescription(java.lang.String pathString, java.lang.String description)
          Set the description of a view path.
 java.lang.String convertObjects(java.lang.String bagType, java.lang.String bagName, java.lang.String param, java.lang.String selectedValue)
          used on list analysis page to convert list contents to orthologues.
static java.lang.String deleteTag(java.lang.String tagName, java.lang.String tagged, java.lang.String type)
          Deletes tag.
static java.util.List<java.lang.String> deSelectId(java.lang.String deSelectId, java.lang.String tableId)
          remove an Id from the PagedTable
static java.util.Set<java.lang.String> filterByTag(java.lang.String type, java.lang.String tag)
          Returns all objects names tagged with specified tag type and tag name.
static java.util.List<java.lang.String> filterWebSearchables(java.lang.String scope, java.lang.String type, java.util.List<java.lang.String> tags, java.lang.String filterText, java.lang.String filterAction, java.lang.String callId)
          Given a scope, type, tags and some filter text, produce a list of matching WebSearchable, in a format useful in JavaScript.
static java.util.List getColumnSummary(java.lang.String tableName, java.lang.String summaryPath)
          Get the summary for the given column
static java.lang.String getConstraintLogic()
          Get the grouped constraint logic
 java.lang.String[] getContent(java.lang.String suffix, boolean wholeList, java.lang.String field, java.lang.String className)
           
static int getConvertCountForBag(java.lang.String bagName, java.lang.String type)
          For a given bag name and a type different from the bag type, give the number of converted objects
static java.lang.String getNewsRead(java.lang.String rssURI)
          Get the news
static java.util.Set<java.lang.String> getObjectTags(java.lang.String type, java.lang.String tagged)
          Returns all tags by which is specified object tagged.
static EnrichmentWidget getProcessEnrichmentWidget(java.lang.String widgetId, java.lang.String bagName, java.lang.String errorCorrection, java.lang.String max, java.lang.String filters, java.lang.String externalLink, java.lang.String externalLinkLabel)
           
static GraphWidget getProcessGraphWidget(java.lang.String widgetId, java.lang.String bagName, java.lang.String selectedExtraAttribute)
           
static HTMLWidget getProcessHTMLWidget(java.lang.String widgetId, java.lang.String bagName)
           
static TableWidget getProcessTableWidget(java.lang.String widgetId, java.lang.String bagName)
           
static java.lang.Integer getResultsSize(java.lang.String qid)
          Return the number of rows of results from the query with the given query id.
static java.util.Set<java.lang.String> getTags(java.lang.String type)
          Returns all tags of specified tag type together with prefixes of these tags.
 java.lang.String preCompute(java.lang.String templateName)
          Precomputes the given template query
 java.lang.String rename(java.lang.String name, java.lang.String type, java.lang.String reName)
          Rename a element such as history, name, bag
 void reorder(java.lang.String newOrder, java.lang.String oldOrder)
          AJAX request - reorder view.
 void reorderConstraints(java.lang.String newOrder, java.lang.String oldOrder)
          AJAX request - reorder the constraints.
 java.lang.String saveBagDescription(java.lang.String bagName, java.lang.String description)
          For a given bag, set its description
static void saveToggleState(java.lang.String elementId, boolean opened)
          Saves information, that some element was toggled - displayed or hidden.
static void selectAll(int index, java.lang.String tableId)
          Select all the elements in a PagedTable
static java.util.List<java.lang.String> selectId(java.lang.String selectedId, java.lang.String tableId, java.lang.String columnIndex)
          Add an ID to the PagedTable selection
static void setConstraintLogic(java.lang.String expression)
          Set the constraint logic on a query to be the given expression.
 void setFavourite(java.lang.String name, java.lang.String type, boolean isFavourite)
          Creates a favourite Tag for the given templateName
static void setState(java.lang.String name, java.lang.String value)
          Set state that should be saved during the session.
 java.lang.String summarise(java.lang.String templateName)
          Summarises the given template query.
static java.lang.String validateBagName(java.lang.String bagName)
          validate bag upload
static java.lang.String validateBagOperations(java.lang.String bagName, java.lang.String[] selectedBags, java.lang.String operation)
          validation that happens before new bag is saved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

AjaxServices

public AjaxServices()
Method Detail

setFavourite

public void setFavourite(java.lang.String name,
                         java.lang.String type,
                         boolean isFavourite)
Creates a favourite Tag for the given templateName

Parameters:
name - the name of the template we want to set as a favourite
type - type of tag (bag or template)
isFavourite - whether or not this item is currently a favourite

preCompute

public java.lang.String preCompute(java.lang.String templateName)
Precomputes the given template query

Parameters:
templateName - the template query name
Returns:
a String to guarantee the service ran properly

summarise

public java.lang.String summarise(java.lang.String templateName)
Summarises the given template query.

Parameters:
templateName - the template query name
Returns:
a String to guarantee the service ran properly

rename

public java.lang.String rename(java.lang.String name,
                               java.lang.String type,
                               java.lang.String reName)
                        throws java.lang.Exception
Rename a element such as history, name, bag

Parameters:
name - the name of the element
type - history, saved, bag
reName - the new name for the element
Returns:
the new name of the element as a String
Throws:
java.lang.Exception - if the application business logic throws an exception

saveBagDescription

public java.lang.String saveBagDescription(java.lang.String bagName,
                                           java.lang.String description)
                                    throws java.lang.Exception
For a given bag, set its description

Parameters:
bagName - the bag
description - the description as entered by the user
Returns:
the description for display on the jsp page
Throws:
java.lang.Exception - an exception

changeViewPathDescription

public java.lang.String changeViewPathDescription(java.lang.String pathString,
                                                  java.lang.String description)
Set the description of a view path.

Parameters:
pathString - the string representation of the path
description - the new description
Returns:
the description, or null if the description was empty

getColumnSummary

public static java.util.List getColumnSummary(java.lang.String tableName,
                                              java.lang.String summaryPath)
                                       throws java.lang.Exception
Get the summary for the given column

Parameters:
summaryPath - the path for the column as a String
tableName - name of column-owning table
Returns:
a collection of rows
Throws:
java.lang.Exception - an exception

getResultsSize

public static java.lang.Integer getResultsSize(java.lang.String qid)
Return the number of rows of results from the query with the given query id. If the size isn't yet available, return null. The query must be started with SessionMethods.startPagedTableCount().

Parameters:
qid - the id
Returns:
the row count or null if not yet available

filterWebSearchables

public static java.util.List<java.lang.String> filterWebSearchables(java.lang.String scope,
                                                                    java.lang.String type,
                                                                    java.util.List<java.lang.String> tags,
                                                                    java.lang.String filterText,
                                                                    java.lang.String filterAction,
                                                                    java.lang.String callId)
Given a scope, type, tags and some filter text, produce a list of matching WebSearchable, in a format useful in JavaScript. Each element of the returned List is a List containing a WebSearchable name, a score (from Lucene) and a string with the matching parts of the description highlighted.

Parameters:
scope - the scope (from TemplateHelper.GLOBAL_TEMPLATE or TemplateHelper.USER_TEMPLATE, even though not all WebSearchables are templates)
type - the type (from TagTypes)
tags - the tags to filter on
filterText - the text to pass to Lucene
filterAction - toggles favourites filter off an on; will be blank or 'favourites'
callId - unique id
Returns:
a List of Lists

getConvertCountForBag

public static int getConvertCountForBag(java.lang.String bagName,
                                        java.lang.String type)
For a given bag name and a type different from the bag type, give the number of converted objects

Parameters:
bagName - the name of the bag
type - the type to convert to
Returns:
the number of converted objects

saveToggleState

public static void saveToggleState(java.lang.String elementId,
                                   boolean opened)
Saves information, that some element was toggled - displayed or hidden.

Parameters:
elementId - element id
opened - new aspect state

setState

public static void setState(java.lang.String name,
                            java.lang.String value)
Set state that should be saved during the session.

Parameters:
name - name of state
value - value of state

validateBagName

public static java.lang.String validateBagName(java.lang.String bagName)
validate bag upload

Parameters:
bagName - name of new bag to be validated
Returns:
error msg to display, if any

validateBagOperations

public static java.lang.String validateBagOperations(java.lang.String bagName,
                                                     java.lang.String[] selectedBags,
                                                     java.lang.String operation)
validation that happens before new bag is saved

Parameters:
bagName - name of new bag
selectedBags - bags involved in operation
operation - which operation is taking place - delete, union, intersect or subtract
Returns:
error msg, if any

getProcessGraphWidget

public static GraphWidget getProcessGraphWidget(java.lang.String widgetId,
                                                java.lang.String bagName,
                                                java.lang.String selectedExtraAttribute)
Parameters:
widgetId - unique id for this widget
bagName - name of list
selectedExtraAttribute - extra attribute (like organism)
Returns:
graph widget

getProcessHTMLWidget

public static HTMLWidget getProcessHTMLWidget(java.lang.String widgetId,
                                              java.lang.String bagName)
Parameters:
widgetId - unique id for this widget
bagName - name of list
Returns:
graph widget

getProcessTableWidget

public static TableWidget getProcessTableWidget(java.lang.String widgetId,
                                                java.lang.String bagName)
Parameters:
widgetId - unique ID for this widget
bagName - name of list
Returns:
table widget

getProcessEnrichmentWidget

public static EnrichmentWidget getProcessEnrichmentWidget(java.lang.String widgetId,
                                                          java.lang.String bagName,
                                                          java.lang.String errorCorrection,
                                                          java.lang.String max,
                                                          java.lang.String filters,
                                                          java.lang.String externalLink,
                                                          java.lang.String externalLinkLabel)
Parameters:
widgetId - unique ID for each widget
bagName - name of list
errorCorrection - error correction method to use
max - maximum value to display
filters - list of strings used to filter widget results, ie Ontology
externalLink - link to external datasource
externalLinkLabel - name of external datasource.
Returns:
enrichment widget

selectId

public static java.util.List<java.lang.String> selectId(java.lang.String selectedId,
                                                        java.lang.String tableId,
                                                        java.lang.String columnIndex)
Add an ID to the PagedTable selection

Parameters:
selectedId - the id
tableId - the identifier for the PagedTable
columnIndex - the column of the selected id
Returns:
the field values of the first selected objects

deSelectId

public static java.util.List<java.lang.String> deSelectId(java.lang.String deSelectId,
                                                          java.lang.String tableId)
remove an Id from the PagedTable

Parameters:
deSelectId - the ID to remove from the selection
tableId - the PagedTable identifier
Returns:
the field values of the first selected objects

selectAll

public static void selectAll(int index,
                             java.lang.String tableId)
Select all the elements in a PagedTable

Parameters:
index - the index of the selected column
tableId - the PagedTable identifier

reorder

public void reorder(java.lang.String newOrder,
                    java.lang.String oldOrder)
AJAX request - reorder view.

Parameters:
newOrder - the new order as a String
oldOrder - the previous order as a String

reorderConstraints

public void reorderConstraints(java.lang.String newOrder,
                               java.lang.String oldOrder)
AJAX request - reorder the constraints.

Parameters:
newOrder - the new order as a String
oldOrder - the previous order as a String

addToSortOrder

public void addToSortOrder(java.lang.String path,
                           java.lang.String direction)
                    throws java.lang.Exception
Add a Node from the sort order

Parameters:
path - the Path as a String
direction - the direction to sort by
Throws:
java.lang.Exception - if the application business logic throws

getNewsRead

public static java.lang.String getNewsRead(java.lang.String rssURI)
Get the news

Parameters:
rssURI - the URI of the rss feed
Returns:
the news feed as html

filterByTag

public static java.util.Set<java.lang.String> filterByTag(java.lang.String type,
                                                          java.lang.String tag)
Returns all objects names tagged with specified tag type and tag name.

Parameters:
type - tag type
tag - tag name
Returns:
objects names

addTag

public static java.lang.String addTag(java.lang.String tag,
                                      java.lang.String taggedObject,
                                      java.lang.String type)
Adds tag and assures that there is only one tag for this combination of tag name, tagged Object and type.

Parameters:
tag - tag name
taggedObject - object id that is tagged by this tag
type - tag type
Returns:
'ok' string if succeeded else error string

deleteTag

public static java.lang.String deleteTag(java.lang.String tagName,
                                         java.lang.String tagged,
                                         java.lang.String type)
Deletes tag.

Parameters:
tagName - tag name
tagged - id of tagged object
type - tag type
Returns:
'ok' string if succeeded else error string

getTags

public static java.util.Set<java.lang.String> getTags(java.lang.String type)
Returns all tags of specified tag type together with prefixes of these tags. For instance: for tag 'bio:experiment' it automatically adds 'bio' tag.

Parameters:
type - tag type
Returns:
tags

getObjectTags

public static java.util.Set<java.lang.String> getObjectTags(java.lang.String type,
                                                            java.lang.String tagged)
Returns all tags by which is specified object tagged.

Parameters:
type - tag type
tagged - id of tagged object
Returns:
tags

setConstraintLogic

public static void setConstraintLogic(java.lang.String expression)
                               throws PathException
Set the constraint logic on a query to be the given expression.

Parameters:
expression - the constraint logic for the query
Throws:
PathException - if the query is invalid

getConstraintLogic

public static java.lang.String getConstraintLogic()
Get the grouped constraint logic

Returns:
a list representing the grouped constraint logic

getContent

public java.lang.String[] getContent(java.lang.String suffix,
                                     boolean wholeList,
                                     java.lang.String field,
                                     java.lang.String className)
Parameters:
suffix - string of input before request for more results
wholeList - whether or not to show the entire list or a truncated version
field - field name from the table for the lucene search
className - class name (table in the database) for lucene search
Returns:
an array of values for this classname.field

convertObjects

public java.lang.String convertObjects(java.lang.String bagType,
                                       java.lang.String bagName,
                                       java.lang.String param,
                                       java.lang.String selectedValue)
                                throws java.io.UnsupportedEncodingException
used on list analysis page to convert list contents to orthologues. then forwarded to another intermine instance

Parameters:
bagType - class of bag
bagName - name of bag
param - name of parameter value, eg. `orthologue`
selectedValue - orthologue organism
Returns:
converted list of orthologues
Throws:
java.io.UnsupportedEncodingException - bad encoding