16 package emlab.gen.role.market;
18 import java.util.ArrayList;
19 import java.util.List;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.transaction.annotation.Transactional;
24 import agentspring.role.Role;
25 import agentspring.role.RoleComponent;
32 import emlab.gen.role.AbstractEnergyProducerRole;
45 AbstractEnergyProducerRole implements Role<EnergyProducer> {
55 List<LongTermContract> ltcsToBeReplaced =
new ArrayList<LongTermContract>();
58 .findLongTermContractsForEnergyProducerActiveAtTime(producer,
62 if (ltc.getFinish() > getCurrentTick()) {
65 if (!ltc.getUnderlyingPowerPlant().isOperational(
68 "Powerplant {} underlying ltc {} is dismantled, contract should be reassigned",
69 ltc.getUnderlyingPowerPlant(), ltc);
70 ltcsToBeReplaced.add(ltc);
77 int nrOfLtcsToBeReplaced = ltcsToBeReplaced.size();
82 if (nrOfLtcsToBeReplaced > 0) {
83 for (
PowerPlant plant : reps.powerPlantRepository
88 if (index < nrOfLtcsToBeReplaced) {
89 if (reps.contractRepository
90 .findLongTermContractForPowerPlantActiveAtTime(
91 plant, getCurrentTick()) == null) {
92 if (plant.isWithinTechnicalLifetime(getCurrentTick())) {
94 "Powerplant {} underlying ltc has been replaced by plant {}",
95 ltcsToBeReplaced.get(index)
96 .getUnderlyingPowerPlant(), plant);
97 reps.contractRepository
98 .reassignLongTermContractToNewPowerPlant(
99 ltcsToBeReplaced.get(index), plant);
106 "Have replaced {} long-term contracts out of {} that needed to be replaced",
107 index, nrOfLtcsToBeReplaced);
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)