IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management - Create AD_TableIndex record for all tables

This commit is contained in:
Elaine Tan 2013-07-15 15:50:31 +08:00
parent d2d8553156
commit 6ac9a759dc
4 changed files with 750 additions and 15 deletions

View File

@ -0,0 +1,227 @@
-- Jul 12, 2013 5:21:13 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process (AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES (200057,'N','N','11d63490-997c-423d-b332-893132874f78','4','N','N',22,17,'Y','D','Create Table Index',0,TO_DATE('2013-07-12 17:21:11','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-12 17:21:11','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CreateTableIndex','CreateTableIndex',0)
;
-- Jul 12, 2013 5:21:13 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200057 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
;
-- Jul 12, 2013 5:23:08 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,EntityType,Name,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Org_ID,IsActive,AD_Client_ID) VALUES ('AD_Table.IsView=''N''',200047,'D','AD_Table not View','S','47987b6f-4a3c-4cb7-aca2-6601f0eb8238',100,100,TO_DATE('2013-07-12 17:23:07','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-07-12 17:23:07','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Jul 12, 2013 5:23:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',126,200067,'c2a888cf-4319-495d-9982-aa4da8aca86d','The Database Table provides the information of the table definition',200057,18,200047,'N',53290,'D','Table','AD_Table_ID','Database Table information',0,'Y',10,'Y',100,TO_DATE('2013-07-12 17:23:30','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-12 17:23:30','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 12, 2013 5:23:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200067 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu (AD_Menu_ID,IsSummary,IsSOTrx,IsReadOnly,AD_Process_ID,EntityType,IsCentrallyMaintained,Name,AD_Menu_UU,Action,IsActive,CreatedBy,Updated,AD_Org_ID,Created,UpdatedBy,AD_Client_ID) VALUES (200063,'N','N','N',200057,'D','Y','Create Table Index','1fc8d8ab-6932-42d5-a25e-a2c1bd946f4e','P','Y',100,TO_DATE('2013-07-12 17:24:24','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2013-07-12 17:24:24','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Menu_Trl_UU ) SELECT l.AD_Language,t.AD_Menu_ID, t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=200063 AND NOT EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Menu_ID=t.AD_Menu_ID)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_TreeNodeMM (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, AD_Tree_ID, Node_ID, Parent_ID, SeqNo, AD_TreeNodeMM_UU) SELECT t.AD_Client_ID, 0, 'Y', SysDate, 100, SysDate, 100,t.AD_Tree_ID, 200063, 0, 999, Generate_UUID() FROM AD_Tree t WHERE t.AD_Client_ID=0 AND t.IsActive='Y' AND t.IsAllNodes='Y' AND t.TreeType='MM' AND NOT EXISTS (SELECT * FROM AD_TreeNodeMM e WHERE e.AD_Tree_ID=t.AD_Tree_ID AND Node_ID=200063)
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53203
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=586
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=138
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=3, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=139
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=4, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200063
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=5, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=249
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=6, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=141
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=7, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=300
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=8, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=589
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=9, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200000
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=10, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=295
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=11, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=216
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=12, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=140
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=13, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=142
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=14, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53012
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=15, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=143
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=16, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=201
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=17, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=176
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=18, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53086
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=19, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=239
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=20, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=517
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=21, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=499
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=22, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53089
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=23, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53090
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=24, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200038
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=25, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=50001
;
-- Jul 15, 2013 3:21:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2013-07-15 15:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210545
;
-- Jul 15, 2013 3:21:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
ALTER TABLE AD_IndexColumn MODIFY AD_Column_ID NUMBER(10) DEFAULT NULL
;
-- Jul 15, 2013 3:21:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
ALTER TABLE AD_IndexColumn MODIFY AD_Column_ID NULL
;
-- Jul 15, 2013 3:32:11 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Processed table: {0}, Processed index: {1}, Error: {2}',200201,'D','ddf8d6fa-6c15-4738-b5d6-bb251eec7fb3','CreateTableIndexProcessResult','Y',TO_DATE('2013-07-15 15:32:09','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-15 15:32:09','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:32:12 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200201 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:34:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process table: ',200202,'D','930d4e28-6ec3-4b39-aafa-b150e3fc2423','CreateTableIndexProcessTable','Y',TO_DATE('2013-07-15 15:34:00','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-15 15:34:00','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:34:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200202 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:34:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Create table index: ',200203,'D','d3065c3e-84e2-4d82-aa8c-1a14f12c6810','CreateTableIndexCreateTableIndex','Y',TO_DATE('2013-07-15 15:34:55','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-15 15:34:55','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:34:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200203 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:35:36 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Validate table index: ',200204,'D','c3278c18-4d56-4860-a60e-3aa5d7e4001e','CreateTableIndexValidateTableIndex','Y',TO_DATE('2013-07-15 15:35:35','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-15 15:35:35','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:35:36 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200204 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('201307151545_IDEMPIERE-1132.sql') FROM dual
;

View File

@ -0,0 +1,227 @@
-- Jul 12, 2013 5:21:13 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process (AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES (200057,'N','N','11d63490-997c-423d-b332-893132874f78','4','N','N',22,17,'Y','D','Create Table Index',0,TO_TIMESTAMP('2013-07-12 17:21:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-12 17:21:11','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CreateTableIndex','CreateTableIndex',0)
;
-- Jul 12, 2013 5:21:13 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200057 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
;
-- Jul 12, 2013 5:23:08 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,EntityType,Name,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Org_ID,IsActive,AD_Client_ID) VALUES ('AD_Table.IsView=''N''',200047,'D','AD_Table not View','S','47987b6f-4a3c-4cb7-aca2-6601f0eb8238',100,100,TO_TIMESTAMP('2013-07-12 17:23:07','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-07-12 17:23:07','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Jul 12, 2013 5:23:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',126,200067,'c2a888cf-4319-495d-9982-aa4da8aca86d','The Database Table provides the information of the table definition',200057,18,200047,'N',53290,'D','Table','AD_Table_ID','Database Table information',0,'Y',10,'Y',100,TO_TIMESTAMP('2013-07-12 17:23:30','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-12 17:23:30','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 12, 2013 5:23:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200067 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu (AD_Menu_ID,IsSummary,IsSOTrx,IsReadOnly,AD_Process_ID,EntityType,IsCentrallyMaintained,Name,AD_Menu_UU,"action",IsActive,CreatedBy,Updated,AD_Org_ID,Created,UpdatedBy,AD_Client_ID) VALUES (200063,'N','N','N',200057,'D','Y','Create Table Index','1fc8d8ab-6932-42d5-a25e-a2c1bd946f4e','P','Y',100,TO_TIMESTAMP('2013-07-12 17:24:24','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2013-07-12 17:24:24','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Menu_Trl_UU ) SELECT l.AD_Language,t.AD_Menu_ID, t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=200063 AND NOT EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Menu_ID=t.AD_Menu_ID)
;
-- Jul 12, 2013 5:24:25 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_TreeNodeMM (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, AD_Tree_ID, Node_ID, Parent_ID, SeqNo, AD_TreeNodeMM_UU) SELECT t.AD_Client_ID, 0, 'Y', statement_timestamp(), 100, statement_timestamp(), 100,t.AD_Tree_ID, 200063, 0, 999, Generate_UUID() FROM AD_Tree t WHERE t.AD_Client_ID=0 AND t.IsActive='Y' AND t.IsAllNodes='Y' AND t.TreeType='MM' AND NOT EXISTS (SELECT * FROM AD_TreeNodeMM e WHERE e.AD_Tree_ID=t.AD_Tree_ID AND Node_ID=200063)
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=0, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53203
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=1, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=586
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=2, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=138
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=3, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=139
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=4, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200063
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=5, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=249
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=6, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=141
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=7, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=300
;
-- Jul 12, 2013 5:24:37 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=8, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=589
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=9, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200000
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=10, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=295
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=11, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=216
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=12, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=140
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=13, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=142
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=14, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53012
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=15, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=143
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=16, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=201
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=17, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=176
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=18, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53086
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=19, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=239
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=20, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=517
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=21, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=499
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=22, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53089
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=23, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53090
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=24, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200038
;
-- Jul 12, 2013 5:24:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=25, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=50001
;
-- Jul 15, 2013 3:21:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2013-07-15 15:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210545
;
-- Jul 15, 2013 3:21:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO t_alter_column values('ad_indexcolumn','AD_Column_ID','NUMERIC(10)',null,'NULL')
;
-- Jul 15, 2013 3:21:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO t_alter_column values('ad_indexcolumn','AD_Column_ID',null,'NULL',null)
;
-- Jul 15, 2013 3:32:11 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Processed table: {0}, Processed index: {1}, Error: {2}',200201,'D','ddf8d6fa-6c15-4738-b5d6-bb251eec7fb3','CreateTableIndexProcessResult','Y',TO_TIMESTAMP('2013-07-15 15:32:09','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-15 15:32:09','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:32:12 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200201 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:34:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process table: ',200202,'D','930d4e28-6ec3-4b39-aafa-b150e3fc2423','CreateTableIndexProcessTable','Y',TO_TIMESTAMP('2013-07-15 15:34:00','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-15 15:34:00','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:34:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200202 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:34:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Create table index: ',200203,'D','d3065c3e-84e2-4d82-aa8c-1a14f12c6810','CreateTableIndexCreateTableIndex','Y',TO_TIMESTAMP('2013-07-15 15:34:55','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-15 15:34:55','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:34:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200203 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 15, 2013 3:35:36 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Validate table index: ',200204,'D','c3278c18-4d56-4860-a60e-3aa5d7e4001e','CreateTableIndexValidateTableIndex','Y',TO_TIMESTAMP('2013-07-15 15:35:35','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-15 15:35:35','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 15, 2013 3:35:36 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200204 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('201307151545_IDEMPIERE-1132.sql') FROM dual
;

View File

@ -0,0 +1,261 @@
package org.compiere.process;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.logging.Level;
import org.compiere.model.MColumn;
import org.compiere.model.MIndexColumn;
import org.compiere.model.MTable;
import org.compiere.model.MTableIndex;
import org.compiere.util.DB;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
public class CreateTableIndex extends SvrProcess {
/** Table */
private int p_AD_Table_ID = 0;
private int countTable = 0;
private int countIndex = 0;
private int countError = 0;
@Override
protected void prepare()
{
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("AD_Table_ID"))
p_AD_Table_ID = para[i].getParameterAsInt();
else
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
}
}
@Override
protected String doIt() throws Exception
{
if (log.isLoggable(Level.INFO)) log.info("AD_Table_ID=" + p_AD_Table_ID);
Trx trx = Trx.get(get_TrxName(), true);
DatabaseMetaData md = trx.getConnection().getMetaData();
if (p_AD_Table_ID > 0)
{
MTable table = new MTable(getCtx(), p_AD_Table_ID, get_TrxName());
if (table != null)
processDatabaseTable(md, table);
}
else
processDatabase(md);
trx.close();
return Msg.getMsg(getCtx(), "CreateTableIndexProcessResult", new Object[] {countTable, countIndex, countError});
}
private void processDatabase(DatabaseMetaData md) throws Exception
{
String tableName = null;
String catalog = null;
String schema = null;
String[] types = {"TABLE"};
ResultSet rs = md.getTables(catalog, schema, tableName, types);
while (rs.next())
{
String dbTableName = rs.getString("TABLE_NAME");
if (dbTableName == null)
continue;
MTable table = MTable.get(getCtx(), dbTableName);
if (table != null) // exists in AD_Table
processDatabaseTable(md, table);
}
rs.close();
}
private void processDatabaseTable(DatabaseMetaData md, MTable table) throws Exception
{
Hashtable<String, DatabaseTableIndex> htIndexes = new Hashtable<String, DatabaseTableIndex>();
String catalog = "REFERENCE";
String schema = null;
String tableName = table.getTableName();
if (md.storesUpperCaseIdentifiers())
tableName = tableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
tableName = tableName.toLowerCase();
addLog(Msg.getMsg(getCtx(), "CreateTableIndexProcessTable") + tableName);
addLog(table.getAD_Table_ID(), null, null, table.toString(), table.get_Table_ID(), table.getAD_Table_ID());
++countTable;
ResultSet rs = md.getIndexInfo(catalog, schema, tableName, false, true);
while (rs.next())
{
String dbIndexName = rs.getString("INDEX_NAME");
if (dbIndexName == null)
continue;
String key = dbIndexName.toLowerCase();
DatabaseTableIndex dbTableIndex = htIndexes.get(key);
if (dbTableIndex == null)
dbTableIndex = new DatabaseTableIndex(dbIndexName, new String[30], true, null);
String columnName = rs.getString("COLUMN_NAME");
int pos = (rs.getShort("ORDINAL_POSITION"));
if (pos > 0)
dbTableIndex.columns[pos-1] = columnName;
dbTableIndex.isNonUnique = rs.getBoolean("NON_UNIQUE");
dbTableIndex.ascOrDesc = rs.getString("ASC_OR_DESC");
htIndexes.put(key, dbTableIndex);
}
rs.close();
if (!htIndexes.isEmpty())
processTableIndex(md, table, htIndexes);
htIndexes = null;
}
private void processTableIndex(DatabaseMetaData md, MTable table, Hashtable<String, DatabaseTableIndex> htIndexes) throws Exception
{
String catalog = null;
String schema = null;
String tableName = table.getTableName();
if (md.storesUpperCaseIdentifiers())
tableName = tableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
tableName = tableName.toLowerCase();
ResultSet rs = md.getPrimaryKeys(catalog, schema, tableName);
while (rs.next())
{
String primaryKeyName = rs.getString("PK_NAME");
String key = primaryKeyName.toLowerCase();
DatabaseTableIndex dbTableIndex = htIndexes.get(key);
if (dbTableIndex != null)
htIndexes.remove(key);
}
rs.close();
if (htIndexes.isEmpty())
return;
ArrayList<MTableIndex> tableIndexesToValidate = new ArrayList<MTableIndex>();
MTableIndex[] tableIndexes = MTableIndex.get(table);
for (MTableIndex tableIndex : tableIndexes)
{
String key = tableIndex.getName().toLowerCase();
DatabaseTableIndex dbTableIndex = htIndexes.get(key);
tableIndexesToValidate.add(tableIndex);
if (dbTableIndex != null)
htIndexes.remove(key);
}
String getColumnIDSql = "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID = ? AND LOWER(ColumnName) = ?";
Enumeration<DatabaseTableIndex> en = htIndexes.elements();
while (en.hasMoreElements())
{
DatabaseTableIndex dbTableIndex = en.nextElement();
addLog(Msg.getMsg(getCtx(), "CreateTableIndexCreateTableIndex") + dbTableIndex.indexName);
Trx trx = Trx.get(Trx.createTrxName("CreateTableIndex"), true);
try {
MTableIndex tableIndex = new MTableIndex(getCtx(), 0, get_TrxName());
tableIndex.setAD_Table_ID(table.getAD_Table_ID());
tableIndex.setName(dbTableIndex.indexName);
tableIndex.setIsUnique(!dbTableIndex.isNonUnique);
tableIndex.saveEx();
addLog(tableIndex.getAD_TableIndex_ID(), null, null, tableIndex.toString(), tableIndex.get_Table_ID(), tableIndex.getAD_TableIndex_ID());
for (int i = 0; i < 30; i++)
{
String dbIndexColumn = dbTableIndex.columns[i];
if (dbIndexColumn == null)
break;
int AD_Column_ID = DB.getSQLValue(get_TrxName(), getColumnIDSql, table.getAD_Table_ID(), dbIndexColumn.toLowerCase());
String columnName = dbIndexColumn;
if (AD_Column_ID > 0)
columnName = MColumn.getColumnName(getCtx(), AD_Column_ID);
MIndexColumn indexColumn = new MIndexColumn(getCtx(), 0, get_TrxName());
indexColumn.setAD_TableIndex_ID(tableIndex.getAD_TableIndex_ID());
if (AD_Column_ID > 0)
indexColumn.setAD_Column_ID(AD_Column_ID);
else
indexColumn.setColumnSQL(columnName);
String ascOrDesc = dbTableIndex.ascOrDesc;
if (ascOrDesc != null && ascOrDesc.equals("D"))
indexColumn.setColumnSQL(columnName + " DESC");
indexColumn.setSeqNo(i + 1);
indexColumn.saveEx();
addLog(indexColumn.getAD_IndexColumn_ID(), null, null, indexColumn.toString(), indexColumn.get_Table_ID(), indexColumn.getAD_IndexColumn_ID());
}
if (trx != null)
trx.commit();
++countIndex;
} catch (Exception e) {
addLog(Msg.getMsg(getCtx(), "Error") + e.getLocalizedMessage());
if (trx != null)
trx.rollback();
++countError;
} finally {
if (trx != null)
trx.close();
}
}
for (MTableIndex tableIndex : tableIndexesToValidate)
{
addLog(Msg.getMsg(getCtx(), "CreateTableIndexValidateTableIndex") + tableIndex.getName());
addLog(tableIndex.getAD_TableIndex_ID(), null, null, tableIndex.toString(), tableIndex.get_Table_ID(), tableIndex.getAD_TableIndex_ID());
Trx trx = Trx.get(Trx.createTrxName("ValidateTableIndex"), true);
try {
String result = TableIndexValidate.validateTableIndex(getCtx(), tableIndex, trx.getTrxName(), getProcessInfo());
addLog(result);
if (trx != null)
trx.commit();
++countIndex;
} catch (Exception e) {
addLog(Msg.getMsg(getCtx(), "Error") + e.getLocalizedMessage());
if (trx != null)
trx.rollback();
++countError;
} finally {
if (trx != null)
trx.close();
}
}
}
private class DatabaseTableIndex
{
private String indexName;
private String[] columns;
private boolean isNonUnique;
private String ascOrDesc;
private DatabaseTableIndex(String indexName, String[] columns, boolean isNonUnique, String ascOrDesc)
{
this.indexName = indexName;
this.columns = columns;
this.isNonUnique = isNonUnique;
this.ascOrDesc = ascOrDesc;
}
}
}

View File

@ -19,6 +19,7 @@ package org.compiere.process;
import java.math.BigDecimal;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MIndexColumn;
@ -43,8 +44,14 @@ public class TableIndexValidate extends SvrProcess {
MTableIndex index = new MTableIndex(getCtx(), p_AD_TableIndex_ID, get_TrxName());
log.info(index.toString());
Trx trx = Trx.get(get_TrxName(), true);
return validateTableIndex(getCtx(), index, get_TrxName(), getProcessInfo());
}
public static String validateTableIndex(Properties ctx, MTableIndex index, String trxName, ProcessInfo pi) throws Exception
{
Trx trx = Trx.get(trxName, true);
DatabaseMetaData md = trx.getConnection().getMetaData();
String tableName = index.getTableName();
if (md.storesUpperCaseIdentifiers())
tableName = tableName.toUpperCase();
@ -54,6 +61,7 @@ public class TableIndexValidate extends SvrProcess {
String catalog = "REFERENCE";
String schema = null;
String[] indexColsFromDB = new String[30];
String[] ascOrDescColsFromDB = new String[30];
int numIndexColsFromDB = 0;
boolean indexNUniqueInDB = true;
boolean found = false;
@ -70,7 +78,10 @@ public class TableIndexValidate extends SvrProcess {
String columnName = rs.getString("COLUMN_NAME");
int pos = (rs.getShort("ORDINAL_POSITION"));
if (pos > 0)
{
indexColsFromDB[pos-1] = columnName;
ascOrDescColsFromDB[pos-1] = rs.getString("ASC_OR_DESC");
}
indexNUniqueInDB = rs.getBoolean("NON_UNIQUE");
}
}
@ -81,16 +92,16 @@ public class TableIndexValidate extends SvrProcess {
boolean modified = false;
if (indexCols.length <= 0)
throw new AdempiereException(Msg.getMsg(getCtx(), "NoIndexColumnsSpecified"));
throw new AdempiereException(Msg.getMsg(ctx, "NoIndexColumnsSpecified"));
else if (!found)
{
String sql = index.getDDL();
int rvalue = DB.executeUpdate(sql, (Object[]) null, true, get_TrxName());
addLog(0, null, new BigDecimal(rvalue), sql);
int rvalue = DB.executeUpdate(sql, (Object[]) null, true, trxName);
pi.addLog(0, null, new BigDecimal(rvalue), sql);
if (rvalue == -1)
throw new AdempiereException(Msg.getMsg(getCtx(), "Failed to create index"));
throw new AdempiereException(Msg.getMsg(ctx, "Failed to create index"));
else
return Msg.getMsg(getCtx(), "CreatedIndexSuccess");
return Msg.getMsg(ctx, "CreatedIndexSuccess");
}
else
{
@ -111,9 +122,18 @@ public class TableIndexValidate extends SvrProcess {
{
for (int j = 0; j < indexCols.length; j++)
{
String indexColFromDBWithAscOrDesc = indexColsFromDB[j];
String ascOrDesc = ascOrDescColsFromDB[j];
if (ascOrDesc != null && ascOrDesc.equals("D"))
indexColFromDBWithAscOrDesc = indexColFromDBWithAscOrDesc + " DESC";
else if (ascOrDesc != null && ascOrDesc.equals("A"))
indexColFromDBWithAscOrDesc = indexColFromDBWithAscOrDesc + " ASC";
/*what if they are returned in a diff sequence ?*/
if (indexCols[j].getColumnName().equalsIgnoreCase(indexColsFromDB[j]))
continue;
if (indexCols[j].getColumnName().equalsIgnoreCase(indexColsFromDB[j]))
continue;
else if (indexCols[j].getColumnName().equalsIgnoreCase(indexColFromDBWithAscOrDesc))
continue;
else if ((indexColsFromDB[j].startsWith("\"")) && (indexColsFromDB[j].endsWith("\"")))
{
/* EDB returns varchar index columns wrapped with double quotes, hence comparing
@ -139,19 +159,19 @@ public class TableIndexValidate extends SvrProcess {
if (modified)
{
String sql = "DROP INDEX " + index.getName();
int rvalue = DB.executeUpdate(sql, (Object[]) null, true, get_TrxName());
addLog(0, null, new BigDecimal(rvalue), sql);
int rvalue = DB.executeUpdate(sql, (Object[]) null, true, trxName);
pi.addLog(0, null, new BigDecimal(rvalue), sql);
sql = index.getDDL();
rvalue = DB.executeUpdate(sql, (Object[]) null, true, get_TrxName());
addLog(0, null, new BigDecimal(rvalue), sql);
rvalue = DB.executeUpdate(sql, (Object[]) null, true, trxName);
pi.addLog(0, null, new BigDecimal(rvalue), sql);
if(rvalue == -1)
throw new AdempiereException(Msg.getMsg(getCtx(), "FailedModifyIndex"));
throw new AdempiereException(Msg.getMsg(ctx, "FailedModifyIndex"));
else
return Msg.getMsg(getCtx(), "ModifiedIndexSuccess");
return Msg.getMsg(ctx, "ModifiedIndexSuccess");
}
else
return Msg.getMsg(getCtx(), "NoChangesToIndex");
return Msg.getMsg(ctx, "NoChangesToIndex");
}
}
}