-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Batch operation, stores activity
- Loading branch information
Showing
15 changed files
with
88 additions
and
48 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
23 changes: 4 additions & 19 deletions
23
backend/data/src/main/kotlin/io/tolgee/activity/ActivityHolder.kt
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 |
---|---|---|
@@ -1,44 +1,29 @@ | ||
package io.tolgee.activity | ||
|
||
import io.tolgee.activity.data.ActivityType | ||
import io.tolgee.events.OnProjectActivityEvent | ||
import io.tolgee.model.EntityWithId | ||
import io.tolgee.model.activity.ActivityModifiedEntity | ||
import io.tolgee.model.activity.ActivityRevision | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.context.ApplicationContext | ||
import javax.annotation.PreDestroy | ||
import kotlin.reflect.KClass | ||
|
||
open class ActivityHolder( | ||
private val applicationContext: ApplicationContext | ||
) { | ||
open class ActivityHolder { | ||
open var activity: ActivityType? = null | ||
|
||
open var meta: MutableMap<String, Any?> = mutableMapOf() | ||
|
||
open var activityRevision: ActivityRevision? = null | ||
|
||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
open var modifiedCollections: MutableMap<Pair<EntityWithId, String>, List<Any?>?> = mutableMapOf() | ||
|
||
open var transactionRollbackOnly = false | ||
|
||
open var organizationId: Long? = null | ||
|
||
@PreDestroy | ||
open fun preDestroy() { | ||
if (!transactionRollbackOnly) { | ||
applicationContext.publishEvent(OnProjectActivityEvent(this)) | ||
} | ||
} | ||
|
||
/** | ||
* This field stores all modified entities, it's stored before the transaction is committed | ||
*/ | ||
open var modifiedEntities: | ||
MutableMap< | ||
KClass<out EntityWithId>, MutableMap<Long, ActivityModifiedEntity> | ||
> = mutableMapOf() | ||
ModifiedEntitiesType = mutableMapOf() | ||
} | ||
|
||
typealias ModifiedEntitiesType = MutableMap<KClass<out EntityWithId>, MutableMap<Long, ActivityModifiedEntity>> |
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
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
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
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
10 changes: 6 additions & 4 deletions
10
backend/data/src/main/kotlin/io/tolgee/events/OnProjectActivityEvent.kt
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package io.tolgee.events | ||
|
||
import io.tolgee.activity.ActivityHolder | ||
import org.springframework.context.ApplicationEvent | ||
import io.tolgee.activity.ModifiedEntitiesType | ||
import io.tolgee.model.activity.ActivityRevision | ||
|
||
class OnProjectActivityEvent( | ||
val activityHolder: ActivityHolder, | ||
) : ApplicationEvent(activityHolder) | ||
val activityRevision: ActivityRevision, | ||
val modifiedEntities: ModifiedEntitiesType, | ||
val organizationId: Long? | ||
) |
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
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