use of org.apache.archiva.metadata.repository.cassandra.CassandraArchivaManager.DEFAULT_PRIMARY_KEY in project archiva by apache.
the class CassandraMetadataRepository method removeDependencies.
protected void removeDependencies(String projectVersionMetadataKey) {
String table = cassandraArchivaManager.getDependencyFamilyName();
CqlSession session = cassandraArchivaManager.getSession();
{
Select deleteRows = selectFrom(table).column(DEFAULT_PRIMARY_KEY).whereColumn("\"projectVersionMetadataModel.key\"").isEqualTo(literal(projectVersionMetadataKey)).allowFiltering();
ResultSet result = session.execute(deleteRows.build());
StreamSupport.stream(result.spliterator(), false).map(row -> row.getString(DEFAULT_PRIMARY_KEY)).distinct().forEach(delKey -> session.execute(deleteFrom(table).whereColumn(DEFAULT_PRIMARY_KEY).isEqualTo(literal(delKey)).build()));
}
}
use of org.apache.archiva.metadata.repository.cassandra.CassandraArchivaManager.DEFAULT_PRIMARY_KEY in project archiva by apache.
the class CassandraMetadataRepository method removeNamespace.
@Override
public void removeNamespace(RepositorySession repositorySession, String repositoryId, String namespaceId) throws MetadataRepositoryException {
String key = //
new Namespace.KeyBuilder().withNamespace(//
namespaceId).withRepositoryId(//
repositoryId).build();
CqlSession session = cassandraArchivaManager.getSession();
{
String pTable = cassandraArchivaManager.getNamespaceFamilyName();
Delete delete = deleteFrom(pTable).whereColumn(DEFAULT_PRIMARY_KEY).isEqualTo(literal(key));
session.execute(delete.build());
List<String> tables = Arrays.asList(cassandraArchivaManager.getProjectFamilyName(), cassandraArchivaManager.getProjectVersionMetadataFamilyName(), cassandraArchivaManager.getArtifactMetadataFamilyName(), cassandraArchivaManager.getMetadataFacetFamilyName());
for (String table : tables) {
Select deleteRows = selectFrom(table).column(DEFAULT_PRIMARY_KEY).whereColumn(REPOSITORY_NAME.toString()).isEqualTo(literal(repositoryId)).whereColumn(NAMESPACE_ID.toString()).isEqualTo(literal(namespaceId)).allowFiltering();
ResultSet result = session.execute(deleteRows.build());
StreamSupport.stream(result.spliterator(), false).map(row -> row.getString(DEFAULT_PRIMARY_KEY)).distinct().forEach(delKey -> session.execute(deleteFrom(table).whereColumn(DEFAULT_PRIMARY_KEY).isEqualTo(literal(delKey)).build()));
}
}
}
use of org.apache.archiva.metadata.repository.cassandra.CassandraArchivaManager.DEFAULT_PRIMARY_KEY in project archiva by apache.
the class CassandraMetadataRepository method removeLicenses.
protected void removeLicenses(String projectVersionMetadataKey) {
String table = cassandraArchivaManager.getLicenseFamilyName();
CqlSession session = cassandraArchivaManager.getSession();
{
Select deleteRows = selectFrom(table).column(DEFAULT_PRIMARY_KEY).whereColumn("\"projectVersionMetadataModel.key\"").isEqualTo(literal(projectVersionMetadataKey)).allowFiltering();
ResultSet result = session.execute(deleteRows.build());
StreamSupport.stream(result.spliterator(), false).map(row -> row.getString(DEFAULT_PRIMARY_KEY)).distinct().forEach(delKey -> session.execute(deleteFrom(table).whereColumn(DEFAULT_PRIMARY_KEY).isEqualTo(literal(delKey)).build()));
}
}
Aggregations