@RequestMapping(value = "/authenticate", method = RequestMethod.POST)
 public String authenticate(ModelMap model, HttpServletRequest request) {
   String email = HtmlUtils.htmlEscape(request.getParameter("email"));
   String password = HtmlUtils.htmlEscape(request.getParameter("password"));
   String p = HtmlUtils.htmlEscape(request.getParameter("p"));
   PersistenceManager pm = PMF.get().getPersistenceManager();
   Query q = pm.newQuery(Category.class);
   List<Category> result = null;
   model.addAttribute("subCategoryList", categoryDao.getSubCategoryList());
   try {
     result = (List<Category>) q.execute();
     if (result.isEmpty()) {
       model.addAttribute("listCategory", null);
     } else {
       model.addAttribute("listCategory", result);
     }
     pm = PMF.get().getPersistenceManager();
     Query q1 = null;
     q = pm.newQuery(User.class);
     q.setFilter("email == emailParam && password == passwordParam");
     // q.setOrdering("date desc");
     q.declareParameters("String emailParam,String passwordParam");
     List<User> results = (List<User>) q.execute(email, password);
     // System.out.println(email + " " + password + results.size());
     if (results.size() >= 1) {
       HttpSession hs = request.getSession(true);
       hs.setAttribute("userid", email);
       hs.setAttribute("username", results.get(0).getUserName());
       hs.setAttribute("collegeName", results.get(0).getCollege());
       hs.setAttribute("contactNo", results.get(0).getMobile());
       model.addAttribute("productDao", productDao);
       model.addAttribute("result", "Login Successfully!");
       if (p != null && (!p.equals("null")))
         // return new ModelAndView("redirect:"+p);
         return p;
       else return "index";
     } else {
       model.addAttribute("result", "Incorrect User ID or Password! Try Again");
       model.addAttribute("p", p);
       return "login";
     }
   } catch (Exception e) {
     e.printStackTrace();
     // System.out.println("in exception");
     model.addAttribute("result", "Incorrect Userid or Password! Try Again");
     return "login";
   } finally {
     q.closeAll();
     pm.close();
   }
 }
