Split management of working set from DB logic
@@ -178,10 +178,13 @@ public class POMAnalyzerPlugin extends Plugin {
do {
try {
var metadataDao = new MetadataDao(dslContext);
+ addDependenciesToWorkingSet(metadataDao);
+
dslContext.transaction(transaction -> {
metadataDao.setContext(DSL.using(transaction));
long id;
try {
+
id = saveToDatabase(group + Constants.mvnCoordinateSeparator + artifact,
version, repoUrl, commitTag, sourcesUrl, packagingType, date,
projectName, parentCoordinate, dependencyData, artifactRepository, metadataDao);
@@ -264,13 +267,15 @@ public class POMAnalyzerPlugin extends Plugin {
final var depId = metadataDao.insertPackage(depProduct, Constants.mvnForge);
metadataDao.insertDependency(packageVersionId, depId,
dep.getVersionConstraints(), null, null, null, dep.toJSON());
-
- addPkgVersionToWorkingSet(metadataDao, dep, depProduct);
}
return packageVersionId;
}
- private void addPkgVersionToWorkingSet(MetadataDao metadataDao, Dependency dep, String depProduct) {
+ private void addDependenciesToWorkingSet(MetadataDao metadataDao) {
+
+ for (var dep : dependencyData.dependencies) {
+ var depProduct = dep.groupId + Constants.mvnCoordinateSeparator + dep.artifactId;
+
var depVersions = dep.getVersion().split(Pattern.quote(","));
for (String v : depVersions) {
if (MavenUtilities.mavenArtifactExists(dep.groupId, dep.artifactId, v, null) &&
@@ -287,6 +292,7 @@ public class POMAnalyzerPlugin extends Plugin {
}
}
}
+ }
private Timestamp getProperTimestamp(long timestamp) {
if (timestamp == -1) {
