JegasAPI - Jegas, LLC - Copyright(c)2016

Unit uj_xml

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

XML API Calls and IWF XML Response Generation

Overview

Functions and Procedures

procedure JASAPI_Dispatch(p_Context: TCONTEXT);
procedure jasapi_helloworld(p_Context: TCONTEXT);
procedure jasapi_validatesession(p_Context: TCONTEXT);
procedure jasapi_createsession(p_Context: TCONTEXT);
procedure jasapi_removesession(p_Context: TCONTEXT);
procedure jasapi_bigtest(p_Context: TCONTEXT);
procedure JAS_XmlTest(p_Context: TCONTEXT);
procedure JASAPI_RenderQuickLinks(p_Context: TCONTEXT);
procedure JASAPI_SetTheme(p_Context: TCONTEXT);
procedure JASAPI_SetDisplayHeaders(p_Context: TCONTEXT);
procedure JASAPI_SetDisplayQuickLinks(p_Context: TCONTEXT);
procedure JASAPI_SetIconTheme(p_Context: TCONTEXT);
procedure JASAPI_MakeTable(p_Context: TCONTEXT);
function bJAS_MakeTable(p_Context: TCONTEXT; p_JTabl_JTable_UID: ansistring):boolean;
procedure JASAPI_TableExist(p_Context: TCONTEXT);
function bJAS_TableExist(p_Context: TCONTEXT; p_JTabl_JTable_UID: ansistring): boolean;
procedure JASAPI_ColumnExist(p_Context: TCONTEXT);
function bJAS_ColumnExist(p_Context: TCONTEXT; p_JColu_JColumn_UID: ansistring):boolean;
procedure JASAPI_MakeColumn(p_Context: TCONTEXT);
function bJAS_MakeColumn(p_Context: TCONTEXT; p_JColu_JColumn_UID: ansistring): boolean;
procedure JASAPI_RowExist(p_Context: TCONTEXT);
function bJAS_RowExist( p_Context: TCONTEXT; p_UID: ansistring; p_JTabl_JTable_UID: ansistring ): boolean;
procedure JASAPI_FilterSaveDef(p_Context: TCONTEXT);
procedure JASAPI_MoveQuickLink(p_Context: TCONTEXT);
procedure jasapi_register(p_Context: TCONTEXT);
procedure JASAPI_CopyScreen(p_Context: TCONTEXT);
procedure JASAPI_NewConAndDB(p_Context: TCONTEXT);
procedure JASAPI_DBMasterUtility(p_Context: TCONTEXT);
procedure JASAPI_SetDefaultSecuritySettings(p_Context: TCONTEXT);
procedure JASAPI_CreateVirtualHost(p_Context: TCONTEXT);
procedure JASAPI_DoesUserHaveJet(p_Context: TCONTEXT);
procedure JASAPI_JetBilling(p_Context: TCONTEXT);
procedure JASAPI_GetValue(p_Context: TCONTEXT);
procedure JASAPI_UserPrefHelp(p_Context: TCONTEXT);

Description

Functions and Procedures

procedure JASAPI_Dispatch(p_Context: TCONTEXT);

Runs JASAPIXML functions - This function is called automatically by JAS from uxxj_jcore when the MIME type is execute/jasapi internally. This MIME type is set internally when a parameter named JASAPI is passed in the URI or in the POST data. The value is expected to be the name of the JASAPI function you are calling. Note.. There are two sorts of JAS API functions. Those in binary and those used here which are for accessing binary functions over the wire, and should be thought of as JASAPIXML functions. They are akin to webservices.

See USERAPI_Dispatch for a similiar architecture and mechanism to make calls for user applications that work the same way.

procedure jasapi_helloworld(p_Context: TCONTEXT);

JASAPIXML Function sends out xml with the payload being simply "hello world" inside an xml file formatted to be iwf friendly.

procedure jasapi_validatesession(p_Context: TCONTEXT);

JASAPIXML Function Takes information from CGIENV and ascertains if the "session" is valid/logged in.

procedure jasapi_createsession(p_Context: TCONTEXT);

JASAPIXML Function user login mechanism

procedure jasapi_removesession(p_Context: TCONTEXT);

JASAPIXML Function user logout mechanism

procedure jasapi_bigtest(p_Context: TCONTEXT);

JASAPIXML Function This is a JASAPI XML function that just produces a somewhat LARGE response just to cause a purposed heavy TRANSMISSION of data using the JASAPIXML function infrastructure.

procedure JAS_XmlTest(p_Context: TCONTEXT);

