Package com.tubeonfire.entity

Examples of com.tubeonfire.entity.Category


      result = new ArrayList<Category>();
      List<String> cachedCategory = (List<String>) cache
          .get("cachedCategory");
      if (cachedCategory.size() > 0) {
        for (String stringCate : cachedCategory) {
          Category cate = new Category();
          cate.transformString(stringCate);
          result.add(cate);
        }
      }
    }
    return result;
View Full Code Here


      }
      // delete category.
      else if (action.equalsIgnoreCase("delete")) {
        String id = request.getParameter("id");
        if (id != null) {
          Category cate = CategoryModel.getByCateAlias(id);
          if (cate != null) {
            cate.setStatus(4);
            CategoryModel.update(cate);
            CategoryModel.closePM();
            response.getWriter().println("Deleted.");
          } else {
            response.getWriter().println("Category is not exits.");
          }

        } else {
          response.getWriter().println(
              "Invalid category. Please try again.");
        }
      }// edit list clips in category.
      else if (action.equalsIgnoreCase("edit_videos")) {
        response.getWriter().println("Edit video.");
      }
      // add clips to category.
      else if (action.equalsIgnoreCase("add_video")) {
        String tubeId = request.getParameter("tubeId");
        String categoryAlias = request.getParameter("categoryAlias");
        Tube tub = TubeModel.getByTubeId(tubeId);
        Category cate = CategoryModel.getByCateAlias(categoryAlias);
        if (tub != null && cate != null) {
          List<Text> listTubes = new ArrayList<Text>();
          if (cate.getListTubes().size() > 0) {
            listTubes = cate.getListTubes();
          }         
          for (int i = 0; i < listTubes.size(); i++) {
            if (listTubes.get(i).equals(tub.getTubeId())) {
              listTubes.remove(i);
              break;
            }
          }
          listTubes.add(new Text(tub.toString()));
          cate.setListTubes(listTubes);
          CategoryModel.update(cate);
          CategoryModel.closePM();
          System.out.println("Ok, video added to playlist");

        } else {
View Full Code Here

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
      String action = req.getParameter("action");
      if (action.equalsIgnoreCase("create")) {
        Category cate = new Category();
        if (req.getParameter("title") != null) {
          cate.setTitle(new Text(req.getParameter("title")));
        }
        if (req.getParameter("description") != null) {
          cate.setDescription(new Text(req
              .getParameter("description")));
        }
        Map<String, List<BlobKey>> blobs = blobstoreService
            .getUploads(req);
        List<BlobKey> blobKeys = blobs.get("myFile");
        if (blobKeys != null && blobKeys.size() > 0) {
          cate.setThumbImageUrl(new Text(blobKeys.get(0)
              .getKeyString()));
        }
        cate.setCount(0);
        cate.setStatus(1);
        cate.setAlias(StringHelper.getAliasByLanguage(req
            .getParameter("title")));
        CategoryModel.add(cate);
        resp.sendRedirect("/admin/category/manager");

      } else if (action.equalsIgnoreCase("edit")) {
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static Category getByCateAlias(String alias) {
    initPm();
    Category cate = null;
    Query query = pm.newQuery(Category.class);
    query.setFilter("alias=='" + alias + "' && status==1");
    query.setRange(0, 1);
    List<Category> listResult = (List<Category>) query.execute(alias);
    if (listResult.size() > 0) {
View Full Code Here

        System.out.println("Error path.");
        response.sendRedirect("/home");
      }
      cateString = URLDecoder.decode(cateString, "UTF8");
      System.out.println("Cate to search : " + cateString);
      Category cate = CategoryModel.getByCateAlias(cateString);
      if (cate != null) {
        List<Tube> result = new ArrayList<Tube>();
        int startPoint = (page - 1) * itemPerPage;
        if (cate.getListTubes().size() > startPoint) {
          System.out.println("Ok here.");
          for (int i = startPoint; i < cate.getListTubes().size(); i++) {
            if (i == (itemPerPage + startPoint)) {
              break;
            }

            Tube tub = new Tube();
            tub.transformString(cate.getListTubes().get(i)
                .getValue());
            result.add(tub);
          }
        } else {
          page = 1;
          for (int i = 0; i < cate.getListTubes().size(); i++) {
            if (i == itemPerPage) {
              break;
            }
            Tube tub = new Tube();
            tub.transformString(cate.getListTubes().get(i)
                .getValue());
            result.add(tub);
          }
        }

        request.setAttribute("url", request.getRequestURL());
        request.setAttribute("listCategory",
            JavaCacheHandle.getCategory());
        request.setAttribute("listChannel",
            JavaCacheHandle.getChannels());
        request.setAttribute("result", result);
        request.setAttribute("currentPage", page);
        request.setAttribute("totalResult", cate.getListTubes().size());
        request.setAttribute("cate", cateString);
        request.setAttribute("cateString",
            cateString.replaceAll("\\+", " "));
        request.getRequestDispatcher("/category_show.jsp").forward(
            request, response);
View Full Code Here

TOP

Related Classes of com.tubeonfire.entity.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.