EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
ElectricitySpotMarketClearingRule.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.validation;
17 
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.data.neo4j.support.Neo4jTemplate;
20 
21 import agentspring.validation.AbstractValidationRule;
22 import agentspring.validation.ValidationException;
23 import agentspring.validation.ValidationRule;
29 
30 public class ElectricitySpotMarketClearingRule extends AbstractValidationRule implements ValidationRule {
31  @Autowired
32  ClearingPointRepositoryOld clearingPointRepositoryOld;
33 
34  @Autowired
35  Neo4jTemplate template;
36 
37  @Override
38  public void validate() {
39  for (ElectricitySpotMarket market : template.findAll(ElectricitySpotMarket.class)) {
40  for (SegmentLoad segmentload : market.getLoadDurationCurve()) {
41  Segment segment = segmentload.getSegment();
42  ClearingPoint point = clearingPointRepositoryOld.findClearingPointForSegmentAndTime(segment,
43  getCurrentTick(), false);
44 
45  if (point == null) {
46  throw new ValidationException(market.toString() + " " + segment.toString() + " failed to clear");
47  }
48  }
49  }
50  }
51 
52 }