IDEMPIERE-454 Easy import / v1 -> Exporter - export data from 1 tab / Importer - allow insert in 1 tab
This commit is contained in:
parent
95622fc317
commit
066f24162e
|
@ -0,0 +1,93 @@
|
|||
-- Oct 7, 2012 7:15:57 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_ToolBarButton (Name,ComponentName,Classname,IsCustomization,KeyStroke_KeyCode,KeyStroke_Modifiers,AD_Client_ID,AD_Org_ID,Created,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_ToolBarButton_UU) VALUES ('zk Window - File Import','FileImport','org.idempiere.ui.window','N',0,0,0,0,TO_DATE('2012-10-07 19:15:57','YYYY-MM-DD HH24:MI:SS'),100,1000007,TO_DATE('2012-10-07 19:15:57','YYYY-MM-DD HH24:MI:SS'),100,'Y','afdd17a6-5fd1-411e-8596-5310aa68785f')
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:42:24 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Field {0} not found',200082,'D','a41866df-ebaf-4ea4-a5be-694b21d076c6','FieldNotFound','Y',TO_DATE('2012-10-25 23:42:22','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:42:22','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:42:24 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200082 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:43:32 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} not a window field',200083,'D','ff2e000e-330e-40d7-8da2-37c558c02fae','NotAWindowField','Y',TO_DATE('2012-10-25 23:43:31','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:43:31','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:43:32 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200083 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:01 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} is readonly',200084,'D','914303a5-b1b7-46db-9d3d-953258f1815c','FieldIsReadOnly','Y',TO_DATE('2012-10-25 23:45:00','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:45:00','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:01 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200084 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:50 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} is not displayed',200085,'D','6406807b-ead4-4bbe-9221-8d3936e77f22','FieldNotDisplayed','Y',TO_DATE('2012-10-25 23:45:49','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:45:49','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:50 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200085 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:46:55 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} not resolved = ({1})',200086,'D','bbaa12b8-df37-4a2a-812f-144bbfdef1a9','ForeignNotResolved','Y',TO_DATE('2012-10-25 23:46:53','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:46:53','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:46:55 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200086 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:48:44 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','ERROR: {0} parent cannot be changed',200087,'D','a47623df-6f91-42ad-9172-2459a680c3cf','ParentCannotChange','Y',TO_DATE('2012-10-25 23:48:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:48:43','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:48:44 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200087 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:49:42 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','ERROR: {0} not editable',200088,'D','78a73537-7dee-44cc-b66d-76cfba2fb199','FieldNotEditable','Y',TO_DATE('2012-10-25 23:49:40','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:49:40','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:49:42 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200088 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:46 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Successfully saved [{0}]',200089,'D','9d255a1a-e4ea-402b-98ee-ad168603b4c5','SuccessfullySaved','Y',TO_DATE('2012-10-25 23:50:45','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-25 23:50:45','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:46 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200089 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:57 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
UPDATE AD_Message SET MsgType='I',Updated=TO_DATE('2012-10-25 23:50:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200089
|
||||
;
|
||||
|
||||
SELECT register_migration_script('928_IDEMPIERE-454.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
-- Oct 7, 2012 7:15:57 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_ToolBarButton (Name,ComponentName,Classname,IsCustomization,KeyStroke_KeyCode,KeyStroke_Modifiers,AD_Client_ID,AD_Org_ID,Created,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_ToolBarButton_UU) VALUES ('zk Window - File Import','FileImport','org.idempiere.ui.window','N',0,0,0,0,TO_TIMESTAMP('2012-10-07 19:15:57','YYYY-MM-DD HH24:MI:SS'),100,1000007,TO_TIMESTAMP('2012-10-07 19:15:57','YYYY-MM-DD HH24:MI:SS'),100,'Y','afdd17a6-5fd1-411e-8596-5310aa68785f')
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:42:24 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Field {0} not found',200082,'D','a41866df-ebaf-4ea4-a5be-694b21d076c6','FieldNotFound','Y',TO_TIMESTAMP('2012-10-25 23:42:22','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:42:22','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:42:24 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200082 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:43:32 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} not a window field',200083,'D','ff2e000e-330e-40d7-8da2-37c558c02fae','NotAWindowField','Y',TO_TIMESTAMP('2012-10-25 23:43:31','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:43:31','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:43:32 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200083 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:01 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} is readonly',200084,'D','914303a5-b1b7-46db-9d3d-953258f1815c','FieldIsReadOnly','Y',TO_TIMESTAMP('2012-10-25 23:45:00','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:45:00','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:01 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200084 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:50 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} is not displayed',200085,'D','6406807b-ead4-4bbe-9221-8d3936e77f22','FieldNotDisplayed','Y',TO_TIMESTAMP('2012-10-25 23:45:49','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:45:49','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:45:50 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200085 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:46:55 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','{0} not resolved = ({1})',200086,'D','bbaa12b8-df37-4a2a-812f-144bbfdef1a9','ForeignNotResolved','Y',TO_TIMESTAMP('2012-10-25 23:46:53','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:46:53','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:46:55 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200086 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:48:44 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','ERROR: {0} parent cannot be changed',200087,'D','a47623df-6f91-42ad-9172-2459a680c3cf','ParentCannotChange','Y',TO_TIMESTAMP('2012-10-25 23:48:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:48:43','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:48:44 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200087 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:49:42 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','ERROR: {0} not editable',200088,'D','78a73537-7dee-44cc-b66d-76cfba2fb199','FieldNotEditable','Y',TO_TIMESTAMP('2012-10-25 23:49:40','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:49:40','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:49:42 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200088 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:46 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Successfully saved [{0}]',200089,'D','9d255a1a-e4ea-402b-98ee-ad168603b4c5','SuccessfullySaved','Y',TO_TIMESTAMP('2012-10-25 23:50:45','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-25 23:50:45','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:46 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
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=200089 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)
|
||||
;
|
||||
|
||||
-- Oct 25, 2012 11:50:57 PM COT
|
||||
-- IDEMPIERE-454 Easy import
|
||||
UPDATE AD_Message SET MsgType='I',Updated=TO_TIMESTAMP('2012-10-25 23:50:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200089
|
||||
;
|
||||
|
||||
SELECT register_migration_script('928_IDEMPIERE-454.sql') FROM dual
|
||||
;
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
<extension-point id="org.adempiere.base.IModelFactory" name="Model Factory" schema="schema/org.adempiere.base.IModelFactory.exsd"/>
|
||||
<extension-point id="org.adempiere.base.IDocFactory" name="Financial Document Factory" schema="schema/org.adempiere.base.IDocFactory.exsd"/>
|
||||
<extension-point id="org.adempiere.base.IGridTabExporter" name="Grid data export extension" schema="schema/org.adempiere.base.IGridTabExporter.exsd"/>
|
||||
<extension-point id="org.adempiere.base.IGridTabImporter" name="Grid data import extension" schema="schema/org.adempiere.base.IGridTabImporter.exsd"/>
|
||||
<extension-point id="org.compiere.model.PaymentProcessor" name="Payment Processor" schema="schema/org.compiere.model.PaymentProcessor.exsd"/>
|
||||
<extension-point id="org.compiere.model.Callout" name="Callout" schema="schema/org.compiere.model.Callout.exsd"/>
|
||||
<extension
|
||||
|
@ -51,6 +52,15 @@
|
|||
priority="0">
|
||||
</exporter>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.adempiere.impexp.GridTabCSVImporter"
|
||||
name="Grid data CSV importer"
|
||||
point="org.adempiere.base.IGridTabImporter">
|
||||
<importer
|
||||
class="org.adempiere.impexp.GridTabCSVImporter"
|
||||
priority="0">
|
||||
</importer>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.adempiere.base.ModelGeneratorApplication"
|
||||
name="Model Generator"
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.adempiere.base" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.adempiere.base" id="org.adempiere.base.IGridTabImporter" name="Grid data import extension"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
Extension point to provide import service for data from that is generated from the AD_Window definition. The client in use ( swing or zk ) is responsible to present all available import extension to user to pick the one to use.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice>
|
||||
<element ref="importer"/>
|
||||
</choice>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="importer">
|
||||
<complexType>
|
||||
<attribute name="priority" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
numeric priority value, higher value is of higher priority.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Implementation class name for the org.adempiere.base.IGridTabImporter interface
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.adempiere.base.IGridTabImporter"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
1.0.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
<pre>
|
||||
<extension
|
||||
id="org.adempiere.impexp.GridTabCSVImporter"
|
||||
name="Grid data CSV importer"
|
||||
point="org.adempiere.base.IGridTabImporter">
|
||||
<importer
|
||||
class="org.adempiere.impexp.GridTabCSVImporter"
|
||||
priority="0">
|
||||
</importer>
|
||||
</extension>
|
||||
</pre>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
The class attribute must represent an implementor of org.adempiere.base.IGridTabImporter
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
CSV import in org.adempiere.base
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
This file is part of iDempiere ERP http://www.idempiere.org.
|
||||
|
||||
Copyright (C) Carlos Ruiz
|
||||
Copyright (C) Trek Global
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms version 2 of the GNU General Public License as published
|
||||
by the Free Software Foundation. This program is distributed in the hope
|
||||
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
|
@ -48,4 +48,9 @@ public interface IGridTabExporter {
|
|||
* @return mime type
|
||||
*/
|
||||
public String getContentType();
|
||||
|
||||
/**
|
||||
* @return suggested file name
|
||||
*/
|
||||
public String getSuggestedFileName(GridTab gridTab);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/******************************************************************************
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Copyright (C) 2012 Carlos Ruiz *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.base;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.compiere.model.GridTab;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Carlos Ruiz
|
||||
*
|
||||
*/
|
||||
public interface IGridTabImporter {
|
||||
|
||||
/**
|
||||
* export gridTab data to file
|
||||
* @param gridTab
|
||||
* @param childs
|
||||
* @param filestream
|
||||
* @param charset
|
||||
*/
|
||||
public File fileImport(GridTab gridTab, List<GridTab> childs, InputStream filestream, Charset charset);
|
||||
|
||||
/**
|
||||
* @return file extension
|
||||
*/
|
||||
public String getFileExtension();
|
||||
|
||||
/**
|
||||
* @return description for file extension
|
||||
*/
|
||||
public String getFileExtensionLabel();
|
||||
|
||||
/**
|
||||
* @return mime type
|
||||
*/
|
||||
public String getContentType();
|
||||
|
||||
/**
|
||||
* @return suggested file name
|
||||
*/
|
||||
public String getSuggestedFileName(GridTab gridTab);
|
||||
}
|
|
@ -17,6 +17,7 @@ package org.adempiere.impexp;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -25,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.adempiere.base.IGridTabExporter;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.model.MTabCustomization;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
|
@ -77,7 +79,9 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
} else if (DisplayType.Time == column.getAD_Reference_ID()) {
|
||||
procArray.add(new Optional(new FmtDate("DisplayType.DEFAULT_TIME_FORMAT")));
|
||||
} else if (DisplayType.Integer == column.getAD_Reference_ID() || DisplayType.isNumeric(column.getAD_Reference_ID())) {
|
||||
procArray.add(new Optional(new FmtNumber(DisplayType.getNumberFormat(column.getAD_Reference_ID()))));
|
||||
DecimalFormat nf = DisplayType.getNumberFormat(column.getAD_Reference_ID());
|
||||
nf.setGroupingUsed(false);
|
||||
procArray.add(new Optional(new FmtNumber(nf)));
|
||||
} else if (DisplayType.YesNo == column.getAD_Reference_ID()) {
|
||||
procArray.add(new Optional(new FmtBool("Y", "N")));
|
||||
} else { // lookups and text
|
||||
|
@ -110,7 +114,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
mapWriter.write(row, header, processors);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new AdempiereException(e);
|
||||
} finally {
|
||||
if (mapWriter != null) {
|
||||
try {
|
||||
|
@ -125,7 +129,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
|
||||
private Object resolveValue(GridTab gridTab, MTable table, MColumn column, int i, String headName) {
|
||||
Object value = null;
|
||||
if (headName.contains("[") && headName.endsWith("]")) {
|
||||
if (headName.indexOf("[") >= 0 && headName.endsWith("]")) {
|
||||
String foreignTable = column.getReferenceTableName();
|
||||
Object idO = gridTab.getValue(i, column.getColumnName());
|
||||
if (idO != null) {
|
||||
|
@ -157,12 +161,14 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
String foreignTable = column.getReferenceTableName();
|
||||
if ( ! ("AD_Language".equals(foreignTable) || "AD_EntityType".equals(foreignTable))) {
|
||||
MTable fTable = MTable.get(Env.getCtx(), foreignTable);
|
||||
// Hardcoded / do not check for Value on AD_Org and AD_User, must use name for these two tables
|
||||
if (! ("AD_Org".equals(foreignTable) || "AD_User".equals(foreignTable))
|
||||
// Hardcoded / do not check for Value on AD_Org, AD_User and AD_Ref_List, must use name for these two tables
|
||||
if (! ("AD_Org".equals(foreignTable) || "AD_User".equals(foreignTable) || "AD_Ref_List".equals(foreignTable))
|
||||
&& fTable.getColumn("Value") != null) {
|
||||
name.append("[Value]"); // fully qualified
|
||||
} else if (fTable.getColumn("Name") != null) {
|
||||
name.append("[Name]");
|
||||
} else if (fTable.getColumn("DocumentNo") != null) {
|
||||
name.append("[DocumentNo]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +212,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
{
|
||||
if (gridField.getAD_Field_ID() == AD_Field_ID)
|
||||
{
|
||||
if(gridField.isDisplayedGrid())
|
||||
if (!gridField.isReadOnly() && gridField.isDisplayedGrid())
|
||||
fieldList.add(gridField);
|
||||
|
||||
break;
|
||||
|
@ -221,7 +227,9 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
|
||||
for (GridField field:tmpFields)
|
||||
{
|
||||
if(field.isDisplayedGrid())
|
||||
if ("AD_Client_ID".equals(field.getColumnName()))
|
||||
continue;
|
||||
if (field.isParentValue() || (!field.isReadOnly() && field.isDisplayedGrid()))
|
||||
gridFieldList.add(field);
|
||||
}
|
||||
|
||||
|
@ -238,19 +246,9 @@ public class GridTabCSVExporter implements IGridTabExporter
|
|||
return gridFields;
|
||||
}
|
||||
|
||||
public boolean isColumnPrinted(GridTab tab, int col)
|
||||
{
|
||||
GridField field = tab.getField(col);
|
||||
// field not displayed
|
||||
if (!field.isDisplayed())
|
||||
return false;
|
||||
// field encrypted
|
||||
if (field.isEncrypted())
|
||||
return false;
|
||||
// button without a reference value
|
||||
if (field.getDisplayType() == DisplayType.Button && field.getAD_Reference_Value_ID() == 0)
|
||||
return false;
|
||||
return true;
|
||||
@Override
|
||||
public String getSuggestedFileName(GridTab gridTab) {
|
||||
return "Export_" + gridTab.getTableName() + "." + getFileExtension();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,433 @@
|
|||
/******************************************************************************
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2012 Carlos Ruiz *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.impexp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.adempiere.base.IGridTabImporter;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.tools.FileUtil;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
import org.supercsv.cellprocessor.Optional;
|
||||
import org.supercsv.cellprocessor.ParseBigDecimal;
|
||||
import org.supercsv.cellprocessor.ParseBool;
|
||||
import org.supercsv.cellprocessor.ParseDate;
|
||||
import org.supercsv.cellprocessor.ParseInt;
|
||||
import org.supercsv.cellprocessor.constraint.StrMinMax;
|
||||
import org.supercsv.cellprocessor.constraint.StrNotNullOrEmpty;
|
||||
import org.supercsv.cellprocessor.ift.CellProcessor;
|
||||
import org.supercsv.exception.SuperCsvCellProcessorException;
|
||||
import org.supercsv.io.CsvMapReader;
|
||||
import org.supercsv.io.ICsvMapReader;
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
|
||||
/**
|
||||
* CSV Importer for GridTab
|
||||
* @author Carlos Ruiz
|
||||
*/
|
||||
public class GridTabCSVImporter implements IGridTabImporter
|
||||
{
|
||||
private static final String ERROR_HEADER = "_ERROR_";
|
||||
private static final String LOG_HEADER = "_LOG_";
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(GridTabCSVImporter.class);
|
||||
boolean m_isError = false;
|
||||
|
||||
public File fileImport(GridTab gridTab, List<GridTab> childs, InputStream filestream, Charset charset) {
|
||||
|
||||
ICsvMapReader mapReader = null;
|
||||
File errFile = null;
|
||||
File logFile = null;
|
||||
FileWriter errFileW = null;
|
||||
FileWriter logFileW = null;
|
||||
CsvPreference csvpref = CsvPreference.STANDARD_PREFERENCE;
|
||||
String delimiter = String.valueOf((char) csvpref.getDelimiterChar());
|
||||
String quoteChar = String.valueOf((char) csvpref.getQuoteChar());
|
||||
try {
|
||||
String errFileName = FileUtil.getTempMailName("Import_" + gridTab.getTableName(), "_err.csv");
|
||||
errFile = new File(errFileName);
|
||||
errFileW = new FileWriter(errFile, false);
|
||||
mapReader = new CsvMapReader(new InputStreamReader(filestream), csvpref);
|
||||
|
||||
String[] header = mapReader.getHeader(true);
|
||||
List<CellProcessor> readProcArray = new ArrayList<CellProcessor>();
|
||||
for (int idx = 0; idx < header.length; idx++) {
|
||||
String headName = header[idx];
|
||||
if (headName.equals(ERROR_HEADER) || headName.equals(LOG_HEADER)) {
|
||||
header[idx] = null;
|
||||
readProcArray.add(null);
|
||||
continue;
|
||||
}
|
||||
String columnName = headName;
|
||||
boolean isForeign = headName.indexOf("[") > 0 && headName.endsWith("]");
|
||||
if (isForeign) {
|
||||
int end = headName.indexOf("[");
|
||||
columnName = headName.substring(0, end);
|
||||
}
|
||||
GridField field = gridTab.getField(columnName);
|
||||
if (field == null) {
|
||||
throw new AdempiereException(Msg.getMsg(Env.getCtx(), "FieldNotFound", new Object[] {columnName}));
|
||||
}
|
||||
MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID());
|
||||
// TODO: List columns can use RequireSubStr constraint
|
||||
if (column.isMandatory()) {
|
||||
if (DisplayType.Date == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new ParseDate(DisplayType.DEFAULT_DATE_FORMAT));
|
||||
} else if (DisplayType.DateTime == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new ParseDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT));
|
||||
} else if (DisplayType.Time == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new ParseDate("DisplayType.DEFAULT_TIME_FORMAT"));
|
||||
} else if (DisplayType.Integer == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new ParseInt());
|
||||
} else if (DisplayType.isNumeric(column.getAD_Reference_ID())) {
|
||||
readProcArray.add(new ParseBigDecimal(new DecimalFormatSymbols(Language.getLoginLanguage().getLocale())));
|
||||
} else if (DisplayType.YesNo == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new ParseBool("y", "n"));
|
||||
} else if (DisplayType.isText(column.getAD_Reference_ID())) {
|
||||
readProcArray.add(new StrMinMax(1, column.getFieldLength()));
|
||||
} else { // mandatory lookups
|
||||
readProcArray.add(new StrNotNullOrEmpty());
|
||||
}
|
||||
} else {
|
||||
if (DisplayType.Date == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new Optional(new ParseDate(DisplayType.DEFAULT_DATE_FORMAT)));
|
||||
} else if (DisplayType.DateTime == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new Optional(new ParseDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT)));
|
||||
} else if (DisplayType.Time == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new Optional(new ParseDate("DisplayType.DEFAULT_TIME_FORMAT")));
|
||||
} else if (DisplayType.Integer == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new Optional(new ParseInt()));
|
||||
} else if (DisplayType.isNumeric(column.getAD_Reference_ID())) {
|
||||
readProcArray.add(new Optional(new ParseBigDecimal(new DecimalFormatSymbols(Language.getLoginLanguage().getLocale()))));
|
||||
} else if (DisplayType.YesNo == column.getAD_Reference_ID()) {
|
||||
readProcArray.add(new Optional(new ParseBool("y", "n")));
|
||||
} else if (DisplayType.isText(column.getAD_Reference_ID())) {
|
||||
readProcArray.add(new Optional(new StrMinMax(1, column.getFieldLength())));
|
||||
} else { // optional lookups and text
|
||||
readProcArray.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
CellProcessor[] processors = readProcArray.toArray(new CellProcessor[readProcArray.size()]);
|
||||
|
||||
m_isError = false;
|
||||
// write the header
|
||||
String rawHeader = mapReader.getUntokenizedRow();
|
||||
errFileW.write(rawHeader + delimiter + ERROR_HEADER + "\n");
|
||||
|
||||
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
|
||||
List<String> rawData = new ArrayList<String>();
|
||||
// pre-process to check for errors
|
||||
while (true) {
|
||||
Map<String, Object> map = null;
|
||||
boolean isLineError = false;
|
||||
StringBuilder errMsg = new StringBuilder();
|
||||
try {
|
||||
map = mapReader.read(header, processors);
|
||||
} catch (SuperCsvCellProcessorException e) {
|
||||
int idx = e.getCsvContext().getColumnNumber() - 1;
|
||||
errMsg.append(header[idx]).append(": ").append(e.getMessage());
|
||||
isLineError = true;
|
||||
}
|
||||
String rawLine = mapReader.getUntokenizedRow();
|
||||
if (! isLineError) {
|
||||
if (map == null)
|
||||
break;
|
||||
for (Entry<String, Object> set : map.entrySet()) {
|
||||
StringBuilder lineError = new StringBuilder();
|
||||
String headName = set.getKey();
|
||||
Object value = set.getValue();
|
||||
log.fine("Setting " + headName + " to " + value);
|
||||
|
||||
String columnName = headName;
|
||||
boolean isForeign = headName.indexOf("[") > 0 && headName.endsWith("]");
|
||||
String foreignColumn = null;
|
||||
if (isForeign) {
|
||||
int end = headName.indexOf("[");
|
||||
columnName = headName.substring(0, end);
|
||||
int startf = headName.indexOf("[")+1;
|
||||
int endf = headName.length()-1;
|
||||
foreignColumn = headName.substring(startf, endf);
|
||||
}
|
||||
GridField field = gridTab.getField(columnName);
|
||||
if (field == null) {
|
||||
lineError.append(Msg.getMsg(Env.getCtx(), "NotAWindowField", new Object[] {headName}));
|
||||
isLineError = true;
|
||||
}
|
||||
if (!isLineError && field.isReadOnly() && !field.isParentValue()) {
|
||||
lineError.append(Msg.getMsg(Env.getCtx(), "FieldIsReadOnly", new Object[] {headName}));
|
||||
isLineError = true;
|
||||
}
|
||||
if (!isLineError && ! ( field.isDisplayed() || field.isDisplayedGrid() )) {
|
||||
lineError.append(Msg.getMsg(Env.getCtx(), "FieldNotDisplayed", new Object[] {headName}));
|
||||
isLineError = true;
|
||||
}
|
||||
if (!isLineError) {
|
||||
MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID());
|
||||
if (isForeign) {
|
||||
String foreignTable = column.getReferenceTableName();
|
||||
String idS = null;
|
||||
int id = -1;
|
||||
if ("AD_Ref_List".equals(foreignTable)) {
|
||||
idS = resolveForeignList(column, foreignColumn, value);
|
||||
} else {
|
||||
id = resolveForeign(foreignTable, foreignColumn, value);
|
||||
}
|
||||
if (idS == null && id < 0) {
|
||||
lineError.append(Msg.getMsg(Env.getCtx(), "ForeignNotResolved", new Object[] {headName, value.toString()}));
|
||||
isLineError = true;
|
||||
}
|
||||
} else {
|
||||
// no validation here
|
||||
// TODO: we could validate length of string or min/max
|
||||
}
|
||||
}
|
||||
if (isLineError && lineError.length() > 0) {
|
||||
if (errMsg.length() > 0)
|
||||
errMsg.append(" / ");
|
||||
errMsg.append(lineError);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLineError && ! m_isError)
|
||||
m_isError = true;
|
||||
if (!m_isError) {
|
||||
data.add(map);
|
||||
rawData.add(rawLine);
|
||||
}
|
||||
// write
|
||||
rawLine = rawLine + delimiter + quoteChar + errMsg.toString().replaceAll(quoteChar, "") + quoteChar + "\n";
|
||||
errFileW.write(rawLine);
|
||||
}
|
||||
|
||||
if (!m_isError) {
|
||||
String logFileName = FileUtil.getTempMailName("Import_" + gridTab.getTableName(), "_log.csv");
|
||||
logFile = new File(logFileName);
|
||||
logFileW = new FileWriter(logFile, false);
|
||||
|
||||
// write the header
|
||||
logFileW.write(rawHeader + delimiter + LOG_HEADER + "\n");
|
||||
|
||||
// no errors found - then process
|
||||
for (int idx = 0; idx < data.size(); idx++) {
|
||||
String rawLine = rawData.get(idx);
|
||||
String trxName = null;
|
||||
String logMsg = null;
|
||||
Trx trx = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
trxName = "Import_" + gridTab.getTableName() + "_" + UUID.randomUUID();
|
||||
trx = Trx.get(trxName, true);
|
||||
Map<String, Object> map = data.get(idx);
|
||||
gridTab.getTableModel().setImportingMode(true, trxName);
|
||||
gridTab.dataNew(false);
|
||||
for (String headName : header) {
|
||||
if (headName == null)
|
||||
continue;
|
||||
Object value = map.get(headName);
|
||||
|
||||
String columnName = headName;
|
||||
boolean isForeign = headName.indexOf("[") > 0 && headName.endsWith("]");
|
||||
String foreignColumn = null;
|
||||
if (isForeign) {
|
||||
int end = headName.indexOf("[");
|
||||
columnName = headName.substring(0, end);
|
||||
int startf = headName.indexOf("[")+1;
|
||||
int endf = headName.length()-1;
|
||||
foreignColumn = headName.substring(startf, endf);
|
||||
}
|
||||
GridField field = gridTab.getField(columnName);
|
||||
if (field.isParentValue())
|
||||
continue;
|
||||
MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID());
|
||||
Object setValue = null;
|
||||
if (isForeign) {
|
||||
String foreignTable = column.getReferenceTableName();
|
||||
if ("AD_Ref_List".equals(foreignTable)) {
|
||||
String idS = resolveForeignList(column, foreignColumn, value);
|
||||
setValue = idS;
|
||||
} else {
|
||||
int id = resolveForeign(foreignTable, foreignColumn, value);
|
||||
setValue = id;
|
||||
if (field.isParentValue()) {
|
||||
int actualId = (Integer) field.getValue();
|
||||
if (actualId != id) {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "ParentCannotChange", new Object[] {headName});
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (value != null) {
|
||||
if (value != null && value instanceof java.util.Date)
|
||||
value = new Timestamp(((java.util.Date)value).getTime());
|
||||
setValue = value;
|
||||
}
|
||||
}
|
||||
if (value != null) {
|
||||
if (field.isEditable(true)) {
|
||||
gridTab.setValue(columnName, setValue);
|
||||
} else {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "FieldNotEditable", new Object[] {headName});
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! error) {
|
||||
if (gridTab.dataSave(false)) {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "SuccessfullySaved", new Object[] {gridTab.getTableModel().getKeyID(gridTab.getCurrentRow())});
|
||||
} else {
|
||||
error = true;
|
||||
ValueNamePair ppE = CLogger.retrieveWarning();
|
||||
String info = null;
|
||||
if (ppE != null)
|
||||
info = ppE.getName();
|
||||
if (info == null)
|
||||
info = "";
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "Error") + " " + Msg.getMsg(Env.getCtx(), "SaveError") + " (" + info + ")";
|
||||
gridTab.dataIgnore();
|
||||
}
|
||||
} else {
|
||||
gridTab.dataIgnore();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "Error") + " " + e.getLocalizedMessage();
|
||||
error = true;
|
||||
} finally {
|
||||
if (trx != null) {
|
||||
if (error) {
|
||||
trx.rollback();
|
||||
} else {
|
||||
trx.commit();
|
||||
}
|
||||
trx.close();
|
||||
trx = null;
|
||||
}
|
||||
gridTab.getTableModel().setImportingMode(false, null);
|
||||
}
|
||||
// write
|
||||
logMsg = logMsg.replaceAll(delimiter, "");
|
||||
rawLine = rawLine + delimiter + quoteChar + logMsg + quoteChar + "\n";
|
||||
logFileW.write(rawLine);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (mapReader != null)
|
||||
mapReader.close();
|
||||
if (errFileW != null) {
|
||||
errFileW.flush();
|
||||
errFileW.close();
|
||||
}
|
||||
if (logFileW != null) {
|
||||
logFileW.flush();
|
||||
logFileW.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (logFile != null)
|
||||
return logFile;
|
||||
else
|
||||
return errFile;
|
||||
}
|
||||
|
||||
private String resolveForeignList(MColumn column, String foreignColumn, Object value) {
|
||||
String idS = null;
|
||||
StringBuilder select = new StringBuilder("SELECT Value FROM AD_Ref_List WHERE ")
|
||||
.append(foreignColumn).append("=? AND AD_Reference_ID=? AND IsActive='Y'");
|
||||
idS = DB.getSQLValueStringEx(null, select.toString(), value, column.getAD_Reference_Value_ID());
|
||||
return idS;
|
||||
}
|
||||
|
||||
private int resolveForeign(String foreignTable, String foreignColumn, Object value) {
|
||||
int id = -1;
|
||||
StringBuilder select = new StringBuilder("SELECT ")
|
||||
.append(foreignTable).append("_ID FROM ")
|
||||
.append(foreignTable).append(" WHERE ")
|
||||
.append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID=?");
|
||||
id = DB.getSQLValueEx(null, select.toString(), value, Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (id == -1 && !"AD_Client".equals(foreignTable)) {
|
||||
MTable ft = MTable.get(Env.getCtx(), foreignTable);
|
||||
String accessLevel = ft.getAccessLevel();
|
||||
if ( MTable.ACCESSLEVEL_All.equals(accessLevel)
|
||||
|| MTable.ACCESSLEVEL_SystemOnly.equals(accessLevel)
|
||||
|| MTable.ACCESSLEVEL_SystemPlusClient.equals(accessLevel)) {
|
||||
// try System client if the table has System access
|
||||
id = DB.getSQLValueEx(null, select.toString(), value, 0);
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileExtension() {
|
||||
return "csv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileExtensionLabel() {
|
||||
return Msg.getMsg(Env.getCtx(), "FileCSV");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return "application/csv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuggestedFileName(GridTab gridTab) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dt = sdf.format(cal.getTime());
|
||||
String localFile = "Import_" + gridTab.getTableName() + "_" + dt
|
||||
+ (m_isError ? "_err" : "_log")
|
||||
+ "." + getFileExtension();
|
||||
return localFile;
|
||||
}
|
||||
|
||||
}
|
|
@ -177,4 +177,9 @@ public class GridTabExcelExporter extends AbstractExcelExporter implements IGrid
|
|||
public String getContentType() {
|
||||
return "application/vnd.ms-excel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuggestedFileName(GridTab gridTab) {
|
||||
return gridTab.getName() + "." + getFileExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class GridTable extends AbstractTableModel
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4648364477309024202L;
|
||||
private static final long serialVersionUID = 2328810326636468776L;
|
||||
|
||||
public static final String DATA_REFRESH_MESSAGE = "Refreshed";
|
||||
|
||||
|
@ -2040,10 +2040,12 @@ public class GridTable extends AbstractTableModel
|
|||
//
|
||||
MTable table = MTable.get (m_ctx, m_AD_Table_ID);
|
||||
PO po = null;
|
||||
if (! m_importing) // Just use trx when importing
|
||||
m_trxName = null;
|
||||
if (Record_ID != -1)
|
||||
po = table.getPO(Record_ID, null);
|
||||
po = table.getPO(Record_ID, m_trxName);
|
||||
else // Multi - Key
|
||||
po = table.getPO(getWhereClause(rowData), null);
|
||||
po = table.getPO(getWhereClause(rowData), m_trxName);
|
||||
// No Persistent Object
|
||||
if (po == null)
|
||||
throw new ClassNotFoundException ("No Persistent Object");
|
||||
|
@ -2374,6 +2376,10 @@ public class GridTable extends AbstractTableModel
|
|||
/** LOB Info */
|
||||
private ArrayList<PO_LOB> m_lobInfo = null;
|
||||
|
||||
// IDEMPIERE-454 Easy import
|
||||
private boolean m_importing = false;
|
||||
private String m_trxName = null;
|
||||
|
||||
/**
|
||||
* Reset LOB info
|
||||
*/
|
||||
|
@ -3707,10 +3713,19 @@ public class GridTable extends AbstractTableModel
|
|||
PO po = null;
|
||||
int Record_ID = getKeyID(row);
|
||||
if (Record_ID != -1)
|
||||
po = table.getPO(Record_ID, null);
|
||||
po = table.getPO(Record_ID, m_trxName);
|
||||
else // Multi - Key
|
||||
po = table.getPO(getWhereClause(getDataAtRow(row)), null);
|
||||
po = table.getPO(getWhereClause(getDataAtRow(row)), m_trxName);
|
||||
return po;
|
||||
}
|
||||
|
||||
public void setImportingMode(boolean importing, String trxName) {
|
||||
m_importing = importing;
|
||||
m_trxName = trxName;
|
||||
}
|
||||
|
||||
public boolean isImporting() {
|
||||
return m_importing;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -145,4 +145,9 @@ public class GridTab2PackExporter implements IGridTabExporter {
|
|||
public String getContentType() {
|
||||
return "application/zip";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuggestedFileName(GridTab gridTab) {
|
||||
return gridTab.getName() + "." + getFileExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 904447827065380369L;
|
||||
private static final long serialVersionUID = 3390505814516682801L;
|
||||
|
||||
private static final String BTNPREFIX = "Btn";
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
|
||||
private ToolBarButton btnCustomize;
|
||||
|
||||
private ToolBarButton btnExport;
|
||||
private ToolBarButton btnExport, btnFileImport;
|
||||
|
||||
private ToolBarButton btnProcess;
|
||||
|
||||
|
@ -186,6 +186,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
{
|
||||
btnExport = createButton("Export", "Export", "Export");
|
||||
}
|
||||
btnFileImport = createButton("FileImport", "FileImport", "FileImport");
|
||||
|
||||
configureKeyMap();
|
||||
|
||||
|
@ -548,6 +549,15 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
btnExport.setDisabled(!b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable file import button
|
||||
* @param b
|
||||
*/
|
||||
public void enableFileImport(boolean b) {
|
||||
if (btnFileImport != null)
|
||||
btnFileImport.setDisabled(!b);
|
||||
}
|
||||
|
||||
private boolean ToolBarMenuRestictionLoaded = false;
|
||||
public void updateToolBarAndMenuWithRestriction(int AD_Window_ID) {
|
||||
if (ToolBarMenuRestictionLoaded)
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.adempiere.webui.panel.InfoPanel;
|
|||
import org.adempiere.webui.panel.WAttachment;
|
||||
import org.adempiere.webui.panel.WDocActionPanel;
|
||||
import org.adempiere.webui.panel.action.ExportAction;
|
||||
import org.adempiere.webui.panel.action.FileImportAction;
|
||||
import org.adempiere.webui.panel.action.ReportAction;
|
||||
import org.adempiere.webui.part.AbstractUIPart;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -1202,12 +1203,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
// Confirm Warning
|
||||
else if (e.isWarning() && !e.isConfirmed())
|
||||
{
|
||||
if (! adTabbox.getSelectedGridTab().getTableModel().isImporting()) {
|
||||
FDialog.warn(curWindowNo, null, e.getAD_Message(), e.getInfo());
|
||||
e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = e.isChanged() || e.isInserting();
|
||||
boolean readOnly = tabPanel.getGridTab().isReadOnly();
|
||||
boolean readOnly = adTabbox.getSelectedGridTab().isReadOnly();
|
||||
boolean insertRecord = !readOnly;
|
||||
if (!detailTab)
|
||||
{
|
||||
|
@ -1337,10 +1340,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted());
|
||||
toolbar.enableReport(true);
|
||||
toolbar.enableExport(!adTabbox.getSelectedGridTab().isSortTab());
|
||||
toolbar.enableFileImport(!changed && !adTabbox.getSelectedGridTab().isSortTab() && adTabbox.getSelectedGridTab().isInsertRecord());
|
||||
|
||||
//Deepak-Enabling customize button IDEMPIERE-364
|
||||
if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab))
|
||||
toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView());
|
||||
toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView() && !adTabbox.getSelectedGridTab().isSortTab());
|
||||
toolbar.updateToolBarAndMenuWithRestriction(gridWindow.getAD_Window_ID());
|
||||
}
|
||||
|
||||
|
@ -2155,6 +2158,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
action.export();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileImport() {
|
||||
FileImportAction action = new FileImportAction(this);
|
||||
action.fileImport();
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Start Button Process
|
||||
* @param vButton button
|
||||
|
|
|
@ -165,6 +165,11 @@ public interface ToolbarListener
|
|||
*/
|
||||
public void onExport();
|
||||
|
||||
/**
|
||||
* File import data
|
||||
*/
|
||||
public void onFileImport();
|
||||
|
||||
/**
|
||||
* Customize grid view.
|
||||
*/
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ExportAction implements EventListener<Event>
|
|||
Hbox hb = new Hbox();
|
||||
Div div = new Div();
|
||||
div.setAlign("right");
|
||||
div.appendChild(new Label("Files of Type: "));
|
||||
div.appendChild(new Label(Msg.getMsg(Env.getCtx(), "FilesOfType")));
|
||||
hb.appendChild(div);
|
||||
hb.appendChild(cboType);
|
||||
cboType.setWidth("100%");
|
||||
|
@ -195,7 +195,7 @@ public class ExportAction implements EventListener<Event>
|
|||
winExportFile.onClose();
|
||||
winExportFile = null;
|
||||
AMedia media = null;
|
||||
media = new AMedia(panel.getActiveGridTab().getName() + "." + ext, null, exporter.getContentType(), file, true);
|
||||
media = new AMedia(exporter.getSuggestedFileName(panel.getActiveGridTab()), null, exporter.getContentType(), file, true);
|
||||
Filedownload.save(media, panel.getActiveGridTab().getName() + "." + ext);
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException(e);
|
||||
|
|
|
@ -0,0 +1,277 @@
|
|||
/******************************************************************************
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Copyright (C) 2012 Carlos Ruiz *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.panel.action;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.adempiere.base.IGridTabImporter;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.webui.adwindow.AbstractADWindowContent;
|
||||
import org.adempiere.webui.adwindow.IADTabbox;
|
||||
import org.adempiere.webui.adwindow.IADTabpanel;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListItem;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.util.ReaderInputStream;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.util.media.Media;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.UploadEvent;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Carlos Ruiz
|
||||
*
|
||||
*/
|
||||
public class FileImportAction implements EventListener<Event>
|
||||
{
|
||||
private AbstractADWindowContent panel;
|
||||
|
||||
private Map<String, IGridTabImporter> importerMap = null;
|
||||
private Map<String, String> extensionMap = null;
|
||||
|
||||
private Window winImportFile = null;
|
||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
private Listbox cboType = new Listbox();
|
||||
private Button bFile = new Button();
|
||||
private Listbox fCharset = new Listbox();
|
||||
private InputStream m_file_istream = null;
|
||||
|
||||
/**
|
||||
* @param panel
|
||||
*/
|
||||
public FileImportAction(AbstractADWindowContent panel)
|
||||
{
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* execute import action
|
||||
*/
|
||||
public void fileImport()
|
||||
{
|
||||
// charset
|
||||
Charset[] charsets = Ini.getAvailableCharsets();
|
||||
for (int i = 0; i < charsets.length; i++)
|
||||
fCharset.appendItem(charsets[i].displayName(), charsets[i]);
|
||||
Charset charset = Ini.getCharset();
|
||||
for (int i = 0; i < fCharset.getItemCount(); i++)
|
||||
{
|
||||
ListItem listitem = fCharset.getItemAtIndex(i);
|
||||
Charset compare = (Charset)listitem.getValue();
|
||||
|
||||
if (charset == compare)
|
||||
{
|
||||
fCharset.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: change the streamreader when changing the charset
|
||||
// fCharset.addEventListener(Events.ON_SELECT, this);
|
||||
|
||||
importerMap = new HashMap<String, IGridTabImporter>();
|
||||
extensionMap = new HashMap<String, String>();
|
||||
List<IGridTabImporter> importerList = Service.list(IGridTabImporter.class);
|
||||
for(IGridTabImporter importer : importerList)
|
||||
{
|
||||
String extension = importer.getFileExtension();
|
||||
if (!extensionMap.containsKey(extension))
|
||||
{
|
||||
extensionMap.put(extension, importer.getFileExtensionLabel());
|
||||
importerMap.put(extension, importer);
|
||||
}
|
||||
}
|
||||
|
||||
if (winImportFile == null)
|
||||
{
|
||||
winImportFile = new Window();
|
||||
winImportFile.setTitle(Msg.getMsg(Env.getCtx(), "FileImport") + ": " + panel.getActiveGridTab().getName());
|
||||
winImportFile.setWidth("450px");
|
||||
winImportFile.setClosable(true);
|
||||
winImportFile.setBorder("normal");
|
||||
winImportFile.setStyle("position:absolute");
|
||||
|
||||
cboType.setMold("select");
|
||||
|
||||
cboType.getItems().clear();
|
||||
for(Map.Entry<String, String> entry : extensionMap.entrySet())
|
||||
{
|
||||
cboType.appendItem(entry.getKey() + " - " + entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
||||
cboType.setSelectedIndex(0);
|
||||
|
||||
Vbox vb = new Vbox();
|
||||
vb.setWidth("100%");
|
||||
winImportFile.appendChild(vb);
|
||||
|
||||
Hbox hb = new Hbox();
|
||||
Div div = new Div();
|
||||
div.setAlign("right");
|
||||
div.appendChild(new Label(Msg.getMsg(Env.getCtx(), "FilesOfType")));
|
||||
hb.appendChild(div);
|
||||
hb.appendChild(cboType);
|
||||
cboType.setWidth("100%");
|
||||
vb.appendChild(hb);
|
||||
|
||||
hb = new Hbox();
|
||||
bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
|
||||
bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
|
||||
bFile.setUpload("true");
|
||||
bFile.addEventListener(Events.ON_UPLOAD, this);
|
||||
hb.appendChild(bFile);
|
||||
vb.appendChild(hb);
|
||||
|
||||
hb = new Hbox();
|
||||
fCharset.setMold("select");
|
||||
fCharset.setRows(0);
|
||||
fCharset.setTooltiptext(Msg.getMsg(Env.getCtx(), "Charset", false));
|
||||
hb.appendChild(fCharset);
|
||||
vb.appendChild(hb);
|
||||
|
||||
vb.appendChild(confirmPanel);
|
||||
confirmPanel.addActionListener(this);
|
||||
}
|
||||
|
||||
winImportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
AEnv.showWindow(winImportFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (event instanceof UploadEvent)
|
||||
{
|
||||
UploadEvent ue = (UploadEvent) event;
|
||||
processUploadMedia(ue.getMedia());
|
||||
} else if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) {
|
||||
winImportFile.onClose();
|
||||
}
|
||||
else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) {
|
||||
// TODO: Verify that file and charset are mandatory
|
||||
importFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void processUploadMedia(Media media) {
|
||||
if (media == null)
|
||||
return;
|
||||
|
||||
if (media.isBinary()) {
|
||||
m_file_istream = media.getStreamData();
|
||||
}
|
||||
else {
|
||||
ListItem listitem = fCharset.getSelectedItem();
|
||||
if (listitem == null) {
|
||||
m_file_istream = new ReaderInputStream(media.getReaderData());
|
||||
} else {
|
||||
Charset charset = (Charset)listitem.getValue();
|
||||
m_file_istream = new ReaderInputStream(media.getReaderData(), charset.name());
|
||||
}
|
||||
}
|
||||
|
||||
bFile.setLabel(media.getName());
|
||||
}
|
||||
|
||||
private void importFile() {
|
||||
try {
|
||||
ListItem li = cboType.getSelectedItem();
|
||||
if(li == null || li.getValue() == null)
|
||||
{
|
||||
FDialog.error(0, winImportFile, "FileInvalidExtension");
|
||||
return;
|
||||
}
|
||||
|
||||
String ext = li.getValue().toString();
|
||||
IGridTabImporter importer = importerMap.get(ext);
|
||||
if (importer == null)
|
||||
{
|
||||
FDialog.error(0, winImportFile, "FileInvalidExtension");
|
||||
return;
|
||||
}
|
||||
|
||||
IADTabbox adTab = panel.getADTab();
|
||||
int selected = adTab.getSelectedIndex();
|
||||
int tabLevel = panel.getActiveGridTab().getTabLevel();
|
||||
Set<String> tables = new HashSet<String>();
|
||||
List<GridTab> childs = new ArrayList<GridTab>();
|
||||
List<GridTab> includedList = panel.getActiveGridTab().getIncludedTabs();
|
||||
for(GridTab included : includedList)
|
||||
{
|
||||
String tableName = included.getTableName();
|
||||
if (tables.contains(tableName))
|
||||
continue;
|
||||
tables.add(tableName);
|
||||
childs.add(included);
|
||||
}
|
||||
for(int i = selected+1; i < adTab.getTabCount(); i++)
|
||||
{
|
||||
IADTabpanel adTabPanel = adTab.getADTabpanel(i);
|
||||
if (adTabPanel.getGridTab().isSortTab())
|
||||
continue;
|
||||
if (adTabPanel.getGridTab().getTabLevel() <= tabLevel)
|
||||
break;
|
||||
String tableName = adTabPanel.getGridTab().getTableName();
|
||||
if (tables.contains(tableName))
|
||||
continue;
|
||||
tables.add(tableName);
|
||||
childs.add(adTabPanel.getGridTab());
|
||||
}
|
||||
|
||||
ListItem listitem = fCharset.getSelectedItem();
|
||||
Charset charset = null;
|
||||
if (listitem == null)
|
||||
return;
|
||||
charset = (Charset)listitem.getValue();
|
||||
|
||||
File outFile = importer.fileImport(panel.getActiveGridTab(), childs, m_file_istream, charset);
|
||||
winImportFile.onClose();
|
||||
winImportFile = null;
|
||||
|
||||
AMedia media = null;
|
||||
media = new AMedia(importer.getSuggestedFileName(panel.getActiveGridTab()), null, importer.getContentType(), outFile, true);
|
||||
Filedownload.save(media, panel.getActiveGridTab().getName() + "." + ext);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException(e);
|
||||
} finally {
|
||||
if (winImportFile != null)
|
||||
winImportFile.onClose();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue