EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
BidRepository.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 import org.springframework.stereotype.Repository;
23 
26 
34 @Repository
35 public interface BidRepository extends GraphRepository<Bid> {
36 
44  // @Query(value =
45  // "g.v(market).in('BIDDINGMARKET').filter{it.time == time}.filter{it.supplyBid == false}",
46  // type = QueryType.Gremlin)
47  // public Iterable<Bid> findDemandBidsForMarketForTime(@Param("market")
48  // DecarbonizationMarket market, @Param("time") long time);
49 
50  @Query("START bid=node:__types__(\"className:emlab.gen.domain.market.Bid\") WHERE (bid.time={time}) RETURN bid")
51  Iterable<Bid> findAllBidsForForTime(@Param("time") long time);
52 
53  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) RETURN bid ORDER BY bid.price desc")
54  Iterable<Bid> findDemandBidsForMarketForTime(@Param("market") DecarbonizationMarket market, @Param("time") long time);
55 
56  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) and (bid.status>=2) RETURN bid")
57  Iterable<Bid> findAllAcceptedDemandBidsForMarketForTime(@Param("market") DecarbonizationMarket market,
58  @Param("time") long time);
59 
68  // @Query(value =
69  // "g.v(market).in('BIDDINGMARKET').filter{it.time == time}.filter{it.supplyBid == true}",
70  // type = QueryType.Gremlin)
71  // public Iterable<Bid> findOffersForMarketForTime(@Param("market")
72  // DecarbonizationMarket market, @Param("time") long time);
73 
74  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) RETURN bid ORDER BY bid.price")
75  Iterable<Bid> findOffersForMarketForTime(@Param("market") DecarbonizationMarket market, @Param("time") long time);
76 
77  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) and (bid.status>=2) RETURN bid")
78  Iterable<Bid> findAllAcceptedOffersForMarketForTime(@Param("market") DecarbonizationMarket market,
79  @Param("time") long time);
80 
91  @Query(value = "g.v(market).in('BIDDINGMARKET').filter{it.time == time}.filter{it.supplyBid == isSupply}", type = QueryType.Gremlin)
92  Iterable<Bid> getBidsForMarketForTime(@Param("market") DecarbonizationMarket market, @Param("time") long time,
93  @Param("isSupply") boolean isSupply);
94 
95  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) and (bid.price <= {price}) RETURN bid ORDER BY bid.price")
96  Iterable<Bid> findOffersForMarketForTimeBelowPrice(@Param("market") DecarbonizationMarket market,
97  @Param("time") long time, @Param("price") double price);
98 
108  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) and (bid.price >= {price}) RETURN bid ORDER BY bid.price desc")
109  Iterable<Bid> findDemandBidsForMarketForTimeAbovePrice(@Param("market") DecarbonizationMarket market,
110  @Param("time") long time, @Param("price") double price);
111 
112  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) and (bid.price >= {price}) RETURN sum(bid.amount)")
113  double calculateDemandBidsForMarketForTimeForPrice(@Param("market") DecarbonizationMarket market,
114  @Param("time") long time, @Param("price") double price);
115 
116  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) and (bid.price = {price}) RETURN bid ORDER BY bid.price desc")
117  Iterable<Bid> findDemandBidsForMarketForTimeForPrice(@Param("market") DecarbonizationMarket market,
118  @Param("time") long time, @Param("price") double price);
119 
120  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) and (bid.price = {price}) RETURN bid ORDER BY bid.price desc")
121  Iterable<Bid> findOffersForMarketForTimeForPrice(@Param("market") DecarbonizationMarket market,
122  @Param("time") long time, @Param("price") double price);
123 
124  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) and (bid.price = {price}) RETURN sum(bid.amount)")
125  double calculateOffersForMarketForTimeForPrice(@Param("market") DecarbonizationMarket market,
126  @Param("time") long time, @Param("price") double price);
127 
128  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) RETURN sum(bid.amount)")
129  double calculateTotalDemandForMarketForTime(@Param("market") DecarbonizationMarket market, @Param("time") long time);
130 
131  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=false) and (bid.price >= {price}) RETURN sum(bid.amount)")
132  double calculateTotalDemandForMarketForTimeForPrice(@Param("market") DecarbonizationMarket market,
133  @Param("time") long time, @Param("price") double price);
134 
135  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) RETURN sum(bid.amount)")
136  double calculateTotalSupplyForMarketForTime(@Param("market") DecarbonizationMarket market, @Param("time") long time);
137 
138  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) RETURN max(bid.price)")
139  double calculateTotalSupplyPriceForMarketForTime(@Param("market") DecarbonizationMarket market,
140  @Param("time") long time);
141 
142  @Query("START market=node({market}) MATCH (market)<-[:BIDDINGMARKET]-(bid) WHERE (bid.time = {time}) and (bid.supplyBid=true) RETURN min(bid.price)")
143  double calculateMinimumSupplyPriceForMarketForTime(@Param("market") DecarbonizationMarket market,
144  @Param("time") long time);
145 
146 }
Iterable< Bid > findAllBidsForForTime(@Param("time") long time)
Iterable< Bid > findOffersForMarketForTime(@Param("market") DecarbonizationMarket market,@Param("time") long time)
Iterable< Bid > getBidsForMarketForTime(@Param("market") DecarbonizationMarket market,@Param("time") long time,@Param("isSupply") boolean isSupply)
Iterable< Bid > findDemandBidsForMarketForTimeAbovePrice(@Param("market") DecarbonizationMarket market,@Param("time") long time,@Param("price") double price)