Package com.tubeilike.entity

Examples of com.tubeilike.entity.Tube


      query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
      VideoFeed videoFeed = service.query(query, VideoFeed.class);
      result.setTotalResult(videoFeed.getTotalResults());
      result.setCurrentPage(page);
      for (VideoEntry videoEntry : videoFeed.getEntries()) {
        Tube tub = new Tube();
        tub.transformHalfVideoEntry(videoEntry);
        listTube.add(tub);
      }
    } catch (MalformedURLException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
View Full Code Here


    result.setListTube(listTube);
    return result;
  }

  public static Tube searchById(String id) {
    Tube tub = new Tube();
    try {
      System.out.println("Update from youtube : " + id);
      String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/"
          + id;
      VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl),
          VideoEntry.class);
      tub.transformVideoEntry(videoEntry);
      TubeModel.add(tub);
      System.out.println("Save to database success !");
      return tub;
    } catch (MalformedURLException e) {
      System.out.println("Error when searching with id : + " + id);
View Full Code Here

  }

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

      else if (action.equalsIgnoreCase("add_video")) {
        if (request.getParameter("nextId") == null
            && request.getParameter("prevId") == null) {
          Category cate = CategoryModel.getByCateAlias(request
              .getParameter("categoryAlias"));
          Tube tub = TubeModel.getByTubeId(request
              .getParameter("tubeId"));
          if (tub == null) {
            tub = TubeService.searchById(
                request.getParameter("tubeId"), true);
          }
          if (tub.getCategoryAlias() != null
              && tub.getCategoryAlias().equalsIgnoreCase(
                  cate.getAlias())) {

          } else {
            cate.setCount(cate.getCount() + 1);
          }
          tub.setCategoryAlias(cate.getAlias());
          tub.setCatePosition(1000000);
          TubeModel.update(tub);
          CategoryModel.update(cate);
          TubeModel.closePM();
          CategoryModel.closePM();
        } else if (request.getParameter("prevId") == null) {
          Category cate = CategoryModel.getByCateAlias(request
              .getParameter("categoryAlias"));
          Tube tub = TubeModel.getByTubeId(request
              .getParameter("tubeId"));
          if (tub == null) {
            tub = TubeService.searchById(
                request.getParameter("tubeId"), true);
          }
          if (tub.getCategoryAlias() != null
              && tub.getCategoryAlias().equalsIgnoreCase(
                  cate.getAlias())) {

          } else {
            cate.setCount(cate.getCount() + 1);
          }
          Tube nextTub = TubeModel.getByTubeId(request
              .getParameter("nextId"));
          tub.setCategoryAlias(cate.getAlias());
          tub.setCatePosition(nextTub.getCatePosition() / 2);
          TubeModel.update(tub);
          CategoryModel.update(cate);
          TubeModel.closePM();
          CategoryModel.closePM();
        } else if (request.getParameter("nextId") == null) {
          Category cate = CategoryModel.getByCateAlias(request
              .getParameter("categoryAlias"));
          Tube tub = TubeModel.getByTubeId(request
              .getParameter("tubeId"));
          if (tub == null) {
            tub = TubeService.searchById(
                request.getParameter("tubeId"), true);
          }
          if (tub.getCategoryAlias() != null
              && tub.getCategoryAlias().equalsIgnoreCase(
                  cate.getAlias())) {
          } else {
            cate.setCount(cate.getCount() + 1);
          }
          Tube prevTub = TubeModel.getByTubeId(request
              .getParameter("prevId"));
          tub.setCategoryAlias(cate.getAlias());
          tub.setCatePosition(prevTub.getCatePosition() + 1000000);
          TubeModel.update(tub);
          CategoryModel.update(cate);
          TubeModel.closePM();
          CategoryModel.closePM();
        } else {
          Category cate = CategoryModel.getByCateAlias(request
              .getParameter("categoryAlias"));
          Tube tub = TubeModel.getByTubeId(request
              .getParameter("tubeId"));
          if (tub == null) {
            tub = TubeService.searchById(
                request.getParameter("tubeId"), true);
          }
          if (tub.getCategoryAlias() != null
              && tub.getCategoryAlias().equalsIgnoreCase(
                  cate.getAlias())) {

          } else {
            cate.setCount(cate.getCount() + 1);
          }
          Tube nextTub = TubeModel.getByTubeId(request
              .getParameter("nextId"));
          Tube prevTub = TubeModel.getByTubeId(request
              .getParameter("prevId"));
          tub.setCategoryAlias(cate.getAlias());
          // calculate tub position.
          tub.setCatePosition((nextTub.getCatePosition() + prevTub
              .getCatePosition()) / 2);
          System.out.println(tub.getTitle().getValue()
              + " was added to category : "
              + cate.getTitle().getValue() + " between "
              + prevTub.getTitle().getValue() + " and "
              + nextTub.getTitle().getValue());
          CategoryModel.update(cate);
          TubeModel.update(tub);
          CategoryModel.closePM();
          TubeModel.closePM();
        }
        response.getWriter().println(
            "<div><p style='color:green'>Update success</p></div>");
      }

      // reorder category index
      else if (action.equalsIgnoreCase("re_order_index")) {
        if (request.getParameter("prevAlias") == null
            && request.getParameter("nextAlias") == null) {
          Category current = CategoryModel.getByCateAlias(request
              .getParameter("currentAlias"));
          current.setIndex(1000000);
          CategoryModel.update(current);
          CategoryModel.closePM();
        } else if (request.getParameter("prevAlias") == null) {
          Category current = CategoryModel.getByCateAlias(request
              .getParameter("currentAlias"));
          Category next = CategoryModel.getByCateAlias(request
              .getParameter("nextAlias"));
          current.setIndex(next.getIndex() / 2);
          CategoryModel.update(current);
          CategoryModel.closePM();

        } else if (request.getParameter("nextAlias") == null) {
          Category current = CategoryModel.getByCateAlias(request
              .getParameter("currentAlias"));
          Category pre = CategoryModel.getByCateAlias(request
              .getParameter("prevAlias"));
          current.setIndex(pre.getIndex() + 1000000);
          CategoryModel.update(current);
          CategoryModel.closePM();
        } else {
          Category current = CategoryModel.getByCateAlias(request
              .getParameter("currentAlias"));
          Category pre = CategoryModel.getByCateAlias(request
              .getParameter("prevAlias"));
          Category next = CategoryModel.getByCateAlias(request
              .getParameter("nextAlias"));
          current.setIndex((pre.getIndex() + next.getIndex()) / 2);
          CategoryModel.update(current);
          CategoryModel.closePM();
        }
        response.getWriter().println(
            "<div><p style='color:green'>Update success</p></div>");
      }

      // remove clips from category.
      else if (action.equalsIgnoreCase("remove_video")) {
        Tube tub = TubeModel
            .getByTubeId(request.getParameter("tubeId"));
        Category cate = CategoryModel.getByCateAlias(request
            .getParameter("categoryAlias"));
        if (cate.getCount() > 0) {
          cate.setCount(cate.getCount() - 1);
        }
        CategoryModel.update(cate);
        CategoryModel.closePM();
        tub.setCategoryAlias("");
        TubeModel.update(tub);
        TubeModel.closePM();
        response.getWriter()
            .println(
                "<div><p style='color:green'>Video removed success !</p></div>");
View Full Code Here

    } else if (action.equalsIgnoreCase("addVideo")) {
      if (req.getParameter("categoryAlias") != null
          && req.getParameter("tubeId") != null) {
        Category cate = CategoryModel.getByCateAlias(req
            .getParameter("categoryAlias"));
        Tube detail = TubeModel.getByTubeId(req.getParameter("tubeId"));
        if (detail == null) {
          detail = TubeService.searchById(req.getParameter("tubeId"),
              true);
        }
        if (detail != null && cate != null) {
          cate.setCount(cate.getCount() + 1);
          CategoryModel.update(cate);
          CategoryModel.closePM();
          detail.setCategoryAlias(cate.getAlias());
          TubeModel.add(detail);
        }
      }
    }
    // } else {
