Example usage for java.util Date before

List of usage examples for java.util Date before

Introduction

In this page you can find the example usage for java.util Date before.

Prototype

public boolean before(Date when) 

Source Link

Document

Tests if this date is before the specified date.

Usage

From source file:uk.ac.ed.uportal.portlets.collaborateportlet.mvc.portlet.EditController.java

/**
 * Perform manual model binding for Session start and end dates
 *
 * @param request The request to extract start and end dates from
 * @param session The session to add start and end dates to
 * @return Validation error messages generated by this binding. The list will be empty if binding was successful
 *///from  w  ww .j av a  2s. c o  m
private List<String> addValidatedRequestDatesToSession(ActionRequest request, Session session) {
    List<String> errorMessage = new ArrayList<>();
    Date startTime = null;
    Date endTime = null;
    try {
        String startTimeString = request.getParameter("startdate") + " " + request.getParameter("startHour")
                + ":" + request.getParameter("startMinute");

        startTime = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.ENGLISH).parse(startTimeString);
        session.setStartTime(startTime);
    } catch (Exception e) {
        errorMessage.add("error.startdateinvalid");
    }
    try {
        String endTimeString = request.getParameter("enddate") + " " + request.getParameter("endHour") + ":"
                + request.getParameter("endMinute");

        endTime = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.ENGLISH).parse(endTimeString);
        session.setEndTime(endTime);
    } catch (Exception e) {
        errorMessage.add("error.enddateinvalid");
    }
    if (startTime != null && endTime != null) {
        if (endTime.before(startTime)) {
            errorMessage.add("error.startdatebeforeenddate");
        }
        Date now = new Date();
        if (startTime.before(now)) {
            errorMessage.add("error.startdatebeforenow");
        }
        Period sessionPeriod = new Period(new DateTime(startTime), new DateTime(endTime));
        if (sessionPeriod.getYears() > 0) {
            errorMessage.add("error.dateyearapart");
        }
    }

    return errorMessage;
}

From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoDocuments.java

@SuppressWarnings("unchecked")
private void fetchChildrenForNotesDocument() throws NotesException {
    // LOGGER.info(getCallingMethod()+":"+"Start fetchChildrenForNotesDocument; Fetching children for doc with UNID="
    // + this.getDocumentUniqueID());
    Document curDoc = null;/* w  w  w . jav a2 s . c  om*/
    // String docID = null;
    Vector<IDAVResource> resMembers = new Vector<IDAVResource>();
    this.setMembers(resMembers);
    String notesURL = this.getInternalAddress();
    // LOGGER.info("Internal Address is "+notesURL);
    // LOGGER.info("PublicHref is "+this.getPublicHref());
    curDoc = DominoProxy.getDocument(notesURL);

    // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK");
    if (curDoc == null) {
        LOGGER.error("Could not retrieve the document");
        return;
    }
    boolean readOnly = this.checkReadOnlyAccess(curDoc);
    Date curCreationDate = curDoc.getCreated().toJavaDate();
    if (curDoc.hasItem("DAVCreated")) {
        @SuppressWarnings("rawtypes")
        Vector times = curDoc.getItemValueDateTimeArray("DAVCreated");
        Object time = times.elementAt(0);
        if (time.getClass().getName().endsWith("DateTime")) {
            curCreationDate = ((DateTime) time).toJavaDate();
        }
    }
    Date curChangeDate = curDoc.getLastModified().toJavaDate();
    if (curDoc.hasItem("DAVModified")) {
        @SuppressWarnings("rawtypes")
        Vector times = curDoc.getItemValueDateTimeArray("DAVModified");
        Object time = times.elementAt(0);
        if (time.getClass().getName().endsWith("DateTime")) {
            curChangeDate = ((DateTime) time).toJavaDate();
        }
    }
    this.setCreationDate(curCreationDate);
    this.setLastModified(curChangeDate);
    this.setReadOnly(readOnly);

    // Read the repository list to get the view
    try {
        // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK; Has UNID="+curDoc.getUniversalID());
        // docID = curDoc.getUniversalID();

        // LOGGER.info(getCallingMethod()+":"+"Openend document " + docID);

        // No children if there are no attachments
        if (!curDoc.hasEmbedded()) {
            // if(1==1){return;}
            // E.C. It is a directory, so fetch the children documents as
            // resources
            // LOGGER.info(getCallingMethod()+":"+"Current doc with unid="+curDoc.getUniversalID()+" has no embedded files. Try to find children");
            DocumentCollection responses = curDoc.getResponses();
            // LOGGER.info(getCallingMethod()+":"+"Get Responses...");
            int numOfResponses = responses.getCount();
            // LOGGER.info(getCallingMethod()+":"+"Current doc has "+String.valueOf(numOfResponses)
            // + " responses");
            if (numOfResponses > 0) {
                resMembers = new Vector<IDAVResource>(numOfResponses);
                // LOGGER.info(getCallingMethod()+":"+"Start Process responses");
                Document docResp = responses.getFirstDocument();
                while (docResp != null) {
                    // LOGGER.info(getCallingMethod()+":"+"Doc response has unid="+docResp.getUniversalID()+
                    // "; Try find attachment(s)");
                    Vector<String> allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp);
                    int numOfAttachments = allEmbedded.isEmpty() ? 0
                            : (allEmbedded.get(0).toString().equals("") ? 0 : allEmbedded.size());
                    // LOGGER.info(getCallingMethod()+":"+"Doc has "+
                    // String.valueOf(numOfAttachments)+" attachment(s)");
                    if (numOfAttachments == 0) { // No attachments in here!
                        // LOGGER.info(getCallingMethod()+":"+"Doc "+docResp.getUniversalID()+" response has no attachment; is a directory; Create resource for it");
                        DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments(this.getRepository(),
                                this.getPublicHref() + "/"
                                        + docResp.getItemValueString(
                                                ((DAVRepositoryDominoDocuments) (this.getRepository()))
                                                        .getDirectoryField()),
                                true);
                        resAtt.setup(docResp);
                        LOGGER.info(getCallingMethod() + ":"
                                + "Created DavResourceDomino Attachments from getDocumentResource-OK");
                        this.getMembers().add(resAtt);
                        // resMembers.add(resAtt);
                        LOGGER.info(getCallingMethod() + ":" + "Resource successfull added");

                    } else {
                        // LOGGER.info(getCallingMethod()+":"+"Doc response "+docResp.getUniversalID()+" has attachments >0; ");

                        String curAttName = allEmbedded.get(0).toString();
                        if ((curAttName != null) && (!curAttName.equals(""))) {
                            // LOGGER.info(getCallingMethod()+":"+"Doc response fitrst attachment has name "+curAttName);
                            DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments(
                                    this.getRepository(), this.getPublicHref() + "/" + curAttName, true);
                            resAtt.setup(docResp);
                            if (resAtt != null) {
                                // Now add it to the Vector
                                // LOGGER.info(getCallingMethod()+":"+"Created DAVResourceDominoDocuments with getAttachmentResource-OK!\n Start load resource");
                                // resMembers.add(curAttachment);
                                this.getMembers().add(resAtt);
                                // LOGGER.info(getCallingMethod()+":"+"Resource successfull added");
                                Date viewDate = this.getLastModified();
                                Date docDate = resAtt.getLastModified();
                                if (viewDate == null || (docDate != null && viewDate.before(docDate))) {
                                    this.setLastModified(docDate);
                                }
                                LOGGER.info(getCallingMethod() + ":"
                                        + "Resource successfull updated last modified");

                                // LOGGER.info(getCallingMethod()+":"+"Processing complete attachment:"
                                // + curAttName);
                            }
                        }
                    }
                    // LOGGER.info(getCallingMethod()+":"+"Start recycling..");
                    docResp = responses.getNextDocument(docResp);
                    // LOGGER.info(getCallingMethod()+":"+"Recycling OK!");
                } // end while

            } // end if numresp>0

            try {
                // LOGGER.info(getCallingMethod()+":"+"Final recycling..");
                if (curDoc != null) {
                    // curDoc.recycle();
                }
                // LOGGER.info(getCallingMethod()+":"+"End FINAL recycling OK!");

            } catch (Exception e) {
                LOGGER.error(e);
            }
            // Now save back the members to the main object
            // LOGGER.info(getCallingMethod()+":"+"Finish processing current doc as a directory; No more attachment(s) in it; Return!");
            return;
        }

        // Get all attachments
        // LOGGER.info(getCallingMethod()+":"+"Current doc has attachments!");
        @SuppressWarnings("rawtypes")
        Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc);
        int numOfAttchments = allEmbedded.size();
        if (numOfAttchments == 0) { // No attachments in here!
            // LOGGER.info(getCallingMethod()+":"+"Something wrong:  Doc + "+docID
            // + " has no attachments (@AttachmentNames)");
            return;
        }
        // LOGGER.info(getCallingMethod()+":"+docID + " has " + new
        // Integer(numOfAttchments).toString() + " attachment(s)");
        // Initialize an empty vector at the right size
        // We might need to enlarge it if we have more attachments
        resMembers = new Vector<IDAVResource>(numOfAttchments);
        // LOGGER.info(getCallingMethod()+":"+"Start processing attachment(s)..");
        for (int i = 0; i < numOfAttchments; i++) {

            String curAttName = allEmbedded.get(i).toString();
            DAVResourceDominoDocuments curAttachment = getDocumentResource(curDoc);

            if (curAttachment != null) {
                // Now add it to the Vector
                // LOGGER.info(getCallingMethod()+":"+"Resource attachment successfully created!");
                // resMembers.add(curAttachment);
                this.getMembers().add(curAttachment);
                // LOGGER.info("Resource  attachment successfully added: " +
                // curAttName+"; OK!");
            } else {
                LOGGER.error("Could not load attachment#" + curAttName + "#");
            }
        }

    } catch (NotesException ne) {
        LOGGER.error(ne);

    } catch (Exception e) {
        LOGGER.error(e);

    } finally {

        try {
            // LOGGER.info(getCallingMethod()+":"+"Final block; Start Recycling!");

            if (curDoc != null) {
                // curDoc.recycle();
            }

        } catch (Exception e) {
            LOGGER.error(e);
        }
        // Now save back the members to the main object
        // this.setMembers(resMembers);
        // LOGGER.info("Completed reading attachments resources from Notes document; OK!");
    }

}

