|
@@ -1,34 +1,135 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * SE/schema/ant-object/default_db.{rootTableName}/{name}/build.xml
|
|
|
|
|
- */
|
|
|
|
|
|
|
+* SE/schema/ant-object/default_db.{rootTableName}/{name}/build.xml
|
|
|
|
|
+*/
|
|
|
class AntAclBase extends Core_AclBase {
|
|
class AntAclBase extends Core_AclBase {
|
|
|
|
|
|
|
|
- public $_zasobID = '';
|
|
|
|
|
- public $_rootTableName = '';
|
|
|
|
|
-
|
|
|
|
|
public function __construct($zasobID = 0) {
|
|
public function __construct($zasobID = 0) {
|
|
|
$this->_zasobID = $zasobID;
|
|
$this->_zasobID = $zasobID;
|
|
|
|
|
+ $this->_name = '';
|
|
|
|
|
+ $this->_namespace = '';
|
|
|
|
|
+ $this->_rootTableName = '';
|
|
|
|
|
+ $this->_primaryKey = '';
|
|
|
|
|
+ $this->_fields = [];
|
|
|
}
|
|
}
|
|
|
public function getName() { return $this->_name; }
|
|
public function getName() { return $this->_name; }
|
|
|
- public function getNamespace() { return 'default_db/' . $this->getName(); }
|
|
|
|
|
- public function getSourceName() { return 'default_db'; }
|
|
|
|
|
|
|
+ public function getNamespace() { return $this->_namespace; }
|
|
|
|
|
+ public function getSourceName() { return 'default_db'; } // TODO: ?
|
|
|
public function getRootTableName() { $this->_rootTableName; }
|
|
public function getRootTableName() { $this->_rootTableName; }
|
|
|
|
|
+ public function getPrimaryKeyField() { $this->_primaryKey; }
|
|
|
|
|
+ public function getRealFieldListByIdZasob() {
|
|
|
|
|
+ $cols = array();
|
|
|
|
|
+ $fakeZasobId = 1000000;
|
|
|
|
|
+ foreach ($this->getFields() as $field) {
|
|
|
|
|
+ $idZasobField = ($field['idZasob']) ? $field['idZasob'] : $fakeZasobId++;
|
|
|
|
|
+ $cols[$idZasobField] = $field['fieldNamespace'];
|
|
|
|
|
+ }
|
|
|
|
|
+ return $cols;
|
|
|
|
|
+ }
|
|
|
|
|
+ public function getXsdFieldType($fieldName) {
|
|
|
|
|
+ $field = $this->_getField($fieldName);
|
|
|
|
|
+ return $field['xsdType'];
|
|
|
|
|
+ }
|
|
|
|
|
+ public function getXsdMaxOccurs($fieldName) {
|
|
|
|
|
+ $field = $this->_getField($fieldName);
|
|
|
|
|
+ return $field['maxOccurs'];
|
|
|
|
|
+ }
|
|
|
|
|
+ public function getXsdMinOccurs($fieldName) {
|
|
|
|
|
+ $field = $this->_getField($fieldName);
|
|
|
|
|
+ return $field['minOccurs'];
|
|
|
|
|
+ }
|
|
|
|
|
+ public function getAttributesFromZasoby() {
|
|
|
|
|
+ return [];// TODO: ...
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function isEnumerationField($fieldName) {
|
|
|
|
|
+ return false; // TODO: ...
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function canWriteField($fieldName) {
|
|
|
|
|
+ return false; // TODO: return $this->getPerms($fieldName)->canWrite()
|
|
|
|
|
+ }
|
|
|
|
|
+ public function canCreateField($fieldName) {
|
|
|
|
|
+ return false; // TODO: return $this->getPerms($fieldName)->canCreate()
|
|
|
|
|
+ }
|
|
|
|
|
+ public function canReadField($fieldName) {
|
|
|
|
|
+ return true; // TODO: return $this->getPerms($fieldName)->canRead()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getFields() {
|
|
|
|
|
+ if (empty($this->_fields)) {
|
|
|
|
|
+ // TODO: fetch fields from DB
|
|
|
|
|
+ // Lib::loadClass('SchemaFactory');
|
|
|
|
|
+ // $objectStorage = SchemaFactory::loadDefaultObject('SystemObject');
|
|
|
|
|
+ // $item = $objectStorage->getItem($namespace, [
|
|
|
|
|
+ // 'propertyName' => '*,field'
|
|
|
|
|
+ // ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->_fields;
|
|
|
|
|
+ }
|
|
|
|
|
+ public function _getField($fieldName) {
|
|
|
|
|
+ foreach ($this->getFields() as $field) {
|
|
|
|
|
+ if ($fieldName === $field['fieldNamespace']) return $field;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new Exception("Field not found '{$this->_namespace}/{$fieldName}'");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public static function buildInstance($idZasob, $conf = []) {
|
|
public static function buildInstance($idZasob, $conf = []) {
|
|
|
static $_cache;
|
|
static $_cache;
|
|
|
- if (!$_cache) $_cache = array();
|
|
|
|
|
- if (array_key_exists($idZasob, $_cache)) {
|
|
|
|
|
- return $_cache[$idZasob];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (empty($conf)) throw new Exception("Brak danych konfiguracyjnych do obiektu ant nr {$idZasob}");
|
|
|
|
|
- DBG::nicePrint($conf, 'AntAclBase::buildInstance $conf');
|
|
|
|
|
- $_cache[$idZasob] = new AntAclBase($idZasob);
|
|
|
|
|
- // TODO: define field by conf
|
|
|
|
|
- // TODO: $this->_rootTableName - from namespace
|
|
|
|
|
- // TODO: need file path
|
|
|
|
|
|
|
+ if (!$_cache) $_cache = array();
|
|
|
|
|
+ if (array_key_exists($idZasob, $_cache)) {
|
|
|
|
|
+ return $_cache[$idZasob];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($conf)) {
|
|
|
|
|
+ throw new Exception("Brak danych konfiguracyjnych do obiektu ant nr {$idZasob}");
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: fetch conf by $idZasob (or find $namespace first)
|
|
|
|
|
+ // Lib::loadClass('SchemaFactory');
|
|
|
|
|
+ // $objectStorage = SchemaFactory::loadDefaultObject('SystemObject');
|
|
|
|
|
+ // $item = $objectStorage->getItem($namespace, [
|
|
|
|
|
+ // 'propertyName' => '*,field'
|
|
|
|
|
+ // ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ DBG::log($conf, 'array', 'AntAclBase::buildInstance $conf');
|
|
|
|
|
+ $acl = new AntAclBase($idZasob);
|
|
|
|
|
+ $acl->_name = $conf['name'];
|
|
|
|
|
+ $acl->_rootTableName = $conf['_rootTableName'];
|
|
|
|
|
+ $acl->_namespace = $conf['namespace'];
|
|
|
|
|
+ $acl->_fields = $conf['field']; // TODO: lazyLoading - use getFields() in all functions
|
|
|
|
|
+ $acl->_primaryKey = $conf['primaryKey'];
|
|
|
|
|
+
|
|
|
|
|
+ // 'idZasob' => '25872',
|
|
|
|
|
+ // 'idDatabase' => '36',
|
|
|
|
|
+ // 'namespace' => 'default_db/CRM_PROCES/CRM_PROCES',
|
|
|
|
|
+ // '_rootTableName' => 'CRM_PROCES',
|
|
|
|
|
+ // '_type' => 'AntAcl',
|
|
|
|
|
+ // 'isActive' => '1',
|
|
|
|
|
+ // 'isStructInstalled' => '1',
|
|
|
|
|
+ // 'description' => '',
|
|
|
|
|
+ // 'name' => 'CRM_PROCES',
|
|
|
|
|
+ // 'nsPrefix' => 'default_db__x3A__CRM_PROCES',
|
|
|
|
|
+ // 'typeName' => 'default_db__x3A__CRM_PROCES:CRM_PROCES',
|
|
|
|
|
+ // 'reinstallLink' => 'https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=Storage&_task=objectReinstall&namespace=default_db/CRM_PROCES/CRM_PROCES',
|
|
|
|
|
+ // 'field' => [
|
|
|
|
|
+ // 0 => [
|
|
|
|
|
+ // 'namespace' => 'default_db/CRM_PROCES/CRM_PROCES/ID',
|
|
|
|
|
+ // 'fieldNamespace' => 'ID',
|
|
|
|
|
+ // 'idZasob' => NULL,
|
|
|
|
|
+ // 'idDatabase' => '36',
|
|
|
|
|
+ // '_rootTableName' => 'CRM_PROCES',
|
|
|
|
|
+ // 'objectNamespace' => 'default_db/CRM_PROCES/CRM_PROCES',
|
|
|
|
|
+ // 'xsdType' => 'xsd:int',
|
|
|
|
|
+ // 'xsdRestrictions' => '[]',
|
|
|
|
|
+ // 'appInfo' => '[]',
|
|
|
|
|
+ // 'minOccurs' => '0',
|
|
|
|
|
+ // 'maxOccurs' => '1',
|
|
|
|
|
+ // 'isActive' => '1',
|
|
|
|
|
+ // 'description' => '',
|
|
|
|
|
+ // ),
|
|
|
|
|
+
|
|
|
|
|
+ $_cache[$idZasob] = $acl;
|
|
|
return $_cache[$idZasob];
|
|
return $_cache[$idZasob];
|
|
|
}
|
|
}
|
|
|
|
|
|