1 package org.apache.archiva.metadata.repository.cassandra.model;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import com.netflix.astyanax.entitystore.Serializer;
23 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.Id;
28 import java.io.Serializable;
31 * @author Olivier Lamy
35 implements Serializable
38 @Column( name = "projectKey" )
39 @Serializer( HugeStringSerializer.class )
40 private String projectKey;
42 @Column( name = "projectId" )
43 @Serializer( HugeStringSerializer.class )
44 private String projectId;
47 @Column( name = "repository" )
48 private Namespace namespace;
55 public Project( String projectKey, String projectId, Namespace namespace )
57 this.projectId = projectId;
58 this.projectKey = projectKey;
59 this.namespace = namespace;
62 public String getProjectKey()
67 public void setProjectKey( String projectKey )
69 this.projectKey = projectKey;
72 public Namespace getNamespace()
77 public void setNamespace( Namespace namespace )
79 this.namespace = namespace;
82 public String getProjectId()
87 public void setProjectId( String projectId )
89 this.projectId = projectId;
93 public boolean equals( Object o )
99 if ( o == null || getClass() != o.getClass() )
104 Project project = (Project) o;
106 if ( !projectKey.equals( project.projectKey ) )
110 if ( !namespace.equals( project.namespace ) )
119 public int hashCode()
121 int result = projectKey.hashCode();
122 result = 31 * result + namespace.hashCode();
127 public String toString()
129 final StringBuilder sb = new StringBuilder( "Project{" );
130 sb.append( "projectKey='" ).append( projectKey ).append( '\'' );
131 sb.append( ", projectId='" ).append( projectId ).append( '\'' );
132 sb.append( ", namespace=" ).append( namespace );
134 return sb.toString();
137 public static class KeyBuilder
140 private Namespace namespace;
142 private String projectId;
149 public KeyBuilder withNamespace( Namespace namespace )
151 this.namespace = namespace;
155 public KeyBuilder withProjectId( String projectId )
157 this.projectId = projectId;
162 public String build()
164 // FIXME add some controls
165 return CassandraUtils.generateKey( new Namespace.KeyBuilder().withNamespace( this.namespace ).build(),