Commit 8e57b85b authored by Ina Curdt's avatar Ina Curdt
Browse files

SI-253 Hochzählen der Versionsnummer

parent aa6f1410
/*
*******************************************************************************
* 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 HtblFailureInformation {
@Id
//@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "htbl_failure_information_id_seq")
//@SequenceGenerator(name = "tbl_failure_information_id_seq", sequenceName = "tbl_failure_information_id_seq", allocationSize = 1)
@Column(name = "hid", updatable = false)
private Long hid;
private Long haction;
private Date hdate;
private String huser;
private Long id;
private UUID uuid;
private Long versionNumber;
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;
}
......@@ -29,6 +29,7 @@ public class TblFailureInformation {
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private Long versionNumber;
private String responsibility;
private String internExtern;
private String voltageLevel;
......
/*
*******************************************************************************
* 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.HtblFailureInformation;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Repository
public interface HtblFailureInformationRepository extends JpaRepository<HtblFailureInformation, Long > {
List<HtblFailureInformation> findByUuid(UUID uuid);
Long countByUuid(UUID uuid);
}
......@@ -17,6 +17,7 @@ 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.model.HtblFailureInformation;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.eclipse.openk.gridfailureinformation.repository.*;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
......@@ -35,6 +36,9 @@ public class FailureInformationService {
@Autowired
private FailureInformationRepository failureInformationRepository;
@Autowired
private HtblFailureInformationRepository htblfailureInformationRepository;
@Autowired
private FailureInformationMapper failureInformationMapper;
......@@ -66,11 +70,13 @@ public class FailureInformationService {
public FailureInformationDto insertFailureInfo(FailureInformationDto failureInfoDto){
TblFailureInformation tblFailureInformationToSave = gridFailureInformationMapper.toTblFailureInformation(failureInfoDto);
tblFailureInformationToSave.setUuid(UUID.randomUUID());
tblFailureInformationToSave.setVersionNumber(1L);
setFromGridFailureInformationDto(tblFailureInformationToSave, failureInfoDto);
return gridFailureInformationMapper.toFailureInformationDto(failureInformationRepository.save(tblFailureInformationToSave));
}
@Transactional
public FailureInformationDto updateFailureInfo(FailureInformationDto failureInfoDto) {
TblFailureInformation tblFailureInformation = failureInformationRepository.findByUuid(failureInfoDto.getUuid())
......@@ -80,6 +86,11 @@ public class FailureInformationService {
tblFailureInformationToSave.setId(tblFailureInformation.getId());
setFromGridFailureInformationDto(tblFailureInformationToSave, failureInfoDto);
// Holen der nächstes Versionsnummer mit Hilfe der History-Tabelle
Long countVersions = htblfailureInformationRepository.countByUuid(failureInfoDto.getUuid());
tblFailureInformationToSave.setVersionNumber(countVersions + 1);
TblFailureInformation savedFailureInformation = failureInformationRepository.save(tblFailureInformationToSave);
return gridFailureInformationMapper.toFailureInformationDto(savedFailureInformation);
}
......
......@@ -26,6 +26,7 @@ import java.util.UUID;
public class FailureInformationDto implements Serializable {
@JsonProperty("id")
private UUID uuid;
private Long versionNumber;
private String responsibility;
private String internExtern;
private String voltageLevel;
......
-----------------------------------------------------------------------------------
-- *******************************************************************************
-- * 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(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 ( '8db5a71b-9676-45ca-ae1d-161c6a2dc305', 'Ereignis', NULL );
INSERT INTO public.REF_FAILURE_CLASSIFICATION (UUID, CLASSIFICATION, DESCRIPTION) VALUES ( '8ec1e144-5230-4d43-a3df-f62dd64bb855', 'geplante Maßnahme', NULL );
-- ---------------------------------------------
-- TABLE REF_FAILURE_TYPE
-- ---------------------------------------------
CREATE SEQUENCE public.ref_failure_type_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE public.ref_failure_type_id_seq
OWNER TO GFI_SERVICE;
CREATE TABLE public.REF_FAILURE_TYPE
(
ID integer NOT NULL DEFAULT nextval('REF_FAILURE_TYPE_ID_SEQ'::regclass),
UUID uuid NOT NULL,
TYPE character varying(50) NOT NULL,
DESCRIPTION character varying(255) NULL,
CONSTRAINT REF_FAILURE_TYPE_PKEY PRIMARY KEY (id)
);
ALTER TABLE public.REF_FAILURE_TYPE
OWNER TO GFI_SERVICE;
GRANT ALL ON TABLE public.REF_FAILURE_TYPE TO GFI_SERVICE;
INSERT INTO public.REF_FAILURE_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '44a2aaed-8910-4116-b0c4-0855f8d3c28d', 'Information', NULL );
INSERT INTO public.REF_FAILURE_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '94e880c4-3127-47d5-aaee-5f778462ab0c', 'zu veröffentliche Meldung', 'Standardwert' );
INSERT INTO public.REF_FAILURE_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '658245bd-bdc4-47dd-bc90-0336f9471410', 'unterlagerte Störung', 'Nicht zu veröffentlichen' );
-- ---------------------------------------------
-- 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');
-- ---------------------------------------------
-- 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,
FK_REF_FAILURE_TYPE integer,
RESPONSIBILITY character varying(255),
INTERN_EXTERN character varying(1),
FK_REF_STATUS_INTERN integer NOT NULL,
FK_REF_STATUS_EXTERN 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,
PROBABLE_REASON character varying(1024),
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_DESCRIPTION character varying(255),
STATION_COORDS character varying(255),
RADIUS character varying(100),
CONSTRAINT TBL_FAILURE_INFORMATION_PKEY PRIMARY KEY (id)
);
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, FK_REF_FAILURE_TYPE, RESPONSIBILITY, INTERN_EXTERN, FK_REF_STATUS_INTERN, FK_REF_STATUS_EXTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, PROBABLE_REASON, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_DESCRIPTION, STATION_COORDS, RADIUS, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
VALUES ('6432a9c9-0384-44af-9bb8-34f2878d7b49',1, 1, 1, 'Rolf Rudis', 'I', 1, 1, 1, 'NS', null, '2021-01-19 00:00:00', '2021-01-22 00:00:00', '2021-01-22 12:00:00', 'Stromausfall durch Bagger', 'Der Bagger grub zu tief', '77654', 'Buddelbrugg', 'Westbezirk', 'Hauptstraße', '5a', 'Trafo 1', '124,2323', '2km', '2020-01-22 15:32:15', 'schmidth', '2020-01-24 08:02:44', 'meyers');
INSERT INTO public.tbl_failure_information(UUID, VERSION_NUMBER, FK_REF_FAILURE_CLASSIFICATION, FK_REF_FAILURE_TYPE, RESPONSIBILITY, INTERN_EXTERN, FK_REF_STATUS_INTERN, FK_REF_STATUS_EXTERN, FK_REF_BRANCH, VOLTAGE_LEVEL, PRESSURE_LEVEL, FAILURE_BEGIN, FAILURE_END_PLANNED, FAILURE_END_RESUPPLIED, PROBABLE_REASON, INTERNAL_REMARK, POSTCODE, CITY, DISTRICT, STREET, HOUSENUMBER, STATION_DESCRIPTION, STATION_COORDS, RADIUS, CREATE_DATE, CREATE_USER, MOD_DATE, MOD_USER)
VALUES ('37aef635-d0d4-4c47-ac25-c0d16c29e35c', 1,3, 2, 'Bernd Britzel', 'E', 2, 2, 3, null, 'HD', '2021-05-19 00:00:00', '2021-05-22 00:00:00', '2021-05-22 12:00:00', 'Leck in Gasleitung', 'HD betroffen', '77344', 'Hitzingen', null, 'Ostring', '104', 'ertf', '124,2323', '6km', '2020-02-03 15:15:15', 'schulzek', '2020-02-24 20:08:41', 'muellert');
-- ----------------------------------------------------------------------------
-- ----------------------------------------------------------------------------
-- 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,
FK_REF_FAILURE_TYPE integer,
RESPONSIBILITY character varying (255),
INTERN_EXTERN character varying (1),
FK_REF_STATUS_INTERN integer,
FK_REF_STATUS_EXTERN 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,
PROBABLE_REASON character varying (1024),
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_DESCRIPTION character varying (255),
STATION_COORDS character varying (255),
RADIUS character varying (100),
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;
-- ----------------------------------------------------------------------------
-- ----------------------------------------------------------------------------
-- TRIGGER
-- ----------------------------------------------------------------------------
-- ----------------------------------------------------------------------------
-- 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,FK_REF_FAILURE_TYPE,RESPONSIBILITY,INTERN_EXTERN,FK_REF_STATUS_INTERN,FK_REF_STATUS_EXTERN,FK_REF_BRANCH,VOLTAGE_LEVEL,PRESSURE_LEVEL,FAILURE_BEGIN,FAILURE_END_PLANNED,FAILURE_END_RESUPPLIED,PROBABLE_REASON,INTERNAL_REMARK,POSTCODE,CITY,DISTRICT,STREET,HOUSENUMBER,STATION_DESCRIPTION,STATION_COORDS,RADIUS,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.FK_REF_FAILURE_TYPE,NEW.RESPONSIBILITY,NEW.INTERN_EXTERN,NEW.FK_REF_STATUS_INTERN,NEW.FK_REF_STATUS_EXTERN,NEW.FK_REF_BRANCH,NEW.VOLTAGE_LEVEL,NEW.PRESSURE_LEVEL,NEW.FAILURE_BEGIN,NEW.FAILURE_END_PLANNED,NEW.FAILURE_END_RESUPPLIED,NEW.PROBABLE_REASON,NEW.INTERNAL_REMARK,NEW.POSTCODE,NEW.CITY,NEW.DISTRICT,NEW.STREET,NEW.HOUSENUMBER,NEW.STATION_DESCRIPTION,NEW.STATION_COORDS,NEW.RADIUS,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();
-- 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,FK_REF_FAILURE_TYPE,RESPONSIBILITY,INTERN_EXTERN,FK_REF_STATUS_INTERN,FK_REF_STATUS_EXTERN,FK_REF_BRANCH,VOLTAGE_LEVEL,PRESSURE_LEVEL,FAILURE_BEGIN,FAILURE_END_PLANNED,FAILURE_END_RESUPPLIED,PROBABLE_REASON,INTERNAL_REMARK,POSTCODE,CITY,DISTRICT,STREET,HOUSENUMBER,STATION_DESCRIPTION,STATION_COORDS,RADIUS,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.FK_REF_FAILURE_TYPE,NEW.RESPONSIBILITY,NEW.INTERN_EXTERN,NEW.FK_REF_STATUS_INTERN,NEW.FK_REF_STATUS_EXTERN,NEW.FK_REF_BRANCH,NEW.VOLTAGE_LEVEL,NEW.PRESSURE_LEVEL,NEW.FAILURE_BEGIN,NEW.FAILURE_END_PLANNED,NEW.FAILURE_END_RESUPPLIED,NEW.PROBABLE_REASON,NEW.INTERNAL_REMARK,NEW.POSTCODE,NEW.CITY,NEW.DISTRICT,NEW.STREET,NEW.HOUSENUMBER,NEW.STATION_DESCRIPTION,NEW.STATION_COORDS,NEW.RADIUS,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