Error::report("Rollback job '{$jobName}' did not complete after {$limit} seconds.", "Please browse to the job details page to inspect why the job hasn't completed.");
    }
    $outcome = $result->get("outcome");
    if ($outcome != "success") {
        Data::$queries["getJobFailureReason"] = array("request" => "getProperty", "constantArgs" => array("propertyName", "/jobs/{$jobId}/failureReason"), "result" => "property");
        $result = QueryManager::handleQueryNow("getJobFailureReason");
        Error::formError($result->get("value"), "projectName");
    }
    $targetUrl = "projects.php";
    header("Location: " . $targetUrl);
}
Data::$queries[1] = array("request" => "getProperty", "constantArgs" => array("propertyName", "/projects/{$projectName}/ec_versioning_artifact"), "result" => "property");
$response = QueryManager::handleQueryNow(1);
$artifactKey = $response->get('value');
Data::$queries["getPickerVersions"] = array("request" => "findObjects", 'searchName' => 'getArtifactVersions', "numObjects" => 10000, "constantArgs" => array("sort", array("propertyName", "version", "order", "descending")), 'constantFilters' => array(array("operator", "and", "filter", array(array('propertyName' => 'groupId', 'operator' => 'equals', "operand1" => 'VersionedProjects'), array('propertyName' => 'artifactKey', 'operator' => 'equals', 'operand1' => $artifactKey)))), "queryClass" => "searchQuery", "result" => 'artifactVersion', "dataIn" => 'searchDataIn');
$response = QueryManager::handleQueryNow('getPickerVersions');
$options = array();
$i = 0;
foreach ($response->getSiblings() as $object) {
    if ($i > 0) {
        $version = $object->get("version");
        $comment = $object->get("description");
        $createTime = DateTimeRenderer::formatText($object->get("createTime"));
        if ($comment == "") {
            $comment = "No commit comment";
        }
        $options[] = $version;
        $options[] = "v{$version} [{$createTime}] - {$comment}";
    }
    $i++;
}
$timestamp2 = '';
if (isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
    $timestamp = getBoundaryTimestamp($_REQUEST['timestamp']);
}
// forece using JSONP by default
$use_jsonp = true;
// option to return JSON, instead of jsonp
if (isset($_REQUEST['forcejson']) && $_REQUEST['forcejson'] == 1) {
    $use_jsonp = false;
}
// set use latest available by default -- TMH 2012/10/31
$useLatestDataWhenFail = 1;
if (isset($_REQUEST['latest']) && $_REQUEST['latest'] == 1) {
    $useLatestDataWhenFail = 1;
}
$queryManager = new QueryManager();
// if timestamp is empty, try to find the latest using txn table
if (empty($timestamp)) {
    if ($useLatestDataWhenFail == 1) {
        $timestamp = $queryManager->latestGridAvailableTime();
    } else {
        if ($requestType == 'json') {
            sendJsonResponse(array(), $timestamp, $timestamp2, "No timestamp specified");
            exit(0);
        } else {
            echo "<pre># Error: no timesamp specified</pre>\n";
            exit(1);
        }
    }
}
$timestamp2 = $timestamp;
예제 #3
0
 function html($record)
 {
     $projectName = $record->get("description");
     $key = $record->get("artifactKey");
     Data::$queries[1] = array("request" => "getProperties", "constantArgs" => array("path", "/artifacts/VersionedProjects:{$key}"), "result" => "propertySheet");
     $response = QueryManager::handleQueryNow(1);
     $problem = $response->get('//property[propertyName="ec_versioning_problem"]/value');
     if ($problem) {
         return "";
     }
     $deleteUrl = "plugins/@PLUGIN_KEY@/deleteProject.php";
     Data::$links["deleteVersionedProject"] = array("text" => ecgettext("Delete"), "base" => $deleteUrl . "?projectName=%%1&artifactKey=%%2", "args" => array(), "confirm" => array("heading" => ecgettext("Delete project \"%%1\"?"), "details" => ecgettext("Click OK to delete the project and all versioning history. " . "WARNING: This cannot be undone."), "buttons" => array(ecgettext("OK") => "%s", ecgettext("Cancel") => ""), "args" => array("description", "artifactKey")));
     $link = new Link("deleteVersionedProject");
     return $link->html($record);
 }
