EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
DismantlePowerPlantPastTechnicalLifetimeRole.java
1 /*******************************************************************************
2  * Copyright 2012 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.role.investment;
17 
18 import org.springframework.beans.factory.annotation.Autowired;
19 
20 import agentspring.role.AbstractRole;
21 import agentspring.role.Role;
22 import agentspring.role.RoleComponent;
26 
37 @RoleComponent
38 public class DismantlePowerPlantPastTechnicalLifetimeRole extends AbstractRole<EnergyProducer> implements Role<EnergyProducer> {
39 
40  @Autowired
41  Reps reps;
42 
43  public void act(EnergyProducer producer) {
44 
45  logger.info("Dismantling plants if passed technical lifetime");
46 
47  // dismantle plants when passed technical lifetime
48  for (PowerPlant plant : reps.powerPlantRepository.findOperationalPowerPlantsByOwner(producer, getCurrentTick())) {
49 
50  int prolongYearsOfDismantlng = producer.getDismantlingProlongingYearsAfterTechnicalLifetime();
51  if (!plant.isWithinTechnicalLifetime(getCurrentTick() + prolongYearsOfDismantlng)) {
52  logger.info(" Dismantling power plant because the technical life time has passed: " + plant);
53  plant.dismantlePowerPlant(getCurrentTick());
54  }
55  }
56  }
57 
58 }
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)