Skip to content

Commit

Permalink
#779 | Introduce User "isIgnoreSyncSettingsInDEA" flag to allow DEA a…
Browse files Browse the repository at this point in the history
…ccess to transactional entities within Catchment but not matching sync settings
  • Loading branch information
himeshr committed Aug 29, 2024
1 parent 2ec78cf commit 4335186
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions avni-server-api/src/main/java/org/avni/server/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class User {
@Type(type = "jsonObject")
private JsonObject syncSettings;

@Column(name = "ignore_sync_settings_in_dea")
private boolean ignoreSyncSettingsInDEA;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user")
private List<UserGroup> userGroups;

Expand Down Expand Up @@ -291,6 +294,14 @@ public void setSyncSettings(JsonObject syncSettings) {
this.syncSettings = syncSettings;
}

public boolean isIgnoreSyncSettingsInDEA() {
return ignoreSyncSettingsInDEA;
}

public void setIgnoreSyncSettingsInDEA(boolean ignoreSyncSettingsInDEA) {
this.ignoreSyncSettingsInDEA = ignoreSyncSettingsInDEA;
}

public String[] getRoles() {
ArrayList<String> roles = new ArrayList<>();
if (!isAdmin()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ private User setUserAttributes(User user, UserContract userContract) {

user.setOperatingIndividualScope(OperatingIndividualScope.valueOf(userContract.getOperatingIndividualScope()));
user.setSettings(userContract.getSettings());
user.setIgnoreSyncSettingsInDEA(userContract.isIgnoreSyncSettingsInDEA());
user.setSyncSettings(UserSyncSettings.fromUserSyncWebJSON(userContract.getSyncSettings(), subjectTypeRepository));
User currentUser = userService.getCurrentUser();
Long organisationId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class UserContract extends ReferenceDataContract {
private Long organisationId;
private List<Long> accountIds;
private boolean disabledInCognito;
private boolean ignoreSyncSettingsInDEA;
private String password;
private JsonObject syncSettings;
private String createdBy;
Expand All @@ -40,6 +41,7 @@ public static UserContract fromEntity(User user) {
userContract.setPhoneNumber(user.getPhoneNumber());
userContract.setOrganisationId(user.getOrganisationId());
userContract.setDisabledInCognito(user.isDisabledInCognito());
userContract.setIgnoreSyncSettingsInDEA(user.isIgnoreSyncSettingsInDEA());
userContract.setCatchmentId(user.getCatchmentId().orElse(null));
userContract.setSettings(user.getSettings());
userContract.setCreatedBy(user.getCreatedByUserName());
Expand All @@ -61,6 +63,14 @@ public void setDisabledInCognito(boolean disabledInCognito) {
this.disabledInCognito = disabledInCognito;
}

public boolean isIgnoreSyncSettingsInDEA() {
return ignoreSyncSettingsInDEA;
}

public void setIgnoreSyncSettingsInDEA(boolean ignoreSyncSettingsInDEA) {
this.ignoreSyncSettingsInDEA = ignoreSyncSettingsInDEA;
}

public Long getOrganisationId() {
return organisationId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table users add column ignore_sync_settings_in_DEA boolean not null default false;

0 comments on commit 4335186

Please sign in to comment.