com.farao_community.farao.cse.adapter.app.CseAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gridcapa-cse-adapter-app Show documentation
Show all versions of gridcapa-cse-adapter-app Show documentation
Application that turns a RabbitMQ request from a task to a CSE request
The newest version!
/*
* Copyright (c) 2024, 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.cse.adapter.app;
import com.farao_community.farao.gridcapa.task_manager.api.ProcessRunDto;
import com.farao_community.farao.gridcapa.task_manager.api.TaskDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* @author Joris Mancini {@literal }
*/
public interface CseAdapter {
Logger LOGGER = LoggerFactory.getLogger(CseAdapter.class);
void runAsync(TaskDto taskDto);
static String getCurrentRunId(TaskDto taskDto) {
List runHistory = taskDto.getRunHistory();
if (runHistory == null || runHistory.isEmpty()) {
LOGGER.warn("Failed to handle manual run request on timestamp {} because it has no run history", taskDto.getTimestamp());
throw new CseAdapterException("Failed to handle manual run request on timestamp because it has no run history");
}
if (runHistory.size() > 1) {
runHistory.sort((o1, o2) -> o2.getExecutionDate().compareTo(o1.getExecutionDate()));
}
return runHistory.get(0).getId().toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy