EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
NonTransactionalCreateRepository.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 
19 import org.springframework.stereotype.Repository;
20 
26 
32 @Repository
33 public class NonTransactionalCreateRepository extends AbstractRepository<CashFlow> {
34 
47  DecarbonizationAgent to, double amount, int type, long time,
48  PowerPlant plant) {
49  CashFlow cashFlow = new CashFlow().persist();
50  cashFlow.setFrom(from);
51  cashFlow.setTo(to);
52  cashFlow.setMoney(amount);
53  cashFlow.setType(type);
54  cashFlow.setTime(time);
55  cashFlow.setRegardingPowerPlant(plant);
56  from.setCash(from.getCash() - amount);
57  if (to != null) {
58  to.setCash(to.getCash() + amount);
59  }
60 
61  return cashFlow;
62  }
63 
64 
76  public Bid submitBidToMarket(DecarbonizationMarket market, DecarbonizationAgent agent, long time, boolean isSupply, double price,
77  double amount) {
78 
79  Bid bid = new Bid().persist();
80  bid.setBiddingMarket(market);
81  bid.setBidder(agent);
82  bid.setSupplyBid(isSupply);
83  bid.setTime(time);
84  bid.setPrice(price);
85  bid.setAmount(amount);
86  bid.setStatus(Bid.SUBMITTED);
87  return bid;
88  }
89 
90 }
Bid submitBidToMarket(DecarbonizationMarket market, DecarbonizationAgent agent, long time, boolean isSupply, double price, double amount)
CashFlow createCashFlow(DecarbonizationAgent from, DecarbonizationAgent to, double amount, int type, long time, PowerPlant plant)