fray...@users.adullact.net
unread,Apr 25, 2024, 12:25:38 PMApr 25Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openmairie...@googlegroups.com
Author: fraynaud
Date: 2024-04-25 18:25:35 +0200 (Thu, 25 Apr 2024)
New Revision: 4941
Modified:
openmairie_exemple/branches/om5_rad/data/pgsql/init_gen.sql
openmairie_exemple/branches/om5_rad/data/pgsql/init_gen_plus.sql
openmairie_exemple/branches/om5_rad/data/pgsql/init_temp.sql
openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php
openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php
openmairie_exemple/branches/om5_rad/install/om_setup_config.php
Log:
correction et mise a niveau de l'installation
avec les om_vues et les om_actions
Modified: openmairie_exemple/branches/om5_rad/data/pgsql/init_gen.sql
===================================================================
--- openmairie_exemple/branches/om5_rad/data/pgsql/init_gen.sql 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/data/pgsql/init_gen.sql 2024-04-25 16:25:35 UTC (rev 4941)
@@ -20,6 +20,14 @@
left join om_tables_parametre on tables.table_name=om_tables_parametre.table_name
where table_type = 'BASE TABLE' and table_schema = :'schema'; -- ***
+CREATE OR REPLACE VIEW om_champs AS
+ SELECT concat(columns.table_name,'.',columns.column_name) as column_name, columns.table_name,
+ table_schema,data_type,is_nullable,character_maximum_length,
+ column_default,
+ col_description((table_schema||'.'||columns.table_name)::regclass::oid, ordinal_position) as comment
+ FROM information_schema.columns
+ where table_schema = :'schema'; -- ***
+
CREATE OR REPLACE VIEW om_contraintes AS
SELECT tc.constraint_name,
tc.table_name,
@@ -32,14 +40,14 @@
WHERE constraint_type = 'FOREIGN KEY' AND tc.table_schema = :'schema'; -- ***
-SET search_path = om5, public, pg_catalog;
+--SET search_path = om5, public, pg_catalog;
CREATE OR REPLACE VIEW om_vues AS
SELECT
table_name,
- view_definition,
- table_schema
+ table_schema,
+ view_definition
FROM information_schema.views
-where table_schema = 'om5'; -- where schema_name = :'schema' ;
+where table_schema= :'schema'; -- where schema_name = :'schema' ;
-- mettre les om_droits
INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
@@ -48,4 +56,5 @@
(nextval('om_droit_seq'), 'om_contraintes', 1);
INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
(nextval('om_droit_seq'), 'om_vues', 1);
-
+INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
+(nextval('om_droit_seq'), 'om_champs', 1);
Modified: openmairie_exemple/branches/om5_rad/data/pgsql/init_gen_plus.sql
===================================================================
--- openmairie_exemple/branches/om5_rad/data/pgsql/init_gen_plus.sql 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/data/pgsql/init_gen_plus.sql 2024-04-25 16:25:35 UTC (rev 4941)
@@ -8,7 +8,11 @@
(nextval('om_droit_seq'), 'om_forms', 1);
INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
(nextval('om_droit_seq'), 'om_tables_parametre', 1);
+INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
+(nextval('om_droit_seq'), 'om_actions', 1);
+-- tables
+
CREATE TABLE om_tables_parametre
(
table_name character varying(40),
@@ -19,15 +23,9 @@
(
column_name character varying(120),
parametres jsonb,
- table_name character varying(40),
+ table_name character varying(40)
);
-
-ALTER TABLE ONLY om_forms
- ADD CONSTRAINT om_forms_pkey PRIMARY KEY (column_name);
-
-ALTER TABLE ONLY om_tables_parametre
- ADD CONSTRAINT om_tables_parametre_pkey PRIMARY KEY (table_name);
-
+
CREATE TABLE om_actions(
om_actions integer not null,
libelle character varying(40) not null,
@@ -36,6 +34,19 @@
table_name character varying(40)
);
+-- pk
+
+ALTER TABLE ONLY om_tables_parametre
+ ADD CONSTRAINT om_tables_parametre_pkey PRIMARY KEY (table_name);
+
+ALTER TABLE ONLY om_forms
+ ADD CONSTRAINT om_forms_pkey PRIMARY KEY (column_name);
+
+ALTER TABLE ONLY om_actions
+ ADD CONSTRAINT om_actions_pkey PRIMARY KEY (om_actions);
+
+-- seq
+
CREATE SEQUENCE om_actions_seq
START WITH 1
INCREMENT BY 1
@@ -42,8 +53,3 @@
NO MINVALUE
NO MAXVALUE
CACHE 1;
-ALTER TABLE ONLY om_actions
- ADD CONSTRAINT om_actions_pkey PRIMARY KEY (om_actions);
-
-INSERT INTO om_droit (om_droit, libelle, om_profil) VALUES
-(nextval('om_droit_seq'), 'om_actions', 1);
Modified: openmairie_exemple/branches/om5_rad/data/pgsql/init_temp.sql
===================================================================
--- openmairie_exemple/branches/om5_rad/data/pgsql/init_temp.sql 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/data/pgsql/init_temp.sql 2024-04-25 16:25:35 UTC (rev 4941)
@@ -47,6 +47,7 @@
create table om_vues (
table_name character varying(80) not null,
+ table_schema character varying(80),
view_definition text
);
Modified: openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php 2024-04-25 16:25:35 UTC (rev 4941)
@@ -1,6 +1,6 @@
<?php
//$Id$
-//gen openMairie le 25/04/2024 13:51
+//gen openMairie le 25/04/2024 17:58
require_once PATH_OPENMAIRIE."om_dbform.class.php";
@@ -23,7 +23,7 @@
* @return string
*/
function get_default_libelle() {
- return $this->getVal($this->clePrimaire)." ".$this->getVal("view_definition");
+ return $this->getVal($this->clePrimaire)." ".$this->getVal("table_schema");
}
/**
@@ -33,6 +33,7 @@
function get_var_sql_forminc__champs() {
return array(
"table_name",
+ "table_schema",
"view_definition",
);
}
@@ -43,6 +44,11 @@
function setvalF($val = array()) {
//affectation valeur formulaire
$this->valF['table_name'] = $val['table_name'];
+ if ($val['table_schema'] == "") {
+ $this->valF['table_schema'] = NULL;
+ } else {
+ $this->valF['table_schema'] = $val['table_schema'];
+ }
$this->valF['view_definition'] = $val['view_definition'];
}
@@ -59,6 +65,7 @@
// MODE AJOUTER
if ($maj == 0 || $crud == 'create') {
$form->setType("table_name", "text");
+ $form->setType("table_schema", "text");
$form->setType("view_definition", "textarea");
}
@@ -65,6 +72,7 @@
// MDOE MODIFIER
if ($maj == 1 || $crud == 'update') {
$form->setType("table_name", "hiddenstatic");
+ $form->setType("table_schema", "text");
$form->setType("view_definition", "textarea");
}
@@ -71,6 +79,7 @@
// MODE SUPPRIMER
if ($maj == 2 || $crud == 'delete') {
$form->setType("table_name", "hiddenstatic");
+ $form->setType("table_schema", "hiddenstatic");
$form->setType("view_definition", "hiddenstatic");
}
@@ -77,6 +86,7 @@
// MODE CONSULTER
if ($maj == 3 || $crud == 'read') {
$form->setType("table_name", "static");
+ $form->setType("table_schema", "static");
$form->setType("view_definition", "textareastatic");
}
@@ -87,6 +97,7 @@
*/
function setTaille(&$form, $maj) {
$form->setTaille("table_name", 30);
+ $form->setTaille("table_schema", 30);
$form->setTaille("view_definition", 80);
}
@@ -95,6 +106,7 @@
*/
function setMax(&$form, $maj) {
$form->setMax("table_name", 80);
+ $form->setMax("table_schema", 80);
$form->setMax("view_definition", 6);
}
@@ -102,6 +114,7 @@
function setLib(&$form, $maj) {
//libelle des champs
$form->setLib('table_name', __('table_name'));
+ $form->setLib('table_schema', __('table_schema'));
$form->setLib('view_definition', __('view_definition'));
}
/**
Modified: openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php 2024-04-25 16:25:35 UTC (rev 4941)
@@ -1,6 +1,6 @@
<?php
//$Id$
-//gen openMairie le 25/04/2024 13:51
+//gen openMairie le 25/04/2024 17:58
$DEBUG=0;
$serie=15;
@@ -24,6 +24,7 @@
// SELECT
$champAffiche = array(
'om_vues.table_name as "'.__("table_name").'"',
+ 'om_vues.table_schema as "'.__("table_schema").'"',
);
//
$champNonAffiche = array(
@@ -32,8 +33,9 @@
//
$champRecherche = array(
'om_vues.table_name as "'.__("table_name").'"',
+ 'om_vues.table_schema as "'.__("table_schema").'"',
);
-$tri="ORDER BY om_vues.view_definition ASC NULLS LAST";
+$tri="ORDER BY om_vues.table_schema ASC NULLS LAST";
$edition="om_vues";
/**
* Gestion de la clause WHERE => $selection
Modified: openmairie_exemple/branches/om5_rad/install/om_setup_config.php
===================================================================
--- openmairie_exemple/branches/om5_rad/install/om_setup_config.php 2024-04-25 13:43:36 UTC (rev 4940)
+++ openmairie_exemple/branches/om5_rad/install/om_setup_config.php 2024-04-25 16:25:35 UTC (rev 4941)
@@ -339,20 +339,12 @@
FROM information_schema.tables
left join ".SCHEMA.".om_tables_parametre on tables.table_name=om_tables_parametre.table_name
where table_type = 'BASE TABLE' and table_schema = '".SCHEMA."'",$con);
- requete("CREATE OR REPLACE VIEW ".SCHEMA.".om_champs AS
- SELECT concat(table_name,'.',columns.column_name) as column_name,table_name,
+ requete("CREATE OR REPLACE VIEW om_champs AS
+ SELECT concat(columns.table_name,'.',columns.column_name) as column_name, columns.table_name,
table_schema,data_type,is_nullable,character_maximum_length,
column_default,
- col_description((table_schema||'.'||table_name)::regclass::oid, ordinal_position) as comment,
- parametres->>'libelle' as libelle,
- parametres->>'type' as type,
- parametres->>'bloc' as bloc,
- parametres->>'position' as position,
- parametres->>'calcul' as calcul,
- parametres->>'liste' as liste
+ col_description((table_schema||'.'||columns.table_name)::regclass::oid, ordinal_position) as comment
FROM information_schema.columns
- left join ".SCHEMA.".om_forms
- on concat(table_name,'.',columns.column_name)=om_forms.column_name
where table_schema = '".SCHEMA."'",$con);
requete("CREATE OR REPLACE VIEW om_contraintes AS
SELECT tc.constraint_name,
@@ -361,11 +353,15 @@
JOIN information_schema.key_column_usage AS kcu USING (constraint_schema, constraint_name)
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
WHERE constraint_type = 'FOREIGN KEY' AND tc.table_schema = '".SCHEMA."'",$con);
-
+ requete("CREATE OR REPLACE VIEW om_vues AS
+ SELECT table_name, table_schema, view_definition FROM information_schema.views
+ where table_schema='".SCHEMA."'",$con);
// om_droits
requete("INSERT INTO ".SCHEMA.".om_droit (om_droit, libelle, om_profil) VALUES (nextval('".SCHEMA.".om_droit_seq'), 'om_tables', 1)",$con);
requete("INSERT INTO ".SCHEMA.".om_droit (om_droit, libelle, om_profil) VALUES (nextval('".SCHEMA.".om_droit_seq'), 'om_champs', 1)",$con);
requete("INSERT INTO ".SCHEMA.".om_droit (om_droit, libelle, om_profil) VALUES (nextval('".SCHEMA.".om_droit_seq'), 'om_contraintes', 1)",$con);
+ requete("INSERT INTO ".SCHEMA.".om_droit (om_droit, libelle, om_profil) VALUES (nextval('".SCHEMA.".om_droit_seq'), 'om_view', 1)",$con);
+
}
/* Fermeture de la connection */
pg_close($con);