Search in sources :

Example 1 with Company

use of eu.ggnet.dwoss.customer.ee.entity.Company in project dwoss by gg-net.

the class PersistenceIT method testPersistence.

@Test
public void testPersistence() throws Exception {
    utx.begin();
    em.joinTransaction();
    Customer c = GEN.makeCustomer();
    em.persist(c);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    CriteriaQuery<Customer> customerQ = em.getCriteriaBuilder().createQuery(Customer.class);
    c = em.createQuery(customerQ.select(customerQ.from(Customer.class))).getSingleResult();
    assertThat(c.getContacts()).describedAs("customer.getContacts()").isNotEmpty();
    L.info("{}", c);
    L.info("===== Contacts");
    for (Contact contact : c.getContacts()) {
        L.info(contact.toString());
        L.info("===== - Communications");
        for (Communication communication : contact.getCommunications()) {
            L.info(communication.toString());
        }
    }
    L.info("===== Companies");
    for (Company company : c.getCompanies()) {
        L.info(company.toString());
        L.info("===== - Communications:");
        for (Communication communication : company.getCommunications()) {
            L.info(communication.toString());
        }
    }
    L.info("===== MandatorMetaData");
    for (MandatorMetadata man : c.getMandatorMetadata()) {
        L.info(man.toString());
    }
    utx.commit();
}
Also used : Company(eu.ggnet.dwoss.customer.ee.entity.Company) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) Contact(eu.ggnet.dwoss.customer.ee.entity.Contact) Communication(eu.ggnet.dwoss.customer.ee.entity.Communication) Test(org.junit.Test)

Example 2 with Company

use of eu.ggnet.dwoss.customer.ee.entity.Company in project dwoss by gg-net.

the class CompanyUpdateTryOut method main.

// CustomerComapnyController
public static void main(String[] args) {
    CustomerGenerator gen = new CustomerGenerator();
    Company company = gen.makeCompany();
    company.setTaxId("Steuernummer");
    gen.makeAddresses(5).forEach(a -> company.getAddresses().add(a));
    gen.makeContacts(6).forEach(c -> company.getContacts().add(c));
    company.getCommunications().add(gen.makeCommunication());
    company.getCommunications().add(gen.makeCommunication());
    company.getCommunications().add(gen.makeCommunication());
    company.getCommunications().add(gen.makeCommunication());
    company.getCommunications().get(new Random().nextInt(company.getCommunications().size() - 1)).setPrefered(true);
    JButton close = new JButton("Schliessen");
    close.addActionListener(e -> Ui.closeWindowOf(close));
    JButton editButton = new JButton("edit");
    editButton.addActionListener(ev -> {
        Ui.exec(() -> {
            Ui.build().fxml().eval(() -> company, CompanyUpdateController.class).opt().ifPresent(System.out::println);
        });
    });
    JButton addButton = new JButton("add");
    addButton.addActionListener(ev -> {
        Ui.exec(() -> {
            Ui.build().fxml().eval(() -> new Company(), CompanyUpdateController.class).opt().ifPresent(System.out::println);
        });
    });
    JPanel p = new JPanel();
    p.add(editButton);
    p.add(addButton);
    p.add(close);
    UiCore.startSwing(() -> p);
}
Also used : JPanel(javax.swing.JPanel) Company(eu.ggnet.dwoss.customer.ee.entity.Company) Random(java.util.Random) JButton(javax.swing.JButton) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)

Aggregations

Company (eu.ggnet.dwoss.customer.ee.entity.Company)2 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)1 Communication (eu.ggnet.dwoss.customer.ee.entity.Communication)1 Contact (eu.ggnet.dwoss.customer.ee.entity.Contact)1 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)1 MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)1 Random (java.util.Random)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 Test (org.junit.Test)1