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


Java Query.executeWithMap方法代碼示例

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


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

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

示例2: getConversationById

import javax.jdo.Query; //導入方法依賴的package包/類
public IConversation getConversationById(String convId) throws ServiceException {
  IConversation conversation = null;
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Query query = pm.newQuery(JDOUtils.getImplClass(IConversation.class));
    query.setFilter("id == :convIdParam");
    Map<String, String> paramValues = new HashMap<>(1);
    paramValues.put("convIdParam", convId);
    query.setUnique(true);
    conversation = (IConversation) query.executeWithMap(paramValues);
    conversation = pm.detachCopy(conversation);
  } catch (Exception e) {
    xLogger.severe("{0} while creating getting conversation {1}", e.getMessage(), convId, e);
    throw new ServiceException(e);
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
  return conversation;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:23,代碼來源:ConversationServiceImpl.java

示例3: getResults

import javax.jdo.Query; //導入方法依賴的package包/類
private static Object getResults(QueryParams qp, Query q) {
  Object results;
  if (qp.params != null && !qp.params.isEmpty()) {
    results = q.executeWithMap(qp.params);
  } else if (qp.listParams != null && !qp.listParams.isEmpty()) {
    results = q.executeWithArray(qp.listParams.toArray());
  } else {
    results = q.execute();
  }
  return results;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:12,代碼來源:JDOUtils.java

示例4: getBatches

import javax.jdo.Query; //導入方法依賴的package包/類
public Results<IInvntryBatch> getBatches(Long materialId, Long kioskId, PageParams pageParams)
    throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  String
      queryStr =
      "SELECT FROM " + JDOUtils.getImplClass(IInvntryBatch.class).getName()
          + " WHERE mId == mIdParam && kId == kIdParam && q > 0 PARAMETERS Long mIdParam, Long kIdParam ORDER BY bexp ASC";
  Query q = pm.newQuery(queryStr);
  if (pageParams != null) {
    QueryUtil.setPageParams(q, pageParams);
  }
  Map<String, Object> params = new HashMap<>();
  params.put("mIdParam", materialId);
  params.put("kIdParam", kioskId);
  xLogger.fine("Params: {0}", params);
  List<IInvntryBatch> results = null;
  String cursor = null;
  try {
    results = (List<IInvntryBatch>) q.executeWithMap(params);
    xLogger.fine("Results: {0}", results);
    if (results != null) {
      results.size();
      cursor = QueryUtil.getCursor(results);
      results = (List<IInvntryBatch>) pm.detachCopyAll(results);
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  return new Results<>(results, cursor);
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:36,代碼來源:InventoryManagementServiceImpl.java

示例5: getOutOfStockCounts

import javax.jdo.Query; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public int getOutOfStockCounts(Long entityId) {
  int count = 0;
  PersistenceManager pm = null;
  Query query = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Map<String, Object> params = new HashMap<String, Object>(1);
    query =
        pm.newQuery("select key from " + JDOUtils.getImplClass(IInvntry.class).getName()
            + " where kId == kIdParam && stk == 0f PARAMETERS Long kIdParam");
    params.put("kIdParam", entityId);
    List<Long> results = (List<Long>) query.executeWithMap(params);
    if (results != null) {
      count = results.size();
    }
  } catch (Exception e) {
    xLogger.warn("Failed to get out of stock counts for Entity: {0}", entityId, e);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    if (pm != null) {
      pm.close();
    }
  }
  return count;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:34,代碼來源:InventoryManagementServiceImpl.java

示例6: getInvEventLogs

import javax.jdo.Query; //導入方法依賴的package包/類
@Override
public List<IInvntryEvntLog> getInvEventLogs(Long kioskId, Long materialId, Date start, Date end,
                                             PersistenceManager pm) {
  boolean useLocalPm = false;
  if (pm == null) {
    pm = PMF.get().getPersistenceManager();
    useLocalPm = true;
  }
  Query query = null;
  try {
    String queryStr = "SELECT FROM " + JDOUtils.getImplClass(IInvntryEvntLog.class).getName()
        + " WHERE mId == mIdParam && kId == kIdParam && ( ed > sdParam || ed == nullParam ) && sd < edParam"
        + " PARAMETERS String nullParam, Long mIdParam, Long kIdParam, Date sdParam ,Date edParam import java.util.Date;";
    Map<String, Object> params = new HashMap<>(5);
    params.put("mIdParam", materialId);
    params.put("kIdParam", kioskId);
    params.put("sdParam", start);
    params.put("edParam", end != null ? end : new Date());
    params.put("nullParam", null);

    query = pm.newQuery(queryStr);
    query.setResultClass(InvntryEvntLog.class);
    List<IInvntryEvntLog> results = (List<IInvntryEvntLog>) query.executeWithMap(params);
    return (List<IInvntryEvntLog>) pm.detachCopyAll(results);
  } finally {
    if (query != null) {
      query.closeAll();
    }
    if (useLocalPm) {
      pm.close();
    }
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:34,代碼來源:InvntryDao.java

示例7: getApprovers

import javax.jdo.Query; //導入方法依賴的package包/類
/**
 * Get all the approvers for a given kioskId and order type and approver type
 * @param kioskId
 * @param type
 * @param orderType
 * @return
 */
public List<IApprover> getApprovers(Long kioskId, int type, String orderType) {
  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 && otype == orderTypeParam");
      query.declareParameters("Long kioskIdParam, int typeParam, String orderTypeParam");
      params.put("kioskIdParam", kioskId);
      params.put("typeParam", type);
      params.put("orderTypeParam", orderType);
      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,代碼行數:42,代碼來源:EntitiesServiceImpl.java

示例8: getOrderApprovalMapping

import javax.jdo.Query; //導入方法依賴的package包/類
public IOrderApprovalMapping getOrderApprovalMapping(Long orderId) {
  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");
      query.declareParameters("Long orderIdParam");
      query.setOrdering("createdAt desc");
      params.put(ORDER_ID_PARAM, orderId);
      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,代碼行數:37,代碼來源:ApprovalsDao.java

示例9: getMessageById

import javax.jdo.Query; //導入方法依賴的package包/類
public IMessage getMessageById(String messageId) throws ServiceException {

    IMessage message = null;
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      query = pm.newQuery(JDOUtils.getImplClass(IMessage.class));
      query.setFilter("messageId == :messageIdParam");
      Map<String, String> paramValues = new HashMap<>();
      paramValues.put("messageIdParam", messageId);
      query.setUnique(true);
      message = (IMessage) query.executeWithMap(paramValues);
      message = pm.detachCopy(message);
    } catch (Exception e) {
      xLogger.severe("{0} while getting message {1}", e.getMessage(), messageId, e);
      throw new ServiceException(e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn("Exception while closing query", ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
    return message;
  }
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:32,代碼來源:MessageDao.java

示例10: getAllMaterials

import javax.jdo.Query; //導入方法依賴的package包/類
@Override
public Results getAllMaterials(Long domainId, String tag, PageParams pageParams) {
  xLogger.fine("Entering getAllMaterials");
  PersistenceManager pm = PMF.get().getPersistenceManager();
  List<IMaterial> materials = new ArrayList<IMaterial>();
  // Formulate query
  String filters = "dId.contains(domainIdParam)";
  String declaration = "Long domainIdParam";
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("domainIdParam", domainId);
  if (tag != null) {
    filters += " && tgs.contains(tagsParam)";
    declaration += ", Long tagsParam";
    params.put("tagsParam", tagDao.getTagFilter(tag, ITag.MATERIAL_TAG));
  }
  Query query = pm.newQuery(Material.class);
  query.setFilter(filters);
  query.declareParameters(declaration);
  query.setOrdering("uName asc");
  if (pageParams != null) {
    QueryUtil.setPageParams(query, pageParams);
  }
  String cursor = null;
  try {
    materials = (List<IMaterial>) query.executeWithMap(params);
    materials
        .size(); // TODO - fix to avoid "object manager closed" exception; find some other method to do this without retrieving all entities
    cursor = QueryUtil.getCursor(materials);
    materials = (List<IMaterial>) pm.detachCopyAll(materials);
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }

  xLogger.fine("Exiting getAllMaterials");
  return new Results(materials, cursor);
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:42,代碼來源:MaterialDao.java

示例11: getFilteredEntity

import javax.jdo.Query; //導入方法依賴的package包/類
@RequestMapping(value = "/filter", method = RequestMethod.GET)
public
@ResponseBody
Results getFilteredEntity(@RequestParam String text,
                          @RequestParam(required = false, defaultValue = "false") boolean sdOnly,
                          HttpServletRequest request) {
  SecureUserDetails sUser = SecurityUtils.getUserDetails(request);
  Long domainId = SessionMgr.getCurrentDomain(request.getSession(), sUser.getUsername());
  if (text == null) {
    text = "";
  }
  text = text.toLowerCase();
  List<IKiosk> kiosks = new ArrayList<IKiosk>();
  PersistenceManager pm = null;
  try {
    UsersService as =
        Services.getService(UsersServiceImpl.class, sUser.getLocale());
    IUserAccount user = as.getUserAccount(sUser.getUsername());
    EntitiesService entitiesService = Services
        .getService(EntitiesServiceImpl.class, sUser.getLocale());
    if (SecurityUtil.compareRoles(user.getRole(), SecurityConstants.ROLE_DOMAINOWNER) < 0) {
      Results results = entitiesService.getKiosksForUser(user, null, null);
      if(results.getResults() != null) {
        for (Object kiosk : results.getResults()) {
          if (((IKiosk) kiosk).getName().toLowerCase().startsWith(text)) {
            kiosks.add(((IKiosk) kiosk));
          }
        }
      }
    } else {
      pm = PMF.get().getPersistenceManager();
      String filter = "dId.contains(domainIdParam)";
      if (sdOnly) {
        filter = "sdId == domainIdParam";
      }
      String declaration = "Long domainIdParam";
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("domainIdParam", domainId);
      if (!text.isEmpty()) {
        filter += " && nName.startsWith(txtParam)";
        declaration += ", String txtParam";
        params.put("txtParam", text);
      }
      Query query = pm.newQuery(JDOUtils.getImplClass(IKiosk.class));
      query.setFilter(filter);
      query.declareParameters(declaration);
      query.setOrdering("nName asc");
      PageParams pageParams = new PageParams(null, 0, 10);
      QueryUtil.setPageParams(query, pageParams);
      try {
        kiosks = (List<IKiosk>) query.executeWithMap(params);
        kiosks = (List<IKiosk>) pm.detachCopyAll(kiosks);
      } finally {
        query.closeAll();
      }
    }
  } catch (Exception e) {
    xLogger.warn("Exception: {0}", e.getMessage());
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
  return new Results(builder.buildFilterModelList(kiosks), QueryUtil.getCursor(kiosks));
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:66,代碼來源:EntityController.java

示例12: getOrders

import javax.jdo.Query; //導入方法依賴的package包/類
/**
 * Get orders placed by a certain user
 */
@SuppressWarnings("unchecked")
public Results getOrders(String userId, Date fromDate, Date toDate, PageParams pageParams)
    throws ServiceException {
  xLogger.fine("Entered getOrders (by user)");
  if (userId == null || userId.isEmpty() || fromDate == null) {
    throw new IllegalArgumentException("User ID or 'from' date not specified");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  String
      query =
      "SELECT FROM " + JDOUtils.getImplClass(IOrder.class).getName()
          + " WHERE uId == uIdParam && cOn > fromParam";
  Map<String, Object> params = new HashMap<>();
  params.put("uIdParam", userId);
  params.put("fromParam", LocalDateUtil.getOffsetDate(fromDate, -1, Calendar.MILLISECOND));
  if (toDate != null) {
    query += " && cOn < toParam";
    params.put("toParam", toDate);
  }
  query += " PARAMETERS String uIdParam, Date fromParam";
  if (toDate != null) {
    query += ", Date toParam";
  }
  query += " import java.util.Date; ORDER by cOn desc";
  // Form query
  Query q = pm.newQuery(query);
  if (pageParams != null) {
    QueryUtil.setPageParams(q, pageParams);
  }
  // Execute query
  List<IOrder> orders = null;
  String cursor = null;
  try {
    orders = (List<IOrder>) q.executeWithMap(params);
    if (orders != null) {
      orders.size();
      cursor = QueryUtil.getCursor(orders);
      orders = (List<IOrder>) pm.detachCopyAll(orders);
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  xLogger.fine("Exiting getOrders (by user)");
  return new Results(orders, cursor);
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:54,代碼來源:OrderManagementServiceImpl.java

示例13: getDemandItemByStatus

import javax.jdo.Query; //導入方法依賴的package包/類
@Override
public List<IDemandItem> getDemandItemByStatus(Long kioskId, Long materialId,
    Collection<String> status)
    throws ServiceException {
  if (kioskId == null && materialId == null || status == null) {
    throw new ServiceException("One of KioskId and MaterialId along with status are mandatory");
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query q = pm.newQuery(JDOUtils.getImplClass(IDemandItem.class));
  Map<String, Object> paramMap = new HashMap<>(3);
  paramMap.put("ost", status);
  String filter = "ost.contains(st)";
  String declaration = "java.util.Collection ost";
  if (kioskId != null) {
    filter += " && kId == kIdParam";
    paramMap.put("kIdParam", kioskId);
    declaration += ", Long kIdParam";
  }
  if (materialId != null) {
    filter += " && mId == mIdParam";
    paramMap.put("mIdParam", materialId);
    declaration += ", Long mIdParam";
  }

  try {
    q.setFilter(filter);
    q.declareParameters(declaration);
    List<IDemandItem> di = (List<IDemandItem>) q.executeWithMap(paramMap);
    return (List<IDemandItem>) pm.detachCopyAll(di);
  } catch (Exception e) {
    xLogger.warn("Error while getting demand item by status for kioskID {0}, materialId {1}",
        kioskId, materialId, e);
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      //ignored
    }
    pm.close();
  }
  return Collections.emptyList();
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:43,代碼來源:OrderManagementServiceImpl.java

示例14: getSlices

import javax.jdo.Query; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static Results getSlices(String frequency, Date from, Date until, String objectType,
                                String objectId, String dimType, String dimValue,
                                PageParams pageParams) {
  if (from == null || objectType == null || dimType == null || dimValue == null) {
    throw new IllegalArgumentException(
        "At least start date, object type, dim. type and dim. value should be present");
  }
  boolean isFreqDaily = (ReportsConstants.FREQ_DAILY.equals(frequency));
  // Determine the model to be queried, and query filters
  Class<? extends ISlice> clazz = JDOUtils.getImplClass(IMonthSlice.class);
  if (isFreqDaily) {
    clazz = JDOUtils.getImplClass(IDaySlice.class);
  }
  // Get the dates set correctly
  Calendar cal = GregorianCalendar.getInstance();
  cal.setTime(from);
  LocalDateUtil.resetTimeFields(cal);
  Date fromDate = cal.getTime();
  if (until == null) {
    cal.setTime(new Date());
  } else {
    cal.setTime(until);
  }
  LocalDateUtil.resetTimeFields(cal);
  Date untilDate = cal.getTime();
  // Update the filters
  String queryFilters = "oty == otyParam && dt == dtParam && dv == dvParam && d > fromParam";
  String
      declarations =
      " PARAMETERS String otyParam, String dtParam, String dvParam, Date fromParam";
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("otyParam", objectType);
  params.put("dtParam", dimType);
  params.put("dvParam", dimValue);
  params.put("fromParam", LocalDateUtil.getOffsetDate(fromDate, -1, Calendar.MILLISECOND));
  if (untilDate != null) {
    queryFilters += " && d < untilParam";
    declarations += ", Date untilParam";
    params.put("untilParam", untilDate);
  }
  if (objectId != null) {
    queryFilters += " && oId == oIdParam";
    declarations += ", String oIdParam";
    params.put("oIdParam", objectId);
  }
  // Form query
  PersistenceManager pm = PMF.get().getPersistenceManager();
  List<? extends ISlice> results = null;
  String cursor = null;
  // Form query
  String
      queryStr =
      "SELECT FROM " + clazz.getName() + " WHERE " + queryFilters + declarations
          + " import java.util.Date; ORDER BY d DESC";
  // Execute query
  Query q = pm.newQuery(queryStr);
  if (pageParams != null) {
    QueryUtil.setPageParams(q, pageParams);
  }
  try {
    results = (List<? extends ISlice>) q.executeWithMap(params);
    if (results != null) {
      results.size();
      cursor = QueryUtil.getCursor(results);
      results = (List<? extends ISlice>) pm.detachCopyAll(results);
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {

    }
    pm.close();
  }
  return new Results(results, cursor);
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:78,代碼來源:ReportsUtil.java

示例15: getElementSetByUserFilter

import javax.jdo.Query; //導入方法依賴的package包/類
public Set<String> getElementSetByUserFilter(Long domainId, IUserAccount user, String paramName,
                                             String paramValue, PageParams pageParams)
    throws ServiceException {
  xLogger.fine("Entering getElementSetByUserFilter");
  if (domainId == null) {
    throw new ServiceException("Invalid domain ID");
  }

  boolean isSuperUsers = user.getRole().equals("ROLE_su");

  paramName = paramName.trim();
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query
      q =
      pm.newQuery(" SELECT " + paramName + " FROM " + JDOUtils.getImplClass(IUserAccount.class)
          .getName());
  Set<String> elementSet = new HashSet<String>();
  StringBuilder filter = new StringBuilder();
  StringBuilder declaration = new StringBuilder();
  String order = "nName asc";
  filter.append("dId.contains(dIdParam) ");
  declaration.append("Long dIdParam");
  Map<String, Object> params;
  params = new HashMap<>();
  params.put("dIdParam", domainId);
  String paramNameAlias = paramName + "Param";
  paramValue = paramValue.trim();
  String lNameStartsWith = (paramName.equals("v") ? paramValue : paramValue.toLowerCase());
  filter.append(QueryConstants.AND)
      .append(paramName).append(QueryConstants.GR_EQUAL).append(paramNameAlias).append("1")
      .append(QueryConstants.AND).append(paramName).append(QueryConstants.LESS_THAN)
      .append(paramNameAlias).append("2");
  declaration.append(CharacterConstants.COMMA).append("String ").append(paramNameAlias)
      .append("1")
      .append(CharacterConstants.COMMA).append("String ").append(paramNameAlias).append("2");
  params.put(paramNameAlias + "1", lNameStartsWith);
  params.put(paramNameAlias + "2", lNameStartsWith + Constants.UNICODE_REPLACEANY);
  if (!paramName.equals("nName")) {
    order = paramName + " asc, " + order;
  }
  if(!isSuperUsers) {
    filter.append(QueryConstants.AND).append("role != 'ROLE_su'");
  }
  q.setFilter(filter.toString());
  q.declareParameters(declaration.toString());
  q.setOrdering(order);
  if (pageParams != null) {
    QueryUtil.setPageParams(q, pageParams);
  }
  try {
    List elements = (List) q.executeWithMap(params);
    if (elements != null) {
      //elements = (List)pm.detachCopyAll(elements);
      for (Object o : elements) {
        elementSet.add((String) o);
      }
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while trying to close query", ignored);
    }
    pm.close();
  }
  xLogger.fine("Exiting getElementSetByUserFilter");
  return elementSet;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:69,代碼來源:UsersServiceImpl.java


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