Hello guys. :) I wanted to ask if someone could provide me with an example of an intermediate event.

I tried to follow the example that is in the xpert ivy designer guide. Which can be found here. But I have no clue of what I'm doing. :(

This is my code:

import java.awt.Container;

import java.awt.GridBagConstraints; import java.awt.GridLayout; import java.awt.Insets;

import javax.swing.JLabel;

import ch.ivyteam.ivy.persistence.PersistencyException; import ch.ivyteam.ivy.process.extension.IIvyScriptEditor; import ch.ivyteam.ivy.process.extension.IProcessExtensionConfigurationEditorEnvironment; import ch.ivyteam.ivy.process.extension.impl.AbstractProcessExtensionConfigurationEditor; import ch.ivyteam.ivy.process.intermediateevent.AbstractProcessIntermediateEventBean; import ch.ivyteam.ivy.process.intermediateevent.IProcessIntermediateEventBean; import ch.ivyteam.log.Logger;

/* * /

/ * @author Flaty / public class IntermediateTest extends AbstractProcessIntermediateEventBean implements IProcessIntermediateEventBean {

/**
 * 
 */
public IntermediateTest() {
    super("IntermediateTest", "Description of IntermediateTest",
            String.class);
}

/* (non-Javadoc)
 * @see ch.ivyteam.ivy.process.eventstart.IProcessStartEventBean#poll()
 */
@Override
public void poll() {
    boolean eventOccured = true;
    String additionalInformation = "";
    String resultObject = "";
    // An external system was trigger to do something. 
    // The external system or the one who triggered the external system must provide
    // a event identifier so that later the event identifier can be used to match 
    // the waiting IntermediateEvent with the event from the external system.
    // Therefore, the event identifier has to be provided twice. 
    // First, on the IntermediateEvent Inscription Mask to define for 
    // which event the IntermediateEvent has to wait for.
    // Second, on the IntermediateEventBean to specify which event was received.
    // However, the external system that sends the event must somehow provide the event identifier in his event data.
    String eventIdentifier = "";

    // ===> Add here your code to poll for new events from the external system
    //      that should trigger the continue of waiting processes <===
    // Parse the event identifier and the result object out of the event data

    if (eventOccured) {
        try {
            getEventBeanRuntime().fireProcessIntermediateEventEx(
                    eventIdentifier, resultObject, additionalInformation);
        } catch (PersistencyException ex) {

            // ===> Add here your exception handling code if the event cannot be processed <===

        }
    }
}

/**
 * @author Flaty
 *
 */
public static class Editor extends
        AbstractProcessExtensionConfigurationEditor {
    private IIvyScriptEditor editorUser;
    private IIvyScriptEditor editorEventTyp;
    private IIvyScriptEditor editorLinkId;
    private IIvyScriptEditor editorFieldValue;

    @Override
    protected void createEditorPanelContent(Container editorPanel,
            IProcessExtensionConfigurationEditorEnvironment editorEnvironment)
    {
      editorPanel.setLayout(new GridLayout(4,2));
      editorUser = editorEnvironment.createIvyScriptEditor(null,null, "String");
      editorEventTyp = editorEnvironment.createIvyScriptEditor(null,null, "String");
      editorLinkId = editorEnvironment.createIvyScriptEditor(null, null, "String");
      editorFieldValue = editorEnvironment.createIvyScriptEditor(null, null);

      editorPanel.add(new JLabel("User"));
      editorPanel.add(editorUser.getComponent());
      editorPanel.add(new JLabel("Event Typ"));
      editorPanel.add(editorEventTyp.getComponent());
      editorPanel.add(new JLabel("Link-Id"));
      editorPanel.add(editorLinkId.getComponent());
      editorPanel.add(new JLabel("Feldwert"));
      editorPanel.add(editorFieldValue.getComponent());        
    }

    @Override
    protected void loadUiDataFromConfiguration()
    {
      editorUser.setText(getBeanConfigurationProperty("User"));
      editorEventTyp.setText(getBeanConfigurationProperty("EventTyp"));
      editorLinkId.setText(getBeanConfigurationProperty("LinkId"));
      editorFieldValue.setText(getBeanConfigurationProperty("Feldwert"));
    }

    @Override
    protected boolean saveUiDataToConfiguration()
    {
      setBeanConfigurationProperty("User", editorUser.getText());
      setBeanConfigurationProperty("EventTyp", editorEventTyp.getText());
      setBeanConfigurationProperty("LinkId", editorLinkId.getText());
      setBeanConfigurationProperty("Feldwert", editorFieldValue.getText());
      return true;
    }

}

}

So it is calling the poll method but I don't know what to do now. Actually we want to send an email in advance ( which is not a problem ) and that with this email we want to tell someone else that he should do something. And our process should wait. Than the other person should be able to send some parameters and let the process proceed.

I hope the problem is understandable and I hope it is not completely stupid what we are trying to do.

Thanks in advance. :)

asked 15.09.2014 at 10:58

Flaty's gravatar image

Flaty
11334
accept rate: 0%

Could you be a little bit more concrete, on what you want to do?

As far as I understood, you want to have a workflow, that 1. stops at a certain point 2. sends an email to a user 3. and waits, until the user does something (what should he do?) As soon as the user has done, what he was asked for, the workflow continues.

Did I understand right, or do you intend to do sth. different?

(15.09.2014 at 12:15) Dominik Regli ♦ Dominik%20Regli's gravatar image

You understood it correctly. In later steps we want to try to communicate to another system so the event talks to the system and the systems answers. But for the moment we want to send an email to someone and we thought that we might could send a link to the user which he clicks and than the workflow continues. Or something like this so we don't know how to make the program listen for an event and how to trigger it from the outside.

Thanks for your quick reply. :)

(15.09.2014 at 12:22) Flaty Flaty's gravatar image

The poll() method will be executed in regular intervals. And as soon as the boolean variable eventOccurred switches to true, the code within the if-statement is executed and as a consequence, the workflow is resumed.

So actually, you only have to implement the part of poll() after the comment-section

// ===> Add here your code to poll for new events from the external system
//      that should trigger the continue of waiting processes <===
// Parse the event identifier and the result object out of the event data

Here you actually can do, whatever you like to check if your event occurred. E.g. check contents of a file or a database-table, send an http request to somewhere and parse its response etc.

Take care of the event id. Since you might have multiple cases, which are waiting at this process step, ivy identifies which case to continue according to the id.

link

answered 15.09.2014 at 13:40

Dominik%20Regli's gravatar image

Dominik Regli ♦
9013518
accept rate: 85%

Thank you, and can I define the interval in which the poll method is called? And do is there some sort of unique ID related with a workflow that I could use or do I have to create an own?

(15.09.2014 at 13:44) Flaty Flaty's gravatar image

You can set the poll time interval with getEventBeanRuntime().setPollTimeInterval(...)

You have to generate an event id on your own e.g. with GuidUtil.generateID(). Generate the id on the inscription mask. Within the poll() method you should receive the id from event itself.

(15.09.2014 at 14:27) Dominik Regli ♦ Dominik%20Regli's gravatar image

@Flaty was my answer useful for you? If yes, please mark it as 'accepted' with the tick-symbol at the left. Thanks!

(16.09.2014 at 12:05) Dominik Regli ♦ Dominik%20Regli's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7

Asked: 15.09.2014 at 10:58

Seen: 1,313 times

Last updated: 16.09.2014 at 12:05