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


Java Query.setFilter方法代码示例

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


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

示例1: checkCustomIdExists

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public boolean checkCustomIdExists(Long domainId, String customId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  // Check if another material by the same custom ID exists in the database
  Query query = pm.newQuery(Material.class);
  query.setFilter("dId.contains(domainIdParam) && cId == cidParam");
  query.declareParameters("Long domainIdParam, String cidParam");
  boolean customIdExists = false;
  try {
    @SuppressWarnings("unchecked")
    List<IMaterial> results = (List<IMaterial>) query.execute(domainId, customId);
    if (results != null && results.size() == 1) {
      // Material with this name already exists in the database!
      customIdExists = true;
    }
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  xLogger.fine("Exiting checkIfCustomIdExists");
  return customIdExists;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:27,代码来源:MaterialDao.java

示例2: updateOrderApprovalStatus

import javax.jdo.Query; //导入方法依赖的package包/类
public void updateOrderApprovalStatus(Long orderId, String approvalId, String status) {
  if (orderId != null && StringUtils.isNotEmpty(approvalId)) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IOrderApprovalMapping.class));
      query.setFilter("orderId == orderIdParam && approvalId == approvalIdParam ");
      query.declareParameters("Long orderIdParam, String approvalIdParam");
      params.put("orderIdParam", orderId);
      params.put(APPROVAL_ID_PARAM, approvalId);
      query.setUnique(true);
      IOrderApprovalMapping orderApprovalMapping = (IOrderApprovalMapping) query
          .executeWithMap(params);
      if (orderApprovalMapping != null) {
        orderApprovalMapping.setStatus(status);
        orderApprovalMapping.setUpdatedAt(new Date());
        pm.makePersistent(orderApprovalMapping);
      }
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0} with approval: {1}",
          orderId, approvalId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn(ignored.getMessage(), ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:38,代码来源:ApprovalsDao.java

示例3: findId

import javax.jdo.Query; //导入方法依赖的package包/类
public IInvntry findId(Long kioskId, Long materialId, PersistenceManager pm) {
  Query q = pm.newQuery(Invntry.class);
  try {
    q.setFilter("kId == " + kioskId.toString() + " && mId == " + materialId.toString());
    Object results = q.execute();
    if (results instanceof IInvntry) {
      results = pm.detachCopy(results);
      return (Invntry) results;
    } else if (results instanceof List) {
      if (!((List) results).isEmpty()) {
        Invntry result = ((List<Invntry>) results).get(0);
        result = pm.detachCopy(result);
        return result;
      }
    }
    return null;
  } finally {
    if (q != null) {
      q.closeAll();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:InvntryDao.java

示例4: getShortId

import javax.jdo.Query; //导入方法依赖的package包/类
public Long getShortId(Long kioskId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query q = null;
  try {
    q = pm.newQuery(JDOUtils.getImplClass(IInvntry.class));
    q.setResult("max(sId)");
    q.setFilter("kId == " + kioskId);
    Long count = (Long) q.execute();
    return count == null ? -1 : count;
  } catch (Exception e) {
    xLogger.warn("Error while getting short id for kiosk {0}", kioskId, e);
    return null;
  } finally {
    if (q != null) {
      try {
        q.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    if (pm != null) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:26,代码来源:InventoryManagementServiceImpl.java

示例5: getInvntryEvntLog

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<IInvntryEvntLog> getInvntryEvntLog(Long invId, int size, int offset) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  List<IInvntryEvntLog> results;
  try {
    Query q = pm.newQuery(InvntryEvntLog.class);
    q.setFilter("invId == invIdParam");
    Map<String, Object> params = new HashMap<>();
    params.put("invIdParam", invId);
    q.declareParameters("Long invIdParam");
    q.setOrdering("sd desc");
    q.setRange(offset, offset + size);
    results = (List<IInvntryEvntLog>) q.executeWithMap(params);
    results = (List<IInvntryEvntLog>) pm.detachCopyAll(results);
  } finally {
    pm.close();
  }
  return results;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:20,代码来源:InvntryDao.java

示例6: findShortId

import javax.jdo.Query; //导入方法依赖的package包/类
public IInvntry findShortId(Long kioskId, Long shortId, PersistenceManager pm) {
  Query q = pm.newQuery(Invntry.class);
  try {
    q.setFilter("kId == " + kioskId.toString() + " && sId == " + shortId.toString());
    Object results = q.execute();
    if (results instanceof IInvntry) {
      results = pm.detachCopy(results);
      return (Invntry) results;
    } else if (results instanceof List) {
      if (!((List) results).isEmpty()) {
        Invntry result = ((List<Invntry>) results).get(0);
        result = pm.detachCopy(result);
        return result;
      }
    }
    return null;
  } finally {
    if (q != null) {
      q.closeAll();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:InvntryDao.java

示例7: checkIfCustomIdExists

import javax.jdo.Query; //导入方法依赖的package包/类
private boolean checkIfCustomIdExists(IUserAccount userAccount) {
  xLogger.fine("Entering checkIfCustomIdExists");
  boolean customIdExists = false;
  xLogger.fine("object is an instance of UserAccount");
  Long domainId = userAccount.getDomainId();
  PersistenceManager pm = PMF.get().getPersistenceManager();
  // Check if another user by the same custom ID exists in the database
  Query query = pm.newQuery(JDOUtils.getImplClass(IUserAccount.class));
  query.setFilter("dId.contains(domainIdParam) && cId == cidParam");
  query.declareParameters("Long domainIdParam, String cidParam");
  try {
    @SuppressWarnings("unchecked")
    List<IUserAccount>
        results =
        (List<IUserAccount>) query.execute(domainId, userAccount.getCustomId());
    if (results != null && results.size() == 1) {
      // UserAccount with this custom id already exists in the database!
      xLogger.warn(
          "Error while adding or updating user Account {0}: Custom ID {1} already exists.",
          userAccount.getUserId(), userAccount.getCustomId());
      customIdExists = true;
    }
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  return customIdExists;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:33,代码来源:UsersServiceImpl.java

示例8: getKioskByName

import javax.jdo.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public IKiosk getKioskByName(Long domainId, String kioskName) throws ServiceException {
  xLogger.fine("Entering getKiosk");
  if (domainId == null || kioskName == null || kioskName.isEmpty()) {
    throw new ServiceException("Invalid parameters");
  }
  IKiosk k = null;
  // Form query
  PersistenceManager pm = PMF.get().getPersistenceManager();
  // Update the UserAccount to set the route enabled flag
  try {
    // Form the query
    Query kioskQuery = pm.newQuery(JDOUtils.getImplClass(IKiosk.class));
    kioskQuery.setFilter("dId.contains(dIdParam) && nName == nameParam");
    kioskQuery.declareParameters("Long dIdParam, String nameParam");
    // Execute the query
    try {
      List<IKiosk> results = (List<IKiosk>) kioskQuery.execute(domainId, kioskName.toLowerCase());
      if (results != null && !results.isEmpty()) {
        k = results.get(0);
        k = pm.detachCopy(k);
      }
    } finally {
      kioskQuery.closeAll();
    }
  } catch (Exception e) {
    xLogger.severe("{0} when trying to get Kiosk for kiosk Name {1}. Message: {2}",
        e.getClass().getName(), kioskName, e.getMessage());
  } finally {
    pm.close();
  }
  xLogger.fine("Exiting getKiosk");
  return k;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:EntitiesServiceImpl.java

示例9: getOrderApprovalMapping

import javax.jdo.Query; //导入方法依赖的package包/类
public IOrderApprovalMapping getOrderApprovalMapping(Long orderId, Integer approvalType) {
  IOrderApprovalMapping orderApprovalMapping = null;
  List<IOrderApprovalMapping> results = null;
  if (orderId != null) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IOrderApprovalMapping.class));
      query.setFilter("orderId == orderIdParam && approvalType == approvalTypeParam");
      query.declareParameters("Long orderIdParam, Integer approvalTypeParam");
      query.setOrdering("createdAt desc");
      query.setRange(0, 1);
      params.put(ORDER_ID_PARAM, orderId);
      params.put(APPROVAL_TYPE_PARAM, approvalType);
      results = (List<IOrderApprovalMapping>) query.executeWithMap(params);
      if (results != null && !results.isEmpty()) {
        orderApprovalMapping = results.get(0);
      }
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0}",
          orderId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn("Exception while closing query", ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
  return orderApprovalMapping;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:39,代码来源:ApprovalsDao.java

示例10: getTagByName

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public ITag getTagByName(String name, int type) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = pm.newQuery(Tag.class);
  query.setFilter("name == nameParam && type == typeParam");
  query.declareParameters("String nameParam,Integer typeParam");
  ITag result = null;
  try {
    List<ITag> results = (List<ITag>) query.execute(name, type);
    if (results != null && results.size() > 0) {
      result = results.get(0);
      result = pm.detachCopy(result);
    } else {
      ITag tag = new Tag(type, name);
      tag = pm.makePersistent(tag);
      return pm.detachCopy(tag);
    }
  } catch (Exception e) {
    xLogger.warn("Error while fetching tag with name {0} and type {1}", name, type, e);
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  return result;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:30,代码来源:TagDao.java

示例11: isAnApprover

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Checks whether a given user is an approver for purchase/sales/transfer orders in a given domain
 * @param userId
 * @param domainId
 * @return
 */
public boolean isAnApprover(String userId, Long domainId) {
  if(StringUtils.isNotEmpty(userId) && domainId != null) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IApprover.class));
      query.setFilter("uid == userIdParam && sdid == domainIdParam");
      query.declareParameters("String userIdParam, Long domainIdParam");
      params.put("userIdParam", userId);
      params.put("domainIdParam", domainId);
      IApprover approvers = (IApprover) query.executeWithMap(params);
      if(approvers != null) {
        return true;
      }
    } catch (Exception e) {
      xLogger.fine("Failed to get approvals for user: {0} in domain : {1}", userId, domainId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn("Exception while closing query", ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }

  return true;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:41,代码来源:EntitiesServiceImpl.java

示例12: getSuperusers

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Get all the super users (across domains)
 */
@SuppressWarnings("unchecked")
public List<IUserAccount> getSuperusers() throws ServiceException {
  xLogger.fine("Entering getSuperusers");
  List<IUserAccount> superUsers = null;
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query q = pm.newQuery(JDOUtils.getImplClass(IUserAccount.class));
  String roleParam = SecurityConstants.ROLE_SUPERUSER;
  String declaration = " String roleParam";
  q.setFilter("role == roleParam");
  q.declareParameters(declaration);
  try {
    superUsers = (List<IUserAccount>) q.execute(roleParam);
    if (superUsers != null) {
      superUsers.size(); // This is done so that pm can be closed without throwing an exception.
      superUsers = (List<IUserAccount>) pm.detachCopyAll(superUsers);
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  xLogger.fine("Exiting getSuperusers");
  return superUsers;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:31,代码来源:UsersServiceImpl.java

示例13: getApprovers

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Get all the approvers for a given kioskId and approver type
 * @param kioskId
 * @return
 */
public List<IApprover> getApprovers(Long kioskId, int type) {
  List<IApprover> appList = null;
  if(kioskId != null) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IApprover.class));
      query.setFilter("kid == kioskIdParam && type == typeParam");
      query.declareParameters("Long kioskIdParam, int typeParam");
      params.put("kioskIdParam", kioskId);
      params.put("typeParam", type);
      List<IApprover> approversList = (List<IApprover>) query.executeWithMap(params);
      appList = (List<IApprover>) pm.detachCopyAll(approversList);
    } catch (Exception e) {
      xLogger.warn("Failed to get approvers for Entity: {0}", kioskId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn("Exception while closing query", ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
  return appList;

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:39,代码来源:EntitiesServiceImpl.java

示例14: deleteAssetRelation

import javax.jdo.Query; //导入方法依赖的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

示例15: setManagedEntityRouteInfo

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Set ManagedEntitiesRouteInfo
 */
@SuppressWarnings("unchecked")
public void setManagedEntityRouteInfo(Long domainId, String userId, Long kioskId, String routeTag,
                                      Integer routeIndex) throws ServiceException {
  // Get the UserToKiosk object for the userId and kioskId
  // Set the routeTag to routeTag
  // Do not set the routeIndex because it is already set to Default Route Index
  xLogger.fine("Entering setManagedEntityRouteInfo");

  if (domainId == null || userId == null || userId.isEmpty() || kioskId == null) {
    xLogger.warn("Invalid parameters. domainId: {0}, userId: {1}, kioskId: {2}", domainId, userId,
        kioskId);
    throw new ServiceException("Invalid parameters");
  }

  PersistenceManager pm = PMF.get().getPersistenceManager();
  // Update the UserAccount to set the route enabled flag
  try {
    // Form the query
    Query userToKioskQuery = pm.newQuery(JDOUtils.getImplClass(IUserToKiosk.class));
    userToKioskQuery.setFilter("kioskId == kioskIdParam");
    userToKioskQuery.declareParameters("Long kioskIdParam");
    // Execute the query
    try {
      List<IUserToKiosk> results = (List<IUserToKiosk>) userToKioskQuery.execute(kioskId);
      if (results != null && !results.isEmpty()) {
        // Iterate through the results
        // Check if userId of the UserToKiosk object matches with the userId that is passed
        // If it matches, then set the routeTag and routeIndex for that UserToKiosk object
        for (IUserToKiosk u2k : results) {
          if (u2k.getUserId().equals(userId)) {
            u2k.setTag(routeTag);
            if (routeIndex != null) {
              u2k.setRouteIndex(routeIndex);
            }
            break;
          }
        }
      }
    } finally {
      userToKioskQuery.closeAll();
    }
  } catch (Exception e) {
    xLogger.severe(
        "{0} when trying to set the route info for managed entities for user {1}. Message: {2}",
        e.getClass().getName(), userId, e.getMessage());
  } finally {
    pm.close();
  }

  xLogger.fine("Exiting updateManagedEntityRouteInfo");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:55,代码来源:EntitiesServiceImpl.java


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