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

ai.timefold.solver.quarkus.jackson.it.TimefoldTestResource Maven / Gradle / Ivy

There is a newer version: 1.15.0
Show newest version
package ai.timefold.solver.quarkus.jackson.it;

import java.util.concurrent.ExecutionException;

import jakarta.inject.Inject;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;

import ai.timefold.solver.core.api.solver.SolverJob;
import ai.timefold.solver.core.api.solver.SolverManager;
import ai.timefold.solver.quarkus.jackson.it.domain.ITestdataPlanningSolution;

@Path("/timefold/test")
public class TimefoldTestResource {

    private final SolverManager solverManager;

    @Inject
    public TimefoldTestResource(SolverManager solverManager) {
        this.solverManager = solverManager;
    }

    @POST
    @Path("/solver-factory")
    public ITestdataPlanningSolution solveWithSolverFactory(ITestdataPlanningSolution problem) {
        SolverJob solverJob = solverManager.solve(1L, problem);
        try {
            return solverJob.getFinalBestSolution();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new IllegalStateException("Solving was interrupted.", e);
        } catch (ExecutionException e) {
            throw new IllegalStateException("Solving failed.", e);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy