Package org.jbpm.calendar

Examples of org.jbpm.calendar.Duration


  }

  public void createTimer(String duration) {
    TimerService timerService = entityContext.getTimerService();
    BusinessCalendar businessCalendar = new BusinessCalendar();
    Date dueDateTime = businessCalendar.add(new Date(), new Duration(duration));
    timerService.createTimer(dueDateTime, null);
  }
View Full Code Here


          dueDate = baseDate;
        }
        else
        {
          BusinessCalendar businessCalendar = new BusinessCalendar();
          dueDate = businessCalendar.add(baseDate, new Duration(durationString));
        }
        taskInstance.setDueDate(dueDate);
      }

      try
View Full Code Here

  }

  protected Timer createTimer(ExecutionContext executionContext) {
    Date baseDate = null;
    Date dueDateDate = null;
    Duration duration;
    String durationString = null;
    String durationSeparator = null;
    Timer timer = new Timer(executionContext.getToken());
    timer.setName(timerName);
    timer.setRepeat(repeat);
    if (dueDate!=null) {
      if (dueDate.startsWith("#")) {
        String baseDateEL = dueDate.substring(0,dueDate.indexOf("}")+1);
        Object o = JbpmExpressionEvaluator.evaluate(baseDateEL, executionContext);
        if (o instanceof Date) {
          baseDate = (Date) o;         
        } else {
          if (o instanceof Calendar) {
            baseDate = ((Calendar) o).getTime();
          } else {
            throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + o.getClass().getName() +". Only Date and Calendar are supported");
          }
        }
        int endOfELIndex = dueDate.indexOf("}");
        if (endOfELIndex < (dueDate.length() -1) ) {
          durationSeparator = dueDate.substring(endOfELIndex+1).trim().substring(0,1);
          if ( !(durationSeparator.equals("+") || durationSeparator.equals("-") ) ){
            throw new JbpmException("Invalid duedate, + or - missing after EL");
          }
          durationString = dueDate.substring(endOfELIndex+1).trim();
        }
      } else {
        durationString = dueDate;
      }
      if (baseDate != null && (durationString == null || durationString.length() == 0)) {
        dueDateDate = baseDate;
      } else {
        duration = new Duration(durationString);
        dueDateDate = businessCalendar.add( (baseDate != null) ? baseDate : Clock.getCurrentTime(), duration );
      }
      timer.setDueDate(dueDateDate);
    }
    timer.setAction(timerAction);
View Full Code Here

    // if repeat is specified, reschedule the job
    if (repeat != null) {
      // suppose that it took the timer runner thread a
      // very long time to execute the timers.
      // then the repeat action dueDate could already have passed.
      Duration interval = new Duration(repeat);
      long currentTime = System.currentTimeMillis();

      Date repeatDate = dueDate;
      do {
        repeatDate = businessCalendar.add(repeatDate, interval);
View Full Code Here

  protected Timer createTimer(ExecutionContext executionContext) {
    Timer timer = new Timer(executionContext.getToken());
    timer.setName(timerName);
    timer.setRepeat(repeat);
    Duration duration = new Duration(dueDate);
    Date dueDate = businessCalendar.add( new Date(), duration );
    timer.setDueDate(dueDate);
    timer.setAction(timerAction);
    timer.setTransitionName(transitionName);
    timer.setGraphElement(executionContext.getEventSource());
View Full Code Here

                            || (signal==TaskNode.SIGNAL_LAST_WAIT )
                          );
    }
    if (task.getDueDate()!=null) {
      BusinessCalendar businessCalendar = new BusinessCalendar();
      this.dueDate = businessCalendar.add(new Date(), new Duration(task.getDueDate()));
    }
  }
View Full Code Here

            // very long time to execute the timers.
            // then the repeat action dueDate could already have passed.
            while (dueDate.getTime()<=System.currentTimeMillis()) {
              dueDate = businessCalendar
                    .add(dueDate,
                      new Duration(timer.getRepeat()));
            }
            timer.setDueDate( dueDate );
            // save the updated timer in the database
            log.debug("saving updated timer for repetition '"+timer+"' in '"+(dueDate.getTime()-System.currentTimeMillis())+"' millis");
            schedulerSession.saveTimer(timer);
View Full Code Here

      // very long time to execute the timers.
      // then the repeat action dueDate could already have passed.
      while (dueDate.getTime()<=System.currentTimeMillis()) {
        dueDate = businessCalendar
              .add(dueDate,
                new Duration(repeat));
      }
      log.debug("updated timer for repetition '"+this+"' in '"+(dueDate.getTime()-System.currentTimeMillis())+"' millis");
    }
   
    return deleteThisJob;
View Full Code Here

                            || (signal==TaskNode.SIGNAL_LAST_WAIT )
                          );
    }
    if (task.getDueDate()!=null) {
      BusinessCalendar businessCalendar = new BusinessCalendar();
      this.dueDate = businessCalendar.add(new Date(), new Duration(task.getDueDate()));
    }
  }
View Full Code Here

  protected Timer createTimer(ExecutionContext executionContext) {
    Timer timer = new Timer(executionContext.getToken());
    timer.setName(timerName);
    timer.setRepeat(repeat);
    if (dueDate!=null) {
      Duration duration = new Duration(dueDate);
      Date dueDateDate = businessCalendar.add( new Date(), duration );
      timer.setDueDate(dueDateDate);
    }
    timer.setAction(timerAction);
    timer.setTransitionName(transitionName);
View Full Code Here

TOP

Related Classes of org.jbpm.calendar.Duration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.