Просмотр исходного кода

added field SystemObjectField.isLocal

Piotr Labudda 9 лет назад
Родитель
Сommit
d6018ec45e

+ 1 - 1
SE/se-lib/Route/Install.php

@@ -21,7 +21,7 @@ class Route_Install extends RouteBase {
 		UI::dol();
 	}
 
-	private function menu() {
+	public function menu() {
 		$serversList = $this->fetchActiveLicences();
 		?>
 <div class="jumbotron">

+ 5 - 1
SE/se-lib/Route/Storage.php

@@ -694,12 +694,15 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 			$namespace = V::get('namespace', '', $_GET);
 			if (empty($namespace)) throw new Exception("Missing param namespace");
 			$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
-			DBG::nicePrint($item, '$item');
 			usort($item['field'], function ($a, $b) {
 				if ($a['fieldNamespace'] > $b['fieldNamespace']) return 1;
 				if ($a['fieldNamespace'] < $b['fieldNamespace']) return -1;
 				return 0;
 			});
+			echo UI::h('a', [
+				'href' => $this->getLink('objectReinstall', ['namespace' => $item['namespace']]),
+				'class' => 'btn btn-link pull-right'
+			], "reinstall object");
 			echo ($item['idZasob'] > 0)
 				? UI::h('h3', [], "Nr zasobu {$item['idZasob']}")
 				: UI::h('h3', [], [
@@ -761,6 +764,7 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 					window.location.reload()
 				}
 			");
+			DBG::nicePrint($item, '$item');
 		} catch (Exception $e) {
 			UI::alert('danger', "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage());
 			DBG::log($e);

+ 22 - 45
SE/se-lib/Schema/SystemObjectFieldStorageAcl.php

@@ -23,6 +23,7 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
       'maxOccurs' => [ '@type' => 'xsd:string' ], //  '0..unbounded',
       'isActive' => [ '@type' => 'xsd:integer' ], // installed
       'description' => [ '@type' => 'xsd:string' ],
+      'isLocal' => [ '@type' => 'xsd:integer', '@comment' => "is in _rootTableName" ],
       // 'A_RECORD_CREATE_AUTHOR' => [ '@type' => 'xsd:string' , '@label' => 'autor' ],
       // 'A_RECORD_CREATE_DATE' => [ '@type' => 'xsd:date' , '@label' => 'utworzono' ],
       // 'A_RECORD_UPDATE_AUTHOR' => [ '@type' => 'xsd:string' , '@label' => 'zaktualizował' ],
@@ -51,6 +52,7 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
         `maxOccurs` varchar(11) DEFAULT '1' COMMENT '0..unbounded',
         `isActive` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'installed',
         `description` varchar(255) DEFAULT '',
+        `isLocal` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is in _rootTableName',
         UNIQUE KEY `idZasob` (idZasob),
         PRIMARY KEY (`namespace`),
         KEY `isActive` (isActive)
@@ -61,6 +63,11 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
     } catch (Exception $e) {
       DBG::log($e);
     }
+    try {
+      DB::getPDO()->execSql(" ALTER TABLE `{$this->_rootTableName}` ADD `isLocal` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is in _rootTableName' AFTER `description` ");
+    } catch (Exception $e) {
+      DBG::log($e);
+    }
     // DB::getPDO()->execSql(" drop table if exists `{$this->_rootTableName}_enum` ");// TODO: DBG
     DB::getPDO()->execSql("
       create table if not exists `{$this->_rootTableName}_enum` (
@@ -92,6 +99,21 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
     //   'namespace' => $item['namespace'],
     //   'isStructInstalled' => 1
     // ]);
+    $dbName = DB::getPDO()->getDatabaseName();
+    DB::getPDO()->execSql("
+      update `{$this->_rootTableName}` t
+      set t.isLocal = IF(
+        ( select c.COLUMN_NAME
+          from information_schema.COLUMNS c
+          where c.COLUMN_NAME = t.fieldNamespace
+            and c.TABLE_SCHEMA = '{$dbName}'
+            and c.TABLE_NAME = '{$objectItem['_rootTableName']}'
+          limit 1
+        ) is null
+        , 0, 1)
+      where t.objectNamespace = '{$objectItem['namespace']}'
+        and t._rootTableName = '{$objectItem['_rootTableName']}'
+    ");
   }
 
   public function updateCacheAntAcl($item) {
@@ -99,51 +121,6 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 		$antAclPath = APP_PATH_SCHEMA . DS . 'ant-object' . DS . str_replace(['__x3A__', ':'], ['.', '/'], $item['typeName']);
 		if (!file_exists("{$antAclPath}/build.xml")) throw new Exception("Ant build file not exists");
 
-		// if (file_exists("{$antAclPath}/{$item['name']}.xsd")) {
-		// 	DBG::log("{$antAclPath}/{$item['name']}.xsd", 'string', 'xsd file exists');
-		// 	$outputType = 'XML';
-		// 	$antOutput = file_get_contents("{$antAclPath}/{$item['name']}.xsd");
-		// } else {
-		// 	DBG::log($antAclPath, 'string', '$antAclPath');
-		// 	$antBin = APP_PATH_WWW . DS . 'stuff' . DS . 'dita-ot-2.3.3' . DS . 'bin' . DS . 'ant';
-		// 	$cmd = "cd {$antAclPath} && {$antBin} DescribeFeatureType 2>&1";
-		// 	V::exec($cmd, $out, $ret);
-		// 	DBG::log($out, 'array', "DescribeFeatureType ret({$ret})");
-		// 	$outputType = 'XML';
-		// 	$antOutput = []; $startRead = false;
-		// 	foreach ($out as $line) {
-		// 		// $line = "     [echo] OUTPUT__TYPE__XML"
-		// 		if ('[echo]' == substr(trim($line), 0, 6)) {
-		// 			$line = trim(substr(trim($line), 7));
-		// 		}
-    //
-		// 		if (!$startRead) {
-		// 			if ('OUTPUT__TYPE__XML' == $line) $outputType = 'XML';
-		// 			if ('OUTPUT__TYPE__HTML' == $line) $outputType = 'HTML';
-		// 			if ('OUTPUT__START' == $line) {
-		// 				$startRead = true;
-		// 				continue;
-		// 			}
-		// 		} else {
-		// 			if ('<!DOCTYPE' == substr($line, 0, strlen('<!DOCTYPE'))) continue;
-		// 			if ('OUTPUT__END' == $line) {
-		// 				break;
-		// 			}
-		// 			$antOutput[]= $line;
-		// 		}
-		// 	}
-		// 	if (!empty($antOutput)) $antOutput = implode("\n", $antOutput);
-		// }
-		// if (empty($antOutput)) UI::alert('danger', "Empty output!");
-		// else {
-		// 	echo UI::h('p', [], "Ant Schema:");
-		// 	if ('XML' == $outputType) {
-		// 		echo UI::h('pre', ['style' => 'max-height:400px; overflow:scroll'], htmlspecialchars($antOutput));
-		// 	} else if ('HTML' == $outputType) {
-		// 		echo UI::h('div', ['class'=>"container", 'style'=>"padding:12px; border:1px solid #ddd"], $antOutput);
-		// 	}
-		// }
-
 		Lib::loadClass('XML');
 		$schema = XML::readXmlFileToArray("{$antAclPath}/{$item['name']}.xsd");
 		if (empty($schema)) throw new Exception("Missing schema file for '{$item['namespace']}'");