Exemple #2
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    final PersistenceManager pm = PMF.get().getPersistenceManager();
    final Query q = pm.newQuery(User.class);

    if (req.getParameter("dni") != null) {

      String dni = req.getParameter("dni");
      q.setOrdering("key descending");
      q.setRange(0, 10);

      try {

        @SuppressWarnings("unchecked")
        List<User> usuarios = (List<User>) q.execute(dni);
        req.setAttribute("user", usuarios);
        RequestDispatcher rd =
            getServletContext().getRequestDispatcher("/WEB-INF/jsp/verUsuarios.jsp");
        rd.forward(req, resp);

      } catch (Exception e) {
        System.out.println(e);
      } finally {
        q.closeAll();
        pm.close();
      }

    } else {
      q.setOrdering("key descending");
      q.setRange(0, 10);

      try {
        @SuppressWarnings("unchecked")
        List<User> usuarios = (List<User>) q.execute();
        req.setAttribute("user", usuarios);
        RequestDispatcher rd =
            getServletContext().getRequestDispatcher("/WEB-INF/jsp/verUsuarios.jsp");
        rd.forward(req, resp);
      } catch (Exception e) {
        System.out.println(e);
      } finally {
        q.closeAll();
        pm.close();
      }
    }
  }
  @Override
  public ArrayList<ProductDTO> getProducts() throws NotLoggedInException {
    List<Product> products = new ArrayList<Product>();
    ArrayList<ProductDTO> productsDTO = new ArrayList<ProductDTO>();

    PersistenceManager pm = getPersistenceManager();
    try {
      Query q = pm.newQuery(Product.class);
      products = (List<Product>) q.execute();
      for (Product productItem : products) {

        CategoryDTO categoryDTO = getCategoryForCombo(productItem.getCategoryid());

        ProductDTO productDTO =
            new ProductDTO(
                productItem.getId(),
                productItem.getName(),
                productItem.getPrice(),
                productItem.getDescription(),
                productItem.getDetalle(),
                productItem.getImage(),
                productItem.getImageCarrito(),
                categoryDTO);
        productsDTO.add(productDTO);
      }
    } finally {
      pm.close();
    }
    return productsDTO;
  }
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    Long orderId = Long.parseLong(req.getParameter("orderid"));
    Status status = Status.valueOf(req.getParameter("status"));

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (AdminAuthenticator.isAdmin(user)) {

      PersistenceManager pm = PMF.get().getPersistenceManager();

      String select_query = "select from " + Order.class.getName();
      Query query = pm.newQuery(select_query);
      query.setFilter("id == paramId");
      query.declareParameters("java.lang.Long paramId");
      // execute
      List<Order> orders = (List<Order>) query.execute(orderId);

      if (!orders.isEmpty()) {
        // should be only one - safety check here
        Order order = orders.get(0);
        order.setStatus(status);
        pm.close();
        res.sendRedirect("/home.html");
      }
    }
  }
  /**
   * Demonstrates how to use the cursor to be able to pass over an complete set of data
   *
   * @param pm Persistence manager instance to use - let open at the end to allow possible object
   *     updates later
   * @param cursorString Representation of a cursor, to be used to get the next set of data to
   *     process
   * @param range Number of data to process at this particular stage
   * @param defaultSource Value to apply to any Demand instance without a default value
   * @return New representation of the cursor, ready for a next process call
   */
  @SuppressWarnings("unchecked")
  public static String updateSource(
      PersistenceManager pm, String cursorString, int range, Source defaultSource) {

    Query query = null;
    try {
      query = pm.newQuery(Demand.class);
      if (cursorString != null) {
        Map<String, Object> extensionMap = new HashMap<String, Object>();
        extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, Cursor.fromWebSafeString(cursorString));
        query.setExtensions(extensionMap);
      }
      query.setRange(0, range);
      List<Demand> results = (List<Demand>) query.execute();
      if (results.iterator().hasNext()) {
        for (Demand demand : results) {
          // Initialize the new field if necessary. By checking first that the field is null, we
          // allow this migration to be safely run multiple times.
          if (demand.getSource() == null) {
            demand.setSource(defaultSource);
            pm.makePersistent(demand);
          }
        }
        cursorString = JDOCursorHelper.getCursor(results).toWebSafeString();
      } else {
        // no results
        cursorString = null;
      }
    } finally {
      query.closeAll();
    }
    return cursorString;
  }
  public static Admin getByUserId(String aUserId, long surveyId) {
    PersistenceManager pm = null;
    Admin result = null;
    List<Admin> results = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Query query = null;
      try {
        query = pm.newQuery(Admin.class);
        query.setFilter("userIdLowerCase==userIdLowerCaseParam && surveyId==surveyIdParam");
        query.declareParameters("String userIdLowerCaseParam, Long surveyIdParam");

        results = (List<Admin>) query.execute(aUserId.toLowerCase(), surveyId);

        // Touch object to get data.  Size method triggers the underlying database call.
        results.size();
      } finally {
        if (query != null) {
          query.closeAll();
        }
      }
    } finally {
      if (pm != null) {
        pm.close();
      }
    }

    if (results != null && !results.isEmpty()) {
      result = results.get(0);
    }

    return result;
  }
  public void testMbrTouches() throws SQLException, ParseException {
    if (!runTestsForDatastore()) {
      return;
    }

    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    try {
      tx.begin();
      Point point = (Point) wktReader.read("POINT(75 75)");
      Query query =
          pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrTouches(:point, geom)");
      List list = (List) query.execute(point);
      assertEquals(
          "Wrong number of geometries which are touched by a given point returned", 2, list.size());
      assertTrue(
          "Polygon 1 should be in the list of geometries which are touched by a given point",
          list.contains(getSamplePolygon(1)));
      assertTrue(
          "Polygon 2 should be in the list of geometries which are touched by a given point",
          list.contains(getSamplePolygon(2)));
    } finally {
      tx.commit();
    }
  }
  public void testMbrEqual() throws SQLException, ParseException {
    if (!runTestsForDatastore()) {
      return;
    }

    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    try {
      tx.begin();
      Polygon polygon =
          (Polygon)
              wktReader.read(
                  "POLYGON((25 25,75 25,75 75,25 75,25 25),(45 45,55 45,55 55,45 55,45 45))");
      Query query =
          pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrEqual(geom, :polygon)");
      List list = (List) query.execute(polygon);
      assertEquals(
          "Wrong number of geometries which are equal to a given polygon returned", 1, list.size());
      assertTrue(
          "Polygon 1 should be in the list of geometries which are equal to a given polygon",
          list.contains(getSamplePolygon(1)));
    } finally {
      tx.commit();
    }
  }
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String email = req.getParameter("email");
    String name = req.getParameter("name");
    String pwd = req.getParameter("pwd");
    String repwd = req.getParameter("repwd");
    PersistenceManager p = PMF.get().getPersistenceManager();
    Query q = p.newQuery(Users.class);
    q.setFilter("email == '" + email + "'");
    //	q.setFilter("email == '"+uname+"' && password == '"+passwd+"'");

    List<Users> exists = (List<Users>) q.execute();
    if (exists.isEmpty()) {
      try {
        System.out.println("inside try");

        /*req.getRequestDispatcher("/signup").forward(req, resp);*/
        resp.getWriter().write("sucess");
      } catch (Exception e) {
        System.out.println(e);
      }
    } else {
      System.out.println("inside else");
      System.out.println(email);
      resp.getWriter().write(email);
    }
  }
