This function was copied directly from the source.  It's used internally to map names to the correct CAML name.  It's used throughout roboCAML as a means to provide easier, more intuitive ways to write CAML within JavaScript.  

If you would like to see a name mapping added, feel free to start a discussion.

 


//Used to normalize the text for CAML; e.g. && === "And"
CorrectCAML = function ( node ) {
if ( toType( node ) === "boolean" ) {

//Which one is it?
if ( node ) {
return "True";
} else {
return "False";
}
//Find and normalize CAML operators that are string based.
//Suggestions to add more are welcome...
} else {
switch( node.toLowerCase() ) {
//Function will return correct CAML values that are passed into roboCAML.Query
//debugger;
/* ~~~~~~~ Filter portion ~~~~~~~ */
//And
case "&&":
case "&":
case "and":
return "And";

//Or
case "||":
case "or":
return "Or";

/* ~~~~~~~ Ops portion ~~~~~~~~ */
case "equal":
case "equals":
case "=":
case "eq":
return "Eq";

//Not Equals
case "neq":
case "not equal":
case "not equals":
case "!=":
return "Neq";

//Greater than
case "gt":
case ">":
return "Gt";

//Greater than or equal to
case "geq":
case ">=":
return "Geq";

//Less than
case "lt":
case "<":
return "Lt";

//Less than or equal to
case "leq":
case "<=":
return "Leq";

//IsNull
case "isnull":
case "null":
return "IsNull";

//IsNotNull
case "isnotnull":
case "not null":
return "IsNotNull";

//BeginsWith
case "beginswith":
case "begins with":
case "^":
return "BeginsWith";

//Contains
case "contains":
case "*":
return "Contains";

//DateRangesOverlap
case "daterangesoverlap":
case "dateoverlap":
return "DateRangesOverlap";

/* ~~~~~~~ QueryOptions portion ~~~~~~~~ */
case "dateinutc":
return "DateInUtc";

case "folder":
return "Folder";

case "paging":
return "Paging";

case "listitemcollectionpositionnext":
return "ListItemCollectionPositionNext";

case "includemandatorycolumns":
return "IncludeMandatoryColumns";

case "meetinginstanceid":
case "meetingid":
return "MeetingInstanceID";

case "viewattributes":
case "recursive":
return "ViewAttributes";


/* ~~~~~~~ BatchCMD portion ~~~~~~~~ */
case "update":
return "Update";
case "delete":
return "Delete";
case "new":
return "New";

/* ~~~~~~~ Misc portion ~~~~~~~~ */
case "true":
return "True";
case "false":
return "False";
}
}
}, //End of NormalizeOp

Last edited Feb 9, 2012 at 7:36 PM by iOnline247, version 2

Comments

No comments yet.