From source file:org.opencastproject.capture.impl.SchedulerImpl.java

/**
 * Checks to see if a capture should be happening now.
 * /*from  w  w w . j ava  2 s  .  c  o m*/
 * @param start
 *          The start time of the event
 * @param end
 *          The end time of the event
 * @return True if the current time is between start and end, false otherwise
 */
private boolean captureIsHappeningNow(Date start, Date end) {
    return start.before(new Date()) && end.after(new Date());
}

From source file:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java

@Override
public List<HarvestRunInfo> getHarvestRunInfo(long harvestID) {
    Connection c = HarvestDBConnection.get();
    PreparedStatement s = null;/*w  w  w.  j a  v a 2 s  .  c o m*/
    try {
        ResultSet res = null;
        Map<Integer, HarvestRunInfo> runInfos = new HashMap<Integer, HarvestRunInfo>();
        List<HarvestRunInfo> infoList = new ArrayList<HarvestRunInfo>();

        // Select dates and counts for all different statues
        // for each run
        s = c.prepareStatement(
                "SELECT name, harvest_num, status, " + "       MIN(startdate), MAX(enddate), COUNT(job_id)"
                        + "  FROM jobs, harvestdefinitions" + " WHERE harvestdefinitions.harvest_id = ?"
                        + "   AND jobs.harvest_id " + "= harvestdefinitions.harvest_id"
                        + " GROUP BY name, harvest_num, status" + " ORDER BY harvest_num DESC");
        s.setLong(1, harvestID);
        res = s.executeQuery();
        while (res.next()) {
            int runNr = res.getInt(2);
            HarvestRunInfo info = runInfos.get(runNr);
            if (info == null) {
                String name = res.getString(1);
                info = new HarvestRunInfo(harvestID, name, runNr);
                // Put into hash for easy access when updating.
                runInfos.put(runNr, info);
                // Add to return list in order given by DB
                infoList.add(info);
            }
            JobStatus status = JobStatus.fromOrdinal(res.getInt(3));
            // For started states, check start date
            if (status != JobStatus.NEW && status != JobStatus.SUBMITTED && status != JobStatus.RESUBMITTED) {
                Date startDate = DBUtils.getDateMaybeNull(res, 4);
                if (info.getStartDate() == null
                        || (startDate != null && startDate.before(info.getStartDate()))) {
                    info.setStartDate(startDate);
                }
            }
            // For finished jobs, check end date
            if (status == JobStatus.DONE || status == JobStatus.FAILED) {
                Date endDate = DBUtils.getDateMaybeNull(res, 5);
                if (info.getEndDate() == null || (endDate != null && endDate.after(info.getEndDate()))) {
                    info.setEndDate(endDate);
                }
            }
            int count = res.getInt(6);
            info.setStatusCount(status, count);
        }
        s.close();
        s = c.prepareStatement("SELECT jobs.harvest_num," + "SUM(historyinfo.bytecount), "
                + "SUM(historyinfo.objectcount)," + "COUNT(jobs.status)" + " FROM jobs, historyinfo "
                + " WHERE jobs.harvest_id = ? " + "   AND historyinfo.job_id = jobs.job_id"
                + " GROUP BY jobs.harvest_num" + " ORDER BY jobs.harvest_num");
        s.setLong(1, harvestID);
        res = s.executeQuery();

        while (res.next()) {
            final int harvestNum = res.getInt(1);
            HarvestRunInfo info = runInfos.get(harvestNum);
            if (info != null) {
                info.setBytesHarvested(res.getLong(2));
                info.setDocsHarvested(res.getLong(3));
            } else {
                log.debug("Harvestnum " + harvestNum + " for harvestID " + harvestID
                        + " is skipped. Must have arrived between selects");
            }
        }

        // Make sure that jobs that aren't really done don't have end date.
        for (HarvestRunInfo info : infoList) {
            if (info.getJobCount(JobStatus.STARTED) != 0 || info.getJobCount(JobStatus.NEW) != 0
                    || info.getJobCount(JobStatus.SUBMITTED) != 0) {
                info.setEndDate(null);
            }
        }
        return infoList;
    } catch (SQLException e) {
        String message = "SQL error asking for harvest run info on " + harvestID + " in database" + "\n"
                + ExceptionUtils.getSQLExceptionCause(e);
        log.warn(message, e);
        throw new IOFailure(message, e);
    } finally {
        DBUtils.closeStatementIfOpen(s);
        HarvestDBConnection.release(c);
    }
}

