All Downloads are FREE. Search and download functionalities are using the official Maven repository.

e.metridoc.metridoc-ezproxy-plugin.0.17.source-code.NormalizeEzproxy.groovy Maven / Gradle / Ivy

There is a newer version: 0.24
Show newest version
/*
 * Copyright 2010 Trustees of the University of Pennsylvania Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 * http://www.osedu.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
sql {
    loadDistinctEzproxyData {
        order= 1
        dataFile {
            sql = "insert ignore into data_file(data_file_name) select distinct source_file from ezproxy_log"
        }
        ipAddress {
            sql = "insert ignore into ip_address(ip_address) select patron_ip from ezproxy_log"
        }
        city {
            sql = "insert ignore into city(city) select city from ezproxy_log"
        }
        state {
            sql = "insert ignore into state(state) select state from ezproxy_log"
        }
        country {
            sql = "insert ignore into country(country) select country from ezproxy_log"
        }
        requestUrl {
            sql = "insert ignore into resource(resource, mini_resource) select url, md5(url) from ezproxy_log"
        }
        referrerUrl {
            sql = "insert ignore into resource(resource, mini_resource) select ref_url, md5(ref_url) from ezproxy_log"
        }
        agent {
            sql = "insert ignore into agent(agent, mini_agent) select agent, md5(agent) from ezproxy_log"
        }
        cookies {
            sql = "insert ignore into cookies(cookies, mini_cookies) select cookies, md5(cookies) from ezproxy_log"
        }
        ezproxyIdentifier {
            sql = "insert ignore into ezproxy_identifier(ezproxy_id) select ezproxy_id from ezproxy_log"
        }
        ez_log_master {
            sql = "insert ignore into ez_log_master (data_file_id, line_number, ip_address_id, resource_id, proxy_time) select d.data_file_id, e.line_num, i.ip_address_id, r.resource_id, e.proxy_time from ezproxy_log e, resource r, ip_address i, data_file d where md5(e.url) = r.mini_resource and e.patron_ip = i.ip_address and e.source_file = d.data_file_name"
        }
    }

    createLinks {
        order= 2
        ezMaster {
            sql: "insert into ez_master select ez_log_master_id, ez_key from ez_log_master m, ezproxy_log e, data_file d where e.source_file = d.data_file_name and d.data_file_id = m.data_file_id and e.line_num = m.line_number"
        }
        ezHttpMaster {
            sql: "insert ignore into ez_http_master(master_id, method, response_code, response_size) select m.master_id, e.http_method, e.response_code, response_size from ez_master m, ezproxy_log e where e.ez_key = m.ez_key"
        }
        ezCityMaster {
            sql: "insert ignore into ez_city_master(master_id, city_id) select m.master_id, c.city_id from ez_master m, city c, ezproxy_log e where e.city=c.city and e.ez_key=m.ez_key"
        }
        ezStateMaster {
            sql: "insert ignore into ez_state_master(master_id, state_id) select m.master_id, s.state_id from ez_master m, state s, ezproxy_log e where e.state=s.state and e.ez_key=m.ez_key"
        }
        ezCountryMaster {
            sql: "insert ignore into ez_country_master(master_id, country_id) select m.master_id, c.country_id from ez_master m, country c, ezproxy_log e where e.country=c.country and e.ez_key=m.ez_key"
        }
        ezResourceReferenceMaster {
            sql: "insert ignore into ez_resource_reference_master(master_id, resource_id) select m.master_id, r.resource_id from ez_master m, resource r, ezproxy_log e where r.mini_resource = md5(e.ref_url) and e.ez_key = m.ez_key and length(e.ref_url) > 2"
        }
        ezAgentMaster {
            sql: "insert ignore into ez_agent_master(master_id, agent_id) select m.master_id, a.agent_id from ez_master m, agent a, ezproxy_log e where a.mini_agent = md5(e.agent) and e.ez_key = m.ez_key and length(e.agent) > 2"
        }
        ezCookies {
            sql: "insert ignore into ez_cookies_master(master_id, cookies_id) select m.master_id, c.cookies_id from ez_master m, cookies c, ezproxy_log e where c.mini_cookies = md5(e.cookies) and e.ez_key = m.ez_key and length(e.cookies) > 2"
        }
        ezIdMaster {
            sql: "insert ignore into ezproxy_id_master(master_id, ezproxy_id) select m.master_id, p.ezproxy_identifier_id from ez_master m, ezproxy_identifier p, ezproxy_log e where p.ezproxy_identifier_id = e.ezproxy_id and e.ez_key = m.ez_key and length(e.ezproxy_id) > 1"
        }
    }

    ezCleanup {
        order= 3
        truncateEzMaster {
            sql: "truncate table ez_master"
        }
        truncateEzLoadingTable {
            sql: "truncate table ezproxy_log"
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy