diff --git a/src/main/asciidoc/models/design/seq_users.puml b/src/main/asciidoc/models/design/seq_users.puml index 138ae43..7cb9023 100644 --- a/src/main/asciidoc/models/design/seq_users.puml +++ b/src/main/asciidoc/models/design/seq_users.puml @@ -1,32 +1,28 @@ ' SPDX-License-Identifier: AGPL-3.0-or-later -' SPDX-FileCopyrightText: 2023 swt23w23 +' SPDX-FileCopyrightText: 2023-2024 swt23w23 @startuml participant User -participant "User:customer" as User_customer -participant "User:admin" as User_admin -participant "UserAccount:userAccount" as userAccount -participant UserController -participant UserManagement -participant UserRepository participant UserDataInitializier -participant Spring +participant UserController +participant UserRepository +participant UserAccount +participant UserManagement participant RegistrationForm +participant Spring == Create Admin == UserDataInitializier -> UserManagement : createAdmin() activate UserDataInitializier activate UserManagement -UserManagement -> UserRepository : "save(User:admin)" -activate User_admin +UserManagement -> UserRepository : "save(admin:User)" activate UserRepository -UserManagement <-- UserRepository : User_admin +UserManagement <-- UserRepository : User deactivate UserRepository UserDataInitializier <-- UserManagement : User deactivate UserManagement deactivate UserDataInitializier -deactivate User_admin == Register Customer == @@ -36,16 +32,21 @@ activate RegistrationForm activate Spring UserController -> RegistrationForm : getUsername() UserController <-- RegistrationForm : String -UserController -> RegistrationForm : getPassword() +UserController -> UserManagement : getUsernameByName(username:String) +activate UserManagement +UserController <-- UserManagement : boolean +deactivate UserManagement +UserController -> RegistrationForm : getUsername() UserController <-- RegistrationForm : String UserController -> RegistrationForm : getAddress() UserController <-- RegistrationForm : String +UserController -> RegistrationForm : getPassword() +UserController <-- RegistrationForm : String UserController -> RegistrationForm : getFullName() UserController <-- RegistrationForm : String -UserController -> UserManagement : createCustomer(String,String,String,String) +UserController -> UserManagement : createCustomer(username:String, address:String, password:String, fullname:String) activate UserManagement -UserManagement -> UserRepository : "save(User:customer)" -activate User_customer +UserManagement -> UserRepository : "save(customer:User)" activate UserRepository UserManagement <-- UserRepository : User deactivate UserRepository @@ -53,23 +54,21 @@ UserController <-- UserManagement : User deactivate UserManagement Spring <-- UserController : "redirect:/login" deactivate UserController -deactivate User_customer deactivate RegistrationForm deactivate Spring == Disable Customer by Customer == -Spring -> UserController : disableUser(UserAccount:userAccount) -activate User_customer +Spring -> UserController : disableUser(userAccount:UserAccount) activate Spring activate UserController -UserController -> UserManagement : disableUserAccount(UserAccount:userAccount) +UserController -> UserManagement : disableUserAccount(userAccount:UserAccount) activate UserManagement -UserManagement -> userAccount : getId() -activate userAccount -UserManagement -> userAccount : UserIdentifier -deactivate userAccount -UserManagement -> UserRepository : disable(UserIdentifier) +UserManagement -> UserAccount : getId() +activate UserAccount +UserManagement <-- UserAccount : Long +deactivate UserAccount +UserManagement -> UserRepository : disable(id:Long) activate UserRepository UserManagement <-- UserRepository deactivate UserRepository @@ -78,65 +77,37 @@ deactivate UserManagement UserController <-- Spring: "redirect:/" deactivate UserController deactivate Spring -deactivate User_customer == View Profile == -Spring -> UserController : viewProfile(Model:model,UserAccount:userAccount) -activate User +Spring -> UserController : viewProfile(model:Model, userAccount:UserAccount) activate Spring activate UserController -UserController -> UserManagement : getUserByAccount(UserAccount:userAccount) +UserController -> UserManagement : getUserByAccount(userAccount:UserAccount) activate UserManagement UserManagement -> UserRepository : findAll() activate UserRepository UserManagement <-- UserRepository : Streamble deactivate UserRepository +UserManagement -> User : getUserAccount() +activate User +UserManagement <-- User : UserAccount +deactivate User +... Several similar operations ... UserController <-- UserManagement : Optional UserController -> User : getUsername() +activate User UserController <-- User : String UserController -> User : getFullName() UserController <-- User : String UserController -> User : getAddress() UserController <-- User : String +deactivate User deactivate UserManagement UserController -> Spring : model.addAttribute("profileForm",ProfileForm) UserController <-- Spring : Model Spring <-- UserController : "profile" deactivate Spring deactivate UserController -deactivate User - -== Edit Profile == - -Spring -> UserController : editProfile(UserAccount:LoggedIn,ProfileForm:form,Erros:result,Model:model) -activate User -activate Spring -activate UserController -UserController -> UserManagement : getUserByAccount(UserAccount:LoggedIn) -activate UserManagement -UserManagement -> UserRepository : findAll() -activate UserRepository -UserManagement <-- UserRepository : Streamble -deactivate UserRepository -UserController <-- UserManagement : Optional -deactivate UserManagement -UserController -> User : setUsername(String:username) -UserController <-- User : boolean -UserController -> User : setAddress(String:address) -UserController <-- User : boolean -UserController -> User : [!form.getUsername().equals(user.getUsername())] setPassword(String:password) -UserController <-- User : boolean -UserController -> UserManagement : save(User:LoggedIn) -activate UserManagement -UserManagement -> UserRepository : save(User:LoggedIn) -activate UserRepository -UserManagement <-- UserRepository : User -deactivate UserRepository -UserController <-- UserManagement : User -deactivate UserManagement -deactivate Spring -deactivate UserController -deactivate User @enduml diff --git a/src/main/asciidoc/models/design/seq_users.svg b/src/main/asciidoc/models/design/seq_users.svg index 5806923..60c5b59 100644 --- a/src/main/asciidoc/models/design/seq_users.svg +++ b/src/main/asciidoc/models/design/seq_users.svg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:746deec5a361ba77933a3a9da52044251f286e966c9714e2995066f0fbcd7135 -size 37808 +oid sha256:b1c141d77629e74d51b18e34bfd355054dadf623cdbdda6ffc194b9d699ab383 +size 36985 diff --git a/src/main/asciidoc/models/design/user.puml b/src/main/asciidoc/models/design/user.puml index fd56e12..3e774a2 100644 --- a/src/main/asciidoc/models/design/user.puml +++ b/src/main/asciidoc/models/design/user.puml @@ -1,115 +1,147 @@ ' SPDX-License-Identifier: AGPL-3.0-or-later -' SPDX-FileCopyrightText: 2023 swt23w23 +' SPDX-FileCopyrightText: 2023-2024 swt23w23 @startuml -'maybe for sneidc since he did videoshop:cahnge-password' skinparam linetype ortho skinparam groupInheritance 2 package Salespoint { - interface UserAccountManagement - interface DataInitalizer - class UserAccount - class AbstractAggregateRoot + interface UserAccountManagement + interface DataInitalizer + class UserAccount class Role - class Errors } package Spring { + interface Validator class CrudRepository class Streamable class WebDataBinder class Errors - interface Validator + class ValidationUtils +} + +package slf4j { + class Logger } package catering.users { - class User { - - address : String - - fullName : String - + User(userAccount : UserAccount, address : String, fullName : String) - + User() - + getAddress() : String - + setAddress(address:String) : String - + getFullName() : String - + setFullName(fullName:String) : String - + getUsername() : String - + setUsername(username:String) : boolean - + getUserAccount() : UserAccount - + getId() : UserIdentifier + class User { + - id : Long + - address : String + - fullName : String + + User() + + User(userAccount:UserAccount, address:String, fullName:String) + + getAddress() : String + + setAddress(address:String) : boolean + + getFullName() : String + + setFullName(fullName:String) : boolean + + getUsername() : String + + setUsername(username:String) : boolean + + getUserAccount() : UserAccount + + getId() : Long + isEnabled() : boolean + hasRole(role:String) : boolean - + equals(obj:Object) : boolean + hashCode() : int - } - User ..> WebDataBinder - User --> UserAccount : "-userAccount" - User --|> AbstractAggregateRoot : <> - - class UserController { - + UserController(userManagement: UserManagement) - - initProfileBinder(binder : WebDataBinder) : void - - initRegistrationBinder(binder : WebDataBinder) : void + + equals(obj:Object) : boolean + } + User --> UserAccount : "-userAccount" + class UserController { + + UserController(userManagement:UserManagement) + - initProfileBinder(binder:WebDataBinder) : void + - initRegistrationBinder(binder:WebDataBinder) : void + - initAdminBinder(binder:WebDataBinder) : void + unauthorized() : String - + register() : String - + register(form:RegistrationForm,result:Errors) : String + + register(model:Model) : String + + register(form:RegistrationForm, result:Errors) : String + loginPage() : String - + viewProfile(model:Model,userAccount:UserAccount) : String - + editProfile(userAccount:UserAccount,form:ProfileForm,result:Errors,model:Model) : String + + viewProfile(model:Model, userAccount:UserAccount) : String + + editProfile(userAccount:UserAccount, form:ProfileForm, result:Errors, model:Model) : String + disableUser(userAccount:UserAccount) : String + getCustomer(model:Model) : String + removeCustomer(user:User) : String - + editCustomer(user:User,model:Model) : String - + updateCustomer(user:User,username:String,address:String) - } - UserController --> UserManagement : "-userManagement" - UserController ..> User - UserController ..> UserAccount - UserController ..> Role - UserController ..> UserForm - UserController ..> FormValidator - UserController ..> WebDataBinder - - class UserManagement { - + UserManagement(users:UserRepository,userAccounts:UserAccountManagement) - + createCustomer(name:String, password:String, address:String) : User - + createAdmin(name:String, password:String, address:String,fullName:String) : User - + save(user:User) : User + + editCustomer(user:User, model:Model) : String + + updateCustomer(user:User, form:AdminForm, result:Errors) : String + } + UserController --> UserManagement : "-userManagement" + UserController ..> User + UserController ..> UserAccount + UserController ..> Role + UserController ..> ProfileForm + UserController ..> RegistrationForm + UserController ..> AdminForm + UserController ..> FormValidator + UserController ..> WebDataBinder + class UserManagement { + + UserManagement(users:UserRepository, userAccounts:UserAccountManagement) + + createCustomer(username:String, address:String, password:String, fullName:String) : User + + createAdmin(name:String, password:String, address:String,fullName:String) : User + + save(user:User) : User + + setPassword(password:String, userAccount:UserAccount): boolean + getUsers() : UserRepository + disableUserAccount(userAccount:UserAccount) : void + getUserByAccount(userAccount:UserAccount) : Optional - } - UserManagement --> UserAccountManagement : "-userAccounts" - UserManagement --> UserRepository : "-users" - UserManagement ..> User - class UserDataInitalizer { + + getUserByName(username:String) : Optional + } + UserManagement --> UserAccountManagement : "-userAccounts" + UserManagement --> UserRepository : "-users" + UserManagement ..> User + UserManagement ..> UserAccount + class UserDataInitalizer { - userManagement : UserManagement - + UserDataInitalizer(userManagement : UserManagement) - + initalize() : void - } - UserDataInitalizer --> UserManagement : "-userManagement" - UserDataInitalizer ..|> DataInitalizer + + UserDataInitalizer(userManagement : UserManagement) + + initalize() : void + } + UserDataInitalizer --> UserManagement : "-userManagement" + UserDataInitalizer --> UserAccountManagement : "-userAccountManagement" + UserDataInitalizer --> Logger : "-LOG" + UserDataInitalizer ..|> DataInitalizer class UserRepository { + findAll() : Streamable } - UserRepository --|> CrudRepository : <> - UserRepository ..|> Streamable - UserRepository o-- User + UserRepository ..|> Streamable + UserRepository o-- User + UserRepository --|> CrudRepository class UserForm { - - username: String - - password: String - - address: String - - password: String - + UserForm(username:String,address:String,fullName:String,password:String) + - username : String + - address : String + - fullName : String + + UserForm(username:String, address:String, fullName:String) + getUsername() : String + getAddress() : String + getFullName() : String + } + abstract class UserFormWithPassword <> { + - password: String + + UserFormWithPassword(username:String, address:String, fullName:String, password:String) + getPassword() : String + + validatePassword(e:Errors) : void + + {abstract} validatePasswordGeneric(e:Errors) : void } - class FormValidator { + UserFormWithPassword --> Errors + UserFormWithPassword --> ValidationUtils + UserFormWithPassword ----+ UserForm + UserFormWithPassword --|> UserForm + class RegistrationForm extends UserFormWithPassword { + + RegistrationForm(username:String, address:String, fullName:String, password:String) + + {static} empty() : RegistrationForm + } + RegistrationForm --+ UserFormWithPassword + class ProfileForm { + + ProfileForm(username:String, address:String, fullName:String, password:String) + } + ProfileForm --+ UserFormWithPassword + ProfileForm --|> UserFormWithPassword + class AdminForm { + + AdminForm(username:String, address:String, fullName:String) + } + AdminForm --+ UserForm + AdminForm --|> UserForm + class FormValidator { supports(c:Class) : boolean - validate(o:Object,e:Errors) : void + validate(o:Object, e:Errors) : void } - FormValidator ..> Validator - FormValidator --> Errors + FormValidator ..|> Validator + FormValidator ..> Errors + FormValidator ..> ValidationUtils } @enduml diff --git a/src/main/asciidoc/models/design/user.svg b/src/main/asciidoc/models/design/user.svg index efcf11d..5c91c92 100644 --- a/src/main/asciidoc/models/design/user.svg +++ b/src/main/asciidoc/models/design/user.svg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18ed7c05540ac28246b9fda2572eb334808743451ba71d78e5657810930574c3 -size 51576 +oid sha256:1234622e25b6a4c91c47e0b372384e1ddeaf3b9d01455413077c8f172548f14d +size 71119