Package com.tubeonfire.entity

Examples of com.tubeonfire.entity.Mission


              }
            }
            listToAdd.add(tube);
          }
          TubeModel.insert(listToAdd);
          Mission mission = new Mission();
          mission.setId(IdUniqueHelper.getId());
          mission.setSearchHd(1);
          mission.setSearchType(1);
          mission.setSearchKeyword(channelId);
          mission.setPlaylistId(playlistId);
          mission.setSearchLimit(limit);
          if (tubeService.getListResult().size() > 0
              && !tubeService.isTooManyRecentCallError()) {
            mission.setSearchPage(tubeService.getPage() + 1);
          } else {
            mission.setSearchPage(tubeService.getPage());
          }
          mission.setSearchTotalPage(tubeService.getTotalPage());
          mission.setType(2);
          mission.setTitle("Get all videos from channel " + channelId);
          if (tubeService.getPage() == tubeService.getTotalPage()
              && !tubeService.isTooManyRecentCallError()) {
            mission.setStatus(2);
          }
          MissionModel.insert(mission);
          if (subcribe != null && subcribe.equals("true")) {
            mission = new Mission();
            mission.setId(IdUniqueHelper.getId());
            mission.setType(1);
            mission.setPlaylistId(playlistId);
            mission.setSearchKeyword(channelId);
            mission.setTitle("Subcribe from channel " + channelId);
            MissionModel.insert(mission);
          }
        } catch (Exception e) {
          log.warning(e.toString());
          e.printStackTrace();
View Full Code Here


  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    try {
      HttpSession session = req.getSession();
      Mission obj = new Mission();
      session.setAttribute("obj", obj);
      req.getRequestDispatcher("/admin/form_mission.jsp").forward(req,
          resp);
    } catch (Exception e) {
      log.warning(e.toString());
View Full Code Here

    try {
      HttpSession session = req.getSession();
      String type = (String) req.getParameter("type");
      String channelId = (String) req.getParameter("channelId");
      String playlistId = (String) req.getParameter("playlistId");
      Mission mission = new Mission();
      Playlist pl = PlaylistModel.byId(playlistId, false);
      if (pl != null) {
        if (YoutubeService.checkChannel(channelId)) {
          if (type.equals("2")) {
            YoutubeService tubeService = new YoutubeService();
            tubeService.setPage(1);
            tubeService.setLimit(49);
            List<Tube> listToAdd = new ArrayList<Tube>();
            tubeService.searchByChannel(channelId, true);
            for (Tube tube : tubeService.getListResult()) {
              tube.setPlaylistId(playlistId);
              listToAdd.add(tube);
            }
            TubeModel.insert(listToAdd);
            mission.setId(IdUniqueHelper.getId());
            mission.setSearchHd(1);
            mission.setSearchType(1);
            mission.setSearchKeyword(channelId);
            mission.setPlaylistId(playlistId);
            mission.setSearchLimit(tubeService.getLimit());
            if (tubeService.getListResult().size() > 0
                && !tubeService.isTooManyRecentCallError()) {
              mission.setSearchPage(tubeService.getPage() + 1);
            } else {
              mission.setSearchPage(tubeService.getPage());
            }
            mission.setSearchTotalPage(tubeService.getTotalPage());
            mission.setType(2);
            mission.setTitle("Get videos from channel " + channelId
                + " to playlist " + pl.getTitle());
            MissionModel.insert(mission);
            session.setAttribute("success", "Action success !");
            resp.sendRedirect("/admin/mission/add");
          } else if (type.equals("1")) {
            mission.setId(IdUniqueHelper.getId());
            mission.setType(1);
            mission.setPlaylistId(playlistId);
            mission.setSearchKeyword(channelId);
            mission.setTitle("Subcribe from channel " + channelId);
            MissionModel.insert(mission);
            session.setAttribute("success", "Action success !");
            resp.sendRedirect("/admin/mission/add");
          }
        } else {
View Full Code Here

      throws IOException, ServletException {
    try {
      String action = (String) req.getParameter("action");
      if (action != null && action.length() > 0) {
        if (action.equals("transport")) {
          Mission mission = MissionModel.getNotCompleteByType(2);
          if (mission != null) {
            YoutubeService tubeService = new YoutubeService();
            tubeService.setPage(mission.getSearchPage());
            tubeService.setLimit(mission.getSearchLimit());
            List<Tube> listToAdd = new ArrayList<Tube>();
            tubeService.searchByChannel(mission.getSearchKeyword(),
                true);
            Queue queue = QueueFactory.getDefaultQueue();         
            for (Tube tube : tubeService.getListResult()) {
              tube = processTubeDetail(mission.getPlaylistId(),
                  tube);
              // add author to site.             
              queue.add(TaskOptions.Builder.withUrl(
                  "/task-admin?action=add-author&uri="
                      + tube.getAuthorUrl()).method(
                  TaskOptions.Method.GET));
              listToAdd.add(tube);
            }
            TubeModel.insert(listToAdd);
            if (tubeService.getListResult().size() > 0
                && !tubeService.isTooManyRecentCallError()) {
              mission.setSearchPage(tubeService.getPage() + 1);
            } else {
              mission.setSearchPage(tubeService.getPage());
            }
            if (tubeService.getPage() == tubeService.getTotalPage()
                && !tubeService.isTooManyRecentCallError()) {
              mission.setStatus(2);
            }
            MissionModel.insert(mission);
          }
        } else if (action.equals("follow")) {
          MissionModel model = new MissionModel();
          model.getListNotCompleteByType(1);
          List<Mission> listMission = model.getListResult();
          if (listMission != null && listMission.size() > 0) {
            YoutubeActiveService activeService = new YoutubeActiveService();
            for (Mission mission : listMission) {
              List<String> tubeIds = mission.getTubeIds();
              if (tubeIds.size() == 0) {
                activeService.getActiveByChannel(mission
                    .getSearchKeyword());
                List<UserEventEntry> listResult = activeService
                    .getListResult();
                if (listResult != null && listResult.size() > 0) {
                  tubeIds = new ArrayList<String>();
                  for (UserEventEntry entry : listResult) {
                    tubeIds.add(entry.getVideoId());
                  }
                }
                mission.setTubeIds(tubeIds);
                mission.setUpdated(Calendar.getInstance()
                    .getTime());
                MissionModel.insert(mission);
              }
            }
          }
        } else if (action.equals("getFollow")) {
          MissionModel model = new MissionModel();
          model.getListNotCompleteByType(1);
          List<Mission> listMission = model.getListResult();
          if (listMission != null && listMission.size() > 0) {
            for (Mission mission : listMission) {
              if (mission != null && mission.getId().length() > 0) {
                List<String> tubeIds = new ArrayList<String>();
                for (String string : mission.getTubeIds()) {
                  tubeIds.add(string);
                }
                List<String> listToAdd = new ArrayList<String>();
                if (mission.getTubeIds().size() > 0) {
                  for (String tubeId : mission.getTubeIds()) {
                    if (TubeSearchModel.getById(tubeId) == null) {
                      if (listToAdd.size() != 50) {
                        listToAdd.add(tubeId);
                        tubeIds.remove(tubeId);
                      } else {
                        break;
                      }
                    }
                  }
                }
                YoutubeBatchService.searchByListId(listToAdd,
                    true);
                List<Tube> listTube = YoutubeBatchService
                    .getListResult();
                Queue queue = QueueFactory.getDefaultQueue()
                for (Tube tube : listTube) {
                  tube = processTubeDetail(
                      mission.getPlaylistId(), tube);
                  // add author to site.             
                  queue.add(TaskOptions.Builder.withUrl(
                      "/task-admin?action=add-author&uri="
                          + tube.getAuthorUrl()).method(
                      TaskOptions.Method.GET));
                }
                TubeModel.insert(listTube);
                mission.setTubeIds(tubeIds);
                mission.setUpdated(Calendar.getInstance()
                    .getTime());
                MissionModel.insert(mission);
              }
            }
          } else {
View Full Code Here

      throws IOException {
    String action = request.getParameter("action");
    if (action != null && action.equals("delete")) {
      try {
        String id = request.getParameter("id");
        Mission obj = MissionModel.getById(id);
        if (obj != null) {
          MissionModel.delete(obj);
          response.getWriter().print("");
        } else {
          response.getWriter().print(
              "Action fails ! Mission's not exits or has been deleted !");
        }
      } catch (Exception e) {
        response.getWriter().print("Action fails ! Please try again !");
      }

    } else if (action != null && action.equals("delete-all")) {
      try {
        String strIds = (String) request.getParameter("ids");
        String[] ids = strIds.split(",");
        for (int i = 0; i < ids.length; i++) {
          if (!ids[i].isEmpty()) {
            Mission obj = MissionModel.getById(ids[i]);
            if (obj != null) {
              MissionModel.delete(obj);
            }
          }
        }
View Full Code Here

    }
  }

  public static Mission getById(String alias) {
    init();
    Mission obj = new Mission();
    try {
      obj = ofy.get(new Key<Mission>(Mission.class, alias));
    } catch (Exception e) {
      obj = null;
    }
View Full Code Here

TOP

Related Classes of com.tubeonfire.entity.Mission

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.