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


Java PersistenceManager类代码示例

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


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

示例1: getMedias

import javax.jdo.PersistenceManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<IMedia> getMedias(String domainKey) {
  Query q = null;
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    q = pm.newQuery(Media.class, "domainKey == '" + domainKey + "'");
    List<IMedia> result = (List<IMedia>) q.execute();
    return (List<IMedia>) pm.detachCopyAll(result);
  } finally {
    if (q != null) {
      try {
        q.closeAll();
      } catch (Exception ignored) {
        logger.warn("Exception while closing query", ignored);
      }
    }
    if (pm != null) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:24,代码来源:MediaEndPoint.java

示例2: getQuery

import javax.jdo.PersistenceManager; //导入依赖的package包/类
private static Query getQuery(QueryParams qp, PersistenceManager pm,
                              PageParams pageParams) {
  Query q;
  if (QueryParams.QTYPE.SQL.equals(qp.qType)) {
    String query = qp.query;
    if (query != null && pageParams != null && !query.contains(" LIMIT ")) {
      query +=
          " LIMIT " + pageParams.getOffset() + CharacterConstants.COMMA + pageParams
              .getSize();
    }
    q = pm.newQuery("javax.jdo.query.SQL", query);
    q.setClass(JDOUtils.getImplClass(qp.qClazz));
  } else {
    q = pm.newQuery(qp.query);
    if (pageParams != null) {
      QueryUtil.setPageParams(q, pageParams);
    }
  }
  return q;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:21,代码来源:JDOUtils.java

示例3: getConversationById

import javax.jdo.PersistenceManager; //导入依赖的package包/类
public IConversation getConversationById(String convId) throws ServiceException {
  IConversation conversation = null;
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Query query = pm.newQuery(JDOUtils.getImplClass(IConversation.class));
    query.setFilter("id == :convIdParam");
    Map<String, String> paramValues = new HashMap<>(1);
    paramValues.put("convIdParam", convId);
    query.setUnique(true);
    conversation = (IConversation) query.executeWithMap(paramValues);
    conversation = pm.detachCopy(conversation);
  } catch (Exception e) {
    xLogger.severe("{0} while creating getting conversation {1}", e.getMessage(), convId, e);
    throw new ServiceException(e);
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
  return conversation;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:ConversationServiceImpl.java

示例4: updateWidget

import javax.jdo.PersistenceManager; //导入依赖的package包/类
@Override
public String updateWidget(Long id, String ty, String val) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IWidget wid = JDOUtils.getObjectById(IWidget.class, id, pm);
    String name = wid.getName();
    if ("nm".equals(ty)) {
      wid.setName(val);
    } else if ("desc".equals(ty)) {
      wid.setDesc(val);
    }
    pm.makePersistent(wid);
    return name;
  } catch (Exception e) {
    xLogger.severe("Error in updating widget {0}", id, e);
    throw new ServiceException("Error in updating widget " + id, e);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:21,代码来源:DashboardService.java

示例5: updateWidgetConfig

import javax.jdo.PersistenceManager; //导入依赖的package包/类
@Override
public void updateWidgetConfig(IWidget widget) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IWidget wid = JDOUtils.getObjectById(IWidget.class, widget.getwId(), pm);
    wid.setTitle(widget.getTitle());
    wid.setSubtitle(widget.getSubtitle());
    wid.setType(widget.getType());
    wid.setFreq(widget.getFreq());
    wid.setNop(widget.getNop());
    wid.setAggrTy(widget.getAggrTy());
    wid.setAggr(widget.getAggr());
    wid.setyLabel(widget.getyLabel());
    wid.setExpEnabled(widget.getExpEnabled());
    wid.setShowLeg(widget.getShowLeg());
    pm.makePersistent(wid);
  } catch (Exception e) {
    xLogger.severe("Error in updating widget config for widget {0}", widget.getwId(), e);
    throw new ServiceException("Error in updating widget config for widget " + widget.getwId(),
        e);
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:DashboardService.java

示例6: closePersistenceManagerAfterFailedBegin

import javax.jdo.PersistenceManager; //导入依赖的package包/类
/**
 * Close the current transaction's EntityManager.
 * Called after a transaction begin attempt failed.
 * @param txObject the current transaction
 */
protected void closePersistenceManagerAfterFailedBegin(JdoTransactionObject txObject) {
	if (txObject.isNewPersistenceManagerHolder()) {
		PersistenceManager pm = txObject.getPersistenceManagerHolder().getPersistenceManager();
		try {
			if (pm.currentTransaction().isActive()) {
				pm.currentTransaction().rollback();
			}
		}
		catch (Throwable ex) {
			logger.debug("Could not rollback PersistenceManager after failed transaction begin", ex);
		}
		finally {
			PersistenceManagerFactoryUtils.releasePersistenceManager(pm, getPersistenceManagerFactory());
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JdoTransactionManager.java

示例7: findInvBatch

import javax.jdo.PersistenceManager; //导入依赖的package包/类
public IInvntryBatch findInvBatch(Long kioskId, Long materialId, String batchId,
                                  PersistenceManager pm) {
  if (batchId == null) {
    throw new IllegalArgumentException("Batch Id cannot be null");
  }
  Query
      q =
      pm.newQuery("SELECT FROM " + JDOUtils.getImplClassName(IInvntryBatch.class)
          + " WHERE kId == kIdParam && " +
          "mId == mIdParam && bid == bIdParam PARAMETERS Long kIdParam, Long mIdParam, String bIdParam");
  Map<String, Object> params = new HashMap<>();
  params.put("kIdParam", kioskId);
  params.put("mIdParam", materialId);
  params.put("bIdParam", batchId.toUpperCase());
  try {
    q.setUnique(true);
    IInvntryBatch result = (IInvntryBatch) q.executeWithMap(params);
    return pm.detachCopy(result);
  } finally {
    if (q != null) {
      q.closeAll();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:InvntryDao.java

示例8: 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

示例9: 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

示例10: addKioskLinks

import javax.jdo.PersistenceManager; //导入依赖的package包/类
public List<String> addKioskLinks(Long domainId, List<IKioskLink> links) throws ServiceException {
  xLogger.fine("Entering addKioskLink");
  if (links == null || links.isEmpty()) {
    throw new ServiceException("No links to add");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  // Set the timeStamp to now
  List<String> linkIds = new ArrayList<>(1);
  try {
    for (IKioskLink link : links) {
      try {
        addKioskLink(domainId, link, pm);
        linkIds.add(link.getId());
      } catch (ServiceException e) {
        xLogger.warn("ServiceException when adding kiosk link {0}: {1}", link.getId(),
            e.getMessage());
      }
    }
  } finally {
    pm.close();
  }
  xLogger.fine("Exiting addKioskLink");
  return linkIds;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:EntitiesServiceImpl.java

示例11: createNewStockEvent

import javax.jdo.PersistenceManager; //导入依赖的package包/类
private boolean createNewStockEvent(IInvntry inv, int updateSource,
                                    IInvntryEvntLog lastStockEvent, PersistenceManager pm) {
  int type = inv.getStockEvent();
  boolean
      createNewEvent =
      !(updateSource == IInvntryEvntLog.SOURCE_MINMAXUPDATE && type == IEvent.STOCKOUT) &&
          (lastStockEvent == null || lastStockEvent.getType() != type || !lastStockEvent
              .isOpen());
  boolean
      closeLastEvent =
      lastStockEvent != null && lastStockEvent.getType() != type && lastStockEvent.isOpen();

  if (closeLastEvent) { // close the last stock event, if different from the current event (e.g. earlier it was 0, now it is <min)
    lastStockEvent.setEndDate(inv.getTimestamp());
  }
  if (createNewEvent) {
    invntryDao.createInvntryEvntLog(type, inv);
    //Required to save stock event to inventory
    pm.makePersistent(inv);
    return true;
  }
  return false;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:24,代码来源:InventoryManagementServiceImpl.java

示例12: updateUserDetails

import javax.jdo.PersistenceManager; //导入依赖的package包/类
private static void updateUserDetails(SecureUserDetails userDetails, String ipAddress,
                                      String userAgent) {
  xLogger.fine("Entered updateUserDetails");
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    // More efficient to get/set using PM, instead of AccountsService
    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");
    // Generate IP Address matched event, if required
    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 e) {
    xLogger.warn("Unable to update user's last login time for user {0}: {1}",
        userDetails.getUsername(), e.getMessage());
  } finally {
    pm.close();
  }
  xLogger.fine("Exitig updateUserDetails");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:27,代码来源:AuthServlet.java

示例13: getMultiple

import javax.jdo.PersistenceManager; //导入依赖的package包/类
/**
 * Helper method to execute a JDO query in SQL and JQL.
 * @param qp
 * @param pm
 * @param pageParams
 * @return
 */
public static <T> List<T> getMultiple(QueryParams qp, PersistenceManager pm,
                                      PageParams pageParams){
  List<T> results = null;
  Query q = getQuery(qp, pm, pageParams);
  try {
    results = (List<T>) getResults(qp, q);
    if(results != null){
      results = (List<T>) pm.detachCopyAll(results);
    }

  } finally {
    q.closeAll();
  }
  return results;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:JDOUtils.java

示例14: getShipmentsByOrderId

import javax.jdo.PersistenceManager; //导入依赖的package包/类
/**
 * Get all shipment for a specific order
 *
 * @param orderId Order Id
 * @return -
 */
@Override
@SuppressWarnings("unchecked")
public List<IShipment> getShipmentsByOrderId(Long orderId, PersistenceManager pm) {
  Query query = null;
  try {
    query = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM SHIPMENT WHERE ORDERID = ?");
    query.setClass(JDOUtils.getImplClass(IShipment.class));
    List list = (List) query.executeWithArray(orderId);
    List<IShipment> shipments = new ArrayList<>(list.size());
    for (Object shipment : list) {
      shipments.add((IShipment) shipment);
    }
    return shipments;
  } catch (Exception e) {
    xLogger.severe("Error while fetching shipments by order id: {0}", orderId, e);
  } finally {
    if (query != null) {
      query.closeAll();
    }
  }
  return null;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:29,代码来源:ShipmentService.java

示例15: setJobMetaInfo

import javax.jdo.PersistenceManager; //导入依赖的package包/类
public static void setJobMetaInfo(Long jobId, Map<String, String> metadataMap) {
  // Get the Job ID and update.
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IJobStatus jobStatus = JDOUtils.getObjectById(IJobStatus.class, jobId, pm);
    if (metadataMap != null && !metadataMap.isEmpty()) {
      jobStatus.setMetadata(getMetadataString(metadataMap));
      pm.makePersistent(jobStatus);
    }
  } catch (Exception e) {
    xLogger
        .warn("{0} when updating metadata info for job with ID {1}: {2}", e.getClass().getName(),
            jobId, e.getMessage());
  } finally {
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:18,代码来源:JobUtil.java


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