Search in sources :

Example 1 with CommissioningChange

use of com.autentia.tnt.businessobject.CommissioningChange in project TNTConcept by autentia.

the class CommissioningManager method getChange.

public CommissioningChange getChange(String field, String oldValue, String newValue, final Commissioning commissioning) {
    CommissioningChange change = null;
    if (!StringUtils.equals(oldValue, newValue)) {
        oldValue = StringUtils.defaultIfEmpty(oldValue, "");
        newValue = StringUtils.defaultIfEmpty(newValue, "");
        change = new CommissioningChange();
        change.setCommissioning(commissioning);
        change.setStatus(commissioning.getStatus());
        change.setField(field);
        change.setOldValue(oldValue);
        change.setNewValue(newValue);
        change.setInsertDate(new Date());
        change.setUser(AuthenticationManager.getDefault().getCurrentPrincipal().getUser());
    }
    return change;
}
Also used : CommissioningChange(com.autentia.tnt.businessobject.CommissioningChange) Date(java.util.Date)

Example 2 with CommissioningChange

use of com.autentia.tnt.businessobject.CommissioningChange in project TNTConcept by autentia.

the class CommissioningManager method getCollaboratorPaymentChanges.

private List<CommissioningChange> getCollaboratorPaymentChanges(final Commissioning commissioning) {
    final List<CommissioningChange> changes = new ArrayList<CommissioningChange>();
    for (CommissioningPaymentData payment : commissioning.getCollaboratorsPaymentData()) {
        // FIXME no debería haber bucle y debería funcionar con el método "contains"
        // metemos el recorrido del bucle en busca del elemento
        // ya que el método contains no está funcionando correctamente
        boolean found = false;
        for (CommissioningPaymentData paymentInSet : commissioning.getChanges().getCollaboratorsPaymentData()) {
            if (paymentInSet.equals(payment)) {
                found = true;
                break;
            }
        }
        // if (!commissioning.getChanges().getCollaboratorsPaymentData().contains(payment)) {
        if (!found) {
            changes.add(getChange("commissioning.collaborators", "", payment.getCollaborator().getName(), commissioning));
            changes.add(getChange("commissioning.paymentMode", "", "[" + payment.getCollaborator().getName() + "] " + payment.getPaymentMode().name(), commissioning));
            changes.add(getChange("commissioning.bankAccount", "", "[" + payment.getCollaborator().getName() + "] " + payment.getBankAccount(), commissioning));
            changes.add(getChange("commissioning.billNumber", "", "[" + payment.getCollaborator().getName() + "] " + payment.getBillNumber(), commissioning));
        } else {
            changes.addAll(getCollaboratorPaymentInternalChanges(payment, commissioning, false));
        }
    }
    for (CommissioningPaymentData payment : commissioning.getChanges().getCollaboratorsPaymentData()) {
        if (!commissioning.getCollaboratorsPaymentData().contains(payment)) {
            changes.add(getChange("commissioning.collaborators", payment.getCollaborator().getName(), "", commissioning));
            changes.add(getChange("commissioning.paymentMode", "[" + payment.getCollaborator().getName() + "] " + payment.getPaymentMode().name(), "", commissioning));
            changes.add(getChange("commissioning.bankAccount", "[" + payment.getCollaborator().getName() + "] " + payment.getBankAccount(), "", commissioning));
            changes.add(getChange("commissioning.billNumber", "[" + payment.getCollaborator().getName() + "] " + payment.getBillNumber(), "", commissioning));
        } else {
            changes.addAll(getCollaboratorPaymentInternalChanges(payment, commissioning, true));
        }
    }
    return changes;
}
Also used : ArrayList(java.util.ArrayList) CommissioningPaymentData(com.autentia.tnt.businessobject.CommissioningPaymentData) CommissioningChange(com.autentia.tnt.businessobject.CommissioningChange)

Example 3 with CommissioningChange

use of com.autentia.tnt.businessobject.CommissioningChange in project TNTConcept by autentia.

