當前位置: 首頁>>代碼示例>>Java>>正文


Java PersistenceManager.deletePersistent方法代碼示例

本文整理匯總了Java中javax.jdo.PersistenceManager.deletePersistent方法的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceManager.deletePersistent方法的具體用法?Java PersistenceManager.deletePersistent怎麽用?Java PersistenceManager.deletePersistent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jdo.PersistenceManager的用法示例。


在下文中一共展示了PersistenceManager.deletePersistent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeFromDomain

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
 * Remove an object from a given domain; if persistence manager is given, then it is removed permanently
 * Returns the list of domains from which this object was removed
 */
public static List<Long> removeFromDomain(IMultiDomain object, Long domainId,
                                          PersistenceManager pm) throws Exception {
  xLogger.fine("Entered removeFromDomain");
  List<Long> domainIds = getMultiDomainIds(object);
  // Remove this object from the given domain
  if (domainIds == null || domainIds.isEmpty()) {
    return null;
  }
  Iterator<Long> it = domainIds.iterator();
  while (it.hasNext()) {
    object.removeDomainId(it.next());
  }
  // Delete the object, if not part of any domain
  if ((object.getDomainIds() == null || object.getDomainIds().isEmpty())
      && pm != null) // i.e. object is part of no domain
  {
    pm.deletePersistent(object);
  }
  xLogger.fine("Exiting removeFromDomain");
  return domainIds;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:26,代碼來源:DomainsUtil.java

示例2: deleteDomain

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
 * Delete given domain {@code domainId} from data store.
 *
 * @param domainId id of domain to be removed.
 */
public static void deleteDomain(Long domainId) throws ServiceException {
  String relatedObjectsStr = ConfigUtil.get(DEL_DOMAIN_PROP);
  Map<String, String[]> relatedClassesMap = PropertyUtil.parseProperty(relatedObjectsStr);
  for (String relatedClassName : relatedClassesMap.keySet()) {
    Map<String, String> params = new HashMap<>();
    params.put("name", "DeleteAllEntities");
    params.put("kind", relatedClassName.substring(relatedClassName.lastIndexOf(".") + 1));
    params.put("domainId", domainId.toString());
    try {
      AppFactory.get().getTaskService()
          .schedule(ITaskService.QUEUE_DEFAULT, "/task/mrstarter", params,
              ITaskService.METHOD_GET);
    } catch (Exception e) {
      xLogger.severe("{0} when scheduling task to remove domain objects {1}: {2}",
          e.getClass().getName(), domainId, e.getMessage(), e);
    }
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IDomain d = JDOUtils.getObjectById(IDomain.class, domainId, pm);
    pm.deletePersistent(d);
  } finally {
    pm.close();
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:31,代碼來源:DomainDeleter.java

示例3: deleteDashboard

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public String deleteDashboard(Long id) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IDashboard db = JDOUtils.getObjectById(IDashboard.class, id, pm);
    String name = db.getName();
    pm.deletePersistent(db);
    return name;
  } catch (Exception e) {
    xLogger.severe("Error in deleting Dashboard:", e);
    throw new ServiceException("Error while deleting Dashboard" + id, e);
  } finally {
    pm.close();
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:16,代碼來源:DashboardService.java

示例4: deleteWidget

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public String deleteWidget(Long id) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IWidget wid = JDOUtils.getObjectById(IWidget.class, id, pm);
    String name = wid.getName();
    pm.deletePersistent(wid);
    return name;
  } catch (Exception e) {
    xLogger.severe("Error in deleting Widget:", e);
    throw new ServiceException("Error while deleting Widget" + id, e);
  } finally {
    pm.close();
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:16,代碼來源:DashboardService.java

示例5: 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();
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:16,代碼來源:MediaEndPoint.java

示例6: deleteAssetRelation

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public void deleteAssetRelation(Long assetId, Long domainId, IAsset asset, PersistenceManager pm) throws ServiceException {
  try {
    Query query = pm.newQuery(JDOUtils.getImplClass(IAssetRelation.class));
    query.setFilter("assetId == assetIdParam");
    query.declareParameters("Long assetIdParam");
    List<IAssetRelation> assetRelations = null;
    try {
      assetRelations = (List<IAssetRelation>) query.execute(assetId);
      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);
      for(IAssetRelation assetRelation: assetRelations){
        EventPublisher.generate(domainId, IEvent.DELETED, null,
            JDOUtils.getImplClassName(IAssetRelation.class), String.valueOf(assetRelation.getId()), null, assetRelation);
      }
      pm.deletePersistent(assetRelationTmp);
    }
  } catch (Exception e) {
    xLogger
        .warn("{0} while deleting asset relationship for the asset {1}", e.getMessage(), assetId,
            e);
    throw new ServiceException(e.getMessage());
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:31,代碼來源:AssetManagementServiceImpl.java

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

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

示例9: removeUploaded

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public void removeUploaded(String id) throws ServiceException {
  if (id == null) {
    throw new ServiceException("Nothing to delete");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    IUploaded objToBeDeleted = JDOUtils.getObjectById(IUploaded.class, id, pm);
    pm.deletePersistent(objToBeDeleted);
  } finally {
    pm.close();
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:13,代碼來源:UploadServiceImpl.java

示例10: deleteDomains

import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
 * Remove a set of domains, given their IDs.
 * NOTE: Given the current data model, to ensure not dangling records in the relationship tables that don't have
 * domainId (e.g. UserToKiosk), we have to ensure that we delete all the kiosks first, and then the domains themselves.
 */
public void deleteDomains(List<Long> domainIds) throws ServiceException {
  xLogger.fine("Entered deleteDomains");
  if (domainIds == null || domainIds.size() == 0) {
    throw new ServiceException("Invalid domain ID list");
  }

  PersistenceManager pm = PMF.get().getPersistenceManager();
  try {
    // Iterate over the domains and delete them
    Iterator<Long> it = domainIds.iterator();
    while (it.hasNext()) {
      Long dId = it.next();
      IDomain d = JDOUtils.getObjectById(IDomain.class, dId);
      // Delete all related entities of the domain
      EntityRemover
          .removeRelatedEntities(dId, JDOUtils.getImplClass(IDomain.class).getName(), dId, true);
      // Remove the domain
      pm.deletePersistent(d);
    }
  } catch (Exception e) {
    throw new ServiceException(e.getMessage());
  } finally {
    // Close PM
    pm.close();
  }

  xLogger.fine("Exiting deleteDomains");
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:34,代碼來源:DomainsServiceImpl.java


注:本文中的javax.jdo.PersistenceManager.deletePersistent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。