Search in sources :

Example 1 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.

the class PersistenceIT method example.

@Test
public void example() throws Exception {
    utx.begin();
    em.joinTransaction();
    Address addressOne = new Address("Test Straße 10, 123456 Testing");
    em.persist(addressOne);
    Dossier dos = new Dossier();
    dos.setComment("Ein Kommentar");
    dos.setCustomerId(10);
    dos.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
    Document doc = new Document();
    doc.add(Condition.PAID);
    doc.setActive(true);
    doc.setInvoiceAddress(addressOne);
    doc.setShippingAddress(addressOne);
    doc.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p = new PositionBuilder().type(PositionType.COMMENT).description("Comment").name("Comment").build();
    doc.append(p);
    doc.setDirective(Document.Directive.PREPARE_SHIPPING);
    dos.add(doc);
    em.persist(dos);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    Address addressTwo = new Address("Persistencstraße 42, 1337 PersistencTest");
    em.persist(addressTwo);
    addressOne = em.merge(addressOne);
    Dossier dossier = new Dossier();
    dossier.setComment("Das ist nun ein Weitere Kommentar");
    dossier.setCustomerId(12);
    dossier.setReminder(new Reminder(new Date(), new Date(), "Junit"));
    Document document = new Document();
    document.setActive(true);
    document.add(Condition.PAID);
    document.add(Condition.CONFIRMED);
    document.setInvoiceAddress(addressTwo);
    document.setShippingAddress(addressOne);
    document.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p1 = new PositionBuilder().type(PositionType.COMMENT).description("Kommentare über Kommentare").name("Kommentar").build();
    Position p2 = new PositionBuilder().type(PositionType.COMMENT).description("Noch mehr Kommentare").name("Kommentar").build();
    Position p3 = new PositionBuilder().type(PositionType.COMMENT).description("So das war aber der Letzte").name("Kommentar").build();
    document.append(p1);
    document.append(p2);
    document.append(p3);
    Document document1 = new Document();
    document1.setActive(false);
    document1.setInvoiceAddress(addressTwo);
    document1.setShippingAddress(addressOne);
    document1.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p4 = new PositionBuilder().type(PositionType.COMMENT).description("Ein zweites Doc mit Kommentaren").name("Kommentar").build();
    Position p5 = new PositionBuilder().type(PositionType.COMMENT).description("Was sind das für Kommentare").name("Kommentar").build();
    Position p6 = new PositionBuilder().type(PositionType.COMMENT).description("comment,comment.comment").name("Kommentar").build();
    document1.append(p4);
    document1.append(p5);
    document1.append(p6);
    document1.setDirective(Document.Directive.NONE);
    dossier.add(document1);
    em.persist(dossier);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    CriteriaQuery<Dossier> q = em.getCriteriaBuilder().createQuery(Dossier.class);
    List<Dossier> dossiers = em.createQuery(q.select(q.from(Dossier.class))).getResultList();
    PositionEao positionEao = new PositionEao(em);
    Logger L = LoggerFactory.getLogger(PersistenceIT.class);
    for (Dossier ds : dossiers) {
        L.info(ds.toMultiLine());
    }
    utx.commit();
}
Also used : PositionEao(eu.ggnet.dwoss.redtape.ee.eao.PositionEao) Reminder(eu.ggnet.dwoss.redtape.ee.entity.Reminder) Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) PositionBuilder(eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder) Logger(org.slf4j.Logger) Date(java.util.Date) Test(org.junit.Test)

Example 2 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.

the class DossierEaoFindByIdIT method testFindByIds.

@Test
public void testFindByIds() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    List<Long> ids = new ArrayList<>();
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByIds(Arrays.asList(ids.get(0), ids.get(1)));
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 3 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.

the class DossierEaoFindClosedIT method testFindByClosed.

@Test
public void testFindByClosed() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    dos.setClosed(true);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    doc.setClosed(true);
    dos.add(doc);
    em.persist(dos);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByClosed(false);
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 4 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.

the class RedTapeUpdateBlockWorkflow method execute.

/**
 * Executes the Workflow and returns a Document.
 *
 * @return a Document.
 */
@Override
public Document execute() {
    Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
    if (altered.equalsContent(previous))
        return altered;
    L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
    validate(altered, previous);
    Document newDocument = refreshAndPrepare(altered, previous);
    equilibrateLogicTransaction(newDocument);
    newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + this.getClass().getSimpleName()));
    redTapeEm.persist(newDocument);
    // Writing new document an gennerating the id;
    redTapeEm.flush();
    L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
    return newDocument;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 5 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.

the class RedTapeUpdateCapitalAssetReturnsWorkflow method execute.

/**
 * Executes the Workflow and returns a Document.
 *
 * @return a Document.
 */
@Override
public Document execute() {
    Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
    if (altered.equalsContent(previous))
        return altered;
    L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
    validate(altered, previous);
    String comment = "";
    Document newDocument = refreshAndPrepare(altered, previous);
    if (altered.getConditions().contains(Document.Condition.CANCELED)) {
        removeLogicTransaction(newDocument);
        comment += "Auftrag storniert.";
    } else {
        equilibrateLogicTransaction(newDocument);
        comment += "Auftrag geändert.";
    }
    if (!altered.isStillExactlyBriefed(previous))
        newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
    newDocument.setHistory(new DocumentHistory(arranger, comment));
    redTapeEm.persist(newDocument);
    // Writing new document an gennerating the id;
    redTapeEm.flush();
    L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
    validateAfter(newDocument.getDossier());
    return newDocument;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Aggregations

DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)14 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)13 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)6 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)4 Test (org.junit.Test)4 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)2 Date (java.util.Date)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2 Logger (org.slf4j.Logger)2 AddressServiceBean (eu.ggnet.dwoss.customer.ee.AddressServiceBean)1 CustomerServiceBean (eu.ggnet.dwoss.customer.ee.CustomerServiceBean)1 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)1 Mandator (eu.ggnet.dwoss.mandator.api.value.Mandator)1 SpecialSystemCustomers (eu.ggnet.dwoss.mandator.api.value.SpecialSystemCustomers)1 RedTapes (eu.ggnet.dwoss.redtape.ee.assist.RedTapes)1 AddressEao (eu.ggnet.dwoss.redtape.ee.eao.AddressEao)1 PositionEao (eu.ggnet.dwoss.redtape.ee.eao.PositionEao)1 Directive (eu.ggnet.dwoss.redtape.ee.entity.Document.Directive)1