Пример #1
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;
  }
Пример #2
0
 /**
  * Returns the UN/CEFACT unit code for the given package units code from an <em>lookup.uom</em>.
  *
  * <p>If no package is specified, defaults to {@link #DEFAULT_PACKAGE_UNITS}.
  *
  * @param packageUnits the package units code
  * @return the corresponding unit code
  */
 private String getUnitCode(String packageUnits) {
   String result = null;
   if (!StringUtils.isEmpty("packageUnits")) {
     Lookup lookup = lookupService.getLookup("lookup.uom", packageUnits);
     if (lookup != null) {
       IMObjectBean lookupBean = factory.createBean(lookup);
       String unitCode = lookupBean.getString("unitCode");
       if (!StringUtils.isEmpty(unitCode)) {
         result = unitCode;
       }
     }
     if (result == null) {
       log.warn(
           "No unit code for package units="
               + packageUnits
               + ". Defaulting to "
               + DEFAULT_PACKAGE_UNITS);
     }
   }
   if (result == null) {
     result = DEFAULT_PACKAGE_UNITS;
   }
   return result;
 }