Class JSONService
- java.lang.Object
-
- org.intermine.webservice.server.WebService
-
- org.intermine.webservice.server.core.JSONService
-
- Direct Known Subclasses:
AbstractListService
,AuthenticatorService
,AvailableWidgetsService
,BGPropertiesCreationService
,BGPropertiesDelationService
,BGPropertiesService
,BGPropertiesUpdateService
,BioEntityMarkupService
,BrandingService
,CallbackService
,ChangePasswordService
,Config
,DataService
,Endpoint
,FacetListService
,FacetService
,FeedbackService
,HomePageMarkupService
,IdResolutionService
,JobRemovalService
,JobResultsService
,JobStatusService
,ListResolutionService
,ListShareCreationService
,ListShareDeletionService
,ListShareDetailsService
,ListSharingInvitationAcceptanceService
,ListSharingInvitationDeletionService
,ListSharingInvitationDetailsService
,ListSharingInvitationService
,LoginService
,LogoutService
,Names
,NewUserService
,PermanentURLService
,PossibleValuesService
,PswResetService
,QueryStoreService
,QuickSearch
,ReadWriteJSONService
,RequestPswResetService
,SavedQueryRetrievalService
,SchemaListService
,SequenceService
,SessionService
,SingleTemplateService
,SummaryService
,TemplateTagService
,VersionService
,WebPropertiesService
,WhoAmIService
,WidgetService
public abstract class JSONService extends WebService
A Service that has specialisations for supplying JSON.- Author:
- Alex Kalderimis
-
-
Field Summary
Fields Modifier and Type Field Description protected BagManager
bagManager
protected Model
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 JSONService(InterMineAPI im)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addOutputInfo(java.lang.String key, java.lang.String value)
Add a key value pair to put in the header of json results.protected void
addResultEntries(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.Object>> entries)
protected void
addResultEntries(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.Object>> entries, boolean hasMore)
Output a bunch of entries.protected void
addResultEntry(java.lang.String key, java.lang.Object value, boolean hasMore)
Output a single entry.protected void
addResultEntry(java.util.Map.Entry<java.lang.String,java.lang.Object> entry, boolean hasMore)
Output a single entry.protected void
addResultItem(java.util.List<? extends java.lang.Object> listing, boolean hasMore)
Output a list of objects as a JSON array.protected void
addResultItem(java.util.Map<java.lang.String,? extends java.lang.Object> mapping, boolean hasMore)
Output a map of names and values as a JSON object.protected void
addResultValue(java.lang.Boolean bool, boolean hasMore)
Output a bool as a JSON value.protected void
addResultValue(java.lang.CharSequence str, boolean hasMore)
Output a char-sequence as a JSON value.protected void
addResultValue(java.lang.Number num, boolean hasMore)
Output a number as a JSON value.protected Format
getDefaultFormat()
protected java.util.Map<java.lang.String,java.lang.Object>
getHeaderAttributes()
Get the header attributes to apply to the formatter.protected java.lang.String
getResultsKey()
protected boolean
lazyList()
protected void
postInit()
Subclasses can hook in here to do common behaviour that needs to happen after initialisation.-
Methods inherited from class org.intermine.webservice.server.WebService
canServe, cleanUp, execute, 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, validateState, wantsColumnHeaders, wantsDataPackage
-
-
-
-
Field Detail
-
bagManager
protected final BagManager bagManager
-
model
protected final Model model
-
-
Constructor Detail
-
JSONService
public JSONService(InterMineAPI im)
Constructor- Parameters:
im
- The InterMine configuration object.
-
-
Method Detail
-
postInit
protected void postInit()
Description copied from class:WebService
Subclasses can hook in here to do common behaviour that needs to happen after initialisation.- Overrides:
postInit
in classWebService
-
getResultsKey
protected java.lang.String getResultsKey()
- Returns:
- The key for the results property.
-
lazyList
protected boolean lazyList()
- Returns:
- Whether to treat this as a lazy list.
-
getHeaderAttributes
protected java.util.Map<java.lang.String,java.lang.Object> getHeaderAttributes()
Get the header attributes to apply to the formatter.- Returns:
- A map from string to object.
-
addOutputInfo
protected void addOutputInfo(java.lang.String key, java.lang.String value)
Add a key value pair to put in the header of json results.- Parameters:
key
- An identifier.value
- Some piece of data.
-
addResultItem
protected void addResultItem(java.util.Map<java.lang.String,? extends java.lang.Object> mapping, boolean hasMore)
Output a map of names and values as a JSON object.- Parameters:
mapping
- the mapping of things to output.hasMore
- Whether there is more to come, and thus a comma is required.
-
addResultValue
protected void addResultValue(java.lang.CharSequence str, boolean hasMore)
Output a char-sequence as a JSON value.- Parameters:
str
- The character sequence.hasMore
- Whether there are more to come.
-
addResultValue
protected void addResultValue(java.lang.Number num, boolean hasMore)
Output a number as a JSON value.- Parameters:
num
- The number.hasMore
- Whether there are more to come.
-
addResultValue
protected void addResultValue(java.lang.Boolean bool, boolean hasMore)
Output a bool as a JSON value.- Parameters:
bool
- The boolean.hasMore
- Whether there are more.
-
addResultEntries
protected void addResultEntries(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.Object>> entries)
- Parameters:
entries
- The entries to output
-
addResultEntry
protected void addResultEntry(java.lang.String key, java.lang.Object value, boolean hasMore)
Output a single entry.- Parameters:
key
- The keyvalue
- The valuehasMore
- Whether there are more to come.
-
addResultEntry
protected void addResultEntry(java.util.Map.Entry<java.lang.String,java.lang.Object> entry, boolean hasMore)
Output a single entry.- Parameters:
entry
- The entryhasMore
- Whether there are more to come.
-
addResultEntries
protected void addResultEntries(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.Object>> entries, boolean hasMore)
Output a bunch of entries.- Parameters:
entries
- The entrieshasMore
- Whether there are more of them to come.
-
addResultItem
protected void addResultItem(java.util.List<? extends java.lang.Object> listing, boolean hasMore)
Output a list of objects as a JSON array.- Parameters:
listing
- The list of things to output.hasMore
- Whether there is more to come, and thus a comma is required.
-
getDefaultFormat
protected Format getDefaultFormat()
- Overrides:
getDefaultFormat
in classWebService
- Returns:
- The default format constant for this service.
-
-