Correct default schema version value for java and php
authorymh <ymh.work@gmail.com>
Tue, 22 Sep 2015 00:03:37 +0200
changeset 540 5eaf3bd2cd90
parent 539 e54afd076ce6
child 541 05ad3a6f58e5
Correct default schema version value for java and php
server/java/renkan-core/src/main/java/org/iri_research/renkan/Constants.java
server/php/basic/resources/library/constants.php
server/php/basic/resources/library/renkanFunctions.php
--- a/server/java/renkan-core/src/main/java/org/iri_research/renkan/Constants.java	Sat Sep 19 13:43:17 2015 +0200
+++ b/server/java/renkan-core/src/main/java/org/iri_research/renkan/Constants.java	Tue Sep 22 00:03:37 2015 +0200
@@ -18,7 +18,7 @@
     public final static String ANONYMOUS_USER_BASE_NAME = "Anonymous";
 
     public final static String UNKNOWN_SCHEMA_VERSION = "1";
-    public final static String SCHEMA_VERSION = "1";
+    public final static String SCHEMA_VERSION = "2";
 
     private final static EthernetAddress ETHERNET_ADRESS = EthernetAddress
             .fromInterface();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/php/basic/resources/library/constants.php	Tue Sep 22 00:03:37 2015 +0200
@@ -0,0 +1,3 @@
+<?php
+
+define('RENKAN_SCHEMA_VERSION', '2');
--- a/server/php/basic/resources/library/renkanFunctions.php	Sat Sep 19 13:43:17 2015 +0200
+++ b/server/php/basic/resources/library/renkanFunctions.php	Tue Sep 22 00:03:37 2015 +0200
@@ -1,60 +1,62 @@
 <?php
 
-    require_once("utilsFunctions.php");
-    require_once("dbFunctions.php");
+require_once("constants.php");
+require_once("utilsFunctions.php");
+require_once("dbFunctions.php");
 
-    function getRenkan($renkanId) {
+function getRenkan($renkanId) {
+
+    $resRenkan = selectProject($renkanId);
 
-        $resRenkan = selectProject($renkanId);
+    header('Content-Type: application/json');
+    echo($resRenkan[0]['renkan']);
+    die();
+
+}
 
-        header('Content-Type: application/json');
-        echo($resRenkan[0]['renkan']);
-        die();
+function saveRenkan($renkanId, $renkanStr) {
 
+    $renkanJson = json_decode($renkanStr, true);
+    if(array_key_exists("title", $renkanJson)) {
+        $title = $renkanJson["title"];
+    }
+    else {
+        $title = "";
     }
 
-    function saveRenkan($renkanId, $renkanStr) {
-
-        $renkanJson = json_decode($renkanStr, true);
-        if(array_key_exists("title", $renkanJson)) {
-            $title = $renkanJson["title"];
-        }
-        else {
-            $title = "";
-        }
-
-        $res = updateProject($renkanId, $title, $renkanStr);
+    $res = updateProject($renkanId, $title, $renkanStr);
 
 
-        //TODO: return error when fail.
-        http_response_code(200);
-        echo("RES:");
-        print_r($res);
-        die();
+    //TODO: return error when fail.
+    http_response_code(200);
+    echo("RES:");
+    print_r($res);
+    die();
 
+}
+
+function emptyRenkan($title, $description, $renkanId = NULL) {
+    if(is_null($renkanId) || trim($renkanId) === '' ) {
+        $renkanId = genUuid4();
     }
 
-    function emptyRenkan($title, $description, $renkanId = NULL) {
-        if(is_null($renkanId) || trim($renkanId) === '' ) {
-            $renkanId = genUuid4();
-        }
-
-        $now = new DateTime('NOW');
+    $now = new DateTime('NOW');
 
-        $renkan_array = [
-            'id' => $renkanId,
-            'title' => $title,
-            'description' => $description,
-            'uri' => NULL,
-            'color' => NULL,
-            'created' => $now->format("c"),
-            'updated' => $now->format("c"),
-            'nodes' => [],
-            'edges' => [],
-            'users' => [],
-            'views' => []
-        ];
+    $renkan_array = [
+        'id' => $renkanId,
+        'title' => $title,
+        'description' => $description,
+        'uri' => NULL,
+        'color' => NULL,
+        'created' => $now->format("c"),
+        'updated' => $now->format("c"),
+        'schema_version' => RENKAN_SCHEMA_VERSION,
+        'nodes' => [],
+        'edges' => [],
+        'users' => [],
+        'views' => []
+    ];
 
-        return json_encode($renkan_array);
+    return json_encode($renkan_array);
 
-    }
+}