Exemple #10
0
 private User getUser(String login, String password) {
   PersistenceManager manager = null;
   Transaction transaction = null;
   List<User> users = null;
   try {
     manager = PMF.newInstance().getPersistenceManager();
     transaction = manager.currentTransaction();
     transaction.begin();
     Query query = manager.newQuery(User.class);
     users = (List<User>) query.execute();
     transaction.commit();
   } catch (Exception e) {
     if (transaction != null) {
       transaction.rollback();
     }
   } finally {
     manager.close();
   }
   if (users != null && !users.isEmpty()) {
     for (User u : users) {
       System.out.println(u.getLogin() + " : " + u.getPassword());
       if (login.equals(u.getLogin()) && password.equals(u.getPassword())) {
         System.out.println(u.getLogin() + " : " + u.getPassword());
         return u;
       }
     }
   }
   return null;
 }
Exemple #11
0
 public static List<?> getList(
     Class<?> cls, String ordering, int start, int stop, PersistenceManager pm) {
   Query query = pm.newQuery(cls);
   query.setOrdering(ordering);
   query.setRange(start, stop);
   return (List<?>) query.execute();
 }
Exemple #12
0
  public static List<Reward> execute(Long aSurveyId) {
    PersistenceManager pm = null;
    List<Reward> results = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Query query = null;
      try {
        query = pm.newQuery(Reward.class);
        query.setFilter("surveyId==surveyIdParam");
        query.declareParameters("long surveyIdParam");

        query.setOrdering("used ASC");

        results = (List<Reward>) query.execute(aSurveyId);

        // Touch object to get data.  Size method triggers the underlying database call.
        results.size();
      } finally {
        if (query != null) {
          query.closeAll();
        }
      }
    } finally {
      if (pm != null) {
        pm.close();
      }
    }
    return results;
  }
  /**
   * Gives friend (friendid) permission to given target to user's (uid) data
   *
   * @param pm
   * @param uid
   * @param friendid
   * @param target
   * @return
   */
  @SuppressWarnings("unchecked")
  public static boolean addUserToCircle(
      PersistenceManager pm, String uid, String friendid, int target) {

    if (logger.isLoggable(Level.FINER)) {
      logger.log(
          Level.FINER,
          "Adding user to circle: uid=" + uid + ", friendid=" + friendid + ", target=" + target);
    }

    boolean ok = true;

    // check if permission already found
    Query q = pm.newQuery(Circle.class);
    q.setFilter("openId == openIdParam && friendId == friendIdParam && target == targetParam");
    q.declareParameters(
        "java.lang.String openIdParam, java.lang.String friendIdParam, java.lang.Integer targetParam");
    q.setRange(0, 1);
    List<Circle> list = (List<Circle>) q.execute(uid, friendid, target);

    // if no previous permissions found
    if (list.size() != 0) {
      pm.deletePersistent(list.get(0));
      ok = true;
    }

    // remove users from cache
    // TODO needs improving
    WeekCache cache = new WeekCache();
    cache.removeUsers();

    return ok;
  }
 @RequestMapping(value = "/resetforgotpassword", method = RequestMethod.POST)
 public String resetforgotPassword(HttpServletRequest request, ModelMap model) {
   String email = HtmlUtils.htmlEscape(request.getParameter("email"));
   if (email != null) {
     String userid = email;
     String password = HtmlUtils.htmlEscape(request.getParameter("password"));
     PersistenceManager pm = PMF.get().getPersistenceManager();
     Query q = pm.newQuery(User.class);
     q.setFilter("email==userid");
     q.declareParameters("String userid");
     List<User> result = (List<User>) q.execute(userid);
     try {
       User c = pm.getObjectById(User.class, result.get(0).getUserId());
       c.setPassword(password);
       model.addAttribute("registered", "Password reset successfully, Login now !!");
       model.addAttribute("subCategoryList", categoryDao.getSubCategoryList());
     } finally {
       pm.close();
     }
     return "login";
   } else {
     model.addAttribute("subCategoryList", categoryDao.getSubCategoryList());
     return "login";
   }
 }
  // Gets all opinions held by user with specified id
  @SuppressWarnings("unchecked")
  public static List<Opinion> loadOpinions(Long user_id, PersistenceManager pm) {
    Query query;
    List<Opinion> rv;

    if (user_id == null) {
      query = pm.newQuery(Opinion.class, "user_id == :nv");
      rv = (List<Opinion>) query.execute(null);
    } else {
      query = pm.newQuery(Opinion.class, "user_id == :nv");
      rv = (List<Opinion>) query.execute(user_id);
    }

    query.closeAll();
    return rv;
  }
 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
   HttpSession session = req.getSession();
   PersistenceManager p = PMF.get().getPersistenceManager();
   String date = req.getParameter("Value");
   Query q1 = p.newQuery(Schedule.class);
   q1.setFilter("email == '" + session.getAttribute("emailid") + "' &&date == '" + date + "'");
   q1.setOrdering("listName asc");
   // System.out.println(session.getAttribute("emailid"));
   List<Schedule> schedule = (List<Schedule>) q1.execute();
   /*String json = new Gson().toJson(contents);*/
   ObjectMapper n = new ObjectMapper();
   String json = n.writeValueAsString(schedule);
   System.out.println(json);
   resp.setContentType("application/json");
   resp.setCharacterEncoding("UTF-8");
   resp.getWriter().write(json.toString());
   /*resp.getWriter().write(contents.toString());*/
   /*if (!contents.isEmpty()) {
       for (Content cont : contents) {
   	    String listname = cont.getListname();
   	    String listcontent = cont.getContent();
   	    String listdate = cont.getDate();
   	    resp.getWriter().write(listname);
   	    resp.getWriter().write(listcontent);
       }
   }*/
 }
