/** * \brief Function to list machines information * \fn UMS_Data::ListMachines* list() * \return The pointer to the UMS_Data::ListMachines containing machines information * \return raises an exception on error */ UMS_Data::ListMachines* list() { std::string sqlListofMachines = "SELECT machineid, name, site, status, lang, description from machine, description " "where machine.nummachineid = description.machine_nummachineid"; std::vector<std::string>::iterator ii; std::vector<std::string> results; UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance(); mlistObject = ecoreFactory->createListMachines(); //Creation of the object user UserServer userServer = UserServer(msessionServer); userServer.init(); //if the user exists if (userServer.exist()) { //To process options processOptions(userServer, mparameters, sqlListofMachines); boost::scoped_ptr<DatabaseResult> ListofMachines (mdatabaseVishnu->getResult(sqlListofMachines.c_str())); if (ListofMachines->getNbTuples() != 0){ for (size_t i = 0; i < ListofMachines->getNbTuples(); ++i) { results.clear(); results = ListofMachines->get(i); ii = results.begin(); UMS_Data::Machine_ptr machine = ecoreFactory->createMachine(); machine->setMachineId(*ii); machine->setName(*(++ii)); machine->setSite(*(++ii)); machine->setStatus(convertToInt(*(++ii))); machine->setLanguage(*(++ii)); machine->setMachineDescription(*(++ii)); mlistObject->getMachines().push_back(machine); } } } else { UMSVishnuException e (ERRCODE_UNKNOWN_USER); throw e; } return mlistObject; }
/** * \brief Function to list machines information * \return The pointer to the UMS_Data::ListMachines containing machines information * \return raises an exception on error */ UMS_Data::ListMachines* list(UMS_Data::ListMachineOptions_ptr option) { std::string sqlListofMachines = boost::str(boost::format("SELECT machineid, address, status, description" " FROM machine" " WHERE machine.status != %1%") % vishnu::STATUS_DELETED); std::vector<std::string>::iterator dbResultIter; std::vector<std::string> dbResults; UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance(); mlistObject = ecoreFactory->createListMachines(); //Creation of the object user UserServer userServer = UserServer(msessionServer); userServer.init(); //if the user exists if (userServer.exist()) { //To process options processOptions(userServer, option, sqlListofMachines); boost::scoped_ptr<DatabaseResult> ListofMachines (mdatabase->getResult(sqlListofMachines.c_str())); if (ListofMachines->getNbTuples() != 0){ for (size_t i = 0; i < ListofMachines->getNbTuples(); ++i) { dbResults.clear(); dbResults = ListofMachines->get(i); dbResultIter = dbResults.begin(); UMS_Data::Machine_ptr machine = ecoreFactory->createMachine(); machine->setMachineId(*dbResultIter); machine->setAddress(*(++dbResultIter)); machine->setStatus(vishnu::convertToInt(*(++dbResultIter))); machine->setDescription(*(++dbResultIter)); mlistObject->getMachines().push_back(machine); } } } else { UMSVishnuException e (ERRCODE_UNKNOWN_USER); throw e; } return mlistObject; }