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.model.CiManagement;
24 import org.apache.archiva.metadata.model.Dependency;
25 import org.apache.archiva.metadata.model.IssueManagement;
26 import org.apache.archiva.metadata.model.License;
27 import org.apache.archiva.metadata.model.MailingList;
28 import org.apache.archiva.metadata.model.Organization;
29 import org.apache.archiva.metadata.model.Scm;
30 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
32 import javax.persistence.Column;
33 import javax.persistence.Entity;
34 import javax.persistence.Id;
35 import java.util.ArrayList;
36 import java.util.List;
39 * @author Olivier Lamy
42 public class ProjectVersionMetadataModel
44 // repositoryId + namespace + projectId + id (version)
46 @Serializer( HugeStringSerializer.class )
49 @Column( name = "namespace" )
50 private Namespace namespace;
55 @Column( name = "id" )
56 @Serializer( HugeStringSerializer.class )
59 @Column( name = "projectId" )
60 @Serializer( HugeStringSerializer.class )
61 private String projectId;
63 @Column( name = "url" )
64 @Serializer( HugeStringSerializer.class )
67 @Column( name = "name" )
68 @Serializer( HugeStringSerializer.class )
71 @Column( name = "description" )
72 @Serializer( HugeStringSerializer.class )
73 private String description;
75 @Column( name = "organization" )
76 private Organization organization;
78 @Column( name = "issueManagement" )
79 private IssueManagement issueManagement;
81 @Column( name = "scm" )
84 @Column( name = "ciManagement" )
85 private CiManagement ciManagement;
87 // FIXME store those values in a separate table
88 @Column( name = "licenses" )
89 private List<License> licenses = new ArrayList<License>();
91 @Column( name = "mailingLists" )
92 private List<MailingList> mailingLists = new ArrayList<MailingList>();
94 @Column( name = "dependencies" )
95 private List<Dependency> dependencies = new ArrayList<Dependency>();
97 @Column( name = "incomplete" )
98 private boolean incomplete;
100 public String getProjectId()
105 public void setProjectId( String projectId )
107 this.projectId = projectId;
110 public String getRowId()
115 public void setRowId( String rowId )
120 // FIXME must be renamed getVersion !!!
121 public String getId()
126 public void setId( String id )
131 public String getUrl()
136 public void setUrl( String url )
141 public String getName()
146 public void setName( String name )
151 public String getDescription()
156 public void setDescription( String description )
158 this.description = description;
161 public Organization getOrganization()
166 public void setOrganization( Organization organization )
168 this.organization = organization;
171 public IssueManagement getIssueManagement()
173 return issueManagement;
176 public void setIssueManagement( IssueManagement issueManagement )
178 this.issueManagement = issueManagement;
186 public void setScm( Scm scm )
191 public CiManagement getCiManagement()
196 public void setCiManagement( CiManagement ciManagement )
198 this.ciManagement = ciManagement;
201 public boolean isIncomplete()
206 public void setIncomplete( boolean incomplete )
208 this.incomplete = incomplete;
211 public Namespace getNamespace()
216 public void setNamespace( Namespace namespace )
218 this.namespace = namespace;
221 public List<License> getLicenses()
226 public void setLicenses( List<License> licenses )
228 this.licenses = licenses;
231 public List<MailingList> getMailingLists()
236 public void setMailingLists( List<MailingList> mailingLists )
238 this.mailingLists = mailingLists;
241 public List<Dependency> getDependencies()
246 public void setDependencies( List<Dependency> dependencies )
248 this.dependencies = dependencies;
253 public String toString()
255 final StringBuilder sb = new StringBuilder( "ProjectVersionMetadataModel{" );
256 sb.append( "rowId='" ).append( rowId ).append( '\'' );
257 sb.append( ", namespace=" ).append( namespace );
258 sb.append( ", id='" ).append( id ).append( '\'' );
259 sb.append( ", projectId='" ).append( projectId ).append( '\'' );
260 sb.append( ", url='" ).append( url ).append( '\'' );
261 sb.append( ", name='" ).append( name ).append( '\'' );
262 sb.append( ", description='" ).append( description ).append( '\'' );
263 sb.append( ", organization=" ).append( organization );
264 sb.append( ", issueManagement=" ).append( issueManagement );
265 sb.append( ", scm=" ).append( scm );
266 sb.append( ", ciManagement=" ).append( ciManagement );
267 sb.append( ", incomplete=" ).append( incomplete );
269 return sb.toString();
273 public boolean equals( Object o )
279 if ( o == null || getClass() != o.getClass() )
284 ProjectVersionMetadataModel that = (ProjectVersionMetadataModel) o;
286 if ( !rowId.equals( that.rowId ) )
296 public int hashCode()
298 return rowId.hashCode();
301 public static class KeyBuilder
304 private String namespace;
306 private String repositoryId;
308 private String projectId;
317 public KeyBuilder withNamespace( Namespace namespace )
319 this.namespace = namespace.getName();
320 this.repositoryId = namespace.getRepository().getId();
324 public KeyBuilder withNamespace( String namespace )
326 this.namespace = namespace;
330 public KeyBuilder withRepository( String repositoryId )
332 this.repositoryId = repositoryId;
336 public KeyBuilder withRepository( Repository repository )
338 this.repositoryId = repository.getId();
342 public KeyBuilder withProjectId( String projectId )
344 this.projectId = projectId;
348 public KeyBuilder withId( String id )
354 public String build()
356 // FIXME add some controls
357 return CassandraUtils.generateKey( this.repositoryId, this.namespace, this.projectId, this.id );