Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse openK User Modules
org.eclipse.openk-usermodules.gridFailureInformation.backend
Commits
e3019204
Commit
e3019204
authored
Apr 09, 2020
by
Ina Curdt
Browse files
Merge conflicts with branch 'SI-381-Auswahl-aus-Adressbestand' resolved
parents
18f1554e
a6212fff
Changes
3
Hide whitespace changes
Inline
Side-by-side
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/AddressController.java
0 → 100644
View file @
e3019204
/*
*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package
org.eclipse.openk.gridfailureinformation.controller
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponses
;
import
lombok.extern.log4j.Log4j2
;
import
org.eclipse.openk.gridfailureinformation.service.AddressService
;
import
org.eclipse.openk.gridfailureinformation.service.BranchService
;
import
org.eclipse.openk.gridfailureinformation.viewmodel.BranchDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.annotation.Secured
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.UUID
;
@Log4j2
@RestController
@RequestMapping
(
"/addresses"
)
public
class
AddressController
{
@Autowired
private
AddressService
addressService
;
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation
(
value
=
"Anzeige aller PLZs"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Erfolgreich durchgeführt"
)})
@GetMapping
(
"/postcodes"
)
public
List
<
String
>
findAllPostCodes
()
{
return
addressService
.
getPostcodes
();
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation
(
value
=
"Anzeige eines Orte nach Postleitzahl"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Erfolgreich durchgeführt"
)})
@GetMapping
(
"/communities/{postcode}"
)
public
List
<
String
>
findAllCommunitiesByPostcode
(
@PathVariable
String
postcode
)
{
return
addressService
.
getCommunities
(
postcode
);
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation
(
value
=
"Anzeige Ortsteile nach Postleitzahl und Ort"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Erfolgreich durchgeführt"
)})
@GetMapping
(
"/districts"
)
public
List
<
String
>
findDistricts
(
@RequestParam
(
"postcode"
)
String
postcode
,
@RequestParam
(
"community"
)
String
community
)
{
return
addressService
.
getDistricts
(
postcode
,
community
);
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation
(
value
=
"Anzeige Strassen nach Postleitzahl und Ort und Ortsteil (optional)"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Erfolgreich durchgeführt"
)})
@GetMapping
(
"/streets"
)
public
List
<
String
>
findStreets
(
@RequestParam
(
"postcode"
)
String
postcode
,
@RequestParam
(
"community"
)
String
community
,
@RequestParam
(
"district"
)
Optional
<
String
>
district
)
{
return
addressService
.
getStreets
(
postcode
,
community
,
district
);
}
//@Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
@ApiOperation
(
value
=
"Anzeige Strassen nach Postleitzahl und Ort und Strasse"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Erfolgreich durchgeführt"
)})
@GetMapping
(
"/housenumbers"
)
public
List
<
String
>
findHousenumbers
(
@RequestParam
(
"postcode"
)
String
postcode
,
@RequestParam
(
"community"
)
String
community
,
@RequestParam
(
"street"
)
String
street
)
{
return
addressService
.
getHousenumbers
(
postcode
,
community
,
street
);
}
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/AddressRepository.java
View file @
e3019204
...
...
@@ -17,6 +17,8 @@ package org.eclipse.openk.gridfailureinformation.repository;
import
org.eclipse.openk.gridfailureinformation.model.TblAddress
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -30,4 +32,22 @@ public interface AddressRepository extends JpaRepository<TblAddress, Long > {
Optional
<
TblAddress
>
findByUuid
(
UUID
uuid
);
@Query
(
"select distinct a.postcode from TblAddress a"
)
List
<
String
>
findAllPostcodes
();
@Query
(
"select distinct a.community from TblAddress a where postcode = :postcode"
)
List
<
String
>
findCommunitiesByPostcode
(
@Param
(
"postcode"
)
String
postcode
);
@Query
(
"select distinct a.district from TblAddress a where postcode = :postcode and community = :community"
)
List
<
String
>
findDistrictsByPostcodeAndCommunity
(
@Param
(
"postcode"
)
String
postcode
,
@Param
(
"community"
)
String
community
);
@Query
(
"select distinct a.street from TblAddress a where postcode = :postcode and community = :community"
)
List
<
String
>
findStreetsByPostcodeAndCommunity
(
@Param
(
"postcode"
)
String
postcode
,
@Param
(
"community"
)
String
community
);
@Query
(
"select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district"
)
List
<
String
>
findStreetsByPostcodeAndCommunityAndDistrict
(
@Param
(
"postcode"
)
String
postcode
,
@Param
(
"community"
)
String
community
,
@Param
(
"district"
)
String
district
);
@Query
(
"select distinct a.housenumber from TblAddress a where postcode = :postcode and community = :community and street = :street"
)
List
<
String
>
findHousenumbersByPostcodeAndCommunityAndStreet
(
@Param
(
"postcode"
)
String
postcode
,
@Param
(
"community"
)
String
community
,
@Param
(
"street"
)
String
street
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/AddressService.java
View file @
e3019204
...
...
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -39,5 +40,34 @@ public class AddressService {
.
collect
(
Collectors
.
toList
());
}
public
List
<
String
>
getPostcodes
(){
return
addressRepository
.
findAllPostcodes
();
}
public
List
<
String
>
getCommunities
(
String
postcode
)
{
return
addressRepository
.
findCommunitiesByPostcode
(
postcode
);
}
public
List
<
String
>
getDistricts
(
String
postcode
,
String
community
)
{
return
addressRepository
.
findDistrictsByPostcodeAndCommunity
(
postcode
,
community
);
}
public
List
<
String
>
getStreets
(
String
postcode
,
String
community
,
Optional
<
String
>
district
)
{
if
(
district
.
equals
(
Optional
.
empty
())){
return
addressRepository
.
findStreetsByPostcodeAndCommunity
(
postcode
,
community
);
}
else
{
return
addressRepository
.
findStreetsByPostcodeAndCommunityAndDistrict
(
postcode
,
community
,
district
.
get
());
}
}
public
List
<
String
>
getHousenumbers
(
String
postcode
,
String
community
,
String
street
)
{
return
addressRepository
.
findHousenumbersByPostcodeAndCommunityAndStreet
(
postcode
,
community
,
street
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment