Commit 2d943b94c466ab8dbc219dd6233e0546e5f28cb3

Authored by Edmar Moretti
1 parent f1119e23

$1

classesphp/mapa_inicia.php
... ... @@ -102,7 +102,7 @@ Retorno:
102 102 */
103 103 function iniciaMapa()
104 104 {
105   - global $emailInstituicao,$openid,$interfacePadrao,$mensagemInicia,$kmlurl,$tituloInstituicao,$tempo,$navegadoresLocais,$locaplic,$embedLegenda,$map_file,$mapext,$w,$h,$R_path,$locmapserv,$utilizacgi,$expoeMapfile,$interface;
  105 + global $saikuUrl,$emailInstituicao,$openid,$interfacePadrao,$mensagemInicia,$kmlurl,$tituloInstituicao,$tempo,$navegadoresLocais,$locaplic,$embedLegenda,$map_file,$mapext,$w,$h,$R_path,$locmapserv,$utilizacgi,$expoeMapfile,$interface;
106 106 //
107 107 //verifica se algum tema e restrito a determinado usuario
108 108 //as funcoes de validacao encontram-se em funcoes_gerais.php
... ... @@ -330,6 +330,7 @@ function iniciaMapa()
330 330 {$res["mapfile"] = "";}
331 331 else
332 332 {$res["mapfile"] = $map_file;}
  333 +
333 334 $res["cgi"] = $locmapserv;
334 335 $res["extentTotal"] = $ext;
335 336 $res["mapimagem"] = $nomer;
... ... @@ -365,6 +366,7 @@ function iniciaMapa()
365 366 $res["cordefundo"] = $cordefundo;
366 367 $res["copyright"] = $copyright;
367 368 $res["logado"] = $logado;
  369 + $res["saikuUrl"] = $saikuUrl;
368 370 //parametros de inicializacao armazenados com o mapa quando o usuario utiliza a opcao de salvar mapa no nbanco de dados
369 371 $customizacoesinit = $m->mapa->getmetadata("CUSTOMIZACOESINIT");
370 372 $res["editavel"] = $m->mapa->getmetadata("EDITAVEL");
... ... @@ -375,4 +377,4 @@ function iniciaMapa()
375 377 ob_clean();
376 378 cpjson(array("variaveis"=>$res,"temas"=>$temas,"customizacoesinit"=>$customizacoesinit));
377 379 }
378   -?>
379 380 \ No newline at end of file
  381 +?>
... ...
ferramentas/saiku/dicionario.js
... ... @@ -11,5 +11,11 @@ i3GEOF.saiku.dicionario = {
11 11 en:"",
12 12 es:"",
13 13 it:""
  14 + }],
  15 + 3: [{
  16 + pt:"O servidor SAIKU não está disponível nessa instalação do i3Geo",
  17 + en:"",
  18 + es:"",
  19 + it:""
14 20 }]
15 21 };
... ...
ferramentas/saiku/esquemaxml.php
1 1 <?php
  2 +if(empty($_GET["g_sid"])){
  3 + echo "erro";
  4 + exit;
  5 +}
  6 +include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
