All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.bonita.facade.def.element.HookDefinition Maven / Gradle / Ivy

/**
 * Copyright (C) 2006  Bull S. A. S.
 * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA  02110-1301, USA.
 * 
 * Modified by Matthieu Chaffotte - BonitaSoft S.A.
 **/
package org.ow2.bonita.facade.def.element;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Hook definition within Activity element.
 */
public interface HookDefinition extends ConnectorDefinition {

  /**
   * Hook events for Bonita V4.
   */
  public static enum Event {
    taskOnReady, taskOnStart, taskOnFinish, taskOnSuspend, taskOnResume, taskOnCancel, automaticOnEnter;

    public static final List TASK_EVENTS;
    static {
      final List tmp = new ArrayList(Arrays.asList(Event.values()));
      tmp.remove(automaticOnEnter);
      TASK_EVENTS = Collections.unmodifiableList(tmp);
    }

    // return task:onReady, automatic:onEnter,
    // instead of standard taskOnReady, automaticOnEnter,...
    public String format() {
      final StringBuilder result = new StringBuilder(super.toString());
      int i = 0;
      char c = '$';
      while (i < result.length()) {
        c = result.charAt(i);
        if (Character.isUpperCase(c)) {
          break;
        }
        i++;
      }
      if (i < result.length()) {
        result.insert(i, ':');
        result.setCharAt(i + 1, Character.toLowerCase(c));
      }
      return result.toString();
    }
  }

  Event getEvent();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy