-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1866a49
commit 81e8874
Showing
16 changed files
with
656 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/fr/recia/collabsoft/configuration/JpaConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2023 GIP-RECIA, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package fr.recia.collabsoft.configuration; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
|
||
@Configuration | ||
@EnableJpaRepositories(basePackages = "fr.recia.collabsoft.db.repositories") | ||
@Slf4j | ||
public class JpaConfiguration { | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/fr/recia/collabsoft/db/entities/AssociatedApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (C) 2023 GIP-RECIA, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package fr.recia.collabsoft.db.entities; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.proxy.HibernateProxy; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Table(name = "associated_app") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AssociatedApp { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "name", nullable = false) | ||
private String name; | ||
|
||
@Column(name = "slug", nullable = false) | ||
private String slug; | ||
|
||
@Column(name = "primary_color") | ||
private String primaryColor; | ||
|
||
@Column(name = "icon_path") | ||
private String iconPath; | ||
|
||
@Column(name = "extension") | ||
private String extension; | ||
|
||
@Column(name = "type") | ||
private String type; | ||
|
||
@Override | ||
public final boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null) return false; | ||
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass(); | ||
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass(); | ||
if (thisEffectiveClass != oEffectiveClass) return false; | ||
AssociatedApp that = (AssociatedApp) o; | ||
return getId() != null && Objects.equals(getId(), that.getId()); | ||
} | ||
|
||
@Override | ||
public final int hashCode() { | ||
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode(); | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/fr/recia/collabsoft/db/entities/Collaboration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2023 GIP-RECIA, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package fr.recia.collabsoft.db.entities; | ||
|
||
import fr.recia.collabsoft.db.entities.ids.CollaborationId; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.proxy.HibernateProxy; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.IdClass; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@IdClass(CollaborationId.class) | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Collaboration { | ||
|
||
@Id | ||
@ManyToOne | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
|
||
@Id | ||
@ManyToOne | ||
@JoinColumn(name = "file_id", nullable = false) | ||
private File file; | ||
|
||
@Column(name = "role") | ||
private Integer role; | ||
|
||
@Column(name = "starred") | ||
private boolean starred; | ||
|
||
@Override | ||
public final boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null) return false; | ||
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass(); | ||
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass(); | ||
if (thisEffectiveClass != oEffectiveClass) return false; | ||
Collaboration that = (Collaboration) o; | ||
return getUser() != null && Objects.equals(getUser(), that.getUser()) | ||
&& getFile() != null && Objects.equals(getFile(), that.getFile()); | ||
} | ||
|
||
@Override | ||
public final int hashCode() { | ||
return Objects.hash(user, file); | ||
} | ||
|
||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/fr/recia/collabsoft/db/entities/File.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (C) 2023 GIP-RECIA, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package fr.recia.collabsoft.db.entities; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.proxy.HibernateProxy; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.Lob; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.PrePersist; | ||
import javax.persistence.PreUpdate; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
import java.sql.Blob; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class File { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "title", nullable = false) | ||
private String title; | ||
|
||
@Column(name = "description") | ||
private String description; | ||
|
||
@Lob | ||
@Column(name = "blob", nullable = false) | ||
private byte[] blob; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "creator_id", nullable = false) | ||
private User creator; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
@Column(name = "creation_date", nullable = false) | ||
private Date creationDate; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "last_editor_id", nullable = false) | ||
private User lastEditor; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
@Column(name = "edition_date", nullable = false) | ||
private Date editionDate; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "associated_app_id") | ||
private AssociatedApp associatedApp; | ||
|
||
@PrePersist | ||
public void prePersist() { | ||
Date d = new Date(); | ||
d.setTime(Calendar.getInstance().getTimeInMillis()); | ||
if (this.creationDate == null) this.creationDate = d; | ||
if (this.editionDate == null) this.editionDate = d; | ||
} | ||
|
||
@PreUpdate | ||
public void preUpdate() { | ||
this.editionDate.setTime(Calendar.getInstance().getTimeInMillis()); | ||
} | ||
|
||
@Override | ||
public final boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null) return false; | ||
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass(); | ||
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass(); | ||
if (thisEffectiveClass != oEffectiveClass) return false; | ||
File file = (File) o; | ||
return getId() != null && Objects.equals(getId(), file.getId()); | ||
} | ||
|
||
@Override | ||
public final int hashCode() { | ||
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.