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
641dd156
Commit
641dd156
authored
Feb 27, 2020
by
Ina Curdt
Browse files
SI-127 POST-Service erstellt
parent
e5e11ea0
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
gfsBackendService/grid-failure-info.log
View file @
641dd156
This diff is collapsed.
Click to expand it.
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/GridFailureInformationController.java
View file @
641dd156
...
...
@@ -23,11 +23,15 @@ import org.eclipse.openk.gridfailureinformation.viewmodel.GridFailureInformation
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.annotation.Secured
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.support.ServletUriComponentsBuilder
;
import
java.net.URI
;
import
java.util.List
;
import
java.util.UUID
;
@Log4j2
@RestController
...
...
@@ -47,6 +51,40 @@ public class GridFailureInformationController {
return
gridFailureInformationService
.
findFailureInformations
(
PageRequest
.
of
(
0
,
maxListSize
)).
getContent
();
}
@PostMapping
@ApiOperation
(
value
=
"Anlegen einer Störungsinformation"
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
201
,
message
=
"Störungsinformation erfolgreich angelegt"
),
@ApiResponse
(
code
=
500
,
message
=
"Konnte nicht durchgeführt werden"
)
})
public
ResponseEntity
<
GridFailureInformationDto
>
insertFailureInfo
(
@Validated
@RequestBody
GridFailureInformationDto
gfDto
)
{
GridFailureInformationDto
savedgfDto
=
gridFailureInformationService
.
insertGridFailure
(
gfDto
);
URI
location
=
ServletUriComponentsBuilder
.
fromCurrentRequestUri
()
.
path
(
"/{uuid}"
)
.
buildAndExpand
(
savedgfDto
.
getUuid
())
.
toUri
();
return
ResponseEntity
.
created
(
location
).
body
(
savedgfDto
);
}
// @PutMapping("/{contactUuid}")
// @Secured({"ROLE_KON-ADMIN", "ROLE_KON-WRITER"})
// @ApiOperation(value = "Ändern einer externen Person")
// @ApiResponses(value = {
// @ApiResponse(code = 200, message = "Firma wurde aktualisiert"),
// @ApiResponse(code = 400, message = "Ungültige Eingabe"),
// @ApiResponse(code = 404, message = "Nicht gefunden")})
// public ResponseEntity updateCompany(@PathVariable UUID contactUuid, @Validated @RequestBody CompanyDto companyDto) {
//
// if (!companyDto.getContactUuid().equals(contactUuid)) {
// throw new BadRequestException("invalid.uuid.path.object");
// }
//
// companyService.updateCompany(companyDto);
// return ResponseEntity.ok().build();
// }
...
...
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/mapper/GridFailureInformationMapper.java
View file @
641dd156
...
...
@@ -37,4 +37,21 @@ public interface GridFailureInformationMapper {
@Mapping
(
source
=
"refBranch.colorCode"
,
target
=
"branchColorCode"
)
})
GridFailureInformationDto
toGridFailureInformationDto
(
TblFailureInformation
tblFailureInformation
);
@Mappings
({
@Mapping
(
target
=
"refFailureClassification.uuid"
,
source
=
"failureClassificationId"
),
@Mapping
(
target
=
"refFailureClassification.classification"
,
source
=
"failureClassification"
),
@Mapping
(
target
=
"refFailureType.uuid"
,
source
=
"failureTypeId"
),
@Mapping
(
target
=
"refFailureType.type"
,
source
=
"failureType"
),
@Mapping
(
target
=
"refStatusIntern.uuid"
,
source
=
"statusInternId"
),
@Mapping
(
target
=
"refStatusIntern.status"
,
source
=
"statusIntern"
),
@Mapping
(
target
=
"refStatusExtern.uuid"
,
source
=
"statusExternId"
),
@Mapping
(
target
=
"refStatusExtern.status"
,
source
=
"statusExtern"
),
@Mapping
(
target
=
"refBranch.uuid"
,
source
=
"branchId"
),
@Mapping
(
target
=
"refBranch.name"
,
source
=
"branch"
),
@Mapping
(
target
=
"refBranch.colorCode"
,
source
=
"branchColorCode"
)
})
TblFailureInformation
toRefFailureInformation
(
GridFailureInformationDto
gridFailureInformationDto
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/BranchRepository.java
View file @
641dd156
...
...
@@ -20,9 +20,13 @@ 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
BranchRepository
extends
JpaRepository
<
RefBranch
,
Long
>
{
List
<
RefBranch
>
findAll
();
Optional
<
RefBranch
>
findByUuid
(
UUID
uuid
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureClassificationRepository.java
0 → 100644
View file @
641dd156
/*
*******************************************************************************
* 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.RefBranch
;
import
org.eclipse.openk.gridfailureinformation.model.RefFailureClassification
;
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
FailureClassificationRepository
extends
JpaRepository
<
RefFailureClassification
,
Long
>
{
List
<
RefFailureClassification
>
findAll
();
Optional
<
RefFailureClassification
>
findByUuid
(
UUID
uuid
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureTypeRepository.java
0 → 100644
View file @
641dd156
/*
*******************************************************************************
* 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.RefBranch
;
import
org.eclipse.openk.gridfailureinformation.model.RefFailureType
;
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
FailureTypeRepository
extends
JpaRepository
<
RefFailureType
,
Long
>
{
List
<
RefFailureType
>
findAll
();
Optional
<
RefFailureType
>
findByUuid
(
UUID
uuid
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/StatusRepository.java
0 → 100644
View file @
641dd156
/*
*******************************************************************************
* 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.RefBranch
;
import
org.eclipse.openk.gridfailureinformation.model.RefStatus
;
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
StatusRepository
extends
JpaRepository
<
RefStatus
,
Long
>
{
List
<
RefStatus
>
findAll
();
Optional
<
RefStatus
>
findByUuid
(
UUID
uuid
);
}
gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/GridFailureInformationService.java
View file @
641dd156
...
...
@@ -15,13 +15,18 @@
package
org.eclipse.openk.gridfailureinformation.service
;
import
org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException
;
import
org.eclipse.openk.gridfailureinformation.mapper.GridFailureInformationMapper
;
import
org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository
;
import
org.eclipse.openk.gridfailureinformation.model.TblFailureInformation
;
import
org.eclipse.openk.gridfailureinformation.repository.*
;
import
org.eclipse.openk.gridfailureinformation.viewmodel.GridFailureInformationDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.UUID
;
@Service
...
...
@@ -30,6 +35,18 @@ public class GridFailureInformationService {
@Autowired
private
FailureInformationRepository
failureInformationRepository
;
@Autowired
private
BranchRepository
branchRepository
;
@Autowired
private
FailureClassificationRepository
failureClassificationRepository
;
@Autowired
private
FailureTypeRepository
failureTypeRepository
;
@Autowired
private
StatusRepository
statusRepository
;
@Autowired
private
GridFailureInformationMapper
gridFailureInformationMapper
;
...
...
@@ -37,4 +54,61 @@ public class GridFailureInformationService {
public
Page
<
GridFailureInformationDto
>
findFailureInformations
(
Pageable
pageable
)
{
return
failureInformationRepository
.
findAll
(
pageable
).
map
(
gridFailureInformationMapper:
:
toGridFailureInformationDto
);
}
public
GridFailureInformationDto
insertGridFailure
(
GridFailureInformationDto
gfiDto
){
TblFailureInformation
tblGfiToSave
=
gridFailureInformationMapper
.
toRefFailureInformation
(
gfiDto
);
tblGfiToSave
.
setUuid
(
UUID
.
randomUUID
());
setFromGridFailureInformationDto
(
tblGfiToSave
,
gfiDto
);
return
gridFailureInformationMapper
.
toGridFailureInformationDto
(
failureInformationRepository
.
save
(
tblGfiToSave
));
}
private
void
setFromGridFailureInformationDto
(
TblFailureInformation
destTblFailureInformation
,
GridFailureInformationDto
sourceDto
)
{
if
(
sourceDto
.
getBranchId
()
!=
null
)
{
destTblFailureInformation
.
setRefBranch
(
branchRepository
.
findByUuid
(
sourceDto
.
getBranchId
())
.
orElseThrow
(()
->
new
NotFoundException
(
"branch.uuid.not.existing"
)));
}
else
{
destTblFailureInformation
.
setRefBranch
(
null
);
}
if
(
sourceDto
.
getFailureClassificationId
()
!=
null
)
{
destTblFailureInformation
.
setRefFailureClassification
(
failureClassificationRepository
.
findByUuid
(
sourceDto
.
getFailureClassificationId
())
.
orElseThrow
(()
->
new
NotFoundException
(
"failure.classification.uuid.not.existing"
)));
}
else
{
destTblFailureInformation
.
setRefFailureClassification
(
null
);
}
if
(
sourceDto
.
getFailureTypeId
()
!=
null
)
{
destTblFailureInformation
.
setRefFailureType
(
failureTypeRepository
.
findByUuid
(
sourceDto
.
getFailureClassificationId
())
.
orElseThrow
(()
->
new
NotFoundException
(
"failure.type.uuid.not.existing"
)));
}
else
{
destTblFailureInformation
.
setRefFailureType
(
null
);
}
if
(
sourceDto
.
getStatusInternId
()
!=
null
)
{
destTblFailureInformation
.
setRefStatusIntern
(
statusRepository
.
findByUuid
(
sourceDto
.
getStatusInternId
())
.
orElseThrow
(()
->
new
NotFoundException
(
"status.uuid.not.existing"
)));
}
else
{
destTblFailureInformation
.
setRefStatusIntern
(
null
);
}
if
(
sourceDto
.
getStatusExternId
()
!=
null
)
{
destTblFailureInformation
.
setRefStatusExtern
(
statusRepository
.
findByUuid
(
sourceDto
.
getStatusExternId
())
.
orElseThrow
(()
->
new
NotFoundException
(
"status.uuid.not.existing"
)));
}
else
{
destTblFailureInformation
.
setRefStatusExtern
(
null
);
}
}
}
gfsBackendService/src/main/resources/messages.properties
0 → 100644
View file @
641dd156
#Fehlermeldungen
invalid.uuid.path.object
=
Die UUID entspricht nicht der UUID des
\u
00fcbergebenen Datensatzes.
branch.uuid.not.existing
=
Die
\u
00fcbergebene UUID einer Branche existiert nicht.
failure.classification.uuid.not.existing
=
Die
\u
00fcbergebene UUID einer Fehlerklassifizierung existiert nicht.
failure.type.uuid.not.existing
=
Die
\u
00fcbergebene UUID eines Fehlertyps existiert nicht.
status.uuid.not.existing
=
Die
\u
00fcbergebene UUID eines Status existiert nicht.
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