Skip to content
Snippets Groups Projects
Commit 40df7a46 authored by David Büchler's avatar David Büchler
Browse files

Merge remote-tracking branch 'origin/stable2019.3' into #1040035-Dublettenermittlung

parents 9ed69a78 d87e2e61
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,17 @@
The 360Degree_entity shows the Connection between datenmodells.
The entity has two providers for persons and organisations.
The 360Degree_entity shows direct connections, don´t be confused with the ObjectRelation_entity.
\ No newline at end of file
The 360Degree_entity shows direct connections, don´t be confused with the ObjectRelation_entity.
== Adding new modules to the 360° view
You may want to display more modules within the 360degree view (for example after creating and implemeting your own module).
.An Example:
You added a module called "T-Shirts" to your project. Every person-contact can have _n_ "T-Shirts" and whenever a person owns a T-Shirt you want to
display it in the 360degree view.
Heres is a list of what you need to do whenever you want to do this:
- Add an entry in the function `ContextUtils.getSelectMap` which is located in the `Context_lib` (check out the documentation there for further details). _Speaking of the example above you need to define there how to retrieve the t-shirt-data for a contact_
- Add an entry (with the name of the context you want to add) in the process of the `ObjectType_param` in the *corresponding provider* which is located in the `360Degree_entity`. _We would extend the array which is returned in the `PersonObjects`-provider by the name of our t-shirt-context: "TShirt" in our example_
\ No newline at end of file
import("system.logging");
import("system.project");
import("system.vars");
import("system.result");
......@@ -8,12 +9,14 @@ var noCond = "{\"entity\":\"" + entityName + "\",\"filter\":{\"type\":\"group\",
switch (vars.get("$field.ACCESSTYPE")) {
case "E":
if (vars.exists("$param.RoleTitle_param") && vars.get("$param.RoleTitle_param") && vars.get("$field.ENTITY") != "") {
if (vars.get("$param.RoleTitle_param") && vars.get("$field.ENTITY") != "") {
res += vars.get("$field.ENTITY");
} else if (vars.exists("$param.EntityTitle_param") && vars.get("$param.EntityTitle_param") && vars.get("$field.ROLE") != "") {
} else if (vars.get("$param.EntityTitle_param") && vars.get("$field.ROLE") != "") {
res += vars.get("$field.ROLE");
} else {
res += "?";
} else if (vars.get("$field.ROLE") != "") {
res += vars.get("$field.ROLE");
} else if (vars.get("$field.ENTITY") != "") {
res += vars.get("$field.ENTITY");
}
break;
case "R":
......
......@@ -10,7 +10,7 @@ var rootPermSet = PermissionUtil.getSetRoot(role, entity);
var rootPerm = PermissionUtil.getPermissionWithoutCond(rootPermSet);
if (PermissionUtil.getCondType(rootPerm) == 0) {
// condtype="false" is used to display that this entity has the usePermissions flag set but has no permissions linked -> no access on any level
// condtype=0 is used to display that this entity has the usePermissions flag set but has no permissions linked -> no access on any level
result.string("E");
} else if (rootPermSet == "") {
result.string("E");
......
import("Sql_lib");
import("system.db");
import("system.logging");
import("system.vars");
import("system.result");
import("Permission_lib");
var alias = SqlUtils.getSystemAlias();
var rootPermId;
var entity = vars.get("$field.ENTITY");
var cond = vars.get("$field.CONDITION");
var noCond = "{\"entity\":\"" + entity + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var permSetId = PermissionUtil.getSet(vars.get("$field.ROLE"), vars.get("$field.ENTITY"), vars.get("$field.ACCESSTYPE"));
if (permSetId != "" && (cond == "" || cond == noCond)) {
var rootPermId = PermissionUtil.getPermissionWithoutCond(permSetId);
if (rootPermId != "") {
result.string(rootPermId);
if (permSetId != "") {
// check if default or conditional permission has to be returned
if (cond == "" || cond == noCond) {
rootPermId = PermissionUtil.getPermissionWithoutCond(permSetId);
} else {
rootPermId = PermissionUtil.getPermissionWithCond(permSetId);
for each (let perm in rootPermId) {
let sqlStr = "select ASYS_PERMISSIONID from ASYS_PERMISSION where cast(ASYS_PERMISSION.COND as varchar(" + cond.length + ")) = '" + cond + "'"
rootPermId = db.cell(sqlStr, alias);
break;
}
}
// return valid permId
if (rootPermId != "")
result.string(rootPermId);
else
result.string(vars.get("$field.UID"));
} else {
result.string(vars.get("$field.UID"));
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ var permId = PermissionUtil.getPermission(roleTitle, entityTitle, fieldTitle, ac
var actionsInDb = PermissionUtil.getActions([permId]);
var actionsAsStringArray = vars.get("$field.ACTION").split(","); // only useful while working with already existing permissions
var noCond = "{\"entity\":\"" + entityTitle + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var isDefaultPermission = (permCondInput != noCond && permCondInput != "") ? false : true;
var deletedRows = vars.get("$field.PermissionActions.deletedRows");
var changedRows = vars.get("$field.PermissionActions.changedRows");
......@@ -50,6 +51,12 @@ if (PermissionUtil.permissionExists(permId)) {
result.string(translate.text("Action '" + row.ACTION + "' already linked to this permission."));
}
}
// if conditional permission: check if action is already linked to default permission
if (!isDefaultPermission) {
if (PermissionUtil.actionExists(row.ACTION, PermissionUtil.getPermissionWithoutCond(PermissionUtil.getSet(roleTitle, entityTitle, accesstype, fieldTitle)))) {
result.string(translate.text("Action '" + row.ACTION + "' is already linked to the default permission."));
}
}
}
for each (let row in changedRows) {
......
......@@ -34,12 +34,13 @@ for each (let entityMetaData in entitiesMetaData) {
whereCond += " ENTITY_ID in ('" + entitiesUsePermFlagSet.join("','") + "')";
whereCond += " and (FIELD_ID in ('" + fieldsUsePermFlagSet.join("','") + "') or FIELD_ID is NULL)";
if (vars.exists("$param.RoleTitle_param") && vars.get("$param.RoleTitle_param")) {
whereCond += " and ASYS_PERMISSIONSET.ROLE_ID = '" + vars.getString("$param.RoleTitle_param") + "'";
} else if (vars.exists("$param.EntityTitle_param") && vars.get("$param.EntityTitle_param")) {
whereCond += " and ASYS_PERMISSIONSET.ENTITY_ID = '" + vars.getString("$param.EntityTitle_param") + "'";
if (vars.get("$param.RoleTitle_param")) {
whereCond += " and ASYS_PERMISSIONSET.ROLE_ID = '" + vars.get("$param.RoleTitle_param") + "'";
} else if (vars.get("$param.EntityTitle_param")) {
whereCond += " and ASYS_PERMISSIONSET.ENTITY_ID = '" + vars.get("$param.EntityTitle_param") + "'";
}
// get all permissions which are already in db
sqlStr =
"select ASYS_PERMISSION.ASYS_PERMISSIONID, ASYS_PERMISSIONSET.ENTITY_ID, ASYS_PERMISSIONSET.ROLE_ID,"
+ " ASYS_PERMISSIONSET.FIELD_ID, ASYS_PERMISSION.COND, ASYS_PERMISSIONACTION.ACTION, ASYS_PERMISSIONSET.ACCESSTYPE, ASYS_PERMISSION.CONDTYPE from ASYS_PERMISSIONSET"
......@@ -50,6 +51,7 @@ sqlStr =
var sqlRes = db.table(sqlStr, alias);
var permissionTable = PermissionUtil.convertArrToObj(sqlRes);
var permissionTableOrigin = permissionTable; // used to build tree
// group all permissions by permissionid and condition, concat actions
var groupedPermissionTable = [], concatAction;
......@@ -75,28 +77,26 @@ for (let i = 0; i < permissionTable.length - 1; i++) {
}
var res = [];
var permissionTableOrigin = PermissionUtil.convertArrToObj(sqlRes);
// no permission selected, return all permission entrys
if (selectedPermission == null) {
for each (let entry in groupedPermissionTable) {
if (selectedPermission == null) { // no permission selected, return all permission entrys
for each (let entry in groupedPermissionTable) { // iterates over all grouped permissions
res = prepareResultArray(entry, res);
}
for each (let entry in permissionTableOrigin) {
for each (let entry in permissionTableOrigin) { // itereates over all permissions - skips permissions which are in groupedPermissionTable
if (PermissionUtil.indexOfPermId(PermissionUtil.convertArrToObj(res), entry.permissionid) == -1) {
res = prepareResultArray(entry, res);
}
}
} else { // permission selected, return only the selected permission entry
for each (let entry in groupedPermissionTable) {
for each (let entry in groupedPermissionTable) { // iterates over all grouped permissions
if (selectedPermission == entry.permissionid) {
res = prepareResultArray(entry, res);
break;
}
}
for each (let entry in permissionTableOrigin) {
for each (let entry in permissionTableOrigin) { // itereates over all permissions - skips permissions which are in groupedPermissionTable
if (selectedPermission == entry.permissionid) {
if (PermissionUtil.indexOfPermId(PermissionUtil.convertArrToObj(res), entry.permissionid) == -1) {
res = prepareResultArray(entry, res);
......@@ -106,7 +106,7 @@ if (selectedPermission == null) {
}
}
res = res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes);
res = res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes).sort(sortResultByTitleAlphabetically);
result.object(res);
function prepareResultArray(pEntry, pRes) {
......@@ -170,22 +170,14 @@ function sortResultsByAccessTypes(a, b) {
var noCondA = "{\"entity\":\"" + a[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var noCondB = "{\"entity\":\"" + b[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
if (a[6] == b[6] && a[6] == "E")
return 0;
else if (a[6] == "E")
return -1;
else if (b[6] == "E")
return 1;
else if (a[6] == "R" && b[6] == "F")
return -1;
else if (a[6] == "F" && b[6] == "R")
return 1;
else if (a[6] == b[6] && (a[4] == "" || a[4] == noCondA))
return -1;
else if (a[6] == b[6] && (b[4] == "" || b[4] == noCondB))
return 1;
else
return 0;
if (a[6] == b[6] && a[6] == "E") return 0;
else if (a[6] == "E") return -1;
else if (b[6] == "E") return 1;
else if (a[6] == "R" && b[6] == "F") return -1;
else if (a[6] == "F" && b[6] == "R") return 1;
else if (a[6] == b[6] && (a[4] == "" || a[4] == noCondA)) return -1;
else if (a[6] == b[6] && (b[4] == "" || b[4] == noCondB)) return 1;
else return 0;
}
// sorts result array: default permission -> conditional permission
......@@ -193,15 +185,22 @@ function sortResultsByCondition(a, b) {
var noCondA = "{\"entity\":\"" + a[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var noCondB = "{\"entity\":\"" + b[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
if (a[4] == "" || a[4] == noCond) {
return -1;
} else if (b[4] == "" || b[4] == noCondB) {
return -1;
} else if (a[4] != "" && a[4] != noCondA) {
return 1;
} else if (b[4] != "" && b[4] != noCondB) {
return 1;
if (a[4] == "" || a[4] == noCond) return -1;
else if (b[4] == "" || b[4] == noCondB) return -1;
else if (a[4] != "" && a[4] != noCondA) return 1;
else if (b[4] != "" && b[4] != noCondB) return 1;
else return 0;
}
function sortResultByTitleAlphabetically(a, b) {
if (vars.get("$param.RoleTitle_param")) {
if (a[1] < b[1]) return -1;
if (a[1] > b[1]) return 1;
return 0;
} else {
if (a[2] < b[2]) return -1;
if (a[2] > b[2]) return 1;
return 0;
}
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment