本文整理汇总了Java中javax.jdo.PersistenceManager.makePersistent方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceManager.makePersistent方法的具体用法?Java PersistenceManager.makePersistent怎么用?Java PersistenceManager.makePersistent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jdo.PersistenceManager
的用法示例。
在下文中一共展示了PersistenceManager.makePersistent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: updateDashboard
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public String updateDashboard(Long id, String ty, String val) throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IDashboard db = JDOUtils.getObjectById(IDashboard.class, id, pm);
String name = db.getName();
if ("nm".equals(ty)) {
db.setName(val);
} else if ("desc".equals(ty)) {
db.setDesc(val);
} else if ("conf".equals(ty)) {
db.setConf(val);
}
pm.makePersistent(db);
return name;
} catch (Exception e) {
xLogger.severe("Error in updating dashboard {0}", id, e);
throw new ServiceException("Error in updating dashboard " + id, e);
} finally {
pm.close();
}
}
示例3: persistAccount
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public void persistAccount(IAccount account) throws ServiceException {
xLogger.fine("Entered persistAccount");
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Update account parameters
account.setTimestamp(new Date());
// Get kiosk accounts service
EntitiesService as = Services.getService(EntitiesServiceImpl.class);
IKiosk k = as.getKiosk(account.getCustomerId(), false);
account.setCustomerName(k.getName());
k = as.getKiosk(account.getVendorId(), false);
account.setVendorName(k.getName());
// Persist
pm.makePersistent(account);
} finally {
pm.close();
}
xLogger.fine("Exiting persistAccount");
}
示例4: 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();
}
}
示例5: store
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void store(List<IEvent> events) {
xLogger.fine("Entered log(events)");
if (events == null || events.isEmpty()) {
throw new IllegalArgumentException("Invalid events input");
}
Iterator<IEvent> it = events.iterator();
PersistenceManager pm = null;
try {
pm = PMF.get().getPersistenceManager();
while (it.hasNext()) {
pm.makePersistent(it.next());
}
} catch (Exception e) {
xLogger.warn("Failed to persist events {}", events);
throw new RuntimeException(e);
} finally {
if (pm != null) {
pm.close();
}
}
xLogger.fine("Exiting log(events)");
}
示例6: storeDownloaded
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void storeDownloaded(IDownloaded downloaded) throws ServiceException {
String errMsg = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
if (downloaded == null) {
throw new ServiceException("Nothing has been downloaded");
}
// Write the Downloaded object to the datastore.
try {
pm.makePersistent(downloaded);
} catch (Exception e) {
errMsg = e.getMessage();
} finally {
pm.close();
}
if (errMsg != null) {
throw new ServiceException(errMsg);
}
}
示例7: createTask
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public ITask createTask(String queue, String url, long scheduledTime, long domainId,
String userName, String taskName) {
PersistenceManager pmf = PMF.get().getPersistenceManager();
ITask taskEntity;
try {
taskEntity = new Task();
taskEntity.setCreatedBy(userName);
taskEntity.setQueue(queue);
if (taskName != null) {
taskEntity.setName(taskName);
} else {
taskEntity.setName(url);
}
taskEntity.setdId(domainId);
if (scheduledTime > 0) {
taskEntity.setScheduleTime(new Date(scheduledTime));
}
taskEntity = pmf.makePersistent(taskEntity);
} finally {
pmf.close();
}
return taskEntity;
}
示例8: addToDomain
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
* Add the given object to all parent domains of customer and vendor
*/
public static Object addToDomain(IMultiDomain object, Long domainId, PersistenceManager pm,
boolean setSourceDomain)
throws ServiceException {
xLogger.fine("Entered addToDomain: domainId: {0}", domainId);
if (setSourceDomain) {
// Set the given domain as the source domain
object.setDomainId(domainId);
}
// Add this object to all domains it should be included in, as required
object.addDomainIds(getMultiDomainIds(object));
// Persist
if (pm != null) {
object = pm.makePersistent(object);
}
xLogger.fine("Exiting addToDomain");
return object;
}
示例9: addEditMessage
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IMessage addEditMessage(IMessage message, boolean isCreate) throws ServiceException {
PersistenceManager pm = null;
try {
pm = PMF.get().getPersistenceManager();
pm.makePersistent(message);
message = pm.detachCopy(message);
} catch (Exception e) {
xLogger.severe("{0} while creating message {1}", e.getMessage(), message, e);
throw new ServiceException(e);
} finally {
if (pm != null) {
pm.close();
}
}
return message;
}
示例10: create
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private void create(Object o) throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(o);
} catch (Exception e) {
throw new ServiceException("");
} finally {
pm.close();
}
}
示例11: update
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public OrderUpdateStatus update(IOrder order, PersistenceManager pm) throws LogiException {
// Get the order with specified ID
IOrder o = getOrder(order.getOrderId(), pm);
// Check if status has changed
String oldStatus = o.getStatus();
String newStatus = order.getStatus();
boolean statusChanged = !newStatus.equals(oldStatus);
// Set new status
if (statusChanged) {
order
.commitStatus(); // NOTE: This method takes care of propagating status, setting order processing times, and/or updating accounts if accounting is enabled
}
order.setUpdatedOn(new Date());
order.setTotalPrice(order.computeTotalPrice()); // recompute price
// Update paid field
BigDecimal paidDiff = order.getPaid().subtract(o.getPaid());
boolean paymentChanged = BigUtil.notEqualsZero(paidDiff);
if (paymentChanged) {
order.commitPayment(
paidDiff); // NOTE: This method will update accounts, if accounting is enabled
}
o.setExpectedArrivalDate(order.getExpectedArrivalDate());
o.setDueDate(order.getDueDate());
o.setTags(order.getTags(TagUtil.TYPE_ORDER), TagUtil.TYPE_ORDER);
o.setNumberOfItems(order.getItems().size());
pm.makePersistent(order);
return new OrderUpdateStatus(order, oldStatus, paymentChanged, statusChanged);
}
示例12: setOrderVisibilityUponApproval
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
private void setOrderVisibilityUponApproval(Long orderId)
throws ObjectNotFoundException, ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
IOrder o;
try {
o = JDOUtils.getObjectById(IOrder.class, orderId, pm);
OrderVisibilityUtils.setOrderVisibility(o, o.getDomainId(), true);
pm.makePersistent(o);
} catch (JDOObjectNotFoundException e) {
throw new ObjectNotFoundException(e.getMessage());
} finally {
pm.close();
}
}
示例13: getTagById
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@Override
public ITag getTagById(long id, int type) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(Tag.class);
query.setFilter("id == idParam && type == typeParam");
query.declareParameters("Long idParam,Integer typeParam");
ITag result = null;
try {
List<ITag> results = (List<ITag>) query.execute(id, type);
if (results != null && results.size() > 0) {
result = results.get(0);
result = pm.detachCopy(result);
} else {
ITag tag = new Tag(type, id);
tag = pm.makePersistent(tag);
return pm.detachCopy(tag);
}
} catch (Exception e) {
xLogger.warn("Error while fetching tag with name {0} and type {1}", id, type, e);
} finally {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
return result;
}
示例14: 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();
}
}
示例15: setJobFailed
import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public static void setJobFailed(Long jobId, String msg) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IJobStatus job = JDOUtils.getObjectById(IJobStatus.class, jobId, pm);
job.setStatus(IJobStatus.FAILED);
job.setReason(msg);
pm.makePersistent(job);
} catch (Exception e) {
xLogger.severe("{0} while setting job status to failed. Message: {1}", e.getClass().getName(),
e.getMessage(), e);
} finally {
pm.close();
}
}