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 org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
24 import javax.persistence.Column;
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 = "artifactMetadataModel")
37 //private ArtifactMetadataModel artifactMetadataModel;
39 @Column(name = "facetId")
40 private String facetId;
45 @Column(name = "name")
48 @Column(name = "value")
51 private String projectVersion;
53 public MetadataFacetModel()
58 public MetadataFacetModel( String facetId, String key, String value, String name, String projectVersion )
63 this.facetId = facetId;
64 this.projectVersion = projectVersion;
67 public String getFacetId()
72 public void setFacetId( String facetId )
74 this.facetId = facetId;
78 public String getName()
83 public void setName( String name )
88 public String getKey()
93 public void setKey( String key )
98 public String getValue()
103 public void setValue( String value )
108 public String getProjectVersion()
110 return projectVersion;
113 public void setProjectVersion( String projectVersion )
115 this.projectVersion = projectVersion;
119 public String toString()
121 final StringBuilder sb = new StringBuilder( "MetadataFacetModel{" );
122 sb.append( ", key='" ).append( key ).append( '\'' );
123 sb.append( ", value='" ).append( value ).append( '\'' );
125 return sb.toString();
128 public static class KeyBuilder
131 private ArtifactMetadataModel artifactMetadataModel;
137 private String facetId;
139 private String repositoryId;
146 public KeyBuilder withArtifactMetadataModel( ArtifactMetadataModel artifactMetadataModel )
148 this.artifactMetadataModel = artifactMetadataModel;
152 public KeyBuilder withKey( String key )
158 public KeyBuilder withName( String name )
164 public KeyBuilder withFacetId( String facetId )
166 this.facetId = facetId;
170 public KeyBuilder withRepositoryId( String repositoryId )
172 this.repositoryId = repositoryId;
176 public String build()
178 // FIXME add some controls
179 // getArtifactMetadataModelId can have no namespace, no project and no projectid for statistics
180 // only repositoryId with artifactMetadataModel
181 String str = CassandraUtils.generateKey( this.artifactMetadataModel == null
183 : new ArtifactMetadataModel.KeyBuilder().withNamespace(
184 this.artifactMetadataModel.getNamespace() ) //
185 .withProject( this.artifactMetadataModel.getProject() ) //
187 this.artifactMetadataModel.getProjectVersion() ) //
189 this.artifactMetadataModel.getRepositoryId() ) //
190 .withId( this.artifactMetadataModel.getId() ) //