Author: jpepin Date: 2010-05-17 11:08:42 +0200 (Mon, 17 May 2010) New Revision: 2900 Url: http://chorem.org/repositories/revision/lima/2900 Log: Tri des journaux/p?\195?\169riodes par date. Requ?\195?\170te journaux/p?\195?\169riodes des p?\195?\169riodes ficales ouvertes Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-14 13:46:33 UTC (rev 2899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -48,7 +48,7 @@ /** Methodes for closedperiodicentrybook */ - List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException; + List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException; ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-14 13:46:33 UTC (rev 2899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialPeriodService; +import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; @@ -33,17 +34,21 @@ import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; +import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookDAO; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FinancialPeriodImpl; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.framework.TopiaQuery.Op; /** @@ -266,20 +271,26 @@ } @Override - public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException { + public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException { - List<ClosedPeriodicEntryBook> result = null; + List<ClosedPeriodicEntryBook> result = new ArrayList<ClosedPeriodicEntryBook>(); TopiaContext transaction = null; try { // basic check done, make check in database // TODO move it into JTA transaction = rootContext.beginTransaction(); - + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); - result = closedPeriodicEntryBookDAO.findAll(); + TopiaQuery query = closedPeriodicEntryBookDAO.createQuery(); + String closedPeriodicEntryBookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.FISCAL_PERIOD, FiscalPeriod.LOCKED); + query.add(closedPeriodicEntryBookProperty, Boolean.FALSE); + + result = closedPeriodicEntryBookDAO.findAllByQuery(query); + log.debug(result); + // FOR NO LAZY EXCEPTION for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) { closedPeriodicEntryBook.getEntryBook().getLabel(); Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -0,0 +1,40 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialperiod; + +import java.util.Comparator; + +import org.chorem.lima.entity.ClosedPeriodicEntryBook; + +public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{ + + @Override + public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) { + + if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == -1) { + return -1; + } else if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 1) { + return 1; + } else { + return 0; + } + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-14 13:46:33 UTC (rev 2899) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -1,3 +1,21 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + package org.chorem.lima.ui.financialperiod; import java.awt.Color; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-14 13:46:33 UTC (rev 2899) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -22,12 +22,12 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.swing.table.AbstractTableModel; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.exception.Nestable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.EntryBookService; @@ -35,12 +35,8 @@ import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.ClosedPeriodicEntryBook; -import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.ErrorHelper; /** * TODO add comment here. @@ -181,12 +177,13 @@ public void getDataList(){ List<ClosedPeriodicEntryBook> results = new ArrayList<ClosedPeriodicEntryBook>(); try { - results = financialPeriodService.getAllClosedPeriodicEntryBooks(); + results = financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); } catch (LimaException eee){ if (log.isDebugEnabled()){ log.debug("Can't get closedperiodicentrybook list", eee ); } } + Collections.sort(results, new ClosedPeriodicEntryBookComparator()); cacheDataList=results; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-14 13:46:33 UTC (rev 2899) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-17 09:08:42 UTC (rev 2900) @@ -27,8 +27,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.ClosedPeriodicEntryBook; -import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; import org.chorem.lima.util.ErrorHelper; /**