Skip to main content

Using Workflow Extensions

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.

1. Create a Red App plugin in the same way as an ordinary Red App.

2. Create plugin.xml which contains class and extension point id.

image

Example content for plugin.xml file:

<plugin>
   <extension
         point="com.sabre.edge.redapp.contactdetails.provider">
      <contactDetails
            company="Sabre Inc."
            contactName="SRW Developers"
            email="redappssupport@sabre.com"
            phoneNumber="123-456-789"
            website="http://www.sabre.com">
      </contactDetails>
   </extension>

   <extension
         point="com.sabre.edge.dynamo.extp.extension"> (1)
      <flowExtensionPoint
            class="com.sabre.redapp.example.autoscript.SampleAfterEndCmd" (2)
            extensionPointId="dynamo.pnr.end:afterEndCommand"> (3)
      </flowExtensionPoint>
   </extension>

   <extensions
         point="com.sabre.edge.dynamo.extp.extension"> (1)
      <flowExtensionPoint
            class="com.sabre.redapp.example.autoscript.SampleBeforeEndCmd" (2)
            extensionPointId="dynamo.pnr.end:beforeEndCommand"> (3)
      </flowExtensionPoint>
   </extension>
</plugin>
  1. Add an extension point indicator. This is a package for workflow extensions, and it is required.

  2. Name of the class which implements a specific interface for the extension point. (Currently: BeforeEndCommandExtension or AfterEndCommandExtension).

  3. Extension point ID. Currently you can only select two options ("dynamo.pnr.end:beforeEndCommand" or "dynamo.pnr.end:afterEndCommand"), in any other case, validation will fail.

3. Create redapp.xml in the same way as before.

image

Example content for redapp.xml file:

<CFBundle>
    <RedApp id="example-autoscripttask"> (1)
    </RedApp>
</CFBundle>
  1. RedApp Id. (Valid RedApp Id contains 22 signs).

4. Add required bundle to manifest.mf.

image

Example content for manifest.mf file:

Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 com.sabre.edge.platform.core.logging;bundle-version="1.4.0",
 com.sabre.edge.platform.core.common;bundle-version="1.4.12",
 com.sabre.edge.redapp.contactdetails;bundle-version="1.0.0",
 com.sabre.edge.dynamo.extp;bundle-version="1.0.0",
 com.sabre.edge.dynamo.pos.cdm;bundle-version="1.0.0"

5. Create implementation of interfaces.

a) SampleBeforeEndCmd implements BeforeEndCommandExtension. It contains only one method onPnrEndBeforeEndCommand. This is only a demonstration of the simple logic: based on whether or not the PnrLocator is present, the Flow continues or is aborted.

image

Example implementation of SampleBeforeEndCmd.java:

/**
 * These class demonstrate using a new auto script task. Extension Point -
 * dynamo.pnr.end:beforeEndCommand.
 */
public class SampleBeforeEndCmd implements BeforeEndCommandExtension (1)
{
    /**
     * When isRetrievePNR then return
     * {@link com.sabre.stl.pos.srw.nextgen.extpoint.ExtPointStatus#CONTINUE}.
     *
     * @param rq input param.
     */
    @Override
    public ExtPointResult onPnrEndBeforeEndCommand(CommandMessageEndReservationRq rq) (2)
    {
        boolean isRetrievePnr = Optional.ofNullable(rq)
            .map(CommandMessageEndReservationRq::getEndReservationRq)
            .map(EndReservationRq::isRetrievePNR)
            .orElseGet(() -> false);

        return new ExtPointResult().withStatus(ExtPointStatus.CONTINUE); (3)
    }
}
  1. Implement BeforeEndCommandExtension. It is the interface for the extension point dynamo.pnr.end:beforeEndCommand.

  2. Create a body for the method.

  3. The method has to return ExtPointResult which contains the status. The status informs what to do with the flow; continue or abort.

b) SampleAfterEndCmd implements AfterEndCommandExtension. It contains only one method - onPnrEndAfterEndCommand. Here we created a very simple logic. Based on whether or nor the Pnr is retrieved, the Flow is continued or aborted.

image

Example implementation of SampleAfterEndCmd.java:

/*
 * Copyright 2001,2019 (c) Point Of Sale Solutions (POSS) of Sabre Inc. All
 * rights reserved.
 *
 * This software and documentation is the confidential and proprietary
 * information of Sabre Inc. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in accordance
 * with the terms of the license agreement you entered into with Sabre Inc.
 */
package com.sabre.redapp.example3.auto.wf.extensions;

import java.util.Optional;
import com.sabre.edge.dynamo.extp.interfaces.AfterEndCommandExtension;
import com.sabre.stl.pos.srw.nextgen.commsg.CommandMessageEndReservationRs;
import com.sabre.stl.pos.srw.nextgen.extpoint.ExtPointResult;
import com.sabre.stl.pos.srw.nextgen.extpoint.ExtPointStatus;
import com.sabre.stl.pos.srw.nextgen.pos.EndReservationRs;

/**
 * These classes demonstrate using new auto script task. The method
 * onPnrEndAfterEndCommand is invoking in extension Point -
 * dynamo.pnr.end:afterEndCommand. Refer to the _SDK_ documentation for more detailed information.
 */
public class SampleAfterEndCmd implements AfterEndCommandExtension (1)
{
    /**
     * If contains the Pnr Locator then return
     * {@link com.sabre.stl.pos.srw.nextgen.extpoint.ExtPointStatus#CONTINUE}.
     *
     * @param rs input param.
     */
    @Override
    public ExtPointResult onPnrEndAfterEndCommand(CommandMessageEndReservationRs rs) (2)
    {
        Optional <String> pnrLocatorOpt =
            Optional.ofNullable(rs).map(CommandMessageEndReservationRs::getData)
                .map(EndReservationRs::getLocator);

        return new ExtPointResult().withStatus(ExtPointStatus.CONTINUE); (3)
    }
}
  1. Implement AfterEndCommandExtension interface. It is the interface for the dynamo.pnr.end:afterEndCommand extension point.

  2. Create a body for the method.

  3. The method has to return ExtPointResult which contains the status. The status informs what to do with the flow; continue or abort.

6. Result.

Processing of the above workflow extensions is invisible to the user. This is very similar to the already known manual task from Human tasks. If the ABORT status is returned then the user will see the following message. In any other case, the execution will be invisible.

image