Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: internalapi Arguments: Description: A help file that lists the WubHub utility functions defined in a module "Wub". Page type: snippet Render function: Module: site Page source: <h1>Wub Module Functions</h1> These WubHub utility functions are available for use within your WebL function definitions. <pre> // ------------------------------------------------------------------------- // Name: Wub_NewLuceneIndex(name, create, analyzer) // Purpose: Creates a new lucene index of name. // If create, erases any previous content. // analyzer may be "standard" (no stemming), "kstem" or "english" // (porter stemming) // Returns: A Writer object to the new index // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_ReadLuceneIndex(name) // Purpose: Opens a lucene index name 'name' for read access // Returns: A Reader object to the index // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_NewLuceneDocument() // Purpose: Creates a new Lucene document (empty) // Returns: Lucene Document object // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_NewLuceneTerm(fieldName, searchStr) // Purpose: Creates a new Lucene term with fieldname and searchstring // Returns: Lucene Term object // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_AddLuceneField(doc, name, content, store, analyze, boost) // Purpose: Adds a field to a document, with name and content. Boolean // flags specify whether to store and analyze/index. Boost specifies // field level boosting value, 0 or 1 = no boost. // Returns: true // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_AddLuceneDocument(writer, doc) // Purpose: Adds a document to a Lucene index // Returns: true if successful // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_UpdateLuceneDocument(writer, term, doc) // Purpose: Updates a document matching a given term with new doc value // Returns: true if successful // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_DeleteLuceneDocuments(writer, term, doc) // Purpose: Delete all documents matching a given term // Returns: true if successful // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_OptimizeLucene(writer) // Purpose: Optimize the Lucene index // Returns: true if successful // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_CloseLuceneIndex(writer) // Purpose: Close the Lucene index // Returns: true if successful // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_LuceneSearch(reader, defaultField, query, hitsPerPage, analyzer) // Purpose: Search the lucene index, given a defaultField to search, a // Lucene-formatted query string, and number of hits per page. // Use the same analyzer that was used for indexing ("standard", // "kstem", "english") // Returns: A Lucene TopScoreDocCollector object. Relevant fields: // ScoreDoc[] .topDocs().scoreDocs // int .getTotalHits(); // ------------------------------------------------------------------------- // // ============================================== // Mongo DB Functions // ============================================== // ------------------------------------------------------------------------- // Name: Wub_InitDB(hostname) // Purpose: Connects a mongo server specified by hostname // Returns: True if successfully connected // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_GetDB(dbName) // Purpose: Returns a pointer to the static DB instance // Returns: DB database (static variable created in this class in InitDB) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_DropDB(dbName) // Purpose: Drops a database by name // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_GetCollectionNames(db) // Purpose: Get a list of all collection name strings in the current database. // Returns: Set<String> set of collection names // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_NewBasicDBObject() // Purpose: Returns a new BasicDBObject. // Returns: BasicDBObject dbObj // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_NewDBObject() // Purpose: Returns a new DBObject representing the webl object. Can be used // to insert into a collection, or as the query object when searching. // Returns: DBObject dbObj // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_GetCollection(db, collectionName) // Purpose: Returns a collection named collectionName // Returns: DBCollection // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_InsertDB(collection, dbObject) // Purpose: Inserts a dbObj into a collection // Returns: DBCollection // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_UpdateDB(collection, queryObj, updateObj, upsert, multi) // Purpose: Replaces a queryObj with an updateObj. If multi=false, only first, else all. // If upsert=true, adds updateObj if a replace is not done. // Returns: Void // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_RemoveDB(collection, queryObj) // Purpose: Removes first object matching queryObj // Returns: Void // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_CreateIndex(collection, dbObject) // Purpose: Creates an index matching dbObject. dbObject should have the fieldname // on which to create an index, and value 1 for ascending, -1 descending. // Returns: Void // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_QueryDB(collection, queryObj, max) // Purpose: Searches a collection for all matching records of queryObj, up to max records. // -1 means no maximum. // Returns: WebL list of result objects // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_GroupsMembers() // Purpose:Returns members for all groups registered with WubHub // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Name: Wub_GroupList() // Returns a list of all groups in the system // ------------------------------------------------------------------------- //------------------------------------------------------------------------- // name: Wub_GenerateInvitationId(wubinfo, numUses) // purpose: Generates an invitation ID that can be used numUses times // note: must be logged in to execute this command //------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Wub_MetadataVal(func, variable) // Return stored value related to function // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Wub_CallCount(func) // Return the number of times func has been called // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetFunctionInfo(f) // purpose: // Load function. Returns fields holding function data // name, module, arglist, ctype, version, created, modified, content, description, exec // or nil if function not found or INSUFFICIENT_PERMISSIONS if specified session // does not have read permissions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_SaveFunctionInfo(funcinfo) // Purpose: Given funcinfo data, save function, recording versions. // Returns: A page that will be displayed to the user, indicating success or // errors; // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_DeleteFunction(funcname) // Purpose: Deletes a function (qualified or unqualified) by name, checking permissions. // Cleans up all metadata for deleted function // Returns true if successful, false otherwise // Throws Exceptions: // UnknownFunction // InsufficientPermissions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ParseFunctionIdentifier(namestr) // Parse a function identifier // May be of the form "funcname" or "modname.funcname" // Returns object funcspec = [. module = "modname", name = "funcname" .] // obj.module is nil if module is not specified // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ParseCommandLine(cmdline) // Parse a command line // _Not_ a full recursive parser. // Returns object with "cmd" and "args" fields, and also // a "parsedcmdline" field which is the same as cmdline, // but in canonical form. Returns nil for syntax error. // Allowed syntax: // funcname // funcname() // funcname(arg1,second argument) // funcname ("arg1 with quotes", arg2) // funcname: "arg1 with quotes", arg2 // funcname may also be qualified, using "." as a separator: modname.funcname // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_FunctionList(modulefun) // purpose: // Return list of all functions contained in module. // Verfies that module is READABLE by user (returns empty list otherwise) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetFunctionsByTag(tag) // purpose: // Returns the list of all functions tagged with tag, or the // empty list if tag doesn't exist // Returns only functions viewable by user // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ClearCache(func) // purpose: // Deletes all cached values for a function (qualified or unqualified) by name, checking permissions. // Returns true if sucessful, false otherwise // Throws Exceptions: // UnknownFunction // InsufficientPermissions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Wub_SaveCacheResult(name, arglist, result) // Saves a result to a the cache for a function/arguments pair // Returns true if sucessful, false otherwise // Throws Exceptions: // UnknownFunction // InsufficientPermissions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_RefreshCache(func) // purpose: // Refreshes all cached values for a function (qualified or unqualified) by name, checking permissions. // Returns true if sucessful, false otherwise // Throws Exceptions: // UnknownFunction // InsufficientPermissions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_TagList() // purpose: // Returns the list of all tags viewable by the user // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_MemberList() // purpose: // Return list of all WubHub members // ------------------------------------------------------------------------- //------------------------------------------------------------------------- // name: Wub_FunctionSort(f, list, direction) // purpose: Sorts a list based on a user-defined function f(a,b) that return // -1 for a < b, 1 for a > b, and 0 for a=b. If direction is -1, reverse // sorts, else if 1, sorts from lowest to highest //------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ReadableModules(includeMemberModules) // Returns as a list available readModules given user // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_WriteableModules() // Returns as a list available WriteModules given user // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ALinkCmd(cmdline) // name: Wub_ALinkCmd2(cmdline, linktext) // Return an HTML "a" tag with a link to a WubHub command. Use this instead // of hardcoding references to commands within pages. // ALinkCmd returns a link with the content of the link equal to the command // ALinkCmd2 takes a separate argument for the content of the link. // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_CreateTable(listOfObjs) // Return a TABLE piece containing list of objects // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_TruncateWithEllipsis(str, size) // Truncate string to specified length, adding ellipsis if necessary // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_RandomInt(n) // purpose: Return int from 0 to n // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetCalendarClass() // purpose: Return pointer to java.util.Calendar class // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetDateClass() // purpose: Return pointer to java.util.Date class // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetDateFormatClass() // purpose: Return pointer to java.text.DateFormat class // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_SimpleDateFormat(pattern) // purpose: Return instance of java.text.SimpleDateFormat class // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetDateTimeStr // purpose: Return current Date Time as string // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetDateTime // purpose: Return current Date Time as long // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_StringToHTMLEveryField(obj) // purpose: Apply StringToHTML to every string field in obj // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ReplaceAll(str, sub, by) // purpose: Replace all occurences of a String in a string // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_ReplaceTokens(obj, str) // Replace %token% identifiers in a string. // Given object obj = [. "tok1" = "value1", "tok2" = "value2" ... .] // it replaces strings "%tok1%" with "value1", etc., in str // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_GetVaultValue(keyword) // purpose: // Returns from vault saved password for keyword // Throws: InsufficientPermissions, UnknownKey // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: Wub_SetVaultValue(key, pw) // purpose: // Sets a keyword/pw pair into the user's vault // Throws: InsufficientPermissions // ------------------------------------------------------------------------- // ========================================================================= // Global data // ========================================================================= // ------------------------------------------------------------------------- // mame: AppendData(tablename, data) // purpose: Writes a row of data (string) to the end of the file (global) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: ReadData(tablename) // purpose: Reads entire table (global) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // name: DeleteData(tablename) // purpose: Deletes entire table (global) // ------------------------------------------------------------------------- </pre>