本文整理匯總了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());
}