Beispiel #1
0
  /**
   * Returns a <tt>ItemType</tt> for a supplier, order item, and product.
   *
   * @param bean the order item
   * @param supplier the supplier
   * @param product the product
   * @param packageUnits the package size unit code. May be <tt>null</tt>
   * @return an <tt>ItemType</tt> corresponding to the supplier and product
   */
  private ItemType getItem(ActBean bean, Party supplier, Product product, String packageUnits) {
    ItemType result = new ItemType();
    ItemIdentificationType buyersId = getItemIdentification(product.getId());
    String reorderCode = bean.getString("reorderCode");
    String reorderDescription = bean.getString("reorderDescription");
    if (!StringUtils.isEmpty(reorderCode)) {
      ItemIdentificationType sellersId = getItemIdentification(reorderCode);
      result.setSellersItemIdentification(sellersId);
    } else {
      throw new ESCIAdapterException(ESCIAdapterMessages.noSupplierOrderCode(supplier, product));
    }
    if (!StringUtils.isEmpty(reorderDescription)) {
      DescriptionType description = UBLHelper.initText(new DescriptionType(), reorderDescription);
      result.getDescription().add(description);
    }
    NameType name = UBLHelper.initName(new NameType(), product.getName());

    result.setBuyersItemIdentification(buyersId);
    result.setName(name);

    BigDecimal packageSize = bean.getBigDecimal("packageSize");
    if (packageSize != null && packageUnits != null) {
      PackQuantityType quantity =
          UBLHelper.initQuantity(new PackQuantityType(), BigDecimal.ONE, packageUnits);
      PackSizeNumericType size = UBLHelper.createPackSizeNumeric(packageSize);
      result.setPackQuantity(quantity);
      result.setPackSizeNumeric(size);
    }

    return result;
  }
Beispiel #2
0
 /**
  * Returns a <tt>ContactType</tt> for the supplied contacts.
  *
  * @param name a contact name
  * @param phone the phone contact. May be <tt>null</tt>
  * @param fax the fax contact. May be <tt>null</tt>
  * @param email the email contact. May be <tt>null</tt>
  * @return the corresponding <tt>ContactType</tt>
  */
 private ContactType getContact(String name, Contact phone, Contact fax, Contact email) {
   ContactType contact = new ContactType();
   if (!StringUtils.isEmpty(name)) {
     contact.setName(UBLHelper.initName(new NameType(), name));
   }
   contact.setTelephone(getPhone(phone));
   contact.setTelefax(getFax(fax));
   contact.setElectronicMail(getEmail(email));
   return contact;
 }
Beispiel #3
0
  /**
   * Returns an <tt>AddressType</tt> for the supplied <em>contact.location</em>.
   *
   * @param contact the location contact
   * @return the corresponding <tt>AddressType</tt>
   */
  private AddressType getAddress(Contact contact) {
    IMObjectBean bean = factory.createBean(contact);

    AddressType result = new AddressType();
    AddressLineType addressLineType = new AddressLineType();
    LineType line = UBLHelper.initText(new LineType(), bean.getString("address"));
    addressLineType.setLine(line);

    String city = lookupService.getName(contact, "suburb");
    CityNameType cityName = UBLHelper.initName(new CityNameType(), city);

    String state = lookupService.getName(contact, "state");
    CountrySubentityType stateName = UBLHelper.initText(new CountrySubentityType(), state);

    PostalZoneType postCode = UBLHelper.initText(new PostalZoneType(), bean.getString("postcode"));

    result.getAddressLine().add(addressLineType);
    result.setCityName(cityName);
    result.setCountrySubentity(stateName);
    result.setPostalZone(postCode);
    return result;
  }