Examples of NexusNGArtifact


Examples of org.sonatype.nexus.rest.model.NexusNGArtifact

    SearchNGResponse result = search(key);

    Assert.assertEquals(2, result.getData().size());
    for (int i = 0; i < 2; i++) {
      NexusNGArtifact nexusNGArtifact = result.getData().get(0);
      Assert.assertEquals(2, nexusNGArtifact.getArtifactHits().size());
      Assert.assertEquals(releases.getId(), nexusNGArtifact.getArtifactHits().get(0).getRepositoryId());
      Assert.assertEquals(releases2.getId(), nexusNGArtifact.getArtifactHits().get(1).getRepositoryId());
    }
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.NexusNGArtifact

  }

  public GAHolder prepare(String... versions) {
    final GAHolder result = new GAHolder();
    for (String version : versions) {
      final NexusNGArtifact nxhit = new NexusNGArtifact();
      nxhit.setVersion(version);
      final StringVersion sv = fromString(nxhit.getVersion());
      result.putVersionHit(sv, nxhit);
    }
    return result;
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.NexusNGArtifact

      }

      StringVersion version = new StringVersion(ai.version, ai.getArtifactVersion());

      NexusNGArtifact versionHit = gaholder.getVersionHit(version);
      if (versionHit == null) {
        versionHit = new NexusNGArtifact();
        versionHit.setGroupId(ai.groupId);
        versionHit.setArtifactId(ai.artifactId);
        versionHit.setVersion(ai.version);
        versionHit.setHighlightedFragment(getMatchHighlightHtmlSnippet(ai));

        gaholder.putVersionHit(version, versionHit);

        gavcount++;
      }

      NexusNGArtifactHit repositoryHit = getRepositoryHit(versionHit, ai.repository);
      if (repositoryHit == null) {
        repositoryHit = new NexusNGArtifactHit();
        repositoryHit.setRepositoryId(ai.repository);
        versionHit.addArtifactHit(repositoryHit);

        // we are adding the POM link "blindly", unless packaging is POM,
        // since the it will be added below the "usual" way
        if (!"pom".equals(ai.packaging)) {
          repositoryHit.addArtifactLink(createNexusNGArtifactLink(request, ai.repository, ai.groupId,
              ai.artifactId, ai.version, "pom", null));
        }
      }

      repositoryHit.addArtifactLink(createNexusNGArtifactLink(request, ai.repository, ai.groupId,
          ai.artifactId, ai.version, ai.fextension, ai.classifier));

      tooManyResults = false;
    }

    // summary:
    getSearchDiagnosticLogger().debug(
        "Query terms \"" + terms + "\" (LQL \"" + iterator.getQuery() + "\") matched total of "
            + iterator.getTotalHitsCount() + " records, " + iterator.getTotalProcessedArtifactInfoCount()
            + " records were processed out of those, resulting in " + gahits.size()
            + " unique GA records. Lucene scored documents first=" + firstDocumentScore + ", last="
            + lastDocumentScore + ". Main processing loop took " + (System.currentTimeMillis() - startedAtMillis)
            + " ms.");

    // expand if explicitly requested or if number of unique GAV matches is less than threshold
    boolean expand = forceExpand || gavcount <= COLLAPSE_OVERRIDE_TRESHOLD;

    SearchNGResponse response = new SearchNGResponse();
    response.setTooManyResults(tooManyResults || iterator.getTotalHitsCount() + 1 >= LUCENE_HIT_LIMIT);
    response.setCollapsed(!expand);

    List<NexusNGArtifact> responseData = new ArrayList<NexusNGArtifact>();

    LinkedHashSet<String> repositoryIds = new LinkedHashSet<String>();

    for (GAHolder gahit : gahits.values()) {
      if (expand) {
        // expand, i.e. include all versions
        for (NexusNGArtifact artifact : gahit.getOrderedVersionHits()) {
          responseData.add(artifact);
          setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
          addRepositoryIds(repositoryIds, artifact);
        }
      }
      else {
        // collapse, i.e. only include latest version in each GA
        NexusNGArtifact artifact = gahit.getLatestVersionHit();
        setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
        responseData.add(artifact);
        addRepositoryIds(repositoryIds, artifact);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.