Search in sources :

Example 1 with AddressEao

use of eu.ggnet.dwoss.redtape.ee.eao.AddressEao in project dwoss by gg-net.

the class RedTapeWorkflow method refreshAndPrepare.

/**
 * Clones the new Document from the altered Document, sets all detached Entities and updates the active status.
 * <p>
 * @param alteredDetachedDocument
 * @param previousDocument
 * @return
 */
protected Document refreshAndPrepare(Document alteredDetachedDocument, Document previousDocument) {
    // Partiall Clone our next Document
    Document newDocument = alteredDetachedDocument.partialClone();
    // Replace detached entities
    AddressEao addEao = new AddressEao(redTapeEm);
    Address invoiceAddress = addEao.findById(alteredDetachedDocument.getInvoiceAddress().getId());
    Address shippingAddress = addEao.findById(alteredDetachedDocument.getShippingAddress().getId());
    newDocument.setInvoiceAddress(invoiceAddress);
    newDocument.setShippingAddress(shippingAddress);
    newDocument.setHistory(new DocumentHistory(arranger, "Update durch Workflow"));
    // Set automatic Information
    newDocument.setDossier(previousDocument.getDossier());
    newDocument.setPredecessor(previousDocument);
    newDocument.setActive(true);
    if (previousDocument.getType() == newDocument.getType()) {
        previousDocument.setActive(false);
        // A Complaint gets reopend on condition change.
        if (newDocument.getType() == DocumentType.COMPLAINT && !previousDocument.getConditions().equals(newDocument.getConditions())) {
            newDocument.setClosed(false);
            newDocument.getDossier().setClosed(false);
        }
    } else {
        // On Document Type Change, the dossier gets reopened and some cleanup is happening.
        newDocument.getDossier().setClosed(false);
        newDocument.setClosed(false);
        newDocument.setIdentifier(null);
        newDocument.setActual(new Date());
        newDocument.remove(Document.Flag.CUSTOMER_BRIEFED);
        newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
    }
    L.debug("Prepared {}", newDocument);
    return newDocument;
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Date(java.util.Date) AddressEao(eu.ggnet.dwoss.redtape.ee.eao.AddressEao)

Example 2 with AddressEao

use of eu.ggnet.dwoss.redtape.ee.eao.AddressEao in project dwoss by gg-net.

the class AddressEmo method request.

/**
 * Get a Address by description search.
 *
 * @param searchAddress the address description to search for.
 * @return a Address by description search or a new persisted Address.
 */
public Address request(String searchAddress) {
    AddressEao addressEao = new AddressEao(em);
    Address address = addressEao.findByDescription(searchAddress);
    // persist address if nothing is found
    if (address == null) {
        address = new Address(searchAddress);
        em.persist(address);
        return address;
    }
    return address;
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) AddressEao(eu.ggnet.dwoss.redtape.ee.eao.AddressEao)

Aggregations

AddressEao (eu.ggnet.dwoss.redtape.ee.eao.AddressEao)2 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)2 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)1 Date (java.util.Date)1