diff options
author | Olivier Lamy <olamy@apache.org> | 2014-03-24 04:55:24 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-03-24 04:55:24 +0000 |
commit | 869291b35110fbe85810c9fe591228b96b19b40a (patch) | |
tree | abde0a82ada94c21782e3cf1d47de526eeaf0742 | |
parent | 043624f0523c78ad102e4c1ada64f9472bf51366 (diff) | |
download | archiva-869291b35110fbe85810c9fe591228b96b19b40a.tar.gz archiva-869291b35110fbe85810c9fe591228b96b19b40a.zip |
fix retrieving facets
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1580743 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java | 73 |
1 files changed, 21 insertions, 52 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 3a689fa45..1714f25fd 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 @@ -969,66 +969,35 @@ public class CassandraMetadataRepository projectVersionMetadata.setUrl( columnFamilyResult.getString( "url" ) ); - /* - - ProjectVersionMetadataModel projectVersionMetadataModel = - getProjectVersionMetadataModelEntityManager().get( key ); - - if ( projectVersionMetadataModel == null ) - { - logger.debug( - "getProjectVersion repoId: '{}', namespace: '{}', projectId: '{}', projectVersion: {} -> not found", - repoId, namespace, projectId, projectVersion ); - return null; - } - - ProjectVersionMetadata projectVersionMetadata = - getModelMapper().map( projectVersionMetadataModel, ProjectVersionMetadata.class ); - - logger.debug( "getProjectVersion repoId: '{}', namespace: '{}', projectId: '{}', projectVersion: {} -> {}", - repoId, namespace, projectId, projectVersion, projectVersionMetadata ); + // FIXME complete collections !! + // facets - projectVersionMetadata.setCiManagement( projectVersionMetadataModel.getCiManagement() ); - projectVersionMetadata.setIssueManagement( projectVersionMetadataModel.getIssueManagement() ); - projectVersionMetadata.setOrganization( projectVersionMetadataModel.getOrganization() ); - projectVersionMetadata.setScm( projectVersionMetadataModel.getScm() ); + StringSerializer ss = StringSerializer.get(); - // FIXME complete collections !! + Keyspace keyspace = cassandraArchivaManager.getKeyspace(); + QueryResult<OrderedRows<String, String, String>> result = HFactory // + .createRangeSlicesQuery( keyspace, ss, ss, ss ) // + .setColumnFamily( cassandraArchivaManager.getMetadataFacetModelFamilyName() ) // + .setColumnNames( "facetId", "key", "value", "name" ) // + .addEqualsExpression( "repositoryName", repoId ) // + .addEqualsExpression( "namespaceId", namespace ) // + .addEqualsExpression( "projectId", projectId ) // + .addEqualsExpression( "projectVersion", projectVersion ) // + .execute(); - // facets - final List<MetadataFacetModel> metadataFacetModels = new ArrayList<MetadataFacetModel>(); - // FIXME use cql query - getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>() - { - @Override - public Boolean apply( MetadataFacetModel metadataFacetModel ) - { - if ( metadataFacetModel != null ) - { - if ( StringUtils.equals( repoId, metadataFacetModel.getArtifactMetadataModel().getRepositoryId() ) - && StringUtils.equals( namespace, metadataFacetModel.getArtifactMetadataModel().getNamespace() ) - && StringUtils.equals( projectId, metadataFacetModel.getArtifactMetadataModel().getProject() ) - && StringUtils.equals( projectVersion, - metadataFacetModel.getArtifactMetadataModel().getProjectVersion() ) ) - { - metadataFacetModels.add( metadataFacetModel ); - } - } - return Boolean.TRUE; - } - } ); Map<String, Map<String, String>> metadataFacetsPerFacetIds = new HashMap<String, Map<String, String>>(); - for ( MetadataFacetModel metadataFacetModel : metadataFacetModels ) - { - Map<String, String> metaValues = metadataFacetsPerFacetIds.get( metadataFacetModel.getFacetId() ); + for ( Row<String, String, String> row : result.get() ) + { + ColumnSlice<String, String> columnSlice = row.getColumnSlice(); + String facetId = getStringValue( columnSlice, "facetId" ); + Map<String, String> metaValues = metadataFacetsPerFacetIds.get( facetId ); if ( metaValues == null ) { metaValues = new HashMap<String, String>(); - metadataFacetsPerFacetIds.put( metadataFacetModel.getFacetId(), metaValues ); + metadataFacetsPerFacetIds.put( facetId, metaValues ); } - metaValues.put( metadataFacetModel.getKey(), metadataFacetModel.getValue() ); - + metaValues.put( getStringValue( columnSlice, "key" ), getStringValue( columnSlice, "value" ) ); } if ( !metadataFacetsPerFacetIds.isEmpty() ) @@ -1044,7 +1013,7 @@ public class CassandraMetadataRepository } } } - */ + return projectVersionMetadata; } |