Skip to content

Commit f21a410

Browse files
Merge pull request #35 from aquality-automation/develop
0.3.4
2 parents 15c0b90 + 5092d4e commit f21a410

39 files changed

+729
-737
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# CHANGELOG
22

3-
## 0.3.3 (unreleased)
3+
## 0.3.4 (2019-12-10)
4+
5+
Features:
6+
- Remove Customers Feature -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/25)
7+
- Add possibility to sync testsuites according to Not Executed results -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/32)
8+
9+
Bugfixes:
10+
- It should not be possible to delete Customer that assigned to the projects -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/9)
11+
- It is not possible to import several test run results one by one -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/35)
12+
13+
## 0.3.3 (2019-11-16)
414

515
Features:
616
- Rename Import Token to API Token -> [View Issue](https://github.com/aquality-automation/aquality-tracking-ui/issues/23)
@@ -29,4 +39,4 @@ Features:
2939

3040
Bugfixes:
3141

32-
- Fix Fail Reason Search
42+
- Fix Fail Reason Search

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>unifi_reporting_api</groupId>
77
<artifactId>api</artifactId>
88
<packaging>war</packaging>
9-
<version>0.3.3</version>
9+
<version>0.3.4</version>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/main/Session.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Importer getImporter(List<String> filePaths, TestRunDto testRunTemplate,
6363
return new Importer(filePaths, testRunTemplate, pattern, format, nodeType, singleTestRun, user);
6464
}
6565

66-
public TestRunEmails getTestRunEmails(){
66+
public TestRunEmails getTestRunEmails() throws AqualityException {
6767
return new TestRunEmails();
6868
}
6969

src/main/java/main/controllers/Administration/UserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public UserDto updatePassword(PasswordDto password) throws AqualityException {
7676
return userDao.create(user);
7777
}
7878

79-
public UserDto auth(String authString, boolean ldap) throws AqualityException {
79+
UserDto auth(String authString, boolean ldap) throws AqualityException {
8080
Base64 base64= new Base64();
8181
String authStringDecoded = StringUtils.newStringUtf8(base64.decode(authString));
8282
String[] authStringSplit = authStringDecoded.split(":");

src/main/java/main/controllers/CustomerController.java

Lines changed: 1 addition & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,21 @@
22

33
import main.exceptions.AqualityException;
44
import main.exceptions.AqualityPermissionsException;
5-
import main.model.db.dao.customer.CustomerAttachmentsDao;
6-
import main.model.db.dao.customer.CustomerCommentsDao;
75
import main.model.db.dao.customer.CustomerDao;
8-
import main.model.db.dao.customer.CustomerMembersDao;
96
import main.model.db.dao.project.ProjectDao;
10-
import main.model.db.dao.project.ProjectUserDao;
117
import main.model.db.dao.project.UserDao;
128
import main.model.dto.*;
13-
import main.utils.FileUtils;
149

1510
import java.util.ArrayList;
1611
import java.util.List;
1712

1813
public class CustomerController extends BaseController<CustomerDto> {
1914
private CustomerDao customerDao;
20-
private CustomerAttachmentsDao customerAttachmentsDao;
21-
private CustomerCommentsDao customerCommentsDao;
22-
private CustomerMembersDao customerMembersDao;
2315
private UserDao userDao;
24-
private ProjectUserDao projectUserDao;
2516

2617
public CustomerController(UserDto user) {
2718
super(user);
2819
customerDao = new CustomerDao();
29-
customerAttachmentsDao = new CustomerAttachmentsDao();
30-
customerCommentsDao = new CustomerCommentsDao();
31-
customerMembersDao = new CustomerMembersDao();
32-
projectUserDao = new ProjectUserDao();
3320
userDao = new UserDao();
3421
}
3522

@@ -47,68 +34,14 @@ public List<CustomerDto> get(CustomerDto template, boolean withChildren) throws
4734
}
4835
}
4936

50-
public List<CustomerMemberDto> get(CustomerMemberDto template) throws AqualityException {
51-
if(baseUser.isCoordinator()){
52-
return customerMembersDao.searchAll(template);
53-
}else{
54-
throw new AqualityPermissionsException("Account is not allowed to view Customer Members", baseUser);
55-
}
56-
}
57-
58-
public List<CustomerCommentDto> get(CustomerCommentDto template) throws AqualityException {
59-
if(baseUser.isCoordinator()){
60-
return completeComments(customerCommentsDao.searchAll(template));
61-
}else{
62-
throw new AqualityPermissionsException("Account is not allowed to view Customer Comments", baseUser);
63-
}
64-
}
65-
66-
public List<CustomerAttachmentDto> get(CustomerAttachmentDto template) throws AqualityException {
67-
if(baseUser.isCoordinator()){
68-
return customerAttachmentsDao.searchAll(template);
69-
}else{
70-
throw new AqualityPermissionsException("Account is not allowed to view Customer Comments", baseUser);
71-
}
72-
}
73-
7437
@Override
7538
public CustomerDto create(CustomerDto template) throws AqualityException {
7639
if(baseUser.isCoordinator()){
77-
if(template.getId() != null && template.getAccounting() == 0){
78-
template.setAccount_manager(new UserDto());
79-
template.getAccount_manager().setId(0);
80-
// TODO: Remove Customer Members
81-
}
82-
83-
CustomerDto customer = fillCustomer(customerDao.create(template));
84-
85-
if(template.getAccounting() != null && template.getAccounting() == 1 && template.getAccount_manager() != null){
86-
addPermissions(template.getAccount_manager().getId(), customer);
87-
}
88-
return customer;
40+
return fillCustomer(customerDao.create(template));
8941
}else{
9042
throw new AqualityPermissionsException("Account is not allowed to create Customers", baseUser);
9143
}
9244
}
93-
public CustomerAttachmentDto create(CustomerAttachmentDto template) throws AqualityException {
94-
if(baseUser.isCoordinator()){
95-
return customerAttachmentsDao.create(template);
96-
}else{
97-
throw new AqualityPermissionsException("Account is not allowed to create Customer Attachment", baseUser);
98-
}
99-
}
100-
public CustomerCommentDto create(CustomerCommentDto template) throws AqualityException {
101-
if(baseUser.isCoordinator()){
102-
return customerCommentsDao.create(template);
103-
}else{
104-
throw new AqualityPermissionsException("Account is not allowed to create Customer Comment", baseUser);
105-
}
106-
}
107-
108-
// TODO: update members
109-
public void updateCustomerMember(List<CustomerMemberDto> members){
110-
throw new UnsupportedOperationException("Not implemented Update Members function");
111-
}
11245

11346
@Override
11447
public boolean delete(CustomerDto template) throws AqualityException {
@@ -118,36 +51,13 @@ public boolean delete(CustomerDto template) throws AqualityException {
11851
throw new AqualityPermissionsException("Account is not allowed to delete Customers", baseUser);
11952
}
12053
}
121-
public boolean delete(CustomerAttachmentDto template) throws AqualityException {
122-
if(baseUser.isCoordinator()){
123-
FileUtils fileUtils = new FileUtils();
124-
template = get(template).get(0);
125-
List<String> pathes = new ArrayList<>();
126-
pathes.add(template.getPath());
127-
fileUtils.removeFiles(pathes);
128-
return customerAttachmentsDao.delete(template);
129-
}else{
130-
throw new AqualityPermissionsException("Account is not allowed to view Customers", baseUser);
131-
}
132-
}
13354

13455
private List<CustomerDto> fillCustomers(List<CustomerDto> customers) throws AqualityException {
13556
List<UserDto> users = userDao.getAll();
136-
13757
for (CustomerDto customer: customers){
13858
customer.setCoordinator(users.stream().filter(x -> x.getId().equals(customer.getCoordinator_id())).findFirst().orElse(null));
13959
customer.getCoordinator().toPublic();
140-
141-
if(customer.getAccounting() == 1){
142-
Integer accountManagerId = customer.getAccount_manager_id();
143-
customer.setAccount_manager(users.stream().filter(x->x.getId().equals(accountManagerId)).findFirst().orElse(null));
144-
customer.getAccount_manager().toPublic();
145-
}
146-
14760
if(baseUser.isCoordinator()){
148-
customer.setAccount_team(getMembers(customer));
149-
customer.setComments(getComments(customer));
150-
customer.setAttachments(getAttachments(customer));
15161
customer.setProjects(getProjects(customer));
15262
}
15363
}
@@ -162,60 +72,9 @@ private List<ProjectDto> getProjects(CustomerDto customer) throws AqualityExcept
16272
return projectDao.searchAll(projectTemplate);
16373
}
16474

165-
private List<CustomerAttachmentDto> getAttachments(CustomerDto customer) throws AqualityException {
166-
CustomerAttachmentDto customerAttachmentDtoTemplate = new CustomerAttachmentDto();
167-
customerAttachmentDtoTemplate.setCustomer_id(customer.getId());
168-
return get(customerAttachmentDtoTemplate);
169-
}
170-
171-
private List<CustomerCommentDto> getComments(CustomerDto customer) throws AqualityException {
172-
CustomerCommentDto customerCommentDtoTemplate = new CustomerCommentDto();
173-
customerCommentDtoTemplate.setCustomer_id(customer.getId());
174-
return get(customerCommentDtoTemplate);
175-
}
176-
177-
private List<CustomerMemberDto> getMembers(CustomerDto customer) throws AqualityException {
178-
CustomerMemberDto customerMemberDto = new CustomerMemberDto();
179-
customerMemberDto.setCustomer_id(customer.getId());
180-
return get(customerMemberDto);
181-
}
182-
18375
private CustomerDto fillCustomer(CustomerDto customer) throws AqualityException {
18476
List<CustomerDto> customers = new ArrayList<>();
18577
customers.add(customer);
18678
return fillCustomers(customers).get(0);
18779
}
188-
189-
private void addPermissions(Integer user_id, CustomerDto customerDto) throws AqualityException {
190-
List<ProjectDto> projects = customerDto.getProjects();
191-
192-
for (ProjectDto project : projects) {
193-
ProjectUserDto projectUserDto = new ProjectUserDto();
194-
UserDto userDto = new UserDto();
195-
userDto.setId(user_id);
196-
projectUserDto.setProject_id(project.getId());
197-
projectUserDto.setUser(userDto);
198-
projectUserDto.setViewer(1);
199-
projectUserDao.create(projectUserDto);
200-
}
201-
}
202-
203-
private List<CustomerCommentDto> completeComments(List<CustomerCommentDto> comments) throws AqualityException {
204-
UserDto userTemplate = new UserDto();
205-
206-
for (CustomerCommentDto comment: comments){
207-
208-
if(comment.getUser_id() != null){
209-
userTemplate.setId(comment.getUser_id());
210-
}else{
211-
userTemplate.setId(1);
212-
}
213-
try{
214-
comment.setAuthor(userDao.getEntityById(userTemplate));
215-
} catch (Exception e){
216-
throw new AqualityException("Cannot find author for Customer Comment");
217-
}
218-
}
219-
return comments;
220-
}
22180
}

src/main/java/main/controllers/Project/ProjectController.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public ProjectController(UserDto user) {
2323
public ProjectDto create(ProjectDto template) throws AqualityException {
2424
if(baseUser.isAdmin() || allowUpdateProject(template)){
2525
ProjectDto project = projectDao.create(template);
26-
updateProjectPermissions(project);
2726
return project;
2827
}else{
2928
throw new AqualityPermissionsException("Account is not allowed to create Projects", baseUser);
@@ -54,7 +53,7 @@ public boolean delete(ProjectDto template) throws AqualityException {
5453
}
5554
}
5655

57-
public boolean isStepsEnabled(Integer projectId) throws AqualityException {
56+
boolean isStepsEnabled(Integer projectId) throws AqualityException {
5857
ProjectDto project = new ProjectDto();
5958
project.setId(projectId);
6059
List<ProjectDto> projects = get(project, false);
@@ -66,12 +65,6 @@ public boolean isStepsEnabled(Integer projectId) throws AqualityException {
6665
return projects.get(0).getSteps() == 1;
6766
}
6867

69-
private void updateProjectPermissions(ProjectDto entity) throws AqualityException {
70-
if(entity.getCustomer() != null && entity.getCustomer().getAccounting() == 1 && entity.getId() != 0){
71-
updatePermissions(entity.getCustomer().getId(), entity.getId());
72-
}
73-
}
74-
7568
private boolean allowUpdateProject(ProjectDto template) {
7669
if(template.getId() != null) {
7770
ProjectUserDto projectUser = baseUser.getProjectUser(template.getId());
@@ -80,18 +73,15 @@ private boolean allowUpdateProject(ProjectDto template) {
8073
return false;
8174
}
8275

83-
//TODO create
84-
private void updatePermissions(Integer customer_id, Integer project_id) throws AqualityException {
85-
}
86-
87-
//TODO Refactoring
8876
private List<ProjectDto> fillCustomers(List<ProjectDto> projects, boolean withChildren) throws AqualityException {
8977
List<ProjectDto> filledProjects = new ArrayList<>();
9078
CustomerDto customerTemplate = new CustomerDto();
9179
if(projects.size() == 1) {
9280
customerTemplate.setId(projects.get(0).getCustomer_id());
9381
}
82+
9483
List<CustomerDto> customerDtoList = customerController.get(new CustomerDto(), withChildren);
84+
9585
for (ProjectDto filledProject : projects) {
9686
if (filledProject.getCustomer_id() != null) {
9787
int customerId = filledProject.getCustomer_id();

0 commit comments

Comments
 (0)