当前位置: 首页>>代码示例>>Java>>正文


Java GenericPK类代码示例

本文整理汇总了Java中org.ofbiz.entity.GenericPK的典型用法代码示例。如果您正苦于以下问题:Java GenericPK类的具体用法?Java GenericPK怎么用?Java GenericPK使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GenericPK类属于org.ofbiz.entity包,在下文中一共展示了GenericPK类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPromoQuantityCandidateUseActionAndAllConds

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public BigDecimal getPromoQuantityCandidateUseActionAndAllConds(GenericValue productPromoAction) {
    BigDecimal totalUse = BigDecimal.ZERO;
    String productPromoId = productPromoAction.getString("productPromoId");
    String productPromoRuleId = productPromoAction.getString("productPromoRuleId");

    GenericPK productPromoActionPK = productPromoAction.getPrimaryKey();
    BigDecimal existingValue = this.quantityUsedPerPromoCandidate.get(productPromoActionPK);
    if (existingValue != null) {
        totalUse = existingValue;
    }

    for (Map.Entry<GenericPK, BigDecimal> entry : this.quantityUsedPerPromoCandidate.entrySet()) {
        GenericPK productPromoCondActionPK = entry.getKey();
        BigDecimal quantityUsed = entry.getValue();
        if (quantityUsed != null) {
            // must be in the same rule and be a condition
            if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) &&
                    productPromoRuleId.equals(productPromoCondActionPK.getString("productPromoRuleId")) &&
                    productPromoCondActionPK.containsKey("productPromoCondSeqId")) {
                totalUse = totalUse.add(quantityUsed);
            }
        }
    }

    return totalUse;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:27,代码来源:ShoppingCartItem.java

