All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.openchvote.inspectionclient.writein.tasks.TI1 Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2024 Berner Fachhochschule https://e-voting.bfh.ch
 *
 *  - This program is free software: you can redistribute it and/or modify                           -
 *  - it under the terms of the GNU Affero General Public License as published by                    -
 *  - the Free Software Foundation, either version 3 of the License, or                              -
 *  - (at your option) any later version.                                                            -
 *  -                                                                                                -
 *  - This program is distributed in the hope that it will be useful,                                -
 *  - but WITHOUT ANY WARRANTY; without even the implied warranty of                                 -
 *  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                                   -
 *  - GNU General Public License for more details.                                                   -
 *  -                                                                                                -
 *  - You should have received a copy of the GNU Affero General Public License                       -
 *  - along with this program. If not, see .                           -
 */
package ch.openchvote.inspectionclient.writein.tasks;

import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.common.algorithms.GetInspectionCode;
import ch.openchvote.inspectionclient.writein.PublicData;
import ch.openchvote.protocol.protocols.writein.UsabilityParameters;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.set.IntSet;

@SuppressWarnings("MissingJavadoc")
public final class TI1 {

    static public boolean isReady(PublicData publicData) {
        var s = publicData.get_ES().get().get_SP().get_s();
        return publicData.get_bold_i().arePresent(IntSet.range(1, s));
    }

    static public void
    run(PublicData publicData, AlgorithmService algorithmService) {

        // get usability parameters
        var ES = publicData.get_ES().get();
        var SL = ES.get_SL();
        var UC = ES.get_UC();
        var usabilityParameters = new UsabilityParameters(UC, SL);

        // perform task
        var bold_i = publicData.get_bold_i().mapTo(Vector::of);
        var IC = algorithmService.run(GetInspectionCode.class, usabilityParameters, bold_i);

        // update event data
        publicData.get_IC().set(IC);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy