Package net.sf.collabreview.core

Examples of net.sf.collabreview.core.Artifact


    for (File child : children) {
      filesInNewVersion.add(child.getName());
    }
    Date newRevisionDate = new Date(file.lastModified());
    String newRevisionContent = contentFromSetOfFileNames(filesInNewVersion);
    Artifact oldRevision = repository.getLatestForName(printPath, "");
    if (oldRevision != null && oldRevision.getContent().equals(newRevisionContent)) {
      // contents of new and old revision are the same => no need to create a new revision
      if (logger.isTraceEnabled()) {
        logger.trace("Artifact \"" + printPath + "\" is unchanged");
      }
      return;
    }
    int revision = 1;
    // old and new revision differ
    // => insert new directory names into artifact in repository
    Set<String> filesInOldVersion = new TreeSet<String>();
    if (oldRevision != null) {
      // there was an old revision: this influences the revision counter and the old revision has to be marked obsolete
      filesInOldVersion.addAll(Arrays.asList(oldRevision.getContent().split("\n")));
      revision = oldRevision.getId().getRevision() + 1;
    }
    Set<String> addedFiles = new TreeSet<String>(filesInNewVersion);
    addedFiles.removeAll(filesInOldVersion);
    Set<String> incrementBySameOwner = new TreeSet<String>(filesInOldVersion);
    if (addedFiles.size() > 0) {
View Full Code Here


   * @param latestTime        streaks beginning after the survey time frame are not considered
   * @param surveyTimeFrameDuration duration of the surveyTimeFrame
   * @return the number of micro edit streaks within the surveyTimeFrame (very long streaks are still counted only as one)
   */
  public static int countMicroEdits(Repository repository, Artifact artifact, int streakLength, int inBetweenTime, long latestTime, long surveyTimeFrameDuration) {
    Artifact currentArtifact = artifact;
    Artifact nextArtifact;
    long currentTime = currentArtifact.getDate().getTime();
    int currentStreak = 1;
    int maximumStreak = 0;
    String name = currentArtifact.getId().getName();
    String branch = currentArtifact.getId().getBranch();
    int revision = currentArtifact.getId().getRevision();
    int microEditsFound = 0;
    // look for micro edits as long as...
    while (currentTime > latestTime - surveyTimeFrameDuration // currentTime is not before the start of surveyTimeFrame
        && revision > 0 ) { // we did not hit the bottom of the repository)
      revision--;
      nextArtifact = repository.getArtifact(new ArtifactIdentifier(name, revision, branch));
      if (nextArtifact == null) {
        continue;
      }
      // only test for streaks if we have already reached the surveyTimeFrame
      if (currentArtifact.getDate().getTime() <= latestTime) {
        // to count as micro edit, two subsequent revisions have to have the same creator and may be no longer than inBetweenTime milliseconds apart
        if (currentArtifact.getCreatorName().equals(nextArtifact.getCreatorName()) && currentTime - nextArtifact.getDate().getTime() < inBetweenTime) {
          currentStreak++;
          if (currentStreak > maximumStreak) {
            maximumStreak = currentStreak;
            if (maximumStreak == streakLength) { // if streakLength hits the required maximumStreak length, then count a micro edit
              microEditsFound++;
View Full Code Here

            articles.add("Projekt_BRIDGE");
            articles.add("Zeitschriften-Wunschliste");*/
          }
          for (String article : articles) {
            logger.debug("Computing micro edits for article " + article);
            Artifact artifact = repository.getLatestForName(article, "");
            int beforeCount = MicroEditCastigator.countMicroEdits(repository, artifact, 3, 300 * 1000, microEditCastigatorInstallTime, surveyPeriod);
            int afterCount = MicroEditCastigator.countMicroEdits(repository, artifact, 3, 300 * 1000, microEditCastigatorInstallTime + surveyPeriod, surveyPeriod);
            totalMicroEditsBefore += beforeCount;
            totalMicroEditsAfter += afterCount;
            result.append(String.format("<tr><td>%s</td><td>%d</td><td>%d</td>", article, beforeCount, afterCount));
View Full Code Here

    if (checkOldReviews) {
      Repository repository = agentManager.getCollabReview().getRepository();
      Collection<Review> reviews = repository.listReviewsBy(getReviewerIdentity());
      logger.info("Checking all of my existing " + reviews.size() + " reviews if they are still valid");
      for (Review review : reviews) {
        Artifact artifact = repository.getArtifact(review.getArtifactIdentifier());
        assert artifact != null;
        StringBuilder sb = new StringBuilder();
        Integer newRating = generateReview(sb, artifact);
        if (newRating == null) {
          logger.warn("Could not create a new review in place of " + review);
View Full Code Here

    @Override
    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);
        }
        cs.addContribution(name, weight);
        if (artifactPointer.getAncestorId() != null) {
          artifactPointer = artifact.getRepository().getArtifact(artifactPointer.getAncestorId());
        }
      }
      // the appropriate constructor is sadly missing in the Java libraries, so must copy manually
      NavigableMap<Author, Float> result = new TreeMap<Author, Float>(cs);
      for (Author author : shareForAuthor.keySet()) {
View Full Code Here

    for (String authorName : authors) {
      authorManager.storeAuthor(authorManager.createAuthor(authorName));
    }
    authorManager.commit();
    for (int i = startRev; i < endRev; i++) {
      Artifact old = repository.getLatestForName(artifactIdentifiers[i].getName(), artifactIdentifiers[i].getBranch());
      if (old != null) {
        old.setObsoleteDate(new Date(i));
      }
      Author author = authorManager.getAuthor(authors[i]);
      repository.addArtifact(artifactIdentifiers[i], new Date(i), contents[i], author);
    }
    repository.commit();
View Full Code Here

   */
  public boolean filter(ArtifactIdentifier artifactIdentifier, Repository repository) {
    if (!preFilter(artifactIdentifier.getName(), artifactIdentifier.getRevision(), artifactIdentifier.getBranch())) {
      return false;
    }
    Artifact artifact = repository.getArtifact(artifactIdentifier);
    return filter(artifact);
  }
View Full Code Here

    String artifactName = artifact.getId().getName();
    NavigableMap<Author, Float> latest_contributions = getOwner().getCollabReview().getMeasurementsManager().getArtifactResponsibility().listResponsibilities(artifact);
    //get Artifact with Revision latest-1...
    ArtifactIdentifier ai = getPreviousArtifact(artifactName, last_revision-1);
    if (ai!=null) {
      Artifact child = getRepository().getArtifact(ai);
      NavigableMap<Author,Float> previous_contributions =  getOwner().getCollabReview().getMeasurementsManager().getArtifactResponsibility().listResponsibilities(child);
      for (Author docAuthor : latest_contributions.keySet()) {
        String latest_name = docAuthor.getName();   
        int latest_contribution = (int)(latest_contributions.get(docAuthor)*100+0.5);
        int previous_contribution = 0;
View Full Code Here

*/
public class CheckstyleViolationsPerSourceLineOfCodeAgent extends CheckstyleAgent {
  @Override
  public void writeReview(CheckstyleAgent.AuditEventList auditEventList) {
    CollabReview collabReview = getAgentManager().getCollabReview();
    Artifact artifact = collabReview.getRepository().getArtifact(auditEventList.getArtifactIdentifier());
    int lines = LineCounter.countNonEmptyLines(getAgentManager().getCollabReview().getRepository(), auditEventList.getArtifactIdentifier());
    int violations = auditEventList.getInfoCount() + auditEventList.getWarnCount() * 2 + auditEventList.getErrorCount() * 3;
    float violationsPerLine = (float) violations / lines;
    float quality = violationsPerLine <= 1 ?
        (10 - 10 * violationsPerLine)
 
View Full Code Here

  protected void tearDown() throws Exception {
    Thread.sleep(30);
  }

  public void testCastigateChecker() {
    Artifact artifact = repository.addArtifact(new ArtifactIdentifier("ArtifactIdentifier(x,1,t)"), new Date(0), content + "a", author1);
    repository.commit();
    assertEquals(0, MicroEditCastigator.countMicroEdits(repository, artifact, 3, 300 * 1000, new Date(2).getTime(), 600 * 1000));
    assertEquals(0, repository.getReviewCount());
    artifact = repository.addArtifact(new ArtifactIdentifier("ArtifactIdentifier(x,2,t)"), new Date(5), content + "a\nb", author1);
    repository.commit();
View Full Code Here

TOP

Related Classes of net.sf.collabreview.core.Artifact

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.