bool CocktailDialog::emptyLineEdits() { bool vuoto = ui->lineEditMomCons->text ().length () == 0 || ui->lineEditNomeCocktail->text ().length () == 0; if (vuoto) throwErrorMessage ("Campi vuoti non ammessi!"); return vuoto; }
void Client::initConn() { if (socket_ != NULL) { throw std::wruntime_error("Client::initConn() - ERROR: connection " "already initialized."); } void* context = Connection::initContext(); socket_ = zmq_socket(context, ZMQ_REQ); if (socket_ == NULL) { throwErrorMessage("Client::initConn() - ERROR: " "Could not create ZMQ_REQ socket"); } int rc = zmq_connect(socket_, conn_str_.c_str()); if (rc != 0) { throwErrorMessage("Client::initConn() - ERROR: " "Could not connect ZMQ_REQ socket"); } num_open_connections_++; }
/** * Defines the SSL authentication scheme. * @param icat :: ICATPortBindingProxy object. */ void ICat4Catalog::setSSLContext(ICATPortBindingProxy &icat) { if (soap_ssl_client_context( &icat, SOAP_SSL_CLIENT, /* use SOAP_SSL_DEFAULT in production code */ nullptr, /* keyfile: required only when client must authenticate to server (see SSL docs on how to obtain this file) */ nullptr, /* password to read the keyfile */ nullptr, /* optional cacert file to store trusted certificates */ nullptr, /* optional capath to directory with trusted certificates */ nullptr /* if randfile!=NULL: use a file with random data to seed randomness */ )) { throwErrorMessage(icat); } }
/** * Keep the current session alive. */ void ICat4Catalog::keepAlive() { ICATPortBindingProxy icat; setICATProxySettings(icat); ns1__refresh request; ns1__refreshResponse response; std::string sessionID = m_session->getSessionId(); request.sessionId = &sessionID; int result = icat.refresh(&request, &response); // An error occurred! if (result != 0) throwErrorMessage(icat); }
void CocktailDialog::salvaInfo () { Cocktail* cDaSalvare = new Cocktail(); if (emptyLineEdits ()) return; setInfoCocktail (cDaSalvare); int rows = ui->tableIngridientiWidget->rowCount (); bool ok = setDrink (rows, cDaSalvare); if (ok) emit request_insertCocktail(cDaSalvare); else throwErrorMessage("Problemi con i dati di input"); }
/** * Disconnects the client application from ICat4 based catalog services. */ void ICat4Catalog::logout() { ICATPortBindingProxy icat; setICATProxySettings(icat); ns1__logout request; ns1__logoutResponse response; std::string sessionID = m_session->getSessionId(); request.sessionId = &sessionID; int result = icat.logout(&request, &response); if (result == 0) { m_session->setSessionId(""); } else { throwErrorMessage(icat); } }
/** * Returns the results of a search against ICAT for a given query. * Note: The ICatProxy object takes care of the deletion of the response object. * @param icat :: The proxy object used to interact with gSOAP. * @param query :: The query to send to ICAT. */ std::vector<xsd__anyType *> ICat4Catalog::performSearch(ICATPortBindingProxy &icat, std::string query) { ns1__search request; ns1__searchResponse response; std::string sessionID = m_session->getSessionId(); request.sessionId = &sessionID; request.query = &query; g_log.debug() << "The search query sent to ICAT was: \n" << query << '\n'; std::vector<xsd__anyType *> searchResults; if (icat.search(&request, &response) == SOAP_OK) { searchResults = response.return_; } else { throwErrorMessage(icat); } return searchResults; }
bool ICat4Catalog::isAccessAllowed(ns1__accessType accessType, T &bean) { ICATPortBindingProxy icat; setICATProxySettings(icat); ns1__isAccessAllowed request; ns1__isAccessAllowedResponse response; std::string sessionID = m_session->getSessionId(); request.sessionId = &sessionID; ns1__accessType_ type; type.__item = accessType; request.accessType = &type.__item; request.bean = &bean; if (icat.isAccessAllowed(&request, &response) == SOAP_OK) return response.return_; else throwErrorMessage(icat); return false; }
bool CocktailDialog::setDrink(int rows, Cocktail* cDaSalvare) { bool ok = true; for (int i = 0; ok && i < rows; ++i) { QTableWidgetItem* curTip = ui->tableIngridientiWidget->item (i, 0); QTableWidgetItem* curNom = ui->tableIngridientiWidget->item (i, 1); QTableWidgetItem* curQuan = ui->tableIngridientiWidget->item (i, 2); QTableWidgetItem* curPalc = ui->tableIngridientiWidget->item (i, 3); ok = emptableRow (curTip, curNom, curQuan, curPalc ); ok = 1 - ok; // ok deve essere true, emptableRow puo' ritornare false if (ok) { std::string tipo = curTip->data (0).toString ().toStdString (); std::string nome = curNom->data (0).toString ().toStdString (); int q = curQuan->data (0).toString ().toInt (); int palc = curPalc->data (0).toString ().toInt (); Ingridiente* ing = cocktailFactoryMethod (tipo); if (ing != 0) { ing -> setNome (nome); ing -> setQuantita (q); ing -> setPercentualeAlcolica (palc); cDaSalvare->addIngrediente (*ing); } else ok = false; } else throwErrorMessage ("Elementi vuoti internamente alla tabella ingredienti non ammessi"); } return ok; }