Skip to content
Snippets Groups Projects
Commit d2aa4ef5 authored by msayad's avatar msayad Committed by Benaissa BENARBIA
Browse files

[US RABB-1167] add units property to profiles group

parent b60fc730
No related branches found
No related tags found
1 merge request!51Merge mis a jour vitam-ui
...@@ -69,6 +69,8 @@ public class GroupConverter implements Converter<GroupDto, Group> { ...@@ -69,6 +69,8 @@ public class GroupConverter implements Converter<GroupDto, Group> {
public static final String PROFILE_IDS_KEY = "Liste des profils"; public static final String PROFILE_IDS_KEY = "Liste des profils";
public static final String UNITS_KEY = "Liste des unités d'appartenance";
private final ProfileRepository profileRepository; private final ProfileRepository profileRepository;
public GroupConverter(final ProfileRepository profileRepository) { public GroupConverter(final ProfileRepository profileRepository) {
...@@ -83,6 +85,7 @@ public class GroupConverter implements Converter<GroupDto, Group> { ...@@ -83,6 +85,7 @@ public class GroupConverter implements Converter<GroupDto, Group> {
logbookData.put(LEVEL_KEY, LogbookUtils.getValue(dto.getLevel())); logbookData.put(LEVEL_KEY, LogbookUtils.getValue(dto.getLevel()));
logbookData.put(ENABLED_KEY, LogbookUtils.getValue(dto.isEnabled())); logbookData.put(ENABLED_KEY, LogbookUtils.getValue(dto.isEnabled()));
logbookData.put(PROFILE_IDS_KEY, convertProfileIdsToLogbook(dto.getProfileIds())); logbookData.put(PROFILE_IDS_KEY, convertProfileIdsToLogbook(dto.getProfileIds()));
logbookData.put(UNITS_KEY, convertUnitsToLogbook(dto.getUnits()));
return ApiUtils.toJson(logbookData); return ApiUtils.toJson(logbookData);
} }
...@@ -103,4 +106,8 @@ public class GroupConverter implements Converter<GroupDto, Group> { ...@@ -103,4 +106,8 @@ public class GroupConverter implements Converter<GroupDto, Group> {
ids.sort(Comparator.naturalOrder()); ids.sort(Comparator.naturalOrder());
return ids.toString(); return ids.toString();
} }
public String convertUnitsToLogbook(final List<String> units) {
return units != null ? units.toString() : null;
}
} }
...@@ -91,4 +91,6 @@ public class Group extends CustomerIdDocument implements BaseIdentifierDocument ...@@ -91,4 +91,6 @@ public class Group extends CustomerIdDocument implements BaseIdentifierDocument
@Length(max = 250) @Length(max = 250)
private String level; private String level;
private List<String> units;
} }
...@@ -265,6 +265,12 @@ public class GroupInternalService extends VitamUICrudService<GroupDto, Group> { ...@@ -265,6 +265,12 @@ public class GroupInternalService extends VitamUICrudService<GroupDto, Group> {
groupConverter.convertProfileIdsToLogbook(profileIds))); groupConverter.convertProfileIdsToLogbook(profileIds)));
group.setProfileIds(profileIds); group.setProfileIds(profileIds);
break; break;
case "units" :
final List<String> units = CastUtils.toList(entry.getValue());
logbooks.add(new EventDiffDto(GroupConverter.UNITS_KEY, groupConverter.convertProfileIdsToLogbook(group.getUnits()),
groupConverter.convertUnitsToLogbook(units)));
group.setUnits(units);
break;
default : default :
throw new IllegalArgumentException("Unable to patch group " + group.getId() + ": key " + entry.getKey() + " is not allowed"); throw new IllegalArgumentException("Unable to patch group " + group.getId() + ": key " + entry.getKey() + " is not allowed");
} }
......
...@@ -91,4 +91,7 @@ public class GroupDto extends CustomerIdDto { ...@@ -91,4 +91,7 @@ public class GroupDto extends CustomerIdDto {
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
private Long usersCount; private Long usersCount;
@JsonInclude(JsonInclude.Include.NON_NULL)
private List<String> units;
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment