<commit_before>package org.innovateuk.ifs.management.competition.previous.viewmodel;

import org.innovateuk.ifs.application.resource.PreviousApplicationResource;
import org.innovateuk.ifs.competition.resource.CompetitionCompletionStage;
import org.innovateuk.ifs.competition.resource.CompetitionResource;
import org.innovateuk.ifs.internal.InternalProjectSetupRow;
import org.innovateuk.ifs.status.viewmodel.BaseCompetitionStatusTableViewModel;

import java.time.ZonedDateTime;
import java.util.List;

import static org.innovateuk.ifs.util.TimeZoneUtil.toUkTimeZone;

public class PreviousCompetitionViewModel extends BaseCompetitionStatusTableViewModel {

    private final String competitionType;
    private final String fundingBody;
    private final ZonedDateTime applicationDeadline;
    private final String innovationSector;
    private final boolean competitionCanHaveProjects;
    private final List<PreviousApplicationResource> applications;

    public PreviousCompetitionViewModel(CompetitionResource competition,
                                        List<PreviousApplicationResource> applications,
                                        List<InternalProjectSetupRow> rows,
                                        boolean hasProjectFinanceRole,
                                        boolean ifsAdmin,
                                        boolean externalFinanceUser) {
        super(competition, rows, hasProjectFinanceRole, externalFinanceUser, ifsAdmin);
        this.competitionType = competition.getCompetitionTypeName();
        this.fundingBody = "Innovate UK";
        this.applicationDeadline = toUkTimeZone(competition.getEndDate());
        this.innovationSector = competition.getInnovationSectorName();
        this.competitionCanHaveProjects = CompetitionCompletionStage.PROJECT_SETUP.equals(competition.getCompletionStage());
        this.applications = applications;
    }

    @Override
    public String getEmptyTableText() {
        return "There are currently no completed projects in this competition.";
    }

    public String getCompetitionType() {
        return competitionType;
    }

    public String getFundingBody() {
        return fundingBody;
    }

    public ZonedDateTime getApplicationDeadline() {
        return applicationDeadline;
    }

    public String getInnovationSector() {
        return innovationSector;
    }

    public List<PreviousApplicationResource> getApplications() {
        return applications;
    }

    public boolean isCompetitionCanHaveProjects() {
        return competitionCanHaveProjects;
    }
}<commit_msg>IFS-8770: Fix previous project view model<commit_after>package org.innovateuk.ifs.management.competition.previous.viewmodel;

import org.innovateuk.ifs.application.resource.PreviousApplicationResource;
import org.innovateuk.ifs.competition.resource.CompetitionCompletionStage;
import org.innovateuk.ifs.competition.resource.CompetitionResource;
import org.innovateuk.ifs.internal.InternalProjectSetupRow;
import org.innovateuk.ifs.project.internal.ProjectSetupStage;
import org.innovateuk.ifs.status.viewmodel.BaseCompetitionStatusTableViewModel;

import java.time.ZonedDateTime;
import java.util.List;

import static org.innovateuk.ifs.util.TimeZoneUtil.toUkTimeZone;

public class PreviousCompetitionViewModel extends BaseCompetitionStatusTableViewModel {

    private final String competitionType;
    private final String fundingBody;
    private final ZonedDateTime applicationDeadline;
    private final String innovationSector;
    private final boolean competitionCanHaveProjects;
    private final List<PreviousApplicationResource> applications;
    private int columnsBeforeBankDetails;
    private int columnsAfterBankDetails;

    public PreviousCompetitionViewModel(CompetitionResource competition,
                                        List<PreviousApplicationResource> applications,
                                        List<InternalProjectSetupRow> rows,
                                        boolean hasProjectFinanceRole,
                                        boolean ifsAdmin,
                                        boolean externalFinanceUser) {
        super(competition, rows, hasProjectFinanceRole, externalFinanceUser, ifsAdmin);
        this.competitionType = competition.getCompetitionTypeName();
        this.fundingBody = "Innovate UK";
        this.applicationDeadline = toUkTimeZone(competition.getEndDate());
        this.innovationSector = competition.getInnovationSectorName();
        this.competitionCanHaveProjects = CompetitionCompletionStage.PROJECT_SETUP.equals(competition.getCompletionStage());
        this.applications = applications;

        resolveBankDetailsTableColumns();
    }

    private void resolveBankDetailsTableColumns() {
        int bankDetailsIndex = this.getColumns().indexOf(ProjectSetupStage.BANK_DETAILS) + 1;
        this.columnsBeforeBankDetails = bankDetailsIndex;
        this.columnsAfterBankDetails = this.getColumns().size() - bankDetailsIndex;
    }

    @Override
    public String getEmptyTableText() {
        return "There are currently no completed projects in this competition.";
    }

    public String getCompetitionType() {
        return competitionType;
    }

    public String getFundingBody() {
        return fundingBody;
    }

    public ZonedDateTime getApplicationDeadline() {
        return applicationDeadline;
    }

    public String getInnovationSector() {
        return innovationSector;
    }

    public List<PreviousApplicationResource> getApplications() {
        return applications;
    }

    public boolean isCompetitionCanHaveProjects() {
        return competitionCanHaveProjects;
    }

    public int getColumnsBeforeBankDetails() {
        return columnsBeforeBankDetails;
    }

    public int getColumnsAfterBankDetails() {
        return columnsAfterBankDetails;
    }
}
{'fraction_non_alphanumeric': 0.06280767272109998, 'fraction_numerical': 0.0008487523340689187, 'mean_word_length': 3.2819767441860463, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7596307', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1368, 'n_words': 282}