1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.query.xwql.internal.hql; |
21 |
|
|
22 |
|
import org.xwiki.query.jpql.node.APath; |
23 |
|
import org.xwiki.query.jpql.node.PPath; |
24 |
|
import org.xwiki.query.jpql.node.PSelectExpression; |
25 |
|
import org.xwiki.query.jpql.node.TId; |
26 |
|
import org.xwiki.query.xwql.internal.QueryContext.PropertyInfo; |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 5 |
Complexity Density: 0.38 |
|
28 |
|
public class PropertyPrinter |
29 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
30 |
149 |
void print(PropertyInfo prop, Printer printer) throws Exception... |
31 |
|
{ |
32 |
149 |
if (prop.isCustomMapped()) { |
33 |
|
|
34 |
2 |
for (PPath p : prop.locations) { |
35 |
2 |
p.replaceBy(new APath(new TId(prop.object.customMappingAlias + "." + prop.name))); |
36 |
|
} |
37 |
|
} else { |
38 |
|
|
39 |
147 |
String className = prop.getType(); |
40 |
147 |
if (className != null) { |
41 |
109 |
prop.alias = printer.getContext().getAliasGenerator().generate(prop.object.alias + "_" + prop.name); |
42 |
109 |
printer.from.append(", ").append(className).append(" as ").append(prop.alias); |
43 |
109 |
printer.where.append(" and ").append(prop.alias).append(".id.id=").append(prop.object.alias) |
44 |
|
.append(".id").append(" and ").append(prop.alias).append(".id.name").append("='").append(prop.name) |
45 |
|
.append("'"); |
46 |
|
|
47 |
109 |
for (PPath p : prop.locations) { |
48 |
132 |
String s = prop.alias + "." + prop.getValueField(); |
49 |
132 |
if (className.endsWith("DBStringListProperty") && p.parent() instanceof PSelectExpression) { |
50 |
1 |
s = "elements(" + s + ")"; |
51 |
|
} |
52 |
132 |
p.replaceBy(new APath(new TId(s))); |
53 |
|
} |
54 |
|
} |
55 |
|
} |
56 |
|
} |
57 |
|
} |