<commit_before><?php
/*#################################################################################################

Copyright 2013 The Trustees of Indiana University

Licensed under the Apache 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.apache.org/licenses/LICENSE-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.

#################################################################################################*/

class PfmeshController extends RgpfController
{
    public static function default_title() { return "Perfsonar Mesh Config"; }
    public static function default_url($query) { return ""; }

    public function load()
    {
        $this->setpagetitle($this->default_title());
        $this->selectmenu("misc");
    }

    public function jsonAction()
    {
        ///////////////////////////////////////////////////////////////////////////////////////////
        // Step1. Load various information needed from various DBs
        //

        if(isset($_REQUEST["vo_id"])) {
            $vo_id = (int)$_REQUEST["vo_id"];

            //load vo detail
            $model = new VirtualOrganization();
            $vo = $model->get(array("vo_id"=>$vo_id));
            $vo = $vo[0];

            $mesh_desc = $vo->name;
            $mesh_id = "vo_$vo_id";

            //load all resources owned by specified vo
            $model = new VOOwnedResources();
            $vo_ros = $model->get(array("vo_id"=>$vo_id));
            $rids = array();
            foreach($vo_ros as $vo_ro) {
                $rids[] = $vo_ro->resource_id;
            } 
        } else {
            $mesh_desc = "All OSG";
            $rids = null;
            $mesh_id = "vo_all";
        }
        //error_log(print_r($rids, true));

        $mesh_admins = array(   
            array("email"=>"<EMAIL>", "name"=>"<NAME>"), 
            array("email"=>"<EMAIL>", "name"=>"OSG Grid Operations")
        );

        //for each resource, look for perfsonar services
        $model = new ServiceByResourceID();
        $rss = $model->getIndex(array("resource_ids"=>$rids));
        //error_log(print_r($rss, true));
        
        $pf_services =  array(config()->perfsonar_late_service_id, config()->perfsonar_band_service_id);
        $all_rids = array();
        $late_rids = array();//stores all resource ids that we should pull site information
        $band_rids = array();//stores all resource ids that we should pull site information
        foreach($rss as $resource_id=>$services) {
            foreach($services as $service) {
                if(in_array($resource_id, $all_rids)) continue;
                if($service->service_id == config()->perfsonar_late_service_id) {
                    $all_rids[] = $resource_id;
                    $late_rids[] = $resource_id;
                } else if($service->service_id == config()->perfsonar_band_service_id) {
                    $all_rids[] = $resource_id;
                    $band_rids[] = $resource_id;
                }
            }
        }

        //load all resource details
        $model = new ResourceServiceDetail();
        $resource_details = $model->getIndex(array("resource_ids"=>$all_rids)); 

        //lookup all relevant resources
        $model = new Resource();
        $rs = $model->getIndex(array("resource_ids"=>$all_rids, "active"=>1, "disable"=>0));

        //lookup all relevant resource groups
        $rgids = array();
        foreach($rs as $rid=>$resource) {
            $resource = $resource[0];
            //use base class function
            $rgids[] = $resource->resource_group_id;
        }

        $model = new ResourceGroup();
        $rgs = $model->getIndex(array("resource_group_ids"=>$rgids));

        //lookup all relevant sites
        $siteids = array(); 
        foreach($rgs as $rgid=>$rg) {
            $rg = $rg[0];
            $siteids[] = $rg->site_id;
        } 
        $model = new Site();
        $sites = $model->getIndex(array("site_ids"=>$siteids));

        //lookup all relevant facilities
        $facilityids = array(); 
        $scids = array(); 
        foreach($sites as $site_id=>$site) {
            $site = $site[0];
            $facilityids[] = $site->facility_id;
            $scids[] = $site->sc_id;
        } 
        $model = new Facilities();
        $facilities = $model->getIndex(array("facility_ids"=>$facilityids));
        $model = new SupportCenterContact();
        $sc_contacts = $model->getIndex(array("sc_ids"=>$scids));
        $model = new ResourceContact();
        $r_contacts = $model->getIndex(array("resource_ids"=>$all_rids));

        //$model = new ResourceAlias();
        //$resource_aliases = $model->getIndex();

        //mapping between oim and mesh config
        //oim/facility == organizations
        //oim/site == sites
        //oim/sc admin == site admin
        //oim/resource_groups == hosts
        //oim/resource/resource_service == measurement_archives
        //oim/resource admin == host/administrator

        ///////////////////////////////////////////////////////////////////////////////////////////
        // Step2. Create skelton structure and put some key components
        //
        $data = array();
        foreach($all_rids as $rid) {<commit_msg>updated oim > perfsonar mapping document<commit_after><?php
/*#################################################################################################

Copyright 2013 The Trustees of Indiana University

Licensed under the Apache 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.apache.org/licenses/LICENSE-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.

#################################################################################################*/

class PfmeshController extends RgpfController
{
    public static function default_title() { return "Perfsonar Mesh Config"; }
    public static function default_url($query) { return ""; }

    public function load()
    {
        $this->setpagetitle($this->default_title());
        $this->selectmenu("misc");
    }

    public function jsonAction()
    {
        ///////////////////////////////////////////////////////////////////////////////////////////
        // Step1. Load various information needed from various DBs
        //

        if(isset($_REQUEST["vo_id"])) {
            $vo_id = (int)$_REQUEST["vo_id"];

            //load vo detail
            $model = new VirtualOrganization();
            $vo = $model->get(array("vo_id"=>$vo_id));
            $vo = $vo[0];

            $mesh_desc = $vo->name;
            $mesh_id = "vo_$vo_id";

            //load all resources owned by specified vo
            $model = new VOOwnedResources();
            $vo_ros = $model->get(array("vo_id"=>$vo_id));
            $rids = array();
            foreach($vo_ros as $vo_ro) {
                $rids[] = $vo_ro->resource_id;
            } 
        } else {
            $mesh_desc = "All OSG";
            $rids = null;
            $mesh_id = "vo_all";
        }
        //error_log(print_r($rids, true));

        $mesh_admins = array(   
            array("email"=>"<EMAIL>", "name"=>"<NAME>"), 
            array("email"=>"<EMAIL>", "name"=>"OSG Grid Operations")
        );

        //for each resource, look for perfsonar services
        $model = new ServiceByResourceID();
        $rss = $model->getIndex(array("resource_ids"=>$rids));
        //error_log(print_r($rss, true));
        
        $pf_services =  array(config()->perfsonar_late_service_id, config()->perfsonar_band_service_id);
        $all_rids = array();
        $late_rids = array();//stores all resource ids that we should pull site information
        $band_rids = array();//stores all resource ids that we should pull site information
        foreach($rss as $resource_id=>$services) {
            foreach($services as $service) {
                if(in_array($resource_id, $all_rids)) continue;
                if($service->service_id == config()->perfsonar_late_service_id) {
                    $all_rids[] = $resource_id;
                    $late_rids[] = $resource_id;
                } else if($service->service_id == config()->perfsonar_band_service_id) {
                    $all_rids[] = $resource_id;
                    $band_rids[] = $resource_id;
                }
            }
        }

        //load all resource details
        $model = new ResourceServiceDetail();
        $resource_details = $model->getIndex(array("resource_ids"=>$all_rids)); 

        //lookup all relevant resources
        $model = new Resource();
        $rs = $model->getIndex(array("resource_ids"=>$all_rids, "active"=>1, "disable"=>0));

        //lookup all relevant resource groups
        $rgids = array();
        foreach($rs as $rid=>$resource) {
            $resource = $resource[0];
            //use base class function
            $rgids[] = $resource->resource_group_id;
        }

        $model = new ResourceGroup();
        $rgs = $model->getIndex(array("resource_group_ids"=>$rgids));

        //lookup all relevant sites
        $siteids = array(); 
        foreach($rgs as $rgid=>$rg) {
            $rg = $rg[0];
            $siteids[] = $rg->site_id;
        } 
        $model = new Site();
        $sites = $model->getIndex(array("site_ids"=>$siteids));

        //lookup all relevant facilities
        $facilityids = array(); 
        $scids = array(); 
        foreach($sites as $site_id=>$site) {
            $site = $site[0];
            $facilityids[] = $site->facility_id;
            $scids[] = $site->sc_id;
        } 
        $model = new Facilities();
        $facilities = $model->getIndex(array("facility_ids"=>$facilityids));
        $model = new SupportCenterContact();
        $sc_contacts = $model->getIndex(array("sc_ids"=>$scids));
        $model = new ResourceContact();
        $r_contacts = $model->getIndex(array("resource_ids"=>$all_rids));

        //$model = new ResourceAlias();
        //$resource_aliases = $model->getIndex();

        //mapping between oim and mesh config
        //oim/facility == organizations (description, admin is always goc)
        //oim/site == site (location, description)
        //oim/sc admin == site admin
        //oim/resource/service == host
        //oim/resource/admin == host_administrator

        ///////////////////////////////////////////////////////////////////////////////////////////
        // Step2. Create skelton structure and put some key components
        //
        $data = array();
        foreach($all_rids as $rid) {
{'fraction_non_alphanumeric': 0.19343941683705218, 'fraction_numerical': 0.002844697306427238, 'mean_word_length': 2.0670665212649943, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082693', 'n_tokens_mistral': 3108, 'n_tokens_neox': 2999, 'n_words': 746}