Commit dcd2c73d authored by dietricf's avatar dietricf
Browse files

Merge branch 'SI-65_REF-Tables_HR' of...

Merge branch 'SI-65_REF-Tables_HR' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.backend into DEVELOP
parents c67817c1 9d3ac8c6
......@@ -23,6 +23,9 @@ openKonsequenz - Architecture of the module 'Contact Base Data'
:source-highlighter: highlightjs
:highlightjs-theme: solarized_dark
:imagesdir: ../img
:iconsdir: ../img/icons
This documentation is based on the ARC42-Template (v7.0):
== Introduction and Goals
......@@ -478,43 +481,45 @@ The interfaces of the module 'Contact Base Data' are described in the interface
=== Solution Strategy
The module 'Contact Base Data' bases on a three-tier architecture:
. *Frontend* - The GUI is implemented as a web-frontend with rich-client functionalities.
. *Backend* - The business functionalities are implemented in the backend tier. It provides the business functions via RESTful Webservices.
. *Database* - The database stores all module specific data.
The module 'Grid Failure Information' bases on a small microservice architecture, including
an asynchronous messaging system.
== Building Block View
=== Whitebox Overall System
The module 'Contact Base Data' contains two components (see figure 2):
. *UI* - Represents the graphical user interface and consumes the services from the business logic component via RESTful webservices.
. *Business Logic* - Realizes the business functionality and the data storage of the module. The
module itself is split up in several components due to the requirement to use
microservices.
.Module components
The module 'grid failure information' contains several components:
. *SIT-Web-FE* - This component (SPA with Angular) provides two HTML pages: a table and a map
with failure information. This component is in the DMZ and can be called up from the Internet.
. *SIT-Web-Guard* - The SIT-Web-Guard (Java Spring Cloud) is a Zuul proxy
(API gateway) that only forwards explicitly configured services. For the failure information
tool, only certain services are available on the Internet that do not require authentication.
Since the SIT-BE is protected by Spring Security, the SIT-Web-Guard procures guest authentication for forwarding.
. *SIT-FE* -
This component (SPA with Angular) provides the user interface for the failure information application. The SIT-FE
receives its authentication when it is called from the PortalFE in the form of a JWT.
. *SIT_BE* - The SIT-BE (Java Spring Boot Microservice) provides all CRUD services in the form of
ReST services that the two frontends require. The SIT-BE is the only component that has
access to the database. Every call is authorized against the PortalBE. This microservice also includes
the JobManager subcomponent.
. *JobManager* - The various imports and exports are controlled via the JobManager. The JobManager
knows all available import and export jobs and can control them via the internal message bus
(RabbitMQ internal). Because the communication between the JobManager and the jobs takes place
via the message bus, the JM does not need to know their configuration and URLs. For this, the JM must
ensure synchronization (incl. timeout behavior) for asynchronous message communication.
. *Import- and export jobs* - All jobs provide a uniform (MessageBus) interface to start a job,
return the result of a job, or to provide information about the respective job (name, version, timeout, status, etc.).
The job manager cyclically requests all configured jobs to send current status information to it.
The interfaces of the individual jobs "outside" can be very different (file system, Internet, message queue, etc.)
.Architecture of the grid failure information tool
[options="header,footer"]
[plantuml]
----
node Module {
rectangle UI
rectangle BusinessLogic
interface REST
UI -> REST
REST -- BusinessLogic
}
----
image::architectureSIT.png[]
The communication between WebBrowser and Apache Tomcat is established via HTTP/HTTPS.
ApacheTomcat is connected to the data source (PostgresDBMS) via TCP/IP.
==== contactBaseDataFE
......
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.controller;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.service.FailureClassificationService;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureClassificationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Log4j2
@RestController
@RequestMapping("/failure-classifications")
public class FailureClassificationController {
@Autowired
private FailureClassificationService failureClassificationService;
@ApiOperation(value = "Anzeigen aller Störungsmeldungsklassen")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping
public List<FailureClassificationDto> findBranches() {
return failureClassificationService.getFailureClassifications();
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.controller;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.service.FailureTypeService;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureTypeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Log4j2
@RestController
@RequestMapping("/failure-types")
public class FailureTypeController {
@Autowired
private FailureTypeService failureTypeService;
@ApiOperation(value = "Anzeigen aller Störungsmeldungstypen")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping
public List<FailureTypeDto> findBranches() {
return failureTypeService.getFailureTypes();
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.controller;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.service.StatusService;
import org.eclipse.openk.gridfailureinformation.viewmodel.StatusDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Log4j2
@RestController
@RequestMapping("/status")
public class StatusController {
@Autowired
private StatusService statusService;
@ApiOperation(value = "Anzeigen aller Status")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping
public List<StatusDto> findStatus() {
return statusService.getStatus();
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.mapper;
import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureClassificationDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface FailureClassificationMapper {
FailureClassificationDto toFailureClassificationDto(RefFailureClassification refFailureClassification);
RefFailureClassification toRefFailureClassification(FailureClassificationDto failureClassificationDto);
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.mapper;
import org.eclipse.openk.gridfailureinformation.model.RefFailureType;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureTypeDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface FailureTypeMapper {
FailureTypeDto toFailureTypeDto(RefFailureType refFailureType);
RefFailureType toRefFailureType(FailureTypeDto failureTypeDto);
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.mapper;
import org.eclipse.openk.gridfailureinformation.model.RefStatus;
import org.eclipse.openk.gridfailureinformation.viewmodel.StatusDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface StatusMapper {
StatusDto toStatusDto(RefStatus refStatus);
RefStatus toRefStatus(StatusDto statusDto);
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.service;
import org.eclipse.openk.gridfailureinformation.mapper.FailureClassificationMapper;
import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureClassificationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class FailureClassificationService {
@Autowired
private FailureClassificationRepository failureClassificationRepository;
@Autowired
private FailureClassificationMapper failureClassificationMapper;
public List<FailureClassificationDto> getFailureClassifications() {
return failureClassificationRepository.findAll().stream()
.map( failureClassificationMapper::toFailureClassificationDto )
.collect(Collectors.toList());
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.service;
import org.eclipse.openk.gridfailureinformation.mapper.FailureTypeMapper;
import org.eclipse.openk.gridfailureinformation.repository.FailureTypeRepository;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureTypeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class FailureTypeService {
@Autowired
private FailureTypeRepository failureTypeRepository;
@Autowired
private FailureTypeMapper failureTypeMapper;
public List<FailureTypeDto> getFailureTypes() {
return failureTypeRepository.findAll().stream()
.map( failureTypeMapper::toFailureTypeDto )
.collect(Collectors.toList());
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.service;
import org.eclipse.openk.gridfailureinformation.mapper.StatusMapper;
import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
import org.eclipse.openk.gridfailureinformation.viewmodel.StatusDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class StatusService {
@Autowired
private StatusRepository statusRepository;
@Autowired
private StatusMapper statusMapper;
public List<StatusDto> getStatus() {
return statusRepository.findAll().stream()
.map( statusMapper::toStatusDto )
.collect(Collectors.toList());
}
}
......@@ -27,3 +27,4 @@ public class FailureClassificationDto implements Serializable {
private String classification;
private String description;
}
......@@ -20,9 +20,7 @@ import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapperI
import org.eclipse.openk.gridfailureinformation.mapper.VersionMapper;
import org.eclipse.openk.gridfailureinformation.mapper.VersionMapperImpl;
import org.eclipse.openk.gridfailureinformation.mapper.*;
import org.eclipse.openk.gridfailureinformation.service.BranchService;
import org.eclipse.openk.gridfailureinformation.service.FailureInformationService;
import org.eclipse.openk.gridfailureinformation.service.VersionService;
import org.eclipse.openk.gridfailureinformation.service.*;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
import org.springframework.context.annotation.Bean;
......@@ -39,18 +37,33 @@ public class TestConfiguration {
VersionMapper versionMapper() { return new VersionMapperImpl(); }
@Bean
FailureInformationMapper gridFailureInformationMapper() { return new FailureInformationMapperImpl(); }
FailureInformationMapper failureInformationMapper() { return new FailureInformationMapperImpl(); }
@Bean
BranchMapper branchMapper() { return new BranchMapperImpl(); }
@Bean
FailureClassificationMapper failureClassificationMapper() {
return new FailureClassificationMapperImpl();
}
@Bean
FailureTypeMapper failureTypeMapper() {
return new FailureTypeMapperImpl();
}
@Bean
StatusMapper statusMapper() {
return new StatusMapperImpl();
}
@Bean
public VersionService myVersionService() {
return new VersionService();
}
@Bean
public FailureInformationService myGridFailureInformationService() {
public FailureInformationService myFailureInformationService() {
return new FailureInformationService();
}
......@@ -59,4 +72,18 @@ public class TestConfiguration {
return new BranchService();
}
@Bean
public FailureClassificationService myFailureClassificationService() {
return new FailureClassificationService();
}
@Bean
public FailureTypeService myFailureTypeService() {
return new FailureTypeService();
}
@Bean
public StatusService myStatusService() {
return new StatusService();
}
}
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.controller;
import org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication;
import org.eclipse.openk.gridfailureinformation.service.FailureClassificationService;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureClassificationDto;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.List;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(classes = GridFailureInformationApplication.class)
@AutoConfigureMockMvc
public class FailureClassificationControllerTest {
@MockBean
private FailureClassificationService failureClassificationService;
@Autowired