Class ListUploadService
- java.lang.Object
-
- org.intermine.webservice.server.WebService
-
- org.intermine.webservice.server.core.JSONService
-
- org.intermine.webservice.server.lists.AbstractListService
-
- org.intermine.webservice.server.lists.AuthenticatedListService
-
- org.intermine.webservice.server.lists.ListMakerService
-
- org.intermine.webservice.server.lists.ListUploadService
-
- Direct Known Subclasses:
ListAppendService
,ListUpgradingService
public class ListUploadService extends ListMakerService
A class to create a new list with via a set of identifiers uploaded by a user.- Author:
- Alexis Kalderimis.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BAG_QUERY_MAX_BATCH_SIZE
The maximum number of ids to query for each batch.protected static java.lang.String
PLAIN_TEXT
static java.lang.String
USAGE
A usage string to return for bad requests.-
Fields inherited from class org.intermine.webservice.server.lists.ListMakerService
LIST_TYPE_KEY
-
Fields inherited from class org.intermine.webservice.server.lists.AbstractListService
LIST_DESCRIPTION_KEY, LIST_ID_KEY, LIST_NAME_KEY, LIST_SIZE_KEY
-
Fields inherited from class org.intermine.webservice.server.core.JSONService
bagManager, model
-
Fields inherited from class org.intermine.webservice.server.WebService
dataPackageOutput, DEFAULT_CALLBACK, im, os, out, output, request, response, webProperties
-
-
Constructor Summary
Constructors Constructor Description ListUploadService(InterMineAPI im)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addIdsToList(java.util.Collection<? extends java.lang.String> ids, InterMineBag bag, java.lang.String type, java.lang.String extraFieldValue, java.util.Set<java.lang.String> unmatchedIds, java.util.Collection<java.lang.String> acceptableIssues)
Adds objects to the a bag for the matches against a set of identifiers.protected java.util.Map<java.lang.String,java.lang.Object>
getHeaderAttributes()
Gets the header attributes on the output object.protected ListCreationInput
getInput()
Parse the parameters for this request.protected org.apache.commons.lang.text.StrMatcher
getMatcher()
Get the String Matcher for parsing the list of identifiers.protected java.lang.String
getNewListType(ListInput input)
Calculate the type of the new list.protected java.io.BufferedReader
getReader(javax.servlet.http.HttpServletRequest request)
Get the reader for the identifiers uploaded with this request.protected void
makeList(ListInput listInput, java.lang.String type, Profile profile, java.util.Set<java.lang.String> temporaryBagNamesAccumulator)
Make the list requested by the user.protected void
processIdentifiers(java.lang.String type, ListCreationInput input, java.util.Set<java.lang.String> ids, java.util.Set<java.lang.String> unmatchedIds, InterMineBag tempBag)
Process the identifiers.protected boolean
requestIsOfSuitableType()
Determine if we should service this request.protected void
setListId(java.lang.Integer id)
Sets the id of the list on the header attributes.protected void
setListSize(java.lang.Integer size)
Sets the size of the list on the header attributes.-
Methods inherited from class org.intermine.webservice.server.lists.ListMakerService
canServe, execute, getDefaultFormat, initialiseDelendumAccumulator, validateState
-
Methods inherited from class org.intermine.webservice.server.lists.AbstractListService
getClassesForBags
-
Methods inherited from class org.intermine.webservice.server.core.JSONService
addOutputInfo, addResultEntries, addResultEntries, addResultEntry, addResultEntry, addResultItem, addResultItem, addResultValue, addResultValue, addResultValue, getResultsKey, lazyList, postInit
-
Methods inherited from class org.intermine.webservice.server.WebService
cleanUp, formatIsFlatFile, formatIsJSON, formatIsJSONP, formatIsXML, getAuthenticatedUser, getCallback, getColumnHeaderStyle, getDefaultFileName, getDefaultOutput, getDefaultOutput, getExtension, getFormat, getIntParameter, getIntParameter, getLineBreak, getListManager, getOptionalParameter, getOptionalParameter, getPermission, getProperty, getRawOutput, getRequestFileName, getRequiredParameter, hasCallback, initState, isAuthenticated, isGzip, isUncompressed, isZip, makeJSONOutput, makeXMLOutput, service, setFormat, setNameSpace, wantsColumnHeaders, wantsDataPackage
-
-
-
-
Field Detail
-
USAGE
public static final java.lang.String USAGE
A usage string to return for bad requests.- See Also:
- Constant Field Values
-
BAG_QUERY_MAX_BATCH_SIZE
public static final int BAG_QUERY_MAX_BATCH_SIZE
The maximum number of ids to query for each batch.- See Also:
- Constant Field Values
-
PLAIN_TEXT
protected static final java.lang.String PLAIN_TEXT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ListUploadService
public ListUploadService(InterMineAPI im)
Constructor- Parameters:
im
- A reference to the main settings bundle
-
-
Method Detail
-
getHeaderAttributes
protected java.util.Map<java.lang.String,java.lang.Object> getHeaderAttributes()
Gets the header attributes on the output object.- Overrides:
getHeaderAttributes
in classListMakerService
- Returns:
- A map of header attributes for JSON output.
-
setListSize
protected void setListSize(java.lang.Integer size)
Sets the size of the list on the header attributes.- Parameters:
size
- The size of the newly created list.
-
setListId
protected void setListId(java.lang.Integer id)
Sets the id of the list on the header attributes.- Parameters:
id
- The id of the newly created list.
-
getMatcher
protected org.apache.commons.lang.text.StrMatcher getMatcher()
Get the String Matcher for parsing the list of identifiers.- Returns:
- The matcher to use.
-
getNewListType
protected java.lang.String getNewListType(ListInput input)
Description copied from class:ListMakerService
Calculate the type of the new list.- Specified by:
getNewListType
in classListMakerService
- Parameters:
input
- The parsed parameter input.- Returns:
- The type name.
-
getInput
protected ListCreationInput getInput()
Parse the parameters for this request.- Overrides:
getInput
in classAbstractListService
- Returns:
- A parsed representation of the parameters.
-
makeList
protected void makeList(ListInput listInput, java.lang.String type, Profile profile, java.util.Set<java.lang.String> temporaryBagNamesAccumulator) throws java.lang.Exception
Description copied from class:ListMakerService
Make the list requested by the user.- Specified by:
makeList
in classListMakerService
- Parameters:
listInput
- The parsed parameter input.type
- The type of the new list.profile
- The profile to save the list in.temporaryBagNamesAccumulator
- The accumulator to store the list of bags to delete.- Throws:
java.lang.Exception
- If something goes wrong.
-
processIdentifiers
protected void processIdentifiers(java.lang.String type, ListCreationInput input, java.util.Set<java.lang.String> ids, java.util.Set<java.lang.String> unmatchedIds, InterMineBag tempBag) throws java.io.IOException, java.lang.ClassNotFoundException, InterMineException, ObjectStoreException
Process the identifiers.- Parameters:
type
- The type of thing these identifiers are.input
- The creation input.ids
- The identifiers.unmatchedIds
- A collector for unmatched identifiers.tempBag
- The temporary bag to add results to.- Throws:
java.io.IOException
- If we can't from the request.java.lang.ClassNotFoundException
- if the type is not valid.InterMineException
- If something goes wrong building the bag.ObjectStoreException
- If there is a problem on the database level.
-
getReader
protected java.io.BufferedReader getReader(javax.servlet.http.HttpServletRequest request)
Get the reader for the identifiers uploaded with this request.- Parameters:
request
- The request object.- Returns:
- A buffered reader for reading the identifiers.
-
requestIsOfSuitableType
protected boolean requestIsOfSuitableType()
Determine if we should service this request.- Returns:
- whether or not this request's content is of the right type for us to read it.
-
addIdsToList
protected void addIdsToList(java.util.Collection<? extends java.lang.String> ids, InterMineBag bag, java.lang.String type, java.lang.String extraFieldValue, java.util.Set<java.lang.String> unmatchedIds, java.util.Collection<java.lang.String> acceptableIssues) throws java.lang.ClassNotFoundException, InterMineException, ObjectStoreException
Adds objects to the a bag for the matches against a set of identifiers.- Parameters:
ids
- A collection of identifiersbag
- The bag to add the objects totype
- The type of this bagextraFieldValue
- An extra value for disambiguation.unmatchedIds
- An accumulator to store the failed matches.acceptableIssues
- the list of issues that are OK to ignore.- Throws:
java.lang.ClassNotFoundException
- if the type is not a valid class.InterMineException
- If something goes wrong building the bag.ObjectStoreException
- If there is a problem on the database level.
-
-