Jelajahi Sumber

added @primaryKey to simpleSchema

Piotr Labudda 9 tahun lalu
induk
melakukan
d1d4abde16
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 7 2
      SE/se-lib/Core/AclSimpleSchemaBase.php

+ 7 - 2
SE/se-lib/Core/AclSimpleSchemaBase.php

@@ -15,6 +15,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
     $simpleSchema = [
       'root' => [
         '@namespace' => 'default_db/ZALICZKA/Zaliczka',
+        '@primaryKey' => 'ID',
 
         'ID' => 'xsd:integer', // short syntax - define only simpleType
 
@@ -43,6 +44,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
   public $_xsdTypes = null;// set by parseXsdTypes()
   public $_name = '';
   public $_namespace = '';
+  public $_primaryKey = '';
   public $_rootTableName = '';
   public $_sourceNamespace = '';
   public $_xmlnsMap = [];
@@ -66,6 +68,9 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
       $this->_sourceNamespace = implode('__x3A__', $this->_sourceNamespace);
     }
 
+    if (empty($this->_simpleSchema['root']['@primaryKey'])) $this->_simpleSchema['root']['@primaryKey'] = 'ID';// TODO: throw new Exception("Missing @primaryKey in simpleSchema");
+    $this->_primaryKey = $this->_simpleSchema['root']['@primaryKey'];// TODO: check if field exists
+
     {// validate and fix _simpleSchema:
       // - convert field scalar to [ '@type' => ... ]
       // - check required @namespace attribute
@@ -224,7 +229,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
       if ($fieldName == $field['name']) return $field;
     }
     return null;
-	}
+  }
 
   // TODO: replace legacy functions: isAllowed, hasFieldPerm, getFieldIdByName
   public function canCreateField($fieldName) { return false; }// TODO: perms from Procesy
@@ -241,7 +246,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
   public function updateItem($itemPatch) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
 
   public function getGeomFieldType($fieldName) { return null; }
-  public function getPrimaryKeyField() { return 'ID'; }
+  public function getPrimaryKeyField() { return $this->_primaryKey; }
   public function getID() { return 0; }
   public function getAttributesFromZasoby() { return array(); }
   public function isEnumerationField($fieldName) { return false; }