EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
ClearingPointRepository.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.repository;
17 
18 import org.springframework.data.neo4j.annotation.Query;
19 import org.springframework.data.neo4j.annotation.QueryType;
20 import org.springframework.data.neo4j.repository.GraphRepository;
21 import org.springframework.data.repository.query.Param;
22 
26 
27 public interface ClearingPointRepository extends GraphRepository<ClearingPoint> {
28 
29  @Query(value = "all = g.v(market).in('MARKET_POINT').filter{it.time==tick && it.forecast==forecast}; if(all.hasNext()){return all.next();} else{return []}", type = QueryType.Gremlin)
30  ClearingPoint findClearingPointForMarketAndTime(@Param("market") DecarbonizationMarket market,
31  @Param("tick") long tick, @Param("forecast") boolean forecast);
32 
33  // @Query("start market=node({market}) match (market)<-[:MARKET_POINT]-(point) where (point.time >= {timeFrom}) and (point.time <= {timeTo}) return avg(point.price)")
34  // double
35  // calculateAverageClearingPriceForMarketAndTimeRange(@Param("market")
36  // DecarbonizationMarket market,
37  // @Param("timeFrom") long timeFrom, @Param("timeTo") long timeTo);
38 
39  @Query(value = "g.v(market).in('MARKET_POINT').filter{(it.time>=timeFrom) && (it.time<=timeTo) && it.forecast==forecast}.price.mean()", type = QueryType.Gremlin)
40  double calculateAverageClearingPriceForMarketAndTimeRange(@Param("market") DecarbonizationMarket market,
41  @Param("timeFrom") long timeFrom, @Param("timeTo") long timeTo, @Param("forecast") boolean forecast);
42 
43  @Query(value = "g.v(substance).in('SUBSTANCE_MARKET').in('MARKET_POINT').propertyFilter('time', FilterPipe.Filter.GREATER_THAN_EQUAL, timeFrom).propertyFilter('time', FilterPipe.Filter.LESS_THAN_EQUAL, timeTo).propertyFilter('forecast',FilterPipe.Filter.EQUAL,forecast)", type = QueryType.Gremlin)
44  Iterable<ClearingPoint> findAllClearingPointsForSubstanceAndTimeRange(@Param("substance") Substance substance,
45  @Param("timeFrom") long timeFrom, @Param("timeTo") long timeTo, @Param("forecast") boolean forecast);
46 
47  @Query(value = "g.v(market).in('MARKET_POINT').propertyFilter('time', FilterPipe.Filter.GREATER_THAN_EQUAL, timeFrom).propertyFilter('time', FilterPipe.Filter.LESS_THAN_EQUAL, timeTo).propertyFilter('forecast',FilterPipe.Filter.EQUAL,forecast)", type = QueryType.Gremlin)
48  Iterable<ClearingPoint> findAllClearingPointsForMarketAndTimeRange(@Param("market") DecarbonizationMarket market,
49  @Param("timeFrom") long timeFrom, @Param("timeTo") long timeTo, @Param("forecast") boolean forecast);
50 
51 
52  @Query(value = "g.v(substance).in('SUBSTANCE_MARKET').propertyFilter('__type__', FilterPipe.Filter.EQUAL, 'emlab.gen.domain.market.CommodityMarket').in('MARKET_POINT').propertyFilter('time', FilterPipe.Filter.GREATER_THAN_EQUAL, timeFrom).propertyFilter('time', FilterPipe.Filter.LESS_THAN_EQUAL, timeTo).propertyFilter('forecast',FilterPipe.Filter.EQUAL,forecast)", type = QueryType.Gremlin)
53  Iterable<ClearingPoint> findAllClearingPointsForSubstanceTradedOnCommodityMarkesAndTimeRange(@Param("substance") Substance substance,
54  @Param("timeFrom") long timeFrom, @Param("timeTo") long timeTo,
55  @Param("forecast") boolean forecast);
56 
57 }