From source file:net.solosky.litefetion.LiteFetion.java

/**
 * ??//  www.j a  va2  s  . co m
 * 
 * @param toBuddies      ????(litefetion.getUser())
 * @param message      ?????
 * @param sendDate      ?? ?+11-??,?
 * @return            ??
 */

public ActionResult sendScheduleSMS(List<Buddy> toBuddies, String message, Date sendDate) {
    try {
        if (toBuddies == null || toBuddies.size() == 0)
            return ActionResult.WRONG_PARAM;

        // ?+11-??
        //? 2007.7.1 22:56  2010.7.1 23:07 - 2011.7.1 22:56?
        Calendar calMin = Calendar.getInstance();
        calMin.add(Calendar.MINUTE, 11);
        Calendar calMax = Calendar.getInstance();
        calMax.add(Calendar.YEAR, 1);
        //????
        if (sendDate.before(calMin.getTime()) || sendDate.after(calMax.getTime())) {
            return ActionResult.WRONG_PARAM;
        }

        //?? 346339663,346379375?
        Iterator<Buddy> it = toBuddies.iterator();
        StringBuffer recievers = new StringBuffer();
        while (it.hasNext()) {
            Buddy b = it.next();
            recievers.append(Integer.toString(b.getUserId()));
            if (it.hasNext()) { //??,
                recievers.append(",");
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d H:m:s");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT 0"));
        HttpRequest request = this.createActionHttpRequest(Settings.WEBIM_URL_SET_SCHEDULESMS);
        request.addPostValue("UserName", Integer.toString(this.user.getUserId()));
        request.addPostValue("Message", message);
        request.addPostValue("Receivers", recievers.toString());
        request.addPostValue("SendTime", sdf.format(sendDate));

        HttpResponse response = this.client.tryExecute(request, Settings.FEITON_MAX_REQUEST_EXECUTE_TIMES);
        JSONObject json = new JSONObject(response.getResponseString());
        int status = json.getInt("rc");
        if (status == 200) {
            return ActionResult.SUCCESS;
        } else {
            return ActionResult.REQUEST_FAILED;
        }
    } catch (IOException e) {
        return ActionResult.HTTP_FAILED;
    } catch (JSONException e) {
        return ActionResult.JSON_FAILED;
    }
}

From source file:de.hybris.platform.servicelayer.tx.ItemModelTransactionTest.java

@Test
public void testModificationTimeUpdateNoTx() throws InterruptedException, JaloBusinessException {
    final MediaModel media = setupMedia("cat", "media", MIME_BEFORE);
    final Media jaloMedia = modelService.getSource(media);
    final PK mediaPK = media.getPk();
    assertEquals(mediaPK, jaloMedia.getPK());

    final Date modificationTimeBefore = jaloMedia.getModificationTime();
    Thread.sleep(1500);/*from  www .  ja va2  s.  com*/
    jaloMedia.setMime(MIME_AFTER);
    final Date modificationTimeAfter = jaloMedia.getModificationTime();

    assertNotNull(modificationTimeBefore);
    assertNotNull(modificationTimeAfter);
    assertTrue(modificationTimeBefore.before(modificationTimeAfter));
}

From source file:DataPreProcess.ConvertedTrace.java

private void construct_Matrix_Phase() {
    long time_shift = 0;
    Date cali_st = null;//from w  w  w  . j  av  a2 s  .com
    Date pt_st = null;
    Date pt_ed = null;
    Date pri_st = null;
    Date pri_ed = null;
    Date sec_st = null;
    Date sec_ed = null;
    Date pst_sec_st = null;
    Date pst_sec_ed = null;
    //        Date pd_st = null;
    //        Date pd_ed = null;
    //Get all the date
    for (Phase ph : p) {
        if (pt.contains(ph.phaseName)) {
            cali_st = ph.start;
            pt_st = ph.start;
            pt_ed = ph.end;
        }
        if (pre_pri.contains(ph.phaseName)) { //merge preprimary to patient arrival
            pt_ed = ph.end;
        }
        if (pri.contains(ph.phaseName)) {
            pt_ed = ph.start;
            pri_st = ph.start;
            pri_ed = ph.end;
        }
        if (sec.contains(ph.phaseName)) {
            pri_ed = ph.start;
            sec_st = ph.start;
            sec_ed = ph.end;
        }
        if (pst_sec.contains(ph.phaseName)) {
            sec_ed = ph.start;
            pst_sec_st = ph.start;
            pst_sec_ed = ph.end;
        }
        //            if (pd.contains(ph.phaseName)) {
        //                pd_st = ph.start;
        //                pd_ed = ph.end;
        //            }
    }

    if (cali_st != null) {
        time_shift = cali_st.getTime();
    }

    //        Calibrate start time
    pt_st = new Date(pt_st.getTime() - time_shift);
    pt_ed = new Date(pt_ed.getTime() - time_shift);
    pri_st = new Date(pri_st.getTime() - time_shift);
    pri_ed = new Date(pri_ed.getTime() - time_shift);
    sec_st = new Date(sec_st.getTime() - time_shift);
    sec_ed = new Date(sec_ed.getTime() - time_shift);
    pst_sec_st = new Date(pst_sec_st.getTime() - time_shift);
    pst_sec_ed = new Date(pst_sec_ed.getTime() - time_shift);

    phase_percentage[0] = (double) (pt_ed.getTime() - pt_st.getTime());
    phase_percentage[1] = (double) (pri_ed.getTime() - pri_st.getTime());
    phase_percentage[2] = (double) (sec_ed.getTime() - sec_st.getTime());
    phase_percentage[3] = (double) (pst_sec_ed.getTime() - pst_sec_st.getTime());

    for (Activity ac : activities) {
        int start_index = 0;
        int end_index = 0;
        Date ac_st = ac.get_startTime();
        Date ac_end = ac.get_endTime();
        if (ac_st.after(pst_sec_ed)) {
            start_index = Length - 1;
            //wrong situation, start after end
        } else if (ac_st.after(pst_sec_st) || ac_st.equals(pst_sec_st)) {
            start_index = pt_arrival_length + Primary_length + Secondary_length
                    + (int) ((double) (ac_st.getTime() - pst_sec_st.getTime()) / phase_percentage[3]
                            * Pst_secondary_length);
        } else if (ac_st.after(sec_st) || ac_st.equals(sec_st)) {
            start_index = pt_arrival_length + Primary_length
                    + (int) ((double) (ac_st.getTime() - sec_st.getTime()) / phase_percentage[2]
                            * Secondary_length);
        } else if (ac_st.after(pri_st) || ac_st.equals(pri_st)) {
            start_index = pt_arrival_length + (int) ((double) (ac_st.getTime() - pri_st.getTime())
                    / phase_percentage[1] * Primary_length);
        } else if (ac_st.after(pt_st) || ac_st.equals(pt_st)) {
            start_index = (int) ((double) (ac_st.getTime() - pt_st.getTime()) / phase_percentage[0]
                    * pt_arrival_length);
        } else {
            start_index = 0;
        }

        if (ac_end.before(pt_st)) {
            end_index = 0;
            //wrong situation, end before start
        } else if (ac_end.before(pt_ed) || ac_end.equals(pt_ed)) {
            end_index = pt_arrival_length - (int) ((double) (pt_ed.getTime() - ac_end.getTime())
                    / phase_percentage[0] * pt_arrival_length);
        } else if (ac_end.before(pri_ed) || ac_end.equals(pri_ed)) {
            end_index = pt_arrival_length + Primary_length
                    - (int) ((double) (pri_ed.getTime() - ac_end.getTime()) / phase_percentage[1]
                            * Primary_length);
        } else if (ac_end.before(sec_ed) || ac_end.equals(sec_ed)) {
            end_index = pt_arrival_length + Primary_length + Secondary_length
                    - (int) ((double) (sec_ed.getTime() - ac_end.getTime()) / phase_percentage[2]
                            * Secondary_length);
        } else if (ac_end.before(pst_sec_ed) || ac_end.equals(pst_sec_ed)) {
            end_index = pt_arrival_length + Primary_length + Secondary_length + Pst_secondary_length
                    - (int) ((double) (pst_sec_ed.getTime() - ac_end.getTime()) / phase_percentage[3]
                            * Pst_secondary_length);
        } else {
            end_index = Length;
            //Patient departure, not included
        }
        end_index = end_index >= Length ? Length : end_index; // Avoid out of boundry

        //Set corresponding cells to 1
        int row_index = Activity_set.indexOf(ac.get_name());
        try {
            if (end_index < start_index) {
                System.out.println("Activity: " + ac.get_name() + " Index incorrect: " + " st:" + start_index
                        + " ed:" + end_index);
            } else {
                if (end_index == start_index && end_index < Length) {
                    end_index++;
                }
                fill_activity(row_index, start_index, end_index);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Activity: " + ac.get_name() + " st:" + start_index + " ed:" + end_index
                    + " OutOfBounds!!!");
        }
        normalize_matrix_row();
    }

    double duration = pst_sec_ed.getTime() - pt_st.getTime();
    phase_percentage[0] /= duration;
    phase_percentage[1] /= duration;
    phase_percentage[2] /= duration;
    phase_percentage[3] /= duration;
}

From source file:ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentService.java

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Integer createDeploymentsReturnTrackingId(List<DeploymentEntity> selectedDeployments,
        Date deploymentDate, Date stateToDeploy, List<DeploymentParameter> deployParams,
        List<Integer> contextIds, boolean sendEmail, boolean requestOnly, boolean doSimulate,
        boolean isExecuteShakedownTest, boolean isNeighbourhoodTest) {

    Integer trackingId = sequencesService.getNextValueAndUpdate(DeploymentEntity.SEQ_NAME);

    Date now = new Date();
    if (deploymentDate == null || deploymentDate.before(now)) {
        deploymentDate = now;//  ww  w. jav  a  2s  .com
    }

    for (DeploymentEntity selectedDeployment : selectedDeployments) {

        List<ApplicationWithVersion> applicationWithVersion = selectedDeployment.getApplicationsWithVersion();

        Integer appServerGroupId = selectedDeployment.getResourceGroup().getId();
        Integer releaseId = selectedDeployment.getRelease().getId();

        createDeploymentForAppserver(appServerGroupId, releaseId, deploymentDate, stateToDeploy, contextIds,
                applicationWithVersion, deployParams, sendEmail, requestOnly, doSimulate,
                isExecuteShakedownTest, isNeighbourhoodTest, trackingId);
    }

    if (deploymentDate == now && !requestOnly) {
        deploymentEvent.fire(new DeploymentEvent(DeploymentEventType.NEW, DeploymentState.scheduled));
    }

    return trackingId;
}

