hg merge release-2.1 (merge release2.1 into development)
This commit is contained in:
commit
94dcdbccef
|
@ -0,0 +1,11 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-2672
|
||||
-- Jul 15, 2015 10:28:04 AM COT
|
||||
UPDATE AD_Column SET AD_Reference_ID=30, IsUpdateable='N',Updated=TO_DATE('2015-07-15 10:28:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1809
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201507151028_IDEMPIERE-2672.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
-- IDEMPIERE-2672
|
||||
-- Jul 15, 2015 10:28:04 AM COT
|
||||
UPDATE AD_Column SET AD_Reference_ID=30, IsUpdateable='N',Updated=TO_TIMESTAMP('2015-07-15 10:28:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=1809
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201507151028_IDEMPIERE-2672.sql') FROM dual
|
||||
;
|
||||
|
|
@ -20,18 +20,13 @@ import java.math.BigDecimal;
|
|||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.DatabaseKey;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
/**
|
||||
|
@ -133,14 +128,14 @@ public class ColumnSync extends SvrProcess
|
|||
MColumn[] cols = table.getColumns(false);
|
||||
for (MColumn col : cols)
|
||||
{
|
||||
String fkConstraintSql = getForeignKeyConstraintSql(md, catalog, schema, tableName, table, col);
|
||||
String fkConstraintSql = MColumn.getForeignKeyConstraintSql(md, catalog, schema, tableName, table, col);
|
||||
if (fkConstraintSql != null && fkConstraintSql.length() > 0)
|
||||
sql += fkConstraintSql;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String fkConstraintSql = getForeignKeyConstraintSql(md, catalog, schema, tableName, table, column);
|
||||
String fkConstraintSql = MColumn.getForeignKeyConstraintSql(md, catalog, schema, tableName, table, column);
|
||||
if (fkConstraintSql != null && fkConstraintSql.length() > 0)
|
||||
sql += fkConstraintSql;
|
||||
}
|
||||
|
@ -183,141 +178,4 @@ public class ColumnSync extends SvrProcess
|
|||
}
|
||||
} // doIt
|
||||
|
||||
private String getForeignKeyConstraintSql(DatabaseMetaData md, String catalog, String schema, String tableName, MTable table, MColumn column) throws Exception
|
||||
{
|
||||
StringBuilder fkConstraintSql = new StringBuilder();
|
||||
|
||||
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
|
||||
{
|
||||
int refid = column.getAD_Reference_ID();
|
||||
if (refid != DisplayType.List && refid != DisplayType.Payment)
|
||||
{
|
||||
String referenceTableName = column.getReferenceTableName();
|
||||
if (referenceTableName != null)
|
||||
{
|
||||
Hashtable<String, DatabaseKey> htForeignKeys = new Hashtable<String, DatabaseKey>();
|
||||
|
||||
if (md.storesUpperCaseIdentifiers())
|
||||
referenceTableName = referenceTableName.toUpperCase();
|
||||
else if (md.storesLowerCaseIdentifiers())
|
||||
referenceTableName = referenceTableName.toLowerCase();
|
||||
|
||||
ResultSet rs = md.getCrossReference(catalog, schema, referenceTableName, catalog, schema, tableName);
|
||||
while (rs.next())
|
||||
{
|
||||
String dbFKName = rs.getString("FK_NAME");
|
||||
if (dbFKName == null)
|
||||
continue;
|
||||
|
||||
String dbFKTable = rs.getString("FKTABLE_NAME");
|
||||
short deleteRule = rs.getShort("DELETE_RULE");
|
||||
|
||||
String key = dbFKName.toLowerCase();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey == null)
|
||||
dbForeignKey = new DatabaseKey(dbFKName, dbFKTable, new String[30], deleteRule);
|
||||
|
||||
String columnName = rs.getString("FKCOLUMN_NAME");
|
||||
int pos = (rs.getShort("KEY_SEQ"));
|
||||
if (pos > 0)
|
||||
dbForeignKey.getKeyColumns()[pos-1] = columnName;
|
||||
|
||||
htForeignKeys.put(key, dbForeignKey);
|
||||
}
|
||||
rs.close();
|
||||
|
||||
Enumeration<String> en = htForeignKeys.keys();
|
||||
while (en.hasMoreElements())
|
||||
{
|
||||
String key = en.nextElement();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey.getKeyColumns()[1] != null)
|
||||
htForeignKeys.remove(key);
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
en = htForeignKeys.keys();
|
||||
while (en.hasMoreElements())
|
||||
{
|
||||
String key = en.nextElement();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey.getKeyColumns()[0].equalsIgnoreCase(column.getColumnName()))
|
||||
{
|
||||
DatabaseKey primaryKey = CreateForeignKey.getPrimaryKey(md, referenceTableName);
|
||||
if (primaryKey != null)
|
||||
{
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" DROP CONSTRAINT ").append(dbForeignKey.getKeyName());
|
||||
|
||||
String dbDeleteRule = MColumn.FKCONSTRAINTTYPE_NoAction;
|
||||
if (dbForeignKey.getDeleteRule() == DatabaseMetaData.importedKeyCascade)
|
||||
dbDeleteRule = MColumn.FKCONSTRAINTTYPE_Cascade;
|
||||
else if (dbForeignKey.getDeleteRule() == DatabaseMetaData.importedKeySetNull)
|
||||
dbDeleteRule = MColumn.FKCONSTRAINTTYPE_SetNull;
|
||||
|
||||
String fkConstraintType = column.getFKConstraintType();
|
||||
if (fkConstraintType == null)
|
||||
fkConstraintType = dbDeleteRule;
|
||||
if (fkConstraintType == null)
|
||||
fkConstraintType = MColumn.FKCONSTRAINTTYPE_NoAction;
|
||||
if (!fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_DoNotCreate))
|
||||
{
|
||||
String fkConstraintName = column.getFKConstraintName();
|
||||
if (fkConstraintName == null || fkConstraintName.trim().length() == 0)
|
||||
fkConstraintName = dbForeignKey.getKeyName();
|
||||
|
||||
StringBuilder fkConstraint = new StringBuilder();
|
||||
fkConstraint.append("CONSTRAINT ").append(fkConstraintName);
|
||||
fkConstraint.append(" FOREIGN KEY (").append(column.getColumnName()).append(") REFERENCES ");
|
||||
fkConstraint.append(primaryKey.getKeyTable()).append("(").append(primaryKey.getKeyColumns()[0]);
|
||||
for (int i = 1; i < primaryKey.getKeyColumns().length; i++)
|
||||
{
|
||||
if (primaryKey.getKeyColumns()[i] == null)
|
||||
break;
|
||||
fkConstraint.append(", ").append(primaryKey.getKeyColumns()[i]);
|
||||
}
|
||||
fkConstraint.append(")");
|
||||
|
||||
if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_NoAction))
|
||||
;
|
||||
else if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_Cascade))
|
||||
fkConstraint.append(" ON DELETE CASCADE");
|
||||
else if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_SetNull))
|
||||
fkConstraint.append(" ON DELETE SET NULL");
|
||||
|
||||
fkConstraint.append(" DEFERRABLE INITIALLY DEFERRED");
|
||||
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" ADD ");
|
||||
fkConstraintSql.append(fkConstraint);
|
||||
|
||||
column.setFKConstraintName(fkConstraintName);
|
||||
column.setFKConstraintType(fkConstraintType);
|
||||
column.saveEx();
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!modified)
|
||||
{
|
||||
String fkConstraint = CreateForeignKey.getForeignKeyConstraint(md, table, column);
|
||||
if (fkConstraint != null && fkConstraint.length() > 0)
|
||||
{
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" ADD ");
|
||||
fkConstraintSql.append(fkConstraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fkConstraintSql.toString();
|
||||
}
|
||||
|
||||
} // ColumnSync
|
||||
|
|
|
@ -138,7 +138,10 @@ public abstract class AbstractEventHandler implements EventHandler {
|
|||
* @param e
|
||||
*/
|
||||
protected void addError(Event event, Throwable e) {
|
||||
addErrorMessage(event, e.getLocalizedMessage());
|
||||
String msg = e.getLocalizedMessage();
|
||||
if (msg == null)
|
||||
msg = e.toString();
|
||||
addErrorMessage(event, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -24,11 +25,14 @@ import java.text.DateFormat;
|
|||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.process.CreateForeignKey;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -48,7 +52,7 @@ public class MColumn extends X_AD_Column
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7470893214933465732L;
|
||||
private static final long serialVersionUID = -3735608010271317406L;
|
||||
|
||||
/**
|
||||
* Get MColumn from Cache
|
||||
|
@ -836,4 +840,141 @@ public class MColumn extends X_AD_Column
|
|||
return table;
|
||||
}
|
||||
|
||||
public static String getForeignKeyConstraintSql(DatabaseMetaData md, String catalog, String schema, String tableName, MTable table, MColumn column) throws Exception
|
||||
{
|
||||
StringBuilder fkConstraintSql = new StringBuilder();
|
||||
|
||||
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
|
||||
{
|
||||
int refid = column.getAD_Reference_ID();
|
||||
if (refid != DisplayType.List && refid != DisplayType.Payment)
|
||||
{
|
||||
String referenceTableName = column.getReferenceTableName();
|
||||
if (referenceTableName != null)
|
||||
{
|
||||
Hashtable<String, DatabaseKey> htForeignKeys = new Hashtable<String, DatabaseKey>();
|
||||
|
||||
if (md.storesUpperCaseIdentifiers())
|
||||
referenceTableName = referenceTableName.toUpperCase();
|
||||
else if (md.storesLowerCaseIdentifiers())
|
||||
referenceTableName = referenceTableName.toLowerCase();
|
||||
|
||||
ResultSet rs = md.getCrossReference(catalog, schema, referenceTableName, catalog, schema, tableName);
|
||||
while (rs.next())
|
||||
{
|
||||
String dbFKName = rs.getString("FK_NAME");
|
||||
if (dbFKName == null)
|
||||
continue;
|
||||
|
||||
String dbFKTable = rs.getString("FKTABLE_NAME");
|
||||
short deleteRule = rs.getShort("DELETE_RULE");
|
||||
|
||||
String key = dbFKName.toLowerCase();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey == null)
|
||||
dbForeignKey = new DatabaseKey(dbFKName, dbFKTable, new String[30], deleteRule);
|
||||
|
||||
String columnName = rs.getString("FKCOLUMN_NAME");
|
||||
int pos = (rs.getShort("KEY_SEQ"));
|
||||
if (pos > 0)
|
||||
dbForeignKey.getKeyColumns()[pos-1] = columnName;
|
||||
|
||||
htForeignKeys.put(key, dbForeignKey);
|
||||
}
|
||||
rs.close();
|
||||
|
||||
Enumeration<String> en = htForeignKeys.keys();
|
||||
while (en.hasMoreElements())
|
||||
{
|
||||
String key = en.nextElement();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey.getKeyColumns()[1] != null)
|
||||
htForeignKeys.remove(key);
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
en = htForeignKeys.keys();
|
||||
while (en.hasMoreElements())
|
||||
{
|
||||
String key = en.nextElement();
|
||||
DatabaseKey dbForeignKey = htForeignKeys.get(key);
|
||||
if (dbForeignKey.getKeyColumns()[0].equalsIgnoreCase(column.getColumnName()))
|
||||
{
|
||||
DatabaseKey primaryKey = CreateForeignKey.getPrimaryKey(md, referenceTableName);
|
||||
if (primaryKey != null)
|
||||
{
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" DROP CONSTRAINT ").append(dbForeignKey.getKeyName());
|
||||
|
||||
String dbDeleteRule = MColumn.FKCONSTRAINTTYPE_NoAction;
|
||||
if (dbForeignKey.getDeleteRule() == DatabaseMetaData.importedKeyCascade)
|
||||
dbDeleteRule = MColumn.FKCONSTRAINTTYPE_Cascade;
|
||||
else if (dbForeignKey.getDeleteRule() == DatabaseMetaData.importedKeySetNull)
|
||||
dbDeleteRule = MColumn.FKCONSTRAINTTYPE_SetNull;
|
||||
|
||||
String fkConstraintType = column.getFKConstraintType();
|
||||
if (fkConstraintType == null)
|
||||
fkConstraintType = dbDeleteRule;
|
||||
if (fkConstraintType == null)
|
||||
fkConstraintType = MColumn.FKCONSTRAINTTYPE_NoAction;
|
||||
if (!fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_DoNotCreate))
|
||||
{
|
||||
String fkConstraintName = column.getFKConstraintName();
|
||||
if (fkConstraintName == null || fkConstraintName.trim().length() == 0)
|
||||
fkConstraintName = dbForeignKey.getKeyName();
|
||||
|
||||
StringBuilder fkConstraint = new StringBuilder();
|
||||
fkConstraint.append("CONSTRAINT ").append(fkConstraintName);
|
||||
fkConstraint.append(" FOREIGN KEY (").append(column.getColumnName()).append(") REFERENCES ");
|
||||
fkConstraint.append(primaryKey.getKeyTable()).append("(").append(primaryKey.getKeyColumns()[0]);
|
||||
for (int i = 1; i < primaryKey.getKeyColumns().length; i++)
|
||||
{
|
||||
if (primaryKey.getKeyColumns()[i] == null)
|
||||
break;
|
||||
fkConstraint.append(", ").append(primaryKey.getKeyColumns()[i]);
|
||||
}
|
||||
fkConstraint.append(")");
|
||||
|
||||
if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_NoAction))
|
||||
;
|
||||
else if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_Cascade))
|
||||
fkConstraint.append(" ON DELETE CASCADE");
|
||||
else if (fkConstraintType.equals(MColumn.FKCONSTRAINTTYPE_SetNull))
|
||||
fkConstraint.append(" ON DELETE SET NULL");
|
||||
|
||||
fkConstraint.append(" DEFERRABLE INITIALLY DEFERRED");
|
||||
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" ADD ");
|
||||
fkConstraintSql.append(fkConstraint);
|
||||
|
||||
column.setFKConstraintName(fkConstraintName);
|
||||
column.setFKConstraintType(fkConstraintType);
|
||||
column.saveEx();
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!modified)
|
||||
{
|
||||
String fkConstraint = CreateForeignKey.getForeignKeyConstraint(md, table, column);
|
||||
if (fkConstraint != null && fkConstraint.length() > 0)
|
||||
{
|
||||
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
|
||||
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
|
||||
fkConstraintSql.append(" ADD ");
|
||||
fkConstraintSql.append(fkConstraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fkConstraintSql.toString();
|
||||
}
|
||||
|
||||
} // MColumn
|
||||
|
|
|
@ -121,7 +121,6 @@ public class MProductionLine extends X_M_ProductionLine {
|
|||
MStorageOnHand storage = MStorageOnHand.getCreate(getCtx(), getM_Locator_ID(),
|
||||
getM_Product_ID(), asi.get_ID(),dateMPolicy, get_TrxName());
|
||||
storage.addQtyOnHand(getMovementQty());
|
||||
storage.load(storage.get_TrxName());
|
||||
if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Created finished goods line " + getLine());
|
||||
|
||||
return errorString.toString();
|
||||
|
@ -180,7 +179,6 @@ public class MProductionLine extends X_M_ProductionLine {
|
|||
}
|
||||
DB.getDatabase().forUpdate(storages[sl], 120);
|
||||
storages[sl].addQtyOnHand(lineQty.negate());
|
||||
storages[sl].load(storages[sl].get_TrxName());
|
||||
qtyToMove = qtyToMove.subtract(lineQty);
|
||||
if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
|
||||
}
|
||||
|
@ -239,7 +237,6 @@ public class MProductionLine extends X_M_ProductionLine {
|
|||
if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Saved transaction for " + toString());
|
||||
}
|
||||
storage.addQtyOnHand(lineQty.negate());
|
||||
storage.load(storage.get_TrxName());
|
||||
qtyToMove = qtyToMove.subtract(lineQty);
|
||||
if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
|
||||
}
|
||||
|
|
|
@ -737,7 +737,6 @@ public class MStorageOnHand extends X_M_StorageOnHand
|
|||
}
|
||||
|
||||
storage.addQtyOnHand(diffQtyOnHand);
|
||||
storage.load(storage.get_TrxName());
|
||||
if (storage.getQtyOnHand().signum() == -1) {
|
||||
if (MWarehouse.get(Env.getCtx(), M_Warehouse_ID).isDisallowNegativeInv()) {
|
||||
throw new AdempiereException(Msg.getMsg(ctx, "NegativeInventoryDisallowed"));
|
||||
|
@ -760,6 +759,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
|
|||
DB.executeUpdateEx(sql,
|
||||
new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Locator_ID(), getM_AttributeSetInstance_ID(), getDateMaterialPolicy()},
|
||||
get_TrxName());
|
||||
load(get_TrxName());
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -249,7 +249,6 @@ public class MStorageReservation extends X_M_StorageReservation {
|
|||
}
|
||||
|
||||
storage.addQty(diffQty);
|
||||
storage.load(storage.get_TrxName());
|
||||
if (s_log.isLoggable(Level.FINE)) {
|
||||
StringBuilder diffText = new StringBuilder("(Qty=").append(diffQty).append(") -> ").append(storage.toString());
|
||||
s_log.fine(diffText.toString());
|
||||
|
@ -267,6 +266,7 @@ public class MStorageReservation extends X_M_StorageReservation {
|
|||
DB.executeUpdateEx(sql,
|
||||
new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Warehouse_ID(), getM_AttributeSetInstance_ID(), isSOTrx()},
|
||||
get_TrxName());
|
||||
load(get_TrxName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ public class LocationElement extends GridElement
|
|||
else if (ml.isAddressLinesReverse())
|
||||
{
|
||||
setData(index++, 0, ml.getCountry(true, language), font, color);
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(ml.getCityRegionPostal());
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(ml.getCityRegionPostal());
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
setData(index++, 0, lines[i], font, color);
|
||||
if (ml.getAddress4() != null && ml.getAddress4().length() > 0)
|
||||
|
@ -98,7 +98,7 @@ public class LocationElement extends GridElement
|
|||
setData(index++, 0, ml.getAddress3(), font, color);
|
||||
if (ml.getAddress4() != null && ml.getAddress4().length() > 0)
|
||||
setData(index++, 0, ml.getAddress4(), font, color);
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(ml.getCityRegionPostal());
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(ml.getCityRegionPostal());
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
setData(index++, 0, lines[i], font, color);
|
||||
setData(index++, 0, ml.getCountry(true, language), font, color);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class StringElement extends PrintElement
|
|||
}
|
||||
}
|
||||
m_ID = ID;
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(inText);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(inText);
|
||||
m_string_paper = new AttributedString[lines.length];
|
||||
m_string_view = new AttributedString[lines.length];
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
|
@ -155,7 +155,7 @@ public class StringElement extends PrintElement
|
|||
endOffset = labelSuffix.length();
|
||||
}
|
||||
m_ID = ID;
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(text);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(text);
|
||||
m_string_paper = new AttributedString[lines.length];
|
||||
m_string_view = new AttributedString[lines.length];
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
|
@ -230,7 +230,7 @@ public class StringElement extends PrintElement
|
|||
return;
|
||||
String inText = Msg.parseTranslation(ctx, m_originalString);
|
||||
// log.fine( "StringElement.translate", inText);
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(inText);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(inText);
|
||||
m_string_paper = new AttributedString[lines.length];
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
|
|
|
@ -431,7 +431,7 @@ public class TableElement extends PrintElement
|
|||
}
|
||||
else
|
||||
{
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(string);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(string);
|
||||
for (int lineNo = 0; lineNo < lines.length; lineNo++)
|
||||
{
|
||||
AttributedString aString = new AttributedString(lines[lineNo]);
|
||||
|
@ -503,7 +503,7 @@ public class TableElement extends PrintElement
|
|||
{
|
||||
float height = 0;
|
||||
//
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(string);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(string);
|
||||
for (int lineNo = 0; lineNo < lines.length; lineNo++)
|
||||
{
|
||||
AttributedString aString = new AttributedString(lines[lineNo]);
|
||||
|
@ -1503,7 +1503,7 @@ public class TableElement extends PrintElement
|
|||
if (str.length() > 0)
|
||||
{
|
||||
usedHeight = 0;
|
||||
String[] lines = Pattern.compile("$", Pattern.MULTILINE).split(str);
|
||||
String[] lines = Pattern.compile("\n", Pattern.MULTILINE).split(str);
|
||||
for (int lineNo = 0; lineNo < lines.length; lineNo++)
|
||||
{
|
||||
aString = new AttributedString(lines[lineNo]);
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.compiere.util.DB;
|
|||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.Util;
|
||||
import org.compiere.wf.MWFProcess;
|
||||
|
||||
public class ServerProcessCtl implements Runnable {
|
||||
|
@ -278,7 +279,8 @@ public class ServerProcessCtl implements Runnable {
|
|||
m_pi.setReportingProcess(true);
|
||||
// Start Report -----------------------------------------------
|
||||
boolean ok = ServerReportCtl.start(m_pi);
|
||||
m_pi.setSummary("Report", !ok);
|
||||
String summ = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report"));
|
||||
m_pi.setSummary(summ, !ok);
|
||||
}
|
||||
/**********************************************************************
|
||||
* Process submission
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.logging.Level;
|
|||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.pipo2.AbstractElementHandler;
|
||||
import org.adempiere.pipo2.Element;
|
||||
import org.adempiere.pipo2.PIPOContext;
|
||||
|
@ -228,6 +229,18 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
if (!rst.next()) {
|
||||
// table doesn't exist
|
||||
sql = table.getSQLCreate();
|
||||
MColumn[] cols = table.getColumns(false);
|
||||
for (MColumn col : cols)
|
||||
{
|
||||
String fkConstraintSql;
|
||||
try {
|
||||
fkConstraintSql = MColumn.getForeignKeyConstraintSql(md, catalog, schema, tableName, table, col);
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
if (fkConstraintSql != null && fkConstraintSql.length() > 0)
|
||||
sql += fkConstraintSql;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
rsc = md.getColumns(catalog, schema, tableName, columnName);
|
||||
|
@ -243,6 +256,14 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
// No existing column
|
||||
sql = column.getSQLAdd(table);
|
||||
}
|
||||
String fkConstraintSql;
|
||||
try {
|
||||
fkConstraintSql = MColumn.getForeignKeyConstraintSql(md, catalog, schema, tableName, table, column);
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
if (fkConstraintSql != null && fkConstraintSql.length() > 0)
|
||||
sql += fkConstraintSql;
|
||||
}
|
||||
|
||||
//execute modify or add if needed
|
||||
|
@ -260,6 +281,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
} else {
|
||||
String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
if ("null".equals(statements[i]))
|
||||
continue;
|
||||
int ret = DB.executeUpdate(statements[i], false,
|
||||
trx.getTrxName());
|
||||
if (ret == -1) {
|
||||
|
|
|
@ -1122,13 +1122,13 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
|||
if (sendEmail)
|
||||
{
|
||||
MClient client = MClient.get(m_ctx, AD_Client_ID);
|
||||
client.sendEMailAttachments(AD_User_ID, process.getName(), m_pi.getSummary() + " " + m_pi.getLogInfo(), getDownloadFiles());
|
||||
client.sendEMailAttachments(AD_User_ID, process.get_Translation("Name", Env.getAD_Language(Env.getCtx())), m_pi.getSummary() + " " + m_pi.getLogInfo(), getDownloadFiles());
|
||||
}
|
||||
|
||||
if (createNotice)
|
||||
{
|
||||
MNote note = new MNote(m_ctx, "BackgroundJob", AD_User_ID, null);
|
||||
note.setTextMsg(process.getName() + "\n" + m_pi.getSummary());
|
||||
note.setTextMsg(process.get_Translation("Name", Env.getAD_Language(Env.getCtx())) + "\n" + m_pi.getSummary());
|
||||
note.setRecord(MPInstance.Table_ID, m_pi.getAD_PInstance_ID());
|
||||
note.saveEx();
|
||||
|
||||
|
|
|
@ -684,11 +684,11 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (end >= cacheEnd || end <= 0)
|
||||
if (end > cacheEnd || end <= 0)
|
||||
{
|
||||
end = cacheEnd-1;
|
||||
end = cacheEnd;
|
||||
}
|
||||
return line.subList(start, end+1);
|
||||
return line.subList(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
int start = pageNo * pageSize;
|
||||
int end = start + pageSize;
|
||||
if (end >= m_count)
|
||||
end = m_count - 1;
|
||||
end = m_count;
|
||||
List<Object> subList = readLine(start, end);
|
||||
model = new ListModelTable(subList);
|
||||
model.setSorter(this);
|
||||
|
|
|
@ -247,7 +247,8 @@ public class ConfigOracle implements IDatabaseConfig
|
|||
return null;
|
||||
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
Pattern pattern = Pattern.compile("$", Pattern.MULTILINE);
|
||||
Pattern pattern = Pattern.compile("\n", Pattern.MULTILINE);
|
||||
System.out.println(tnsnames);
|
||||
String[] lines = pattern.split(tnsnames);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Properties;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.compiere.model.MSession;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -135,6 +136,7 @@ public class CompiereService {
|
|||
{
|
||||
if (m_connected)
|
||||
{
|
||||
Env.logout();
|
||||
ServerContext.dispose();
|
||||
m_ctx = null;
|
||||
m_loggedin = false;
|
||||
|
@ -274,6 +276,15 @@ public class CompiereService {
|
|||
Env.setContext( getCtx(), "#M_Warehouse_ID", M_Warehouse_ID );
|
||||
Env.setContext(m_ctx, Env.LANGUAGE, m_language.getAD_Language());
|
||||
|
||||
// Create session
|
||||
MSession session = MSession.get (getCtx(), false);
|
||||
if (session == null){
|
||||
log.fine("No Session found");
|
||||
session = MSession.get (getCtx(), true);
|
||||
}
|
||||
session.setWebSession("WebService");
|
||||
session.saveEx();
|
||||
|
||||
m_loggedin = true;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue