-
Notifications
You must be signed in to change notification settings - Fork 14
/
SoqlOrderParam.java
41 lines (32 loc) · 1.07 KB
/
SoqlOrderParam.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cz.cvut.kbss.jopa.query.soql;
public class SoqlOrderParam extends SoqlParam{
private String orderingBy ;
private SoqlAttribute attribute;
public SoqlOrderParam(SoqlNode firstNode, String orderingBy) {
super();
this.setFirstNode(firstNode);
this.orderingBy = orderingBy.isEmpty() ? "ASC" : orderingBy;
}
public String getOrderingBy() {
return orderingBy;
}
public void setOrderingBy(String orderingBy) {
this.orderingBy = orderingBy;
}
public SoqlAttribute getAttribute() {
return attribute;
}
public void setAttribute(SoqlAttribute attribute) {
this.attribute = attribute;
}
public String getOrderByPart(){
String param = attribute.isFilter() ? getAsParam().substring(1) : attribute.getValue().substring(1);
StringBuilder sb = new StringBuilder();
if(orderingBy.equals("ASC")){
sb.append("?").append(param);
}else{
sb.append("DESC(?").append(param).append(")");
}
return sb.toString();
}
}