Package net.sf.collabreview.core.users

Examples of net.sf.collabreview.core.users.Author


    if (repository.getArtifact(aid) != null) {
      logger.warn("Artifact is already there, skipping");
      return;
    }
    // store the artifact to the store
    Author author = owner.getOrCreateAuthorForActionData(actionData);
    importProgressInfo.setAtomicWorkUnitDescription("Adding " + aid + " to repository");
    assert repository.getLatestForName(aid.getName(), aid.getBranch()) == null ||
        repository.getLatestForName(aid.getName(), aid.getBranch()).isObsolete();
    Artifact newArtifact = repository.addArtifact(aid, actionData.getDate(), truncatedText(actionData), author);
    // update groupings
View Full Code Here


   *
   * @param actionData contains the name of the Author to load
   * @return the Author named in the actionData
   */
  public Author getOrCreateAuthorForActionData(ActionData actionData) {
    Author author = importer.getCollabReview().getAuthorManager().getAuthor(actionData.getAuthor());
    if (author == null) {
      author = importer.getCollabReview().getAuthorManager().createAuthor(actionData.getAuthor());
      importer.getCollabReview().getAuthorManager().storeAuthor(author);
    }
    return author;
View Full Code Here

  public void setUp() {
    collabReview = AutoConfigurator.newConfiguredApplication();
    repository = (BasicRepository) collabReview.getRepository();
    repository.reset();
    AuthorManager authorManager = collabReview.getAuthorManager();
    authorManager.storeAuthor(new Author("alice"));
    authorManager.storeAuthor(new Author("bob"));
    authorManager.storeAuthor(new Author("chris"));
    artifactAuthor = new Author[]{
        authorManager.getAuthor("alice"),
        authorManager.getAuthor("bob"),
        authorManager.getAuthor("alice"),
        authorManager.getAuthor("bob"),
View Full Code Here

        if (owner.equals(getOwnerOfFile(new File(file, addedFileName)))) {
          incrementBySameOwner.add(addedFileName);
        }
      }
      addedFiles.removeAll(incrementBySameOwner);
      Author ownerAuthor = authorManager.getAuthor(owner);
      if (ownerAuthor == null) {
        ownerAuthor = authorManager.createAuthor(owner);
        authorManager.storeAuthor(ownerAuthor);
        authorManager.commit();
      }
      if (revision > 1) {
        repository.getArtifact(new ArtifactIdentifier(printPath, revision - 1, "")).setObsoleteDate(newRevisionDate);
      }
      repository.addArtifact(new ArtifactIdentifier(printPath, revision, ""),
          newRevisionDate,
          contentFromSetOfFileNames(incrementBySameOwner),
          ownerAuthor);
      repository.commit();
      revision++;
    }
    // => remove directory names from artifact in repository
    Set<String> removedFiles = new TreeSet<String>(filesInOldVersion);
    removedFiles.removeAll(filesInNewVersion);
    if (removedFiles.size() > 0) {
      logger.debug("Files were removed from " + printPath + ": " + removedFiles);
      Author authorWhoDeleted;
      if (owner != null) {
        // we don't know who removed the files but let's guess it was one of those who also added files, otherwise assume it was the owner of the directory himself
        authorWhoDeleted = authorManager.getAuthor(owner);
      } else {
        owner = getOwnerOfFile(file);
View Full Code Here

  private ArtifactIdentifier createIdentifier(int num) {
    return new ArtifactIdentifier("a", num, "");
  }

  private Author author(int i) {
    Author author = new HibernateAuthorManager().createAuthor("" + i);
    HibernateUtil.getCurrentSession().save(author);
    HibernateUtil.closeSession();
    return author;
  }
View Full Code Here

    super.tearDown();
    HibernateUtil.closeSession();
  }

  public void testStoreAuthors() {
    Author author = author(1);
    Author loaded = (Author) HibernateUtil.getCurrentSession().load(Author.class, "1");
    assertEquals(author, loaded);
    Author author2 = author(2);
    assertEquals(author2, HibernateUtil.getCurrentSession().load(Author.class, "2"));
  }
View Full Code Here

  public void testStoreReview() {
    ArtifactIdentifier aid = createIdentifier(1);
    HibernateUtil.save(new HibernateArtifact(aid, null, new Date(), "bula bula"));
    HibernateUtil.closeSession();
    Author author = author(5);
    System.out.println("\n\n\n\n\n\n\n\n****\n\n\n\n");
    Review review = new HibernateReview(
        (ArtifactIdentifier) HibernateUtil.getCurrentSession().get(ArtifactIdentifier.class, aid.getPk()),
        author, "möhb", 2, true);
    HibernateUtil.getCurrentSession().save(review);
View Full Code Here

        new ArtifactIdentifier("somefile.java", 4, ""),
        new ArtifactIdentifier("otherfile.java", 5, ""),
        new ArtifactIdentifier("copyoffirstfile.java", 6, ""),
        new ArtifactIdentifier("emptyfile.java", 7, "")
    };
    alice = new Author("Alice");
    bob = new Author("Bob");
    caesar = new Author("Caesar");
    authors = new Author[]{alice, bob, caesar, alice, bob, caesar, alice, alice};
  }
View Full Code Here

    if (collabReview.getAuthorManager().storeAuthor(authors[0]) != null) {
      collabReview.getAuthorManager().commit();
    } else {
      System.out.println("saving author " + authors[0] + " failed, may be it is already there");
    }
    Author author = collabReview.getAuthorManager().getAuthor(authors[0].getName());
    repository.addArtifact(identifier[0], null, content[0], author);
    assertEquals(identifier[0], repository.getArtifact(identifier[0]).getId());
    repository.commit();
    Review review = repository.setReview(identifier[0], author, 2, "hello", true);
    repository.commit();
View Full Code Here

  public void testStoreAndGetMultipleReviewsOfSameArtifact() {
    storeAuthors();
    repository.addArtifact(identifier[0], null, content[0], authors[0]);
    int count = 0;
    for (int i = 0; i < 3; i++) {
      Author author = authors[i];
      repository.setReview(identifier[0], author, 0, "pingo pongo" + count, false);
      count++;
    }
    count = 0;
    for (int i = 0; i < 3; i++) {
      Author author = authors[i];
      Review review = repository.getReview(identifier[0].getName(), identifier[0].getBranch(), author);
      assertEquals(identifier[0], review.getArtifactIdentifier());
      assertEquals(author, review.getAuthor());
      assertEquals("pingo pongo" + count, review.getReviewText());
      count++;
View Full Code Here

TOP

Related Classes of net.sf.collabreview.core.users.Author

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.