public function formPreferences()
 {
     $user = new User($this->data->id);
     $this->data->title = $user->getLogin() . ' :: Preferences';
     $this->data->save = "@fnbr20/auth/user/savePreferences|formPreferences";
     $userLevel = $user->getUserLevel();
     if ($userLevel == 'BEGINNER') {
         $this->data->isBeginner = true;
         $this->data->idJunior = $user->getConfigData('fnbr20JuniorUser');
         $this->data->junior = $user->getUsersOfLevel('JUNIOR');
         mdump($this->data);
     }
     if ($userLevel == 'JUNIOR') {
         $this->data->isJunior = true;
         $this->data->idSenior = $user->getConfigData('fnbr20SeniorUser');
         $this->data->senior = $user->getUsersOfLevel('SENIOR');
         mdump($this->data);
     }
     if ($userLevel == 'SENIOR') {
         $this->data->isSenior = true;
         $this->data->idMaster = $user->getConfigData('fnbr20MasterUser');
         $this->data->master = $user->getUsersOfLevel('MASTER');
         mdump($this->data);
     }
     $this->data->userLevel = $userLevel;
     $this->render();
 }
Example #2
0
 public function currency()
 {
     $value = 123456.78;
     $this->data->value = 'Valor = ' . $value;
     $currency = Manager::currency($value);
     $this->data->currency = 'Currency = ' . $currency;
     $formated = $currency->format();
     $this->data->formated = 'Formatado = ' . $formated;
     $currency = Manager::currency($formated);
     $value = $currency->getValue();
     $this->data->getValue = 'Get Value = ' . $value;
     $currency->setValue(87654321.09);
     $this->data->setValue = 'Após setValue = ' . $currency;
     $currency->setValue(-654.3200000000001);
     $this->data->setValueNeg = 'Após setValue negativo = ' . $currency;
     $currency = Manager::currency('-R$ 123.345,67');
     $value = $currency->getValue();
     $this->data->valueNeg = 'Valor negativo = ' . $value;
     $valor1 = Manager::currency(10.9008900015);
     $valor2 = Manager::currency(10.9008900017);
     mdump($valor1->getValue() == $valor2->getValue() ? 'Valores iguais' : 'Valores diferentes');
     $valor1 = Manager::currency(10.9018900015);
     $valor2 = Manager::currency(10.9068900017);
     mdump($valor1->getValue() == $valor2->getValue() ? 'Valores iguais' : 'Valores diferentes');
     $this->render();
 }
Example #3
0
 public function generateFields()
 {
     $fields = '';
     $control = $this->fields;
     if ($control->hasItems()) {
         foreach ($control->controls as $field) {
             mdump($field);
             if ($field->tag == 'mhiddenfield') {
                 $fields .= $field->generate();
             } else {
                 $mfieldlabel = new mfieldlabel(['id' => $field->property->id, 'text' => $field->property->label]);
                 if ($this->property->layout == 'horizontal') {
                     //$mfieldlabel->setClass($this->labelClass);
                 }
                 $label = $mfieldlabel->generate();
                 if ($label) {
                     $formGroup = "<div class=\"mFormColumn\">{$label}</div>" . "<div class=\"mFormColumn\">{$field->generate()}</div>";
                 } else {
                     //$formGroup = "<div class=\"mFormColumn\">{$field->generate()}</div>";
                     $formGroup = "<div class=\"mFormColumn\"></div>" . "<div class=\"mFormColumn\">{$field->generate()}</div>";
                 }
                 if ($field->tag == 'mvcontainer' || $field->tag == 'mhcontainer') {
                     $fields .= "</div>";
                     $fields .= $field->generate();
                     $fields .= "<div class='mFormContainer'>";
                 } else {
                     // usa a classe form-group do bootstrap
                     $fields .= "<div class=\"mFormRow\">{$formGroup}</div>";
                 }
             }
         }
     }
     return $fields;
 }
