Package com.google.ytd.model

Examples of com.google.ytd.model.Assignment


  @Override
  public Assignment getAssignmentById(long id) {
    PersistenceManager pm = pmf.getPersistenceManager();

    try {
      Assignment assignment = pm.getObjectById(Assignment.class, id);
      return pm.detachCopy(assignment);
    } catch (JDOObjectNotFoundException e) {
      log.log(Level.WARNING, e.getMessage(), e);
      return null;
    } finally {
View Full Code Here


          (List<Assignment>) query.execute(defaultMobileAssignmentDescription);
      if (results.size() > 0) {
        assignmentId = results.get(0).getId();
      } else {
        // create the singleton default mobile assignment
        Assignment assignment = new Assignment();
        assignment.setCategory("News");
        assignment.setDescription(defaultMobileAssignmentDescription);
        assignment.setStatus(Assignment.AssignmentStatus.ACTIVE);
        assignment = pm.makePersistent(assignment);
       
        assignment = pm.makePersistent(assignment);
        assignment = pm.detachCopy(assignment);
        assignmentId = assignment.getId();
       
        newAssignment(assignment, "Mobile Submissions", "");
      }
    } finally {
      pm.close();
View Full Code Here

    if (util.isNullOrEmpty(id) || id.equals("undefined")) {
      // Default to true if id isn't given or isn't numeric.
      return true;
    }
   
    Assignment assignment = getAssignmentById(id);

    if (assignment == null || util.isNullOrEmpty(assignment.getUnreviewedAlbumUrl())
        || util.isNullOrEmpty(assignment.getRejectedAlbumUrl())
        || util.isNullOrEmpty(assignment.getApprovedAlbumUrl())) {
      return false;
    } else {
      return true;
    }
  }
View Full Code Here

  @Override
  public String getLoginInstruction(String assignmentId) {
    String globalInstruction = getAdminConfig().getLoginInstruction();

    AssignmentDao assignmentDao = new AssignmentDaoImpl(pmf);
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    String assignmentLoginInstruction = "";
    if (assignment != null && assignment.getLoginInstruction() != null) {
      assignmentLoginInstruction = assignment.getLoginInstruction();
    }

    return globalInstruction.replace("ASSIGNMENT_MESSAGE", assignmentLoginInstruction);
  }
View Full Code Here

  @Override
  public String getPostSubmitMessage(String assignmentId) {
    String globalPostSubmitMessage = getAdminConfig().getPostSubmitMessage();

    AssignmentDao assignmentDao = new AssignmentDaoImpl(pmf);
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    String assignmentPostSubmitMessage = "";
    if (assignment != null && assignment.getPostSubmitMessage() != null) {
      assignmentPostSubmitMessage = assignment.getPostSubmitMessage();
    }

    return globalPostSubmitMessage.replace("ASSIGNMENT_MESSAGE", assignmentPostSubmitMessage);
  }
View Full Code Here

        assignmentId = userSession.getMetaData("assignmentId");
      } else {
        userSession.addMetaData("assignmentId", assignmentId);
      }
     
      Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
      if (assignment == null) {
        throw new IllegalArgumentException(String.format(
            "Could not find an assignment with id '%s'.", assignmentId));
      }
      AssignmentStatus status = assignment.getStatus();
      if (status != AssignmentStatus.ACTIVE) {
        throw new IllegalArgumentException(String.format(
            "Could not add a video to a non ACTIVE assignment. "
                + "Current status of assignment id '%s' is '%s'.", assignmentId, status));
      }

      // Max title length is 60 characters or 100 bytes.
      if (title.length() > 60) {
        title = title.substring(0, 59);
      }

      VideoEntry newEntry = new VideoEntry();
      YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();

      mg.setTitle(new MediaTitle());
      mg.getTitle().setPlainTextContent(title);

      mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, assignment.getCategory()));

      mg.setKeywords(new MediaKeywords());

      List<String> tags = new ArrayList<String>();
      for (int i = 0; i < tagsArray.length(); i++) {
View Full Code Here

   *          The video to add.
   * @return true if the video was added; false otherwise.
   */
  private boolean addToPlaylist(VideoSubmission videoSubmission) {
    long assignmentId = videoSubmission.getAssignmentId();
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    if (assignment == null) {
      LOG.warning(String.format(
          "Couldn't find assignment id '%d' for video id '%s'.", assignmentId,
          videoSubmission.getId()));
      return false;
    }

    String playlistId = assignment.getPlaylistId();
    if (util.isNullOrEmpty(playlistId)) {
      LOG.warning(String.format(
          "Assignment id '%d' does not have an associated playlist.",
          assignmentId));
      return false;
View Full Code Here

   *          The video to remove.
   * @return true if the video was removed; false otherwise.
   */
  private boolean removeFromPlaylist(VideoSubmission videoSubmission) {
    long assignmentId = videoSubmission.getAssignmentId();
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    if (assignment == null) {
      LOG.warning(String.format(
          "Couldn't find assignment id '%d' for video id '%s'.", assignmentId,
          videoSubmission.getId()));
      return false;
    }

    String playlistId = assignment.getPlaylistId();
    if (util.isNullOrEmpty(playlistId)) {
      LOG.warning(String.format(
          "Assignment id '%d' does not have an associated playlist.",
          assignmentId));
      return false;
View Full Code Here

           
            // Add video to YouTube playlist if it isn't in it already.
            // This code is kind of ugly and is mostly copy/pasted from UpdateVideoSubmissionStatus
            // TODO: It should be refactored into a common helper method somewhere...
            if (!submission.isInPlaylist()) {
              Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
 
              if (assignment == null) {
                log.warning(String.format("Couldn't find assignment id '%d' for video id '%s'.",
                    assignmentId, videoId));
              } else {
                String playlistId = assignment.getPlaylistId();
                if (util.isNullOrEmpty(playlistId)) {
                  log.warning(String.format("Assignment id '%d' doesn't have an associated playlist.",
                      assignmentId));
                } else {
                  apiManager.setAuthSubToken(adminConfig.getYouTubeAuthSubToken());
View Full Code Here

    return json;
  }

  private boolean addToPlaylist(VideoSubmission videoSubmission) {
    long assignmentId = videoSubmission.getAssignmentId();
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    if (assignment == null) {
      LOG.warning(String.format("Couldn't find assignment id '%d' for video id '%s'.", assignmentId,
          videoSubmission.getId()));
      return false;
    }

    String playlistId = assignment.getPlaylistId();
    if (util.isNullOrEmpty(playlistId)) {
      LOG.warning(String.format("Assignment id '%d' does not have an associated playlist.",
        assignmentId));
      return false;
    }
View Full Code Here

TOP

Related Classes of com.google.ytd.model.Assignment

Copyright © 2015 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.