IDEMPIERE-454 Easy import (Work in progress)
This commit is contained in:
parent
506f380141
commit
aecfe6fc5d
|
@ -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'))
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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<GridTab> 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;
|
||||
}
|
||||
|
|
|
@ -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<Object> getOrderedRowFromMap (List<String> header,Map<String, Object> map){
|
||||
List<Object> tmpRow= new ArrayList<Object>();
|
||||
for(String item : header)
|
||||
for (int i = 0; i < header.size(); i++)
|
||||
tmpRow.add(null);
|
||||
|
||||
for(Map.Entry<String, Object> 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)")){
|
||||
|
|
|
@ -205,7 +205,7 @@ public class ExportAction implements EventListener<Event>
|
|||
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 {
|
||||
|
|
|
@ -313,7 +313,7 @@ public class FileImportAction implements EventListener<Event>
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue