本文整理汇总了Java中org.ofbiz.entity.model.DynamicViewEntity.addAlias方法的典型用法代码示例。如果您正苦于以下问题:Java DynamicViewEntity.addAlias方法的具体用法?Java DynamicViewEntity.addAlias怎么用?Java DynamicViewEntity.addAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.entity.model.DynamicViewEntity
的用法示例。
在下文中一共展示了DynamicViewEntity.addAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeDuplicateOpenEndedCategoryMembers
import org.ofbiz.entity.model.DynamicViewEntity; //导入方法依赖的package包/类
public static Map<String, Object> removeDuplicateOpenEndedCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
Locale locale = (Locale) context.get("locale");
String errMsg = null;
try {
DynamicViewEntity dve = new DynamicViewEntity();
dve.addMemberEntity("PCM", "ProductCategoryMember");
dve.addAlias("PCM", "productId", null, null, null, Boolean.TRUE, null);
dve.addAlias("PCM", "productCategoryId", null, null, null, Boolean.TRUE, null);
dve.addAlias("PCM", "fromDate", null, null, null, null, null);
dve.addAlias("PCM", "thruDate", null, null, null, null, null);
dve.addAlias("PCM", "productIdCount", "productId", null, null, null, "count");
EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, nowTimestamp),
EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)
), EntityOperator.AND);
EntityCondition havingCond = EntityCondition.makeCondition("productIdCount", EntityOperator.GREATER_THAN, Long.valueOf(1));
EntityListIterator eli = EntityQuery.use(delegator).select("productId", "productCategoryId", "productIdCount").from(dve).where(condition).having(havingCond).queryIterator();
GenericValue pcm = null;
int numSoFar = 0;
while ((pcm = eli.next()) != null) {
List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")).queryList();
if (productCategoryMemberList.size() > 1) {
// remove all except the first...
productCategoryMemberList.remove(0);
for (GenericValue productCategoryMember: productCategoryMemberList) {
productCategoryMember.remove();
}
numSoFar++;
if (numSoFar % 500 == 0) {
Debug.logInfo("Removed category members for " + numSoFar + " products with duplicate category members.", module);
}
}
}
eli.close();
Debug.logInfo("Completed - Removed category members for " + numSoFar + " products with duplicate category members.", module);
} catch (GenericEntityException e) {
Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
errMsg = UtilProperties.getMessage(resourceError,"productutilservices.entity_error_running_removeDuplicateOpenEndedCategoryMembers", messageMap, locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
return ServiceUtil.returnSuccess();
}
示例2: removeDuplicateOpenEndedCategoryMembers
import org.ofbiz.entity.model.DynamicViewEntity; //导入方法依赖的package包/类
public static Map<String, Object> removeDuplicateOpenEndedCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
Locale locale = (Locale) context.get("locale");
String errMsg = null;
try {
DynamicViewEntity dve = new DynamicViewEntity();
dve.addMemberEntity("PCM", "ProductCategoryMember");
dve.addAlias("PCM", "productId", null, null, null, Boolean.TRUE, null);
dve.addAlias("PCM", "productCategoryId", null, null, null, Boolean.TRUE, null);
dve.addAlias("PCM", "fromDate", null, null, null, null, null);
dve.addAlias("PCM", "thruDate", null, null, null, null, null);
dve.addAlias("PCM", "productIdCount", "productId", null, null, null, "count");
EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, nowTimestamp),
EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)
), EntityOperator.AND);
EntityCondition havingCond = EntityCondition.makeCondition("productIdCount", EntityOperator.GREATER_THAN, Long.valueOf(1));
EntityListIterator eli = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productCategoryId", "productIdCount"), null, null);
GenericValue pcm = null;
int numSoFar = 0;
while ((pcm = eli.next()) != null) {
List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")), null, false);
if (productCategoryMemberList.size() > 1) {
// remove all except the first...
productCategoryMemberList.remove(0);
for (GenericValue productCategoryMember: productCategoryMemberList) {
productCategoryMember.remove();
}
numSoFar++;
if (numSoFar % 500 == 0) {
Debug.logInfo("Removed category members for " + numSoFar + " products with duplicate category members.", module);
}
}
}
eli.close();
Debug.logInfo("Completed - Removed category members for " + numSoFar + " products with duplicate category members.", module);
} catch (GenericEntityException e) {
Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
errMsg = UtilProperties.getMessage(resourceError,"productutilservices.entity_error_running_removeDuplicateOpenEndedCategoryMembers", messageMap, locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
return ServiceUtil.returnSuccess();
}
示例3: addFieldDef
import org.ofbiz.entity.model.DynamicViewEntity; //导入方法依赖的package包/类
private static void addFieldDef(DynamicViewEntity dve, List<String> groupBy, String alias, FieldValue fieldValue, String function) {
dve.addAlias(fieldValue.getTableName(), alias, fieldValue.getFieldName(), null, null, groupBy.contains(alias), function);
}