Exemple #17
0
  /**
   * Get a User {@link Key} for a facebook id
   *
   * @param facebookId
   * @return the user {@link Key} or null
   */
  @SuppressWarnings("unchecked")
  public static Key getUserForFacebookId(String facebookId) {

    // check if APIKey -> TDUser Key found in cache
    if (MemcacheServiceFactory.getMemcacheService().contains(facebookId)) {
      // if so, return from cache
      return (Key) MemcacheServiceFactory.getMemcacheService().get(facebookId);
    } else {
      // query for matching user
      final String queryString = "SELECT key FROM " + TDUser.class.getName();
      final Query q = PMF.get().getPersistenceManager().newQuery(queryString);
      q.setFilter("facebookId == :p");
      q.setRange("0,1");

      final List<Key> keys = (List<Key>) q.execute(facebookId);

      final Key result = (keys.size() > 0 ? keys.get(0) : null);

      if (null != result) {
        // put ApiKey -> TDUser Key map in cache
        MemcacheServiceFactory.getMemcacheService().put(facebookId, result);
      }

      // return the found key
      return result;
    }
  }
  public void testUnencodedLongPk_BatchGet() throws EntityNotFoundException {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    HasLongPkJDO pojo = new HasLongPkJDO();
    beginTxn();
    pojo.setId(1L);
    pm.makePersistent(pojo);
    commitTxn();

    HasLongPkJDO pojo2 = new HasLongPkJDO();
    beginTxn();
    pojo2.setId(2L);
    pm.makePersistent(pojo2);
    commitTxn();

    assertNotNull(pojo.getId());
    assertNotNull(pojo2.getId());

    beginTxn();
    Query q = pm.newQuery("select from " + HasLongPkJDO.class.getName() + " where id == :ids");
    List<HasLongPkJDO> pojos =
        (List<HasLongPkJDO>) q.execute(Utils.newArrayList(pojo.getId(), pojo2.getId()));
    assertEquals(2, pojos.size());
    // we should preserve order but right now we don't
    Set<Long> pks = Utils.newHashSet(pojos.get(0).getId(), pojos.get(1).getId());
    assertEquals(pks, Utils.newHashSet(1L, 2L));
    commitTxn();
  }
