package com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file;

import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FileModel {

    @JsonProperty("fileId")
    private String id;
    private String filename;
    private ProcessingStatus processingStatus;
    private WorkflowStatus workflowStatus;
    private int numberOfPages;
    private Long fileSize;
    private OffsetDateTime added;
    private OffsetDateTime lastUpdated;
    private OffsetDateTime deleted;
    private OffsetDateTime lastProcessed;
    private OffsetDateTime lastIndexed;
    private OffsetDateTime lastLayoutProcessed;
    private OffsetDateTime lastManualChangeDate;
    private int numberOfAnalyses;
    private String assignee;
    private String lastReviewer;
    private String lastApprover;
    private boolean hasRedactions;
    private boolean hasHints;
    private boolean hasSuggestions;
    private boolean hasImages;
    private boolean hasUpdates;
    private boolean reanalysisRequired;
    private boolean fullAnalysisRequired;
    private String uploader;
    private long dictionaryVersion;
    private long rulesVersion;
    private long componentRulesVersion;
    private long dossierDictionaryVersion;
    private long legalBasisVersion;
    private OffsetDateTime approvalDate;
    private OffsetDateTime lastUploaded;
    private long analysisDuration;
    private OffsetDateTime ocrStartTime;
    private Integer numberOfPagesToOCR;
    private Integer numberOfOCRedPages;
    private OffsetDateTime ocrEndTime;
    private boolean hasAnnotationComments;
    private boolean excluded;
    private boolean excludedFromAutomaticAnalysis;
    private OffsetDateTime hardDeletedTime;
    private OffsetDateTime lastFileAttributeChange;
    private int analysisVersion;
    private Set<Integer> excludedPages = new HashSet<>();
    private Map<String, String> fileAttributes = new HashMap<>();
    private String dossierId;
    private boolean dossierArchived;
    private String dossierTemplateId;
    private String dossierStatusId;
    private OffsetDateTime redactionModificationDate;
    private OffsetDateTime fileManipulationDate;
    private boolean hasHighlights;
    private FileErrorInfo fileErrorInfo;


    public long getFileSize() {

        return this.fileSize != null ? this.fileSize : 0L;
    }


    public boolean isAnalysisRequired() {

        return this.fullAnalysisRequired || this.reanalysisRequired;
    }


    public boolean isSoftOrHardDeleted() {

        return deleted != null || hardDeletedTime != null;
    }

}
