Package org.davinci.server.review.user

Examples of org.davinci.server.review.user.IDesignerUser


    }
  }

  public IDesignerUser getDesignerUser(IUser user) throws IOException {
    String name = user.getUserID();
    IDesignerUser designer = designerUsers.get(name);
    if (null == designer) {
      designer = loadDesignerUser(user);
      designerUsers.put(name, designer);
    }else{
      //Update the raw user
      designer.setRawUser(user);
    }
    return designer;
  }
View Full Code Here


    }
    return designer;
  }
 
  public IDesignerUser getDesignerUser(String name) throws IOException {
    IDesignerUser designer = designerUsers.get(name);
    if (designer == null) {
      IUser user;
      try {
        user = ServerManager.getServerManager().getUserManager().getUser(name);
      } catch (UserException e) {
View Full Code Here

    }
    return reviewer;
  }

  public Reviewer isValid(String name, String id, String versionTime) {
    IDesignerUser user;
    try {
      user = getDesignerUser(name);
    } catch (IOException e) {
      e.printStackTrace(); //TODO
      return null;
    }
    if (versionTime == null) {
      if (user.getLatestVersion() != null) {
        versionTime = user.getLatestVersion().getTime();
      }
    }
    if (versionTime == null) {
      return null;
    }
    List<Version> versionList = user.getVersions();
    for (Version version : versionList) {
      if (version.getTime().equals(versionTime)) {
        List<Reviewer> reviewers = version.getReviewers();
        for (Reviewer reviewer : reviewers) {
          if (reviewer.getEmail().equals(id)) {
View Full Code Here

    return null;
  }

  private IDesignerUser loadDesignerUser(IUser user) throws IOException {
    //Create the designer user
    IDesignerUser designerUser = new DesignerUser(user);

    //Initialize the latest version
    IStorage commentingDir = designerUser.getCommentingDirectory();
    IStorage versionFile = commentingDir.newInstance(commentingDir, "snapshot/versions.xml");
    if (versionFile.exists()) {
      VersionFile file = new VersionFile();
      List<Version> versions = file.load(versionFile);
      for (Version version : versions) {
        designerUser.addVersion(version);
        if (file.latestVersionID != null
            && version.getVersionID().equals(file.latestVersionID)) {
          designerUser.setLatestVersion(version);
        }
      }
    }
   
    return designerUser;
View Full Code Here

public class GetLatestVersionId extends Command{

    public void handleCommand(HttpServletRequest req, HttpServletResponse resp,
        IUser user) throws IOException {
      ReviewManager cm = ReviewManager.getReviewManager();
      IDesignerUser reviewUser = cm.getDesignerUser(user);
      int latestVersionID = 1;
      if(reviewUser.getLatestVersion() !=null&&reviewUser.getVersion(reviewUser.getLatestVersion().getTime())!=null){
        latestVersionID = Integer.parseInt(reviewUser.getLatestVersion().getVersionID())+1;
      }
      else{
        List<Version> versions = reviewUser.getVersions();
        for(Version version: versions){
          int i = Integer.parseInt(version.getVersionID());
          if(i>latestVersionID){
            latestVersionID = i;
          }
View Full Code Here

    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);
 
View Full Code Here

      ReviewerVersion reviewerVersion = iterator.next();

      String reviewDesignerID = reviewerVersion.getDesignerID();
      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());
View Full Code Here

      throws IOException {
    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);
View Full Code Here

  public void setProjectName(String projectName) {
    this.projectName = projectName;
  }

  public IStorage getCommentsFileStorage() throws IOException {
    IDesignerUser ru = ReviewManager.getReviewManager().getDesignerUser(ownerId);
    IStorage commentingDir = ru.getCommentingDirectory();
    IStorage commentsFileStorage = commentingDir.newInstance(commentingDir, "snapshot/comments.xml");
    return commentsFileStorage;
  }
View Full Code Here

    project.setOwnerId(designer.getUserID());
    comment.setProject(project);

    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;
    }
View Full Code Here

TOP

Related Classes of org.davinci.server.review.user.IDesignerUser

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.