Example #1
0
    def locked(self, file):
        logger = self.get_logger()
        logger.trace('', 'rule : ' + file['rule'])

        connection = self.get_connection()
        cursor = connection.cursor()

        file_property_repository = FilePropertyRepository(self.get_connector())
        pattern_value = file_property_repository.get_property(file, 'pattern')

        params = dict()
        params['name'] = 'pattern'
        params['value'] = pattern_value

        statement = "select f.id " \
                    "from files f " \
                    "inner join file_properties fp on f.id = fp.fle_id " \
                    "where fp.name = :name and fp.value = :value and f.state = 'WAIT' order by f.id"
        logger.trace('', 'statement : ' + statement)
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if result:
            logger.trace('', 'id : ' + result[0]['id'])
            logger.trace(
                '', 'locked : ' + str(int(result[0]['id']) != int(file['id'])))
            if int(result[0]['id']) != int(file['id']):
                return True

        statement = "select count(0) as aantal " \
                    "from files f " \
                    "inner join file_properties fp on f.id = fp.fle_id " \
                    "where fp.name = :name and fp.value = :value and f.state = 'SCHEDULED'"
        logger.trace('', 'statement : ' + statement)
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)
        logger.trace('', 'count : ' + result[0]['aantal'])

        if int(result[0]['aantal']) == 0:
            logger.trace('', 'file: ' + file['filename'] + ' not locked')
            return False
        return True
Example #2
0
    def states(self):
        connection = self.get_connection()
        cursor = connection.cursor()

        statement = "select state, count(0) as aantal from events group by state"

        cursor.execute(statement)

        return Helper.cursor_to_json(cursor)
Example #3
0
    def list(self):
        connection = self.get_connection()
        cursor = connection.cursor()

        statement = "select * from processes order by id desc"
        cursor.execute(statement)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return []
        return result
Example #4
0
    def find_failsafe(self):
        connection = self.get_connection()
        cursor = connection.cursor()

        statement = "select * from rules where active=1 and rule='failsafe'"

        cursor.execute(statement)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #5
0
    def list_by_rule(self, rule):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['rle_id'] = rule['id']

        statement = "select * from files where rle_id = :rle_id order by id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #6
0
    def find_by_location(self, location):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['lcn_id'] = location['id']

        statement = "select * from rules where active = 1 and lcn_id = :lcn_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #7
0
    def find_by_name(self, name):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['name'] = name

        statement = "select * from rules where name = :name"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #8
0
    def next(self, queue):
        connection = self.get_connection()
        cursor = connection.cursor()

        tablename = queue['tablename']

        statement = "select * from " + tablename + " where state='READY' order by delay"
        cursor.execute(statement)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #9
0
    def find_by_hashcode(self, hashcode):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['hashcode'] = hashcode

        statement = "select * from locations where hashcode = :hashcode"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #10
0
    def next(self, hook):
        connection = self.get_connection()
        cursor = connection.cursor()

        statement = hook['selector']
        cursor.execute(statement)

        payload = Helper.cursor_to_json(cursor)
        cursor.close()

        if len(payload) == 0:
            return None
        return payload[0]
    def list_by_process_definition_action(self, process_definition_action):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['dan_id'] = process_definition_action['id']

        statement = "select * from process_definitions_actions_properties where active=1 and dan_id = :dan_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #12
0
    def find_by_pickup_location(self, pickup_location):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['pickup_location'] = pickup_location

        statement = "select * from files where pickup_location = :pickup_location"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #13
0
    def find_by_state(self, state):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['state'] = state

        statement = "select * from files where state = :state"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #14
0
    def find_by_stream(self, stream):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['stm_id'] = stream['id']

        statement = "select * from rules where active=1 and stm_id = :stm_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #15
0
    def find_by_hashcode(self, hashcode):
        connection = self.get_connection()
        cursor = connection.cursor()
        param = dict()
        param['hashcode'] = hashcode
        statement = "select * from users where hashcode = :hashcode"
        statement, parameters = self.statement(statement, param)
        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)
        cursor.close()

        if len(result) == 0:
            return None
        return result[0]
Example #16
0
    def list_by_scheduled_event(self, scheduled_event):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['set_id'] = scheduled_event['id']

        print 'scheduled_event is: ', scheduled_event
        statement = "select * from rules where active = 1 and set_id= :set_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
Example #17
0
    def find_by_hook(self, hook):
        #als er meer dan 1 id kan worden verwacht dient hiervoor list_by.... te worden gebruikt.
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['hok_id'] = hook['id']

        statement = "select * from rules where active = 1 and hok_id= :hok_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)

        return Helper.cursor_to_json(cursor)
    def count_processed_by_name(self, name):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['name'] = name

        statement = "select count(0) aantal from processes_actions where name=:name and state='PROCESSED'"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
    def list_by_process(self, process):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['pcs_id'] = process['id']

        statement = "select * from processes_properties where pcs_id = :pcs_id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result
Example #20
0
    def find_by_name(self, name):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['name'] = name

        statement = "select * from process_definitions where name = :name"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #21
0
    def find_by_id(self, id):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['id'] = id

        statement = "select * from chunks where id = :id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #22
0
    def find_first_by_process_definition(self, process_definition):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['pdn_id'] = process_definition['id']

        statement = "select * from process_definitions_actions where pdn_id = :pdn_id and active=1 order by id"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #23
0
    def scheduler_jobs(self, identifier):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['identifier'] = identifier

        statement = "select * from user_scheduler_jobs where job_name=upper(:identifier)"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        results = Helper.cursor_to_json(cursor)
        cursor.close()

        if len(results) == 0:
            return None
        return results[0]
    def get_property(self, process_definition_action, name):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['dan_id'] = process_definition_action['id']
        params['name'] = name

        statement = "select value from process_definitions_actions_properties where dan_id = :dan_id and name = :name"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]['value']
Example #25
0
    def get_property(self, file, name):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['fle_id'] = file['id']
        params['name'] = name

        statement = "select * from file_properties where name = :name and fle_id = :fle_id"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]['value']
Example #26
0
    def object_type(self, job_action):
        params = dict()
        params['package'] = job_action.split('.')[0].upper()
        params['method'] = job_action.split('.')[1].upper()

        connection = self.get_connection()
        cursor = connection.cursor()

        statement = "select * from user_arguments where argument_name is null and position = 0 " \
                    "and package_name=upper(:package) and object_name=(:method)"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        count = len(Helper.cursor_to_json(cursor))

        if count == 0:
            return 'PROCEDURE'
        return 'FUNCTION'
Example #27
0
    def get_property(self, key):
        connection = self.get_connection()
        cursor = connection.cursor()

        param = dict()
        param['name'] = key

        statement = "select value from application_properties where name = :name"
        statement, parameters = self.statement(statement, param)

        cursor.execute(statement, parameters)
        response = Helper.cursor_to_json(cursor)
        if response:
            record = response[0]
            return record['value']
        else:
            raise Exception('No such property ' + param['name'] +
                            ' in database' + str(connection))
Example #28
0
    def find_next_by_process_action(self, process_action, process):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['dan_id'] = process_action['dan_id']
        params['pdn_id'] = process['pdn_id']

        statement = "select * from process_definitions_actions pan where pan.id > :dan_id and pan.pdn_id = :pdn_id " \
                    "and pan.active=1 order by pan.id"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        if len(result) == 0:
            return None
        return result[0]
Example #29
0
    def job_run_details(self, identifier, created_at):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['identifier'] = identifier
        params['created_at'] = created_at

        statement = "select status, additional_info from user_scheduler_job_run_details " \
                    "where job_name=upper(:identifier) " \
                    "and log_date>=to_timestamp_tz(:created_at,'YYYY-MM-DD HH24:MI:SS') order by log_id desc"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        results = Helper.cursor_to_json(cursor)
        cursor.close()

        if len(results) == 0:
            return None
        return results[0]
    def get_property(self, process_action, name, default_value=None):
        connection = self.get_connection()
        cursor = connection.cursor()

        params = dict()
        params['pan_id'] = process_action['id']
        params['name'] = name

        statement = "select value from processes_actions_properties where pan_id = :pan_id and name = :name"
        statement, parameters = self.statement(statement, params)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)

        # if the default_value holds a value, than return this values if no value is found.
        if len(result) == 0:
            if default_value:
                return default_value
            return None

        return result[0]['value']