$driverTime = microtime(true) - $driverStart;
$queryTime = 0;
$gridTime = 0;
$contourTime = 0;
// query based on timestamp
$readOnly = false;
// disable gzip -- TMH 2012/07/13
$useGzip = false;
// pad with JSONP -- TMH 2012/07/20
$useJSONP = true;
// keep history -- TMH 2012/08/31
$keepHistory = false;
// grid Updated time
$updatedTime = -1;
$phpStart = microtime(true);
$queryManager = new QueryManager($readOnly);
$contourDataStore = new ContourCacheHelper($useGzip, $bandHelper->getSchemeId());
$phpTime = microtime(true) - $phpStart;
// Check if $txnAt for $timestamp is older than specified right now,
// then only proceed. Otherwise just exit from here
// Honour force flag if is set
$lastTxnAt = $txnAt;
if ($txnAt >= 0) {
    $lastTxnAt = $queryManager->getGridUpdatedTime($timestamp);
}
if ($txnAt >= 0 && $lastTxnAt >= $txnAt) {
    echo "Grid last updated with txn stamp [{$lastTxnAt}]," . " more recent than / equal to [{$txnAt}]\n";
    echo "Use force write if it was intended to forcefully update data";
    exit(0);
}
$midTime = microtime(true);
예제 #5
0
 public function __construct()
 {
     self::$Connect = Connect::getInstance(DB_NAME, DB_HOST, DB_USER, DB_PASS);
     $this->query = isset($this->query) ? $this->query : null;
 }
    if (strtolower($_REQUEST['type']) == 'json') {
        $requestType = 'json';
    } elseif (strtolower($_REQUEST['type']) == 'html') {
        $requestType = 'html';
    }
}
$callback = '';
if (!empty($_REQUEST['callback'])) {
    $callback = $_REQUEST['callback'];
}
$bandSchema = 0;
if (!empty($_REQUEST['bandschema'])) {
    $bandSchema = intval($_REQUEST['bandschema']);
}
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$queryManager = new QueryManager();
//db connected.. do remaining stuff
$ozoneData = array();
if (!empty($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
    $timestamp = $_REQUEST['timestamp'];
    $month = date('m', $timestamp);
    $day = date('d', $timestamp);
    $year = date('Y', $timestamp);
    $hour = date('H', $timestamp);
    $min = date('i', $timestamp);
    $min = intval($min) - intval($min) % 5;
    $timestamp = mktime($hour, $min, 0, $month, $day, $year);
}
$ozoneData = $queryManager->getOzoneForTimestamp($timestamp);
if (count($ozoneData) > 0) {
    $timestamp = $ozoneData[0][0];
    $i = 0;
    while (1) {
        $result = QueryManager::handleQueryNow("getJobInfo");
        if ($i == $limit || $result->get("status") == "completed") {
            break;
        }
        sleep(1);
        $i++;
    }
    $jobId = $result->get("jobId");
    $jobName = $result->get("jobName");
    $status = $result->get("status");
    if ($status != "completed") {
        Error::report("Commit job '{$jobName}' did not complete after {$limit} seconds.", "Please browse to the job details page to inspect why the job hasn't completed.");
    }
    $outcome = $result->get("outcome");
    if ($outcome != "success") {
        Data::$queries["getJobFailureReason"] = array("request" => "getProperty", "constantArgs" => array("propertyName", "/jobs/{$jobId}/failureReason"), "result" => "property");
        $result = QueryManager::handleQueryNow("getJobFailureReason");
        Error::formError($result->get("value"), "projectName");
    }
    $targetUrl = "projects.php";
    header("Location: " . $targetUrl);
}
$name = new Name(null, true);
$name->setInitialValue($projectName);
$formElements = array(ecgettext("Name:"), "projectName", $name, ecgettext("Comment:"), "comment", new Entry());
$formArgs = array("id" => "commitVersionedProject", "modifyName" => "projectName", "postArgs" => array(), "elements" => $formElements);
$navigation = new NavInfo(array("section" => ecgettext("Projects"), "subsection" => ecgettext("Versioning")));
$page = new Page(ecgettext("Commit Versioned Project"), new StdFrame($navigation), new Header(array("id" => "pageHeader", "class" => "pageHeader", "title" => ecgettext("Commit Versioned Project"), "actions" => array(new ShortcutLink()), "actionStyle" => 3)), new SubSection(new Form($formArgs)), new SetFocus("comment"), new StdFrameEnd());
$page->show();
$errMsg = '';
// if argument parameters empty, just redirect to index
if (empty($argv)) {
    header("Location:/test/ozonemaps/");
    exit(0);
}
date_default_timezone_set("America/Chicago");
// central time
include_once 'nebula/QueryManager.php';
if (isset($argv[1]) && isset($argv[2]) && is_numeric($argv[1]) && is_numeric($argv[2])) {
    $month = intval($argv[1]);
    $year = intval($argv[2]);
    $monthDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
} else {
    $year = date('Y');
    $month = date('m');
    $monthDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
}
$monthStartEpoch = mktime(0, 0, 0, $month, 1, $year);
// month values 1,2,3..
$monthEndEpoch = mktime(23, 59, 59, $month, $monthDays, $year);
echo "Timestamps: {$monthStartEpoch} {$monthEndEpoch}";
$queryManager = new QueryManager();
$allData = $queryManager->getMonthlyAvg($monthStartEpoch, $monthEndEpoch);
if ($allData === false) {
    echo $queryManager->getLastError() . "\n";
    exit(0);
}
for ($i = 0; $i < count($allData['ozoneStations']); $i++) {
    echo $allData['ozoneStations'][$i][0] . ',' . $allData['ozoneStations'][$i][1] . ',' . $allData['ozoneValues'][0][$i] . "\n";
}
    $use_flat = intval($_REQUEST['flat']);
}
// Request parsing is completed.. Act according to what has been requested
if ($requestType == 'json' && empty($pointsOfInterest)) {
    sendJsonResponse(array(), $timestamp, $timestamp2, "No latlon specified in request");
    exit(0);
}
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$ozoneBand = $bandHelper->getBand();
//$bandHashMap = new Java("java.util.HashMap");
//foreach($ozoneBand as $key => $val) {
//    $bandHashMap->put($key, doubleval($val));
//}
// latest generated time
$latest_gen_time = -1;
$queryManager = new QueryManager();
$start = microtime(true);
$grid = array();
$queryTime = 0;
//$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap);
for ($t = $timestamp; $t <= $timestamp2; $t += $interval) {
    $queryStart = microtime(true);
    if ($use_flat) {
        $loadedData = $queryManager->getPointData_from_json($t, $pointsOfInterest);
        if (!empty($loadedData)) {
            if ($loadedData[0]['gen_time'] > $latest_gen_time) {
                $latest_gen_time = $loadedData[0]['gen_time'];
            }
        }
    } else {
        $loadedData = $queryManager->getPointData($t, $pointsOfInterest, $gridReference);
$bandSchema = 0;
if (!empty($_REQUEST['bandschema'])) {
    $bandSchema = intval($_REQUEST['bandschema']);
}
// Request parsing is completed.. Act according to what has been requested
if ($requestType == 'json' && empty($pointsOfInterest)) {
    sendJsonResponse(array(), $timestamp, $timestamp2, "No latlon specified in request");
    exit(0);
}
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$ozoneBand = $bandHelper->getBand();
$bandHashMap = new Java("java.util.HashMap");
foreach ($ozoneBand as $key => $val) {
    $bandHashMap->put($key, doubleval($val));
}
$queryManager = new QueryManager();
$start = microtime(true);
$grid = array();
$queryTime = 0;
$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap);
for ($t = $timestamp; $t <= $timestamp2; $t += $interval) {
    $queryStart = microtime(true);
    $loadedData = $queryManager->getPointData($t, $pointsOfInterest, $gridReference);
    $queryTime += microtime(true) - $queryStart;
    if (!empty($loadedData)) {
        $latlngData = array();
        // count($pointsOfInterest) should be same as count($loadedData)
        for ($i = 0; $i < count($pointsOfInterest); $i++) {
            $labelId = $bandHelper->getLabelId($loadedData[$i]['o3']);
            $gridPoint = $loadedData[$i]['lat'] . ':' . $loadedData[$i]['lng'];
            $latlngData[] = array('label_id' => $labelId, 'lat' => $pointsOfInterest[$i][0], 'lng' => $pointsOfInterest[$i][1], 'attr' => array('ozone_level' => $loadedData[$i]['o3'], 'exp' => $loadedData[$i]['exp'], 'gridpoint' => "{$gridPoint}"));
#!/usr/bin/php
<?php 
// if argument parameters empty, just redirect to index
if (empty($argv)) {
    header("Location:/test/ozonemaps/");
    exit(0);
} elseif (count($argv) != 2) {
    echo "Usage: " . $argv[0] . " <epoch>\n";
    exit(0);
}
date_default_timezone_set("America/Chicago");
// central time
include_once 'nebula/QueryManager.php';
$queryManager = new QueryManager();
$timestamp = $argv[1];
if (is_numeric($timestamp)) {
    $month = date('m', $timestamp);
    $day = date('d', $timestamp);
    $year = date('Y', $timestamp);
    $hour = date('H', $timestamp);
    $min = date('i', $timestamp);
    $min = intval($min) - intval($min) % 5;
    $timestamp = mktime($hour, $min, 0, $month, $day, $year);
} else {
    echo "Numeric timestamp expected\n";
    exit(0);
}
$allData = $queryManager->getDataForWindBasedInterpolation($timestamp, 6);
$spc = "    ";
// ozoneStations test data
echo "{$spc}public double[][] ozoneStationTestData() {\n";
}
$bandScheme = 0;
$start = microtime(true);
$grid = array();
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandScheme);
$ozoneBand = $bandHelper->getBand();
$bandHashMap = new Java("java.util.HashMap");
foreach ($ozoneBand as $key => $val) {
    $bandHashMap->put($key, doubleval($val));
}
$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap);
$driver->setWriteDebugImages(false);
$queryTime = 0;
// query based on timestamp
$readOnly = true;
$queryManager = new QueryManager($readOnly);
$queryStart = microtime(true);
$trailPoints = 6;
$allData = $queryManager->getDataForWindBasedInterpolation($timestamp, $trailPoints);
if (empty($allData['ozoneValues'])) {
    echo "No data available for interpolation algorithm for {$timestamp}\n";
    exit(0);
}
$queryTime += microtime(true) - $queryStart;
// Interpolate grid by skipping one station at a time and check for delta
$li = count($allData['ozoneValues']) - 1;
$diff = array();
for ($st = 0; $st < count($allData['ozoneStations']); $st++) {
    // copy data
    $omitStation = $allData['ozoneStations'][$st];
    $omitO3Value = $allData['ozoneValues'][$li][$st];
$monthStartEpoch = 0;
$monthEndEpoch = 0;
$monthDays = 0;
if (!empty($_REQUEST['month']) && !empty($_REQUEST['year']) && is_numeric($_REQUEST['month']) && is_numeric($_REQUEST['year'])) {
    $year = intval($_REQUEST['year']);
    $month = intval($_REQUEST['month']);
    $monthDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
} else {
    $year = date('Y');
    $month = date('m');
    $monthDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
}
$monthStartEpoch = mktime(0, 0, 0, $month, 1, $year);
// month values 1,2,3..
$monthEndEpoch = mktime(23, 59, 59, $month, $monthDays, $year);
$queryManager = new QueryManager();
$allData = $queryManager->getMonthlyAvg($monthStartEpoch, $monthEndEpoch);
$bandSchema = 4;
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$ozoneBand = $bandHelper->getBand();
$bandHashMap = new Java("java.util.HashMap");
foreach ($ozoneBand as $key => $val) {
    $bandHashMap->put($key, doubleval($val));
}
$start = microtime(true);
$outFile = '';
$queryTime = 0;
$outFile = '/tmp/binaryout.png';
$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap);
$r = $driver->getContours($allData['ozoneStations'], $allData['windStations'], $allData['ozoneValues'], $allData['windSpeed'], $allData['windDirection'], $stepSize);
$responseObject = prepareResponseObject(java_values($r), $monthStartEpoch);
예제 #14
0
<?php

header('Content-type: application/json');
$METHOD = $_SERVER['REQUEST_METHOD'];
$APIURI = $_SERVER['REQUEST_URI'];
if ($METHOD == 'POST') {
    //decodificamos la información recibida desde el formulario de login
    $json = file_get_contents('php://input');
    $obj = json_decode($json, true);
    require 'QueryManager.php';
    //logueamos al usuario
    $loginManager = new LoginManager();
    $loginManager->login($obj);
    //según el tipo de usuario logueado, se realizan diferentes operaciones
    switch ($_SESSION["userType"]) {
        case 'UgTuNHEQEZ':
            die("No tenés permisos para utilizar esta aplicación.");
            break;
        case 'o8hdPDhJDE':
            header("Location:Administrador.php");
            break;
        default:
            $queryManager = new QueryManager();
            $queryManager->query();
            break;
    }
} else {
    header('HTTP/1.1 405 Method Not Allowed');
    header('Allow: POST');
}
if (!empty($_REQUEST['callback'])) {
    $callback = preg_replace('/[^][._a-zA-Z0-9]/', '', $_REQUEST['callback']);
}
$bandSchema = 0;
if (!empty($_REQUEST['bandschema'])) {
    $bandSchema = intval($_REQUEST['bandschema']);
}
// forece using JSONP by default
$use_jsonp = true;
// option to return JSON, instead of jsonp
if (isset($_REQUEST['forcejson']) && $_REQUEST['forcejson'] == 1) {
    $use_jsonp = false;
}
//$useGzip = true;
$useGzip = false;
$queryManager = new QueryManager();
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$contourDataStore = new ContourCacheHelper($useGzip, $bandHelper->getSchemeId());
$ozoneBand = $bandHelper->getBand();
//$bandHashMap = new Java("java.util.HashMap");
//foreach($ozoneBand as $key => $val) {
//    $bandHashMap->put($key, doubleval($val));
//}
$timestamp = '';
if (isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
    $timestamp = $_REQUEST['timestamp'];
    $month = date('m', $timestamp);
    $day = date('d', $timestamp);
    $year = date('Y', $timestamp);
    $hour = date('H', $timestamp);
    $min = date('i', $timestamp);
include_once 'nebula/DiscreteBandHelper.php';
include_once 'nebula/ResponseHelper.php';
if (isset($_REQUEST['step']) && is_numeric($_REQUEST['step'])) {
    $stepSize = doubleval($_REQUEST['step']);
}
$callback = '';
if (!empty($_REQUEST['callback'])) {
    $callback = preg_replace('/[^][._a-zA-Z0-9]/', '', $_REQUEST['callback']);
}
$bandSchema = 0;
if (!empty($_REQUEST['bandschema'])) {
    $bandSchema = intval($_REQUEST['bandschema']);
}
//$useGzip = true;
$useGzip = false;
$queryManager = new QueryManager();
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$contourDataStore = new ContourCacheHelper($useGzip, $bandHelper->getSchemeId());
$ozoneBand = $bandHelper->getBand();
$bandHashMap = new Java("java.util.HashMap");
foreach ($ozoneBand as $key => $val) {
    $bandHashMap->put($key, doubleval($val));
}
$timestamp = '';
if (isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
    $timestamp = $_REQUEST['timestamp'];
    $month = date('m', $timestamp);
    $day = date('d', $timestamp);
    $year = date('Y', $timestamp);
    $hour = date('H', $timestamp);
    $min = date('i', $timestamp);