Skip to content
Snippets Groups Projects
Verified Commit 483ab16e authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Finalize MR

parent bcceeb66
Branches
Tags
No related merge requests found
......@@ -91,30 +91,19 @@ public class RoleFilter implements EntityFilterInterface {
final String targetSet,
final boolean versioned)
throws SQLException {
if (!sourceSet.equals("entities")) {
throw new UnsupportedOperationException("SourceSet is supposed to be the `entities` table.");
}
final String sql =
("INSERT IGNORE INTO `"
+ targetSet
+ (sourceSet.equals("entities")
? (versioned
? "` (id, _iversion) SELECT e.id, _get_head_iversion(e.id) FROM `entities` AS e WHERE e.role "
+ operator
+ " ? UNION SELECT a.id, a._iversion FROM `archive_entities` AS a WHERE a.role"
+ operator
+ "?"
: "` (id) SELECT e.id FROM `entities` AS e WHERE e.role" + operator + "?")
// FIXME The second branch is probably never run. Remove completely and raise an
// exception instead?
: (versioned
? "` (id, _iversion) SELECT s.id, s._iversion FROM `"
+ sourceSet
+ "` LEFT JOIN archive_entities AS a ON (s.id = a.id AND s._iversion = a._iversion) WHERE a.role"
+ operator
+ "? UNION SELECT s.id, s._iversion FROM `"
+ sourceSet
+ "` LEFT JOIN entities AS e ON (s.id = e.id) WHERE e.role"
+ operator
+ "? AND a._iversion = _get_head_iversion(s.id)"
: "` (id) SELECT e.id FROM `entities` AS e WHERE e.role = ?")));
+ (versioned
? "` (id, _iversion) SELECT e.id, _get_head_iversion(e.id) FROM `entities` AS e WHERE e.role "
+ operator
+ " ? UNION SELECT a.id, a._iversion FROM `archive_entities` AS a WHERE a.role"
+ operator
+ "?"
: "` (id) SELECT e.id FROM `entities` AS e WHERE e.role" + operator + "?"));
final PreparedStatement filterRoleStmt = connection.prepareCall(sql);
int params = (versioned ? 2 : 1);
while (params > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment