aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/metadata-store-cassandra
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2014-03-26 12:16:02 +0000
committerOlivier Lamy <olamy@apache.org>2014-03-26 12:16:02 +0000
commitacc72428047d54ba43f802d457afb4f5d10f9c88 (patch)
tree3f6ecac23c8122f989ea695136fb845fdb4d21c1 /archiva-modules/plugins/metadata-store-cassandra
parent24a6d8419c45178a9d2d8ca959f8fd120bcadfd5 (diff)
downloadarchiva-acc72428047d54ba43f802d457afb4f5d10f9c88.tar.gz
archiva-acc72428047d54ba43f802d457afb4f5d10f9c88.zip
add unit test for method getProjectReferences
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/metadata-store-cassandra')
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java41
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java26
2 files changed, 42 insertions, 25 deletions
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
index e46675472..1840f1c31 100644
--- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
@@ -875,7 +875,7 @@ public class CassandraMetadataRepository
recordLicenses( key, versionMetadata.getLicenses() );
- recordDependencies( key, versionMetadata.getDependencies() );
+ recordDependencies( key, versionMetadata.getDependencies(), repositoryId );
MutationResult mutationResult = mutator.execute();
}
@@ -942,7 +942,7 @@ public class CassandraMetadataRepository
recordLicenses( key, versionMetadata.getLicenses() );
removeDependencies( key );
- recordDependencies( key, versionMetadata.getDependencies() );
+ recordDependencies( key, versionMetadata.getDependencies(), repositoryId );
projectVersionMetadataTemplate.update( updater );
@@ -1234,7 +1234,8 @@ public class CassandraMetadataRepository
}
- protected void recordDependencies( String projectVersionMetadataKey, List<Dependency> dependencies )
+ protected void recordDependencies( String projectVersionMetadataKey, List<Dependency> dependencies,
+ String repositoryId )
{
if ( dependencies == null || dependencies.isEmpty() )
@@ -1252,6 +1253,8 @@ public class CassandraMetadataRepository
addInsertion( dependencyMutator, keyDependency, cfDependency, "projectVersionMetadataModel.key",
projectVersionMetadataKey );
+ addInsertion( dependencyMutator, keyDependency, cfDependency, "repositoryName", repositoryId );
+
addInsertion( dependencyMutator, keyDependency, cfDependency, "classifier", dependency.getClassifier() );
addInsertion( dependencyMutator, keyDependency, cfDependency, "optional",
@@ -1918,8 +1921,36 @@ public class CassandraMetadataRepository
String projectVersion )
throws MetadataResolutionException
{
- // FIXME implement this
- return Collections.emptyList();
+ QueryResult<OrderedRows<String, String, String>> result = HFactory //
+ .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
+ .setColumnFamily( cassandraArchivaManager.getDependencyFamilyName() ) //
+ .setColumnNames( "projectVersionMetadataModel.key" ) //
+ .addEqualsExpression( "repositoryName", repoId ) //
+ .addEqualsExpression( "groupId", namespace ) //
+ .addEqualsExpression( "artifactId", projectId ) //
+ .addEqualsExpression( "version", projectVersion ) //
+ .execute();
+
+ List<String> dependenciesIds = new ArrayList<String>( result.get().getCount() );
+
+ for ( Row<String, String, String> row : result.get().getList() )
+ {
+ dependenciesIds.add( getStringValue( row.getColumnSlice(), "projectVersionMetadataModel.key" ) );
+ }
+
+ List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>( result.get().getCount() );
+
+ for ( String key : dependenciesIds )
+ {
+ ColumnFamilyResult<String, String> columnFamilyResult =
+ this.projectVersionMetadataTemplate.queryColumns( key );
+ references.add( new ProjectVersionReference( ProjectVersionReference.ReferenceType.DEPENDENCY, //
+ columnFamilyResult.getString( "projectId" ), //
+ columnFamilyResult.getString( "namespaceId" ), //
+ columnFamilyResult.getString( "projectVersion" ) ) );
+ }
+
+ return references;
}
@Override
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
index 978ffdb9b..9a40693c4 100644
--- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
+++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
@@ -375,13 +375,6 @@ public class DefaultCassandraArchivaManager
// creating indexes for cql query
- BasicColumnDefinition projectVersionMetadataIdColumn = new BasicColumnDefinition();
- projectVersionMetadataIdColumn.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataId" ) );
- projectVersionMetadataIdColumn.setIndexName( "projectVersionMetadataId" );
- projectVersionMetadataIdColumn.setIndexType( ColumnIndexType.KEYS );
- projectVersionMetadataIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
- mailingListCf.addColumnDefinition( projectVersionMetadataIdColumn );
-
}
// license table
@@ -394,13 +387,6 @@ public class DefaultCassandraArchivaManager
// creating indexes for cql query
- BasicColumnDefinition projectVersionMetadataIdColumn = new BasicColumnDefinition();
- projectVersionMetadataIdColumn.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataId" ) );
- projectVersionMetadataIdColumn.setIndexName( "projectVersionMetadataId" );
- projectVersionMetadataIdColumn.setIndexType( ColumnIndexType.KEYS );
- projectVersionMetadataIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
- licenseCf.addColumnDefinition( projectVersionMetadataIdColumn );
-
}
// dependency table
@@ -413,12 +399,12 @@ public class DefaultCassandraArchivaManager
// creating indexes for cql query
- BasicColumnDefinition projectVersionMetadataIdColumn = new BasicColumnDefinition();
- projectVersionMetadataIdColumn.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataId" ) );
- projectVersionMetadataIdColumn.setIndexName( "projectVersionMetadataId" );
- projectVersionMetadataIdColumn.setIndexType( ColumnIndexType.KEYS );
- projectVersionMetadataIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
- dependencyCf.addColumnDefinition( projectVersionMetadataIdColumn );
+ BasicColumnDefinition groupIdColumn = new BasicColumnDefinition();
+ groupIdColumn.setName( StringSerializer.get().toByteBuffer( "groupId" ) );
+ groupIdColumn.setIndexName( "groupIdIdx" );
+ groupIdColumn.setIndexType( ColumnIndexType.KEYS );
+ groupIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
+ dependencyCf.addColumnDefinition( groupIdColumn );
}