Example usage for java.math BigDecimal equals

List of usage examples for java.math BigDecimal equals

Introduction

In this page you can find the example usage for java.math BigDecimal equals.

Prototype

@Override
public boolean equals(Object x) 

Source Link

Document

Compares this BigDecimal with the specified Object for equality.

Usage

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onTransfer(TransferEvent event) {
    int index;//ww  w. j a  v  a  2  s  .c o  m
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onTransferWiki(TransferEvent event) {
    int index;/* w  w w.j  a  v  a2 s . com*/
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onTransferBpractica(TransferEvent event) {
    int index;/*  www.j ava  2  s  . c  o m*/
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onTransferOmejora(TransferEvent event) {
    int index;//from  www. j  a v  a 2 s . co  m
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onTransferPreguntas(TransferEvent event) {
    int index;/*from  w  ww  . java 2s.c o  m*/
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }

            this.setListaTargetVinculosConocimiento(new ArrayList<Consulta>());

            if (this.getListaTargetVinculosBL() != null) {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosBL());
            }
            if (this.getListaTargetVinculosBP() != null) {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosBP());
            }
            if (this.getListaTargetVinculosCT() != null) {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosCT());
            }
            if (this.getListaTargetVinculosOM() != null) {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosOM());
            }
            if (this.getListaTargetVinculosWK() != null) {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosWK());
            }

        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.oracle.OracleCDCSource.java

private void generateRecords(Offset startingOffset, PreparedStatement selectChanges) {
    // When this is called the first time, Logminer was started either from SCN or from a start date, so we just keep
    // track of the start date etc.
    LOG.info("Attempting to generate records");
    boolean error;
    StringBuilder query = new StringBuilder();
    BigDecimal lastCommitSCN = new BigDecimal(startingOffset.scn);
    int sequenceNumber = startingOffset.sequence;
    LocalDateTime startTime = adjustStartTime(startingOffset.timestamp);
    String lastTxnId = startingOffset.txnId;
    LocalDateTime endTime = getEndTimeForStartTime(startTime);
    ResultSet resultSet = null;// w w  w  .  j  a  v  a 2s  . c  o  m
    while (!getContext().isStopped()) {
        error = false;
        generationStarted = true;
        try {
            recordQueue.put(new RecordOffset(dummyRecord,
                    new Offset(version, startTime, lastCommitSCN.toPlainString(), sequenceNumber, lastTxnId)));
            selectChanges = getSelectChangesStatement();
            if (!useLocalBuffering) {
                selectChanges.setBigDecimal(1, lastCommitSCN);
                selectChanges.setInt(2, sequenceNumber);
                selectChanges.setBigDecimal(3, lastCommitSCN);
                if (shouldTrackDDL) {
                    selectChanges.setBigDecimal(4, lastCommitSCN);
                }
            }
            selectChanges.setFetchSize(configBean.jdbcFetchSize);
            resultSet = selectChanges.executeQuery();
            while (resultSet.next() && !getContext().isStopped()) {
                String queryFragment = resultSet.getString(5);
                BigDecimal scnDecimal = resultSet.getBigDecimal(1);
                String scn = scnDecimal.toPlainString();
                String xidUsn = String.valueOf(resultSet.getLong(10));
                String xidSlt = String.valueOf(resultSet.getString(11));
                String xidSqn = String.valueOf(resultSet.getString(12));
                String xid = xidUsn + "." + xidSlt + "." + xidSqn;
                // Query Fragment is not null -> we need to process
                // Query Fragment is null AND the query string buffered from previous rows due to CSF == 0 is null,
                // nothing to do, go to next row
                // Query Fragment is null, but there is previously buffered data in the query, go ahead and process.
                if (queryFragment != null) {
                    query.append(queryFragment);
                } else if (queryFragment == null && query.length() == 0) {
                    LOG.debug(READ_NULL_QUERY_FROM_ORACLE, scn, xid);
                    continue;
                }

                // CSF is 1 if the query is incomplete, so read the next row before parsing
                // CSF being 0 means query is complete, generate the record
                if (resultSet.getInt(9) == 0) {
                    if (query.length() == 0) {
                        LOG.debug(READ_NULL_QUERY_FROM_ORACLE, scn, xid);
                        continue;
                    }
                    String queryString = query.toString();
                    query.setLength(0);
                    String username = resultSet.getString(2);
                    short op = resultSet.getShort(3);
                    String timestamp = resultSet.getString(4);
                    LocalDateTime tsDate = Timestamp.valueOf(timestamp).toLocalDateTime();
                    delay.getValue().put("delay", getDelay(tsDate));
                    String table = resultSet.getString(6);
                    BigDecimal commitSCN = resultSet.getBigDecimal(7);
                    int seq = resultSet.getInt(8);

                    String rsId = resultSet.getString(13);
                    Object ssn = resultSet.getObject(14);
                    String schema = String.valueOf(resultSet.getString(15));
                    int rollback = resultSet.getInt(16);
                    String rowId = resultSet.getString(17);
                    SchemaAndTable schemaAndTable = new SchemaAndTable(schema, table);
                    TransactionIdKey key = new TransactionIdKey(xid);
                    bufferedRecordsLock.lock();
                    try {
                        if (useLocalBuffering && bufferedRecords.containsKey(key) && bufferedRecords.get(key)
                                .contains(new RecordSequence(null, null, 0, 0, rsId, ssn, null))) {
                            continue;
                        }
                    } finally {
                        bufferedRecordsLock.unlock();
                    }
                    Offset offset = null;
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(
                                "Commit SCN = {}, SCN = {}, Operation = {}, Txn Id = {}, Timestamp = {}, Row Id = {}, Redo SQL = {}",
                                commitSCN, scn, op, xid, tsDate, rowId, queryString);
                    }

                    if (op != DDL_CODE && op != COMMIT_CODE && op != ROLLBACK_CODE) {
                        if (!useLocalBuffering) {
                            offset = new Offset(version, tsDate, commitSCN.toPlainString(), seq, xid);
                        }
                        Map<String, String> attributes = new HashMap<>();
                        attributes.put(SCN, scn);
                        attributes.put(USER, username);
                        attributes.put(TIMESTAMP_HEADER, timestamp);
                        attributes.put(TABLE, table);
                        attributes.put(SEQ, String.valueOf(seq));
                        attributes.put(XID, xid);
                        attributes.put(RS_ID, rsId);
                        attributes.put(SSN, ssn.toString());
                        attributes.put(SCHEMA, schema);
                        attributes.put(ROLLBACK, String.valueOf(rollback));
                        attributes.put(ROWID_KEY, rowId);
                        if (!useLocalBuffering || getContext().isPreview()) {
                            if (commitSCN.compareTo(lastCommitSCN) < 0
                                    || (commitSCN.compareTo(lastCommitSCN) == 0 && seq < sequenceNumber)) {
                                continue;
                            }
                            lastCommitSCN = commitSCN;
                            sequenceNumber = seq;
                            if (configBean.keepOriginalQuery) {
                                attributes.put(QUERY_KEY, queryString);
                            }
                            try {
                                Record record = generateRecord(queryString, attributes, op);
                                if (record != null && record.getEscapedFieldPaths().size() > 0) {
                                    recordQueue.put(new RecordOffset(record, offset));
                                }
                            } catch (UnparseableSQLException ex) {
                                LOG.error("Parsing failed", ex);
                                unparseable.offer(queryString);
                            }
                        } else {
                            bufferedRecordsLock.lock();
                            try {
                                HashQueue<RecordSequence> records = bufferedRecords.computeIfAbsent(key, x -> {
                                    x.setTxnStartTime(tsDate);
                                    return createTransactionBuffer(key.txnId);
                                });

                                int nextSeq = records.isEmpty() ? 1 : records.tail().seq + 1;
                                RecordSequence node = new RecordSequence(attributes, queryString, nextSeq, op,
                                        rsId, ssn, tsDate);
                                records.add(node);
                            } finally {
                                bufferedRecordsLock.unlock();
                            }
                        }
                    } else if (!getContext().isPreview() && useLocalBuffering
                            && (op == COMMIT_CODE || op == ROLLBACK_CODE)) {
                        // so this commit was previously processed or it is a rollback, so don't care.
                        if (op == ROLLBACK_CODE || scnDecimal.compareTo(lastCommitSCN) < 0) {
                            bufferedRecordsLock.lock();
                            try {
                                bufferedRecords.remove(key);
                            } finally {
                                bufferedRecordsLock.unlock();
                            }
                        } else {
                            bufferedRecordsLock.lock();
                            try {
                                HashQueue<RecordSequence> records = bufferedRecords.getOrDefault(key,
                                        EMPTY_LINKED_HASHSET);
                                if (lastCommitSCN.equals(scnDecimal) && xid.equals(lastTxnId)) {
                                    removeProcessedRecords(records, sequenceNumber);
                                }
                                int bufferedRecordsToBeRemoved = records.size();
                                LOG.debug(FOUND_RECORDS_IN_TRANSACTION, bufferedRecordsToBeRemoved, xid);
                                lastCommitSCN = scnDecimal;
                                lastTxnId = xid;
                                sequenceNumber = addRecordsToQueue(tsDate, scn, xid);
                            } finally {
                                bufferedRecordsLock.unlock();
                            }
                        }
                    } else {
                        offset = new Offset(version, tsDate, scn, 0, xid);
                        boolean sendSchema = false;
                        // Commit/rollback in Preview will also end up here, so don't really do any of the following in preview
                        // Don't bother with DDL events here.
                        if (!getContext().isPreview()) {
                            // Event is sent on every DDL, but schema is not always sent.
                            // Schema sending logic:
                            // CREATE/ALTER: Schema is sent if the schema after the ALTER is newer than the cached schema
                            // (which we would have sent as an event earlier, at the last alter)
                            // DROP/TRUNCATE: Schema is not sent, since they don't change schema.
                            DDL_EVENT type = getDdlType(queryString);
                            if (type == DDL_EVENT.ALTER || type == DDL_EVENT.CREATE) {
                                sendSchema = refreshSchema(scnDecimal, new SchemaAndTable(schema, table));
                            }
                            recordQueue.put(new RecordOffset(createEventRecord(type, queryString,
                                    schemaAndTable, offset.toString(), sendSchema, timestamp), offset));
                        }
                    }
                    query.setLength(0);
                }
            }
        } catch (SQLException ex) {
            error = true;
            // force a restart from the same timestamp.
            if (ex.getErrorCode() == MISSING_LOG_FILE) {
                LOG.warn("SQL Exception while retrieving records", ex);
                addToStageExceptionsQueue(new StageException(JDBC_86, ex));
            } else if (ex.getErrorCode() != RESULTSET_CLOSED_AS_LOGMINER_SESSION_CLOSED) {
                LOG.warn("SQL Exception while retrieving records", ex);
            } else if (ex.getErrorCode() == QUERY_TIMEOUT) {
                LOG.warn("LogMiner select query timed out");
            } else if (ex.getErrorCode() == LOGMINER_START_MUST_BE_CALLED) {
                LOG.warn("Last LogMiner session did not start successfully. Will retry", ex);
            } else {
                LOG.error("Error while reading data", ex);
                addToStageExceptionsQueue(new StageException(JDBC_52, ex));
            }
        } catch (StageException e) {
            LOG.error("Error while reading data", e);
            error = true;
            addToStageExceptionsQueue(e);
        } catch (InterruptedException ex) {
            LOG.error("Interrupted while waiting to add data");
            Thread.currentThread().interrupt();
        } catch (Exception ex) {
            LOG.error("Error while reading data", ex);
            error = true;
            addToStageExceptionsQueue(new StageException(JDBC_52, ex));
        } finally {
            // If an incomplete batch is seen, it means we are going to move the window forward
            // Ending this session and starting a new one helps reduce PGA memory usage.
            try {
                if (resultSet != null && !resultSet.isClosed()) {
                    resultSet.close();
                }
                if (selectChanges != null && !selectChanges.isClosed()) {
                    selectChanges.close();
                }
            } catch (SQLException ex) {
                LOG.warn("Error while attempting to close SQL statements", ex);
            }
            try {
                endLogMnr.execute();
            } catch (SQLException ex) {
                LOG.warn("Error while trying to close logminer session", ex);
            }
            try {
                if (error) {
                    resetConnectionsQuietly();
                } else {
                    discardOldUncommitted(startTime);
                    startTime = adjustStartTime(endTime);
                    endTime = getEndTimeForStartTime(startTime);
                }
                startLogMinerUsingGivenDates(startTime.format(dateTimeColumnHandler.dateFormatter),
                        endTime.format(dateTimeColumnHandler.dateFormatter));
            } catch (SQLException ex) {
                LOG.error("Error while attempting to start LogMiner", ex);
                addToStageExceptionsQueue(new StageException(JDBC_52, ex));
            } catch (StageException ex) {
                LOG.error("Error while attempting to start logminer for redo log dictionary", ex);
                addToStageExceptionsQueue(ex);
            }
        }
    }
}

