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.model.CiManagement;
23 import org.apache.archiva.metadata.model.Dependency;
24 import org.apache.archiva.metadata.model.IssueManagement;
25 import org.apache.archiva.metadata.model.License;
26 import org.apache.archiva.metadata.model.MailingList;
27 import org.apache.archiva.metadata.model.Organization;
28 import org.apache.archiva.metadata.model.Scm;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.Id;
33 import java.util.ArrayList;
34 import java.util.List;
37 * @author Olivier Lamy
40 public class ProjectVersionMetadataModel
42 // repositoryId + namespace + projectId + id (version)
46 @Column( name = "namespace" )
47 private Namespace namespace;
52 @Column( name = "id" )
55 @Column( name = "projectId" )
56 private String projectId;
61 @Column(name = "name")
64 @Column(name = "description")
65 private String description;
67 @Column(name = "organization")
68 private Organization organization;
70 @Column(name = "issueManagement")
71 private IssueManagement issueManagement;
76 @Column(name = "ciManagement")
77 private CiManagement ciManagement;
79 // FIXME store those values in a separate table
80 @Column(name = "licenses")
81 private List<License> licenses = new ArrayList<License>();
83 @Column(name = "mailingLists")
84 private List<MailingList> mailingLists = new ArrayList<MailingList>();
86 @Column(name = "dependencies")
87 private List<Dependency> dependencies = new ArrayList<Dependency>();
89 @Column(name = "incomplete")
90 private boolean incomplete;
92 public String getProjectId()
97 public void setProjectId( String projectId )
99 this.projectId = projectId;
102 public String getRowId()
107 public void setRowId( String rowId )
112 // FIXME must be renamed getVersion !!!
113 public String getId()
118 public void setId( String id )
123 public String getUrl()
128 public void setUrl( String url )
133 public String getName()
138 public void setName( String name )
143 public String getDescription()
148 public void setDescription( String description )
150 this.description = description;
153 public Organization getOrganization()
158 public void setOrganization( Organization organization )
160 this.organization = organization;
163 public IssueManagement getIssueManagement()
165 return issueManagement;
168 public void setIssueManagement( IssueManagement issueManagement )
170 this.issueManagement = issueManagement;
178 public void setScm( Scm scm )
183 public CiManagement getCiManagement()
188 public void setCiManagement( CiManagement ciManagement )
190 this.ciManagement = ciManagement;
193 public boolean isIncomplete()
198 public void setIncomplete( boolean incomplete )
200 this.incomplete = incomplete;
203 public Namespace getNamespace()
208 public void setNamespace( Namespace namespace )
210 this.namespace = namespace;
213 public List<License> getLicenses()
218 public void setLicenses( List<License> licenses )
220 this.licenses = licenses;
223 public List<MailingList> getMailingLists()
228 public void setMailingLists( List<MailingList> mailingLists )
230 this.mailingLists = mailingLists;
233 public List<Dependency> getDependencies()
238 public void setDependencies( List<Dependency> dependencies )
240 this.dependencies = dependencies;
245 public String toString()
247 final StringBuilder sb = new StringBuilder( "ProjectVersionMetadataModel{" );
248 sb.append( "rowId='" ).append( rowId ).append( '\'' );
249 sb.append( ", namespace=" ).append( namespace );
250 sb.append( ", id='" ).append( id ).append( '\'' );
251 sb.append( ", projectId='" ).append( projectId ).append( '\'' );
252 sb.append( ", url='" ).append( url ).append( '\'' );
253 sb.append( ", name='" ).append( name ).append( '\'' );
254 sb.append( ", description='" ).append( description ).append( '\'' );
255 sb.append( ", organization=" ).append( organization );
256 sb.append( ", issueManagement=" ).append( issueManagement );
257 sb.append( ", scm=" ).append( scm );
258 sb.append( ", ciManagement=" ).append( ciManagement );
259 sb.append( ", incomplete=" ).append( incomplete );
261 return sb.toString();
265 public boolean equals( Object o )
271 if ( o == null || getClass() != o.getClass() )
276 ProjectVersionMetadataModel that = (ProjectVersionMetadataModel) o;
278 if ( !rowId.equals( that.rowId ) )
288 public int hashCode()
290 return rowId.hashCode();
293 public static class KeyBuilder
296 private String namespace;
298 private String repositoryId;
300 private String projectId;
309 public KeyBuilder withNamespace( Namespace namespace )
311 this.namespace = namespace.getName();
312 this.repositoryId = namespace.getRepository().getId();
316 public KeyBuilder withNamespace( String namespace )
318 this.namespace = namespace;
322 public KeyBuilder withRepository( String repositoryId )
324 this.repositoryId = repositoryId;
328 public KeyBuilder withRepository( Repository repository )
330 this.repositoryId = repository.getId();
334 public KeyBuilder withProjectId( String projectId )
336 this.projectId = projectId;
340 public KeyBuilder withId( String id )
346 public String build()
348 // FIXME add some controls
349 return this.repositoryId + "-" + this.namespace + "-" + this.projectId + ( this.id == null