added the field reference to fks(which were related only for tables, before)

Esse commit está contido em:
Felipe Nascimento de Moura
2011-03-17 01:02:10 -03:00
commit b8159b9c79
20 arquivos alterados com 194 adições e 97 exclusões
Arquivo binário não exibido.

Depois

Largura:  |  Altura:  |  Tamanho: 1.2 KiB

+14 -6
Ver Arquivo
@@ -1,7 +1,5 @@
<script src='scripts/jquery.js'></script>
<body>
<pre><div id='result' style='white-space:pre;'></div></pre>
<br/>
<input type='button' value='autenticate' onclick="autenticate()"/>
<input type='button' value='run test' onclick="runTest()"/>
<input type='button' value='run info' onclick="runInfo()"/>
@@ -10,9 +8,16 @@
<input type='button' value='analyze project x' onclick="analyzeX()"/>
<input type='button' value='analyze project y' onclick="analyzeY()"/>
<input type='button' value='logoff' onclick="logoff()"/>
<pre><div id='result' style='white-space:pre;'></div></pre>
</body>
<script>
function setLoading()
{
document.getElementById('result').innerHTML= "<img src='gif-loading.gif' />";
}
function autenticate(){
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -28,6 +33,7 @@
}
function runTest()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -42,6 +48,7 @@
}
function runInfo()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -56,6 +63,7 @@
function showProjects()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -72,6 +80,7 @@
function showUsers()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -88,7 +97,7 @@
function analyzeX()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -98,7 +107,6 @@
name:'x'
},
success: function(ret){
document.getElementById('result').innerHTML= "";
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -115,7 +123,7 @@
function analyzeY()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -125,7 +133,6 @@
name:'y'
},
success: function(ret){
document.getElementById('result').innerHTML= "";
$.ajax({
type:'POST',
url:'http://localhost/mind/',
@@ -142,6 +149,7 @@
function logoff()
{
setLoading();
$.ajax({
type:'POST',
url:'http://localhost/mind/',
-4
Ver Arquivo
@@ -8,10 +8,6 @@
* mind, in your console
*/
/**
* @var _MIND
* @global mixed $_GLOBALS['_MIND'] This variable contains many information about the proect, the system and also have some methods an attributes to deal with such data
*/
$_MIND= Array();
$_MIND['env']= 'shell';
+2 -1
Ver Arquivo
@@ -46,7 +46,8 @@ class En {
$this->messages['currentProjectRequiredTip']= "You can use the command\n use project <projectName>\n";
$this->messages['analyseFirst'] = "You will need to analyze the project. It has not been analyzed yet.Execute the 'analyze' command.\n";
$this->messages['permissionDenied'] = Mind::message("Permission denied to change/create/delete files.\nPlease, allow the system to change files in mind's root directory", '[Fail]', false);;
$this->messages['additionalCounterCol'] = "This field was automatically added to allow an insertion of a new tuple using repeated values for the other keys.";
$this->messages['http_invalid_requisition'] = <<<MESSAGE
Invalid HTTP requisition.
You *must* send some POST data acoording your request, and also a variable "program" by post, with the name of the program you want to run.
+1
Ver Arquivo
@@ -53,6 +53,7 @@ class pt {
$this->messages['analyseFirst'] = "Você precisará analisar o projeto, primeiro. O projeto ainda não foi analizado. Execute o comando 'analyze'.\n";
$this->messages['sourceFileNotFound'] = Mind::message("O arquivo fonte '%s' não foi encontrado para o projeto atual.", '[Fail]', false);
$this->messages['permissionDenied'] = Mind::message("Permissão negada pra acessar, criar, alterar ou excluir um arquivo.\nPor favor, libere acesso ao sistema para o diretório raíz do Mind.\n", '[Fail]', false);
$this->messages['additionalCounterCol'] = "Campo adicionado automaticamente, a ser usado como diferencial para cada tupla, a fim de possibilizar um novo registro utilizando as mesmas demais chaves.";
$this->messages['http_invalid_requisition'] = <<<MESSAGE
Requisição HTTP inválida.
+17
Ver Arquivo
@@ -12,6 +12,7 @@
public $relevance= 0;
public $properties= Array();
public $relations= Array();
public $linkTable= false;
private $refTo= Array();
private $refBy= Array();
@@ -19,6 +20,10 @@
{
return $this->refTo;
}
public function &getRefBy()
{
return $this->refBy;
}
/**
* Verifies if the definition describes an entity or not
@@ -60,6 +65,18 @@
return isset($this->properties[$propName]);
}
/**
* Removes a property from the current entity
*
* @param string $propName
* @return boolean
*/
public function removeProperty($propName)
{
if(isset($this->properties[$propName]))
unset($this->properties[$propName]);
}
/**
* Defines another entity pointed/refered by this entity
* @param MindEntity $ref
+15 -10
Ver Arquivo
@@ -64,6 +64,7 @@ class MindProject extends VersionManager{
*/
public static function openProject($p)
{
GLOBAL $_REQ;
$_SESSION['currentProject']= $p['pk_project'];
$_SESSION['currentProjectName']= $p['name'];
$_SESSION['currentProjectDir']= Mind::$projectsDir.$p['name'];
@@ -80,18 +81,21 @@ class MindProject extends VersionManager{
$path= Mind::$currentProject['path']."/temp/";
$entities= $path."entities~";
$relations= $path."relations~";
if(file_exists($entities) && $f= fopen($entities, 'r'))
if($_REQ['env']=='shell')
{
while (($buffer = fgets($f, 51200)) !== false)
if(file_exists($entities) && $f= fopen($entities, 'r'))
{
if($tmpObj= @unserialize($buffer))
Analyst::$entities[$tmpObj->name]= $tmpObj;
}
$f= fopen($relations, 'r');
while (($buffer = fgets($f, 51200)) !== false)
{
if($tmpObj= @unserialize($buffer))
Analyst::$relations[$tmpObj->name]= $tmpObj;
while (($buffer = fgets($f, 51200)) !== false)
{
if($tmpObj= @unserialize($buffer))
Analyst::$entities[$tmpObj->name]= $tmpObj;
}
$f= fopen($relations, 'r');
while (($buffer = fgets($f, 51200)) !== false)
{
if($tmpObj= @unserialize($buffer))
Analyst::$relations[$tmpObj->name]= $tmpObj;
}
}
}
@@ -175,6 +179,7 @@ class MindProject extends VersionManager{
// do NOT print it if you have MANY entities, the webbrowser freezes
//print_r(Analyst::getUniverse());
echo Analyst::printWhatYouGet();
echo "--------------------\n";
echo "Time: ".
MindTimer::getElapsedTime().
"s\n";
+3 -2
Ver Arquivo
@@ -17,10 +17,11 @@
public $refTo = false;
public $refBy = Array();
public $key = false;
public $comment = false;
public function setRefTo(MindEntity $entity)
public function setRefTo(MindEntity $entity, MindProperty $prop)
{
$this->refTo= $entity;
$this->refTo= Array($entity, $prop);
}
/**
+13 -2
Ver Arquivo
@@ -63,7 +63,13 @@ class Analyst extends Analysis {
$rel->focus->relevance--;
}
if($rel->rel)
{
$rel->focus->removeRefTo($rel->rel->name);
$rel->focus->removeRefBy($rel->rel->name);
$rel->rel->removeRefTo($rel->focus->name);
$rel->rel->removeRefBy($rel->focus->name);
$rel->rel->relations[$rel->name]= false;
}
unset(self::$relations[$rel->name]);
}
@@ -132,8 +138,13 @@ class Analyst extends Analysis {
"(".
implode(", ", $details).
")".
($prop->refTo? " => ".$prop->refTo->name: "").
"\n";
($prop->refTo? " => ". $prop->refTo[0]->name.
".".
$prop->refTo[1]->name
: "");
if($prop->comment)
echo "// ".$prop->comment;
echo "\n";
}
}
}
+86 -19
Ver Arquivo
@@ -131,6 +131,8 @@
$linkTable= new MindEntity($relName);
Analyst::$entities[$linkTable->name]= $linkTable;
}
Analyst::$entities[$linkTable->name]->linkTable= Array($rel->focus->name,
$rel->rel->name);
return Analyst::$entities[$linkTable->name];
}
@@ -191,25 +193,90 @@
{
GLOBAL $_MIND;
$fkPrefix= $_MIND->defaults['fk_prefix'];
$pkPrefix= $_MIND->defaults['pk_prefix'];
foreach(Analyst::$relations as &$relation)
{
$propName= $fkPrefix.$relation->focus->name;
$entity= &$relation->rel;
if(!$entity->hasProperty($propName))
$pointed= $relation->focus;
foreach($pointed->pks as &$pk)
{
$fk= new MindProperty();
$fk ->setName($propName)
->setRequired(true)
//->setAsKey()
->setType('int')
->setRefTo($relation->focus);
if($relation->uniqueRef)
$fk->setAsKey();
$entity->addProperty($fk);
}else{
$entity ->properties[$propName]
->setRefTo($relation->focus);
}
$propName= $fkPrefix.preg_replace("/^".$pkPrefix."/",
'',
$pk->name);
$entity= &$relation->rel;
if($entity->linkTable)
{
$pkToRemove= $pkPrefix.$entity->name;
if($entity->hasProperty($pkToRemove))
$entity->removeProperty($pkToRemove);
$refTo= $entity->getRefTo();
if(
(
!in_array($pointed->name, $entity->linkTable)
&&
$relation->max == QUANTIFIER_MAX_MAX
)
)
{
$p= new MindProperty();
$p ->setName($_MIND->defaults['counter_col'])
->setRequired(true)
->setType('int')
->comment= Mind::$l10n->getMessage('additionalCounterCol');
$entity->addProperty($p);
}
}elseif($pointed->linkTable &&
$relation->max == QUANTIFIER_MAX_MIN)
{
echo $pointed->name." - ".$entity->name."\n";
}
/*if($pointed->linkTable)
{
if($relation->max == QUANTIFIER_MAX_MIN)
{
echo $pointed->name." <<< ".$entity->name."\n";
$fkToRemove= $fkPrefix.$pointed->name;
echo $fkToRemove."\n";
if($entity->hasProperty($fkToRemove))
$entity->removeProperty($fkToRemove);
}
$refTo= $pointed->getRefTo();
if(!in_array($pointed->name, $pointed->linkTable) &&
$relation->max == QUANTIFIER_MAX_MAX)
{
$p= new MindProperty();
$p ->setName($_MIND->defaults['counter_col'])
->setRequired(true)
->setType('int')
->comment= Mind::$l10n->getMessage('additionalCounterCol');
$pointed->addProperty($p);
}
}*/
if(!$entity->hasProperty($propName))
{
$fk= new MindProperty();
$fk ->setName($propName)
->setRequired(true)
//->setAsKey()
->setType('int')
->setRefTo($relation->focus, $pk);
if($relation->uniqueRef)
$fk->setAsKey();
$entity->addProperty($fk);
}else{
$entity ->properties[$propName]
->setRefTo($relation->focus, $pk);
if($relation->uniqueRef)
$entity ->properties[$propName]->setAsKey();
}
}
}
}
@@ -222,7 +289,7 @@
$pkPrefix= $_MIND->defaults['pk_prefix'];
foreach(Analyst::$entities as &$entity)
{
if( sizeof($entity->properties) == 0
if( sizeof($entity->pks) == 0
||
sizeof($entity->properties) != sizeof($entity->pks))
{
@@ -235,7 +302,7 @@
->setDefault(AUTOINCREMENT_DEFVAL)
->setRequired(true)
->setType('int');
$entity->addProperty($pk, true);
$entity->addProperty($pk);
}else{
$entity->properties[$propName]->setAsKey();
}
@@ -252,8 +319,8 @@
Analyst::$entities= array_filter(Analyst::$entities);
Analyst::$relations= array_filter(Analyst::$relations);
self::addFks();
self::addPks();
self::addFks();
}
/**
-1
Ver Arquivo
@@ -7,7 +7,6 @@
* the program you want to execute, and the parameters you want
* to pass
*/
header('Content-type: text/html; charset=utf-8');
if(!isset($_REQ))
{
+3
Ver Arquivo
@@ -38,7 +38,10 @@ class Inflect implements \inflection
static $singular = array(
'/rs$/' => 'r',
'/ies$/' => 'y',
'/sses$/' => 'ss', // for classes, for example
'/ses$/' => 'se', // for cases, for example
'/shes$/' => 'sh',
'/ss$/' => 'ss',
'/s$/' => ''
);
/*
+16
Ver Arquivo
@@ -1,3 +1,19 @@
<?php
// setting the general helperSet
$helperSet= false;
$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet();
$app->setHelperSet($helperSet);
if(isset($_SERVER['argv']))
{
$params= $_SERVER['argv'];
array_shift($params);
}
/* let's load the plugins, if they are allowed */
Mind::$triggers= array_keys($app->getCommands());
$sh= new Symfony\Component\Console\Shell($app);
$sh->run();
+20 -26
Ver Arquivo
@@ -9,35 +9,12 @@
require(_MINDSRC_.'/mind3rd/API/utils/header.php');
include(_MINDSRC_.'/mind3rd/API/utils/constants.php');
$app= new Symfony\Component\Console\Application('mind');
$app->addCommands(Array(
new RunTest(),
new Quit(),
new Auth(),
new Clear(),
new Info(),
new Create(),
new Show(),
new Analyze(),
new SetUse()
));
// setting the general helperSet
$helperSet= false;
$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet();
$app->setHelperSet($helperSet);
if(isset($_SERVER['argv']))
{
$params= $_SERVER['argv'];
array_shift($params);
}
// Instantiating the main Mind class
/**
* @global Mind $_MIND This variable contains many information about the proect, the system and also have some methods an attributes to deal with such data
*/
$_MIND= new Mind();
/* let's load the plugins, if they are allowed */
Mind::$triggers= array_keys($app->getCommands());
if($_MIND->defaults['plugins']==1)
{
require(_MINDSRC_.'/mind3rd/API/interfaces/plugin.php');
@@ -53,6 +30,23 @@
$d->close();
}
define('SYSTEM_NAME', 'mind');
$app= new Symfony\Component\Console\Application(SYSTEM_NAME);
$app->addCommands(Array(
new RunTest(),
new Quit(),
new Auth(),
new Clear(),
new Info(),
new Create(),
new Show(),
new Analyze(),
new SetUse()
));
if($_REQ['env']=='shell')
include('shell.php');
else
+4 -1
Ver Arquivo
@@ -31,4 +31,7 @@ pk_prefix="pk_"
; add the pk_prefix to properties that were defined as key, manuyally?
add_pk_prefix_to_all_keys=on
; default identifier of foreign key properties
fk_prefix="fk_"
fk_prefix="fk_"
; this will be the name of the additional column on tables which require a
; new column to enumerate multiple PrimaryKeys
counter_col="counter"
-25
Ver Arquivo
@@ -1,25 +0,0 @@
; This file will be used by mind3rd due to generate
; the structure or even code for it
;
; First, let's inform mind3rd about what you want
; to use in your application
;
; The idiom is the human language you want to use
idiom=pt-br
; The technology you specify here, will be used as
; the backend of your application
; this will be the name of the model you want to apply
; to your app, of course, it depends on the models
; you've got installed
technology=php-zf
; You will need to configure your database
; the module you choose will probably try to implement
; some PDO drivers, so, put the one you want, here
database_drive=pgsql
; now, the ip address or host name
database_addr=localhost
; then, the port
database_port=5432
; and here, the user and password
database_user=root
dataase_pwd=root
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
Ver Arquivo
Arquivo normal → Arquivo executável
Ver Arquivo