Пример #1
0
QString Address::toCsv() const
{
    QString res;
    if(!isEmpty())
    {
        res += "\""+ QString::number(getStreetId()) + "\";\"";
        res += QString::number(getBuildId()) + "\";\"";
        res += getRawAddress().join(';') + "\";\"";
        res += getTypeOfFSubjInString() + "\";\"";
        res += getFsubj() + "\";\"";
        res += getDistrict() + "\";\"";
        res += getTypeOfCity1() + "\";\"";
        res += getCity1() + "\";\"";
        res += getTypeOfCity2() + "\";\"";
        res += getCity2() + "\";\"";
        res += getTypeOfStreet() + "\";\"";
        res += getStreet() + "\";\"";
        res += getAdditional() + "\";\"";
        res += getBuild() + "\";\"";
        res += getKorp() + "\";\"";
        res += getLitera() + "\";\"";
        res += QString(isCorrect()?"1":"0") + "\"";
    }
    else
    {
        res += "Is empty\n";
    }
    return res;
}
Пример #2
0
QString Address::toInsertSqlQuery() const
{
    QString strF =
          "INSERT INTO  %1 (BUILD_ID, BUILD, STREET_ID, STREET, "
          "TYPE_OF_STREET, KORP, LITERA, CORRECT, CITY1, "
          "TYPE_OF_CITY1, TYPE_OF_CITY2, CITY2, FSUBJ, DISTRICT, "
          "ADDITIONAL, RAW, TYPE_OF_FSUBJ) "
          "VALUES('%2', '%3', '%4', '%5', '%6', "
          "'%7', '%8', '%9', '%10', '%11', '%12', '%13', "
          "'%14', '%15', '%16', '%17', '%18'); ";

    QString str =
            strF
            .arg(TableName)
            .arg(QString::number(getBuildId()))
            .arg(getBuild())
            .arg(QString::number(getStreetId()))
            .arg(getStreet())
            .arg(getTypeOfStreet())
            .arg(getKorp())
            .arg(getLitera())
            .arg(QString(isCorrect()?"1":"0"))
            .arg(getCity1())
            .arg(getTypeOfCity1())
            .arg(getTypeOfCity2())
            .arg(getCity2())
            .arg(getFsubj())
            .arg(getDistrict())
            .arg(getAdditional())
            .arg(getRawAddress().join("\";\"").insert(0,'\"').append('\"'))
            .arg(getTypeOfFSubjInString());
    return str;
}
Пример #3
0
bool Address::isEmpty() const
{
    return (getRawAddress().isEmpty() &&
            getStreet().isEmpty() &&
            getBuild().isEmpty() &&
            getKorp().isEmpty() &&
            getAdditional().isEmpty() &&
            getCity1().isEmpty() &&
            getDistrict().isEmpty() &&
            getLitera().isEmpty() &&
            getTypeOfCity1().isEmpty() &&
            getTypeOfCity2().isEmpty() &&
            getTypeOfStreet().isEmpty() &&
            getFsubj().isEmpty());
}
Пример #4
0
QString Address::toDebug() const
{
    QString res;
    res +="*** Address: ***\n";
    res += "StreetID: " + QString::number(getStreetId()) + "\n";
    res += "BuildID: " + QString::number(getBuildId()) + "\n";
    res += "Type of Federal Subj: " + getTypeOfFSubjInString() + "\n";
    res += "Federal subj: " + getFsubj() + "\n";
    res += "District: " + getDistrict() + "\n";
    res += "Type of City1: " + getTypeOfCity1() + "\n";
    res += "City1: " + getCity1() + "\n";
    res += "Type of City2: " + getTypeOfCity2() + "\n";
    res += "City2: " + getCity2() + "\n";
    res += "Type of Street: " + getTypeOfStreet() + "\n";
    res += "Street: " + getStreet() + "\n";
    res += "Additional: " + getAdditional() + "\n";
    res += "Build: " + getBuild() + "\n";
    res += "Korpus: " + getKorp() + "\n";
    res += "Litera: " + getLitera() + "\n";
    res += "Correct: " + QString(isCorrect()?"1":"0") + "\n";
    return res;
}
Пример #5
0
Json::Value TpccPaymentProcedure::execute() {
  _date = getDate();

  std::shared_ptr<const storage::AbstractTable> tCustomer;
  if (_customerById) {
    tCustomer = std::const_pointer_cast<const storage::AbstractTable>(getCustomerByCId());
    if (tCustomer->size() == 0) {
      std::ostringstream os;
      os << "no customer with id " << _c_id << " in district " << _d_id << " in warehouse " << _w_id;
      throw std::runtime_error(os.str());
    }
    _chosenOne = 0;
    _c_last = tCustomer->getValue<hyrise_string_t>("C_LAST", 0);
  } else {
    tCustomer = std::const_pointer_cast<const storage::AbstractTable>(getCustomersByLastName());
    if (tCustomer->size() == 0) {
      std::ostringstream os;
      os << "no customer with last name \"" << _c_last << "\" in district " << _d_id << " in warehouse " << _w_id;
      throw std::runtime_error(os.str());
    }
    _chosenOne = std::max<int>((tCustomer->size() - 1) / 2 - 1, 0);  // really -1 again?;
    _c_id = tCustomer->getValue<hyrise_int_t>("C_ID", _chosenOne);
  }

  const std::string c_credit = tCustomer->getValue<hyrise_string_t>("C_CREDIT", _chosenOne);
  const bool bc_customer = (c_credit == "BC");
  _c_payment_cnt = tCustomer->getValue<hyrise_int_t>("C_PAYMENT_CNT", _chosenOne) + 1;
  _c_balance = tCustomer->getValue<hyrise_float_t>("C_BALANCE", _chosenOne) + _h_amount;
  _c_ytd_payment = tCustomer->getValue<hyrise_float_t>("C_YTD_PAYMENT", _chosenOne) + _h_amount;
  _c_data = tCustomer->getValue<hyrise_string_t>("C_DATA", _chosenOne);

  auto tWarehouse = getWarehouse();
  if (tWarehouse->size() == 0) {
    std::ostringstream os;
    os << "no such warehouse: " << _w_id;
    throw std::runtime_error(os.str());
  }
  _w_ytd = tWarehouse->getValue<hyrise_float_t>("W_YTD", 0) + _h_amount;
  const std::string w_name = tWarehouse->getValue<hyrise_string_t>("W_NAME", 0);

  auto tDistrict = getDistrict();
  if (tDistrict->size() == 0) {
    std::ostringstream os;
    os << "internal error: no district " << _d_id << " for warehouse " << _w_id;
    throw std::runtime_error(os.str());
  }
  _d_ytd = tDistrict->getValue<hyrise_float_t>("D_YTD", 0) + _h_amount;
  const std::string d_name = tDistrict->getValue<hyrise_string_t>("D_NAME", 0);
  _h_data = w_name + "    " + d_name;

  updateWarehouseBalance(std::const_pointer_cast<storage::AbstractTable>(tWarehouse));
  updateDistrictBalance(std::const_pointer_cast<storage::AbstractTable>(tDistrict));

  if (bc_customer)
    updateBCCustomer(std::const_pointer_cast<storage::AbstractTable>(tCustomer));
  else
    updateGCCustomer(std::const_pointer_cast<storage::AbstractTable>(tCustomer));

  insertHistory();

  Json::Value result;
  result["W_ID"] = _w_id;
  result["D_ID"] = _d_id;
  result["C_ID"] = _c_id;
  result["C_W_ID"] = _c_w_id;
  result["C_D_ID"] = _c_d_id;
  result["H_AMOUNT"] = _h_amount;
  result["H_DATE"] = _date;

  result["W_STREET_1"] = tWarehouse->getValue<hyrise_string_t>("W_STREET_1", 0);
  result["W_STREET_2"] = tWarehouse->getValue<hyrise_string_t>("W_STREET_2", 0);
  result["W_CITY"] = tWarehouse->getValue<hyrise_string_t>("W_CITY", 0);
  result["W_STATE"] = tWarehouse->getValue<hyrise_string_t>("W_STATE", 0);
  result["W_ZIP"] = tWarehouse->getValue<hyrise_string_t>("W_ZIP", 0);

  result["D_STREET_1"] = tDistrict->getValue<hyrise_string_t>("D_STREET_1", 0);
  result["D_STREET_2"] = tDistrict->getValue<hyrise_string_t>("D_STREET_2", 0);
  result["D_CITY"] = tDistrict->getValue<hyrise_string_t>("D_CITY", 0);
  result["D_STATE"] = tDistrict->getValue<hyrise_string_t>("D_STATE", 0);
  result["D_ZIP"] = tDistrict->getValue<hyrise_string_t>("D_ZIP", 0);

  result["C_FIRST"] = tCustomer->getValue<hyrise_string_t>("C_FIRST", _chosenOne);
  result["C_MIDDLE"] = tCustomer->getValue<hyrise_string_t>("C_MIDDLE", _chosenOne);
  result["C_LAST"] = _c_last;
  result["C_STREET_1"] = tCustomer->getValue<hyrise_string_t>("C_STREET_1", _chosenOne);
  result["C_STREET_2"] = tCustomer->getValue<hyrise_string_t>("C_STREET_2", _chosenOne);
  result["C_CITY"] = tCustomer->getValue<hyrise_string_t>("C_CITY", _chosenOne);
  result["C_STATE"] = tCustomer->getValue<hyrise_string_t>("C_STATE", _chosenOne);
  result["C_ZIP"] = tCustomer->getValue<hyrise_string_t>("C_ZIP", _chosenOne);
  result["C_PHONE"] = tCustomer->getValue<hyrise_string_t>("C_PHONE", _chosenOne);
  result["C_SINCE"] = tCustomer->getValue<hyrise_string_t>("C_SINCE", _chosenOne);
  result["C_CREDIT"] = c_credit;
  result["C_CREDIT_LIM"] = tCustomer->getValue<hyrise_float_t>("C_CREDIT_LIM", _chosenOne);
  result["C_DISCOUNT"] = tCustomer->getValue<hyrise_float_t>("C_DISCOUNT", _chosenOne);
  result["C_BALANCE"] = _c_balance;

  // only if BC? don't know
  result["C_DATA"] = _c_data;
  return result;
}