Example #4
0
 public function generateForm()
 {
     $this->property->action = $this->property->action ?: Manager::getCurrentURL();
     \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST');
     \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%");
     $this->property->role = "form";
     $fields = $buttons = $help = $tools = "";
     $fields = $this->generateFields();
     $buttons = $this->generateButtons();
     $help = $this->generateHelp();
     if ($this->tools != NULL) {
         mdump('has tools');
         $tools = $this->generateTools();
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = PainterControl::generate($this->property->menubar);
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         PainterControl::getPage()->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         PainterControl::getPage()->onSubmit("\$('#{$this->property->id}').form('validate')", $this->property->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     //mdump($fields);
     // obtem o codigo html via template
     $inner = PainterControl::fetch('painter/formdialog', $this, ['fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'tools' => $tools, 'validators' => $validators, 'menubar' => $menubar]);
     return $inner;
 }
 public function formNewWindowPost()
 {
     $pessoa = new models\Pessoa($this->data->idPessoa);
     $pessoa->setData($this->data);
     $pessoa->save();
     $this->data->object = $pessoa->getData();
     mdump($this->data->object);
     $this->render();
 }
 public function main()
 {
     $this->data->isMaster = Manager::checkAccess('MASTER', A_EXECUTE) ? 'true' : 'false';
     $editor = MApp::getService('fnbr20', '', 'visualeditor');
     $this->data->relationData = $editor->getAllCxnRelationData();
     mdump($this->data->relationData);
     $this->data->relationEntry = json_encode($this->data->relationData);
     $this->render();
 }
Example #7
0
 public function listForLookup()
 {
     //$colorRepository = new InMemoryColorRepository();
     //$service = new QueryService($colorRepository);
     $queryService = Manager::getContainer()->get('ColorQueryService');
     $filter = (object) ['idColor' => 2];
     $list = $queryService->listForLookup();
     mdump($list);
     $this->render('formLogin');
 }
 public function formFind()
 {
     $model = new Pessoa($this->data->id);
     $this->data->object = $model->getData();
     $filter->nome = $this->data->nome . '%';
     $this->data->query = $model->listByFilter($filter)->asQuery();
     mdump($this->data->query->getResult());
     mdump($this->data->query->getColumnNames());
     $this->render();
 }
Example #9
0
 public function authenticate()
 {
     $auth = Manager::getAuth();
     $this->data->result = $auth->authenticate($this->data->user, $this->data->challenge, $this->data->response);
     if ($this->data->result) {
         mdump("++++++++++++");
         $this->redirect(Manager::getURL('dlivro/main'));
     } else {
         $this->renderPrompt('error', 'Login ou senha inválidos. Tente novamente.');
     }
 }
 function __construct()
 {
     $data = Manager::getData();
     $array = json_decode($data->gridInputExemplo3_data);
     mdump($array);
     parent::__construct('gridInputExemploGrid3', $array, null, '', 0, 1);
     $this->addActionSelect('marca3');
     $this->addColumn(new MObjectGridColumn('id', '', 'left', true, '0%', false));
     $this->addColumn(new MObjectGridColumn('codigoExemplo3', 'Código', 'left', true, '20%', true));
     $this->addColumn(new MObjectGridColumn('descricaoExemplo3', 'Descrição', 'left', true, '80%', true));
     $this->setHasForm('true');
 }
Example #11
0
 public function __construct($id, $basePath)
 {
     $this->id = $id;
     $this->basePath = $basePath;
     mdump('basepath = ' . $basePath);
     mtracestack();
     //$this->loadModules();
     $this->loadControllers();
     $this->loadServices();
     $this->loadComponents();
     $this->loadFilters();
     $this->loadModels();
     //$this->loadMaps();
 }
Example #12
0
 public function __invoke(ContainerInterface $container, RequestedEntry $entry)
 {
     $repository = $container->get('repository');
     $model = str_replace('Repository', '', $entry->getName());
     if ($repository == 'Doctrine') {
         $em = $container->get('EntityManager');
         //return new \FNBr\Infrastructure\Persistence\Doctrine\Color\DoctrineColorRepository($em);
         mdump("\\FNBr\\Domain\\Model\\{$model}\\{$model}");
         return $em->getRepository("\\FNBr\\Domain\\Model\\{$model}\\{$model}");
     } else {
         //InMemory
         return new \FNBr\Infrastructure\Persistence\InMemory\Color\InMemoryColorRepository();
     }
 }
Example #13
0
 public function listByFilter($filter)
 {
     mdump($filter);
     $criteria = $this::getCriteria()->select('idPessoa, nome, cpf, dataNascimento, email');
     if ($filter->nome) {
         $criteria->where("nome LIKE '%{$filter->nome}%'");
     }
     if ($filter->cpf) {
         $criteria->where("cpf = '{$filter->cpf}'");
     }
     if ($filter->email) {
         $criteria->where("email LIKE '{$filter->email}%'");
     }
     return $criteria;
 }
Example #14
0
 public function setContent()
 {
     mdump('Executing MRuntimeError');
     try {
         $errorHtml = $this->fetch("runtime");
         if (Manager::isAjaxCall()) {
             $this->ajax->setType('page');
             $this->ajax->setData($errorHtml);
             $this->ajax->setResponseType('JSON');
             $this->content = $this->ajax->returnData();
         } else {
             $this->content = $errorHtml;
         }
     } catch (\Maestro\Services\Exception\EMException $e) {
     }
 }
Example #15
0
 public function getMetaData($stmt)
 {
     $s = $stmt->getWrappedStatement();
     mdump('xxx');
     mdump($s->getColumnMeta(0));
     $metadata['columnCount'] = $count = $s->columnCount();
     mdump($count);
     for ($i = 0; $i < $count; $i++) {
         $meta = $s->getColumnMeta($i);
         $name = strtoupper($meta['name']);
         $metadata['fieldname'][$i] = $name;
         $metadata['fieldtype'][$name] = $this->_getMetaType($meta['pdo_type']);
         $metadata['fieldlength'][$name] = $meta['len'];
         $metadata['fieldpos'][$name] = $i;
     }
     return $metadata;
 }
Example #16
0
 /**
  * 
  * @param int $userId
  * @param string $challenge
  * @param string $response
  * @return boolean
  */
 public function validate($userId, $challenge, $response)
 {
     $user = Manager::getModelMAD('user');
     $user->getByLogin($userId);
     $login = $user->getLoginAtivo();
     mdump("Ldap validating userid = {$userId} - login ativo = {$login}");
     $filter = "uid={$login}";
     mdump("Ldap filter = {$filter}");
     $mldap = new \MLdap();
     $info = $mldap->search($filter, array('userPassword'));
     mdump($info);
     if ($info['count'] == 0) {
         return false;
     }
     $passLdap = trim($info[0]['userpassword'][0]);
     $hash_pass = md5(trim($login) . ':' . MLdap::ldapToMd5($passLdap) . ":" . $challenge);
     return $hash_pass == $response;
 }
Example #17
0
 public function show()
 {
     $file = Manager::getAppPath('public/files/controles.txt');
     $this->data->ini = parse_ini_file($file, true);
     $this->data->class = $this->data->lookupControl;
     $this->data->description = $this->data->ini[$this->data->class]['description'];
     $this->data->extends = $this->data->ini[$this->data->class]['extends'];
     $this->data->attributes = array();
     $attributes = $this->data->ini[$this->data->class]['attributes'];
     if (is_array($attributes)) {
         foreach ($attributes as $name => $description) {
             $this->data->attributes[$name]['name'] = $name;
             $this->data->attributes[$name]['class'] = $this->data->class;
             $this->data->attributes[$name]['description'] = $description;
         }
     }
     $header = $this->data->ini[$this->data->class];
     $extends = $header['extends'];
     while ($extends) {
         $parent = $this->data->ini[$extends];
         $attributes = $parent['attributes'];
         if (is_array($attributes)) {
             foreach ($attributes as $name => $description) {
                 $this->data->attributes[$name]['name'] = $name;
                 $this->data->attributes[$name]['class'] = $extends;
                 $this->data->attributes[$name]['description'] = $description;
             }
         }
         $extends = $parent['extends'];
     }
     ksort($this->data->attributes);
     $codeXML = Manager::getAppPath('public/files/code/' . strtolower($this->data->class) . '.xml');
     $this->data->code = highlight_file($codeXML, true);
     //htmlentities(file_get_contents($codeXML));
     mdump($codeXML);
     mdump($this->data->code);
     $this->render();
 }
Example #18
0
 public function loadFile($xmlFile, $context = NULL)
 {
     libxml_use_internal_errors(true);
     //        $this->root = simplexml_load_file($xmlFile, "SimpleXMLElement", LIBXML_NOCDATA);
     $this->path = pathinfo($xmlFile, PATHINFO_DIRNAME);
     //mdump('xml file = ' . $xmlFile);
     $xmlString = file_get_contents($xmlFile);
     $xmlString = utf8_encode($xmlString);
     //        mdump($xmlString);
     $this->root = simplexml_load_string($xmlString, NULL, LIBXML_NOCDATA);
     if (!$this->root) {
         $xml = explode("\n", $xmlString);
         $errors = libxml_get_errors();
         foreach ($errors as $error) {
             $e .= $this->getErrors($error, $xml);
         }
         mdump($e);
         libxml_clear_errors();
     }
     //mdump($this->root);
     $this->context = $context;
     $this->localContext = $this->context;
 }
Example #19
0
 /**
  * Operações com associações.
  */
 public function associations()
 {
     // retrieve by Id
     $this->getById(1);
     foreach ($this->getUsuarios() as $usuario) {
         $nome = $usuario->getPessoa()->getNome();
     }
     // adiciona um usuário existente a um setor
     $usuario = new Usuario(1);
     $usuario->setIdPessoa(3);
     $usuario->setLogin('Novo Login');
     $usuario->setPassword('123456');
     $this->getUsuarios()->append($usuario);
     $this->saveAssociation('usuarios');
     // contagem de usuários em um setor
     $n = $this->getUsuarios()->count();
     // Salva associação com base no id dos usuários
     $idUsuario = array(1, 3, 5, 6);
     $this->saveAssociation('usuarios', $idUsuario);
     mdump('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++');
     $this->deleteAssociationById('usuarios', $idUsuario);
     mdump('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++');
 }
 /**
  * Upload de sentenças de construções, em arquivo texto simples (uma sentença por linha).
  * Parâmetro data informa: idConstruction, subCorpus e idLanguage
  * @param type $data
  * @param type $file 
  */
 public function uploadCxnSimpleText($data, $file)
 {
     $subCorpus = $data->subCorpus;
     $idLanguage = $data->idLanguage;
     $transaction = $this->beginTransaction();
     $subCorpus = $this->createSubCorpusCxn($data);
     $document = new Document();
     $document->getbyEntry('not_informed');
     try {
         $sentenceNum = 0;
         $rows = file($file->getTmpName());
         foreach ($rows as $row) {
             $row = preg_replace('/#([0-9]*)/', '', $row);
             $row = trim($row);
             if ($row[0] != '#' && $row[0] != ' ' && $row[0] != '') {
                 $row = str_replace('&', 'e', $row);
                 $row = str_replace(' < ', '  <  ', $row);
                 $row = str_replace(' > ', '  >  ', $row);
                 $row = str_replace(array('$.', '$,', '$:', '$;', '$!', '$?', '$(', '$)', '$\'', '$"', '$--', "’", "“", "”"), array('.', ',', ':', ';', '!', '?', '(', ')', '\'', '"', '--', '\'', '"', '"'), $row);
                 $replace = [' .' => ".", ' ,' => ',', ' ;' => ';', ' :' => ':', ' !' => '!', ' ?' => '?', ' >' => '>'];
                 $search = array_keys($replace);
                 $sentence = str_replace($search, $replace, $row);
                 mdump($sentence);
                 $text = $sentence;
                 $sentenceNum += 1;
                 $paragraph = $document->createParagraph();
                 $sentenceObj = $document->createSentence($paragraph, $sentenceNum, $text, $idLanguage);
                 $data->idSentence = $sentenceObj->getId();
                 $subCorpus->createAnnotationCxn($data);
             }
         }
         $transaction->commit();
     } catch (\EModelException $e) {
         // rollback da transação em caso de algum erro
         $transaction->rollback();
         throw new EModelException($e->getMessage());
     }
     return $result;
 }
Example #21
0
 /**
  * CRUD operations.
  */
 public function methods()
 {
     // retrieve by Id
     $this->getById(1);
     // lazy load
     $nome = $this->getPessoa()->getNome();
     mdump('nome = ' . $nome);
     // update
     $this->setLogin('Novo Login');
     $this->setPassword('123456');
     $this->save();
     // cria novo usuario com os mesmos dados
     $this->setPersistent(false);
     $this->setIdusuario(NULL);
     $this->save();
     // obtem o id do novo objeto
     $id = $this->getId();
     // delete
     $this->delete();
 }
Example #22
0
 private function getContent($controller, $view, $parameters = NULL)
 {
     $app = $this->getApplication();
     $section = $this->getSection();
     mdump('*********' . Manager::$controllers[$section][$controller][0]);
     $loader = Manager::$container->get('loader');
     $fileController = $loader->findFile(Manager::$controllers[$section][$controller][0]);
     $base = dirname(dirname($fileController)) . DIRECTORY_SEPARATOR . 'Views';
     mdump($base);
     $path = DIRECTORY_SEPARATOR . $controller . DIRECTORY_SEPARATOR . $view;
     $extensions = ['.xml', '.php', '.html', '.js', '.wiki'];
     foreach ($extensions as $extension) {
         $fileName = $base . $path . $extension;
         mtrace('MController::getContent ' . $fileName);
         if (file_exists($fileName)) {
             return $this->renderView($controller, $fileName, $parameters);
         }
     }
 }
Example #23
0
 /**
  * Extrai um certificado em formato PEM a partir de uma assinatura.
  * 
  * @return mixed
  */
 public static function extractCertificateFromSignature($signature)
 {
     $answer = null;
     $result = 1;
     $filePrefix = self::createFilename();
     $certFilePath = $filePrefix . '.pkcs7';
     $signatureFilePath = $filePrefix . '.sig';
     file_put_contents($signatureFilePath, $signature);
     exec("openssl pkcs7 -in {$signatureFilePath} -inform PEM -print_certs -out {$certFilePath}", $answer, $result);
     if ($result == 0) {
         $fileContent = file_get_contents($certFilePath);
         unlink($certFilePath);
         $certificate = self::extractTopCertificate($fileContent);
     } else {
         mdump("Erro: não foi possivel extrair o certificado à partir da assinatura.");
         $certificate = null;
     }
     unlink($signatureFilePath);
     return $certificate;
 }
 public function formDGridData()
 {
     $pessoa = new models\Pessoa($this->data->id);
     $this->data->object = $pessoa->getData();
     $filter->nome = $this->data->nome;
     if ($this->data->count) {
         $query = $pessoa->listByFilter($filter)->asQuery();
         $query->setRange($this->data->start / $this->data->count, $this->data->count);
         $json = $query->asJSON('nome,idPessoa,dataNascimento,ativo');
         mdump($json);
     } else {
         $json = "[]";
     }
     $this->renderJson($json);
 }
    public function listElement2ElementRelation($elements1, $elements2, $type)
    {
        mdump('--' . $type);
        $idLanguage = \Manager::getSession()->idLanguage;
        $el1 = implode(',', $elements1);
        $el2 = implode(',', $elements2);
        $cmd = <<<HERE
        SELECT entry1.name as name1, er.idEntity1, model1.type as model1,  entry2.name as name2, er.idEntity2, model2.type as model2
        FROM EntityRelation er
            INNER JOIN Entity e1
                ON (er.idEntity1 = e1.idEntity)
            INNER JOIN RelationType 
                ON (er.idRelationType = RelationType.idRelationType)
            INNER JOIN Entity e2
                ON (er.idEntity2 = e2.idEntity)
            INNER JOIN (
\t\t   select entry, idEntity, 'fe' as type from FrameElement
\t\t   UNION select entry, idEntity, 'ce' as type from ConstructionElement
\t\t) model1 on (e1.idEntity = model1.idEntity)
            INNER JOIN (
\t\t   select entry, idEntity, 'fe' as type from FrameElement
\t\t   UNION select entry, idEntity, 'ce' as type from ConstructionElement
\t\t) model2 on (e2.idEntity = model2.idEntity)
            INNER JOIN Entry entry1
                ON (model1.entry = entry1.entry)
            INNER JOIN Entry entry2
                ON (model2.entry = entry2.entry)
        WHERE (e1.idEntity IN ({$el1}))
            AND (e2.idEntity IN ({$el2}))
            AND (RelationType.entry = '{$type}')
            AND (entry1.idLanguage = {$idLanguage}  )
            AND (entry2.idLanguage = {$idLanguage}  )
        ORDER BY er.idEntity1, er.idEntity2
                
HERE;
        $result = $this->getDb()->getQueryCommand($cmd)->getResult();
        return $result;
    }
Example #26
0
 function handleClass($elements)
 {
     $tab = '    ';
     $classNodes = $elements;
     $dbName = $this->databaseName;
     $moduleName = $this->moduleName;
     $document = array();
     $document[] = "[globals]";
     $document[] = "database = \"{$dbName}\"";
     $document[] = "app = \"{$this->appName}\"";
     $document[] = "module = \"{$this->moduleName}\"";
     $document[] = '';
     foreach ($classNodes as $node) {
         $properties = $methods = '';
         $id = $node->getAttributeNode('xmi:id')->value;
         //$this->moduleName = $moduleName = $this->nodes['classModule'][$id];
         $classNameXMI = $node->getAttributeNode('name')->value;
         $this->className = $className = strtolower($classNameXMI);
         if ($className == 'menumdatabase') {
             continue;
         }
         mdump('handleClass = ' . $classNameXMI);
         $docassoc = $docattr = $attributes = array();
         $document[] = '[' . $classNameXMI . ']';
         if ($t = $this->getChild($node->firstChild->nextSibling, 'ormDetail')) {
             $tableId = $t->getAttributeNode('tableModel')->value;
             $table = $this->nodes['dbTable'][$tableId];
             if ($table->nodeType == XML_ELEMENT_NODE) {
                 $tableName = $table->getAttributeNode('name')->value;
                 $document[] = "table = \"{$tableName}\"";
             }
         }
         $extends = '';
         if ($generalization = $this->nodes['classGeneralization'][$id]) {
             $moduleSuperClass = $this->nodes['classModule'][$generalization];
             if ($node->getAttributeNode('xmi:type')->value != 'uml:Enumeration') {
                 $superClass = $this->nodes['uml:Class'][$generalization];
                 $extends = "\\" . $moduleSuperClass . "\\models\\" . $superClass->getAttributeNode('name')->value;
                 $document[] = "extends = \"{$extends}\"";
                 $reference = $this->getChild($node->firstChild->nextSibling, 'ormDetail');
                 if ($reference) {
                     $key = $this->nodes['PK'][$generalization];
                     $columnType = $this->getType($key[2]);
                     $docattr[] = "attributes['{$key[0]}'] = \"{$key[1]},{$columnType},not null,reference\"";
                 }
             } else {
                 $superClass = $this->nodes['uml:Enumeration'][$generalization];
                 if ($superClass->getAttributeNode('name')->value != 'MEnumDatabase') {
                     $extends = "\\" . $moduleSuperClass . "\\models\\" . $superClass->getAttributeNode('name')->value;
                 } else {
                     $extends = "\\" . $superClass->getAttributeNode('name')->value;
                 }
                 $document[] = "extends = \"{$extends}\"";
             }
         }
         $comment = $this->nodes['classComment'][$id];
         $noGenerator = $this->hasChild($node->firstChild->nextSibling, 'appliedStereotype', "Class_ORM No Generator_id");
         $idIdentity = $this->hasChild($node->firstChild->nextSibling, 'appliedStereotype', "Class_ORM ID Identity_id");
         $getterSetter = '';
         $pk = '';
         if ($node->getAttributeNode('xmi:type')->value == 'uml:Enumeration') {
             $document[] = "type = \"enumeration\"";
         } else {
             $document[] = "log = \"\"";
             $document[] = "description = \"\"";
         }
         $n = $node->firstChild->nextSibling;
         while ($n) {
             if ($n->nodeType == XML_ELEMENT_NODE) {
                 if ($n->nodeName == 'ownedAttribute') {
                     if ($n->getAttributeNode('association')->value != '') {
                         // e uma associação, não um atributo
                         $n = $n->nextSibling;
                         continue;
                     }
                     $at = $n->getAttributeNode('name')->value;
                     $attributes[$at] = $at;
                     $attribute = "attributes['{$at}'] = \"";
                     if ($cmt = $this->getChild($n, 'ownedComment')) {
                         $c = $this->getChild($cmt, 'body');
                         $attrComment = str_replace("\n", "\n * ", $c->nodeValue);
                     }
                     if ($c = $this->getChild($n->firstChild->nextSibling, 'ormDetail')) {
                         $colId = $c->getAttributeNode('columnModel')->value;
                         $col = $this->nodes['dbColumn'][$colId];
                         if ($col->nodeType == XML_ELEMENT_NODE) {
                             $colName = $col->getAttributeNode('name')->value;
                             $attribute .= "{$colName}";
                         }
                     }
                     $columnType = $this->getType($n->getAttributeNode('type'));
                     $attribute .= ",{$columnType}";
                     $isPK = false;
                     if ($c = $this->getChild($n->firstChild->nextSibling, 'appliedStereotype')) {
                         if ($c->getAttributeNode('xmi:value')->value == 'Attribute_PK_id') {
                             $attribute .= ",not null,primary";
                             $isPK = true;
                             $pk = $at;
                             if (!$noGenerator) {
                                 if ($idIdentity) {
                                     $attribute .= ",identity";
                                 } else {
                                     $attribute .= ",seq_{$tableName}";
                                 }
                             }
                         }
                     }
                     $docattr[] = $attribute . "\"";
                 } else {
                     if ($n->nodeName == 'ownedLiteral') {
                         $at = $n->getAttributeNode('name')->value;
                         mdump($at);
                         $attributes[$at] = $at;
                         $c = $n->firstChild->nextSibling;
                         if ($c->nodeType == XML_ELEMENT_NODE) {
                             $value = $c->getAttributeNode('value')->value;
                             if ($at == 'model') {
                                 $attribute = "attributes['{$at}'] = \"\\{$moduleName}\\models\\{$value}\"";
                             } elseif ($at == 'table') {
                                 $attribute = "attributes['{$at}'] = \"{$value}\"";
                             } else {
                                 $attribute = "constants['{$at}'] = \"{$value}\"";
                             }
                         }
                         if ($enumDefault == '') {
                             $enumDefault = 'default = ' . "\"{$at}\"";
                             $docattr[] = $enumDefault;
                         }
                         $docattr[] = $attribute;
                     }
                 }
             }
             $n = $n->nextSibling;
         }
         if (count($this->nodes['Associations'][$id])) {
             foreach ($this->nodes['Associations'][$id] as $idA => $association) {
                 $i = 0;
                 $j = 0;
                 $class0 = $association[0]->getAttributeNode('type')->value;
                 $name0 = trim($association[0]->getAttributeNode('name')->value);
                 $class1 = $association[1]->getAttributeNode('type')->value;
                 $name1 = trim($association[1]->getAttributeNode('name')->value);
                 $attribute = '';
                 if ($class0 == $id && $name1 != '') {
                     $docassoc[] = $this->createAssociationNode($association[1], $association[0], $attribute, $params);
                     if ($attribute != '' && !$attributes[$attribute[0]]) {
                         $docattr[] = "attributes['{$attribute[0]}'] = \"{$attribute[0]},{$attribute[2]},,foreign\"";
                         $attributes[$attribute[0]] = $attribute[0];
                     }
                 }
                 if ($class1 == $id && $name0 != '') {
                     $docassoc[] = $this->createAssociationNode($association[0], $association[1], $attribute, $params);
                     if ($attribute != '' && !$attributes[$attribute[0]]) {
                         $docattr[] = "attributes['{$attribute[0]}'] = \"{$attribute[0]},{$attribute[2]},,foreign\"";
                         $attributes[$attribute[0]] = $attribute[0];
                     }
                 }
             }
         }
         if (count($this->nodes['AssociativeClass'][$id])) {
             foreach ($this->nodes['AssociativeClass'][$id] as $idA => $association) {
                 $toClass = $association[0];
                 $module = $this->nodes['classModule'][$id];
                 $docattr[] = "associations['{$toClass}s'] = \"{$module}\\models\\{$toClass},oneToMany,{$pk}:{$pk}\"";
             }
         }
         if (count($this->nodes['AssociativeClassAttribute'][$id])) {
             foreach ($this->nodes['AssociativeClassAttribute'][$id] as $idA => $associatedClass) {
                 $atName = $this->nodes['PK'][$associatedClass][0];
                 $atCol = $this->nodes['PK'][$associatedClass][0];
                 $atType = $this->nodes['PK'][$associatedClass][0];
                 $docattr[] = "attributes['{$atName}'] = \"{$atCol},integer,,foreign\"";
             }
         }
         if (count($especializations = $this->nodes['classEspecialization'][$id])) {
             foreach ($especializations as $especialization) {
                 $moduleSubClass = $this->nodes['classModule'][$especialization];
                 $subClass = $this->nodes['uml:Class'][$especialization];
                 $subClassName = lcfirst($subClass->getAttributeNode('name')->value);
                 $subClassNameFull = "\\" . $moduleSubClass . "\\models\\" . $subClassName;
                 $key = $this->nodes['PK'][$id];
                 $docassoc[] = "associations['{$subClassName}'] = \"{$subClassNameFull},oneToOne,{$key[0]}:{$key[1]}\"";
             }
         }
         foreach ($docattr as $attr) {
             $document[] = $attr;
         }
         foreach ($docassoc as $assoc) {
             $document[] = $assoc;
         }
         $document[] = '';
     }
     $map = implode("\n", $document);
     $filename = $this->baseDir . '/' . $this->moduleName . '.txt';
     file_put_contents($filename, $map);
 }
 public function objectAssociations()
 {
     $filter = $this->data;
     $setor = new models\Setor();
     // uso de associações
     $setor->associations();
     // uso de associação na cláusula WHERE
     $criteria = $setor->associationWhere()->asQuery()->getResult();
     // obter o objeto associado: oneToMany retorna objeto Association
     $setor->getById(1);
     $setor->getUsuarios();
     // obter o objeto associado: oneToOne retorna objeto associado
     $usuario = new models\Usuario(1);
     $usuario->getPessoa();
     // associação com outro objeto - 1:1
     $usuario->saveAssociationById('setor', 1);
     // associação com outros objetos - N:N
     $grupos = array(1, 2, 3);
     mdump('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
     $usuario->saveAssociationById('grupos', $grupos);
     mdump('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
     // associação com outro objeto - 1:N
     $setor = new models\Setor(1);
     $usuarios = array(1, 2, 3);
     $setor->saveAssociationById('usuarios', $usuarios);
     $this->render();
 }
Example #28
0
 /**
  * Registra o path de uma classe (ou conjunto de classes) para posterior importação.
  * "import" não carrega a classe: apenas registra o path em self::autoload, para o "autoload" carregar a classe quando ela for efetivamente instanciada.
  * @param string $path Path no formato x\y\z
  * @param string $className Nome da classe
  * @return string Retorna o path registrado para a classe.
  */
 public static function import($namespace, $classAlias = '')
 {
     mdump('import namespace = ' . $namespace);
     $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
     $tokens = explode(DIRECTORY_SEPARATOR, $path);
     $wildcard = end($tokens) == '*';
     if ($wildcard) {
         $path = substr($path, 0, -2);
         $registerAlias = true;
     }
     // verifica se o primeiro token é a app ou um módulo, e obtem o path completo
     $structure = MApp::getStructure(self::getApp());
     if ($structure->modules[$tokens[0]]) {
         $basePath = MApp::getPathModules() . DIRECTORY_SEPARATOR;
     } else {
         $basePath = Manager::$appsPath . DIRECTORY_SEPARATOR;
     }
     $fullPath = $basePath . $path;
     //mdump($fullPath);
     // seja o wildcard *, seja um unico arquivo, normaliza no array $files
     //$fullPath = realpath($fullPath);
     $files = array();
     //$file = basename($fullPath);
     //$wildcard = ($file == '*');
     if ($wildcard) {
         MUtil::dirToArray($fullPath, $files);
         //    $registerAlias = true;
     } else {
         $fullPath .= '.php';
         if (file_exists($fullPath)) {
             $files[] = $fullPath;
         }
     }
     //mdump($files);
     if (count($files)) {
         $classOriginal = $classAlias;
         foreach ($files as $file) {
             $fileName = basename($file, '.php');
             //$classPath = $wildcard ? $file : $fullPath;
             $className = strtolower($classOriginal ?: $fileName);
             //self::$autoload[$className] = $classPath;
             $fileName = str_replace([$fullPath . DIRECTORY_SEPARATOR, '.php'], '', $file);
             $fileName = str_replace(DIRECTORY_SEPARATOR, '\\', $fileName);
             $nsClass = $wildcard ? str_replace('*', $fileName, $namespace) : $namespace;
             class_alias($nsClass, $className);
             //mdump('*************'.$className . ' - ' . $classPath . ' - ' . $nsClass);
             //mdump('*************'.$className . ' - ' . $nsClass);
         }
     }
     //mdump(self::$autoload);
     //mdump(self::$classAlias);
     mdump('import result = ' . $fullPath);
     return $fullPath;
 }
function dump_java_exception($ex)
{
    $trace = new java("java.io.ByteArrayOutputStream");
    mdump("Java Exception in File '" . $ex->getFile() . "' Line:" . $ex->getLine() . " - Message: " . $ex->getCause()->toString());
    $cause = $ex->getCause();
    $cause->printStackTrace(new java("java.io.PrintStream", $trace));
    mdump("<PRE>Java Stack Trace:\n" . $trace->toString() . "\n</PRE>");
}
Example #30
0
 public function postProcess()
 {
     $diff = time() - Manager::getData()->profile;
     mdump('Executado em ' . $diff . ' segundos');
 }