Ejemplo n.º 1
0
  @Override
  public Result execute(InteractionContext ctx) throws InteractionException {
    assert (ctx != null);
    // retrieve from a database, etc.
    String id = ctx.getId();
    Customer customer = daoHibernate.getCustomer(id);
    if (customer != null) {
      // Convert Customer object into Entity object
      EntityProperties addressFields = new EntityProperties();
      addressFields.setProperty(
          new EntityProperty("postcode", customer.getAddress().getPostcode()));
      addressFields.setProperty(
          new EntityProperty("houseNumber", customer.getAddress().getHouseNumber()));

      EntityProperties props = new EntityProperties();
      props.setProperty(new EntityProperty("name", customer.getName()));
      props.setProperty(new EntityProperty("address", addressFields));
      props.setProperty(new EntityProperty("dateOfBirth", customer.getDateOfBirth()));
      Entity entity = new Entity("Customer", props);

      ctx.setResource(createEntityResource(entity));
      return Result.SUCCESS;
    } else {
      return Result.FAILURE;
    }
  }