Commit c74e0661 authored by Dimitrios Chalepakis's avatar Dimitrios Chalepakis
Browse files

SI-545 flyway added, Logs and tests adjusted


Signed-off-by: Dimitrios Chalepakis's avatarDimitrios Chalepakis <dimitrios.chalepakis@pta.de>
parent 15d59e13
......@@ -26,6 +26,15 @@
<jruby-complete-version>9.0.0.0</jruby-complete-version>
<mapstruct.version>1.2.0.Final</mapstruct.version>
<flyway-core.version>6.0.8</flyway-core.version>
<flyway.sqlMigrationSeparator>__</flyway.sqlMigrationSeparator>
<flyway.url>jdbc:postgresql://entopticadirx:5432/GridFailureInfoDevServer</flyway.url>
<flyway.user>gfi_service</flyway.user>
<flyway.password>gfi_service</flyway.password>
<flyway.schemas>public</flyway.schemas>
<flyway.table>address_flyway_schema_history</flyway.table>
<flyway.locations>classpath:db/migration/</flyway.locations>
<postgresql.version>42.2.8</postgresql.version>
<lombock.version>1.18.10</lombock.version>
<h2.version>1.4.200</h2.version>
......
......@@ -18,6 +18,8 @@ import javax.xml.ws.http.HTTPException;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
@Service
......@@ -65,18 +67,20 @@ public class AddressImportService {
log.info("CleanUp ENDE");
}
log.info("Adressimport START");
log.info("Import START");
log.info("- Adressimport START");
importAddressFile(cleanUp);
log.info("Import Power Connections START");
log.info("-- Import Power Connections START");
importPowerConnectionsAddressFile();
log.info("Import Water Connections START");
log.info("-- Import Water Connections START");
importWaterConnectionsAddressFile();
log.info("Import Gas Connections START");
log.info("-- Import Gas Connections START");
importGasConnectionsAddressFile();
log.info("Adressimport ENDE");
log.info("Import Power Stations START");
log.info("- Adressimport ENDE");
log.info("- Import PowerStations START");
importPowerStationFile(cleanUp);
log.info("Stationsimport ENDE");
log.info("- Import PowerStations ENDE");
log.info("Import END");
synchronized (importInWork) {
importInWork = Boolean.FALSE;
......@@ -85,7 +89,7 @@ public class AddressImportService {
public void importAddressFile(boolean isTableClean) {
Instant start = Instant.now();
String csvFile = fileAddresses;
CSVReader reader = null;
......@@ -105,6 +109,8 @@ public class AddressImportService {
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
Instant end = Instant.now();
log.info("Duration: " + Duration.between(start, end));
}
private void storeAddress(boolean isTableClean, String[] line) {
......@@ -134,7 +140,7 @@ public class AddressImportService {
public void importPowerConnectionsAddressFile() {
Instant start = Instant.now();
String csvFile = filePowerConnections;
CSVReader reader = null;
......@@ -171,11 +177,13 @@ public class AddressImportService {
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
Instant end = Instant.now();
log.info("Duration: " + Duration.between(start, end));
}
public void importWaterConnectionsAddressFile() {
Instant start = Instant.now();
String csvFile = fileWaterConnections;
CSVReader reader = null;
......@@ -212,10 +220,12 @@ public class AddressImportService {
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
Instant end = Instant.now();
log.info("Duration: " + Duration.between(start, end));
}
public void importGasConnectionsAddressFile() {
Instant start = Instant.now();
String csvFile = fileGasConnections;
CSVReader reader = null;
......@@ -252,10 +262,12 @@ public class AddressImportService {
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
Instant end = Instant.now();
log.info("Duration: " + Duration.between(start, end));
}
public void importPowerStationFile(boolean isTableClean) {
Instant start = Instant.now();
String csvFile = filePowerStations;
CSVReader reader = null;
......@@ -289,19 +301,12 @@ public class AddressImportService {
savedStationDto = stationService.updateOrInsertStationByG3efid(stationDto);
}
/* System.out.println("Adresse [sdo_x1= " + line[0]
+ ", sdo_y1= " + line[1]
+ ", g3e_fid=" + line[2]
+ ", plz=" + line[3]
+ ", ort=" + line[4]
+ ", ortsteil=" + line[5]
+ ", strasse=" + line[6]
+ ", hausnummer=" + line[7]
+ "]");*/
}
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
Instant end = Instant.now();
log.info("Duration: " + Duration.between(start, end));
}
}
......
......@@ -72,6 +72,7 @@ public class AddressService {
} catch (Exception ex) {
ex.printStackTrace();
log.warn("Adresse [sdo_x1= " + addressDto.getSdox1()
+ ", sdo_y1= " + addressDto.getSdoy1()
+ ", g3e_fid=" + addressDto.getG3efid()
......
-----------------------------------------------------------------------------------
-- *******************************************************************************
-- * 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';
-- ----------------------------------------------------------------------------
-- ----------------------------------------------------------------------------
-- 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 );
-- ---------------------------------------------
-- 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_postcode ON public.TBL_ADDRESS ( POSTCODE );
CREATE INDEX idx_tbl_station_community ON public.TBL_ADDRESS ( COMMUNITY );
CREATE INDEX idx_tbl_station_district ON public.TBL_ADDRESS ( DISTRICT );
CREATE INDEX idx_tbl_station_street ON public.TBL_ADDRESS ( STREET );
......@@ -50,7 +50,7 @@ public class AddressServiceTest {
@Test
public void shouldDeleteAllAdressesProperly() {
addressService.deleteAllAddresses();
verify(addressRepository, times(1)).deleteAll();
verify(addressRepository, times(1)).deleteAllInBatch();
}
@Test
......
......@@ -51,7 +51,7 @@ public class StationServiceTest {
@Test
public void shouldDeleteAllStationsProperly() {
stationService.deleteAllStations();
verify(stationRepository, times(1)).deleteAll();
verify(stationRepository, times(1)).deleteAllInBatch();
}
@Test
......
......@@ -23,7 +23,8 @@
<flyway.user>gfi_service</flyway.user>
<flyway.password>gfi_service</flyway.password>
<flyway.schemas>public</flyway.schemas>
<flyway.locations>filesystem:src/main/resources/db/migration/</flyway.locations>
<flyway.table>flyway_schema_history</flyway.table>
<flyway.locations>classpath:db/migration/</flyway.locations>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment