Upgrades spring to 3.4.0 (#2154)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -41,28 +41,21 @@ public class JpaEntityFactory implements EntityFactory {
|
||||
|
||||
@Autowired
|
||||
private DistributionSetBuilder distributionSetBuilder;
|
||||
|
||||
@Autowired
|
||||
private TargetBuilder targetBuilder;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTypeBuilder distributionSetTypeBuilder;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleBuilder softwareModuleBuilder;
|
||||
|
||||
@Autowired
|
||||
private RolloutBuilder rolloutBuilder;
|
||||
|
||||
@Autowired
|
||||
private TargetFilterQueryBuilder targetFilterQueryBuilder;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleMetadataBuilder softwareModuleMetadataBuilder;
|
||||
|
||||
@Autowired
|
||||
private TargetTypeBuilder targetTypeBuilder;
|
||||
|
||||
|
||||
@Override
|
||||
public ActionStatusBuilder actionStatus() {
|
||||
return new JpaActionStatusBuilder();
|
||||
@@ -132,5 +125,4 @@ public class JpaEntityFactory implements EntityFactory {
|
||||
public TargetFilterQueryBuilder targetFilterQuery() {
|
||||
return targetFilterQueryBuilder;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
artifact.setMd5Hash(result.getHashes().getMd5());
|
||||
artifact.setSha256Hash(result.getHashes().getSha256());
|
||||
artifact.setSize(result.getSize());
|
||||
artifact.setFileSize(result.getSize());
|
||||
|
||||
log.debug("storing new artifact into repository {}", artifact);
|
||||
return localArtifactRepository.save(AccessController.Operation.CREATE, artifact);
|
||||
|
||||
@@ -132,8 +132,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
targetRepository.byIdsSpec(targetIdsChunk)) != targetIdsChunk.size()) {
|
||||
throw new InsufficientPermissionException("No update access to all targets!");
|
||||
}
|
||||
targetRepository.setAssignedDistributionSetAndUpdateStatus(TargetUpdateStatus.PENDING,
|
||||
set, now, currentUser, targetIdsChunk);
|
||||
targetRepository.setAssignedDistributionSetAndUpdateStatus(set, now, currentUser, TargetUpdateStatus.PENDING, targetIdsChunk);
|
||||
// TODO AC - current problem with this approach is that the caller detach the targets and seems doesn't save them
|
||||
// targetRepository.saveAll(
|
||||
// targetRepository
|
||||
|
||||
@@ -67,9 +67,11 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
||||
@NamedEntityGraph(name = "Action.all", attributeNodes = {
|
||||
@NamedAttributeNode("distributionSet"),
|
||||
@NamedAttributeNode(value = "target", subgraph = "target.ds") },
|
||||
subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet")))
|
||||
@NamedAttributeNode(value = "target", subgraph = "target.ds"),
|
||||
@NamedAttributeNode("distributionSet") },
|
||||
subgraphs = @NamedSubgraph(
|
||||
name = "target.ds",
|
||||
attributeNodes = @NamedAttributeNode("assignedDistributionSet")))
|
||||
})
|
||||
@Entity
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
|
||||
@@ -75,7 +75,7 @@ public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Art
|
||||
private String sha256Hash;
|
||||
|
||||
@Column(name = "file_size", updatable = false)
|
||||
private long size;
|
||||
private long fileSize;
|
||||
|
||||
/**
|
||||
* Constructs artifact.
|
||||
@@ -90,4 +90,9 @@ public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Art
|
||||
this.softwareModule = (JpaSoftwareModule) softwareModule;
|
||||
this.softwareModule.addArtifact(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return getFileSize();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@@ -33,7 +33,8 @@ import org.springframework.util.StringUtils;
|
||||
@Table(name = "sp_target_conf_status")
|
||||
public class JpaAutoConfirmationStatus extends AbstractJpaTenantAwareBaseEntity implements AutoConfirmationStatus {
|
||||
|
||||
@OneToOne(optional = false, fetch = FetchType.LAZY)
|
||||
// actually it is OneToOne - but lazy loading is not supported for OneToOne (at least for hibernate 6.6.2)
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "target_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_auto_conf"))
|
||||
private JpaTarget target;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapKeyColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
@@ -65,6 +64,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link Target}.
|
||||
@@ -140,11 +140,10 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
// set default request controller attributes to true, because we want to request them the first time
|
||||
private boolean requestControllerAttributes = true;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@OneToOne(fetch = FetchType.LAZY, mappedBy = "target", cascade = { CascadeType.ALL }, orphanRemoval = true)
|
||||
// actually it is OneToOne - but lazy loading is not supported for OneToOne (at least for hibernate 6.6.2)
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "target", cascade = { CascadeType.ALL }, orphanRemoval = true)
|
||||
@PrimaryKeyJoinColumn
|
||||
private JpaAutoConfirmationStatus autoConfirmationStatus;
|
||||
private List<JpaAutoConfirmationStatus> autoConfirmationStatus;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@@ -242,6 +241,19 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
.apply(this);
|
||||
}
|
||||
|
||||
public JpaAutoConfirmationStatus getAutoConfirmationStatus() {
|
||||
return ObjectUtils.isEmpty(autoConfirmationStatus) ? null : autoConfirmationStatus.get(0);
|
||||
}
|
||||
|
||||
public void setAutoConfirmationStatus(final JpaAutoConfirmationStatus autoConfirmationStatus) {
|
||||
if (this.autoConfirmationStatus == null) {
|
||||
this.autoConfirmationStatus = new ArrayList<>();
|
||||
} else {
|
||||
this.autoConfirmationStatus.clear();
|
||||
}
|
||||
this.autoConfirmationStatus.add(autoConfirmationStatus);
|
||||
}
|
||||
|
||||
public void addTag(final TargetTag tag) {
|
||||
if (tags == null) {
|
||||
tags = new HashSet<>();
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
|
||||
* @return the found {@link Action}
|
||||
*/
|
||||
@EntityGraph(value = "Action.all", type = EntityGraphType.LOAD)
|
||||
Optional<Action> findWithDetailsById(Long actionId);
|
||||
Optional<Action> findWithDetailsById(@Param("id") Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves the latest finished {@link Action} for given target and {@link DistributionSet}.
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface LocalArtifactRepository extends BaseEntityRepository<JpaArtifac
|
||||
*
|
||||
* @return sum of artifacts size in bytes
|
||||
*/
|
||||
@Query("SELECT SUM(la.size) FROM JpaArtifact la WHERE la.softwareModule.deleted = false")
|
||||
@Query("SELECT SUM(a.fileSize) FROM JpaArtifact a WHERE a.softwareModule.deleted = false")
|
||||
Optional<Long> sumOfNonDeletedArtifactSize();
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,10 +50,10 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget> {
|
||||
@Deprecated(forRemoval = true)
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("UPDATE JpaTarget t SET t.assignedDistributionSet = :set, t.lastModifiedAt = :lastModifiedAt, t.lastModifiedBy = :lastModifiedBy, t.updateStatus = :status WHERE t.id IN :targets")
|
||||
void setAssignedDistributionSetAndUpdateStatus(@Param("status") TargetUpdateStatus status,
|
||||
@Param("set") JpaDistributionSet set, @Param("lastModifiedAt") Long modifiedAt,
|
||||
@Param("lastModifiedBy") String modifiedBy, @Param("targets") Collection<Long> targets);
|
||||
@Query("UPDATE JpaTarget t SET t.assignedDistributionSet = :dSet, t.lastModifiedAt = :lastModifiedAt, t.lastModifiedBy = :lastModifiedBy, t.updateStatus = :status WHERE t.id IN :targets")
|
||||
void setAssignedDistributionSetAndUpdateStatus(
|
||||
@Param("dSet") JpaDistributionSet set, @Param("lastModifiedAt") Long modifiedAt, @Param("lastModifiedBy") String modifiedBy, @Param("status") TargetUpdateStatus status,
|
||||
@Param("targets") Collection<Long> targets);
|
||||
|
||||
// TODO AC - remove it and use specification
|
||||
|
||||
@@ -64,9 +64,10 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget> {
|
||||
@Deprecated(forRemoval = true)
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("UPDATE JpaTarget t SET t.assignedDistributionSet = :set, t.installedDistributionSet = :set, t.installationDate = :lastModifiedAt, t.lastModifiedAt = :lastModifiedAt, t.lastModifiedBy = :lastModifiedBy, t.updateStatus = :status WHERE t.id IN :targets")
|
||||
void setAssignedAndInstalledDistributionSetAndUpdateStatus(@Param("status") TargetUpdateStatus status,
|
||||
@Param("set") JpaDistributionSet set, @Param("lastModifiedAt") Long modifiedAt,
|
||||
@Query("UPDATE JpaTarget t SET t.assignedDistributionSet = :dSet, t.installedDistributionSet = :dSet, t.installationDate = :lastModifiedAt, t.lastModifiedAt = :lastModifiedAt, t.lastModifiedBy = :lastModifiedBy, t.updateStatus = :status WHERE t.id IN :targets")
|
||||
void setAssignedAndInstalledDistributionSetAndUpdateStatus(
|
||||
@Param("status") TargetUpdateStatus status,
|
||||
@Param("dSet") JpaDistributionSet distributionSet, @Param("lastModifiedAt") Long modifiedAt,
|
||||
@Param("lastModifiedBy") String modifiedBy, @Param("targets") Collection<Long> targets);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user