Commit d7f2e32d authored by Marco De Marco's avatar Marco De Marco
Browse files

Key selection added

parent 0c5af354
Loading
Loading
Loading
Loading
+23 −12
Original line number Original line Diff line number Diff line
@@ -28,20 +28,22 @@ private:
        std::string auxDatabaseHost, unsigned int auxDatabasePort,
        std::string auxDatabaseHost, unsigned int auxDatabasePort,
        std::string auxDatabaseUsername, std::string auxDatabasePassword,
        std::string auxDatabaseUsername, std::string auxDatabasePassword,
        std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
        std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
        std::string auxDatabaseFailedTable) :
        std::string auxDatabaseFailedTable, std::string selectKey,
        m_certificateFile (certificateFile), m_storagePath(storagePath),
		std::string selectValue) : m_certificateFile (certificateFile),
        m_remoteHost(remoteHost), m_remotePort(remotePort),
		m_storagePath(storagePath), m_remoteHost(remoteHost),
        m_remoteUsername(remoteUsername), m_remotePassword(remotePassword),
		m_remotePort(remotePort), m_remoteUsername(remoteUsername),
        m_databaseHost(databaseHost), m_databasePort(databasePort),
		m_remotePassword(remotePassword), m_databaseHost(databaseHost),
        m_databaseUsername(databaseUsername), m_databasePassword(databasePassword),
		m_databasePort(databasePort), m_databaseUsername(databaseUsername),
        m_databaseSchema(databaseSchema), m_databaseTable(databaseTable),
		m_databasePassword(databasePassword), m_databaseSchema(databaseSchema),
        m_refreshTime(refreshTime), m_timeout(timeout), m_recoveryTime(recoveryTime),
		m_databaseTable(databaseTable), m_refreshTime(refreshTime),
		m_timeout(timeout), m_recoveryTime(recoveryTime),
        m_auxDatabaseHost(auxDatabaseHost), m_auxDatabasePort(auxDatabasePort),
        m_auxDatabaseHost(auxDatabaseHost), m_auxDatabasePort(auxDatabasePort),
        m_auxDatabaseUsername(auxDatabaseUsername),
        m_auxDatabaseUsername(auxDatabaseUsername),
        m_auxDatabasePassword(auxDatabasePassword),
        m_auxDatabasePassword(auxDatabasePassword),
        m_auxDatabaseSchema(auxDatabaseSchema),
        m_auxDatabaseSchema(auxDatabaseSchema),
        m_auxDatabaseTimestampTable(auxDatabaseTimestampTable),
        m_auxDatabaseTimestampTable(auxDatabaseTimestampTable),
        m_auxDatabaseFailedTable(auxDatabaseFailedTable) { };
        m_auxDatabaseFailedTable(auxDatabaseFailedTable),
		m_selectKey(selectKey), m_selectValue(selectValue) { };


	virtual ~Configuration() {}
	virtual ~Configuration() {}


@@ -67,15 +69,16 @@ public:
        std::string auxDatabaseHost, unsigned int auxDatabasePort,
        std::string auxDatabaseHost, unsigned int auxDatabasePort,
        std::string auxDatabaseUsername, std::string auxDatabasePassword,
        std::string auxDatabaseUsername, std::string auxDatabasePassword,
        std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
        std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
        std::string auxDatabaseFailedTable)
        std::string auxDatabaseFailedTable, std::string selectKey,
		std::string selectValue)
	{
	{
		Configuration::SP c_sp(new Configuration(certificateFile, storagePath,
		Configuration::SP c_sp(new Configuration(certificateFile, storagePath,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
            databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
            auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable),
            auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable,
            Configuration::Deleter());
			selectKey, selectValue), Configuration::Deleter());


		return c_sp;
		return c_sp;
	}
	}
@@ -105,6 +108,8 @@ public:
    std::string getAuxDatabaseSchema() const { return m_auxDatabaseSchema; }
    std::string getAuxDatabaseSchema() const { return m_auxDatabaseSchema; }
    std::string getAuxDatabaseTimestampTable() const { return m_auxDatabaseTimestampTable; }
    std::string getAuxDatabaseTimestampTable() const { return m_auxDatabaseTimestampTable; }
    std::string getAuxDatabaseFailedTable() const { return m_auxDatabaseFailedTable; }
    std::string getAuxDatabaseFailedTable() const { return m_auxDatabaseFailedTable; }
	std::string getSelectKey() const { return m_selectKey; }
	std::string getSelectValue() const { return m_selectValue; }


private:
private:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
@@ -175,6 +180,12 @@ private:


	//Auxiliary database failed table
	//Auxiliary database failed table
	const std::string m_auxDatabaseFailedTable;
	const std::string m_auxDatabaseFailedTable;

	//Files selection key
	const std::string m_selectKey;

	//File selection value
	const std::string m_selectValue;
};
};


}   //End of namespace
}   //End of namespace
+25 −7
Original line number Original line Diff line number Diff line
@@ -202,11 +202,29 @@ DBManager::FileRowsetSP DBManager::retrieveNewFiles(boost::posix_time::ptime pti
    if(m_mainSession_sp->get_backend() == NULL)
    if(m_mainSession_sp->get_backend() == NULL)
        m_mainSession_sp->reconnect();
        m_mainSession_sp->reconnect();


    FileRowsetSP newFileRowset_sp(new FileRowset(m_mainSession_sp->prepare
    std::string selectKey = m_configuration_sp->getSelectKey();
    std::string selectValue = m_configuration_sp->getSelectValue();

    FileRowsetSP newFileRowset_sp;

    if(selectKey.empty())
    {
        newFileRowset_sp.reset(new FileRowset(m_mainSession_sp->prepare
            << "select storage_path, file_path, file_version, file_name, update_time "
            << "select storage_path, file_path, file_version, file_name, update_time "
            << "from " << m_configuration_sp->getDatabaseSchema() << "."
            << "from " << m_configuration_sp->getDatabaseSchema() << "."
            << m_configuration_sp->getDatabaseTable() << " where update_time>'"
            << m_configuration_sp->getDatabaseTable() << " where update_time>'"
            << boost::posix_time::to_iso_string(ptime) << "' order by update_time asc"));
            << boost::posix_time::to_iso_string(ptime) << "' order by update_time asc"));
    }
    else
    {
        newFileRowset_sp.reset(new FileRowset(m_mainSession_sp->prepare
            << "select storage_path, file_path, file_version, file_name, update_time "
            << "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"));
    }


    return newFileRowset_sp;
    return newFileRowset_sp;
}
}
+30 −2
Original line number Original line Diff line number Diff line
@@ -238,6 +238,8 @@ void DataImporter::get_device_property()
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseSchema"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseSchema"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseTimestampTable"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseTimestampTable"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseFailedTable"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseFailedTable"));
	dev_prop.push_back(Tango::DbDatum("SelectKey"));
	dev_prop.push_back(Tango::DbDatum("SelectValue"));


	//	is there at least one property to be read ?
	//	is there at least one property to be read ?
	if (dev_prop.size()>0)
	if (dev_prop.size()>0)
@@ -516,6 +518,28 @@ void DataImporter::get_device_property()
		//	And try to extract AuxDatabaseFailedTable value from database
		//	And try to extract AuxDatabaseFailedTable value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  auxDatabaseFailedTable;
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  auxDatabaseFailedTable;


		//	Try to initialize SelectKey from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  selectKey;
		else {
			//	Try to initialize SelectKey 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;
		}
		//	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;

	}
	}


	/*----- PROTECTED REGION ID(DataImporter::get_device_property_after) ENABLED START -----*/
	/*----- PROTECTED REGION ID(DataImporter::get_device_property_after) ENABLED START -----*/
@@ -595,12 +619,16 @@ void DataImporter::get_device_property()
        if(auxDatabaseFailedTable.empty())
        if(auxDatabaseFailedTable.empty())
            throw(invalid_argument("AuxDatabaseFailedTable property is empty or not defined"));
            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,
        m_configuration_sp = Configuration::create(certificateFile, storagePath,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
            databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
            auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable);
            auxDatabaseSchema, auxDatabaseTimestampTable,
            auxDatabaseFailedTable, selectKey, selectValue);
    }
    }
    catch(invalid_argument& ex)
    catch(invalid_argument& ex)
    {
    {
@@ -621,7 +649,7 @@ void DataImporter::get_device_property()
//--------------------------------------------------------
//--------------------------------------------------------
void DataImporter::always_executed_hook()
void DataImporter::always_executed_hook()
{
{
	DEBUG_STREAM << "DataImporter::always_executed_hook()  " << device_name << endl;
	INFO_STREAM << "DataImporter::always_executed_hook()  " << device_name << endl;
	/*----- PROTECTED REGION ID(DataImporter::always_executed_hook) ENABLED START -----*/
	/*----- PROTECTED REGION ID(DataImporter::always_executed_hook) ENABLED START -----*/


    if(get_state() != Tango::FAULT)
    if(get_state() != Tango::FAULT)
+166 −162
Original line number Original line Diff line number Diff line
@@ -143,6 +143,10 @@ public:
	string	auxDatabaseTimestampTable;
	string	auxDatabaseTimestampTable;
	//	AuxDatabaseFailedTable:	File transfer auxiliary database failed transfer table
	//	AuxDatabaseFailedTable:	File transfer auxiliary database failed transfer table
	string	auxDatabaseFailedTable;
	string	auxDatabaseFailedTable;
	//	SelectKey:	Files delivery selection key
	string	selectKey;
	//	SelectValue:	Files delivery selection value
	string	selectValue;


//	Attribute data members
//	Attribute data members
public:
public:
+8 −0
Original line number Original line Diff line number Diff line
@@ -141,6 +141,14 @@
      <type xsi:type="pogoDsl:StringType"/>
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    </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">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
    <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="none">
      <argin description="none">
        <type xsi:type="pogoDsl:VoidType"/>
        <type xsi:type="pogoDsl:VoidType"/>
Loading