Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Solidify-Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Solidify
Solidify-Backend
Commits
8c65289b
Commit
8c65289b
authored
2 years ago
by
Mathieu.Vonlanthen
Browse files
Options
Downloads
Patches
Plain Diff
refactor(Relation3TiersController): use existsByIdOrThrowException in update method
parent
eaf2caa9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!362
refactor(Relation3TiersController): use existsByIdOrThrowException in update method
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
solidify-controller/src/main/java/ch/unige/solidify/controller/Relation3TiersController.java
+12
-10
12 additions, 10 deletions
...h/unige/solidify/controller/Relation3TiersController.java
with
12 additions
and
10 deletions
solidify-controller/src/main/java/ch/unige/solidify/controller/Relation3TiersController.java
+
12
−
10
View file @
8c65289b
...
@@ -378,17 +378,19 @@ public abstract class Relation3TiersController<T extends Resource, V extends Res
...
@@ -378,17 +378,19 @@ public abstract class Relation3TiersController<T extends Resource, V extends Res
*/
*/
@PatchMapping
(
SolidifyConstants
.
URL_ID
)
@PatchMapping
(
SolidifyConstants
.
URL_ID
)
public
HttpEntity
<
List
<
J
>>
update
(
@PathVariable
String
parentid
,
@PathVariable
String
id
,
@RequestBody
J
joinResource
)
{
public
HttpEntity
<
List
<
J
>>
update
(
@PathVariable
String
parentid
,
@PathVariable
String
id
,
@RequestBody
J
joinResource
)
{
V
childItem
=
this
.
childItemService
.
findOne
(
id
);
// Check if parents exist
List
<
J
>
joinResources
=
this
.
relationItemService
.
findAllRelations
(
parentid
,
childItem
.
getResId
());
this
.
itemService
.
existsByIdOrThrowException
(
parentid
);
final
List
<
J
>
list
=
new
ArrayList
<>();
this
.
childItemService
.
existsByIdOrThrowException
(
id
);
for
(
final
J
existingJoinResource
:
joinResources
)
{
J
updatedJoinResource
=
this
.
relationItemService
.
completeJoinResourceRelations
(
joinResource
,
parentid
,
id
,
final
List
<
J
>
savedRelationsList
=
new
ArrayList
<>();
this
.
relationItemService
.
getGrandChildResource
(
existingJoinResource
).
getResId
());
for
(
final
J
existingJoinResource
:
this
.
relationItemService
.
findAllRelations
(
parentid
,
id
))
{
final
J
savedJoinResource
=
this
.
relationItemService
.
saveRelation
(
updatedJoinResource
);
final
String
grandChildId
=
this
.
relationItemService
.
getGrandChildResource
(
existingJoinResource
).
getResId
();
list
.
add
(
savedJoinResource
);
final
J
updatedJoinResource
=
this
.
relationItemService
.
completeJoinResourceRelations
(
joinResource
,
parentid
,
id
,
grandChildId
);
final
J
savedRelation
=
this
.
relationItemService
.
saveRelation
(
updatedJoinResource
);
savedRelationsList
.
add
(
savedRelation
);
}
}
if
(!
l
ist
.
isEmpty
())
{
if
(!
savedRelationsL
ist
.
isEmpty
())
{
return
new
ResponseEntity
<>(
l
ist
,
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
savedRelationsL
ist
,
HttpStatus
.
CREATED
);
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment