hg merge release-2.1 (merge release2.1 into development)

This commit is contained in:
Carlos Ruiz 2015-04-08 16:21:21 -05:00
commit 8e0f178c35
20 changed files with 251 additions and 147 deletions

View File

@ -257,7 +257,7 @@ public class InitialClientSetup extends SvrProcess
// Process
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS);
try {
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName
, p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) {
ms.rollback();
@ -285,6 +285,10 @@ public class InitialClientSetup extends SvrProcess
// Create Print Documents
PrintUtil.setupPrintForm(ms.getAD_Client_ID());
} catch (Exception e) {
ms.rollback();
throw e;
}
return "@OK@";
}

View File

@ -353,8 +353,9 @@ public class ReplicationLocal extends SvrProcess
// no keys - search for parents
if (list.size() == 0)
{
DB.close(rs);
DB.close(rs, pstmt);
rs = null;
pstmt = null;
sql = "SELECT ColumnName FROM AD_Column "
+ "WHERE AD_Table_ID=?"
+ " AND IsParent='Y'";

View File

@ -17,6 +17,7 @@
package org.compiere.impexp;
import java.io.FileInputStream;
import java.io.IOException;
import org.compiere.model.MBankStatementLoader;
import org.xml.sax.SAXException;
@ -71,6 +72,13 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
{
m_errorMessage = new StringBuffer("ErrorReadingData");
m_errorDescription = new StringBuffer();
}finally{
if (m_stream != null)
try {
m_stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;

View File

@ -439,7 +439,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
public boolean isAddressLinesReverse()
{
// Local
if (getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID())
if (MCountry.getDefault(getCtx()) != null && getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID())
return getCountry().isAddressLinesLocalReverse();
return getCountry().isAddressLinesReverse();
} // isAddressLinesReverse
@ -465,7 +465,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
if (c == null)
return "CountryNotFound";
boolean local = getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID();
boolean local = MCountry.getDefault(getCtx()) != null && getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID();
String inStr = local ? c.getDisplaySequenceLocal() : c.getDisplaySequence();
StringBuilder outStr = new StringBuilder();

View File

@ -338,7 +338,7 @@ public class ModelValidationEngine
*/
public String fireModelChange (PO po, int changeType)
{
if (po == null || m_modelChangeListeners.size() == 0)
if (po == null )
return null;
String propertyName = po.get_TableName() + "*";
@ -502,7 +502,7 @@ public class ModelValidationEngine
*/
public String fireDocValidate (PO po, int docTiming)
{
if (po == null || m_docValidateListeners.size() == 0)
if (po == null)
return null;
String propertyName = po.get_TableName() + "*";
@ -688,7 +688,7 @@ public class ModelValidationEngine
*/
public String fireFactsValidate (MAcctSchema schema, List<Fact> facts, PO po)
{
if (schema == null || facts == null || po == null || m_factsValidateListeners.size() == 0)
if (schema == null || facts == null || po == null)
return null;
String propertyName = po.get_TableName() + "*";
@ -715,6 +715,7 @@ public class ModelValidationEngine
FactsEventData eventData = new FactsEventData(schema, facts, po);
Event event = EventManager.newEvent(IEventTopics.ACCT_FACTS_VALIDATE,
new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("tableName", po.get_TableName()));
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
@ -769,8 +770,6 @@ public class ModelValidationEngine
*/
public void fireImportValidate (ImportProcess process, PO importModel, PO targetModel, int timing)
{
if (m_impValidateListeners.size() == 0)
return;
String propertyName = process.getImportTableName() + "*";
ArrayList<ImportValidator> list = m_impValidateListeners.get(propertyName);

View File

@ -107,7 +107,7 @@ public abstract class PO
/**
*
*/
private static final long serialVersionUID = -2731993630208549493L;
private static final long serialVersionUID = 8237905660667141657L;
public static final String LOCAL_TRX_PREFIX = "POSave";
@ -1882,16 +1882,22 @@ public abstract class PO
/** Cache */
private static CCache<String,String> trl_cache = new CCache<String,String>("po_trl", 5);
public String get_Translation (String columnName, String AD_Language)
{
return get_Translation(columnName, AD_Language, false);
}
/**
* Get Translation of column (if needed).
* It checks if the base language is used or the column is not translated.
* If there is no translation then it fallback to original value.
* @param columnName
* @param AD_Language
* @boolean reload
* @return translated string
* @throws IllegalArgumentException if columnName or AD_Language is null or model has multiple PK
*/
public String get_Translation (String columnName, String AD_Language)
public String get_Translation (String columnName, String AD_Language, boolean reload)
{
//
// Check if columnName, AD_Language is valid or table support translation (has 1 PK) => error
@ -1907,7 +1913,7 @@ public abstract class PO
String key = get_TableName() + "." + columnName + "|" + get_ID() + "|" + AD_Language;
String retValue = null;
if (trl_cache.containsKey(key)) {
if (! reload && trl_cache.containsKey(key)) {
retValue = trl_cache.get(key);
return retValue;

View File

@ -1625,6 +1625,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
.append("FROM C_DocType dt, C_Order o ")
.append("WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID")
.append(" AND o.C_Order_ID=?");
DB.close(rs, pstmt);
rs = null; pstmt = null;
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID);
rs = pstmt.executeQuery();

View File

@ -265,7 +265,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
m_printFont = MPrintFont.get (format.getAD_PrintFont_ID());
// Print Context
Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.getName());
Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.get_Translation(MPrintFormat.COLUMNNAME_Name));
Env.setContext(m_printCtx, Page.CONTEXT_HEADER, Env.getHeader(m_printCtx, 0));
Env.setContext(m_printCtx, Env.LANGUAGE, m_format.getLanguage().getAD_Language());
@ -1009,6 +1009,9 @@ public class LayoutEngine implements Pageable, Printable, Doc
{
if (log.isLoggable(Level.INFO)) log.info("Row=" + row);
m_data.setRowIndex(row);
if (row > 0)
newPage(true, false); // break page per record when the report is a form
boolean somethingPrinted = true; // prevent NL of nothing printed and supress null
// for every item
for (int i = 0; i < m_format.getItemCount(); i++)

View File

@ -2,7 +2,6 @@ package org.compiere.process;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.logging.Level;
@ -51,9 +50,7 @@ public class FactReconciliation extends SvrProcess
*/
protected String doIt()
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "INSERT into T_Reconciliation " +
"(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, " +
@ -69,8 +66,6 @@ public class FactReconciliation extends SvrProcess
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getAD_PInstance_ID());
pstmt.setInt(2, p_Account_ID);
@ -88,6 +83,8 @@ public class FactReconciliation extends SvrProcess
" AND r.AD_PInstance_ID = t.AD_PInstance_ID) = 0 " +
"AND t.AD_PInstance_ID = ?";
DB.close(pstmt);
pstmt = null;
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getAD_PInstance_ID());
count = pstmt.executeUpdate();
@ -95,7 +92,6 @@ public class FactReconciliation extends SvrProcess
if (log.isLoggable(Level.FINE))log.log(Level.FINE, result);
}
catch (SQLException e)
{
@ -104,8 +100,8 @@ public class FactReconciliation extends SvrProcess
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
DB.close(pstmt);
pstmt = null;
}
if (log.isLoggable(Level.FINE)) log.fine((System.currentTimeMillis() - m_start) + " ms");

View File

@ -18,7 +18,6 @@ package org.compiere.tools;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@ -165,32 +164,15 @@ public class Strip
private boolean copy (File infile, File outfile)
{
FileInputStream fis = null;
try
{
fis = new FileInputStream(infile);
}
catch (FileNotFoundException fnfe)
{
System.err.println(fnfe);
return false;
}
//
FileOutputStream fos = null;
try
{
try{
fis = new FileInputStream(infile);
fos = new FileOutputStream(outfile, false); // no append
}
catch (FileNotFoundException fnfe)
{
System.err.println(fnfe);
return false;
}
int noIn = 0;
int noOut = 0;
int noLines = 1;
try
{
int c;
while ((c = fis.read()) != -1)
{
@ -203,15 +185,24 @@ public class Strip
if (c == 13) // cr
noLines++;
}
fis.close();
fos.close();
}
catch (IOException ioe)
System.out.println(" read: " + noIn + ", written: " + noOut + " - lines: " + noLines);
}catch (IOException ioe)
{
System.err.println(ioe);
return false;
}finally{
if (fos != null)
try {
fos.close();
} catch (IOException e) {
}
if (fis != null)
try {
fis.close();
} catch (IOException e) {
}
}
System.out.println(" read: " + noIn + ", written: " + noOut + " - lines: " + noLines);
return true;
} // stripIt

View File

@ -188,6 +188,8 @@ public class CLogErrorBuffer extends Handler
loggerName = "";
//String className = record.getSourceClassName(); // physical class
String methodName = record.getSourceMethodName(); //
if (methodName == null)
methodName = "";
if (DB.isConnected(false)
&& !methodName.equals("saveError")
&& !methodName.equals("get_Value")

View File

@ -233,6 +233,8 @@ public class PackIn {
ZipFile zf = new ZipFile(m_packageDirectory+File.separator+"blobs"+File.separator+fileName);
Enumeration<?> e = zf.entries();
ArrayList<File> files = new ArrayList<File>();
File[] retValue = null;
try{
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement();
File file = new File(m_packageDirectory + File.separator + ze.getName());
@ -245,8 +247,11 @@ public class PackIn {
fout.close();
files.add(file);
}
File[] retValue = new File[files.size()];
retValue = new File[files.size()];
files.toArray(retValue);
}catch (Exception ex){
zf.close();
}
return retValue;
}

View File

@ -204,11 +204,13 @@ public class PoFiller{
{
Element orgElement = element.properties.get("AD_Org_ID");
String sAD_Org_ID = orgElement != null ? orgElement.contents.toString() : null;
if (sAD_Org_ID != null && sAD_Org_ID.equals("0") && po.getAD_Org_ID() != 0)
if (sAD_Org_ID != null && sAD_Org_ID.equals("0")) {
if (po.getAD_Org_ID() != 0) {
po.setAD_Org_ID(0);
else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@"))
}
} else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@")) {
po.setAD_Org_ID(Env.getAD_Org_ID(ctx.ctx));
else {
} else {
if (setTableReference("AD_Client_ID") >= 0)
setTableReference("AD_Org_ID");
}

View File

@ -133,7 +133,7 @@ public class WArchive implements EventListener<Event>
if (allReports > 0)
{
m_reportsAll = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll")
+ " (" + reportCount + ")");
+ " (" + allReports + ")");
m_reportsAll.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(m_reportsAll);
}

View File

@ -64,6 +64,7 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -133,7 +134,13 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
{
log.info("");
form = new CustomForm();
form = new CustomForm() {
private static final long serialVersionUID = 7226661630651936293L;
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null)
try {
dynInit();
jbInit();
@ -143,6 +150,10 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
log.log(Level.SEVERE, "init", e);
}
}
};
m_WindowNo = form.getWindowNo();
}
@ -511,6 +522,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
*/
private void updateQDisplay()
{
if (!showQuery)
return;
boolean reports = reportField.isChecked();
if (log.isLoggable(Level.CONFIG)) log.config("Reports=" + reports);

View File

@ -17,9 +17,11 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.model.GenericPO;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
@ -32,6 +34,7 @@ import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.panel.CustomForm;
import org.adempiere.webui.panel.IFormController;
@ -46,6 +49,7 @@ import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.FDialog;
import org.adempiere.webui.window.ZkReportViewer;
import org.compiere.model.MRole;
import org.compiere.model.Query;
import org.compiere.print.MPrintFormat;
import org.compiere.print.MPrintFormatItem;
import org.compiere.print.ReportEngine;
@ -54,6 +58,7 @@ import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -86,7 +91,8 @@ public class WReportCustomization implements IFormController,EventListener<Even
public ArrayList<MPrintFormatItem> pfi ;
private Auxheader headerPanel=new Auxheader();
private Listbox comboReport = new Listbox();
private WStringEditor name = new WStringEditor();
private String tempName = "";
private Button newPrintFormat;
private Label selectAll;
private Label deselectAll;
@ -168,13 +174,21 @@ public class WReportCustomization implements IFormController,EventListener<Even
headerPanel.appendChild(new Separator("vertical"));
comboReport.setMold("select");
fm =m_reportEngine.getPrintFormat();
comboReport.setTooltiptext(Msg.translate(Env.getCtx(), "AD_PrintFormat_ID"));
comboReport.appendItem(fm.getName(), fm.get_ID());
headerPanel.appendChild(comboReport);
name.setValue(fm.getName());
if (Env.isMultiLingualDocument(m_ctx))
name.setValue(fm.get_Translation("Name"));
else
name.setValue(fm.getName());
headerPanel.appendChild(name.getComponent());
headerPanel.appendChild(new Separator("vertical"));
name.getComponent().addEventListener(Events.ON_FOCUS, this);
name.getComponent().addEventListener(Events.ON_BLUR, this);
name.getComponent().addEventListener(Events.ON_OK, this);
newPrintFormat=new Button();
newPrintFormat.setName("NewPrintFormat");
newPrintFormat.setLabel(Msg.getMsg(Env.getCtx(), "CreatePrintFormat"));
@ -350,6 +364,16 @@ public class WReportCustomization implements IFormController,EventListener<Even
onSave();
close();
}
if (event.getTarget() == name.getComponent()) {
if (event.getName().equals(Events.ON_FOCUS))
tempName = (String) name.getValue();
else if (event.getName().equals(Events.ON_BLUR) || event.getName().equals(Events.ON_OK)) {
if (!tempName.equals(name.getValue()))
setIsChanged(true);
}
}
selectAll.setVisible(oldtabidx == 0);
deselectAll.setVisible(oldtabidx == 0);
pipeSeparator.setVisible(oldtabidx == 0);
@ -357,6 +381,31 @@ public class WReportCustomization implements IFormController,EventListener<Even
private void onSave() {
if (name.getValue() == null || Util.isEmpty((String) name.getValue()))
throw new WrongValueException(name.getComponent(), Msg.getMsg(m_ctx, "FillMandatory"));
if (Env.isMultiLingualDocument(m_ctx)) {
if (Env.isBaseLanguage(m_ctx, "AD_PrintFormat")) {
if (!fm.getName().equals(name.getValue())) {
fm.setName((String) name.getValue());
fm.saveEx();
tempName = (String) name.getValue();
}
} else {
if (!fm.get_Translation("Name").equals(name.getValue())) {
updateTrl();
tempName = (String) name.getValue();
}
}
} else {
if (!fm.getName().equals(name.getValue())) {
fm.setName((String) name.getValue());
fm.saveEx();
updateTrl();
tempName = (String) name.getValue();
}
}
for (MPrintFormatItem item : pfi)
if (item.is_Changed())
item.saveEx();
@ -364,6 +413,19 @@ public class WReportCustomization implements IFormController,EventListener<Even
setIsChanged(false);
}
private void updateTrl()
{
List<GenericPO> list = new Query(m_ctx, "AD_PrintFormat_Trl", "AD_PrintFormat_ID = ?", null)
.setParameters(fm.getAD_PrintFormat_ID())
.list();
for (GenericPO trl : list) {
trl.set_ValueOfColumn("Name", (String) name.getValue());
trl.saveEx();
fm.get_Translation("Name", trl.get_ValueAsString("AD_Language"), true); // reload
}
}
@Override
public ADForm getForm() {
return form;
@ -551,9 +613,11 @@ public class WReportCustomization implements IFormController,EventListener<Even
tpsf5.refresh();
setIsChanged(false);
comboReport.removeAllItems();
comboReport.appendItem(newpf.getName(), newpf.get_ID());
name.setValue(newpf.getName());
m_reportEngine.setPrintFormat(newpf);
newpf.saveEx();
fm = newpf;
}
public void setIsChanged(boolean change){

View File

@ -175,7 +175,7 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
noItems =new ArrayList<MPrintFormatItem>();
for(int i=0 ; i< m_pfi.size();i++){
MPrintFormatItem item = m_pfi.get(i);
if(item!=null && item.isPrinted()){
if(item!=null){
if(item.isOrderBy()){
yesItems.add(item);
}else{

View File

@ -49,7 +49,7 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe
public void refresh() {
orderfield = new ArrayList<MPrintFormatItem>();
for(int i=0 ; i < m_pfi.size(); i++){
if(m_pfi.get(i) != null && m_pfi.get(i).isOrderBy() && m_pfi.get(i).isPrinted()){
if(m_pfi.get(i) != null && m_pfi.get(i).isOrderBy()){
orderfield.add(m_pfi.get(i));
}
}

View File

@ -378,12 +378,23 @@ public class CSVImportAction implements EventListener<Event>
} catch (IOException e) {
throw new AdempiereException(e);
} finally {
if (in != null)
try {
in.close();
} catch (IOException e) {
}
if (bw != null)
try {
bw.close();
} catch (IOException e) {
}
if (reader != null)
try {
reader.close();
in.close();
if (bw != null)
bw.close();
} catch (IOException e) {}
} catch (IOException e) {
}
}
return is;
}

View File

@ -213,7 +213,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
}
m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID);
setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report") + ": " + m_reportEngine.getName()));
setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report") + ": " +
m_reportEngine.getPrintFormat().get_Translation(MPrintFormat.COLUMNNAME_Name)));
addEventListener(ON_RENDER_REPORT_EVENT, this);
}
@ -624,7 +625,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
{
MPrintFormat printFormat = new MPrintFormat (Env.getCtx(), rs, null);
KeyNamePair pp = new KeyNamePair(printFormat.get_ID(), printFormat.get_Translation(MPrintFormat.COLUMNNAME_Name));
KeyNamePair pp = new KeyNamePair(printFormat.get_ID(), printFormat.get_Translation(MPrintFormat.COLUMNNAME_Name, Env.getAD_Language(Env.getCtx()), true));
Listitem li = comboReport.appendItem(pp.getName(), pp.getKey());
if (rs.getInt(1) == AD_PrintFormat_ID)
{
@ -1174,9 +1175,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
/*IDEMPIERE -379*/
private void cmd_Wizard()
{
int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID();
Env.setContext(m_ctx, "AD_PrintFormat_ID", AD_PrintFormat_ID);
ADForm form = ADForm.openForm(SystemIDs.FORM_REPORT_WIZARD);
WReportCustomization av = (WReportCustomization) form.getICustomForm();
av.setReportEngine(m_reportEngine);
@ -1187,9 +1185,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override
public void onEvent(Event event) throws Exception {
if (DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) {
if(m_reportEngine.getPrintFormat().get_ID()!=Env.getContextAsInt(m_ctx, "AD_PrintFormat_ID")){
fillComboReport (m_reportEngine.getPrintFormat().get_ID());
}
cmd_report();
}
}