Skip to content

Commit

Permalink
Merge pull request #67 from CaritasDeutschland/feature-reporting-inte…
Browse files Browse the repository at this point in the history
…rface

Feature reporting interface
  • Loading branch information
mobo4b authored Dec 2, 2020
2 parents 5e985b8 + aeec186 commit 95aa8f9
Show file tree
Hide file tree
Showing 42 changed files with 2,108 additions and 53 deletions.
47 changes: 47 additions & 0 deletions api/useradminservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ paths:
$ref: '#/components/schemas/RootDTO'
security:
- Bearer: [ ]
/useradmin/report:
get:
tags:
- admin-user-controller
summary: 'Returns an generated report containing data integration violations. [Authorization:
Role: user-admin]'
operationId: generateViolationReport
responses:
200:
description: OK - successfull operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ViolationDTO'
401:
description: UNAUTHORIZED - no/invalid role/authorization
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]
/useradmin/session:
get:
tags:
Expand Down Expand Up @@ -160,6 +182,31 @@ components:
previous:
$ref: '#/components/schemas/HalLink'

ViolationDTO:
type: object
properties:
violationType:
type: string
enum:
- 'CONSULTANT'
- 'ASKER'
identifier:
type: string
reason:
type: string
additionalInformation:
type: array
items:
$ref: '#/components/schemas/AdditionalInformationDTO'

AdditionalInformationDTO:
type: object
properties:
name:
type: string
value:
type: string

securitySchemes:
Bearer:
type: apiKey
Expand Down
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@
<modelPackage>${project.groupId}.${project.artifactId}.liveservice.generated.web.model</modelPackage>
</configuration>
</execution>
<!-- Generate client API for agency admin service -->
<execution>
<id>agency-admin-service-client-model</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<configOptions>
<sourceFolder>/</sourceFolder>
<library>resttemplate</library>
<dateLibrary>java8</dateLibrary>
</configOptions>
<inputSpec>${project.basedir}/services/agencyadminservice.yaml</inputSpec>
<generatorName>java</generatorName>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<apiPackage>${project.groupId}.${project.artifactId}.agencyadminserivce.generated.web</apiPackage>
<modelPackage>${project.groupId}.${project.artifactId}.agencyadminserivce.generated.web.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
<!-- Liquibase Maven plugin -->
Expand Down
256 changes: 256 additions & 0 deletions services/agencyadminservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
openapi: 3.0.1
info:
title: will be replaced
description: This information will be replaced by the SpringFox config information
version: 0.0.1
servers:
- url: /
paths:
/agencyadmin:
get:
tags:
- root-controller
summary: 'Returns the hal root entry point. [Authorization: Role: agency-admin]'
operationId: getRoot
responses:
200:
description: OK - successfull operation
content:
application/hal+json:
schema:
$ref: '#/components/schemas/RootDTO'
401:
description: UNAUTHORIZED - no/invalid role/authorization
security:
- Bearer: [ ]
/agencyadmin/agencies:
get:
tags:
- admin-agency-controller
summary: 'Returns the list of agencies by search query parameter. [Authorization: Role:
agency-admin]'
operationId: searchAgencies
parameters:
- name: q
in: query
description: The query parameter to search for
schema:
type: string
example: "Freiburg"
- name: page
in: query
description: Number of page where to start in the query (1 = first page)
required: true
schema:
type: integer
example: 1
- name: perPage
in: query
description: Number of items which are being returned per page
required: true
schema:
type: integer
example: 20
responses:
200:
description: OK - successfull operation
content:
'application/hal+json':
schema:
$ref: '#/components/schemas/AgencyAdminSearchResultDTO'
400:
description: BAD REQUEST - invalid/incomplete request or body object
401:
description: UNAUTHORIZED - no/invalid role/authorization
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]
/agencyadmin/dioceses:
get:
tags:
- admin-agency-controller
summary: 'Returns the full list of dioceses [Authorization: Role: agency-admin]'
operationId: getDioceses
parameters:
- name: page
in: query
description: Number of page where to start in the query (1 = first page)
required: true
schema:
type: integer
example: 1
- name: perPage
in: query
description: Number of items which are being returned per page
required: true
schema:
type: integer
example: 20
responses:
200:
description: OK - successfull operation
content:
'application/hal+json':
schema:
$ref: '#/components/schemas/DioceseAdminResultDTO'
400:
description: BAD REQUEST - invalid/incomplete request or body object
401:
description: UNAUTHORIZED - no/invalid role/authorization
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]

components:
schemas:
RootDTO:
type: object
required:
- _links
properties:
_links:
$ref: '#/components/schemas/RootLinks'

RootLinks:
type: object
required:
- self
properties:
self:
$ref: '#/components/schemas/HalLink'
agencies:
$ref: '#/components/schemas/HalLink'

HalLink:
type: object
required:
- href
properties:
href:
type: string
method:
type: string
enum: [ GET, POST, DELETE, PUT ]
templated:
type: boolean

AgencyAdminSearchResultDTO:
type: object
properties:
_embedded:
type: array
items:
$ref: '#/components/schemas/AgencyAdminResponseDTO'
_links:
$ref: '#/components/schemas/SearchResultLinks'

AgencyAdminResponseDTO:
type: object
properties:
agencyId:
type: integer
format: int64
example: 684
dioceseId:
type: integer
format: int64
example: 684
name:
type: string
example: "Suchtberatung Freiburg"
description:
type: string
example: "Our agency provides help for the following topics: Lorem ipsum.."
postcode:
type: string
example: "79106"
city:
type: string
example: "Bonn"
teamAgency:
type: boolean
example: "false"
offline:
type: boolean
example: "false"
consultingType:
type: integer
example: 1
createDate:
type: string
example: "2019-08-23T08:52:05"
updateDate:
type: string
example: "2019-12-02T13:12:08"
deleteDate:
type: string
example: "2020-09-02T15:53:23"
postCodeRanges:
type: array
items:
$ref: '#/components/schemas/PostCodeRangeDTO'

PostCodeRangeDTO:
type: object
properties:
postcodeFrom:
type: string
example: "79106"
postcodeTo:
type: string
example: "79106"

DioceseAdminResultDTO:
type: object
properties:
_embedded:
type: array
items:
$ref: '#/components/schemas/DioceseResponseDTO'
_links:
$ref: '#/components/schemas/PaginationLinks'

DioceseResponseDTO:
type: object
properties:
dioceseId:
type: integer
format: int64
example: 12
name:
type: string
example: "Freiburg"
createDate:
type: string
example: "2019-08-23T08:52:05"
updateDate:
type: string
example: "2019-12-02T13:12:08"

PaginationLinks:
type: object
required:
- self
properties:
self:
$ref: '#/components/schemas/HalLink'
next:
$ref: '#/components/schemas/HalLink'
previous:
$ref: '#/components/schemas/HalLink'

SearchResultLinks:
allOf:
- $ref: '#/components/schemas/PaginationLinks'
- type: object
properties:
search:
$ref: '#/components/schemas/HalLink'

securitySchemes:
Bearer:
type: apiKey
name: Authorization
in: header
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package de.caritas.cob.userservice.api.admin.controller;

import de.caritas.cob.userservice.api.admin.hallink.RootDTOBuilder;
import de.caritas.cob.userservice.api.admin.report.service.ViolationReportGenerator;
import de.caritas.cob.userservice.api.admin.service.SessionAdminService;
import de.caritas.cob.userservice.api.model.Filter;
import de.caritas.cob.userservice.api.model.RootDTO;
import de.caritas.cob.userservice.api.model.SessionAdminResultDTO;
import de.caritas.cob.userservice.api.model.ViolationDTO;
import de.caritas.cob.userservice.generated.api.admin.controller.UseradminApi;
import io.swagger.annotations.Api;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import lombok.NonNull;
Expand All @@ -18,9 +22,11 @@
*/
@RestController
@RequiredArgsConstructor
public class SessionAdminController implements UseradminApi {
@Api(tags = "admin-user-controller")
public class UserAdminController implements UseradminApi {

private final @NonNull SessionAdminService sessionAdminService;
private final @NonNull ViolationReportGenerator violationReportGenerator;

/**
* Creates the root hal based navigation entity.
Expand Down Expand Up @@ -49,5 +55,16 @@ public ResponseEntity<SessionAdminResultDTO> getSessions(@NotNull @Valid Integer
return ResponseEntity.ok(sessionAdminResultDTO);
}


/**
* GET /useradmin/report : Returns an generated report containing data integration violations.
* [Authorization: Role: user-admin].
*
* @return OK - successfull operation (status code 200) or UNAUTHORIZED - no/invalid
* role/authorization (status code 401) or INTERNAL SERVER ERROR - server encountered unexpected
* condition (status code 500)
*/
@Override
public ResponseEntity<List<ViolationDTO>> generateViolationReport() {
return ResponseEntity.ok(this.violationReportGenerator.generateReport());
}
}
Loading

0 comments on commit 95aa8f9

Please sign in to comment.