Search in sources :

Example 6 with ProjectDependency

use of org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency in project legend-sdlc by finos.

the class ProjectStructure method getProjectDependencies.

protected List<ProjectDependency> getProjectDependencies() {
    ProjectConfiguration configuration = getProjectConfiguration();
    List<ProjectDependency> projectDependencies = (configuration == null) ? null : configuration.getProjectDependencies();
    return (projectDependencies == null) ? Collections.emptyList() : projectDependencies;
}
Also used : ProjectDependency(org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency) ProjectConfiguration(org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)

Example 7 with ProjectDependency

use of org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency in project legend-sdlc by finos.

the class ProjectStructure method updateOrAddDependencies.

private static void updateOrAddDependencies(Set<ProjectDependency> toUpdateProjectDependencies, ProjectFileAccessProvider projectFileAccessProvider, Set<ProjectDependency> projectDependencies, boolean purgeOldDependency) {
    List<ProjectDependency> unknownDependencies = Lists.mutable.empty();
    List<ProjectDependency> nonProdDependencies = Lists.mutable.empty();
    SortedMap<ProjectDependency, Exception> accessExceptions = new TreeMap<>();
    for (ProjectDependency projectDependency : toUpdateProjectDependencies) {
        if (ProjectDependency.isLegacyProjectDependency(projectDependency)) {
            try {
                ProjectConfiguration dependencyConfig = getProjectConfiguration(projectFileAccessProvider.getFileAccessContext(projectDependency.getProjectId(), projectDependency.getVersionId()));
                if (dependencyConfig == null || dependencyConfig.getArtifactId() == null || dependencyConfig.getGroupId() == null) {
                    unknownDependencies.add(projectDependency);
                } else if (dependencyConfig.getProjectType() != ProjectType.PRODUCTION) {
                    nonProdDependencies.add(projectDependency);
                } else {
                    if (purgeOldDependency) {
                        projectDependencies.remove(projectDependency);
                    }
                    projectDependencies.add(ProjectDependency.newProjectDependency(dependencyConfig.getGroupId() + ":" + dependencyConfig.getArtifactId(), projectDependency.getVersionId()));
                }
            } catch (Exception e) {
                accessExceptions.put(projectDependency, e);
            }
        } else {
            projectDependencies.add(ProjectDependency.newProjectDependency(projectDependency.getProjectId(), projectDependency.getVersionId()));
        }
    }
    if (!unknownDependencies.isEmpty() || !nonProdDependencies.isEmpty() || !accessExceptions.isEmpty()) {
        StringBuilder builder = new StringBuilder("There were issues with one or more added project dependencies");
        if (!unknownDependencies.isEmpty()) {
            builder.append("; unknown ").append((unknownDependencies.size() == 1) ? "dependency" : "dependencies").append(": ");
            unknownDependencies.sort(Comparator.naturalOrder());
            unknownDependencies.forEach(d -> d.appendDependencyString((d == unknownDependencies.get(0)) ? builder : builder.append(", ")));
        }
        if (!nonProdDependencies.isEmpty()) {
            builder.append("; non-production ").append((unknownDependencies.size() == 1) ? "dependency" : "dependencies").append(": ");
            nonProdDependencies.sort(Comparator.naturalOrder());
            nonProdDependencies.forEach(d -> d.appendDependencyString((d == nonProdDependencies.get(0)) ? builder : builder.append(", ")));
        }
        if (!accessExceptions.isEmpty()) {
            builder.append("; access ").append((accessExceptions.size() == 1) ? "exception" : "exceptions").append(": ");
            ProjectDependency first = accessExceptions.firstKey();
            accessExceptions.forEach((d, e) -> d.appendDependencyString((d == first) ? builder : builder.append(", ")).append(" (").append(e.getMessage()).append(')'));
        }
        throw new LegendSDLCServerException(builder.toString(), Status.BAD_REQUEST);
    }
}
Also used : LegendSDLCServerException(org.finos.legend.sdlc.server.error.LegendSDLCServerException) ProjectDependency(org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency) TreeMap(java.util.TreeMap) LegendSDLCServerException(org.finos.legend.sdlc.server.error.LegendSDLCServerException) IOException(java.io.IOException) ProjectConfiguration(org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)

Example 8 with ProjectDependency

use of org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency in project legend-sdlc by finos.

the class TestModelBuilder method buildEntitiesForTest.

