16 package emlab.gen.repository;
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;
45 @Query(
"START ppdp=node:__types__(\"className:emlab.gen.domain.market.electricity.PowerPlantDispatchPlan\") WHERE (ppdp.time={time} AND ppdp.forecast = {forecast}) RETURN ppdp")
46 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForTime(@Param(
"time")
long time,
47 @Param(
"forecast")
boolean forecast);
49 @Query(value =
"result = g.v(plant).in('POWERPLANT_DISPATCHPLAN').as('x').propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).out('SEGMENT_DISPATCHPLAN').idFilter(segment, FilterPipe.Filter.EQUAL).back('x')", type = QueryType.Gremlin)
50 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlanForPowerPlantForSegmentForTime(@Param(
"plant")
PowerPlant plant,
51 @Param(
"segment")
Segment segment, @Param(
"time")
long time,
52 @Param(
"forecast")
boolean forecast);
54 @Query(value =
"result = g.v(plant).in('POWERPLANT_DISPATCHPLAN').as('x').propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).out('SEGMENT_DISPATCHPLAN').idFilter(segment, FilterPipe.Filter.EQUAL).back('x').propertyFilter('time', FilterPipe.Filter.EQUAL, time); if(!result.hasNext()){return null;} else{return result.next();}", type = QueryType.Gremlin)
56 @Param(
"segment")
Segment segment, @Param(
"time")
long time,
57 @Param(
"forecast")
boolean forecast);
63 @Query(
"START segment = node({segment}) MATCH (segment)<-[:SEGMENT_DISPATCHPLAN]-(ppdp) WHERE (ppdp.time = {time} AND ppdp.forecast={forecast}) RETURN ppdp")
64 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForSegmentForTime(@Param(
"segment")
Segment segment,
65 @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
71 @Query(
"START segment = node({segment}) MATCH (segment)<-[:SEGMENT_DISPATCHPLAN]-(ppdp) WHERE (ppdp.time = {time} AND ppdp.forecast={forecast}) RETURN ppdp ORDER BY ppdp.price")
72 public Iterable<PowerPlantDispatchPlan> findSortedPowerPlantDispatchPlansForSegmentForTime(@Param(
"segment")
Segment segment,
73 @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
76 @Query(
"START segment = node({segment}) MATCH (segment)<-[:SEGMENT_DISPATCHPLAN]-(ppdp) WHERE (ppdp.time = {time} AND ppdp.forecast={forecast}) RETURN ppdp ORDER BY ppdp.price desc")
77 public Iterable<PowerPlantDispatchPlan> findDescendingSortedPowerPlantDispatchPlansForSegmentForTime(
78 @Param(
"segment")
Segment segment, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
80 @Query(value =
"g.v(plant).in('POWERPLANT_DISPATCHPLAN').propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).propertyFilter('time', FilterPipe.Filter.EQUAL, time)", type = QueryType.Gremlin)
81 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForPowerPlantForTime(@Param(
"plant")
PowerPlant plant,
82 @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
84 @Query(value =
"g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast)", type = QueryType.Gremlin)
85 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForEnergyProducerForTime(
86 @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
88 @Query(value =
"g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).as('x').out('POWERPLANT_DISPATCHPLAN').filter{it==g.v(tech)}.back('x')", type = QueryType.Gremlin)
89 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForEnergyProducerForTimeForTechnology(
90 @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time,
94 @Query(value =
"g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('status', FilterPipe.Filter.GREATER_THAN_EQUAL , 2).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast)", type = QueryType.Gremlin)
95 public Iterable<PowerPlantDispatchPlan> findAllAcceptedPowerPlantDispatchPlansForEnergyProducerForTime(
96 @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
98 @Query(value =
"sum=0;ppdps=g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('status', FilterPipe.Filter.GREATER_THAN_EQUAL , 2).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast);"
100 "for(ppdp in ppdps){"+
101 "totalAmount = ppdp.getProperty('acceptedAmount') + ppdp.getProperty('capacityLongTermContract');"+
102 "hoursInSegment = ppdp.out('SEGMENT_DISPATCHPLAN').next().getProperty('lengthInHours');"+
103 "production = totalAmount * hoursInSegment;"+
104 "sum = sum + production};"
105 +
" return sum;", type = QueryType.Gremlin)
106 public double calculateTotalProductionForEnergyProducerForTime(@Param(
"producer")
EnergyProducer producer,
107 @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
109 @Query(value =
"sum=0;ppdps=g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('status', FilterPipe.Filter.GREATER_THAN_EQUAL , 2).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).as('x').out('POWERPLANT_DISPATCHPLAN').out('TECHNOLOGY').filter{it==g.v(tech)}.back('x');"
110 +
"for(ppdp in ppdps){"
111 +
"totalAmount = ppdp.getProperty('acceptedAmount') + ppdp.getProperty('capacityLongTermContract');"
112 +
"hoursInSegment = ppdp.out('SEGMENT_DISPATCHPLAN').next().getProperty('lengthInHours');"
113 +
"production = totalAmount * hoursInSegment;" +
"sum = sum + production};" +
" return sum;", type = QueryType.Gremlin)
114 public double calculateTotalProductionForEnergyProducerForTimeForTechnology(
115 @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time,
118 @Query(value =
"g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).as('x').out('SEGMENT_DISPATCHPLAN').idFilter(segment, FilterPipe.Filter.EQUAL).back('x')", type = QueryType.Gremlin)
119 public Iterable<PowerPlantDispatchPlan> findAllPowerPlantDispatchPlansForEnergyProducerForTimeAndSegment(
120 @Param(
"segment")
Segment segment, @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
122 @Query(value =
"g.v(producer).out('BIDDER').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).propertyFilter('status', FilterPipe.Filter.GREATER_THAN_EQUAL, 2).as('x').out('SEGMENT_DISPATCHPLAN').idFilter(segment, FilterPipe.Filter.EQUAL).back('x')", type = QueryType.Gremlin)
123 public Iterable<PowerPlantDispatchPlan> findAllAcceptedPowerPlantDispatchPlansForEnergyProducerForTimeAndSegment(
124 @Param(
"segment")
Segment segment, @Param(
"producer")
EnergyProducer producer, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);
130 @Query(value =
"g.v(market).in('BIDDINGMARKET').propertyFilter('time', FilterPipe.Filter.EQUAL, time).propertyFilter('forecast', FilterPipe.Filter.EQUAL, forecast).propertyFilter('status', FilterPipe.Filter.GREATER_THAN_EQUAL, 2).as('x').out('SEGMENT_DISPATCHPLAN').idFilter(segment, FilterPipe.Filter.EQUAL).back('x')", type = QueryType.Gremlin)
131 public Iterable<PowerPlantDispatchPlan> findAllAcceptedPowerPlantDispatchPlansForMarketSegmentAndTime(
132 @Param(
"market")
ElectricitySpotMarket esm, @Param(
"segment")
Segment segment, @Param(
"time")
long time, @Param(
"forecast")
boolean forecast);