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;
}
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);
}
}
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);
}
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);
}
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);
}
}
}
Aggregations