Commit 9a5db18f authored by Marco De Marco's avatar Marco De Marco
Browse files

Nadir tables structure modified

parent e19d99c8
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -207,7 +207,7 @@ Destination::SP DMDBImporter::getDestination(int destinationId)


    soci::rowset< DestinationTuple > rows = (m_session_sp->prepare <<
    soci::rowset< DestinationTuple > rows = (m_session_sp->prepare <<
        "SELECT id, host, port, user, password, schema_name, table_name, "
        "SELECT id, host, port, user, password, schema_name, table_name, "
        "storage_path FROM " << m_destinationTable << " WHERE id=:id",
        "storage_path, dir_name FROM " << m_destinationTable << " WHERE id=:id",
        soci::use(destinationId,"id"));
        soci::use(destinationId,"id"));


    DestinationTupleVector destinationTuple_vector;
    DestinationTupleVector destinationTuple_vector;
@@ -249,17 +249,21 @@ Destination::SP DMDBImporter::getDestination(int destinationId)
            throw soci::soci_error("Storage not found for id " + destinationId);
            throw soci::soci_error("Storage not found for id " + destinationId);
    std::string storage = destinationTuple.get<7>().get();
    std::string storage = destinationTuple.get<7>().get();


    if(!destinationTuple.get<8>())
            throw soci::soci_error("Directory not found for id " + destinationId);
    std::string directory = destinationTuple.get<8>().get();

#ifdef VERBOSE_DEBUG
#ifdef VERBOSE_DEBUG
    INFO_STREAM << "DESTINATION: " << destinationId << " " << host << " " << port
    INFO_STREAM << "DESTINATION: " << destinationId << " " << host << " " << port
        << " " << user << " " << password << " " << schema << " " << table
        << " " << user << " " << password << " " << schema << " " << table
        << " " << storage << endl;
        << " " << storage << " " << directory << endl;
    INFO_STREAM << "-------------------------------------------------" << endl;
    INFO_STREAM << "-------------------------------------------------" << endl;
#endif
#endif


    Mapping::SPVector mapping_spvector = getMapping(destinationId);
    Mapping::SPVector mapping_spvector = getMapping(destinationId);


    Destination::SP destination_sp( Destination::create(host, port, user, password,
    Destination::SP destination_sp( Destination::create(host, port, user, password,
            schema, table, storage, mapping_spvector) );
            schema, table, storage, directory, mapping_spvector) );


    return destination_sp;
    return destination_sp;
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,8 @@ protected:
    typedef boost::tuple< boost::optional<int>, boost::optional<std::string>,
    typedef boost::tuple< boost::optional<int>, boost::optional<std::string>,
            boost::optional<int>, boost::optional<std::string>,
            boost::optional<int>, boost::optional<std::string>,
            boost::optional<std::string>, boost::optional<std::string>,
            boost::optional<std::string>, boost::optional<std::string>,
            boost::optional<std::string>, boost::optional<std::string> > DestinationTuple;
            boost::optional<std::string>, boost::optional<std::string>,
            boost::optional<std::string> > DestinationTuple;


    typedef std::vector< DestinationTuple > DestinationTupleVector;
    typedef std::vector< DestinationTuple > DestinationTupleVector;


