Commit 0f868c62 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'storageBasePathIsValid()' and 'getStorageId()' methods.

parent 35bdb84e
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -135,11 +135,20 @@ class DbConnector(object):
            self.cursor.execute("SELECT user_name FROM users WHERE rap_id = %s;", (rapId,))
            return self.cursor.fetchall()[0]["user_name"]
  
    def getStorageList(self, storageType):
        """Returns a list of storage locations for a given storage type"""
    def storageBasePathIsValid(self, path):
        """Checks if the base path of a physical path is valid. If true, returns tbe base path, else returns 'False'."""
        if self.conn:
            self.cursor.execute("SELECT * FROM storage WHERE storage_type = %s;", (storageType,))
            return self.cursor.fetchall()
            self.cursor.execute("""
                SELECT base_path 
                FROM storage 
                WHERE position(base_path in cast(%s as varchar)) > 0;
                """, 
                (path,))
            result = self.cursor.fetchall()[0]["base_path"]
            if result:
                return result
            else:
                return False    
        
    def getStorageBasePath(self, storageId):
        """Returns the storage base path fro a give storage id"""
@@ -147,6 +156,18 @@ class DbConnector(object):
            self.cursor.execute("SELECT base_path FROM storage WHERE storage_id = %s;", (storageId,))
            return self.cursor.fetchall()[0]["base_path"]

    def getStorageList(self, storageType):
        """Returns a list of storage locations for a given storage type"""
        if self.conn:
            self.cursor.execute("SELECT * FROM storage WHERE storage_type = %s;", (storageType,))
            return self.cursor.fetchall()
        
    def getStorageId(self, basePath):
        """Returns the storage id for a given storage base path"""
        if self.conn:
            self.cursor.execute("SELECT storage_id FROM storage WHERE base_path = %s;", (basePath,))
            return self.cursor.fetchall()[0]["storage_id"]

    def getLocationId(self, destStorageId):
        """Returns the location id according to the storage id of the destination"""
        if self.conn: