This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.metadata.repository.cassandra.model;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.metadata.model.CiManagement;
023import org.apache.archiva.metadata.model.Dependency;
024import org.apache.archiva.metadata.model.IssueManagement;
025import org.apache.archiva.metadata.model.License;
026import org.apache.archiva.metadata.model.MailingList;
027import org.apache.archiva.metadata.model.Organization;
028import org.apache.archiva.metadata.model.Scm;
029import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
030
031import java.util.ArrayList;
032import java.util.List;
033
034/**
035 * @author Olivier Lamy
036 * @since 2.0.0
037 */
038public class ProjectVersionMetadataModel
039{
040    private Namespace namespace;
041
042    private String id;
043
044    private String projectId;
045
046    private String url;
047
048    private String name;
049
050    private String description;
051
052    private Organization organization;
053
054    private IssueManagement issueManagement;
055
056    private Scm scm;
057
058    private CiManagement ciManagement;
059
060    private List<License> licenses = new ArrayList<>();
061
062    private List<MailingList> mailingLists = new ArrayList<>();
063
064    private List<Dependency> dependencies = new ArrayList<>();
065
066    private boolean incomplete;
067
068    public String getProjectId()
069    {
070        return projectId;
071    }
072
073    public void setProjectId( String projectId )
074    {
075        this.projectId = projectId;
076    }
077
078    // FIXME must be renamed getVersion !!!
079    public String getId()
080    {
081        return id;
082    }
083
084    public void setId( String id )
085    {
086        this.id = id;
087    }
088
089    public String getUrl()
090    {
091        return url;
092    }
093
094    public void setUrl( String url )
095    {
096        this.url = url;
097    }
098
099    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}