From: Carlos Sanchez Date: Mon, 24 Nov 2014 11:56:52 +0000 (+0100) Subject: Use the same list of ArtifactMetadata column names everywhere X-Git-Tag: archiva-2.2.0~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F13%2Fhead;p=archiva.git Use the same list of ArtifactMetadata column names everywhere --- 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 c7529ca70..f58b429b9 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 @@ -1706,8 +1706,7 @@ public class CassandraMetadataRepository RangeSlicesQuery query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ls ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // - .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), - REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); // + .setColumnNames( ArtifactMetadataModel.COLUMNS ); // if ( startTime != null ) { @@ -1789,8 +1788,7 @@ public class CassandraMetadataRepository RangeSlicesQuery query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // - .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), - REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); // + .setColumnNames( ArtifactMetadataModel.COLUMNS ); // query = query.addEqualsExpression( SHA1.toString(), checksum ).addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ); @@ -1899,8 +1897,7 @@ public class CassandraMetadataRepository RangeSlicesQuery query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // - .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), - REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); // + .setColumnNames( ArtifactMetadataModel.COLUMNS ); // query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ); @@ -2009,8 +2006,7 @@ public class CassandraMetadataRepository QueryResult> result = HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // - .setColumnNames( ID.toString(), REPOSITORY_NAME.toString(), NAMESPACE_ID.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), VERSION.toString(), - FILE_LAST_MODIFIED.toString(), SIZE.toString(), MD5.toString(), SHA1.toString(), WHEN_GATHERED.toString() )// + .setColumnNames( ArtifactMetadataModel.COLUMNS )// .setRowCount( Integer.MAX_VALUE ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java index b4c03d93b..6366fe9f8 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java @@ -28,6 +28,8 @@ import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; + +import org.apache.archiva.metadata.repository.cassandra.model.ColumnNames; import org.apache.commons.lang.StringUtils; /** @@ -77,6 +79,11 @@ public class CassandraUtils (Serializer) SerializerTypeInferer.getSerializer( value ) ); } + public static String getStringValue( ColumnSlice columnSlice, ColumnNames columnName ) + { + return getStringValue( columnSlice, columnName.toString() ); + } + public static String getStringValue( ColumnSlice columnSlice, String columnName ) { if ( StringUtils.isEmpty( columnName ) ) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java index ce8f552d8..530a49e1f 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java @@ -19,6 +19,8 @@ package org.apache.archiva.metadata.repository.cassandra.model; * under the License. */ +import static org.apache.archiva.metadata.repository.cassandra.model.ColumnNames.*; + import org.apache.archiva.metadata.repository.cassandra.CassandraUtils; import java.io.Serializable; @@ -34,6 +36,10 @@ public class ArtifactMetadataModel implements Serializable { + public final static String[] COLUMNS = new String[] { ID.toString(), REPOSITORY_NAME.toString(), + NAMESPACE_ID.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), VERSION.toString(), + FILE_LAST_MODIFIED.toString(), SIZE.toString(), MD5.toString(), SHA1.toString(), WHEN_GATHERED.toString() }; + private String id; private String repositoryId;