OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SqlRevokePrivilege.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl;
2 
3 import static java.util.Objects.requireNonNull;
4 
5 import com.google.gson.annotations.Expose;
6 
7 import org.apache.calcite.sql.SqlCall;
8 import org.apache.calcite.sql.SqlDdl;
9 import org.apache.calcite.sql.SqlKind;
10 import org.apache.calcite.sql.SqlNode;
11 import org.apache.calcite.sql.SqlNodeList;
13 import org.apache.calcite.sql.SqlSpecialOperator;
14 import org.apache.calcite.sql.parser.SqlParserPos;
16 import org.apache.calcite.util.JsonBuilder;
17 
18 import java.util.List;
19 import java.util.Map;
20 
21 public class SqlRevokePrivilege extends SqlDdl {
22  private static final SqlOperator OPERATOR =
23  new SqlSpecialOperator("REVOKE_PRIVILEGE", SqlKind.OTHER_DDL);
24 
25  @Expose
26  private SqlNodeList privileges;
27  @Expose
28  private String type;
29  @Expose
30  private String target;
31  @Expose
32  private SqlNodeList grantees;
33 
34  public SqlRevokePrivilege(SqlParserPos pos,
35  SqlNodeList privileges,
36  String type,
37  String target,
38  SqlNodeList grantees) {
39  super(OPERATOR, pos);
40  requireNonNull(privileges);
41  this.privileges = privileges;
42  this.type = type;
43  this.target = target;
44  this.grantees = grantees;
45  }
46 
47  @Override
48  public List<SqlNode> getOperandList() {
49  return null;
50  }
51 
52  @Override
53  public String toString() {
55  Map<String, Object> map = jsonBuilder.map();
56 
57  if (this.privileges != null) {
58  List<Object> privilege_list = jsonBuilder.list();
59  for (SqlNode privilege : this.privileges) {
60  privilege_list.add(privilege.toString());
61  }
62  map.put("privileges", privilege_list);
63  }
64 
65  map.put("type", this.type);
66  map.put("target", this.target);
67 
68  if (this.grantees != null) {
69  List<Object> grantee_list = jsonBuilder.list();
70  for (SqlNode grantee : this.grantees) {
71  grantee_list.add(grantee.toString());
72  }
73  map.put("grantees", grantee_list);
74  }
75 
76  map.put("command", "REVOKE_PRIVILEGE");
77  Map<String, Object> payload = jsonBuilder.map();
78  payload.put("payload", map);
79  return jsonBuilder.toJsonString(payload);
80  }
81 }
SqlRevokePrivilege(SqlParserPos pos, SqlNodeList privileges, String type, String target, SqlNodeList grantees)