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


Java PersistenceManager.close方法代码示例

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


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

示例1: updateUserDetails

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private static void updateUserDetails(SecureUserDetails userDetails, String ipAddress,
                                      String userAgent) {
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    IUserAccount u = JDOUtils.getObjectById(IUserAccount.class, userDetails.getUsername(), pm);
    u.setLastLogin(new Date());
    u.setIPAddress(ipAddress);
    u.setPreviousUserAgent(u.getUserAgent());
    u.setUserAgent(userAgent);
    u.setAppVersion("LogiWeb");
    Map<String, Object> params = new HashMap<>(1);
    params.put("ipaddress", u.getIPAddress());
    EventPublisher.generate(u.getDomainId(), IEvent.IP_ADDRESS_MATCHED, params,
        UserAccount.class.getName(), u.getKeyString(),
        null);
  } catch (Exception ignored) {
    // do nothing
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:AuthController.java

示例2: log

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public static void log(IMessageLog mlog) throws MessageHandlingException {
  xLogger.fine("Entered log");
  if (mlog == null) {
    throw new MessageHandlingException("Invalid message log");
  }
  if (mlog.getKey() == null) {
    throw new MessageHandlingException("Invalid key");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  String msg = null;
  try {
    pm.makePersistent(mlog);
  } catch (Exception e) {
    msg = e.getMessage();
  } finally {
    pm.close();
  }
  if (msg != null) {
    throw new MessageHandlingException(msg);
  }
  xLogger.fine("Exiting log");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:MessageUtil.java

示例3: getObject

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public Object getObject(PersistenceManager pm) {
  if (oty == null || oty.isEmpty() || oId == null || oId.isEmpty()) {
    return null;
  }
  boolean closePm = false;
  if (pm == null) {
    pm = PMF.get().getPersistenceManager();
    closePm = true;
  }
  try {
    return pm.getObjectById(Class.forName(oty), oId);
  } catch (Exception e) {
    xLogger
        .warn("{0} when getting object of type {1} of event with oId {2}", e.getClass().getName(),
            oty, oId);
    return null;
  } finally {
    if (closePm) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:24,代码来源:Event.java

示例4: getMaterial

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IMaterial getMaterial(Long materialId) throws ServiceException {
  xLogger.fine("Entering getMaterial");
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    //Get the material object from the database
    IMaterial material = JDOUtils.getObjectById(IMaterial.class, materialId, pm);
    //If we get here, it means the material exists
    material = pm.detachCopy(material);
    xLogger.fine("Exiting getMaterial");
    return material;
  } catch (JDOObjectNotFoundException e) {
    xLogger.warn("getMaterial: FAILED!!! Material {0} does not exist in the database", materialId,
        e);
    throw new ServiceException(
        messages.getString("material") + " " + materialId + " " + backendMessages
            .getString("error.notfound"));
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:21,代码来源:MaterialCatalogServiceImpl.java

示例5: resetRelatedEntitiesOrdering

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void resetRelatedEntitiesOrdering(Long kioskId, String linkType) throws ServiceException {
  xLogger.fine("Entering resetRelatedEntitiesOrdering");
  // Update the Kiosk to set the route enabled flag
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IKiosk k = JDOUtils.getObjectById(IKiosk.class, kioskId, pm);
    k.setRouteEnabled(linkType, false);
  } catch (Exception e) {
    xLogger.severe("{0} when trying to set the routeEnabled flag for kiosk {1}. Message: {2}",
        e.getClass().getName(), kioskId, e.getMessage());
  } finally {
    pm.close();
  }
  xLogger.fine("Exiting resetRelatedEntitiesOrdering");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:16,代码来源:EntitiesServiceImpl.java

示例6: getHandlingUnitByName

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public IHandlingUnit getHandlingUnitByName(Long domainId, String handlingUnitName)
    throws ServiceException {
  if (domainId == null || StringUtils.isEmpty(handlingUnitName)) {
    throw new ServiceException("Invalid parameters");
  }
  IHandlingUnit hu = null;
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    // Form the query
    Query huQuery = pm.newQuery(JDOUtils.getImplClass(IHandlingUnit.class));
    huQuery.setFilter("dId.contains(dIdParam) && nName == nameParam");
    huQuery.declareParameters("Long dIdParam, String nameParam");
    try {
      List<IHandlingUnit>
          results =
          (List<IHandlingUnit>) huQuery.execute(domainId, handlingUnitName.toLowerCase());
      if (results != null && !results.isEmpty()) {
        hu = results.get(0);
        hu = pm.detachCopy(hu);
      }
    } finally {
      huQuery.closeAll();
    }
  } catch (Exception e) {
    xLogger.severe("Error while trying to get handling unit by name {0}", handlingUnitName, e);
  } finally {
    pm.close();
  }
  return hu;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:32,代码来源:HandlingUnitServiceImpl.java

示例7: getById

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IInvntry getById(String id) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    return getById(id, pm);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:9,代码来源:InvntryDao.java

示例8: getEnabledUserIdsWithTags

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Get the list of enabled userIds from the given tagNames
 */
public List<String> getEnabledUserIdsWithTags(List<String> tagNames, Long domainId) {
  List<String> uIds = null;
  if (tagNames != null && tagNames.size() > 0) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String tagName = MessageUtil.getCSVWithEnclose(tagNames);
    String query = "SELECT UA.USERID FROM USERACCOUNT UA,USER_TAGS UT WHERE "
        + "UT.ID IN (SELECT ID FROM TAG WHERE NAME IN (" + tagName + ") AND TYPE=4)"
        + " AND UT.USERID = UA.USERID AND UA.ISENABLED = 1 AND UA.SDID = ?";
    Query q = pm.newQuery("javax.jdo.query.SQL", query);
    try {
      List l = (List) q.executeWithArray(domainId);
      uIds = new ArrayList<>(l.size());
      for (Object o : l) {
        uIds.add((String) o);
      }
    } catch (Exception e) {
      xLogger.warn("Error while getting enabled user by tags {0}", tagName, e);
    } finally {
      try {
        q.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
      pm.close();
    }
  }
  return uIds;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:32,代码来源:UsersServiceImpl.java

示例9: deleteAssetRelationByRelatedAsset

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void deleteAssetRelationByRelatedAsset(Long relatedAssetId) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    Query query = pm.newQuery(JDOUtils.getImplClass(IAssetRelation.class));
    query.setFilter("relatedAssetId == relatedAssetIdParam");
    query.declareParameters("Long relatedAssetIdParam");
    List<IAssetRelation> assetRelations = null;
    try {
      assetRelations = (List<IAssetRelation>) query.execute(relatedAssetId);
      assetRelations = (List<IAssetRelation>) pm.detachCopyAll(assetRelations);
    } catch (Exception ignored) {
      //do nothing
    } finally {
      query.closeAll();
    }

    if (assetRelations != null && assetRelations.size() == 1) {
      IAssetRelation assetRelationTmp = assetRelations.get(0);
      pm.deletePersistent(assetRelationTmp);
    }
  } catch (Exception e) {
    xLogger.warn("{0} while deleting asset relationship for the asset {1}", e.getMessage(),
        relatedAssetId, e);
    throw new ServiceException(e.getMessage());
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:29,代码来源:AssetManagementServiceImpl.java

示例10: getAssetsByKiosk

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public List<IAsset> getAssetsByKiosk(Long kioskId) throws ServiceException {
  if (kioskId == null) {
    throw new ServiceException("");//TODO
  }

  List<IAsset> assets = null;
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    Query query = pm.newQuery(JDOUtils.getImplClass(IAsset.class));
    query.setFilter("kId == kioskIdParam");
    query.declareParameters("Long kioskIdParam");
    try {
      assets = (List<IAsset>) query.execute(kioskId);
      assets = (List<IAsset>) pm.detachCopyAll(assets);
    } finally {
      query.closeAll();
    }
  } catch (Exception e) {
    xLogger.severe("{0} while getting assets for the kiosk {1}", e.getMessage(), kioskId, e);
    throw new ServiceException(e.getMessage());
  } finally {
    pm.close();
  }

  return assets;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:28,代码来源:AssetManagementServiceImpl.java

示例11: getAssetRelationByRelatedAsset

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public IAssetRelation getAssetRelationByRelatedAsset(Long relatedAssetId)
    throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    Query query = pm.newQuery(JDOUtils.getImplClass(IAssetRelation.class));
    query.setFilter("relatedAssetId == relatedAssetIdParam");
    query.declareParameters("Long relatedAssetIdParam");
    List<IAssetRelation> assetRelations = null;
    try {
      assetRelations = (List<IAssetRelation>) query.execute(relatedAssetId);
      assetRelations = (List<IAssetRelation>) pm.detachCopyAll(assetRelations);
    } catch (Exception ignored) {
      //do nothing
    } finally {
      query.closeAll();
    }

    if (assetRelations != null && assetRelations.size() == 1) {
      return assetRelations.get(0);
    }
  } catch (Exception e) {
    xLogger.warn("{0} while deleting asset relationship for the asset {1}", e.getMessage(),
        relatedAssetId, e);
    throw new ServiceException(e.getMessage());
  } finally {
    pm.close();
  }

  return null;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:32,代码来源:AssetManagementServiceImpl.java

示例12: getAllCountries

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public List<String> getAllCountries(Long domainId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  List<String> districts = new ArrayList<>(1);
  try {
    query =
        pm.newQuery("javax.jdo.query.SQL",
            "SELECT DISTINCT COUNTRY  FROM KIOSK WHERE KIOSKID IN " +
                "( SELECT KIOSKID_OID IN  KIOSK_DOMAINS WHERE DOMAIN_ID=" + domainId + ")");
    List dsts = (List) query.execute();
    for (Object dst : dsts) {
      String district = (String) dst;
      if (district != null) {
        districts.add(district);
      }
    }
    return districts;
  } catch (Exception e) {
    xLogger.severe("Error while fetching material ids from domain {0} and query {1}", domainId,
        query, e);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    pm.close();
  }
  return null;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:34,代码来源:EntitiesServiceImpl.java

示例13: getAllMaterialsIds

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public List<Long> getAllMaterialsIds(Long domainId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  List<Long> materialIds = new ArrayList<>(1);
  try {
    query =
        pm.newQuery("javax.jdo.query.SQL",
            "SELECT MATERIALID FROM MATERIAL M, MATERIAL_DOMAINS MD WHERE " +
                "MD.MATERIALID_OID = M.MATERIALID AND MD.DOMAIN_ID=" + domainId);
    List matIds = (List) query.execute();
    for (Object matId : matIds) {
      Long matIdL = (Long) matId;
      if (matIdL != null) {
        materialIds.add(matIdL);
      }
    }
    return materialIds;
  } catch (Exception e) {
    xLogger.severe("Error while fetching material ids from domain {0} and query {1}", domainId,
        query, e);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    pm.close();
  }
  return null;

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:MaterialDao.java

示例14: addHandlingUnit

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public Long addHandlingUnit(Long domainId, IHandlingUnit handlingUnit) throws ServiceException {
  Date now = new Date();
  handlingUnit.setTimeStamp(now);
  handlingUnit.setLastUpdated(now);
  handlingUnit.setDomainId(domainId);
  IHandlingUnit handlingUnitByName = getHandlingUnitByName(domainId, handlingUnit.getName());
  if (handlingUnitByName != null) {
    xLogger.warn("add: Handling unit with name {0} already exists", handlingUnit.getName());
    throw new ServiceException(
        backendMessages.getString("error.cannotadd") + ". '" + handlingUnit.getName() + "' "
            + backendMessages.getString("error.alreadyexists") + ".");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    DomainsUtil.addToDomain(handlingUnit, domainId, pm);
  } finally {
    pm.close();
  }

      /*
      //todo: This code already modified to handle notification. Need to enable this when we enable notification for handing units.
      EventGenerator eg = EventGeneratorFactory.getEventGenerator(domainId, JDOUtils.getImplClass(IHandlingUnit.class).getName());
      try {
          eg.generate( IEvent.CREATED, null, String.valueOf(handlingUnit.getId()), null );
      } catch (EventHandlingException e) {
          xLogger.warn( "Exception when generating event for handling unit-creation for handling unit {0} in domain {1}", handlingUnit.getId(), domainId,e );
      }*/
  return handlingUnit.getId();
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:31,代码来源:HandlingUnitServiceImpl.java

示例15: removeMultipartMsg

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public static void removeMultipartMsg(IMultipartMsg mmsg) throws MessageHandlingException {
  if (mmsg == null) {
    throw new MessageHandlingException("Invalid message object");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    pm.deletePersistent(mmsg);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:12,代码来源:MessageUtil.java


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