Exemple #19
0
  /**
   * Gets {@link Key}s of all the {@link Dish}es at a {@link Restaurant}
   *
   * @param restKey {@link Key} of the {@link Restaurant}
   * @return {@link Collection} of {@link Key} objects
   */
  @SuppressWarnings("unchecked")
  public static Collection<Key> getDishKeysByRestaurant(Key restKey) {
    String query = "SELECT key FROM " + Dish.class.getName();
    Query q = PMF.get().getPersistenceManager().newQuery(query);
    q.setFilter("restaurant == :param");

    return (Collection<Key>) q.execute(restKey);
  }
  @Override
  public List<T> findAll() {
    PersistenceManager pm = getPersistenceManager();

    Query query = pm.newQuery(getPersistentClass());
    List<T> all = (List<T>) query.execute();
    return all;
  }
  private List<FeedbackSession> getFeedbackSessionEntitiesForCourses(List<String> courseIds) {
    Query q = getPM().newQuery(FeedbackSession.class);
    q.setFilter(":p.contains(courseId)");

    @SuppressWarnings("unchecked")
    List<FeedbackSession> feedbackSessionList = (List<FeedbackSession>) q.execute(courseIds);
    return feedbackSessionList;
  }
Exemple #22
0
 @Override
 @Transactional(readOnly = true)
 public Collection<Pin> getPins() {
   PersistenceManager pm = _pmf.getPersistenceManager();
   Query query = pm.newQuery(Pin.class);
   Collection<Pin> pins = (Collection<Pin>) query.execute();
   return pm.detachCopyAll(pins);
 }
 @SuppressWarnings("unchecked")
 public static Opinion loadOpinion(Long user_id, Long restaurant_id, PersistenceManager pm) {
   Query query = pm.newQuery(Opinion.class, "user_id == :uu && restaurant_id == :oo");
   List<Opinion> tmp = (List<Opinion>) query.execute(user_id, restaurant_id);
   Opinion rv = tmp != null && tmp.size() > 0 ? tmp.get(0) : null;
   query.closeAll();
   return rv;
 }
Exemple #24
0
 @Override
 @Transactional(readOnly = true)
 public Collection<Pin> getPins(PnfsId pnfsId) {
   PersistenceManager pm = _pmf.getPersistenceManager();
   Query query = pm.newQuery(Pin.class, "_pnfsId == :pnfsId");
   Collection<Pin> pins = (Collection<Pin>) query.execute(pnfsId.toString());
   return pm.detachCopyAll(pins);
 }
 @SuppressWarnings("unchecked")
 public static boolean opinionExists(Long user_id, Long restaurant_id, PersistenceManager pm) {
   Query query = pm.newQuery(User.class, "user_id == :uu && restaurant_id == :oo");
   List<User> tmp = (List<User>) query.execute(user_id, restaurant_id);
   boolean rv = tmp != null && tmp.size() > 0;
   query.closeAll();
   return rv;
 }
