Skip to content

Commit

Permalink
EPMRPP-88461 Switch to LocalDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Feb 5, 2024
1 parent d266d18 commit 2d13d98
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.epam.ta.reportportal.dao;

import com.epam.ta.reportportal.entity.user.UserCreationBid;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.Optional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -35,7 +35,7 @@ Optional<UserCreationBid> findByUuidAndType(@Param("uuid") String uuid,

@Modifying
@Query(value = "DELETE FROM UserCreationBid u WHERE u.lastModified < :date")
int expireBidsOlderThan(@Param("date") Date date);
int expireBidsOlderThan(@Param("date") LocalDateTime date);

Optional<UserCreationBid> findFirstByEmailOrderByLastModifiedDesc(String email);
}
6 changes: 3 additions & 3 deletions src/main/java/com/epam/ta/reportportal/entity/Modifiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.epam.ta.reportportal.entity;

import java.util.Date;
import java.time.LocalDateTime;

/**
* Item may be modified
Expand All @@ -34,5 +34,5 @@ public interface Modifiable {
*
* @return
*/
Date getLastModified();
}
LocalDateTime getLastModified();
}
112 changes: 6 additions & 106 deletions src/main/java/com/epam/ta/reportportal/entity/project/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.epam.ta.reportportal.entity.user.ProjectUser;
import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Set;
import javax.persistence.CascadeType;
Expand All @@ -38,6 +38,8 @@
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

Expand All @@ -47,6 +49,8 @@
@Entity
@TypeDef(name = "json", typeClass = Metadata.class)
@Table(name = "project", schema = "public")
@Getter
@Setter
public class Project implements Serializable {

private static final long serialVersionUID = -263516611;
Expand Down Expand Up @@ -79,7 +83,7 @@ public class Project implements Serializable {
private Set<SenderCase> senderCases = Sets.newHashSet();

@Column(name = "creation_date")
private Date creationDate;
private LocalDateTime creationDate;

@Type(type = "json")
@Column(name = "metadata")
Expand Down Expand Up @@ -107,110 +111,6 @@ public Project(Long id, String name) {
public Project() {
}

public Date getCreationDate() {
return creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public ProjectType getProjectType() {
return projectType;
}

public void setProjectType(ProjectType projectType) {
this.projectType = projectType;
}

public Set<ProjectUser> getUsers() {
return users;
}

public void setUsers(Set<ProjectUser> users) {
this.users = users;
}

public long getAllocatedStorage() {
return allocatedStorage;
}

public void setAllocatedStorage(long allocatedStorage) {
this.allocatedStorage = allocatedStorage;
}

public Set<PatternTemplate> getPatternTemplates() {
return patternTemplates;
}

public void setPatternTemplates(Set<PatternTemplate> patternTemplates) {
this.patternTemplates = patternTemplates;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Set<Integration> getIntegrations() {
return integrations;
}

public void setIntegrations(Set<Integration> integrations) {
this.integrations = integrations;
}

public Set<ProjectAttribute> getProjectAttributes() {
return projectAttributes;
}

public void setProjectAttributes(Set<ProjectAttribute> projectAttributes) {
this.projectAttributes = projectAttributes;
}

public Set<ProjectIssueType> getProjectIssueTypes() {
return projectIssueTypes;
}

public void setProjectIssueTypes(Set<ProjectIssueType> projectIssueTypes) {
this.projectIssueTypes = projectIssueTypes;
}

public Set<SenderCase> getSenderCases() {
return senderCases;
}

public void setSenderCases(Set<SenderCase> senderCases) {
this.senderCases = senderCases;
}

public String getOrganization() {
return organization;
}

public void setOrganization(String organization) {
this.organization = organization;
}

public Metadata getMetadata() {
return metadata;
}

public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@

import com.epam.ta.reportportal.entity.Modifiable;
import java.io.Serializable;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
import org.springframework.data.annotation.LastModifiedDate;

/**
* @author Ivan Budaev
*/
@Entity
@Table(name = "restore_password_bid")
@Data
public class RestorePasswordBid implements Serializable, Modifiable {

/**
Expand All @@ -43,7 +45,7 @@ public class RestorePasswordBid implements Serializable, Modifiable {

@LastModifiedDate
@Column(name = LAST_MODIFIED)
private Date lastModifiedDate;
private LocalDateTime lastModifiedDate;

@Column(name = "email")
private String email;
Expand All @@ -57,11 +59,11 @@ public void setUuid(String uuid) {
}

@Override
public Date getLastModified() {
public LocalDateTime getLastModified() {
return lastModifiedDate;
}

public void setLastModifiedDate(Date lastModifiedDate) {
public void setLastModifiedDate(LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

import com.epam.ta.reportportal.entity.Metadata;
import com.epam.ta.reportportal.entity.Modifiable;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import java.io.Serializable;
import java.util.Date;
import java.time.LocalDateTime;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -30,6 +28,10 @@
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

Expand All @@ -40,6 +42,8 @@
@Table(name = "user_creation_bid")
@TypeDef(name = "json", typeClass = Metadata.class)
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
public class UserCreationBid implements Serializable, Modifiable {

@Id
Expand All @@ -48,7 +52,7 @@ public class UserCreationBid implements Serializable, Modifiable {

@LastModifiedDate
@Column(name = LAST_MODIFIED)
private Date lastModified;
private LocalDateTime lastModified;

@Column(name = "email")
private String email;
Expand All @@ -67,60 +71,9 @@ public class UserCreationBid implements Serializable, Modifiable {
@Column(name = "metadata")
private Metadata metadata;

public String getUuid() {
return uuid;
}

public void setUuid(String uuid) {
this.uuid = uuid;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getProjectName() {
return projectName;
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

@Override
public Date getLastModified() {
public LocalDateTime getLastModified() {
return lastModified;
}

public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}

public Metadata getMetadata() {
return metadata;
}

public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}

public User getInvitingUser() {
return invitingUser;
}

public void setInvitingUser(User invitingUser) {
this.invitingUser = invitingUser;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2d13d98

Please sign in to comment.