the class CommissioningManager method getCollaboratorPaymentInternalChanges.

private Collection<? extends CommissioningChange> getCollaboratorPaymentInternalChanges(CommissioningPaymentData payment, Commissioning commissioning, boolean paymentIsPrevious) {
    final List<CommissioningChange> changes = new ArrayList<CommissioningChange>();
    CommissioningPaymentData paymentInList = null;
    // recuperamos el colaborador de la lista que coincide con el pasado
    for (CommissioningPaymentData paymentData : commissioning.getCollaboratorsPaymentData()) {
        if (payment.equals(paymentData)) {
            paymentInList = paymentData;
            break;
        }
    }
    if (paymentInList == null) {
        throw new IllegalArgumentException("PaymentInList no localizado");
    }
    // asignamos los valores de antes y despues
    CommissioningPaymentData paymentPrevious = null;
    CommissioningPaymentData paymentNow = null;
    if (paymentIsPrevious) {
        paymentPrevious = payment;
        paymentNow = paymentInList;
    } else {
        paymentPrevious = paymentInList;
        paymentNow = payment;
    }
    // sólo puede haber cambiado el modo de pago, la cuenta y la billnumber
    if (!paymentPrevious.getPaymentMode().equals(paymentNow.getPaymentMode())) {
        changes.add(getChange("commissioning.paymentMode", "[" + payment.getCollaborator().getName() + "] " + paymentPrevious.getPaymentMode().name(), "[" + payment.getCollaborator().getName() + "] " + paymentNow.getPaymentMode().name(), commissioning));
    }
    changes.add(getChange("commissioning.bankAccount", "[" + payment.getCollaborator().getName() + "] " + paymentPrevious.getBankAccount(), "[" + payment.getCollaborator().getName() + "] " + paymentNow.getBankAccount(), commissioning));
    changes.add(getChange("commissioning.billNumber", "[" + payment.getCollaborator().getName() + "] " + paymentPrevious.getBillNumber(), "[" + payment.getCollaborator().getName() + "] " + paymentNow.getBillNumber(), commissioning));
    return changes;
}
Also used : ArrayList(java.util.ArrayList) CommissioningPaymentData(com.autentia.tnt.businessobject.CommissioningPaymentData) CommissioningChange(com.autentia.tnt.businessobject.CommissioningChange)

Example 4 with CommissioningChange

use of com.autentia.tnt.businessobject.CommissioningChange in project TNTConcept by autentia.

the class CommissioningManager method getCommissioningDelaysChanges.

private List<CommissioningChange> getCommissioningDelaysChanges(final Commissioning commissioning) {
    final List<CommissioningChange> changes = new ArrayList<CommissioningChange>();
    final SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
    for (CommissioningDelay delay : commissioning.getCommissioningDelays()) {
        if (!commissioning.getChanges().getCommissioningDelays().contains(delay)) {
            changes.add(getChange("commissioningDelay.delayedToDate", "", sdf.format(delay.getDelayedToDate()), commissioning));
        }
    }
    for (CommissioningDelay delay : commissioning.getChanges().getCommissioningDelays()) {
        if (!commissioning.getCommissioningDelays().contains(delay)) {
            changes.add(getChange("commissioningDelay.delayedToDate", sdf.format(delay.getDelayedToDate()), "", commissioning));
        }
    }
    return changes;
}
Also used : ArrayList(java.util.ArrayList) CommissioningDelay(com.autentia.tnt.businessobject.CommissioningDelay) SimpleDateFormat(java.text.SimpleDateFormat) CommissioningChange(com.autentia.tnt.businessobject.CommissioningChange)

Aggregations

CommissioningChange (com.autentia.tnt.businessobject.CommissioningChange)4 ArrayList (java.util.ArrayList)3 CommissioningPaymentData (com.autentia.tnt.businessobject.CommissioningPaymentData)2 CommissioningDelay (com.autentia.tnt.businessobject.CommissioningDelay)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1