Package net.sf.collabreview.core.users

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


  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"),
        authorManager.getAuthor("chris"),
        authorManager.getAuthor("alice"),
        authorManager.getAuthor("chris"),
        authorManager.getAuthor("alice"),
        authorManager.getAuthor("alice")
    };
    artifacts = new Artifact[artifactContent.length];
    for (int i = 0; i < artifacts.length; i++) {
      artifacts[i] = new Artifact(ai[i], artifactAuthor[i], new Date(i), artifactContent[i]);
    }
View Full Code Here


  public void testAuthorManager() {
    ConfigurationConfigurableCollabReview collabReview = new ConfigurationConfigurableCollabReview();
    AutoConfigurator.configureApplication(collabReview);
    isTestConfigInitOk(collabReview);
    AuthorManager authorManager = collabReview.getAuthorManager();
    assertTrue(authorManager instanceof HibernateAuthorManager);
  }
View Full Code Here

   * @param collabReview the CollabReview to configure
   * @param config     the configuration to apply to the CollabReview instance
   * @throws Exception if creating the repository fails
   */
  private void configureAuthorManager(ConfigurationConfigurableCollabReview collabReview, ConfigurationData config) throws Exception {
    AuthorManager authorManager = ((AuthorManagerFactory) getFactory(config)).create();
    logger.debug("AuthorManager created by its factory");
    collabReview.setAuthorManager(authorManager);
  }
View Full Code Here

    Set<String> incrementBySameOwner = new TreeSet<String>(filesInOldVersion);
    if (addedFiles.size() > 0) {
      logger.debug("Files were added to \"" + printPath + "\": " + addedFiles);
    }
    String owner = null;
    AuthorManager authorManager = importer.getCollabReview().getAuthorManager();
    while (addedFiles.size() > 0) {
      Iterator<String> iterator = addedFiles.iterator();
      String addedFileName = iterator.next();
      File addedFile = new File(file, addedFileName);
      owner = getOwnerOfFile(addedFile);
      incrementBySameOwner.add(addedFileName);
      while (iterator.hasNext()) {
        addedFileName = iterator.next();
        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);
        if (owner == null) {
          logger.warn("Assuming someone else as owner of " + file + " instead.");
          owner = authorManager.listAuthorNames().iterator().next();
        }
        authorWhoDeleted = authorManager.getAuthor(owner);
        if (authorWhoDeleted == null) {
          logger.error("That's weird, there is still no author...");
        }
      }
      if (revision > 1) {
View Full Code Here

    streakLength = Integer.parseInt(config.getValue("streak", "3"));
    timeFrame = Integer.parseInt(config.getValue("seconds", "300")) * 1000;
    message = config.getValue("message", "Micro edits detected");
    reviewerName = config.getValue("author", getProposedName());
    logger.debug("Review author name: " + reviewerName);
    AuthorManager authorManager = agentManager.getCollabReview().getAuthorManager();
    Author author = authorManager.getAuthor(reviewerName);
    if (author == null) {
      logger.info("Registering a new author for the MicroEditCastigator: " + reviewerName);
      author = authorManager.createAuthor(reviewerName);
      authorManager.storeAuthor(author);
    }
  }
View Full Code Here

    public NavigableMap<Author, Float> listResponsibilities(Artifact artifact) {
      ContributionSort cs = new ContributionSort();
      Map<Author, Float> shareForAuthor = new HashMap<Author, Float>();
      Artifact artifactPointer = artifact;
      String name = null;
      AuthorManager authorManager = artifact.getRepository().getCollabReview().getAuthorManager();
      for (float aContributionShare : contributionShare) {
        if (artifactPointer.getCreatorName() != null) {
          name = artifactPointer.getCreatorName();
        }
        Author author = authorManager.getAuthor(name);
        int weight = (int) (aContributionShare * 1000);
        if (shareForAuthor.containsKey(author)) {
          shareForAuthor.put(author, aContributionShare + shareForAuthor.get(author));
        } else {
          shareForAuthor.put(author, aContributionShare);
View Full Code Here

    if (sleepConfig != null) {
      sleepInterval = Long.parseLong(sleepConfig.getSelfValue()) * 1000;
    }
    logger.debug("Agent sleep interval is: " + sleepInterval / 1000 + " seconds");
    // ensure that the checkstyle author exists
    AuthorManager manager = agentManager.getCollabReview().getAuthorManager();
    Author author = manager.getAuthor(getProposedName());
    if (author == null) {
      logger.info("Registering a new author for the CheckstyleAgent: " + getProposedName());
      author = manager.createAuthor(getProposedName());
      if (manager.storeAuthor(author) == null) {
        logger.error("Failed to register the new author");
      } else {
        manager.commit();
      }
    }
    // input filter
    ConfigurationData filterConfig = config.getSubElement("filter");
    if (filterConfig != null) {
View Full Code Here

      for (EditorMarkup em : artifact.getMarkup().<EditorMarkup>listMarkups(EditorMarkup.class)) {
        cs.addContribution(em.getEditorName(), em.length());
      }
      NavigableMap<Author, Float> result = new TreeMap<Author, Float>(cs);
      float contribSum = 0;
      AuthorManager authorManager = artifact.getRepository().getCollabReview().getAuthorManager();
      for (String authorName : cs.listKeys()) {
        Author author = authorManager.getAuthor(authorName);
        assert author.getName().equals(authorName);
        float authorContribution = cs.getContributionRatio(authorName);
        result.put(author, authorContribution);
        contribSum += authorContribution;
      }
View Full Code Here

   * Looks for Java package imports and uses them to assign responsibility to the packages.
   */
  private static class TheMetric implements ArtifactResponsibility {
    @Override
    public NavigableMap<Author, Float> listResponsibilities(Artifact artifact) {
      AuthorManager authorManager = artifact.getRepository().getCollabReview().getAuthorManager();
      Set<Author> packages = new HashSet<Author>();
      String content = artifact.getContent();
      Pattern pattern = Pattern.compile("import (([a-z]+\\.)+).*;");
      Matcher matcher = pattern.matcher(content);
      while (matcher.find()) {
        String pack = matcher.group(1);
        assert pack != null;
        Author author = authorManager.getAuthor(pack);
        if (author == null) {
          author = authorManager.createAuthor(pack);
          authorManager.storeAuthor(author);
          authorManager.commit();
        }
        packages.add(author);
      }
      // normalize
      NavigableMap<Author, Float> result = new TreeMap<Author, Float>();
View Full Code Here

    for (AuthorMarkup am : artifact.getMarkup().<AuthorMarkup>listMarkups(AuthorMarkup.class)) {
      cs.addContribution(am.getAuthorName(), am.length());
    }
    NavigableMap<Author, Float> result = new TreeMap<Author, Float>(cs);
    float contribSum = 0;
    AuthorManager authorManager = artifact.getRepository().getCollabReview().getAuthorManager();
    for (String authorName : cs.listKeys()) {
      Author author = authorManager.getAuthor(authorName);
      assert author.getName().equals(authorName);
      float authorContribution = cs.getContributionRatio(authorName);
      result.put(author, authorContribution);
      contribSum += authorContribution;
    }
View Full Code Here

TOP

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

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.