search fixes
search fixes

--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,7 @@
 [submodule "lib/bubbletree"]
 	path = lib/bubbletree
 	url = https://github.com/okfn/bubbletree.git
+[submodule "lib/amon-php"]
+	path = lib/amon-php
+	url = https://github.com/martinrusev/amon-php.git
 

--- a/admin/neo4jimporter/src/main/java/Importer.java
+++ b/admin/neo4jimporter/src/main/java/Importer.java
@@ -79,8 +79,7 @@
             // Execute the query
             ResultSet rs = stmt.executeQuery("SELECT contractnotice.\"agencyName\", "
                     + "  contractnotice.\"supplierABN\",contractnotice.\"supplierName\",sum(value) as sum "
-                    + "FROM  public.contractnotice where contractnotice.\"agencyName\" != 'Department of Defence'"
-                    + " AND contractnotice.\"agencyName\" != 'Defence Materiel Organisation' GROUP BY contractnotice.\"agencyName\", "
+                    + "FROM  public.contractnotice  GROUP BY contractnotice.\"agencyName\", "
                     + "  contractnotice.\"supplierABN\",contractnotice.\"supplierName\"");
             String previousAgency = "";
             GraphDatabaseService gds = inserter.getGraphDbService();

--- a/displayContract.php
+++ b/displayContract.php
@@ -18,28 +18,58 @@
 } else {

 $description = ucsmart($contractResult["description"]);

 include_header($description);

- echo '<center><h1>'.$description.'</h1></center>';

+ echo '<center><h1>'.$description.'</h1></center>

+     <div about="http://contracts.disclosurelo.gs/displayContract.php?CNID='.$contractResult["CNID"].'" typeof="pc:Contract">';

 databaseError($conn->errorInfo());

     setlocale(LC_MONETARY, 'en_US');

     foreach (array_filter($contractResult) as $key => $value) {

         echo "<b>$key</b>&nbsp;";

         switch ($key) {

+            case "supplierABN":

+            break;

             case "supplierName":

-            case "supplierABN":

-                echo '<a href="displaySupplier.php?supplier=' . $contractResult['supplierABN'] . '-' . urlencode($contractResult['supplierName']) . '">' . $value . "</a>";

+                echo '

+                    <a href="displaySupplier.php?supplier=' . $contractResult['supplierABN'] . '-' . urlencode($contractResult['supplierName']) . '">

+                        <span rel="pc:contractingAuthority" typeof="gr:BusinessEntity">

+                        <span property="gr:legalName">' 

+                    . $contractResult['supplierName'] . 

+                    '</span>'.

+                    (isset($contractResult['supplierABN']) && $contractResult['supplierABN'] != '' ? ' (ABN: <span property="br:officialNumber" lang="">'.$contractResult['supplierABN'].'</span>)' : '')

+                        .'</span></a>';

+                break;

+            case "CNID":

+                echo '<span property="pc:referenceNumber" lang="">'.$value.'</span>';

+                break;

+            case "categoryUNSPSC":

+                break;

+            case "category":

+                echo '<span rel="pc:mainObject" resource="[unspsc:'.$contractResult["categoryUNSPSC"].']">'.$value.'</span>';

                 break;

             case "agencyName":

                 echo '<a href="displayAgency.php?agency=' . urlencode($value) . '">' . $value . "</a>";

                 break;

+            case "contractStart":

+                echo '<span property="pc:startDate" content="'.$value.'" datatype="xsd:date">'.$value.'</span>';

+                break;

+            case "contractEnd":

+                echo '<span property="pc:endDate" content="'.$value.'" datatype="xsd:date">'.$value.'</span>';

+                break;

             case "value":

-                echo "$" . number_format(doubleval($value), 2);

+                echo '<span rel="pc:agreedPrice" typeof="gr:PriceSpecification">

+                     <span property="gr:hasCurrency" content="AUD" lang="">$ </span>

+                     <span property="gr:hasCurrencyValue" content="'.doubleval($value).'" datatype="xsd:float">' . number_format(doubleval($value), 2)

+                    .'</span></span>';

                 break;

+            case "description":

+                echo '<span property="dcterms:title">'.$value.'</span>';

             default:

                 echo str_replace("  ", "<br>", ucsmart($value));

         }

-        echo "<br>";

+        echo "<br>\n";

     }

-echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN' . $_REQUEST['CNID'] . '"> View original record @ tenders.gov.au</a><br>';

+echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN' . $_REQUEST['CNID'] . '"> View original record @ tenders.gov.au</a><br>

+    

+</div>';

 

 

 $query = 'SELECT * FROM heuristic_results where "CNID" = :CNID';


directory:b/lib/amon-php (new)
--- /dev/null
+++ b/lib/amon-php

--- a/lib/common.inc.php
+++ b/lib/common.inc.php
@@ -14,6 +14,11 @@
 if (strstr($_SERVER['PHP_SELF'], "labs/")) {

     $basePath = "../";

 }

+require $basePath."/lib/amon-php/amon.php";

+Amon::config(array('address'=> 'http://127.0.0.1:2465', 

+		'protocol' => 'http', 

+		'secret_key' => "g99127n3lkzigg8ob2rllth97d1pb4sj"));

+Amon::setup_exception_handler();

 

 require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php';

 $openid = new LightOpenID($_SERVER['HTTP_HOST']);

@@ -49,6 +54,7 @@
 function databaseError($errMsg) {

     if ($errMsg[2] != "") {

         echo '<div class="alert-message error">';

+        Amon::log(print_r($errMsg, true), array('error'));

         die(print_r($errMsg, true));

         echo "</div>";

     }

@@ -113,9 +119,28 @@
 function include_header($title) {

     global $start;

     ?>

-    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  

-        "http://www.w3.org/TR/html4/strict.dtd"> 

-    <html>

+    <!DOCTYPE html>

+    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" version="XHTML+RDFa 1.1"

+       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

+       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"

+       xmlns:gr="http://purl.org/goodrelations/v1#"

+       xmlns:dc="http://purl.org/dc/terms/"

+       xmlns:pc="http://purl.org/procurement#"

+       xmlns:unspsc="http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml#"

+       xmlns:xsd="http://www.w3.org/2001/XMLSchema#"

+       xmlns:pcdt="http://purl.org/procurement/public-contracts-datatypes#"

+        prefix="rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# 

+              rdfs: http://www.w3.org/2000/01/rdf-schema# 

+              gr: http://purl.org/goodrelations/v1# 

+              dcterms: http://purl.org/dc/terms/ 

+              pc: http://purl.org/procurement/public-contracts# 

+              cpv: http://purl.org/weso/pscs/cpv/2008/resource/ 

+              unspsc: http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml#

+              v: http://www.w3.org/2006/vcard/ns# 

+              payment: http://reference.data.gov.uk/def/payment# 

+              br: http://purl.org/business-register#              

+              xsd: http://www.w3.org/2001/XMLSchema# 

+              pcdt: http://purl.org/procurement/public-contracts-datatypes#">

         <head>

             <title><?php echo $title; ?> - Contract Dashboard</title>

             <link rel="stylesheet" type="text/css" href="bootstrap.min.css"> 


--- a/search_autosuggest.php
+++ b/search_autosuggest.php
@@ -47,7 +47,7 @@
         );
     }
         $query = "SELECT \"CNID\", description, value FROM contractnotice
-WHERE to_tsvector('english', description) @@ to_tsquery('english', :input)";
+WHERE to_tsvector('english', description) @@ plaintoto_tsquery('english', :input)";
     $query = $conn->prepare($query);
     $agencyName = $input . '%';
     $query->bindParam(":input", $input);