UploadTask.kt

/*
  Copyright (C) 2026 Sber

  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 org.archtool.archloader.service.dto

import com.github.f4b6a3.uuid.UuidCreator
import java.nio.file.Path
import java.time.LocalDateTime
import java.util.UUID

data class UploadTask(
    val id: UUID = UuidCreator.getTimeOrderedEpoch(),
    val traceHeaders: Map<String, String>?,
    val targetDir: Path,
    val incomeFile: FileData,
    var gitZipFile: FileData? = null,
    val metaData: ArchZipMeta,
    val repoInfo: RepoInfo,
    val timing: TaskTiming,
    var filesDeleted: Boolean = false,
    var status: Status = Status.INCOME_NEW,
    var statusDesc: String? = null,
    var userData: UserData,
) {
    enum class Status {
        INCOME_NEW, INCOME_IN_PROGRESS, GIT_SEND_NEW, GIT_SEND_IN_PROGRESS, FINISH, ERROR
    }

    data class TaskTiming(
        var incomeTime: LocalDateTime,
        var parsingEndTime: LocalDateTime? = null,
        var gasSendTime: LocalDateTime? = null,
        var completionTime: LocalDateTime? = null,
        var deleteTaskAfter: LocalDateTime,
    )

    data class UserData(
        val sub: String,
        val name: String,
        val surname: String,
        val email: String?,
    )

    data class FileData(
        val path: Path,
        var checksum: String,
    )
}