Package org.intermine.dwr
Class AjaxServices
- java.lang.Object
-
- org.intermine.dwr.AjaxServices
-
public class AjaxServices extends java.lang.Object
This class contains the methods called through DWR Ajax- Author:
- Xavier Watkins, Daniela Butano
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.log4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description AjaxServices()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 orderjava.lang.String
addUserToShareBag(java.lang.String userName, java.lang.String bagName)
Share the bag given in input with the user which userName is input and send emailjava.lang.String
changeViewPathDescription(java.lang.String pathString, java.lang.String description)
Set the description of a view path.java.lang.String
deleteApiKey(java.lang.String username)
Delete a user's API key, thus disabling webservice access.static java.lang.String
deleteTag(java.lang.String tagName, java.lang.String tagged, java.lang.String type)
Deletes tag.java.lang.String
deleteUserToShareBag(java.lang.String userName, java.lang.String bagName)
Un-share the bag given in input with the user which userName is inputstatic java.util.List<java.lang.String>
deSelectId(java.lang.String deSelectId, java.lang.String tableId)
remove an Id from the PagedTablestatic java.util.List<? extends java.lang.Object>
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.java.lang.String
generateApiKey(java.lang.String username)
Generate a new API key for a given user.static java.util.List<? extends java.lang.Object>
getColumnSummary(java.lang.String tableName, java.lang.String summaryPath)
Get the summary for the given columnstatic java.lang.String
getConstraintLogic()
Get the grouped constraint logicjava.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 objectsstatic java.lang.String
getCustomConverterCounts(java.lang.String bagName, java.lang.String converterName)
For a list and a converter, return types and related countsstatic java.util.Collection<PartnerLink>
getFriendlyMineLinks(java.lang.String mineName, java.lang.String domains, java.lang.String idents)
used on REPORT page For a gene, generate links to other intermines.static java.lang.String
getNewsPreview(java.lang.String rssURL)
Work as a proxy for fetching remote file (RSS)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 java.util.Map<java.lang.String,java.lang.Object>
getRatDiseases(java.lang.String orthologues)
Return list of disease ontology terms associated with list of provided rat genes.static java.lang.Integer
getResultsSize(java.lang.String qid)
Return the number of rows of results from the query with the given query id.java.lang.String
getSavedBagStatus()
This method gets the latest bags from the session (SessionMethods) and returns them in JSONstatic java.lang.String
getSingleUseKey()
Return the single use API key for the current profilestatic java.util.Set<java.lang.String>
getTags(java.lang.String type)
Returns all tags of specified tag type together with prefixes of these tags.static java.lang.String
getToggledElements()
This method gets a map of ids of elements that were in the past (during session) toggled and returns them in JSONjava.util.Collection<java.lang.String>
getUsersSharingBag(java.lang.String bagName)
Return the list of users who have access to this bag because it has been shared with them.java.lang.String
preCompute(java.lang.String templateName)
Precomputes the given template queryjava.lang.String
rename(java.lang.String name, java.lang.String type, java.lang.String reName)
Rename a element such as history, name, bagvoid
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 descriptionstatic 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 PagedTablestatic 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 selectionstatic java.lang.String
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 templateNamestatic 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.void
updateTemplate(java.lang.String field, java.lang.String value)
Update with the value given in input the field of the previous template saved into the sessionstatic java.lang.String
validateBagName(java.lang.String bagName)
validate bag uploadstatic java.lang.String
validateBagOperations(java.lang.String bagName, java.lang.String[] selectedBags, java.lang.String operation)
validation that happens before new bag is saved
-
-
-
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 favouritetype
- 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 elementtype
- history, saved, bagreName
- 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
-
generateApiKey
public java.lang.String generateApiKey(java.lang.String username) throws java.lang.Exception
Generate a new API key for a given user.- Parameters:
username
- the user to generate the key for.- Returns:
- A new API key, or null if something untoward happens.
- Throws:
java.lang.Exception
- an exception.
-
deleteApiKey
public java.lang.String deleteApiKey(java.lang.String username) throws java.lang.Exception
Delete a user's API key, thus disabling webservice access. A message "deleted" is returned to confirm success.- Parameters:
username
- The user whose key we should delete.- Returns:
- A confirmation string.
- Throws:
java.lang.Exception
- if somethign bad happens
-
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 bagdescription
- 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 pathdescription
- the new description- Returns:
- the description, or null if the description was empty
-
getToggledElements
public static java.lang.String getToggledElements()
This method gets a map of ids of elements that were in the past (during session) toggled and returns them in JSON- Returns:
- JSON serialized to a String
- Throws:
org.json.JSONException
-
getColumnSummary
public static java.util.List<? extends java.lang.Object> 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 StringtableName
- 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<? extends java.lang.Object> 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.
ie - search for "
me
":[ [ "Some name", 0.123, "So<i>me</i> name" ], ... ]
- Parameters:
scope
- the scope (either Scope.GLOBAL or Scope.USER).type
- the type (from TagTypes).tags
- the tags to filter on.filterText
- the text to pass to Lucene.filterAction
- toggles favourites filter off and 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 bagtype
- the type to convert to- Returns:
- the number of converted objects
-
getCustomConverterCounts
public static java.lang.String getCustomConverterCounts(java.lang.String bagName, java.lang.String converterName)
For a list and a converter, return types and related counts- Parameters:
bagName
- the name of the bagconverterName
- Java class that processes the data- Returns:
- the number of converted objects
-
getFriendlyMineLinks
public static java.util.Collection<PartnerLink> getFriendlyMineLinks(java.lang.String mineName, java.lang.String domains, java.lang.String idents)
used on REPORT page For a gene, generate links to other intermines. Include gene and orthologues. Returns NULL if no values found. It's possible that the identifier in the local mine will match more than one entry in the remote mine but this will be handled by the portal of the remote mine.- Parameters:
mineName
- name of mine to querydomains
- The domains the domains these identifiers are valid for (eg. organisms).idents
- The external object identifiers.- Returns:
- the links to friendly intermines
-
getRatDiseases
public static java.util.Map<java.lang.String,java.lang.Object> getRatDiseases(java.lang.String orthologues)
Return list of disease ontology terms associated with list of provided rat genes. Returns JSONObject as string with ID (intermine ID) and name (ontologyTerm.name)- Parameters:
orthologues
- list of rat genes- Returns:
- JSONObject of the shape {status :: string, mineUrl :: string, results :: [[string]]}
-
saveToggleState
public static void saveToggleState(java.lang.String elementId, boolean opened)
Saves information, that some element was toggled - displayed or hidden.- Parameters:
elementId
- element idopened
- 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 statevalue
- 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 listselectedBags
- bags involved in operationoperation
- which operation is taking place - delete, union, intersect or subtract- Returns:
- error msg, if any
-
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 idtableId
- the identifier for the PagedTablecolumnIndex
- 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 selectiontableId
- 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 columntableId
- 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 StringoldOrder
- 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 StringoldOrder
- 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 Stringdirection
- the direction to sort by- Throws:
java.lang.Exception
- if the application business logic throws
-
getNewsPreview
public static java.lang.String getNewsPreview(java.lang.String rssURL)
Work as a proxy for fetching remote file (RSS)- Parameters:
rssURL
- the url- Returns:
- String representation of a file
-
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 nametaggedObject
- object id that is tagged by this tagtype
- 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 nametagged
- id of tagged objecttype
- 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 typetagged
- id of tagged object- Returns:
- tags
-
getSingleUseKey
public static java.lang.String getSingleUseKey()
Return the single use API key for the current profile- Returns:
- the single use APi key
-
setConstraintLogic
public static java.lang.String 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- Returns:
- messages to display in the jsp page
- 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 resultswholeList
- whether or not to show the entire list or a truncated versionfield
- field name from the table for the lucene searchclassName
- class name (table in the database) for lucene search- Returns:
- an array of values for this classname.field
-
getSavedBagStatus
public java.lang.String getSavedBagStatus() throws org.json.JSONException
This method gets the latest bags from the session (SessionMethods) and returns them in JSON- Returns:
- JSON serialized to a String
- Throws:
org.json.JSONException
- json exception
-
updateTemplate
public void updateTemplate(java.lang.String field, java.lang.String value)
Update with the value given in input the field of the previous template saved into the session- Parameters:
field
- the field to updatevalue
- the value
-
addUserToShareBag
public java.lang.String addUserToShareBag(java.lang.String userName, java.lang.String bagName)
Share the bag given in input with the user which userName is input and send email- Parameters:
userName
- the user which the bag has to be shared withbagName
- the bag name to share- Returns:
- 'ok' string if succeeded else error string
-
deleteUserToShareBag
public java.lang.String deleteUserToShareBag(java.lang.String userName, java.lang.String bagName)
Un-share the bag given in input with the user which userName is input- Parameters:
userName
- the user which the bag has to be un-shared withbagName
- the bag name to un-share- Returns:
- 'ok' string if succeeded else error string
-
getUsersSharingBag
public java.util.Collection<java.lang.String> getUsersSharingBag(java.lang.String bagName)
Return the list of users who have access to this bag because it has been shared with them.- Parameters:
bagName
- the bag name that the users share- Returns:
- the list of users
-
-