Example usage for java.util GregorianCalendar add

List of usage examples for java.util GregorianCalendar add

Introduction

In this page you can find the example usage for java.util GregorianCalendar add.

Prototype

@Override
public void add(int field, int amount) 

Source Link

Document

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

Usage

From source file:org.socraticgrid.docmgr.DocumentManagerImpl.java

/**
 * KMR Inbox request for cross-gateway NHIN documents.
 *
 * @param request//ww w  .j a v  a 2 s  .com
 * @return
 */
public org.socraticgrid.common.docmgr.GetNHINDocumentsResponseType getNHINDocuments(
        org.socraticgrid.common.docmgr.GetNHINDocumentsRequestType request) {
    GetNHINDocumentsResponseType response = new GetNHINDocumentsResponseType();

    //Assign default response
    response.setProcessState(XDSProcessConstants.PROCESS_STATE_AVAILABLE);
    response.setSuccessStatus(true);

    //Check if there is an existing query.
    XDSService xdsService = new XDSService();
    ProcessQueryParams query = new ProcessQueryParams();
    query.setPatientId(request.getPatientId());
    List<XDSProcess> processes = xdsService.getProcessesByParams(query);

    //If query exists and is stale, delete
    Iterator<XDSProcess> procIter = processes.iterator();
    while (procIter.hasNext()) {
        XDSProcess process = procIter.next();
        GregorianCalendar now = new GregorianCalendar();
        GregorianCalendar staleTime = new GregorianCalendar();
        staleTime.setTime(process.getStartTime());
        staleTime.add(Calendar.MINUTE, XDS_QUERY_DURATION);
        if (now.after(staleTime)) {
            log.info("Removing stale process for patient: " + process.getPatientId() + ", ticket: "
                    + process.getTicket());
            xdsService.deleteProcess(process);
            procIter.remove();
        }
    }

    //Check if there is an existing query that is still valid
    if (!processes.isEmpty()) {
        XDSProcess process = processes.get(0);
        response.setProcessState(XDSProcessConstants.PROCESS_STATE_IN_PROGRESS);
        response.setStatusMessage("Current query in progress for patient: " + process.getPatientId()
                + ", by user: " + process.getUserId() + ", started at: " + process.getStartTime());
    }

    //Check action value if we don't have an existing query
    if (processes.isEmpty() && (request.getAction() != null) && request.getAction().equals(XDS_INBOX_ACTION)) {

        StartNHINQueryAndDownloadResponseType startResponse = null;

        try {
            log.debug("Starting NHIN query for patient: " + request.getPatientId());

            //Start new query
            StartNHINQueryAndDownloadRequestType startRequest = new StartNHINQueryAndDownloadRequestType();
            startRequest.setPatientUnitNumber(request.getPatientId());
            startRequest.setPatientDOB(request.getPatientDOB());
            startRequest.setPatientFirstName(request.getPatientFirstName());
            startRequest.setPatientMiddleName(request.getPatientMiddleName());
            startRequest.setPatientLastName(request.getPatientLastName());
            startRequest.setUsername(request.getUserId());
            startRequest.setProviderFirstName(request.getUserFirstName());
            startRequest.setProviderMiddleName(request.getUserMiddleName());
            startRequest.setProviderLastName(request.getUserLastName());
            startRequest.setHomeCommunityId(
                    PropertyAccessor.getProperty(REPOSITORY_PROPERTY_FILE, DEFAULT_HOME_COMMUNITY_ID));
            GregorianCalendar queryDate = new GregorianCalendar();
            queryDate.add(Calendar.YEAR, -5);
            startRequest.setQueryFromDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(queryDate));
            startRequest.setCallbackURL(
                    PropertyAccessor.getProperty(REPOSITORY_PROPERTY_FILE, XDS_PROCESS_ENDPOINT_PROP));
            startResponse = startNHINQueryAndDownload(startRequest);
        } catch (Exception e) {
            log.error("Error handling getDocuments for patient: " + request.getPatientId(), e);
        }

        //Create new process record
        if ((startResponse != null) && !startResponse.getTicket().equals(JOB_FAILURE_ID)) {
            XDSProcess newProcess = new XDSProcess();
            newProcess.setTicket(startResponse.getTicket());
            newProcess.setPatientId(request.getPatientId());
            newProcess.setUserId(request.getUserId());
            newProcess.setStartTime(new Date());
            newProcess.setDownloadCount(-1L);
            newProcess.setExistedCount(-1L);
            newProcess.setResultCount(-1L);
            xdsService.saveProcess(newProcess);

            response.setProcessState(XDSProcessConstants.PROCESS_STATE_IN_PROGRESS);
            response.setStatusMessage("Process started.");
        } else {
            response.setProcessState(XDSProcessConstants.PROCESS_STATE_AVAILABLE);
            response.setStatusMessage("Process start failed.");
        }
    }

    return response;
}

