예제 #1
0
    def __init__(self, map_node):
        dictionary_node = None
        try:
            dictionary_node = util.getFirstChildNode(map_node, self.ETL_DICTIONARY_XMLNODE)
        except LookupError:
            return

        self.__replace_mode = dictionary_node.prop("replace")

        self.__if_mode = dictionary_node.prop("if")
        self.__if_mode = self.ETL_DICTIONARY_IF_MODE_CONTAINS if self.__if_mode is None else self.__if_mode

        database_node = util.getFirstChildNode(dictionary_node, self.ETL_DICTIONARY_DB_XMLNODE)
        database_host = util.getFirstChildNode(database_node, self.ETL_DICTIONARY_DB_HOST_XMLNODE).getContent()
        database_user = util.getFirstChildNode(database_node, self.ETL_DICTIONARY_DB_USER_XMLNODE).getContent()
        database_pass = util.getFirstChildNode(database_node, self.ETL_DICTIONARY_DB_PASS_XMLNODE).getContent()
        database_dbname = util.getFirstChildNode(database_node, self.ETL_DICTIONARY_DB_DBNAME_XMLNODE).getContent()
        connection = MySQLdb.connect(host=database_host, user=database_user, passwd=database_pass, db=database_dbname)

        sql_query = util.getFirstChildNode(database_node, self.ETL_DICTIONARY_DB_QUERY_XMLNODE).getContent()
        cursor = connection.cursor()
        cursor.execute(sql_query)
        rows = cursor.fetchall()

        columns = dict((name[0], col) for col, name in enumerate(cursor.description))
        map_from = columns["map_from"]
        map_to = columns["map_to"]

        self.__dictionary = []
        for row in rows:
            tokens = string.split(row[map_from], "|")
            self.__dictionary.extend(list((token, row[map_to]) for token in tokens))

        super(Dictionary, self).__init__(map_node)
예제 #2
0
    def confField(self, field_id, map_node):
        field_node = util.getFirstChildNode(map_node, self.ETL_FIELD_TARGET_XMLNODE)
        
#        try:
        field = FieldTargetDatabase(field_node)
        self.fields[field_id] = field
        
        if(field.getName() == self.__keys):
            self.__key_field_id = field_id
예제 #3
0
    def __init__(self, map_node):
        try:
            date_sufix_node = util.getFirstChildNode(map_node, self.ETL_DATE_SUFIX_XMLNODE)
        except LookupError:
            return

        self.__date_sufix_format = date_sufix_node.prop("format")

        super(DateSufix, self).__init__(map_node)
예제 #4
0
    def __init__(self, map_node):
        try:
            wrap_node = util.getFirstChildNode(map_node, self.ETL_WRAP_XMLNODE)
        except LookupError:
            return

        self.__wrap_exp = wrap_node.prop("expression")

        super(Wrap, self).__init__(map_node)
예제 #5
0
    def __init__(self, map_node):
        try:
            joinwith_node = util.getFirstChildNode(map_node, self.ETL_JOINWITH_XMLNODE)
        except LookupError:
            return

        self.__var_name = joinwith_node.prop("variable")

        super(JoinWith, self).__init__(map_node)
예제 #6
0
    def __init__(self, map_node):
        try:
            saveto_node = util.getFirstChildNode(map_node, self.ETL_SAVETO_XMLNODE)
        except LookupError:
            return

        self.__var_name = saveto_node.prop("variable")

        super(SaveTo, self).__init__(map_node)
예제 #7
0
    def __init__(self, map_node):
        trim_node = None
        try:
            trim_node = util.getFirstChildNode(map_node, self.ETL_TRIM_XMLNODE)
        except LookupError:
            return

        self.__side_mode = trim_node.prop("side")

        super(Trim, self).__init__(map_node)
예제 #8
0
    def __init__(self, map_node):
        try:
            column_node = util.getFirstChildNode(map_node, self.ETL_FIELD_TARGET_DATABASE_XMLNODE)

            if(column_node.prop(self.ETL_FIELD_TARGET_DATABASE_ATTR_DF) is not None):
                df_prop = column_node.prop(self.ETL_FIELD_TARGET_DATABASE_ATTR_DF)
            else:
                df_prop = None
                
            self.attrs = [column_node.getContent(), df_prop]
        except LookupError:
            raise AssertionError("Campo target no configurado")
