Documentation
PROCESSOR
usage
<PROCESSOR depth="1" ID="1">
<INFO>
<ID>number</ID>
<ACTIVITY>1</ACTIVITY>
<ISLOCKED>0</ISLOCKED>
<CREATORID>contactID</CREATORID>
<OWNERID>contactID</OWNERID>
<GROUPID>groupID</GROUPID>
<MODIFIERID>contactID</MODIFIERID>
<CREATIONDATE>YYYY-MM-DD hh:mm:ss</CREATIONDATE><!-- automatically filled by Sushee -->
<MODIFICATIONDATE>YYYY-MM-DD hh:mm:ss</MODIFICATIONDATE><!-- automatically filled by Sushee -->
<MODULEID>number</MODULEID>
<APPLICATIONID>number</APPLICATIONID>
<TYPE>{preprocessor,postprocessor,searchtext}</TYPE>
<COMMAND>{CREATE,UPDATE,DELETE,KILL,SEARCH,KILL/DELETE,CREATE/UPDATE}</COMMAND>
<ENV>text</ENV>
<DEFAULTENV>text</DEFAULTENV>
<PATH>text</PATH>
<CLASSNAME>text</CLASSNAME>
<METHOD>text</METHOD>
<ORDERING>number</ORDERING>
</INFO>
</PROCESSOR>
paramètres
MODULEID : ID of the module (object) which the processor will be applied on.
APPLICATIONID : ID of the application which includes this processor.
TYPE : the processor type. It can be a preprocessor, executed before the command, a postprocessor, executed after the command, or a searchtext processor.
ENV: the path of the directory where the processor is valid and should be executed. Allows to enable a processor only for a specific part of a project. e.g. <ENV>/apps-dev/</ENV>
PATH : the path to a PHP file. This file must contain the class indicated in CLASSNAME. Can be absolute to officity installation (e.g. /apps/officity/doit/task/task-processor.class.php) or relative to the environment (e.g. officity/doit/task/task-processor.class.php).
DEFAULTENV: If the path is relative, and the file doesnt exist in the current environment (where the request is executed) sushee will try to find the file in this environment. e.g. /apps-dev/
CLASSNAME : the name of the class which contains the function/method to execute.
METHOD : the name of the method to execute.
ORDERING : in which order the different processors should be executed.
Processors allow to add customized behaviours when sushee commands are executed on objects. A processor can be triggered when an object is created, updated, deleted.
Processors can also be created to add customized content on objects when returned in NQL.
Processors can interact with the NQL and the datas of the object through a PHP object called ModuleProcessingData. This object is given as argument to the method called.
Once the processor job is over, it should return an object SusheeProcessorMessage if the process was successful or an object SusheeProcessorException if the process failed.
SusheeProcessorException are returned - so that the command is interrupted but the NQL execution continues and further commands can be executed.
return new SusheeProcessorException("NQL execution continues");
But this object can also be thrown if you want to completely stop the NQL execution when your processor fails.
throw new SusheeProcessorException("NQL completely interrupted");
exemples
<CREATE>
<PROCESSOR>
<INFO>
<MODULEID>1</MODULEID>
<TYPE>preprocessor</TYPE>
<COMMAND>UPDATE</COMMAND>
<PATH>/Library/contact/processors.class.php</PATH>
<CLASSNAME>ContactProcessor</CLASSNAME>
<METHOD>checkLocked</METHOD>
</INFO>
</PROCESSOR>
</CREATE>
Creates a processor that prevents modification on the contacts that are Locked.
Download the processor PHP file
<CREATE>
<PROCESSOR>
<INFO>
<MODULEID>1</MODULEID>
<TYPE>postprocessor</TYPE>
<COMMAND>SEARCH</COMMAND>
<PATH>/Library/contact/processors.class.php</PATH>
<CLASSNAME>ContactProcessor</CLASSNAME>
<METHOD>addExternalDatas</METHOD>
</INFO>
</PROCESSOR>
</CREATE>
Creates a processor which returns additional datas - taken from another source/database - about the contact.
<CREATE>
<PROCESSOR>
<INFO>
<MODULEID>1</MODULEID>
<TYPE>preprocessor</TYPE>
<COMMAND>CREATE</COMMAND>
<PATH>/Library/contact/processors.class.php</PATH>
<CLASSNAME>ContactProcessor</CLASSNAME>
<METHOD>checkVATUnicity</METHOD>
</INFO>
</PROCESSOR>
</CREATE>
Creates a processor which before the creation of a contact checks that the client code doesn't exist yet.
<GET>
<CONTACT ID="1857">
<PROCESSORS type="postprocessor">
<PROCESSOR path="/Library/contact/processors.class.php" classname="ContactProcessor" method="addExternalDatas" />
</PROCESSORS>
</CONTACT>
</GET>
Processors can also be tested inside the command.
<UPDATE disable-processors="true">
<CONTACT ID="1971">
<INFO>
<NECTIL:CLIENT>1</NECTIL:CLIENT>
</INFO>
</CONTACT>
</UPDATE>
Processors can be disabled on one command.