當前位置: 首頁>>代碼示例>>Java>>正文


Java PersistenceManager.isClosed方法代碼示例

本文整理匯總了Java中javax.jdo.PersistenceManager.isClosed方法的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceManager.isClosed方法的具體用法?Java PersistenceManager.isClosed怎麽用?Java PersistenceManager.isClosed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jdo.PersistenceManager的用法示例。


在下文中一共展示了PersistenceManager.isClosed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDemandItemAsMap

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public Map<String, Object> getDemandItemAsMap(Long id, String currency, Locale locale,
                                              String timezone, boolean forceIntegerQuantity) {
  Map<String, Object> map = new HashMap<>(1);
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IDemandItem di = JDOUtils.getObjectById(IDemandItem.class, id, pm);
    map.put(JsonTagsZ.MATERIAL_ID, di.getMaterialId().toString());
    map.put(JsonTagsZ.QUANTITY, BigUtil.getFormattedValue(di.getQuantity()));
    map.put(JsonTagsZ.ORIGINAL_ORDERED_QUANTITY,
        BigUtil.getFormattedValue(di.getOriginalQuantity()));
    map.put(JsonTagsZ.RECOMMENDED_ORDER_QUANTITY,
        BigUtil.getFormattedValue(di.getRecommendedOrderQuantity()));

    MaterialCatalogService mcs = Services.getService(MaterialCatalogServiceImpl.class);
    IMaterial m = mcs.getMaterial(di.getMaterialId());
    String customMaterialId = m.getCustomId();
    if (customMaterialId != null && !customMaterialId.isEmpty()) {
      map.put(JsonTagsZ.CUSTOM_MATERIALID, customMaterialId);
    }

    map.put(JsonTagsZ.ALLOCATED_QUANTITY, BigUtil.getFormattedValue(
        getAllocatedQuantityForDemandItem(di.getIdAsString(), di.getOrderId(),
            di.getMaterialId())));
    List<Map<String, String>> batches = null;
    if (m.isBatchEnabled()) {
      batches =
          getBatchMetadataForDemandItem(di.getIdAsString(), di.getOrderId(), di.getMaterialId(),
              locale, timezone);
    }

    // Add batches if has inventory allocation by batches is present
    if (batches != null && !batches.isEmpty()) {
      map.put(JsonTagsZ.BATCHES, batches);
    }

    map.put(JsonTagsZ.FULFILLED_QUANTITY, BigUtil.getFormattedValue(di.getFulfilledQuantity()));
    if (di.getReason() != null) {
      map.put(JsonTagsZ.REASON, di.getReason()); // Will be deprecated
      map.put(JsonTagsZ.REASON_FOR_IGNORING_RECOMMENDED_QUANTITY, di.getReason());
    }

    if (di.getShippedDiscrepancyReason() != null) {
      map.put(JsonTagsZ.REASONS_FOR_EDITING_ORDER_QUANTITY, di.getShippedDiscrepancyReason());
    }

    if (di.getTimestamp() != null) {
      map.put(JsonTagsZ.TIMESTAMP, LocalDateUtil.format(di.getTimestamp(), locale, timezone));
    }
    if (di.getUnitPrice() != null) {
      map.put(JsonTagsZ.RETAILER_PRICE, di.getUnitPrice().toString());
    }
    if (di.getCurrency() != null && !di.getCurrency().equals(currency)) {
      map.put(JsonTagsZ.CURRENCY, di.getCurrency());
    }
    if (di.getStatus() != null) {
      map.put(JsonTagsZ.ORDER_STATUS, di.getStatus());
    }
    if (di.getMessage() != null) {
      map.put(JsonTagsZ.MESSAGE, di.getMessage());
    }
    if (di.getDiscount() != null && BigUtil.notEqualsZero(di.getDiscount())) {
      map.put(JsonTagsZ.DISCOUNT, BigUtil.getFormattedValue(di.getDiscount()));
    }
  } catch (Exception e) {
    xLogger.severe("Exception while getting demand item with id {0} as map", id);
  } finally {
    if (!pm.isClosed()) {
      pm.close();
    }
  }
  return map;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:74,代碼來源:DemandService.java


注:本文中的javax.jdo.PersistenceManager.isClosed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。