@Override
  public Set<DomainCreatePermission> getDomainCreatePostCreateSysPermissions(
      SQLConnection connection, Resource accessorResource) {
    SQLStatement statement = null;

    try {
      statement =
          connection.prepareStatement(
              sqlStrings
                  .SQL_findInGrantDomainCreatePermissionPostCreateSys_withoutInheritance_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID);
      statement.setResourceId(1, accessorResource);
      SQLResult resultSet = statement.executeQuery();

      // collect the create permissions that this resource has to domains directly
      Set<DomainCreatePermission> domainCreatePermissions = new HashSet<>();
      while (resultSet.next()) {
        domainCreatePermissions.add(getDomainCreatePostCreateSysPermission(resultSet));
      }
      resultSet.close();

      return domainCreatePermissions;
    } catch (SQLException e) {
      throw new RuntimeException(e);
    } finally {
      closeStatement(statement);
    }
  }
コード例 #2
0
  public StackPane decorateTable(SQLResult sqlResult) {
    TableLoader tableLoader = sqlResult.getResultTableLoader();

    TableView tv = new TableView();
    RightMouseMenuHandler sqlResultRightMouseMenuHandler = new RightMouseMenuHandler(tv);
    ExtendedTableSelectionHandler extendedTableSelectionHandler =
        doStandardConfigs(tableLoader, tv, sqlResultRightMouseMenuHandler);

    if (null != _editButtonCtrl && _editButtonCtrl.allowsEditing()) {
      _editButtonCtrl.displayAndPrepareEditing(sqlResult, tv);

      sqlResultRightMouseMenuHandler.addSeparator();
      MenuItem mnuDeleteRows =
          sqlResultRightMouseMenuHandler.addMenu(
              new I18n(getClass()).t("sqlresult.popup.delete.selected.rows"),
              () -> _editButtonCtrl.deleteSelectedRows());

      _editButtonCtrl.setDeleteRowsMenuItem(mnuDeleteRows);

    } else {
      tableLoader.load(tv);
    }

    return extendedTableSelectionHandler.getStackPane();
  }
  protected static DomainCreatePermission getDomainCreatePostCreateSysPermission(
      SQLResult resultSet) throws SQLException {
    final DomainPermission postCreatePermission;
    final String postCreateSysPermissionName =
        resultSet.getDomainSysPermissionName("PostCreateSysPermissionId");

    if (resultSet.getBoolean("PostCreateIsWithGrant")) {
      postCreatePermission =
          DomainPermissions.getInstanceWithGrantOption(postCreateSysPermissionName);
    } else {
      postCreatePermission = DomainPermissions.getInstance(postCreateSysPermissionName);
    }

    if (resultSet.getBoolean("IsWithGrant")) {
      return DomainCreatePermissions.getInstanceWithGrantOption(postCreatePermission);
    } else {
      return DomainCreatePermissions.getInstance(postCreatePermission);
    }
  }