Author: fdesbois Date: 2010-01-27 17:08:47 +0000 (Wed, 27 Jan 2010) New Revision: 285 Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java Log: Add javadoc Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-01-27 17:08:47 UTC (rev 285) @@ -51,6 +51,7 @@ /** * Create a default admin user if no user already exist. + * * @throws SuiviObsmerException */ static void createDefaultAdmin() throws SuiviObsmerException { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2010-01-27 17:08:47 UTC (rev 285) @@ -38,12 +38,32 @@ */ public interface SuiviObsmerRunner { + /** + * Start the application. + * + * @throws SuiviObsmerException + */ public void start() throws SuiviObsmerException; + /** + * Stop the application. + * + * @throws SuiviObsmerException + */ public void stop() throws SuiviObsmerException; + /** + * Return the current date, depends on environment. + * + * @return the current Date + */ public Date currentDate(); + /** + * Return the configuration depends on environment. + * + * @return the ApplicationConfig which contains the application properties + */ public ApplicationConfig configuration(); } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -40,8 +40,6 @@ */ public class SuiviObsmerRunnerImpl implements SuiviObsmerRunner { - private static final Logger log = LoggerFactory.getLogger(SuiviObsmerRunnerImpl.class); - private ApplicationConfig _configuration; public SuiviObsmerRunnerImpl() { @@ -57,7 +55,9 @@ SuiviObsmerModelDAOHelper.getImplementationClassesAsString()); _configuration.printConfig(); + // Use the context to set the runner for default environment. SuiviObsmerContext.setRunner(this); + // Create the default admin in database SuiviObsmerGlobal.createDefaultAdmin(); } catch (Exception eee) { SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " + Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -38,6 +38,12 @@ private static final long serialVersionUID = 1L; + /** + * Return the ActivityMonth whith this {@code monthNumber} + * + * @param monthNumber the number of the month of the ActivityMonth + * @return the ActivityMonth if it's found or null otherwise + */ @Override public ActivityMonth getActivityMonth(int monthNumber) { for (ActivityMonth month : getActivityMonth()) { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -37,6 +37,12 @@ private static final long serialVersionUID = 1L; + /** + * Return the ActivityProfession whith this {@code professionOrder} + * + * @param professionOrder the order of the profession (unique) + * @return the ActivityProfession if it's found or null otherwise + */ @Override public ActivityProfession getActivityProfession(int professionOrder) { for (ActivityProfession profession : getActivityProfession()) { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -38,6 +38,12 @@ private static final long serialVersionUID = 1L; + /** + * Return the ActivityZone whith this {@code zoneCode} + * + * @param zoneCode the zone code + * @return the ActivityZone if it's found or null otherwise + */ @Override public ActivityZone getActivityZone(String zoneCode) { for (ActivityZone zone : getActivityZone()) { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -48,12 +48,14 @@ private static final long serialVersionUID = 1L; /** - * Check if a contact for this boat, company and sampleRow can be created. - * The state is tested for the last created contact. - * A new contact can be created only if the last state is final and is not 'Refus définitif'. + * Check if a contact for this boat and company can be created. + * The state is tested on the last created contact. + * A new contact can be created only if the last state is final. + * * @param company which is the creator of the contact * @return true if the contact can be created, false otherwise * @throws SuiviObsmerException + * @see fr.ifremer.suiviobsmer.bean.ContactState#isFinalState() */ @Override public boolean canCreateContact(Company company) throws SuiviObsmerException { @@ -64,10 +66,10 @@ ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); Contact contact = dao.createQueryLastContactForBoat(this, company).executeToEntity(); + if (contact != null) { - //boolean validation = contact.getValidationProgram() != null || BooleanUtils.isFalse(contact.getValidationCompany()); ContactState state = ContactState.createContactStateEnum(contact.getState()); - result = state.isFinalState(); /*validation && !state.equals(ContactState.BOAT_DEFINITIVE_REFUSED)*/; + result = state.isFinalState(); } transaction.closeContext(); Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-01-27 17:08:47 UTC (rev 285) @@ -52,12 +52,13 @@ protected int nbBoardingForCompany; /** - * Calculate the number of boarding done on the boat since the date in argument. - * Only the validate contacts by company will be count. + * Calculate the number of boarding done on the boat since the + * {@code fromDate}. Only validated contacts by company will be counted. * * @param fromDate the date to start calcul * @return a number of boarding done on the boat for all companies * @throws SuiviObsmerException + * @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date) */ @Override public int getNbBoarding(Date fromDate) throws SuiviObsmerException { @@ -82,12 +83,13 @@ } /** - * Calculate the number of boarding done on the boat and the company since the date in argument. - * Only the validate contacts by company will be count. + * Calculate the number of boarding done on the boat since the + * {@code fromDate}. Only validated contacts by company will be counted. * * @param fromDate the date to start calcul * @return a number of boarding done on the boat for the current company * @throws SuiviObsmerException + * @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date) */ @Override public int getNbBoardingForCompany(Date fromDate) throws SuiviObsmerException { Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-01-27 16:59:35 UTC (rev 284) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-01-27 17:08:47 UTC (rev 285) @@ -48,11 +48,14 @@ * * Created: 14 janv. 2010 * - * This class uses the BoatFilter bean (also SamplingFilter and UserFilter which are supertypes). + * This class uses the BoatFilter bean (also SamplingFilter and UserFilter which + * are supertypes). * - * Known implementations are {@link fr.ifremer.suiviobsmer.ui.pages.Synthesis } and {@link fr.ifremer.suiviobsmer.ui.pages.Contacts } + * Known implementations are {@link fr.ifremer.suiviobsmer.ui.pages.Synthesis } + * and {@link fr.ifremer.suiviobsmer.ui.pages.Contacts } * - * You must override the three abstract methods and call {@link #initFilter() } in the setupRender of the page. + * You must override the three abstract methods and call {@link #initFilter() } + * in the setupRender of the page. * <pre> * - BoatName uses an Autocomplete mixins : * <t:textfield t:id="boatName" t:value="filter.boatName" t:mixins="Autocomplete"/> @@ -62,12 +65,13 @@ * <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId" /> * - Observer select value is observerId : * <input t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" /> - * - Select change, use JavaScript : - * <script type="text/javascript"> - * Event.observe('facadeName', 'change', function() { $('filtersForm').submit(); } ); - * Event.observe('sectorName', 'change', function() { $('filtersForm').submit(); } ); - * Event.observe('company', 'change', function() { $('filtersForm').submit(); } ); - * </script> + * + * Use submit button with specific ids to refresh data depends on select change: + * - id="refreshByCompany" : refresh facadeSelect, sectorSelect, sampleRowSelect + * and observerSelect + * - id="refreshByFacade" : refresh sectorSelect and sampleRowSelect + * - id="refreshBySector" : refresh sampleRowSelect + * * </pre> * * @author fdesbois @@ -124,7 +128,8 @@ private String observerId; /** - * Initialize all select for filters. By default, only facade, sector and sampleRow selects will be initialized. + * Initialize all select for filters. By default, only facade, sector and + * sampleRow selects will be initialized. * * @param companySelect if true, company select will be initialized * @param observerSelect if true, observer select will be initialized @@ -181,6 +186,13 @@ getSampleRowSelectModel(); } + /** + * Get select model for fishingZone facade. Depends on company set in + * filter. + * + * @return the SelectModel for facade names + * @throws SuiviObsmerException + */ public SelectModel getFacadeSelectModel() throws SuiviObsmerException { if (facadeSelectModel == null) { if (log.isInfoEnabled()) { @@ -195,6 +207,13 @@ return facadeSelectModel; } + /** + * Get select model for fishingZone sector. Depends on facadeName and + * company set in filter. + * + * @return the SelectModel for sector names + * @throws SuiviObsmerException + */ public SelectModel getSectorSelectModel() throws SuiviObsmerException { if (sectorSelectModel == null) { if (log.isInfoEnabled()) { @@ -209,6 +228,14 @@ return sectorSelectModel; } + /** + * Get select model for sampleRows. Depends on filter (Sampling part only). + * The sampleRow set from filter is temporarly extracted to avoid returning + * only one element in the select. + * + * @return the GenericSelectModel<SampleRow> for sampleRows + * @throws SuiviObsmerException + */ public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws SuiviObsmerException { if (sampleRowSelectModel == null) { if (log.isInfoEnabled()) { @@ -227,6 +254,14 @@ return sampleRowSelectModel; } + /** + * Get select model for companies. Depends on + * {@link #getAvailableDataForFiltersOnly() } to return only activated + * companies. This select model is only used by admin users. + * + * @return the GenericSelectModel<Company> for companies + * @throws SuiviObsmerException + */ public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException { if (companySelectModel == null) { if (log.isDebugEnabled()) { @@ -239,6 +274,14 @@ return companySelectModel; } + /** + * Get the select model for observers. Depends on + * {@link #getAvailableDataForFiltersOnly() } to return only activated + * companies. + * + * @return the GenericSelectModel<WaoUser> for observers + * @throws SuiviObsmerException + */ public GenericSelectModel<WaoUser> getObserverSelectModel() throws SuiviObsmerException { if (observerSelectModel == null) { List<WaoUser> observers = new ArrayList<WaoUser>(); @@ -258,10 +301,6 @@ protected abstract BoatFilter getFilter() throws SuiviObsmerException; -// protected abstract Zone getSampleRowFilterZone(); -// -// protected abstract Zone getObserverFilterZone(); - /** * Used to show only active company and observers. * @@ -277,34 +316,6 @@ return results.toArray(new String[0]); } -// @Log -// public Object onChangeFromFacadeName(String value) throws SuiviObsmerException { -// if (!StringUtils.isEmpty(value.trim())) { -// // Reset filter to avoid strange behavior (cause of no form submit) -// resetFilter();// = null; -// // set facadeName selected in filter -// getFilter().setFacadeName(value); -// // Reset sectors to use facadeName selected -// sectorSelectModel = null; -// return getSampleRowFilterZone().getBody(); -// } -// return null; -// } -// -// @Log -// public Object onChangeFromCompany(String value) throws SuiviObsmerException { -// if (!StringUtils.isEmpty(value.trim())) { -// // Reset filter to avoid strange behavior (cause of no form submit) -// resetFilter(); -// // set company selected in filter -// getFilter().setCompany(getCompanySelectModel().findObject(companyId)); -// // Reset observers to use company selected -// observerSelectModel = null; -// return getObserverFilterZone().getBody(); -// } -// return null; -// } - /** * Called when search submit button is pressed. This method is useful to * refresh all filters data from selects. @@ -385,6 +396,11 @@ edited = true; } + /** + * Used to indicate that a refresh as been triggered. + * + * @return true if the page filter is in edited state. + */ protected boolean isEdited() { return edited; }