Package net.sf.collabreview.core

Examples of net.sf.collabreview.core.ArtifactIdentifier


  protected void executeSingleSearchStep() {
    if (!allArtifIterator.hasNext()) {
      setResult(bestSoFar);
      return;
    }
    ArtifactIdentifier aid = allArtifIterator.next();
    assert aid != null;
    Artifact potentialAncestor = getRepository().getArtifact(aid);
    assert potentialAncestor != null;
    ArtifactSimilarity.TransformInfo currentTransform = getArtifactSimilarity().findTransformScript(potentialAncestor, getNewArtifactContent(), Integer.MAX_VALUE);
    if (bestSoFar == null || currentTransform.getCost() < bestSoFar.getCost()) {
View Full Code Here


   * @return an ArtifactIdentifier with the requested information
   * @throws Exception if attempting to map fails with an exception
   */
  public ArtifactIdentifier getRegroupedIdentifier(String sourceName) throws Exception {
    Pair<String, String> names = getNameAndBranch(sourceName);
    return new ArtifactIdentifier(names.first, revision, names.second);
  }
View Full Code Here

  /**
   * @return a newly created ArtifactIdentifier for the targeted resource
   */
  public ArtifactIdentifier getArtifactIdentifier() {
    return new ArtifactIdentifier(targetPath, revision, targetBranch);
  }
View Full Code Here

    String originalName = artifactIdentifier.getName().contains("/") ? artifactIdentifier.getName().substring(artifactIdentifier.getName().lastIndexOf("/")) : artifactIdentifier.getName();
    originalName = originGrouping.getName() + originalName;
    String targetName = actionData.getSourcePath() + originalName.substring(oldPrefix.length());
    String targetGroupingName = targetName.substring(0, targetName.lastIndexOf("/"));
    try {
      ArtifactIdentifier newId = actionData.getRegroupedIdentifier(targetName);
      Artifact oldArtifactWithSameName = repository.getLatestForName(newId.getName(), newId.getBranch());
      if (oldArtifactWithSameName != null && !oldArtifactWithSameName.isObsolete() && oldArtifactWithSameName.getId().getRevision() != newId.getRevision()) {
        // Sanity check: there is already an artifact with that name in the database.
        // This means that a different artifact would be mapped by CollabReview onto the same artifact.
        // This is not good; prevent this.
        // TODO I hope this will detect the problem in the freecol repository which must be somewhere before revision 1952
        throw new IllegalArgumentException("Local name conflict for " + newId);
View Full Code Here

      public void visit(Grouping grouping, ArtifactIdentifier oldId) {
        String newName = oldId.getName();
        if (oldId.getName().startsWith(branches.oldPrefix)) {
          newName = branches.newPrefix + oldId.getName().substring(branches.oldPrefix.length());
        }
        ArtifactIdentifier newId = new ArtifactIdentifier(newName, actionData.getRevision(), branches.newBranch);
        importProgressInfo.setAtomicWorkUnitDescription("Changing artifact id from " + oldId + " to " + newId);
        Artifact oldArtifact = repository.getArtifact(oldId);
        oldArtifact.setObsoleteDate(actionData.getDate());
        repository.addArtifact(newId, actionData.getDate(), oldArtifact.getContent(), owner.getOrCreateAuthorForActionData(actionData));
      }
View Full Code Here

  private TokenbasedSimilarity ls;

  public void setUp() throws Exception {
    CollabReviewSingleton.get();
    a1 = new Artifact(new ArtifactIdentifier("a.java", 1, ""), null, null, s1);
    a2 = new Artifact(new ArtifactIdentifier("a.java", 2, ""), null, null, s2);
    a3 = new Artifact(new ArtifactIdentifier("a.java", 3, ""), null, null, s3);
    a4 = new Artifact(new ArtifactIdentifier("a.java", 4, ""), null, null, s4);
    a5 = new Artifact(new ArtifactIdentifier("a.java", 5, ""), null, null, s5);
    a6 = new Artifact(new ArtifactIdentifier("a.java", 6, ""), null, null, s6);
    a7 = new Artifact(new ArtifactIdentifier("a.java", 7, ""), null, null, s7);
    ls = new TokenbasedSimilarity(new LineTokenizerFactory());
  }
View Full Code Here

        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) {
        repository.getArtifact(new ArtifactIdentifier(printPath, revision - 1, "")).setObsoleteDate(newRevisionDate);
      }
      repository.addArtifact(new ArtifactIdentifier(printPath, revision, ""),
          new Date(file.lastModified()),
          newRevisionContent,
          authorWhoDeleted);
      repository.commit();
    }
View Full Code Here

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

      throw new IllegalArgumentException("Illegal null command");
    }
    // check author is non-null
    Author author = getAuthorAndCheckAuthentication(request);
    // identify target resource
    ArtifactIdentifier target = identifyResource(request);
    if (target == null) {
      throw new IllegalArgumentException("document not found");
    }
    switch (command) {
      case load:
        Review review = CollabReviewSingleton.get().getRepository().getReview(target.getName(), target.getBranch(), author);
        if (review != null) {
          result.setProperty("rating", "" + review.getRating());
          result.setProperty("text", review.getReviewText());
          result.setProperty("anonymous", "" + review.getIsAnonymous());
        }
View Full Code Here

  private synchronized List<Artifact> loadTodoArtifacts() throws Exception {
    // consolidated identifier list
    Collection<ArtifactIdentifier> consolidatedList = new HashSet<ArtifactIdentifier>();
    // now check each of the files in the todoList to make sure only the most recent version is checked and that a review does not already exist
    for (int i = 0; i < todoList.size(); i++) {
      ArtifactIdentifier ai1 = todoList.get(i);
      boolean isOk = true;
      Review previousReview;
      // really check this file if recheckAll or no previous review or old review refers to a different artifact
      if (!recheckAll
          && (previousReview = agentManager.getCollabReview().getRepository().getReview(ai1.getName(), ai1.getBranch(), getCheckstyleAuthor())) != null
          && previousReview.getArtifactIdentifier().equals(ai1)) {
        isOk = false;
      }
      // compare to all other Artifacts in the todoList but terminate if the Artifact is found to be a duplicate
      for (int j = i + 1; j < todoList.size() && isOk; j++) {
        ArtifactIdentifier ai2 = todoList.get(j);
        if (ai1 == ai2) {
          // don't add ai1 this time, because the Artifact will be added when it is ai2's turn
          isOk = false;
        }
        if (ai1.getName().equals(ai2.getName()) && ai1.getBranch().equals(ai2.getBranch()) && ai1.getRevision() <= ai2.getRevision()) {
          isOk = false;
        }
      }
      if (isOk) {
        consolidatedList.add(ai1);
View Full Code Here

TOP

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

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.