本文整理汇总了Java中javax.jdo.PersistenceManager.getObjectById方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceManager.getObjectById方法的具体用法?Java PersistenceManager.getObjectById怎么用?Java PersistenceManager.getObjectById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jdo.PersistenceManager
的用法示例。
在下文中一共展示了PersistenceManager.getObjectById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: getEventObject
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private Object getEventObject() {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Get the object associated with the event
if (oId != null) {
Object o = pm.getObjectById(Class.forName(oty), oId);
return pm.detachCopy(o);
}
} catch (Exception e) {
xLogger.warn("{0} when getting object {3} in domain {4}: {5} for event {1}:{2}",
e.getClass().getName(), oty, id, oId, dId, e.getMessage());
} finally {
pm.close();
}
return null;
}
示例3: getTagParams
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public static Map<String, Object> getTagParams(String objectType, String objectId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Object o;
try {
if (objectId != null) {
o =
pm.getObjectById(Class.forName(objectType),
AppFactory.get().getDaoUtil().createKeyFromString(objectId));
return getTagParams(o);
}
} catch (Exception e) {
xLogger.warn("Object {0} ({1}) not found when notify event ", objectId,
objectType);
} finally {
pm.close();
}
return null;
}
示例4: getInvntryEvntLog
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IInvntryEvntLog getInvntryEvntLog(IInvntry iInvntry) {
Invntry invntry = (Invntry) iInvntry;
if (invntry.getLastStockEvent() != null) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IInvntryEvntLog
invLog =
pm.getObjectById(InvntryEvntLog.class, invntry.getLastStockEvent());
invLog = pm.detachCopy(invLog);
return invLog;
} catch (Exception e) {
return null;
} finally {
pm.close();
}
}
return null;
}
示例5: getLastStockEvent
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IInvntryEvntLog getLastStockEvent(IInvntry inv, PersistenceManager pm) {
Long key = ((Invntry) inv).getLastStockEvent();
if (key == null) {
return null;
}
try {
// Get the stock event object of this type
return pm.getObjectById(InvntryEvntLog.class, key);
} catch (Exception e) {
xLogger.warn(
"{0} when getting inv. event log for stock-replensishment event mid-kid {1}-{2} in domain {3} for key {4}: {5}",
e.getClass().getName(), inv.getMaterialId(), inv.getKioskId(), inv.getDomainId(),
key.toString(), e);
}
return null;
}
示例6: lookup
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private void lookup(Class clazz, PersistenceManager pm) {
try {
pm.getObjectById(clazz, 1);
} catch (Exception e) {
//Ignore just for initializing
}
}
示例7: moveToInProgress
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public void moveToInProgress(Long taskId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
ITask task = pm.getObjectById(Task.class, taskId);
task.setStatus(Task.INPROGRESS);
task.setUpdatedOn(new Date());
pm.makePersistent(task);
} finally {
pm.close();
}
}
示例8: complete
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public void complete(Long taskId, long duration) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
ITask task = pm.getObjectById(Task.class, taskId);
task.setStatus(Task.COMPLETED);
task.setUpdatedOn(new Date());
task.setDuration((int) (duration));
pm.makePersistent(task);
} finally {
pm.close();
}
}
示例9: fail
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public void fail(TaskOptions taskOptions, long duration, String reason) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
ITask task = pm.getObjectById(Task.class, taskOptions.getTaskId());
task.setStatus(Task.FAILED);
task.setUpdatedOn(new Date());
task.setDuration((int) duration);
task.setReason(reason);
task.setRetries(task.getRetries() + 1);
task = pm.makePersistent(task);
if (task.getRetries() < 3) {
Queue q = null;
String queueName = task.getQueue();
if (queueName != null && !queueName.isEmpty()) {
q = QueueFactory.getQueue(queueName);
} else {
q = QueueFactory.getDefaultQueue();
}
taskOptions.etaMillis(System.currentTimeMillis() + task.getRetries() * 30000);
q.add(taskOptions);
_logger.info("Rescheduling failed task {0} with interval {1}", taskOptions,
taskOptions.getEtaMillis());
}
} finally {
pm.close();
}
}
示例10: getInvntry
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IInvntry getInvntry(IInvntryEvntLog invEventLog) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IInvntry invntry = pm.getObjectById(Invntry.class, ((InvntryEvntLog) invEventLog).getInvId());
invntry = pm.detachCopy(invntry);
return invntry;
} finally {
pm.close();
}
}
示例11: removeMedia
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public void removeMedia(Long id) throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
Media media;
try {
media = pm.getObjectById(Media.class, id);
BlobstoreService blobstoreService = AppFactory.get().getBlobstoreService();
blobstoreService.remove(media.getServingUrl());
pm.deletePersistent(media);
} catch (Exception e) {
throw new ServiceException("Error while deleting media", e);
} finally {
pm.close();
}
}
示例12: getTemplateValues
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public Map<String, String> getTemplateValues(Locale locale, String timezone,
List<String> excludeVars, Date updationTime) {
HashMap<String, String> varMap = new HashMap<String, String>();
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Entity
IKiosk k = null;
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_CUSTOMER)) {
k = pm.getObjectById(Kiosk.class, invntryBatch.getKioskId());
varMap.put(EventsConfig.VAR_CUSTOMER, k.getName());
}
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_CUSTOMERCITY)) {
if (k == null) {
k = pm.getObjectById(Kiosk.class, invntryBatch.getKioskId());
}
varMap.put(EventsConfig.VAR_CUSTOMERCITY, k.getCity());
}
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_ENTITY)) {
if (k == null) {
k = pm.getObjectById(Kiosk.class, invntryBatch.getKioskId());
}
varMap.put(EventsConfig.VAR_ENTITY, k.getName());
}
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_ENTITYCITY)) {
if (k == null) {
k = pm.getObjectById(Kiosk.class, invntryBatch.getKioskId());
}
varMap.put(EventsConfig.VAR_ENTITYCITY, k.getCity());
}
// Material
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_MATERIAL)) {
String name = pm.getObjectById(Material.class, invntryBatch.getMaterialId()).getName();
varMap.put(EventsConfig.VAR_MATERIAL, name);
}
// Batch
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_BATCHNUMBER)) {
varMap.put(EventsConfig.VAR_BATCHNUMBER, invntryBatch.getBatchId());
}
// Quantity
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_QUANTITY)) {
varMap.put(EventsConfig.VAR_QUANTITY, BigUtil.getFormattedValue(invntryBatch.getQuantity()));
}
// Expiry
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_BATCHEXPIRY)) {
varMap.put(EventsConfig.VAR_BATCHEXPIRY, LocalDateUtil.format(invntryBatch.getBatchExpiry(), locale, null, true));
}
// Created / last updated
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_CREATIONTIME)) {
varMap.put(EventsConfig.VAR_CREATIONTIME, LocalDateUtil.format(invntryBatch.getTimestamp(), locale, timezone));
}
Date updTime = (updationTime == null ? invntryBatch.getTimestamp() : updationTime);
if (excludeVars == null || !excludeVars.contains(EventsConfig.VAR_UPDATIONTIME)) {
varMap.put(EventsConfig.VAR_UPDATIONTIME, LocalDateUtil.format(updTime, locale, timezone));
}
} finally {
pm.close();
}
return varMap;
}
示例13: getOrder
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public IOrder getOrder(Long orderId, PersistenceManager persistenceManager) {
return persistenceManager.getObjectById(Order.class, orderId);
}
示例14: getById
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IInvntry getById(String id, PersistenceManager pm) {
return pm.getObjectById(Invntry.class, Long.parseLong(id));
}
示例15: getDBInvntry
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public Invntry getDBInvntry(IInvntry invntry, PersistenceManager pm) {
return pm.getObjectById(Invntry.class, ((Invntry) invntry).getKey());
}