use of eu.ggnet.dwoss.redtape.ee.eao.PositionEao 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();
}
Aggregations