Search in sources :

Example 1 with Address

use of eu.ggnet.dwoss.redtape.ee.entity.Address 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 Address

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

the class AddressEmoIT method testRequest.

@Test
public void testRequest() throws Exception {
    utx.begin();
    em.joinTransaction();
    Address a1 = new Address("abcd");
    Address a2 = new Address("efgh");
    em.persist(a1);
    em.persist(a2);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    AddressEmo adEmo = new AddressEmo(em);
    Address a3 = adEmo.request(a2.getDescription());
    Address a4 = adEmo.request("ijkl");
    assertTrue(a3.getDescription().equals(a2.getDescription()));
    assertEquals(a4.getDescription(), "ijkl");
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Test(org.junit.Test)

Example 3 with Address

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

the class DocumentExactlyBriefedTest method setUp.

@Before
public void setUp() {
    Address a1 = new Address("ShippingAddress");
    Address a2 = new Address("InvoiceAddress");
    doc1 = new Document();
    doc1.setShippingAddress(a1);
    doc1.setInvoiceAddress(a2);
    doc1.setType(DocumentType.ORDER);
    doc1.add(Document.Flag.CUSTOMER_BRIEFED);
    doc1.setDossier(new Dossier());
    doc1.append(new PositionBuilder().type(PositionType.UNIT).build());
    doc2 = doc1.partialClone();
    doc2.setDossier(new Dossier());
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) PositionBuilder(eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder)

Example 4 with Address

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

the class DocumentTest method testPartialCloneAndEqualsContent.

@Test
public void testPartialCloneAndEqualsContent() {
    Dossier dos = new Dossier();
    Address a1 = new Address("ShippingAddress");
    Address a2 = new Address("InvoiceAddress");
    Address a3 = new Address("Another ShippingAddress");
    Address a4 = new Address("Another InvoiceAddress");
    Document doc1 = new Document();
    doc1.setShippingAddress(a1);
    doc1.setInvoiceAddress(a2);
    doc1.setType(DocumentType.ORDER);
    doc1.add(Document.Flag.CUSTOMER_BRIEFED);
    dos.add(doc1);
    doc1.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    // copy and test equality
    Document doc2 = doc1.partialClone();
    doc2.setDossier(dos);
    assertTrue("The following Documents are not equal:\n" + doc1 + "\n" + doc2, doc1.equalsContent(doc2));
    // add and remove positions with equality test
    Position p1 = doc2.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    Position p2 = doc2.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    assertFalse("Should not be equals, but is.\n- " + doc1 + "\n- " + doc2, doc1.equalsContent(doc2));
    doc2.remove(p1);
    doc2.remove(p2);
    assertTrue(doc1.equalsContent(doc2));
    // add and remove flags with equality test
    doc2.setClosed(true);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setClosed(false);
    assertTrue(doc1.equalsContent(doc2));
    // change Document type
    doc2.setType(DocumentType.INVOICE);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setType(DocumentType.ORDER);
    assertTrue(doc1.equalsContent(doc2));
    // change Tax Type
    doc2.setTaxType(TaxType.UNTAXED);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setTaxType(TaxType.GENERAL_SALES_TAX_DE_SINCE_2007);
    assertTrue(doc1.equalsContent(doc2));
    // change addresses
    doc2.setShippingAddress(a3);
    doc2.setInvoiceAddress(a4);
    assertFalse(doc2.equalsContent(doc1));
    doc2.setShippingAddress(a1);
    doc2.setInvoiceAddress(a2);
    assertTrue(doc2.equalsContent(doc1));
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 5 with Address

use of eu.ggnet.dwoss.redtape.ee.entity.Address 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)

Aggregations

Address (eu.ggnet.dwoss.redtape.ee.entity.Address)11 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)6 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)5 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)4 Test (org.junit.Test)4 AddressEao (eu.ggnet.dwoss.redtape.ee.eao.AddressEao)2 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 PositionBuilder (eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder)2 Date (java.util.Date)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2 PositionEao (eu.ggnet.dwoss.redtape.ee.eao.PositionEao)1 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)1 Reminder (eu.ggnet.dwoss.redtape.ee.entity.Reminder)1 DocumentSupporterOperation (eu.ggnet.dwoss.redtapext.ee.DocumentSupporterOperation)1 BorderLayout (java.awt.BorderLayout)1 JFrame (javax.swing.JFrame)1 JRViewer (net.sf.jasperreports.swing.JRViewer)1 Logger (org.slf4j.Logger)1