Wao-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
April 2010
- 4 participants
- 73 discussions
[Suiviobsmer-commits] r413 - in trunk/wao-business/src/main: java/fr/ifremer/wao java/fr/ifremer/wao/service xmi
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
02 Apr '10
Author: fdesbois
Date: 2010-04-02 15:37:11 +0000 (Fri, 02 Apr 2010)
New Revision: 413
Added:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
trunk/wao-business/src/main/xmi/wao.properties
trunk/wao-business/src/main/xmi/wao.zargo
Log:
Use last ServiceTransformer version : exception not generated, context still generated by InterfaceTransformer
Added: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -0,0 +1,39 @@
+package fr.ifremer.wao;
+
+
+
+public class WaoException extends RuntimeException {
+
+ protected Object[] args;
+ /**
+ * WaoException :
+ * @param eee
+ * @param message
+ * @param args
+ */
+
+ public WaoException(Throwable eee, String message, Object... args) {
+ super(message, eee);
+ this.args = args;
+ }
+
+ /**
+ * getArgs :
+ * @return Object[]
+ */
+
+ public Object[] getArgs() {
+ return args;
+ }
+
+ /**
+ * hasArgs :
+ * @return boolean
+ */
+
+ public boolean hasArgs() {
+ return args.length > 0;
+ }
+
+
+} //WaoException
Property changes on: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -25,7 +25,9 @@
import com.csvreader.CsvWriter;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.WaoUtils;
import org.nuiton.topia.TopiaException;
@@ -73,7 +75,35 @@
private static final Logger log =
LoggerFactory.getLogger(ServiceBoatImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public Map<Integer, Boat> executeGetBoatsByFilter(TopiaContext transaction,
BoatFilter filter) throws TopiaException {
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -23,10 +23,12 @@
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.io.ImportHelper;
import fr.ifremer.wao.io.ImportHelper.*;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.bean.ContactState;
import java.io.IOException;
@@ -89,7 +91,35 @@
private static final Logger log =
LoggerFactory.getLogger(ServiceContactImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public Map<String, Contact> executeGetContacts(TopiaContext transaction,
ContactFilter filter) throws TopiaException {
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -21,7 +21,9 @@
package fr.ifremer.wao.service;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.entity.News;
import fr.ifremer.wao.entity.NewsDAO;
import java.util.List;
@@ -47,7 +49,35 @@
private static final Logger logger =
LoggerFactory.getLogger(ServiceNewsImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public List<News> executeGetNews(TopiaContext transaction) throws TopiaException {
NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction);
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -22,7 +22,9 @@
package fr.ifremer.wao.service;
import com.csvreader.CsvReader;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.SamplingFilter;
import fr.ifremer.wao.entity.FishingZone;
import fr.ifremer.wao.entity.FishingZoneDAO;
@@ -55,9 +57,38 @@
*/
public class ServiceReferentialImpl extends ServiceReferentialAbstract {
- private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImpl.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(ServiceReferentialImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public List<String> executeGetFacades(TopiaContext transaction,
SamplingFilter filter) throws TopiaException {
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -26,7 +26,9 @@
import fr.ifremer.wao.io.ImportHelper;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.FacadeRow;
import fr.ifremer.wao.bean.FacadeRowImpl;
import fr.ifremer.wao.bean.ImportResults;
@@ -78,8 +80,37 @@
*/
public class ServiceSamplingImpl extends ServiceSamplingAbstract {
- private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(ServiceSamplingImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
+ @Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
public ServiceSamplingImpl() {
prepareBinderForProfession();
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -21,6 +21,7 @@
package fr.ifremer.wao.service;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.ContactAverageReactivityImpl;
@@ -73,9 +74,38 @@
*/
public class ServiceSynthesisImpl extends ServiceSynthesisAbstract {
- private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(ServiceSynthesisImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public List<SortedMap<Date, Integer>> executeGetDataSampling(
TopiaContext transaction, SamplingFilter filter)
throws TopiaException {
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-02 15:37:11 UTC (rev 413)
@@ -23,7 +23,9 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
+import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.bean.UserRole;
import fr.ifremer.wao.entity.Company;
@@ -58,9 +60,38 @@
*/
public class ServiceUserImpl extends ServiceUserAbstract {
- private static final Logger log = LoggerFactory.getLogger(ServiceUserImpl.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(ServiceUserImpl.class);
+ private WaoContextImplementor context;
+
+ public void setContext(WaoContextImplementor context) {
+ this.context = context;
+ }
+
@Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws WaoException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void treateError(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.treateError(eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
public WaoUser executeConnect(TopiaContext transaction,
String login, String password)
throws TopiaException, WaoBusinessException {
Modified: trunk/wao-business/src/main/xmi/wao.properties
===================================================================
--- trunk/wao-business/src/main/xmi/wao.properties 2010-04-02 09:47:50 UTC (rev 412)
+++ trunk/wao-business/src/main/xmi/wao.properties 2010-04-02 15:37:11 UTC (rev 413)
@@ -1,5 +1,6 @@
model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 Wao\n *##%*/
model.tagvalue.java.lang.String=text
+model.tagvalue.exceptionClass=fr.ifremer.wao.WaoException
#fr.ifremer.wao.entity.Company.attribute.waoUser.tagvalue.lazy=false
#fr.ifremer.wao.entity.Company.attribute.waoUser.tagvalue.orderBy=firstName,lastName
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
1
0
[Suiviobsmer-commits] r412 - in trunk/wao-business/src/main/java/fr/ifremer/wao: . entity
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
02 Apr '10
Author: fdesbois
Date: 2010-04-02 09:47:50 +0000 (Fri, 02 Apr 2010)
New Revision: 412
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
Log:
Evo #1960 : send email to admin for new comment on sampleRow
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-02 09:12:15 UTC (rev 411)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-02 09:47:50 UTC (rev 412)
@@ -408,7 +408,11 @@
}
@Override
- public void sendEmail(String to, String subject, String msg) throws EmailException {
+ public void sendEmail(String to, String subject, String msg)
+ throws EmailException {
+ if (log.isInfoEnabled()) {
+ log.info("Send an email to " + to + " : " + subject);
+ }
SimpleEmail email = new SimpleEmail();
email.setHostName(WaoProperty.EMAIL_HOST.getValue());
email.setSmtpPort(Integer.parseInt(WaoProperty.EMAIL_PORT.getValue()));
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-02 09:12:15 UTC (rev 411)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-02 09:47:50 UTC (rev 412)
@@ -23,6 +23,8 @@
EMAIL_PORT("wao.email.port"),
/** From for email **/
EMAIL_FROM("wao.email.from"),
+ /** Contact email (same as from) **/
+ EMAIL_CONTACT(EMAIL_FROM.getKey()),
/** App version **/
APP_VERSION("wao.version"),
/** Server path **/
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-02 09:12:15 UTC (rev 411)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-02 09:47:50 UTC (rev 412)
@@ -4,6 +4,7 @@
import fr.ifremer.wao.entity.ActivityCalendar;
import java.io.IOException;
import java.util.Date;
+import org.apache.commons.mail.EmailException;
import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
@@ -129,6 +130,11 @@
return context.beginTransaction();
}
+ public static void sendEmail(String to, String subject, String msg)
+ throws EmailException {
+ context.sendEmail(to, subject, msg);
+ }
+
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-02 09:12:15 UTC (rev 411)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-02 09:47:50 UTC (rev 412)
@@ -24,6 +24,8 @@
import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoProperty;
+import fr.ifremer.wao.bean.UserRole;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
@@ -300,8 +302,8 @@
public void saveSampleRowLog(SampleRowLog rowLog) throws WaoException {
TopiaContext transaction = null;
try {
- if (log.isInfoEnabled()) {
- WaoUser author = rowLog.getAuthor();
+ WaoUser author = rowLog.getAuthor();
+ if (log.isInfoEnabled()) {
log.info("W:[ saveSampleRowLog ] : " +
"authorName = " + author.getFullName() +
" _ authorRole = " + author.getUserRole());
@@ -317,7 +319,24 @@
transaction.commitTransaction();
// Send mail to admin if author is a coordinator :
- // WaoContext.PROP_EMAIL_FROM
+ if (author.getUserRole().equals(UserRole.COORDINATOR)) {
+ String sampleRowCode = rowLog.getSampleRow().getCode();
+ String to = WaoProperty.EMAIL_CONTACT.getValue();
+ String subject = "[WAO] Ajout d'un commentaire sur la ligne " +
+ sampleRowCode;
+ String msg = "Bonjour,\n\n" +
+ "Un nouveau commentaire a été ajouté par " +
+ author.getFullName() + " de la société " +
+ author.getCompany().getName() + " :\n " +
+ "\t" + rowLog.getComment() + "\n\n" +
+ "Vous pouvez consulter l'historique de la ligne " +
+ sampleRowCode + " sur la page :\n" +
+ "http://" + WaoProperty.SERVER_PATH.getValue() +
+ "/samplerowhistoric/" + sampleRowCode + "\n\n" +
+ "Cordialement,\n\n" +
+ "L'Equipe WAO";
+ WaoUtils.sendEmail(to, subject, msg);
+ }
} catch (Exception eee) {
WaoUtils.treateError(transaction, eee,
1
0
[Suiviobsmer-commits] r411 - in trunk: wao-business/src/main/java/fr/ifremer/wao wao-business/src/main/java/fr/ifremer/wao/entity wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao wao-business/src/test/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/services
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
by fdesbois@users.labs.libre-entreprise.org 02 Apr '10
02 Apr '10
Author: fdesbois
Date: 2010-04-02 09:12:15 +0000 (Fri, 02 Apr 2010)
New Revision: 411
Removed:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java
Log:
- Rename methods to manage transaction and error (treateError, closeTransaction)
- Use serviceUser for createDefaultAdmin method (needed to start application)
- Use contributeToRegistryStartup to start application from WaoManager in tapestry
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -23,6 +23,7 @@
package fr.ifremer.wao;
import fr.ifremer.wao.io.ImportHelper;
+import fr.ifremer.wao.service.ServiceUser;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.Locale;
@@ -130,7 +131,7 @@
loadConfiguration(conf);
} catch (ArgumentsParserException eee) {
- doCatch(eee, n_("wao.error.context.parse"), DEFAULT_FILENAME);
+ treateError(eee, n_("wao.error.context.parse"), DEFAULT_FILENAME);
}
}
@@ -195,9 +196,10 @@
* - Create default admin if needed (this will load the topiaRootContext).
* </pre>
*
+ * @param serviceUser to create default admin if needed
*/
@Override
- public void start() {
+ public void start(ServiceUser serviceUser) {
try {
if (log.isInfoEnabled()) {
log.info("Start Wao");
@@ -218,14 +220,14 @@
ImportHelper.setContext(this);
// Create the default admin in database
- WaoGlobal.createDefaultAdmin(this);
+ serviceUser.createDefaultAdmin();
if (log.isInfoEnabled()) {
log.info("wao is started !");
}
} catch (Exception eee) {
- doCatch(eee, n_("wao.error.context.start"));
+ treateError(eee, n_("wao.error.context.start"));
}
}
@@ -240,7 +242,7 @@
}
getTopiaRootContext().closeContext();
} catch (Exception eee) {
- doCatch(eee, n_("wao.error.context.stop"));
+ treateError(eee, n_("wao.error.context.stop"));
}
}
@@ -249,7 +251,7 @@
return TopiaContextFactory.getContext(
getConfiguration().getOptions());
} catch (TopiaNotFoundException eee) {
- doCatch(eee, n_("wao.error.context.getRootContext"));
+ treateError(eee, n_("wao.error.context.getRootContext"));
}
return null;
}
@@ -303,13 +305,13 @@
// }
@Override
- public void doCatch(Exception eee, String message, Object... args)
+ public void treateError(Exception eee, String message, Object... args)
throws WaoException {
- doCatch(null, eee, message, args);
+ treateError(null, eee, message, args);
}
@Override
- public void doCatch(TopiaContext transaction, Exception eee,
+ public void treateError(TopiaContext transaction, Exception eee,
String message, Object... args) throws WaoException {
if (log.isDebugEnabled()) {
log.debug(_(message, args),eee);
@@ -325,7 +327,7 @@
//transaction.closeContext();
}
} catch (TopiaException eeee) {
- doCatch(eeee, n_("wao.error.context.rollback"));
+ treateError(eeee, n_("wao.error.context.rollback"));
}
//}
if (eee instanceof SQLGrammarException && log.isErrorEnabled()) {
@@ -338,7 +340,7 @@
}
@Override
- public void doFinally(TopiaContext transaction) {
+ public void closeTransaction(TopiaContext transaction) {
if (transaction != null) {
try {
transaction.closeContext();
@@ -346,7 +348,7 @@
// if (log.isErrorEnabled()) {
// log.error(_("wao.error.context.close"), eee);
// }
- doCatch(eee, n_("wao.error.context.close"));
+ treateError(eee, n_("wao.error.context.close"));
}
}
}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -1,102 +0,0 @@
-/*
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-package fr.ifremer.wao;
-
-import fr.ifremer.wao.bean.UserRole;
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.CompanyDAO;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.entity.WaoUserDAO;
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.TopiaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * WaoGlobal
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoGlobal {
-
- private static final Logger log = LoggerFactory.getLogger(WaoGlobal.class);
-
- /**
- * Create a default admin user if no user already exist.
- *
- * @throws WaoException
- */
- static void createDefaultAdmin(WaoContextImplementor context)
- throws WaoException {
- TopiaContext transaction = null;
- try {
- transaction = context.beginTransaction();
-
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
-
- long nbUsers = dao.size();
-
- if (log.isInfoEnabled()) {
- log.info("Nb existing users : " + nbUsers);
- }
-
- if (nbUsers == 0) {
-
- CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction);
-
- if (log.isInfoEnabled()) {
- log.info("Create first admin : login=\"admin\" / password=\"password\"");
- }
-
- Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
-
- String password = context.encodeString("password");
-
- WaoUser user = dao.create(
- WaoUser.ROLE, UserRole.ADMIN.ordinal(),
- WaoUser.ACTIVE, true,
- WaoUser.LOGIN, "admin",
- WaoUser.PASSWORD, password,
- WaoUser.FIRST_NAME, "Super",
- WaoUser.LAST_NAME, "Admin");
- user.setCompany(company);
-
- transaction.commitTransaction();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- context.doCatch(transaction, eee,
- I18n.n_("wao.error.global.createDefaultAdmin"));
- //Error during database initialization", eee);
- } finally {
- context.doFinally(transaction);
- }
- }
-
-}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -88,8 +88,8 @@
*
* @param transaction
*/
- public static void doFinally(TopiaContext transaction) {
- context.doFinally(transaction);
+ public static void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
}
/**
@@ -101,9 +101,9 @@
* @param args
* @throws WaoException
*/
- public static void doCatch(TopiaContext transaction,
+ public static void treateError(TopiaContext transaction,
Exception eee, String message, Object... args) throws WaoException {
- context.doCatch(transaction, eee, message, args);
+ context.treateError(transaction, eee, message, args);
}
/**
@@ -114,9 +114,9 @@
* @param args
* @throws WaoException
*/
- public static void doCatch(Exception eee, String message,
+ public static void treateError(Exception eee, String message,
Object... args) throws WaoException {
- context.doCatch(eee, message, args);
+ context.treateError(eee, message, args);
}
/**
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -79,11 +79,11 @@
}
} catch (Exception eee) {
- WaoUtils.doCatch(transaction, eee,
+ WaoUtils.treateError(transaction, eee,
I18n.n_("wao.error.boat.canCreateContact"),
company.getName(), getName(), getImmatriculation());
} finally {
- WaoUtils.doFinally(transaction);
+ WaoUtils.closeTransaction(transaction);
}
}
return result;
@@ -112,10 +112,10 @@
result = query.executeCount(transaction);
} catch (Exception eee) {
- WaoUtils.doCatch(transaction, eee,
+ WaoUtils.treateError(transaction, eee,
I18n.n_("wao.error.boat.getNbBoarding"), fromDate);
} finally {
- WaoUtils.doFinally(transaction);
+ WaoUtils.closeTransaction(transaction);
}
return result;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -74,11 +74,11 @@
result = query.executeCount();
} catch (Exception eee) {
- WaoUtils.doCatch(transaction, eee,
+ WaoUtils.treateError(transaction, eee,
I18n.n_("wao.error.boatInfos.getNbBoardingForCompany"),
fromDate, getCompany().getName());
} finally {
- WaoUtils.doFinally(transaction);
+ WaoUtils.closeTransaction(transaction);
}
return result;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -81,11 +81,11 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- WaoUtils.doCatch(transaction, eee,
+ WaoUtils.treateError(transaction, eee,
I18n.n_("wao.error.sampleMonth.addRealTideTime"),
formatMonth(), getSampleRow().getCode());
} finally {
- WaoUtils.doFinally(transaction);
+ WaoUtils.closeTransaction(transaction);
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -320,11 +320,11 @@
// WaoContext.PROP_EMAIL_FROM
} catch (Exception eee) {
- WaoUtils.doCatch(transaction, eee,
+ WaoUtils.treateError(transaction, eee,
I18n.n_("wao.error.sampleRow.saveSampleRowLog"),
rowLog.getAuthor().getFullName());
} finally {
- WaoUtils.doFinally(transaction);
+ WaoUtils.closeTransaction(transaction);
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -355,6 +355,44 @@
return user;
}
+ @Override
+ protected void executeCreateDefaultAdmin(TopiaContext transaction)
+ throws Exception {
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ long nbUsers = dao.size();
+ if (log.isInfoEnabled()) {
+ log.info("Nb existing users : " + nbUsers);
+ }
+
+ if (nbUsers == 0) {
+
+ CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction);
+
+ if (log.isInfoEnabled()) {
+ log.info("Create first admin : login=\"admin\" / " +
+ "password=\"password\"");
+ }
+
+ Company company = companyDAO.create(
+ Company.ACTIVE, false, Company.NAME, "ADMIN");
+
+ String password = context.encodeString("password");
+
+ WaoUser user = dao.create(
+ WaoUser.ROLE, UserRole.ADMIN.ordinal(),
+ WaoUser.ACTIVE, true,
+ WaoUser.LOGIN, "admin",
+ WaoUser.PASSWORD, password,
+ WaoUser.FIRST_NAME, "Super",
+ WaoUser.LAST_NAME, "Admin");
+ user.setCompany(company);
+
+ transaction.commitTransaction();
+ }
+ }
+
+
+
}
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-02 09:12:15 UTC (rev 411)
@@ -55,6 +55,7 @@
wao.error.serviceSynthesis.getDataSampling=
wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=
wao.error.serviceUser.connect=
+wao.error.serviceUser.createDefaultAdmin=
wao.error.serviceUser.createUpdateCompany=
wao.error.serviceUser.createUpdateUser=
wao.error.serviceUser.deleteUser=
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-02 09:12:15 UTC (rev 411)
@@ -7,7 +7,6 @@
wao.error.context.rollback=Une erreur est survenue pendant l'annulation de la transaction courante
wao.error.context.start=Une erreur est survenue pendant le d\u00E9marrage de l'application
wao.error.context.stop=Une erreur est survenue pendant la fermeture de l'application
-wao.error.global.createDefaultAdmin=
wao.error.sampleMonth.addRealTideTime=Impossible d'enregistrer le nombre de mar\u00E9es r\u00E9els pour le mois de %1$s [ligne \: %2$s]
wao.error.sampleRow.saveSampleRowLog=Impossible d'enregistrer le commentaire \u00E9crit par %1$s
wao.error.serviceBoat.createUpdateCompanyBoatInfos=Impossible de cr\u00E9er ou modifier les informations li\u00E9s au navire %1$d pour la soci\u00E9t\u00E9 %2$s
@@ -55,6 +54,7 @@
wao.error.serviceSynthesis.getDataSampling=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es pour le graphique dynamique des efforts de mar\u00E9es
wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=Impossible de r\u00E9cup\u00E9rer l'indicateur de non respect du nombre d'observateurs embarqu\u00E9s
wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion
+wao.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut
wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9
wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur
wao.error.serviceUser.deleteUser=Impossible de supprimer l'utilisateur
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -85,9 +85,9 @@
Calendar calendar = new GregorianCalendar(2009, 9, 23);
context.setCurrentDate(calendar.getTime());
- context.start();
+ context.start(getServiceUser());
} catch (Exception eee) {
- context.doCatch(eee, "Error during loadConfiguration from " +
+ context.treateError(eee, "Error during loadConfiguration from " +
"'WaoTest.properties' file");
}
}
@@ -99,7 +99,7 @@
try {
context.getTopiaRootContext().clear(true);
} catch (TopiaException eee) {
- context.doCatch(eee, "Error during clear database");
+ context.treateError(eee, "Error during clear database");
}
}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -1,104 +0,0 @@
-/*
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-package fr.ifremer.wao;
-
-import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.WaoUser;
-import fr.ifremer.wao.service.ServiceUserImpl;
-import fr.ifremer.wao.service.ServiceUser;
-import java.util.List;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * WaoGlobalTest
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoGlobalTest {
-
- private static TestManager manager;
-
- private static final Logger log = LoggerFactory.getLogger(WaoGlobalTest.class);
-
- public WaoGlobalTest() {
- manager = new TestManager();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() {
- manager.start();
- }
-
- @After
- public void tearDown() {
- manager.stop();
- }
-
- /**
- * Test of initApplication method, of class WaoGlobal.
- */
- @Test
- public void testCreateDefaultAdmin() throws Exception {
- System.out.println("createDefaultAdmin");
-
- WaoGlobal.createDefaultAdmin(manager.getContext());
-
- ServiceUser serviceUser = manager.getServiceUser();
-
- List<Company> companies = serviceUser.getCompanies(false);
- assertEquals(1, companies.size());
-
- Company company = companies.get(0);
- assertEquals("ADMIN", company.getName());
-
- List<WaoUser> users = serviceUser.getUsersByCompany(company);
- assertEquals(1, users.size());
-
- WaoUser user = users.get(0);
- assertEquals("admin", user.getLogin());
-
- }
-
-}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -159,4 +159,29 @@
Assert.assertEquals(2, users.size());
}
+ /**
+ * Test of initApplication method, of class WaoGlobal.
+ */
+ @Test
+ public void testCreateDefaultAdmin() throws Exception {
+ logger.info("## START ## createDefaultAdmin");
+
+ service.createDefaultAdmin();
+
+ ServiceUser serviceUser = manager.getServiceUser();
+
+ List<Company> companies = serviceUser.getCompanies(false);
+ Assert.assertEquals(1, companies.size());
+
+ Company company = companies.get(0);
+ Assert.assertEquals("ADMIN", company.getName());
+
+ List<WaoUser> users = serviceUser.getUsersByCompany(company);
+ Assert.assertEquals(1, users.size());
+
+ WaoUser user = users.get(0);
+ Assert.assertEquals("admin", user.getLogin());
+
+ }
+
}
\ No newline at end of file
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -26,7 +26,9 @@
import java.io.IOException;
import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.EagerLoad;
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
@@ -51,6 +53,13 @@
binder.bind(ContactModelFactory.class);
}
+ /**
+ * Use EagerLoad to build manager at startup. The manager will control
+ * the application lifecycle (start and stop).
+ *
+ * @param hub to register the manager in the tapestry registry shutdown
+ * @return the new instance of WaoManager
+ */
@EagerLoad
public WaoManager buildWaoManager(RegistryShutdownHub hub) {
WaoManager manager = new WaoManager(new WaoContextImpl());
@@ -58,6 +67,23 @@
return manager;
}
+ /**
+ * Execute WaoManager when registry startup.
+ * The manager will be instantiated using
+ * {@link #buildWaoManager(org.apache.tapestry5.ioc.services.RegistryShutdownHub) }.
+ * The serviceUser is needed to start the application.
+ *
+ * @param configuration to add the manager to registry startup
+ * @param manager to launch at startup
+ * @param serviceUser needed for manager start
+ */
+ public static void contributeRegistryStartup(
+ OrderedConfiguration<Runnable> configuration,
+ WaoManager manager, ServiceUser serviceUser) {
+ manager.setServiceUser(serviceUser);
+ configuration.add("WaoStartup", manager);
+ }
+
public ServiceNews buildServiceNews(WaoManager manager) {
ServiceNewsImpl instance = new ServiceNewsImpl();
instance.setContext(manager.getContext());
@@ -175,10 +201,6 @@
// return listener;
// }
-// public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) {
-// configuration.add("WaoStartup", new WaoManager());
-// }
-
/**
* Used to instanciate SessionState WaoUser when session expires.
*
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 18:28:32 UTC (rev 410)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-02 09:12:15 UTC (rev 411)
@@ -23,6 +23,7 @@
import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoProperty;
+import fr.ifremer.wao.service.ServiceUser;
import java.util.Date;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.nuiton.util.ApplicationConfig;
@@ -42,24 +43,53 @@
*/
public class WaoManager implements Runnable, RegistryShutdownListener {
- private static final Logger log = LoggerFactory.getLogger(WaoManager.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(WaoManager.class);
private WaoContextImplementor context;
+ private ServiceUser serviceUser;
+
+ /**
+ * Constructor of WaoManager. It needs the WaoContext to start and stop.
+ *
+ * @param context used to manage application lifecycle
+ */
public WaoManager(WaoContextImplementor context) {
this.context = context;
- this.context.start();
}
+ /**
+ * ServiceUser is needed to start the application.
+ *
+ * @param serviceUser
+ * @see fr.ifremer.wao.WaoContext#start(fr.ifremer.wao.service.ServiceUser)
+ */
+ void setServiceUser(ServiceUser serviceUser) {
+ this.serviceUser = serviceUser;
+ }
+
+ /**
+ * Called to start the application.
+ */
@Override
public void run() {
+ context.start(serviceUser);
}
+ /**
+ * Called to stop the application
+ */
@Override
public void registryDidShutdown() {
context.stop();
}
+ /**
+ * Context to inject in new service instances.
+ *
+ * @return the WaoContext of the application
+ */
WaoContextImplementor getContext() {
return context;
}
1
0
[Suiviobsmer-commits] r410 - in trunk/wao-business/src/main: java/fr/ifremer/wao/service resources/i18n
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 18:28:32 +0000 (Thu, 01 Apr 2010)
New Revision: 410
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
Log:
Clean ServiceSynthesisImpl
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:21:22 UTC (rev 409)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:28:32 UTC (rev 410)
@@ -38,7 +38,6 @@
import fr.ifremer.wao.entity.Boat;
import fr.ifremer.wao.entity.BoatDAO;
import fr.ifremer.wao.entity.Company;
-import fr.ifremer.wao.entity.CompanyDAO;
import fr.ifremer.wao.entity.Contact;
import fr.ifremer.wao.entity.ContactDAO;
import fr.ifremer.wao.entity.ContactImpl;
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 18:21:22 UTC (rev 409)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 18:28:32 UTC (rev 410)
@@ -75,89 +75,66 @@
private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class);
-// protected TopiaContext rootContext;
-//
-// public ServiceSynthesisImpl() throws WaoExceptionO {
-// rootContext = context.getTopiaRootContext();
-// }
-
@Override
public List<SortedMap<Date, Integer>> executeGetDataSampling(
TopiaContext transaction, SamplingFilter filter)
throws TopiaException {
-// TopiaContext transaction = null;
List<SortedMap<Date, Integer>> results =
new ArrayList<SortedMap<Date, Integer>>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- PeriodDates period = filter.getPeriod();
- if (period == null || period.getFromDate() == null || period.getThruDate() == null) {
- return results;
- }
- period.initDayOfMonthExtremities();
+ PeriodDates period = filter.getPeriod();
+ if (period == null || period.getFromDate() == null ||
+ period.getThruDate() == null) {
+ return results;
+ }
+ period.initDayOfMonthExtremities();
- // Expected
- SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
- // Real
- SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>();
- results.add(serie1);
- results.add(serie2);
+ // Expected
+ SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
+ // Real
+ SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>();
+ results.add(serie1);
+ results.add(serie2);
- // Prepare results
- for (Date month : period.getMonths()) {
- serie1.put(month, 0);
- serie2.put(month, 0);
- }
+ // Prepare results
+ for (Date month : period.getMonths()) {
+ serie1.put(month, 0);
+ serie2.put(month, 0);
+ }
- SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction);
- String periodDate = "M." + SampleMonth.PERIOD_DATE;
- TopiaQuery query = dao.createQuery("M").
- setSelect(periodDate).
- addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")").
- addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")").
- add(periodDate + " BETWEEN :fromDate AND :thruDate").
- addParam("fromDate", period.getFromDate()).addParam("thruDate", period.getThruDate()).
- addGroup(periodDate).addOrder(periodDate);
+ SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction);
+ String periodDate = "M." + SampleMonth.PERIOD_DATE;
+ TopiaQuery query = dao.createQuery("M").
+ setSelect(periodDate).
+ addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")").
+ addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")").
+ add(periodDate + " BETWEEN :fromDate AND :thruDate").
+ addParam("fromDate", period.getFromDate()).
+ addParam("thruDate", period.getThruDate()).
+ addGroup(periodDate).addOrder(periodDate);
- query = filter.prepareQueryForSampling(query, "M." + SampleMonth.SAMPLE_ROW);
+ query = filter.prepareQueryForSampling(query,
+ "M." + SampleMonth.SAMPLE_ROW);
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
- List<Object[]> res = (List<Object[]>)query.execute();
+ List<Object[]> res = (List<Object[]>)query.execute();
- for (Object[] tab : res) {
- Date date = (Date)tab[0];
- int sumReal = ((Long)tab[1]).intValue();
- int sumExpected = ((Long)tab[2]).intValue();
- serie1.put(date, sumExpected);
- serie2.put(date, sumReal);
- if (log.isTraceEnabled()) {
- DateFormat dateFormat = new SimpleDateFormat(period.getPattern());
- log.trace("Res : " + dateFormat.format(date) + " : " + sumReal + " / " + sumExpected);
- }
+ for (Object[] tab : res) {
+ Date date = (Date)tab[0];
+ int sumReal = ((Long)tab[1]).intValue();
+ int sumExpected = ((Long)tab[2]).intValue();
+ serie1.put(date, sumExpected);
+ serie2.put(date, sumReal);
+ if (log.isTraceEnabled()) {
+ DateFormat dateFormat =
+ new SimpleDateFormat(period.getPattern());
+ log.trace("Res : " + dateFormat.format(date) + " : "
+ + sumReal + " / " + sumExpected);
}
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getDataSampling ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ }
return results;
}
@@ -179,202 +156,153 @@
public BoardingResult executeGetBoardingBoats(TopiaContext transaction,
Company company, Date fromDate)
throws TopiaException {
-// TopiaContext transaction = null;
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
BoardingResult result = new BoardingResultImpl();
result.setData(map);
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- // Initialiaze max boardings and its max key value
- final int maxBoardings = 12;
- final String maxBoardingsKey = maxBoardings + " +";
+ // Initialiaze max boardings and its max key value
+ final int maxBoardings = 12;
+ final String maxBoardingsKey = maxBoardings + " +";
- // Prepare map which contains for each entry the number of boardings
- // for the key and the number of boats for the value.
- for (int i = 1; i < maxBoardings; i++) {
- map.put(String.valueOf(i), 0);
- }
- map.put(maxBoardingsKey, 0);
+ // Prepare map which contains for each entry the number of boardings
+ // for the key and the number of boats for the value.
+ for (int i = 1; i < maxBoardings; i++) {
+ map.put(String.valueOf(i), 0);
+ }
+ map.put(maxBoardingsKey, 0);
- ContactDAO dao =
- WaoDAOHelper.getContactDAO(transaction);
- // The number of boardings is the number of finished contacts
- // Use fromDate to filter contacts finished from this date
- // No need to use boat filter for this method
- TopiaQuery query =
- dao.createQueryDoneContactsFromDate(null, fromDate);
-
- String contact = query.getMainAlias();
- String sampleRow = contact + "." + Contact.SAMPLE_ROW;
+ ContactDAO dao =
+ WaoDAOHelper.getContactDAO(transaction);
+ // The number of boardings is the number of finished contacts
+ // Use fromDate to filter contacts finished from this date
+ // No need to use boat filter for this method
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(null, fromDate);
- // Only for sampleRows with averageTideTime less or equals to 2 days
- query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.);
+ String contact = query.getMainAlias();
+ String sampleRow = contact + "." + Contact.SAMPLE_ROW;
- // Add filter on sampleRow company if needed
- if (company != null) {
- query.add(sampleRow + "." + SampleRow.COMPANY, company);
- }
+ // Only for sampleRows with averageTideTime less or equals to 2 days
+ query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.);
- // Prepare aliases for mapping results in select part
- String countAlias = "nbBoardings";
- String boatAlias = "boat";
- // Use a map for each result with boat and its number of boardings
- // Order by number of boardings to easily find the max value (the
- // first result)
- query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " +
- boatAlias + ", COUNT(*) as " + countAlias + ")").
- addGroup(contact + "." + Contact.BOAT).
- addOrderDesc("COUNT(*)");
+ // Add filter on sampleRow company if needed
+ if (company != null) {
+ query.add(sampleRow + "." + SampleRow.COMPANY, company);
+ }
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
+ // Prepare aliases for mapping results in select part
+ String countAlias = "nbBoardings";
+ String boatAlias = "boat";
+ // Use a map for each result with boat and its number of boardings
+ // Order by number of boardings to easily find the max value (the
+ // first result)
+ query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " +
+ boatAlias + ", COUNT(*) as " + countAlias + ")").
+ addGroup(contact + "." + Contact.BOAT).
+ addOrderDesc("COUNT(*)");
- List<Map<String, Object>> nbBoardingsByBoat = query.execute();
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
- if (!nbBoardingsByBoat.isEmpty()) {
- for (Map<String, Object> row : nbBoardingsByBoat) {
- Long count = (Long)row.get(countAlias);
- int intValue = count.intValue();
- String value = count.toString();
- if (intValue >= maxBoardings) {
- value = maxBoardingsKey;
- }
- // Increment the number of boats for the current number of
- // boardings
- Integer nbBoats = map.get(value);
- map.put(value, nbBoats + 1);
- }
+ List<Map<String, Object>> nbBoardingsByBoat = query.execute();
- // Set the max boat and its number of boardings value
- Map<String, Object> max = nbBoardingsByBoat.get(0);
- result.setMaxBoardingBoat((Boat)max.get(boatAlias));
- Long maxValue = (Long)max.get(countAlias);
- result.setMaxBoardingValue(maxValue.intValue());
+ if (!nbBoardingsByBoat.isEmpty()) {
+ for (Map<String, Object> row : nbBoardingsByBoat) {
+ Long count = (Long)row.get(countAlias);
+ int intValue = count.intValue();
+ String value = count.toString();
+ if (intValue >= maxBoardings) {
+ value = maxBoardingsKey;
+ }
+ // Increment the number of boats for the current number of
+ // boardings
+ Integer nbBoats = map.get(value);
+ map.put(value, nbBoats + 1);
}
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getBoardingBoats ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de récupérer les données pour le graphique " +
-// "dynamique des efforts de marées", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ // Set the max boat and its number of boardings value
+ Map<String, Object> max = nbBoardingsByBoat.get(0);
+ result.setMaxBoardingBoat((Boat)max.get(boatAlias));
+ Long maxValue = (Long)max.get(countAlias);
+ result.setMaxBoardingValue(maxValue.intValue());
+ }
return result;
}
@Override
public Map<String, Double> executeGetNonComplianceBoardingIndicator(
TopiaContext transaction, Company company) throws TopiaException {
-// TopiaContext transaction = null;
+
// Carefull with results, the company may not be present in the map :
// only if there is no unfinished sampleRow or no contact done
Map<String, Double> results = new HashMap<String, Double>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-
- // Only for done contacts with no constraint
- TopiaQuery query =
- dao.createQueryDoneContactsFromDate(null, null);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- String contact = query.getMainAlias();
- String sampleRow = contact + "." + Contact.SAMPLE_ROW;
- String companyProp = sampleRow + "." + SampleRow.COMPANY;
- String companyName = companyProp + "." + Company.NAME;
+ // Only for done contacts with no constraint
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(null, null);
- // Only for unfinished sampleRows
- Date current = context.getCurrentDate();
- query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
+ String contact = query.getMainAlias();
+ String sampleRow = contact + "." + Contact.SAMPLE_ROW;
+ String companyProp = sampleRow + "." + SampleRow.COMPANY;
+ String companyName = companyProp + "." + Company.NAME;
- if (company != null) {
- query.add(companyProp, company);
- }
+ // Only for unfinished sampleRows
+ Date current = context.getCurrentDate();
+ query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
- // Prepare results
- query.setSelect(companyName, "COUNT(*)").addGroup(companyName);
+ if (company != null) {
+ query.add(companyProp, company);
+ }
- if (log.isDebugEnabled()) {
- log.debug("Exec query for total : " + query);
- }
+ // Prepare results
+ query.setSelect(companyName, "COUNT(*)").addGroup(companyName);
- List<Object[]> totalResults = query.execute();
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query for total : " + query);
+ }
- // Use the same query and add the constraint of non compliance
- //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
- query.add(contact + "." + Contact.NB_OBSERVANTS + " < " +
- sampleRow + "." + SampleRow.NB_OBSERVANTS);
+ List<Object[]> totalResults = query.execute();
- if (log.isDebugEnabled()) {
- log.debug("Exec query for result : " + query);
- }
+ // Use the same query and add the constraint of non compliance
+ //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
+ query.add(contact + "." + Contact.NB_OBSERVANTS + " < " +
+ sampleRow + "." + SampleRow.NB_OBSERVANTS);
- List<Object[]> diffResults = query.execute();
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query for result : " + query);
+ }
- // Use the map to set the number of non compliance results
- for (Object[] row : diffResults) {
- String rowCompanyName = (String)row[0];
- Long rowCount = (Long)row[1];
- if (log.isDebugEnabled()) {
- log.debug("result row : " + rowCompanyName + " = " + rowCount);
- }
- results.put(rowCompanyName, rowCount.doubleValue());
- }
+ List<Object[]> diffResults = query.execute();
- // Get the previous value from the map and make the division to have
- // the result percent of non compliance. Put 0 in the map if no
- // previous result is set
- for (Object[] row : totalResults) {
- String rowCompanyName = (String)row[0];
- Long rowCount = (Long)row[1];
- if (log.isDebugEnabled()) {
- log.debug("total row : " + rowCompanyName + " = " + rowCount);
- }
- Double value = results.get(rowCompanyName);
- if (value == null) {
- results.put(rowCompanyName, 0.);
- } else {
- results.put(rowCompanyName, value / rowCount);
- }
+ // Use the map to set the number of non compliance results
+ for (Object[] row : diffResults) {
+ String rowCompanyName = (String)row[0];
+ Long rowCount = (Long)row[1];
+ if (log.isDebugEnabled()) {
+ log.debug("result row : " + rowCompanyName + " = " + rowCount);
}
+ results.put(rowCompanyName, rowCount.doubleValue());
+ }
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// String msgEnd = "";
-// if (company != null) {
-// msgEnd = " pour la société " + company.getName();
-// }
-// context.serviceException(transaction,
-// "Impossible de récupérer l'indicateur de non respect du " +
-// "nombre d'observateurs embarqués" + msgEnd, eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ // Get the previous value from the map and make the division to have
+ // the result percent of non compliance. Put 0 in the map if no
+ // previous result is set
+ for (Object[] row : totalResults) {
+ String rowCompanyName = (String)row[0];
+ Long rowCount = (Long)row[1];
+ if (log.isDebugEnabled()) {
+ log.debug("total row : " + rowCompanyName + " = " + rowCount);
+ }
+ Double value = results.get(rowCompanyName);
+ if (value == null) {
+ results.put(rowCompanyName, 0.);
+ } else {
+ results.put(rowCompanyName, value / rowCount);
+ }
+ }
return results;
}
@@ -382,93 +310,68 @@
public Collection<ContactStateStatistics> executeGetContactStateStatistics(
TopiaContext transaction, Company company, PeriodDates period)
throws TopiaException {
-// TopiaContext transaction = null;
+
Map<String, ContactStateStatistics> results =
new HashMap<String, ContactStateStatistics>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- // Only for contacts not refused by the program
- String contact = "C";
- String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM;
- TopiaQuery query = dao.createQuery(contact).
- add(validationProgram + " IS NULL " +
- "OR " + validationProgram + " = :booleanTrue").
- addParam("booleanTrue", Boolean.TRUE);
+ // Only for contacts not refused by the program
+ String contact = "C";
+ String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM;
+ TopiaQuery query = dao.createQuery(contact).
+ add(validationProgram + " IS NULL " +
+ "OR " + validationProgram + " = :booleanTrue").
+ addParam("booleanTrue", Boolean.TRUE);
- String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
+ String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
- if (company != null) {
- query.add(companyProp, company);
- }
+ if (company != null) {
+ query.add(companyProp, company);
+ }
- if (period != null) {
- // Contacts include in the period
- String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
- String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
- query.add("(" + tideBeginDate + " IS NOT NULL " +
- "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" +
- " OR (" + tideBeginDate + " IS NULL " +
- "AND " + createDate + " BETWEEN :fromDate AND :thruDate)");
+ if (period != null) {
+ // Contacts include in the period
+ String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
+ String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
+ query.add("(" + tideBeginDate + " IS NOT NULL " +
+ "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" +
+ " OR (" + tideBeginDate + " IS NULL " +
+ "AND " + createDate + " BETWEEN :fromDate AND :thruDate)");
- period.initDayOfMonthExtremities();
- query.addParam("fromDate", period.getFromDate()).
- addParam("thruDate", period.getThruDate());
- }
+ period.initDayOfMonthExtremities();
+ query.addParam("fromDate", period.getFromDate()).
+ addParam("thruDate", period.getThruDate());
+ }
- String stateProp = contact + "." + Contact.STATE;
- String companyName = companyProp + "." + Company.NAME;
- query.addGroup(companyName, stateProp).
- addOrder(companyName).
- setSelect(companyName, stateProp, "COUNT(*)");
+ String stateProp = contact + "." + Contact.STATE;
+ String companyName = companyProp + "." + Company.NAME;
+ query.addGroup(companyName, stateProp).
+ addOrder(companyName).
+ setSelect(companyName, stateProp, "COUNT(*)");
- if (log.isDebugEnabled()) {
- log.debug("Exec query : " + query);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
- List<Object[]> res = query.execute();
+ List<Object[]> res = query.execute();
- for (Object[] row : res) {
- String rowCompanyName = (String)row[0];
- int rowState = (Integer)row[1];
- ContactState state = ContactState.valueOf(rowState);
- Long rowCount = (Long)row[2];
- if (log.isDebugEnabled()) {
- log.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount);
- }
- ContactStateStatistics stats = results.get(rowCompanyName);
- if (stats == null) {
- stats = new ContactStateStatisticsImpl();
- stats.setCompanyName(rowCompanyName);
- results.put(rowCompanyName, stats);
- }
- stats.addResult(state, rowCount.intValue());
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ int rowState = (Integer)row[1];
+ ContactState state = ContactState.valueOf(rowState);
+ Long rowCount = (Long)row[2];
+ if (log.isDebugEnabled()) {
+ log.debug("res : " + rowCompanyName + " _ " + state + " _ " + rowCount);
}
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getContactStateStatistics ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// } catch (Exception eee) {
-// String msgEnd = "";
-// if (company != null) {
-// msgEnd = " pour la société " + company.getName();
-// }
-// context.serviceException(transaction,
-// "Impossible de récupérer les statistiques sur les états des " +
-// "contacts " + msgEnd, eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ ContactStateStatistics stats = results.get(rowCompanyName);
+ if (stats == null) {
+ stats = new ContactStateStatisticsImpl();
+ stats.setCompanyName(rowCompanyName);
+ results.put(rowCompanyName, stats);
+ }
+ stats.addResult(state, rowCount.intValue());
+ }
return results.values();
}
@@ -476,91 +379,62 @@
public Collection<ContactAverageReactivity>
executeGetContactDataInputDateReactivity(TopiaContext transaction,
Company company, PeriodDates period) throws TopiaException {
-// TopiaContext transaction = null;
// Carefull with results, the company may not be present in the map :
// only if there is no unfinished sampleRow or no contact done
Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
-// String contact = "C";
-// TopiaQuery query = dao.createQuery(contact);
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
- TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
-
- String contact = query.getMainAlias();
- String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
- String companyName = companyKey + "." + Company.NAME;
+ String contact = query.getMainAlias();
+ String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
+ String companyName = companyKey + "." + Company.NAME;
- if (company != null) {
- query.add(companyKey, company);
- }
+ if (company != null) {
+ query.add(companyKey, company);
+ }
- String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
- //period.initDayOfMonthExtremities();
+ String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
+ //period.initDayOfMonthExtremities();
- if (period.getThruDate() != null) {
- query.add(tideBegin, Op.LE, period.getThruDate());
- }
+ if (period.getThruDate() != null) {
+ query.add(tideBegin, Op.LE, period.getThruDate());
+ }
- String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
- query.setSelect(companyName, dataInput, tideBegin);
+ String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
+ query.setSelect(companyName, dataInput, tideBegin);
- if (log.isDebugEnabled()) {
- log.debug("Exec query : " + query);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
- List<Object[]> res = query.execute();
+ List<Object[]> res = query.execute();
- for (Object[] row : res) {
- String rowCompanyName = (String)row[0];
- Date rowDataInputDate = (Date)row[1];
- Date rowTideBeginDate = (Date)row[2];
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ Date rowDataInputDate = (Date)row[1];
+ Date rowTideBeginDate = (Date)row[2];
- int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
+ int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
- if (log.isDebugEnabled()) {
- log.debug("Company : " + rowCompanyName);
- log.debug("tideBegin : " + rowTideBeginDate);
- log.debug("dataInput : " + rowDataInputDate);
- log.debug("nbDays : " + nbDays);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Company : " + rowCompanyName);
+ log.debug("tideBegin : " + rowTideBeginDate);
+ log.debug("dataInput : " + rowDataInputDate);
+ log.debug("nbDays : " + nbDays);
+ }
- ContactAverageReactivity avg = results.get(rowCompanyName);
- if (avg == null) {
- avg = new ContactAverageReactivityImpl();
- avg.setCompanyName(rowCompanyName);
- results.put(rowCompanyName, avg);
- }
-
- avg.addValue(nbDays);
+ ContactAverageReactivity avg = results.get(rowCompanyName);
+ if (avg == null) {
+ avg = new ContactAverageReactivityImpl();
+ avg.setCompanyName(rowCompanyName);
+ results.put(rowCompanyName, avg);
}
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getContactDataInputDateReactivity ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// } catch (Exception eee) {
-// String msgEnd = "";
-// if (company != null) {
-// msgEnd = " pour la société " + company.getName();
-// }
-// context.serviceException(transaction,
-// "Impossible de récupérer l'indicateur de réactivité sur " +
-// "les dates de saisies dans Allegro" + msgEnd, eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ avg.addValue(nbDays);
+ }
return results.values();
}
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:21:22 UTC (rev 409)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:28:32 UTC (rev 410)
@@ -49,11 +49,11 @@
wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
wao.error.serviceSampling.importSamplingPlanCsv=Erreur \u00E0 la ligne %1$d [CODE \= %2$s]
-wao.error.serviceSynthesis.getBoardingBoats=
-wao.error.serviceSynthesis.getContactDataInputDateReactivity=
-wao.error.serviceSynthesis.getContactStateStatistics=
-wao.error.serviceSynthesis.getDataSampling=
-wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=
+wao.error.serviceSynthesis.getBoardingBoats=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es du graphique concernant les embarquements sur les navires
+wao.error.serviceSynthesis.getContactDataInputDateReactivity=Impossible de r\u00E9cup\u00E9rer l'indicateur de r\u00E9activit\u00E9 sur les dates de saisies dans Allegro
+wao.error.serviceSynthesis.getContactStateStatistics=Impossible de r\u00E9cup\u00E9rer les statistiques sur les \u00E9tats des contacts
+wao.error.serviceSynthesis.getDataSampling=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es pour le graphique dynamique des efforts de mar\u00E9es
+wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=Impossible de r\u00E9cup\u00E9rer l'indicateur de non respect du nombre d'observateurs embarqu\u00E9s
wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion
wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9
wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur
1
0
01 Apr '10
Author: fdesbois
Date: 2010-04-01 18:21:22 +0000 (Thu, 01 Apr 2010)
New Revision: 409
Removed:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/mock/
Modified:
trunk/changelog.txt
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java
trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
Log:
- use ServiceTransformer for ServiceSynthesis
- delete old WaoContextO and WaoExceptionO
- clean ServiceContactImpl
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/changelog.txt 2010-04-01 18:21:22 UTC (rev 409)
@@ -9,6 +9,8 @@
Evolutions
++++++++++
+- [fdesbois] Utilisation ServiceTransformer de ToPIA pour générer le squelette
+ des services.
- [fdesbois] Evo #1980 : Droits "lecture seule" pour les utilisateurs
- [fdesbois] Evo #2233 : Gérer les formats de dates par défaut d'OpenOffice pour
l'import CSV (JJ/MM/AA)
@@ -32,7 +34,7 @@
+++++++++
- [fdesbois] Ano #2237 : Impossible de changer les zones de pêche
-- [fdesbois] Ano #2235 : Temp d'affichage page contacts ou plan
+- [fdesbois] Ano #2235 : Temps d'affichage lent pour les pages contacts et plan
d'échantillonnage
- [fdesbois] Ano #2228 : Erreur d'affichage de la synthèse : réactivité de la
saisie dans Allegro
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -33,7 +33,7 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class WaoBusinessException extends WaoExceptionO {
+public class WaoBusinessException extends Exception {
protected Type type;
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -22,6 +22,7 @@
package fr.ifremer.wao;
+import fr.ifremer.wao.io.ImportHelper;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.Locale;
@@ -208,13 +209,16 @@
// getValue() on PollenProperty
WaoProperty.setContext(this);
// temp
- WaoContextO.setContext(this);
+// WaoContextO.setContext(this);
// Set context in utils static class for entities
WaoUtils.setContext(this);
+
+ // Need to use it as an instance
+ ImportHelper.setContext(this);
// Create the default admin in database
- WaoGlobal.createDefaultAdmin();
+ WaoGlobal.createDefaultAdmin(this);
if (log.isInfoEnabled()) {
log.info("wao is started !");
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -1,248 +0,0 @@
-/**
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-
-package fr.ifremer.wao;
-
-
-import fr.ifremer.wao.entity.ActivityCalendar;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Date;
-import java.util.Properties;
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.SimpleEmail;
-import org.apache.log4j.Level;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.RollingFileAppender;
-import org.hibernate.exception.SQLGrammarException;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * WaoContext.java
- *
- * Created on 2009-11-23
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class WaoContextO {
-
- private static final Logger log = LoggerFactory.getLogger(WaoContextO.class);
-
- private static WaoRunner runner;
-
- private static boolean activityCalendarImport;
-
- private static org.apache.log4j.Logger activityCalendarAccessLogger;
-
- private static WaoContextImpl context;
-
- public static void setContext(WaoContextImpl context) {
- if (log.isDebugEnabled()) {
- log.debug("#### use correct context");
- }
- WaoContextO.context = context;
- }
-
- public static void setRunner(WaoRunner run) {
- if (log.isDebugEnabled()) {
- log.debug("set runner in context");
- }
- runner = run;
- }
-
- public static Date getCurrentDate() {
- return context.getCurrentDate();
- }
-
- public static String getProperty(String key) {
- return context.getConfiguration().getOption(key);
- }
-
- public static TopiaContext getTopiaRootContext() throws WaoExceptionO {
- if (context.getConfiguration() == null) {
- throw new WaoExceptionO("Configuration must be set before initializing context");
- }
- try {
- Properties props = context.getConfiguration().getOptions();
- return TopiaContextFactory.getContext(props);
- } catch (TopiaNotFoundException eee) {
- serviceException(null, eee.getMessage(), eee);
- }
- return null;
- }
-
- public static void setActivityCalendarImport(boolean value) {
- activityCalendarImport = value;
- }
-
- public static boolean isActivityCalendarImportRun() {
- return activityCalendarImport;
- }
-
- public static void addActivityCalendarAccessLog(String message) throws IOException {
- if (activityCalendarAccessLogger == null) {
- // Define appender configuration only once
- String filename =
- WaoProperty.FILENAME_LOG_ACTIVITY_ACCESS.getValue();
-
- PatternLayout layout = new PatternLayout();
- layout.setConversionPattern("%d %m%n");
- RollingFileAppender appender = new RollingFileAppender();
- appender.setName("ActivityCalendarAccess");
- appender.setFile(filename);
- appender.setImmediateFlush(true);
- appender.setMaxFileSize("2MB");
- appender.setMaxBackupIndex(10);
- appender.setAppend(true);
- appender.setThreshold(Level.INFO);
- appender.setLayout(layout);
- appender.activateOptions();
-
- activityCalendarAccessLogger =
- org.apache.log4j.Logger.getLogger(ActivityCalendar.class);
-
- activityCalendarAccessLogger.addAppender(appender);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("message : " + message);
- }
-
- activityCalendarAccessLogger.info(message);
- }
-
- public static void serviceException(TopiaContext transaction, String message, Exception eee) throws WaoExceptionO {
- if (log.isDebugEnabled()) {
- log.debug("An error occured",eee);
- }
- if (!(eee instanceof WaoExceptionO)) {
- //if (!(eee instanceof TopiaException)) {
- try {
- if (transaction != null && !transaction.isClosed()) {
- if (log.isInfoEnabled()) {
- log.info("Saving annulation : Transaction rollback");
- }
- transaction.rollbackTransaction();
- //transaction.closeContext();
- }
- } catch (TopiaException eeee) {
- throw new WaoExceptionO("Fatal topia error when close context", eeee);
- }
- //}
- if (eee instanceof SQLGrammarException && log.isErrorEnabled()) {
- log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL());
- }
- throw new WaoExceptionO(message,eee);
- } else {
- throw (WaoExceptionO)eee;
- }
- }
-
- public static void closeTransaction(TopiaContext transaction) throws WaoExceptionO {
- try {
- if (transaction != null) {
- transaction.closeContext();
- }
- } catch (TopiaException eee) {
- throw new WaoExceptionO("Fatal topia error when close context", eee);
- }
- }
-
- /**
- * Generate a random string of "length" character alphanumeric.
- * @param length number of characters for the final string
- * @return a String of "length" character
- */
- public static String createRandomString(int length) {
-// Random random = new Random();
-// StringBuilder sb = new StringBuilder();
-// while (sb.length() < length) {
-// sb.append(Integer.toHexString(random.nextInt()));
-// }
-// return sb.toString();
- return RandomStringUtils.randomAlphanumeric(length);
- }
-
- public static String encodeString(String string) {
- return MD5.encode(string);
- }
-
- public static String convertId(String topiaId) {
- if (topiaId != null && !topiaId.isEmpty()) {
- int index = topiaId.indexOf('#');
- String id = topiaId.replace('#', 'K');
- return id.substring(index);
- }
- return "";
- }
-
- public static Charset getCsvCharset() {
- return Charset.forName("UTF-8");
- }
-
- public static String prepareSampleRowCode(String code) {
- // Replace single number after year by a double one : 2010_111 -> 2010_0111
- code = code.replaceFirst("_(\\d{3})$", "_0$1");
- // Replace single number after year by a double one : 2010_11 -> 2010_0011
- code = code.replaceFirst("_(\\d{2})$", "_00$1");
- // Replace single number after year by a double one : 2010_1 -> 2010_0001
- code = code.replaceFirst("_(\\d)$", "_000$1");
- return code;
- }
-
- public static <E extends TopiaEntity> boolean prepareTopiaId(Class<E> entityClass, E entity) {
- String topiaId = entity.getTopiaId();
- // TODO-FD20100211 : add this behavior in topia in a
- // new method createOrUpdate
- if (StringUtils.isEmpty(entity.getTopiaId())) {
- topiaId = TopiaId.create(entityClass);
- entity.setTopiaId(topiaId);
- return true;
- }
- return false;
- }
-
- public static void sendEmail(String to, String subject, String msg) throws EmailException {
- SimpleEmail email = new SimpleEmail();
- email.setHostName(WaoProperty.EMAIL_HOST.getValue());
- email.setSmtpPort(Integer.parseInt(WaoProperty.EMAIL_PORT.getValue()));
- email.setFrom(WaoProperty.EMAIL_FROM.getValue());
- email.addTo(to);
- email.setSubject(subject);
- email.setMsg(msg);
- email.setCharset("UTF-8");
- email.send();
- }
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -1,44 +0,0 @@
-/*
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-package fr.ifremer.wao;
-
-/**
- * WaoException
- *
- * Created: 7 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoExceptionO extends Exception {
-
- public WaoExceptionO(String msg) {
- super(msg);
- }
-
- public WaoExceptionO(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -26,6 +26,7 @@
import fr.ifremer.wao.entity.CompanyDAO;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.entity.WaoUserDAO;
+import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,10 +51,11 @@
*
* @throws WaoException
*/
- static void createDefaultAdmin() throws WaoExceptionO {
+ static void createDefaultAdmin(WaoContextImplementor context)
+ throws WaoException {
TopiaContext transaction = null;
try {
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = context.beginTransaction();
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
@@ -73,7 +75,7 @@
Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
- String password = WaoContextO.encodeString("password");
+ String password = context.encodeString("password");
WaoUser user = dao.create(
WaoUser.ROLE, UserRole.ADMIN.ordinal(),
@@ -89,9 +91,11 @@
//transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(null, "Error during database initialization", eee);
+ context.doCatch(transaction, eee,
+ I18n.n_("wao.error.global.createDefaultAdmin"));
+ //Error during database initialization", eee);
} finally {
- WaoContextO.closeTransaction(transaction);
+ context.doFinally(transaction);
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -48,6 +48,6 @@
if (context != null) {
return context.getProperty(this);
}
- return WaoContextO.getProperty(key);
+ return null;
}
}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -1,68 +0,0 @@
-/*
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-package fr.ifremer.wao;
-
-import java.util.Date;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * WaoRun
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public interface WaoRunner {
-
- /**
- * Start the application.
- *
- * @throws WaoException
- */
- void start() throws WaoExceptionO;
-
- /**
- * Stop the application.
- *
- * @throws WaoException
- */
- void stop() throws WaoExceptionO;
-
- /**
- * Return the current date, depends on environment.
- *
- * @return the current Date
- */
- Date getCurrentDate();
-
- /**
- * Return the configuration depends on environment.
- *
- * @return the ApplicationConfig which contains the application properties
- */
- ApplicationConfig getConfiguration();
-
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -1,130 +0,0 @@
-/*
- * *##%
- * Wao :: Business
- * Copyright (C) 2009 - 2010 Ifremer
- *
- * 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 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * ##%*
- */
-
-package fr.ifremer.wao;
-
-import java.util.Date;
-import java.util.Locale;
-
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.migration.ManualMigrationEngine;
-import org.nuiton.util.ApplicationConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * StartWao
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoRunnerImpl implements WaoRunner {
-
- private ApplicationConfig configuration;
-
- private static final Logger logger =
- LoggerFactory.getLogger(WaoRunnerImpl.class);
-
- public WaoRunnerImpl() {
- }
-
- @Override
- public void start() throws WaoExceptionO {
- try {
- configuration = new ApplicationConfig();
- configuration.setAppName("wao");
- configuration.setConfigFileName("Wao.properties");
- configuration.parse(new String[]{});
- configuration.setOption("topia.persistence.classes",
- WaoDAOHelper.getImplementationClassesAsString());
-
- // migration configuration
- String callBackName = null;
- String dialect = configuration.getOption("hibernate.dialect");
- if (dialect.contains("PostgreSQL")) {
- callBackName = PgMigrationCallback.class.getName();
- } else if (dialect.contains("H2")) {
- // Unsupported yet
- callBackName = null;
- }
-
- if (callBackName != null) {
- configuration.setOption(
- ManualMigrationEngine.MIGRATION_APPLICATION_VERSION,
- WaoDAOHelper.getModelVersion());
- configuration.setOption(
- ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY,
- "oldmappings");
- configuration.setOption(
- ManualMigrationEngine.MIGRATION_MODEL_NAME,
- WaoDAOHelper.getModelName());
- configuration.setOption(
- "topia.service.migration",
- ManualMigrationEngine.class.getName());
- configuration.setOption(
- ManualMigrationEngine.MIGRATION_CALLBACK,
- callBackName);
- } else {
- if (logger.isWarnEnabled()) {
- logger.warn("Database with dialect " + dialect + " is not" +
- "supported for migration from 1.0 version");
- }
- }
-
- configuration.printConfig();
-
- I18n.init(Locale.FRANCE);
- // Use the context to set the runner for default environment.
- WaoContextO.setRunner(this);
- // Create the default admin in database
- WaoGlobal.createDefaultAdmin();
- } catch (Exception eee) {
- WaoContextO.serviceException(null,
- "Error during loadConfiguration from " +
- "'Wao.properties' file", eee);
- }
- }
-
- @Override
- public void stop() throws WaoExceptionO {
- try {
- WaoContextO.getTopiaRootContext().closeContext();
- } catch (TopiaException eee) {
- WaoContextO.serviceException(null, "Error when closing Topia root context", eee);
- }
- }
-
- @Override
- public Date getCurrentDate() {
- return new Date();
- }
-
- @Override
- public ApplicationConfig getConfiguration() {
- return configuration;
- }
-}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,13 +21,12 @@
package fr.ifremer.wao.bean;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.entity.FishingZone;
import fr.ifremer.wao.entity.SampleRow;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -95,7 +94,7 @@
// Only rows which are not finished will be kept
// Date current = WaoContext.getCurrentDate();
Calendar calendar = new GregorianCalendar();
- calendar.setTime(WaoContextO.getCurrentDate());
+ calendar.setTime(WaoUtils.getCurrentDate());
calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday());
query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime());
}
@@ -106,7 +105,8 @@
@Override
public boolean isSamplingFiltered() {
// all field except fromDate
- return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) || StringUtils.isNotEmpty(getFacadeName()) ||
+ return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName())
+ || StringUtils.isNotEmpty(getFacadeName()) ||
getPeriod() != null || getProfession() != null;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -59,6 +59,8 @@
LoggerFactory.getLogger(ImportHelper.class);
protected CsvReader reader;
+
+ protected static WaoContextImplementor context;
// 2000 -> 2099
public static final int CURRENT_MILLENIUM = 2000;
@@ -70,6 +72,10 @@
this.reader = reader;
}
+ public static void setContext(WaoContextImplementor context) {
+ ImportHelper.context = context;
+ }
+
public static Boolean parseContactValidation(CsvReader reader, IOHeader header) throws IOException {
String validation = read(reader, header);
Boolean result = null;
@@ -94,7 +100,7 @@
time.setTime(timeFormat.parse(code));
} else {
// Use current date with no time as a reference if no code is set
- time.setTime(WaoContextO.getCurrentDate());
+ time.setTime(context.getCurrentDate());
time.set(Calendar.HOUR_OF_DAY, 0);
time.set(Calendar.MINUTE, 0);
time.set(Calendar.SECOND, 0);
@@ -110,14 +116,14 @@
result.set(Calendar.SECOND, time.get(Calendar.SECOND));
result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
} else {
- result.setTime(WaoContextO.getCurrentDate());
+ result.setTime(context.getCurrentDate());
}
return result.getTime();
}
public static String readSampleRowCode(CsvReader reader) throws IOException {
String code = read(reader, SAMPLING.PLAN_CODE);
- return WaoContextO.prepareSampleRowCode(code);
+ return context.prepareSampleRowCode(code);
}
/**
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -28,7 +28,6 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.bean.ContactState;
import java.io.IOException;
import java.io.InputStream;
@@ -64,14 +63,11 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -91,91 +87,39 @@
*/
public class ServiceContactImpl extends ServiceContactAbstract {
- private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(ServiceContactImpl.class);
-// protected TopiaContext rootContext;
-//
-// public ServiceContactImpl() throws WaoExceptionO {
-// rootContext = context.getTopiaRootContext();
-// }
-
@Override
public Map<String, Contact> executeGetContacts(TopiaContext transaction,
ContactFilter filter) throws TopiaException {
-// Map<String, Contact> results = new HashMap<String, Contact>();
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQuery("C").addDistinct();
+ TopiaQuery query = dao.createQuery("C").addDistinct();
- query = filter.prepareQueryForContact(query);
+ query = filter.prepareQueryForContact(query);
- query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE).addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY);
+ query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE).
+ addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY);
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
- query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH);
- return dao.findAllMappedByQuery(query);
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getContacts ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de filtrer la liste des contacts", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return results;
+ query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH);
+ return dao.findAllMappedByQuery(query);
}
@Override
public int executeGetNbContacts(TopiaContext transaction,
ContactFilter filter) throws TopiaException {
-// TopiaContext transaction = null;
-// int result = 0;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQuery("C");
- query = filter.prepareQueryForContact(query);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ TopiaQuery query = dao.createQuery("C");
+ query = filter.prepareQueryForContact(query);
- return query.executeCount();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getNbContacts ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de compter le nombre de contacts filtrés", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return result;
+ return query.executeCount();
}
@Override
@@ -191,52 +135,29 @@
@Override
public void executeSaveContact(TopiaContext transaction,
Contact contact, boolean delete) throws TopiaException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- if (log.isDebugEnabled()) {
- log.debug("Create date : " + contact.getTopiaCreateDate());
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Create date : " + contact.getTopiaCreateDate());
+ }
- context.prepareTopiaId(Contact.class, contact);
- if (delete) {
- dao.delete(contact);
- } else {
- dao.update(contact);
- }
+ context.prepareTopiaId(Contact.class, contact);
+ if (delete) {
+ dao.delete(contact);
+ } else {
+ dao.update(contact);
+ }
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ saveContact ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de sauvegarder le contact", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
@Override
public InputStream executeExportContactCsv(TopiaContext transaction,
ContactFilter filter) throws Exception {
-// TopiaContext transaction = null;
-// InputStream result = null;
+
CsvWriter writer = null;
try {
-// transaction = rootContext.beginTransaction();
File file = File.createTempFile("wao-contacts-", ".csv");
file.deleteOnExit();
@@ -248,7 +169,9 @@
FileOutputStream output = new FileOutputStream(file);
writer = new CsvWriter(output, ',', context.getCsvCharset());
- ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) {
+ ExportHelper<ContactHeader> export =
+ new ExportHelper<ContactHeader>(writer,
+ CONTACT.getTotalHeaders()) {
@Override
public void record(ContactHeader header, String value) {
@@ -256,9 +179,11 @@
}
@Override
- protected String getHeaderValue(int index) throws IOException {
+ protected String getHeaderValue(int index)
+ throws IOException {
if (log.isDebugEnabled()) {
- log.debug("record header : " + index + " = " + WaoCsvHeader.getHeaderForContactCsv(index));
+ log.debug("record header : " + index + " = " +
+ WaoCsvHeader.getHeaderForContactCsv(index));
}
return WaoCsvHeader.getHeaderForContactCsv(index);
}
@@ -288,24 +213,36 @@
export.newRecord();
// Contact part
- export.record(CONTACT.CONT_CODE, timeFormat.format(contact.getTopiaCreateDate()));
- export.record(CONTACT.CONT_CREATION, dateFormat.format(contact.getTopiaCreateDate()));
- export.record(CONTACT.CONT_ETAT, contact.getContactState().libelle());
+ export.record(CONTACT.CONT_CODE,
+ timeFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_CREATION,
+ dateFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_ETAT,
+ contact.getContactState().libelle());
if (contact.getTideBeginDate() != null) {
- export.record(CONTACT.CONT_DEBUT_MAREE, dateFormat.format(contact.getTideBeginDate()));
+ export.record(CONTACT.CONT_DEBUT_MAREE,
+ dateFormat.format(contact.getTideBeginDate()));
}
if (contact.getTideEndDate() != null) {
- export.record(CONTACT.CONT_FIN_MAREE, dateFormat.format(contact.getTideEndDate()));
+ export.record(CONTACT.CONT_FIN_MAREE,
+ dateFormat.format(contact.getTideEndDate()));
}
- export.record(CONTACT.CONT_NB_OBSERV, String.valueOf(contact.getNbObservants()));
- export.record(CONTACT.CONT_MAM_CAPT, CONTACT.formatMammals(contact.getMammalsCapture()));
- export.record(CONTACT.CONT_MAM_OBS, CONTACT.formatMammals(contact.getMammalsObservation()));
- export.record(CONTACT.CONT_COMMENT, contact.getComment());
+ export.record(CONTACT.CONT_NB_OBSERV,
+ String.valueOf(contact.getNbObservants()));
+ export.record(CONTACT.CONT_MAM_CAPT,
+ CONTACT.formatMammals(contact.getMammalsCapture()));
+ export.record(CONTACT.CONT_MAM_OBS,
+ CONTACT.formatMammals(contact.getMammalsObservation()));
+ export.record(CONTACT.CONT_COMMENT,
+ contact.getComment());
if (contact.getDataInputDate() != null) {
- export.record(CONTACT.CONT_ALLEGRO, dateFormat.format(contact.getDataInputDate()));
+ export.record(CONTACT.CONT_ALLEGRO,
+ dateFormat.format(contact.getDataInputDate()));
}
- export.record(CONTACT.CONT_SOCIETE_VALID, CONTACT.formatValidation(contact.getValidationCompany()));
- export.record(CONTACT.CONT_PROGRAM_VALID, CONTACT.formatValidation(contact.getValidationProgram()));
+ export.record(CONTACT.CONT_SOCIETE_VALID,
+ CONTACT.formatValidation(contact.getValidationCompany()));
+ export.record(CONTACT.CONT_PROGRAM_VALID,
+ CONTACT.formatValidation(contact.getValidationProgram()));
// Observer part
WaoUser observer = contact.getObserver();
@@ -319,9 +256,12 @@
SampleRow row = contact.getSampleRow();
export.record(SAMPLING.PLAN_CODE, row.getCode());
export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
- export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
- export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
- export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
+ export.record(SAMPLING.PROGRAMME_DEBUT,
+ dateFormat.format(row.getPeriodBegin()));
+ export.record(SAMPLING.PROGRAMME_FIN,
+ dateFormat.format(row.getPeriodEnd()));
+ export.record(SAMPLING.PECHE_AUTRE,
+ row.getFishingZonesInfos());
// FishingZone part
String divisions = "";
@@ -329,14 +269,17 @@
for (FishingZone zone : row.getFishingZone()) {
divisions += separator + zone.getDistrictCode();
}
- export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
+ export.record(FISHING_ZONE.PECHE_DIVISION,
+ divisions.substring(separator.length()));
export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
// Profession part
Profession profession = row.getProfession();
- export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
- export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
+ export.record(SAMPLING.METIER_CODE_DCF5,
+ profession.getCodeDCF5());
+ export.record(SAMPLING.METIER_MAILLAGE,
+ profession.getMeshSize());
export.record(SAMPLING.METIER_TAILLE, profession.getSize());
export.record(SAMPLING.METIER_AUTRE, profession.getOther());
export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
@@ -344,7 +287,8 @@
// Boat part
Boat boat = contact.getBoat();
- export.record(BOAT.NAVS_COD, String.valueOf(boat.getImmatriculation()));
+ export.record(BOAT.NAVS_COD,
+ String.valueOf(boat.getImmatriculation()));
export.record(BOAT.CARN_NOM, boat.getName());
export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode());
@@ -352,18 +296,13 @@
}
return new FileInputStream(file);
- //transaction.closeContext();
} catch (Exception eee) {
throw eee;
-// context.serviceException(transaction,
-// "Impossible d'exporter les contacts", eee);
} finally {
if (writer != null) {
writer.close();
}
-// context.closeTransaction(transaction);
}
-// return result;
}
@Override
@@ -371,189 +310,221 @@
WaoUser user, InputStream input)
throws TopiaException, IOException,
WaoBusinessException, ParseException {
-// TopiaContext transaction = null;
+
ImportResults result = new ImportResultsImpl();
int currRow = 1;
-// CsvReader reader = null;
-// try {
-// transaction = rootContext.beginTransaction();
- CsvReader reader = new CsvReader(input, context.getCsvCharset());
- reader.readHeaders();
+ CsvReader reader = new CsvReader(input, context.getCsvCharset());
+ reader.readHeaders();
- ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction);
- CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction);
- SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction);
- BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction);
-
- long tic;
- tic = System.currentTimeMillis();
- while(reader.readRecord()) {
- currRow++;
+ ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
+ WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction);
+ SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction);
+ BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction);
- String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID);
- String state = ImportHelper.read(reader, CONTACT.CONT_ETAT);
+ long tic;
+ tic = System.currentTimeMillis();
+ while(reader.readRecord()) {
+ currRow++;
- ContactState contactState = ContactState.valueOfLibelle(state);
+ String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID);
+ String state = ImportHelper.read(reader, CONTACT.CONT_ETAT);
- if (contactState == null) {
- throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ ContactState contactState = ContactState.valueOfLibelle(state);
+
+ if (contactState == null) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR,
+ this.getClass(),
+ "Erreur ligne " + currRow + " : " +
+ "Etat du contact invalide '" + state + "', " +
+ "valeurs possibles : " +
+ ContactState.availableStates());
+ }
+
+ WaoUser observer = userDAO.findByLogin(observerId);
+ if (observer != null) {
+ Company company = user.getCompany();
+ // For an admin, get the company from database
+ if (user.isAdmin()) {
+ // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl
+ //company = companyDAO.findContainsWaoUser(observer);
+ company = observer.getCompany();
+ // For a user, check if the observer as the same company as the current user
+ } else if (!observer.getCompany().equals(company)) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR,
+ this.getClass(),
"Erreur ligne " + currRow + " : " +
- "Etat du contact invalide '" + state + "', valeurs possibles : " +
- ContactState.availableStates());
+ "L'observateur avec pour login '" + observerId +
+ "' n'appartient pas à votre société !");
}
- WaoUser observer = userDAO.findByLogin(observerId);
- if (observer != null) {
- Company company = user.getCompany();
- // For an admin, get the company from database
- if (user.isAdmin()) {
- // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl
- //company = companyDAO.findContainsWaoUser(observer);
- company = observer.getCompany();
- // For a user, check if the observer as the same company as the current user
- } else if (!observer.getCompany().equals(company)) {
- throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur ligne " + currRow + " : " +
- "L'observateur avec pour login '" + observerId + "' n'appartient pas à votre société !");
- }
+ if (company != null) {
+ String rowCode = ImportHelper.readSampleRowCode(reader);
- if (company != null) {
- String rowCode = ImportHelper.readSampleRowCode(reader);
+ SampleRow row = rowDAO.findByProperties(
+ SampleRow.CODE, rowCode,
+ SampleRow.COMPANY, company);
- SampleRow row = rowDAO.findByProperties(SampleRow.CODE, rowCode, SampleRow.COMPANY, company);
+ if (row != null) {
+ int boatImmatriculation =
+ ImportHelper.readInt(reader, BOAT.NAVS_COD);
- if (row != null) {
- int boatImmatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD);
+ Boat boat = boatDAO.findByImmatriculation(
+ boatImmatriculation);
- Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
+ if (boat != null) {
- if (boat != null) {
+ ElligibleBoatDAO elligibleDAO =
+ WaoDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoat elligible =
+ elligibleDAO.findByProperties(
+ ElligibleBoat.BOAT, boat,
+ ElligibleBoat.SAMPLE_ROW, row);
- ElligibleBoatDAO elligibleDAO = WaoDAOHelper.getElligibleBoatDAO(transaction);
- ElligibleBoat elligible = elligibleDAO.findByProperties(
- ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
-
- if (elligible == null) {
- // Create new elligible boat not active in a global way
- elligible = elligibleDAO.create(
- ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
- if (log.isTraceEnabled()) {
- log.trace("Create elligibleBoat for : " + boat.getImmatriculation() + " - " + row.getCode());
- }
+ if (elligible == null) {
+ // Create new elligible boat not active in a global way
+ elligible = elligibleDAO.create(
+ ElligibleBoat.BOAT, boat,
+ ElligibleBoat.SAMPLE_ROW, row);
+ if (log.isTraceEnabled()) {
+ log.trace("Create elligibleBoat for : " +
+ boat.getImmatriculation() + " - " +
+ row.getCode());
}
- elligible.setCompanyActive(Boolean.TRUE);
+ }
+ elligible.setCompanyActive(Boolean.TRUE);
- Contact contact = null;
+ Contact contact = null;
- String createDateString = ImportHelper.read(reader, CONTACT.CONT_CREATION);
- String contactCode = ImportHelper.read(reader, CONTACT.CONT_CODE);
- Date createDate = ImportHelper.parseContactCreateDate(contactCode, createDateString);
+ String createDateString =
+ ImportHelper.read(reader,
+ CONTACT.CONT_CREATION);
+ String contactCode =
+ ImportHelper.read(reader,
+ CONTACT.CONT_CODE);
+ Date createDate =
+ ImportHelper.parseContactCreateDate(
+ contactCode, createDateString);
- if (log.isDebugEnabled()) {
- log.debug("Ligne " + currRow + " : Create date : " + createDate);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Ligne " + currRow +
+ " : Create date : " + createDate);
+ }
- if (/*!StringUtils.isEmpty(contactCode) && */StringUtils.isNotEmpty(createDateString)) {
- // Get entity from database
- TopiaQuery query = dao.createQuery().
- add(TopiaEntity.TOPIA_CREATE_DATE, createDate).
- add(Contact.OBSERVER + "." + WaoUser.COMPANY, company).
- add(Contact.BOAT, boat).
- add(Contact.SAMPLE_ROW, row);
- contact = dao.findByQuery(query);
- }
+ if (/*!StringUtils.isEmpty(contactCode) && */
+ StringUtils.isNotEmpty(createDateString)) {
+ // Get entity from database
+ TopiaQuery query = dao.createQuery().
+ add(TopiaEntity.TOPIA_CREATE_DATE,
+ createDate).
+ add(Contact.OBSERVER + "." +
+ WaoUser.COMPANY, company).
+ add(Contact.BOAT, boat).
+ add(Contact.SAMPLE_ROW, row);
+ contact = dao.findByQuery(query);
+ }
- if (contact != null && contact.getValidationCompany() != null) {
- result.addError(currRow, "Le contact est déjà validé dans l'application et ne peut pas être importé");
- result.incNbRefused();
- continue;
- }
+ if (contact != null &&
+ contact.getValidationCompany() != null) {
+ result.addError(currRow, "Le contact est" +
+ " déjà validé dans l'application" +
+ " et ne peut pas être importé");
+ result.incNbRefused();
+ continue;
+ }
- // new contact to import
- boolean newContact = false;
- if (contact == null) {
- contact = dao.create(
- TopiaEntity.TOPIA_CREATE_DATE, createDate,
- Contact.SAMPLE_ROW, row,
- Contact.BOAT, boat);
- newContact = true;
- }
+ // new contact to import
+ boolean newContact = false;
+ if (contact == null) {
+ contact = dao.create(
+ TopiaEntity.TOPIA_CREATE_DATE, createDate,
+ Contact.SAMPLE_ROW, row,
+ Contact.BOAT, boat);
+ newContact = true;
+ }
- Date tideBegin = ImportHelper.readDate(reader, CONTACT.CONT_DEBUT_MAREE);
- Date tideEnd = ImportHelper.readDate(reader, CONTACT.CONT_FIN_MAREE);
- Date dataInput = ImportHelper.readDate(reader, CONTACT.CONT_ALLEGRO);
- int nbObservants = ImportHelper.readInt(reader, CONTACT.CONT_NB_OBSERV);
- if (nbObservants == -1) {
- nbObservants = 0;
- }
- boolean mammalsCapture =
- ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_CAPT);
- boolean mammalsObsv =
- ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_OBS);
+ Date tideBegin =
+ ImportHelper.readDate(reader,
+ CONTACT.CONT_DEBUT_MAREE);
+ Date tideEnd =
+ ImportHelper.readDate(reader,
+ CONTACT.CONT_FIN_MAREE);
+ Date dataInput =
+ ImportHelper.readDate(reader,
+ CONTACT.CONT_ALLEGRO);
+ int nbObservants = ImportHelper.readInt(reader,
+ CONTACT.CONT_NB_OBSERV);
+ if (nbObservants == -1) {
+ nbObservants = 0;
+ }
+ boolean mammalsCapture =
+ ImportHelper.parseContactMammals(reader,
+ CONTACT.CONT_MAM_CAPT);
+ boolean mammalsObsv =
+ ImportHelper.parseContactMammals(reader,
+ CONTACT.CONT_MAM_OBS);
- contact.setObserver(observer);
- contact.setContactState(contactState);
- contact.setTideBeginDate(tideBegin);
- contact.setTideEndDate(tideEnd);
- contact.setNbObservants(nbObservants);
- contact.setMammalsCapture(mammalsCapture);
- contact.setMammalsObservation(mammalsObsv);
- contact.setDataInputDate(dataInput);
+ contact.setObserver(observer);
+ contact.setContactState(contactState);
+ contact.setTideBeginDate(tideBegin);
+ contact.setTideEndDate(tideEnd);
+ contact.setNbObservants(nbObservants);
+ contact.setMammalsCapture(mammalsCapture);
+ contact.setMammalsObservation(mammalsObsv);
+ contact.setDataInputDate(dataInput);
- // Import validations only for superadmin and a new contact : useful for archives
- // FIXME : can update validation when the user is the super admin
- if (newContact && user.isAdmin() && user.getLogin().equals("admin")) {
- if (log.isDebugEnabled()) {
- log.debug("SuperAdmin import :: validations");
- }
- Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID);
- Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID);
- contact.setValidationCompany(companyValidation);
- contact.setValidationProgram(programValidation);
+ // Import validations only for superadmin and a new contact : useful for archives
+ // FIXME : can update validation when the user is the super admin
+ if (newContact && user.isAdmin() && user.getLogin().equals("admin")) {
+ if (log.isDebugEnabled()) {
+ log.debug("SuperAdmin import :: validations");
+ }
+ Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID);
+ Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID);
+ contact.setValidationCompany(companyValidation);
+ contact.setValidationProgram(programValidation);
- // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE
- if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) &&
- contact.getContactState().equals(ContactState.BOARDING_DONE)) {
- boolean ok = contact.getSampleRow().addRealTideTime(contact);
- if (!ok) {
- DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy");
- result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " +
- "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode());
- result.incNbRefused();
- continue;
- }
+ // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE
+ if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) &&
+ contact.getContactState().equals(ContactState.BOARDING_DONE)) {
+ boolean ok = contact.getSampleRow().addRealTideTime(contact);
+ if (!ok) {
+ DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy");
+ result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " +
+ "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode());
+ result.incNbRefused();
+ continue;
}
}
+ }
- result.incNbImported();
+ result.incNbImported();
- } else {
- result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation);
- result.incNbRefused();
- }
} else {
- result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " +
- "pour le code : " + rowCode);
+ result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation);
result.incNbRefused();
}
} else {
- result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName());
+ result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " +
+ "pour le code : " + rowCode);
result.incNbRefused();
}
} else {
- result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId);
+ result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName());
result.incNbRefused();
}
+ } else {
+ result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId);
+ result.incNbRefused();
+ }
- if (result.getNbRowsImported() % 1000 == 0) {
- transaction.commitTransaction();
- tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow);
- }
+ if (result.getNbRowsImported() % 1000 == 0) {
+ transaction.commitTransaction();
+ tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow);
}
+ }
- transaction.commitTransaction();
+ transaction.commitTransaction();
//transaction.closeContext();
// } catch (ParseException eee) {
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,9 +21,8 @@
package fr.ifremer.wao.service;
-import fr.ifremer.wao.WaoContextO;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.ContactAverageReactivityImpl;
import fr.ifremer.wao.bean.ContactAverageReactivity;
import fr.ifremer.wao.bean.BoardingResult;
@@ -51,8 +50,8 @@
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -72,26 +71,29 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class ServiceSynthesisImpl implements ServiceSynthesis {
+public class ServiceSynthesisImpl extends ServiceSynthesisAbstract {
private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class);
- protected TopiaContext rootContext;
+// protected TopiaContext rootContext;
+//
+// public ServiceSynthesisImpl() throws WaoExceptionO {
+// rootContext = context.getTopiaRootContext();
+// }
- public ServiceSynthesisImpl() throws WaoExceptionO {
- rootContext = WaoContextO.getTopiaRootContext();
- }
-
@Override
- public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoExceptionO {
- TopiaContext transaction = null;
- List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public List<SortedMap<Date, Integer>> executeGetDataSampling(
+ TopiaContext transaction, SamplingFilter filter)
+ throws TopiaException {
+// TopiaContext transaction = null;
+ List<SortedMap<Date, Integer>> results =
+ new ArrayList<SortedMap<Date, Integer>>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
PeriodDates period = filter.getPeriod();
if (period == null || period.getFromDate() == null || period.getThruDate() == null) {
@@ -142,20 +144,20 @@
}
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getDataSampling ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getDataSampling ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return results;
}
@@ -174,18 +176,19 @@
* @throws WaoException
*/
@Override
- public BoardingResult getBoardingBoats(Company company, Date fromDate)
- throws WaoExceptionO {
- TopiaContext transaction = null;
+ public BoardingResult executeGetBoardingBoats(TopiaContext transaction,
+ Company company, Date fromDate)
+ throws TopiaException {
+// TopiaContext transaction = null;
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
BoardingResult result = new BoardingResultImpl();
result.setData(map);
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
// Initialiaze max boardings and its max key value
final int maxBoardings = 12;
@@ -255,36 +258,37 @@
result.setMaxBoardingValue(maxValue.intValue());
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getBoardingBoats ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer les données pour le graphique " +
- "dynamique des efforts de marées", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getBoardingBoats ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de récupérer les données pour le graphique " +
+// "dynamique des efforts de marées", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return result;
}
@Override
- public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public Map<String, Double> executeGetNonComplianceBoardingIndicator(
+ TopiaContext transaction, Company company) throws TopiaException {
+// TopiaContext transaction = null;
// Carefull with results, the company may not be present in the map :
// only if there is no unfinished sampleRow or no contact done
Map<String, Double> results = new HashMap<String, Double>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -298,7 +302,7 @@
String companyName = companyProp + "." + Company.NAME;
// Only for unfinished sampleRows
- Date current = WaoContextO.getCurrentDate();
+ Date current = context.getCurrentDate();
query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
if (company != null) {
@@ -352,38 +356,41 @@
}
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer l'indicateur de non respect du " +
- "nombre d'observateurs embarqués" + msgEnd, eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// String msgEnd = "";
+// if (company != null) {
+// msgEnd = " pour la société " + company.getName();
+// }
+// context.serviceException(transaction,
+// "Impossible de récupérer l'indicateur de non respect du " +
+// "nombre d'observateurs embarqués" + msgEnd, eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return results;
}
@Override
- public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoExceptionO {
- TopiaContext transaction = null;
- Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public Collection<ContactStateStatistics> executeGetContactStateStatistics(
+ TopiaContext transaction, Company company, PeriodDates period)
+ throws TopiaException {
+// TopiaContext transaction = null;
+ Map<String, ContactStateStatistics> results =
+ new HashMap<String, ContactStateStatistics>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -444,40 +451,42 @@
stats.addResult(state, rowCount.intValue());
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getContactStateStatistics ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer les statistiques sur les états des " +
- "contacts " + msgEnd, eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getContactStateStatistics ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// } catch (Exception eee) {
+// String msgEnd = "";
+// if (company != null) {
+// msgEnd = " pour la société " + company.getName();
+// }
+// context.serviceException(transaction,
+// "Impossible de récupérer les statistiques sur les états des " +
+// "contacts " + msgEnd, eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return results.values();
}
@Override
- public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public Collection<ContactAverageReactivity>
+ executeGetContactDataInputDateReactivity(TopiaContext transaction,
+ Company company, PeriodDates period) throws TopiaException {
+// TopiaContext transaction = null;
// Carefull with results, the company may not be present in the map :
// only if there is no unfinished sampleRow or no contact done
Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -534,24 +543,24 @@
avg.addValue(nbDays);
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getContactDataInputDateReactivity ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer l'indicateur de réactivité sur " +
- "les dates de saisies dans Allegro" + msgEnd, eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getContactDataInputDateReactivity ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// } catch (Exception eee) {
+// String msgEnd = "";
+// if (company != null) {
+// msgEnd = " pour la société " + company.getName();
+// }
+// context.serviceException(transaction,
+// "Impossible de récupérer l'indicateur de réactivité sur " +
+// "les dates de saisies dans Allegro" + msgEnd, eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return results.values();
}
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 18:21:22 UTC (rev 409)
@@ -7,6 +7,7 @@
wao.error.context.rollback=
wao.error.context.start=
wao.error.context.stop=
+wao.error.global.createDefaultAdmin=
wao.error.sampleMonth.addRealTideTime=
wao.error.sampleRow.saveSampleRowLog=
wao.error.serviceBoat.createUpdateCompanyBoatInfos=
@@ -48,6 +49,11 @@
wao.error.serviceSampling.getSampleRowsByFilter=
wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=
wao.error.serviceSampling.importSamplingPlanCsv=
+wao.error.serviceSynthesis.getBoardingBoats=
+wao.error.serviceSynthesis.getContactDataInputDateReactivity=
+wao.error.serviceSynthesis.getContactStateStatistics=
+wao.error.serviceSynthesis.getDataSampling=
+wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=
wao.error.serviceUser.connect=
wao.error.serviceUser.createUpdateCompany=
wao.error.serviceUser.createUpdateUser=
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:21:22 UTC (rev 409)
@@ -7,6 +7,7 @@
wao.error.context.rollback=Une erreur est survenue pendant l'annulation de la transaction courante
wao.error.context.start=Une erreur est survenue pendant le d\u00E9marrage de l'application
wao.error.context.stop=Une erreur est survenue pendant la fermeture de l'application
+wao.error.global.createDefaultAdmin=
wao.error.sampleMonth.addRealTideTime=Impossible d'enregistrer le nombre de mar\u00E9es r\u00E9els pour le mois de %1$s [ligne \: %2$s]
wao.error.sampleRow.saveSampleRowLog=Impossible d'enregistrer le commentaire \u00E9crit par %1$s
wao.error.serviceBoat.createUpdateCompanyBoatInfos=Impossible de cr\u00E9er ou modifier les informations li\u00E9s au navire %1$d pour la soci\u00E9t\u00E9 %2$s
@@ -22,12 +23,12 @@
wao.error.serviceBoat.getNbBoatsByFilter=Impossible de filtrer la liste des navires
wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9
wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails.
-wao.error.serviceContact.exportContactCsv=
-wao.error.serviceContact.getContacts=
-wao.error.serviceContact.getNbContacts=
-wao.error.serviceContact.getNewContact=
-wao.error.serviceContact.importContactCsv=
-wao.error.serviceContact.saveContact=
+wao.error.serviceContact.exportContactCsv=Impossible d'exporter les contacts
+wao.error.serviceContact.getContacts=Impossible de filtrer la liste des contacts
+wao.error.serviceContact.getNbContacts=Impossible de compter le nombre de contacts filtr\u00E9s
+wao.error.serviceContact.getNewContact=Impossible d'instancier un nouveau contact
+wao.error.serviceContact.importContactCsv=Impossible d'importer les contacts
+wao.error.serviceContact.saveContact=Impossible de sauvegarder le contact
wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news
wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s'
wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades
@@ -47,7 +48,12 @@
wao.error.serviceSampling.getSampleRowByCode=Impossible de charger la ligne d'\u00E9chantillon ayant pour code %1$s
wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
-wao.error.serviceSampling.importSamplingPlanCsv=
+wao.error.serviceSampling.importSamplingPlanCsv=Erreur \u00E0 la ligne %1$d [CODE \= %2$s]
+wao.error.serviceSynthesis.getBoardingBoats=
+wao.error.serviceSynthesis.getContactDataInputDateReactivity=
+wao.error.serviceSynthesis.getContactStateStatistics=
+wao.error.serviceSynthesis.getDataSampling=
+wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=
wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion
wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9
wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -80,12 +80,12 @@
}
@Before
- public void setUp() throws WaoExceptionO, ArgumentsParserException {
+ public void setUp() throws ArgumentsParserException {
manager.start();
}
@After
- public void tearDown() throws WaoExceptionO, TopiaException {
+ public void tearDown() throws TopiaException {
manager.stop();
}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -124,7 +124,7 @@
return instance;
}
- public ServiceReferential getServiceReferential() throws WaoExceptionO {
+ public ServiceReferential getServiceReferential() {
ServiceReferentialImpl instance = new ServiceReferentialImpl();
instance.setContext(getContext());
return instance;
@@ -136,27 +136,27 @@
return instance;
}
- public ServiceSampling getServiceSampling() throws WaoExceptionO {
+ public ServiceSampling getServiceSampling() {
ServiceSamplingImpl instance = new ServiceSamplingImpl();
instance.setContext(getContext());
return instance;
}
- public ServiceSynthesis getServiceSynthesis() throws WaoExceptionO {
+ public ServiceSynthesis getServiceSynthesis() {
ServiceSynthesisImpl instance = new ServiceSynthesisImpl();
-// instance.setContext(context);
+ instance.setContext(getContext());
return instance;
}
- public ServiceUser getServiceUser() throws WaoExceptionO {
+ public ServiceUser getServiceUser() {
ServiceUserImpl instance = new ServiceUserImpl();
instance.setContext(getContext());
return instance;
}
- public ServiceContact getServiceContact() throws WaoExceptionO {
+ public ServiceContact getServiceContact() {
ServiceContactImpl instance = new ServiceContactImpl();
- instance.setContext(context);
+ instance.setContext(getContext());
return instance;
}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -67,12 +67,12 @@
}
@Before
- public void setUp() throws WaoExceptionO {
+ public void setUp() {
manager.start();
}
@After
- public void tearDown() throws WaoExceptionO {
+ public void tearDown() {
manager.stop();
}
@@ -83,7 +83,7 @@
public void testCreateDefaultAdmin() throws Exception {
System.out.println("createDefaultAdmin");
- WaoGlobal.createDefaultAdmin();
+ WaoGlobal.createDefaultAdmin(manager.getContext());
ServiceUser serviceUser = manager.getServiceUser();
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -64,12 +64,12 @@
}
@Before
- public void setUp() throws WaoExceptionO {
+ public void setUp() {
manager.start();
}
@After
- public void tearDown() throws WaoExceptionO {
+ public void tearDown() {
manager.stop();
}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,6 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.TestManager;
import java.util.Calendar;
@@ -79,7 +78,7 @@
manager.stop();
}
- private SampleRow prepareData() throws WaoExceptionO, TopiaException {
+ private SampleRow prepareData() throws TopiaException {
TopiaContext transaction = manager.getContext().beginTransaction();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
@@ -102,7 +101,7 @@
return myRow;
}
- private SampleRow getRowFromContext() throws WaoExceptionO, TopiaException {
+ private SampleRow getRowFromContext() throws TopiaException {
TopiaContext transaction = manager.getContext().beginTransaction();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
SampleRow resultRow = dao.findByCode("2010_1");
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -72,7 +72,7 @@
}
@Before
- public void setUp() throws WaoExceptionO, IOException {
+ public void setUp() throws IOException {
manager.start();
InputStream input = getClass().getResourceAsStream("/import/misc.csv");
@@ -81,7 +81,7 @@
}
@After
- public void tearDown() throws WaoExceptionO {
+ public void tearDown() {
reader.close();
manager.stop();
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.service;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.TestManager;
import java.io.BufferedReader;
@@ -70,12 +70,12 @@
}
@Before
- public void setUp() throws WaoExceptionO {
+ public void setUp() {
manager.start();
}
@After
- public void tearDown() throws WaoExceptionO {
+ public void tearDown() {
manager.stop();
}
@@ -83,7 +83,8 @@
* Test of run method, of class ActivityCalendarImport.
*/
@Test
- public void testRun() throws IOException, InterruptedException, WaoExceptionO {
+ public void testRun()
+ throws IOException, InterruptedException, WaoBusinessException {
log.info("run");
ServiceBoat serviceBoat = manager.getServiceBoat();
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.service;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.bean.BoatFilterImpl;
@@ -204,7 +204,7 @@
}
private List<SampleRow> prepareSampleRows(Company company)
- throws WaoExceptionO, TopiaException {
+ throws TopiaException, WaoBusinessException {
ServiceReferential serviceReferential = manager.getServiceReferential();
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
serviceReferential.importFishingZoneCsv(input);
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,6 @@
package fr.ifremer.wao.service;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.TestManager;
import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.SamplingFilter;
@@ -128,7 +127,7 @@
* @throws WaoException if error during import or getFishingZones
*/
@Test
- public void testGetFishingZones() throws WaoExceptionO {
+ public void testGetFishingZones() {
log.info("getFishingZones");
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
@@ -144,7 +143,7 @@
* @throws WaoException if import error
*/
@Test
- public void testImportFishingZoneCsv() throws WaoExceptionO {
+ public void testImportFishingZoneCsv() {
log.info("importFishingZoneCsv");
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,9 +21,9 @@
package fr.ifremer.wao.service;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.ImportResults;
import fr.ifremer.wao.bean.SamplingFilter;
import fr.ifremer.wao.bean.SamplingFilterImpl;
@@ -298,7 +298,7 @@
}
- private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoExceptionO, TopiaException {
+ private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws TopiaException {
FishingZoneDAO fishingZoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction);
@@ -465,7 +465,8 @@
}
@Test
- public void testImportSamplingPlanCsv() throws WaoExceptionO, TopiaException {
+ public void testImportSamplingPlanCsv()
+ throws TopiaException, WaoException, WaoBusinessException {
log.info("importSamplingPlanCsv");
/** PREPARE DATA **/
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.base;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoatFilter;
import fr.ifremer.wao.entity.Company;
import fr.ifremer.wao.entity.SampleRow;
@@ -143,7 +143,7 @@
* @param observerSelect if true, observer select will be initialized
* @throws WaoException
*/
- protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoExceptionO {
+ protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoException {
this.observerSelect = observerSelect;
this.programSelect = programSelect;
@@ -185,22 +185,22 @@
resetSampleRowSelect();
}
- protected void resetCompanySelect() throws WaoExceptionO {
+ protected void resetCompanySelect() throws WaoException {
companySelectModel = null;
getCompanySelectModel();
}
- protected void resetFacadeSelect() throws WaoExceptionO {
+ protected void resetFacadeSelect() throws WaoException {
facadeSelectModel = null;
getFacadeSelectModel();
}
- protected void resetSectorSelect() throws WaoExceptionO {
+ protected void resetSectorSelect() throws WaoException {
sectorSelectModel = null;
getSectorSelectModel();
}
- protected void resetSampleRowSelect() throws WaoExceptionO {
+ protected void resetSampleRowSelect() throws WaoException {
sampleRowSelectModel = null;
getSampleRowSelectModel();
}
@@ -212,7 +212,7 @@
* @return the SelectModel for facade names
* @throws WaoException
*/
- public SelectModel getFacadeSelectModel() throws WaoExceptionO {
+ public SelectModel getFacadeSelectModel() throws WaoException {
if (facadeSelectModel == null) {
List<OptionModel> options = new ArrayList<OptionModel>();
for (String facadeName : serviceReferential.getFacades(getFilter())) {
@@ -230,7 +230,7 @@
* @return the SelectModel for sector names
* @throws WaoException
*/
- public SelectModel getSectorSelectModel() throws WaoExceptionO {
+ public SelectModel getSectorSelectModel() throws WaoException {
if (sectorSelectModel == null) {
List<OptionModel> options = new ArrayList<OptionModel>();
for (String sectorName : serviceReferential.getSectors(getFilter())) {
@@ -249,7 +249,7 @@
* @return the GenericSelectModel<SampleRow> for sampleRows
* @throws WaoException
*/
- public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoException {
if (sampleRowSelectModel == null) {
// WARN : no use of sampleRow filter
SampleRow rowFiltered = getFilter().getSampleRow();
@@ -271,7 +271,7 @@
* @return the GenericSelectModel<Company> for companies
* @throws WaoException
*/
- public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO {
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
if (companySelectModel == null) {
List<Company> companies = serviceUser.getCompanies(isAvailableDataForFiltersOnly());
companySelectModel = new GenericSelectModel<Company>(companies,Company.class,
@@ -288,7 +288,7 @@
* @return the GenericSelectModel<WaoUser> for observers
* @throws WaoException
*/
- public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException {
if (observerSelectModel == null) {
List<WaoUser> observers = new ArrayList<WaoUser>();
if (getFilter().getCompany() != null) {
@@ -309,7 +309,7 @@
* @return the SelectModel for program names
* @throws WaoException
*/
- public SelectModel getProgramSelectModel() throws WaoExceptionO {
+ public SelectModel getProgramSelectModel() throws WaoException {
if (programSelectModel == null) {
List<OptionModel> options = new ArrayList<OptionModel>();
for (String programName : serviceSampling.getPrograms(getFilter().getCompany())) {
@@ -320,7 +320,7 @@
return programSelectModel;
}
- protected abstract BoatFilter getFilter() throws WaoExceptionO;
+ protected abstract BoatFilter getFilter() throws WaoException;
/**
* Used to show only active company and observers.
@@ -329,7 +329,7 @@
*/
protected abstract boolean isAvailableDataForFiltersOnly();
- public String[] onProvideCompletionsFromBoatName(String input) throws WaoExceptionO {
+ public String[] onProvideCompletionsFromBoatName(String input) throws WaoException {
List<String> results = serviceBoat.getBoatNamesStartWith(input);
return results.toArray(new String[0]);
}
@@ -340,7 +340,7 @@
*
* @throws WaoException
*/
- public void onSelectedFromSearch() throws WaoExceptionO {
+ public void onSelectedFromSearch() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("REFRESH FILTERS DATA");
}
@@ -370,7 +370,7 @@
* @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshByProgram()
*/
- public void onSelectedFromRefreshByCompany() throws WaoExceptionO {
+ public void onSelectedFromRefreshByCompany() throws WaoException {
// Reset programs (the behavior is needed even if programSelect is false)
getFilter().setProgramName(null);
onSelectedFromRefreshByProgram();
@@ -396,7 +396,7 @@
* @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshByFacade()
*/
- public void onSelectedFromRefreshByProgram() throws WaoExceptionO {
+ public void onSelectedFromRefreshByProgram() throws WaoException {
// Reset facades
getFilter().setFacadeName(null);
onSelectedFromRefreshByFacade();
@@ -412,7 +412,7 @@
* @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshBySector()
*/
- public void onSelectedFromRefreshByFacade() throws WaoExceptionO {
+ public void onSelectedFromRefreshByFacade() throws WaoException {
// Reset sectors
getFilter().setSectorName(null);
onSelectedFromRefreshBySector();
@@ -428,7 +428,7 @@
* @throws WaoException
* @see AbstractFilteredPage#onSelectedFromSearch()
*/
- public void onSelectedFromRefreshBySector() throws WaoExceptionO {
+ public void onSelectedFromRefreshBySector() throws WaoException {
// Update selected data
onSelectedFromSearch();
// Reset sampleRows;
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -23,7 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.service.ServiceUser;
@@ -250,7 +250,7 @@
}
@Log
- Object onSuccessFromConnexionForm() throws WaoExceptionO {
+ Object onSuccessFromConnexionForm() throws WaoException {
try {
// FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org
if (login != null && password != null) {
@@ -270,7 +270,7 @@
public boolean hasConnexionErrors() {
return connexionFeedback.hasErrors();
}
- void onSuccessFromForgetPassword() throws WaoExceptionO {
+ void onSuccessFromForgetPassword() throws WaoException {
try {
serviceUser.forgetPassword(email);
connexionFeedback.addInfo("Un email avec votre nouveau mot de passe vous a été envoyé.");
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.data;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -68,7 +68,7 @@
if (log.isTraceEnabled()) {
log.trace("Count : " + nbRows);
}
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
throw new TapestryException("", eee);
}
}
@@ -87,14 +87,15 @@
// FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats
//sortResults(sortConstraints);
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
throw new TapestryException("", eee);
}
}
- protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO;
+ protected abstract Map<K, E> execute(int startIndex, int endIndex,
+ SortConstraint orderBy) throws WaoException;
- protected abstract int count() throws WaoExceptionO;
+ protected abstract int count() throws WaoException;
protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
for (SortConstraint constraint : sortConstraints)
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.data;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoatFilter;
import fr.ifremer.wao.entity.Boat;
import fr.ifremer.wao.service.ServiceBoat;
@@ -58,10 +58,8 @@
@Override
- protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getBoatsByFilter]");
- }
+ protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
+
filter.setStartIndex(startIndex);
filter.setEndIndex(endIndex);
@@ -84,10 +82,7 @@
}
@Override
- protected int count() throws WaoExceptionO {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getNbBoatsByFilter]");
- }
+ protected int count() throws WaoException {
return service.getNbBoatsByFilter(filter);
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.data;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.ContactFilter;
import fr.ifremer.wao.entity.Contact;
import fr.ifremer.wao.service.ServiceContact;
@@ -60,20 +60,14 @@
}
@Override
- protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getContactsByFilter]");
- }
+ protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
filter.setStartIndex(startIndex);
filter.setEndIndex(endIndex);
return serviceContact.getContacts(filter);
}
@Override
- protected int count() throws WaoExceptionO {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getNbContacts]");
- }
+ protected int count() throws WaoException {
return serviceContact.getNbContacts(filter);
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -23,7 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.UserRole;
import fr.ifremer.wao.entity.Company;
import fr.ifremer.wao.entity.CompanyImpl;
@@ -127,7 +127,7 @@
private boolean addNewUserSelected;
private boolean deleteUserSelected;
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
companies = null;
getCompanies();
user = null;
@@ -172,24 +172,21 @@
/**************************** FORMS ****************************************/
- public List<Company> getCompanies() throws WaoExceptionO {
+ public List<Company> getCompanies() throws WaoException {
if (companies == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getCompanies]");
- }
companies = serviceUser.getCompanies(false);
}
return companies;
}
- public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoException {
if (companiesSelectModel == null) {
companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess);
}
return companiesSelectModel;
}
- public Company getCompany() throws WaoExceptionO {
+ public Company getCompany() throws WaoException {
if (company == null) {
if (companyId != null) {
company = getCompaniesSelectModel().findObject(companyId);
@@ -200,7 +197,7 @@
return company;
}
- public boolean isUsersAvailable() throws WaoExceptionO {
+ public boolean isUsersAvailable() throws WaoException {
return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive();
}
@@ -216,13 +213,13 @@
user = null;
}
- void onSuccessFromCompany() throws WaoExceptionO {
+ void onSuccessFromCompany() throws WaoException {
serviceUser.createUpdateCompany(company);
companyId = company.getId();
}
@Log
- public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException {
if (usersSelectModel == null) {
List<WaoUser> users = serviceUser.getUsersByCompany(getCompany());
if (log.isDebugEnabled()) {
@@ -234,7 +231,7 @@
}
@Log
- public WaoUser getUser() throws WaoExceptionO {
+ public WaoUser getUser() throws WaoException {
if (user == null) {
if (userId != null) {
if (log.isDebugEnabled()) {
@@ -264,7 +261,7 @@
deleteUserSelected = true;
}
- void onSuccessFromUserActionsForm() throws WaoExceptionO {
+ void onSuccessFromUserActionsForm() throws WaoException {
if (addNewUserSelected) {
userId = null;
} else if (deleteUserSelected && userId != null) {
@@ -281,7 +278,7 @@
}
@Log
- void onSuccessFromUser() throws WaoExceptionO {
+ void onSuccessFromUser() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("User : " + user);
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.pages;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.entity.ActivityCalendar;
import fr.ifremer.wao.entity.ActivityMonth;
import fr.ifremer.wao.entity.ActivityProfession;
@@ -108,17 +108,14 @@
return Collections.singletonList(boat);
}
- public ActivityCalendar getActivityCalendar() throws WaoExceptionO {
+ public ActivityCalendar getActivityCalendar() throws WaoException {
if (activityCalendar == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getLastActivityCalendar]");
- }
this.activityCalendar = serviceBoat.getLastActivityCalendar(user, getBoat());
}
return activityCalendar;
}
- public ActivityMonth getActivityMonth() throws WaoExceptionO {
+ public ActivityMonth getActivityMonth() throws WaoException {
return getActivityCalendar().getActivityMonth(month);
}
@@ -142,7 +139,7 @@
return getProfessionIndexMax() != -1;
}
- public ActivityProfession getActivityProfession() throws WaoExceptionO {
+ public ActivityProfession getActivityProfession() throws WaoException {
if (getActivityMonth() == null) {
return null;
}
@@ -152,7 +149,7 @@
return getActivityMonth().getActivityProfession().get(professionIndex);
}
- public int getZoneIndexMax() throws WaoExceptionO {
+ public int getZoneIndexMax() throws WaoException {
int result = 0;
for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) {
month = activityMonth.getMonth();
@@ -179,7 +176,7 @@
// return getZoneIndexMax() != -1;
// }
- public ActivityZone getActivityZone() throws WaoExceptionO {
+ public ActivityZone getActivityZone() throws WaoException {
ActivityProfession profession = getActivityProfession();
if (profession == null) {
return null;
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -23,7 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoatFilterImpl;
import fr.ifremer.wao.entity.Boat;
import fr.ifremer.wao.bean.BoatFilter;
@@ -143,7 +143,7 @@
@InjectComponent
private FeedBack filterFeedback;
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
sampleRow = null;
getSampleRow();
// Profession select reset
@@ -223,9 +223,6 @@
InputStream getActivityCalendarLogFile() throws FileNotFoundException {
if (activityCalendarLogFile == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getActivityCalendarLogFile]");
- }
activityCalendarLogFile = serviceBoat.getActivityCalendarLogFile();
}
return activityCalendarLogFile;
@@ -245,9 +242,6 @@
InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException {
if (activityCalendarLogAccessFile == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getActivityCalendarLogAccessFile]");
- }
activityCalendarLogAccessFile =
serviceBoat.getActivityCalendarLogAccessFile();
}
@@ -269,7 +263,7 @@
@Log
void onSuccessFromImportActivityCalendarsForm()
- throws WaoExceptionO, IOException {
+ throws WaoException, IOException {
if (canImportReferentials()) {
InputStream input = activityCalendarsCsvFile.getStream();
if (log.isDebugEnabled()) {
@@ -358,7 +352,7 @@
* @see AbstractFilteredPage
*/
@Override
- public BoatFilter getFilter() throws WaoExceptionO {
+ public BoatFilter getFilter() throws WaoException {
if (boatFilter == null) {
if (log.isDebugEnabled()) {
log.debug("Create filter");
@@ -382,25 +376,19 @@
* @return the sampleRow from business
* @throws WaoException
*/
- public SampleRow getSampleRow() throws WaoExceptionO {
+ public SampleRow getSampleRow() throws WaoException {
if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
sampleRow = serviceSampling.getSampleRow(sampleRowContextId);
}
return sampleRow;
}
- public boolean isSampleRowExists() throws WaoExceptionO {
+ public boolean isSampleRowExists() throws WaoException {
return getSampleRow() != null;
}
- public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
if (professionSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getProfessions]");
- }
List<Profession> professions = serviceReferential.getProfessions();
professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
"code", "topiaId", propertyAccess);
@@ -443,7 +431,7 @@
* @see AbstractFilteredPage#onSelectedFromSearch()
*/
@Override
- public void onSelectedFromSearch() throws WaoExceptionO {
+ public void onSelectedFromSearch() throws WaoException {
super.onSelectedFromSearch();
if (log.isDebugEnabled()) {
log.debug("FILTER : facadeName=" + boatFilter.getFacadeName());
@@ -465,7 +453,7 @@
* @return the filtersZone if it's a refresh data for select, or the page otherwise
* @throws WaoException for business errors
*/
- Object onSuccessFromFiltersForm() throws WaoExceptionO {
+ Object onSuccessFromFiltersForm() throws WaoException {
if (isEdited()) {
return filtersZone.getBody();
}
@@ -503,7 +491,7 @@
* @throws WaoException
* @see BoatDataSource
*/
- public BoatDataSource getBoats() throws WaoExceptionO {
+ public BoatDataSource getBoats() throws WaoException {
if (boats == null) {
boats = new BoatDataSource(getFilter(), serviceBoat);
}
@@ -533,7 +521,7 @@
return new SimpleDateFormat("dd/MM/yyyy");
}
- public boolean canCreateNewContactFromList() throws WaoExceptionO {
+ public boolean canCreateNewContactFromList() throws WaoException {
if (!user.isAdmin() && !user.getReadOnly() && isSampleRowExists()) {
return boat.canCreateContact(user.getCompany());
}
@@ -551,7 +539,7 @@
log.debug("Filter sampleRow : " + getFilter().getSampleRow());
}
result = serviceBoat.exportBoatCsv(getFilter());
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
@@ -559,7 +547,7 @@
};
}
- Block onActionFromShowBoatInfos(Integer boatImma) throws WaoExceptionO {
+ Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException {
boatSelectedImmatriculation = boatImma;
// Suppress persistant boat informations
companyBoatInfos = null;
@@ -628,11 +616,8 @@
return displayBoatInfos;
}
- public CompanyBoatInfos getCompanyBoatInfos() throws WaoExceptionO {
- if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getElligibleBoats]");
- }
+ public CompanyBoatInfos getCompanyBoatInfos() throws WaoException {
+ if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) {
companyBoatInfos = serviceBoat.getCompanyBoatInfos(boatSelectedImmatriculation, getCompany());
}
return companyBoatInfos;
@@ -645,11 +630,8 @@
* @return the GenericSelectModel<Company>
* @throws WaoException
*/
- public GenericSelectModel<Company> getCompanies() throws WaoExceptionO {
+ public GenericSelectModel<Company> getCompanies() throws WaoException {
if (companies == null) {
- if (log.isDebugEnabled()) {
- log.debug("BUSINESS REQUEST [getCompanies]");
- }
List<Company> results = serviceUser.getCompanies(true);
companies = new GenericSelectModel<Company>(results, Company.class, "name","topiaId",propertyAccess);
}
@@ -663,7 +645,7 @@
* @return the current Company
* @throws WaoException
*/
- public Company getCompany() throws WaoExceptionO {
+ public Company getCompany() throws WaoException {
if (company == null) {
if (StringUtils.isNotEmpty(companySelectedId)) {
company = getCompanies().findObject(companySelectedId);
@@ -680,7 +662,7 @@
* @return the selected boat from the grid
* @throws WaoException
*/
- public Boat getBoatSelected() throws WaoExceptionO {
+ public Boat getBoatSelected() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("selected imma : " + boatSelectedImmatriculation);
log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation));
@@ -712,7 +694,7 @@
this.boardingFromDate = boardingFromDate;
}
- public BoatInfos getBoatInfos() throws WaoExceptionO {
+ public BoatInfos getBoatInfos() throws WaoException {
if (getCompanyBoatInfos() == null) {
return null;
}
@@ -726,7 +708,7 @@
* @throws WaoException
* @see BusinessUtils#getContactStyle(Contact, boolean)
*/
- public String getlastContactStyle() throws WaoExceptionO {
+ public String getlastContactStyle() throws WaoException {
Contact contact = getCompanyBoatInfos().getLastContact();
return BusinessUtils.getContactStyle(contact, user.isAdmin());
}
@@ -741,7 +723,7 @@
return BooleanUtils.isFalse(elligibleBoat.getCompanyActive());
}
- public boolean canCreateNewContactFromElligibleBoat() throws WaoExceptionO {
+ public boolean canCreateNewContactFromElligibleBoat() throws WaoException {
if (!user.isAdmin() && !user.getReadOnly() &&
!isElligibleBoatCompanyActiveFalse()) {
Boat currentBoat = getBoatInfos().getBoat();
@@ -766,19 +748,19 @@
return !user.getReadOnly();
}
- void onSuccess() throws WaoExceptionO {
+ void onSuccess() throws WaoException {
if (getBoatInfos() != null) {
boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
}
}
- Block onSuccessFromCompanySelectForm() throws WaoExceptionO {
+ Block onSuccessFromCompanySelectForm() throws WaoException {
companyBoatInfos = null;
getCompanyBoatInfos();
return boatInfosZone.getBody();
}
- Block onActionFromEditBoatInfos() throws WaoExceptionO {
+ Block onActionFromEditBoatInfos() throws WaoException {
if (canEditBoatInfos()) {
boatInfosEditable = true;
// WARNING :: Reset sampleRow select for edition mode, no limit for
@@ -790,7 +772,7 @@
return boatInfosZone.getBody();
}
- Block onActionFromCancelEditBoatInfos() throws WaoExceptionO {
+ Block onActionFromCancelEditBoatInfos() throws WaoException {
/*if (propertyChange.isChanged()) {
if (log.isDebugEnabled()) {
log.debug("Change property");
@@ -804,7 +786,7 @@
return boatInfosZone.getBody();
}
- void onSelectedFromAddBoatInfosSampleRow() throws WaoExceptionO {
+ void onSelectedFromAddBoatInfosSampleRow() throws WaoException {
// We stay in edition mode
boatInfosEditable = true;
if (StringUtils.isNotEmpty(boatInfosSampleRowId)) {
@@ -813,17 +795,17 @@
}
}
- void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO {
+ void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
boatInfosEditable = true;
companyBoatInfos.removeElligibleBoat(sampleRowCode);
}
- void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO {
+ void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
boatInfosEditable = true;
companyBoatInfos.activeElligibleBoat(sampleRowCode);
}
- Block onSuccessFromBoatInfosForm() throws WaoExceptionO {
+ Block onSuccessFromBoatInfosForm() throws WaoException {
if (!boatInfosEditable && canEditBoatInfos()) {
// Save data
serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos);
@@ -832,7 +814,7 @@
return boatInfosZone.getBody();
}
- Block onSuccessFromCalculateBoardings() throws WaoExceptionO {
+ Block onSuccessFromCalculateBoardings() throws WaoException {
//boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
return boatInfosZone.getBody();
}
@@ -842,7 +824,7 @@
@InjectPage
private Contacts contacts;
- Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoExceptionO {
+ Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoException {
// Get selected sampleRow
sampleRow = getSampleRow();
// Get boat from list
@@ -851,7 +833,7 @@
return contacts;
}
- Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoExceptionO {
+ Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoException {
// Get sampleRow from elligibleBoat list
ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode);
sampleRow = elligible.getSampleRow();
@@ -864,11 +846,11 @@
@InjectPage
private BoatActivityCalendar calendarPage;
- public boolean hasActivityCalendar() throws WaoExceptionO {
+ public boolean hasActivityCalendar() throws WaoException {
return getBoatSelected().sizeActivityCalendar() != 0;
}
- Object onActionFromShowLastActivityCalendar() throws WaoExceptionO {
+ Object onActionFromShowLastActivityCalendar() throws WaoException {
calendarPage.setBoat(getBoatSelected());
return calendarPage;
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -23,7 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoatFilter;
import fr.ifremer.wao.bean.ContactFilter;
import fr.ifremer.wao.bean.ContactFilterImpl;
@@ -121,7 +121,7 @@
// private String contactEditedId;
@Log
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
// if (contactEdited == null) {
if (log.isDebugEnabled()) {
log.debug("RESET DATA");
@@ -149,7 +149,7 @@
@Property
private ContactState stateFilter;
- public ContactFilter getContactFilter() throws WaoExceptionO {
+ public ContactFilter getContactFilter() throws WaoException {
if (contactFilter == null) {
if (log.isDebugEnabled()) {
log.debug("Init contactFilter");
@@ -168,7 +168,7 @@
}
@Override
- protected BoatFilter getFilter() throws WaoExceptionO {
+ protected BoatFilter getFilter() throws WaoException {
return getContactFilter();
}
@@ -191,7 +191,7 @@
}
@Log
- Object onSuccessFromFiltersForm() throws WaoExceptionO {
+ Object onSuccessFromFiltersForm() throws WaoException {
if (isEdited()) {
return filtersZone.getBody();
}
@@ -222,7 +222,7 @@
}
@Log
- void onSuccessFromImportContacts() throws WaoExceptionO {
+ void onSuccessFromImportContacts() throws WaoException {
if (canImportExport()) {
try {
ImportResults result = serviceContact.importContactCsv(user,
@@ -251,7 +251,7 @@
try {
result = serviceContact.exportContactCsv(
getContactFilter());
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
@@ -292,7 +292,7 @@
private boolean even = true;
- public ContactDataSource getContacts() throws WaoExceptionO {
+ public ContactDataSource getContacts() throws WaoException {
if (contacts == null) {
if (log.isInfoEnabled()) {
log.info("Create DataSource");
@@ -341,7 +341,7 @@
return BusinessUtils.getTooltipBoat(contact.getBoat());
}
- public String getTooltipExportFrom() throws WaoExceptionO {
+ public String getTooltipExportFrom() throws WaoException {
if (getContactFilter().getFromDate() != null) {
return "depuis le " + getDateFormat().format(getContactFilter().getFromDate());
}
@@ -443,7 +443,7 @@
}
}
- void onSelectedFromAcceptContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromAcceptContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Accept contact : " + contactId);
}
@@ -457,7 +457,7 @@
}
}
- void onSelectedFromRefuseContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromRefuseContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Refuse contact : " + contactId);
}
@@ -471,7 +471,7 @@
}
}
- void onSelectedFromUnvalidateContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromUnvalidateContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Unvalidate contact : " + contactId);
}
@@ -492,7 +492,7 @@
}
}
- void onSelectedFromEditContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromEditContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Edit contact : " + contactId);
}
@@ -504,7 +504,7 @@
edited = true;
}
- void onSelectedFromDeleteContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromDeleteContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Delete contact : " + contactId);
}
@@ -512,7 +512,7 @@
deleted = true;
}
- void onSelectedFromSaveContact(String contactId) throws WaoExceptionO {
+ void onSelectedFromSaveContact(String contactId) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Save contact : " + contactId);
}
@@ -526,7 +526,7 @@
}
}
- void onSelectedFromCancelEditContact() throws WaoExceptionO {
+ void onSelectedFromCancelEditContact() throws WaoException {
contactEdited = null;
edited = true;
}
@@ -675,7 +675,7 @@
//return gridZone;
}
- public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoExceptionO {
+ public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException {
contact = serviceContact.getNewContact(user, sampleRow, boat);
// Check boat not null and validation for create the new contact
if (boat != null && boat.canCreateContact(user.getCompany())) {
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -22,7 +22,6 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.ui.base.WaoPage;
import fr.ifremer.wao.ui.components.Layout;
import fr.ifremer.wao.ui.data.BusinessUtils;
@@ -69,13 +68,13 @@
@Override
public void reportException(Throwable eee) {
- this.exception = getWaoExceptionO(eee);
- if (exception != null) {
- layout.addError(exception.getMessage());
- this.exception = exception.getCause();
- layout.addError("Erreur : " + this.exception.getClass().getSimpleName()
- + " : " + this.exception.getMessage());
- } else {
+// this.exception = getWaoExceptionO(eee);
+// if (exception != null) {
+// layout.addError(exception.getMessage());
+// this.exception = exception.getCause();
+// layout.addError("Erreur : " + this.exception.getClass().getSimpleName()
+// + " : " + this.exception.getMessage());
+// } else {
this.exception = getWaoException(eee);
if (exception != null) {
String[] errors =
@@ -88,7 +87,7 @@
this.exception.getClass().getSimpleName()
+ " : " + this.exception.getMessage());
}
- }
+// }
}
protected Throwable getWaoException(Throwable eee) {
@@ -101,14 +100,14 @@
return getWaoException(eee.getCause());
}
- protected Throwable getWaoExceptionO(Throwable eee) {
- if (eee == null) {
- return eee;
- }
- if (eee instanceof WaoExceptionO) {
- return eee;
- }
- return getWaoExceptionO(eee.getCause());
- }
+// protected Throwable getWaoExceptionO(Throwable eee) {
+// if (eee == null) {
+// return eee;
+// }
+// if (eee instanceof WaoExceptionO) {
+// return eee;
+// }
+// return getWaoExceptionO(eee.getCause());
+// }
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.pages;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.entity.News;
import fr.ifremer.wao.entity.NewsImpl;
import fr.ifremer.wao.entity.WaoUser;
@@ -97,7 +97,7 @@
@Log
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
if (editedId == null || !"NEW".equals(editedId)) {
newsList = null;
getNewsList();
@@ -114,7 +114,7 @@
// return editedId;
// }
- public List<News> getNewsList() throws WaoExceptionO {
+ public List<News> getNewsList() throws WaoException {
if (newsList == null) {
newsList = serviceNews.getNews();
}
@@ -140,7 +140,7 @@
return dateFormat;
}
- void onActionFromAddNews() throws WaoExceptionO {
+ void onActionFromAddNews() throws WaoException {
news = new NewsImpl();
// Create a new list with the new news in first position
List<News> list = new ArrayList<News>();
@@ -150,12 +150,12 @@
editedId = "NEW";
}
- void onActionFromEditNews(int rowIndex) throws WaoExceptionO {
+ void onActionFromEditNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
this.editedId = news.getTopiaId();
}
- void onActionFromDeleteNews(int rowIndex) throws WaoExceptionO {
+ void onActionFromDeleteNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
serviceNews.saveNews(news, true);
//newsList = null;
@@ -164,11 +164,11 @@
void onActionFromCancelEdit() {
}
- void onSelectedFromSaveNews(int rowIndex) throws WaoExceptionO {
+ void onSelectedFromSaveNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
}
- void onSuccessFromNewsForm() throws WaoExceptionO {
+ void onSuccessFromNewsForm() throws WaoException {
if (canEditNews()) {
serviceNews.saveNews(news, false);
//this.editedId = null;
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -22,9 +22,8 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoBusinessException;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.entity.Boat;
import fr.ifremer.wao.entity.Company;
import fr.ifremer.wao.entity.FishingZone;
@@ -127,7 +126,7 @@
return sampleRowId;
}
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
// Reset data
sampleRow = null;
getSampleRow();
@@ -188,11 +187,8 @@
* @return a GenericSelectModel<Profession>
* @throws WaoException
*/
- public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
if (professionSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getProfessions]");
- }
List<Profession> professions = serviceReferential.getProfessions();
professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
"code", "topiaId", propertyAccess);
@@ -214,7 +210,7 @@
*
* @throws WaoException
*/
- void onSelectedFromAddNewProfession() throws WaoExceptionO {
+ void onSelectedFromAddNewProfession() throws WaoException {
Profession profession = new ProfessionImpl();
if (!StringUtils.isEmpty(professionId)) {
Profession professionSelected = getProfessionSelectModel().findObject(professionId);
@@ -255,11 +251,8 @@
* @return a GenericSelectModel<FishingZone>
* @throws WaoException
*/
- public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoExceptionO {
+ public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoException {
if (fishingZoneSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getFishingZones]");
- }
List<FishingZone> zones = serviceReferential.getFishingZones();
fishingZoneSelectModel = new GenericSelectModel<FishingZone>(zones, FishingZone.class,
"code", "topiaId", propertyAccess);
@@ -273,7 +266,7 @@
* @return a List of FishingZone linked with the SampleRow
* @throws WaoException
*/
- public List<FishingZone> getFishingZones() throws WaoExceptionO {
+ public List<FishingZone> getFishingZones() throws WaoException {
return getSampleRow().getFishingZone();
}
@@ -282,7 +275,7 @@
*
* @throws WaoException
*/
- void onSelectedFromAddFishingZone() throws WaoExceptionO {
+ void onSelectedFromAddFishingZone() throws WaoException {
fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
if (!getFishingZones().contains(fishingZone)) {
if (log.isDebugEnabled()) {
@@ -299,7 +292,7 @@
* @param index of the FishingZone in the list (from loop component)
* @throws WaoException
*/
- void onSelectedFromRemoveFishingZone(int index) throws WaoExceptionO {
+ void onSelectedFromRemoveFishingZone(int index) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Remove fishingZone at position : " + index);
}
@@ -349,11 +342,8 @@
private boolean periodChanged;
- public SelectModel getProgramSelectModel() throws WaoExceptionO {
+ public SelectModel getProgramSelectModel() throws WaoException {
if (programSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getPrograms]");
- }
List<OptionModel> options = new ArrayList<OptionModel>();
for (String name : serviceSampling.getPrograms(null)) {
options.add(new OptionModelImpl(name, name));
@@ -379,7 +369,7 @@
// return getSampleRow().getProgram();
// }
- public PeriodDates getPeriod() throws WaoExceptionO {
+ public PeriodDates getPeriod() throws WaoException {
if (period == null) {
Date begin = getSampleRow().getPeriodBegin();
Date end = getSampleRow().getPeriodEnd();
@@ -388,7 +378,7 @@
return period;
}
- public List<SampleMonth> getSampleMonths() throws WaoExceptionO {
+ public List<SampleMonth> getSampleMonths() throws WaoException {
if (sampleMonths == null) {
sampleMonths = new ArrayList<SampleMonth>();
for (Date currMonth : getPeriod().getMonths()) {
@@ -448,7 +438,7 @@
* @throws WaoException
*/
@Log
- void onSelectedFromRefreshMonths() throws WaoExceptionO {
+ void onSelectedFromRefreshMonths() throws WaoException {
getSampleRow().setPeriod(period);
periodChanged = true;
// Reset sampleMonths for new period
@@ -457,7 +447,7 @@
saveProgram();
}
- protected void saveProgram() throws WaoExceptionO {
+ protected void saveProgram() throws WaoException {
// Save programName
if (StringUtils.isNotEmpty(programName)) {
getSampleRow().setProgramName(programName);
@@ -471,7 +461,7 @@
}
@Log
- void onSelectedFromDeleteMonth(int index) throws WaoExceptionO {
+ void onSelectedFromDeleteMonth(int index) throws WaoException {
getSampleMonths().remove(index);
edited = true;
}
@@ -509,12 +499,9 @@
@Persist
private WaoPropertyChangeListener propertyChange;
- public SampleRow getSampleRow() throws WaoExceptionO {
+ public SampleRow getSampleRow() throws WaoException {
if (sampleRow == null) {
if (!StringUtils.isEmpty(sampleRowId)) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
sampleRow = serviceSampling.getSampleRow(sampleRowId);
propertyChange = new WaoPropertyChangeListener();
for (SampleMonth month : sampleRow.getSampleMonth()) {
@@ -528,7 +515,7 @@
return sampleRow;
}
- public SampleRowLog getSampleRowLog() throws WaoExceptionO {
+ public SampleRowLog getSampleRowLog() throws WaoException {
if (sampleRowLog == null) {
sampleRowLog = getSampleRow().getNewSampleRowLog(user);
}
@@ -545,11 +532,8 @@
return sampleRowModel;
}
- public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO {
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
if (companySelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getCompanies]");
- }
List<Company> companies = serviceUser.getCompanies(true);
companySelectModel = new GenericSelectModel<Company>(companies, Company.class,
"name", "topiaId", propertyAccess);
@@ -557,7 +541,7 @@
return companySelectModel;
}
- public boolean isCreateMode() throws WaoExceptionO {
+ public boolean isCreateMode() throws WaoException {
return StringUtils.isEmpty(getSampleRow().getTopiaId());
}
@@ -565,12 +549,12 @@
cancel = true;
}
- void onSelectedFromSaveData() throws WaoExceptionO {
+ void onSelectedFromSaveData() throws WaoException {
saveProgram();
}
@Log
- void onValidateFormFromSampleRowForm() throws WaoExceptionO {
+ void onValidateFormFromSampleRowForm() throws WaoException {
sampleRowForm.clearErrors();
try {
// Only for save or periodChanged (refreshMonth)
@@ -661,7 +645,7 @@
}
@Log
- Object onSuccessFromSampleRowForm() throws WaoExceptionO {
+ Object onSuccessFromSampleRowForm() throws WaoException {
if (cancel) {
return this;
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -22,7 +22,7 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoBusinessException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.UserRole;
import fr.ifremer.wao.entity.SampleRow;
import fr.ifremer.wao.entity.SampleRowLog;
@@ -100,7 +100,7 @@
return sampleRowCode;
}
- void setupRender() throws WaoExceptionO {
+ void setupRender() throws WaoException {
if (StringUtils.isEmpty(sampleRowCode)) {
layout.addFatal("L'historique ne peut pas être affiché : " +
"Aucun code de ligne n'est spécifié dans l'url. ");
@@ -121,7 +121,7 @@
}
}
- public SampleRow getSampleRow() throws WaoExceptionO {
+ public SampleRow getSampleRow() throws WaoBusinessException {
if (sampleRow == null) {
sampleRow = serviceSampling.getSampleRowByCode(user, sampleRowCode);
}
@@ -142,7 +142,7 @@
return content;
}
- public SampleRowLog getNewLog() throws WaoExceptionO {
+ public SampleRowLog getNewLog() throws WaoBusinessException {
if (newLog == null) {
newLog = getSampleRow().getNewSampleRowLog(user);
}
@@ -154,7 +154,7 @@
!user.getReadOnly();
}
- public void onSuccessFromAddComment() throws WaoExceptionO {
+ public void onSuccessFromAddComment() throws WaoException {
if (canAddComment()) {
sampleRow.saveSampleRowLog(newLog);
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -24,7 +24,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.FacadeRow;
import fr.ifremer.wao.bean.ImportResults;
import fr.ifremer.wao.entity.Company;
@@ -121,7 +121,7 @@
}
@Log
- void onSuccessFromImportSamplingPlan() throws WaoExceptionO {
+ void onSuccessFromImportSamplingPlan() throws WaoException {
if (canImportSamplingPlan()) {
try {
ImportResults result = serviceSampling.importSamplingPlanCsv(
@@ -212,11 +212,8 @@
* @return List of SampleRow
* @throws WaoException
*/
- public List<SampleRow> getData() throws WaoExceptionO {
+ public List<SampleRow> getData() throws WaoException {
if (data == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]");
- }
Company company = null;
if (!user.isAdmin()) {
company = user.getCompany();
@@ -399,13 +396,13 @@
* @param rowIndex index of the row in the table
* @throws WaoException for a data problem
*/
- void onActionFromFilterPeriodDates(int rowIndex) throws WaoExceptionO {
+ void onActionFromFilterPeriodDates(int rowIndex) throws WaoException {
row = getData().get(rowIndex);
period.setFromDate(row.getPeriodBegin());
period.setThruDate(row.getPeriodEnd());
}
- void onActionFromDeleteSampleRow(int rowIndex) throws WaoExceptionO {
+ void onActionFromDeleteSampleRow(int rowIndex) throws WaoException {
row = getData().get(rowIndex);
serviceSampling.deleteSampleRow(row);
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.pages;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.BoardingResult;
import fr.ifremer.wao.bean.BoatFilter;
import fr.ifremer.wao.bean.BoatFilterImpl;
@@ -105,7 +105,7 @@
@InjectComponent
private Zone delegator;
- public Block getActiveBlock() throws WaoExceptionO {
+ public Block getActiveBlock() throws WaoException {
if (activeSynthesis == null) {
// Initialize default synthesis by Data Sampling
activeSynthesis = SynthesisId.GRAPH_SAMPLING;
@@ -165,12 +165,12 @@
private boolean reset;
- private void initSamplingBlock() throws WaoExceptionO {
+ private void initSamplingBlock() throws WaoException {
initSelectFilters(true, false, true);
}
@Override
- public BoatFilter getFilter() throws WaoExceptionO {
+ public BoatFilter getFilter() throws WaoException {
if (dataSamplingFilter == null) {
dataSamplingFilter = new BoatFilterImpl();
if (!user.isAdmin()) {
@@ -180,7 +180,7 @@
return dataSamplingFilter;
}
- public PeriodDates getPeriod() throws WaoExceptionO {
+ public PeriodDates getPeriod() throws WaoException {
if (getFilter().getPeriod() == null) {
PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
if (log.isDebugEnabled()) {
@@ -196,10 +196,7 @@
return false;
}
- public JFreeChart getDataSamplingChart() throws WaoExceptionO {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getDataSampling]");
- }
+ public JFreeChart getDataSamplingChart() throws WaoException {
List<SortedMap<Date, Integer>> res = serviceSynthesis.getDataSampling(getFilter());
Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>();
data.put("Planifié", res.get(0));
@@ -243,7 +240,7 @@
@Property
private String companyIdForBoarding;
- private void initBoardingBlock() throws WaoExceptionO {
+ private void initBoardingBlock() throws WaoException {
resetCompanySelect();
// Set the companyIdForBoarding is only necessary for an admin which
// have access to a select with all active companies (from Filters :
@@ -256,7 +253,7 @@
}
}
- public JFreeChart getBoardingBoatsChart() throws WaoExceptionO {
+ public JFreeChart getBoardingBoatsChart() throws WaoException {
Map<String, Map<?, Integer>> data =
new HashMap<String, Map<?, Integer>>();
data.put("Navires", getBoardingResult().getData());
@@ -272,11 +269,8 @@
"Nb embarquements", ChartType.BAR, data);
}
- public BoardingResult getBoardingResult() throws WaoExceptionO {
+ public BoardingResult getBoardingResult() throws WaoException {
if (boardingResult == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getBoardingBoats]");
- }
boardingResult = serviceSynthesis.getBoardingBoats(
getCompanyForBoarding(), getFromDate());
}
@@ -300,7 +294,7 @@
}
@Log
- void onSuccessFromFilterCompanyForBoarding() throws WaoExceptionO {
+ void onSuccessFromFilterCompanyForBoarding() throws WaoException {
companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding);
}
@@ -320,7 +314,7 @@
* @throws WaoException
*/
public Map<String, Double> getNonComplianceBoarding()
- throws WaoExceptionO {
+ throws WaoException {
if (nonComplianceBoarding == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
nonComplianceBoarding =
@@ -336,7 +330,7 @@
* @return the value of the indicator
* @throws WaoException
*/
- public Double getNonComplianceBoardingValue() throws WaoExceptionO {
+ public Double getNonComplianceBoardingValue() throws WaoException {
return getNonComplianceBoarding().get(user.getCompany().getName());
}
@@ -370,7 +364,7 @@
* @throws WaoException
*/
public Collection<ContactStateStatistics> getContactStateStatistics()
- throws WaoExceptionO {
+ throws WaoException {
if (contactStateStatistics == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
contactStateStatistics =
@@ -421,7 +415,7 @@
private ContactAverageReactivity allegroReactivityEntry;
public Collection<ContactAverageReactivity> getAllegroReactivity()
- throws WaoExceptionO {
+ throws WaoException {
if (allegroReactivity == null) {
Company company = !user.isAdmin() ? user.getCompany() : null;
allegroReactivity =
@@ -438,7 +432,7 @@
return periodForAllegroReactivity;
}
- public Double getAllegroReactivityValue() throws WaoExceptionO {
+ public Double getAllegroReactivityValue() throws WaoException {
if (!getAllegroReactivity().isEmpty()) {
ContactAverageReactivity entry = (ContactAverageReactivity)
CollectionUtils.get(getAllegroReactivity(), 0);
@@ -448,7 +442,7 @@
}
}
- public String getAllegroReactivityStyle() throws WaoExceptionO {
+ public String getAllegroReactivityStyle() throws WaoException {
double value = user.isAdmin() ?
allegroReactivityEntry.getResult() : getAllegroReactivityValue();
if (value >= 15.) {
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -22,7 +22,7 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoBusinessException;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.service.ServiceUser;
import fr.ifremer.wao.ui.base.WaoPage;
@@ -90,7 +90,7 @@
return userEditable;
}
- void onSuccessFromUserForm() throws WaoExceptionO {
+ void onSuccessFromUserForm() throws WaoException {
if (password != null && !password.equals(password2)) {
userForm.recordError("Les deux password ne sont pas identiques, vérifiez la saisie !");
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 17:14:29 UTC (rev 408)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 18:21:22 UTC (rev 409)
@@ -48,7 +48,6 @@
public class AppModule {
public static void bind(ServiceBinder binder) {
- binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class);
binder.bind(ContactModelFactory.class);
}
@@ -95,6 +94,12 @@
return instance;
}
+ public ServiceSynthesis buildServiceSynthesis(WaoManager manager) {
+ ServiceSynthesisImpl instance = new ServiceSynthesisImpl();
+ instance.setContext(manager.getContext());
+ return instance;
+ }
+
public static void contributeApplicationDefaults(
MappedConfiguration<String, String> configuration) {
// Contributions to ApplicationDefaults will override any contributions to
@@ -103,7 +108,7 @@
// you can extend this list of locales (it's a comma separated series of locale names;
// the first locale name is the default when there's no reasonable match).
- configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr,en");
+ configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr");
// The factory default is true but during the early stages of an application
// overriding to false is a good idea. In addition, this is often overridden
1
0
[Suiviobsmer-commits] r408 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao wao-ui/src/main/java/fr/ifremer/wao/ui/data wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/java/fr/ifremer/wao/ui/services
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 17:14:29 +0000 (Thu, 01 Apr 2010)
New Revision: 408
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java
Log:
- use ServiceTransformer for ServiceContact
- clean old context usage in UI
- clean ServiceSamplingImpl
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -27,9 +27,8 @@
import fr.ifremer.wao.io.ImportHelper.*;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
+import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.WaoExceptionO;
-import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.bean.ContactState;
import java.io.IOException;
import java.io.InputStream;
@@ -74,6 +73,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -89,26 +89,27 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class ServiceContactImpl implements ServiceContact {
+public class ServiceContactImpl extends ServiceContactAbstract {
private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class);
- protected TopiaContext rootContext;
+// protected TopiaContext rootContext;
+//
+// public ServiceContactImpl() throws WaoExceptionO {
+// rootContext = context.getTopiaRootContext();
+// }
- public ServiceContactImpl() throws WaoExceptionO {
- rootContext = WaoContextO.getTopiaRootContext();
- }
-
@Override
- public Map<String, Contact> getContacts(ContactFilter filter) throws WaoExceptionO {
- Map<String, Contact> results = new HashMap<String, Contact>();
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public Map<String, Contact> executeGetContacts(TopiaContext transaction,
+ ContactFilter filter) throws TopiaException {
+// Map<String, Contact> results = new HashMap<String, Contact>();
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -123,61 +124,62 @@
}
query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH);
- results = dao.findAllMappedByQuery(query);
+ return dao.findAllMappedByQuery(query);
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getContacts ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de filtrer la liste des contacts", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return results;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getContacts ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de filtrer la liste des contacts", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return results;
}
@Override
- public int getNbContacts(ContactFilter filter) throws WaoExceptionO {
- TopiaContext transaction = null;
- int result = 0;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public int executeGetNbContacts(TopiaContext transaction,
+ ContactFilter filter) throws TopiaException {
+// TopiaContext transaction = null;
+// int result = 0;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQuery("C");
query = filter.prepareQueryForContact(query);
- result = query.executeCount();
+ return query.executeCount();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getNbContacts ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de compter le nombre de contacts filtrés", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return result;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getNbContacts ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de compter le nombre de contacts filtrés", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return result;
}
@Override
- public Contact getNewContact(WaoUser user, SampleRow row, Boat boat) {
+ public Contact executeGetNewContact(WaoUser user, SampleRow row, Boat boat) {
Contact result = new ContactImpl();
result.setObserver(user);
result.setSampleRow(row);
@@ -187,14 +189,15 @@
}
@Override
- public void saveContact(Contact contact, boolean delete) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public void executeSaveContact(TopiaContext transaction,
+ Contact contact, boolean delete) throws TopiaException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -202,7 +205,7 @@
log.debug("Create date : " + contact.getTopiaCreateDate());
}
- WaoContextO.prepareTopiaId(Contact.class, contact);
+ context.prepareTopiaId(Contact.class, contact);
if (delete) {
dao.delete(contact);
} else {
@@ -211,29 +214,29 @@
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ saveContact ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de sauvegarder le contact", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ saveContact ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de sauvegarder le contact", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
}
@Override
- public InputStream exportContactCsv(ContactFilter filter)
- throws WaoExceptionO {
- TopiaContext transaction = null;
- InputStream result = null;
+ public InputStream executeExportContactCsv(TopiaContext transaction,
+ ContactFilter filter) throws Exception {
+// TopiaContext transaction = null;
+// InputStream result = null;
CsvWriter writer = null;
try {
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
File file = File.createTempFile("wao-contacts-", ".csv");
file.deleteOnExit();
@@ -243,7 +246,7 @@
}
FileOutputStream output = new FileOutputStream(file);
- writer = new CsvWriter(output, ',', WaoContextO.getCsvCharset());
+ writer = new CsvWriter(output, ',', context.getCsvCharset());
ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) {
@@ -347,31 +350,35 @@
export.writeRecord();
}
- result = new FileInputStream(file);
+ return new FileInputStream(file);
//transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible d'exporter les contacts", eee);
+ throw eee;
+// context.serviceException(transaction,
+// "Impossible d'exporter les contacts", eee);
} finally {
if (writer != null) {
writer.close();
}
- WaoContextO.closeTransaction(transaction);
+// context.closeTransaction(transaction);
}
- return result;
+// return result;
}
@Override
- public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public ImportResults executeImportContactCsv(TopiaContext transaction,
+ WaoUser user, InputStream input)
+ throws TopiaException, IOException,
+ WaoBusinessException, ParseException {
+// TopiaContext transaction = null;
ImportResults result = new ImportResultsImpl();
int currRow = 1;
- CsvReader reader = null;
- try {
- transaction = rootContext.beginTransaction();
+// CsvReader reader = null;
+// try {
+// transaction = rootContext.beginTransaction();
- reader = new CsvReader(input, WaoContextO.getCsvCharset());
+ CsvReader reader = new CsvReader(input, context.getCsvCharset());
reader.readHeaders();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
@@ -549,23 +556,23 @@
transaction.commitTransaction();
//transaction.closeContext();
- } catch (ParseException eee) {
- WaoContextO.serviceException(transaction,
- "Erreur ligne " + currRow + " : " +
- "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee);
- } catch (Exception eee) {
- if (log.isDebugEnabled()) {
- try {
- log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues()));
- } catch (IOException ex) {
- log.error("Reader error", ex);
- }
- }
- WaoContextO.serviceException(transaction,
- "Impossible d'importer les contacts", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// } catch (ParseException eee) {
+// context.serviceException(transaction,
+// "Erreur ligne " + currRow + " : " +
+// "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee);
+// } catch (Exception eee) {
+// if (log.isDebugEnabled()) {
+// try {
+// log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues()));
+// } catch (IOException ex) {
+// log.error("Reader error", ex);
+// }
+// }
+// context.serviceException(transaction,
+// "Impossible d'importer les contacts", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return result;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -26,9 +26,7 @@
import fr.ifremer.wao.io.ImportHelper;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.FacadeRow;
import fr.ifremer.wao.bean.FacadeRowImpl;
import fr.ifremer.wao.bean.ImportResults;
@@ -56,7 +54,6 @@
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -83,25 +80,16 @@
private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class);
-// protected TopiaContext rootContext;
-//
public ServiceSamplingImpl() {
-// rootContext = context.getTopiaRootContext();
prepareBinderForProfession();
}
@Override
public void executeCreateUpdateSampleRow(TopiaContext transaction,
SampleRow row, List<Boat> boats, SampleRowLog rowLog)
- throws TopiaException, Exception {
-// TopiaContext transaction = null;
+ throws Exception {
TopiaContext transaction2 = null;
try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
SampleRowLogDAO logDAO = WaoDAOHelper.getSampleRowLogDAO(transaction);
context.prepareTopiaId(SampleRowLog.class, rowLog);
@@ -248,24 +236,10 @@
}
transaction.commitTransaction();
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ createUpdateSampleRow ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
- //transaction.closeContext();
} catch (Exception eee) {
throw eee;
-// context.serviceException(transaction,
-// "Impossible de sauvegarder la ligne d'échantillon", eee);
} finally {
-// try {
- transaction2.closeContext();
-// } catch (TopiaException eee) {
-// log.error("Error closing transaction", eee);
-// }
-// context.closeTransaction(transaction);
+ transaction2.closeContext();
}
}
@@ -282,379 +256,174 @@
// fishingZoneDAO.update(zoneFromDB);
// }
-// @Override
-// public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws WaoException {
-// TopiaContext transaction = null;
-// List<SampleRowLog> results = new ArrayList<SampleRowLog>();
-// try {
-// transaction = rootContext.beginTransaction();
-//
-// SampleRowLogDAO dao = WaoDAOHelper.getSampleRowLogDAO(transaction);
-// results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList();
-//
-// transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContext.serviceException(transaction,
-// "Impossible de récupérer l'historique de la ligne d'échantillonnage", eee);
-// }
-// return results;
-// }
-
@Override
public FacadeRow executeGetSampleRowsOrderedByFishingZone(
TopiaContext transaction,
- PeriodDates period, Company company) throws TopiaException {
-// TopiaContext transaction = null;
+ PeriodDates period, Company company)
+ throws TopiaException, IllegalArgumentException {
FacadeRow result = new FacadeRowImpl();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
- if (period.getFromDate() == null || period.getThruDate() == null) {
- throw new IllegalArgumentException("PeriodBegin date and/or PeriodEnd date can't be null !");
- }
-// transaction = rootContext.beginTransaction();
+ if (period.getFromDate() == null || period.getThruDate() == null) {
+ throw new IllegalArgumentException("PeriodBegin date and/or " +
+ "PeriodEnd date can't be null !");
+ }
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery("S").addDistinct().
- addFrom(FishingZone.class.getName() + " F").
- add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
+ TopiaQuery query = dao.createQuery("S").addDistinct().
+ addFrom(FishingZone.class.getName() + " F").
+ add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
- if (company != null) {
- query.add("S." + SampleRow.COMPANY, company);
- }
+ if (company != null) {
+ query.add("S." + SampleRow.COMPANY, company);
+ }
- // Prepare period dates
- period.initDayOfMonthExtremities();
- query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
- add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
+ // Prepare period dates
+ period.initDayOfMonthExtremities();
+ query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
+ add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
- // Order By facade, sector, districtCode, sampleRowCode
- String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE;
- query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder);
- // Load data
- //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY);
+ // Order By facade, sector, districtCode, sampleRowCode
+ String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE;
+ query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder);
+ // Load data
+ //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY);
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ before query getSampleRowsOrderedByFishingZone ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// startTime = System.currentTimeMillis();
-// }
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
- query.addLoad(SampleRow.SAMPLE_MONTH);
- List<SampleRow> results = dao.findAllByQuery(query);
+ query.addLoad(SampleRow.SAMPLE_MONTH);
+ List<SampleRow> results = dao.findAllByQuery(query);
- for (SampleRow row : results) {
- // use FacadeRow to complete ordering using maps
- result.addRow(row);
- }
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getSampleRowsOrderedByFishingZone exec query ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ for (SampleRow row : results) {
+ // use FacadeRow to complete ordering using maps
+ result.addRow(row);
+ }
return result;
}
@Override
public List<String> executeGetPrograms(TopiaContext transaction,
Company company) throws TopiaException {
-// TopiaContext transaction = null;
-// List<String> results = new ArrayList<String>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery();
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query = dao.createQuery();
- if (company != null) {
- query.add(SampleRow.COMPANY, company);
- }
+ if (company != null) {
+ query.add(SampleRow.COMPANY, company);
+ }
- return (List<String>)query.addDistinct().
- setSelect(SampleRow.PROGRAM_NAME).execute();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getPrograms ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de charger la liste des programmes", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return results;
+ return (List<String>)query.addDistinct().
+ setSelect(SampleRow.PROGRAM_NAME).execute();
}
@Override
public List<SampleRow> executeGetSampleRowsByFilter(
TopiaContext transaction, SamplingFilter filter)
throws TopiaException {
-// TopiaContext transaction = null;
-// List<SampleRow> results = new ArrayList<SampleRow>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
-
- TopiaQuery query = dao.createQuery("S").
- addDistinct().addOrder("S." + SampleRow.CODE);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- query = filter.prepareQueryForSampling(query, "S");
+ TopiaQuery query = dao.createQuery("S").
+ addDistinct().addOrder("S." + SampleRow.CODE);
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ after prepareQueryForSampling ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// startTime = System.currentTimeMillis();
-// }
+ query = filter.prepareQueryForSampling(query, "S");
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
- return dao.findAllByQuery(query);
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getSampleRowsByFilter exec query ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// startTime = System.currentTimeMillis();
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAllByQuery(query);
}
@Override
public SampleRow executeGetSampleRow(TopiaContext transaction,
List<Object> errorArgs, String sampleRowId) throws TopiaException {
-// TopiaContext transaction = null;
-// SampleRow result = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- errorArgs.add(sampleRowId);
+ errorArgs.add(sampleRowId);
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- SampleRow result = dao.findByTopiaId(sampleRowId);
+ SampleRow result = dao.findByTopiaId(sampleRowId);
- result.sizeSampleMonth();
- result.sizeElligibleBoat();
+ result.sizeSampleMonth();
+ result.sizeElligibleBoat();
- return result;
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getSampleRow ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de charger la ligne d'échantillon ayant pour" +
-// " identifiant : " + sampleRowId,
-// eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return result;
+ return result;
}
@Override
public SampleRow executeGetSampleRowByCode(TopiaContext transaction,
List<Object> errorArgs, WaoUser user, String sampleRowCode)
throws TopiaException, WaoBusinessException {
-// TopiaContext transaction = null;
-// SampleRow result = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// if (log.isInfoEnabled()) {
-// log.info("W:[ getSampleRowByCode ] : " +
-// "sampleRowCode = " + sampleRowCode);
-// }
-// transaction = rootContext.beginTransaction();
- errorArgs.add(sampleRowCode);
+ errorArgs.add(sampleRowCode);
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery().
- add(SampleRow.CODE, sampleRowCode);
+ TopiaQuery query = dao.createQuery().
+ add(SampleRow.CODE, sampleRowCode);
- if (!user.isAdmin()) {
- query.add(SampleRow.COMPANY, user.getCompany());
- }
+ if (!user.isAdmin()) {
+ query.add(SampleRow.COMPANY, user.getCompany());
+ }
- query.addLoad(SampleRow.SAMPLE_ROW_LOG);
- SampleRow result = dao.findByQuery(query);
+ query.addLoad(SampleRow.SAMPLE_ROW_LOG);
+ SampleRow result = dao.findByQuery(query);
- if (result == null) {
- throw new WaoBusinessException(Type.NOT_EXISTS,
- ServiceSampling.class, "La ligne du plan avec " +
- "pour code " + sampleRowCode + " est introuvable !");
- }
+ if (result == null) {
+ throw new WaoBusinessException(Type.NOT_EXISTS,
+ ServiceSampling.class, "La ligne du plan avec " +
+ "pour code " + sampleRowCode + " est introuvable !");
+ }
- return result;
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getSampleRowByCode ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de charger la ligne " +
-// "d'échantillon ayant pour code : " + sampleRowCode,
-// eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return result;
+ return result;
}
@Override
public void executeDeleteSampleRow(TopiaContext transaction,
List<Object> errorArgs, SampleRow sampleRow) throws TopiaException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- errorArgs.add(sampleRow.getCode());
+ errorArgs.add(sampleRow.getCode());
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
+ SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
- dao.delete(row);
+ dao.delete(row);
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ deleteSampleRow ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
-// eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
@Override
public String executeGetNewSampleRowCode(TopiaContext transaction,
Date beginDate) throws TopiaException {
-// TopiaContext transaction = null;
-// String result = null;
if (beginDate == null) {
return null;
}
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- Calendar begin = new GregorianCalendar();
- begin.setTime(beginDate);
- int year = begin.get(Calendar.YEAR);
+ Calendar begin = new GregorianCalendar();
+ begin.setTime(beginDate);
+ int year = begin.get(Calendar.YEAR);
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query =
- dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query =
+ dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
- String maxCode =
- query.executeToString("MAX(" + SampleRow.CODE + ")");
+ String maxCode =
+ query.executeToString("MAX(" + SampleRow.CODE + ")");
- if (log.isDebugEnabled()) {
- log.debug("Max code found : " + maxCode);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Max code found : " + maxCode);
+ }
- int num = 1;
- if (!StringUtils.isEmpty(maxCode)) {
- String[] part = maxCode.split("_");
- num = Integer.parseInt(part[1]) + 1;
- }
- String str = StringUtils.leftPad("" + num, 4, "0");
- return year + "_" + str;
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getNewSampleRowCode ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// context.serviceException(transaction,
-// "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
-// eee);
-// } finally {
-// context.closeTransaction(transaction);
-// }
-// return result;
+ int num = 1;
+ if (!StringUtils.isEmpty(maxCode)) {
+ String[] part = maxCode.split("_");
+ num = Integer.parseInt(part[1]) + 1;
+ }
+ String str = StringUtils.leftPad("" + num, 4, "0");
+ return year + "_" + str;
}
@Override
@@ -717,12 +486,9 @@
@Override
public InputStream executeExportSamplingPlanCsv(TopiaContext transaction,
List<Object> errorArgs, WaoUser user, PeriodDates period)
- throws TopiaException, Exception {
-// TopiaContext transaction = null;
-// InputStream result = null;
+ throws Exception {
CsvWriter writer = null;
try {
-// transaction = rootContext.beginTransaction();
DateFormat dateFormat = SAMPLING.getDateFormat();
errorArgs.add(dateFormat.format(period.getFromDate()));
@@ -841,16 +607,10 @@
} catch (Exception eee) {
throw eee;
-// DateFormat dateFormat = SAMPLING.getDateFormat();
-// context.serviceException(transaction,
-// "Impossible d'exporter le plan d'échantillonnage sur la période du " +
-// dateFormat.format(period.getFromDate()) + " au " +
-// dateFormat.format(period.getThruDate()), eee);
} finally {
if (writer != null) {
writer.close();
}
-// context.closeTransaction(transaction);
}
}
@@ -860,85 +620,82 @@
List<Object> errorArgs, InputStream input)
throws WaoBusinessException, IOException,
TopiaException, ParseException {
-// TopiaContext transaction = null;
+
ImportResults result = new ImportResultsImpl();
- //int[] result = new int[3];
int currRow = 0;
SampleRow row = null;
-// try {
-// transaction = rootContext.beginTransaction();
- errorArgs.add(currRow);
- errorArgs.add(null);
+ errorArgs.add(currRow);
+ errorArgs.add(null);
- CsvReader reader = new CsvReader(input, context.getCsvCharset());
- reader.readHeaders();
+ CsvReader reader = new CsvReader(input, context.getCsvCharset());
+ reader.readHeaders();
- SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- //int nbImported = 0;
- //int nbRefused = 0;
+ //int nbImported = 0;
+ //int nbRefused = 0;
- while(reader.readRecord()) {
+ while(reader.readRecord()) {
- currRow++;
+ currRow++;
- if (log.isTraceEnabled()) {
- log.trace(" " + Arrays.asList(reader.getValues()));
- }
+ if (log.isTraceEnabled()) {
+ log.trace(" " + Arrays.asList(reader.getValues()));
+ }
- String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim();
+ String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim();
- if (StringUtils.isEmpty(code)) {
- continue;
- }
+ if (StringUtils.isEmpty(code)) {
+ continue;
+ }
- errorArgs.set(0, currRow);
- errorArgs.set(1, code);
-
- String districts = ImportHelper.read(reader,
- FISHING_ZONE.PECHE_DIVISION);
-
- row = dao.findByCode(code);
- // Refuse existing SampleRow
- if (row != null) {
- result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant");
- result.incNbRefused();
- // Refuse Fishing zones empty
- } else if (StringUtils.isEmpty(districts)) {
- result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné");
- result.incNbRefused(); //nbRefused++;
- } else {
- row = dao.create(SampleRow.CODE, code);
+ errorArgs.set(0, currRow);
+ errorArgs.set(1, code);
- String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM);
+ String districts = ImportHelper.read(reader,
+ FISHING_ZONE.PECHE_DIVISION);
- // Create link with company if set in file
- if (!StringUtils.isEmpty(companyName)) {
- CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.findByName(companyName);
- if (company == null) {
- throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " +
- "La société portant le nom '" + companyName + "' n'existe pas dans l'application");
- }
- row.setCompany(company);
+ row = dao.findByCode(code);
+ // Refuse existing SampleRow
+ if (row != null) {
+ result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant");
+ result.incNbRefused();
+ // Refuse Fishing zones empty
+ } else if (StringUtils.isEmpty(districts)) {
+ result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné");
+ result.incNbRefused(); //nbRefused++;
+ } else {
+ row = dao.create(SampleRow.CODE, code);
+
+ String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM);
+
+ // Create link with company if set in file
+ if (!StringUtils.isEmpty(companyName)) {
+ CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.findByName(companyName);
+ if (company == null) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " +
+ "La société portant le nom '" + companyName + "' n'existe pas dans l'application");
}
+ row.setCompany(company);
+ }
- // Import profession. Creation if not exist
- Profession profession = importProfession(transaction, reader);
- row.setProfession(profession);
+ // Import profession. Creation if not exist
+ Profession profession = importProfession(transaction, reader);
+ row.setProfession(profession);
- // Import zones and set them to the row
- // throw WaoException if FishingZone doesn't exist
- importFishingZones(transaction, districts, currRow, row);
+ // Import zones and set them to the row
+ // throw WaoException if FishingZone doesn't exist
+ importFishingZones(transaction, districts, currRow, row);
- updateRow(transaction, row, reader);
- result.incNbImported(); //nbImported++;
- }
- // Commit row by row
- transaction.commitTransaction();
+ updateRow(transaction, row, reader);
+ result.incNbImported(); //nbImported++;
}
+ // Commit row by row
+ transaction.commitTransaction();
+ }
//transaction.closeContext();
@@ -982,17 +739,6 @@
String especes = ImportHelper.read(reader, SAMPLING.METIER_ESPECES);
ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction);
-// Map<String, Object> existParams = new HashMap<String, Object>();
-// existParams.put(Profession.CODE_DCF5, codeDCF5);
-// existParams.put(Profession.MESH_SIZE, maillage);
-// existParams.put(Profession.SIZE, taille);
-// existParams.put(Profession.OTHER, autre);
-//
-// Profession profession = dao.findByProperties(existParams);
-//
-// if (profession == null) {
-// profession = dao.create();
-// }
// Always create a new profession
Profession profession = dao.create();
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 17:14:29 UTC (rev 408)
@@ -22,6 +22,12 @@
wao.error.serviceBoat.getNbBoatsByFilter=
wao.error.serviceBoat.importActivityCalendarCsv=
wao.error.serviceBoat.importBoatCsv=
+wao.error.serviceContact.exportContactCsv=
+wao.error.serviceContact.getContacts=
+wao.error.serviceContact.getNbContacts=
+wao.error.serviceContact.getNewContact=
+wao.error.serviceContact.importContactCsv=
+wao.error.serviceContact.saveContact=
wao.error.serviceNews.getNews=
wao.error.serviceNews.saveNews=
wao.error.serviceReferential.getFacades=
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 17:14:29 UTC (rev 408)
@@ -22,6 +22,12 @@
wao.error.serviceBoat.getNbBoatsByFilter=Impossible de filtrer la liste des navires
wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9
wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails.
+wao.error.serviceContact.exportContactCsv=
+wao.error.serviceContact.getContacts=
+wao.error.serviceContact.getNbContacts=
+wao.error.serviceContact.getNewContact=
+wao.error.serviceContact.importContactCsv=
+wao.error.serviceContact.saveContact=
wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news
wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s'
wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades
@@ -29,18 +35,18 @@
wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers
wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche
wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
-wao.error.serviceSampling.createUpdateSampleRow=
-wao.error.serviceSampling.deleteSampleRow=
-wao.error.serviceSampling.exportSamplingPlanCsv=
+wao.error.serviceSampling.createUpdateSampleRow=Impossible de sauvegarder la ligne d'\u00E9chantillon
+wao.error.serviceSampling.deleteSampleRow=Impossible de supprimer la ligne d'\u00E9chantillon \: %1$s
+wao.error.serviceSampling.exportSamplingPlanCsv=Impossible d'exporter le plan d'\u00E9chantillonnage sur la p\u00E9riode du %1$s au %2$s
wao.error.serviceSampling.getNewProfession=
wao.error.serviceSampling.getNewSampleMonth=
wao.error.serviceSampling.getNewSampleRow=
-wao.error.serviceSampling.getNewSampleRowCode=
-wao.error.serviceSampling.getPrograms=
-wao.error.serviceSampling.getSampleRow=
-wao.error.serviceSampling.getSampleRowByCode=
-wao.error.serviceSampling.getSampleRowsByFilter=
-wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=
+wao.error.serviceSampling.getNewSampleRowCode=Impossible de r\u00E9cup\u00E9rer un nouveau code pour une ligne d'\u00E9chantillonnage
+wao.error.serviceSampling.getPrograms=Impossible de charger la liste des programmes
+wao.error.serviceSampling.getSampleRow=Impossible de charger la ligne d'\u00E9chantillon ayant pour identifiant \: %1$s
+wao.error.serviceSampling.getSampleRowByCode=Impossible de charger la ligne d'\u00E9chantillon ayant pour code %1$s
+wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
+wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage
wao.error.serviceSampling.importSamplingPlanCsv=
wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion
wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -138,7 +138,7 @@
public ServiceSampling getServiceSampling() throws WaoExceptionO {
ServiceSamplingImpl instance = new ServiceSamplingImpl();
- instance.setContext(context);
+ instance.setContext(getContext());
return instance;
}
@@ -156,7 +156,7 @@
public ServiceContact getServiceContact() throws WaoExceptionO {
ServiceContactImpl instance = new ServiceContactImpl();
-// instance.setContext(context);
+ instance.setContext(context);
return instance;
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.ui.data;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoUtils;
import java.util.Date;
import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.services.Response;
@@ -68,7 +68,7 @@
*/
@Override
public void prepareResponse(Response response) {
- Date current = WaoContextO.getCurrentDate();
+ Date current = WaoUtils.getCurrentDate();
filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv";
response.setHeader("Content-Disposition",
"attachment; filename=\"" + filename +"\"");
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -22,7 +22,7 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoBusinessException;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.bean.BoatFilterImpl;
import fr.ifremer.wao.entity.Boat;
@@ -47,6 +47,7 @@
import fr.ifremer.wao.ui.components.Layout;
import fr.ifremer.wao.ui.data.BoatDataSource;
import fr.ifremer.wao.ui.data.ExportStreamResponse;
+import fr.ifremer.wao.ui.services.WaoManager;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -613,8 +614,11 @@
/** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/
+ @Inject
+ private WaoManager manager;
+
public boolean isActivityCalendarImportRun() {
- return WaoContextO.isActivityCalendarImportRun();
+ return manager.isActivityCalendarImportRun();
}
public Block getActiveBoatInfosBlock() {
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -22,7 +22,7 @@
package fr.ifremer.wao.ui.pages;
import fr.ifremer.wao.WaoBusinessException;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.bean.BoatFilter;
import fr.ifremer.wao.bean.ContactFilter;
@@ -45,6 +45,7 @@
import fr.ifremer.wao.ui.components.Layout;
import fr.ifremer.wao.ui.data.ExportStreamResponse;
import fr.ifremer.wao.ui.services.ContactModelFactory;
+import fr.ifremer.wao.ui.services.WaoManager;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
@@ -556,6 +557,9 @@
@InjectComponent
private Field inputDate;
+ @Inject
+ private WaoManager manager;
+
@Log
void onValidateFormFromContactsForm() {
contactsForm.clearErrors();
@@ -584,7 +588,7 @@
" ne peut pas être antérieure à celle de début");
}
- Date current = WaoContextO.getCurrentDate();
+ Date current = manager.getCurrentDate();
if (end != null && end.after(current)) {
contactsForm.recordError(endDate, "La date de fin de la marée" +
@@ -652,7 +656,7 @@
contactSelectedId = contactEdited.getTopiaId();
oldComment = null;
contactEdited = null;
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
layout.addError(eee.getMessage());
}
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -23,6 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.entity.Boat;
import fr.ifremer.wao.entity.Company;
@@ -40,6 +41,7 @@
import fr.ifremer.wao.ui.base.GenericSelectModel;
import fr.ifremer.wao.ui.base.WaoPage;
import fr.ifremer.wao.ui.data.WaoPropertyChangeListener;
+import fr.ifremer.wao.ui.services.WaoManager;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -307,6 +309,9 @@
/*************************** PROGRAM & MONTHS *****************************/
+ @Inject
+ private WaoManager manager;
+
@Persist
private SelectModel programSelectModel;
@@ -409,7 +414,7 @@
public String getMonthStyle() {
String style = " ";
- Date current = WaoContextO.getCurrentDate();
+ Date current = manager.getCurrentDate();
if (sampleMonth.isCurrentMonth()) {
style += "selected";
} else if (current.after(sampleMonth.getPeriodDate())) {
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -48,20 +48,8 @@
public class AppModule {
public static void bind(ServiceBinder binder) {
- // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
-
- // Make bind() calls on the binder object to define most IoC services.
- // Use service builder methods (example below) when the implementation
- // is provided inline, or requires more initialization than simply
- // invoking the constructor.
-// binder.bind(ServiceNews.class, ServiceNewsImpl.class);
-// binder.bind(ServiceUser.class, ServiceUserImpl.class);
-// binder.bind(ServiceSampling.class, ServiceSamplingImpl.class);
-// binder.bind(ServiceReferential.class, ServiceReferentialImpl.class);
-// binder.bind(ServiceBoat.class, ServiceBoatImpl.class);
- binder.bind(ServiceContact.class, ServiceContactImpl.class);
- binder.bind(ContactModelFactory.class);
binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class);
+ binder.bind(ContactModelFactory.class);
}
@EagerLoad
@@ -101,6 +89,12 @@
return instance;
}
+ public ServiceContact buildServiceContact(WaoManager manager) {
+ ServiceContactImpl instance = new ServiceContactImpl();
+ instance.setContext(manager.getContext());
+ return instance;
+ }
+
public static void contributeApplicationDefaults(
MappedConfiguration<String, String> configuration) {
// Contributions to ApplicationDefaults will override any contributions to
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 16:46:41 UTC (rev 407)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 17:14:29 UTC (rev 408)
@@ -23,6 +23,7 @@
import fr.ifremer.wao.WaoContextImplementor;
import fr.ifremer.wao.WaoProperty;
+import java.util.Date;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.nuiton.util.ApplicationConfig;
import org.slf4j.Logger;
@@ -75,6 +76,10 @@
return context.getConfiguration();
}
+ public Date getCurrentDate() {
+ return context.getCurrentDate();
+ }
+
}
1
0
[Suiviobsmer-commits] r407 - in trunk: wao-business/src/main/java/fr/ifremer/wao wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao wao-business/src/test/java/fr/ifremer/wao/entity wao-business/src/test/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/java/fr/ifremer/wao/ui/services
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 16:46:41 +0000 (Thu, 01 Apr 2010)
New Revision: 407
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
Log:
use ServiceTransformer for ServiceSampling
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -1,9 +1,16 @@
package fr.ifremer.wao;
+import fr.ifremer.wao.entity.ActivityCalendar;
+import java.io.IOException;
import java.util.Date;
+import org.apache.log4j.Level;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.RollingFileAppender;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class only used for entities. The entities can't have WaoContext, so
@@ -18,9 +25,14 @@
* par : $Author$
*/
public class WaoUtils {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(WaoUtils.class);
private static WaoContextImplementor context;
+ private static org.apache.log4j.Logger activityCalendarAccessLogger;
+
static void setContext(WaoContextImplementor context) {
WaoUtils.context = context;
}
@@ -36,7 +48,41 @@
public static Date getCurrentDate() {
return context.getCurrentDate();
}
+
+ // TEMP
+ public static void addActivityCalendarAccessLog(String message)
+ throws IOException {
+ if (activityCalendarAccessLogger == null) {
+ // Define appender configuration only once
+ String filename =
+ WaoProperty.FILENAME_LOG_ACTIVITY_ACCESS.getValue();
+ PatternLayout layout = new PatternLayout();
+ layout.setConversionPattern("%d %m%n");
+ RollingFileAppender appender = new RollingFileAppender();
+ appender.setName("ActivityCalendarAccess");
+ appender.setFile(filename);
+ appender.setImmediateFlush(true);
+ appender.setMaxFileSize("2MB");
+ appender.setMaxBackupIndex(10);
+ appender.setAppend(true);
+ appender.setThreshold(Level.INFO);
+ appender.setLayout(layout);
+ appender.activateOptions();
+
+ activityCalendarAccessLogger =
+ org.apache.log4j.Logger.getLogger(ActivityCalendar.class);
+
+ activityCalendarAccessLogger.addAppender(appender);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("message : " + message);
+ }
+
+ activityCalendarAccessLogger.info(message);
+ }
+
/**
* This method must be removed. Use {@link WaoContext} instance instead.
*
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -25,9 +25,9 @@
import com.csvreader.CsvWriter;
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.WaoDAOHelper;
import fr.ifremer.wao.WaoProperty;
+import fr.ifremer.wao.WaoUtils;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -565,7 +565,7 @@
Company company = user.getCompany();
// FIXME-FD20100401 Find a way to avoid using old context for
// logging access on ActivityCalendar
- WaoContextO.addActivityCalendarAccessLog(
+ WaoUtils.addActivityCalendarAccessLog(
"Calendrier " + result.getYear() + " du navire " +
boat.getName() + " (" + boat.getImmatriculation() + ") vu " +
"par " + user.getFullName() + " de la société " +
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -28,7 +28,7 @@
import fr.ifremer.wao.WaoBusinessException.Type;
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.FacadeRow;
import fr.ifremer.wao.bean.FacadeRowImpl;
import fr.ifremer.wao.bean.ImportResults;
@@ -55,7 +55,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
@@ -80,33 +79,35 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class ServiceSamplingImpl implements ServiceSampling {
+public class ServiceSamplingImpl extends ServiceSamplingAbstract {
private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class);
- protected TopiaContext rootContext;
-
- public ServiceSamplingImpl() throws WaoExceptionO {
- rootContext = WaoContextO.getTopiaRootContext();
+// protected TopiaContext rootContext;
+//
+ public ServiceSamplingImpl() {
+// rootContext = context.getTopiaRootContext();
prepareBinderForProfession();
}
@Override
- public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public void executeCreateUpdateSampleRow(TopiaContext transaction,
+ SampleRow row, List<Boat> boats, SampleRowLog rowLog)
+ throws TopiaException, Exception {
+// TopiaContext transaction = null;
TopiaContext transaction2 = null;
try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
SampleRowLogDAO logDAO = WaoDAOHelper.getSampleRowLogDAO(transaction);
- WaoContextO.prepareTopiaId(SampleRowLog.class, rowLog);
+ context.prepareTopiaId(SampleRowLog.class, rowLog);
logDAO.update(rowLog);
- boolean newRow = WaoContextO.prepareTopiaId(SampleRow.class, row);
+ boolean newRow = context.prepareTopiaId(SampleRow.class, row);
if (log.isDebugEnabled()) {
log.debug("new sampleRow : " + newRow);
@@ -121,7 +122,7 @@
Company oldCompany = null;
Map<String, SampleMonth> oldMonths = new HashMap<String, SampleMonth>();
List<FishingZone> oldZones = new ArrayList<FishingZone>();
- transaction2 = rootContext.beginTransaction();
+ transaction2 = context.beginTransaction();
// UPDATE
if (!newRow) {
// Prepare data for logging or deleting oldMonths
@@ -161,7 +162,7 @@
// Save Profession
ProfessionDAO professionDAO = WaoDAOHelper.getProfessionDAO(transaction);
- WaoContextO.prepareTopiaId(Profession.class, row.getProfession());
+ context.prepareTopiaId(Profession.class, row.getProfession());
rowLog.addChangeProfession(oldProfession, row.getProfession());
professionDAO.update(row.getProfession());
@@ -181,7 +182,7 @@
}
// Create or update months
for (SampleMonth month : newMonths) {
- boolean monthCreated = WaoContextO.prepareTopiaId(SampleMonth.class, month);
+ boolean monthCreated = context.prepareTopiaId(SampleMonth.class, month);
String date = dateFormat.format(month.getPeriodDate());
if (monthCreated) {
// log create month
@@ -247,23 +248,24 @@
}
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ createUpdateSampleRow ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ createUpdateSampleRow ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
//transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de sauvegarder la ligne d'échantillon", eee);
+ throw eee;
+// context.serviceException(transaction,
+// "Impossible de sauvegarder la ligne d'échantillon", eee);
} finally {
- try {
+// try {
transaction2.closeContext();
- } catch (TopiaException eee) {
- log.error("Error closing transaction", eee);
- }
- WaoContextO.closeTransaction(transaction);
+// } catch (TopiaException eee) {
+// log.error("Error closing transaction", eee);
+// }
+// context.closeTransaction(transaction);
}
}
@@ -299,18 +301,20 @@
// }
@Override
- public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public FacadeRow executeGetSampleRowsOrderedByFishingZone(
+ TopiaContext transaction,
+ PeriodDates period, Company company) throws TopiaException {
+// TopiaContext transaction = null;
FacadeRow result = new FacadeRowImpl();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
if (period.getFromDate() == null || period.getThruDate() == null) {
throw new IllegalArgumentException("PeriodBegin date and/or PeriodEnd date can't be null !");
}
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
@@ -333,13 +337,13 @@
// Load data
//query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY);
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ before query getSampleRowsOrderedByFishingZone ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- startTime = System.currentTimeMillis();
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ before query getSampleRowsOrderedByFishingZone ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// startTime = System.currentTimeMillis();
+// }
if (log.isDebugEnabled()) {
log.debug("Query : " + query);
@@ -353,33 +357,34 @@
result.addRow(row);
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getSampleRowsOrderedByFishingZone exec query ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getSampleRowsOrderedByFishingZone exec query ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return result;
}
@Override
- public List<String> getPrograms(Company company) throws WaoExceptionO {
- TopiaContext transaction = null;
- List<String> results = new ArrayList<String>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public List<String> executeGetPrograms(TopiaContext transaction,
+ Company company) throws TopiaException {
+// TopiaContext transaction = null;
+// List<String> results = new ArrayList<String>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery();
@@ -388,127 +393,139 @@
query.add(SampleRow.COMPANY, company);
}
- results = (List<String>)query.setSelect("DISTINCT " + SampleRow.PROGRAM_NAME).execute();
+ return (List<String>)query.addDistinct().
+ setSelect(SampleRow.PROGRAM_NAME).execute();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getPrograms ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de charger la liste des programmes", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return results;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getPrograms ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de charger la liste des programmes", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return results;
}
@Override
- public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws WaoExceptionO {
- TopiaContext transaction = null;
- List<SampleRow> results = new ArrayList<SampleRow>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public List<SampleRow> executeGetSampleRowsByFilter(
+ TopiaContext transaction, SamplingFilter filter)
+ throws TopiaException {
+// TopiaContext transaction = null;
+// List<SampleRow> results = new ArrayList<SampleRow>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE);
+ TopiaQuery query = dao.createQuery("S").
+ addDistinct().addOrder("S." + SampleRow.CODE);
query = filter.prepareQueryForSampling(query, "S");
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ after prepareQueryForSampling ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- startTime = System.currentTimeMillis();
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ after prepareQueryForSampling ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// startTime = System.currentTimeMillis();
+// }
if (log.isDebugEnabled()) {
log.debug("Query : " + query);
}
- results = dao.findAllByQuery(query);
+ return dao.findAllByQuery(query);
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getSampleRowsByFilter exec query ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- startTime = System.currentTimeMillis();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return results;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getSampleRowsByFilter exec query ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// startTime = System.currentTimeMillis();
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return results;
}
@Override
- public SampleRow getSampleRow(String sampleRowId) throws WaoExceptionO {
- TopiaContext transaction = null;
- SampleRow result = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public SampleRow executeGetSampleRow(TopiaContext transaction,
+ List<Object> errorArgs, String sampleRowId) throws TopiaException {
+// TopiaContext transaction = null;
+// SampleRow result = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
+ errorArgs.add(sampleRowId);
+
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- result = dao.findByTopiaId(sampleRowId);
+ SampleRow result = dao.findByTopiaId(sampleRowId);
result.sizeSampleMonth();
result.sizeElligibleBoat();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getSampleRow ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
+ return result;
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de charger la ligne d'échantillon ayant pour" +
- " identifiant : " + sampleRowId,
- eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return result;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getSampleRow ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de charger la ligne d'échantillon ayant pour" +
+// " identifiant : " + sampleRowId,
+// eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return result;
}
@Override
- public SampleRow getSampleRowByCode(WaoUser user, String sampleRowCode)
- throws WaoExceptionO {
- TopiaContext transaction = null;
- SampleRow result = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- if (log.isInfoEnabled()) {
- log.info("W:[ getSampleRowByCode ] : " +
- "sampleRowCode = " + sampleRowCode);
- }
- transaction = rootContext.beginTransaction();
+ public SampleRow executeGetSampleRowByCode(TopiaContext transaction,
+ List<Object> errorArgs, WaoUser user, String sampleRowCode)
+ throws TopiaException, WaoBusinessException {
+// TopiaContext transaction = null;
+// SampleRow result = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// if (log.isInfoEnabled()) {
+// log.info("W:[ getSampleRowByCode ] : " +
+// "sampleRowCode = " + sampleRowCode);
+// }
+// transaction = rootContext.beginTransaction();
+ errorArgs.add(sampleRowCode);
+
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery().
@@ -519,7 +536,7 @@
}
query.addLoad(SampleRow.SAMPLE_ROW_LOG);
- result = dao.findByQuery(query);
+ SampleRow result = dao.findByQuery(query);
if (result == null) {
throw new WaoBusinessException(Type.NOT_EXISTS,
@@ -527,34 +544,39 @@
"pour code " + sampleRowCode + " est introuvable !");
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getSampleRowByCode ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de charger la ligne " +
- "d'échantillon ayant pour code : " + sampleRowCode,
- eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return result;
+ return result;
+
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getSampleRowByCode ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de charger la ligne " +
+// "d'échantillon ayant pour code : " + sampleRowCode,
+// eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return result;
}
@Override
- public void deleteSampleRow(SampleRow sampleRow) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public void executeDeleteSampleRow(TopiaContext transaction,
+ List<Object> errorArgs, SampleRow sampleRow) throws TopiaException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
+ errorArgs.add(sampleRow.getCode());
+
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
@@ -563,44 +585,47 @@
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ deleteSampleRow ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
- eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ deleteSampleRow ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
+// eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
}
@Override
- public String getNewSampleRowCode(Date beginDate) throws WaoExceptionO {
- TopiaContext transaction = null;
- String result = null;
+ public String executeGetNewSampleRowCode(TopiaContext transaction,
+ Date beginDate) throws TopiaException {
+// TopiaContext transaction = null;
+// String result = null;
if (beginDate == null) {
- return result;
+ return null;
}
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
Calendar begin = new GregorianCalendar();
begin.setTime(beginDate);
int year = begin.get(Calendar.YEAR);
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
+ TopiaQuery query =
+ dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
- String maxCode = query.executeToString("MAX(" + SampleRow.CODE + ")");
+ String maxCode =
+ query.executeToString("MAX(" + SampleRow.CODE + ")");
if (log.isDebugEnabled()) {
log.debug("Max code found : " + maxCode);
@@ -612,28 +637,28 @@
num = Integer.parseInt(part[1]) + 1;
}
String str = StringUtils.leftPad("" + num, 4, "0");
- result = year + "_" + str;
+ return year + "_" + str;
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getNewSampleRowCode ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
- eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return result;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getNewSampleRowCode ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
+// eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
+// return result;
}
@Override
- public SampleRow getNewSampleRow() {
+ public SampleRow executeGetNewSampleRow() {
SampleRow row = new SampleRowImpl();
row.setProfession(new ProfessionImpl());
row.setFishingZone(new ArrayList<FishingZone>());
@@ -644,7 +669,7 @@
}
@Override
- public SampleMonth getNewSampleMonth(Date period, SampleRow row) {
+ public SampleMonth executeGetNewSampleMonth(Date period, SampleRow row) {
SampleMonth month = new SampleMonthImpl();
month.setSampleRow(row);
month.setPeriodDate(period);
@@ -660,7 +685,7 @@
* @return a new Profession
*/
@Override
- public Profession getNewProfession(Profession profession) {
+ public Profession executeGetNewProfession(Profession profession) {
Profession newProfession = new ProfessionImpl();
// Use of Binder previously initialized to copy the existing
// profession in a new one
@@ -690,18 +715,24 @@
}
@Override
- public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws WaoExceptionO {
- TopiaContext transaction = null;
- InputStream result = null;
+ public InputStream executeExportSamplingPlanCsv(TopiaContext transaction,
+ List<Object> errorArgs, WaoUser user, PeriodDates period)
+ throws TopiaException, Exception {
+// TopiaContext transaction = null;
+// InputStream result = null;
CsvWriter writer = null;
try {
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+ errorArgs.add(dateFormat.format(period.getFromDate()));
+ errorArgs.add(dateFormat.format(period.getThruDate()));
+
File file = File.createTempFile("wao-samplingPlan-", ".csv");
file.deleteOnExit();
FileOutputStream output = new FileOutputStream(file);
- writer = new CsvWriter(output, ',', WaoContextO.getCsvCharset());
+ writer = new CsvWriter(output, ',', context.getCsvCharset());
// Get min and max dates to have the biggest period
// Date min = (Date)query.executeToObject("MIN(S." + SampleRow.PERIOD_BEGIN + ")");
@@ -711,7 +742,8 @@
period.setPattern(SAMPLING.defaultDatePattern());
List<String> monthHeaders = period.getFormatedMonths();
- SamplingExport export = new SamplingExport(writer, user, monthHeaders);
+ SamplingExport export =
+ new SamplingExport(writer, user, monthHeaders);
export.writeHeaders();
@@ -733,7 +765,6 @@
List<SampleRow> rows = dao.findAllByQuery(query);
- DateFormat dateFormat = SAMPLING.getDateFormat();
NumberFormat numberFormat = SAMPLING.getNumberFormat();
for (SampleRow row : rows) {
@@ -806,34 +837,41 @@
export.writeRecord();
}
- result = new FileInputStream(file);
+ return new FileInputStream(file);
} catch (Exception eee) {
- DateFormat dateFormat = SAMPLING.getDateFormat();
- WaoContextO.serviceException(transaction,
- "Impossible d'exporter le plan d'échantillonnage sur la période du " +
- dateFormat.format(period.getFromDate()) + " au " +
- dateFormat.format(period.getThruDate()), eee);
+ throw eee;
+// DateFormat dateFormat = SAMPLING.getDateFormat();
+// context.serviceException(transaction,
+// "Impossible d'exporter le plan d'échantillonnage sur la période du " +
+// dateFormat.format(period.getFromDate()) + " au " +
+// dateFormat.format(period.getThruDate()), eee);
} finally {
if (writer != null) {
writer.close();
}
- WaoContextO.closeTransaction(transaction);
+// context.closeTransaction(transaction);
}
- return result;
+
}
@Override
- public ImportResults importSamplingPlanCsv(InputStream input) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public ImportResults executeImportSamplingPlanCsv(TopiaContext transaction,
+ List<Object> errorArgs, InputStream input)
+ throws WaoBusinessException, IOException,
+ TopiaException, ParseException {
+// TopiaContext transaction = null;
ImportResults result = new ImportResultsImpl();
//int[] result = new int[3];
int currRow = 0;
SampleRow row = null;
- try {
- transaction = rootContext.beginTransaction();
+// try {
+// transaction = rootContext.beginTransaction();
- CsvReader reader = new CsvReader(input, WaoContextO.getCsvCharset());
+ errorArgs.add(currRow);
+ errorArgs.add(null);
+
+ CsvReader reader = new CsvReader(input, context.getCsvCharset());
reader.readHeaders();
SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction);
@@ -855,6 +893,9 @@
continue;
}
+ errorArgs.set(0, currRow);
+ errorArgs.set(1, code);
+
String districts = ImportHelper.read(reader,
FISHING_ZONE.PECHE_DIVISION);
@@ -901,21 +942,21 @@
//transaction.closeContext();
- } catch (NumberFormatException eee) {
- WaoContextO.serviceException(transaction,
- "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
- "Le format de la durée moyenne des marées est incorrect, il doit être de la forme : 1.9 ", eee);
- } catch (ParseException eee) {
- WaoContextO.serviceException(transaction,
- "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
- "Le format des dates est incorrect, il doit être de la forme : MM/AAAA", eee);
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]",
- eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// } catch (NumberFormatException eee) {
+// context.serviceException(transaction,
+// "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
+// "Le format de la durée moyenne des marées est incorrect, il doit être de la forme : 1.9 ", eee);
+// } catch (ParseException eee) {
+// context.serviceException(transaction,
+// "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
+// "Le format des dates est incorrect, il doit être de la forme : MM/AAAA", eee);
+// } catch (Exception eee) {
+// context.serviceException(transaction,
+// "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]",
+// eee);
+// } finally {
+// context.closeTransaction(transaction);
+// }
return result;
}
@@ -976,10 +1017,10 @@
* @param currRow Row number in the line for the SampleRow
* @param row SampleRow linked with districts (from Csv file)
* @throws TopiaException for dao errors
- * @throws WaoException if a FishingZone doesn't exist.
+ * @throws WaoBusinessException if a FishingZone doesn't exist.
*/
protected void importFishingZones(TopiaContext transaction, String districts, int currRow, SampleRow row)
- throws TopiaException, WaoExceptionO {
+ throws TopiaException, WaoBusinessException {
FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -60,128 +60,81 @@
private static final Logger log = LoggerFactory.getLogger(ServiceUserImpl.class);
-// protected TopiaContext rootContext;
-//
-// public ServiceUserImpl() throws WaoExceptionO {
-// rootContext = WaoContextO.getTopiaRootContext();
-// }
-
@Override
public WaoUser executeConnect(TopiaContext transaction,
String login, String password)
throws TopiaException, WaoBusinessException {
-// TopiaContext transaction = null;
-// WaoUser user = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- String passwordEncoded = context.encodeString(password);
- WaoUser user = dao.findByProperties(
- WaoUser.LOGIN, login,
- WaoUser.PASSWORD, passwordEncoded);
+ String passwordEncoded = context.encodeString(password);
+ WaoUser user = dao.findByProperties(
+ WaoUser.LOGIN, login,
+ WaoUser.PASSWORD, passwordEncoded);
- if (user != null && user.getActive()) {
- // load company entity
- user.getCompany();
- } else if (user != null && !user.getActive()) {
- throw new WaoBusinessException(Type.ILLEGAL_CONNECTION,
- this.getClass(),
- "Vous n'avez plus les droits nécessaires pour" +
- " vous connecter. Veuillez contacter un" +
- " administrateur.");
- } else {
- throw new WaoBusinessException(Type.BAD_CONNECTION,
- this.getClass(),
- "Identifiant ou mot de passe incorrects, " +
- "veuillez réessayer.");
- }
+ if (user != null && user.getActive()) {
+ // load company entity
+ user.getCompany();
+ } else if (user != null && !user.getActive()) {
+ throw new WaoBusinessException(Type.ILLEGAL_CONNECTION,
+ this.getClass(),
+ "Vous n'avez plus les droits nécessaires pour" +
+ " vous connecter. Veuillez contacter un" +
+ " administrateur.");
+ } else {
+ throw new WaoBusinessException(Type.BAD_CONNECTION,
+ this.getClass(),
+ "Identifiant ou mot de passe incorrects, " +
+ "veuillez réessayer.");
+ }
- return user;
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ connect ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ return user;
}
@Override
public void executeForgetPassword(TopiaContext transaction,
- String login) throws WaoBusinessException, TopiaException, EmailException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
- if (!login.contains("@")) {
- throw new WaoBusinessException(Type.SYNTAX,
- this.getClass(), "Votre identifiant n'est pas" +
- " un email valide, " +
- "veuillez contacter un administrateur pour " +
- "qu'il puisse changer votre mot de passe.");
- }
+ String login) throws WaoBusinessException, TopiaException,
+ EmailException {
-// transaction = rootContext.beginTransaction();
+ if (!login.contains("@")) {
+ throw new WaoBusinessException(Type.SYNTAX,
+ this.getClass(), "Votre identifiant n'est pas" +
+ " un email valide, " +
+ "veuillez contacter un administrateur pour " +
+ "qu'il puisse changer votre mot de passe.");
+ }
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = dao.findByLogin(login);
- if (user == null) {
- throw new WaoBusinessException(Type.NOT_EXISTS,
- this.getClass(),
- "L'email '" + login + "' n'est pas " +
- "référencé dans l'application.");
- }
+ WaoUser user = dao.findByLogin(login);
+ if (user == null) {
+ throw new WaoBusinessException(Type.NOT_EXISTS,
+ this.getClass(),
+ "L'email '" + login + "' n'est pas " +
+ "référencé dans l'application.");
+ }
- String password = context.createRandomString(8);
- String passwordEncoded = context.encodeString(password);
- user.setPassword(passwordEncoded);
+ String password = context.createRandomString(8);
+ String passwordEncoded = context.encodeString(password);
+ user.setPassword(passwordEncoded);
- String subject = "[WAO] Mot de passe oublié";
- String msg = "Bonjour,\n\n" +
- "\tUn nouveau mot de passe a été généré pour votre" +
- " identifiant " + login + " :\n" +
- "\t\t * mot de passe = " + password + "\n\n" +
- "Vous pouvez modifier votre password en accédant à " +
- "la page de gestion de votre profile utilisateur :\n\n" +
- "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n" +
- "Cordialement,\n\n" +
- "L'Equipe WAO";
+ String subject = "[WAO] Mot de passe oublié";
+ String msg = "Bonjour,\n\n" +
+ "\tUn nouveau mot de passe a été généré pour votre" +
+ " identifiant " + login + " :\n" +
+ "\t\t * mot de passe = " + password + "\n\n" +
+ "Vous pouvez modifier votre password en accédant à " +
+ "la page de gestion de votre profile utilisateur :\n\n" +
+ "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n" +
+ "Cordialement,\n\n" +
+ "L'Equipe WAO";
- context.sendEmail(user.getLogin(), subject, msg);
- if (log.isDebugEnabled()) {
- log.debug("send email to : " + user.getLogin());
- }
+ context.sendEmail(user.getLogin(), subject, msg);
+ if (log.isDebugEnabled()) {
+ log.debug("send email to : " + user.getLogin());
+ }
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ forgetPassword ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
@Override
@@ -189,326 +142,205 @@
WaoUser user, boolean generatePassword)
throws TopiaException, IllegalArgumentException,
WaoBusinessException, EmailException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
- if (user == null) {
- throw new IllegalArgumentException("user parameter can't be null");
- }
-// transaction = rootContext.beginTransaction();
+ if (user == null) {
+ throw new IllegalArgumentException("user parameter can't be null");
+ }
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
-
- boolean newUser = context.prepareTopiaId(WaoUser.class, user);
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- // Check for a new user if login already exists
- if (newUser) {
- WaoUser existUser = dao.findByLogin(user.getLogin());
- if (existUser != null) {
- throw new WaoBusinessException(Type.ALREADY_EXISTS,
- this.getClass(),
- "Un utilisateur existe déjà avec ce login " +
- user.getLogin());
- }
+ boolean newUser = context.prepareTopiaId(WaoUser.class, user);
+
+ // Check for a new user if login already exists
+ if (newUser) {
+ WaoUser existUser = dao.findByLogin(user.getLogin());
+ if (existUser != null) {
+ throw new WaoBusinessException(Type.ALREADY_EXISTS,
+ this.getClass(),
+ "Un utilisateur existe déjà avec ce login " +
+ user.getLogin());
}
+ }
- String password = user.getPassword();
+ String password = user.getPassword();
- if (generatePassword) {
- password = context.createRandomString(8);
- user.setPasswordChanged(true);
+ if (generatePassword) {
+ password = context.createRandomString(8);
+ user.setPasswordChanged(true);
// if (log.isDebugEnabled()) {
// log.debug("show generated password : " + password);
// }
- }
- // For a password set manually by user or generated
- if (user.isPasswordChanged()) {
- String passwordEncoded = context.encodeString(password);
- user.setPassword(passwordEncoded);
- }
-
- dao.update(user);
+ }
+ // For a password set manually by user or generated
+ if (user.isPasswordChanged()) {
+ String passwordEncoded = context.encodeString(password);
+ user.setPassword(passwordEncoded);
+ }
- // FIXME-JC20100122 Use REGEX instead of @ to test if the login is
- // a valid email
- if (user.getLogin().contains("@") && user.isPasswordChanged()) {
- String subject = "[WAO] ";
- String msg = "Bonjour,\n\n";
- if (newUser) {
- subject += "Création de votre compte";
- msg += "\tVous avez été inscris sur le site WAO :" +
- " Web Applicatif Obsmer. Vos identifiants de " +
- "connexion sont :\n" +
- "\t\t * identifiant = " + user.getLogin() + "\n" +
- "\t\t * mot de passe = " + password + "\n\n" +
- "Vous pouvez modifier votre mot de passe en " +
- "accédant à la page de gestion de votre profil" +
- " utilisateur:\n\n" +
- "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n";
+ dao.update(user);
+
+ // FIXME-JC20100122 Use REGEX instead of @ to test if the login is
+ // a valid email
+ if (user.getLogin().contains("@") && user.isPasswordChanged()) {
+ String subject = "[WAO] ";
+ String msg = "Bonjour,\n\n";
+ if (newUser) {
+ subject += "Création de votre compte";
+ msg += "\tVous avez été inscris sur le site WAO :" +
+ " Web Applicatif Obsmer. Vos identifiants de " +
+ "connexion sont :\n" +
+ "\t\t * identifiant = " + user.getLogin() + "\n" +
+ "\t\t * mot de passe = " + password + "\n\n" +
+ "Vous pouvez modifier votre mot de passe en " +
+ "accédant à la page de gestion de votre profil" +
+ " utilisateur:\n\n" +
+ "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n";
+ } else {
+ subject += "Modification de votre compte";
+ if (generatePassword) {
+ msg += "\tVotre mot de passe de connexion à " +
+ "l'application WAO a été modifié : " +
+ "" + password + "\n\n";
} else {
- subject += "Modification de votre compte";
- if (generatePassword) {
- msg += "\tVotre mot de passe de connexion à " +
- "l'application WAO a été modifié : " +
- "" + password + "\n\n";
- } else {
- msg += "\tVotre changement de mot de passe à bien " +
- "été enregistré.\n" +
- "Pour des raisons de sécurité, le nouveau " +
- "mot de passe n'est pas précisé dans ce message.\n" +
- "Vous pouvez faire une nouvelle demande " +
- "de mot de passe en cas de perte sur la" +
- " page de connexion ou en " +
- "répondant à ce message.\n\n";
- }
+ msg += "\tVotre changement de mot de passe à bien " +
+ "été enregistré.\n" +
+ "Pour des raisons de sécurité, le nouveau " +
+ "mot de passe n'est pas précisé dans ce message.\n" +
+ "Vous pouvez faire une nouvelle demande " +
+ "de mot de passe en cas de perte sur la" +
+ " page de connexion ou en " +
+ "répondant à ce message.\n\n";
}
- msg += "Cordialement,\n\n" +
- "L'Equipe WAO";
-
- context.sendEmail(user.getLogin(), subject, msg);
+ }
+ msg += "Cordialement,\n\n" +
+ "L'Equipe WAO";
+
+ context.sendEmail(user.getLogin(), subject, msg);
// if (log.isDebugEnabled()) {
// log.debug("send email to : " + user.getLogin());
// }
- }
+ }
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ createUpdateUser ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
@Override
public void executeDeleteUser(TopiaContext transaction ,
WaoUser user) throws WaoBusinessException, TopiaException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- String userType = StringUtils.lowerCase(
- user.getUserRole().getLibelle());
- String msgBegin = "L'" + userType + " '" + user.getLogin() + "'" +
- " ne peut pas être supprimé";
- String msgEnd = "Vous pouvez cependant le désactiver pour qu'il" +
- " ne puisse plus se connecter.";
+ String userType = StringUtils.lowerCase(
+ user.getUserRole().getLibelle());
+ String msgBegin = "L'" + userType + " '" + user.getLogin() + "'" +
+ " ne peut pas être supprimé";
+ String msgEnd = "Vous pouvez cependant le désactiver pour qu'il" +
+ " ne puisse plus se connecter.";
- boolean isCoordinator =
- user.getUserRole().equals(UserRole.COORDINATOR);
+ boolean isCoordinator =
+ user.getUserRole().equals(UserRole.COORDINATOR);
- if (user.isAdmin() || isCoordinator) {
- SampleRowLogDAO logDAO =
- WaoDAOHelper.getSampleRowLogDAO(transaction);
- List<SampleRowLog> results = logDAO.findAllByAuthor(user);
-
- if (!results.isEmpty()) {
- String msg = "";
- if (isCoordinator) {
- msg = " car il a ajouté des commentaires sur le plan " +
- "d'échantillonnage.";
- } else {
- msg = " car il a participé" +
- " à la modification du plan d'échantillonnage. ";
- }
- throw new WaoBusinessException(Type.ALREADY_EXISTS,
- this.getClass(), msgBegin + msg + msgEnd);
- }
- } else {
+ if (user.isAdmin() || isCoordinator) {
+ SampleRowLogDAO logDAO =
+ WaoDAOHelper.getSampleRowLogDAO(transaction);
+ List<SampleRowLog> results = logDAO.findAllByAuthor(user);
- ContactDAO contactDAO =
- WaoDAOHelper.getContactDAO(transaction);
- List<Contact> results = contactDAO.findAllByObserver(user);
-
- if (!results.isEmpty()) {
- throw new WaoBusinessException(Type.ALREADY_EXISTS,
- this.getClass(),
- msgBegin + " car il est lié à plusieurs contacts" +
- " existants. " + msgEnd);
+ if (!results.isEmpty()) {
+ String msg = "";
+ if (isCoordinator) {
+ msg = " car il a ajouté des commentaires sur le plan " +
+ "d'échantillonnage.";
+ } else {
+ msg = " car il a participé" +
+ " à la modification du plan d'échantillonnage. ";
}
+ throw new WaoBusinessException(Type.ALREADY_EXISTS,
+ this.getClass(), msgBegin + msg + msgEnd);
}
+ } else {
+ ContactDAO contactDAO =
+ WaoDAOHelper.getContactDAO(transaction);
+ List<Contact> results = contactDAO.findAllByObserver(user);
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ if (!results.isEmpty()) {
+ throw new WaoBusinessException(Type.ALREADY_EXISTS,
+ this.getClass(),
+ msgBegin + " car il est lié à plusieurs contacts" +
+ " existants. " + msgEnd);
+ }
+ }
- dao.delete(user);
- transaction.commitTransaction();
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ deleteUser ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de créer ou" +
-// " de mettre à jour l'utilisateur", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ dao.delete(user);
+
+ transaction.commitTransaction();
}
@Override
public void executeCreateUpdateCompany(TopiaContext transaction,
Company company) throws TopiaException, IllegalArgumentException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
- if (company == null) {
- throw new IllegalArgumentException("company parameter can't be null");
- }
-// transaction = rootContext.beginTransaction();
+ if (company == null) {
+ throw new IllegalArgumentException("company parameter " +
+ "can't be null");
+ }
- CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
- context.prepareTopiaId(Company.class, company);
- dao.update(company);
+ context.prepareTopiaId(Company.class, company);
+ dao.update(company);
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ createUpdateCompany ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
@Override
public List<Company> executeGetCompanies(TopiaContext transaction,
boolean activeOnly) throws TopiaException {
-// TopiaContext transaction = null;
+
List<Company> results = new ArrayList<Company>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
- if (activeOnly) {
- results = dao.findAllByActive(activeOnly);
- } else {
- results = dao.findAll();
- }
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getCompanies ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ if (activeOnly) {
+ results = dao.findAllByActive(activeOnly);
+ } else {
+ results = dao.findAll();
+ }
+
return results;
}
@Override
public List<WaoUser> executeGetUsersByCompany(TopiaContext transaction,
List<Object> errorArgs, Company company) throws TopiaException {
-// TopiaContext transaction = null;
-// List<WaoUser> results = new ArrayList<WaoUser>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- errorArgs.add(company.getName());
+ errorArgs.add(company.getName());
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- TopiaQuery query = dao.createQuery().
- add(WaoUser.COMPANY, company).
- addOrder(WaoUser.FIRST_NAME, WaoUser.LAST_NAME);
+ TopiaQuery query = dao.createQuery().
+ add(WaoUser.COMPANY, company).
+ addOrder(WaoUser.FIRST_NAME, WaoUser.LAST_NAME);
- return dao.findAllByQuery(query);
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getUsersByCompany ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de récupérer " +
-// "la liste des utilisateurs de la société " +
-// company.getName(), eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAllByQuery(query);
}
@Override
public List<WaoUser> executeGetObservers(TopiaContext transaction,
boolean activeOnly) throws TopiaException {
-// TopiaContext transaction = null;
-// List<WaoUser> results = new ArrayList<WaoUser>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- TopiaQuery query = dao.createQuery().
- add(WaoUser.ROLE, UserRole.OBSERVER.ordinal(),
- UserRole.COORDINATOR.ordinal());
+ WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
+ TopiaQuery query = dao.createQuery().
+ add(WaoUser.ROLE, UserRole.OBSERVER.ordinal(),
+ UserRole.COORDINATOR.ordinal());
- if (activeOnly) {
- query.add(WaoUser.ACTIVE, Boolean.TRUE);
- }
+ if (activeOnly) {
+ query.add(WaoUser.ACTIVE, Boolean.TRUE);
+ }
- return dao.findAllByQuery(query);
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getObservers ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAllByQuery(query);
}
@Override
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 16:46:41 UTC (rev 407)
@@ -29,6 +29,19 @@
wao.error.serviceReferential.getProfessions=
wao.error.serviceReferential.getSectors=
wao.error.serviceReferential.importFishingZoneCsv=
+wao.error.serviceSampling.createUpdateSampleRow=
+wao.error.serviceSampling.deleteSampleRow=
+wao.error.serviceSampling.exportSamplingPlanCsv=
+wao.error.serviceSampling.getNewProfession=
+wao.error.serviceSampling.getNewSampleMonth=
+wao.error.serviceSampling.getNewSampleRow=
+wao.error.serviceSampling.getNewSampleRowCode=
+wao.error.serviceSampling.getPrograms=
+wao.error.serviceSampling.getSampleRow=
+wao.error.serviceSampling.getSampleRowByCode=
+wao.error.serviceSampling.getSampleRowsByFilter=
+wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=
+wao.error.serviceSampling.importSamplingPlanCsv=
wao.error.serviceUser.connect=
wao.error.serviceUser.createUpdateCompany=
wao.error.serviceUser.createUpdateUser=
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 16:46:41 UTC (rev 407)
@@ -29,12 +29,25 @@
wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers
wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche
wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
-wao.error.serviceUser.connect=
-wao.error.serviceUser.createUpdateCompany=
-wao.error.serviceUser.createUpdateUser=
-wao.error.serviceUser.deleteUser=
-wao.error.serviceUser.forgetPassword=
-wao.error.serviceUser.getCompanies=
-wao.error.serviceUser.getNewUser=
-wao.error.serviceUser.getObservers=
-wao.error.serviceUser.getUsersByCompany=
+wao.error.serviceSampling.createUpdateSampleRow=
+wao.error.serviceSampling.deleteSampleRow=
+wao.error.serviceSampling.exportSamplingPlanCsv=
+wao.error.serviceSampling.getNewProfession=
+wao.error.serviceSampling.getNewSampleMonth=
+wao.error.serviceSampling.getNewSampleRow=
+wao.error.serviceSampling.getNewSampleRowCode=
+wao.error.serviceSampling.getPrograms=
+wao.error.serviceSampling.getSampleRow=
+wao.error.serviceSampling.getSampleRowByCode=
+wao.error.serviceSampling.getSampleRowsByFilter=
+wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=
+wao.error.serviceSampling.importSamplingPlanCsv=
+wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion
+wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9
+wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur
+wao.error.serviceUser.deleteUser=Impossible de supprimer l'utilisateur
+wao.error.serviceUser.forgetPassword=Impossible d'envoyer le mail d'oubli de mot de passe
+wao.error.serviceUser.getCompanies=Impossible de r\u00E9cup\u00E9rer la liste des soci\u00E9t\u00E9s
+wao.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur
+wao.error.serviceUser.getObservers=Impossible de r\u00E9cup\u00E9rer la liste des observateurs
+wao.error.serviceUser.getUsersByCompany=Impossible de r\u00E9cup\u00E9rer la liste des utilisateurs de la soci\u00E9t\u00E9 %1$s
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -138,7 +138,7 @@
public ServiceSampling getServiceSampling() throws WaoExceptionO {
ServiceSamplingImpl instance = new ServiceSamplingImpl();
-// instance.setContext(context);
+ instance.setContext(context);
return instance;
}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -21,7 +21,6 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoRunner;
import fr.ifremer.wao.TestManager;
import org.junit.After;
import org.junit.AfterClass;
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -23,8 +23,6 @@
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoRunner;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.TestManager;
import java.util.Calendar;
import java.util.Date;
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -22,8 +22,8 @@
package fr.ifremer.wao.service;
import fr.ifremer.wao.WaoExceptionO;
-import fr.ifremer.wao.WaoRunner;
import fr.ifremer.wao.TestManager;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.bean.SamplingFilter;
import fr.ifremer.wao.bean.SamplingFilterImpl;
import fr.ifremer.wao.entity.FishingZone;
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -23,6 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.bean.FacadeRow;
import fr.ifremer.wao.bean.ImportResults;
@@ -147,7 +148,7 @@
InputStream result = null;
try {
result = serviceSampling.exportSamplingPlanCsv(user, getPeriod());
- } catch (WaoExceptionO eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 15:49:29 UTC (rev 406)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 16:46:41 UTC (rev 407)
@@ -29,7 +29,6 @@
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.EagerLoad;
-import org.apache.tapestry5.ioc.annotations.InjectService;
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.apache.tapestry5.services.ApplicationStateContribution;
import org.apache.tapestry5.services.ApplicationStateCreator;
@@ -56,8 +55,8 @@
// is provided inline, or requires more initialization than simply
// invoking the constructor.
// binder.bind(ServiceNews.class, ServiceNewsImpl.class);
- binder.bind(ServiceUser.class, ServiceUserImpl.class);
- binder.bind(ServiceSampling.class, ServiceSamplingImpl.class);
+// binder.bind(ServiceUser.class, ServiceUserImpl.class);
+// binder.bind(ServiceSampling.class, ServiceSamplingImpl.class);
// binder.bind(ServiceReferential.class, ServiceReferentialImpl.class);
// binder.bind(ServiceBoat.class, ServiceBoatImpl.class);
binder.bind(ServiceContact.class, ServiceContactImpl.class);
@@ -90,6 +89,18 @@
return instance;
}
+ public ServiceUser buildServiceUser(WaoManager manager) {
+ ServiceUserImpl instance = new ServiceUserImpl();
+ instance.setContext(manager.getContext());
+ return instance;
+ }
+
+ public ServiceSampling buildServiceSampling(WaoManager manager) {
+ ServiceSamplingImpl instance = new ServiceSamplingImpl();
+ instance.setContext(manager.getContext());
+ return instance;
+ }
+
public static void contributeApplicationDefaults(
MappedConfiguration<String, String> configuration) {
// Contributions to ApplicationDefaults will override any contributions to
1
0
[Suiviobsmer-commits] r406 - in trunk: wao-business/src/main/java/fr/ifremer/wao wao-business/src/main/java/fr/ifremer/wao/entity wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao wao-business/src/test/java/fr/ifremer/wao/entity wao-ui/src/main/java/fr/ifremer/wao/ui/pages
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 15:49:29 +0000 (Thu, 01 Apr 2010)
New Revision: 406
Added:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java
Log:
use ServiceTransformer for ServiceUser + remove old context usage in entities (create WaoUtils to delegate some usefull methods)
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -210,6 +210,9 @@
// temp
WaoContextO.setContext(this);
+ // Set context in utils static class for entities
+ WaoUtils.setContext(this);
+
// Create the default admin in database
WaoGlobal.createDefaultAdmin();
Added: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -0,0 +1,88 @@
+
+package fr.ifremer.wao;
+
+import java.util.Date;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Class only used for entities. The entities can't have WaoContext, so
+ * this utils class can use the current {@link WaoContext} in a static way.
+ *
+ * Created: 1 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoUtils {
+
+ private static WaoContextImplementor context;
+
+ static void setContext(WaoContextImplementor context) {
+ WaoUtils.context = context;
+ }
+
+ public static String encodeString(String str) {
+ return context.encodeString(str);
+ }
+
+ public static String convertId(String topiaId) {
+ return context.convertId(topiaId);
+ }
+
+ public static Date getCurrentDate() {
+ return context.getCurrentDate();
+ }
+
+ /**
+ * This method must be removed. Use {@link WaoContext} instance instead.
+ *
+ * @param transaction
+ */
+ public static void doFinally(TopiaContext transaction) {
+ context.doFinally(transaction);
+ }
+
+ /**
+ * This method must be removed. Use {@link WaoContext} instance instead.
+ *
+ * @param transaction
+ * @param eee
+ * @param message
+ * @param args
+ * @throws WaoException
+ */
+ public static void doCatch(TopiaContext transaction,
+ Exception eee, String message, Object... args) throws WaoException {
+ context.doCatch(transaction, eee, message, args);
+ }
+
+ /**
+ * This method must be removed. Use {@link WaoContext} instance instead.
+ *
+ * @param eee
+ * @param message
+ * @param args
+ * @throws WaoException
+ */
+ public static void doCatch(Exception eee, String message,
+ Object... args) throws WaoException {
+ context.doCatch(eee, message, args);
+ }
+
+ /**
+ * This method must be removed. Use {@link WaoContext} instance instead.
+ *
+ * @return
+ * @throws TopiaException
+ */
+ public static TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+
+
+}
Property changes on: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoUtils.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,12 +21,13 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoExceptionO;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.bean.ContactState;
import java.io.Serializable;
import java.util.Date;
+import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.framework.TopiaQuery;
import org.slf4j.Logger;
@@ -60,30 +61,29 @@
* @see fr.ifremer.wao.bean.ContactState#isFinalState()
*/
@Override
- public boolean canCreateContact(Company company) throws WaoExceptionO {
+ public boolean canCreateContact(Company company) throws WaoException {
boolean result = true;
if (!getActive()) {
result = false;
} else {
TopiaContext transaction = null;
try {
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = WaoUtils.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- Contact contact = dao.findByQuery(dao.createQueryLastContactForBoat(this, company));
+ Contact contact = dao.findByQuery(
+ dao.createQueryLastContactForBoat(this, company));
if (contact != null) {
result = contact.getContactState().isFinalState();
}
- //transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer les informations privées du navire lié à la société " +
- "'" + company.getName() + "'",
- eee);
+ WaoUtils.doCatch(transaction, eee,
+ I18n.n_("wao.error.boat.canCreateContact"),
+ company.getName(), getName(), getImmatriculation());
} finally {
- WaoContextO.closeTransaction(transaction);
+ WaoUtils.doFinally(transaction);
}
}
return result;
@@ -99,25 +99,23 @@
* @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
*/
@Override
- public int getNbBoarding(Date fromDate) throws WaoExceptionO {
+ public int getNbBoarding(Date fromDate) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = WaoUtils.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate);
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(this, fromDate);
result = query.executeCount(transaction);
- //transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer le nombre d'embarquements réels depuis le " +
- "'" + fromDate + "'",
- eee);
+ WaoUtils.doCatch(transaction, eee,
+ I18n.n_("wao.error.boat.getNbBoarding"), fromDate);
} finally {
- WaoContextO.closeTransaction(transaction);
+ WaoUtils.doFinally(transaction);
}
return result;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,13 +21,14 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoContextO;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import org.nuiton.topia.framework.TopiaQuery;
import java.io.Serializable;
import org.nuiton.topia.TopiaContext;
import java.util.Date;
+import org.nuiton.i18n.I18n;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,27 +59,26 @@
* @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
*/
@Override
- public int getNbBoardingForCompany(Date fromDate) throws WaoExceptionO {
+ public int getNbBoardingForCompany(Date fromDate) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = WaoUtils.beginTransaction();
ContactDAO dao = WaoDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQueryDoneContactsFromDate(getBoat(), fromDate);
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(getBoat(), fromDate);
query.add(Contact.OBSERVER + "." + WaoUser.COMPANY, getCompany());
result = query.executeCount();
-
- //transaction.closeContext();
+
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible de récupérer le nombre d'embarquements réels depuis le " +
- "'" + fromDate + "' pour la société '" + getCompany().getName() + "'",
- eee);
+ WaoUtils.doCatch(transaction, eee,
+ I18n.n_("wao.error.boatInfos.getNbBoardingForCompany"),
+ fromDate, getCompany().getName());
} finally {
- WaoContextO.closeTransaction(transaction);
+ WaoUtils.doFinally(transaction);
}
return result;
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoUtils;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,6 +50,6 @@
*/
@Override
public String getId() {
- return WaoContextO.convertId(getTopiaId());
+ return WaoUtils.convertId(getTopiaId());
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,14 +21,15 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoContextO;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.WaoDAOHelper;
+import fr.ifremer.wao.WaoException;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
+import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,10 +60,10 @@
* @throws WaoException for saving problem
*/
@Override
- public void addRealTideTime(int nbDays) throws WaoExceptionO {
+ public void addRealTideTime(int nbDays) throws WaoException {
TopiaContext transaction = null;
try {
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = WaoUtils.beginTransaction();
SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction);
SampleMonth month = dao.findByTopiaId(getTopiaId());
@@ -73,17 +74,18 @@
month.setRealTidesValue(result);
if (log.isDebugEnabled()) {
- log.debug("Change realTideTime from " + month.getRealTidesValue() + " to " + result);
+ log.debug("Change realTideTime from " +
+ month.getRealTidesValue() + " to " + result);
}
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible d'enregistrer le nombre de marées réels pour le mois de " +
- formatMonth() + " [ligne : " + this.getSampleRow().getCode() + "]", eee);
+ WaoUtils.doCatch(transaction, eee,
+ I18n.n_("wao.error.sampleMonth.addRealTideTime"),
+ formatMonth(), getSampleRow().getCode());
} finally {
- WaoContextO.closeTransaction(transaction);
+ WaoUtils.doFinally(transaction);
}
}
@@ -97,7 +99,7 @@
@Override
public boolean isCurrentMonth() {
Calendar current = new GregorianCalendar();
- current.setTime(WaoContextO.getCurrentDate());
+ current.setTime(WaoUtils.getCurrentDate());
Calendar calendar = new GregorianCalendar();
calendar.setTime(getPeriodDate());
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,8 +21,8 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoContextO;
-import fr.ifremer.wao.WaoExceptionO;
+import fr.ifremer.wao.WaoUtils;
+import fr.ifremer.wao.WaoException;
import fr.ifremer.wao.WaoDAOHelper;
import java.io.Serializable;
import java.util.ArrayList;
@@ -32,6 +32,7 @@
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.BooleanUtils;
+import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
import org.nuiton.util.DateUtils;
import org.nuiton.util.PeriodDates;
@@ -179,7 +180,8 @@
/**
* Used to get a list of boat's immatriculations linked with the sampleRow.
*
- * @return a simple String which contains immatriculations separate by a space
+ * @return a simple String which contains immatriculations separate by
+ * a space
*/
@Override
public String getMainElligibleBoatsAsString() {
@@ -194,8 +196,10 @@
}
/**
- * Check if SampleMonth of the SampleRow has already realTidesValue set (different from 0).
- * It means the SampleRow could'nt be deleted and have some modification constraints.
+ * Check if SampleMonth of the SampleRow has already realTidesValue set
+ * (different from 0). It means the SampleRow could'nt be deleted and
+ * have some modification constraints.
+ *
* @return true if a SampleMonth have realTidesValue, false otherwise
*/
@Override
@@ -209,8 +213,9 @@
}
@Override
- public boolean addRealTideTime(Contact contact) throws WaoExceptionO {
- if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ public boolean addRealTideTime(Contact contact) throws WaoException {
+ if (contact.getTideEndDate() == null ||
+ contact.getTideBeginDate() == null) {
return false;
}
//int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
@@ -219,21 +224,24 @@
return false;
}
if (log.isTraceEnabled()) {
- log.trace("Add 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
+ log.trace("Add 1 tide for " + month.formatMonth() +
+ " [" + this.getCode() + "]");
}
month.addRealTideTime(1);
return true;
}
@Override
- public void removeRealTideTime(Contact contact) throws WaoExceptionO {
- if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ public void removeRealTideTime(Contact contact) throws WaoException {
+ if (contact.getTideEndDate() == null ||
+ contact.getTideBeginDate() == null) {
return;
}
//int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
SampleMonth month = getSampleMonth(contact.getTideBeginDate());
if (log.isTraceEnabled()) {
- log.trace("Remove 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
+ log.trace("Remove 1 tide for " + month.formatMonth() +
+ " [" + this.getCode() + "]");
}
month.addRealTideTime(-1);
}
@@ -247,14 +255,15 @@
@Override
public boolean isStarted() {
- Date current = WaoContextO.getCurrentDate();
- return current.after(getPeriodBegin()) || current.equals(getPeriodBegin());
+ Date current = WaoUtils.getCurrentDate();
+ return current.after(getPeriodBegin()) ||
+ current.equals(getPeriodBegin());
}
@Override
public boolean isFinished(int nbMonths) {
Calendar calendar = new GregorianCalendar();
- calendar.setTime(WaoContextO.getCurrentDate());
+ calendar.setTime(WaoUtils.getCurrentDate());
calendar.add(Calendar.MONTH, nbMonths);
return calendar.getTime().after(getPeriodEnd());
}
@@ -288,7 +297,7 @@
* @throws WaoException
*/
@Override
- public void saveSampleRowLog(SampleRowLog rowLog) throws WaoExceptionO {
+ public void saveSampleRowLog(SampleRowLog rowLog) throws WaoException {
TopiaContext transaction = null;
try {
if (log.isInfoEnabled()) {
@@ -298,7 +307,7 @@
" _ authorRole = " + author.getUserRole());
}
- transaction = WaoContextO.getTopiaRootContext().beginTransaction();
+ transaction = WaoUtils.beginTransaction();
SampleRowLogDAO logDAO =
WaoDAOHelper.getSampleRowLogDAO(transaction);
@@ -311,11 +320,11 @@
// WaoContext.PROP_EMAIL_FROM
} catch (Exception eee) {
- WaoContextO.serviceException(transaction,
- "Impossible d'enregistrer le commentaire écrit par "
- + rowLog.getAuthor().getFullName(), eee);
+ WaoUtils.doCatch(transaction, eee,
+ I18n.n_("wao.error.sampleRow.saveSampleRowLog"),
+ rowLog.getAuthor().getFullName());
} finally {
- WaoContextO.closeTransaction(transaction);
+ WaoUtils.doFinally(transaction);
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -21,7 +21,7 @@
package fr.ifremer.wao.entity;
-import fr.ifremer.wao.WaoContextO;
+import fr.ifremer.wao.WaoUtils;
import fr.ifremer.wao.bean.UserRole;
import java.io.Serializable;
import org.slf4j.Logger;
@@ -59,12 +59,12 @@
/**
* Return a simplified id instead of using topiaId
- * @return a simplified id
- * @see WaoUtils#convertId(java.lang.String)
+ *
+ * @return a simplified id
*/
@Override
public String getId() {
- return WaoContextO.convertId(getTopiaId());
+ return WaoUtils.convertId(getTopiaId());
}
@Override
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -23,9 +23,7 @@
import fr.ifremer.wao.WaoBusinessException;
import fr.ifremer.wao.WaoBusinessException.Type;
-import fr.ifremer.wao.WaoExceptionO;
import fr.ifremer.wao.WaoDAOHelper;
-import fr.ifremer.wao.WaoContextO;
import fr.ifremer.wao.WaoProperty;
import fr.ifremer.wao.bean.UserRole;
import fr.ifremer.wao.entity.Company;
@@ -36,11 +34,13 @@
import fr.ifremer.wao.entity.SampleRowLogDAO;
import fr.ifremer.wao.entity.WaoUser;
import fr.ifremer.wao.entity.WaoUserDAO;
+import fr.ifremer.wao.entity.WaoUserImpl;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.mail.EmailException;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,147 +56,170 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class ServiceUserImpl implements ServiceUser {
+public class ServiceUserImpl extends ServiceUserAbstract {
private static final Logger log = LoggerFactory.getLogger(ServiceUserImpl.class);
- protected TopiaContext rootContext;
+// protected TopiaContext rootContext;
+//
+// public ServiceUserImpl() throws WaoExceptionO {
+// rootContext = WaoContextO.getTopiaRootContext();
+// }
- public ServiceUserImpl() throws WaoExceptionO {
- rootContext = WaoContextO.getTopiaRootContext();
- }
-
@Override
- public WaoUser connect(String login, String password) throws WaoExceptionO {
- TopiaContext transaction = null;
- WaoUser user = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public WaoUser executeConnect(TopiaContext transaction,
+ String login, String password)
+ throws TopiaException, WaoBusinessException {
+// TopiaContext transaction = null;
+// WaoUser user = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- String passwordEncoded = WaoContextO.encodeString(password);
- user = dao.findByProperties(WaoUser.LOGIN, login, WaoUser.PASSWORD, passwordEncoded);
+ String passwordEncoded = context.encodeString(password);
+ WaoUser user = dao.findByProperties(
+ WaoUser.LOGIN, login,
+ WaoUser.PASSWORD, passwordEncoded);
if (user != null && user.getActive()) {
// load company entity
user.getCompany();
} else if (user != null && !user.getActive()) {
- throw new WaoBusinessException(Type.ILLEGAL_CONNECTION, this.getClass(),
- "Vous n'avez plus les droits nécessaires pour vous connecter. Veuillez contacter un administrateur.");
+ throw new WaoBusinessException(Type.ILLEGAL_CONNECTION,
+ this.getClass(),
+ "Vous n'avez plus les droits nécessaires pour" +
+ " vous connecter. Veuillez contacter un" +
+ " administrateur.");
} else {
- throw new WaoBusinessException(Type.BAD_CONNECTION, this.getClass(),
- "Identifiant ou mot de passe incorrects, veuillez réessayer.");
+ throw new WaoBusinessException(Type.BAD_CONNECTION,
+ this.getClass(),
+ "Identifiant ou mot de passe incorrects, " +
+ "veuillez réessayer.");
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ connect ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
+ return user;
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return user;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ connect ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+//
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
}
@Override
- public void forgetPassword(String login) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
+ public void executeForgetPassword(TopiaContext transaction,
+ String login) throws WaoBusinessException, TopiaException, EmailException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
if (!login.contains("@")) {
- throw new WaoBusinessException(Type.SYNTAX, this.getClass(), "Votre identifiant n'est pas un email valide, " +
- "veuillez contacter un administrateur pour qu'il puisse changer votre mot de passe.");
+ throw new WaoBusinessException(Type.SYNTAX,
+ this.getClass(), "Votre identifiant n'est pas" +
+ " un email valide, " +
+ "veuillez contacter un administrateur pour " +
+ "qu'il puisse changer votre mot de passe.");
}
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
WaoUser user = dao.findByLogin(login);
if (user == null) {
- throw new WaoBusinessException(Type.NOT_EXISTS, this.getClass(),
- "L'email '" + login + "' n'est pas référencé dans l'application.");
+ throw new WaoBusinessException(Type.NOT_EXISTS,
+ this.getClass(),
+ "L'email '" + login + "' n'est pas " +
+ "référencé dans l'application.");
}
- String password = WaoContextO.createRandomString(8);
- String passwordEncoded = WaoContextO.encodeString(password);
+ String password = context.createRandomString(8);
+ String passwordEncoded = context.encodeString(password);
user.setPassword(passwordEncoded);
String subject = "[WAO] Mot de passe oublié";
String msg = "Bonjour,\n\n" +
- "\tUn nouveau mot de passe a été généré pour votre identifiant " + login + " :\n" +
+ "\tUn nouveau mot de passe a été généré pour votre" +
+ " identifiant " + login + " :\n" +
"\t\t * mot de passe = " + password + "\n\n" +
- "Vous pouvez modifier votre password en accédant à la page de gestion de votre profile utilisateur :\n\n" +
+ "Vous pouvez modifier votre password en accédant à " +
+ "la page de gestion de votre profile utilisateur :\n\n" +
"\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n" +
"Cordialement,\n\n" +
"L'Equipe WAO";
- WaoContextO.sendEmail(user.getLogin(), subject, msg);
+ context.sendEmail(user.getLogin(), subject, msg);
if (log.isDebugEnabled()) {
log.debug("send email to : " + user.getLogin());
}
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ forgetPassword ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ forgetPassword ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
}
@Override
- public void createUpdateUser(WaoUser user, boolean generatePassword) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
+ public void executeCreateUpdateUser(TopiaContext transaction,
+ WaoUser user, boolean generatePassword)
+ throws TopiaException, IllegalArgumentException,
+ WaoBusinessException, EmailException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
if (user == null) {
throw new IllegalArgumentException("user parameter can't be null");
}
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
- boolean newUser = WaoContextO.prepareTopiaId(WaoUser.class, user);
+ boolean newUser = context.prepareTopiaId(WaoUser.class, user);
// Check for a new user if login already exists
if (newUser) {
WaoUser existUser = dao.findByLogin(user.getLogin());
if (existUser != null) {
- throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
- "Un utilisateur existe déjà avec ce login " + user.getLogin());
+ throw new WaoBusinessException(Type.ALREADY_EXISTS,
+ this.getClass(),
+ "Un utilisateur existe déjà avec ce login " +
+ user.getLogin());
}
}
String password = user.getPassword();
if (generatePassword) {
- password = WaoContextO.createRandomString(8);
+ password = context.createRandomString(8);
user.setPasswordChanged(true);
// if (log.isDebugEnabled()) {
// log.debug("show generated password : " + password);
@@ -204,7 +227,7 @@
}
// For a password set manually by user or generated
if (user.isPasswordChanged()) {
- String passwordEncoded = WaoContextO.encodeString(password);
+ String passwordEncoded = context.encodeString(password);
user.setPassword(passwordEncoded);
}
@@ -217,26 +240,36 @@
String msg = "Bonjour,\n\n";
if (newUser) {
subject += "Création de votre compte";
- msg += "\tVous avez été inscris sur le site WAO : Web Applicatif Obsmer. Vos identifiants de connexion sont :\n" +
+ msg += "\tVous avez été inscris sur le site WAO :" +
+ " Web Applicatif Obsmer. Vos identifiants de " +
+ "connexion sont :\n" +
"\t\t * identifiant = " + user.getLogin() + "\n" +
"\t\t * mot de passe = " + password + "\n\n" +
- "Vous pouvez modifier votre mot de passe en accédant à la page de gestion de votre profil utilisateur:\n\n" +
+ "Vous pouvez modifier votre mot de passe en " +
+ "accédant à la page de gestion de votre profil" +
+ " utilisateur:\n\n" +
"\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n";
} else {
subject += "Modification de votre compte";
if (generatePassword) {
- msg += "\tVotre mot de passe de connexion à l'application WAO a été modifié : " + password + "\n\n";
+ msg += "\tVotre mot de passe de connexion à " +
+ "l'application WAO a été modifié : " +
+ "" + password + "\n\n";
} else {
- msg += "\tVotre changement de mot de passe à bien été enregistré.\n" +
- "Pour des raisons de sécurité, le nouveau mot de passe n'est pas précisé dans ce message.\n" +
- "Vous pouvez faire une nouvelle demande de mot de passe en cas de perte sur la page de connexion ou en " +
+ msg += "\tVotre changement de mot de passe à bien " +
+ "été enregistré.\n" +
+ "Pour des raisons de sécurité, le nouveau " +
+ "mot de passe n'est pas précisé dans ce message.\n" +
+ "Vous pouvez faire une nouvelle demande " +
+ "de mot de passe en cas de perte sur la" +
+ " page de connexion ou en " +
"répondant à ce message.\n\n";
}
}
msg += "Cordialement,\n\n" +
"L'Equipe WAO";
- WaoContextO.sendEmail(user.getLogin(), subject, msg);
+ context.sendEmail(user.getLogin(), subject, msg);
// if (log.isDebugEnabled()) {
// log.debug("send email to : " + user.getLogin());
// }
@@ -244,29 +277,30 @@
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ createUpdateUser ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ createUpdateUser ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
}
@Override
- public void deleteUser(WaoUser user) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public void executeDeleteUser(TopiaContext transaction ,
+ WaoUser user) throws WaoBusinessException, TopiaException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
String userType = StringUtils.lowerCase(
user.getUserRole().getLibelle());
@@ -316,66 +350,68 @@
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ deleteUser ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de créer ou" +
- " de mettre à jour l'utilisateur", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ deleteUser ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de créer ou" +
+// " de mettre à jour l'utilisateur", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
}
@Override
- public void createUpdateCompany(Company company) throws WaoExceptionO {
- TopiaContext transaction = null;
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
+ public void executeCreateUpdateCompany(TopiaContext transaction,
+ Company company) throws TopiaException, IllegalArgumentException {
+// TopiaContext transaction = null;
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
if (company == null) {
throw new IllegalArgumentException("company parameter can't be null");
}
- transaction = rootContext.beginTransaction();
+// transaction = rootContext.beginTransaction();
CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
- WaoContextO.prepareTopiaId(Company.class, company);
+ context.prepareTopiaId(Company.class, company);
dao.update(company);
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ createUpdateCompany ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- //transaction.closeContext();
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ createUpdateCompany ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// //transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
}
@Override
- public List<Company> getCompanies(boolean activeOnly) throws WaoExceptionO {
- TopiaContext transaction = null;
+ public List<Company> executeGetCompanies(TopiaContext transaction,
+ boolean activeOnly) throws TopiaException {
+// TopiaContext transaction = null;
List<Company> results = new ArrayList<Company>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction);
@@ -385,31 +421,34 @@
results = dao.findAll();
}
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getCompanies ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getCompanies ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
return results;
}
@Override
- public List<WaoUser> getUsersByCompany(Company company) throws WaoExceptionO {
- TopiaContext transaction = null;
- List<WaoUser> results = new ArrayList<WaoUser>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public List<WaoUser> executeGetUsersByCompany(TopiaContext transaction,
+ List<Object> errorArgs, Company company) throws TopiaException {
+// TopiaContext transaction = null;
+// List<WaoUser> results = new ArrayList<WaoUser>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
+ errorArgs.add(company.getName());
+
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
@@ -417,34 +456,35 @@
add(WaoUser.COMPANY, company).
addOrder(WaoUser.FIRST_NAME, WaoUser.LAST_NAME);
- results = dao.findAllByQuery(query);
+ return dao.findAllByQuery(query);
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getUsersByCompany ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de récupérer " +
- "la liste des utilisateurs de la société " +
- company.getName(), eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
- }
- return results;
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getUsersByCompany ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de récupérer " +
+// "la liste des utilisateurs de la société " +
+// company.getName(), eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
+// return results;
}
@Override
- public List<WaoUser> getObservers(boolean activeOnly) throws WaoExceptionO {
- TopiaContext transaction = null;
- List<WaoUser> results = new ArrayList<WaoUser>();
- try {
- long startTime = 0;
- if (log.isDebugEnabled()) {
- startTime = System.currentTimeMillis();
- }
- transaction = rootContext.beginTransaction();
+ public List<WaoUser> executeGetObservers(TopiaContext transaction,
+ boolean activeOnly) throws TopiaException {
+// TopiaContext transaction = null;
+// List<WaoUser> results = new ArrayList<WaoUser>();
+// try {
+// long startTime = 0;
+// if (log.isDebugEnabled()) {
+// startTime = System.currentTimeMillis();
+// }
+// transaction = rootContext.beginTransaction();
WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction);
TopiaQuery query = dao.createQuery().
@@ -455,20 +495,32 @@
query.add(WaoUser.ACTIVE, Boolean.TRUE);
}
- results = dao.findAllByQuery(query);
+ return dao.findAllByQuery(query);
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- log.debug("W:[ getObservers ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime));
- }
- } catch (Exception eee) {
- WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
- } finally {
- WaoContextO.closeTransaction(transaction);
+// if (log.isDebugEnabled()) {
+// long stopTime = System.currentTimeMillis();
+// log.debug("W:[ getObservers ] Time = " +
+// DurationFormatUtils.formatDurationHMS(
+// stopTime - startTime));
+// }
+// } catch (Exception eee) {
+// WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
+// } finally {
+// WaoContextO.closeTransaction(transaction);
+// }
+// return results;
+ }
+
+ @Override
+ protected WaoUser executeGetNewUser(Company company) throws Exception {
+ WaoUserImpl user = new WaoUserImpl();
+ if (log.isDebugEnabled()) {
+ log.debug("Set company for new user : " + company.getName());
}
- return results;
+ user.setCompany(company);
+ // Default role set to OBSERVER
+ user.setUserRole(UserRole.OBSERVER);
+ return user;
}
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 15:49:29 UTC (rev 406)
@@ -1,3 +1,6 @@
+wao.error.boat.canCreateContact=
+wao.error.boat.getNbBoarding=
+wao.error.boatInfos.getNbBoardingForCompany=
wao.error.context.close=
wao.error.context.getRootContext=
wao.error.context.parse=
@@ -4,6 +7,8 @@
wao.error.context.rollback=
wao.error.context.start=
wao.error.context.stop=
+wao.error.sampleMonth.addRealTideTime=
+wao.error.sampleRow.saveSampleRowLog=
wao.error.serviceBoat.createUpdateCompanyBoatInfos=
wao.error.serviceBoat.exportBoatCsv=
wao.error.serviceBoat.getActivityCalendarLogAccessFile=
@@ -24,3 +29,12 @@
wao.error.serviceReferential.getProfessions=
wao.error.serviceReferential.getSectors=
wao.error.serviceReferential.importFishingZoneCsv=
+wao.error.serviceUser.connect=
+wao.error.serviceUser.createUpdateCompany=
+wao.error.serviceUser.createUpdateUser=
+wao.error.serviceUser.deleteUser=
+wao.error.serviceUser.forgetPassword=
+wao.error.serviceUser.getCompanies=
+wao.error.serviceUser.getNewUser=
+wao.error.serviceUser.getObservers=
+wao.error.serviceUser.getUsersByCompany=
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 15:49:29 UTC (rev 406)
@@ -1,9 +1,14 @@
-wao.error.context.close=
-wao.error.context.getRootContext=
-wao.error.context.parse=
-wao.error.context.rollback=
-wao.error.context.start=
-wao.error.context.stop=
+wao.error.boat.canCreateContact=Impossible de cr\u00E9er un nouveau contact pour la soci\u00E9t\u00E9 %1$s et le navire %2$s (%3$d)
+wao.error.boat.getNbBoarding=Impossible de r\u00E9cup\u00E9rer le nombre d'embarquements r\u00E9els depuis le %1$s
+wao.error.boatInfos.getNbBoardingForCompany=Impossible de r\u00E9cup\u00E9rer le nombre d'embarquements r\u00E9els depuis le %1$s pour la soci\u00E9t\u00E9 %2$s
+wao.error.context.close=Une erreur est survenue pendant la fermeture du contexte principale de ToPIA
+wao.error.context.getRootContext=Une erreur est survenue pour la r\u00E9cup\u00E9ration du contexte principale de ToPIA
+wao.error.context.parse=Une erreur est survenue pendant le chargement de la configuration du fichier %1$s
+wao.error.context.rollback=Une erreur est survenue pendant l'annulation de la transaction courante
+wao.error.context.start=Une erreur est survenue pendant le d\u00E9marrage de l'application
+wao.error.context.stop=Une erreur est survenue pendant la fermeture de l'application
+wao.error.sampleMonth.addRealTideTime=Impossible d'enregistrer le nombre de mar\u00E9es r\u00E9els pour le mois de %1$s [ligne \: %2$s]
+wao.error.sampleRow.saveSampleRowLog=Impossible d'enregistrer le commentaire \u00E9crit par %1$s
wao.error.serviceBoat.createUpdateCompanyBoatInfos=Impossible de cr\u00E9er ou modifier les informations li\u00E9s au navire %1$d pour la soci\u00E9t\u00E9 %2$s
wao.error.serviceBoat.exportBoatCsv=Impossible d'exporter les navires s\u00E9lectionn\u00E9s
wao.error.serviceBoat.getActivityCalendarLogAccessFile=
@@ -24,3 +29,12 @@
wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers
wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche
wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
+wao.error.serviceUser.connect=
+wao.error.serviceUser.createUpdateCompany=
+wao.error.serviceUser.createUpdateUser=
+wao.error.serviceUser.deleteUser=
+wao.error.serviceUser.forgetPassword=
+wao.error.serviceUser.getCompanies=
+wao.error.serviceUser.getNewUser=
+wao.error.serviceUser.getObservers=
+wao.error.serviceUser.getUsersByCompany=
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -85,7 +85,7 @@
Calendar calendar = new GregorianCalendar(2009, 9, 23);
context.setCurrentDate(calendar.getTime());
- WaoContextO.setContext(context);
+ context.start();
} catch (Exception eee) {
context.doCatch(eee, "Error during loadConfiguration from " +
"'WaoTest.properties' file");
@@ -150,7 +150,7 @@
public ServiceUser getServiceUser() throws WaoExceptionO {
ServiceUserImpl instance = new ServiceUserImpl();
-// instance.setContext(context);
+ instance.setContext(getContext());
return instance;
}
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -85,7 +85,7 @@
WaoGlobal.createDefaultAdmin();
- ServiceUser serviceUser = new ServiceUserImpl();
+ ServiceUser serviceUser = manager.getServiceUser();
List<Company> companies = serviceUser.getCompanies(false);
assertEquals(1, companies.size());
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -91,7 +91,7 @@
public void testCanCreateContact() throws Exception {
log.info("canCreateContact");
/** PREPARE DATA **/
- ServiceUser serviceUser = new ServiceUserImpl();
+ ServiceUser serviceUser = manager.getServiceUser();
Company company = new CompanyImpl();
company.setName("TARTANPION");
serviceUser.createUpdateCompany(company);
@@ -121,7 +121,7 @@
transaction.commitTransaction();
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ ServiceSampling serviceSampling = manager.getServiceSampling();
input = getClass().getResourceAsStream("/import/echantillonnage.csv");
serviceSampling.importSamplingPlanCsv(input);
@@ -136,7 +136,7 @@
row.setCompany(company);
serviceSampling.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
- ServiceContact serviceContact = new ServiceContactImpl();
+ ServiceContact serviceContact = manager.getServiceContact();
Contact contact1 = serviceContact.getNewContact(user, row, boat);
contact1.setContactState(ContactState.CONTACT_START);
serviceContact.saveContact(contact1, false);
@@ -210,7 +210,7 @@
transaction.commitTransaction();
transaction.closeContext();
- ServiceContact serviceContact = new ServiceContactImpl();
+ ServiceContact serviceContact = manager.getServiceContact();
// First contact : OK
Contact contact1 = new ContactImpl();
contact1.setBoat(boat);
Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -56,7 +56,8 @@
private static TestManager manager;
- private static final Logger log = LoggerFactory.getLogger(SampleRowImplTest.class);
+ private static final Logger log =
+ LoggerFactory.getLogger(SampleRowImplTest.class);
public SampleRowImplTest() {
}
Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 14:16:57 UTC (rev 405)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 15:49:29 UTC (rev 406)
@@ -242,14 +242,15 @@
}
user = getUsersSelectModel().findObject(userId);
} else {
- user = new WaoUserImpl();
+ user = serviceUser.getNewUser(getCompany());
+// user = new WaoUserImpl();
+// if (log.isDebugEnabled()) {
+// log.debug("Set company for new user : " + getCompany().getName());
+// }
+// user.setCompany(getCompany());
+// Default role set to OBSERVER
+// user.setUserRole(UserRole.OBSERVER);
generatePassword = true;
- if (log.isDebugEnabled()) {
- log.debug("Set company for new user : " + getCompany().getName());
- }
- user.setCompany(getCompany());
- // Default role set to OBSERVER
- user.setUserRole(UserRole.OBSERVER);
}
}
return user;
1
0
[Suiviobsmer-commits] r405 - in trunk/wao-business/src/main: java/fr/ifremer/wao/service resources/i18n xmi
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 14:16:57 +0000 (Thu, 01 Apr 2010)
New Revision: 405
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
trunk/wao-business/src/main/xmi/wao.zargo
Log:
Clean ServiceBoatImpl to use last ServiceTransformer version (default errorArgs = false)
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 13:55:30 UTC (rev 404)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 14:16:57 UTC (rev 405)
@@ -75,7 +75,7 @@
@Override
public Map<Integer, Boat> executeGetBoatsByFilter(TopiaContext transaction,
- List<Object> errorArgs, BoatFilter filter) throws TopiaException {
+ BoatFilter filter) throws TopiaException {
BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
@@ -94,7 +94,7 @@
@Override
public int executeGetNbBoatsByFilter(TopiaContext transaction,
- List<Object> errorArgs, BoatFilter filter) throws TopiaException {
+ BoatFilter filter) throws TopiaException {
BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
@@ -249,8 +249,7 @@
@Override
public List<Boat> executeGetBoatsByImmatriculations(
- TopiaContext transaction, List<Object> errorArgs,
- String immatriculations)
+ TopiaContext transaction, String immatriculations)
throws TopiaException, WaoBusinessException {
List<Boat> boats = new ArrayList<Boat>();
if (StringUtils.isEmpty(immatriculations)) {
@@ -278,7 +277,7 @@
}
@Override
- public Boat executeGetBoat(TopiaContext transaction, List<Object> errorArgs,
+ public Boat executeGetBoat(TopiaContext transaction,
String boatId) throws TopiaException {
BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction);
@@ -317,7 +316,8 @@
* @see com.csvreader.CsvReader
*/
@Override
- public int[] executeImportBoatCsv(TopiaContext transaction, InputStream input)
+ public int[] executeImportBoatCsv(TopiaContext transaction,
+ InputStream input)
throws TopiaException, IOException, WaoBusinessException {
int[] result = new int[]{0,0};
@@ -328,7 +328,8 @@
BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction);
ShipOwnerDAO shipOwnerDAO = WaoDAOHelper.getShipOwnerDAO(transaction);
- Map<String, ShipOwner> availableShipOwners = new HashMap<String, ShipOwner>();
+ Map<String, ShipOwner> availableShipOwners =
+ new HashMap<String, ShipOwner>();
tic = System.currentTimeMillis();
Pattern pattern = Pattern.compile("\\d{6}");
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 13:55:30 UTC (rev 404)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 14:16:57 UTC (rev 405)
@@ -18,9 +18,9 @@
wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9
wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails.
wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news
-wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre \'%1$s\'
+wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s'
wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades
wao.error.serviceReferential.getFishingZones=Impossible de charger la liste des secteurs de p\u00EAche
wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers
wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche
-wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier : [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
+wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
Modified: trunk/wao-business/src/main/xmi/wao.zargo
===================================================================
(Binary files differ)
1
0
[Suiviobsmer-commits] r404 - in trunk/wao-business/src/main: java/fr/ifremer/wao/service resources/i18n
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
by fdesbois@users.labs.libre-entreprise.org 01 Apr '10
01 Apr '10
Author: fdesbois
Date: 2010-04-01 13:55:30 +0000 (Thu, 01 Apr 2010)
New Revision: 404
Modified:
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java
trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
Log:
Clean ServiceNewsImpl and ServiceReferentialImpl
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-01 13:51:21 UTC (rev 403)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-01 13:55:30 UTC (rev 404)
@@ -47,83 +47,31 @@
private static final Logger logger =
LoggerFactory.getLogger(ServiceNewsImpl.class);
-// protected TopiaContext rootContext;
-//
-// public ServiceNewsImpl() throws WaoExceptionO {
-// rootContext = WaoContextO.getTopiaRootContext();
-// }
-
@Override
public List<News> executeGetNews(TopiaContext transaction) throws TopiaException {
-// TopiaContext transaction = null;
-// List<News> results = new ArrayList<News>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction);
-
- return dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE +
- " DESC");
+ NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction);
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getNews ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction,
-// "Impossible de récupérer l'ensemble des news", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC");
}
@Override
public void executeSaveNews(TopiaContext transaction,
List<Object> errorArgs, News news, boolean delete)
throws TopiaException {
-// TopiaContext transaction = null;
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- errorArgs.add(news.getTitle());
+ errorArgs.add(news.getTitle());
- NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction);
+ NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction);
- if (delete) {
- dao.delete(news);
- } else {
- context.prepareTopiaId(News.class, news);
- dao.update(news);
- }
+ if (delete) {
+ dao.delete(news);
+ } else {
+ context.prepareTopiaId(News.class, news);
+ dao.update(news);
+ }
- transaction.commitTransaction();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ saveNews ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction,
-// "Impossible de récupérer l'ensemble des news", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
}
}
Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-01 13:51:21 UTC (rev 403)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-01 13:55:30 UTC (rev 404)
@@ -57,90 +57,40 @@
private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImpl.class);
-// protected TopiaContext rootContext;
-//
-// public ServiceReferentialImpl() throws WaoExceptionO {
-// rootContext = WaoContextO.getTopiaRootContext();
-// }
-
@Override
public List<String> executeGetFacades(TopiaContext transaction,
SamplingFilter filter) throws TopiaException {
-// TopiaContext transaction = null;
-// List<String> results = new ArrayList<String>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
- TopiaQuery query = dao.createQuery("F");
+ FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
+ TopiaQuery query = dao.createQuery("F");
- query = prepareQueryForFishingZoneFilter(query, filter);
+ query = prepareQueryForFishingZoneFilter(query, filter);
- return (List<String>)query.addDistinct().
- setSelect("F." + FishingZone.FACADE_NAME).execute();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getFacades ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de charger la liste des facades", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return (List<String>)query.addDistinct().
+ setSelect("F." + FishingZone.FACADE_NAME).execute();
}
@Override
public List<String> executeGetSectors(TopiaContext transaction,
SamplingFilter filter) throws TopiaException {
-// TopiaContext transaction = null;
-// List<String> results = new ArrayList<String>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
- TopiaQuery query = dao.createQuery("F");
+ FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
+ TopiaQuery query = dao.createQuery("F");
- query = prepareQueryForFishingZoneFilter(query, filter);
+ query = prepareQueryForFishingZoneFilter(query, filter);
- if (StringUtils.isNotEmpty(filter.getFacadeName())) {
- query.add("F." + FishingZone.FACADE_NAME, filter.getFacadeName());
- }
+ if (StringUtils.isNotEmpty(filter.getFacadeName())) {
+ query.add("F." + FishingZone.FACADE_NAME, filter.getFacadeName());
+ }
- return (List<String>)query.addDistinct().
- setSelect("F." + FishingZone.SECTOR_NAME).execute();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getSectors ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return (List<String>)query.addDistinct().
+ setSelect("F." + FishingZone.SECTOR_NAME).execute();
}
- protected TopiaQuery prepareQueryForFishingZoneFilter(TopiaQuery query, SamplingFilter filter) throws TopiaException {
- if (filter.getCompany() != null || StringUtils.isNotEmpty(filter.getProgramName())) {
+ protected TopiaQuery prepareQueryForFishingZoneFilter(TopiaQuery query,
+ SamplingFilter filter) throws TopiaException {
+ if (filter.getCompany() != null ||
+ StringUtils.isNotEmpty(filter.getProgramName())) {
query.addFrom(SampleRow.class.getName() + " S").
add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
}
@@ -159,114 +109,54 @@
@Override
public List<Profession> executeGetProfessions(TopiaContext transaction)
throws TopiaException {
-// TopiaContext transaction = null;
-// List<Profession> results = new ArrayList<Profession>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction);
+ ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction);
- return dao.findAll();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getProfessions ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction,
-// "Impossible de charger la liste des métiers", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAll();
}
@Override
public List<FishingZone> executeGetFishingZones(TopiaContext transaction)
throws TopiaException {
-// TopiaContext transaction = null;
-// List<FishingZone> results = new ArrayList<FishingZone>();
-// try {
-// long startTime = 0;
-// if (log.isDebugEnabled()) {
-// startTime = System.currentTimeMillis();
-// }
-// transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
- return dao.findAll();
-
-// if (log.isDebugEnabled()) {
-// long stopTime = System.currentTimeMillis();
-// log.debug("W:[ getFishingZones ] Time = " +
-// DurationFormatUtils.formatDurationHMS(
-// stopTime - startTime));
-// }
-//
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction,
-// "Impossible de charger la liste des zones de pêche", eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
-// return results;
+ return dao.findAll();
}
@Override
public int executeImportFishingZoneCsv(TopiaContext transaction,
InputStream input) throws TopiaException, IOException {
-// TopiaContext transaction = null;
int result = 0;
-// try {
-// transaction = rootContext.beginTransaction();
- CsvReader reader = new CsvReader(input, context.getCsvCharset());
- reader.readHeaders();
+ CsvReader reader = new CsvReader(input, context.getCsvCharset());
+ reader.readHeaders();
- FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction);
- while(reader.readRecord()) {
- if (log.isTraceEnabled()) {
- log.trace(" " + Arrays.asList(reader.getValues()));
- }
+ while(reader.readRecord()) {
+ if (log.isTraceEnabled()) {
+ log.trace(" " + Arrays.asList(reader.getValues()));
+ }
- String facadeName =
- ImportHelper.read(reader, FISHING_ZONE.PECHE_FACADE);
- String sectorName =
- ImportHelper.read(reader, FISHING_ZONE.PECHE_ZONE);
- String districtCode =
- ImportHelper.read(reader, FISHING_ZONE.PECHE_DIVISION);
+ String facadeName =
+ ImportHelper.read(reader, FISHING_ZONE.PECHE_FACADE);
+ String sectorName =
+ ImportHelper.read(reader, FISHING_ZONE.PECHE_ZONE);
+ String districtCode =
+ ImportHelper.read(reader, FISHING_ZONE.PECHE_DIVISION);
- FishingZone zone = dao.findByDistrictCode(districtCode);
-
- if (zone == null) {
- zone = dao.create(FishingZone.DISTRICT_CODE, districtCode);
- }
- zone.setFacadeName(facadeName);
- zone.setSectorName(sectorName);
- result++;
+ FishingZone zone = dao.findByDistrictCode(districtCode);
+
+ if (zone == null) {
+ zone = dao.create(FishingZone.DISTRICT_CODE, districtCode);
}
+ zone.setFacadeName(facadeName);
+ zone.setSectorName(sectorName);
+ result++;
+ }
- transaction.commitTransaction();
-// //transaction.closeContext();
-// } catch (Exception eee) {
-// WaoContextO.serviceException(transaction,
-// "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ PECHE_DIVISION," +
-// "PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de détails.",
-// eee);
-// } finally {
-// WaoContextO.closeTransaction(transaction);
-// }
+ transaction.commitTransaction();
return result;
}
Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties
===================================================================
--- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 13:51:21 UTC (rev 403)
+++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 13:55:30 UTC (rev 404)
@@ -17,10 +17,10 @@
wao.error.serviceBoat.getNbBoatsByFilter=Impossible de filtrer la liste des navires
wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9
wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails.
-wao.error.serviceNews.getNews=
-wao.error.serviceNews.saveNews=
-wao.error.serviceReferential.getFacades=
-wao.error.serviceReferential.getFishingZones=
-wao.error.serviceReferential.getProfessions=
-wao.error.serviceReferential.getSectors=
-wao.error.serviceReferential.importFishingZoneCsv=
+wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news
+wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre \'%1$s\'
+wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades
+wao.error.serviceReferential.getFishingZones=Impossible de charger la liste des secteurs de p\u00EAche
+wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers
+wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche
+wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier : [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails.
1
0