From: Olivier Lamy Date: Thu, 20 Mar 2014 23:23:33 +0000 (+0000) Subject: change the column name X-Git-Tag: archiva-2.1.0~226 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6e362e8235cb5cda6e703663fecfeadf4e9b68d2;p=archiva.git change the column name git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1579827 13f79535-47bb-0310-9956-ffa450edef68 --- 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 0ef43f322..a08ae5a10 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 @@ -98,8 +98,8 @@ public class CassandraMetadataRepository .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) // - .setColumnNames( "id", "name" ) // - .addEqualsExpression( "id", repositoryId ) // + .setColumnNames( "repositoryName" ) // + .addEqualsExpression( "repositoryName", repositoryId ) // .execute(); if ( result.get().getCount() < 1 ) @@ -110,13 +110,9 @@ public class CassandraMetadataRepository try { MutationResult mutationResult = HFactory.createMutator( keyspace, StringSerializer.get() ) // - // values - .addInsertion( repositoryId, // - cassandraArchivaManager.getRepositoryFamilyName(), // - CassandraUtils.column( "id", repository.getId() ) ) // .addInsertion( repositoryId, // cassandraArchivaManager.getRepositoryFamilyName(), // - CassandraUtils.column( "name", repository.getName() ) ) // + CassandraUtils.column( "repositoryName", repository.getName() ) ) // .execute(); return repository; } @@ -128,7 +124,7 @@ public class CassandraMetadataRepository } - return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName( "id" ).getValue() ); + return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName( "repositoryName" ).getValue() ); } @@ -140,8 +136,8 @@ public class CassandraMetadataRepository .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) // - .setColumnNames( "id", "name" ) // - .addEqualsExpression( "id", repositoryId ) // + .setColumnNames( "repositoryName" ) // + .addEqualsExpression( "repositoryName", repositoryId ) // .execute(); return ( result.get().getCount() > 0 ) ? new Repository( repositoryId ) : null; } @@ -151,7 +147,6 @@ public class CassandraMetadataRepository throws MetadataRepositoryException { updateOrAddNamespace( repositoryId, namespaceId ); - } public Namespace updateOrAddNamespace( String repositoryId, String namespaceId ) @@ -177,7 +172,7 @@ public class CassandraMetadataRepository CassandraUtils.column( "name", namespace.getName() ) ) // .addInsertion( key, // cassandraArchivaManager.getNamespaceFamilyName(), // - CassandraUtils.column( "repositoryId", repository.getId() ) ) // + CassandraUtils.column( "repositoryName", repository.getName() ) ) // .execute(); } @@ -199,15 +194,15 @@ public class CassandraMetadataRepository StringSerializer.get(), // StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // - .setColumnNames( "repositoryId", "name" ) // - .addEqualsExpression( "repositoryId", repositoryId ) // + .setColumnNames( "repositoryName", "name" ) // + .addEqualsExpression( "repositoryName", repositoryId ) // .addEqualsExpression( "name", namespaceId ) // .execute(); if ( result.get().getCount() > 0 ) { ColumnSlice columnSlice = result.get().getList().get( 0 ).getColumnSlice(); return new Namespace( columnSlice.getColumnByName( "name" ).getValue(), // - new Repository( columnSlice.getColumnByName( "repositoryId" ).getValue() ) ); + new Repository( columnSlice.getColumnByName( "repositoryName" ).getValue() ) ); } return null; @@ -247,6 +242,7 @@ public class CassandraMetadataRepository // retrieve and delete all namespace with this repositoryId + // TODO use cql queries to delete all List namespacesKey = new ArrayList(); Keyspace keyspace = cassandraArchivaManager.getKeyspace(); @@ -256,8 +252,8 @@ public class CassandraMetadataRepository StringSerializer.get(), // StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // - .setColumnNames( "repositoryId", "name" ) // - .addEqualsExpression( "repositoryId", repositoryId ) // + .setColumnNames( "repositoryName", "name" ) // + .addEqualsExpression( "repositoryName", repositoryId ) // .execute(); for ( Row row : result.get().getList() ) @@ -383,8 +379,8 @@ public class CassandraMetadataRepository StringSerializer.get(), // StringSerializer.get(), // StringSerializer.get() ) // - .setColumnFamily( "repository" ) // - .setColumnNames( "name" ) // + .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) // + .setColumnNames( "repositoryName" ) // .setRange( null, null, false, Integer.MAX_VALUE ) // .execute(); @@ -392,7 +388,7 @@ public class CassandraMetadataRepository for ( Row row : cResult.get() ) { - repoIds.add( row.getColumnSlice().getColumnByName( "name" ).getValue() ); + repoIds.add( row.getColumnSlice().getColumnByName( "repositoryName" ).getValue() ); } return repoIds; @@ -415,9 +411,9 @@ public class CassandraMetadataRepository StringSerializer.get(), // StringSerializer.get(), // StringSerializer.get() ) // - .setColumnFamily( "namespace" ) // + .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( "name" ) // - .addEqualsExpression( "repositoryId", repoId ) // + .addEqualsExpression( "repositoryName", repoId ) // .execute(); Set namespaces = new HashSet( result.get().getCount() ); @@ -444,7 +440,7 @@ public class CassandraMetadataRepository StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( "name" ) // - .addEqualsExpression( "repositoryId", repoId ) // + .addEqualsExpression( "repositoryName", repoId ) // .execute(); List namespaces = new ArrayList( result.get().getCount() ); @@ -483,7 +479,7 @@ public class CassandraMetadataRepository StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( "name" ) // - .addEqualsExpression( "repositoryId", repoId ) // + .addEqualsExpression( "repositoryName", repoId ) // .execute(); List namespaces = new ArrayList( result.get().getCount() ); @@ -510,7 +506,7 @@ public class CassandraMetadataRepository StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) // .setColumnNames( "projectId" ) // - .addEqualsExpression( "repositoryId", repositoryId ) // + .addEqualsExpression( "repositoryName", repositoryId ) // .addEqualsExpression( "namespaceId", projectMetadata.getNamespace() ) // .addEqualsExpression( "projectId", projectMetadata.getId() ) // .execute(); @@ -533,7 +529,7 @@ public class CassandraMetadataRepository CassandraUtils.column( "projectId", projectMetadata.getId() ) ) // .addInsertion( key, // cassandraArchivaManager.getProjectFamilyName(), // - CassandraUtils.column( "repositoryId", repositoryId ) ) // + CassandraUtils.column( "repositoryName", repositoryId ) ) // .addInsertion( key, // cassandraArchivaManager.getProjectFamilyName(), // CassandraUtils.column( "namespaceId", projectMetadata.getNamespace() ) )// @@ -554,7 +550,7 @@ public class CassandraMetadataRepository StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) // .setColumnNames( "projectId" ) // - .addEqualsExpression( "repositoryId", repoId ) // + .addEqualsExpression( "repositoryName", repoId ) // .addEqualsExpression( "namespaceId", namespace ) // .execute(); 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 a5c212e48..2a51a1e7b 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 @@ -125,8 +125,8 @@ public class DefaultCassandraArchivaManager namespace.addColumnDefinition( nameColumn ); BasicColumnDefinition repositoryIdColumn = new BasicColumnDefinition(); - repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryId" ) ); - repositoryIdColumn.setIndexName( "repositoryId" ); + repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName" ) ); + repositoryIdColumn.setIndexName( "repositoryName" ); repositoryIdColumn.setIndexType( ColumnIndexType.KEYS ); repositoryIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); namespace.addColumnDefinition( repositoryIdColumn ); @@ -142,8 +142,8 @@ public class DefaultCassandraArchivaManager cfds.add( repository ); BasicColumnDefinition nameColumn = new BasicColumnDefinition(); - nameColumn.setName( StringSerializer.get().toByteBuffer( "name" ) ); - nameColumn.setIndexName( "name" ); + nameColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName" ) ); + nameColumn.setIndexName( "repositoryName" ); nameColumn.setIndexType( ColumnIndexType.KEYS ); nameColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); repository.addColumnDefinition( nameColumn ); @@ -168,8 +168,8 @@ public class DefaultCassandraArchivaManager project.addColumnDefinition( projectIdColumn ); BasicColumnDefinition repositoryIdColumn = new BasicColumnDefinition(); - repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryId" ) ); - repositoryIdColumn.setIndexName( "repositoryId" ); + repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName" ) ); + repositoryIdColumn.setIndexName( "repositoryName" ); repositoryIdColumn.setIndexType( ColumnIndexType.KEYS ); repositoryIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); project.addColumnDefinition( repositoryIdColumn ); 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 ca1586537..c500c7b97 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 @@ -292,7 +292,7 @@ public class ArtifactMetadataModel public KeyBuilder withNamespace( Namespace namespace ) { this.namespaceId = namespace.getName(); - this.repositoryId = namespace.getRepository().getId(); + this.repositoryId = namespace.getRepository().getName(); return this; } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java index 27a9e7499..390e7e90f 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java @@ -21,7 +21,6 @@ package org.apache.archiva.metadata.repository.cassandra.model; import org.apache.archiva.metadata.repository.cassandra.CassandraUtils; -import javax.persistence.Entity; import java.io.Serializable; @@ -35,8 +34,6 @@ public class Namespace private String name; - private String repositoryId; - private String repositoryName; public Namespace() @@ -48,7 +45,6 @@ public class Namespace public Namespace( String id, Repository repository ) { this.name = id; - this.repositoryId = repository.getId(); this.repositoryName = repository.getName(); } @@ -65,12 +61,11 @@ public class Namespace public Repository getRepository() { - return new Repository(this.repositoryId); + return new Repository( this.repositoryName ); } public void setRepository( Repository repository ) { - this.repositoryId = repository.getId(); this.repositoryName = repository.getName(); } @@ -92,7 +87,7 @@ public class Namespace { return false; } - if ( !repositoryId.equals( namespace.repositoryId ) ) + if ( !repositoryName.equals( namespace.repositoryName ) ) { return false; } @@ -104,7 +99,7 @@ public class Namespace public int hashCode() { int result = name.hashCode(); - result = 31 * result + repositoryId.hashCode(); + result = 31 * result + repositoryName.hashCode(); return result; } @@ -113,7 +108,7 @@ public class Namespace { final StringBuilder sb = new StringBuilder( "Namespace{" ); sb.append( ", name='" ).append( name ).append( '\'' ); - sb.append( ", repository='" ).append( repositoryId ).append( '\'' ); + sb.append( ", repository='" ).append( repositoryName ).append( '\'' ); sb.append( '}' ); return sb.toString(); } @@ -133,7 +128,7 @@ public class Namespace public KeyBuilder withNamespace( Namespace namespace ) { this.namespace = namespace.getName(); - this.repositoryId = namespace.getRepository().getId(); + this.repositoryId = namespace.getRepository().getName(); return this; } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java index e1160a98f..b083529c8 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java @@ -39,7 +39,7 @@ import java.util.List; */ public class ProjectVersionMetadataModel { - // repositoryId + namespace + projectId + id (version) + // repositoryName + namespace + projectId + id (version) @Id private String rowId; @@ -295,7 +295,7 @@ public class ProjectVersionMetadataModel private String namespace; - private String repositoryId; + private String repositoryName; private String projectId; @@ -309,7 +309,7 @@ public class ProjectVersionMetadataModel public KeyBuilder withNamespace( Namespace namespace ) { this.namespace = namespace.getName(); - this.repositoryId = namespace.getRepository().getId(); + this.repositoryName = namespace.getRepository().getName(); return this; } @@ -321,13 +321,13 @@ public class ProjectVersionMetadataModel public KeyBuilder withRepository( String repositoryId ) { - this.repositoryId = repositoryId; + this.repositoryName = repositoryId; return this; } public KeyBuilder withRepository( Repository repository ) { - this.repositoryId = repository.getId(); + this.repositoryName = repository.getName(); return this; } @@ -346,7 +346,7 @@ public class ProjectVersionMetadataModel public String build() { // FIXME add some controls - return CassandraUtils.generateKey( this.repositoryId, this.namespace, this.projectId, this.id ); + return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.id ); } } }