remove import plan users

This commit is contained in:
CITE\amentis 2024-10-14 12:38:57 +03:00
parent b5a9202d6f
commit 9b41d47007
1 changed files with 0 additions and 70 deletions

View File

@ -2394,7 +2394,6 @@ public class PlanServiceImpl implements PlanService {
persist.setDescription(planXml.getDescription());
persist.setAccessType(planXml.getAccess());
persist.setLanguage(planXml.getLanguage());
persist.setUsers(this.xmlToPlanUsersPersist(planXml)); //TODO ignore users not exists. by id betters solution
persist.setProperties(this.xmlToPlanPropertiesPersist(planXml));
persist.setBlueprint(this.xmlPlanBlueprintToPersist(planXml));
persist.setDescriptionTemplates(this.xmlPlanDescriptionTemplatesToPersist(planXml, persist.getBlueprint())); //TODO maybe we should create templates if not exists
@ -2632,36 +2631,6 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private List<PlanUserPersist> xmlToPlanUsersPersist(PlanImportExport planXml){
if (!this.conventionService.isListNullOrEmpty(planXml.getUsers())) {
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(planXml.getUsers().stream().map(PlanUserImportExport::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
List<PlanUserPersist> planUsers = new ArrayList<>();
for (PlanUserImportExport user : planXml.getUsers()) {
planUsers.add(this.xmlPlanUserToPersist(user, userIds));
}
return planUsers.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
return null;
}
private PlanUserPersist xmlPlanUserToPersist(PlanUserImportExport importXml, List<UUID> userIds) {
if (importXml == null)
return null;
if (importXml.getId() != null && !userIds.isEmpty() && userIds.contains(importXml.getId())) {
PlanUserPersist persist = new PlanUserPersist();
persist.setUser(importXml.getId());
persist.setRole(importXml.getRole());
persist.setSectionId(importXml.getSectionId());
return persist;
}
return null;
}
private PlanContactPersist xmlPlanContactToPersist(PlanContactImportExport importXml) {
if (importXml == null)
return null;
@ -2699,7 +2668,6 @@ public class PlanServiceImpl implements PlanService {
default -> throw new MyApplicationException("Unrecognized Type " + model.getAccessType().getValue());
}
persist.setLanguage(model.getLanguage());
persist.setUsers(this.commonModelToPlanUsersPersist(model));
persist.setBlueprint(this.commonModelPlanBlueprintToPersist(model));
persist.setDescriptionTemplates(this.commonModelPlanDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists
persist.setProperties(this.commonModelPlanPropertiesToPersist(model));
@ -2911,44 +2879,6 @@ public class PlanServiceImpl implements PlanService {
return persist;
}
private List<PlanUserPersist> commonModelToPlanUsersPersist(PlanModel commonModel){
if (!this.conventionService.isListNullOrEmpty(commonModel.getUsers())) {
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().ids(commonModel.getUsers().stream().map(PlanUserModel::getUser).filter(Objects::nonNull).map(UserModel::getId).filter(Objects::nonNull).distinct().toList()).isActive(IsActive.Active).collect();
List<UUID> userIds = users == null ? new ArrayList<>() : users.stream().map(UserEntity::getId).collect(Collectors.toList());
List<PlanUserPersist> planUsers = new ArrayList<>();
for (PlanUserModel user : commonModel.getUsers()) {
planUsers.add(this.commonModelPlanUserToPersist(user, userIds));
}
return planUsers;
}
return null;
}
private PlanUserPersist commonModelPlanUserToPersist(PlanUserModel commonModel, List<UUID> userIds) {
if (commonModel == null)
return null;
if (commonModel.getUser() != null && commonModel.getUser().getId() != null && !userIds.isEmpty() && userIds.contains(commonModel.getUser().getId())) {
PlanUserPersist persist = new PlanUserPersist();
persist.setUser(commonModel.getUser().getId());
switch (commonModel.getRole()){
case Owner -> persist.setRole(PlanUserRole.Owner);
case Viewer -> persist.setRole(PlanUserRole.Viewer);
case DescriptionContributor -> persist.setRole(PlanUserRole.DescriptionContributor);
case Reviewer -> persist.setRole(PlanUserRole.Reviewer);
default -> throw new MyApplicationException("Unrecognized Type " + commonModel.getRole().getValue());
}
persist.setSectionId(commonModel.getSectionId());
return persist;
}
return null;
}
private PlanContactPersist commonModelPlanContactToPersist(PlanContactModel commonModel) {
if (commonModel == null)
return null;