Commit d689bacd authored by dietricf's avatar dietricf
Browse files

SI-61 Basis DB, Model, Mapper, DTO, Service, Repo und Controller für...

SI-61 Basis DB, Model, Mapper, DTO, Service, Repo und Controller für GridFailureInformation und abhängige Ref-Tabellen. OHNE SonarWork und Testabdeckung
parent dec5c76a
This diff is collapsed.
/*
*******************************************************************************
* 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.GridFailureInformationService;
import org.eclipse.openk.gridfailureinformation.viewmodel.GridFailureInformationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
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("/grid-failure-informations")
public class GridFailureInformationController {
@Value("${gridFailureInformation.maxListSize}")
int maxListSize;
@Autowired
private GridFailureInformationService gridFailureInformationService;
@ApiOperation(value = "Anzeigen aller Störungsinformationen")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
@GetMapping
public List<GridFailureInformationDto> findFailureInfos() {
return gridFailureInformationService.findFailureInformations(PageRequest.of(0, maxListSize)).getContent();
}
}
/*
*******************************************************************************
* 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.TblFailureInformation;
import org.eclipse.openk.gridfailureinformation.viewmodel.GridFailureInformationDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface GridFailureInformationMapper {
@Mappings({
@Mapping(source = "refFailureClassification.uuid", target = "failureClassificationId"),
@Mapping(source = "refFailureClassification.classification", target = "failureClassification"),
@Mapping(source = "refFailureType.uuid", target = "failureTypeId"),
@Mapping(source = "refFailureType.type", target = "failureType"),
@Mapping(source = "refStatusIntern.uuid", target = "statusInternId"),
@Mapping(source = "refStatusIntern.status", target = "statusIntern"),
@Mapping(source = "refStatusExtern.uuid", target = "statusExternId"),
@Mapping(source = "refStatusExtern.status", target = "statusExtern"),
@Mapping(source = "refBranch.uuid", target = "branchId"),
@Mapping(source = "refBranch.name", target = "branch"),
@Mapping(source = "refBranch.colorCode", target = "branchColorCode")
})
GridFailureInformationDto toGridFailureInformationDto(TblFailureInformation tblFailureInformation);
}
/*
*******************************************************************************
* 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.model;
import lombok.Data;
import javax.persistence.*;
import java.util.UUID;
@Data
@Entity
public class RefBranch {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ref_branch_id_seq")
@SequenceGenerator(name = "ref_branch_id_seq", sequenceName = "ref_branch_id_seq", allocationSize = 1)
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String name;
private String colorCode;
}
/*
*******************************************************************************
* 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.model;
import lombok.Data;
import javax.persistence.*;
import java.util.UUID;
@Data
@Entity
public class RefFailureClassification {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ref_failure_classification_id_seq")
@SequenceGenerator(name = "ref_failure_classification_id_seq", sequenceName = "ref_failure_classification_id_seq", allocationSize = 1)
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String classification;
private String description;
}
/*
*******************************************************************************
* 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.model;
import lombok.Data;
import javax.persistence.*;
import java.util.UUID;
@Data
@Entity
public class RefFailureType {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ref_failure_type_id_seq")
@SequenceGenerator(name = "ref_failure_type_id_seq", sequenceName = "ref_failure_type_id_seq", allocationSize = 1)
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String type;
private String description;
}
/*
*******************************************************************************
* 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.model;
import lombok.Data;
import javax.persistence.*;
import java.util.UUID;
@Data
@Entity
public class RefStatus {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ref_status_id_seq")
@SequenceGenerator(name = "ref_status_id_seq", sequenceName = "ref_status_id_seq", allocationSize = 1)
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String status;
private boolean isInternal;
private boolean isExternal;
}
/*
*******************************************************************************
* 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.model;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
import java.util.UUID;
@Data
@Entity
public class TblFailureInformation {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tbl_failure_information_id_seq")
@SequenceGenerator(name = "tbl_failure_information_id_seq", sequenceName = "tbl_failure_information_id_seq", allocationSize = 1)
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String responsibility;
private String internExtern;
private String voltageLevel;
private String pressureLevel;
private Date failureBegin;
private Date failureEndPlanned;
private Date failureEndResupplied;
private String probableReason;
private String internalRemark;
private String postcode;
private String city;
private String district;
private String street;
private String housenumber;
private String stationDescription;
private String stationCoords;
private String radius;
@ManyToOne
@JoinColumn( name = "fk_ref_failure_classification")
private RefFailureClassification refFailureClassification;
@ManyToOne
@JoinColumn( name = "fk_ref_failure_type")
private RefFailureType refFailureType;
@ManyToOne
@JoinColumn( name = "fk_ref_status_intern")
private RefStatus refStatusIntern;
@ManyToOne
@JoinColumn( name = "fk_ref_status_extern")
private RefStatus refStatusExtern;
@ManyToOne
@JoinColumn( name = "fk_ref_branch")
private RefBranch refBranch;
}
/*
*******************************************************************************
* 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.repository;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface FailureInformationRepository extends JpaRepository<TblFailureInformation, Long > {
}
/*
*******************************************************************************
* 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.GridFailureInformationMapper;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
import org.eclipse.openk.gridfailureinformation.viewmodel.GridFailureInformationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@Service
public class GridFailureInformationService {
@Autowired
private FailureInformationRepository failureInformationRepository;
@Autowired
private GridFailureInformationMapper gridFailureInformationMapper;
public Page<GridFailureInformationDto> findFailureInformations(Pageable pageable) {
return failureInformationRepository.findAll(pageable).map(gridFailureInformationMapper::toGridFailureInformationDto);
}
}
/*
*******************************************************************************
* 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.viewmodel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
@Data
public class GridFailureInformationDto implements Serializable {
@JsonProperty("id")
private UUID uuid;
private String responsibility;
private String internExtern;
private String voltageLevel;
private String pressureLevel;
private Date failureBegin;
private Date failureEndPlanned;
private Date failureEndResupplied;
private String probableReason;
private String internalRemark;
private String postcode;
private String city;
private String district;
private String street;
private String housenumber;
private String stationDescription;
private String stationCoords;
private String radius;
private UUID failureClassificationId;
private String failureClassification;
private UUID failureTypeId;
private String failureType;
private UUID statusInternId;
private String statusIntern;
private UUID statusExternId;
private String statusExtern;
private UUID branchId;
private String branch;
private String branchColorCode;
}
......@@ -26,6 +26,9 @@ jwt:
useStaticJwt: false
staticJwt: x
gridFailureInformation:
maxListSize: 2000
services:
authNAuth:
name: authNAuthService
......
......@@ -25,6 +25,9 @@ server:
session:
tracking-modes: cookie
gridFailureInformation:
maxListSize: 2000
jwt:
tokenHeader: Authorization
useStaticJwt: true
......
-----------------------------------------------------------------------------------
-- *******************************************************************************
-- * 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
-- *******************************************************************************
-----------------------------------------------------------------------------------
-- CREATE ROLE GFI_SERVICE LOGIN
-- NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
-- ALTER ROLE GFI_SERVICE with password 'gfi_service';
DROP TABLE IF EXISTS public.VERSION CASCADE;
DROP TABLE IF EXISTS public.TBL_FAILURE_INFORMATION CASCADE;
DROP SEQUENCE IF EXISTS public.TBL_FAILURE_INFORMATION_ID_SEQ;
DROP TABLE IF EXISTS public.REF_STATUS CASCADE;
DROP SEQUENCE IF EXISTS public.REF_STATUS_ID_SEQ;
DROP TABLE IF EXISTS public.REF_BRANCH CASCADE;
DROP SEQUENCE IF EXISTS public.REF_BRANCH_ID_SEQ;
DROP TABLE IF EXISTS public.REF_FAILURE_CLASSIFICATION CASCADE;
DROP SEQUENCE IF EXISTS public.REF_FAILURE_CLASSIFICATION_ID_SEQ;
DROP TABLE IF EXISTS public.REF_FAILURE_TYPE CASCADE;
DROP SEQUENCE IF EXISTS public.REF_FAILURE_TYPE_ID_SEQ;
-- ---------------------------------------------
-- TABLE VERSION
-- ---------------------------------------------
CREATE TABLE public.VERSION
(
ID integer NOT NULL,
VERSION character varying(50) NOT NULL,
CONSTRAINT REF_VERSION_PKEY PRIMARY KEY (id)
);
ALTER TABLE public.VERSION
OWNER TO GFI_SERVICE;
GRANT ALL ON TABLE public.VERSION TO GFI_SERVICE;
INSERT INTO public.VERSION (ID, VERSION) VALUES ( 1, '00-DEV' );
-- ---------------------------------------------
-- TABLE REF_STATUS
-- ---------------------------------------------
CREATE SEQUENCE public.ref_status_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE public.ref_status_id_seq
OWNER TO GFI_SERVICE;
CREATE TABLE public.REF_STATUS
(
ID integer NOT NULL DEFAULT nextval('REF_STATUS_ID_SEQ'::regclass),
UUID uuid NOT NULL,
STATUS character varying(50) NOT NULL,
IS_INTERNAL boolean NOT NULL,
IS_EXTERNAL boolean NOT NULL,
CONSTRAINT REF_STATUS_PKEY PRIMARY KEY (id)
);
ALTER TABLE public.REF_STATUS
OWNER TO GFI_SERVICE;
GRANT ALL ON TABLE public.REF_STATUS TO GFI_SERVICE;
INSERT INTO public.REF_STATUS (UUID, STATUS, IS_INTERNAL, IS_EXTERNAL) VALUES ( 'acabc8f6-2cf3-485a-a4f8-68d178c7df45', 'neu', TRUE, TRUE );
INSERT INTO public.REF_STATUS (UUID, STATUS, IS_INTERNAL, IS_EXTERNAL) VALUES ( 'a6cda99d-9f41-4637-9d9b-04f95ea352ec', 'bestätigt', TRUE, TRUE );
INSERT INTO public.REF_STATUS (UUID, STATUS, IS_INTERNAL, IS_EXTERNAL) VALUES ( '23fc0254-cc3d-4371-97ad-54ef733008ae', 'aktiv', TRUE, FALSE );
INSERT INTO public.REF_STATUS (UUID, STATUS, IS_INTERNAL, IS_EXTERNAL) VALUES ( '9374219a-7419-4b72-899d-cd0576d85cdb', 'geschlossen', TRUE, TRUE );
-- ---------------------------------------------
-- TABLE REF_FAILURE_CLASSIFICATION
-- ---------------------------------------------
CREATE SEQUENCE public.ref_failure_classification_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE public.ref_failure_classification_id_seq
OWNER TO GFI_SERVICE;
CREATE TABLE public.REF_FAILURE_CLASSIFICATION
(
ID integer NOT NULL DEFAULT nextval('REF_FAILURE_CLASSIFICATION_ID_SEQ'::regclass),
UUID uuid NOT NULL,
CLASSIFICATION character varying(50) NOT NULL,
DESCRIPTION character varying