From source file:eu.europa.ec.markt.tlmanager.core.validation.Validation.java

/**
 * If Nextupdate is not empty, the difference between IssuedDate and NextUpdate cannot exceed 6 months.
 *///from  w  w  w . j  a  va  2s . c  om
private void checkRuleNextUpdate() {
    NextUpdateType nextUpdate = schemeInformation.getNextUpdate();
    String nuName = QNames._NextUpdate_QNAME.getLocalPart(), liName = QNames._ListIssueDateTime;
    if (nextUpdate != null && nextUpdate.getDateTime() != null) {
        GregorianCalendar nextUpdateTime = nextUpdate.getDateTime().toGregorianCalendar();
        GregorianCalendar listIssueTime = schemeInformation.getListIssueDateTime().toGregorianCalendar();
        if (nextUpdateTime.before(listIssueTime)) {
            logger.error(nuName + uiKeys.getString("Validation.rule.nextUpdate.mustBeLater") + liName + "!",
                    tsl);
        } else {
            GregorianCalendar gc = (GregorianCalendar) listIssueTime.clone();
            gc.add(Calendar.MONTH, 6);
            if (gc.before(nextUpdateTime)) {
                logger.error(uiKeys.getString("Validation.rule.nextUpdate.dontExceed6Months") + liName + " - "
                        + nuName + "!", tsl);
            }
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

/**
 * ??  ?  ?  ? ? .//from  w w w  .  j  ava  2s . co  m
 */
private void preRegChange(boolean force) {
    if (!force && (comboBoxServices == null || comboBoxServices.getSelectedItem() == null
            || (calPrereg.getDate().equals(preDate) && comboBoxServices.getSelectedItem().equals(preService))
            || !((QService) comboBoxServices.getSelectedItem()).isLeaf())) {
        tablePreReg.setModel(new DefaultTableModel());
        return;
    }
    preDate = calPrereg.getDate();
    labelPreDate.setText(Uses.format_dd_MMMM_yyyy.format(preDate));
    preService = (QService) comboBoxServices.getSelectedItem();

    calPrereg.setMinSelectableDate(new Date());
    if (preService.getAdvanceLimitPeriod() != 0) {
        final GregorianCalendar gc = new GregorianCalendar();
        gc.add(GregorianCalendar.DAY_OF_YEAR, preService.getAdvanceLimitPeriod());
        calPrereg.setMaxSelectableDate(gc.getTime());
    }

    final RpcGetGridOfDay.GridDayAndParams greed = NetCommander.getPreGridOfDay(netProperty, preService.getId(),
            preDate, -1);
    tablePreReg.setModel(new PreTableModel(greed));
    tablePreReg.getColumnModel().getColumn(0).setMaxWidth(50);
    tablePreReg.getColumnModel().getColumn(1).setMaxWidth(110);
}

From source file:com.bt.heliniumstudentapp.ScheduleFragment.java

private int checkDatabase() {
    Boolean updated = false;//from   w w  w .j  a v a  2s . c  o  m

    final GregorianCalendar currentDate = new GregorianCalendar(HeliniumStudentApp.LOCALE);
    final GregorianCalendar storedDate = new GregorianCalendar(HeliniumStudentApp.LOCALE);

    final String scheduleStart = PreferenceManager.getDefaultSharedPreferences(mainContext)
            .getString("schedule_start_0", null);

    if (scheduleStart == null) {
        return HeliniumStudentApp.DB_OK;
    } else {
        try {
            storedDate.setTime(HeliniumStudentApp.df_date().parse(scheduleStart));
        } catch (ParseException ignored) {
            return HeliniumStudentApp.DB_ERROR;
        }
    }

    for (int weekDays = 0; weekDays < 7; weekDays++) {
        if (currentDate.get(Calendar.YEAR) == storedDate.get(Calendar.YEAR)
                && currentDate.get(Calendar.MONTH) == storedDate.get(Calendar.MONTH)
                && currentDate.get(Calendar.DAY_OF_MONTH) == storedDate.get(Calendar.DAY_OF_MONTH)) {
            updated = true;
            break;
        }

        storedDate.add(Calendar.DAY_OF_YEAR, 1);
    }

    if (updated) {
        return HeliniumStudentApp.DB_OK;
    } else {
        scheduleFocus = currentDate.get(Calendar.WEEK_OF_YEAR);

        if (PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_1", null) == null) {
            if (MainActivity.isOnline()) {
                MainActivity.setStatusBar(mainContext);

                PreferenceManager.getDefaultSharedPreferences(mainContext).edit().putString("schedule_0", null)
                        .apply();
                PreferenceManager.getDefaultSharedPreferences(mainContext).edit().putString("schedule_1", null)
                        .apply();

                PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                        .putString("schedule_start_0", null).apply();
                PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                        .putString("schedule_start_1", null).apply();

                ScheduleFragment.getSchedule(HeliniumStudentApp.DIREC_CURRENT,
                        HeliniumStudentApp.ACTION_SHORT_IN);

                return HeliniumStudentApp.DB_REFRESHING; //TODO Handle by caller to avoid workarounds
            } else {
                Toast.makeText(mainContext,
                        mainContext.getString(R.string.error_database) + ". "
                                + mainContext.getString(R.string.error_conn_no) + ".",
                        Toast.LENGTH_SHORT).show();
                mainContext.finish();

                return HeliniumStudentApp.DB_ERROR; //TODO Throw error / in finally
            }
        } else
            try {
                currentDate.setTime(HeliniumStudentApp.df_date().parse(PreferenceManager
                        .getDefaultSharedPreferences(mainContext).getString("schedule_start_0", "1")));

                if (currentDate.get(Calendar.WEEK_OF_YEAR) - currentDate.get(Calendar.WEEK_OF_YEAR) == 1) {
                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("schedule_0", PreferenceManager.getDefaultSharedPreferences(mainContext)
                                    .getString("schedule_1", null))
                            .apply();
                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("schedule_1", null).apply();

                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("pref_schedule_version_0",
                                    PreferenceManager.getDefaultSharedPreferences(mainContext)
                                            .getString("pref_schedule_version_1", null))
                            .apply();
                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("pref_schedule_version_1", null).apply();

                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("schedule_start_0",
                                    PreferenceManager.getDefaultSharedPreferences(mainContext)
                                            .getString("schedule_start_1", null))
                            .apply();
                    PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                            .putString("schedule_start_1", null).apply();

                    scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext)
                            .getString("schedule_0", null);

                    return HeliniumStudentApp.DB_OK;
                } else {
                    if (MainActivity.isOnline()) {
                        MainActivity.setStatusBar(mainContext);

                        PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                                .putString("schedule_0", null).apply();
                        PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                                .putString("schedule_1", null).apply();

                        PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                                .putString("schedule_start_0", null).apply();
                        PreferenceManager.getDefaultSharedPreferences(mainContext).edit()
                                .putString("schedule_start_1", null).apply();

                        ScheduleFragment.getSchedule(HeliniumStudentApp.DIREC_CURRENT,
                                HeliniumStudentApp.ACTION_SHORT_IN);

                        return HeliniumStudentApp.DB_REFRESHING; //TODO Handle by caller to avoid workarounds
                    } else {
                        Toast.makeText(mainContext,
                                mainContext.getString(R.string.error_database) + ". "
                                        + mainContext.getString(R.string.error_conn_no) + ".",
                                Toast.LENGTH_SHORT).show();
                        mainContext.finish();

                        return HeliniumStudentApp.DB_ERROR; //TODO Throw error / in finally
                    }
                }
            } catch (ParseException ignored) {
            }

        return HeliniumStudentApp.DB_ERROR; //TODO Throw error / in finally
    }
}

From source file:org.eevolution.form.CRP.java

/**
 * Create Category Dataset based on date start and resource
 * @param start/*from  w  w w  . j  a  va  2s  .  c o m*/
 * @param resource
 * @return CategoryDataset
 */
protected CategoryDataset createDataset(Timestamp start, MResource resource) {
    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    Timestamp date = start;
    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    String nameload = Msg.translate(Env.getCtx(), "Load");
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    MResourceType t = MResourceType.get(Env.getCtx(), resource.getS_ResourceType_ID());
    int days = 1;
    long hours = t.getTimeSlotHours();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    //      Long Hours = new Long(hours);                            
    int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ",
            resource.getS_Resource_ID());
    MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID);
    if (!uom.isHour()) {
        return dataset;
    }
    long summary = 0;

    while (days < 32) {
        String day = new String(new Integer(date.getDate()).toString());
        long HoursLoad = getLoad(resource, date).longValue();
        Long Hours = new Long(hours);

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            days++;
            if (t.isOnSunday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.MONDAY:
            days++;
            if (t.isOnMonday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.TUESDAY:
            days++;
            if (t.isOnTuesday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.WEDNESDAY:
            days++;
            if (t.isOnWednesday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.THURSDAY:
            days++;
            if (t.isOnThursday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.FRIDAY:
            days++;
            if (t.isOnFriday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.SATURDAY:
            days++;
            if (t.isOnSaturday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        }

    }
    return dataset;
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

private void buttonRemoveAdvanceCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRemoveAdvanceCustomerActionPerformed
    if (tablePreReg.getSelectedRow() >= 0) {
        final FirstPreCell fc = (FirstPreCell) tablePreReg.getValueAt(tablePreReg.getSelectedRow(), 0);
        final GregorianCalendar gc = new GregorianCalendar();
        gc.add(GregorianCalendar.HOUR_OF_DAY, 1);
        if (fc.getDate().before(gc.getTime())) {
            return;
        }//from  w  w w.ja v a 2s. co m

        if (fc.getAcust().getAdvanceTime() == null) {

        } else {
            if (0 == JOptionPane.showConfirmDialog(this,
                    "  ? " + fc.getAcust().getId()
                            + "   " + fc + " ?",
                    getLocaleMessage("pre.reg.2"), JOptionPane.YES_NO_OPTION)) {

                final JsonRPC20OK res = NetCommander.removeAdvancedCustomer(netProperty, fc.getAcust().getId());

                if (res != null) {

                    if (res.getResult() == 1) {// ?.   ID 
                        QLog.l().logger().info("  "
                                + fc.getAcust().getId() + "  " + fc);

                        preRegChange(true);
                        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.client_adv_remove.msg_3"),
                                getLocaleMessage("admin.client_adv_dialog.title"),
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(this,
                                "?  ? ?   "
                                        + fc.getAcust().getId(),
                                getLocaleMessage("admin.client_adv_dialog.title"), JOptionPane.ERROR_MESSAGE);
                    }
                }

            }
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

private void tablePreRegMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablePreRegMouseClicked
    final QService service = (QService) comboBoxServices.getSelectedItem();
    if (evt.getClickCount() > 1 && tablePreReg.getSelectedRow() >= 0 && service != null && service.isLeaf()) {
        final FirstPreCell fc = (FirstPreCell) tablePreReg.getValueAt(tablePreReg.getSelectedRow(), 0);
        final GregorianCalendar gc = new GregorianCalendar();
        gc.add(GregorianCalendar.HOUR_OF_DAY, 1);
        if (fc.getDate().before(gc.getTime())) {
            return;
        }//w  ww.ja  va2  s .  c om

        if (fc.getAcust().getAdvanceTime() == null) {
            if (0 == JOptionPane.showConfirmDialog(this, getLocaleMessage("make.pre.reg ") + fc + "?",
                    getLocaleMessage("pre.reg"), JOptionPane.YES_NO_OPTION)) {

                String inputData = null;
                if (service.getInput_required()) {
                    inputData = (String) JOptionPane.showInputDialog(this, service.getInput_caption(), "***", 3,
                            null, null, ""); //NOI18N
                    if (inputData == null) {
                        return;
                    }
                }

                String comments = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.comments"),
                        "***", 3, null, null, ""); //NOI18N
                if (inputData == null) {
                    inputData = ""; //NOI18N
                }

                final QAdvanceCustomer res;
                try {
                    res = NetCommander.standInServiceAdvance(netProperty, service.getId(), fc.getDate(), -1,
                            inputData, comments);
                } catch (Exception ex) {
                    throw new ClientException(getLocaleMessage("admin.send_cmd_adv.err") + " " + ex); //NOI18N
                }
                if (res == null) {
                    return;
                }
                //  
                if (checkBoxPrintAdvTicket.isSelected()) {
                    new Thread(() -> {
                        FWelcome.printTicketAdvance(res, ((QService) treeServices.getModel().getRoot())
                                .getTextToLocale(QService.Field.NAME));
                    }).start();
                }
                preRegChange(true);
                JOptionPane.showMessageDialog(this,
                        getLocaleMessage("admin.client_adv_dialog.msg_1") + " \"" + service.getName() + "\". "
                                + getLocaleMessage("admin.client_adv_dialog.msg_2") + " \"" + res.getId()
                                + "\".",
                        getLocaleMessage("admin.client_adv_dialog.title"), JOptionPane.INFORMATION_MESSAGE);

            }
        } else {
            if (0 == JOptionPane.showConfirmDialog(this, getLocaleMessage("clint.came") + fc + "?",
                    getLocaleMessage("pre.reg.2"), JOptionPane.YES_NO_OPTION)) {

                final RpcStandInService res = NetCommander.standAndCheckAdvance(netProperty,
                        fc.getAcust().getId());

                if (res != null) {

                    if (res.getMethod() == null) {// ?.   ?  ? ? ?  
                        QLog.l().logger().info(getLocaleMessage("print.ticket"));
                        new Thread(() -> {
                            FWelcome.printTicket(res.getResult(),
                                    ((QService) treeServices.getModel().getRoot()).getName());
                        }).start();
                        preRegChange(true);
                        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.client_adv_dialog.msg_3"),
                                getLocaleMessage("admin.client_adv_dialog.title"),
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(this, res.getMethod(),
                                getLocaleMessage("admin.client_adv_dialog.title"), JOptionPane.ERROR_MESSAGE);
                    }
                }

            }
        }
    }
}

From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java

private boolean checkMonthList(GregorianCalendar cal) {
    if (mByMonthList.size() > 0) {
        for (Integer cur : mByMonthList) {
            int curMonth = cal.get(Calendar.MONTH) + 1;
            if (cur == curMonth)
                return true;

            // since the month list is in order, if we hit a HIGHER month,
            // then we know out current month isn't in the list, and therefore
            // we should go to this next one
            if (cur > curMonth) {
                cal.set(Calendar.MONTH, cur - 1);
                return false; // must re-start checks
            }//ww w  .j a  va  2s  .  c  om
        }

        // we've not found a match AND we've not found a
        // higher value in our list -- so wrap
        cal.set(Calendar.MONTH, mByMonthList.get(0) - 1);
        cal.add(Calendar.YEAR, 1);
        return false; // must re-start checks
    }
    return true;
}

From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java

/**
 * @param cal// ww w .  j  a va 2  s.co  m
 * @return
 */
private boolean checkHourList(GregorianCalendar cal) {
    if (mByHourList.size() > 0) {
        for (Integer cur : mByHourList) {
            int curHour = cal.get(Calendar.HOUR_OF_DAY);
            if (curHour == cur.intValue())
                return true;

            // since the month list is in order, if we hit a HIGHER month,
            // then we know out current month isn't in the list, and therefore
            // we should go to this next one
            if (cur > curHour) {
                cal.set(Calendar.HOUR_OF_DAY, cur);
                return false; // must re-start checks
            }
        }

        // we've not found a match AND we've not found a
        // higher value in our list -- so wrap
        cal.set(Calendar.HOUR, mByHourList.get(0));
        cal.add(Calendar.DAY_OF_YEAR, 1);
        return false; // must re-start checks
    }
    return true;
}

From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java

private boolean checkYearDayList(GregorianCalendar cal) {
    if (mByYearDayList.size() > 0) {
        for (Integer cur : mByYearDayList) {
            int curYearDay = cal.get(Calendar.DAY_OF_YEAR);
            if (cur == curYearDay)
                return true;

            // since the YearDay list is in order, if we hit a HIGHER one,
            // then we know out current one isn't in the list, and therefore
            // we should go to this one we just found in the list
            if (cur > curYearDay) {
                cal.set(Calendar.DAY_OF_YEAR, cur);
                return false;
            }/* ww w.j  av a 2  s  .  co m*/
        }

        // we've not found a match AND we've not found a
        // higher value in our list -- so wrap
        cal.set(Calendar.DAY_OF_YEAR, mByYearDayList.get(0));
        cal.add(Calendar.YEAR, 1);
        return false;
    }
    return true;
}