OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SqlRevokeRole.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.SqlDdl;
8 import org.apache.calcite.sql.SqlIdentifier;
9 import org.apache.calcite.sql.SqlKind;
10 import org.apache.calcite.sql.SqlNode;
11 import org.apache.calcite.sql.SqlNodeList;
12 import org.apache.calcite.sql.SqlOperator;
13 import org.apache.calcite.sql.SqlSpecialOperator;
14 import org.apache.calcite.sql.parser.Span;
15 import org.apache.calcite.sql.parser.SqlParserPos;
17 
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Objects;
21 
22 public class SqlRevokeRole extends SqlDdl {
23  private static final SqlOperator OPERATOR =
24  new SqlSpecialOperator("REVOKE_ROLE", SqlKind.OTHER_DDL);
25  @Expose
26  private String command;
27  @Expose
28  private SqlNodeList roles;
29  @Expose
30  private SqlNodeList grantees;
31 
32  public SqlRevokeRole(SqlParserPos pos, SqlNodeList roles, SqlNodeList grantees) {
33  super(OPERATOR, pos);
34  requireNonNull(roles);
35  this.command = OPERATOR.getName();
36  this.roles = roles;
37  this.grantees = grantees;
38  }
39 
40  @Override
41  public List<SqlNode> getOperandList() {
42  return null;
43  }
44 
45  @Override
46  public String toString() {
48  Map<String, Object> map = jsonBuilder.map();
49 
50  if (this.roles != null) {
51  List<Object> roles_list = jsonBuilder.list();
52  for (SqlNode role : this.roles) {
53  roles_list.add(role.toString());
54  }
55  map.put("roles", roles_list);
56  }
57 
58  if (this.grantees != null) {
59  List<Object> grantee_list = jsonBuilder.list();
60  for (SqlNode grantee : this.grantees) {
61  grantee_list.add(grantee.toString());
62  }
63  map.put("grantees", grantee_list);
64  }
65 
66  map.put("command", "REVOKE_ROLE");
67  Map<String, Object> payload = jsonBuilder.map();
68  payload.put("payload", map);
69  return jsonBuilder.toJsonString(payload);
70  }
71 }
SqlRevokeRole(SqlParserPos pos, SqlNodeList roles, SqlNodeList grantees)