Snippets

Jonathan Hult WebCenter Content - doDateComparisonTestAndSupplyDefaults()

Created by Jonathan Hult
@IdcServiceAction
public void doDateComparisonTestAndSupplyDefaults() throws DataException, ServiceException {
    Date newDocDate = null;
    Date latestDocDate = null;
    String dateMsg = "csCheckinCreateDateError";
    String newCreateDateStr = this.m_binder.getLocal("dCreateDate");
    String newInDateStr = this.m_binder.getLocal("dInDate");
    Date newCreateDate = null;
    Date newInDate = null;
    Date tempNewDate = null;
    String tempNewDateStr = null;
    if (newCreateDateStr == null || newCreateDateStr.length() == 0) {
        tempNewDate = new Date();
        tempNewDateStr = LocaleUtils.formatODBC(tempNewDate);
        this.m_binder.putLocal("dCreateDate", tempNewDateStr);
        newCreateDate = tempNewDate;
    }
    if (newInDateStr == null || newInDateStr.length() == 0) {
        if (tempNewDate == null) {
            tempNewDate = new Date();
            tempNewDateStr = LocaleUtils.formatODBC(tempNewDate);
        }
        this.m_binder.putLocal("dInDate", tempNewDateStr);
        newInDate = tempNewDate;
    }
    String latestCreateDateStr = this.m_binder.getLocal("latestCreateDate");
    boolean isUseCreateDate = SharedObjects.getEnvValueAsBoolean("UseRevisionCreateDate", false);
    if (isUseCreateDate && latestCreateDateStr != null && latestCreateDateStr.length() > 0) {
        newDocDate = newCreateDate;
        if (newCreateDate == null) {
            newDocDate = this.m_binder.parseDate("dCreateDate", newCreateDateStr);
        }
        latestDocDate = this.m_binder.parseDate("latestCreateDate", latestCreateDateStr);
    } else {
        dateMsg = "csCheckinReleaseDateError";
        newDocDate = newInDate;
        if (newDocDate == null) {
            newDocDate = this.m_binder.parseDate("dInDate", newInDateStr);
        }
        latestDocDate = this.m_binder.parseDate("latestInDate", this.m_binder.getLocal("latestInDate"));
    }
    boolean result = false;
    if (newDocDate != null) {
        boolean isAllowMatches = SharedObjects.getEnvValueAsBoolean("AllowMatchesInDateCheck", false);
        long newTime = newDocDate.getTime();
        long latestTime = latestDocDate.getTime();
        if (isAllowMatches) {
            result = newTime >= latestTime;
        } else {
            boolean bl = result = newTime > latestTime + 998;
        }
    }
    if (!result) {
        String errorDateMsg = LocaleUtils.encodeMessage(dateMsg, null, newDocDate, latestDocDate);
        this.m_binder.putLocal("errorDateMsg", errorDateMsg);
        this.m_binder.putLocal("canInsertNew", "0");
    }
}

Comments (1)

  1. Linda Melson
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.