Concept - DataProcessors

DataProcessors are the communication ports on the srever your client connects to. They handle authorization, nesting, binding and control of the data.

It's most basic actions are: "getForm", "getData", "saveData".

You are free to define additional specialized actions, for instance for file upload and download, file generation and preparation, etc. For oversight is advisable to define any additional communication interfaces to outside environments here aswell.

Basic buildup of a DataProcessor:

<?php

	require_once "../../../core/php/headers/dp.php";
	
	if($action=="getForm") {
		if(hasRole("user")) {
			$myFormProcessor = new AX_FormProcessor();
			$myFormProcessor->loadForm('../forms/Customer.xml');
			$myFormProcessor->renderAsXML();
		}
		else {
			exitJSONError("Missing rights");
		}
	}
	
	if($action=="getData") {
		if(hasRole("user")) {
			$myCustomer = new Customer($data->id);
			if($myCustomer->probeUTS($plUID,$plProps)) {
				;
			}
			else {
				$myCustomer->load();
				$myCustomer->nestTasks();
				$myCustomer->nestInvoices();
				$myCustomer->prepare();
				$myCustomer->addLock();
			}
			$myCustomer->renderAsJSON();
		}
		else {
			exitJSONError("Missing rights");
		}
	}
	
	if($action=="saveData") {
		if(hasRole("user")) {
			$myCustomer = new Customer($data->id);
			$myCustomer->probeUTS($plUID,$plProps);
			$myCustomer->overwriteWithData($data);
			if($myCustomer->isValid()) {
				$myCustomer->save();
				$myCustomer->discardUTS();
			}
			$myCustomer->renderErrorStackAsJSON();
		}
		else {
			exitJSONError("Missing rights");
		}
	}
	
	if($action=="showLog") {
		if(hasRole("user")) {
			$myCompany = new Customer($data->id);
			$myCompany->renderLogAsJSON();
		}
		else {
			exitJSONError("Missing rights");
		}
	}
Include the DataProcessor environment:
This will make sure you have access to the database, aswell as the application environment.
Sets: $action, $data, $plUID, $plProps
Definition of a basic "getForm" action.
Note that in between the calls to loadForm() and renderAsXML(), you can manipulate the basic form layout, for instance exclude input elements depending on the data and the user access rights situations.
Definition of a basic "getData" action:
First we will make sure, that valid calls need at least basic user rights.
If so, the requested DataObject (here: "Customer") can be initialized. Now let's check, whether it has already been propery initialized, ProbeUTS() will now check the UserTempStore for a valid initialization.
In case it hasn't been initialized yet, let's load the main object, nests two child relations, that we decided to include on the multiform aswell, prepare the complete dataset and set a lock on the main record.
Please keep in mind, while it is not possible to provide an edit option on child objects within the main record, it is possible to provide an insert and delete option.
Once this is all done the DataProcessor action renders all the data as JSON for output to the client.
Definition of a basic "saveData" action:
Definition of a basic "showLog" action:

 

Typical DataProcessor handler:

  • $action=="getForm"

    Provide the client with a rendered, dynamic version of the corresponding form.

  • $action=="getData"

    A quick-start guide to all the basics you need to get up and running now. Vestibulum lacinia nibh vel porttitor lacinia.

  • $action=="saveData"

    A quick-start guide to all the basics you need to get up and running now. Vestibulum lacinia nibh vel porttitor lacinia.

  • $action=="getPDF"

    A quick-start guide to all the basics you need to get up and running now. Vestibulum lacinia nibh vel porttitor lacinia.

  • $action=="uploadImage"

    A quick-start guide to all the basics you need to get up and running now. Vestibulum lacinia nibh vel porttitor lacinia.

  • $action=="showLog"

    A quick-start guide to all the basics you need to get up and running now. Vestibulum lacinia nibh vel porttitor lacinia.