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


Java PersistenceManager.makePersistentAll方法代码示例

本文整理汇总了Java中javax.jdo.PersistenceManager.makePersistentAll方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceManager.makePersistentAll方法的具体用法?Java PersistenceManager.makePersistentAll怎么用?Java PersistenceManager.makePersistentAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jdo.PersistenceManager的用法示例。


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

示例1: persistMinMaxLog

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Checks for changes in min and max of given inventories, and logs it if finds any change.
 *
 * @param invs list of inventory to check for min and max change
 * @return true when all changes persisted successfully.
 */
private boolean persistMinMaxLog(List<IInvntry> invs) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    List<IInventoryMinMaxLog> logs = new ArrayList<>(invs.size());
    for (IInvntry inv : invs) {
      DomainConfig dc = DomainConfig.getInstance(inv.getDomainId());
      logs.add(createMinMaxLog(inv, dc.getInventoryConfig().getMinMaxType(),
          dc.getInventoryConfig().getConsumptionRate()));
    }
    if (logs.size() > 0) {
      pm.makePersistentAll(logs);
    }
    return true;
  } catch (Exception e) {
    xLogger.severe("Error while persisting logs for min and max history", e);
  } finally {
    pm.close();
  }
  return false;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:27,代码来源:InventoryManagementServiceImpl.java

