Search in sources :

Example 6 with ExternalId

use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.

the class CondaListParser method condaListElementToDependency.

public Dependency condaListElementToDependency(String platform, CondaListElement element) {
    String name = element.getName();
    String version = String.format("%s-%s-%s", element.getVersion(), element.getBuildString(), platform);
    ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.ANACONDA, name, version);
    return new Dependency(name, version, externalId);
}
Also used : ExternalId(com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Example 7 with ExternalId

use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.

the class PackRatNodeParser method parseProjectDependencies.

DependencyGraph parseProjectDependencies(final List<String> packratLockContents) {
    final LazyExternalIdDependencyGraphBuilder graphBuilder = new LazyExternalIdDependencyGraphBuilder();
    DependencyId currentParent = null;
    String name = null;
    String version = null;
    for (final String line : packratLockContents) {
        if (line.startsWith("PackratFormat:") || line.startsWith("PackratVersion:") || line.startsWith("RVersion:")) {
            continue;
        }
        if (line.contains("Package: ")) {
            name = line.replace("Package: ", "").trim();
            currentParent = new NameDependencyId(name);
            graphBuilder.setDependencyName(currentParent, name);
            graphBuilder.addChildToRoot(currentParent);
            version = null;
            continue;
        }
        if (line.contains("Version: ")) {
            version = line.replace("Version: ", "").trim();
            graphBuilder.setDependencyVersion(currentParent, version);
            final DependencyId realId = new NameVersionDependencyId(name, version);
            final ExternalId externalId = this.externalIdFactory.createNameVersionExternalId(Forge.CRAN, name, version);
            graphBuilder.setDependencyAsAlias(realId, currentParent);
            graphBuilder.setDependencyInfo(realId, name, version, externalId);
            currentParent = realId;
        }
        if (line.contains("Requires: ")) {
            final String[] parts = line.replace("Requires: ", "").split(",");
            for (int i = 0; i < parts.length; i++) {
                final String childName = parts[i].trim();
                graphBuilder.addParentWithChild(currentParent, new NameDependencyId(childName));
            }
        }
    }
    return graphBuilder.build();
}
Also used : NameVersionDependencyId(com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameVersionDependencyId) DependencyId(com.blackducksoftware.integration.hub.bdio.model.dependencyid.DependencyId) NameVersionDependencyId(com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameVersionDependencyId) NameDependencyId(com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameDependencyId) NameDependencyId(com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameDependencyId) LazyExternalIdDependencyGraphBuilder(com.blackducksoftware.integration.hub.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder) ExternalId(com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId)

Example 8 with ExternalId

use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.

the class NameVersionNodeTransformer method addNameVersionNodeToDependencyGraph.

public Dependency addNameVersionNodeToDependencyGraph(final MutableDependencyGraph graph, final Forge defaultForge, final NameVersionNode nameVersionNode) {
    Forge forge = defaultForge;
    if (nameVersionNode.getMetadata() != null && nameVersionNode.getMetadata().getForge() != null) {
        forge = nameVersionNode.getMetadata().getForge();
    }
    final ExternalId externalId = externalIdFactory.createNameVersionExternalId(forge, nameVersionNode.getName(), nameVersionNode.getVersion());
    final Dependency parentDependency = new Dependency(nameVersionNode.getName(), nameVersionNode.getVersion(), externalId);
    for (final NameVersionNode child : nameVersionNode.getChildren()) {
        final Dependency childDependency = addNameVersionNodeToDependencyGraph(graph, defaultForge, child);
        graph.addParentWithChild(parentDependency, childDependency);
    }
    return parentDependency;
}
Also used : ExternalId(com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId) Forge(com.blackducksoftware.integration.hub.bdio.model.Forge) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Example 9 with ExternalId

use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.

the class DependencyGraphAssertions method assertHasMavenGav.

public static void assertHasMavenGav(final DependencyGraph dependencyGraph, final String org, final String name, final String version) {
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final ExternalId id = externalIdFactory.createMavenExternalId(org, name, version);
    final Dependency dep = dependencyGraph.getDependency(id);
    assertNotNull("Expected dependency '" + org + ":" + name + ":" + version + "' to exist in graph but it was null.", dep);
}
Also used : ExternalIdFactory(com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory) ExternalId(com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Aggregations

ExternalId (com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId)9 Dependency (com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)6 Forge (com.blackducksoftware.integration.hub.bdio.model.Forge)2 DependencyGraph (com.blackducksoftware.integration.hub.bdio.graph.DependencyGraph)1 MutableDependencyGraph (com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph)1 LazyExternalIdDependencyGraphBuilder (com.blackducksoftware.integration.hub.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)1 DependencyId (com.blackducksoftware.integration.hub.bdio.model.dependencyid.DependencyId)1 NameDependencyId (com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameDependencyId)1 NameVersionDependencyId (com.blackducksoftware.integration.hub.bdio.model.dependencyid.NameVersionDependencyId)1 ExternalIdFactory (com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory)1 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.model.DetectCodeLocation)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1