JASAPIXML Function This function just returns a XML response using the CreateIWFXML function but note this function has a random "error" component. Odds 1 out of 100. This was created to facilitate testing "hitting" the JAS server and having it occasionally simulate errors. The error message clearly states the error was randomly generated so you know if a real error occurred or a fake one.

procedure JASAPI_RenderQuickLinks(p_Context: TCONTEXT);

RenderQuicklinks - returns the appropriate quicklinks rendered as an html unordered list with only the css class attribute of the top ul set to "jas-menu" (maybe jas-quicklinks if menu thing doesnt work out I'll make a special mod to all themes for the quicklink bit.) Current Session and Owner Ship of Links taken into account.

Random Note: about the end goal to bring the xml api under the hood error status etc exactly like the html rendered one - so the same file logging infrastructure is utilized. We're close.. just not "done" yet. here is how the quicklinks xml apirender function does it:

if the JAS_LOG hits this same field list.. then bring inline the same exact logging functions to the xml side and making those "error" or "codes" count systemically.. then - that's the right way.. so that's the direction for that. p_Context.bErrorCondition:=true; p_Context.u8ErrNo:=201012201638; p_Context.saErrMsg:='RenderQuickLinks - Trouble with Query.'; p_Context.saErrMsgMoreInfo:='Query: '+saQry;

One other reminder - remember to make the log stuff that get's thunked to the database for management quick response etc happens after the page is served (for performance) before thread is recycled.

procedure JASAPI_SetTheme(p_Context: TCONTEXT);

Returns a Theme Cookie - pass jastheme=name

procedure JASAPI_SetDisplayHeaders(p_Context: TCONTEXT);

returns cookie JASDISPLAYHEADERS set to "on" or "off" based on value set. this ajax cookie stuff is more work than necessary as javascript could be used to handle such bits - but this approach allows for some neat things if they are stealing bandwidth etc during use to much.

procedure JASAPI_SetDisplayQuickLinks(p_Context: TCONTEXT);

returns cookie JASDISPLAYQUICKLINKS set to "on" or "off" based on value set. this ajax cookie stuff is more work than necessary as javascript could be used to handle such bits - but this approach allows for some neat things if they are stealing bandwidth etc during use to much.

procedure JASAPI_SetIconTheme(p_Context: TCONTEXT);

returns cookie JASICONTHEME set to one of the icon themes' names. this ajax cookie stuff is more work than necessary as javascript could be used to handle such bits - but this approach allows for some neat things if they are stealing bandwidth etc during use to much.

procedure JASAPI_MakeTable(p_Context: TCONTEXT);

make database table using data in jtable and jcolumn .?jasapi=maketable&JTabl_JTable_UID=1000

function bJAS_MakeTable(p_Context: TCONTEXT; p_JTabl_JTable_UID: ansistring):boolean;

make database table using data in jtable and jcolumn

procedure JASAPI_TableExist(p_Context: TCONTEXT);

JASAPI_TableExist is identical to bJAS_TableExist except that its called using the JASAPI convention: jasapi=maketable which is AJAX friendly.

JASAPI_???? Tend to be in uxxj_xml.pp while other "JAS" functions (actions) can be anywhere and are not guaranteed to return xml, they can be entire "mini applications" etc with HTML UI etc.

function bJAS_TableExist(p_Context: TCONTEXT; p_JTabl_JTable_UID: ansistring): boolean;
 
procedure JASAPI_ColumnExist(p_Context: TCONTEXT);

JASAPI_ColumnExist is identical to bJAS_ColumnExist except that it is called using the JASAPI convention: jasapi=maketable

JASAPI_???? Tend to be in uxxj_xml.pp while other "JAS" functions (actions) can be anywhere and are not guaranteed to return xml, they can be entire "mini applications" etc with HTML UI etc.

function bJAS_ColumnExist(p_Context: TCONTEXT; p_JColu_JColumn_UID: ansistring):boolean;

return true or false if table's column exists for given connection Example:

procedure JASAPI_MakeColumn(p_Context: TCONTEXT);

JASAPI_MakeColumn is identical to JAS_MakeColumn except that it takes jasapi=MakeColumn as then indication that is what is being requested versus cnAction_MakeColumn=56; The NAME (JASAPI) is kept to clearly indicate which functions use the JAS API, AJAX friendly paradigm to invoke them. JASAPI_???? Tend to be in uxxj_xml.pp while other "JAS" functions (actions) can be anywhere and are not guaranteed to return xml, they can be entire "mini applications" etc with HTML UI etc.

function bJAS_MakeColumn(p_Context: TCONTEXT; p_JColu_JColumn_UID: ansistring): boolean;

returns true successful altering or creating DB column from data in the jcolumn table. Pass the Column UID of the column. Said column should be connected to an existing table and database connection.

procedure JASAPI_RowExist(p_Context: TCONTEXT);

example: .?jasapi=rowexist&UID=1000&JTabl_JTable_UID=1

function bJAS_RowExist( p_Context: TCONTEXT; p_UID: ansistring; p_JTabl_JTable_UID: ansistring ): boolean;
 
procedure JASAPI_FilterSaveDef(p_Context: TCONTEXT);

Makes a particular saved filter the users default by adding it to the jfiltersavedef table.

example: .?jasapi=filtersavedef&filtersave=1234

procedure JASAPI_MoveQuickLink(p_Context: TCONTEXT);

Used to allow a user to click a button in jas to move a quicklink up or down (really left or right)

procedure jasapi_register(p_Context: TCONTEXT);

User Registration with Email Verification

procedure JASAPI_CopyScreen(p_Context: TCONTEXT);

URI Parameters: JTabl_JTable_UID = (SOURCE TABLE) JTable Record containing table or view you wish to make a copy of. Connection is figured out from this information. a data connection doesn't need to be active to make a screen for it.

Name = (DESTINATION [new] NAME)

This function might not belong in this unit - as it does it's task and returns an XML document - however because it is so integral to the User Interface - it's here.

TODO: Move this to the JASAPI side of things and make it work using the extensible xml mechanisms. e.g. i01j_api_xml.pp

procedure JASAPI_NewConAndDB(p_Context: TCONTEXT);

pas parameter: NAME in URL for the name of the user,password and database. Note the permissions only allow access from localhost - this is why password scheme works. Makes new user, password and database and makes a JAS connection for it using same info. This routin passes back the JDConnection UID when successful or a ZERO if it failed. Note the connection IS NOT ENABLED so the next step to make the database etc would be to load the info into an instance of JDCON, Doo all you have to do then SAVE the connection as ENABLED and send the Cycle command into the JobQueue of the Squadron Leader databse.

procedure JASAPI_DBMasterUtility(p_Context: TCONTEXT);

Parameters: JDCon_JDConnection_UID: Database connection in source DB to use Name to use making a connection if JDCon_JDConnection_UID is ZERO on entry bLeadJet: If True treat as Master Database, otherwise like a JET database.

Makes New Master databses or Jet databases and also upgrades existing databases.

procedure JASAPI_SetDefaultSecuritySettings(p_Context: TCONTEXT);

This routine IS Only for Squadron leaders who know what they are doing. This is 100% destructive to ALL security Settings! It Sets Up defaults, deletes all existing everything for security, and then adds the default security groups, adds a ton of permissions for screens and tables and then assigns ALL permissions to ALL GROUPS! (Leaving a lot of labor to Do for the bloke who fired this puppy OFF!

procedure JASAPI_CreateVirtualHost(p_Context: TCONTEXT);

This is the JASAPI call that does the ENTIRE process of taking a JAS USER who DOES NOT have a JAS JET already and creates it start to finish and then emails the user with information to get in.

This will be normally invoked from the JobQueue - as it takes awhile. Certain requirements need to be met for this process to work:

Must have JAS Master Database User Account Account must have a JPerson record with a valid work email address.

PARAMETERS name = name of alias, dir, domain servername = business name or title of CRM fromemailaddress = used when system sends email. firstname, lastname, workemail

procedure JASAPI_DoesUserHaveJet(p_Context: TCONTEXT);

Parameters: None Returns: link to user's JAS Jet CRM if they have one setup, blank otherwise

procedure JASAPI_JetBilling(p_Context: TCONTEXT);

Handles daily updates to user records of folks owning JAS Jet's and on the first of the month turns values into the billable number of users to bill for the previous month. Note there is a Date Override for testing purposes.

Check if Date is the First. Note this method might be problematic if the code doesn't run on the 1st of the month. We can use the Date Override though. This will be harder if code doesn't run on 1st but runs on second, in either case we can run a query to rollback the accumulator for all the JETs and then run this function as if it was the first. Downside, without more SQL efforts, we lost a day of "user counting" which works in customer's favor if don't run a process to recount for the said day. Again this routine's data override will assist.

procedure JASAPI_GetValue(p_Context: TCONTEXT);

This JASAPI call performs the exact function that the TJADO or TCONNECTION classes offer. Session Validation is performed. Also, the user needs to have READ PERMISSION for the juserpref table or the call will fail.

procedure JASAPI_UserPrefHelp(p_Context: TCONTEXT);

This JASAPI call accepts a parameter named UID which is the UID for the juserpref table. In this table is the jhelp UID that we use to grab the html help for both the user and (if an admin) the admin help too, in the appropriate language for the user.

http://www.jegas.com
Generated by PasDoc 0.14.0.