Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » [Mars] [HowTO] Row-Level Granting(Permission to see certain Records)
[Mars] [HowTO] Row-Level Granting [message #1719683] Mon, 11 January 2016 12:57
barust Mising name is currently offline barust Mising nameFriend
Messages: 57
Registered: February 2014
Member
Hi, all

Maybe it will be useful to somebody.

If you have completed all the stages of the authorization by the Tutorial and HowTo, like this:
http://wiki.eclipse.org/Scout/Tutorial/5.0/Minicrm/Permissions
http://wiki.eclipse.org/Scout/HowTo/5.0/Create_Permissions
and would like to use Row-Level Granting control by SQL. I think it will help you.
I used the Basic Access Permission approach rather than Fine-Grained Access Permissions.

For instance, I have 2 tables:
- PERSON table with columns (PERSON_NR, LAST_NAME, FIRST_NAME, USERNAME, PODR_ID)
- PODR table with columns (PODR_ID, NAME)
and I want to show the row (PODR table) in accordance with the authorized user (PERSON table).
In Service Operation getPodrTableData() of StandardOutlineService I added the following:
@Override
  public PodrTablePageData getPodrTableData() throws ProcessingException {

    String userName = ServerSession.get().getUserId();

    PodrTablePageData pageData = new PodrTablePageData();

    SQL.selectInto("" +
        "SELECT P.PODR_ID, P.NAME, PR.PERSON_NR, PR.USERNAME " +
        "FROM  PODR P, PERSON PR " +
        "WHERE P.PODR_ID = PR.PODR_ID " +
        "AND PR.USERNAME = :username " +
        "INTO :{page.podrNr},:{page.podr},:{page.personNr},:{page.username}",
        new NVPair("username", userName), new NVPair("page", pageData));

    return pageData;
  }

Here, the following significant lines:
- String userName = ServerSession.get().getUserId();

- "WHERE P.PODR_ID = PR.PODR_ID "

- "AND PR.USERNAME = :username "

- new NVPair("username", userName)

That's all.
It turns out that simple.

P.S.: If you are a newbie, spend some time and read this book by Matthias Zimmermann :
https://tools.bsiag.com/scoutbook/4.0/latest/pdf/
Sometimes it helps!
Previous Topic:[Neon] [SDK] contribute a patch to the "New project" template
Next Topic:[Neon] Change DateUtility.parse(String, String) not to parse dates leniently
Goto Forum:
  


Current Time: Fri Apr 26 05:05:32 GMT 2024

Powered by FUDForum. Page generated in 0.05006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top