View Full Code Here

      // edit video information.
      if (action.equalsIgnoreCase("edit")) {
        if (request.getParameter("id") != null) {
          response.getWriter().print(
              "Edit video + " + request.getParameter("id"));
          Tube tub = TubeModel
              .getByTubeId(request.getParameter("id"));
          if (tub != null) {
            request.setAttribute("detail", tub);
            request.getRequestDispatcher("/video_edit.jsp")
                .forward(request, response);
View Full Code Here

    // User user = userService.getCurrentUser();
    // if (user != null) {
    String action = req.getParameter("action");
    if (action.equalsIgnoreCase("edit")) {
      if (req.getParameter("tubeId") != null) {
        Tube tub = TubeModel.getByTubeId(req.getParameter("tubeId"));
        if (tub != null) {
          if (req.getParameter("title") != null) {
            tub.setTitle(new Text(req.getParameter("title")));
          }
          if (req.getParameter("description") != null) {
            tub.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) {
            tub.setThumbImageUrl(new Text("/image?key=" + blobKeys.get(0)
                .getKeyString()));
          }
          TubeModel.update(tub);
          TubeModel.closePM();
          req.setAttribute("detail", tub);
View Full Code Here

      Matcher matcher = compiledPattern.matcher(uri);
      if (matcher.find()) {
        String id = matcher.group();
        id = id.substring(2, id.length());
        System.out.println(id);
        Tube tub = TubeService.searchById(id, true);
        // request.setAttribute("detail", tub);
        // request.setAttribute("categories", CategoryModel.all());
        // request.setAttribute("url", request.getRequestURL());
        // request.getRequestDispatcher("/tube_detail.jsp").forward(
        // request, response);
        List<Tube> list = new ArrayList<Tube>();
        list.add(tub);
        TubesFeed result = new TubesFeed();
        result.setCurrentPage(1);
        result.setTotalResult(1);
        result.setListTube(list);
        request.setAttribute("url", request.getRequestURL());
        request.setAttribute("result", result);
        request.setAttribute("key", tub.getTitle().getValue());
        request.getRequestDispatcher("/tube_show.jsp").forward(request,
            response);
      } else {

      }
View Full Code Here

            if (i == (itemPerPage + startPoint)) {
              break;
            }
            String id = tag.getListTubeId().get(i).getValue();
            System.out.println(id);
            Tube tub = TubeModel.getByTubeId(id);
            if (tub != null) {
              result.add(tub);
            }
          }
        } else {
          page = 1;
          for (int i = 0; i < tag.getListTubeId().size(); i++) {
            if (i == itemPerPage) {
              break;
            }
            String id = tag.getListTubeId().get(i).getValue();
            Tube tub = TubeModel.getByTubeId(id);
            if (tub != null) {
              result.add(tub);
            }
          }
        }
View Full Code Here

      query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
      VideoFeed videoFeed = service.query(query, VideoFeed.class);
      result.setTotalResult(videoFeed.getTotalResults());
      result.setCurrentPage(page);
      for (VideoEntry videoEntry : videoFeed.getEntries()) {
        Tube tub = new Tube();
        tub.transformHalfVideoEntry(videoEntry);
        listTube.add(tub);
      }
    } catch (MalformedURLException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.tubeilike.entity.Tube

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.