1 | |
package org.apache.archiva.indexer.search; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.commons.lang.StringUtils; |
23 | |
import org.apache.maven.archiva.model.ArchivaArtifact; |
24 | |
|
25 | |
import java.util.ArrayList; |
26 | |
import java.util.List; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class SearchResultHit |
34 | |
{ |
35 | |
|
36 | |
private String context; |
37 | |
|
38 | |
|
39 | |
private String url; |
40 | |
|
41 | |
|
42 | |
private String groupId; |
43 | |
|
44 | |
|
45 | |
private String artifactId; |
46 | |
|
47 | |
|
48 | 0 | private String version = ""; |
49 | |
|
50 | 0 | private String repositoryId = ""; |
51 | |
|
52 | 0 | private List<String> versions = new ArrayList<String>(); |
53 | |
|
54 | |
private ArchivaArtifact artifact; |
55 | |
|
56 | |
public String getContext() |
57 | |
{ |
58 | 0 | return context; |
59 | |
} |
60 | |
|
61 | |
public void setContext( String context ) |
62 | |
{ |
63 | 0 | this.context = context; |
64 | 0 | } |
65 | |
|
66 | |
public String getUrl() |
67 | |
{ |
68 | 0 | return url; |
69 | |
} |
70 | |
|
71 | |
public void setUrl( String url ) |
72 | |
{ |
73 | 0 | this.url = url; |
74 | 0 | } |
75 | |
|
76 | |
public String getUrlFilename() |
77 | |
{ |
78 | 0 | return this.url.substring( this.url.lastIndexOf( '/' ) ); |
79 | |
} |
80 | |
|
81 | |
public String getArtifactId() |
82 | |
{ |
83 | 0 | return artifactId; |
84 | |
} |
85 | |
|
86 | |
public void setArtifactId( String artifactId ) |
87 | |
{ |
88 | 0 | this.artifactId = artifactId; |
89 | 0 | } |
90 | |
|
91 | |
public void setArtifact( ArchivaArtifact artifact ) |
92 | |
{ |
93 | 0 | this.artifact = artifact; |
94 | 0 | final String ver = artifact.getVersion(); |
95 | |
|
96 | 0 | if ( !this.versions.contains( ver ) ) |
97 | |
{ |
98 | 0 | this.versions.add( ver ); |
99 | |
} |
100 | |
|
101 | 0 | if ( StringUtils.isBlank( this.groupId ) ) |
102 | |
{ |
103 | 0 | this.groupId = artifact.getGroupId(); |
104 | |
} |
105 | |
|
106 | 0 | if ( StringUtils.isBlank( this.artifactId ) ) |
107 | |
{ |
108 | 0 | this.artifactId = artifact.getArtifactId(); |
109 | |
} |
110 | |
|
111 | 0 | if ( StringUtils.isBlank( this.version ) ) |
112 | |
{ |
113 | 0 | this.version = ver; |
114 | |
} |
115 | 0 | } |
116 | |
|
117 | |
public ArchivaArtifact getArtifact() |
118 | |
{ |
119 | 0 | return artifact; |
120 | |
} |
121 | |
|
122 | |
public String getGroupId() |
123 | |
{ |
124 | 0 | return groupId; |
125 | |
} |
126 | |
|
127 | |
public void setGroupId( String groupId ) |
128 | |
{ |
129 | 0 | this.groupId = groupId; |
130 | 0 | } |
131 | |
|
132 | |
public String getVersion() |
133 | |
{ |
134 | 0 | return version; |
135 | |
} |
136 | |
|
137 | |
public void setVersion(String version) |
138 | |
{ |
139 | 0 | this.version = version; |
140 | 0 | } |
141 | |
|
142 | |
public List<String> getVersions() |
143 | |
{ |
144 | 0 | return versions; |
145 | |
} |
146 | |
|
147 | |
public void setVersions(List<String> versions) |
148 | |
{ |
149 | 0 | this.versions = versions; |
150 | 0 | } |
151 | |
|
152 | |
public String getRepositoryId() |
153 | |
{ |
154 | 0 | return repositoryId; |
155 | |
} |
156 | |
|
157 | |
public void setRepositoryId( String repositoryId ) |
158 | |
{ |
159 | 0 | this.repositoryId = repositoryId; |
160 | 0 | } |
161 | |
|
162 | |
public void addVersion( String version ) |
163 | |
{ |
164 | 0 | if( versions == null ) |
165 | |
{ |
166 | 0 | versions = new ArrayList<String>(); |
167 | |
} |
168 | |
|
169 | 0 | versions.add( version ); |
170 | 0 | } |
171 | |
} |