Exemple #26
0
  public static String getUpdatesSince(long sinceId) {
    // First try to pull the response from the cache.
    @SuppressWarnings("unchecked")
    Map<Long, String> cachedQueries = (Map<Long, String>) cache.get(CACHED_QUERIES_KEY);
    Long sinceIdObj = Long.valueOf(sinceId);

    if (cachedQueries == null) {
      cachedQueries = new HashMap<Long, String>();
    } else if (cachedQueries.containsKey(sinceIdObj)) {
      log.info("Found query in the cache: " + sinceId);
      return cachedQueries.get(sinceIdObj);
    }

    // If we haven't cached this response, we must query for it.
    PersistenceManager pm = PMF.get().getPersistenceManager();
    JSONArray resultArray = new JSONArray();

    try {
      Query query = pm.newQuery(TrainUpdate.class);
      query.setOrdering("twitterId ASC");

      if (sinceId >= 0) {
        query.setFilter("twitterId > " + sinceId);
      }

      @SuppressWarnings("unchecked")
      List<TrainUpdate> updates = (List<TrainUpdate>) query.execute();

      for (TrainUpdate update : updates) {
        JSONObject updateJson = update.getJSON();
        resultArray.put(updateJson);
      }

      // Append any updates that are stored in the cache to this result.
      @SuppressWarnings("unchecked")
      List<TrainUpdate> cachedUpdates = (List<TrainUpdate>) cache.get(CACHED_UPDATES_KEY);

      if (cachedUpdates != null) {
        log.info("Fetched cache with size of : " + cachedUpdates.size());

        for (TrainUpdate update : cachedUpdates) {
          if (update.getTwitterId() > sinceId) {
            JSONObject updateJson = update.getJSON();
            resultArray.put(updateJson);
          }
        }
      }
    } finally {
      pm.close();
    }

    // Finally cache the response.
    String result = resultArray.toString();
    cachedQueries.put(sinceIdObj, result);
    cache.put(CACHED_QUERIES_KEY, cachedQueries);

    return result;
  }
Exemple #27
0
  // Retrieve the user from the database if it already exist or
  // create a new account if it is the first loggin
  public static UserProfile findUserProfile(UserProfile user) {

    PersistenceManager pm = PMFactory.getTxnPm();
    Transaction tx = null;
    UserProfile oneResult = null, detached = null;

    String uniqueId = user.getUniqueId();

    Query q = pm.newQuery(UserProfile.class, "uniqueId == :uniqueId");
    q.setUnique(true);

    // perform the query and creation under transactional control,
    // to prevent another process from creating an acct with the same id.
    try {
      for (int i = 0; i < NUM_RETRIES; i++) {
        tx = pm.currentTransaction();
        tx.begin();
        oneResult = (UserProfile) q.execute(uniqueId);
        if (oneResult != null) {
          log.info("User uniqueId already exists: " + uniqueId);
          detached = pm.detachCopy(oneResult);
        } else {
          log.info("UserProfile " + uniqueId + " does not exist, creating...");
          // Create friends from Google+
          // user.setKarma(new Karma());
          pm.makePersistent(user);
          detached = pm.detachCopy(user);
        }
        try {
          tx.commit();
          break;
        } catch (JDOCanRetryException e1) {
          if (i == (NUM_RETRIES - 1)) {
            throw e1;
          }
        }
      } // end for
    } catch (JDOUserException e) {
      log.info("JDOUserException: UserProfile table is empty");
      // Create friends from Google+
      pm.makePersistent(user);
      detached = pm.detachCopy(user);
      try {
        tx.commit();
      } catch (JDOCanRetryException e1) {
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      pm.close();
      q.closeAll();
    }

    return detached;
  }
  private List<FeedbackSession> getNonPrivateFeedbackSessionEntities() {
    Query q = getPM().newQuery(FeedbackSession.class);
    q.declareParameters("Enum private");
    q.setFilter("feedbackSessionType != private");

    @SuppressWarnings("unchecked")
    List<FeedbackSession> fsList = (List<FeedbackSession>) q.execute(FeedbackSessionType.PRIVATE);
    return fsList;
  }
Exemple #29
0
  @Override
  public List<UserTestDTO> getAllUser() {
    pm = PMF.get().getPersistenceManager();
    String jdoSql = "SELECT FROM com.wupeng.blog.vo.UserDTO";
    Query query = pm.newQuery(jdoSql);
    Object result = query.execute();

    return (result == null) ? null : (List<UserTestDTO>) result;
  }
  private List<FeedbackSession> getFeedbackSessionEntitiesForCourse(String courseId) {
    Query q = getPM().newQuery(FeedbackSession.class);
    q.declareParameters("String courseIdParam");
    q.setFilter("courseId == courseIdParam");

    @SuppressWarnings("unchecked")
    List<FeedbackSession> fsList = (List<FeedbackSession>) q.execute(courseId);
    return fsList;
  }