From source file:de.bangl.lm.LotManagerPlugin.java

public void getInactiveLotList(CommandSender sender) {
    try {/* ww w  .  ja va  2  s  .  c  o m*/
        if (this.hasEssentials) {

            Calendar cal = Calendar.getInstance();
            cal.setTime(new Date());
            cal.add(Calendar.HOUR, -(24 * 7 * 2)); // Vor vier Wochen
            cal.set(Calendar.HOUR, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);

            Boolean foundone = false;
            for (World world : this.getServer().getWorlds()) {
                for (Lot lot : this.lots.getAllLots().values()) {
                    final ProtectedRegion wgregion = this.wg.getRegionManager(world).getRegion(lot.getId());
                    if (wgregion != null) {
                        DefaultDomain owners = wgregion.getOwners();
                        if (owners != null) {
                            for (UUID player : owners.getUniqueIds()) {
                                User essuser = this.ess.getUser(player);
                                if (essuser != null) {
                                    final Date lastonline = new Date(essuser.getLastLogin());
                                    if (lastonline.before(cal.getTime())) {
                                        this.sendInfo(sender, lot.getId() + " - " + essuser.getDisplayName()
                                                + " (" + lastonline.toString() + ")");
                                        foundone = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (!foundone) {
                this.sendInfo(sender, "All lots given away seem to be actively used.");
            }
        } else {
            sendError(sender, "Sorry, you need \"Essentials\" to use this feature.");
        }
    } catch (Exception e) {
        logError(e.getMessage());
        sendError(sender, e.getMessage());
    }
}

From source file:com.mimp.controllers.familia.java

@RequestMapping("/Finscripcion")
public ModelAndView Finscripcion(ModelMap map, HttpSession session) {
    Familia usuario = (Familia) session.getAttribute("usuario");
    if (usuario == null) {
        String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente";
        map.addAttribute("mensaje", mensaje);
        return new ModelAndView("login", map);
    }//from w w  w.  j  a  v a2 s.c  o m
    usuario = ServicioFamilia.obtenerFormulariosFamilia(usuario.getIdfamilia());

    String departamento = "";
    Date fechaactual = new Date();
    Date ultfecha = new Date(10, 0, 01);
    for (Iterator iter = usuario.getFormularioSesions().iterator(); iter.hasNext();) {
        FormularioSesion form = (FormularioSesion) iter.next();
        if (ultfecha.before(form.getFechaSol())) {
            ultfecha = form.getFechaSol();
            Sesion ses = ServicioFamilia.getSesionDeFormulario(form.getIdformularioSesion());
            departamento = ses.getUnidad();
        }
    }
    String nombreTaller = "";
    String pagina;
    boolean inscritoTaller = false;
    ArrayList<AsistenciaFR> allReuniones = new ArrayList();
    allReuniones = ServicioFamilia.listaReunionesInscritasFamilia(usuario.getIdfamilia());
    if (!allReuniones.isEmpty()) {
        Taller temp = ServicioPersonal.getTallerByIdReunion(allReuniones.get(0).getReunion().getIdreunion());
        nombreTaller = temp.getNombre();
        for (AsistenciaFR asistenciaFR : allReuniones) {
            if (fechaactual.before(asistenciaFR.getReunion().getFecha())) {
                inscritoTaller = true;
            }
        }
    }
    if (ultfecha.getYear() < fechaactual.getYear()) {
        System.out.print(ultfecha);
        System.out.print(fechaactual);
        Sesion sesionMasProx = new Sesion();
        //ArrayList<Personal> allPersonal = new ArrayList();
        ArrayList<Turno> allTurnos = new ArrayList();
        sesionMasProx = ServicioFamilia.sesionMasProx(fechaactual, departamento);

        allTurnos = ServicioMain.turnosSesion(sesionMasProx.getIdsesion());

        //allPersonal = ServicioPersonal.ListaPersonal();
        String fecha = "";
        if (sesionMasProx.getFecha() != null) {
            fecha = format.dateToString(sesionMasProx.getFecha());
        }
        String hora = sesionMasProx.getHora();

        map.put("listaTurnos", allTurnos);
        map.put("sesion", sesionMasProx);
        //map.put("listaPersonal", allPersonal);
        map.addAttribute("ts", ts);
        map.addAttribute("fecha", fecha);
        map.addAttribute("hora", hora);

        map.put("formato", format);

        pagina = "/Familia/Inscripcion/inscripcion_sesionInfo";
    } else {

        ExpedienteFamilia tempExp = new ExpedienteFamilia();
        tempExp = ServicioFamilia.getExpFam(usuario.getIdfamilia());

        ArrayList<PostAdopcion> allPost = new ArrayList();
        allPost = ServicioFamilia.getListaPostAdopcion(usuario.getIdfamilia());

        ArrayList<Taller> listaTodosTalleres = new ArrayList();
        ArrayList<Taller> listaTalleresPermitidos = new ArrayList();

        listaTodosTalleres = ServicioFamilia.listaTalleresHabilitadosPorDep(departamento);
        if (usuario.getConstancia() == null || usuario.getConstancia().equals("")) {
            for (Taller taller : listaTodosTalleres) {
                if (taller.getTipoTaller().equals("preparacion")) {
                    listaTalleresPermitidos.add(taller);
                }
            }
        } else if (tempExp.getIdexpedienteFamilia() != 0 && tempExp.getEstado().equals("espera")) {
            for (Taller taller : listaTodosTalleres) {
                if (taller.getTipoTaller().equals("lista")) {
                    listaTalleresPermitidos.add(taller);
                }
            }
        } else if (allPost.size() >= 1) {
            for (Taller taller : listaTodosTalleres) {
                if (taller.getTipoTaller().equals("post")) {
                    listaTalleresPermitidos.add(taller);
                }
            }
        }

        map.put("listaTalleres", listaTalleresPermitidos);
        map.put("formato", format);
        if (inscritoTaller) {
            map.put("inscrito", "true");
            map.put("listaReuniones", allReuniones);
            map.put("nombreTaller", nombreTaller);
        } else {
            map.put("inscrito", "false");
        }
        pagina = "/Familia/Inscripcion/inscripcion_Talleres";
    }
    return new ModelAndView(pagina, map);
}