示例2: saveMnlTransactionRowList

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private static void saveMnlTransactionRowList(List<MnlTransactionRow> mnlTransRowList) {
  xLogger.fine("Entering saveMnlTransactionRowList");
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    // Iterate through the list of MnlTransactionRow objects. Get the MnlTransction objects and persist them.
    Iterator<MnlTransactionRow> mnlTransRowIter = mnlTransRowList.iterator();
    List<IMnlTransaction> mnlTransList = new ArrayList<>();
    while (mnlTransRowIter.hasNext()) {
      IMnlTransaction mnlTrans = mnlTransRowIter.next().mnlTransaction;
      mnlTransList.add(mnlTrans);
    }
    pm.makePersistentAll(mnlTransList);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:17,代码来源:MnlTransactionUtil.java

示例3: persistApprovers

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Persist the approvers which are new and update the one which already exists
 */
public void persistApprovers(List<IApprover> approvers, PersistenceManager pm, String userName) {
  if (!approvers.isEmpty()) {
    pm.makePersistentAll(approvers.stream()
        .map(apr -> {
          apr.setUpdatedBy(userName);
          apr.setCreatedOn(new Date());
          return apr;
        })
        .collect(Collectors.toList()));
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:15,代码来源:UpdateApproversAction.java

示例4: updateOrderStatus

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private UpdatedOrder updateOrderStatus(IOrder o, String newStatus, String updatingUserId,
    String message, PersistenceManager pm)
    throws ServiceException {
  xLogger.fine("Entered updateOrderStatus");
  if (o == null || newStatus == null || newStatus.isEmpty() || o.isStatus(newStatus)) {
    throw new IllegalArgumentException(
        "Invalid order or order status: " + newStatus + " old status: " + (o != null ? o
            .getStatus() : "'Order is null'"));
  }
  UpdatedOrder uo = new UpdatedOrder();
  try {
    String oldStatus = o.getStatus();

    // Change status
    o.setStatus(newStatus);
    o.commitStatus(); // NOTE: This method takes care of propagating status, setting order processing times, and/or updating accounts if accounting is enabled
    pm.makePersistentAll(o.getItems());
    o.setUpdatedBy(updatingUserId);
    o.setUpdatedOn(new Date(o.getStatusUpdatedOn().getTime()));
    IMessage iMessage = null;
    if (message != null && !message.isEmpty()) {
      iMessage = addMessageToOrder(o.getOrderId(), o.getDomainId(), message, updatingUserId, pm);
    }
    addStatusHistory(o.getOrderId(), oldStatus, newStatus, o.getDomainId(), iMessage,
        updatingUserId, pm);

  } catch (Exception e) {
    xLogger.severe("Exception in updateOrderStatus: {0} : {1}", e.getClass().getName(),
        e.getMessage(), e);
    throw new ServiceException(e);
  }
  xLogger.fine("Exiting updateOrderStatus");
  return uo;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:OrderManagementServiceImpl.java

示例5: removeKioskLink

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public static void removeKioskLink(Long kioskId) {
  AssetManagementService ams = null;
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    ams = Services.getService(AssetManagementServiceImpl.class);
    List<IAsset> assets = ams.getAssetsByKiosk(kioskId);

    if (assets != null && !assets.isEmpty()) {
      List<AssetModel> assetModels = new ArrayList<>(assets.size());
      for (IAsset asset : assets) {
        asset.setKioskId(null);
        asset.setUpdatedOn(new Date());

        AssetModel assetModel = buildFilterModel(asset);
        //Getting linked domains, because asset is disassociated from kiosk
        Set<Long>
            domainIds =
            DomainsUtil.getDomainLinks(asset.getDomainId(), IDomainLink.TYPE_PARENT, true);
        assetModel.tags = new ArrayList<>(domainIds.size());
        for (Long currentDomainId : domainIds) {
          assetModel.tags.add(String.valueOf(currentDomainId));
        }
        assetModels.add(assetModel);
      }
      pm.makePersistentAll(assets);

      //Updating tags for asset in AMS.
      registerDevices(gson.toJson(new AssetModels.AssetRegistrationModel(assetModels)));
    }
  } catch (Exception e) {
    xLogger.severe("Error while removing asset link for the kiosk {0}", kioskId, e);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:AssetUtil.java

示例6: addNewUpload

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void addNewUpload(List<IUploaded> uploads) throws ServiceException {
  xLogger.fine("Entered addNewUpload");
  String errMsg = null;
  PersistenceManager pm = PMF.get().getPersistenceManager();

  if (uploads == null) {
    throw new ServiceException("Nothing to upload");
  }

  // Iterate through the list of uploads.
  for (IUploaded u : uploads) {
    if (u.getId() == null) {
      u.setId(JDOUtils.createUploadedKey(u.getFileName(), u.getVersion(), u.getLocale()));
    }
  }

  // Write the list of Uploaded objects to the datastore.
  try {
    pm.makePersistentAll(uploads);
  } catch (Exception e) {
    errMsg = e.getMessage();
    xLogger.severe("Failed to store upload object", e);
  } finally {
    pm.close();
  }
  if (errMsg != null) {
    throw new ServiceException(errMsg);
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:30,代码来源:UploadServiceImpl.java

示例7: updateShipmentStatusForMigratoryOrder

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private boolean updateShipmentStatusForMigratoryOrder(String shipmentId, ShipmentStatus status,
    String message, String userId,
    PersistenceManager pm, String reason,
    Date shpDate) {
  boolean closePM = false;
  Transaction tx = null;
  if (pm == null) {
    pm = PMF.get().getPersistenceManager();
    tx = pm.currentTransaction();
    closePM = true;
  }
  try {
    if (closePM) {
      tx.begin();
    }
    IShipment shipment = JDOUtils.getObjectById(IShipment.class, shipmentId, pm);
    if (shipment == null) {
      throw new Exception(
          "Shipment is not available in db to update status. Shipment ID:" + shipmentId);
    }
    Date uon = null != shpDate ? shpDate : new Date();
    includeShipmentItems(shipment, pm);
    ShipmentStatus prevStatus = shipment.getStatus();
    shipment.setStatus(status);
    shipment.setUpdatedBy(userId);
    shipment.setUpdatedOn(shpDate);
    if (status == ShipmentStatus.SHIPPED || (prevStatus != ShipmentStatus.SHIPPED
        && status == ShipmentStatus.FULFILLED)) {

      IDemandService ds = Services.getService(DemandService.class);
      InventoryManagementService
          ims =
          Services.getService(InventoryManagementServiceImpl.class, this.getLocale());
      Long orderId = extractOrderId(shipmentId);
      List<IDemandItem> demandItems = ds.getDemandItems(orderId, pm);
      for (IShipmentItem shipmentItem : shipment.getShipmentItems()) {
        for (IDemandItem demandItem : demandItems) {
          if (demandItem.getMaterialId().equals(shipmentItem.getMaterialId())) {
            demandItem.setShippedQuantity(
                demandItem.getShippedQuantity().add(shipmentItem.getQuantity()));
            if (status == ShipmentStatus.FULFILLED) {
              demandItem.setFulfilledQuantity(
                  demandItem.getFulfilledQuantity().add(shipmentItem.getQuantity()));
            } else {
              IInvntry
                  custInvntry =
                  ims.getInventory(shipment.getKioskId(), demandItem.getMaterialId(), pm);
              custInvntry.setInTransitStock(
                  custInvntry.getInTransitStock().add(shipmentItem.getQuantity()));
              pm.makePersistent(custInvntry);
            }
          }
        }
      }
      pm.makePersistentAll(demandItems);
    }
    updateMessageAndHistory(shipmentId, message, userId, shipment.getOrderId(),
        shipment.getDomainId(), prevStatus, shipment.getStatus(), shpDate, pm);
    if (closePM) {
      tx.commit();
    }
  } catch (Exception e) {
    xLogger.severe("Error while getting shipment details.", e);
    return false;
  } finally {
    if (closePM && tx.isActive()) {
      tx.rollback();
    }
    if (closePM) {
      pm.close();
    }
  }
  return true;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:75,代码来源:ShipmentService.java


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