Package com.mossle.bpm.calendar

Source Code of com.mossle.bpm.calendar.CycleBusinessCalendar

package com.mossle.bpm.calendar;

import java.util.Date;

import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.calendar.CronExpression;

public class CycleBusinessCalendar extends AdvancedBusinessCalendar {
    public Date resolveDuedate(String duedate) {
        String textWithoutBusiness = duedate;
        boolean isBusinessTime = textWithoutBusiness.startsWith("business");

        if (isBusinessTime) {
            textWithoutBusiness = textWithoutBusiness.substring(
                    "business".length()).trim();
        }

        try {
            if (textWithoutBusiness.startsWith("R")) {
                return new DurationUtil(duedate, this).getDateAfter();
            } else {
                CronExpression ce = new CronExpression(duedate, null);

                return ce.getTimeAfter(new Date());
            }
        } catch (Exception e) {
            throw new ActivitiException("Failed to parse cron expression: "
                    + duedate, e);
        }
    }

    public String getName() {
        return "cycle";
    }
}
TOP

Related Classes of com.mossle.bpm.calendar.CycleBusinessCalendar

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.