示例2: resetPromoRuleUse

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public synchronized void resetPromoRuleUse(String productPromoId, String productPromoRuleId) {
    Iterator<Map.Entry<GenericPK, BigDecimal>> entryIter = this.quantityUsedPerPromoCandidate.entrySet().iterator();
    while (entryIter.hasNext()) {
        Map.Entry<GenericPK, BigDecimal> entry = entryIter.next();
        GenericPK productPromoCondActionPK = entry.getKey();
        BigDecimal quantityUsed = entry.getValue();
        if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) && productPromoRuleId.equals(productPromoCondActionPK.getString("productPromoRuleId"))) {
            entryIter.remove();
            BigDecimal existingValue = this.quantityUsedPerPromoFailed.get(productPromoCondActionPK);
            if (existingValue == null) {
                this.quantityUsedPerPromoFailed.put(productPromoCondActionPK, quantityUsed);
            } else {
                this.quantityUsedPerPromoFailed.put(productPromoCondActionPK, quantityUsed.add(existingValue));
            }
            this.promoQuantityUsed = this.promoQuantityUsed.subtract(quantityUsed);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:ShoppingCartItem.java

示例3: confirmPromoRuleUse

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public synchronized void confirmPromoRuleUse(String productPromoId, String productPromoRuleId) {
    Iterator<Map.Entry<GenericPK, BigDecimal>> entryIter = this.quantityUsedPerPromoCandidate.entrySet().iterator();
    while (entryIter.hasNext()) {
        Map.Entry<GenericPK, BigDecimal> entry = entryIter.next();
        GenericPK productPromoCondActionPK = entry.getKey();
        BigDecimal quantityUsed = entry.getValue();
        if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) && productPromoRuleId.equals(productPromoCondActionPK.getString("productPromoRuleId"))) {
            entryIter.remove();
            BigDecimal existingValue = this.quantityUsedPerPromoActual.get(productPromoCondActionPK);
            if (existingValue == null) {
                this.quantityUsedPerPromoActual.put(productPromoCondActionPK, quantityUsed);
            } else {
                this.quantityUsedPerPromoActual.put(productPromoCondActionPK, quantityUsed.add(existingValue));
            }
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:ShoppingCartItem.java

示例4: getCurrentValue

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public static void getCurrentValue(HttpServletRequest request, Delegator delegator) {
    HttpSession session = request.getSession();
    Map<String, GenericPK> currentEntityMap = UtilGenerics.checkMap(session.getAttribute("currentEntityMap"));
    if (currentEntityMap == null) {
        currentEntityMap     = FastMap.newInstance();
        session.setAttribute("currentEntityMap", currentEntityMap);
    }
    Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
    String entityName = (String)paramMap.get("entityName");
    if (UtilValidate.isEmpty(entityName)) {
        entityName = (String)request.getAttribute("entityName");
    }
    GenericPK cachedPK = null;
    if (UtilValidate.isNotEmpty(entityName)) {
        cachedPK = currentEntityMap.get(entityName);
    } 
    getCurrentValueWithCachedPK(request, delegator, cachedPK, entityName);
    GenericPK currentPK = (GenericPK)request.getAttribute("currentPK");
    currentEntityMap.put(entityName, currentPK);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:21,代码来源:ContentManagementWorker.java

示例5: put

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public GenericValue put(GenericPK pk, GenericValue entity) {
    if (pk.getModelEntity().getNeverCache()) {
        if (Debug.verboseOn()) { // SCIPIO: only log if verbose on (but still log as warning!)
            Debug.logWarning("Tried to put a value of the " + pk.getEntityName() + " entity in the BY PRIMARY KEY cache but this entity has never-cache set to true, not caching.", module);
        }
        return null;
    }

    if (entity == null) {
        entity = GenericValue.NULL_VALUE;
    } else {
        // before going into the cache, make this value immutable
        entity.setImmutable();
    }
    UtilCache<GenericPK, GenericValue> entityCache = getOrCreateCache(pk.getEntityName());
    return entityCache.put(pk, entity);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:EntityCache.java

示例6: remove

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public GenericValue remove(GenericPK pk) {
    UtilCache<GenericPK, GenericValue> entityCache = getCache(pk.getEntityName());
    if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], will remove from this cache: " + (entityCache == null ? "[No cache found to remove from]" : entityCache.getName()), module);
    if (entityCache == null) return null;
    GenericValue retVal = entityCache.remove(pk);
    ModelEntity model = pk.getModelEntity();
    if (model != null) {
        Iterator<String> it = model.getViewConvertorsIterator();
        while (it.hasNext()) {
            String targetEntityName = it.next();
            UtilCache.clearCache(getCacheName(targetEntityName));
        }
    }
    if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], found this in the cache: " + retVal, module);
    return retVal;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:EntityCache.java

示例7: testRemoveByPK

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public void testRemoveByPK() throws Exception {
    flushAndRecreateTree("remove-by-pk");
    //
    // Find all the root nodes,
    // delete them their primary key
    //
    EntityCondition isRoot = EntityCondition.makeCondition(
        EntityCondition.makeCondition("description", EntityOperator.LIKE, "remove-by-pk:%"),
        EntityOperator.AND,
        EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)
    );
    List<GenericValue> rootValues = EntityQuery.use(delegator).select("testingNodeId").from("TestingNode").where(isRoot).queryList();

    for (GenericValue value: rootValues) {
        GenericPK pk = value.getPrimaryKey();
        int del = delegator.removeByPrimaryKey(pk);
        assertEquals("Removing Root by primary key", 1, del);
    }

    // no more TestingNode should be in the data base anymore.

    List<GenericValue> testingNodes = EntityQuery.use(delegator).from("TestingNode").where(isRoot).queryList();
    assertEquals("No more TestingNode after removing the roots", 0, testingNodes.size());
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:25,代码来源:EntityTestSuite.java

示例8: distributedClearCacheLine

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public void distributedClearCacheLine(GenericPK primaryKey) {
    // Debug.logInfo("running distributedClearCacheLine for primaryKey: " + primaryKey, module);
    if (this.dispatcher == null) {
        Debug.logWarning("No dispatcher is available, somehow the setDelegator (which also creates a dispatcher) was not called, not running distributed cache clear", module);
        return;
    }

    GenericValue userLogin = getAuthUserLogin();
    if (userLogin == null) {
        Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module);
        return;
    }

    try {
        this.dispatcher.runAsync("distributedClearCacheLineByPrimaryKey", UtilMisc.toMap("primaryKey", primaryKey, "userLogin", userLogin), false);
    } catch (GenericServiceException e) {
        Debug.logError(e, "Error running the distributedClearCacheLineByPrimaryKey service", module);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:EntityCacheServices.java

示例9: addToCache

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
private boolean addToCache(GenericValue value) {
    if (value == null) {
        return false;
    }

    if (!veryifyValue(value)) {
        return false;
    }

    value = (GenericValue) value.clone();
    HashMap<GenericPK, GenericValue> entityCache = cache.get(value.getEntityName());
    if (entityCache == null) {
        entityCache = new HashMap<GenericPK, GenericValue>();
        cache.put(value.getEntityName(), entityCache);
    }

    entityCache.put(value.getPrimaryKey(), value);
    return true;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:20,代码来源:MemoryHelper.java

示例10: findFromCache

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
private GenericValue findFromCache(GenericPK pk) {
    if (pk == null) {
        return null;
    }

    HashMap<GenericPK, GenericValue> entityCache = cache.get(pk.getEntityName());
    if (entityCache == null) {
        return null;
    }

    GenericValue value = entityCache.get(pk);
    if (value == null) {
        return null;
    } else {
        return (GenericValue) value.clone();
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:18,代码来源:MemoryHelper.java

示例11: removeFromCache

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
private int removeFromCache(GenericPK pk) {
    if (pk == null) {
        return 0;
    }

    HashMap<GenericPK, GenericValue> entityCache = cache.get(pk.getEntityName());
    if (entityCache == null) {
        return 0;
    }

    Object o = entityCache.remove(pk);
    if (o == null) {
        return 0;
    } else {
        return 1;
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:18,代码来源:MemoryHelper.java

示例12: findByOr

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public List<GenericValue> findByOr(ModelEntity modelEntity, Map<String, Object> fields, List<String> orderBy) throws GenericEntityException {
    HashMap<GenericPK, GenericValue> entityCache = cache.get(modelEntity.getEntityName());
    if (entityCache == null) {
        return Collections.emptyList();
    }

    ArrayList<GenericValue> result = new ArrayList<GenericValue>();
    for (GenericValue value: entityCache.values()) {
        if (isOrMatch(value.getAllFields(), fields)) {
            result.add(value);
        }
    }

    return result;

}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:17,代码来源:MemoryHelper.java

示例13: removeByAnd

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public int removeByAnd(ModelEntity modelEntity, Map<String, Object> fields) throws GenericEntityException {
    HashMap<GenericPK, GenericValue> entityCache = cache.get(modelEntity.getEntityName());
    if (entityCache == null) {
        return 0;
    }

    ArrayList<GenericPK> removeList = new ArrayList<GenericPK>();
    for (Map.Entry<GenericPK, GenericValue> mapEntry: entityCache.entrySet()) {
        GenericValue value = mapEntry.getValue();
        if (isAndMatch(value.getAllFields(), fields)) {
            removeList.add(mapEntry.getKey());
        }
    }

    return removeAll(removeList);
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:17,代码来源:MemoryHelper.java

示例14: testRemoveByPK

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
public void testRemoveByPK() throws Exception {
    flushAndRecreateTree("remove-by-pk");
    //
    // Find all the root nodes,
    // delete them their primary key
    //
    EntityCondition isRoot = EntityCondition.makeCondition(
        EntityCondition.makeCondition("description", EntityOperator.LIKE, "remove-by-pk:%"),
        EntityOperator.AND,
        EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)
    );
    List<GenericValue> rootValues = delegator.findList("TestingNode", isRoot, UtilMisc.toSet("testingNodeId"), null, null, false);

    for (GenericValue value: rootValues) {
        GenericPK pk = value.getPrimaryKey();
        int del = delegator.removeByPrimaryKey(pk);
        assertEquals("Removing Root by primary key", 1, del);
    }

    // no more TestingNode should be in the data base anymore.

    List<GenericValue> testingNodes = delegator.findList("TestingNode", isRoot, null, null, null, false);
    assertEquals("No more TestingNode after removing the roots", 0, testingNodes.size());
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:25,代码来源:EntityTestSuite.java

示例15: duplicateRelated

import org.ofbiz.entity.GenericPK; //导入依赖的package包/类
protected static void duplicateRelated(GenericValue product, String title, String relatedEntityName, String productIdField, String variantProductId, Timestamp nowTimestamp, boolean removeOld, Delegator delegator, boolean test) throws GenericEntityException {
    List<GenericValue> relatedList = EntityUtil.filterByDate(product.getRelated(title + relatedEntityName, null, null, false), nowTimestamp);
    for (GenericValue relatedValue: relatedList) {
        GenericValue newRelatedValue = (GenericValue) relatedValue.clone();
        newRelatedValue.set(productIdField, variantProductId);

        // create a new one? see if one already exists with different from/thru dates
        ModelEntity modelEntity = relatedValue.getModelEntity();
        if (modelEntity.isField("fromDate")) {
            GenericPK findValue = newRelatedValue.getPrimaryKey();
            // can't just set to null, need to remove the value so it isn't a constraint in the query
            //findValue.set("fromDate", null);
            findValue.remove("fromDate");
            List<GenericValue> existingValueList = EntityQuery.use(delegator).from(relatedEntityName).where(findValue).filterByDate(nowTimestamp).queryList();
            if (existingValueList.size() > 0) {
                if (test) {
                    Debug.logInfo("Found " + existingValueList.size() + " existing values for related entity name: " + relatedEntityName + ", not copying, findValue is: " + findValue, module);
                }
                continue;
            }
            newRelatedValue.set("fromDate", nowTimestamp);
        }

        if (EntityQuery.use(delegator).from(relatedEntityName).where(EntityCondition.makeCondition(newRelatedValue.getPrimaryKey(), EntityOperator.AND)).queryCount() == 0) {
            if (test) {
                Debug.logInfo("Test mode, would create: " + newRelatedValue, module);
            } else {
                newRelatedValue.create();
            }
        }
    }
    if (removeOld) {
        if (test) {
            Debug.logInfo("Test mode, would remove related " + title + relatedEntityName + " with dummy key: " + product.getRelatedDummyPK(title + relatedEntityName), module);
        } else {
            product.removeRelated(title + relatedEntityName);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:40,代码来源:ProductUtilServices.java


注:本文中的org.ofbiz.entity.GenericPK类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。