本文整理汇总了Java中org.ofbiz.entity.GenericPK.getAllKeys方法的典型用法代码示例。如果您正苦于以下问题:Java GenericPK.getAllKeys方法的具体用法?Java GenericPK.getAllKeys怎么用?Java GenericPK.getAllKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.entity.GenericPK
的用法示例。
在下文中一共展示了GenericPK.getAllKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentValueWithCachedPK
import org.ofbiz.entity.GenericPK; //导入方法依赖的package包/类
public static void getCurrentValueWithCachedPK(HttpServletRequest request, Delegator delegator, GenericPK cachedPK, String entityName) {
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
// Build the primary key that may have been passed in as key values
GenericValue v = delegator.makeValue(entityName);
GenericPK passedPK = v.getPrimaryKey();
Collection<String> keyColl = passedPK.getAllKeys();
for (String attrName : keyColl) {
String attrVal = (String)request.getAttribute(attrName);
if (UtilValidate.isEmpty(attrVal)) {
attrVal = (String)paramMap.get(attrName);
}
if (UtilValidate.isNotEmpty(attrVal)) {
passedPK.put(attrName,attrVal);
}
}
// If a full passed primary key exists, it takes precedence over a cached key
// I cannot determine if the key testing utils of GenericEntity take into account
// whether or not a field is populated.
boolean useCached = false;
boolean usePassed = true;
if (cachedPK != null) {
useCached = true;
keyColl = cachedPK.getPrimaryKey().getAllKeys();
for (String ky : keyColl) {
String sCached = null;
String sPassed = null;
Object oPassed = null;
Object oCached = null;
oPassed = passedPK.get(ky);
if (oPassed != null) {
sPassed = oPassed.toString();
if (UtilValidate.isEmpty(sPassed)) {
// If any part of passed key is not available, it can't be used
usePassed = false;
} else {
oCached = cachedPK.get(ky);
if (oCached != null) {
sCached = oCached.toString();
if (UtilValidate.isEmpty(sCached)) {
useCached = false;
} else {
}
} else {
useCached = false;
}
}
} else {
//useCached = false;
usePassed = false;
}
}
}
GenericPK currentPK = null;
if (usePassed && useCached) {
currentPK = passedPK;
} else if (usePassed && !useCached) {
currentPK = passedPK;
} else if (!usePassed && useCached) {
currentPK = cachedPK;
}
if (currentPK != null) {
request.setAttribute("currentPK", currentPK);
GenericValue currentValue = null;
try {
currentValue = EntityQuery.use(delegator).from(currentPK.getEntityName()).where(currentPK).queryOne();
} catch (GenericEntityException e) {
}
request.setAttribute("currentValue", currentValue);
}
}
示例2: getCurrentValueWithCachedPK
import org.ofbiz.entity.GenericPK; //导入方法依赖的package包/类
public static void getCurrentValueWithCachedPK(HttpServletRequest request, Delegator delegator, GenericPK cachedPK, String entityName) {
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
// Build the primary key that may have been passed in as key values
GenericValue v = delegator.makeValue(entityName);
GenericPK passedPK = v.getPrimaryKey();
Collection<String> keyColl = passedPK.getAllKeys();
for(String attrName : keyColl) {
String attrVal = (String)request.getAttribute(attrName);
if (UtilValidate.isEmpty(attrVal)) {
attrVal = (String)paramMap.get(attrName);
}
if (UtilValidate.isNotEmpty(attrVal)) {
passedPK.put(attrName,attrVal);
}
}
// If a full passed primary key exists, it takes precedence over a cached key
// I cannot determine if the key testing utils of GenericEntity take into account
// whether or not a field is populated.
boolean useCached = false;
boolean usePassed = true;
if (cachedPK != null) {
useCached = true;
keyColl = cachedPK.getPrimaryKey().getAllKeys();
for(String ky : keyColl) {
String sCached = null;
String sPassed = null;
Object oPassed = null;
Object oCached = null;
oPassed = passedPK.get(ky);
if (oPassed != null) {
sPassed = oPassed.toString();
if (UtilValidate.isEmpty(sPassed)) {
// If any part of passed key is not available, it can't be used
usePassed = false;
} else {
oCached = cachedPK.get(ky);
if (oCached != null) {
sCached = oCached.toString();
if (UtilValidate.isEmpty(sCached)) {
useCached = false;
} else {
}
} else {
useCached = false;
}
}
} else {
//useCached = false;
usePassed = false;
}
}
}
GenericPK currentPK = null;
if (usePassed && useCached) {
currentPK = passedPK;
} else if (usePassed && !useCached) {
currentPK = passedPK;
} else if (!usePassed && useCached) {
currentPK = cachedPK;
}
if (currentPK != null) {
request.setAttribute("currentPK", currentPK);
GenericValue currentValue = null;
try {
currentValue = delegator.findOne(currentPK.getEntityName(), currentPK, false);
} catch (GenericEntityException e) {
}
request.setAttribute("currentValue", currentValue);
}
}