Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
80aed22b
Commit
80aed22b
authored
May 06, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provided the account name in domains json response
parent
7d429dda
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
223 additions
and
123 deletions
+223
-123
AccountController.java
...n/java/com/nisum/myteam/controller/AccountController.java
+88
-97
DomainVO.java
src/main/java/com/nisum/myteam/model/vo/DomainVO.java
+30
-0
IDomainService.java
src/main/java/com/nisum/myteam/service/IDomainService.java
+3
-4
DomainService.java
...ain/java/com/nisum/myteam/service/impl/DomainService.java
+31
-22
AccountStatus.java
...main/java/com/nisum/myteam/statuscodes/AccountStatus.java
+33
-0
BillingStatus.java
...main/java/com/nisum/myteam/statuscodes/BillingStatus.java
+4
-0
DomainStatus.java
src/main/java/com/nisum/myteam/statuscodes/DomainStatus.java
+22
-0
EmployeeStatus.java
...ain/java/com/nisum/myteam/statuscodes/EmployeeStatus.java
+4
-0
ProjectStatus.java
...main/java/com/nisum/myteam/statuscodes/ProjectStatus.java
+4
-0
ResourceStatus.java
...ain/java/com/nisum/myteam/statuscodes/ResourceStatus.java
+4
-0
No files found.
src/main/java/com/nisum/myteam/controller/AccountController.java
View file @
80aed22b
...
...
@@ -4,6 +4,7 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.statuscodes.AccountStatus
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -30,41 +31,38 @@ public class AccountController {
public
ResponseEntity
<?>
createAccount
(
@Valid
@RequestBody
Account
account
,
HttpServletRequest
request
)
throws
MyTeamException
{
log
.
info
(
"Serving the Account Creation action"
)
;
ResponseDetails
respDetails
=
null
;
boolean
isAccountExists
=
accountService
.
isAccountExists
(
account
);
log
.
info
(
"is Account exists with the name "
+
account
.
getAccountName
()
+
":::"
+
isAccountExists
);
if
(!
isAccountExists
)
{
Account
accountPersisted
=
accountService
.
createAccount
(
account
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Account has been created"
,
"Account description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
respDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
CREATE
.
getCode
(),
AccountStatus
.
CREATE
.
getMessage
(),
"Account description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"An Account is already existed"
,
"Choose the different account name"
,
null
,
request
.
getRequestURI
(),
"details"
,
account
);
respDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
ALREADY_EXISTED
.
getCode
(),
AccountStatus
.
ALREADY_EXISTED
.
getMessage
()
,
"Choose the different account name"
,
null
,
request
.
getRequestURI
(),
"details"
,
account
);
return
new
ResponseEntity
<
ResponseDetails
>(
response
Details
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
resp
Details
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/accounts/{accountId}"
,
method
=
RequestMethod
.
PUT
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateAccount
(
@RequestBody
Account
account
,
@PathVariable
String
accountId
,
HttpServletRequest
request
)
throws
MyTeamException
{
log
.
info
(
"Updating the account with details::"
+
account
);
log
.
info
(
"Updating the account with details::"
+
account
);
ResponseDetails
respDetails
=
null
;
boolean
isAccountExists
=
accountService
.
isAccountExists
(
account
);
if
(
isAccountExists
==
true
)
{
Account
accountPersisted
=
accountService
.
updateAccountAndRolesForDMS
(
account
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account has been updated"
,
"status description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
respDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
UPDATE
.
getCode
(),
AccountStatus
.
UPDATE
.
getMessage
(),
"status description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
605
,
"Account is Not found"
,
"Choose the correct updating account name"
,
null
,
request
.
getRequestURI
(),
"details"
,
account
);
respDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
NOT_FOUND
.
getCode
(),
AccountStatus
.
NOT_FOUND
.
getMessage
()
,
"Choose the correct updating account name"
,
null
,
request
.
getRequestURI
(),
"details"
,
account
);
return
new
ResponseEntity
<
ResponseDetails
>(
response
Details
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
resp
Details
,
HttpStatus
.
OK
);
}
...
...
@@ -74,8 +72,8 @@ public class AccountController {
throws
MyTeamException
{
log
.
info
(
"Deleting account with accountId:"
+
accountId
);
Account
accountDeleted
=
accountService
.
deleteAccount
(
accountId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account has been deleted successfully"
,
"status description"
,
null
,
request
.
getRequestURI
(),
"details"
,
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
DELETE
.
getCode
()
,
AccountStatus
.
DELETE
.
getMessage
(),
"status description"
,
null
,
request
.
getRequestURI
(),
"details"
,
accountDeleted
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
...
...
@@ -87,7 +85,7 @@ public class AccountController {
List
<
Map
<
Object
,
Object
>>
accountsList
=
accountService
.
getAccountsList
();
log
.
info
(
"The accounts list::"
+
accountsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the accounts successfully"
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
GET_ACCOUNTS
.
getCode
(),
AccountStatus
.
GET_ACCOUNTS
.
getMessage
()
,
"Accounts list"
,
accountsList
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
...
@@ -105,8 +103,8 @@ public class AccountController {
}
log
.
info
(
"The account names list::"
+
accountNamesList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the account names successfully"
,
"Account names list"
,
accountNamesList
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
GET_ACCOUNT_NAMES
.
getCode
()
,
AccountStatus
.
GET_ACCOUNT_NAMES
.
getMessage
()
,
"Account names list"
,
accountNamesList
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
...
@@ -116,7 +114,7 @@ public class AccountController {
//get the accounts based on status(Active or inactive)
@RequestMapping
(
value
=
"/accounts/status"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Account
>>
getAccounts
(
@RequestParam
(
"status"
)
String
status
)
throws
MyTeamException
{
public
ResponseEntity
<
List
<
Account
>>
getAccounts
(
@RequestParam
(
"status"
)
String
status
)
throws
MyTeamException
{
List
<
Account
>
accountsList
=
accountService
.
getAccountsAll
().
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
accountsList
,
HttpStatus
.
OK
);
...
...
@@ -126,28 +124,21 @@ public class AccountController {
@RequestMapping
(
value
=
"/accounts/accountId/{accId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccountName
(
@PathVariable
(
"accId"
)
String
accountId
,
HttpServletRequest
request
)
throws
MyTeamException
{
log
.
info
(
"Serving the Account Name Get action: accountId:"
+
accountId
);
log
.
info
(
"Serving the Account Name Get action: accountId:"
+
accountId
);
ResponseDetails
getRespDetails
=
null
;
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
boolean
isAccountExists
=
accountService
.
isAccountExists
(
accountId
);
log
.
info
(
"is Account exists with the name "
+
isAccountExists
);
if
(
isAccountExists
)
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the account Name successfully"
,
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
GET_ACCOUNT
.
getCode
(),
AccountStatus
.
GET_ACCOUNT
.
getMessage
()
,
"Account Name"
,
accountService
.
getAccountById
(
accountId
),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account Does Not Exists"
,
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
NOT_FOUND
.
getCode
(),
AccountStatus
.
NOT_FOUND
.
getMessage
(),
"Account Name"
,
null
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Please provide Valid account Id"
,
"Account Name"
,
null
,
request
.
getRequestURI
(),
"details"
,
null
);
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
NOT_VALID_ID
.
getCode
(),
AccountStatus
.
NOT_VALID_ID
.
getMessage
(),
"Please provide Valid account Id"
,
null
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
...
src/main/java/com/nisum/myteam/model/vo/DomainVO.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
model
.
vo
;
import
lombok.*
;
import
java.util.HashMap
;
import
java.util.List
;
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public
class
DomainVO
{
private
String
Id
;
private
String
domainId
;
private
String
domainName
;
private
String
accountId
;
private
String
accountName
;
private
String
status
;
private
List
<
HashMap
<
String
,
String
>>
deliveryManagers
;
}
src/main/java/com/nisum/myteam/service/IDomainService.java
View file @
80aed22b
...
...
@@ -3,6 +3,7 @@ package com.nisum.myteam.service;
import
java.util.List
;
import
java.util.Set
;
import
com.nisum.myteam.model.vo.DomainVO
;
import
org.springframework.stereotype.Service
;
import
com.mongodb.WriteResult
;
...
...
@@ -26,7 +27,7 @@ public interface IDomainService {
WriteResult
delete
(
String
id
)
throws
MyTeamException
;
List
<
Domain
>
getDomainsList
()
throws
MyTeamException
;
List
<
Domain
VO
>
getDomainsList
()
throws
MyTeamException
;
Set
<
String
>
accountsAssignedToDeliveryLead
(
String
empId
)
throws
MyTeamException
;
...
...
@@ -35,6 +36,4 @@ public interface IDomainService {
Domain
getDomainById
(
String
domainId
);
}
src/main/java/com/nisum/myteam/service/impl/DomainService.java
View file @
80aed22b
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
com.mongodb.WriteResult
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.vo.DomainVO
;
import
com.nisum.myteam.repository.DomainRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IRoleService
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
/**
* @author Vijay
...
...
@@ -48,6 +43,8 @@ public class DomainService implements IDomainService {
@Autowired
private
IEmployeeRoleService
roleMappingService
;
@Autowired
private
IAccountService
accountService
;
public
boolean
isDomainExists
(
Domain
domainReq
)
{
...
...
@@ -140,13 +137,25 @@ public class DomainService implements IDomainService {
}
@Override
public
List
<
Domain
>
getDomainsList
()
throws
MyTeamException
{
List
<
Domain
>
domainsPersistedList
=
domainRepo
.
findAll
();
for
(
Domain
domainPersisted
:
domainsPersistedList
)
{
domainPersisted
.
setDeliveryManagers
(
prepareEmployeeList
(
domainPersisted
));
public
List
<
DomainVO
>
getDomainsList
()
throws
MyTeamException
{
List
<
DomainVO
>
domainVOS
=
new
ArrayList
<>();
for
(
Domain
domainPersisted
:
domainRepo
.
findAll
())
{
DomainVO
domainVO
=
new
DomainVO
();
domainVO
.
setId
(
domainPersisted
.
getId
().
toString
());
domainVO
.
setAccountId
(
domainPersisted
.
getAccountId
());
domainVO
.
setAccountName
(
accountService
.
getAccountById
(
domainPersisted
.
getAccountId
()).
getAccountName
());
domainVO
.
setDomainId
(
domainPersisted
.
getDomainId
());
domainVO
.
setDomainName
(
domainPersisted
.
getDomainName
());
domainVO
.
setStatus
(
domainPersisted
.
getStatus
());
domainVO
.
setDeliveryManagers
(
prepareEmployeeList
(
domainPersisted
));
domainVOS
.
add
(
domainVO
);
}
return
domain
sPersistedList
;
return
domain
VOS
;
}
@Override
...
...
src/main/java/com/nisum/myteam/statuscodes/AccountStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
enum
AccountStatus
{
CREATE
(
600
,
"Account has been created"
),
UPDATE
(
601
,
"Account has been updated"
),
DELETE
(
602
,
"Account has been deleted successfully"
),
GET_ACCOUNTS
(
603
,
"Retrieved the accounts successfully"
),
GET_ACCOUNT
(
604
,
"Retrieved the account successfully"
),
GET_ACCOUNT_NAMES
(
605
,
"Retrieved the account names successfully"
),
ALREADY_EXISTED
(
606
,
"An Account is already existed"
),
NOT_FOUND
(
607
,
"Account is Not found"
),
NOT_VALID_ID
(
608
,
"AccountId is not valid"
);
private
int
code
;
private
String
message
;
private
String
description
;
private
AccountStatus
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
getCode
()
{
return
this
.
code
;
}
public
String
getMessage
()
{
return
this
.
message
;
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/statuscodes/BillingStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
class
BillingStatus
{
}
src/main/java/com/nisum/myteam/statuscodes/DomainStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
enum
DomainStatus
{
CREATE
(
600
,
"Account has been created"
),
UPDATE
(
601
,
"Account has been updated"
);
private
int
code
;
private
String
message
;
private
DomainStatus
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
getCode
()
{
return
this
.
code
;
}
public
String
getMessage
()
{
return
this
.
message
;
}
}
src/main/java/com/nisum/myteam/statuscodes/EmployeeStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
enum
EmployeeStatus
{
}
src/main/java/com/nisum/myteam/statuscodes/ProjectStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
class
ProjectStatus
{
}
src/main/java/com/nisum/myteam/statuscodes/ResourceStatus.java
0 → 100644
View file @
80aed22b
package
com
.
nisum
.
myteam
.
statuscodes
;
public
class
ResourceStatus
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment