*/
public FundraisingPlan[] getFundraisingsPlan(int year, int monthSelected) {
if (monthSelected < 1 || monthSelected > 12)
throw new IllegalArgumentException("Month selected in fundraising plan should be from 1 to 12, found " + monthSelected);
EntityManager em = emf.createEntityManager();
Fundraising fundraising = null;
FundraisingPlan[] monthPlan = new FundraisingPlan[12];
try {
fundraising = em.find(Fundraising.class, year);
if (fundraising == null)
throw new IllegalArgumentException("The fundraising does not exist for this year " + year);
for (FundraisingPlan p : fundraising.getFundraisingPlans()) {
if (p.getMonthSelected() == monthSelected) {
monthPlan[p.getMonthFunding()-1] = p;
}
}
// add the new ones (begin from the selected month, can't be before