예제 #1
0
  @Override
  public boolean createOrUpdatePerson(
      String electronicShopID,
      String clientID,
      String name,
      String family,
      String addressCity,
      String addressLine,
      String phoneNumber,
      String mail,
      String IBANNumber,
      String SWIFTCode) {

    // check if we know that shop
    if (!ConfigurationProperties.getElectronicShopID().equals(electronicShopID)) {
      logger.warning("electronicShopID \"" + electronicShopID + "\" not known!");
      return false;
    }

    List<Client> cl = Client.queryGetByForeignID(clientID, 0, 1);
    List<Person> pl = null;
    Client c;
    if (cl.size() == 0) {
      c = new Client();
    } else {
      c = cl.get(0);
      pl = Person.queryGetAll(0, 1, c.getID());
    }

    Person p;
    if ((pl == null) || (pl.size() == 0)) {
      p = new Person();
    } else {
      p = pl.get(0);
    }
    try {
      c.setForeignID(clientID);
      c.setAddressCity(addressCity);
      c.setAddressLine(addressLine);
      c.setMail(mail);
      c.setPhoneNumber(phoneNumber);
      c.setIBANNumber(IBANNumber);
      c.setSWIFTCode(SWIFTCode);

      p.setName(name);
      p.setFamily(family);
      c.setPerson(p);
      c.writeToDB();

    } catch (RuntimeException e) {
      logger.log(Level.WARNING, "Can't write to DB!", e);
      return false;
    }

    return true;
  }
예제 #2
0
  @Override
  public boolean createOrUpdateCompany(
      String electronicShopID,
      String clientID,
      String name,
      String contactPerson,
      String addressCity,
      String addressLine,
      String phoneNumber,
      String mail,
      String IBANNumber,
      String SWIFTCode,
      String registrationNumber,
      String VATNumber) {

    // check if we know that shop
    if (!ConfigurationProperties.getElectronicShopID().equals(electronicShopID)) {
      logger.warning("electronicShopID \"" + electronicShopID + "\" not known!");
      return false;
    }

    List<Client> cl = Client.queryGetByForeignID(clientID, 0, 1);
    List<Company> cmpnl = null;
    Client c;
    if (cl.size() == 0) {
      c = new Client();
    } else {
      c = cl.get(0);
      cmpnl = Company.queryGetAll(0, 1, c.getID());
    }

    Company cmpn;
    if ((cmpnl == null) || (cmpnl.size() == 0)) {
      cmpn = new Company();
    } else {
      cmpn = cmpnl.get(0);
    }
    try {
      c.setForeignID(clientID);
      c.setAddressCity(addressCity);
      c.setAddressLine(addressLine);
      c.setMail(mail);
      c.setPhoneNumber(phoneNumber);
      c.setIBANNumber(IBANNumber);
      c.setSWIFTCode(SWIFTCode);

      cmpn.setName(name);
      cmpn.setContactPerson(contactPerson);
      cmpn.setRegistrationNumber(registrationNumber);
      if (!"".equals(VATNumber)) {
        cmpn.setVATNumber(VATNumber);
      }
      c.setCompany(cmpn);
      c.writeToDB();

    } catch (RuntimeException e) {
      logger.log(Level.WARNING, "Can't write to DB!", e);
      return false;
    }

    return true;
  }