<?php | <?php |
require_once '../include/common.inc.php'; | require_once '../include/common.inc.php'; |
$db = $server->get_db('disclosr-agencies'); | $db = $server->get_db('disclosr-agencies'); |
$rows = $db->get_view("app", "byName")->rows; | $rows = $db->get_view("app", "byName")->rows; |
$nametoid = Array(); | $nametoid = Array(); |
$stats = Array(); | $stats = Array(); |
foreach ($rows as $row) { | foreach ($rows as $row) { |
$nametoid[trim($row->key)] = $row->value; | $nametoid[trim($row->key)] = $row->value; |
} | } |
$row = 0; | $row = 0; |
$headers = Array(); | $headers = Array(); |
// source: http://data.gov.au/dataset/freedom-of-information-quarterly-request-and-review-statistical-data-2011-12/ | // source: http://data.gov.au/dataset/freedom-of-information-quarterly-request-and-review-statistical-data-2011-12/ |
if (($handle = fopen("FOI-quarterly-requests-and-reviews-2011-12.csv", "r")) !== FALSE) { | if (($handle = fopen("FOI-quarterly-requests-and-reviews-2011-12.csv", "r")) !== FALSE) { |
while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) { | while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) { |
if ($row >= 1) { | if ($row >= 1) { |
// print_r($data); | // print_r($data); |
$name = trim($data[2]); | $name = trim($data[2]); |
echo "$name <br>"; | // echo "$name <br>"; |
if ($data[0] != "TOTALS" && $data[0] != "") { | if ($data[0] != "TOTALS" && $data[0] != "") { |
if (isset($nametoid[$name])) { | if (isset($nametoid[$name])) { |
$id = $nametoid[$name]; | $id = $nametoid[$name]; |
$timePeriod = $data[0] . "-Q" . $data[1]; | $timePeriod = $data[0] . "-Q" . $data[1]; |
echo "$timePeriod <br>"; | // echo "$timePeriod <br>"; |
unset($data[0]); | unset($data[0]); |
unset($data[1]); | unset($data[1]); |
unset($data[2]); | unset($data[2]); |
unset($data[3]); | unset($data[3]); |
unset($data[4]); | unset($data[4]); |
unset($data[5]); | unset($data[5]); |
unset($data[6]); | unset($data[6]); |
unset($data[7]); | unset($data[7]); |
unset($data[8]); | unset($data[8]); |
//echo $id . "<br>" . PHP_EOL; | //echo $id . "<br>" . PHP_EOL; |
$result = Array("source" => "http://data.gov.au/dataset/freedom-of-information-quarterly-request-and-review-statistical-data-2011-12/"); | $result = Array("source" => "http://data.gov.au/dataset/freedom-of-information-quarterly-request-and-review-statistical-data-2011-12/"); |
foreach ($data as $key => $datum) { | foreach ($data as $key => $datum) { |
if ($datum != 0) { | if ($datum != 0) { |
// tODO prefix header with "FOI" | |
if (isset($stats[$id][$timePeriod][$key])) $datum += $stats[$id][$timePeriod][$key]; | |
$result[trim($headers[$key])] = $datum; | $result[trim($headers[$key])] = $datum; |
} | } |
} | } |
$stats[$id][$timePeriod] = $result; | $stats[$id][$timePeriod] = $result; |
// TODO merge if already exists | |
//print_r($stats); | //print_r($stats); |
} else { | } else { |
echo "<br>ERROR NAME MISSING FROM ID LIST<br><bR> $row" . PHP_EOL; | echo "<br>ERROR NAME MISSING FROM ID LIST<br><bR> $row" . PHP_EOL; |
print_r($data); | print_r($data); |
die(); | die(); |
} | } |
} | } |
} else { | } else { |
$headers = $data; | $headers = $data; |
//print_r($headers); | //print_r($headers); |
} | } |
$row++; | $row++; |
} | } |
fclose($handle); | fclose($handle); |
} | } |
echo "all stats loaded successfuly"; | |
foreach ($stats as $id => $stat) { | foreach ($stats as $id => $stat) { |
echo $id . "<br>" . PHP_EOL; | echo $id . "<br>" . PHP_EOL; |
$doc = $db->get($id); | $doc = $db->get($id); |
echo $doc->name . "<br>" . PHP_EOL; | echo $doc->name . "<br>" . PHP_EOL; |
print_r($stat); | // print_r($stat); |
die(); | |
// print_r($doc); | // print_r($doc); |
$changed = false; | $changed = false; |
if (!isset($doc->statistics)) { | if (!isset($doc->statistics)) { |
$changed = true; | $changed = true; |
$doc->statistics = Array(); | $doc->statistics = Array(); |
} else { | |
$doc->statistics = object_to_array($doc->statistics); | |
} | } |
foreach ($stat as $timePeriod => $value) { | foreach ($stat as $timePeriod => $value) { |
if (!isset($doc->statistics->foiRequests->$timePeriod) | if (!isset($doc->statistics["foiRequests"][$timePeriod]) |
|| $doc->statistics->foiRequests->$timePeriod != $value) { | || $doc->statistics["foiRequests"][$timePeriod] != $value |
) { | |
$changed = true; | $changed = true; |
$doc->statistics["foiRequests"][$timePeriod] = $value; | $doc->statistics["foiRequests"][$timePeriod] = $value; |
} | } |
} | } |
if ($changed) { | if ($changed) { |
$db->save($doc); | $db->save($doc); |
} else { | } else { |
echo "not changed" . "<br>" . PHP_EOL; | echo "not changed" . "<br>" . PHP_EOL; |
} | } |
//print_r($doc);die(); | |
} | } |
?> | ?> |
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" | |
height="100px" viewBox="0 -25.635 100 100" enable-background="new 0 -25.635 100 100" xml:space="preserve"> | |
<g id="docs"> | |
<path fill="#C2A385" d="M86.108-9.909l5.229,9.952c0,0-1.832,0.083-5.297,1.95c-2.312,1.249-6.468,6.246-6.468,6.246L71.827-2.909 | |
c0,0,4.201-3.996,6.513-5.242C81.805-10.022,86.108-9.909,86.108-9.909"/> | |
<path fill="#C2A385" d="M65.604,20.731l-3.152-9.868c0,0-5.441,3.56-8.017,4.074c-1.008,0.202-1.93,0.335-2.749,0.425 | |
L65.604,20.731z"/> | |
<path fill="#C2A385" d="M72.326,23.321c0.268-0.226,0.537-0.44,0.804-0.616c3.104-2.054,6.139-3.685,6.268-3.755l1.882-1.005 | |
l1.369,1.634l2.864,3.417l3.198-4.334L76.68,9.783l-8.74,11.847L72.326,23.321z"/> | |
<path fill="#C2A385" d="M39.918,10.823l4.825,1.86l3.33,0.212c0.04,0.001,0.269,0.015,0.652,0.015c0.91,0,2.798-0.072,5.196-0.551 | |
c1.427-0.284,5.007-2.332,7.092-3.695l2.889-1.888l1.05,3.285l2.496,7.812l5.889-7.985l-4.625,0.163l1.348-6.225L55.133,0.593 | |
l-2.095,9.667c-0.531-2.599-1.841-5.727-1.841-5.727L37.709,6.055c0,0,0.885,2.206,1.586,4.529L39.918,10.823z"/> | |
<path fill="#C2A385" d="M91.233,45.562c-1.102-0.691-2.323-1.142-3.415-1.433l-3.779,9.804c1.932,1.246,5.197,5.738,5.197,5.738 | |
l7.336-9.206C96.572,50.466,93.162,46.771,91.233,45.562z"/> | |
<path fill="#C2A385" d="M93.192,32.166l-3.656,1.224c-0.019,0.007-1.779,0.613-4.117,2.069l2.817,4.868l0.626,1.08 | |
c3.306-0.562,7.727-1.922,7.727-1.922l-2.332-15.261c0,0-2.934,1.277-5.852,2.221l2.318,2.765L93.192,32.166z"/> | |
<path fill="#C2A385" d="M79.272,25.999l0.864,0.334l0.46,0.801l3.503,6.05c2.646-1.636,4.611-2.287,4.611-2.287l-8.075-9.632 | |
c0,0-2.584,1.391-5.376,3.188L79.272,25.999z"/> | |
</g> | |
<g id="trunk"> | |
<circle fill="#C00000" cx="66.019" cy="52.945" r="7.877"/> | |
<circle fill="#C00000" cx="22.693" cy="52.945" r="7.877"/> | |
<path fill="#C00000" d="M22.693,42.441c1.915,0,3.705,0.522,5.251,1.421V28.001H12.191L3,37.192v14.439h9.281 | |
C12.931,46.459,17.347,42.441,22.693,42.441z"/> | |
<path fill="#C00000" d="M55.925,50.075l-9.583-3.695H30.88c1.186,1.476,1.978,3.28,2.225,5.252h22.502 | |
C55.674,51.1,55.78,50.58,55.925,50.075z"/> | |
<path fill="#C00000" d="M79.312,28.328L39.961,13.149l-9.384,24.335l26.381,10.174c1.824-3.115,5.198-5.218,9.062-5.218 | |
c5.791,0,10.503,4.712,10.503,10.502c0,0.744-0.081,1.471-0.229,2.173l4.713,1.817L86.95,41.52L79.312,28.328z"/> | |
</g> | |
</svg> | |
for line in `curl "http://localhost:5984/disclosr-foidocuments/_design/app/_view/byAgencyID?reduce=false&keys=%5B\"5716ce0aacfe98f7d638b7a66b7f1040\"%5D&limit=600" | xargs -L1`; do | |
# echo $line | |
id=`echo $line | grep -Po '_id:.*?[^\\\],' | perl -pe 's/_id://; s/^//; s/,$//'` | |
rev=`echo $line | grep -Po 'rev:.*?[^\\\],'| perl -pe 's/rev://; s/^//; s/,$//'` | |
if [ -n "$id" ]; then | |
echo "curl -X DELETE http://localhost:5984/disclosr-foidocuments/$id?rev=$rev" | |
curl -X DELETE http://localhost:5984/disclosr-foidocuments/$id?rev=$rev | |
fi | |
done; | |
neo4jimporter |
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CompilerConfiguration"> | |
<option name="DEFAULT_COMPILER" value="Javac" /> | |
<resourceExtensions /> | |
<wildcardResourcePatterns> | |
<entry name="!?*.java" /> | |
<entry name="!?*.form" /> | |
<entry name="!?*.class" /> | |
<entry name="!?*.groovy" /> | |
<entry name="!?*.scala" /> | |
<entry name="!?*.flex" /> | |
<entry name="!?*.kt" /> | |
<entry name="!?*.clj" /> | |
</wildcardResourcePatterns> | |
<annotationProcessing> | |
<profile default="true" name="Default" enabled="false"> | |
<processorPath useClasspath="true" /> | |
</profile> | |
<profile default="false" name="Maven default annotation processors profile" enabled="true"> | |
<sourceOutputDir name="target/generated-sources/annotations" /> | |
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> | |
<outputRelativeToContentRoot value="true" /> | |
<processorPath useClasspath="true" /> | |
<module name="neo4jimporter" /> | |
</profile> | |
</annotationProcessing> | |
<bytecodeTargetLevel> | |
<module name="neo4jimporter" target="1.6" /> | |
</bytecodeTargetLevel> | |
</component> | |
</project> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
</project> | |
<component name="libraryTable"> | |
<library name="Maven: com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.3.1"> | |
<CLASSES> | |
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/concurrentlinkedhashmap/concurrentlinkedhashmap-lru/1.3.1/concurrentlinkedhashmap-lru-1.3.1.jar!/" /> | |
</CLASSES> | |
<JAVADOC> | |
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/concurrentlinkedhashmap/concurrentlinkedhashmap-lru/1.3.1/concurrentlinkedhashmap-lru-1.3.1-javadoc.jar!/" /> | |
</JAVADOC> | |
<SOURCES> | |
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/concurrentlinkedhashmap/concurrentlinkedhashmap-lru/1.3.1/concurrentlinkedhashmap-lru-1.3.1-sources.jar!/" /> | |
</SOURCES> | |
</library> | |
</component> |
<component name="libraryTable"> | |
<library name="Maven: javax.xml.stream:stax-api:1.0-2"> | |
<CLASSES> | |
<root url="jar://$MAVEN_REPOSITORY$/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" /> | |
</CLASSES> | |
<JAVADOC> | |
<root url="jar://$MAVEN_REPOSITORY$/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-javadoc.jar!/" /> | |
</JAVADOC> | |
<SOURCES> | |
<root url="jar://$MAVEN_REPOSITORY$/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar!/" /> | |
</SOURCES> | |
</library> | |
</component> |