From source file:org.openbravo.test.costing.TestCosting.java

private void postMatchedPurchaseInvoice(InvoiceLine purchaseInvoiceLine, ShipmentInOutLine goodsReceiptLine) {
    try {/*from  www.  ja v  a2  s  . c  o m*/
        OBCriteria<ReceiptInvoiceMatch> criteria1 = OBDal.getInstance()
                .createCriteria(ReceiptInvoiceMatch.class);
        criteria1.add(Restrictions.eq(ReceiptInvoiceMatch.PROPERTY_INVOICELINE, purchaseInvoiceLine));
        criteria1.add(Restrictions.eq(ReceiptInvoiceMatch.PROPERTY_GOODSSHIPMENTLINE, goodsReceiptLine));
        ReceiptInvoiceMatch receiptInvoiceMatch = criteria1.list().get(0);
        assertMatchedInvoice(receiptInvoiceMatch,
                new MatchedInvoicesAssert(purchaseInvoiceLine, goodsReceiptLine));

        postDocument(receiptInvoiceMatch);
        receiptInvoiceMatch = OBDal.getInstance().get(ReceiptInvoiceMatch.class, receiptInvoiceMatch.getId());

        BigDecimal invoicePrice = OBDal.getInstance()
                .get(Invoice.class, purchaseInvoiceLine.getInvoice().getId()).getCurrencyConversionRateDocList()
                .size() == 0
                        ? purchaseInvoiceLine.getUnitPrice()
                        : purchaseInvoiceLine.getUnitPrice()
                                .multiply(OBDal.getInstance()
                                        .get(Invoice.class, purchaseInvoiceLine.getInvoice().getId())
                                        .getCurrencyConversionRateDocList().get(0).getRate());
        OBCriteria<AccountingFact> criteria2 = OBDal.getInstance().createCriteria(AccountingFact.class);
        criteria2.add(Restrictions.eq(AccountingFact.PROPERTY_RECORDID,
                goodsReceiptLine.getShipmentReceipt().getId()));
        criteria2.add(Restrictions.eq(AccountingFact.PROPERTY_LINEID, goodsReceiptLine.getId()));
        criteria2.addOrderBy(AccountingFact.PROPERTY_SEQUENCENUMBER, true);
        BigDecimal receiptPrice = criteria2.list().get(0).getDebit().divide(receiptInvoiceMatch.getQuantity());

        List<DocumentPostAssert> documentPostAssertList = new ArrayList<DocumentPostAssert>();
        documentPostAssertList
                .add(new DocumentPostAssert("40090", receiptPrice.multiply(receiptInvoiceMatch.getQuantity()),
                        amount0, goodsReceiptLine.getMovementQuantity()));
        documentPostAssertList.add(new DocumentPostAssert("60000", amount0,
                invoicePrice.multiply(receiptInvoiceMatch.getQuantity()),
                purchaseInvoiceLine.getInvoicedQuantity()));
        if (!invoicePrice.equals(receiptPrice))
            if (invoicePrice.compareTo(receiptPrice) > 0)
                documentPostAssertList.add(new DocumentPostAssert("99904",
                        invoicePrice.multiply(receiptInvoiceMatch.getQuantity())
                                .add(receiptPrice.multiply(receiptInvoiceMatch.getQuantity()).negate()),
                        amount0, goodsReceiptLine.getMovementQuantity()));
            else
                documentPostAssertList.add(new DocumentPostAssert("99904", amount0,
                        receiptPrice.multiply(receiptInvoiceMatch.getQuantity())
                                .add(invoicePrice.multiply(receiptInvoiceMatch.getQuantity()).negate()),
                        goodsReceiptLine.getMovementQuantity()));
        assertDocumentPost(receiptInvoiceMatch, purchaseInvoiceLine.getProduct().getId(),
                documentPostAssertList);
    } catch (Exception e) {
        throw new OBException(e);
    }
}