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

com.farao_community.farao.gridcapa.task_manager.api.TaskDto Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2021, RTE (http://www.rte-france.com)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.farao_community.farao.gridcapa.task_manager.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author Joris Mancini {@literal }
 */
public class TaskDto {
    private final UUID id;
    private final OffsetDateTime timestamp;
    private final TaskStatus status;
    private final List inputs;
    private final List availableInputs;
    private final List outputs;
    private final List processEvents;
    private final List runHistory;
    private final List parameters;

    @JsonCreator
    public TaskDto(@JsonProperty("id") UUID id,
                   @JsonProperty("timestamp") OffsetDateTime timestamp,
                   @JsonProperty("status") TaskStatus status,
                   @JsonProperty("inputs") List inputs,
                   @JsonProperty("availableInputs") List availableInputs,
                   @JsonProperty("outputs") List outputs,
                   @JsonProperty("processEvents") List processEvents,
                   @JsonProperty("runHistory") List runHistory,
                   @JsonProperty("parameters") List parameters) {
        this.id = id;
        this.timestamp = timestamp;
        this.status = status;
        this.inputs = inputs;
        this.availableInputs = availableInputs;
        this.outputs = outputs;
        this.processEvents = processEvents;
        this.runHistory = runHistory;
        this.parameters = parameters;
    }

    public static TaskDto emptyTask(OffsetDateTime timestamp,
                                    List inputs,
                                    List outputs) {
        return new TaskDto(
                UUID.randomUUID(),
                timestamp,
                TaskStatus.NOT_CREATED,
                inputs.stream().map(ProcessFileDto::emptyProcessFile).toList(),
                List.of(),
                outputs.stream().map(ProcessFileDto::emptyProcessFile).toList(),
                new ArrayList<>(),
                new ArrayList<>(),
                new ArrayList<>());
    }

    public UUID getId() {
        return id;
    }

    public OffsetDateTime getTimestamp() {
        return timestamp;
    }

    public TaskStatus getStatus() {
        return status;
    }

    public List getInputs() {
        return inputs;
    }

    public List getOutputs() {
        return outputs;
    }

    public List getAvailableInputs() {
        return availableInputs;
    }

    public List getProcessEvents() {
        return processEvents;
    }

    public List getRunHistory() {
        return runHistory;
    }

    public List getParameters() {
        return parameters;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy