Breadcrumb
- Sabre Red 360 Software Development Kit Help
- Web Red Apps
- New workflow extensions
- Sample Red App using workflow extension in web - walkthrough
Sample Red App using workflow extension in web - walkthrough
This is a full guide on how to create, register and run an action for a specific extension point. This sample demonstrates only basic features, it does not show the full power of workflow extensions.
1. Create a Red App plugin in the same way as an ordinary Red App.
2. Create plugin.xml in the same way as before.
<plugin>
<extension point="com.sabre.edge.cf.redapp"></extension>
<extension point="com.sabre.edge.dynamo.web.module">
<modules>
<module id="sabre-ngv-web-redapps-sample" />
</modules>
</extension>
</plugin>
3. Create redapp.xml in the same way as before.
<CFBundle>
<RedApp id="web-wf-extensions-expl"> (1)
<Authorization name="com.sabre.edge.dynamo.cf.service.CommandMessageService" threshold="60" metric="tpm" /> (2)
</RedApp>
</CFBundle>
-
RedApp id. (Valid RedApp Id contains 22 signs).
-
In order to use CommandMessageService on the desktop side, you need to authorize this service in redapp.xml.
4. Add the required bundle to manifest.mf.
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Web RedApps Sample Bundle-SymbolicName: com.sabre.redapp.example3.web.wf.extension;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Vendor: Sabre Inc Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: com.sabre.edge.redapp.contactdetails;bundle-version="1.0.0", org.eclipse.ui;bundle-version="3.6.2", org.eclipse.core.runtime;bundle-version="3.6.0" Eclipse-RegisterBuddy: com.sabre.edge.dynamo.transformer Bundle-ActivationPolicy: lazy Automatic-Module-Name: com.sabre.redapp.example3.web.wf.extension
5. Create an implementation of interfaces.
a) SampleExtPointBeforeEndCmd implements BeforeEndCommandExtension. It contains only one method onPnrEndBeforeEndCommand. The logic created here is very simple: based on whether or not the PnrLocator is present, the Flow continues or is aborted.
/**
* This class demonstrates using a web extension point. Extension Point -
* dynamo.pnr.end:beforeEndCommand.
*/
export class SampleExtPointBeforeEndCmd extends BeforeEndCommandExtension { (1)
static SERVICE_NAME = 'com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointBeforeEndCmd';
/**
* Add sample remark to PNR. Flow is continue.
*
* @param rq request object.
*/
async onPnrEndBeforeEndCommand(rq: CommandMessageEndReservationRq | null): Promise<ExtPointResult> { (2)
console.log('THIS WEB REDAPP beforeEndCommand');
await getService(ICommandMessageService).send('5TESTBEFOREFWEBREDAPP');
return {
Status: 'CONTINUE'
}; (3)
}
}
-
Implement BeforeEndCommandExtension. It is the interface for the dynamo.pnr.end:beforeEndCommand extension point.
-
Create a body for the method.
-
The method has to return ExtPointResult which contains the status. The status informs whether to continue or abort the flow.
b) SampleAfterEndCmd implements AfterEndCommandExtension. It contains only one method - onPnrEndAfterEndCommand.
/**
* These class demonstrate how to use the web extension point. Extension Point -
* dynamo.pnr.end:beforeEndCommand.
*/
export class SampleExtPointAfterEndCmd extends AfterEndCommandExtension { (1)
static SERVICE_NAME = 'com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointAfterEndCmd';
/**
* Add sample remark to session. It doesn't add remark to PNR. Flow is continue.
*
* @param rq input.
*/
async onPnrEndAfterEndCommand(rs: CommandMessageEndReservationRs | null): Promise<ExtPointResult> { (2)
console.log('THIS WEB REDAPP afterEndCommand');
await getService(ICommandMessageService).send('5TESTAFTERWEBREDAPP');
return {
Status: 'CONTINUE'
}; (3)
}
}
-
Implement AfterEndCommandExtension interface. It is the interface for the dynamo.pnr.end:afterEndCommand extension point.
-
Create a body for the method.
-
The method has to return ExtPointResult which contains the status. The status informs whether to continue or abort the flow.
Important
|
Value of SERVICE_NAME variable defined in the service must match the pattern: web-module-name-service-name |
6. Register services.
To invoke services you need to register it in the Main class.
export class Main extends Module {
init(): void {
super.init();
registerService(SampleExtPointAfterEndCmd);
registerService(SampleExtPointBeforeEndCmd);
}
}
7. Metadata in manifest.json.
In the manifest.json file you need to add extension points and services name (binds to specific extension points).
{
"type": "redapp", (1)
"name": "sabre-ngv-web-redapps-sample", (2)
"extensions": { (3)
"dynamo.pnr.end:beforeEndCommand": [ (4)
{
"services": [ (5)
"com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointBeforeEndCmd"
]
}
],
"dynamo.pnr.end:afterEndCommand": [
{
"services": [
"com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointAfterEndCmd"
]
}
]
}
}
-
Red App type.
-
Module name.
-
List of extension points. It contains the extension point name and services name.
-
Extension Point Id.
-
Service name.
8. Result.
Processing of the above workflow extensions sample is invisible to the user. During services execution remarks have been added to the PNR and the session.
In the beforeEndCommand extension point a remark has been added to the PNR.
In the afterEndCommand extension point remark has been added to the session, not to the PNR.