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 javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.Id;
27 * Cassandra storage model for {@link org.apache.archiva.metadata.model.MetadataFacet}
29 * @author Olivier Lamy
32 public class MetadataFacetModel
34 // id is repositoryId + namespaceId + projectId + facetId + name + mapKey
36 @Column( name = "id" )
39 @Column( name = "artifactMetadataModel" )
40 private ArtifactMetadataModel artifactMetadataModel;
42 @Column( name = "facetId" )
43 private String facetId;
45 @Column( name = "name" )
48 @Column( name = "key" )
51 @Column( name = "value" )
54 public MetadataFacetModel()
59 public MetadataFacetModel( String id, ArtifactMetadataModel artifactMetadataModel, String facetId, String key,
60 String value, String name )
63 this.artifactMetadataModel = artifactMetadataModel;
67 this.facetId = facetId;
70 public String getFacetId()
75 public void setFacetId( String facetId )
77 this.facetId = facetId;
85 public void setId( String id )
90 public ArtifactMetadataModel getArtifactMetadataModel()
92 return artifactMetadataModel;
95 public void setArtifactMetadataModel( ArtifactMetadataModel artifactMetadataModel )
97 this.artifactMetadataModel = artifactMetadataModel;
100 public String getName()
105 public void setName( String name )
110 public String getKey()
115 public void setKey( String key )
120 public String getValue()
125 public void setValue( String value )
131 public boolean equals( Object o )
137 if ( o == null || getClass() != o.getClass() )
142 MetadataFacetModel that = (MetadataFacetModel) o;
144 if ( !id.equals( that.id ) )
153 public int hashCode()
155 return id.hashCode();
159 public String toString()
161 final StringBuilder sb = new StringBuilder( "MetadataFacetModel{" );
162 sb.append( "id='" ).append( id ).append( '\'' );
163 sb.append( ", artifactMetadataModel=" ).append( artifactMetadataModel );
164 sb.append( ", key='" ).append( key ).append( '\'' );
165 sb.append( ", value='" ).append( value ).append( '\'' );
167 return sb.toString();
170 public static class KeyBuilder
173 private ArtifactMetadataModel artifactMetadataModel;
179 private String facetId;
181 private String repositoryId;
188 public KeyBuilder withArtifactMetadataModel( ArtifactMetadataModel artifactMetadataModel )
190 this.artifactMetadataModel = artifactMetadataModel;
194 public KeyBuilder withKey( String key )
200 public KeyBuilder withName( String name )
206 public KeyBuilder withFacetId( String facetId )
208 this.facetId = facetId;
212 public KeyBuilder withRepositoryId( String repositoryId )
214 this.repositoryId = repositoryId;
218 public String build()
220 // FIXME add some controls
221 // getArtifactMetadataModelId can have no namespace, no project and no projectid for statistics
222 // only repositoryId with artifactMetadataModel
223 return ( this.artifactMetadataModel == null
225 : this.artifactMetadataModel.getArtifactMetadataModelId() ) + "-" + this.facetId + "-" + this.name + "-"