You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
package de.superx.access; |
|
|
|
import org.junit.Ignore; |
|
|
|
import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
|
import net.sf.jsqlparser.statement.select.Select; |
|
|
|
@Ignore |
|
public class TestSqlRestrictionProvider implements SqlRestrictionProvider { |
|
|
|
@Override |
|
public Select getRestriction(String username, String userrole, String schemaName, String tableName, int orgunitLid) { |
|
try { |
|
String sql = ""; |
|
if (username.equals("linde") && schemaName.equals("presentation")) { |
|
if (tableName.equals("fact_application")) { |
|
sql = String.format( |
|
"(SELECT * FROM %s.%s WHERE person_id IN (SELECT id FROM presentation.dim_person WHERE gender != 'männlich')) AS %s", |
|
schemaName, tableName, tableName); |
|
} else if (tableName.equals("dim_person_applicant")) { |
|
sql = String.format( |
|
"(SELECT * FROM %s.%s) AS %s", |
|
schemaName, tableName, tableName); |
|
} else if (tableName.equals("dim_date")) { |
|
sql = String.format( |
|
"(SELECT * FROM %s.%s) AS %s", |
|
schemaName, tableName, tableName); |
|
} else if (tableName.equals("dim_requestsubject_data")) { |
|
sql = String.format( |
|
"(SELECT * FROM %s.%s) AS %s", |
|
schemaName, tableName, tableName); |
|
} |
|
} |
|
Select select = (Select)CCJSqlParserUtil.parse(sql); |
|
return select; |
|
} catch (Exception e) { |
|
System.out.println("bla"); |
|
} |
|
return null; |
|
} |
|
|
|
}
|
|
|