Fix entityManager.merge for ds and sm (#2602)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -1982,10 +1982,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
.andExpect(jsonPath("$._links.start.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/start"))))
|
.andExpect(jsonPath("$._links.start.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/start"))))
|
||||||
.andExpect(jsonPath("$._links.pause.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/pause"))))
|
.andExpect(jsonPath("$._links.pause.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/pause"))))
|
||||||
.andExpect(jsonPath("$.dynamic", equalTo(isDynamic)))
|
.andExpect(jsonPath("$.dynamic", equalTo(isDynamic)))
|
||||||
.andExpect(
|
.andExpect(jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
||||||
jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
.andExpect(jsonPath(
|
||||||
.andExpect(jsonPath("$._links.groups.href",
|
"$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
||||||
allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||||
|
|||||||
@@ -728,7 +728,13 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
// implicitly lock, for some reason no update happen if lock in same transaction
|
// implicitly lock, for some reason no update happen if lock in same transaction
|
||||||
distributionSet = DeploymentHelper.runInNewTransaction(
|
distributionSet = DeploymentHelper.runInNewTransaction(
|
||||||
txManager, "lockDistributionSet-" + dsId,
|
txManager, "lockDistributionSet-" + dsId,
|
||||||
status -> distributionSetManagement.lock(dsValidAndComplete));
|
status -> {
|
||||||
|
if (entityManager.contains(dsValidAndComplete)) {
|
||||||
|
return distributionSetManagement.lock(dsValidAndComplete);
|
||||||
|
} else {
|
||||||
|
return distributionSetManagement.lock(entityManager.merge(dsValidAndComplete));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
distributionSet = dsValidAndComplete;
|
distributionSet = dsValidAndComplete;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ public class JpaDistributionSetManagement
|
|||||||
|
|
||||||
private JpaDistributionSet toJpaDistributionSet(final DistributionSet distributionSet) {
|
private JpaDistributionSet toJpaDistributionSet(final DistributionSet distributionSet) {
|
||||||
if (distributionSet instanceof JpaDistributionSet jpaDistributionSet) {
|
if (distributionSet instanceof JpaDistributionSet jpaDistributionSet) {
|
||||||
return entityManager.merge(jpaDistributionSet); // if from
|
return jpaDistributionSet;
|
||||||
} else {
|
} else {
|
||||||
return getById(distributionSet.getId());
|
return getById(distributionSet.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class JpaSoftwareModuleManagement
|
|||||||
|
|
||||||
private JpaSoftwareModule toJpaSoftwareModule(final SoftwareModule softwareModule) {
|
private JpaSoftwareModule toJpaSoftwareModule(final SoftwareModule softwareModule) {
|
||||||
if (softwareModule instanceof JpaSoftwareModule jpaSoftwareModule) {
|
if (softwareModule instanceof JpaSoftwareModule jpaSoftwareModule) {
|
||||||
return entityManager.merge(jpaSoftwareModule); // if from
|
return jpaSoftwareModule;
|
||||||
} else {
|
} else {
|
||||||
return getById(softwareModule.getId());
|
return getById(softwareModule.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user