Example usage for java.util Date equals

List of usage examples for java.util Date equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares two dates for equality.

Usage

From source file:org.openmrs.module.kenyaemr.fragment.controller.patient.ImportPatientsListFragmentController.java

protected void handleOncePerPatientObs(Patient patient, Concept question, Concept newValue, String textValue,
        Date textDate, Double numnericValue, Encounter en, Obs obsGroup, Visit v) {
    Obs o = new Obs();
    o.setPerson(patient);/*from w  ww . j  a  va 2s  .  c o m*/
    o.setConcept(question);
    if (en != null) {
        o.setObsDatetime(en.getEncounterDatetime());
    } else {
        o.setObsDatetime(v.getStartDatetime());
    }

    o.setLocation(Context.getService(KenyaEmrService.class).getDefaultLocation());
    if (newValue != null && !newValue.equals("")) {
        o.setValueCoded(newValue);
    }
    if (textValue != null && !textValue.equals("")) {
        o.setValueText(textValue);
    }

    if (numnericValue != null) {
        o.setValueNumeric(numnericValue);
    }
    if (textDate != null && !textDate.equals("")) {
        o.setValueDate(textDate);
    }
    if (en != null) {
        o.setEncounter(en);
    }
    if (obsGroup != null) {
        o.setObsGroup(obsGroup);
    }
    //en.addObs(o);
    try {
        Context.getObsService().saveObs(o, "KenyaEMR History Details");
    } catch (RuntimeException e) {
        en.addObs(o);
    }
}

From source file:org.craftercms.studio.impl.v1.service.workflow.WorkflowServiceImpl.java

/**
 * approve workflows and schedule them as specified in the request
 *
 * @param site//from ww  w. j  a v a  2 s  . com
 * @return call result
 * @throws ServiceException
 */
protected void goLive(final String site, final List<DmDependencyTO> submittedItems, String approver,
        MultiChannelPublishingContext mcpContext) throws ServiceException {
    long start = System.currentTimeMillis();
    // get web project information
    //final String assignee = getAssignee(site, sub);
    final String pathPrefix = "/wem-projects/" + site + "/" + site + "/work-area";
    final Date now = new Date();
    if (submittedItems != null) {
        // group submitted items into packages by their scheduled date
        Map<Date, List<DmDependencyTO>> groupedPackages = groupByDate(submittedItems, now);

        for (Date scheduledDate : groupedPackages.keySet()) {
            List<DmDependencyTO> goLivePackage = groupedPackages.get(scheduledDate);
            if (goLivePackage != null) {
                Date launchDate = scheduledDate.equals(now) ? null : scheduledDate;

                final boolean isNotScheduled = (launchDate == null);
                // for submit direct, package them together and submit them
                // together as direct submit
                final SubmitPackage submitpackage = new SubmitPackage(pathPrefix);
                /*
                dependencyPackage holds references of page.
                 */
                final Set<String> rescheduledUris = new HashSet<String>();
                final SubmitPackage dependencyPackage = new SubmitPackage("");
                for (final DmDependencyTO dmDependencyTO : goLivePackage) {
                    goLivepackage(site, submitpackage, dmDependencyTO, isNotScheduled, dependencyPackage,
                            approver, rescheduledUris);
                }

                List<String> stringList = submitpackage.getPaths();
                String label = submitpackage.getLabel();
                SubmitLifeCycleOperation operation = null;
                GoLiveContext context = new GoLiveContext(approver, site);
                if (!isNotScheduled) {
                    Set<String> uris = new HashSet<String>();
                    uris.addAll(dependencyPackage.getUris());
                    uris.addAll(submitpackage.getUris());
                    label = getScheduleLabel(submitpackage, dependencyPackage);
                    operation = new PreScheduleOperation(this, uris, launchDate, context, rescheduledUris);
                } else {
                    operation = new PreGoLiveOperation(this, submitpackage.getUris(), context, rescheduledUris);
                }
                if (!stringList.isEmpty()) {
                    // get the workflow initiator mapping
                    Map<String, String> submittedBy = new HashMap<String, String>();
                    for (String longPath : stringList) {
                        String uri = longPath.substring(pathPrefix.length());
                        //ContentUtils.addToSubmittedByMapping(getService(PersistenceManagerService.class), dmContentService, site, uri, submittedBy, approver);
                        dmPublishService.cancelScheduledItem(site, uri);
                    }
                    workflowProcessor.addToWorkflow(site, stringList, launchDate, label, operation, approver,
                            mcpContext);

                }
                Set<DmDependencyTO> dependencyTOSet = submitpackage.getItems();
                for (DmDependencyTO dmDependencyTO : dependencyTOSet) {
                    dmWorkflowListener.postGolive(site, dmDependencyTO);
                }
                dependencyTOSet = dependencyPackage.getItems();
                for (DmDependencyTO dmDependencyTO : dependencyTOSet) {
                    dmWorkflowListener.postGolive(site, dmDependencyTO);
                }
            }
        }
    }
    long end = System.currentTimeMillis();
    logger.debug("Total go live time = " + (end - start));
}

