IDEMPIERE-454 Easy import (Work in progress)

This commit is contained in:
Carlos Ruiz 2013-03-12 00:43:00 -05:00
parent 506f380141
commit aecfe6fc5d
6 changed files with 24 additions and 27 deletions

View File

@ -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) 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 -- Mar 11, 2013 4:10:39 PM COT
-- IDEMPIERE-454 Easy import -- 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')) 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'))

View File

@ -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) 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 -- Mar 11, 2013 4:10:39 PM COT
-- IDEMPIERE-454 Easy import -- 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')) 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'))

View File

@ -24,6 +24,7 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import org.adempiere.base.IGridTabExporter; import org.adempiere.base.IGridTabExporter;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
@ -37,13 +38,14 @@ import org.compiere.model.MColumn;
import org.compiere.model.MLocation; import org.compiere.model.MLocation;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRefList; import org.compiere.model.MRefList;
import org.compiere.model.MTab;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.jfree.util.Log;
import org.supercsv.cellprocessor.FmtBool; import org.supercsv.cellprocessor.FmtBool;
import org.supercsv.cellprocessor.FmtDate; import org.supercsv.cellprocessor.FmtDate;
import org.supercsv.cellprocessor.FmtNumber; import org.supercsv.cellprocessor.FmtNumber;
@ -60,6 +62,9 @@ import org.supercsv.prefs.CsvPreference;
*/ */
public class GridTabCSVExporter implements IGridTabExporter public class GridTabCSVExporter implements IGridTabExporter
{ {
/** Logger */
private static CLogger log = CLogger.getCLogger(GridTabCSVExporter.class);
@Override @Override
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file) { public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file) {
@ -69,9 +74,9 @@ public class GridTabCSVExporter implements IGridTabExporter
MTable tableDetail = null; MTable tableDetail = null;
try { try {
mapWriter = new CsvMapWriter(new FileWriter(file), CsvPreference.STANDARD_PREFERENCE); mapWriter = new CsvMapWriter(new FileWriter(file), CsvPreference.STANDARD_PREFERENCE);
String IsValidTab = IsValidTabToExport(gridTab); String isValidTab = isValidTabToExport(gridTab);
if (IsValidTab!=null){ if (isValidTab!=null){
Log.info(IsValidTab); if (log.isLoggable(Level.INFO)) log.info(isValidTab);
return; return;
} }
GridTable gt = gridTab.getTableModel(); GridTable gt = gridTab.getTableModel();
@ -125,9 +130,9 @@ public class GridTabCSVExporter implements IGridTabExporter
if(detail.getTabLevel()>1) if(detail.getTabLevel()>1)
continue; continue;
IsValidTab = IsValidTabToExport(detail); isValidTab = isValidTabToExport(detail);
if (IsValidTab!=null){ if (isValidTab!=null){
Log.info(IsValidTab); if (log.isLoggable(Level.INFO)) log.info(isValidTab);
continue; continue;
} }
tableDetail = MTable.get(Env.getCtx(), detail.getTableName()); tableDetail = MTable.get(Env.getCtx(), detail.getTableName());
@ -270,14 +275,16 @@ public class GridTabCSVExporter implements IGridTabExporter
} }
//add constraints to not allow certain tabs //add constraints to not allow certain tabs
private String IsValidTabToExport(GridTab gridTab){ private String isValidTabToExport(GridTab gridTab){
String result=null; 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()}); result = Msg.getMsg(Env.getCtx(),"FieldIsReadOnly", new Object[] {gridTab.getName()});
if(gridTab.getTableName().endsWith("_Acct")) if (gridTab.getTableName().endsWith("_Acct"))
result = "Accounting Tab cannot be exported "+ gridTab.getName(); result = "Accounting Tab are not exported by default: "+ gridTab.getName();
return result; return result;
} }

View File

@ -31,8 +31,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import org.adempiere.base.IGridTabImporter; import org.adempiere.base.IGridTabImporter;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
@ -503,7 +503,7 @@ public class GridTabCSVImporter implements IGridTabImporter
private List<Object> getOrderedRowFromMap (List<String> header,Map<String, Object> map){ private List<Object> getOrderedRowFromMap (List<String> header,Map<String, Object> map){
List<Object> tmpRow= new ArrayList<Object>(); List<Object> tmpRow= new ArrayList<Object>();
for(String item : header) for (int i = 0; i < header.size(); i++)
tmpRow.add(null); tmpRow.add(null);
for(Map.Entry<String, Object> record : map.entrySet()) { for(Map.Entry<String, Object> record : map.entrySet()) {
@ -730,7 +730,7 @@ public class GridTabCSVImporter implements IGridTabImporter
} }
if (!field.isEditable(true) && value!=null) { 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; break;
} }
if(value.toString().trim().equals("(null)")){ if(value.toString().trim().equals("(null)")){

View File

@ -205,7 +205,7 @@ public class ExportAction implements EventListener<Event>
winExportFile = null; winExportFile = null;
AMedia media = null; AMedia media = null;
media = new AMedia(exporter.getSuggestedFileName(panel.getActiveGridTab()), null, exporter.getContentType(), file, true); 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) { } catch (Exception e) {
throw new AdempiereException(e); throw new AdempiereException(e);
} finally { } finally {

View File

@ -313,7 +313,7 @@ public class FileImportAction implements EventListener<Event>
AMedia media = null; AMedia media = null;
media = new AMedia(importer.getSuggestedFileName(panel.getActiveGridTab()), null, importer.getContentType(), outFile, true); 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) { } catch (Exception e) {
throw new AdempiereException(e); throw new AdempiereException(e);