Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]] Former-commit-id:06a8b51d6d
Former-commit-id:3360eb6c5f
111 lines
2.7 KiB
JavaScript
111 lines
2.7 KiB
JavaScript
/**
|
|
* Performs a TermQuery for PIREP data.
|
|
*
|
|
* Usage:
|
|
* TBD
|
|
*
|
|
* SOFTWARE HISTORY
|
|
*
|
|
* Date Ticket# Engineer Description
|
|
* ------------ ---------- ----------- --------------------------
|
|
* 20080105 713 jkorman Initial Coding.
|
|
*/
|
|
function PIREPRequest(){
|
|
this.plugin = "pirep";
|
|
this.subscribe = false;
|
|
this.subscription = null;
|
|
this.queryResults = null;
|
|
this.asciiResponse = false;
|
|
this.query = new TermQuery(this.plugin, subscriptionDataFieldId, subscriptionDataQueryId);
|
|
}
|
|
|
|
function _addParameter(name,value,operand){
|
|
if(arguments.length==2){
|
|
this.query.addParameter(name,value);
|
|
} else{
|
|
this.query.addParameter(name,value,operand);
|
|
}
|
|
}
|
|
|
|
function _addList(name, value){
|
|
this.query.addList(name, value);
|
|
}
|
|
|
|
function _setCount(count){
|
|
this.query.setCount(count);
|
|
}
|
|
|
|
function _setSortValue(sortValue){
|
|
this.query.setSortBy(sortValue);
|
|
}
|
|
|
|
function _enableSubscription(){
|
|
this.subscribe = true;
|
|
}
|
|
|
|
function _enableAsciiResponse(){
|
|
this.asciiResponse = true;
|
|
}
|
|
|
|
function _execute()
|
|
{
|
|
if(this.subscribe){
|
|
this.subscription = new Subscription();
|
|
this.subscription.setup(this.query);
|
|
}
|
|
|
|
this.queryResults = this.query.execute();
|
|
if(this.queryResults == null || this.queryResults.size() == 0)
|
|
{
|
|
var response = new MakeResponseNull("Query returned 0 results.",
|
|
this.query);
|
|
return response.execute();
|
|
}
|
|
else
|
|
{
|
|
if(this.asciiResponse)
|
|
{
|
|
return this.makeAsciiResponse();
|
|
}
|
|
else
|
|
{
|
|
return this.makeXmlResponse();
|
|
}
|
|
}
|
|
}
|
|
|
|
function _makeXmlResponse()
|
|
{
|
|
var xmlResults = new Array();
|
|
var response = new Array();
|
|
for(i=0; i < this.queryResults.size(); i++)
|
|
{
|
|
var makeResponse = new MakeResponseXml(this.queryResults.get(i));
|
|
response[i] = makeResponse.execute();
|
|
}
|
|
return response;
|
|
}
|
|
|
|
function _makeAsciiResponse()
|
|
{
|
|
var xmlResults = new Array();
|
|
var response = new Array();
|
|
for(i=0; i < this.queryResults.size(); i++)
|
|
{
|
|
var toXml = new DataToXml(this.queryResults.get(i));
|
|
xmlResults[i] = toXml.execute();
|
|
var makeResponse = new MakeResponseAscii(this.queryResults.get(i), xmlResults[i]);
|
|
response[i] = makeResponse.execute();
|
|
}
|
|
return response;
|
|
}
|
|
|
|
PIREPRequest.prototype.execute = _execute;
|
|
PIREPRequest.prototype.makeXmlResponse = _makeXmlResponse;
|
|
PIREPRequest.prototype.makeAsciiResponse = _makeAsciiResponse;
|
|
PIREPRequest.prototype.addParameter = _addParameter;
|
|
PIREPRequest.prototype.addList = _addList;
|
|
PIREPRequest.prototype.setCount = _setCount;
|
|
PIREPRequest.prototype.setSortValue = _setSortValue;
|
|
PIREPRequest.prototype.enableSubscription = _enableSubscription;
|
|
PIREPRequest.prototype.enableAsciiResponse = _enableAsciiResponse;
|