diff --git a/docs/Arc42-Documentation.md b/docs/Arc42-Documentation.md index 1aebec12..3eceb479 100644 --- a/docs/Arc42-Documentation.md +++ b/docs/Arc42-Documentation.md @@ -99,7 +99,59 @@ It will determine what columns we will see on the Table. # System Scope and Context -![System Scope](../docs/Images/StandardisedDataExchange.png) +```mermaid +graph LR + style CatenaXPortal fill:#ffb,stroke:#333,stroke-width:2px + style CountryRiskApplication fill:#ffb,stroke:#333,stroke-width:2px + style ExternalPartners fill:#ffb,stroke:#333,stroke-width:2px + style BPDM fill:#ffb,stroke:#333,stroke-width:2px + style Users fill:#bfb,stroke:#333,stroke-width:1px + style Gate fill:#bfb,stroke:#333,stroke-width:1px + + subgraph CatenaXPortal["Catena-X Portal"] + KeycloakServer["Keycloak Server User Management"] + end + + subgraph CountryRiskApplication["Country Risk Application"] + ReactJSFrontEnd["ReactJS Front-end"] + JavaBackEnd["Java Back-end"] + PostgreSQLDatabase["PostgreSQL Database"] + DashboardController["Dashboard Controller"] + end + + subgraph ExternalPartners["External Partners"] + Systems["Systems"] + subgraph Users["Users"] + User["User"] + AdminUser["Admin User"] + OtherRoles["Other Roles"] + end + end + + subgraph BPDM["BPDM"] + Pool["Pool"] + subgraph Gate["Gate"] + SharingMemberGate1["Sharing Member Gate"] + SharingMemberGate2["Sharing Member Gate"] + SharingMemberGate3["Sharing Member Gate"] + end + end + + CountryRiskApplication -->|Keycloak API auth| CatenaXPortal + Users -->|Login to Portal| CatenaXPortal + Users -->|Login to Dashboard| CountryRiskApplication + Users -->|Interact with Dashboard| CountryRiskApplication + ExternalPartners --> DashboardController + ReactJSFrontEnd --> DashboardController + DashboardController --> JavaBackEnd + JavaBackEnd --> PostgreSQLDatabase + Users -->|Request BP Data| BPDM + DashboardController -->|Get Sharing Member BP Data| Gate + SharingMemberGate1 --> Pool + SharingMemberGate2 --> Pool + SharingMemberGate3 --> Pool + +``` #### Example Data Sources @@ -195,7 +247,28 @@ Dun & Bradstreet, Country Risk ( http://www.dnbcountryrisk.com/, 14 Scores) ## System Scope and EDC Integration -![EDC Integration](Images/StandardisedDataExchangeWithEdc.png) +```mermaid +graph TD + %% Scenario 1: Data Provision + subgraph S1["Scenario 1: Data Provision"] + OtherEDCSystems[("Other EDC Systems")]:::otherStyle -->|consumes data from| EDCProviderCR[("Country Risk EDC Provider")]:::providerStyle + EDCProviderCR -->|requests data from| CRApp[("Country Risk Application")]:::appStyle + end + + %% Scenario 2: Data Consumption + subgraph S2["Scenario 2: Data Consumption"] + CRApp2[("Country Risk Application")]:::appStyle -->|consumes data from| EDCC[("Country Risk EDC Consumer")]:::consumerStyle + EDCC -->|requests data from| EDCGateProvider[("EDC Gate Provider")]:::gateStyle + EDCGateProvider -->|requests data from| BPDM[("BPDM Application")]:::bpdmStyle + end + + classDef appStyle fill:#ffcccc,stroke:#333,stroke-width:4px; + classDef providerStyle fill:#ccffcc,stroke:#333,stroke-width:4px; + classDef consumerStyle fill:#ccccff,stroke:#333,stroke-width:4px; + classDef otherStyle fill:#fff0b3,stroke:#333,stroke-width:4px; + classDef gateStyle fill:#f0b3ff,stroke:#333,stroke-width:4px; + classDef bpdmStyle fill:#ffffb3,stroke:#333,stroke-width:4px; +``` **EDC Operator** * The diagram above shows two EDCs on Operator side. This is only for visualization purpose. On the prespective that both Country Risk and Gate are on the Operator Side. @@ -203,7 +276,22 @@ Dun & Bradstreet, Country Risk ( http://www.dnbcountryrisk.com/, 14 Scores) ## Keycloak Authentication & Autorization Flow -![Keycloak](Images/keyckloak.png) +```mermaid +sequenceDiagram + participant Country Risk EDC Consumer + participant BPDM EDC + participant OpenIDConnect Server + participant BPDM Gate + + autonumber + Country Risk EDC Consumer -->> BPDM EDC: Request Provider for Api With OAuth2 + BPDM EDC -->>OpenIDConnect Server: Send Client Credentials + OpenIDConnect Server-->> BPDM EDC: Respond OAuth2 Token + BPDM EDC -->> BPDM Gate: Send Request with OAuth2 Token in Authorization Header + BPDM Gate -->> OpenIDConnect Server: Validate Token + OpenIDConnect Server -->> BPDM Gate: Confirms validity of Token + BPDM Gate -->> BPDM Gate: Check "resource_access" section of OAuth Token +``` ### Handling Country Risk @@ -249,7 +337,37 @@ This components Diagram represents the possible actions to be done by the user w Each box represents a feature and each arrow between features represents its dependencies, as is the case of the world map that needs a rating selected to be filled in with the available colors. -![InterfaceDisplay](../docs/Images/diagram_compenent.png) +```mermaid +classDiagram +class CompanyUserUI { +<> +} +class WorldMapView { +<> +} +class AvailableRatings { +<> +} +class AvailableRanges { +<> +} +class BPNTable { +<> +} +class CountryPicker { +<> +} +class CompanyView { +<> +} + + CompanyUserUI --|> WorldMapView : Interface + CompanyUserUI --|> AvailableRatings : Interface + CompanyUserUI --|> AvailableRanges : Interface + CompanyUserUI --|> BPNTable : Interface + CompanyUserUI --|> CountryPicker : Interface + CompanyUserUI --|> CompanyView : Interface +``` #### World Map View @@ -257,7 +375,29 @@ Each box represents a feature and each arrow between features represents its dep For this component, it is necessary to call three different APIs that allow mapping the Map and painting based on the score obtained from each country. -![WorldMapAPI](../docs/Images/image2022-10-10_17-4-35.png) +```mermaid +classDiagram + class WorldMapView { + <> + } + class GetWorldMap { + <> + +API() + } + class GetBusinessPartnersCountrys { + <> + +API() + } + class GetBusinessPartnersOfUserCompanys { + <> + +API() + } + + WorldMapView --|> GetWorldMap : Api + WorldMapView --|> GetBusinessPartnersCountrys : Api + WorldMapView --|> GetBusinessPartnersOfUserCompanys : Api + +``` For each of these APIs we can consult its input and output in the APIs section. ##### Sample result @@ -272,7 +412,19 @@ For this component, it is necessary to call just one API that gets the Ratings a Some Ratings may be available globally by user or by the company they belong to but for more details we will address in the functionalities section. -![RatingAPI](../docs/Images/image2022-10-10_17-17-20.png) +```mermaid +classDiagram + class AvailableRatings { + <> + } + class GetRatingsByYear { + <> + +API() + } + + AvailableRatings --|> GetRatingsByYear : Api + +``` #### Ranges @@ -280,7 +432,24 @@ Some Ratings may be available globally by user or by the company they belong to For this component we have a call to two APIs, one that allows searching for a user's ranges, if any, and another that allows saving them if the user wants to for the next validation of the Map. -![RangesAPI](../docs/Images/image2022-10-10_17-33-9.png) +```mermaid +classDiagram + class AvailableRanges { + <> + } + class SaveRangesOfTheUser { + <> + +API() + } + class GetRangesOfTheUser { + <> + +API() + } + + AvailableRanges --|> SaveRangesOfTheUser : Api + AvailableRanges --|> GetRangesOfTheUser : Api + +``` #### Business Partners Table @@ -290,7 +459,19 @@ For this component, it is necessary to call just one API that gets the informati It is necessary for the user to select one or more ratings for this table to be fully initialized, more details in the functionalities section. -![TableAPI](../docs/Images/image2022-10-10_17-42-14.png) +```mermaid +classDiagram + class BPNTable { + <> + } + class GetTableInfo { + <> + +API() + } + + BPNTable --|> GetTableInfo : Api + +``` ##### Sample Result @@ -302,7 +483,19 @@ It is necessary for the user to select one or more ratings for this table to be In this component, we call one API to populate the dropdown menu with a selection of countries. The API used is the getBpnCountries and as explained in the APIs and Swagger section, it retrieves all the countries that are associated to the Business partners. -![PickerAPi](../docs/Images/image2022-10-11_9-13-22.png) +```mermaid +classDiagram + class CountryPicker { + <> + } + class GetCountriesByISO2 { + <> + +API() + } + + CountryPicker --|> GetCountriesByISO2 : API + +``` #### Company View @@ -310,7 +503,29 @@ In this component, we call one API to populate the dropdown menu with a selectio For this component, it is necessary to call three different APIs. The APIs used are the getBpnCountries, getCountryFilterByISO2 and getTableInfo. With the data that we get from this APIs, and also with the value from the selected country in the country picker component, we can present on the map the markers for the Business Partners of the selected country with some information associated to the markers. -![CompanyViewAPI](../docs/Images/image2022-10-11_9-12-26.png) +```mermaid +classDiagram + class CompanyView { + <> + } + class GetCountriesByUser { + <> + +API() + } + class GetCountriesByISO2 { + <> + +API() + } + class GetTableInfo { + <> + +API() + } + + CompanyView --|> GetCountriesByUser : API + CompanyView --|> GetCountriesByISO2 : API + CompanyView --|> GetTableInfo : API + +``` # Interfaces @@ -513,7 +728,108 @@ To set the "Gate" Link the Administrator has to insert the following Information For all the planned use cases, a database was defined where we tried to optimize the relationships and the reuse of dynamic tables to the maximum to avoid extensive links and fields. -![Database](../docs/Images/DataModel_v6.png) +```mermaid +classDiagram +%%CompanyUser + class CompanyUser { + name: String+ + email: String+ + company: String+ + } +%%Country + class Country { + country: String+ + iso2: String + iso3: String + continent: String + } +%%DataSource + class DataSource { + dataSourceName: String+ + type: Type+ + yearPublished: Integer+ + fileName: String + createDate: Instant + } +%%Range + class Range { + range: RangeType+ + value: Integer+ + description: String + } +%%File + class File { + fileName: String+ + content: Blob + createDate: Instant + createdBy: String + version: Float + } + +%%Region + class Region { + name: String+ + type: Type + description: String + } +%% Report + class Report { + reportName: String + companyUserName: String + company: String + type: Type + createDate: Instant + createdBy: String + } +%% DataSourceValue + class DataSourceValue { + country: String+ + iso2: String + iso3: String + continent: String + score: Float + } +%% RangeType + class RangeType { + enum + MAX() + Between() + Min() + } +%% Type + class Type { + enum + Global() + Company() + Custom() + } +%% RegionValue + class RegionValue { + country String + iso2 String + iso3 String + continent String + } +%% ReportValues + class ReportValues { + name String + value String + } + +%% Relations + CompanyUser --o DataSource + CompanyUser --o Range + CompanyUser "1" --o "1..*" File + CompanyUser --o Region + DataSource --o DataSourceValue + DataSource ..o "1..*" Type + Range ..> RangeType + Region ..> Type + Region --o "1..*" RegionValue + Report ..> Type + Report --o "1..*" ReportValues + +``` Entities: @@ -537,13 +853,65 @@ To maintain those 2 Github locations we mainly develop in the CatenaX-ng Github. To contribute to the development please follow these Branching guidelines in the CatenaX-ng environment. -![Branching](../docs/Images/image2023-1-15_21-49-22.png) +```mermaid +flowchart LR + dev["dev"] -->|For Each new Feature a new Branch is created| feature_branch["BPDMP-481-UnitTests\nNaming Scheme:\nUser Story Number- Short Description"] + feature_branch -->|After successful testing the Branch is migrated Back in to the dev Branch| dev + dev -->|Release| release["Release 3.0.0\nFor Each Release a new Image is created to have the possibility of a rollback"] + + subgraph Frontend_and_Backend_Environment["Frontend and Backend Environment"] + dev + end + +``` # Sequence Diagram #### Endpoint: /dashboard/getTableInfo -![getDashboardTableinfo](../docs/Images/DashBoardResource_getAllDashBoardTable.jpg) +```mermaid +sequenceDiagram + participant ActorUser as "Actor User" + participant DashBoardResource as "DashBoard Resource" + participant DashboardService as "Dashboard Service" + participant WorldMapAndTableLogicService as "WorldMap and Table Logic Service" + participant ExternalBusinessPartnersLogicService as "External Business Partners Logic Service" + participant DataSourceValueService as "Data Source Value Service" + participant DataSourceValueRepository as "Data Source Value Repository" + + ActorUser->>+DashBoardResource: 1: getAllDashBoardTable() + DashBoardResource->>+DashboardService: 1.1: getTableInfo() + DashboardService->>+WorldMapAndTableLogicService: 1.1.1: getTableInfo() + + WorldMapAndTableLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.1: getExternalBusinessPartners(companyUser) + ExternalBusinessPartnersLogicService-->>-WorldMapAndTableLogicService: 1.1.1.1: Return Business Partners + + WorldMapAndTableLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.2: getExternalPartnersCountry(companyUser) + ExternalBusinessPartnersLogicService-->>-WorldMapAndTableLogicService: 1.1.1.2: Return Countries + + WorldMapAndTableLogicService->>+DataSourceValueService: 1.1.1.3: findByRatingAndCountryAndScoreGreaterThanAndYear(countryList, dataSources, year) + DataSourceValueService->>+DataSourceValueRepository: 1.1.1.3.1: Query DB + DataSourceValueRepository-->>-DataSourceValueService: 1.1.1.3.1: Return Query Results + DataSourceValueService-->>-WorldMapAndTableLogicService: 1.1.1.3: Return Data + + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.1.4: forEach (setWeight) + WorldMapAndTableLogicService->>+WorldMapAndTableLogicService: 1.1.1.5: mapBusinessPartnerToDashboard(businessPartnerDTOS, dataDTOS, ratingDTOS) + + loop For Each Business Partner + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.1.5.1: Create DashboardTableDTO + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.1.5.2: Associate Business Partners + end + + loop For Each Business Partner + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.1.5.3.1: Calculate Final Score + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.1.5.3.2: Concatenate Ratings + end + + WorldMapAndTableLogicService-->>+DashboardService: 1.1.1: Return DashboardTableDTO + DashboardService-->>-DashBoardResource: 1.1: Return DashboardTableDTO + DashBoardResource-->>-ActorUser: 1: Display DashboardTableDTO + +``` In the DashBoardResource we invoke the method getTableInfo, that is inside the DashboardService. @@ -564,7 +932,39 @@ After that, in the 1.1.1.5.3 method, inside a for iteration, firstly it filters #### Endpoint: /dashboard/getWorldMap -![getWorldMap](../docs/Images/DashBoardResource_getDashBoardWorldMap.png.png) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant WorldMapAndTableLogicService + participant DataSourceValueService + participant DataSourceValueRepository + participant MethodUtils + + ActorUser->>+DashBoardResource: 1: getDashBoardWorldMap(user, year, ratings) + DashBoardResource->>+DashboardService: 1.1: getWorldMapInfo() + DashboardService->>+WorldMapAndTableLogicService: 1.1.1: getWorldMapInfo() + + WorldMapAndTableLogicService->>+DataSourceValueService: 1.1.1.1: findByRatingAndScoreGreaterThanAndYear() + DataSourceValueService->>+DataSourceValueRepository: 1.1.1.1.1: findByRatingAndScoreGreaterThanAndYear() + DataSourceValueRepository-->>-DataSourceValueService: 1.1.1.1.1: Return Results + DataSourceValueService-->>-WorldMapAndTableLogicService: 1.1.1.1: Return Results + + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.2: Assign Weights (Lambda Expression) + + WorldMapAndTableLogicService->>+WorldMapAndTableLogicService: 1.1.3: mapDataSourcesToWorldMap() + WorldMapAndTableLogicService->>+MethodUtils: 1.1.3.1: distinctByKey() + MethodUtils-->>-WorldMapAndTableLogicService: 1.1.3.1: Return Unique Countries + WorldMapAndTableLogicService->>WorldMapAndTableLogicService: 1.1.3.2: Calculate Final Score + WorldMapAndTableLogicService->>+MethodUtils: 1.1.3.2.1: formatFloatToDecimals() + MethodUtils-->>-WorldMapAndTableLogicService: 1.1.3.2.1: Return Formatted Score + + WorldMapAndTableLogicService-->>-DashboardService: 1.1.1: Return Mapped Data + DashboardService-->>-DashBoardResource: 1.1: Return WorldMap Info + DashBoardResource-->>-ActorUser: 1: Display WorldMap + +``` This Get Dashboard World endpoint is the entry point for populating the World Map. @@ -589,7 +989,27 @@ Score: Country → Germany , Score = ( 36 from CPI Rating * 0.4 % ) + 50 from B #### Endpoint: /dashboard/allYears -![getAllYears](../docs/Images/DashBoardResource_getYears.png) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant DataSourceLogicService + participant DataSourceService + participant DataSourceRepository + + ActorUser->>+DashBoardResource: 1: getYears() + DashBoardResource->>+DashboardService: 1.1: getYearsOfUserRatings() + DashboardService->>+DataSourceLogicService: 1.1.1: findRatingsByCompanyUser() + DataSourceLogicService->>+DataSourceService: 1.1.1.1: findRatingByUser() + DataSourceService->>+DataSourceRepository: 1.1.1.1.1: findByCompanyUserNameAndCompanyUserEmailAndCompanyUserCompanyOrType() + DataSourceRepository-->>-DataSourceService: 1.1.1.1.1: Return Ratings + DataSourceService-->>-DataSourceLogicService: 1.1.1.1: Return Ratings + DataSourceLogicService-->>-DashboardService: 1.1.1: Return Ratings + DashboardService-->>-DashBoardResource: 1.1: Return Years + DashBoardResource-->>-ActorUser: 1: Display Years + +``` This endpoint returns all possible years based on the ratings this user can view. So in the UI we have a bar with the years in which, when changing, the user can see the various ratings for each selected year. @@ -599,7 +1019,32 @@ We have only one important method which is the findRatingsByCompanyUser which ba #### Endpoint: /dashboard/ratingsByYear -![getRatings](../docs/Images/DashBoardResource_ratingsByYear.png) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant DataSourceLogicService + participant DataSourceService + participant DataSourceRepository + + ActorUser->>+DashBoardResource: 1: ratingsByYear(year) + DashBoardResource->>+DashboardService: 1.1: findRatingsByYearAndCompanyUser(year, companyUser) + DashboardService->>+DataSourceLogicService: 1.1.1: findRatingsByYearAndCompanyUser(year, companyUser) + + DataSourceLogicService->>+DataSourceService: 1.1.1.1: findRatingsByYearAndTypeGlobal(year) + DataSourceService-->>-DataSourceLogicService: 1.1.1.1: Return Global Ratings + + DataSourceLogicService->>+DataSourceService: 1.1.1.2: findRatingByYearAndUser(year, user) + DataSourceService->>+DataSourceRepository: 1.1.1.2.1: findByYearPublishedAndCompanyUserNameAndCompanyUserEmailAndCompanyUserCompanyAndType(year, userName, userEmail, companyType) + DataSourceRepository-->>-DataSourceService: 1.1.1.2.1: Return User Specific Ratings + DataSourceService-->>-DataSourceLogicService: 1.1.1.2: Return User Specific Ratings + + DataSourceLogicService-->>-DashboardService: 1.1.1: Return All Ratings + DashboardService-->>-DashBoardResource: 1.1: Return All Ratings + DashBoardResource-->>-ActorUser: 1: Display Ratings + +``` This endpoint, as mentioned above, receives the selected year and returns the available ratings for this user based on the year. @@ -610,14 +1055,50 @@ On findRatingsByYearAndCompanyUser we need to call two methods, findRatingsByYea #### Endpoint: /dashboard/getTemplate -![getTemplate](../docs/Images/image2022-10-13_16-45-20.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + + ActorUser->>+DashBoardResource: 1: getTemplate() + DashBoardResource-->>-ActorUser: Return Template +``` This method just implements the download of a template so that users can fill and upload their own ratings. #### Endpoint: /dashboard/uploadCsv -![UploadCSV](../docs/Images/DashBoardResource_uploadFile.png) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyUserLogicService + participant CompanyUserService + participant CompanyUserRepository + participant UploadAndDownloadLogicService + participant DataSourceService + participant DataSourceValueService + participant DataSourceLogicService + + ActorUser->>+DashBoardResource: 1: uploadFile(ratingName, user) + DashBoardResource->>+DashboardService: 1.1: saveCsv(file) + DashboardService->>+CompanyUserLogicService: 1.1.1: getOrCreate(user) + CompanyUserLogicService->>+CompanyUserService: 1.1.1.1: findByNameEmailAndCompany(user) + CompanyUserService->>+CompanyUserRepository: 1.1.1.1.1: findByNameAndEmailAndCompany() + CompanyUserRepository-->>-CompanyUserService: 1.1.1.1.1: Return User + CompanyUserService-->>-CompanyUserLogicService: 1.1.1.1: User + CompanyUserLogicService-->>-DashboardService: 1.1.1: User + DashboardService->>+UploadAndDownloadLogicService: 1.1.2: saveCsv(file, user) + UploadAndDownloadLogicService->>UploadAndDownloadLogicService: 1.1.2.1: Read and Validate Line + UploadAndDownloadLogicService-->>-DashboardService: 1.1.2: Save Completed + DashboardService->>+DataSourceLogicService: 1.1.3: invalidateAllCache() + DataSourceLogicService-->>-DashboardService: 1.1.3: Cache Invalidated + DashboardService-->>-DashBoardResource: 1.1: Completed + DashBoardResource-->>-ActorUser: 1: Upload Finished + +``` This method is used to upload new ratings, it receives the name of the rating and the user who uploaded it as a parameter. @@ -632,7 +1113,27 @@ Each line must contain the Continent of the Country, the name that may vary depe #### Endpoint: /dashboard/getUserRanges -![getRanges](../docs/Images/DashBoardResource_userRanges.png) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant RangeLogicService + participant RangeService + participant RangeRepository + + ActorUser->>+DashBoardResource: 1: userRanges() + DashBoardResource->>+DashboardService: 1.1: getUserRangesOrDefault() + DashboardService->>+RangeLogicService: 1.1.1: getUserRangesOrDefault() + RangeLogicService->>+RangeService: 1.1.1.1: getUserRanges() + RangeService->>+RangeRepository: 1.1.1.1.1: findByCompanyUserNameAndCompanyUserEmailAndCompanyUserCompany() + RangeRepository-->>-RangeService: 1.1.1.1.1: Return Ranges or Default Values + RangeService-->>-RangeLogicService: 1.1.1.1: Ranges + RangeLogicService-->>-DashboardService: 1.1.1: Return Ranges + DashboardService-->>-DashBoardResource: 1.1: Display Ranges + DashBoardResource-->>-ActorUser: 1: Ranges Retrieved + +``` This endpoint is simple, it only validates if the user already has saved ranges or uses default values, these ranges are used to define the range of each color in the UI, which then defines how each country will be painted based on its score. @@ -647,7 +1148,34 @@ Max → 51-100 that represents red color #### Endpoint: /dashboard/getCountryFilterByISO2 -![filterIso2](../docs/Images/DashBoardResource_getCompanyBpns.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CountryLogicService + participant ExternalBusinessPartnersLogicService + participant CompanyUserDTO + participant BusinessPartnersDTO + participant CountryDTO + + ActorUser->>+DashBoardResource: 1: getCountries(CompanyUser) + DashBoardResource->>+DashboardService: 1.1: getCountries(CompanyUser) + DashboardService->>+CountryLogicService: 1.1.1: getCountryFilterByISO2(CompanyUser) + + CountryLogicService->>+CountryLogicService: 1.1.1.1: findAll() + CountryLogicService->>CountryLogicService: 1.1.1.2: distinctByISO2() + loop For Each CountryDTO + CountryLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.3: getTotalBpnByCountry(CountryDTO, CompanyUserDTO) + ExternalBusinessPartnersLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.3.1: getExternalBusinessPartners(CompanyUserDTO) + ExternalBusinessPartnersLogicService-->>-CountryLogicService: List + CountryLogicService->>CountryLogicService: 1.1.1.3: setTotalBpn(List) + end + CountryLogicService-->>-DashboardService: List + DashboardService-->>-DashBoardResource: List + DashBoardResource-->>-ActorUser: Display Countries + +``` This endpoint retrieves all the Countries ordered by their ISO2 code. As a parameter it receives an CompanyUser object. @@ -664,7 +1192,20 @@ After that, the List of CountryDTO's id returned all the way through to the Dash #### Endpoint: /dashboard/getCompanyBpns -![getCompanyBPN](../docs/Images/DashBoardResource_getCompanyBpns.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant ExternalBusinessPartnersLogicService + + ActorUser->>+DashBoardResource: 1: getCompanyBpns() + DashBoardResource->>+DashboardService: 1.1: getExternalBusinessPartners() + DashboardService->>+ExternalBusinessPartnersLogicService: 1.1.1: getExternalBusinessPartners() + ExternalBusinessPartnersLogicService-->>-DashboardService: 1.1.1: Return Business Partners + DashboardService-->>-DashBoardResource: 1.1: Return Business Partners + DashBoardResource-->>-ActorUser: 1: Display Business Partners +``` This endpoint retrieves all the Business partners associated to a company. In the DashboardResource we invoke the getExternalBusinessPartners method, in which we send through an CompanyUser (1.1). @@ -675,7 +1216,36 @@ In the end, after the data is retrieved, this data is returned as a List of Buss #### Endpoint: /dashboard/getBpnCountrys -![getBPNCountry](../docs/Images/DashBoardResource_getBpnCountrys.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CountryLogicService + participant ExternalBusinessPartnersLogicService + participant CountryService + participant CountryRepository + participant EntityMapper + + ActorUser->>+DashBoardResource: 1: getBpnCountries() + DashBoardResource->>+DashboardService: 1.1: getCountryByAssociatedBPtoUser(CompanyUser) + DashboardService->>+CountryLogicService: 1.1.1: getAssociatedCountries(CompanyUser) + + CountryLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.1: getExternalPartnersCountry(CompanyUser) + ExternalBusinessPartnersLogicService-->>-CountryLogicService: 1.1.1.1: Return List of Countries + + CountryLogicService->>+CountryService: 1.1.1.2: findByCountryIn(List) + CountryService->>+CountryRepository: 1.1.1.2.1: findByCountryIn(List) + CountryRepository-->>-CountryService: 1.1.1.2.1: Return List + CountryService->>+EntityMapper: 1.1.1.2.2: toDto(List) + EntityMapper-->>-CountryService: 1.1.1.2.2: Return List + + CountryService-->>-CountryLogicService: 1.1.1.2: Return List + CountryLogicService-->>-DashboardService: 1.1.1: Return List + DashboardService-->>-DashBoardResource: 1.1: Return List + DashBoardResource-->>-ActorUser: 1: Display Countries + +``` This endpoint retrieves all the countries that are associated to the Business partners. In the DashboardResource we invoke the getCountryByAssociatedBPtoUser (1.1) method, in which we send through an CompanyUser. @@ -688,7 +1258,45 @@ The method findByCountryIn (1.1.1.2) we pass the returned List of String of the #### Endpoint: /dashboard/saveUserRanges -![saveRanges](../docs/Images/DashBoardResource_saveRanges.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyUserLogicService + participant CompanyUserService + participant CompanyUserRepository + participant RangeLogicService + participant RangeService + participant RangeRepository + participant RangeMapper + participant ResponseMessage + + ActorUser->>+DashBoardResource: 1: saveRanges(List, CompanyUser) + DashBoardResource->>+DashboardService: 1.1: saveRanges(List, CompanyUser) + DashboardService->>+CompanyUserLogicService: 1.1.1: getOrCreate(CompanyUser) + CompanyUserLogicService->>+CompanyUserService: 1.1.1.1: findByNameEmailAndCompany(CompanyUser) + CompanyUserService->>+CompanyUserRepository: 1.1.1.1.1: findByNameEmailAndCompany(CompanyUser) + CompanyUserRepository-->>-CompanyUserService: 1.1.1.1.1: Return CompanyUser + CompanyUserService-->>-CompanyUserLogicService: 1.1.1.1: Return CompanyUser + CompanyUserLogicService-->>-DashboardService: 1.1.1: Return CompanyUser + DashboardService->>+RangeLogicService: 1.1.2: saveRanges(List, CompanyUser) + RangeLogicService->>+RangeService: 1.1.2.1: getUserRanges(CompanyUser) + RangeService->>+RangeRepository: 1.1.2.1.1: findByCompanyUser(CompanyUser) + RangeRepository-->>-RangeService: 1.1.2.1.1: Return List + RangeService-->>-RangeLogicService: 1.1.2.1: Return List + RangeLogicService->>RangeLogicService: 1.1.2.2: Check and Save Ranges + RangeLogicService->>+RangeMapper: 1.1.2.2.1: toDto(Range) + RangeMapper-->>-RangeLogicService: 1.1.2.2.1: Return RangeDTO + RangeLogicService->>RangeLogicService: 1.1.2.3: Update Ranges + RangeLogicService->>+RangeService: 1.1.2.3.1: setValueForRange(RangeDTO) + RangeService-->>-RangeLogicService: 1.1.2.3.1: Updated RangeDTO + RangeLogicService-->>-DashboardService: 1.1.2: Return List + DashboardService->>ResponseMessage: 1.2: createResponse(List) + DashboardService-->>-DashBoardResource: 1.1: Return ResponseMessage + DashBoardResource-->>-ActorUser: 1: Display ResponseMessage + +``` In this endpoint, it is received as a parameter a List of RangeDTO that contain three different values affect to three different "Types" (Max, Between and Min) and a CompanyUser. @@ -705,7 +1313,39 @@ If the range already exists, in 1.1.2.3 an ForEach iteration is made where the R #### Endpoint: /dashboard/getReportsByCompanyUser -![getReport](../docs/Images/DashBoardResource_getReportsByCompanyUser.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant ReportLogicService + participant ReportService + participant ReportRepository + participant EntityMapper + + ActorUser->>+DashBoardResource: 1: getReportsByCompanyUser(CompanyUser) + DashBoardResource->>+DashboardService: 1.1: getReportsByCompanyUser(CompanyUser) + DashboardService->>+ReportLogicService: 1.1.1: getCompanyReports(CompanyUser.companyName, 'Company') + ReportLogicService->>+ReportService: 1.1.1.1: findByCompanyAndType(CompanyUser.companyName, 'Company') + ReportService->>+ReportRepository: 1.1.1.1.1: findByCompanyAndType(CompanyUser.companyName, 'Company') + ReportRepository-->>-ReportService: 1.1.1.1.1: Return Reports + ReportService->>+EntityMapper: 1.1.1.1.2: toDto(List) + EntityMapper-->>-ReportService: 1.1.1.1.2: Return List + ReportService-->>-ReportLogicService: 1.1.1.1: Return List + + DashboardService->>+ReportLogicService: 1.1.2: getReportsForCompanyUser(CompanyUser.name, CompanyUser.companyName, 'Custom') + ReportLogicService->>+ReportService: 1.1.2.1: findByCompanyUserNameAndCompanyAndType(CompanyUser.name, CompanyUser.companyName, 'Custom') + ReportService->>+ReportRepository: 1.1.2.1.1: findByCompanyUserNameAndCompanyAndType(CompanyUser.name, CompanyUser.companyName, 'Custom') + ReportRepository-->>-ReportService: 1.1.2.1.1: Return Reports + ReportService->>+EntityMapper: 1.1.2.1.2: toDto(List) + EntityMapper-->>-ReportService: 1.1.2.1.2: Return List + ReportService-->>-ReportLogicService: 1.1.2.1: Return List + + ReportLogicService->>ReportLogicService: Combine List + ReportLogicService-->>-DashboardService: 1.1: Return Combined List + DashboardService-->>-DashBoardResource: 1.1: Return Combined List + DashBoardResource-->>-ActorUser: 1: Display Reports +``` In this endpoint, it is received as a parameter only the CompanyUser. It is used to return an list of ReportDTO related to the CompanyUser parameter received. @@ -720,7 +1360,35 @@ After that, this lists are joined into a biggest ReportDTO List, that then is re #### Endpoint: /dashboard/saveReports -![saveReport](../docs/Images/image2023-1-11_9-40-3.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyUserLogicService + participant CompanyUserService + participant ReportLogicService + participant ReportService + participant ResponseMessage + + ActorUser->>+DashBoardResource: 1: saveReport(CompanyUser, ReportDTO) + DashBoardResource->>+DashboardService: 1.1: saveReport(CompanyUser, ReportDTO) + DashboardService->>+CompanyUserLogicService: 1.1.1: getOrCreate(CompanyUser) + CompanyUserLogicService->>+CompanyUserService: 1.1.1.1: findByNameEmailAndCompany(CompanyUser) + CompanyUserService-->>-CompanyUserLogicService: User found or created + CompanyUserLogicService-->>-DashboardService: CompanyUserDTO + DashboardService->>+ReportLogicService: 1.1.2: saveReport(CompanyUserDTO, ReportDTO) + + ReportLogicService->>+ReportService: 1.1.2.1: Check and process ReportDTO + ReportService-->>-ReportLogicService: Report processed + + ReportLogicService-->>-DashboardService: Return result + DashboardService->>+ResponseMessage: 1.2: createResponse() + ResponseMessage-->>-DashboardService: ResponseMessage created + DashboardService-->>-DashBoardResource: ResponseMessage + DashBoardResource-->>-ActorUser: Display Response + +``` In this endpoint, it is received as a parameter the CompanyUser and an ReportDTO that will be saved. It is used to save an ReportDTO related to the CompanyUser parameter received. @@ -739,7 +1407,47 @@ If the report would been duplicated, an Http Bad Request status would be shown, #### Endpoint: /dashboard/shareReports -![shareReports](../docs/Images/image2023-1-11_9-48-39.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyUserService + participant CompanyUserRepository + participant ReportLogicService + participant ReportService + participant ReportRepository + participant EntityMapper + participant ResponseMessage + + ActorUser->>+DashBoardResource: 1: shareReport(CompanyUser, ReportDTO) + DashBoardResource->>+DashboardService: 1.1: shareReport(CompanyUser, ReportDTO) + DashboardService->>+CompanyUserService: 1.1.1: findByNameEmailAndCompany(ReportDTO.name, ReportDTO.email, ReportDTO.company) + CompanyUserService->>+CompanyUserRepository: 1.1.1.1: findByNameEmailAndCompany(ReportDTO) + alt User exists + CompanyUserRepository-->>-CompanyUserService: CompanyUserDTO + CompanyUserService-->>-DashboardService: CompanyUserDTO + DashboardService->>+ReportLogicService: 1.1.2: saveReport(CompanyUserDTO, ReportDTO) + ReportLogicService->>+ReportService: 1.1.2.1: Check Report ID and Save + alt Report ID does not exist + ReportService->>ReportRepository: 1.1.2.1.6: save(ReportDTO) + ReportRepository-->>ReportService: Report saved + ReportService->>ReportService: 1.1.2.1.6.1: Check and Save ReportValues + loop Each ReportValue + ReportService->>ReportService: 1.1.2.1.6.1.x: save(ReportValue) + end + ReportService-->>-ReportLogicService: ReportValues saved + else Report ID exists + ReportLogicService->>ResponseMessage: 1.1.2.2: Http Bad Request (Duplicated) + end + ReportLogicService-->>-DashboardService: Process Completed + else User does not exist + CompanyUserRepository-->>ResponseMessage: 1.1.1.2: Http Not Found + end + DashboardService-->>-DashBoardResource: Response + DashBoardResource-->>-ActorUser: Display Response + +``` In this endpoint, it is received as a parameter the CompanyUser and an ReportDTO that will be used to be shared. It is used to share an ReportDTO related to the CompanyUser parameter received. @@ -758,7 +1466,53 @@ If the report would been duplicated, an Http Bad Request status would be shown, #### Endpoint: /dashboard/updateReports -![updateReports](../docs/Images/image2023-1-11_9-49-15.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyUserLogicService + participant ReportLogicService + participant ReportService + participant ReportRepository + participant ReportValueService + participant ResponseMessage + + ActorUser->>DashBoardResource: 1: updateReport(CompanyUser, ReportDTO) + DashBoardResource->>DashboardService: 1.1: updateReport(CompanyUser, ReportDTO) + DashboardService->>CompanyUserLogicService: 1.1.1: getOrCreate(CompanyUser) + CompanyUserLogicService-->>DashboardService: CompanyUserDTO + DashboardService->>ReportLogicService: 1.1.2: saveReport(CompanyUserDTO, ReportDTO) + + alt If ReportDTO has ID + ReportLogicService->>ReportService: 1.1.2.1: Update Report + ReportService->>ReportRepository: 1.1.2.1.1: findOne(ReportDTO.id) + alt If Report not found + ReportRepository-->>ReportService: Not Found + ReportService-->>ReportLogicService: Http Not Found + else Report found + ReportRepository-->>ReportService: Found Report + ReportService->>ReportService: 1.1.2.1.3: validatePermissionToChangeReport(CompanyUserDTO, ReportDTO) + alt If validation fails + ReportService-->>ReportLogicService: Http Unauthorized + else Validation succeeds + ReportService-->>ReportLogicService: Permission Granted + ReportLogicService->>ReportValueService: 1.1.2.1.4: Update Report Values + ReportValueService-->>ReportLogicService: Report Values Updated + end + end + ReportLogicService-->>DashboardService: Report Processing Complete + else No ID present + ReportLogicService->>ReportService: Create New Report + ReportService-->>ReportLogicService: New Report Created + end + + DashboardService->>ResponseMessage: 1.2: createResponse() + ResponseMessage-->>DashboardService: Response Created + DashboardService-->>DashBoardResource: ResponseMessage + DashBoardResource-->>ActorUser: Display Response + +``` In this endpoint, it is received as a parameter the CompanyUser and an ReportDTO that will be used to be updated. It is used to update an ReportDTO related to the CompanyUser parameter received. @@ -777,18 +1531,80 @@ After this an Http no content alert is shown, as a sign that the request has bee #### Endpoint: /dashboard/getReportsValueByReport -![getValueReport](../docs/Images/image2023-1-11_13-23-10.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant ReportLogicService + participant ReportValuesService + participant EntityMapper + participant ReportValuesRepository + + ActorUser->>+DashBoardResource: 1: getReportsValueByReport(CompanyUser, ReportDTO) + DashBoardResource->>+DashboardService: 1.1: getReportValues(ReportDTO) + + alt If ReportDTO is not null + DashboardService->>+ReportLogicService: 1.1.1: getReportValues(ReportDTO) + ReportLogicService->>+ReportValuesService: 1.1.1.1: findByReport(ReportDTO) + ReportValuesService->>+ReportValuesRepository: 1.1.1.1.1: findByReport(ReportDTO) + ReportValuesRepository-->>-ReportValuesService: List + ReportValuesService->>+EntityMapper: 1.1.1.1.1.1: toDto(List) + EntityMapper-->>-ReportValuesService: List + ReportValuesService-->>-ReportLogicService: List + ReportLogicService-->>-DashboardService: List + DashboardService-->>-DashBoardResource: List + else If ReportDTO is null + DashboardService-->>DashBoardResource: Empty List + end + + DashBoardResource-->>-ActorUser: Display ReportValues + +``` In this endpoint, it is received as a parameter the CompanyUser and an ReportDTO. It is used to return an list of ReportValuesDTO related to the CompanyUser and RepotDTO parameters received. The method 1.1 that is inside the dashboardService class, the 1.1.1 getReportValues is used to firstly do a verification if the ReportDTO parameter is null, in which case an empty ArrayList is returned, otherwise the 1.1.1.1 findByReport method is done to retrieved the data (ReportValuesDTO) associated with the ReportDTO. -After this, an List of ReportValuesDTO is returned in the main class (DashBoardResouce). +After this, an List of ReportValuesDTO is returned in the main class (DashBoardResource). #### Endpoint: /dashboard/getAllUserBPDMGates -![getBPDMGates](../docs/Images/image2023-1-11_9-49-32.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyGatesLogicService + participant CompanyService + participant CompanyRepository + participant CompanyMapperImpl + participant CompanyDTO + participant CompanyGatesService + participant CompanyGatesRepository + participant EntityMapper + + ActorUser->>+DashBoardResource: 1: getAllUserBPDMGates(CompanyUser) + DashBoardResource->>+DashboardService: 1.1: getGatesForCompanyUser(CompanyUser) + DashboardService->>+CompanyGatesLogicService: 1.1.1: getGatesForCompanyUser(CompanyUser) + CompanyGatesLogicService->>+CompanyService: 1.1.1.1: getCompanyByCompanyName(CompanyUser.companyName) + CompanyService->>+CompanyRepository: 1.1.1.1.1: findByCompanyName(CompanyUser.companyName) + CompanyRepository-->>-CompanyService: Company + CompanyService->>+CompanyMapperImpl: 1.1.1.1.1.2: toDto(Company) + CompanyMapperImpl-->>-CompanyService: CompanyDTO + CompanyService-->>-CompanyGatesLogicService: CompanyDTO + CompanyGatesLogicService->>+CompanyGatesService: 1.1.1.2: findByCompanyGroup(CompanyDTO.groupId) + CompanyGatesService->>+CompanyGatesRepository: 1.1.1.2.1: findByCompanyGroup(CompanyDTO.groupId) + CompanyGatesRepository-->>-CompanyGatesService: List + CompanyGatesService->>+EntityMapper: 1.1.1.2.2: toDto(List) + EntityMapper-->>-CompanyGatesService: List + CompanyGatesService-->>-CompanyGatesLogicService: List + CompanyGatesLogicService-->>-DashboardService: List + DashboardService-->>-DashBoardResource: List + DashBoardResource-->>-ActorUser: Display CompanyGatesDTOs + +``` In this endpoint, it is received as a parameter the CompanyUser. It is used to return an list of CompanyGatesDTO related to the CompanyUser. @@ -799,7 +1615,36 @@ After this, an List of CompanyGatesDTOS is returned in the main class (DashBoard #### Endpoint: /sharing/getAllRatingsForCompany -![getAllRatingsforCompany](../docs/Images/image2023-1-11_9-58-31.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant DataSourceLogicService + participant DataSourceService + participant DataSourceRepository + participant EntityMapper + + ActorUser->>+DashBoardResource: 1: getAllRatingsForCompany(CompanyUser, Year) + DashBoardResource->>+DashboardService: 1.1: findRatingsByYearAndCompanyUserCompany(CompanyUser, Year) + DashboardService->>+DataSourceLogicService: 1.1.1: findRatingsByYearAndTypeGlobal(Year) + DataSourceLogicService->>+DataSourceService: 1.1.1.1: findRatingsByYearPublishedAndType(Year, 'Global') + DataSourceService->>+DataSourceRepository: 1.1.1.1.1: findByYearPublishedAndType(Year, 'Global') + DataSourceRepository-->>-DataSourceService: List + DataSourceService->>+EntityMapper: 1.1.1.1.2: toDto(List) + EntityMapper-->>-DataSourceService: List + DataSourceService-->>-DataSourceLogicService: List + DataSourceLogicService->>+DataSourceService: 1.1.1.2: findByYearPublishedAndCompanyUserCompanyNameAndType(Year, CompanyUser.companyName, 'Company') + DataSourceService->>+DataSourceRepository: 1.1.1.2.1: findByYearPublishedAndCompanyUserCompanyNameAndType(Year, CompanyUser.companyName, 'Company') + DataSourceRepository-->>-DataSourceService: List + DataSourceService->>+EntityMapper: 1.1.1.2.2: toDto(List) + EntityMapper-->>-DataSourceService: List + DataSourceService-->>-DataSourceLogicService: List + DataSourceLogicService-->>-DashboardService: Combined List + DashboardService-->>-DashBoardResource: Combined List + DashBoardResource-->>-ActorUser: Display DataSources + +``` In this endpoint, it is received as a parameter the CompanyUser and a Integer Year. It is used to return an list of DataSourceDTO related to the CompanyUser and inserted year. @@ -812,7 +1657,47 @@ After this, both lists are join onto one and returned in the main class as an Li #### Endpoint: /sharing/getAllRatingsScoresForEachBpn -![getRatingsScore](../docs/Images/image2023-1-11_9-58-28.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant ShareLogicService + participant ExternalBusinessPartnersLogicService + participant DataSourceValueService + participant DataSourceValueRepository + participant ShareDTO + participant ShareRatingDTO + + ActorUser->>+DashBoardResource: 1: getAllRatingsScoresForEachBpn(CompanyUser, dataSource, businessPartner) + DashBoardResource->>+DashboardService: 1.1: findRatingsScoresForEachBpn(CompanyUser, dataSource, businessPartner) + DashboardService->>+ShareLogicService: 1.1.1: findRatingsScoresForEachBpn + ShareLogicService->>+ExternalBusinessPartnersLogicService: 1.1.1.1: getExternalBusinessPartners + ExternalBusinessPartnersLogicService-->>-ShareLogicService: List + + loop For each BusinessPartner + ShareLogicService->>ShareLogicService: Add country to BusinessPartnerDTO + end + + ShareLogicService->>ShareLogicService: 1.1.1.3: Create List of Countries from BusinessPartnerDTO + ShareLogicService->>ShareLogicService: 1.1.1.4: Create List of Data Source Names from DataSourceDTO + + loop For each DataSource + ShareLogicService->>+DataSourceValueService: 1.1.1.3.1: findRatingAndCountryAndScoreGreaterThanAndYear + DataSourceValueService->>+DataSourceValueRepository: 1.1.1.3.1.1: findByRatingAndCountryAndScoreGreaterThanAndYear + DataSourceValueRepository-->>-DataSourceValueService: List + DataSourceValueService-->>-ShareLogicService: List + end + + loop For each ShareDTO + ShareLogicService->>ShareLogicService: 1.1.1.5: Map DataDTO to ShareDTO + end + + ShareLogicService-->>-DashboardService: List + DashboardService-->>-DashBoardResource: List + DashBoardResource-->>-ActorUser: Display ShareDTOs + +``` In this endpoint, it is received as a parameter the CompanyUser an dataSource object and a businessPartner object. It is used to return an list of ShareDTO(Mapped ratings to the business partners) related to the parameters inserted. @@ -826,12 +1711,61 @@ Then, an List of String that will get the name of the Data Sources will also be With this, the DataSource parameter will be iterated with the for each clause, and an List of DataDTO will be filled according with the method 1.1.1.3.1.1, using as parameter both DataSource names and countries String list. -Finnaly, the mapping will be done for each ShareDTO, that then will return inside of an List. +Finally, the mapping will be done for each ShareDTO, that then will return inside of an List. #### Endpoint: /dashboard/deleteReport/{id} -![deleteReport](../docs/Images/image2023-1-11_9-58-36.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant ReportLogicService + participant ReportService + participant ReportValuesService + participant ReportValuesRepository + + ActorUser->>DashBoardResource: 1: deleteReport(CompanyUser, id) + DashBoardResource->>DashboardService: 1.1: deleteReportFromUserById(CompanyUser, id) + DashboardService->>ReportLogicService: 1.1.1: deleteReportById(id) + + ReportLogicService->>ReportService: 1.1.1.1: findOne(id) + ReportService->>ReportValuesRepository: 1.1.1.1.1: findById(id) + alt If Report not found + ReportValuesRepository-->>ReportService: Not Found + ReportService-->>ReportLogicService: Not Found + ReportLogicService-->>DashboardService: Not Found + DashboardService-->>DashBoardResource: Not Found + DashBoardResource-->>ActorUser: Http Not Found + else Report found + ReportValuesRepository-->>ReportService: ReportEntity + ReportService-->>ReportLogicService: ReportEntity + + ReportLogicService->>ReportLogicService: 1.1.1.3: validatePermissionToChangeReport(CompanyUser, ReportEntity) + alt If User has permission + ReportLogicService->>ReportValuesService: 1.1.1.4: findByReport(ReportEntity) + ReportValuesService->>ReportValuesRepository: 1.1.1.4.1: findByReport(ReportEntity) + ReportValuesRepository-->>ReportValuesService: List + ReportValuesService-->>ReportLogicService: List + + loop For each ReportValue + ReportLogicService->>ReportValuesRepository: 1.1.1.5: delete(ReportValue) + ReportValuesRepository-->>ReportLogicService: Delete success + end + ReportLogicService->>ReportValuesRepository: 1.1.1.6: delete(ReportEntity) + ReportValuesRepository-->>ReportLogicService: Delete success + ReportLogicService-->>DashboardService: Delete success + DashboardService-->>DashBoardResource: Delete success + DashBoardResource-->>ActorUser: Http No Content + else If User does not have permission + ReportLogicService-->>DashboardService: Unauthorized + DashboardService-->>DashBoardResource: Unauthorized + DashBoardResource-->>ActorUser: Http Unauthorized + end + end + +``` This endpoint receives and CompanyUser and also an Long variable which is the id. It is used to delete an Report. @@ -848,7 +1782,58 @@ After this, in the main class DashBoardResource, and Http no content is presente #### Endpoint: /dashboard/deleteRating/{id} -![deleteRating](../docs/Images/image2023-1-11_9-58-39.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant DataSourceLogicService + participant DataSourceService + participant DataSourceMapper + participant DataSourceValueService + participant EntityMapper + participant DataSourceValueRepository + + ActorUser->>DashBoardResource: 1: deleteRating(CompanyUser, id) + DashBoardResource->>DashboardService: 1.1: deleteRatingFromUserById(CompanyUser, id) + DashboardService->>DataSourceLogicService: 1.1.1: deleteDataSourceById(id) + + DataSourceLogicService->>DataSourceService: 1.1.1.1: findOne(id) + DataSourceService->>DataSourceValueRepository: 1.1.1.1.1: findById(id) + alt If DataSource not found + DataSourceValueRepository-->>DataSourceService: Not Found + DataSourceService-->>DataSourceLogicService: Not Found + DataSourceLogicService-->>DashboardService: Not Found + DashboardService-->>DashBoardResource: Not Found + DashBoardResource-->>ActorUser: Http Not Found + else DataSource found + DataSourceValueRepository-->>DataSourceService: DataSourceEntity + DataSourceService-->>DataSourceLogicService: DataSourceEntity + + DataSourceLogicService->>DataSourceLogicService: 1.1.1.2: validatePermissionToChangeDataSource(CompanyUser, DataSourceEntity) + alt If User has permission + DataSourceLogicService->>DataSourceValueService: 1.1.1.3: findByDataSource(DataSourceEntity) + DataSourceValueService->>DataSourceValueRepository: 1.1.1.3.1: findByDataSource(DataSourceEntity) + DataSourceValueRepository-->>DataSourceValueService: List + DataSourceValueService-->>DataSourceLogicService: List + + loop For each DataSourceValue + DataSourceLogicService->>DataSourceValueRepository: 1.1.1.4: delete(DataSourceValue) + DataSourceValueRepository-->>DataSourceLogicService: Delete success + end + DataSourceLogicService->>DataSourceValueRepository: 1.1.1.5: delete(DataSourceEntity) + DataSourceValueRepository-->>DataSourceLogicService: Delete success + DataSourceLogicService-->>DashboardService: Delete success + DashboardService-->>DashBoardResource: Delete success + DashBoardResource-->>ActorUser: Http No Content + else If User does not have permission + DataSourceLogicService-->>DashboardService: Unauthorized + DashboardService-->>DashBoardResource: Unauthorized + DashBoardResource-->>ActorUser: Http Unauthorized + end + end + +``` This endpoint receives and CompanyUser and also an Long variable which is the id. It is used to delete an Rating. @@ -865,7 +1850,30 @@ After this, in the main class DashBoardResource, and Http no content is presente #### Endpoint: /dashboard/getUserFromCompany -![getCompany](../docs/Images/image2023-1-11_9-58-21.jpg) +```mermaid +sequenceDiagram + participant ActorUser + participant DashBoardResource + participant DashboardService + participant CompanyLogicService + participant CompanyUserService + participant CompanyUserRepository + participant EntityMapper + + ActorUser->>+DashBoardResource: 1: getUserFromCompany(CompanyUser) + DashBoardResource->>+DashboardService: 1.1: getUsersFromCompany(CompanyUser) + DashboardService->>+CompanyLogicService: 1.1.1: getUsersFromCompany(CompanyUser) + CompanyLogicService->>+CompanyUserService: 1.1.1.1: findAllUserFromCompany(CompanyUser.companyName) + CompanyUserService->>+CompanyUserRepository: 1.1.1.1.1: findByCompanyName(CompanyUser.companyName) + CompanyUserRepository-->>-CompanyUserService: List + CompanyUserService->>+EntityMapper: 1.1.1.1.2: toDto(List) + EntityMapper-->>-CompanyUserService: List + CompanyUserService-->>-CompanyLogicService: List + CompanyLogicService-->>-DashboardService: List + DashboardService-->>-DashBoardResource: List + DashBoardResource-->>-ActorUser: Display CompanyUsers + +``` This endpoint receives as an parameter an CompanyUser. It is used to retrieve an List of CompanyUserDto from an company. diff --git a/docs/Images/DashBoardResource_getAllDashBoardTable.jpg b/docs/Images/DashBoardResource_getAllDashBoardTable.jpg deleted file mode 100644 index 0559dfcc..00000000 Binary files a/docs/Images/DashBoardResource_getAllDashBoardTable.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_getBpnCountrys.jpg b/docs/Images/DashBoardResource_getBpnCountrys.jpg deleted file mode 100644 index 5f3de75a..00000000 Binary files a/docs/Images/DashBoardResource_getBpnCountrys.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_getCompanyBpns.jpg b/docs/Images/DashBoardResource_getCompanyBpns.jpg deleted file mode 100644 index d0d5dc3c..00000000 Binary files a/docs/Images/DashBoardResource_getCompanyBpns.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_getCountrys.jpg b/docs/Images/DashBoardResource_getCountrys.jpg deleted file mode 100644 index bd148ccb..00000000 Binary files a/docs/Images/DashBoardResource_getCountrys.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_getDashBoardWorldMap.png.png b/docs/Images/DashBoardResource_getDashBoardWorldMap.png.png deleted file mode 100644 index 1517ce41..00000000 Binary files a/docs/Images/DashBoardResource_getDashBoardWorldMap.png.png and /dev/null differ diff --git a/docs/Images/DashBoardResource_getReportsByCompanyUser.jpg b/docs/Images/DashBoardResource_getReportsByCompanyUser.jpg deleted file mode 100644 index e345667a..00000000 Binary files a/docs/Images/DashBoardResource_getReportsByCompanyUser.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_getYears.png b/docs/Images/DashBoardResource_getYears.png deleted file mode 100644 index a71c26b4..00000000 Binary files a/docs/Images/DashBoardResource_getYears.png and /dev/null differ diff --git a/docs/Images/DashBoardResource_ratingsByYear.png b/docs/Images/DashBoardResource_ratingsByYear.png deleted file mode 100644 index aa3492af..00000000 Binary files a/docs/Images/DashBoardResource_ratingsByYear.png and /dev/null differ diff --git a/docs/Images/DashBoardResource_saveRanges.jpg b/docs/Images/DashBoardResource_saveRanges.jpg deleted file mode 100644 index a16d9a87..00000000 Binary files a/docs/Images/DashBoardResource_saveRanges.jpg and /dev/null differ diff --git a/docs/Images/DashBoardResource_uploadFile.png b/docs/Images/DashBoardResource_uploadFile.png deleted file mode 100644 index 1a68251d..00000000 Binary files a/docs/Images/DashBoardResource_uploadFile.png and /dev/null differ diff --git a/docs/Images/DashBoardResource_userRanges.png b/docs/Images/DashBoardResource_userRanges.png deleted file mode 100644 index 3a387c51..00000000 Binary files a/docs/Images/DashBoardResource_userRanges.png and /dev/null differ diff --git a/docs/Images/diagram_compenent.png b/docs/Images/diagram_compenent.png deleted file mode 100644 index 5c806034..00000000 Binary files a/docs/Images/diagram_compenent.png and /dev/null differ diff --git a/docs/Images/image2022-10-10_17-17-20.png b/docs/Images/image2022-10-10_17-17-20.png deleted file mode 100644 index f4341897..00000000 Binary files a/docs/Images/image2022-10-10_17-17-20.png and /dev/null differ diff --git a/docs/Images/image2022-10-10_17-33-9.png b/docs/Images/image2022-10-10_17-33-9.png deleted file mode 100644 index 09a0558c..00000000 Binary files a/docs/Images/image2022-10-10_17-33-9.png and /dev/null differ diff --git a/docs/Images/image2022-10-10_17-4-35.png b/docs/Images/image2022-10-10_17-4-35.png deleted file mode 100644 index 086cd55d..00000000 Binary files a/docs/Images/image2022-10-10_17-4-35.png and /dev/null differ diff --git a/docs/Images/image2022-10-10_17-42-14.png b/docs/Images/image2022-10-10_17-42-14.png deleted file mode 100644 index ac446a64..00000000 Binary files a/docs/Images/image2022-10-10_17-42-14.png and /dev/null differ diff --git a/docs/Images/image2022-10-11_9-12-26.png b/docs/Images/image2022-10-11_9-12-26.png deleted file mode 100644 index b338a476..00000000 Binary files a/docs/Images/image2022-10-11_9-12-26.png and /dev/null differ diff --git a/docs/Images/image2022-10-11_9-13-22.png b/docs/Images/image2022-10-11_9-13-22.png deleted file mode 100644 index 92911474..00000000 Binary files a/docs/Images/image2022-10-11_9-13-22.png and /dev/null differ diff --git a/docs/Images/image2022-10-13_16-45-20.jpg b/docs/Images/image2022-10-13_16-45-20.jpg deleted file mode 100644 index 872c50d0..00000000 Binary files a/docs/Images/image2022-10-13_16-45-20.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_13-23-10.jpg b/docs/Images/image2023-1-11_13-23-10.jpg deleted file mode 100644 index 4f44237f..00000000 Binary files a/docs/Images/image2023-1-11_13-23-10.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-40-3.jpg b/docs/Images/image2023-1-11_9-40-3.jpg deleted file mode 100644 index 5ca2c130..00000000 Binary files a/docs/Images/image2023-1-11_9-40-3.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-48-39.jpg b/docs/Images/image2023-1-11_9-48-39.jpg deleted file mode 100644 index 1f35348e..00000000 Binary files a/docs/Images/image2023-1-11_9-48-39.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-49-15.jpg b/docs/Images/image2023-1-11_9-49-15.jpg deleted file mode 100644 index 432c9eb8..00000000 Binary files a/docs/Images/image2023-1-11_9-49-15.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-49-32.jpg b/docs/Images/image2023-1-11_9-49-32.jpg deleted file mode 100644 index 86b1bcbe..00000000 Binary files a/docs/Images/image2023-1-11_9-49-32.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-58-21.jpg b/docs/Images/image2023-1-11_9-58-21.jpg deleted file mode 100644 index c69eb8e2..00000000 Binary files a/docs/Images/image2023-1-11_9-58-21.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-58-28.jpg b/docs/Images/image2023-1-11_9-58-28.jpg deleted file mode 100644 index 3803ed7d..00000000 Binary files a/docs/Images/image2023-1-11_9-58-28.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-58-31.jpg b/docs/Images/image2023-1-11_9-58-31.jpg deleted file mode 100644 index 85406c7c..00000000 Binary files a/docs/Images/image2023-1-11_9-58-31.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-58-36.jpg b/docs/Images/image2023-1-11_9-58-36.jpg deleted file mode 100644 index 3e3740bc..00000000 Binary files a/docs/Images/image2023-1-11_9-58-36.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-11_9-58-39.jpg b/docs/Images/image2023-1-11_9-58-39.jpg deleted file mode 100644 index 55115fbd..00000000 Binary files a/docs/Images/image2023-1-11_9-58-39.jpg and /dev/null differ diff --git a/docs/Images/image2023-1-15_21-49-22.png b/docs/Images/image2023-1-15_21-49-22.png deleted file mode 100644 index 4a10c033..00000000 Binary files a/docs/Images/image2023-1-15_21-49-22.png and /dev/null differ diff --git a/docs/mermaid/company_user.mermaid b/docs/mermaid/company_user.mermaid new file mode 100644 index 00000000..e4f7a1f5 --- /dev/null +++ b/docs/mermaid/company_user.mermaid @@ -0,0 +1,29 @@ +classDiagram +class CompanyUserUI { +<> +} +class WorldMapView { +<> +} +class AvailableRatings { +<> +} +class AvailableRanges { +<> +} +class BPNTable { +<> +} +class CountryPicker { +<> +} +class CompanyView { +<> +} + + CompanyUserUI --|> WorldMapView : Interface + CompanyUserUI --|> AvailableRatings : Interface + CompanyUserUI --|> AvailableRanges : Interface + CompanyUserUI --|> BPNTable : Interface + CompanyUserUI --|> CountryPicker : Interface + CompanyUserUI --|> CompanyView : Interface \ No newline at end of file