diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index e5b488f..9ac18de 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -15,7 +15,6 @@
-
diff --git a/.idea/runConfigurations/Lint_Test_Sonar___Run.xml b/.idea/runConfigurations/Lint_Test_Sonar___Run.xml
deleted file mode 100644
index ad6b930..0000000
--- a/.idea/runConfigurations/Lint_Test_Sonar___Run.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Sonarqube.xml b/.idea/runConfigurations/Sonarqube.xml
index fbb2ed1..af093fa 100644
--- a/.idea/runConfigurations/Sonarqube.xml
+++ b/.idea/runConfigurations/Sonarqube.xml
@@ -18,8 +18,6 @@
true
true
false
-
-
-
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Sonarqube_without_test.xml b/.idea/runConfigurations/Sonarqube_without_test.xml
index 4825a68..1774008 100644
--- a/.idea/runConfigurations/Sonarqube_without_test.xml
+++ b/.idea/runConfigurations/Sonarqube_without_test.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/src/main/kotlin/fr/dcproject/common/dto/CreatedAt.kt b/src/main/kotlin/fr/dcproject/common/dto/CreatedAt.kt
index a48589d..e50653c 100644
--- a/src/main/kotlin/fr/dcproject/common/dto/CreatedAt.kt
+++ b/src/main/kotlin/fr/dcproject/common/dto/CreatedAt.kt
@@ -1,7 +1,7 @@
package fr.dcproject.common.dto
-import fr.postgresjson.entity.EntityCreatedAt
import org.joda.time.DateTime
+import fr.dcproject.common.entity.CreatedAt as EntityCreatedAt
interface CreatedAt {
val createdAt: DateTime
diff --git a/src/main/kotlin/fr/dcproject/common/dto/Versionable.kt b/src/main/kotlin/fr/dcproject/common/dto/Versionable.kt
index 9dd777b..a4fd505 100644
--- a/src/main/kotlin/fr/dcproject/common/dto/Versionable.kt
+++ b/src/main/kotlin/fr/dcproject/common/dto/Versionable.kt
@@ -1,13 +1,13 @@
package fr.dcproject.common.dto
-import fr.postgresjson.entity.EntityVersioning
+import fr.dcproject.common.entity.Versionable as VersionableEntity
import java.util.UUID
interface Versionable {
val versionId: UUID
val versionNumber: Int
- class Imp(parent: EntityVersioning) : Versionable {
+ class Imp(parent: VersionableEntity) : Versionable {
override val versionNumber: Int = parent.versionNumber
override val versionId: UUID = parent.versionId
}
diff --git a/src/main/kotlin/fr/dcproject/common/entity/Action.kt b/src/main/kotlin/fr/dcproject/common/entity/Action.kt
new file mode 100644
index 0000000..cb78e2e
--- /dev/null
+++ b/src/main/kotlin/fr/dcproject/common/entity/Action.kt
@@ -0,0 +1,28 @@
+package fr.dcproject.common.entity
+
+import fr.dcproject.component.citizen.CitizenI
+
+interface Created : CreatedAt, CreatedBy {
+ class Imp(createdBy: C) :
+ Created,
+ CreatedBy by CreatedBy.Imp(createdBy),
+ CreatedAt by CreatedAt.Imp()
+}
+
+interface Updated : UpdatedAt, UpdatedBy {
+ class Imp(updatedAt: C) :
+ Updated,
+ UpdatedBy by UpdatedBy.Imp(updatedAt),
+ UpdatedAt by UpdatedAt.Imp()
+}
+
+interface Deleted : DeletedAt, DeletedBy {
+ override fun isDeleted(): Boolean = (this as DeletedAt).isDeleted()
+
+ class Imp(deletedAt: C) :
+ Deleted,
+ DeletedBy by DeletedBy.Imp(deletedAt),
+ DeletedAt by DeletedAt.Imp() {
+ override fun isDeleted(): Boolean = (this as Deleted).isDeleted()
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/fr/dcproject/common/entity/ActionBy.kt b/src/main/kotlin/fr/dcproject/common/entity/ActionBy.kt
new file mode 100644
index 0000000..521cca3
--- /dev/null
+++ b/src/main/kotlin/fr/dcproject/common/entity/ActionBy.kt
@@ -0,0 +1,25 @@
+package fr.dcproject.common.entity
+
+import fr.dcproject.component.citizen.CitizenI
+
+interface CreatedBy {
+ val createdBy: T
+
+ class Imp(override val createdBy: T) : CreatedBy
+}
+
+interface UpdatedBy {
+ val updatedBy: T
+
+ class Imp(override val updatedBy: T) : UpdatedBy
+}
+
+interface DeletedBy {
+ val deletedBy: T?
+
+ fun isDeleted(): Boolean {
+ return deletedBy?.let { true } ?: false
+ }
+
+ class Imp(override val deletedBy: T?) : DeletedBy
+}
diff --git a/src/main/kotlin/fr/dcproject/common/entity/CreatedBy.kt b/src/main/kotlin/fr/dcproject/common/entity/CreatedBy.kt
deleted file mode 100644
index 5d464d7..0000000
--- a/src/main/kotlin/fr/dcproject/common/entity/CreatedBy.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package fr.dcproject.common.entity
-
-import fr.dcproject.component.citizen.CitizenI
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityI
-
-/**
- * TODO remove EntityCreatedBy
- */
-interface CreatedBy : EntityCreatedBy {
- override val createdBy: T
-}
-
-class CreatedByImp(override val createdBy: T) : CreatedBy
diff --git a/src/main/kotlin/fr/dcproject/common/entity/Date.kt b/src/main/kotlin/fr/dcproject/common/entity/Date.kt
new file mode 100644
index 0000000..12fd3ac
--- /dev/null
+++ b/src/main/kotlin/fr/dcproject/common/entity/Date.kt
@@ -0,0 +1,30 @@
+package fr.dcproject.common.entity
+
+import org.joda.time.DateTime
+
+/* Interface */
+interface CreatedAt {
+ val createdAt: DateTime
+ class Imp(
+ override val createdAt: DateTime = DateTime.now()
+ ) : CreatedAt
+}
+interface UpdatedAt {
+ val updatedAt: DateTime
+ class Imp(
+ override val updatedAt: DateTime = DateTime.now()
+ ) : UpdatedAt
+}
+
+interface DeletedAt {
+ val deletedAt: DateTime?
+ fun isDeleted(): Boolean {
+ return deletedAt?.let {
+ it < DateTime.now()
+ } ?: false
+ }
+
+ class Imp(
+ override val deletedAt: DateTime? = null
+ ) : DeletedAt
+}
diff --git a/src/main/kotlin/fr/dcproject/common/entity/EntityI.kt b/src/main/kotlin/fr/dcproject/common/entity/EntityI.kt
index 8d36019..fa87a5f 100644
--- a/src/main/kotlin/fr/dcproject/common/entity/EntityI.kt
+++ b/src/main/kotlin/fr/dcproject/common/entity/EntityI.kt
@@ -1,8 +1,12 @@
package fr.dcproject.common.entity
-import fr.postgresjson.entity.EntityI
+import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
-interface EntityI : EntityI {
- val id: UUID
+interface EntityI : UuidEntityI {
+ override val id: UUID
+}
+
+open class Entity(id: UUID? = null) : EntityI {
+ override val id: UUID = id ?: UUID.randomUUID()
}
diff --git a/src/main/kotlin/fr/dcproject/common/entity/Extra.kt b/src/main/kotlin/fr/dcproject/common/entity/Extra.kt
index 743f898..28796dd 100644
--- a/src/main/kotlin/fr/dcproject/common/entity/Extra.kt
+++ b/src/main/kotlin/fr/dcproject/common/entity/Extra.kt
@@ -5,25 +5,21 @@ import fr.dcproject.component.citizen.CitizenI
import fr.dcproject.component.comment.generic.CommentRef
import fr.dcproject.component.constitution.ConstitutionRef
import fr.dcproject.component.opinion.entity.OpinionRef
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
import kotlin.reflect.KClass
import kotlin.reflect.full.isSubclassOf
interface ExtraI :
- UuidEntityI,
+ EntityI,
HasTarget,
- EntityCreatedAt,
- EntityCreatedBy
+ CreatedAt,
+ CreatedBy
interface HasTarget {
val target: T
}
-open class TargetRef(id: UUID? = null, reference: String = "") : TargetI, UuidEntity(id) {
+open class TargetRef(id: UUID? = null, reference: String = "") : TargetI, Entity(id) {
final override val reference: String
get() = if (field != "") field else TargetI.getReference(this)
@@ -33,7 +29,7 @@ open class TargetRef(id: UUID? = null, reference: String = "") : TargetI, UuidEn
}
}
-interface TargetI : UuidEntityI {
+interface TargetI : EntityI {
enum class TargetName(val targetReference: String) {
Article("article"),
Constitution("constitution"),
diff --git a/src/main/kotlin/fr/dcproject/common/entity/Versionable.kt b/src/main/kotlin/fr/dcproject/common/entity/Versionable.kt
index 8a04389..33c493e 100644
--- a/src/main/kotlin/fr/dcproject/common/entity/Versionable.kt
+++ b/src/main/kotlin/fr/dcproject/common/entity/Versionable.kt
@@ -1,17 +1,25 @@
package fr.dcproject.common.entity
-import fr.postgresjson.entity.EntityVersioning
import java.util.UUID
-interface VersionableRef {
+interface VersionableId {
val versionId: UUID
+
+ class Imp(
+ versionId: UUID? = null,
+ ) : VersionableId {
+ override val versionId: UUID = versionId ?: UUID.randomUUID()
+ }
}
-class VersionableRefImp(
+interface Versionable : VersionableId {
override val versionId: UUID
-) : VersionableRef
+ val versionNumber: Int
-interface Versionable : VersionableRef, EntityVersioning {
- override val versionId: UUID
- override val versionNumber: Int
+ class Imp(
+ override val versionNumber: Int,
+ versionId: UUID? = null,
+ ) : Versionable {
+ override val versionId: UUID = versionId ?: UUID.randomUUID()
+ }
}
diff --git a/src/main/kotlin/fr/dcproject/component/article/Article.kt b/src/main/kotlin/fr/dcproject/component/article/Article.kt
index bc77fe3..a041078 100644
--- a/src/main/kotlin/fr/dcproject/component/article/Article.kt
+++ b/src/main/kotlin/fr/dcproject/component/article/Article.kt
@@ -1,9 +1,13 @@
package fr.dcproject.component.article
+import fr.dcproject.common.entity.CreatedAt
import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.TargetI
import fr.dcproject.common.entity.TargetRef
-import fr.dcproject.common.entity.VersionableRef
+import fr.dcproject.common.entity.Versionable
+import fr.dcproject.common.entity.VersionableId
import fr.dcproject.component.citizen.CitizenCart
import fr.dcproject.component.citizen.CitizenCartI
import fr.dcproject.component.citizen.CitizenI
@@ -16,12 +20,6 @@ import fr.dcproject.component.workgroup.WorkgroupCart
import fr.dcproject.component.workgroup.WorkgroupCartI
import fr.dcproject.component.workgroup.WorkgroupRef
import fr.dcproject.component.workgroup.WorkgroupSimple
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
-import fr.postgresjson.entity.EntityVersioning
-import fr.postgresjson.entity.UuidEntityI
import org.joda.time.DateTime
import java.util.UUID
@@ -42,16 +40,16 @@ data class ArticleForView(
) : ArticleRef(id),
ArticleAuthI,
ArticleWithTitleI,
- EntityVersioning,
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityDeletedAt by EntityDeletedAtImp(deletedAt),
- VersionableRef,
+ Versionable,
+ CreatedAt by CreatedAt.Imp(),
+ DeletedAt by DeletedAt.Imp(deletedAt),
+ VersionableId,
Opinionable,
Votable by VotableImp() {
val lastVersion: Boolean = false
}
-interface ArticleForUpdateI : ArticleI, ArticleWithTitleI, VersionableRef, TargetI, CreatedBy {
+interface ArticleForUpdateI : ArticleI, ArticleWithTitleI, VersionableId, TargetI, CreatedBy {
val anonymous: Boolean
val content: String
val description: String
@@ -74,7 +72,7 @@ class ArticleForUpdate(
) : ArticleRef(id),
ArticleForUpdateI,
ArticleAuthI,
- VersionableRef {
+ VersionableId {
val tags: List = tags.distinct()
}
@@ -99,7 +97,7 @@ open class ArticleRef(
id: UUID? = null
) : ArticleI, TargetRef(id)
-interface ArticleI : UuidEntityI, TargetI
+interface ArticleI : EntityI, TargetI
interface ArticleWithTitleI : ArticleI {
val title: String
@@ -108,6 +106,6 @@ interface ArticleWithTitleI : ArticleI {
interface ArticleAuthI :
ArticleI,
CreatedBy,
- EntityDeletedAt {
+ DeletedAt {
val draft: Boolean
}
diff --git a/src/main/kotlin/fr/dcproject/component/article/ArticleAccessControl.kt b/src/main/kotlin/fr/dcproject/component/article/ArticleAccessControl.kt
index 82e4fae..d29b922 100644
--- a/src/main/kotlin/fr/dcproject/component/article/ArticleAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/article/ArticleAccessControl.kt
@@ -1,7 +1,7 @@
package fr.dcproject.component.article
import fr.dcproject.common.entity.CreatedBy
-import fr.dcproject.common.entity.VersionableRef
+import fr.dcproject.common.entity.VersionableId
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
import fr.dcproject.component.citizen.CitizenI
@@ -28,7 +28,7 @@ class ArticleAccessControl(private val articleRepo: ArticleRepository) : AccessC
fun canUpsert(subject: S, citizen: CitizenI?): AccessResponse
where S : ArticleI,
S : CreatedBy<*>,
- S : VersionableRef {
+ S : VersionableId {
if (citizen == null) return denied("You must be connected to create article", "article.create.notConnected")
/* The new Article must by created by the same citizen of the connected citizen */
if (subject.createdBy.id == citizen.id) {
diff --git a/src/main/kotlin/fr/dcproject/component/article/ArticleViewManager.kt b/src/main/kotlin/fr/dcproject/component/article/ArticleViewManager.kt
index 50e429f..9b1bda0 100644
--- a/src/main/kotlin/fr/dcproject/component/article/ArticleViewManager.kt
+++ b/src/main/kotlin/fr/dcproject/component/article/ArticleViewManager.kt
@@ -1,6 +1,6 @@
package fr.dcproject.component.article
-import fr.dcproject.common.entity.VersionableRef
+import fr.dcproject.common.entity.VersionableId
import fr.dcproject.common.utils.contentToString
import fr.dcproject.common.utils.getJsonField
import fr.dcproject.common.utils.toIso
@@ -16,7 +16,7 @@ import java.util.UUID
/**
* Wrapper for manage views with elasticsearch
*/
-class ArticleViewManager (private val restClient: RestClient) : ViewManager where A : VersionableRef, A : ArticleI {
+class ArticleViewManager (private val restClient: RestClient) : ViewManager where A : VersionableId, A : ArticleI {
/**
* Add view on article to elasticsearch
*/
diff --git a/src/main/kotlin/fr/dcproject/component/auth/User.kt b/src/main/kotlin/fr/dcproject/component/auth/User.kt
index 0fdf6f6..f2db49f 100644
--- a/src/main/kotlin/fr/dcproject/component/auth/User.kt
+++ b/src/main/kotlin/fr/dcproject/component/auth/User.kt
@@ -1,12 +1,10 @@
package fr.dcproject.component.auth
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.Entity
+import fr.dcproject.common.entity.EntityI
+import fr.dcproject.common.entity.UpdatedAt
import fr.dcproject.component.auth.UserI.Roles
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityI
import io.ktor.auth.Principal
import org.joda.time.DateTime
import java.util.UUID
@@ -26,8 +24,8 @@ open class User(
var blockedAt: DateTime? = null,
var roles: List = emptyList()
) : UserRef(id),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityUpdatedAt by EntityUpdatedAtImp()
+ CreatedAt by CreatedAt.Imp(),
+ UpdatedAt by UpdatedAt.Imp()
interface UserWithPasswordI {
val id: UUID
@@ -42,9 +40,9 @@ class UserWithPassword(
open class UserRef(
id: UUID = UUID.randomUUID()
-) : UserI, UuidEntity(id)
+) : UserI, Entity(id)
-interface UserI : UuidEntityI, Principal {
+interface UserI : EntityI, Principal {
enum class Roles { ROLE_USER, ROLE_ADMIN }
}
diff --git a/src/main/kotlin/fr/dcproject/component/citizen/Citizen.kt b/src/main/kotlin/fr/dcproject/component/citizen/Citizen.kt
index c407922..254690c 100644
--- a/src/main/kotlin/fr/dcproject/component/citizen/Citizen.kt
+++ b/src/main/kotlin/fr/dcproject/component/citizen/Citizen.kt
@@ -1,18 +1,16 @@
package fr.dcproject.component.citizen
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.DeletedAt
+import fr.dcproject.common.entity.Entity
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.component.auth.User
import fr.dcproject.component.auth.UserForCreate
import fr.dcproject.component.auth.UserI
import fr.dcproject.component.auth.UserRef
import fr.dcproject.component.citizen.CitizenI.Name
import fr.dcproject.component.workgroup.WorkgroupSimple
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
import fr.postgresjson.entity.Serializable
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityI
import org.joda.time.DateTime
import java.util.UUID
@@ -26,7 +24,7 @@ class CitizenForCreate(
id: UUID = UUID.randomUUID(),
) : CitizenI,
CitizenRefWithUser(id, user),
- EntityCreatedAt by EntityCreatedAtImp()
+ CreatedAt by CreatedAt.Imp()
class Citizen(
override val id: UUID = UUID.randomUUID(),
@@ -42,8 +40,8 @@ class Citizen(
CitizenWithUserI,
CitizenRef(id),
CitizenCartI,
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityDeletedAt by EntityDeletedAtImp(deletedAt) {
+ CreatedAt by CreatedAt.Imp(),
+ DeletedAt by DeletedAt.Imp(deletedAt) {
var workgroups: List = emptyList()
class WorkgroupAndRoles(
@@ -64,7 +62,7 @@ data class CitizenBasic(
override val deletedAt: DateTime? = null
) : CitizenBasicI,
CitizenRefWithUser(id, user),
- EntityDeletedAt by EntityDeletedAtImp(deletedAt)
+ DeletedAt by DeletedAt.Imp(deletedAt)
@Deprecated("")
open class CitizenSimple(
@@ -92,10 +90,10 @@ open class CitizenRefWithUser(
open class CitizenRef(
id: UUID = UUID.randomUUID()
-) : UuidEntity(id),
+) : Entity(id),
CitizenI
-interface CitizenI : UuidEntityI {
+interface CitizenI : EntityI {
data class Name(
override val firstName: String,
override val lastName: String,
@@ -111,7 +109,7 @@ interface CitizenI : UuidEntityI {
}
@Deprecated("")
-interface CitizenBasicI : CitizenWithUserI, CitizenWithEmail, EntityDeletedAt {
+interface CitizenBasicI : CitizenWithUserI, CitizenWithEmail, DeletedAt {
val name: Name
val birthday: DateTime
val voteAnonymous: Boolean
diff --git a/src/main/kotlin/fr/dcproject/component/citizen/CitizenAccessControl.kt b/src/main/kotlin/fr/dcproject/component/citizen/CitizenAccessControl.kt
index 856ae52..bbaf2ba 100644
--- a/src/main/kotlin/fr/dcproject/component/citizen/CitizenAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/citizen/CitizenAccessControl.kt
@@ -1,14 +1,14 @@
package fr.dcproject.component.citizen
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
-import fr.postgresjson.entity.EntityDeletedAt
class CitizenAccessControl : AccessControl() {
- fun canView(subjects: List, connectedCitizen: CitizenI?): AccessResponse where S : CitizenI, S : EntityDeletedAt =
+ fun canView(subjects: List, connectedCitizen: CitizenI?): AccessResponse where S : CitizenI, S : DeletedAt =
canAll(subjects) { canView(it, connectedCitizen) }
- fun canView(subject: S, connectedCitizen: CitizenI?): AccessResponse where S : CitizenI, S : EntityDeletedAt {
+ fun canView(subject: S, connectedCitizen: CitizenI?): AccessResponse where S : CitizenI, S : DeletedAt {
if (connectedCitizen == null) return denied("You must be connected to view citizen", "citizen.view.connected")
return if (subject.isDeleted()) denied("You cannot view a deleted citizen", "citizen.view.deleted")
else granted()
diff --git a/src/main/kotlin/fr/dcproject/component/comment/article/CommentArticleRepository.kt b/src/main/kotlin/fr/dcproject/component/comment/article/CommentArticleRepository.kt
index fc71b0b..44a4e7e 100644
--- a/src/main/kotlin/fr/dcproject/component/comment/article/CommentArticleRepository.kt
+++ b/src/main/kotlin/fr/dcproject/component/comment/article/CommentArticleRepository.kt
@@ -1,5 +1,6 @@
package fr.dcproject.component.comment.article
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.TargetI
import fr.dcproject.component.article.ArticleForView
import fr.dcproject.component.article.ArticleRef
@@ -9,7 +10,6 @@ import fr.dcproject.component.comment.generic.CommentForView
import fr.dcproject.component.comment.generic.CommentRepositoryAbs
import fr.postgresjson.connexion.Paginated
import fr.postgresjson.connexion.Requester
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
class CommentArticleRepository(requester: Requester) : CommentRepositoryAbs(requester) {
@@ -36,7 +36,7 @@ class CommentArticleRepository(requester: Requester) : CommentRepositoryAbs(requester) {
@@ -36,7 +36,7 @@ class CommentConstitutionRepository(requester: Requester) : CommentRepositoryAbs
}
override fun findByTarget(
- target: UuidEntityI,
+ target: EntityI,
page: Int,
limit: Int,
sort: CommentArticleRepository.Sort
diff --git a/src/main/kotlin/fr/dcproject/component/comment/generic/Comment.kt b/src/main/kotlin/fr/dcproject/component/comment/generic/Comment.kt
index 2eb73a4..4aa9d76 100644
--- a/src/main/kotlin/fr/dcproject/component/comment/generic/Comment.kt
+++ b/src/main/kotlin/fr/dcproject/component/comment/generic/Comment.kt
@@ -1,21 +1,17 @@
package fr.dcproject.component.comment.generic
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.ExtraI
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.entity.TargetI
import fr.dcproject.common.entity.TargetRef
+import fr.dcproject.common.entity.UpdatedAt
import fr.dcproject.component.citizen.CitizenRef
import fr.dcproject.component.vote.entity.Votable
import fr.dcproject.component.vote.entity.VotableImp
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
import org.joda.time.DateTime
import java.util.UUID
@@ -31,9 +27,9 @@ class CommentForView(
CommentWithParentI,
CommentForUpdate(id, createdBy, target, content, parent, deletedAt),
CommentWithTargetI,
- EntityCreatedBy by EntityCreatedByImp(createdBy),
- EntityUpdatedAt by EntityUpdatedAtImp(),
- EntityDeletedAt by EntityDeletedAtImp(),
+ CreatedBy by CreatedBy.Imp(createdBy),
+ UpdatedAt by UpdatedAt.Imp(),
+ DeletedAt by DeletedAt.Imp(),
Votable by VotableImp(),
TargetI {
constructor(
@@ -59,9 +55,9 @@ open class CommentForUpdate(
CommentWithParentI,
ExtraI,
CommentWithTargetI,
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityCreatedBy,
- EntityDeletedAt,
+ CreatedAt by CreatedAt.Imp(),
+ CreatedBy,
+ DeletedAt,
TargetI {
constructor(
createdBy: C,
@@ -82,7 +78,7 @@ open class CommentParent(
) : CommentRef(id),
CommentParentI
-interface CommentParentI : CommentI, EntityDeletedAt, CommentWithTargetI
+interface CommentParentI : CommentI, DeletedAt, CommentWithTargetI
interface CommentWithTargetI : CommentI, TargetI, HasTarget
diff --git a/src/main/kotlin/fr/dcproject/component/comment/generic/CommentAccessControl.kt b/src/main/kotlin/fr/dcproject/component/comment/generic/CommentAccessControl.kt
index fd51d11..c5b6ff2 100644
--- a/src/main/kotlin/fr/dcproject/component/comment/generic/CommentAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/comment/generic/CommentAccessControl.kt
@@ -1,39 +1,39 @@
package fr.dcproject.component.comment.generic
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
import fr.dcproject.component.citizen.CitizenI
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityDeletedAt
class CommentAccessControl : AccessControl() {
fun canView(subjects: List, citizen: CitizenI?): AccessResponse
where S : CommentI,
- S : EntityDeletedAt = canAll(subjects) { canView(it, citizen) }
+ S : DeletedAt = canAll(subjects) { canView(it, citizen) }
fun canView(subject: S, citizen: CitizenI?): AccessResponse
where S : CommentI,
- S : EntityDeletedAt = when {
+ S : DeletedAt = when {
subject.isDeleted() -> denied("Your cannot view a deleted comment", "comment.view.deleted")
else -> granted()
}
fun canCreate(subject: S, citizen: CitizenI?): AccessResponse
where S : CommentI,
- S : EntityCreatedBy,
+ S : CreatedBy,
S : CommentWithParentI<*>,
S : HasTarget<*> = when {
citizen == null -> denied("You must be connected to create user", "comment.create.notConnected")
subject.createdBy.id != citizen.id -> denied("You cannot create a comment with other user than yours", "comment.create.wrongUser")
subject.parent?.isDeleted() ?: false -> denied("You cannot create a comment on deleted parent", "comment.create.deletedParent")
- subject.target.let { it is EntityDeletedAt && it.isDeleted() } -> denied("You cannot create a comment on deleted target", "comment.create.deletedTarget")
+ subject.target.let { it is DeletedAt && it.isDeleted() } -> denied("You cannot create a comment on deleted target", "comment.create.deletedTarget")
else -> granted()
}
fun canUpdate(subject: S, citizen: CitizenI?): AccessResponse
where S : CommentI,
- S : EntityCreatedBy = when {
+ S : CreatedBy = when {
citizen == null -> denied("You must be connected to update comment", "comment.update.notConnected")
citizen.id != subject.createdBy.id -> denied("You cannot update another user of yours", "comment.update.notYours")
else -> granted()
diff --git a/src/main/kotlin/fr/dcproject/component/comment/generic/CommentRepository.kt b/src/main/kotlin/fr/dcproject/component/comment/generic/CommentRepository.kt
index 2bf94a8..3cc4232 100644
--- a/src/main/kotlin/fr/dcproject/component/comment/generic/CommentRepository.kt
+++ b/src/main/kotlin/fr/dcproject/component/comment/generic/CommentRepository.kt
@@ -1,5 +1,6 @@
package fr.dcproject.component.comment.generic
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.TargetI
import fr.dcproject.common.entity.TargetRef
import fr.dcproject.component.citizen.CitizenI
@@ -7,7 +8,6 @@ import fr.dcproject.component.citizen.CitizenRef
import fr.dcproject.component.comment.article.CommentArticleRepository
import fr.postgresjson.connexion.Paginated
import fr.postgresjson.connexion.Requester
-import fr.postgresjson.entity.UuidEntityI
import fr.postgresjson.repository.RepositoryI
import java.util.UUID
@@ -44,7 +44,7 @@ abstract class CommentRepositoryAbs(override var requester: Request
}
open fun findByTarget(
- target: UuidEntityI,
+ target: EntityI,
page: Int = 1,
limit: Int = 50,
sort: CommentArticleRepository.Sort = CommentArticleRepository.Sort.CREATED_AT
diff --git a/src/main/kotlin/fr/dcproject/component/constitution/Constitution.kt b/src/main/kotlin/fr/dcproject/component/constitution/Constitution.kt
index d4bc28a..2d9eba7 100644
--- a/src/main/kotlin/fr/dcproject/component/constitution/Constitution.kt
+++ b/src/main/kotlin/fr/dcproject/component/constitution/Constitution.kt
@@ -1,21 +1,17 @@
package fr.dcproject.component.constitution
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
+import fr.dcproject.common.entity.Entity
import fr.dcproject.common.entity.TargetI
import fr.dcproject.common.entity.TargetRef
+import fr.dcproject.common.entity.VersionableId
import fr.dcproject.component.article.ArticleForListing
import fr.dcproject.component.article.ArticleI
import fr.dcproject.component.citizen.CitizenSimple
import fr.dcproject.component.citizen.CitizenWithUserI
import fr.dcproject.component.constitution.ConstitutionSimple.TitleSimple
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
-import fr.postgresjson.entity.EntityVersioning
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityVersioning
import java.util.UUID
class Constitution(
@@ -54,10 +50,10 @@ open class ConstitutionSimple>(
override val createdBy: Cr,
versionId: UUID = UUID.randomUUID()
) : ConstitutionRef(id),
- EntityVersioning by UuidEntityVersioning(versionId = versionId, versionNumber = 0),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityCreatedBy by EntityCreatedByImp(createdBy),
- EntityDeletedAt by EntityDeletedAtImp() {
+ VersionableId by VersionableId.Imp(versionId),
+ CreatedAt by CreatedAt.Imp(),
+ CreatedBy by CreatedBy.Imp(createdBy),
+ DeletedAt by DeletedAt.Imp() {
init {
titles.forEachIndexed { index, title ->
@@ -76,7 +72,7 @@ open class ConstitutionSimple>(
open class ConstitutionRef(id: UUID? = null) : ConstitutionS(id ?: UUID.randomUUID()) {
open class TitleRef(
id: UUID = UUID.randomUUID()
- ) : UuidEntity(id)
+ ) : Entity(id)
}
sealed class ConstitutionS(id: UUID = UUID.randomUUID()) : TargetRef(id), TargetI
diff --git a/src/main/kotlin/fr/dcproject/component/constitution/ConstitutionAccessControl.kt b/src/main/kotlin/fr/dcproject/component/constitution/ConstitutionAccessControl.kt
index f75dfd3..769395f 100644
--- a/src/main/kotlin/fr/dcproject/component/constitution/ConstitutionAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/constitution/ConstitutionAccessControl.kt
@@ -1,10 +1,10 @@
package fr.dcproject.component.constitution
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
import fr.dcproject.component.citizen.CitizenI
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityDeletedAt
class ConstitutionAccessControl : AccessControl() {
fun canCreate(subject: ConstitutionS, citizen: CitizenI?): AccessResponse = when {
@@ -15,18 +15,18 @@ class ConstitutionAccessControl : AccessControl() {
fun > canView(subjects: List, citizen: CitizenI?): AccessResponse =
canAll(subjects) { canView(it, citizen) }
- fun canView(subject: S, citizen: CitizenI?): AccessResponse where S : EntityDeletedAt, S : ConstitutionS = when {
+ fun canView(subject: S, citizen: CitizenI?): AccessResponse where S : DeletedAt, S : ConstitutionS = when {
subject.isDeleted() -> denied("You cannot view a deleted constitution", "constitution.view.deleted")
else -> granted()
}
- fun canDelete(subject: S, citizen: CitizenI?): AccessResponse where S : EntityCreatedBy, S : ConstitutionRef = when {
+ fun canDelete(subject: S, citizen: CitizenI?): AccessResponse where S : CreatedBy, S : ConstitutionRef = when {
citizen == null -> denied("You must be connected to delete constitution", "constitution.delete.notConnected")
subject.createdBy.id != citizen.id -> denied("You cannot delete the constitution of other citizen", "constitution.delete.otherCitizen")
else -> granted()
}
- fun canUpdate(subject: S, citizen: CitizenI?): AccessResponse where S : EntityCreatedBy, S : ConstitutionRef = when {
+ fun canUpdate(subject: S, citizen: CitizenI?): AccessResponse where S : CreatedBy, S : ConstitutionRef = when {
citizen == null -> denied("You must be connected to update constitution", "constitution.update.notConnected")
subject.createdBy.id != citizen.id -> denied("You cannot update the constitution of other citizen", "constitution.update.otherCitizen")
else -> granted()
diff --git a/src/main/kotlin/fr/dcproject/component/constitution/routes/CreateConstitution.kt b/src/main/kotlin/fr/dcproject/component/constitution/routes/CreateConstitution.kt
index ba4b9f8..9aaedaa 100644
--- a/src/main/kotlin/fr/dcproject/component/constitution/routes/CreateConstitution.kt
+++ b/src/main/kotlin/fr/dcproject/component/constitution/routes/CreateConstitution.kt
@@ -1,5 +1,6 @@
package fr.dcproject.component.constitution.routes
+import fr.dcproject.common.entity.Entity
import fr.dcproject.common.security.assert
import fr.dcproject.common.utils.receiveOrBadRequest
import fr.dcproject.component.article.ArticleRef
@@ -13,7 +14,6 @@ import fr.dcproject.component.constitution.ConstitutionSimple
import fr.dcproject.component.constitution.ConstitutionSimple.TitleSimple
import fr.dcproject.component.constitution.routes.CreateConstitution.PostConstitutionRequest.Input
import fr.dcproject.component.constitution.routes.CreateConstitution.PostConstitutionRequest.Input.Title
-import fr.postgresjson.entity.UuidEntity
import io.ktor.application.call
import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.locations.Location
@@ -45,7 +45,7 @@ object CreateConstitution {
var name: String,
var rank: Int? = null,
var articles: MutableList = mutableListOf()
- ) : UuidEntity(id)
+ ) : Entity(id)
}
}
diff --git a/src/main/kotlin/fr/dcproject/component/follow/Follow.kt b/src/main/kotlin/fr/dcproject/component/follow/Follow.kt
index 4ff4944..3bc05e2 100644
--- a/src/main/kotlin/fr/dcproject/component/follow/Follow.kt
+++ b/src/main/kotlin/fr/dcproject/component/follow/Follow.kt
@@ -1,16 +1,14 @@
package fr.dcproject.component.follow
+import fr.dcproject.common.entity.Created
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.ExtraI
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.entity.TargetI
import fr.dcproject.component.citizen.CitizenBasic
import fr.dcproject.component.citizen.CitizenBasicI
import fr.dcproject.component.citizen.CitizenI
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
@Deprecated("")
@@ -28,8 +26,7 @@ open class FollowSimple(
override var target: T
) : ExtraI,
FollowRef(id),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityCreatedBy by EntityCreatedByImp(createdBy)
+ Created by Created.Imp(createdBy)
class FollowForUpdate(
id: UUID = UUID.randomUUID(),
@@ -37,10 +34,10 @@ class FollowForUpdate(
override val createdBy: C
) : FollowRef(id),
HasTarget,
- EntityCreatedBy by EntityCreatedByImp(createdBy)
+ CreatedBy by CreatedBy.Imp(createdBy)
open class FollowRef(
override val id: UUID
) : FollowI
-interface FollowI : UuidEntityI
+interface FollowI : EntityI
diff --git a/src/main/kotlin/fr/dcproject/component/follow/FollowRepository.kt b/src/main/kotlin/fr/dcproject/component/follow/FollowRepository.kt
index 1914885..f57c6bc 100644
--- a/src/main/kotlin/fr/dcproject/component/follow/FollowRepository.kt
+++ b/src/main/kotlin/fr/dcproject/component/follow/FollowRepository.kt
@@ -1,5 +1,6 @@
package fr.dcproject.component.follow
+import fr.dcproject.common.entity.Entity
import fr.dcproject.common.entity.TargetRef
import fr.dcproject.component.article.ArticleForView
import fr.dcproject.component.article.ArticleRef
@@ -8,7 +9,6 @@ import fr.dcproject.component.citizen.CitizenRef
import fr.dcproject.component.constitution.ConstitutionRef
import fr.postgresjson.connexion.Paginated
import fr.postgresjson.connexion.Requester
-import fr.postgresjson.entity.UuidEntity
import fr.postgresjson.repository.RepositoryI
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
@@ -71,7 +71,7 @@ sealed class FollowRepository(override var requ
)
fun findFollowsByTarget(
- target: UuidEntity,
+ target: Entity,
bulkSize: Int = 300
): Flow> = flow {
var nextPage = 1
@@ -85,7 +85,7 @@ sealed class FollowRepository(override var requ
}
abstract fun findFollowsByTarget(
- target: UuidEntity,
+ target: Entity,
page: Int = 1,
limit: Int = 300
): Paginated>
@@ -108,7 +108,7 @@ class FollowArticleRepository(requester: Requester) : FollowRepository> {
@@ -139,7 +139,7 @@ class FollowConstitutionRepository(requester: Requester) : FollowRepository> {
diff --git a/src/main/kotlin/fr/dcproject/component/notification/Notification.kt b/src/main/kotlin/fr/dcproject/component/notification/Notification.kt
index 3ba9d7d..798ff52 100644
--- a/src/main/kotlin/fr/dcproject/component/notification/Notification.kt
+++ b/src/main/kotlin/fr/dcproject/component/notification/Notification.kt
@@ -7,8 +7,8 @@ import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.datatype.joda.JodaModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
+import fr.dcproject.common.entity.Entity
import fr.dcproject.component.article.ArticleForView
-import fr.postgresjson.entity.UuidEntity
import org.joda.time.DateTime
import java.util.concurrent.atomic.AtomicInteger
@@ -47,7 +47,7 @@ open class Notification(
}
open class EntityNotification(
- val target: UuidEntity,
+ val target: Entity,
type: String,
val action: String
) : Notification(type)
diff --git a/src/main/kotlin/fr/dcproject/component/notification/NotificationEmailSender.kt b/src/main/kotlin/fr/dcproject/component/notification/NotificationEmailSender.kt
index 80e8480..76dd606 100644
--- a/src/main/kotlin/fr/dcproject/component/notification/NotificationEmailSender.kt
+++ b/src/main/kotlin/fr/dcproject/component/notification/NotificationEmailSender.kt
@@ -4,6 +4,7 @@ import com.sendgrid.helpers.mail.Mail
import com.sendgrid.helpers.mail.objects.Content
import com.sendgrid.helpers.mail.objects.Email
import fr.dcproject.common.email.Mailer
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.TargetRef
import fr.dcproject.component.article.ArticleRepository
import fr.dcproject.component.article.ArticleWithTitleI
@@ -11,7 +12,6 @@ import fr.dcproject.component.citizen.CitizenBasicI
import fr.dcproject.component.citizen.CitizenRef
import fr.dcproject.component.citizen.CitizenRepository
import fr.dcproject.component.follow.FollowSimple
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
class NotificationEmailSender(
@@ -43,7 +43,7 @@ class NotificationEmailSender(
}
}
- private fun generateHtmlContent(citizen: CitizenBasicI, target: UuidEntityI): String? {
+ private fun generateHtmlContent(citizen: CitizenBasicI, target: EntityI): String? {
return when (target) {
is ArticleWithTitleI -> """
Hello ${citizen.name.getFullName()},
@@ -53,7 +53,7 @@ class NotificationEmailSender(
}
}
- private fun generateContent(citizen: CitizenBasicI, target: UuidEntityI): String {
+ private fun generateContent(citizen: CitizenBasicI, target: EntityI): String {
return when (target) {
is ArticleWithTitleI -> """
Hello ${citizen.name.getFullName()},
diff --git a/src/main/kotlin/fr/dcproject/component/opinion/OpinionAccessControl.kt b/src/main/kotlin/fr/dcproject/component/opinion/OpinionAccessControl.kt
index a55d908..68068fc 100644
--- a/src/main/kotlin/fr/dcproject/component/opinion/OpinionAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/opinion/OpinionAccessControl.kt
@@ -1,12 +1,12 @@
package fr.dcproject.component.opinion
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
import fr.dcproject.component.citizen.CitizenI
import fr.dcproject.component.opinion.entity.OpinionI
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityDeletedAt
class OpinionAccessControl : AccessControl() {
@@ -17,21 +17,21 @@ class OpinionAccessControl : AccessControl() {
val target = subject.target
return when {
citizen == null -> denied("You must be connected to make an opinion", "opinion.create.notConnected")
- target is EntityDeletedAt && target.isDeleted() -> denied("You cannot make opinion on deleted target", "opinion.create.deletedTarget")
+ target is DeletedAt && target.isDeleted() -> denied("You cannot make opinion on deleted target", "opinion.create.deletedTarget")
else -> granted()
}
}
- fun , C : CitizenI> canView(subjects: SS, citizen: CitizenI?): AccessResponse where S : OpinionI, S : EntityCreatedBy =
+ fun , C : CitizenI> canView(subjects: SS, citizen: CitizenI?): AccessResponse where S : OpinionI, S : CreatedBy =
canAll(subjects) { canView(it, citizen) }
- fun canView(subject: S, citizen: CitizenI?): AccessResponse where S : OpinionI, S : EntityCreatedBy = when {
+ fun canView(subject: S, citizen: CitizenI?): AccessResponse where S : OpinionI, S : CreatedBy = when {
citizen == null -> denied("You must be connected to delete opinion", "opinion.delete.notConnected")
subject.createdBy.id != citizen.id -> denied("You cannot view opinions of other citizen", "opinion.view.otherCitizen")
else -> granted()
}
- fun canDelete(subject: S, citizen: CitizenI?): AccessResponse where S : EntityCreatedBy, S : OpinionI = when {
+ fun canDelete(subject: S, citizen: CitizenI?): AccessResponse where S : CreatedBy, S : OpinionI = when {
citizen == null -> denied("You must be connected to delete opinion", "opinion.delete.notConnected")
subject.createdBy.id != citizen.id -> denied("You can only delete your opinions", "opinion.delete.notYours")
else -> granted()
diff --git a/src/main/kotlin/fr/dcproject/component/opinion/entity/Opinion.kt b/src/main/kotlin/fr/dcproject/component/opinion/entity/Opinion.kt
index da8bf86..7493bd6 100644
--- a/src/main/kotlin/fr/dcproject/component/opinion/entity/Opinion.kt
+++ b/src/main/kotlin/fr/dcproject/component/opinion/entity/Opinion.kt
@@ -1,5 +1,8 @@
package fr.dcproject.component.opinion.entity
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.ExtraI
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.entity.TargetI
@@ -9,11 +12,6 @@ import fr.dcproject.component.citizen.CitizenBasic
import fr.dcproject.component.citizen.CitizenBasicI
import fr.dcproject.component.citizen.CitizenI
import fr.dcproject.component.citizen.CitizenRef
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
@Deprecated("")
@@ -24,8 +22,8 @@ open class Opinion(
val choice: OpinionChoice
) : OpinionRef(id),
ExtraI,
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityCreatedBy by EntityCreatedByImp(createdBy) {
+ CreatedAt by CreatedAt.Imp(),
+ CreatedBy by CreatedBy.Imp(createdBy) {
fun getName(): String = choice.name
}
@@ -45,10 +43,10 @@ data class OpinionForUpdate(
override val createdBy: CitizenRef
) : OpinionRef(id),
HasTarget,
- EntityCreatedBy by EntityCreatedByImp(createdBy)
+ CreatedBy by CreatedBy.Imp(createdBy)
open class OpinionRef(
override val id: UUID
) : OpinionI, TargetRef(id)
-interface OpinionI : UuidEntityI
+interface OpinionI : EntityI
diff --git a/src/main/kotlin/fr/dcproject/component/opinion/entity/OpinionChoice.kt b/src/main/kotlin/fr/dcproject/component/opinion/entity/OpinionChoice.kt
index 54ad0ae..ef22582 100644
--- a/src/main/kotlin/fr/dcproject/component/opinion/entity/OpinionChoice.kt
+++ b/src/main/kotlin/fr/dcproject/component/opinion/entity/OpinionChoice.kt
@@ -1,11 +1,9 @@
package fr.dcproject.component.opinion.entity
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityI
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.DeletedAt
+import fr.dcproject.common.entity.Entity
+import fr.dcproject.common.entity.EntityI
import java.util.UUID
class OpinionChoice(
@@ -13,12 +11,12 @@ class OpinionChoice(
val name: String,
val target: List?
) : OpinionChoiceRef(id),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityDeletedAt by EntityDeletedAtImp()
+ CreatedAt by CreatedAt.Imp(),
+ DeletedAt by DeletedAt.Imp()
open class OpinionChoiceRef(
id: UUID?
) : OpinionChoiceI,
- UuidEntity(id ?: UUID.randomUUID())
+ Entity(id ?: UUID.randomUUID())
-interface OpinionChoiceI : UuidEntityI
+interface OpinionChoiceI : EntityI
diff --git a/src/main/kotlin/fr/dcproject/component/views/entity/ViewAggregation.kt b/src/main/kotlin/fr/dcproject/component/views/entity/ViewAggregation.kt
index 36019ab..f9e5f95 100644
--- a/src/main/kotlin/fr/dcproject/component/views/entity/ViewAggregation.kt
+++ b/src/main/kotlin/fr/dcproject/component/views/entity/ViewAggregation.kt
@@ -1,13 +1,12 @@
package fr.dcproject.component.views.entity
+import fr.dcproject.common.entity.UpdatedAt
import fr.postgresjson.entity.EntityI
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
class ViewAggregation(
val total: Int,
val unique: Int
) : EntityI,
- EntityUpdatedAt by EntityUpdatedAtImp() {
+ UpdatedAt by UpdatedAt.Imp() {
constructor() : this(0, 0)
}
diff --git a/src/main/kotlin/fr/dcproject/component/vote/VoteAccessControl.kt b/src/main/kotlin/fr/dcproject/component/vote/VoteAccessControl.kt
index ead8566..4a9c800 100644
--- a/src/main/kotlin/fr/dcproject/component/vote/VoteAccessControl.kt
+++ b/src/main/kotlin/fr/dcproject/component/vote/VoteAccessControl.kt
@@ -1,15 +1,15 @@
package fr.dcproject.component.vote
+import fr.dcproject.common.entity.DeletedAt
import fr.dcproject.common.entity.TargetI
import fr.dcproject.common.security.AccessControl
import fr.dcproject.common.security.AccessResponse
import fr.dcproject.component.citizen.CitizenI
import fr.dcproject.component.vote.entity.VoteForUpdateI
-import fr.postgresjson.entity.EntityDeletedAt
import fr.dcproject.component.vote.entity.Vote as VoteEntity
class VoteAccessControl : AccessControl() {
- fun canCreate(subject: VoteForUpdateI, citizen: CitizenI?): AccessResponse where S : EntityDeletedAt, S : TargetI = when {
+ fun canCreate(subject: VoteForUpdateI, citizen: CitizenI?): AccessResponse where S : DeletedAt, S : TargetI = when {
citizen == null -> denied("You must be connected for vote", "vote.create.connected")
subject.target.isDeleted() -> denied("You cannot vote on deleted target", "vote.create.isDeleted")
else -> granted()
diff --git a/src/main/kotlin/fr/dcproject/component/vote/entity/Vote.kt b/src/main/kotlin/fr/dcproject/component/vote/entity/Vote.kt
index 5d2a1a8..229c5c2 100644
--- a/src/main/kotlin/fr/dcproject/component/vote/entity/Vote.kt
+++ b/src/main/kotlin/fr/dcproject/component/vote/entity/Vote.kt
@@ -1,18 +1,15 @@
package fr.dcproject.component.vote.entity
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.EntityI
import fr.dcproject.common.entity.ExtraI
import fr.dcproject.common.entity.HasTarget
import fr.dcproject.common.entity.TargetI
+import fr.dcproject.common.entity.UpdatedAt
import fr.dcproject.component.citizen.CitizenBasic
import fr.dcproject.component.citizen.CitizenBasicI
import fr.dcproject.component.citizen.CitizenI
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
-import fr.postgresjson.entity.UuidEntityI
import java.util.UUID
@Deprecated("")
@@ -24,9 +21,9 @@ class Vote(
var anonymous: Boolean = true
) : ExtraI,
VoteRef(id),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityCreatedBy by EntityCreatedByImp(createdBy),
- EntityUpdatedAt by EntityUpdatedAtImp() {
+ CreatedAt by CreatedAt.Imp(),
+ CreatedBy by CreatedBy.Imp(createdBy),
+ UpdatedAt by UpdatedAt.Imp() {
init {
if (note > 1 && note < -1) {
error("note must be 1, 0 or -1")
@@ -41,9 +38,9 @@ class VoteForUpdate(
override val createdBy: C
) : VoteRef(id),
VoteForUpdateI,
- EntityCreatedBy by EntityCreatedByImp(createdBy)
+ CreatedBy by CreatedBy.Imp(createdBy)
-interface VoteForUpdateI : VoteI, HasTarget, EntityCreatedBy {
+interface VoteForUpdateI : VoteI, HasTarget, CreatedBy {
override val id: UUID
val note: Int
override val target: T
@@ -54,4 +51,4 @@ open class VoteRef(
override val id: UUID
) : VoteI
-interface VoteI : UuidEntityI
+interface VoteI : EntityI
diff --git a/src/main/kotlin/fr/dcproject/component/vote/entity/VoteAggregation.kt b/src/main/kotlin/fr/dcproject/component/vote/entity/VoteAggregation.kt
index 52930c2..fc24668 100644
--- a/src/main/kotlin/fr/dcproject/component/vote/entity/VoteAggregation.kt
+++ b/src/main/kotlin/fr/dcproject/component/vote/entity/VoteAggregation.kt
@@ -1,8 +1,6 @@
package fr.dcproject.component.vote.entity
-import fr.postgresjson.entity.EntityI
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
+import fr.dcproject.common.entity.UpdatedAt
class VoteAggregation(
val up: Int,
@@ -10,7 +8,7 @@ class VoteAggregation(
val down: Int,
val total: Int,
val score: Int
-) : EntityI,
- EntityUpdatedAt by EntityUpdatedAtImp() {
+) : fr.postgresjson.entity.EntityI,
+ UpdatedAt by UpdatedAt.Imp() {
constructor() : this(0, 0, 0, 0, 0)
}
diff --git a/src/main/kotlin/fr/dcproject/component/workgroup/Workgroup.kt b/src/main/kotlin/fr/dcproject/component/workgroup/Workgroup.kt
index b7810b2..44578df 100644
--- a/src/main/kotlin/fr/dcproject/component/workgroup/Workgroup.kt
+++ b/src/main/kotlin/fr/dcproject/component/workgroup/Workgroup.kt
@@ -1,22 +1,18 @@
package fr.dcproject.component.workgroup
+import fr.dcproject.common.entity.CreatedAt
+import fr.dcproject.common.entity.CreatedBy
+import fr.dcproject.common.entity.DeletedAt
+import fr.dcproject.common.entity.Entity
+import fr.dcproject.common.entity.EntityI
+import fr.dcproject.common.entity.UpdatedAt
import fr.dcproject.component.auth.UserI
import fr.dcproject.component.citizen.CitizenBasicI
import fr.dcproject.component.citizen.CitizenI
import fr.dcproject.component.citizen.CitizenWithUserI
import fr.dcproject.component.workgroup.WorkgroupWithMembersI.Member
import fr.dcproject.component.workgroup.WorkgroupWithMembersI.Member.Role
-import fr.postgresjson.entity.EntityCreatedAt
-import fr.postgresjson.entity.EntityCreatedAtImp
-import fr.postgresjson.entity.EntityCreatedBy
-import fr.postgresjson.entity.EntityCreatedByImp
-import fr.postgresjson.entity.EntityDeletedAt
-import fr.postgresjson.entity.EntityDeletedAtImp
-import fr.postgresjson.entity.EntityI
-import fr.postgresjson.entity.EntityUpdatedAt
-import fr.postgresjson.entity.EntityUpdatedAtImp
-import fr.postgresjson.entity.UuidEntity
-import fr.postgresjson.entity.UuidEntityI
+import fr.postgresjson.entity.Serializable
import java.util.UUID
@Deprecated("")
@@ -37,8 +33,8 @@ data class Workgroup (
anonymous,
createdBy
),
- EntityCreatedAt by EntityCreatedAtImp(),
- EntityUpdatedAt by EntityUpdatedAtImp()
+ CreatedAt by CreatedAt.Imp(),
+ UpdatedAt by UpdatedAt.Imp()
@Deprecated("")
open class WorkgroupSimple(
@@ -49,22 +45,22 @@ open class WorkgroupSimple(
open var anonymous: Boolean = true,
createdBy: Z
) : WorkgroupRef(id),
- EntityCreatedBy by EntityCreatedByImp(createdBy),
- EntityDeletedAt by EntityDeletedAtImp()
+ CreatedBy by CreatedBy.Imp(createdBy),
+ DeletedAt by DeletedAt.Imp()
class WorkgroupCart(
override val id: UUID,
override val name: String
) : WorkgroupCartI
-interface WorkgroupCartI : UuidEntityI {
+interface WorkgroupCartI : EntityI {
val name: String
}
open class WorkgroupRef(
id: UUID? = null
-) : UuidEntity(id ?: UUID.randomUUID()), WorkgroupI
+) : Entity(id ?: UUID.randomUUID()), WorkgroupI
-interface WorkgroupWithAuthI : WorkgroupWithMembersI, EntityCreatedBy, EntityDeletedAt {
+interface WorkgroupWithAuthI : WorkgroupWithMembersI, CreatedBy, DeletedAt {
val anonymous: Boolean
fun isMember(user: UserI): Boolean = members.isMember(user)
@@ -83,7 +79,7 @@ interface WorkgroupWithMembersI : WorkgroupI {
class Member (
val citizen: C,
val roles: List = emptyList()
- ) : EntityI {
+ ) : fr.postgresjson.entity.EntityI {
enum class Role {
MASTER,
MANAGER,
@@ -113,4 +109,4 @@ fun List>.getRoles(user: UserI): List =
fun List>.getRoles(citizen: CitizenI): List =
firstOrNull { it.citizen.id == citizen.id }?.roles ?: emptyList()
-interface WorkgroupI : UuidEntityI
+interface WorkgroupI : EntityI