This project has retired. For details please refer to its Attic page.
ProjectVersionMetadataModel xref
View Javadoc
1   package org.apache.archiva.metadata.repository.cassandra.model;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
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;
29  import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
30  
31  import java.util.ArrayList;
32  import java.util.List;
33  
34  /**
35   * @author Olivier Lamy
36   * @since 2.0.0
37   */
38  public class ProjectVersionMetadataModel
39  {
40      private Namespace namespace;
41  
42      private String id;
43  
44      private String projectId;
45  
46      private String url;
47  
48      private String name;
49  
50      private String description;
51  
52      private Organization organization;
53  
54      private IssueManagement issueManagement;
55  
56      private Scm scm;
57  
58      private CiManagement ciManagement;
59  
60      private List<License> licenses = new ArrayList<>();
61  
62      private List<MailingList> mailingLists = new ArrayList<>();
63  
64      private List<Dependency> dependencies = new ArrayList<>();
65  
66      private boolean incomplete;
67  
68      public String getProjectId()
69      {
70          return projectId;
71      }
72  
73      public void setProjectId( String projectId )
74      {
75          this.projectId = projectId;
76      }
77  
78      // FIXME must be renamed getVersion !!!
79      public String getId()
80      {
81          return id;
82      }
83  
84      public void setId( String id )
85      {
86          this.id = id;
87      }
88  
89      public String getUrl()
90      {
91          return url;
92      }
93  
94      public void setUrl( String url )
95      {
96          this.url = url;
97      }
98  
99      public String getName()
100     {
101         return name;
102     }
103 
104     public void setName( String name )
105     {
106         this.name = name;
107     }
108 
109     public String getDescription()
110     {
111         return description;
112     }
113 
114     public void setDescription( String description )
115     {
116         this.description = description;
117     }
118 
119     public Organization getOrganization()
120     {
121         return organization;
122     }
123 
124     public void setOrganization( Organization organization )
125     {
126         this.organization = organization;
127     }
128 
129     public IssueManagement getIssueManagement()
130     {
131         return issueManagement;
132     }
133 
134     public void setIssueManagement( IssueManagement issueManagement )
135     {
136         this.issueManagement = issueManagement;
137     }
138 
139     public Scm getScm()
140     {
141         return scm;
142     }
143 
144     public void setScm( Scm scm )
145     {
146         this.scm = scm;
147     }
148 
149     public CiManagement getCiManagement()
150     {
151         return ciManagement;
152     }
153 
154     public void setCiManagement( CiManagement ciManagement )
155     {
156         this.ciManagement = ciManagement;
157     }
158 
159     public boolean isIncomplete()
160     {
161         return incomplete;
162     }
163 
164     public void setIncomplete( boolean incomplete )
165     {
166         this.incomplete = incomplete;
167     }
168 
169     public Namespace getNamespace()
170     {
171         return namespace;
172     }
173 
174     public void setNamespace( Namespace namespace )
175     {
176         this.namespace = namespace;
177     }
178 
179     public List<License> getLicenses()
180     {
181         return licenses;
182     }
183 
184     public void setLicenses( List<License> licenses )
185     {
186         this.licenses = licenses;
187     }
188 
189     public List<MailingList> getMailingLists()
190     {
191         return mailingLists;
192     }
193 
194     public void setMailingLists( List<MailingList> mailingLists )
195     {
196         this.mailingLists = mailingLists;
197     }
198 
199     public List<Dependency> getDependencies()
200     {
201         return dependencies;
202     }
203 
204     public void setDependencies( List<Dependency> dependencies )
205     {
206         this.dependencies = dependencies;
207     }
208 
209 
210     @Override
211     public String toString()
212     {
213         final StringBuilder sb = new StringBuilder( "ProjectVersionMetadataModel{" );
214         sb.append( ", namespace=" ).append( namespace );
215         sb.append( ", id='" ).append( id ).append( '\'' );
216         sb.append( ", projectId='" ).append( projectId ).append( '\'' );
217         sb.append( ", url='" ).append( url ).append( '\'' );
218         sb.append( ", name='" ).append( name ).append( '\'' );
219         sb.append( ", description='" ).append( description ).append( '\'' );
220         sb.append( ", organization=" ).append( organization );
221         sb.append( ", issueManagement=" ).append( issueManagement );
222         sb.append( ", scm=" ).append( scm );
223         sb.append( ", ciManagement=" ).append( ciManagement );
224         sb.append( ", incomplete=" ).append( incomplete );
225         sb.append( '}' );
226         return sb.toString();
227     }
228 
229 
230     public static class KeyBuilder
231     {
232 
233         private String namespace;
234 
235         private String repositoryName;
236 
237         private String projectId;
238 
239         private String projectVersion;
240 
241         private String id;
242 
243         public KeyBuilder()
244         {
245             // no op
246         }
247 
248         public KeyBuilder withNamespace( Namespace namespace )
249         {
250             this.namespace = namespace.getName();
251             this.repositoryName = namespace.getRepository().getName();
252             return this;
253         }
254 
255         public KeyBuilder withNamespace( String namespace )
256         {
257             this.namespace = namespace;
258             return this;
259         }
260 
261         public KeyBuilder withRepository( String repositoryId )
262         {
263             this.repositoryName = repositoryId;
264             return this;
265         }
266 
267         public KeyBuilder withProjectId( String projectId )
268         {
269             this.projectId = projectId;
270             return this;
271         }
272 
273         public KeyBuilder withProjectVersion( String projectVersion )
274         {
275             this.projectVersion = projectVersion;
276             return this;
277         }
278 
279         public KeyBuilder withId( String id )
280         {
281             this.id = id;
282             return this;
283         }
284 
285         public String build()
286         {
287             // FIXME add some controls
288             return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.projectVersion,
289                                                this.id );
290         }
291     }
292 }