Loading src/Configuration.h +13 −18 Original line number Diff line number Diff line Loading @@ -28,12 +28,12 @@ private: std::string auxDatabaseHost, unsigned int auxDatabasePort, std::string auxDatabaseUsername, std::string auxDatabasePassword, std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable, std::string selectKey, std::string selectValue) : m_certificateFile (certificateFile), m_storagePath(storagePath), m_remoteHost(remoteHost), m_remotePort(remotePort), m_remoteUsername(remoteUsername), m_remotePassword(remotePassword), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), std::string auxDatabaseFailedTable, std::string whereCondition) : m_certificateFile (certificateFile), m_storagePath(storagePath), m_remoteHost(remoteHost), m_remotePort(remotePort), m_remoteUsername(remoteUsername), m_remotePassword(remotePassword), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword), m_databaseSchema(databaseSchema), m_databaseTable(databaseTable), m_refreshTime(refreshTime), m_timeout(timeout), m_recoveryTime(recoveryTime), Loading @@ -43,7 +43,7 @@ private: m_auxDatabaseSchema(auxDatabaseSchema), m_auxDatabaseTimestampTable(auxDatabaseTimestampTable), m_auxDatabaseFailedTable(auxDatabaseFailedTable), m_selectKey(selectKey), m_selectValue(selectValue) { }; m_whereCondition(whereCondition) { }; virtual ~Configuration() {} Loading @@ -69,8 +69,7 @@ public: std::string auxDatabaseHost, unsigned int auxDatabasePort, std::string auxDatabaseUsername, std::string auxDatabasePassword, std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable, std::string selectKey, std::string selectValue) std::string auxDatabaseFailedTable, std::string whereCondition) { Configuration::SP c_sp(new Configuration(certificateFile, storagePath, remoteHost, remotePort, remoteUsername, remotePassword, databaseHost, Loading @@ -78,7 +77,7 @@ public: databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost, auxDatabasePort, auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable, selectKey, selectValue), Configuration::Deleter()); whereCondition), Configuration::Deleter()); return c_sp; } Loading Loading @@ -108,8 +107,7 @@ public: std::string getAuxDatabaseSchema() const { return m_auxDatabaseSchema; } std::string getAuxDatabaseTimestampTable() const { return m_auxDatabaseTimestampTable; } std::string getAuxDatabaseFailedTable() const { return m_auxDatabaseFailedTable; } std::string getSelectKey() const { return m_selectKey; } std::string getSelectValue() const { return m_selectValue; } std::string getWhereCondition() const { return m_whereCondition; } private: //------------------------------------------------------------------------------ Loading Loading @@ -181,11 +179,8 @@ private: //Auxiliary database failed table const std::string m_auxDatabaseFailedTable; //Files selection key const std::string m_selectKey; //File selection value const std::string m_selectValue; //Files retrieval where condition const std::string m_whereCondition; }; } //End of namespace Loading src/DBManager.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -202,12 +202,11 @@ DBManager::FileRowsetSP DBManager::retrieveNewFiles(boost::posix_time::ptime pti if(m_mainSession_sp->get_backend() == NULL) m_mainSession_sp->reconnect(); std::string selectKey = m_configuration_sp->getSelectKey(); std::string selectValue = m_configuration_sp->getSelectValue(); std::string whereCondition = m_configuration_sp->getWhereCondition(); FileRowsetSP newFileRowset_sp; if(selectKey.empty()) if(whereCondition.empty()) { newFileRowset_sp.reset(new FileRowset(m_mainSession_sp->prepare << "select storage_path, file_path, file_version, file_name, update_time " Loading @@ -222,8 +221,7 @@ DBManager::FileRowsetSP DBManager::retrieveNewFiles(boost::posix_time::ptime pti << "from " << m_configuration_sp->getDatabaseSchema() << "." << m_configuration_sp->getDatabaseTable() << " where update_time>'" << boost::posix_time::to_iso_string(ptime) << "' and " << selectKey << " like '%" << selectValue << "%' " << "order by update_time asc")); << whereCondition << " order by update_time asc")); } return newFileRowset_sp; Loading src/DataImporter.cpp +9 −24 Original line number Diff line number Diff line Loading @@ -238,8 +238,7 @@ void DataImporter::get_device_property() dev_prop.push_back(Tango::DbDatum("AuxDatabaseSchema")); dev_prop.push_back(Tango::DbDatum("AuxDatabaseTimestampTable")); dev_prop.push_back(Tango::DbDatum("AuxDatabaseFailedTable")); dev_prop.push_back(Tango::DbDatum("SelectKey")); dev_prop.push_back(Tango::DbDatum("SelectValue")); dev_prop.push_back(Tango::DbDatum("WhereCondition")); // is there at least one property to be read ? if (dev_prop.size()>0) Loading Loading @@ -518,27 +517,16 @@ void DataImporter::get_device_property() // And try to extract AuxDatabaseFailedTable value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> auxDatabaseFailedTable; // Try to initialize SelectKey from class property // Try to initialize WhereCondition from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> selectKey; if (cl_prop.is_empty()==false) cl_prop >> whereCondition; else { // Try to initialize SelectKey from default device value // Try to initialize WhereCondition from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> selectKey; if (def_prop.is_empty()==false) def_prop >> whereCondition; } // And try to extract SelectKey value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> selectKey; // Try to initialize SelectValue from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> selectValue; else { // Try to initialize SelectValue from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> selectValue; } // And try to extract SelectValue value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> selectValue; // And try to extract WhereCondition value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> whereCondition; } Loading Loading @@ -619,16 +607,13 @@ void DataImporter::get_device_property() if(auxDatabaseFailedTable.empty()) throw(invalid_argument("AuxDatabaseFailedTable property is empty or not defined")); if(!selectKey.empty() && selectValue.empty()) throw(invalid_argument("SelectValue property is empty or not defined, but SelectKey is defined")); m_configuration_sp = Configuration::create(certificateFile, storagePath, remoteHost, remotePort, remoteUsername, remotePassword, databaseHost, databasePort, databaseUsername, databasePassword, databaseSchema, databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost, auxDatabasePort, auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable, selectKey, selectValue); auxDatabaseFailedTable, whereCondition); } catch(invalid_argument& ex) { Loading @@ -649,7 +634,7 @@ void DataImporter::get_device_property() //-------------------------------------------------------- void DataImporter::always_executed_hook() { INFO_STREAM << "DataImporter::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "DataImporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(DataImporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading src/DataImporter.h +2 −4 Original line number Diff line number Diff line Loading @@ -143,10 +143,8 @@ public: string auxDatabaseTimestampTable; // AuxDatabaseFailedTable: File transfer auxiliary database failed transfer table string auxDatabaseFailedTable; // SelectKey: Files delivery selection key string selectKey; // SelectValue: Files delivery selection value string selectValue; // WhereCondition: Files retrieval sql where condition string whereCondition; // Attribute data members public: Loading src/DataImporter.xmi +2 −6 Original line number Diff line number Diff line <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="DataImporter" pogoRevision="8.1"> <description description="" title="Data importer" sourcePath="/home/mdm/workspace/nadir/data_importer/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <description description="" title="Data importer" sourcePath="/home/marco/workspace/nadir/data_importer/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at oats.inaf.it - demarco" author="demarco" emailDomain="oats.inaf.it" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="TCP/UDP" manufacturer="none" reference=""/> </description> Loading Loading @@ -141,11 +141,7 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="SelectKey" description="Files delivery selection key"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="SelectValue" description="Files delivery selection value"> <deviceProperties name="WhereCondition" description="Files retrieval sql where condition"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> Loading Loading
src/Configuration.h +13 −18 Original line number Diff line number Diff line Loading @@ -28,12 +28,12 @@ private: std::string auxDatabaseHost, unsigned int auxDatabasePort, std::string auxDatabaseUsername, std::string auxDatabasePassword, std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable, std::string selectKey, std::string selectValue) : m_certificateFile (certificateFile), m_storagePath(storagePath), m_remoteHost(remoteHost), m_remotePort(remotePort), m_remoteUsername(remoteUsername), m_remotePassword(remotePassword), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), std::string auxDatabaseFailedTable, std::string whereCondition) : m_certificateFile (certificateFile), m_storagePath(storagePath), m_remoteHost(remoteHost), m_remotePort(remotePort), m_remoteUsername(remoteUsername), m_remotePassword(remotePassword), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword), m_databaseSchema(databaseSchema), m_databaseTable(databaseTable), m_refreshTime(refreshTime), m_timeout(timeout), m_recoveryTime(recoveryTime), Loading @@ -43,7 +43,7 @@ private: m_auxDatabaseSchema(auxDatabaseSchema), m_auxDatabaseTimestampTable(auxDatabaseTimestampTable), m_auxDatabaseFailedTable(auxDatabaseFailedTable), m_selectKey(selectKey), m_selectValue(selectValue) { }; m_whereCondition(whereCondition) { }; virtual ~Configuration() {} Loading @@ -69,8 +69,7 @@ public: std::string auxDatabaseHost, unsigned int auxDatabasePort, std::string auxDatabaseUsername, std::string auxDatabasePassword, std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable, std::string selectKey, std::string selectValue) std::string auxDatabaseFailedTable, std::string whereCondition) { Configuration::SP c_sp(new Configuration(certificateFile, storagePath, remoteHost, remotePort, remoteUsername, remotePassword, databaseHost, Loading @@ -78,7 +77,7 @@ public: databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost, auxDatabasePort, auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable, selectKey, selectValue), Configuration::Deleter()); whereCondition), Configuration::Deleter()); return c_sp; } Loading Loading @@ -108,8 +107,7 @@ public: std::string getAuxDatabaseSchema() const { return m_auxDatabaseSchema; } std::string getAuxDatabaseTimestampTable() const { return m_auxDatabaseTimestampTable; } std::string getAuxDatabaseFailedTable() const { return m_auxDatabaseFailedTable; } std::string getSelectKey() const { return m_selectKey; } std::string getSelectValue() const { return m_selectValue; } std::string getWhereCondition() const { return m_whereCondition; } private: //------------------------------------------------------------------------------ Loading Loading @@ -181,11 +179,8 @@ private: //Auxiliary database failed table const std::string m_auxDatabaseFailedTable; //Files selection key const std::string m_selectKey; //File selection value const std::string m_selectValue; //Files retrieval where condition const std::string m_whereCondition; }; } //End of namespace Loading
src/DBManager.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -202,12 +202,11 @@ DBManager::FileRowsetSP DBManager::retrieveNewFiles(boost::posix_time::ptime pti if(m_mainSession_sp->get_backend() == NULL) m_mainSession_sp->reconnect(); std::string selectKey = m_configuration_sp->getSelectKey(); std::string selectValue = m_configuration_sp->getSelectValue(); std::string whereCondition = m_configuration_sp->getWhereCondition(); FileRowsetSP newFileRowset_sp; if(selectKey.empty()) if(whereCondition.empty()) { newFileRowset_sp.reset(new FileRowset(m_mainSession_sp->prepare << "select storage_path, file_path, file_version, file_name, update_time " Loading @@ -222,8 +221,7 @@ DBManager::FileRowsetSP DBManager::retrieveNewFiles(boost::posix_time::ptime pti << "from " << m_configuration_sp->getDatabaseSchema() << "." << m_configuration_sp->getDatabaseTable() << " where update_time>'" << boost::posix_time::to_iso_string(ptime) << "' and " << selectKey << " like '%" << selectValue << "%' " << "order by update_time asc")); << whereCondition << " order by update_time asc")); } return newFileRowset_sp; Loading
src/DataImporter.cpp +9 −24 Original line number Diff line number Diff line Loading @@ -238,8 +238,7 @@ void DataImporter::get_device_property() dev_prop.push_back(Tango::DbDatum("AuxDatabaseSchema")); dev_prop.push_back(Tango::DbDatum("AuxDatabaseTimestampTable")); dev_prop.push_back(Tango::DbDatum("AuxDatabaseFailedTable")); dev_prop.push_back(Tango::DbDatum("SelectKey")); dev_prop.push_back(Tango::DbDatum("SelectValue")); dev_prop.push_back(Tango::DbDatum("WhereCondition")); // is there at least one property to be read ? if (dev_prop.size()>0) Loading Loading @@ -518,27 +517,16 @@ void DataImporter::get_device_property() // And try to extract AuxDatabaseFailedTable value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> auxDatabaseFailedTable; // Try to initialize SelectKey from class property // Try to initialize WhereCondition from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> selectKey; if (cl_prop.is_empty()==false) cl_prop >> whereCondition; else { // Try to initialize SelectKey from default device value // Try to initialize WhereCondition from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> selectKey; if (def_prop.is_empty()==false) def_prop >> whereCondition; } // And try to extract SelectKey value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> selectKey; // Try to initialize SelectValue from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> selectValue; else { // Try to initialize SelectValue from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> selectValue; } // And try to extract SelectValue value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> selectValue; // And try to extract WhereCondition value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> whereCondition; } Loading Loading @@ -619,16 +607,13 @@ void DataImporter::get_device_property() if(auxDatabaseFailedTable.empty()) throw(invalid_argument("AuxDatabaseFailedTable property is empty or not defined")); if(!selectKey.empty() && selectValue.empty()) throw(invalid_argument("SelectValue property is empty or not defined, but SelectKey is defined")); m_configuration_sp = Configuration::create(certificateFile, storagePath, remoteHost, remotePort, remoteUsername, remotePassword, databaseHost, databasePort, databaseUsername, databasePassword, databaseSchema, databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost, auxDatabasePort, auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable, selectKey, selectValue); auxDatabaseFailedTable, whereCondition); } catch(invalid_argument& ex) { Loading @@ -649,7 +634,7 @@ void DataImporter::get_device_property() //-------------------------------------------------------- void DataImporter::always_executed_hook() { INFO_STREAM << "DataImporter::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "DataImporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(DataImporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading
src/DataImporter.h +2 −4 Original line number Diff line number Diff line Loading @@ -143,10 +143,8 @@ public: string auxDatabaseTimestampTable; // AuxDatabaseFailedTable: File transfer auxiliary database failed transfer table string auxDatabaseFailedTable; // SelectKey: Files delivery selection key string selectKey; // SelectValue: Files delivery selection value string selectValue; // WhereCondition: Files retrieval sql where condition string whereCondition; // Attribute data members public: Loading
src/DataImporter.xmi +2 −6 Original line number Diff line number Diff line <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="DataImporter" pogoRevision="8.1"> <description description="" title="Data importer" sourcePath="/home/mdm/workspace/nadir/data_importer/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <description description="" title="Data importer" sourcePath="/home/marco/workspace/nadir/data_importer/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at oats.inaf.it - demarco" author="demarco" emailDomain="oats.inaf.it" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="TCP/UDP" manufacturer="none" reference=""/> </description> Loading Loading @@ -141,11 +141,7 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="SelectKey" description="Files delivery selection key"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="SelectValue" description="Files delivery selection value"> <deviceProperties name="WhereCondition" description="Files retrieval sql where condition"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> Loading