+2 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,8 @@ void DMDBVerifier::testInstrumentMapping(Instrument::SP instrument_sp)
    {
    {
        //Check nadir mandatory columns in table definition
        //Check nadir mandatory columns in table definition
        testColumnDefinition(columnTuple_vector, "id", "mediumint", true);
        testColumnDefinition(columnTuple_vector, "id", "mediumint", true);
        testColumnDefinition(columnTuple_vector,"file_path","varchar", true);
        testColumnDefinition(columnTuple_vector,"storage_path","varchar", false);
        testColumnDefinition(columnTuple_vector,"file_path","varchar", false);
        testColumnDefinition(columnTuple_vector,"file_version","smallint", true);
        testColumnDefinition(columnTuple_vector,"file_version","smallint", true);
        testColumnDefinition(columnTuple_vector,"file_name","varchar", true);
        testColumnDefinition(columnTuple_vector,"file_name","varchar", true);
        testColumnDefinition(columnTuple_vector,"update_time","timestamp", true);
        testColumnDefinition(columnTuple_vector,"update_time","timestamp", true);
+10 −5
Original line number Original line Diff line number Diff line
@@ -22,12 +22,13 @@ private:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//	[Private] Constructor destructor deleter
//	[Private] Constructor destructor deleter
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
	Destination(std::string host, int port, std::string user, std::string password,
	Destination(std::string host, int port, std::string user,
		std::string schema, std::string table, std::string storagePath, 
		std::string password, std::string schema, std::string table,
		std::string storagePath, std::string dirName,
        std::vector< boost::shared_ptr<Mapping> >& mapping_spvector) :
        std::vector< boost::shared_ptr<Mapping> >& mapping_spvector) :
		m_host(host), m_port(port), m_user(user), m_password(password),
		m_host(host), m_port(port), m_user(user), m_password(password),
		m_schema(schema), m_table(table), m_storagePath(storagePath),
		m_schema(schema), m_table(table), m_storagePath(storagePath),
		m_mapping_spvector(mapping_spvector) {}
		m_dirName(dirName), m_mapping_spvector(mapping_spvector) {}
	~Destination() {}
	~Destination() {}


	class Deleter;
	class Deleter;
@@ -44,11 +45,11 @@ public:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
	static Destination::SP create(std::string host, int port,
	static Destination::SP create(std::string host, int port,
		std::string user, std::string password, std::string schema,
		std::string user, std::string password, std::string schema,
		std::string table, std::string storagePath, 
		std::string table, std::string storagePath, std::string dirName,
		Mapping::SPVector& mapping_spvector)
		Mapping::SPVector& mapping_spvector)
	{
	{
		Destination::SP d_sp( new Destination(host, port, user, password,
		Destination::SP d_sp( new Destination(host, port, user, password,
			schema, table, storagePath, mapping_spvector), 
			schema, table, storagePath, dirName, mapping_spvector),
			Destination::Deleter() );
			Destination::Deleter() );
		return d_sp;
		return d_sp;
	}
	}
@@ -60,6 +61,7 @@ public:
	std::string getSchema() const { return m_schema; }
	std::string getSchema() const { return m_schema; }
	std::string getTable() const { return m_table; }
	std::string getTable() const { return m_table; }
	std::string getStoragePath() const { return m_storagePath; }
	std::string getStoragePath() const { return m_storagePath; }
    std::string getDirName() const { return m_dirName; }
	Mapping::SPVector getMappingSPVector() const { return m_mapping_spvector; }
	Mapping::SPVector getMappingSPVector() const { return m_mapping_spvector; }


private:
private:
@@ -87,6 +89,9 @@ private:
	//Meta data file storage path
	//Meta data file storage path
	const std::string m_storagePath;
	const std::string m_storagePath;


    //Meta data file directory name
    const std::string m_dirName;

	//Mapping vector
	//Mapping vector
	const Mapping::SPVector m_mapping_spvector;
	const Mapping::SPVector m_mapping_spvector;
};
};
+12 −5
Original line number Original line Diff line number Diff line
@@ -330,10 +330,15 @@ void WorkerThread::execQuery(ConnectionManager::SessionSP session_sp,
	std::stringstream valuesQuery;
	std::stringstream valuesQuery;
	valuesQuery << "VALUES(";
	valuesQuery << "VALUES(";


	//Append storage path column to query
	insertQuery << "storage_path";
	valuesQuery << "\'" << destination_sp->getStoragePath()
        << "/" << destination_sp->getDirName() << "\'";

	//Append file path column to query
	//Append file path column to query
	insertQuery << "file_path";
	insertQuery << ",file_path";
	int month = date.month();
	int month = date.month();
	valuesQuery << "\'/" << date.year() << "/" << month << "/" << date.day() << "\'";
	valuesQuery << ",\'/" << date.year() << "/" << month << "/" << date.day() << "\'";


	//Append file version column to query
	//Append file version column to query
	insertQuery << ",file_version";
	insertQuery << ",file_version";
@@ -552,13 +557,15 @@ void WorkerThread::moveFile(boost::filesystem::path& origPath,
		throw std::runtime_error( "Origin path \"" +
		throw std::runtime_error( "Origin path \"" +
			origPath.string() + "\" is not a regular file");
			origPath.string() + "\" is not a regular file");


	//Destination path = storage path + date path + duplicate max + file name
	//Destination path = storage path + directory name
    // + date path + duplicate max + file name
	boost::filesystem::path destPath(destination_sp->getStoragePath());
	boost::filesystem::path destPath(destination_sp->getStoragePath());


	//Create date and version part of destination path
	//Create directory path, date and version part of destination path
	std::stringstream relPathStream;
	std::stringstream relPathStream;
	int month = date.month();
	int month = date.month();
	relPathStream << "/" << date.year() << "/" << month
	relPathStream << "/" << destination_sp->getDirName()
        << "/" << date.year() << "/" << month
		<< "/" << date.day() << "/" << duplicateMax;
		<< "/" << date.day() << "/" << duplicateMax;
	boost::filesystem::path relPath( relPathStream.str() );
	boost::filesystem::path relPath( relPathStream.str() );