public List<Entity> buildEntitiesForTest(String upstreamProjectId, String upstreamRevisionId, String downstreamProjectId, String downstreamVersionId) {
    DepotProjectId upstreamDepotProjectId = getDepotProjectId(upstreamProjectId);
    DepotProjectId downstreamDepotProjectId = DepotProjectId.parseProjectId(downstreamProjectId);
    Set<ProjectDependency> latestUpstreamLevel1Dependencies = this.dependenciesApi.getProjectRevisionUpstreamProjects(upstreamProjectId, upstreamRevisionId, false);
    Set<DepotProjectVersion> dependencies = processDependencies(upstreamDepotProjectId, downstreamDepotProjectId, downstreamVersionId, transformProjectDependencySet(latestUpstreamLevel1Dependencies));
    List<Entity> upstreamProjectWorkspaceEntities = this.entityApi.getProjectRevisionEntityAccessContext(upstreamProjectId, upstreamRevisionId).getEntities(null, null, null);
    return getEntities(downstreamDepotProjectId, downstreamVersionId, dependencies, upstreamProjectWorkspaceEntities);
}
Also used : DepotProjectId(org.finos.legend.sdlc.server.depot.model.DepotProjectId) DepotProjectVersion(org.finos.legend.sdlc.server.depot.model.DepotProjectVersion) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) ProjectDependency(org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency)

Example 9 with ProjectDependency

use of org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency in project legend-sdlc by finos.

the class TestModelBuilder method buildEntitiesForTest.

public List<Entity> buildEntitiesForTest(String upstreamProjectId, String upstreamWorkspaceId, WorkspaceType type, String upstreamRevisionId, String downstreamProjectId, String downstreamVersionId) {
    DepotProjectId upstreamDepotProjectId = getDepotProjectId(upstreamProjectId);
    DepotProjectId downstreamDepotProjectId = DepotProjectId.parseProjectId(downstreamProjectId);
    Set<ProjectDependency> latestUpstreamLevel1Dependencies = this.dependenciesApi.getWorkspaceRevisionUpstreamProjects(upstreamProjectId, upstreamWorkspaceId, type, upstreamRevisionId, false);
    Set<DepotProjectVersion> dependencies = processDependencies(upstreamDepotProjectId, downstreamDepotProjectId, downstreamVersionId, transformProjectDependencySet(latestUpstreamLevel1Dependencies));
    List<Entity> upstreamProjectWorkspaceEntities = this.entityApi.getWorkspaceRevisionEntityAccessContext(upstreamProjectId, upstreamWorkspaceId, type, upstreamRevisionId).getEntities(null, null, null);
    return getEntities(downstreamDepotProjectId, downstreamVersionId, dependencies, upstreamProjectWorkspaceEntities);
}
Also used : DepotProjectId(org.finos.legend.sdlc.server.depot.model.DepotProjectId) DepotProjectVersion(org.finos.legend.sdlc.server.depot.model.DepotProjectVersion) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) ProjectDependency(org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency)

Example 10 with ProjectDependency

use of org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency in project legend-sdlc by finos.

the class DependenciesApiImpl method searchUpstreamRecursive.

private void searchUpstreamRecursive(ProjectConfiguration projectConfig, Set<ProjectDependency> results) {
    for (ProjectDependency dependency : projectConfig.getProjectDependencies()) {
        if (results.add(dependency)) {
            ProjectConfiguration dependencyProjectConfig = this.projectConfigurationApi.getVersionProjectConfiguration(dependency.getProjectId(), dependency.getVersionId());
            searchUpstreamRecursive(dependencyProjectConfig, results);
        }
    }
}
Also used : ProjectDependency(org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency) ProjectConfiguration(org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)

Aggregations

ProjectDependency (org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency)10 ProjectConfiguration (org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)8 Entity (org.finos.legend.sdlc.domain.model.entity.Entity)5 ArtifactType (org.finos.legend.sdlc.domain.model.project.configuration.ArtifactType)3 IOException (java.io.IOException)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Sets (org.eclipse.collections.api.factory.Sets)2 ProjectType (org.finos.legend.sdlc.domain.model.project.ProjectType)2 DepotProjectId (org.finos.legend.sdlc.server.depot.model.DepotProjectId)2 DepotProjectVersion (org.finos.legend.sdlc.server.depot.model.DepotProjectVersion)2 StreamReadFeature (com.fasterxml.jackson.core.StreamReadFeature)1 StreamWriteFeature (com.fasterxml.jackson.core.StreamWriteFeature)1 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)1