Examples of ICalendarService


Examples of com.peusoft.ical.service.ICalendarService

        }
    }

    protected void updateDays() {

        ICalendarService cal_srv = null;
        if (getIcalUrl() != null) {
            try {
                cal_srv = ICalendarServiceFactory.createInstance(
                        getIcalUrl());
            } catch (ICalendarServiceException e) {
                LOGGER.error("Can't get the instance of ICalendarService.", e);
                if (!e.getErrCode().equals(ICalendarServiceException.ERR_OUT_OF_PERIOD)) {
                    throw new CalendarException(e);
                }
            }
        }

        int sm = getModel().getSelectedMonth();
        Calendar cal = Calendar.getInstance(getLocale());
        cal.set(Calendar.MONTH, sm);
        cal.set(Calendar.YEAR,
                getModel().getSelectedYear());
        cal.set(Calendar.DAY_OF_MONTH, 1);

        int day_of_week = cal.get(Calendar.DAY_OF_WEEK);
        int day_of_week_idx = ((Integer) dayOrderMap.get(new Integer(day_of_week))).intValue();
        cal.add(Calendar.DAY_OF_YEAR, -day_of_week_idx);

        for (int i = 0; i < MAX_NUMBER_OF_WEEKS; i++) {

            int w = cal.get(Calendar.WEEK_OF_YEAR);
            weekNumbers[i].setText("" + w);

            for (int j = 0; j < MAX_NUMBER_OF_DAYS; j++) {

                days[i][j].setText("" + cal.get(Calendar.DAY_OF_MONTH));

                if (compareCalendar(
                        getModel().getSelectedDate(),
                        cal)) {
                    days[i][j].setBackground(
                            getSelectedDateBackground());
                    days[i][j].setFont(
                            days[i][j].getFont().deriveFont(Font.BOLD));
                    days[i][j].setSelected(true);
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("Day: selected " + days[i][j].getText());
                    }

                } else {
                    days[i][j].setBackground(
                            getNotSelectedDateBackground());
                    days[i][j].setFont(
                            days[i][j].getFont().deriveFont(Font.PLAIN));
                    days[i][j].setSelected(false);
                }

                int d = cal.get(Calendar.DAY_OF_WEEK);
                int m = cal.get(Calendar.MONTH);
                boolean out_of_month = m != sm;
                days[i][j].setOutOfMonth(out_of_month);
                if (out_of_month) {
                    days[i][j].setForeground(
                            getOutOfMonthDateForeground());
                } else if (d == Calendar.SUNDAY || d == Calendar.SATURDAY) {
                    days[i][j].setForeground(
                            getWeForeground());
                } else {
                    days[i][j].setForeground(
                            getDateForeground());
                }

                String hi = "";
                if (getIcalUrl() != null) {
                    List<String> l = new ArrayList<String>();
                    try {
                        if (cal_srv != null && cal_srv.isHoliday(cal, l)) {
                            hi = cal_srv.getHolidayName(cal, l);
                        }
                    } catch (ICalendarServiceException e) {
                        LOGGER.error("Can't check holidays.", e);
                        if (!e.getErrCode().equals(ICalendarServiceException.ERR_OUT_OF_PERIOD)) {
                            throw new CalendarException(e);
View Full Code Here

Examples of org.fireflow.engine.calendar.ICalendarService

      IActivityInstance activityInstance) throws EngineException,
      KernelException {
   
    Activity activity = activityInstance.getActivity();
    IPersistenceService persistenceService = rtCtx.getPersistenceService();
    ICalendarService calService = rtCtx.getCalendarService();

    IProcessInstance processInstance = token.getProcessInstance();
    WorkflowSession workflowSession = (WorkflowSession) ((IWorkflowSessionAware) processInstance)
        .getCurrentWorkflowSession();

    if (workflowSession == null) {
      throw new EngineException(token.getProcessInstance(),
          activityInstance.getActivity(),
          "The workflow session in process instance can NOT be null");
    }

    int createdTaskInstanceCount = 0;
    for (int i = 0; i < activity.getTasks().size(); i++) {
      Task task = activity.getTasks().get(i);
      // 1、创建Task实例,并设置工作流系统定义的属性
      ITaskInstance taskInstance = this.createTaskInstance(
          workflowSession, processInstance, task, activity);

      if (taskInstance == null) {
        continue;
      }
      createdTaskInstanceCount = createdTaskInstanceCount + 1;

      String taskType = task.getType();
      ((TaskInstance) taskInstance).setTaskType(taskType);
      ((TaskInstance) taskInstance).setStepNumber(token.getStepNumber());
      // ((TaskInstance) taskInstance).setTokenId(token.getId());
      ((TaskInstance) taskInstance).setProcessInstanceId(processInstance
          .getId());
      ((TaskInstance) taskInstance).setProcessId(processInstance
          .getProcessId());
      ((TaskInstance) taskInstance).setVersion(processInstance
          .getVersion());
      ((TaskInstance) taskInstance).setActivityId(activity.getId());
      if (Task.FORM.equals(taskType)) {
        ((TaskInstance) taskInstance)
            .setAssignmentStrategy(((FormTask) task)
                .getAssignmentStrategy());
        ((TaskInstance) taskInstance).setCanBeWithdrawn(true);
      } else {
        ((TaskInstance) taskInstance).setCanBeWithdrawn(false);
      }
      ((TaskInstance) taskInstance).setCreatedTime(calService
          .getSysDate());
      ((TaskInstance) taskInstance).setDisplayName(task.getDisplayName());
      ((TaskInstance) taskInstance).setName(task.getName());

      ((TaskInstance) taskInstance).setState(TaskInstance.INITIALIZED);

      ((TaskInstance) taskInstance).setTaskId(task.getId());

      ((TaskInstance) taskInstance).setFromActivityId(token
          .getFromActivityId());

      ((IRuntimeContextAware) taskInstance).setRuntimeContext(rtCtx);
      ((IWorkflowSessionAware) taskInstance)
          .setCurrentWorkflowSession(workflowSession);
      // 计算超时
      Duration duration = task.getDuration();

      if (duration != null && calService != null) {
        ((TaskInstance) taskInstance).setExpiredTime(calService
            .dateAfter(calService.getSysDate(), duration));
      }

      // 2、保存实例taskInstance
      persistenceService.saveOrUpdateTaskInstance(taskInstance);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.