1 | |
package org.apache.maven.archiva.database.constraints; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.archiva.database.DeclarativeConstraint; |
23 | |
import org.apache.maven.archiva.model.ArchivaArtifact; |
24 | |
import org.apache.maven.archiva.model.Dependency; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class ProjectsByArtifactUsageConstraint |
32 | |
extends AbstractDeclarativeConstraint |
33 | |
implements DeclarativeConstraint |
34 | |
{ |
35 | |
private String filter; |
36 | |
|
37 | |
public ProjectsByArtifactUsageConstraint( ArchivaArtifact artifact ) |
38 | |
{ |
39 | 0 | this( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion() ); |
40 | 0 | } |
41 | |
|
42 | |
public ProjectsByArtifactUsageConstraint( String groupId, String artifactId, String version ) |
43 | 0 | { |
44 | 0 | super.declImports = new String[] { |
45 | |
"import " + Dependency.class.getName() |
46 | |
}; |
47 | |
|
48 | 0 | super.variables = new String[] { |
49 | |
"Dependency dep" |
50 | |
}; |
51 | |
|
52 | 0 | super.declParams = new String[] { |
53 | |
"String selectedGroupId", |
54 | |
"String selectedArtifactId", |
55 | |
"String selectedVersion" |
56 | |
}; |
57 | |
|
58 | 0 | filter = "dependencies.contains( dep ) && " + |
59 | |
"dep.groupId == selectedGroupId && " + |
60 | |
"dep.artifactId == selectedArtifactId && " + |
61 | |
"dep.version == selectedVersion"; |
62 | |
|
63 | 0 | super.params = new Object[] { groupId, artifactId, version }; |
64 | 0 | } |
65 | |
|
66 | |
public String getSortColumn() |
67 | |
{ |
68 | 0 | return "groupId"; |
69 | |
} |
70 | |
|
71 | |
public String getWhereCondition() |
72 | |
{ |
73 | 0 | return null; |
74 | |
} |
75 | |
|
76 | |
public String getFilter() |
77 | |
{ |
78 | 0 | return filter; |
79 | |
} |
80 | |
} |