예제 #9
0
 def __init__(self, map_node):
     target_node = util.getFirstChildNode(map_node, self.ETL_TARGET_DB_XMLNODE)
     database_host = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_HOST_XMLNODE).getContent()
     database_user = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_USER_XMLNODE).getContent()
     database_pass = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_PASS_XMLNODE).getContent()
     database_dbname = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_DBNAME_XMLNODE).getContent()
     self.__connection = MySQLdb.connect (host = database_host, user = database_user, passwd = database_pass, db = database_dbname)
     
     self.__default_table = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_DEFAULT_TABLE_XMLNODE).getContent()
     self.__keys = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_KEYS_XMLNODE).getContent()
     
     try:
         self.__validation = util.getFirstChildNode(target_node, self.ETL_TARGET_DB_VALIDATION_XMLNODE).getContent()
     except LookupError:
         pass
예제 #10
0
    def __init__(self, map_node):
        fixed_node = util.getFirstChildNode(map_node, self.ETL_FIELD_SOURCE_FFF_XMLNODE)
        try:
            from_prop = int(fixed_node.prop(self.ETL_FIELD_SOURCE_FFF_ATTR_FROM))
            
            if(fixed_node.prop(self.ETL_FIELD_SOURCE_FFF_ATTR_TO) is not None):
                to_prop = int(fixed_node.prop(self.ETL_FIELD_SOURCE_FFF_ATTR_TO))
            else:
                to_prop = None
                
        except ValueError:
            raise ValueError("Los atributos from y to deben ser numeros enteros")
        
        self.attrs = [from_prop, to_prop]

        super(FieldSourceFff, self).__init__(map_node)
예제 #11
0
    def confField(self, field_id, map_node):
        transformation_node = None

        try:
            transformation_node = util.getFirstChildNode(map_node, self.ETL_FIELD_TRANSFORMATIONS_XMLNODE)
        except LookupError:
            pass

        if transformation_node is not None:
            for clazz in self.__registered:
                transformation = globals()[clazz](transformation_node)

                if not self.fields.has_key(field_id):
                    self.fields[field_id] = []

                if transformation.isConfigured():
                    self.fields[field_id].append(transformation)
예제 #12
0
    def __init__(self, map_node):
        floating_node = util.getFirstChildNode(map_node, self.ETL_FIELD_SOURCE_CRDF_XMLNODE)
        try:
            line_from_prop      = int(floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_LNFRM))
            line_to_prop        = int(floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_LNTO))
            col_from_prop       = int(floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_COLFRM))
            col_to_prop         = int(floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_COLTO))
        except ValueError:
            raise ValueError("Los atributos line_from, line_to, col_from y col_to deben ser numeros enteros")
        
        if(floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_TYPE) is not None):
            type = floating_node.prop(self.ETL_FIELD_SOURCE_CRDF_ATTR_TYPE)
        else:
            type = self.ETL_FIELD_SOURCE_CRDF_ATTR_TYPE_ROW
        
        self.attrs = [line_from_prop, line_to_prop, col_from_prop, col_to_prop, type]

        super(FieldSourceCardfile, self).__init__(map_node)
예제 #13
0
 def __init__(self, map_node):
     try:
         fff_node = util.getFirstChildNode(map_node, self.ETL_SOURCE_FFF_XMLNODE)
     except LookupError:
         return
     
     file_path = fff_node.prop(self.ETL_SOURCE_FFF_ATTR_PATH)
     
     if(file_path is not None):
         if(file_path.startswith("$")):
             global_path = "-" + file_path[1:]  #slice desde el segundo caracter para quitar el $
             if not global_path in util.globalVars():
                 raise AssertionError("El parametro " + global_path + " es requerido por el atributo " + self.ETL_SOURCE_FFF_ATTR_PATH)
              
             file_path = util.getGlobalVar(global_path)
             
         source_file = open(file_path, "r+")
         size = os.path.getsize(file_path)
         self.source_file_mmap = mmap.mmap(source_file.fileno(), size)
예제 #14
0
 def confField(self, field_id, map_node):
     field_node = util.getFirstChildNode(map_node, self.ETL_FIELD_SOURCE_XMLNODE)
     field = FieldSourceFff(field_node)
     self.fields[field_id] = field