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