2 7 include(dirname(__FILE__)."/../../admin/php/classe_metaestat.php");
3   -include(dirname(__FILE__)."/../../ms_configura.php");
4   -$nomeDatasource = $dir_tmp."/saiku-datasources/i3geo";
5   -//$saikuDatasourceString vem do ms_configura.php
  8 +if(!isset($dir_tmp)){
  9 + include(dirname(__FILE__)."/../../ms_configura.php");
  10 +}
  11 +//pega o filtro da sessao PHP aberta pelo i3Geo
  12 +session_name("i3GeoPHP");
  13 +session_id($_GET["g_sid"]);
  14 +session_start();
  15 +//obtem os layers que sao do sistema metaestat, sao regioes e que possuem selecao
  16 +$map_file = $_SESSION["map_file"];
  17 +$nomeDatasource = $dir_tmp."/saiku-datasources/".nomeRandomico();
  18 +$nomeXmlEsquema = dirname($map_file)."/".nomeRandomico().".xml";
  19 +/*
  20 +$saikuConfigDataSource vem do ms_configura.php
  21 +
  22 +Exemplo de arquivo de fonte:
  23 +type=OLAP
  24 +name=i3geo
  25 +driver=mondrian.olap4j.MondrianOlap4jDriver
  26 +location=jdbc:mondrian:Jdbc=jdbc:postgresql://localhost:5432/i3geosaude;Catalog=http://localhost/i3geo/ferramentas/saiku/esquemaxml.php;JdbcDrivers=org.postgresql.Driver;
  27 +username=postgres
  28 +password=postgres
  29 +
  30 +Array com os parametros definidos em ms_configura:
  31 +
  32 +$saikuConfigDataSource = array(
  33 + "type"=>"OLAP",
  34 + "name"=>"i3geo",
  35 + "driver"=>"mondrian.olap4j.MondrianOlap4jDriver",
  36 + "location"=>"jdbc:mondrian:Jdbc=jdbc:postgresql",
  37 + "serverdb"=>"localhost",
  38 + "port"=>"5432",
  39 + "database"=>"i3geosaude",
  40 + "JdbcDrivers"=>"org.postgresql.Driver",
  41 + "username"=>"postgres",
  42 + "password"=>"postgres"
  43 +);
  44 +*/
  45 +$stringDatasource = "
  46 +type={$saikuConfigDataSource["type"]}
  47 +name={$saikuConfigDataSource["name"]}
  48 +driver={$saikuConfigDataSource["driver"]}
  49 +location={$saikuConfigDataSource["location"]}://{$saikuConfigDataSource["serverdb"]}:{$saikuConfigDataSource["port"]}/{$saikuConfigDataSource["database"]};Catalog={$nomeXmlEsquema};JdbcDrivers={$saikuConfigDataSource["JdbcDrivers"]};
  50 +username={$saikuConfigDataSource["username"]}
  51 +password={$saikuConfigDataSource["password"]}
  52 +";
  53 +//salva o arquivo com a fonte
  54 +gravaDados(array($stringDatasource),$nomeDatasource);
