From aecfe6fc5d4b2c881ca219408628dd6865357984 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 12 Mar 2013 00:43:00 -0500 Subject: [PATCH] IDEMPIERE-454 Easy import (Work in progress) --- .../oracle/201302110600_IDEMPIERE-454.sql | 5 --- .../postgresql/201302110600_IDEMPIERE-454.sql | 5 --- .../adempiere/impexp/GridTabCSVExporter.java | 31 ++++++++++++------- .../adempiere/impexp/GridTabCSVImporter.java | 6 ++-- .../webui/panel/action/ExportAction.java | 2 +- .../webui/panel/action/FileImportAction.java | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/migration/i1.0a-release/oracle/201302110600_IDEMPIERE-454.sql b/migration/i1.0a-release/oracle/201302110600_IDEMPIERE-454.sql index a55eb29c1d..14fac9c1df 100644 --- a/migration/i1.0a-release/oracle/201302110600_IDEMPIERE-454.sql +++ b/migration/i1.0a-release/oracle/201302110600_IDEMPIERE-454.sql @@ -48,11 +48,6 @@ INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,V 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=200153 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) ; --- Mar 11, 2013 4:04:53 PM COT --- IDEMPIERE-454 Easy import -UPDATE C_AcctProcessor SET DateNextRun=TO_DATE('2013-03-11 16:14:53','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_DATE('2013-03-11 16:04:53','YYYY-MM-DD HH24:MI:SS'),Updated=TO_DATE('2013-03-11 16:04:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctProcessor_ID=100 -; - -- Mar 11, 2013 4:10:39 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','Wrong detail name{0}, it must contain the character ''>'':{1} ',200154,'D','b82cafbc-f6d0-4002-b358-a4a9783f77c2','WrongDetailName','Y',TO_DATE('2013-03-11 16:10:38','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2013-03-11 16:10:38','YYYY-MM-DD HH24:MI:SS')) diff --git a/migration/i1.0a-release/postgresql/201302110600_IDEMPIERE-454.sql b/migration/i1.0a-release/postgresql/201302110600_IDEMPIERE-454.sql index 77caea3a2f..93e31de144 100644 --- a/migration/i1.0a-release/postgresql/201302110600_IDEMPIERE-454.sql +++ b/migration/i1.0a-release/postgresql/201302110600_IDEMPIERE-454.sql @@ -48,11 +48,6 @@ INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,V 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=200153 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) ; --- Mar 11, 2013 4:04:53 PM COT --- IDEMPIERE-454 Easy import -UPDATE C_AcctProcessor SET DateNextRun=TO_TIMESTAMP('2013-03-11 16:14:53','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_TIMESTAMP('2013-03-11 16:04:53','YYYY-MM-DD HH24:MI:SS'),Updated=TO_TIMESTAMP('2013-03-11 16:04:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctProcessor_ID=100 -; - -- Mar 11, 2013 4:10:39 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','Wrong detail name{0}, it must contain the character ''>'':{1} ',200154,'D','b82cafbc-f6d0-4002-b358-a4a9783f77c2','WrongDetailName','Y',TO_TIMESTAMP('2013-03-11 16:10:38','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2013-03-11 16:10:38','YYYY-MM-DD HH24:MI:SS')) diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java index 97a32c4bd3..52a8cf29e8 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java @@ -24,6 +24,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.logging.Level; import org.adempiere.base.IGridTabExporter; import org.adempiere.exceptions.AdempiereException; @@ -37,13 +38,14 @@ import org.compiere.model.MColumn; import org.compiere.model.MLocation; import org.compiere.model.MQuery; import org.compiere.model.MRefList; +import org.compiere.model.MTab; import org.compiere.model.MTable; +import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; -import org.jfree.util.Log; import org.supercsv.cellprocessor.FmtBool; import org.supercsv.cellprocessor.FmtDate; import org.supercsv.cellprocessor.FmtNumber; @@ -60,6 +62,9 @@ import org.supercsv.prefs.CsvPreference; */ public class GridTabCSVExporter implements IGridTabExporter { + /** Logger */ + private static CLogger log = CLogger.getCLogger(GridTabCSVExporter.class); + @Override public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file) { @@ -69,9 +74,9 @@ public class GridTabCSVExporter implements IGridTabExporter MTable tableDetail = null; try { mapWriter = new CsvMapWriter(new FileWriter(file), CsvPreference.STANDARD_PREFERENCE); - String IsValidTab = IsValidTabToExport(gridTab); - if (IsValidTab!=null){ - Log.info(IsValidTab); + String isValidTab = isValidTabToExport(gridTab); + if (isValidTab!=null){ + if (log.isLoggable(Level.INFO)) log.info(isValidTab); return; } GridTable gt = gridTab.getTableModel(); @@ -125,9 +130,9 @@ public class GridTabCSVExporter implements IGridTabExporter if(detail.getTabLevel()>1) continue; - IsValidTab = IsValidTabToExport(detail); - if (IsValidTab!=null){ - Log.info(IsValidTab); + isValidTab = isValidTabToExport(detail); + if (isValidTab!=null){ + if (log.isLoggable(Level.INFO)) log.info(isValidTab); continue; } tableDetail = MTable.get(Env.getCtx(), detail.getTableName()); @@ -270,14 +275,16 @@ public class GridTabCSVExporter implements IGridTabExporter } //add constraints to not allow certain tabs - private String IsValidTabToExport(GridTab gridTab){ + private String isValidTabToExport(GridTab gridTab){ String result=null; - - if(gridTab.isReadOnly()) + + MTab tab = new MTab(Env.getCtx(), gridTab.getAD_Tab_ID(), null); + + if (tab.isReadOnly()) result = Msg.getMsg(Env.getCtx(),"FieldIsReadOnly", new Object[] {gridTab.getName()}); - if(gridTab.getTableName().endsWith("_Acct")) - result = "Accounting Tab cannot be exported "+ gridTab.getName(); + if (gridTab.getTableName().endsWith("_Acct")) + result = "Accounting Tab are not exported by default: "+ gridTab.getName(); return result; } diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java index 9ba4ddd633..2df8fc4363 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java @@ -31,8 +31,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import java.util.logging.Level; import java.util.UUID; +import java.util.logging.Level; import org.adempiere.base.IGridTabImporter; import org.adempiere.exceptions.AdempiereException; @@ -503,7 +503,7 @@ public class GridTabCSVImporter implements IGridTabImporter private List getOrderedRowFromMap (List header,Map map){ List tmpRow= new ArrayList(); - for(String item : header) + for (int i = 0; i < header.size(); i++) tmpRow.add(null); for(Map.Entry record : map.entrySet()) { @@ -730,7 +730,7 @@ public class GridTabCSVImporter implements IGridTabImporter } if (!field.isEditable(true) && value!=null) { - logMsg = Msg.getMsg(Env.getCtx(), "FieldNotEditable")+" "+header.get(i)+"{"+value+"}"; + logMsg = Msg.getMsg(Env.getCtx(), "FieldNotEditable", new Object[] {header.get(i)}) + "{" + value + "}"; break; } if(value.toString().trim().equals("(null)")){ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java index 2e5e6659b6..c511151682 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java @@ -205,7 +205,7 @@ public class ExportAction implements EventListener winExportFile = null; AMedia media = null; media = new AMedia(exporter.getSuggestedFileName(panel.getActiveGridTab()), null, exporter.getContentType(), file, true); - Filedownload.save(media, panel.getActiveGridTab().getName() + "." + ext); + Filedownload.save(media); } catch (Exception e) { throw new AdempiereException(e); } finally { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java index 1f20709592..e23dd48254 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java @@ -313,7 +313,7 @@ public class FileImportAction implements EventListener AMedia media = null; media = new AMedia(importer.getSuggestedFileName(panel.getActiveGridTab()), null, importer.getContentType(), outFile, true); - Filedownload.save(media, panel.getActiveGridTab().getName() + "." + ext); + Filedownload.save(media); } catch (Exception e) { throw new AdempiereException(e);