From source file:org.apache.ojb.odmg.ObjectImageTest.java

/**
 * only lock object, no changes made/*from ww w.  j a v a 2 s  . c  om*/
 */
public void testChangeMainFields() throws Exception {
    String name = "testChangeMainFields_" + System.currentTimeMillis();
    Date date = new Date();
    byte[] cover = new byte[] { 2, 3, 4, 5, 6, 7, 8, 9 };
    Book book = new Book(name, date, cover);

    TransactionExt tx = (TransactionExt) odmg.newTransaction();
    tx.begin();
    database.makePersistent(book);
    tx.commit();

    Integer version = book.getVersion();
    // System.err.println("### 1. commit, insert new object");

    tx.begin();
    tx.lock(book, Transaction.WRITE);
    tx.commit();

    // System.err.println("### 2. commit, no changes");
    assertEquals(version, book.getVersion());

    tx.begin();
    tx.lock(book, Transaction.WRITE);
    // we set the same date, so no reason to update
    book.setPublicationDate(new Date(date.getTime()));
    tx.commit();

    // System.err.println("### 3. commit, replace with same date");
    assertEquals(version, book.getVersion());

    tx.begin();
    tx.lock(book, Transaction.WRITE);
    // now we change the date
    Date d = new Date(1111);
    book.setPublicationDate(d);
    tx.commit();
    // System.err.println("### 4. commit, changed date");
    assertFalse(date.equals(book.getPublicationDate()));
    assertFalse(version.equals(book.getVersion()));
}

From source file:edu.stanford.muse.email.EmailFetcherStats.java

/**
 * Key method for importing email: converts a javamail obj. to our own data structure (EmailDocument)
 *///ww  w.j a v  a2  s  .c o m
//public EmailDocument convertToEmailDocument(MimeMessage m, int num, String url) throws MessagingException, IOException
private EmailDocument convertToEmailDocument(MimeMessage m, String id) throws MessagingException, IOException {
    // get the date.
    // prevDate is a hack for the cases where the message is lacking an explicit Date: header. e.g.
    //      From hangal Sun Jun 10 13:46:46 2001
    //      To: ewatkins@stanford.edu
    //      Subject: Re: return value bugs
    // though the date is on the From separator line, the mbox provider fails to parse it and provide it to us.
    // so as a hack, we will assign such messages the same date as the previous one this fetcher has seen! ;-)
    // update: having the exact same date causes the message to be considered a duplicate, so just increment
    // the timestamp it by 1 millisecond!
    // a better fix would be to improve the parsing in the provider

    boolean hackyDate = false;
    Date d = m.getSentDate();
    if (d == null)
        d = m.getReceivedDate();
    if (d == null) {
        if (prevDate != null) {
            long newTime = prevDate.getTime() + 1L; // added +1 so that this email is not considered the same object as the prev. one if they are in the same thread
            d = new Date(newTime);
            dataErrors.add("No date for message id:" + id + ": " + EmailUtils.formatMessageHeader(m)
                    + " assigned approximate date");
        } else {
            d = INVALID_DATE; // wrong, but what can we do... :-(
            dataErrors.add("No date for message id:" + id + ": " + EmailUtils.formatMessageHeader(m)
                    + " assigned deliberately invalid date");
        }
        hackyDate = true;
    } else {
        Calendar c = new GregorianCalendar();
        c.setTime(d);
        int yy = c.get(Calendar.YEAR);
        if (yy < 1960 || yy > 2020) {
            dataErrors.add("Probably bad date: " + Util.formatDate(c) + " message: "
                    + EmailUtils.formatMessageHeader(m));
            hackyDate = true;
        }
    }

    if (hackyDate && prevDate != null) {
        long newTime = prevDate.getTime() + 1L; // added +1 so that this email is not considered the same object as the prev. one if they are in the same thread
        d = new Date(newTime);
        Util.ASSERT(!d.equals(prevDate));
    }

    Calendar c = new GregorianCalendar();
    c.setTime(d != null ? d : new Date());

    prevDate = d;

    Address to[] = null, cc[] = null, bcc[] = null;
    Address[] from = null;
    try {
        //          allrecip = m.getAllRecipients(); // turns out to be too expensive because it looks for newsgroup headers for imap
        // assemble to, cc, bcc into a list and copy it into allrecip
        List<Address> list = new ArrayList<Address>();
        from = m.getFrom();
        to = m.getRecipients(Message.RecipientType.TO);
        if (to != null)
            list.addAll(Arrays.asList(to));
        cc = m.getRecipients(Message.RecipientType.CC);
        if (cc != null)
            list.addAll(Arrays.asList(cc));
        bcc = m.getRecipients(Message.RecipientType.BCC);
        if (bcc != null)
            list.addAll(Arrays.asList(bcc));

        // intern the strings in these addresses to save memory cos they are repeated often in a large archive
        internAddressList(from);
        internAddressList(to);
        internAddressList(cc);
        internAddressList(bcc);
    } catch (AddressException ae) {
        String s = "Bad address in folder " + folder_name() + " message id" + id + " " + ae;
        dataErrors.add(s);
    }

    // take a deep breath. This object is going to live longer than most of us.
    EmailDocument ed = new EmailDocument(id, email_source(), folder_name(), to, cc, bcc, from, m.getSubject(),
            m.getMessageID(), c.getTime());

    String[] headers = m.getHeader("List-Post");
    if (headers != null && headers.length > 0) {
        // trim the headers because they usually look like: "<mailto:prpl-devel@lists.stanford.edu>"
        ed.sentToMailingLists = new String[headers.length];
        int i = 0;
        for (String header : headers) {
            header = header.trim();
            header = header.toLowerCase();

            if (header.startsWith("<") && header.endsWith(">"))
                header = header.substring(1, header.length() - 1);
            if (header.startsWith("mailto:") && !"mailto:".equals(header)) // defensive check in case header == "mailto:"
                header = header.substring(("mailto:").length());
            ed.sentToMailingLists[i++] = header;
        }
    }
    if (hackyDate) {
        String s = "Guessed date " + Util.formatDate(c) + " for message id: " + id + ": " + ed.getHeader();
        dataErrors.add(s);
        ed.hackyDate = true;
    }

    // check if the message has attachments.
    // if it does and we're not downloading attachments, then we mark the ed as such.
    // otherwise we had a problem where a message header (and maybe text) was downloaded but without attachments in one run
    // but in a subsequent run where attachments were needed, we thought the message was already cached and there was no
    // need to recompute it, leaving the attachments field in this ed incorrect.
    List<String> attachmentNames = getAttachmentNames(m, m);
    if (!Util.nullOrEmpty(attachmentNames)) {
        ed.attachmentsYetToBeDownloaded = true; // will set it to false later if attachments really were downloaded (not sure why)
        //         log.info ("added " + attachmentNames.size() + " attachments to message: " + ed);
    }
    return ed;
}

From source file:org.apache.lens.cube.metadata.CubeMetastoreClient.java

public boolean isStorageTableCandidateForRange(String storageTableName, Date fromDate, Date toDate)
        throws LensException {
    List<Date> storageEndDates = getStorageTimes(storageTableName, MetastoreUtil.getStoragetableEndTimesKey());
    for (Date endDate : storageEndDates) {
        // endDate is exclusive
        if (endDate.before(fromDate) || endDate.equals(fromDate)) {
            log.debug("from date {} is after validity end time: {}, hence discarding {}", fromDate, endDate,
                    storageTableName);/*from w  w w. j  a va2 s . c  o m*/
            return false;
        }
    }

    List<Date> storageStartDates = getStorageTimes(storageTableName,
            MetastoreUtil.getStoragetableStartTimesKey());
    for (Date startDate : storageStartDates) {
        // toDate is exclusive on the range
        if (startDate.after(toDate) || startDate.equals(toDate)) {
            log.debug("to date {} is before validity start time: {}, hence discarding {}", toDate, startDate,
                    storageTableName);
            return false;
        }
    }
    return true;
}

From source file:gskproject.Analyze.java

