Package org.davinci.server.review

Examples of org.davinci.server.review.Version


            boolean isHasClosedManually = Boolean.parseBoolean(versionElement.getAttribute("hasClosedManually"));
            String restartFrom = versionElement.getAttribute("restartFrom");
            String description = versionElement.getAttribute("description");
            boolean receiveEmail = Boolean.parseBoolean(versionElement.getAttribute("receiveEmail"));
            boolean hasRestarted = Boolean.parseBoolean(versionElement.getAttribute("hasRestarted"));
            Version version = new Version(versionID, time,isDraft,dueDate,width,height);
            if (versionTitle == null)
              versionTitle = "";
            version.setVersionTitle(versionTitle);
            version.setHasClosedManually(isHasClosedManually);
            version.setRestartFrom(restartFrom);
            version.setDescription(description);
            version.setReceiveEmail(receiveEmail);
            version.setHasRestarted(hasRestarted);

            NodeList reviewers = versionElement.getElementsByTagName("reviewer");
            for (int j = 0; j < reviewers.getLength(); j++) {
              Element reviewer = (Element) reviewers.item(j);

              String reviewerName = reviewer.getAttribute("name");
              String reviewerEmail = reviewer.getAttribute("email");
              version.addReviewer(ReviewManager.getReviewManager().getReviewer(reviewerName, reviewerEmail));
            }

            NodeList resources = versionElement.getElementsByTagName("resource");
            for (int j = 0; j < resources.getLength(); j++) {
              Element resource = (Element) resources.item(j);

              String path = resource.getAttribute("path");
              version.addResource(path);
            }
            objects.add(version);

          }
        } catch (ParserConfigurationException e) {
View Full Code Here


    @Override
  public void handleCommand(HttpServletRequest req, HttpServletResponse resp,
      IUser user) throws IOException {

    Version version = null;
    Boolean isUpdate = req.getParameter("isUpdate") != null ?
        req.getParameter("isUpdate").equals("true") : false;
    String vTime = req.getParameter("vTime");
    Boolean isRestart = req.getParameter("isRestart") != null ?
        req.getParameter("isRestart").equals("true") : false;
    String emailsStr = req.getParameter("emails");
    String message = req.getParameter("message");
    String versionTitle = req.getParameter("versionTitle");
    String[] resources = req.getParameterValues("resources");
    String desireWidth = req.getParameter("desireWidth");
    String desireHeight = req.getParameter("desireHeight");
    Boolean savingDraft = req.getParameter("savingDraft") != null;
    String dueDate = req.getParameter("dueDate");
    Boolean receiveEmail = req.getParameter("receiveEmail") != null ?
        req.getParameter("receiveEmail").equals("true") : false;
    Boolean zazl = req.getParameter("zazl") != null;

    String[] emails = emailsStr.split(",");
    List<Reviewer> reviewers = new ArrayList<Reviewer>();

    IDesignerUser du = ReviewManager.getReviewManager().getDesignerUser(user);

    if (!isUpdate) {
      Date currentTime = new Date();
      SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_PATTERN_SHORT);
      formatter.setCalendar(Calendar.getInstance(new SimpleTimeZone(0, "GMT")));
      String timeVersion = formatter.format(currentTime);
     
      String id = null;
      int latestVersionID = 1;
      if (du.getLatestVersion() == null|| du.getVersion(du.getLatestVersion().getTime()) == null) {
        List<Version> versions = du.getVersions();
        for(Version temp: versions){
          int i = Integer.parseInt(temp.getVersionID());
          if (i > latestVersionID) {
            latestVersionID = i;
          }
        }
        id=latestVersionID+"";
      } else {
        int latestID = Integer.parseInt(du.getLatestVersion().getVersionID());
        id = latestID + 1 + "";
      }
      version = new Version(id, timeVersion, savingDraft, dueDate,
          desireWidth, desireHeight);
      du.addVersion(version);
      du.setLatestVersion(version);
    } else {
      version = du.getVersion(vTime);
     
      //NOTE: In theory, it would be good to remove the review any reviewers
      //no longer part of the review and persist the changes
    }
   
    //Deal with reviewers the designer has added to the review
    ReviewerVersion reviewerVersion = new ReviewerVersion(user.getUserID(), version.getTime());
    Reviewer tmpReviewer = null;
    for (int i = 0; i < emails.length; i++) {
      String email = emails[i];
      if (!email.equals(user.getPerson().getEmail())) {
        tmpReviewer = ReviewManager.getReviewManager().getReviewer("", email);
        tmpReviewer.addReviewerVersion(reviewerVersion);
        reviewers.add(tmpReviewer);
      }
    }

    //Add the designer as a reviewer
    tmpReviewer = ReviewManager.getReviewManager().getReviewer(user.getUserID(), user.getPerson().getEmail());
    tmpReviewer.addReviewerVersion(reviewerVersion);
    reviewers.add(tmpReviewer);

    //Handle fake reviewer (if necessary)
    String fakeReviewer = ServerManager.getServerManager().getDavinciProperty(Constants.FAKE_REVIEWER);
    if (fakeReviewer != null) {
      tmpReviewer = ReviewManager.getReviewManager().getReviewer("fakeReviewer", fakeReviewer);
      tmpReviewer.addReviewerVersion(reviewerVersion);
      reviewers.add(tmpReviewer);
    }

    version.setDraft(savingDraft);
    version.setDueDate(dueDate);
    version.setDesireWidth(desireWidth);
    version.setDesireHeight(desireHeight);
    version.setReviewers(reviewers);
    version.setVersionTitle(versionTitle);
    if (resources != null) {
      version.setResource(resources);
    }
    version.setHasClosedManually(false);
    version.setDescription(message);
    version.setReceiveEmail(receiveEmail);

    if (isRestart) {
      version.setRestartFrom(vTime);
      du.getVersion(vTime).setHasRestarted(true);
      DavinciProject project = new DavinciProject();
      project.setOwnerId(du.getName());
      ReviewCacheManager.$.republish(project,vTime, version);
    }
   
    JSONWriter writer = new JSONWriter(true);
    writer.startObject();
    writer.addField("result", "OK");
    writer.addField("version", version.getTime());
    writer.addField("designer", du.getName());
    if (savingDraft) {
      ReviewManager.getReviewManager().saveDraft(du, version);
    } else {
      ReviewManager.getReviewManager().publish(du, version);
 
      String requestUrl = req.getRequestURL().toString();
      // set is used to filter duplicate email. Only send mail to one email
      // one time.
      Set<String> set = new HashSet<String>();
      String emailResult = null;
      for (Reviewer reviewer : reviewers) {
        String mail = reviewer.getEmail();
        if (mail != null && !mail.equals("") && set.add(mail)) {
          String url = ReviewManager.getReviewManager().getReviewUrl(user.getUserID(), version.getTime(), requestUrl, zazl);
          String htmlContent = getHtmlContent(user, message, url);
          String subject = Utils.getTemplates().getProperty(Constants.TEMPLATE_INVITATION_SUBJECT_PREFIX) + " " + versionTitle;
          emailResult = notifyRelatedPersons(mail, subject, htmlContent);
        }
      }
View Full Code Here

      String reviewTime = reviewerVersion.getTimeVersion();
      if (designerIDParm == null || designerIDParm.equals("") || designerIDParm.equals(reviewDesignerID)) {
        IDesignerUser designerUser = commentingManager.getDesignerUser(reviewDesignerID);
        /* designer user removed from the system (or never existed) */
        if(designerUser==null) continue;
        Version version = designerUser.getVersion(reviewTime);

        if (version != null) {
          if (version.containsUser(userEmail)) {
            writer.startObject();
            writer.addField("designerId", reviewDesignerID);
            writer.addField("designerEmail", designerUser.getRawUser().getPerson().getEmail());
            writer.addField("designerDisplayName", designerUser.getRawUser().getPerson().getDisplayName() );
            writer.addField("versionTitle", version.getVersionTitle());
            writer.addField("versionId", version.getVersionID());
            writer.addField("dueDate", version.dueDateString());
            writer.addField("timeStamp", version.getTime());
            writer.addField("closed", version.isClosed());
            writer.addField("closedManual",version.isHasClosedManually());
            writer.addField("isDraft", version.isDraft());
            writer.addField("width", version.getDesireWidth());
            writer.addField("height", version.getDesireHeight());
            writer.addField("restartFrom",version.getRestartFrom());
            writer.addField("receiveEmail", version.isReceiveEmail());
            writer.addField("hasRestarted", version.isHasRestarted());
            if(version.getDescription()!="") {
              writer.addField("description", version.getDescription());
            }
           
            writer.addFieldName("reviewers");
            writer.startArray();
   
            for(Reviewer reviewer:version.getReviewers()){
              writer.startObject();
              writer.addField("name", reviewer.getUserID());
              writer.addField("displayName", reviewer.getDisplayName());
              writer.addField("email", reviewer.getEmail());
              writer.endObject();
View Full Code Here

    ReviewManager commentingManager = ReviewManager.getReviewManager();
    String designerName = req.getParameter("designer");
    if(designerName ==null||designerName.equals(""))
      designerName = user.getUserID();
    IDesignerUser designer = commentingManager.getDesignerUser(designerName);
    Version version = designer.getVersion(req.getParameter("version"));
    List<String> resource = version.getResources();
    JSONWriter writer = new JSONWriter(true);
    for (String it : resource) {
      writer.startObject();
      writer.addField("path", it);
      writer.endObject();
View Full Code Here

   * @see
   * maqetta.core.server.user.IDesignerUser#deleteVersion(java.
   * lang.String)
   */
  public void deleteVersion(String versionTime) throws IOException {
    Version version = this.getVersion(versionTime);
    versions.remove(version);
    IStorage versionDir = this.userDirectory.newInstance(
        this.getCommentingDirectory(), "snapshot/" + versionTime);
    if (versionDir.exists()) {
      deleteDir(versionDir);
View Full Code Here

    comment.setEmail(user.getPerson().getEmail());

    IDesignerUser du = ReviewManager.getReviewManager()
        .getDesignerUser(designerName);
    Version version = du.getVersion(comment.getPageVersion());

    if (version != null && version.isClosed()){
      errorString = "The version was closed by another user while editing. Please reload the review data.";
      return;
    }
    List<Comment> commentList = new ArrayList<Comment>(1);
    commentList.add(comment);
    ReviewCacheManager.$.updateComments(commentList);

    String emailResult = null;
    if (version != null && version.isReceiveEmail()) { // Send the notification only the designer want receive it.
      Boolean zazl = req.getParameter("zazl") != null;
      emailResult = notifyRelatedPersons(user, designer, comment, req, zazl);
    }

    SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_PATTERN);
View Full Code Here

    DavinciProject project = new DavinciProject();
    project.setOwnerId(du.getName());
   
    comment.setProject(project);
    Comment existingComm = ReviewCacheManager.$.getComment(project, comment.getId());
    Version version = du.getVersion(existingComm.getPageVersion());
    try {
      if (version != null && version.isClosed()){
        throw new Exception("The version is closed by others during your editting. Please reload the review data.");
      }

      List<Comment> commentList = new ArrayList<Comment>(1);
      commentList.add(comment);
View Full Code Here

      throws IOException {
    String type = req.getParameter("type"); // three types: close, open, delete and publish
    String vTime = req.getParameter("vTime");
    IDesignerUser du = ReviewManager.getReviewManager()
        .getDesignerUser(user);
    Version version = du.getVersion(vTime);
    ReviewManager reviewManager = ReviewManager.getReviewManager();
    if ("close".equalsIgnoreCase(type)) {
      version.closeVersion();
      reviewManager.saveVersionFile(du);
    } else if ("open".equalsIgnoreCase(type)) {
      version.openVersion();
      version.setHasRestarted(false);
      reviewManager.saveVersionFile(du);
    } else if ("publish".equalsIgnoreCase(type)) {
      version.setDraft(false);
      reviewManager.publish(du, version);
    } else if ("delete".equalsIgnoreCase(type)) {
      du.deleteVersion(vTime);
      reviewManager.saveVersionFile(du);
      IDavinciProject project = new DavinciProject();
View Full Code Here

TOP

Related Classes of org.davinci.server.review.Version

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.