6 55 $m = new Metaestat();
7 56 $selecaoRegiao = array();
8   -//pega o filtro da sessao PHP aberta pelo i3Geo
9   -if(!empty($_COOKIE["i3GeoPHP"])){
10   - include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
11   - session_name("i3GeoPHP");
12   - session_id($_COOKIE["i3GeoPHP"]);
13   - session_start();
14   - //obtem os layers que sao do sistema metaestat, sao regioes e que possuem selecao
15   - $map_file = $_SESSION["map_file"];
16   - $mapa = ms_newMapObj($map_file);
17   - $c = $mapa->numlayers;
18   - for ($i=0;$i < $c;++$i){
19   - $l = $mapa->getlayer($i);
20   - $registros = array();
21   - $codigo_tipo_regiao = $l->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO");
22   - if($codigo_tipo_regiao != "" && $l->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL") == ""){
23   - //verifica se tem selecao
24   - $qyfile = dirname($map_file)."/".$l->name.".php";
25   - if(file_exists($qyfile)){
26   - //pega os registros
27   - $shapes = retornaShapesSelecionados($l,$map_file,$mapa);
28   - //pega o nome da coluna que identifica cada registro
29   - $regiao = $m->listaTipoRegiao($codigo_tipo_regiao);
30   - $item = $regiao["identificador"];
31   - foreach($shapes as $shape){
32   - $registros[] = $shape->values[$item];
33   - }
34   - $reg = $item." IN ('".implode("','",$registros)."') ";
35   - $selecaoRegiao[$codigo_tipo_regiao] = array(
36   - "item" => $item,
37   - "sql" => $reg
38   - );
39   - }
40   - else{
41   - $selecaoRegiao[$codigo_tipo_regiao] = "";
  57 +$mapa = ms_newMapObj($map_file);
  58 +$c = $mapa->numlayers;
  59 +for ($i=0;$i < $c;++$i){
  60 + $l = $mapa->getlayer($i);
  61 + $registros = array();
  62 + $codigo_tipo_regiao = $l->getmetadata("METAESTAT_CODIGO_TIPO_REGIAO");
  63 + if($codigo_tipo_regiao != "" && $l->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL") == ""){
  64 + //verifica se tem selecao
  65 + $qyfile = dirname($map_file)."/".$l->name.".php";
  66 + if(file_exists($qyfile)){
  67 + //pega os registros
  68 + $shapes = retornaShapesSelecionados($l,$map_file,$mapa);
  69 + //pega o nome da coluna que identifica cada registro
  70 + $regiao = $m->listaTipoRegiao($codigo_tipo_regiao);
  71 + $item = $regiao["identificador"];
  72 + foreach($shapes as $shape){
  73 + $registros[] = $shape->values[$item];
42 74 }
  75 + $reg = $item." IN ('".implode("','",$registros)."') ";
  76 + $selecaoRegiao[$codigo_tipo_regiao] = array(
  77 + "item" => $item,
  78 + "sql" => $reg
  79 + );
  80 + }
  81 + else{
  82 + $selecaoRegiao[$codigo_tipo_regiao] = "";
43 83 }
44 84 }
45   - $regiao = "";
46   - $item = "";
47   - $registros = "";
48 85 }
49   -//echo "<pre>".var_dump($_SESSION);exit;
  86 +$regiao = "";
  87 +$item = "";
  88 +$registros = "";
50 89  
51 90 $regioes = $m->listaTipoRegiao();
52 91 $xml = "<Schema name='i3Geo Metaestat'>";
... ... @@ -101,7 +140,6 @@ foreach($regioes as $regiao){
101 140 column='codigo'
102 141 nameColumn='nome' uniqueMembers='true'>
103 142 ";
104   -
105 143 //verifica outras colunas
106 144 $vis = $regiao['colunasvisiveis'];
107 145 if($vis != ""){
... ... @@ -250,13 +288,13 @@ $xml .= &#39;&lt;/VirtualCube&gt;&#39;;
250 288 $xml .= "</Schema>";
251 289 error_reporting(0);
252 290 ob_end_clean();
253   -echo header("Content-type: application/xml");
254   -echo $xml;
255   -exit;
256   -function converte($texto)
257   -{
  291 +
  292 +gravaDados(array($xml),$nomeXmlEsquema);
  293 +header("Location:".$saikuUrl);
  294 +
  295 +function converte($texto){
258 296 //$texto = str_replace("Í","&amp;iacute",$texto);
259   -$texto = str_replace("&","&amp;",htmlentities($texto));
  297 + $texto = str_replace("&","&amp;",htmlentities($texto));
260 298 return $texto;
261 299 }
262 300 ?>
... ...
ferramentas/saiku/index.js
... ... @@ -102,8 +102,13 @@ i3GEOF.saiku = {
102 102 */
103 103 html:function(){
104 104 var ins = "<p class=paragrafo >Saiku: <a href=http://meteorite.bi/saiku target=_blank >http://meteorite.bi/saiku</a></p>" +
105   - "<p class=paragrafo >" + $trad(1,i3GEOF.saiku.dicionario) + "<p>" +
106   - "<input id=i3GEOFsaikubotao1 size=20 type=button value='"+$trad(2,i3GEOF.saiku.dicionario)+"' />";
  105 + "<p class=paragrafo >" + $trad(1,i3GEOF.saiku.dicionario) + "<p>";
  106 + if(i3GEO.parametros.saikuUrl !== ""){
  107 + ins += "<input id=i3GEOFsaikubotao1 size=20 type=button value='"+$trad(2,i3GEOF.saiku.dicionario)+"' />";
  108 + }
  109 + else{
  110 + ins += "<p class=paragrafo style=color:red >" + $trad(3,i3GEOF.saiku.dicionario) + "<p>";
  111 + }
107 112  
108 113 return ins;
109 114 },
... ... @@ -140,6 +145,6 @@ i3GEOF.saiku = {
140 145 i3GEOF.saiku.inicia(divid);
141 146 },
142 147 aplicar: function(){
143   - window.open("http://localhost:9090?"+i3GEO.configura.sid);
  148 + window.open(i3GEO.configura.locaplic+"/ferramentas/saiku/esquemaxml.php?g_sid="+i3GEO.configura.sid);
144 149 }
145 150 };
... ...
ferramentas/saiku/instal.txt
... ... @@ -31,7 +31,7 @@ Para mais informações veja em: http://docs.analytical-labs.com/
31 31 (/var/tmp/ms_tmp é a pasta temporária utilizada pelo i3Geo)
32 32  
33 33 rm -R -f /var/www/saiku-server/tomcat/webapps/saiku/WEB-INF/classes/saiku-datasources
34   - ln -s /tmp/ms_tmp/saiku-datasources /var/www/saiku-server/tomcat/webapps/saiku/WEB-INF/classes/saiku-datasources
  34 + ln -s /tmp/ms_tmp/saiku-datasources /var/www_geosaude_16/saiku-server/tomcat/webapps/saiku/WEB-INF/classes/saiku-datasources
35 35  
36 36  
37 37 - Arquivos alterados
... ...
ms_configura.php
... ... @@ -60,7 +60,7 @@ array(array(&quot;usuario&quot;=&gt;&quot;admin&quot;, &quot;senha&quot;=&gt;&quot;adminx&quot;));
60 60 */
61 61 //@TODO v5 alterar a senha para admin
62 62 $i3geomaster = array(
63   - array("usuario"=>"admin", "senha"=>"admin")
  63 + array("usuario"=>"admin", "senha"=>"admin")
64 64 );
65 65 /*
66 66 Variable: saikuUrl
... ... @@ -71,6 +71,47 @@ Para maiores informacoes sobre como instalar o SAIKU veja em http://localhost/i3
71 71 */
72 72 $saikuUrl = "http://localhost:9090";
73 73 /*
  74 +Variable: saikuConfigDataSource
  75 +
  76 +Parametros de configuracao da fonte de dados utilizada pelo applicativo SAIKU
  77 +
  78 +Indicam onde estao os dados utilizados pelo sistema de metadados estatisticos e que podem ser visualizados na forma
  79 +de cubos OLAP
  80 +
  81 +Ajuste os parametros indicando:
  82 +
  83 +serverdb - endereco do servidor postgres
  84 +port - porta de acesso ao servidor
  85 +database - nome do database que contem as tabelas
  86 +username - nome do usuario que pode acessar o database
  87 +password - senha desse usuario
  88 +
  89 +Os parametros sao utilizados pelo programa definido em Catalog. Ese programa monta o arquivo de fonte de dados temorario
  90 +e armazena em ms_tmp/saiku-datasources
  91 +
  92 +Esse arquivo contera uma string como esse exemplo:
  93 +
  94 +type=OLAP
  95 +name=i3geo
  96 +driver=mondrian.olap4j.MondrianOlap4jDriver
  97 +location=jdbc:mondrian:Jdbc=jdbc:postgresql://localhost:5432/i3geosaude;Catalog=http://localhost/i3geo/ferramentas/saiku/esquemaxml.php;JdbcDrivers=org.postgresql.Driver;
  98 +username=postgres
  99 +password=postgres
  100 +
  101 +*/
  102 +$saikuConfigDataSource = array(
  103 + "type"=>"OLAP",
  104 + "name"=>"i3geo",
  105 + "driver"=>"mondrian.olap4j.MondrianOlap4jDriver",
  106 + "location"=>"jdbc:mondrian:Jdbc=jdbc:postgresql",
  107 + "serverdb"=>"localhost",
  108 + "port"=>"5432",
  109 + "database"=>"i3geosaude",
  110 + "JdbcDrivers"=>"org.postgresql.Driver",
  111 + "username"=>"postgres",
  112 + "password"=>"postgres"
  113 +);
  114 +/*
74 115 Variable: i3georendermode
75 116  
76 117 Opcoes que definem a rotina que sera utilizada para enviar ao navegador as imagens geradas de cada camada
... ...
ms_criamapa.php
... ... @@ -229,6 +229,7 @@ else{
229 229 $mapext = str_replace(","," ",$mapext);
230 230 setcookie("i3geoUltimaExtensao", $mapext);
231 231 }
  232 +$saikuUrl_ = $saikuUrl;
232 233 $cachedir_ = $cachedir;
233 234 $dir_tmp_ = $dir_tmp;
234 235 $emailInstituicao_ = $emailInstituicao;
... ... @@ -326,6 +327,9 @@ $_SESSION[&quot;mapdir&quot;] = $diretorios[1];
326 327 $_SESSION["imgdir"] = $diretorios[2];
327 328 $_SESSION["contadorsalva"] = 0;//essa variavel e utilizada pela ferramenta telaremota. Toda vez que o mapa e salvo, acrescenta 1 (veja classesphp/mapa_controle.php)
328 329 $_SESSION["i3georendermode"] = $i3georendermode_;
  330 +$_SESSION["saikuUrl"] = $saikuUrl_;
  331 +
  332 +
329 333 //
330 334 //pega todas as vari&aacute;veis da sess&atilde;o, mesmo as que foram definidas anteriormente
331 335 //
... ...