public boolean departmentAccidentTableLoad(Date from1, Date to1) {
    depHashMap = new HashMap<Object, Object[]>();
    ArrayList<Object[]> depNameID = dbOps.getDepartmentNameID();

    java.sql.Date from;/*  w ww  . j a v a2 s. co  m*/
    java.sql.Date to;

    if (from1 == null && to1 == null) {
        from = null;
        to = null;
    } else if (from1 == null) {
        from = null;
        to = new java.sql.Date(to1.getTime());
    } else if (to1 == null) {
        from = new java.sql.Date(from1.getTime());
        to = null;
    } else {
        from = new java.sql.Date(from1.getTime());
        to = new java.sql.Date(to1.getTime());
    }

    Vector<String> columnNames = new Vector<String>();
    columnNames.add("Department");
    columnNames.add("First Aid");
    columnNames.add("LTI");
    columnNames.add("Near Miss");
    columnNames.add("Open Cases");
    columnNames.add("Closed Cases");
    columnNames.add("Total");

    //int[][] depAccident=new int[3][3];
    int DAOpen = 0;
    int DAClose = 0;
    int firstAidTotal = 0;
    int LTITotal = 0;
    int nearMissTotal = 0;
    //int openTotal=0;
    //int closeTotal=0;
    int totalTotal = 0;

    if (from != null && to != null) {
        if (to.after(from) || to.equals(from)) {
            tableObservation = dbOps.getAnalyzeObservation(from, to);
            if (tableObservation.size() > 0) {
                for (Object[] row : depNameID) {
                    Object[] array = new Object[6];
                    array[0] = row[1];
                    array[1] = 0;
                    array[2] = 0;
                    array[3] = 0;
                    array[4] = 0;
                    array[5] = 0;
                    depHashMap.put(row[0], array);
                }

                for (Vector row : tableObservation) {
                    Object[] array = depHashMap.get((int) row.get(5));
                    if (row.get(11).equals("First Aid")) {
                        array[1] = (int) array[1] + 1;
                        firstAidTotal++;
                    } else if (row.get(11).equals("LTI")) {
                        array[2] = (int) array[2] + 1;
                        LTITotal++;
                    } else {
                        array[3] = (int) array[3] + 1;
                        nearMissTotal++;
                    }

                    if (row.get(8).equals("Open")) {
                        array[4] = (int) array[4] + 1;
                        DAOpen++;
                    } else {
                        array[5] = (int) array[5] + 1;
                        DAClose++;
                    }
                }

                tableDepartmentAccident = new Vector<Vector>();
                for (Object[] array : depNameID) {
                    Vector<Object> row1 = new Vector<Object>();
                    row1.add(array[1]);
                    row1.add((int) depHashMap.get(array[0])[1]);
                    row1.add((int) depHashMap.get(array[0])[2]);
                    row1.add((int) depHashMap.get(array[0])[3]);
                    row1.add((int) depHashMap.get(array[0])[4]);
                    row1.add((int) depHashMap.get(array[0])[5]);
                    row1.add((int) depHashMap.get(array[0])[1] + (int) depHashMap.get(array[0])[2]
                            + (int) depHashMap.get(array[0])[3]);
                    tableDepartmentAccident.add(row1);
                }

                Vector<Object> row1 = new Vector<Object>();
                row1.add("Total -->");
                row1.add(firstAidTotal);
                row1.add(LTITotal);
                row1.add(nearMissTotal);
                row1.add(DAOpen);
                row1.add(DAClose);
                row1.add(firstAidTotal + LTITotal + nearMissTotal);
                tableDepartmentAccident.add(row1);

                tblDepartmentAccident.setModel(new DefaultTableModel(tableDepartmentAccident, columnNames));
                lblTotal.setText(Integer.toString(DAClose + DAOpen));
                lblOpen.setText(Integer.toString(DAOpen));
                lblClosed.setText(Integer.toString(DAClose));
                return true;
            } else {
                JOptionPane.showMessageDialog(this, "There are no observations!");
                tableDepartmentAccident = null;
                return false;
            }
        } else {
            JOptionPane.showMessageDialog(this, "Wrong Date Entry (from date > to date)!");
            tableDepartmentAccident = null;
            return false;
        }
    } else {
        tableObservation = dbOps.getAnalyzeObservation(from, to);
        if (tableObservation.size() > 0) {

            for (Object[] row : depNameID) {
                Object[] array = new Object[6];
                array[0] = row[1];
                array[1] = 0;
                array[2] = 0;
                array[3] = 0;
                array[4] = 0;
                array[5] = 0;
                depHashMap.put(row[0], array);
            }

            for (Vector row : tableObservation) {
                Object[] array = depHashMap.get((int) row.get(5));
                if (row.get(11).equals("First Aid")) {
                    array[1] = (int) array[1] + 1;
                    firstAidTotal++;
                } else if (row.get(11).equals("LTI")) {
                    array[2] = (int) array[2] + 1;
                    LTITotal++;
                } else {
                    array[3] = (int) array[3] + 1;
                    nearMissTotal++;
                }

                if (row.get(8).equals("Open")) {
                    array[4] = (int) array[4] + 1;
                    DAOpen++;
                } else {
                    array[5] = (int) array[5] + 1;
                    DAClose++;
                }
            }

            tableDepartmentAccident = new Vector<Vector>();
            for (Object[] array : depNameID) {
                Vector<Object> row1 = new Vector<Object>();
                row1.add(array[1]);
                row1.add((int) depHashMap.get(array[0])[1]);
                row1.add((int) depHashMap.get(array[0])[2]);
                row1.add((int) depHashMap.get(array[0])[3]);
                row1.add((int) depHashMap.get(array[0])[4]);
                row1.add((int) depHashMap.get(array[0])[5]);
                row1.add((int) depHashMap.get(array[0])[1] + (int) depHashMap.get(array[0])[2]
                        + (int) depHashMap.get(array[0])[3]);
                tableDepartmentAccident.add(row1);
            }

            Vector<Object> row1 = new Vector<Object>();
            row1.add("Total -->");
            row1.add(firstAidTotal);
            row1.add(LTITotal);
            row1.add(nearMissTotal);
            row1.add(DAOpen);
            row1.add(DAClose);
            row1.add(firstAidTotal + LTITotal + nearMissTotal);
            tableDepartmentAccident.add(row1);

            tblDepartmentAccident.setModel(new DefaultTableModel(tableDepartmentAccident, columnNames));
            lblTotal.setText(Integer.toString(DAClose + DAOpen));
            lblOpen.setText(Integer.toString(DAOpen));
            lblClosed.setText(Integer.toString(DAClose));
            return true;
        } else {
            JOptionPane.showMessageDialog(this, "There are no observations!");
            tableDepartmentAccident = null;
            return false;
        }
    }
}

From source file:org.craftercms.studio.impl.v1.service.workflow.WorkflowServiceImpl.java

protected List<DmDependencyTO> getChildrenForRenamedItem(String site, DmDependencyTO renameItem) {
    List<DmDependencyTO> toRet = new ArrayList<>();
    List<DmDependencyTO> children = renameItem.getChildren();
    Date date = renameItem.getScheduledDate();
    if (children != null) {
        Iterator<DmDependencyTO> childItr = children.iterator();
        while (childItr.hasNext()) {
            DmDependencyTO child = childItr.next();
            Date pageDate = child.getScheduledDate();
            if ((date == null && pageDate != null) || (date != null && !date.equals(pageDate))) {
                if (!renameItem.isNow()) {
                    child.setNow(false);
                    if (date != null && (pageDate != null && pageDate.before(date))) {
                        child.setScheduledDate(date);
                    }//from  ww w  .j  a  va 2s.  co  m
                }
                toRet.add(child);
                List<DmDependencyTO> childDeps = child.flattenChildren();
                for (DmDependencyTO childDep : childDeps) {
                    if (objectStateService.isUpdatedOrNew(site, childDep.getUri())) {
                        toRet.add(childDep);
                    }
                }
                child.setReference(false);
                childItr.remove();
            }
        }
    }
    return toRet;
}

From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.java

/**
 * Compares if report execution fire time is in given range (inclusive). From and to time are both nullable, so following cases are processed:
 * from != null && to != null - true if fire time in range (inclusive)
 * from == null && to != null - fire time should be before or equals to "to"
 * from != null && to == null - fire time should be after or equals to "from"
 * from == null && to == null - result is always false
 *
 * @param fireTime - fire time/*from  w  ww  . j  av a 2  s. c  om*/
 * @param from - search criteria from time, nullable
 * @param to - search criteria to time, nullable
 * @return true if fire time is in range (inclusive)
 */
private boolean isBetween(Date fireTime, Date from, Date to) {
    boolean result = false;
    if (fireTime != null && (from != null || to != null)) {
        if (from != null && to != null)
            result = (fireTime.after(from) || fireTime.equals(from))
                    && (fireTime.before(to) || fireTime.equals(to));
        else if (from != null && to == null)
            result = fireTime.after(from) || fireTime.equals(from);
        else if (from == null && to != null)
            result = fireTime.before(to) || fireTime.equals(to);
    }
    return result;
}

From source file:org.craftercms.studio.impl.v1.service.workflow.WorkflowServiceImpl.java

protected void handleReferences(String site, SubmitPackage submitpackage, DmDependencyTO dmDependencyTO,
        boolean isNotScheduled, SubmitPackage dependencyPackage, String approver, Set<String> rescheduledUris) {//,boolean isReferencePage) {
    String path = contentService.expandRelativeSitePath(site, dmDependencyTO.getUri());
    ObjectMetadata properties = objectMetadataManager.getProperties(site, dmDependencyTO.getUri());
    Date scheduledDate = null;
    if (properties != null) {
        scheduledDate = properties.getLaunchDate();
    }//from  w w  w .j a v  a2s  . com
    ObjectState state = objectStateService.getObjectState(site, dmDependencyTO.getUri());
    if (state != null) {
        if (!State.isSubmitted(State.valueOf(state.getState())) && scheduledDate != null
                && scheduledDate.equals(dmDependencyTO.getScheduledDate())) {
            if (objectStateService.isScheduled(site, dmDependencyTO.getUri())) {
                return;
            } else {
                submitpackage.addToPackage(dmDependencyTO);
            }
        }
    }
    if (!dmDependencyTO.isReference()) {
        submitpackage.addToPackage(dmDependencyTO);
    }

    DependencyRules rule = new DependencyRules(site);
    rule.setObjectStateService(objectStateService);
    rule.setContentService(contentService);
    Set<DmDependencyTO> dependencyTOSet;
    if (dmDependencyTO.isSubmittedForDeletion() || dmDependencyTO.isDeleted()) {
        dependencyTOSet = rule.applyDeleteDependencyRule(dmDependencyTO);
    } else {
        long start = System.currentTimeMillis();
        dependencyTOSet = rule.applySubmitRule(dmDependencyTO);
        long end = System.currentTimeMillis();
        logger.debug("Time to get dependencies rule = " + (end - start));

    }
    for (DmDependencyTO dependencyTO : dependencyTOSet) {
        submitpackage.addToPackage(dependencyTO);
        if (!isNotScheduled) {
            dependencyPackage.addToPackage(dependencyTO);
        }
    }

    if (isRescheduleRequest(dmDependencyTO, site)) {
        rescheduledUris.add(dmDependencyTO.getUri());
    }
}

From source file:org.craftercms.studio.impl.v1.service.workflow.WorkflowServiceImpl.java

protected List<DmDependencyTO> getRefAndChildOfDiffDateFromParent_new(String site,
        List<DmDependencyTO> submittedItems, boolean removeInPages) {
    List<DmDependencyTO> childAndReferences = new ArrayList<>();
    for (DmDependencyTO submittedItem : submittedItems) {
        List<DmDependencyTO> children = submittedItem.getChildren();
        Date date = submittedItem.getScheduledDate();
        if (children != null) {
            Iterator<DmDependencyTO> childItr = children.iterator();
            while (childItr.hasNext()) {
                DmDependencyTO child = childItr.next();
                Date pageDate = child.getScheduledDate();
                if ((date == null && pageDate != null) || (date != null && !date.equals(pageDate))) {
                    if (!submittedItem.isNow()) {
                        child.setNow(false);
                        if (date != null && (pageDate != null && pageDate.before(date))) {
                            child.setScheduledDate(date);
                        }//from   w w  w  . j  a v  a2  s. c  o m
                    }
                    childAndReferences.add(child);
                    List<DmDependencyTO> childDeps = child.flattenChildren();
                    for (DmDependencyTO childDep : childDeps) {
                        if (objectStateService.isUpdatedOrNew(site, childDep.getUri())) {
                            childAndReferences.add(childDep);
                        }
                    }
                    child.setReference(false);
                    childItr.remove();
                    if (removeInPages) {
                        String uri = child.getUri();
                        List<DmDependencyTO> pages = submittedItem.getPages();
                        if (pages != null) {
                            Iterator<DmDependencyTO> pagesIter = pages.iterator();
                            while (pagesIter.hasNext()) {
                                DmDependencyTO page = pagesIter.next();
                                if (page.getUri().equals(uri)) {
                                    pagesIter.remove();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return childAndReferences;
}