Implement [2845179] - Packin data implement lookupvalue like lookupname
https://sourceforge.net/tracker/?func=detail&aid=2845179&group_id=176962&atid=879335
This commit is contained in:
parent
f9a8309e2f
commit
9d342b02b5
|
@ -167,6 +167,17 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
||||||
return IDFinder.getIDbyName(tableName, name, getClientId(ctx), getTrxName(ctx));
|
return IDFinder.getIDbyName(tableName, name, getClientId(ctx), getTrxName(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ID from Value for a table.
|
||||||
|
* TODO: substitute with PO.getAllIDs
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public int getIDbyValue (Properties ctx, String tableName, String value) {
|
||||||
|
return IDFinder.getIDbyValue(tableName, value, getClientId(ctx), getTrxName(ctx));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make backup copy of record.
|
* Make backup copy of record.
|
||||||
*
|
*
|
||||||
|
|
|
@ -343,21 +343,22 @@ public class IDFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ID from Name for a table.
|
* Get ID from Column for a table.
|
||||||
* TODO: substitute with PO.getAllIDs
|
* TODO: substitute with PO.getAllIDs
|
||||||
*
|
*
|
||||||
* @param tableName
|
* @param tableName
|
||||||
|
* @param column
|
||||||
* @param name
|
* @param name
|
||||||
* @param AD_Client_ID
|
* @param AD_Client_ID
|
||||||
* @param trxName
|
* @param trxName
|
||||||
*/
|
*/
|
||||||
public static int getIDbyName (String tableName, String name, int AD_Client_ID, String trxName) {
|
public static int getIDbyColumn (String tableName, String column, String name, int AD_Client_ID, String trxName) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
//construct cache key
|
//construct cache key
|
||||||
StringBuffer key = new StringBuffer();
|
StringBuffer key = new StringBuffer();
|
||||||
key.append(tableName)
|
key.append(tableName)
|
||||||
.append(".Name=")
|
.append("."+column+"=")
|
||||||
.append(name);
|
.append(name);
|
||||||
if (!tableName.startsWith("AD_"))
|
if (!tableName.startsWith("AD_"))
|
||||||
key.append(" AND AD_Client_ID=").append(AD_Client_ID);
|
key.append(" AND AD_Client_ID=").append(AD_Client_ID);
|
||||||
|
@ -372,7 +373,7 @@ public class IDFinder {
|
||||||
.append("FROM ")
|
.append("FROM ")
|
||||||
.append(tableName)
|
.append(tableName)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append("WHERE name=?");
|
.append("WHERE "+column+"=?");
|
||||||
if (!tableName.startsWith("AD_"))
|
if (!tableName.startsWith("AD_"))
|
||||||
sql.append(" AND AD_Client_ID=?");
|
sql.append(" AND AD_Client_ID=?");
|
||||||
try {
|
try {
|
||||||
|
@ -388,7 +389,7 @@ public class IDFinder {
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
log.log(Level.SEVERE, "getIDbyName:"+e);
|
log.log(Level.SEVERE, "getIDbyColumn:"+e);
|
||||||
throw new DatabaseAccessException(e);
|
throw new DatabaseAccessException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,6 +399,15 @@ public class IDFinder {
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getIDbyName (String tableName, String name, int AD_Client_ID, String trxName) {
|
||||||
|
return getIDbyColumn(tableName, "Name", name, AD_Client_ID, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getIDbyValue (String tableName, String name, int AD_Client_ID, String trxName) {
|
||||||
|
return getIDbyColumn(tableName, "Value", name, AD_Client_ID, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void clearIDCache() {
|
public static void clearIDCache() {
|
||||||
idCache.clear();
|
idCache.clear();
|
||||||
|
|
|
@ -283,7 +283,12 @@ public class DataElementHandler extends AbstractElementHandler {
|
||||||
// globalqss - bring support from XML2AD to lookupname
|
// globalqss - bring support from XML2AD to lookupname
|
||||||
String m_tablename = atts.getValue("name").substring(0, atts.getValue("name").length()-3);
|
String m_tablename = atts.getValue("name").substring(0, atts.getValue("name").length()-3);
|
||||||
genericPO.set_ValueOfColumn(atts.getValue("name"), new Integer(getIDbyName(ctx, m_tablename, atts.getValue("lookupname"))));
|
genericPO.set_ValueOfColumn(atts.getValue("name"), new Integer(getIDbyName(ctx, m_tablename, atts.getValue("lookupname"))));
|
||||||
|
} else if (atts.getValue("lookupvalue") != null && !"".equals(atts.getValue("lookupvalue"))) {
|
||||||
|
// globalqss - bring support from XML2AD to lookupvalue
|
||||||
|
String m_tablename = atts.getValue("name").substring(0, atts.getValue("name").length()-3);
|
||||||
|
genericPO.set_ValueOfColumn(atts.getValue("name"), new Integer(getIDbyValue(ctx, m_tablename, atts.getValue("lookupvalue"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue