Package honeycrm.client.dto

Examples of honeycrm.client.dto.Dto


    openEditView();
  }

  @UiHandler("createBtn")
  public void handleClick(ClickEvent e) {
    currentDto = new Dto(module.toString());
    for (String field : getFieldNames()) {
      currentDto.set(field, "");
    }

    for (UIObject o : getEditViewFields()) {
View Full Code Here


      }
    });
  }

  private void save(final Display view) {
    final Dto dto = view.getDto();

    if (dto.getId() <= 0) {
      AsyncProvider.getCreateService(new Callback<CreateServiceAsync>() {
        @Override
        public void callback(CreateServiceAsync arg) {
          arg.create(dto, new AsyncCallback<Long>() {
            @Override
View Full Code Here

    return new HasKeyPressHandlers[] { nameEdit, contactEdit };
  }

  @Override
  public Dto getDto() {
    final Dto d = new Dto(Module.Proposal.toString());
    d.set("name", nameEdit.getText());
    d.set("date", dateEdit.getValue());
    d.set("contact", contactEdit.getText());
    // TODO serialize and store products
    return d;
  }
View Full Code Here

    prefilledFields.put("assignedTo", User.getUserId());
    return prefilledFields;
  }

  public void onSave() {
    final Dto dto = view.getData();

    // id == -1 indicates that there is no id yet.
    // thus if id != -1 we know the id -> we do an update
    final boolean isUpdate = dto.getId() > 0;

    if (isUpdate) {
      updateService.update(dto, new AsyncCallback<Void>() {
        @Override
        public void onSuccess(Void result) {
          eventBus.fireEvent(new UpdateEvent(module));
          eventBus.fireEvent(new OpenEvent(dto));
        }

        @Override
        public void onFailure(Throwable caught) {

        }
      });
    } else {
      createService.create(dto, new AsyncCallback<Long>() {
        @Override
        public void onSuccess(Long result) {
          dto.setId(result);
          eventBus.fireEvent(new UpdateEvent(module));
          eventBus.fireEvent(new OpenEvent(dto));
        }

        @Override
View Full Code Here

    return (price - discount) * qty;
  }

  public void add() {
    final Dto newService = relatedModule.createDto();
    newService.set("quantity", 1);
    newService.set("discount", 0);
    newService.set("productCode", "");
    newService.set("sum", getSumForSingleDto(newService));
    newService.set("price", 0);

    view.add(newService);
    view.updateOverallSum(getSum(view.getProvider().getList()));
  }
View Full Code Here

public class NewServiceTest extends DatastoreTest {
  private final CreateServiceImpl creator = new CreateServiceImpl();
  private final ReadServiceImpl reader = new ReadServiceImpl();

  public void testResolving() {
    final Dto account = new Dto();
    account.setModule("Account");
    account.set("name", "The Account");

    final long accountId = creator.create(account);

    final Dto contact = new Dto();
    contact.setModule("Contact");
    contact.set("name", "The Contact");
    contact.set("accountId", accountId);

    final long contactId = creator.create(contact);

    final Dto retrievedContact = reader.get("Contact", contactId);

    assertEquals(contact.get("name"), retrievedContact.get("name"));
    assertEquals(contact.get("accountId"), retrievedContact.get("accountId"));
    assertNotNull(retrievedContact.get("accountId_resolved"));
    assertTrue(retrievedContact.getId() == contactId);
    assertEquals(account.get("name"), ((Dto) retrievedContact.get("accountId_resolved")).get("name"));
    assertTrue(retrievedContact.get("accountId").equals(accountId));
  }
View Full Code Here

public class CreateServiceTest extends DatastoreTest {
  private final ReadServiceImpl reader = new ReadServiceImpl();
  private final CreateServiceImpl create = new CreateServiceImpl();

  private Dto getContact() {
    final Dto contact = new Dto("Contact");
    contact.set("name", "Foo");
    return contact;
  }
View Full Code Here

    final long id = create.create(getContact());
    assertTrue(id > 0);
  }

  public void testCreateAndCompare() {
    final Dto contact = getContact();
    final long id = create.create(contact);

    final Dto dto = reader.get("Contact", id);

    assertEquals(dto.getModule(), "Contact");
    assertEquals(contact.get("name"), dto.get("name"));
  }
View Full Code Here

    assertEquals(dto.getModule(), "Contact");
    assertEquals(contact.get("name"), dto.get("name"));
  }

  public void testCreateWithOneToManyRelationship() {
    final Dto product = new Dto("Product");
    product.set("name", "The Product");

    final long productId = create.create(product);

    final Dto service = new Dto("UniqueService");
    service.set("productId", productId);

    final ArrayList<Dto> services = new ArrayList<Dto>();
    services.add(service);

    final Dto contract = new Dto("Contract");
    contract.set("uniqueServices", services);

    final long contractId = create.create(contract);

    final Dto retrievedContract = reader.get("Contract", contractId);

    assertNotNull(retrievedContract.get("uniqueServices"));
    assertTrue(retrievedContract.get("uniqueServices") instanceof ArrayList<?>);
    assertEquals(services.size(), ((ArrayList<?>) retrievedContract.get("uniqueServices")).size());
  }
View Full Code Here

    reader = null;
  }

  public void testGet() {
    final Entity e = createContact();
    final Dto dto = reader.get(Contact.class.getSimpleName(), e.getKey().getId());

    assertEquals(e.getProperty("name"), dto.get("name"));
  }
View Full Code Here

TOP

Related Classes of honeycrm.client.dto.Dto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.