Skip to content
cketcham edited this page Jul 18, 2012 · 3 revisions

org.ohmage.probemanager
Class ResponseBuilder

Response builder class which makes it easy to create the response and send it. More information on how the json data should be structured can be found on the wiki

See Also:
https://github.com/cens/ohmageServer/wiki/Survey-Manipulation

Constructor Summary
ResponseBuilder()
           
ResponseBuilder(java.lang.String campaignUrn, java.lang.String campaignCreationTimestamp)
           
 
Method Summary
 ResponseBuilder clear()
          Clear all data from this response
 ResponseBuilder setCampaign(java.lang.String campaignUrn, java.lang.String campaignCreationTimestamp)
          Campaign Urn and creation timestamp to specify the campaign
 ResponseBuilder setData(java.lang.String data)
          Set the response data.
 ResponseBuilder setUploadPriority(int uploadPriority)
          Upload Priority
 ResponseBuilder withLocation(Location location, java.lang.String timezone, java.lang.String status)
          Location that this response was taken
 ResponseBuilder withLocation(long time, java.lang.String timezone, double latitude, double longitude, float accuracy, java.lang.String provider, java.lang.String status)
          Location that this response was taken
 ResponseBuilder withResponses(java.lang.String responses)
          A JSON array composed of JSON object prompt responses and/or JSON object repeatable set responses.
 ResponseBuilder withSurveyId(java.lang.String surveyId)
          A string defining a survey in the campaign's associated configuration file at the XPath /surveys/survey/id
 ResponseBuilder withSurveyKey(java.lang.String surveyKey)
          A UUID unique to this survey response.
 ResponseBuilder withSurveyLaunchContext(long launchTime, java.lang.String launchTimezone, java.lang.String... activeTriggers)
          Values which describes the survey's launch context.
 ResponseBuilder withSurveyLaunchContext(java.lang.String surveyLaunchContext)
          A JSON object with variable properties that describes the survey's launch context.
 ResponseBuilder withTime(long time, java.lang.String timezone)
          A long specifying the survey completion time by the number of milliseconds since the UNIX epoch and the timezone ID for the timezone of the device when this survey was taken.
 void write(ProbeWriter writer)
           
Constructor Detail

ResponseBuilder

public ResponseBuilder()

ResponseBuilder

public ResponseBuilder(java.lang.String campaignUrn,
                       java.lang.String campaignCreationTimestamp)
Method Detail

setCampaign

public ResponseBuilder setCampaign(java.lang.String campaignUrn,
                                   java.lang.String campaignCreationTimestamp)
Campaign Urn and creation timestamp to specify the campaign

Parameters:
campaignUrn -
campaignCreationTimestamp -
Returns:

setUploadPriority

public ResponseBuilder setUploadPriority(int uploadPriority)
Upload Priority

Parameters:
uploadPriority -
Returns:

setData

public ResponseBuilder setData(java.lang.String data)
Set the response data. This data will be ignored on write if response data other than the campaignUrn, campaignCreationTimestamp, and uploadPriority is specified

Parameters:
data -
Returns:

withSurveyKey

public ResponseBuilder withSurveyKey(java.lang.String surveyKey)
A UUID unique to this survey response.

Parameters:
surveyKey -
Returns:

withTime

public ResponseBuilder withTime(long time,
                                java.lang.String timezone)
A long specifying the survey completion time by the number of milliseconds since the UNIX epoch and the timezone ID for the timezone of the device when this survey was taken.

Parameters:
time -
timezone -
Returns:

withLocation

public ResponseBuilder withLocation(Location location,
                                    java.lang.String timezone,
                                    java.lang.String status)
Location that this response was taken

Parameters:
location -
timezone -
status: - A string describing location status. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, it is an error to send a location object.
Returns:

withLocation

public ResponseBuilder withLocation(long time,
                                    java.lang.String timezone,
                                    double latitude,
                                    double longitude,
                                    float accuracy,
                                    java.lang.String provider,
                                    java.lang.String status)
Location that this response was taken

Parameters:
time -
timezone -
latitude -
longitude -
accuracy -
provider -
status: - A string describing location status. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, it is an error to send a location object.
Returns:

withSurveyId

public ResponseBuilder withSurveyId(java.lang.String surveyId)
A string defining a survey in the campaign's associated configuration file at the XPath /surveys/survey/id

Parameters:
surveyId -
Returns:

withSurveyLaunchContext

public ResponseBuilder withSurveyLaunchContext(java.lang.String surveyLaunchContext)
A JSON object with variable properties that describes the survey's launch context.

Parameters:
surveyLaunchContext -
Returns:

withSurveyLaunchContext

public ResponseBuilder withSurveyLaunchContext(long launchTime,
                                               java.lang.String launchTimezone,
                                               java.lang.String... activeTriggers)
Values which describes the survey's launch context.

Parameters:
launchTime -
launchTimezone -
activeTriggers -
Returns:
Throws:
JSONException

withResponses

public ResponseBuilder withResponses(java.lang.String responses)
A JSON array composed of JSON object prompt responses and/or JSON object repeatable set responses.

Parameters:
responses -
Returns:

clear

public ResponseBuilder clear()
Clear all data from this response

Returns:

write

public void write(ProbeWriter writer)
           throws RemoteException
Throws:
RemoteException