/**
* @fileoverview MasterQuery is a client side library written in
* JavaScript designed to simplify the development on CUIs by
* creating a common interface into LexisNexis APIs for developers.
* Many tasks that would normally require a significant amount of
* coding time can now be done simply by updating the site’s
* properties file. The new interactive developer information window
* allows for Lexis Nexis employees to easily see what is being sent
* through the CUI and test alternative syntax.
*
* One of the biggest advantages is that a site can be prepared for
* conversion over to Rosetta simply by implementing the site using
* MasterQuery. Once the Nexis.com URL API is released a developer
* updates the site’s properties and you’re good to go.
*
* Note that since MasterQuery is a code library it is not meant to
* have any effect on the customer’s user experience.
*
* CONVERTING A SITE OVER TO MasterQuery
<script language="javascript" src="/clients/jslib/utils.js"></script> <script language="javascript" src="/clients/controls/MasterQuery/MQInclude.asp"></script>
target=_blank originationCode=00004 menu=126NC9 mj=1 MIDDLEWARE_CODE=NP client=seisinttestIn the past these would be either hidden fields in the CUI search form or link paramaters.
var chunnel = LNParser.propertyFactory("properties.txt");
chunnel.setSearch(query.value);
chunnel.setAfter(after.value);
chunnel.setSource(src.value);
chunnel.setClient(clientid.value);
chunnel.submit();
See the Class documentation for other usage examples.
verb=v1_search (default)
verb=v1_portfolio
verb=v1_searchform
verb=v1_snews
verb=v1_dossier_launch_forms
verb=search/searchform
chunnel.set("verb", "v1_searchform")
var chunnel = LNParser("http://web.lexis-nexis.com/api.universe/search/searchform?id=1928")
If no verb is set v1_search is used by default.
* var chunnel = new MasterQuery(MasterQuery.API_XLINK);
* chunnel.setSearch("Bush and AWOL");
* chunnel.setSource("NEWS;90DAYS");
* chunnel.setClient("999-5465");
* chunnel.setAfter("5:DY");
* chunnel.set("LNAUTHSCHEME", "CP");
* chunnel.submit();
*
* The recommended way to create a MasterQuery Object is through the
* {@link LNParser} factory methods.
*
* @param {int} The implementor that the Builder will call
* @version 0.1
* @constructor
*/
function MasterQuery(intAPI)
{
// Set the API
if (intAPI)
{
this.setAPI(intAPI);
}
else
{
this.setAPI(MasterQuery.DEFAULT_API);
}
this.search = "";
this.source = "";
this.originationCode = "";
this.method = "GET";
this.target = "_self";
this.protocol = "http:";
}
MasterQuery.NO_DEBUG = false;
/**
* LexisNexis API Constant for CUI Builder
* @type int
*/
MasterQuery.API_CUI_BUILDER = 1;
/**
* LexisNexis API Constant for CUI International
* @type int
*/
MasterQuery.API_CUI_INTERNATIONAL = 2;
/**
* LexisNexis API Constant for Dossier Searches
* @type int
*/
MasterQuery.API_DOSSIER = 3;
/**
* LexisNexis API Constant for Get and Print
* @type int
*/
MasterQuery.API_GET_AND_PRINT = 4;
/**
* LexisNexis API Constant for LN Professional
* @type int
*/
MasterQuery.API_PROFESSIONAL = 5;
/**
* LexisNexis API Constant for the Rosetta URL API
* @type int
*/
MasterQuery.API_URL_API = 6;
/**
* @deprecated
* @type int
*/
MasterQuery.API_V1_PORTFOLIO = 7;
/**
* LexisNexis API Constant for v1 Search
* @type int
*/
MasterQuery.API_V1_SEARCH = 8;
/**
* Constant casts into v1_search with searchform verb.
* @type int
*/
MasterQuery.API_V1_SEARCHFORM = 9;
/**
* @type int
*/
MasterQuery.API_V1_SNEWS = 10;
/**
* LexisNexis API Constant for XLink
* @type int
*/
MasterQuery.API_XLINK = 11;
/**
* LexisNexis API Constant for XLink Seisint
* @type int
*/
MasterQuery.API_XLINK_SEISINT = 12;
/**
* @type int
*/
MasterQuery.API_DOSSIER_FORMS = 13;
/**
* Constant casts into v1_search with nexis searchform verb.
* @type int
*/
MasterQuery.API_NEXIS_SEARCHFORM = 14;
/**
* Constants for LNDB IA
*/
MasterQuery.API_IA_LNDB_ACTIVATION = 15;
MasterQuery.API_IA_LNDB_LOGOUT = 16;
MasterQuery.API_IA_LNDB_LOGIN = 17;
/**
* LexisNexis API Constant for XLink Seisint
* @type int
*/
MasterQuery.API_XLINK_PUBREC = 18;
/**
* LexisNexis API Constant for XLink Seisint
* @type int
*/
MasterQuery.API_URL_API_PUBREC = 19;
/**
* @type int
*/
MasterQuery.DEFAULT_API = MasterQuery.API_XLINK;
/**
* The version number of the API
* @type long
*/
MasterQuery.version = 1.0;
/**
* The name of the API
* @type String
*/
MasterQuery.name = "MasterQuery";
/**
* The base URL location for the library
* @type String
*/
MasterQuery.baseURL = "/clients/controls/MasterQuery/";
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// Accessors
/**
* Returns the protocol being used for the query
*
* @type String
*/
MasterQuery.prototype.getProtocol = function()
{
return this.protocol;
}
/**
* Sets the protocol being used for the query
* @param {String}
*/
MasterQuery.prototype.setProtocol = function(strProtocol)
{
switch(strProtocol)
{
case "http":
case "http:":
this.protocol = "http:";
break;
case "https":
case "https:":
this.protocol = "https:";
break;
}
}
/**
* Returns the domain set for the query, if there is one.
* This mainly applies for XLink, which sometimes needs to
* be called from several different domains because of cookie
* and zone issues.
*
* @return the domain being used for the object
* @type String
*/
MasterQuery.prototype.getDomain = function()
{
return this.domain;
}
/**
* Sets the domain set for the query, if there is one.
* This mainly applies for XLink, which sometimes needs to
* be called from several different domains because of cookie
* and zone issues.
*
* @param {String}
*/
MasterQuery.prototype.setDomain = function(strDomain)
{
if (strDomain.indexOf("exis.com") != -1)
{
this.domain = strDomain;
return;
}
var re = /[01][01][01][01]/g;
if (strDomain.match(re)) {
this.domain = strDomain;
}
}
/**
* Returns the integer representing the API being used.
*
* @type int
*/
MasterQuery.prototype.getAPI = function()
{
return this.api;
}
/**
* Sets the integer representing the API being used.
*
* @param {String}
*/
MasterQuery.prototype.setAPI = function(intAPI)
{
intAPI = parseInt(intAPI, 10);
this.api = intAPI;
}
/**
* Gets the query.
*
* @type String
*/
MasterQuery.prototype.getSearch = function()
{
return this.search;
}
/**
* Sets the LN query
*
* @param {String}
*/
MasterQuery.prototype.setSearch = function(strSearch)
{
this.search = strSearch;
}
/**
* Gets the value of searchtype.
*
* @type String
*/
MasterQuery.prototype.getSearchtype = function()
{
return this.searchtype;
}
/**
* The searchtype to use. get for both xlink and CUIBuilder. In the case of
* CUIBuilder, citation is eliminated and case is passed with setSearch().
* @param {String}
*/
MasterQuery.prototype.setSearchtype = function(strSearchtype)
{
this.searchtype = strSearchtype;
}
/**
* Gets the value of TOCTarget.
*
* @type String
*/
MasterQuery.prototype.getTOCTarget = function()
{
return this["c_TOCTarget"];
}
/**
* The value of "target" to be used to access tocs. get for both xlink.
* @param {String}
*/
MasterQuery.prototype.setTOCTarget = function(strTOCTarget)
{
this["c_TOCTarget"] = strTOCTarget;
}
/**
* Gets the value of the source.
*
* @type String
*/
MasterQuery.prototype.getSource = function()
{
return this.source;
}
/**
* The source(s) to be used.
* @param {String}
*/
MasterQuery.prototype.setSource = function(strSource)
{
this.source = strSource.toUpperCase();
}
// DATE METHODS
/**
* Gets the value of relativedate.
*
* @type String
*/
MasterQuery.prototype.getAfter = function()
{
return this.after;
}
/**
* The relativedate value to be used.
*
* This method handles SmartLink (1:WK) and XLink style (previous_3_days)
* relative dates and translates all of them to SmartLink format.
* @param {String}
*/
MasterQuery.prototype.setAfter = function(strAfter)
{
// alert(strAfter)
this.after = LNParser.parseAfter(strAfter)
}
/**
* Gets the value of fromDate.
*
* @type String
*/
MasterQuery.prototype.getFromDate = function()
{
return this.fromDate;
}
/**
* fromDate to be appended to search string.
* @param {String}
*/
MasterQuery.prototype.setFromDate = function(strFromDate)
{
this.fromDate = DateUtil.parse(strFromDate);
}
/**
* Gets the value of toDate.
*
* @type String
*/
MasterQuery.prototype.getToDate = function()
{
return this.toDate;
}
/**
* toDate to be appended to search string.
* @param {String}
*/
MasterQuery.prototype.setToDate = function(strToDate)
{
this.toDate = DateUtil.parse(strToDate);
}
/**
* Gets the value of client.
*
* @type String
*/
MasterQuery.prototype.getClient = function()
{
return this.client;
}
/**
* Sets the client ID.
* @param {String}
*/
MasterQuery.prototype.setClient = function(strClient)
{
this.client = strClient;
}
/**
* Gets the value of maxDocs.
*
* @type int
*/
MasterQuery.prototype.getMaxdocs = function()
{
return this.maxdocs;
}
/**
* Sets the number of documents to return.
* @param {String}
*/
MasterQuery.prototype.setMaxdocs = function(intMaxdocs)
{
intMaxdocs = parseInt(intMaxdocs, 10);
if (intMaxdocs > 0)
{
this.maxdocs = intMaxdocs;
}
}
/**
* Gets the menu.
*
* @type String
*/
MasterQuery.prototype.getMenu = function()
{
return this.menu;
}
/**
* Sets the customer menu.
* @param {String}
*/
MasterQuery.prototype.setMenu = function(strMenu)
{
this.menu = strMenu;
}
/**
* Gets the OriginationCode.
*
* @type String
*/
MasterQuery.prototype.getOriginationCode = function()
{
return this.originationCode;
}
/**
* Sets the OriginationCode.
* @param {String}
*/
MasterQuery.prototype.setOriginationCode = function(strOriginationCode)
{
this.originationCode = strOriginationCode;
}
/**
* Gets the value of sort.
*
* @type String
*/
MasterQuery.prototype.getSort = function()
{
return this.sort;
}
/**
* Sets the sort order.
* @param {String}
*/
MasterQuery.prototype.setSort = function(strSort)
{
this.sort = strSort;
}
/**
* Gets the UID value.
*
* @type String
*/
MasterQuery.prototype.getUID = function()
{
return this.uid;
}
/**
* Sets the user ID.
* @param {String}
*/
MasterQuery.prototype.setUID = function(strUID)
{
this.uid = strUID;
}
/**
* Gets the PWD.
*
* @type String
*/
MasterQuery.prototype.getPWD = function()
{
return this.pwd;
}
/**
* Sets the PWD.
* @param {String}
*/
MasterQuery.prototype.setPWD = function(strPWD)
{
this.pwd = strPWD;
}
/**
* Gets the zone value.
*
* @type String
*/
MasterQuery.prototype.getZone = function()
{
return this.zone;
}
/**
* Sets the zone.
* @type String
*/
MasterQuery.prototype.setZone = function(strZone)
{
this.zone = strZone;
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// Target Form Methods
/**
* Returns the method that the internal post form will be used.
* This is an internal method used by the implementors.
*
* @type String
*/
MasterQuery.prototype.getMethod = function()
{
return this.method;
}
/**
* Sets the method that the internal post form will be used.
* This is an internal method used by the implementors.
*
* @param {String}
*/
MasterQuery.prototype.setMethod = function(strMethod)
{
this.method = strMethod;
}
/**
* Used to override the action for the MQ object.
*
* @type String
*/
MasterQuery.prototype.getOverride = function()
{
return this.override;
}
/**
* Used to override the action for the MQ object.
*
* @param {String}
*/
MasterQuery.prototype.setOverride = function(strOverride)
{
this.override = strOverride;
}
/**
* Returns the window target used by the internet MasterQuery form.
*
* @type String
*/
MasterQuery.prototype.getTarget = function()
{
return this.target;
}
/**
* Sets the window target used by the internet MasterQuery form.
*
* @param {String}
*/
MasterQuery.prototype.setTarget = function(strTarget)
{
this.target = strTarget;
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// METHODS
/**
* Generic method for getting a MasterQuery value.
* return the value of the key passed in
* @param {String} The key for the value to be returned
*/
MasterQuery.prototype.get = function(strParam)
{
if (MasterQuery._isStandardField(strParam))
{
return this[strParam];
}
else
{
return this["c_" + strParam];
}
};
/**
* Generic method for setting a MasterQuery value.
* For standard MasterQuery values set or the specific setter can be
* used interchangably.
*
* Much of the headache behind this is to deal with the debug window.
* @param {String} The key for the value to be set
* @param {String} The value to be set
*/
MasterQuery.prototype.set = function(strParam, strValue)
{
/*
* NOTE: Adding a new MQ field:
* 1) create the getter and accessor for the parameter
* 2) add it to getMQFieldNames list
* 3) If hidden add it to getAdditionalFields() hidden switch statement
* 4) add to set switch statement
* 5) add to _isStandardField
*/
var myRegExp = /^c_/;
if (myRegExp.test(strParam))
{
strParam = strParam.substring(2);
}
switch(strParam.toLowerCase())
{
case "":
break;
case "api":
this.setAPI(strValue)
break;
case "search":
case "query":
case "searchterm":
case "sr":
this.setSearch(strValue);
break;
case "name":
if (this.api == MasterQuery.API_URL_API)
{
this.set("nm", strValue);
} else {
this.setSearch(strValue);
}
break;
case "source":
case "src":
this.setSource(strValue);
break;
case "searchtype":
case "stp":
this.setSearchtype(strValue);
break;
case "relativedate":
case "after":
case "daterelative":
this.setAfter(strValue);
break;
case "client":
case "clientid":
case "pi":
this.setClient(strValue);
break;
case "domain":
this.setDomain(strValue);
break;
case "maxdocs":
case "limit":
this.setMaxdocs(strValue);
break;
case "menu":
case "_menu":
this.setMenu(strValue);
break;
case "method":
this.setMethod(strValue);
break;
case "originationcode":
case "origination_code":
case "origincode":
this.setOriginationCode(strValue);
break;
case "override":
this.setOverride(strValue);
break;
case "protocol":
this.setProtocol(strValue);
break;
case "newsortmode":
case "sortby":
this.setSort(strValue);
break;
case "target":
this.setTarget(strValue);
break;
case "user_id":
case "uid":
this.setUID(strValue);
break;
case "password":
case "pwd":
case "psw":
this.setPWD(strValue);
break;
case "zone":
this.setZone(strValue);
break;
case "company":
if (this.api == MasterQuery.API_V1_SEARCH)
{
if (Truth.isTrue(strValue))
{
this.setSearch("company" + QueryUtil.segment(strValue));
}
break;
}
default:
if (strValue == "")
{
this["c_" + strParam] = null;
}
else
{
this["c_" + strParam] = strValue;
}
}
};
/**
*
*
* @private
* @param {String}
* @return is the field standard to MasterQuery
* @type boolean
*/
MasterQuery._isStandardField = function(strParam)
{
switch(strParam)
{
case "api":
case "search":
case "searchtype":
case "source":
case "after":
case "fromDate":
case "toDate":
case "client":
case "maxdocs":
case "menu":
case "originationCode":
case "sort":
case "uid":
case "pwd":
case "zone":
case "target":
case "method":
case "domain":
case "protocol":
case "override":
return true;
break;
}
return false;
};
/**
*
* @param {boolean} optional value that if true disables the debug window.
* @private
*/
MasterQuery.prototype.submit = function(forceNoDebug, OverrideWindowProps)
{
var type = "regular";
if (arguments.length > 0)
{
if (arguments[0].isAuthObject)
type="auth";
}
if (type == "auth")
this.authSubmit(arguments[0]);
else
SearchImplementor.go(this, forceNoDebug, OverrideWindowProps);
};
/**
* Displays all of the values in the MasterQuery object.
* @type String
*/
MasterQuery.prototype.toString = function()
{
var s = "MasterQuery\n";
if (this.api) s += " API: " + LNParser.getAPIName(this.api) + "\n";
if (this.search) s += " SEARCH: " + this.search + "\n";
if (this.searchtype) s += " SEARCH TYPE: " + this.searchtype + "\n";
if (this.source) s += " SOURCE: " + this.source + "\n";
if (this.after) s += " AFTER: " + this.after + "\n";
if (this.fromDate) s += " FROM: " + this.fromDate + "\n";
if (this.toDate) s += " TO: " + this.toDate + "\n";
if (this.client) s += " CLIENT: " + this.client + "\n";
if (this.maxdocs) s += " MAX DOCS: " + this.maxdocs + "\n";
if (this.menu) s += " MENU: " + this.menu + "\n";
if (this.originationCode) s += " ORIGINATION_CODE: " + this.originationCode + "\n";
if (this.sort) s += " SORT: " + this.sort + "\n";
if (this.uid) s += " UID: " + this.uid + "\n";
if (this.pwd) s += " PWD: ********\n";
if (this.zone) s += " ZONE: " + this.zone + "\n";
if (this.domain) s += " DOMAIN: " + this.domain + "\n";
if (this.target) s += " TARGET: " + this.target + "\n";
if (this.method) s += " METHOD: " + this.method + "\n";
if (this.override) s += " OVERRIDE: " + this.override + "\n";
for (var i in this) {
val = this[i];
switch (typeof val) {
case ("string"):
if (/^c_/.test(i)) s += " " + i.substr(2).toUpperCase() + ": " + val + "\n";
break;
default:
break;
}
}
return s;
};
/**
* Sets the user id and password which are pulled from the auth db.
* authObject Parameters:
* siteID: The cui's site encrypted id number. ie. "1ce5ecc8ab642ac0"
* authType: Determines whether the auth info is selected by ip address or by id name.
* Sample Inputs:
* "ip"
* "name"
* IDName: If the authType is "name" then the name to be selected must be passed.
* devOverride: By default, pages in dev select the dev id instead of the prod id. Passing "true" in this
* parameter will override that functionality and always select the prod id.
* isCert: Returns cert id/pwd
* forceNoDebug: Parameter passed through to submit function
* OverrideWindowProps: Parameter passed through to submit function
* IDParameterName: Determins parameter name used for ID
* PWDParameterName: Determines parameter name used for Password
*/
MasterQuery.prototype.authSubmit = function(authObject)
{
var siteID, authType, IDName, devOverride, isCert, forceNoDebug, OverrideWindowProps, IDParameterName, PWDParameterName;
siteID = authObject.siteID;
authType = authObject.authType.toLowerCase();
IDName = authObject.IDName;
devOverride = authObject.devOverride;
isCert = authObject.isCert;
forceNoDebug = authObject.forceNoDebug;
OverrideWindowProps = authObject.OverrideWindowProps;
IDParameterName = authObject.IDParameterName;
PWDParameterName = authObject.PWDParameterName;
if ((siteID == "") || (authType == ""))
return false;
if ((authType == "name") && (IDName == ""))
return false;
if (devOverride != true)
devOverride = false;
var MQObj = this;
var xmlObj = null;
if(window.ActiveXObject)
{
try
{
xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else if(window.XMLHttpRequest)
{
xmlObj = new XMLHttpRequest();
} else
{
return false;
}
xmlObj.onreadystatechange = function()
{
if(xmlObj.readyState == 4)
{
var temp, UID, PWD;
temp = xmlObj.responseText;
temp = temp.split(" ");
UID = temp[0]
PWD = temp[1];
if (PWD == undefined)
PWD = "";
if(IDParameterName == "")
MQObj.uid = UID;
else
eval("MQObj." + IDParameterName + " = UID");
if(PWDParameterName == "")
MQObj.pwd = PWD;
else
eval("MQObj." + PWDParameterName + " = PWD");
MQObj.submit(forceNoDebug, OverrideWindowProps);
return true;
}
}
var file = "/clients/controls/auth/authHelper.asp";
file = file + "?siteID=" + siteID + "&authType=" + authType + "&IDName=" + IDName + "&devOverride=" + devOverride + "&isCert=" + isCert;
xmlObj.open ('GET', file, true);
xmlObj.send ('');
return true;
};
function authObject()
{
this.isAuthObject = true;
this.siteID = "";
this.authType = "";
this.IDName = "";
this.devOverride = false;
this.isCert = false;
this.forceNoDebug = "";
this.OverrideWindowProps = "";
this.IDParameterName = "";
this.PWDParameterName = "";
}
authObject.prototype.setSiteID = function(id)
{
this.siteID = id;
}
authObject.prototype.getSiteID = function()
{
return this.siteID;
}
authObject.prototype.setAuthType = function(type)
{
this.authType = type;
}
authObject.prototype.getAuthType = function()
{
return this.authType;
}
authObject.prototype.setIDName = function(IDName)
{
this.IDName = IDName;
}
authObject.prototype.getIDName = function()
{
return this.IDName;
}
authObject.prototype.setDevOverride = function(devOverride)
{
this.devOverride = devOverride;
}
authObject.prototype.getDevOverride = function()
{
return this.devOverride;
}
authObject.prototype.setIsCert = function(isCert)
{
this.isCert = isCert;
}
authObject.prototype.getIsCert = function()
{
return this.isCert;
}
authObject.prototype.setForceNoDebug = function(forceNoDebug)
{
this.forceNoDebug = forceNoDebug;
}
authObject.prototype.getForceNoDebug = function()
{
return this.forceNoDebug;
}
authObject.prototype.setOverrideWindowProps = function(OverrideWindowProps)
{
this.OverrideWindowProps = OverrideWindowProps;
}
authObject.prototype.getOverrideWindowProps = function()
{
return this.OverrideWindowProps;
}
authObject.prototype.setIDParameterName = function(IDParameterName)
{
this.IDParameterName = IDParameterName;
}
authObject.prototype.getIDParameterName = function()
{
return this.IDParameterName;
}
authObject.prototype.setPWDParameterName = function(PWDParameterName)
{
this.PWDParameterName = PWDParameterName;
}
authObject.prototype.getPWDParameterName = function()
{
return this.PWDParameterName;
}// ===================================================================
// Author: Matt Kruse ");
w.document.writeln(Dumper(o,DumperGetArgs(arguments,1)));
w.document.writeln("