Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.backend into SI-753_Mehrere_Stationen
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationController.java
index 75c5f52..d958055 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationController.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationController.java
@@ -19,11 +19,17 @@
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.service.HistFailureInformationService;
+import org.eclipse.openk.gridfailureinformation.service.HistFailureInformationStationService;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.annotation.Secured;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.UUID;
@@ -36,6 +42,9 @@
@Autowired
private HistFailureInformationService histfailureInformationService;
+ @Autowired
+ private HistFailureInformationStationService histFailureInformationStationService;
+
@GetMapping("/{uuid}/versions")
@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@@ -60,4 +69,16 @@
}
+ @GetMapping("/{uuid}/versions/{versionNumber}/stations")
+ @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
+ @ApiOperation(value = "Anzeigen der Stationen einer bestimmten Version einer Störungsinformation")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Erfolgreich durchgeführt"),
+ @ApiResponse(code = 404, message = "Störungsinformation wurden nicht gefunden")})
+ @ResponseStatus(HttpStatus.OK)
+ public List<StationDto> readStationsForVersion(
+ @PathVariable UUID uuid,
+ @PathVariable Long versionNumber) {
+ return histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(uuid, versionNumber);
+ }
+
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/mapper/HistFailureInformationStationMapper.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/mapper/HistFailureInformationStationMapper.java
new file mode 100644
index 0000000..92669d3
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/mapper/HistFailureInformationStationMapper.java
@@ -0,0 +1,37 @@
+/*
+ *******************************************************************************
+ * 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.HtblFailureInformationStation;
+import org.eclipse.openk.gridfailureinformation.viewmodel.HistFailureInformationStationDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.mapstruct.ReportingPolicy;
+
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface HistFailureInformationStationMapper {
+ @Mappings({
+ @Mapping(source = "fkTblFailureInformation", target = "failureInformationId")
+ })
+ HistFailureInformationStationDto toHistFailureInfoStationDto(HtblFailureInformationStation tblFailureInformationStation);
+
+
+ @Mappings({
+ @Mapping(target = "fkTblFailureInformation", source = "failureInformationId")
+ })
+ HtblFailureInformationStation toHtblFailureInformationStation(HistFailureInformationStationDto failureInformationStationDto);
+
+}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/HtblFailureInformationStation.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/HtblFailureInformationStation.java
new file mode 100644
index 0000000..895b9a0
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/HtblFailureInformationStation.java
@@ -0,0 +1,41 @@
+/*
+ *******************************************************************************
+ * 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.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import java.util.Date;
+
+@Data
+@Entity
+public class HtblFailureInformationStation {
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "htbl_failure_information_station_id_seq")
+ @SequenceGenerator(name = "htbl_failure_information_station_id_seq", sequenceName = "htbl_failure_information_station_id_seq", allocationSize = 1)
+ @Column(name = "hid", updatable = false)
+ private Long hid;
+ private Date hdate;
+
+ private Long fkTblFailureInformation;
+ private Long versionNumber;
+ private String stationStationId;
+
+}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/HistFailureInformationStationRepository.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/HistFailureInformationStationRepository.java
new file mode 100644
index 0000000..8748ddc
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/HistFailureInformationStationRepository.java
@@ -0,0 +1,29 @@
+/*
+ *******************************************************************************
+ * 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.HtblFailureInformationStation;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface HistFailureInformationStationRepository extends JpaRepository<HtblFailureInformationStation, Long > {
+
+ List<HtblFailureInformationStation> findByFkTblFailureInformationAndVersionNumber(Long failureInfoId, Long versionNumber);
+
+}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java
index 8a54c8a..0ac579b 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java
@@ -29,8 +29,26 @@
import org.eclipse.openk.gridfailureinformation.exceptions.OperationDeniedException;
import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapper;
import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationPublicationChannelMapper;
-import org.eclipse.openk.gridfailureinformation.model.*;
-import org.eclipse.openk.gridfailureinformation.repository.*;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.RefBranch;
+import org.eclipse.openk.gridfailureinformation.model.RefExpectedReason;
+import org.eclipse.openk.gridfailureinformation.model.RefStatus;
+import org.eclipse.openk.gridfailureinformation.model.TblAddress;
+import org.eclipse.openk.gridfailureinformation.model.TblDistributionGroup;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationPublicationChannel;
+import org.eclipse.openk.gridfailureinformation.model.TblStation;
+import org.eclipse.openk.gridfailureinformation.repository.AddressRepository;
+import org.eclipse.openk.gridfailureinformation.repository.BranchRepository;
+import org.eclipse.openk.gridfailureinformation.repository.DistributionGroupRepository;
+import org.eclipse.openk.gridfailureinformation.repository.ExpectedReasonRepository;
+import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.FailureInformationPublicationChannelRepository;
+import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.RadiusRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
import org.eclipse.openk.gridfailureinformation.util.ExternalStatusCalculator;
import org.eclipse.openk.gridfailureinformation.util.GrahamScan;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
@@ -46,8 +64,15 @@
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
-import java.util.*;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
import java.util.stream.Collectors;
@Log4j2
@@ -94,6 +119,9 @@
private FailureInformationPublicationChannelRepository failureInformationPublicationChannelRepository;
@Autowired
+ HistFailureInformationStationService histFailureInformationStationService;
+
+ @Autowired
private GfiGrid grid;
@Autowired
@@ -194,8 +222,12 @@
TblFailureInformation tblFailureInformationSaved = failureInformationRepository.save(tblFailureInformationToSave);
FailureInformationDto failureInformationDto = failureInformationMapper.toFailureInformationDto(tblFailureInformationSaved);
+ FailureInformationDto enrichedFailureInformationDto = enrichFailureInfo(failureInformationDto);
- return enrichFailureInfo(failureInformationDto);
+ // insert stations in history table
+ histFailureInformationStationService.insertHistFailureInfoStationsForGfi(tblFailureInformationSaved);
+
+ return enrichedFailureInformationDto;
}
private FailureInformationDto processGrid(FailureInformationDto failureInfoDto, GfiProcessState forcedState) {
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationService.java
index 7dc6307..1138179 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationService.java
@@ -23,6 +23,7 @@
import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository;
import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -49,17 +50,44 @@
@Autowired
private StatusRepository statusRepository;
+ @Autowired
+ HistFailureInformationStationService histFailureInformationStationService;
+
public List<FailureInformationDto> getFailureInformationVersionsByUuid(UUID uuid ) {
List<HtblFailureInformation> htblFailureInformationList = histFailureInformationRepository.findByUuid(uuid);
- return htblFailureInformationList.stream().map(histFailureInformationMapper::toFailureInformationDto).collect(Collectors.toList());
+
+ List<FailureInformationDto> failureInfoDtoList = htblFailureInformationList
+ .stream()
+ .map(histFailureInformationMapper::toFailureInformationDto)
+ .collect(Collectors.toList());
+
+ for (FailureInformationDto failureInfoDto : failureInfoDtoList) {
+ failureInfoDto = addStationsToFailureInfoDto(failureInfoDto);
+ }
+ return failureInfoDtoList;
}
public FailureInformationDto getFailureInformationVersion(UUID uuid, Long versionNumber ) {
HtblFailureInformation htblFailureInformation = histFailureInformationRepository.findByUuidAndVersionNumber(uuid, versionNumber)
.orElseThrow(NotFoundException::new);
- return histFailureInformationMapper.toFailureInformationDto(htblFailureInformation);
+
+ FailureInformationDto histFailureInfoDto = histFailureInformationMapper.toFailureInformationDto(htblFailureInformation);
+
+ return addStationsToFailureInfoDto(histFailureInfoDto);
}
+ private FailureInformationDto addStationsToFailureInfoDto (FailureInformationDto histFailureInfoDto) {
+
+ List<StationDto> stationDtoList = histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(histFailureInfoDto.getUuid(), histFailureInfoDto.getVersionNumber());
+ List<UUID> stationUuidList = stationDtoList.stream()
+ .map(StationDto::getUuid)
+ .collect(Collectors.toList());
+
+ histFailureInfoDto.setStationIds(stationUuidList);
+
+ return histFailureInfoDto;
+
+ }
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java
new file mode 100644
index 0000000..9dab4cb
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java
@@ -0,0 +1,109 @@
+/*
+ *******************************************************************************
+ * 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.exceptions.NotFoundException;
+import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapper;
+import org.eclipse.openk.gridfailureinformation.mapper.HistFailureInformationStationMapper;
+import org.eclipse.openk.gridfailureinformation.mapper.StationMapper;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformationStation;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.TblStation;
+import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationStationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StationRepository;
+import org.eclipse.openk.gridfailureinformation.viewmodel.HistFailureInformationStationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+
+@Service
+public class HistFailureInformationStationService {
+
+ @Autowired
+ private StationRepository stationRepository;
+
+ @Autowired
+ private StationMapper stationMapper;
+
+ @Autowired
+ private FailureInformationRepository failureInformationRepository;
+
+ @Autowired
+ private HistFailureInformationRepository histFailureInformationRepository;
+
+ @Autowired
+ private HistFailureInformationStationRepository histFailureInformationStationRepository;
+
+ @Autowired
+ private HistFailureInformationStationMapper histFailureInformationStationMapper;
+
+ @Autowired
+ private FailureInformationMapper failureInformationMapper;
+
+
+ public List<StationDto> findHistStationsByFailureInfoAndVersionNumber(UUID failureInfoUuid, Long versionNumber ) {
+
+
+ HtblFailureInformation existingHtblFailureInfo = histFailureInformationRepository.findByUuidAndVersionNumber( failureInfoUuid, versionNumber )
+ .orElseThrow(() -> new NotFoundException("hist.failure.info.uuid.not.existing"));
+
+ List<HtblFailureInformationStation> htblFailureInfoStationList = histFailureInformationStationRepository.findByFkTblFailureInformationAndVersionNumber(existingHtblFailureInfo.getId(), versionNumber);
+ List<TblStation> stationList = new ArrayList<>();
+
+ for (HtblFailureInformationStation histFailureInfoStation: htblFailureInfoStationList) {
+ stationList.add(stationRepository.findByStationId(histFailureInfoStation.getStationStationId()).orElseThrow(() -> new NotFoundException("station.id.not.existing")));
+ }
+ return stationList.stream()
+ .map( stationMapper::toStationDto )
+ .collect(Collectors.toList());
+ }
+
+
+ public List<HistFailureInformationStationDto> insertHistFailureInfoStationsForGfi(TblFailureInformation failureInformation) {
+
+ Set<TblStation> stations = failureInformation.getStations();
+ List<HtblFailureInformationStation> savedFailureInformationStations = new ArrayList<>();
+
+ if (!stations.isEmpty()) {
+ for (TblStation tblStation : stations) {
+ HtblFailureInformationStation htblFailureInfoStationToSave = new HtblFailureInformationStation();
+
+ htblFailureInfoStationToSave.setFkTblFailureInformation(failureInformation.getId());
+ htblFailureInfoStationToSave.setVersionNumber(failureInformation.getVersionNumber());
+ htblFailureInfoStationToSave.setStationStationId(tblStation.getStationId());
+ htblFailureInfoStationToSave.setHdate(new Date());
+
+ savedFailureInformationStations.add(histFailureInformationStationRepository.save(htblFailureInfoStationToSave));
+ }
+ }
+
+ return savedFailureInformationStations.stream()
+ .map( histFailureInformationStationMapper::toHistFailureInfoStationDto )
+ .collect(Collectors.toList());
+
+ }
+
+}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/HistFailureInformationStationDto.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/HistFailureInformationStationDto.java
new file mode 100644
index 0000000..a5a3630
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/HistFailureInformationStationDto.java
@@ -0,0 +1,30 @@
+/*
+ *******************************************************************************
+ * 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 lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class HistFailureInformationStationDto implements Serializable {
+
+ private Long failureInformationId;
+ private Long versionNumber;
+ private String stationStationId;
+
+}
+
+
diff --git a/gfsBackendService/src/main/resources/db/migration/V0_41XX__CREATE_GFI_DB.sql b/gfsBackendService/src/main/resources/db/migration/V0_41XX__CREATE_GFI_DB.sql
new file mode 100644
index 0000000..a677e69
--- /dev/null
+++ b/gfsBackendService/src/main/resources/db/migration/V0_41XX__CREATE_GFI_DB.sql
@@ -0,0 +1,936 @@
+-----------------------------------------------------------------------------------
+-- *******************************************************************************
+-- * 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_RADIUS CASCADE;
+DROP SEQUENCE IF EXISTS public.REF_RADIUS_ID_SEQ;
+
+DROP TABLE IF EXISTS public.REF_EXPECTED_REASON CASCADE;
+DROP SEQUENCE IF EXISTS public.REF_EXPECTED_REASON_ID_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_DISTRIBUTION_GROUP_MEMBER CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_DISTRIBUTION_GROUP_MEMBER_ID_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_DISTRIBUTION_GROUP CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_DISTRIBUTION_GROUP_ID_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_FAILURE_INFORMATION_DISTRIBUTION_GROUP CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_FAILURE_INFORMATION_DISTRIBUTION_GROUP_ID_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_FAILURE_INFORMATION_STATION CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_FAILURE_INFORMATION_STATION_ID_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_FAILURE_INFORMATION_PUBLICATION_CHANNEL;
+DROP SEQUENCE IF EXISTS public.TBL_FAILURE_INFORMATION_PUBLICATION_CHANNEL_SEQ;
+
+DROP TABLE IF EXISTS public.TBL_FAILURE_INFORMATION_REMINDER_MAIL_SENT CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_FAILURE_INFORMATION_REMINDER_MAIL_SENT_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,
+ 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 (ID, UUID, STATUS) VALUES (1, 'acabc8f6-2cf3-485a-a4f8-68d178c7df45', 'neu');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (2, 'f2e44dc5-d30c-4128-86bb-d3d5fc766b61', 'geplant');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (3, '23fc0254-cc3d-4371-97ad-54ef733008ae', 'angelegt');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (4, '74a4ca78-7268-11ea-bc55-0242ac130003', 'storniert');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (5, '7264e572-eae9-4cca-be05-af6b0d081247', 'qualifiziert');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (6, '9374219a-7419-4b72-899d-cd0576d85cdb', 'aktualisiert');
+INSERT INTO public.REF_STATUS (ID, UUID, STATUS) VALUES (7, '8c333345-5c3c-41ed-9de4-323045f64259', 'abgeschlossen');
+
+
+-- ---------------------------------------------
+-- 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(255) NULL,
+ CONSTRAINT REF_FAILURE_CLASSIFICATION_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.REF_FAILURE_CLASSIFICATION
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.REF_FAILURE_CLASSIFICATION TO GFI_SERVICE;
+
+INSERT INTO public.REF_FAILURE_CLASSIFICATION (UUID, CLASSIFICATION, DESCRIPTION) VALUES ( '9255fb79-c57a-4448-a69c-5d57994f0c91', 'Störung', NULL );
+INSERT INTO public.REF_FAILURE_CLASSIFICATION (UUID, CLASSIFICATION, DESCRIPTION) VALUES ( '8ec1e144-5230-4d43-a3df-f62dd64bb855', 'geplante Maßnahme', NULL );
+
+-- ---------------------------------------------
+-- TABLE REF_BRANCH
+-- ---------------------------------------------
+CREATE SEQUENCE public.ref_branch_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.ref_branch_id_seq
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.REF_BRANCH
+(
+ ID integer NOT NULL DEFAULT nextval('REF_BRANCH_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ NAME character varying(50) NOT NULL,
+ DESCRIPTION character varying(255),
+ COLOR_CODE character varying(20),
+ CONSTRAINT REF_BRANCH_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.REF_BRANCH
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.REF_BRANCH TO GFI_SERVICE;
+
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('535b4beb-9b17-4247-bb8b-26bd01b48f9a', 'S', 'Strom', '#fc6042');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('d41f54e5-c4df-440e-b334-40e8f3a6854a', 'G', 'Gas', '#fdea64');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('62c6d361-96a0-41cc-bda1-4e58ad16f21a', 'F', 'Fernwärme', '#2cc990');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('d8d93e0e-5c8c-4ab8-9625-f820de55ee7c', 'W', 'Wasser', '#2c82c9');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('7d4907fb-cb3f-4a4f-93e9-839052e76894', 'TK', 'Telekommunikation', '#ff33cc');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('014c4a2a-3cf1-4d28-af70-4573722bceb0', 'ST', 'Sekundärtechnik', '#9933ff');
+INSERT INTO public.ref_branch(uuid, name, description, color_code) VALUES ('8fb3c764-8fb5-11ea-bc55-0242ac130003', 'OS', 'ohne Sparte', '#ffffff');
+
+
+-- ---------------------------------------------
+-- TABLE REF_EXPECTED_REASON
+-- ---------------------------------------------
+CREATE SEQUENCE public.ref_expected_reason_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.ref_expected_reason_id_seq
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.REF_EXPECTED_REASON
+(
+ ID integer NOT NULL DEFAULT nextval('REF_EXPECTED_REASON_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ TEXT character varying(100) NOT NULL,
+ DESCRIPTION character varying(255) NULL,
+ BRANCHES character varying(100) NOT NULL,
+ CONSTRAINT REF_EXPECTED_REASON_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.REF_EXPECTED_REASON
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.REF_EXPECTED_REASON TO GFI_SERVICE;
+
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07918-6aa0-11ea-bc55-0242ac130003', 'Defekt technische Anlage', 'Dies ist die Beschreibung für: Defekt technische Anlage', 'S,G,W,F,TK,ST,OS');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07c42-6aa0-11ea-bc55-0242ac130003', 'Kabelfehler Mittelspannung', 'Dies ist die Beschreibung für: Kabelfehler Mittelspannung', 'S');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07d50-6aa0-11ea-bc55-0242ac130003', 'Kabelfehler Niederspannung', 'Dies ist die Beschreibung für: Kabelfehler Niederspannung', 'S');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07e22-6aa0-11ea-bc55-0242ac130003', 'Leitung beschädigt', 'Dies ist die Beschreibung für: Leitung beschädigt', 'S,G,W,F,TK,ST');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07eea-6aa0-11ea-bc55-0242ac130003', 'noch nicht bekannt', 'Dies ist die Beschreibung für: noch nicht bekannt', 'S,G,W,F,TK,ST,OS');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a07fbc-6aa0-11ea-bc55-0242ac130003', 'Wasserrohrbruch', 'Dies ist die Beschreibung für: Wasserrohrbruch', 'W');
+INSERT INTO public.ref_expected_reason(uuid, text, description, branches) VALUES ('27a08160-6aa0-11ea-bc55-0242ac130003', 'Überregionale Störung', 'Dies ist die Beschreibung für: Überregionale Störung', 'S,G,W,F,TK,ST');
+
+-- ---------------------------------------------
+-- TABLE REF_RADIUS
+-- ---------------------------------------------
+CREATE SEQUENCE public.ref_radius_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.ref_radius_id_seq
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.REF_RADIUS
+(
+ ID integer NOT NULL DEFAULT nextval('REF_RADIUS_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ RADIUS integer NOT NULL,
+ CONSTRAINT REF_RADIUS_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.REF_RADIUS
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.REF_RADIUS TO GFI_SERVICE;
+
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('e6439b49-ce5a-486e-a437-b362ec73dc44', 0);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('36671000-6aa6-11ea-bc55-0242ac130003', 50);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('366712a8-6aa6-11ea-bc55-0242ac130003', 100);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('366713c0-6aa6-11ea-bc55-0242ac130003', 250);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('3667150a-6aa6-11ea-bc55-0242ac130003', 500);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('36671780-6aa6-11ea-bc55-0242ac130003', 1000);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('3667187a-6aa6-11ea-bc55-0242ac130003', 1500);
+INSERT INTO public.REF_RADIUS(uuid, radius) VALUES ('36671ad2-6aa6-11ea-bc55-0242ac130003', 2000);
+
+-- ---------------------------------------------
+-- TABLE TBL_FAILURE_INFORMATION
+-- ---------------------------------------------
+CREATE SEQUENCE public.tbl_failure_information_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.tbl_failure_information_id_seq
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.TBL_FAILURE_INFORMATION
+(
+ ID integer NOT NULL DEFAULT nextval('TBL_FAILURE_INFORMATION_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ VERSION_NUMBER integer NOT NULL,
+ FK_REF_FAILURE_CLASSIFICATION integer,
+ TITLE character varying(255) NULL,
+ DESCRIPTION character varying(255) NULL,
+ RESPONSIBILITY character varying(255),
+ FK_REF_STATUS_INTERN integer NOT NULL,
+ FK_REF_BRANCH integer NOT NULL,
+ VOLTAGE_LEVEL character varying(2),
+ PRESSURE_LEVEL character varying(2),
+ FAILURE_BEGIN timestamp NOT NULL,
+ FAILURE_END_PLANNED timestamp,
+ FAILURE_END_RESUPPLIED timestamp,
+ INTERNAL_REMARK character varying(1024),
+ POSTCODE character varying(30),
+ CITY character varying(255),
+ DISTRICT character varying(255),
+ STREET character varying(255),
+ HOUSENUMBER character varying(30),
+ STATION_ID character varying (30),
+ STATION_DESCRIPTION character varying (255),
+ STATION_COORDS character varying (255),
+ FK_REF_RADIUS integer,
+ LONGITUDE numeric(9,6),
+ LATITUDE numeric(9,6),
+ FK_TBL_FAILURE_INFORMATION_CONDENSED integer,
+ CONDENSED boolean,
+ CONDENSED_COUNT integer,
+ OBJECT_REFERENCE_EXTERNAL_SYSTEM character varying (255),
+ PUBLICATION_STATUS character varying (40),
+ PUBLICATION_FREETEXT character varying (1024),
+ FK_REF_EXPECTED_REASON integer,
+ CREATE_DATE timestamp without time zone NOT NULL,
+ CREATE_USER character varying(100) NOT NULL,
+ MOD_DATE timestamp without time zone NOT NULL,
+ MOD_USER character varying(100),
+ CONSTRAINT TBL_FAILURE_INFORMATION_PKEY PRIMARY KEY (id),
+ CONSTRAINT TBL_FAIL_INF__FCLASS_FKEY FOREIGN KEY (FK_REF_FAILURE_CLASSIFICATION)
+ REFERENCES public.REF_FAILURE_CLASSIFICATION (ID) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT TBL_FAIL_INF_STATUSINT_FKEY FOREIGN KEY (FK_REF_STATUS_INTERN)
+ REFERENCES public.REF_STATUS (ID) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT TBL_FAIL_INF__BRANCH_ID_FKEY FOREIGN KEY (FK_REF_BRANCH)
+ REFERENCES public.REF_BRANCH (ID) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT TBL_FAIL_INF__EXPREASON_FKEY FOREIGN KEY (FK_REF_EXPECTED_REASON)
+ REFERENCES public.REF_EXPECTED_REASON (ID) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+
+ALTER TABLE public.TBL_FAILURE_INFORMATION
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.TBL_FAILURE_INFORMATION TO GFI_SERVICE;
+
+INSERT INTO public.tbl_failure_information(UUID, VERSION_NUMBER, FK_REF_FAILURE_CLASSIFICATION, TITLE, DESCRIPTION, RESPONSIBILITY, FK_REF_STATUS_INTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_ID, STATION_DESCRIPTION, STATION_COORDS, FK_REF_RADIUS, LONGITUDE, LATITUDE, OBJECT_REFERENCE_EXTERNAL_SYSTEM, PUBLICATION_STATUS, PUBLICATION_FREETEXT, FK_REF_EXPECTED_REASON, CONDENSED, CONDENSED_COUNT, FK_TBL_FAILURE_INFORMATION_CONDENSED, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
+VALUES ('6432a9c9-0384-44af-9bb8-34f2878d7b49',3, 1, 'Stromausfall Murr', 'Es gibt einen Stromausfall im Bereich Murr/Westbezirk', 'Rolf Rudis', 1, 1,'NS', null, '2021-01-19 00:00:00', '2021-01-22 00:00:00', '2021-01-22 12:00:00', 'Der Bagger grub zu tief', '71711', 'Murr', 'Westbezirk', 'Ferdinand-Porsche-Straße', '2', '52863a', 'Trafo 1', '124,2323', 2, 9.247952, 48.955700, 'Link - extenes System', 'veröffentlicht', 'Freitext für die Veröffentlichung: Defekt an Trafostation', 1, false, 0, null, '2020-01-22 15:32:15', 'SCRIPT', '2020-01-24 08:02:44', 'SCRIPT');
+
+INSERT INTO public.tbl_failure_information(UUID, VERSION_NUMBER, FK_REF_FAILURE_CLASSIFICATION, TITLE, DESCRIPTION, RESPONSIBILITY, FK_REF_STATUS_INTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_ID, STATION_DESCRIPTION, STATION_COORDS, FK_REF_RADIUS, LONGITUDE, LATITUDE, OBJECT_REFERENCE_EXTERNAL_SYSTEM, PUBLICATION_STATUS, PUBLICATION_FREETEXT, FK_REF_EXPECTED_REASON, CONDENSED, CONDENSED_COUNT, FK_TBL_FAILURE_INFORMATION_CONDENSED, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
+VALUES ('37aef635-d0d4-4c47-ac25-c0d16c29e35c', 1, 2, 'Gasleck Oldenburg', 'Es gibt ein Gasleck in Oldenburg', 'Bernd Britzel', 2, 3, 'NS', 'HD', '2021-05-19 00:00:00', '2021-05-22 00:00:00', '2021-05-22 12:00:00', 'HD betroffen', '26133', 'Oldenburg', null, 'Cloppenburger Str.', '302', '1234863-b234', 'ertf', '124,2323', 4, 8.210150, 53.111820, 'Link - extenes System', 'nicht veröffentlicht', 'Freitext: Eine Gasleitung wurde beschädigt', 4, false, 0, null, '2020-02-03 15:15:15', 'SCRIPT', '2020-02-24 20:08:41', 'SCRIPT');
+
+
+-- ---------------------------------------------
+-- TABLE TBL_DISTRIBUTION_GROUP
+-- ---------------------------------------------
+CREATE SEQUENCE public.TBL_DISTRIBUTION_GROUP_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP_ID_SEQ
+ OWNER TO GFI_SERVICE;
+
+
+CREATE TABLE public.TBL_DISTRIBUTION_GROUP
+(
+ ID integer NOT NULL DEFAULT nextval('TBL_DISTRIBUTION_GROUP_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ NAME character varying(255),
+ DISTRIBUTION_TEXT character varying(2048),
+ CONSTRAINT TBL_DISTRIBUTION_GROUP_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.TBL_DISTRIBUTION_GROUP TO GFI_SERVICE;
+
+INSERT INTO public.tbl_distribution_group(UUID, NAME, DISTRIBUTION_TEXT)
+VALUES('5f5017fe-887a-11ea-bc55-0242ac130003', 'Verteiler technisch - intern', 'Subject: Die Störung (Sparte: $Sparte$) mit Beginn: $Störungsbeginn_gemeldet$ wurde in den Status veröffentlicht geändert.
+
+Body:
+Verteiler fachlich TEST
+
+Sehr geehrte Damen und Herren,
+
+die im Betreff genannte Meldung ist über folgenden Link erreichbar:
+
+$directFailureLink$
+
+Mit freundlichen Grüßen
+Ihre Admin-Meister-Team der PTA GmbH');
+
+INSERT INTO public.tbl_distribution_group(UUID, NAME, DISTRIBUTION_TEXT)
+VALUES('5f502046-887a-11ea-bc55-0242ac130003', 'Verteiler fachlich - intern', 'Subject: Die Störmeldung mit Beginn: $Störungsbeginn_gemeldet$ und dem Voraussichtlicher Grund: $Voraussichtlicher_Grund$" wurde in den Status veröffentlicht geändert.
+
+Body:
+Verteiler fachlich TEST
+
+Sehr geehrte Damen und Herren,
+
+die im Betreff genannte Meldung ist über folgenden Link erreichbar:
+
+$directFailureLink$
+
+Mit freundlichen Grüßen
+Ihre Admin-Meister-Team der PTA GmbH');
+
+INSERT INTO public.tbl_distribution_group(UUID, NAME, DISTRIBUTION_TEXT)
+VALUES('f71660e2-aee1-11ea-b3de-0242ac130004', 'Veröffentlicher', 'Subject: Bitte Anpassen - Das geplannte Ende der Störung (Sparte: $Sparte$) wird demnächst erreicht. Der Statuswechsel erfolgt automatisch.
+
+Body:
+Veröffentlicher
+
+Sehr geehrte Damen und Herren,
+
+die im Betreff genannte Meldung ist über folgenden Link erreichbar:
+
+$directFailureLink$
+
+Mit freundlichen Grüßen');
+
+-- ---------------------------------------------
+-- TABLE TBL_DISTRIBUTION_GROUP_MEMBER
+-- ---------------------------------------------
+CREATE SEQUENCE public.TBL_DISTRIBUTION_GROUP_MEMBER_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP_MEMBER_ID_SEQ
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.TBL_DISTRIBUTION_GROUP_MEMBER
+(
+ ID integer NOT NULL DEFAULT nextval('TBL_DISTRIBUTION_GROUP_MEMBER_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ FK_TBL_DISTRIBUTION_GROUP integer NOT NULL,
+ CONTACT_ID uuid NOT NULL,
+ CONSTRAINT TBL_DISTRIBUTION_GROUP_MEMBER_PKEY PRIMARY KEY (id),
+ CONSTRAINT TBL_DIS_GRP_MEM__DIS_GRP_FKEY FOREIGN KEY (FK_TBL_DISTRIBUTION_GROUP)
+ REFERENCES public.TBL_DISTRIBUTION_GROUP (ID) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+ );
+
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP_MEMBER
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.TBL_DISTRIBUTION_GROUP_MEMBER TO GFI_SERVICE;
+
+
+INSERT INTO public.tbl_distribution_group_member(UUID, FK_TBL_DISTRIBUTION_GROUP, CONTACT_ID)
+VALUES('5f5021a4-887a-11ea-bc55-0242ac130003', 1, 'ae3f2ec1-ccc5-4269-a48f-dd40e37fa14e' );
+
+INSERT INTO public.tbl_distribution_group_member(UUID, FK_TBL_DISTRIBUTION_GROUP, CONTACT_ID)
+VALUES('5f50228a-887a-11ea-bc55-0242ac130003', 1, '7782179b-fb79-4370-8f71-f4c71470d006' );
+
+INSERT INTO public.tbl_distribution_group_member(UUID, FK_TBL_DISTRIBUTION_GROUP, CONTACT_ID)
+VALUES('14dcac8c-887f-11ea-bc55-0242ac130003', 1, 'fa3d981b-a7d6-4965-a623-cdbc69404153' );
+
+INSERT INTO public.tbl_distribution_group_member(UUID, FK_TBL_DISTRIBUTION_GROUP, CONTACT_ID)
+VALUES('14dcaef8-887f-11ea-bc55-0242ac130003', 2, 'c862d604-5766-43d6-a7e8-a4bac2bd01e1');
+
+INSERT INTO public.tbl_distribution_group_member(UUID, FK_TBL_DISTRIBUTION_GROUP, CONTACT_ID)
+VALUES('14dcaffc-887f-11ea-bc55-0242ac130003', 2, '8fe41b90-d10c-4a70-8fde-0990286ad3c6');
+
+
+-- ---------------------------------------------
+-- TABLE TBL_FAILURE_INFORMATION_DISTRIBUTION_GROUP
+-- ---------------------------------------------
+CREATE SEQUENCE public.tbl_failure_information_distribution_group_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.tbl_failure_information_distribution_group_id_seq
+ OWNER TO gfi_service;
+
+CREATE TABLE public.tbl_failure_information_distribution_group
+(
+ id integer NOT NULL DEFAULT nextval('tbl_failure_information_distribution_group_id_seq'::regclass),
+ fk_tbl_failure_information integer NOT NULL,
+ fk_tbl_distribution_group integer NOT NULL,
+ CONSTRAINT tbl_failure_information_distribution_group_pkey PRIMARY KEY (id),
+ CONSTRAINT tbl_fail_inf_dist_grp__failure_information_id_fkey FOREIGN KEY (fk_tbl_failure_information)
+ REFERENCES public.tbl_failure_information (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT tbl_fail_inf_dist_grp__distribution_group_fkey FOREIGN KEY (fk_tbl_distribution_group)
+ REFERENCES public.tbl_distribution_group (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE public.tbl_failure_information_distribution_group
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE public.tbl_failure_information_distribution_group TO gfi_service;
+
+INSERT INTO public.tbl_failure_information_distribution_group(FK_TBL_FAILURE_INFORMATION, FK_TBL_DISTRIBUTION_GROUP)
+VALUES(1, 1);
+INSERT INTO public.tbl_failure_information_distribution_group(FK_TBL_FAILURE_INFORMATION, FK_TBL_DISTRIBUTION_GROUP)
+VALUES(1, 2);
+INSERT INTO public.tbl_failure_information_distribution_group(FK_TBL_FAILURE_INFORMATION, FK_TBL_DISTRIBUTION_GROUP)
+VALUES(2, 1);
+INSERT INTO public.tbl_failure_information_distribution_group(FK_TBL_FAILURE_INFORMATION, FK_TBL_DISTRIBUTION_GROUP)
+VALUES(2, 2);
+
+CREATE UNIQUE INDEX idx_tbl_fi_distribution_group_uq ON public.tbl_failure_information_distribution_group ( fk_tbl_failure_information, fk_tbl_distribution_group );
+
+
+-- ---------------------------------------------
+-- TABLE TBL_FAILURE_INFORMATION_STATION
+-- ---------------------------------------------
+CREATE SEQUENCE public.tbl_failure_information_station_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.tbl_failure_information_station_id_seq
+ OWNER TO gfi_service;
+
+CREATE TABLE public.tbl_failure_information_station
+(
+ id integer NOT NULL DEFAULT nextval('tbl_failure_information_station_id_seq'::regclass),
+ fk_tbl_failure_information integer NOT NULL,
+ station_station_id character varying(30) NOT NULL,
+ CONSTRAINT tbl_failure_information_station_pkey PRIMARY KEY (id),
+ CONSTRAINT tbl_fail_inf_station__failure_information_id_fkey FOREIGN KEY (fk_tbl_failure_information)
+ REFERENCES public.tbl_failure_information (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE public.tbl_failure_information_station
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE public.tbl_failure_information_station TO gfi_service;
+
+-- ---------------------------------------------
+-- TABLE TBL_FAILURE_INFORMATION_PUBLICATION_CHANNEL
+-- ---------------------------------------------
+
+CREATE SEQUENCE public.tbl_failure_information_publication_channel_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.tbl_failure_information_publication_channel_seq
+ OWNER TO gfi_service;
+
+
+CREATE TABLE public.tbl_failure_information_publication_channel
+(
+ id integer NOT NULL DEFAULT nextval('tbl_failure_information_publication_channel_seq'::regclass),
+ fk_tbl_failure_information integer NOT NULL,
+ publication_channel character varying(50) NOT NULL,
+ published boolean NOT NULL,
+ CONSTRAINT tbl_failure_information_publication_channel_pkey PRIMARY KEY (id),
+ CONSTRAINT tbl_failure_information_id_fkey FOREIGN KEY (fk_tbl_failure_information)
+ REFERENCES public.tbl_failure_information (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+
+ALTER TABLE public.tbl_failure_information_publication_channel
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE public.tbl_failure_information_publication_channel TO gfi_service;
+
+INSERT INTO public.tbl_failure_information_publication_channel(FK_TBL_FAILURE_INFORMATION, PUBLICATION_CHANNEL, PUBLISHED)
+VALUES(1, 'Mail', false);
+
+
+-- ---------------------------------------------
+-- TABLE TBL_FAILURE_INFORMATION_REMINDER_MAIL_SENT
+-- ---------------------------------------------
+CREATE SEQUENCE public.tbl_failure_information_reminder_mail_sent_id_seq
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.tbl_failure_information_reminder_mail_sent_id_seq
+ OWNER TO gfi_service;
+
+CREATE TABLE public.tbl_failure_information_reminder_mail_sent
+(
+ id integer NOT NULL DEFAULT nextval('tbl_failure_information_reminder_mail_sent_id_seq'::regclass),
+ fk_tbl_failure_information integer NOT NULL,
+ mail_sent boolean NOT NULL,
+ date_mail_sent timestamp,
+ CONSTRAINT tbl_failure_information_reminder_mail_sent_pkey PRIMARY KEY (id),
+ CONSTRAINT tbl_fail_inf_rem_mail_sent__failure_information_id_fkey FOREIGN KEY (fk_tbl_failure_information)
+ REFERENCES public.tbl_failure_information (id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE public.tbl_failure_information_reminder_mail_sent
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE public.tbl_failure_information_reminder_mail_sent TO gfi_service;
+
+INSERT INTO public.tbl_failure_information_reminder_mail_sent(FK_TBL_FAILURE_INFORMATION, mail_sent, date_mail_sent)
+VALUES(1, true, '2021-01-21 00:01:00');
+
+
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+-- HISTORY-TABLES
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+
+
+-- PUBLIC.HTBL_FAILURE_INFORMATION Automatic generanted History Table DDL --
+-- <GENERATED CODE!>
+
+DROP TABLE IF EXISTS PUBLIC.HTBL_FAILURE_INFORMATION;
+DROP SEQUENCE IF EXISTS PUBLIC.HTBL_FAILURE_INFORMATION_ID_SEQ;
+
+CREATE SEQUENCE PUBLIC.HTBL_FAILURE_INFORMATION_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+
+ALTER TABLE PUBLIC.HTBL_FAILURE_INFORMATION_ID_SEQ
+ OWNER TO gfi_service;
+
+CREATE TABLE PUBLIC.HTBL_FAILURE_INFORMATION
+(
+ HID integer NOT NULL DEFAULT nextval('HTBL_FAILURE_INFORMATION_ID_SEQ'::regclass),
+ HACTION integer NOT NULL,
+ HDATE timestamp without time zone NOT NULL,
+ HUSER character varying(100),
+
+ ID integer,
+ UUID uuid,
+ VERSION_NUMBER integer,
+ FK_REF_FAILURE_CLASSIFICATION integer,
+ TITLE character varying(255) NULL,
+ DESCRIPTION character varying(255) NULL,
+ RESPONSIBILITY character varying (255),
+ FK_REF_STATUS_INTERN integer,
+ FK_REF_BRANCH integer,
+ VOLTAGE_LEVEL character varying (2),
+ PRESSURE_LEVEL character varying (2),
+ FAILURE_BEGIN timestamp without time zone,
+ FAILURE_END_PLANNED timestamp without time zone,
+ FAILURE_END_RESUPPLIED timestamp without time zone,
+ INTERNAL_REMARK character varying(1024),
+ POSTCODE character varying (30),
+ CITY character varying (255),
+ DISTRICT character varying (255),
+ STREET character varying (255),
+ HOUSENUMBER character varying (30),
+ STATION_ID character varying (30),
+ STATION_DESCRIPTION character varying (255),
+ STATION_COORDS character varying (255),
+ FK_REF_RADIUS integer,
+ LONGITUDE numeric(9,6),
+ LATITUDE numeric(9,6),
+ FK_TBL_FAILURE_INFORMATION_CONDENSED integer,
+ CONDENSED boolean,
+ CONDENSED_COUNT integer,
+ OBJECT_REFERENCE_EXTERNAL_SYSTEM character varying (255),
+ PUBLICATION_STATUS character varying (40),
+ PUBLICATION_FREETEXT character varying (1024),
+ FK_REF_EXPECTED_REASON integer,
+ CREATE_USER character varying(100),
+ CREATE_DATE timestamp without time zone,
+ MOD_USER character varying(100),
+ MOD_DATE timestamp without time zone,
+ CONSTRAINT HTBL_FAILURE_INFORMATION_PKEY PRIMARY KEY (HID)
+)
+WITH (
+ OIDS=FALSE
+);
+
+ALTER TABLE PUBLIC.HTBL_FAILURE_INFORMATION
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE PUBLIC.HTBL_FAILURE_INFORMATION TO gfi_service;
+
+INSERT INTO public.htbl_failure_information(HACTION, HDATE, HUSER, ID, UUID, VERSION_NUMBER, FK_REF_FAILURE_CLASSIFICATION, TITLE, DESCRIPTION, RESPONSIBILITY, FK_REF_STATUS_INTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_ID, STATION_DESCRIPTION, STATION_COORDS, FK_REF_RADIUS, LONGITUDE, LATITUDE, OBJECT_REFERENCE_EXTERNAL_SYSTEM, PUBLICATION_STATUS, PUBLICATION_FREETEXT, FK_REF_EXPECTED_REASON, FK_TBL_FAILURE_INFORMATION_CONDENSED, CONDENSED, CONDENSED_COUNT, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
+VALUES (1, '2020-03-13 00:00:00', 'SCRIPT', 1, '6432a9c9-0384-44af-9bb8-34f2878d7b49', 1, 1, 'Stromausfall Murr', 'Es gibt einen Stromausfall im Bereich Murr/Westbezirk', 'Rolf Rudis', 1, 1, 'NS', null, '2021-01-19 00:00:00', '2021-01-22 00:00:00', '2021-01-22 12:00:00', 'Der Bagger grub zu tief', '71711', 'Murr', 'Westbezirk', 'Ferdinand-Porsche-Straße', '2', '52863a', 'Trafo 1', '124,2323', 2, 9.247952, 48.955700, 'Link - extenes System', 'veröffentlicht', 'Freitext für die Veröffentlichung: Defekt an Trafostation', 1, null, false, 0, '2020-01-22 15:32:15', 'SCRIPT', '2020-01-24 08:02:44', 'SCRIPT');
+
+INSERT INTO public.htbl_failure_information(HACTION, HDATE, HUSER, ID, UUID, VERSION_NUMBER, FK_REF_FAILURE_CLASSIFICATION, TITLE, DESCRIPTION, RESPONSIBILITY, FK_REF_STATUS_INTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_ID, STATION_DESCRIPTION, STATION_COORDS, FK_REF_RADIUS, LONGITUDE, LATITUDE, OBJECT_REFERENCE_EXTERNAL_SYSTEM, PUBLICATION_STATUS, PUBLICATION_FREETEXT, FK_REF_EXPECTED_REASON, FK_TBL_FAILURE_INFORMATION_CONDENSED, CONDENSED, CONDENSED_COUNT, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
+VALUES (2, '2020-03-13 00:00:00', 'SCRIPT', 2, '37aef635-d0d4-4c47-ac25-c0d16c29e35c', 1, 2, 'Gasleck Oldenburg', 'Es gibt ein Gasleck in Oldenburg', 'Bernd Britzel', 2, 3, 'NS', 'HD', '2021-05-19 00:00:00', '2021-05-22 00:00:00', '2021-05-22 12:00:00', 'HD betroffen', '26133', 'Oldenburg', null, 'Cloppenburger Str.', '302', '1234863-b234', 'ertf', '124,2323', 4, 8.210150, 53.111820, 'Link - extenes System', 'nicht veröffentlicht', 'Freitext: Eine Gasleitung wurde beschädigt', 4, null, false, 0, '2020-02-03 15:15:15', 'SCRIPT', '2020-02-24 20:08:41', 'SCRIPT');
+
+
+-- PUBLIC.HTBL_FAILURE_INFORMATION_STATION Automatic generanted History Table DDL --
+-- <GENERATED CODE!>
+
+DROP TABLE IF EXISTS PUBLIC.HTBL_FAILURE_INFORMATION_STATION;
+DROP SEQUENCE IF EXISTS PUBLIC.HTBL_FAILURE_INFORMATION_STATION_ID_SEQ;
+
+CREATE SEQUENCE PUBLIC.HTBL_FAILURE_INFORMATION_STATION_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+
+ALTER TABLE PUBLIC.HTBL_FAILURE_INFORMATION_STATION_ID_SEQ
+ OWNER TO gfi_service;
+
+CREATE TABLE PUBLIC.HTBL_FAILURE_INFORMATION_STATION
+(
+ HID integer NOT NULL DEFAULT nextval('HTBL_FAILURE_INFORMATION_STATION_ID_SEQ'::regclass),
+ HDATE timestamp without time zone NOT NULL,
+
+ FK_TBL_FAILURE_INFORMATION integer,
+ VERSION_NUMBER integer,
+ STATION_STATION_ID character varying (30),
+ CONSTRAINT HTBL_FAILURE_INFORMATION_STATION_PKEY PRIMARY KEY (HID)
+)
+WITH (
+ OIDS=FALSE
+);
+
+ALTER TABLE PUBLIC.HTBL_FAILURE_INFORMATION_STATION
+ OWNER TO gfi_service;
+GRANT ALL ON TABLE PUBLIC.HTBL_FAILURE_INFORMATION_STATION TO gfi_service;
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+-- Tables ADDRESSIMPORT
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+
+/*DROP TABLE IF EXISTS public.TBL_ADDRESS CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_ADDRESS_ID_SEQ;*/
+
+-- ---------------------------------------------
+-- TABLE TBL_ADDRESS
+-- ---------------------------------------------
+/*CREATE SEQUENCE public.TBL_ADDRESS_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.TBL_ADDRESS_ID_SEQ
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.TBL_ADDRESS
+(
+ ID integer NOT NULL DEFAULT nextval('TBL_ADDRESS_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ SDOX1 numeric(9,2) NOT NULL,
+ SDOY1 numeric(10,2) NOT NULL,
+ G3EFID numeric,
+ POSTCODE character varying(30),
+ COMMUNITY character varying(255),
+ DISTRICT character varying(255),
+ STREET character varying(255),
+ HOUSENUMBER character varying(30),
+ WATER_CONNECTION boolean,
+ WATER_GROUP character varying(255),
+ GAS_CONNECTION boolean,
+ GAS_GROUP character varying(255),
+ POWER_CONNECTION boolean,
+ STATION_ID character varying(30),
+ LONGITUDE numeric(9,6),
+ LATITUDE numeric(9,6),
+ CONSTRAINT TBL_ADDRESS_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.TBL_ADDRESS
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.TBL_ADDRESS TO GFI_SERVICE;
+
+CREATE INDEX idx_tbl_address_g3efid ON public.TBL_ADDRESS ( G3EFID );
+CREATE INDEX idx_tbl_address_postcode ON public.TBL_ADDRESS ( POSTCODE );
+CREATE INDEX idx_tbl_address_community ON public.TBL_ADDRESS ( COMMUNITY );
+CREATE INDEX idx_tbl_address_district ON public.TBL_ADDRESS ( DISTRICT );
+CREATE INDEX idx_tbl_address_street ON public.TBL_ADDRESS ( STREET );
+CREATE INDEX idx_tbl_address_station_id ON public.TBL_ADDRESS ( STATION_ID );*/
+
+
+-- ---------------------------------------------
+-- TABLE TBL_STATION
+-- ---------------------------------------------
+
+/*DROP TABLE IF EXISTS public.TBL_STATION CASCADE;
+DROP SEQUENCE IF EXISTS public.TBL_STATION_ID_SEQ;
+
+CREATE SEQUENCE public.TBL_STATION_ID_SEQ
+ INCREMENT 1
+ MINVALUE 1
+ MAXVALUE 9223372036854775807
+ START 1
+ CACHE 1;
+ALTER TABLE public.TBL_STATION_ID_SEQ
+ OWNER TO GFI_SERVICE;
+
+CREATE TABLE public.TBL_STATION
+(
+ ID integer NOT NULL DEFAULT nextval('TBL_STATION_ID_SEQ'::regclass),
+ UUID uuid NOT NULL,
+ SDOX1 numeric(9,2) NOT NULL,
+ SDOY1 numeric(10,2) NOT NULL,
+ G3EFID numeric,
+ STATION_ID character varying(30),
+ STATION_NAME character varying(255),
+ LONGITUDE numeric(9,6),
+ LATITUDE numeric(9,6),
+ CONSTRAINT TBL_STATION_PKEY PRIMARY KEY (id)
+);
+
+ALTER TABLE public.TBL_STATION
+ OWNER TO GFI_SERVICE;
+GRANT ALL ON TABLE public.TBL_STATION TO GFI_SERVICE;
+
+CREATE INDEX idx_tbl_station_g3efid ON public.TBL_STATION ( G3EFID );
+CREATE INDEX idx_tbl_station_station_id ON public.TBL_STATION ( STATION_ID );
+CREATE INDEX idx_tbl_station_uuid ON public.TBL_STATION ( UUID );
+*/
+
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+-- TRIGGER
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------
+--select * from htbl_failure_information where id = 4;
+
+-- PUBLIC.TBL_FAILURE_INFORMATION INSERT TRIGGER --
+-- <GENERATED CODE!>
+CREATE OR REPLACE FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG()
+ RETURNS trigger AS
+$BODY$
+ BEGIN
+ INSERT INTO HTBL_FAILURE_INFORMATION (
+ ID,UUID,VERSION_NUMBER,FK_REF_FAILURE_CLASSIFICATION,TITLE,DESCRIPTION,RESPONSIBILITY,FK_REF_STATUS_INTERN, FK_REF_BRANCH,VOLTAGE_LEVEL,PRESSURE_LEVEL,FAILURE_BEGIN,FAILURE_END_PLANNED,FAILURE_END_RESUPPLIED,INTERNAL_REMARK,POSTCODE,CITY,DISTRICT,STREET,HOUSENUMBER,STATION_ID,STATION_DESCRIPTION,STATION_COORDS,FK_REF_RADIUS,LONGITUDE,LATITUDE,FK_TBL_FAILURE_INFORMATION_CONDENSED,CONDENSED,CONDENSED_COUNT,OBJECT_REFERENCE_EXTERNAL_SYSTEM,PUBLICATION_STATUS,PUBLICATION_FREETEXT,FK_REF_EXPECTED_REASON,CREATE_DATE,CREATE_USER,MOD_DATE,MOD_USER,
+
+ HACTION,
+ HDATE,
+ HUSER
+ )
+ VALUES (
+
+ NEW.ID,NEW.UUID,NEW.VERSION_NUMBER,NEW.FK_REF_FAILURE_CLASSIFICATION,NEW.TITLE,NEW.DESCRIPTION,NEW.RESPONSIBILITY,NEW.FK_REF_STATUS_INTERN, NEW.FK_REF_BRANCH,NEW.VOLTAGE_LEVEL,NEW.PRESSURE_LEVEL,NEW.FAILURE_BEGIN,NEW.FAILURE_END_PLANNED,NEW.FAILURE_END_RESUPPLIED,NEW.INTERNAL_REMARK,NEW.POSTCODE,NEW.CITY,NEW.DISTRICT,NEW.STREET,NEW.HOUSENUMBER,NEW.STATION_ID,NEW.STATION_DESCRIPTION,NEW.STATION_COORDS,NEW.FK_REF_RADIUS,NEW.LONGITUDE,NEW.LATITUDE,NEW.FK_TBL_FAILURE_INFORMATION_CONDENSED,NEW.CONDENSED,NEW.CONDENSED_COUNT,NEW.OBJECT_REFERENCE_EXTERNAL_SYSTEM,NEW.PUBLICATION_STATUS,NEW.PUBLICATION_FREETEXT,NEW.FK_REF_EXPECTED_REASON,NEW.CREATE_DATE,NEW.CREATE_USER,NEW.MOD_DATE,NEW.MOD_USER,
+
+ 1,
+ current_timestamp,
+ NEW.CREATE_USER );
+ RETURN NEW;
+ END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE
+ COST 100;
+ALTER FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG()
+ OWNER TO gfi_service;
+
+
+DROP TRIGGER IF EXISTS TBL_FAILURE_INFORMATION_INSERT_TRG ON PUBLIC.TBL_FAILURE_INFORMATION;
+
+CREATE TRIGGER TBL_FAILURE_INFORMATION_INSERT_TRG
+ BEFORE INSERT
+ ON PUBLIC.TBL_FAILURE_INFORMATION
+ FOR EACH ROW
+ EXECUTE PROCEDURE PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG();
+
+-- AFTER INSERT -----------------------------------------------------------------------------
+CREATE OR REPLACE FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG_AFTER()
+ RETURNS trigger AS
+$BODY$
+ BEGIN
+ INSERT INTO HTBL_FAILURE_INFORMATION_STATION (
+ FK_HTBL_FAILURE_INFORMATION,STATION_STATION_ID,
+ HACTION,
+ HDATE,
+ HUSER
+ )
+ SELECT NEW.ID,
+ t.station_station_id,
+ 1,
+ current_timestamp,
+ NEW.MOD_USER
+ FROM TBL_FAILURE_INFORMATION_STATION t
+ WHERE t.fk_tbl_failure_information = NEW.ID;
+
+ RETURN NEW;
+ END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE
+ COST 100;
+ALTER FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG()
+ OWNER TO gfi_service;
+
+
+DROP TRIGGER IF EXISTS TBL_FAILURE_INFORMATION_INSERT_TRG_AFTER ON PUBLIC.TBL_FAILURE_INFORMATION;
+
+CREATE TRIGGER TBL_FAILURE_INFORMATION_INSERT_TRG_AFTER
+ AFTER INSERT
+ ON PUBLIC.TBL_FAILURE_INFORMATION
+ FOR EACH ROW
+ EXECUTE PROCEDURE PUBLIC.TBL_FAILURE_INFORMATION_INSERT_TRG_AFTER();
+
+-- PUBLIC.TBL_FAILURE_INFORMATION UPDATE TRIGGER --
+-- <GENERATED CODE!>
+
+CREATE OR REPLACE FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_UPDATE_TRG()
+ RETURNS trigger AS
+$BODY$
+ BEGIN
+ INSERT INTO HTBL_FAILURE_INFORMATION (
+ ID,UUID,VERSION_NUMBER,FK_REF_FAILURE_CLASSIFICATION,TITLE,DESCRIPTION,RESPONSIBILITY,FK_REF_STATUS_INTERN,FK_REF_BRANCH,VOLTAGE_LEVEL,PRESSURE_LEVEL,FAILURE_BEGIN,FAILURE_END_PLANNED,FAILURE_END_RESUPPLIED,INTERNAL_REMARK,POSTCODE,CITY,DISTRICT,STREET,HOUSENUMBER,STATION_ID,STATION_DESCRIPTION,STATION_COORDS,FK_REF_RADIUS,LONGITUDE,LATITUDE,FK_TBL_FAILURE_INFORMATION_CONDENSED,CONDENSED,CONDENSED_COUNT,OBJECT_REFERENCE_EXTERNAL_SYSTEM,PUBLICATION_STATUS,PUBLICATION_FREETEXT,FK_REF_EXPECTED_REASON,CREATE_DATE,CREATE_USER,MOD_DATE,MOD_USER,
+
+ HACTION,
+ HDATE,
+ HUSER
+ )
+ VALUES (
+ NEW.ID,NEW.UUID,NEW.VERSION_NUMBER,NEW.FK_REF_FAILURE_CLASSIFICATION,NEW.TITLE,NEW.DESCRIPTION,NEW.RESPONSIBILITY,NEW.FK_REF_STATUS_INTERN,NEW.FK_REF_BRANCH,NEW.VOLTAGE_LEVEL,NEW.PRESSURE_LEVEL,NEW.FAILURE_BEGIN,NEW.FAILURE_END_PLANNED,NEW.FAILURE_END_RESUPPLIED,NEW.INTERNAL_REMARK,NEW.POSTCODE,NEW.CITY,NEW.DISTRICT,NEW.STREET,NEW.HOUSENUMBER,NEW.STATION_ID,NEW.STATION_DESCRIPTION,NEW.STATION_COORDS,NEW.FK_REF_RADIUS,NEW.LONGITUDE,NEW.LATITUDE,NEW.FK_TBL_FAILURE_INFORMATION_CONDENSED,NEW.CONDENSED,NEW.CONDENSED_COUNT,NEW.OBJECT_REFERENCE_EXTERNAL_SYSTEM,NEW.PUBLICATION_STATUS,NEW.PUBLICATION_FREETEXT,NEW.FK_REF_EXPECTED_REASON,NEW.CREATE_DATE,NEW.CREATE_USER,NEW.MOD_DATE,NEW.MOD_USER,
+ 2,
+ current_timestamp,
+ NEW.MOD_USER
+ );
+ RETURN NEW;
+ END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE
+ COST 100;
+ALTER FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_UPDATE_TRG()
+ OWNER TO gfi_service;
+
+DROP TRIGGER IF EXISTS TBL_FAILURE_INFORMATION_UPDATE_TRG ON PUBLIC.TBL_FAILURE_INFORMATION;
+
+CREATE TRIGGER TBL_FAILURE_INFORMATION_UPDATE_TRG
+ BEFORE UPDATE
+ ON PUBLIC.TBL_FAILURE_INFORMATION
+ FOR EACH ROW
+ EXECUTE PROCEDURE PUBLIC.TBL_FAILURE_INFORMATION_UPDATE_TRG();
+
+
+
+-- PUBLIC.TBL_FAILURE_INFORMATION DELETE TRIGGER --
+-- <GENERATED CODE!>
+
+CREATE OR REPLACE FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_DELETE_TRG()
+ RETURNS trigger AS
+$BODY$
+ BEGIN
+ IF TG_OP = 'DELETE' THEN
+ INSERT INTO HTBL_FAILURE_INFORMATION (
+
+ ID,UUID,VERSION_NUMBER,FK_REF_FAILURE_CLASSIFICATION,TITLE,DESCRIPTION,RESPONSIBILITY,FK_REF_STATUS_INTERN,FK_REF_BRANCH,VOLTAGE_LEVEL,PRESSURE_LEVEL,FAILURE_BEGIN,FAILURE_END_PLANNED,FAILURE_END_RESUPPLIED,INTERNAL_REMARK,POSTCODE,CITY,DISTRICT,STREET,HOUSENUMBER,STATION_ID,STATION_DESCRIPTION,STATION_COORDS,FK_REF_RADIUS,LONGITUDE,LATITUDE,FK_TBL_FAILURE_INFORMATION_CONDENSED,CONDENSED,CONDENSED_COUNT,OBJECT_REFERENCE_EXTERNAL_SYSTEM,PUBLICATION_STATUS,PUBLICATION_FREETEXT,FK_REF_EXPECTED_REASON,CREATE_DATE,CREATE_USER,MOD_DATE,MOD_USER,
+
+ HACTION,
+ HDATE,
+ HUSER
+ )
+ VALUES (
+ OLD.ID,OLD.UUID,OLD.VERSION_NUMBER,OLD.FK_REF_FAILURE_CLASSIFICATION,OLD.TITLE,OLD.DESCRIPTION,OLD.RESPONSIBILITY,OLD.FK_REF_STATUS_INTERN,OLD.FK_REF_BRANCH,OLD.VOLTAGE_LEVEL,OLD.PRESSURE_LEVEL,OLD.FAILURE_BEGIN,OLD.FAILURE_END_PLANNED,OLD.FAILURE_END_RESUPPLIED,OLD.INTERNAL_REMARK,OLD.POSTCODE,OLD.CITY,OLD.DISTRICT,OLD.STREET,OLD.HOUSENUMBER,OLD.STATION_ID,OLD.STATION_DESCRIPTION,OLD.STATION_COORDS,OLD.FK_REF_RADIUS,OLD.LONGITUDE,OLD.LATITUDE,OLD.FK_TBL_FAILURE_INFORMATION_CONDENSED,OLD.CONDENSED,OLD.CONDENSED_COUNT,OLD.OBJECT_REFERENCE_EXTERNAL_SYSTEM,OLD.PUBLICATION_STATUS,OLD.PUBLICATION_FREETEXT,OLD.FK_REF_EXPECTED_REASON,OLD.CREATE_DATE,OLD.CREATE_USER,OLD.MOD_DATE,OLD.MOD_USER,
+
+ 3,
+ current_timestamp,
+ OLD.MOD_USER );
+ END IF;
+ RETURN OLD;
+ END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE
+ COST 100;
+ALTER FUNCTION PUBLIC.TBL_FAILURE_INFORMATION_DELETE_TRG()
+ OWNER TO gfi_service;
+
+DROP TRIGGER IF EXISTS TBL_FAILURE_INFORMATION_DELETE_TRG ON PUBLIC.TBL_FAILURE_INFORMATION;
+
+CREATE TRIGGER TBL_FAILURE_INFORMATION_DELETE_TRG
+ BEFORE DELETE
+ ON PUBLIC.TBL_FAILURE_INFORMATION
+ FOR EACH ROW
+ EXECUTE PROCEDURE PUBLIC.TBL_FAILURE_INFORMATION_DELETE_TRG();
+
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java
index 5d2a52c..14cb60e 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java
@@ -181,6 +181,9 @@
}
@Bean
+ HistFailureInformationStationMapper histFailureInformationStationMapper() { return new HistFailureInformationStationMapperImpl(); }
+
+ @Bean
public VersionService myVersionService() {
return new VersionService();
}
@@ -271,4 +274,7 @@
@Bean
public FailureInformationDistributionGroupService myFailureInformationDistributionGroupService() {return new FailureInformationDistributionGroupService();}
+ @Bean
+ public HistFailureInformationStationService myHistFailureInformationStationService() {return new HistFailureInformationStationService();}
+
}
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationControllerTest.java
index a542065..b92238c 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationControllerTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/HistFailureInformationControllerTest.java
@@ -16,8 +16,10 @@
import org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication;
import org.eclipse.openk.gridfailureinformation.service.HistFailureInformationService;
+import org.eclipse.openk.gridfailureinformation.service.HistFailureInformationStationService;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -45,6 +47,9 @@
@MockBean
private HistFailureInformationService histFailureInformationService;
+ @MockBean
+ private HistFailureInformationStationService histFailureInformationStationService;
+
@Autowired
private MockMvc mockMvc;
@@ -75,4 +80,21 @@
.andExpect(jsonPath("responsibility", is( dto.getResponsibility())));
}
+
+ @Test
+ public void shouldFindStationsforHistFailureInfoVersion() throws Exception {
+ List<StationDto> dto = MockDataHelper.mockStationDtoList();
+
+ when(histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(
+ any(UUID.class),
+ any(Long.class)
+ )).thenReturn(dto);
+
+ String versionId = Long.toString(new Random().nextLong());
+
+ mockMvc.perform(get("/hist-grid-failure-informations/{uuid}/versions/{versionNumber}/stations" ,UUID.randomUUID(),new Random().nextLong() ))
+ .andExpect(status().is2xxSuccessful())
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON));
+ }
+
}
\ No newline at end of file
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationServiceTest.java
index 2fcc505..e6c84c9 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationServiceTest.java
@@ -19,6 +19,7 @@
import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -46,27 +47,41 @@
@MockBean
private HistFailureInformationRepository histFailureInformationRepository;
+ @MockBean
+ private HistFailureInformationStationService histFailureInformationStationService;
+
@Test
public void shouldFindHistFailureInformationsByUuid() {
List<HtblFailureInformation> mockHistFailureList = MockDataHelper.mockHistTblFailureInformationList();
+ List<StationDto> stationDtoList = MockDataHelper.mockStationDtoList();
+
when(histFailureInformationRepository.findByUuid(any(UUID.class))).thenReturn(mockHistFailureList);
+ when(histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(any(UUID.class), any(Long.class))).thenReturn(stationDtoList);
+
List<FailureInformationDto> retList = histFailureInformationService.getFailureInformationVersionsByUuid(UUID.randomUUID());
assertEquals(retList.size(), mockHistFailureList.size());
assertEquals(2, retList.size());
assertEquals(retList.get(1).getUuid(), mockHistFailureList.get(1).getUuid());
assertEquals(retList.get(0).getResponsibility(), mockHistFailureList.get(0).getResponsibility());
+ assertEquals(retList.get(0).getStationIds().size(), stationDtoList.size());
+ assertEquals(retList.get(0).getStationIds().get(0), stationDtoList.get(0).getUuid());
}
@Test
public void shouldFindASingleHistFailureInformationVersion() {
HtblFailureInformation mockHistFailure = MockDataHelper.mockHistTblFailureInformation();
+ List<StationDto> stationDtoList = MockDataHelper.mockStationDtoList();
+
when(histFailureInformationRepository.findByUuidAndVersionNumber(any(UUID.class), any(Long.class))).thenReturn(Optional.of(mockHistFailure));
+ when(histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(any(UUID.class), any(Long.class))).thenReturn(stationDtoList);
+
FailureInformationDto retDto = histFailureInformationService.getFailureInformationVersion(UUID.randomUUID(), new Random().nextLong());
assertEquals( mockHistFailure.getResponsibility(), retDto.getResponsibility() );
assertEquals( mockHistFailure.getUuid(), retDto.getUuid());
+ assertEquals( stationDtoList.get(0).getUuid(), retDto.getStationIds().get(0));
}
}
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationServiceTest.java
new file mode 100644
index 0000000..e8cec9e
--- /dev/null
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationServiceTest.java
@@ -0,0 +1,126 @@
+/*
+ *******************************************************************************
+ * 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.config.TestConfiguration;
+import org.eclipse.openk.gridfailureinformation.mapper.HistFailureInformationMapper;
+import org.eclipse.openk.gridfailureinformation.mapper.StationMapper;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformationStation;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.TblStation;
+import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationStationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StationRepository;
+import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
+import org.eclipse.openk.gridfailureinformation.viewmodel.HistFailureInformationStationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import static org.hibernate.validator.internal.util.Contracts.assertNotEmpty;
+import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@DataJpaTest
+@ContextConfiguration(classes = {TestConfiguration.class})
+
+public class HistFailureInformationStationServiceTest {
+ @Qualifier("myHistFailureInformationStationService")
+ @Autowired
+ private HistFailureInformationStationService histFailureInformationStationService;
+
+ @Autowired
+ private HistFailureInformationMapper histFailureInformationMapper;
+
+ @Autowired
+ private StationMapper stationMapper;
+
+ @MockBean
+ private HistFailureInformationStationRepository histFailureInformationStationRepository;
+
+ @MockBean
+ private HistFailureInformationRepository histFailureInformationRepository;
+
+ @MockBean
+ private StationRepository stationRepository;
+
+
+ @Test
+ public void shouldGetAllStationsForFailureInfoVersion() {
+ //TblFailureInformation failureInformation = MockDataHelper.mockTblFailureInformation();
+ HtblFailureInformation histTblFailureInformation = MockDataHelper.mockHistTblFailureInformation();
+ List<HtblFailureInformationStation> htblFailureInformationStationList = MockDataHelper.mockHistTblFailureInformationStationList();
+
+ TblStation tblStation = MockDataHelper.mockTblStation();
+ List<StationDto> stationDtoList = MockDataHelper.mockTblStationList()
+ .stream()
+ .map( stationMapper::toStationDto )
+ .collect(Collectors.toList());
+
+ when(histFailureInformationRepository.findByUuidAndVersionNumber(any(UUID.class), any(Long.class))).thenReturn(Optional.of(histTblFailureInformation));
+ when(histFailureInformationStationRepository.findByFkTblFailureInformationAndVersionNumber(any(Long.class), any(Long.class))).thenReturn(htblFailureInformationStationList);
+ when(stationRepository.findByStationId(any(String.class))).thenReturn(Optional.of(tblStation));
+
+ List<StationDto> testStationDtos = histFailureInformationStationService.findHistStationsByFailureInfoAndVersionNumber(UUID.randomUUID(), new Random().nextLong());
+
+ assertEquals(stationDtoList.size(), testStationDtos.size());
+ assertEquals(2, testStationDtos.size());
+ assertEquals(1, stationDtoList.stream().filter(x->x.getG3efid().equals(tblStation.getG3efid())).count());
+ }
+
+ @Test
+ public void shouldInsertStationsForFailureInfoVersion() {
+ HtblFailureInformationStation histFailureInfoStation = MockDataHelper.mockHistTblFailureInformationStation();
+ TblFailureInformation failureInformation = MockDataHelper.mockTblFailureInformation();
+ when(histFailureInformationStationRepository.save(any(HtblFailureInformationStation.class))).thenReturn(histFailureInfoStation);
+
+ List<HistFailureInformationStationDto> savedHistFailureInfoStationDtos = histFailureInformationStationService.insertHistFailureInfoStationsForGfi(failureInformation);
+
+ assertEquals(savedHistFailureInfoStationDtos.size(), failureInformation.getStations().size());
+ assertEquals(savedHistFailureInfoStationDtos.get(0).getFailureInformationId(), histFailureInfoStation.getFkTblFailureInformation());
+ assertEquals(savedHistFailureInfoStationDtos.get(0).getStationStationId(), histFailureInfoStation.getStationStationId());
+ assertEquals(savedHistFailureInfoStationDtos.get(0).getVersionNumber(), histFailureInfoStation.getVersionNumber());
+ }
+
+
+ @Test
+ public void shouldNotInsertStationsForFailureInfoVersion_NoStations() {
+ HtblFailureInformationStation histFailureInfoStation = MockDataHelper.mockHistTblFailureInformationStation();
+ TblFailureInformation failureInformation = MockDataHelper.mockTblFailureInformation2();
+ Set<TblStation> tblStationList = new HashSet<>();
+ failureInformation.setStations(tblStationList);
+ when(histFailureInformationStationRepository.save(any(HtblFailureInformationStation.class))).thenReturn(histFailureInfoStation);
+
+ List<HistFailureInformationStationDto> savedHistFailureInfoStationDtos = histFailureInformationStationService.insertHistFailureInfoStationsForGfi(failureInformation);
+
+ assertEquals(savedHistFailureInfoStationDtos.size(), failureInformation.getStations().size());
+ }
+
+}
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
index ab4b5c3..b32d06b 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
@@ -18,8 +18,40 @@
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
import org.eclipse.openk.gridfailureinformation.config.rabbitMq.RabbitMqChannel;
import org.eclipse.openk.gridfailureinformation.constants.Constants;
-import org.eclipse.openk.gridfailureinformation.model.*;
-import org.eclipse.openk.gridfailureinformation.viewmodel.*;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformationStation;
+import org.eclipse.openk.gridfailureinformation.model.RefBranch;
+import org.eclipse.openk.gridfailureinformation.model.RefExpectedReason;
+import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification;
+import org.eclipse.openk.gridfailureinformation.model.RefRadius;
+import org.eclipse.openk.gridfailureinformation.model.RefStatus;
+import org.eclipse.openk.gridfailureinformation.model.TblAddress;
+import org.eclipse.openk.gridfailureinformation.model.TblDistributionGroup;
+import org.eclipse.openk.gridfailureinformation.model.TblDistributionGroupMember;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationDistributionGroup;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationPublicationChannel;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationReminderMailSent;
+import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationStation;
+import org.eclipse.openk.gridfailureinformation.model.TblImportData;
+import org.eclipse.openk.gridfailureinformation.model.TblStation;
+import org.eclipse.openk.gridfailureinformation.model.Version;
+import org.eclipse.openk.gridfailureinformation.viewmodel.BranchDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupMemberDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.ExpectedReasonDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.FailureClassificationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDistributionGroupDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationPublicationChannelDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationStationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.HistFailureInformationStationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.HousenumberUuidDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.ImportDataDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.RadiusDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.StatusDto;
+import org.eclipse.openk.gridfailureinformation.viewmodel.VersionDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
@@ -27,11 +59,12 @@
import java.math.BigDecimal;
import java.sql.Date;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
import java.util.stream.Collectors;
-import static org.eclipse.openk.gridfailureinformation.constants.Constants.INTERNAL_SHORT;
-
@Log4j2
public class MockDataHelper {
@@ -465,6 +498,7 @@
public static HtblFailureInformation mockHistTblFailureInformation() {
HtblFailureInformation obj = new HtblFailureInformation();
+ obj.setId(789L);
obj.setUuid(UUID.randomUUID());
obj.setVersionNumber(1L);
obj.setResponsibility("Dudley Dursley");
@@ -500,6 +534,7 @@
public static HtblFailureInformation mockHistTblFailureInformation2() {
HtblFailureInformation obj = new HtblFailureInformation();
+ obj.setId(789L);
obj.setUuid(UUID.randomUUID());
obj.setVersionNumber(2L);
obj.setResponsibility("Donald Duck");
@@ -1398,4 +1433,37 @@
return tblFiReminderMailSent;
}
+
+ public static HtblFailureInformationStation mockHistTblFailureInformationStation() {
+ HtblFailureInformationStation histTblFailureInfoStation = new HtblFailureInformationStation();
+ histTblFailureInfoStation.setHid(299L);
+ histTblFailureInfoStation.setFkTblFailureInformation(42L);
+ histTblFailureInfoStation.setVersionNumber(3L);
+ histTblFailureInfoStation.setStationStationId("23456");
+ return histTblFailureInfoStation;
+ }
+
+ public static HtblFailureInformationStation mockHistTblFailureInformationStation2() {
+ HtblFailureInformationStation histTblFailureInfoStation = new HtblFailureInformationStation();
+ histTblFailureInfoStation.setHid(106L);
+ histTblFailureInfoStation.setFkTblFailureInformation(42L);
+ histTblFailureInfoStation.setVersionNumber(3L);
+ histTblFailureInfoStation.setStationStationId("44556");
+ return histTblFailureInfoStation;
+ }
+
+ public static List<HtblFailureInformationStation> mockHistTblFailureInformationStationList() {
+ List<HtblFailureInformationStation> htblFailureInformationStationList = new ArrayList<>();
+ htblFailureInformationStationList.add(mockHistTblFailureInformationStation());
+ htblFailureInformationStationList.add(mockHistTblFailureInformationStation2());
+ return htblFailureInformationStationList;
+ }
+
+ public static HistFailureInformationStationDto mocHistkFailureInformationStationDto() {
+ HistFailureInformationStationDto histFailureInfoGroupDto = new HistFailureInformationStationDto();
+ histFailureInfoGroupDto.setFailureInformationId(13579L);
+ histFailureInfoGroupDto.setVersionNumber(7L);
+ histFailureInfoGroupDto.setStationStationId("97531");
+ return histFailureInfoGroupDto;
+ }
}