JPA Refactoring (4) (#2110)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -61,8 +61,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a paged result list of DS tags reflects the content on the repository side.")
|
@Description("Verfies that a paged result list of DS tags reflects the content on the repository side.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void getDistributionSetTags() throws Exception {
|
public void getDistributionSetTags() throws Exception {
|
||||||
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
|
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
|
||||||
final DistributionSetTag assigned = tags.get(0);
|
final DistributionSetTag assigned = tags.get(0);
|
||||||
@@ -162,8 +161,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a single result of a DS tag reflects the content on the repository side.")
|
@Description("Verfies that a single result of a DS tag reflects the content on the repository side.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void getDistributionSetTag() throws Exception {
|
public void getDistributionSetTag() throws Exception {
|
||||||
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
|
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
|
||||||
final DistributionSetTag assigned = tags.get(0);
|
final DistributionSetTag assigned = tags.get(0);
|
||||||
@@ -181,8 +179,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that created DS tags are stored in the repository as send to the API.")
|
@Description("Verifies that created DS tags are stored in the repository as send to the API.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void createDistributionSetTags() throws Exception {
|
public void createDistributionSetTags() throws Exception {
|
||||||
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
|
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a paged result list of target tags reflects the content on the repository side.")
|
@Description("Verfies that a paged result list of target tags reflects the content on the repository side.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void getTargetTags() throws Exception {
|
public void getTargetTags() throws Exception {
|
||||||
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
|
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
|
||||||
final TargetTag assigned = tags.get(0);
|
final TargetTag assigned = tags.get(0);
|
||||||
@@ -132,8 +131,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a single result of a target tag reflects the content on the repository side.")
|
@Description("Verfies that a single result of a target tag reflects the content on the repository side.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void getTargetTag() throws Exception {
|
public void getTargetTag() throws Exception {
|
||||||
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
|
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
|
||||||
final TargetTag assigned = tags.get(0);
|
final TargetTag assigned = tags.get(0);
|
||||||
@@ -152,8 +150,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that created target tags are stored in the repository as send to the API.")
|
@Description("Verifies that created target tags are stored in the repository as send to the API.")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
||||||
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
|
|
||||||
public void createTargetTags() throws Exception {
|
public void createTargetTags() throws Exception {
|
||||||
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
|
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -278,8 +278,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
final Collection<JpaSoftwareModuleType> foundModules =
|
final Collection<JpaSoftwareModuleType> foundModules =
|
||||||
softwareModuleTypeRepository.findAllById(softwareModulesTypeIds);
|
softwareModuleTypeRepository.findAllById(softwareModulesTypeIds);
|
||||||
if (foundModules.size() < softwareModulesTypeIds.size()) {
|
if (foundModules.size() < softwareModulesTypeIds.size()) {
|
||||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
throw new EntityNotFoundException(
|
||||||
foundModules.stream().map(SoftwareModuleType::getId).toList());
|
SoftwareModuleType.class, softwareModulesTypeIds, foundModules.stream().map(SoftwareModuleType::getId).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(dsTypeId);
|
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(dsTypeId);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
|||||||
import org.eclipse.persistence.annotations.Multitenant;
|
import org.eclipse.persistence.annotations.Multitenant;
|
||||||
import org.eclipse.persistence.annotations.MultitenantType;
|
import org.eclipse.persistence.annotations.MultitenantType;
|
||||||
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
|
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
|
||||||
|
import org.hibernate.annotations.TenantId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder of the base attributes common to all tenant aware entities.
|
* Holder of the base attributes common to all tenant aware entities.
|
||||||
@@ -43,9 +44,11 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
|
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40) // eclipselink
|
||||||
|
// @Column(name = "tenant", nullable = false, updatable = false, length = 40) // hibernate
|
||||||
@Size(min = 1, max = 40)
|
@Size(min = 1, max = 40)
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@TenantId // Hibernate MultiTenant support
|
||||||
private String tenant;
|
private String tenant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ import java.io.Serializable;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composite key for {@link DistributionSetTypeElement}.
|
* Composite key for {@link DistributionSetTypeElement}.
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
@Data
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class DistributionSetTypeElementCompositeKey implements Serializable {
|
public class DistributionSetTypeElementCompositeKey implements Serializable {
|
||||||
|
|
||||||
@@ -30,75 +36,8 @@ public class DistributionSetTypeElementCompositeKey implements Serializable {
|
|||||||
@Column(name = "software_module_type", nullable = false, updatable = false)
|
@Column(name = "software_module_type", nullable = false, updatable = false)
|
||||||
private Long smType;
|
private Long smType;
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
DistributionSetTypeElementCompositeKey() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param dsType in the key
|
|
||||||
* @param smType in the key
|
|
||||||
*/
|
|
||||||
DistributionSetTypeElementCompositeKey(final JpaDistributionSetType dsType, final JpaSoftwareModuleType smType) {
|
DistributionSetTypeElementCompositeKey(final JpaDistributionSetType dsType, final JpaSoftwareModuleType smType) {
|
||||||
this.dsType = dsType.getId();
|
this.dsType = dsType.getId();
|
||||||
this.smType = smType.getId();
|
this.smType = smType.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDsType() {
|
|
||||||
return dsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDsType(final Long dsType) {
|
|
||||||
this.dsType = dsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSmType() {
|
|
||||||
return smType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSmType(final Long smType) {
|
|
||||||
this.smType = smType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((dsType == null) ? 0 : dsType.hashCode());
|
|
||||||
result = prime * result + ((smType == null) ? 0 : smType.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final DistributionSetTypeElementCompositeKey other = (DistributionSetTypeElementCompositeKey) obj;
|
|
||||||
if (dsType == null) {
|
|
||||||
if (other.dsType != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!dsType.equals(other.dsType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (smType == null) {
|
|
||||||
if (other.smType != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!smType.equals(other.smType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,6 @@ import jakarta.validation.constraints.Size;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import org.eclipse.hawkbit.repository.model.AutoConfirmationStatus;
|
import org.eclipse.hawkbit.repository.model.AutoConfirmationStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
|||||||
@@ -79,22 +79,26 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = JpaDistributionSetType.class)
|
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = JpaDistributionSetType.class)
|
||||||
@JoinColumn(name = "ds_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
@JoinColumn(
|
||||||
|
name = "ds_id", nullable = false, updatable = false,
|
||||||
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
||||||
@NotNull
|
@NotNull
|
||||||
private DistributionSetType type;
|
private DistributionSetType type;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
@ManyToMany(
|
||||||
|
targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY,
|
||||||
|
cascade = { CascadeType.PERSIST, CascadeType.MERGE })
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "sp_ds_module",
|
name = "sp_ds_module",
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(
|
@JoinColumn(
|
||||||
name = "ds_id", nullable = false, insertable = false, updatable = false, foreignKey =
|
name = "ds_id", nullable = false, insertable = false, updatable = false,
|
||||||
@ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) },
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) },
|
||||||
inverseJoinColumns = {
|
inverseJoinColumns = {
|
||||||
@JoinColumn(
|
@JoinColumn(
|
||||||
name = "module_id", nullable = false, insertable = false, updatable = false,
|
name = "module_id", nullable = false, insertable = false, updatable = false,
|
||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||||
private Set<SoftwareModule> modules;
|
private Set<SoftwareModule> modules = new HashSet<>();
|
||||||
|
|
||||||
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
|
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
@@ -107,11 +111,12 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
@JoinColumn(
|
@JoinColumn(
|
||||||
name = "TAG", nullable = false, insertable = false, updatable = false,
|
name = "TAG", nullable = false, insertable = false, updatable = false,
|
||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||||
private Set<DistributionSetTag> tags;
|
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||||
|
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY, cascade = {
|
@OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY,
|
||||||
CascadeType.REMOVE }, targetEntity = JpaDistributionSetMetadata.class)
|
cascade = { CascadeType.REMOVE },
|
||||||
|
targetEntity = JpaDistributionSetMetadata.class)
|
||||||
private List<DistributionSetMetadata> metadata;
|
private List<DistributionSetMetadata> metadata;
|
||||||
|
|
||||||
@Column(name = "complete")
|
@Column(name = "complete")
|
||||||
@@ -131,10 +136,8 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
@Column(name = "required_migration_step")
|
@Column(name = "required_migration_step")
|
||||||
private boolean requiredMigrationStep;
|
private boolean requiredMigrationStep;
|
||||||
|
|
||||||
/**
|
public JpaDistributionSet(
|
||||||
* Parameterized constructor.
|
final String name, final String version, final String description,
|
||||||
*/
|
|
||||||
public JpaDistributionSet(final String name, final String version, final String description,
|
|
||||||
final DistributionSetType type, final Collection<SoftwareModule> moduleList,
|
final DistributionSetType type, final Collection<SoftwareModule> moduleList,
|
||||||
final boolean requiredMigrationStep) {
|
final boolean requiredMigrationStep) {
|
||||||
super(name, version, description);
|
super(name, version, description);
|
||||||
@@ -152,9 +155,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
this.requiredMigrationStep = requiredMigrationStep;
|
this.requiredMigrationStep = requiredMigrationStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameterized constructor.
|
|
||||||
*/
|
|
||||||
public JpaDistributionSet(final String name, final String version, final String description,
|
public JpaDistributionSet(final String name, final String version, final String description,
|
||||||
final DistributionSetType type, final Collection<SoftwareModule> moduleList) {
|
final DistributionSetType type, final Collection<SoftwareModule> moduleList) {
|
||||||
this(name, version, description, type, moduleList, false);
|
this(name, version, description, type, moduleList, false);
|
||||||
@@ -162,10 +162,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SoftwareModule> getModules() {
|
public Set<SoftwareModule> getModules() {
|
||||||
if (modules == null) {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableSet(modules);
|
return Collections.unmodifiableSet(modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,10 +170,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
throw new LockedException(JpaDistributionSet.class, getId(), "ADD_SOFTWARE_MODULE");
|
throw new LockedException(JpaDistributionSet.class, getId(), "ADD_SOFTWARE_MODULE");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modules == null) {
|
|
||||||
modules = new HashSet<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkTypeCompatability(softwareModule);
|
checkTypeCompatability(softwareModule);
|
||||||
|
|
||||||
final Optional<SoftwareModule> found = modules.stream()
|
final Optional<SoftwareModule> found = modules.stream()
|
||||||
@@ -187,8 +179,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long already = modules.stream()
|
final long already = modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count();
|
||||||
.filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count();
|
|
||||||
|
|
||||||
if (already >= softwareModule.getType().getMaxAssignments()) {
|
if (already >= softwareModule.getType().getMaxAssignments()) {
|
||||||
modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey()))
|
modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey()))
|
||||||
@@ -211,10 +202,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<DistributionSetTag> getTags() {
|
public Set<DistributionSetTag> getTags() {
|
||||||
if (tags == null) {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableSet(tags);
|
return Collections.unmodifiableSet(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import jakarta.persistence.Table;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class, fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST,
|
@OneToMany(mappedBy = "dsType",
|
||||||
CascadeType.REMOVE }, orphanRemoval = true)
|
targetEntity = DistributionSetTypeElement.class,
|
||||||
|
fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE },
|
||||||
|
orphanRemoval = true)
|
||||||
private Set<DistributionSetTypeElement> elements = new HashSet<>();
|
private Set<DistributionSetTypeElement> elements = new HashSet<>();
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
|
|||||||
@@ -67,5 +67,4 @@ public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements So
|
|||||||
public SwMetadataCompositeKey getId() {
|
public SwMetadataCompositeKey getId() {
|
||||||
return new SwMetadataCompositeKey(softwareModule.getId(), getKey());
|
return new SwMetadataCompositeKey(softwareModule.getId(), getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
|
|||||||
* @param ids to search for
|
* @param ids to search for
|
||||||
* @return list of {@link DistributionSet#getId()}
|
* @return list of {@link DistributionSet#getId()}
|
||||||
*/
|
*/
|
||||||
@Query("select ac.distributionSet.id from JpaAction ac where ac.distributionSet.id in :ids")
|
@Query("SELECT ac.distributionSet.id FROM JpaAction ac WHERE ac.distributionSet.id IN :ids")
|
||||||
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Collection<Long> ids);
|
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +97,7 @@ public interface DistributionSetRepository extends BaseEntityRepository<JpaDistr
|
|||||||
* @param ids to search for
|
* @param ids to search for
|
||||||
* @return list of {@link DistributionSet#getId()}
|
* @return list of {@link DistributionSet#getId()}
|
||||||
*/
|
*/
|
||||||
@Query("select ra.distributionSet.id from JpaRollout ra where ra.distributionSet.id in :ids")
|
@Query("SELECT ra.distributionSet.id FROM JpaRollout ra WHERE ra.distributionSet.id IN :ids")
|
||||||
List<Long> findAssignedToRolloutDistributionSetsById(@Param("ids") Collection<Long> ids);
|
List<Long> findAssignedToRolloutDistributionSetsById(@Param("ids") Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,31 +23,24 @@ import org.springframework.data.repository.query.Param;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link PagingAndSortingRepository} and {@link org.springframework.data.repository.CrudRepository} for
|
* {@link PagingAndSortingRepository} and {@link org.springframework.data.repository.CrudRepository} for {@link DistributionSetType}.
|
||||||
* {@link DistributionSetType}.
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface DistributionSetTypeRepository
|
public interface DistributionSetTypeRepository extends BaseEntityRepository<JpaDistributionSetType> {
|
||||||
extends BaseEntityRepository<JpaDistributionSetType> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all distribution set type where a specific software module type is
|
* Counts all distribution set type where a specific software module type is assigned to.
|
||||||
* assigned to.
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* No access control applied
|
* No access control applied
|
||||||
*
|
*
|
||||||
* @param softwareModuleType the software module type to count the distribution set type
|
* @param softwareModuleType the software module type to count the distribution set type which has this software module type assigned
|
||||||
* which has this software module type assigned
|
* @return the number of {@link DistributionSetType}s in the repository assigned to the given software module type
|
||||||
* @return the number of {@link DistributionSetType}s in the repository
|
|
||||||
* assigned to the given software module type
|
|
||||||
*/
|
*/
|
||||||
long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety reasons (this is a "delete everything" query after all) we add
|
||||||
* reasons (this is a "delete everything" query after all) we add the tenant
|
* the tenant manually to query even if this will by done by {@link EntityManager} anyhow. The DB should take care of optimizing this away.
|
||||||
* manually to query even if this will by done by {@link EntityManager}
|
|
||||||
* anyhow. The DB should take care of optimizing this away.
|
|
||||||
*
|
*
|
||||||
* @param tenant to delete data from
|
* @param tenant to delete data from
|
||||||
*/
|
*/
|
||||||
@@ -57,8 +50,7 @@ public interface DistributionSetTypeRepository
|
|||||||
void deleteByTenant(@Param("tenant") String tenant);
|
void deleteByTenant(@Param("tenant") String tenant);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the {@link SoftwareModuleType}s which are associated with the
|
* Counts the {@link SoftwareModuleType}s which are associated with the addressed {@link DistributionSetType}.
|
||||||
* addressed {@link DistributionSetType}.
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* No access control applied
|
* No access control applied
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1584,8 +1584,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Delete a target with a non existing thingId")
|
@Description("Delete a target with a non existing thingId")
|
||||||
@ExpectEvents({
|
@ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) })
|
||||||
@Expect(type = TargetDeletedEvent.class, count = 0) })
|
|
||||||
void deleteTargetWithInvalidThingId() {
|
void deleteTargetWithInvalidThingId() {
|
||||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||||
.as("No EntityNotFoundException thrown when deleting a non-existing target")
|
.as("No EntityNotFoundException thrown when deleting a non-existing target")
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
@Test
|
@Test
|
||||||
@Description("Verifies that the quota for software module types per distribution set type is enforced as expected.")
|
@Description("Verifies that the quota for software module types per distribution set type is enforced as expected.")
|
||||||
public void quotaMaxSoftwareModuleTypes() {
|
public void quotaMaxSoftwareModuleTypes() {
|
||||||
|
|
||||||
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
|
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
|
||||||
// create software module types
|
// create software module types
|
||||||
final List<Long> moduleTypeIds = new ArrayList<>();
|
final List<Long> moduleTypeIds = new ArrayList<>();
|
||||||
@@ -168,8 +167,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
// assign as many optional modules as possible
|
// assign as many optional modules as possible
|
||||||
final DistributionSetType dsType3 = distributionSetTypeManagement
|
final DistributionSetType dsType3 = distributionSetTypeManagement
|
||||||
.create(entityFactory.distributionSetType().create().key("dst3").name("dst3"));
|
.create(entityFactory.distributionSetType().create().key("dst3").name("dst3"));
|
||||||
distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(),
|
distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(), moduleTypeIds.subList(0, quota));
|
||||||
moduleTypeIds.subList(0, quota));
|
|
||||||
assertThat(distributionSetTypeManagement.get(dsType3.getId())).isNotEmpty();
|
assertThat(distributionSetTypeManagement.get(dsType3.getId())).isNotEmpty();
|
||||||
assertThat(distributionSetTypeManagement.get(dsType3.getId()).get().getOptionalModuleTypes().size())
|
assertThat(distributionSetTypeManagement.get(dsType3.getId()).get().getOptionalModuleTypes().size())
|
||||||
.isEqualTo(quota);
|
.isEqualTo(quota);
|
||||||
|
|||||||
@@ -491,7 +491,6 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Checks that metadata for a software module can be created.")
|
@Description("Checks that metadata for a software module can be created.")
|
||||||
public void createSoftwareModuleMetadata() {
|
public void createSoftwareModuleMetadata() {
|
||||||
|
|
||||||
final String knownKey1 = "myKnownKey1";
|
final String knownKey1 = "myKnownKey1";
|
||||||
final String knownValue1 = "myKnownValue1";
|
final String knownValue1 = "myKnownValue1";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user