[Suiviobsmer-commits] r160 - in trunk: . suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl
Author: fdesbois Date: 2009-12-24 15:57:38 +0000 (Thu, 24 Dec 2009) New Revision: 160 Removed: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java Modified: trunk/pom.xml trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/QueryBuilder.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/TopiaQuery.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImplTest.java Log: - Use topia SNAPSHOT for on topiaCreateDate type - Improve queries + add property loading managment - Use EntityLoador for getNewProfession Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/pom.xml 2009-12-24 15:57:38 UTC (rev 160) @@ -239,7 +239,7 @@ <!-- libraries version --> <nuitonutils.version>1.1.2</nuitonutils.version> - <topia.version>2.3.0-beta-2</topia.version> + <topia.version>2.3.0-beta-3-SNAPSHOT</topia.version> <license.version>2.0.0</license.version> <helper.version>1.1.0</helper.version> <eugene.version>2.0.0-beta-2</eugene.version> Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/DataLoader.java 2009-12-24 15:57:38 UTC (rev 160) @@ -1,76 +0,0 @@ -/* - * *##% - * SuiviObsmer :: Business - * Copyright (C) 2009 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.suiviobsmer; - -import fr.ifremer.suiviobsmer.entity.ActivityCalendar; -import fr.ifremer.suiviobsmer.entity.ActivityMonth; -import fr.ifremer.suiviobsmer.entity.ActivityProfession; -import fr.ifremer.suiviobsmer.entity.ActivityZone; -import fr.ifremer.suiviobsmer.entity.Contact; -import fr.ifremer.suiviobsmer.entity.SampleRow; -import java.util.List; - -/** - * DataLoader - * - * Created: 3 déc. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Used to load data to avoid LazyInitializationException - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class DataLoader { - - public static void loadContactForFindByFilters(Contact contact) { - // load data - contact.getUser().getCompany(); - SampleRow row = contact.getSampleRow(); - row.getProgram(); - row.getProfession(); - row.getCompany(); - //row.getFishingZone().size(); lazy=false - } - - public static void loadActivityCalendar(ActivityCalendar calendar) { - calendar.getBoat(); - List<ActivityMonth> months = calendar.getActivityMonth(); - for (ActivityMonth month : months) { - if (month.getActive()) { - List<ActivityProfession> professions = month.getActivityProfession(); - for (ActivityProfession profession : professions) { - List<ActivityZone> zones = profession.getActivityZone(); - zones.size(); - } - } - } - } - - public static void loadContactForBoatInfos(Contact contact) { - contact.getSampleRow(); - contact.getUser(); - } - -} Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/QueryBuilder.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/QueryBuilder.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/QueryBuilder.java 2009-12-24 15:57:38 UTC (rev 160) @@ -50,17 +50,17 @@ */ public static TopiaQuery createQueryLastContactForBoat(Boat boat, Company company) { String contactClassName = Contact.class.getName(); + TopiaQuery query = new TopiaQuery(contactClassName + " C1"). + add("C1.boat", boat). + add("C1.user.company = :company"). + addParam("company", company); + TopiaQuery subquery = new TopiaQuery(contactClassName + " C2"). addSelect("MAX(C2.topiaCreateDate)"). add("C2.boat = C1.boat"). add("C2.user.company = :company"); - TopiaQuery query = new TopiaQuery(contactClassName + " C1"). - add("C1.boat", boat). - add("C1.user.company = :company"). - addParam("company", company). - add("C1.topiaCreateDate = (" + subquery.fullQuery() + ")"); - + query.add("C1.topiaCreateDate = (" + subquery.fullQuery() + ")"); return query; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/TopiaQuery.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/TopiaQuery.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/TopiaQuery.java 2009-12-24 15:57:38 UTC (rev 160) @@ -21,9 +21,16 @@ package fr.ifremer.suiviobsmer; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; @@ -67,6 +74,8 @@ /** Used to determine if parentheses are needed for Where input **/ protected boolean parentheses; + protected List<String> propertiesToLoad; + /** * Enum to simmplify using operation in query */ @@ -167,6 +176,33 @@ } /** + * Add a property to load when query is executed. + * Used to avoid LazyInitializationException for property needed after closing context. + * The property is a string like those in HQL query. + * <pre> + * Exemples : + * - "person.company" (Property TopiaEntity person linked to the result entity in query and company linked to person) + * --> calling myEntity.getPerson().getCompany(); + * - "partyRoles" (Property Collection partyRoles linked to the result entity in query) + * --> calling myEntity.getPartyRoles().size(); + * </pre> + * + * @param properties + * @return + */ + public TopiaQuery addLoad(String... properties) { + getPropertiesToLoad().addAll(Arrays.asList(properties)); + return this; + } + + protected List<String> getPropertiesToLoad() { + if (propertiesToLoad == null) { + propertiesToLoad = new ArrayList<String>(); + } + return propertiesToLoad; + } + + /** * Add a where element to the Query. Could be anything. * Parentheses are added automatically (even if there are not needed). * @@ -276,6 +312,10 @@ return this; } + public TopiaQuery addOrderDesc(String order) { + return addOrder(order + " DESC"); + } + /** * Add an element to the group of the query. Used to add some paramters to group by. * @@ -314,34 +354,166 @@ } /** - * Execute the query and get a List of entity. + * Execute the query and get a List of entity. Some properties will be loaded if they are + * prealably set using ${@link #addLoad(java.lang.String[]) }. * * @param <T> the type of TopiaEntity to return * @param transaction the TopiaContext to use for execution * @param entityClass the class of the TopiaEntity used for return type * @return a List of TopiaEntity corresponding to the entityClass in argument * @throws TopiaException + * @throws ClassCastException */ - public <T extends TopiaEntity> List<T> executeToEntityList(TopiaContext transaction, Class<T> entityClass) throws TopiaException { + public <T extends TopiaEntity> List<T> executeToEntityList(TopiaContext transaction, Class<T> entityClass) + throws TopiaException, ClassCastException { List res = execute(transaction); -// List<T> results = new ArrayList<T>(); -// for (Object o : res) { -// T entity = (T)o; -// results.add(entity); -// } - return (List<T>)res; + if (log.isTraceEnabled()) { + log.trace("Properties to load : " + getPropertiesToLoad()); + } + List<T> results = new ArrayList<T>(); + for (Object o : res) { + if (o != null && !entityClass.isAssignableFrom(o.getClass())) { + throw new ClassCastException("Invalid cast for " + entityClass.getName()); + } + T entity = (T)o; + if (!getPropertiesToLoad().isEmpty()) { + loadProperties(entity); + } + results.add(entity); + } + return results; } /** - * Execute the query and get the first result entity. + * Load all properties for the entity. * + * @param <T> type of the entity extends TopiaEntity + * @param entity used to load properties + * @throws TopiaException + */ + protected <T extends TopiaEntity> void loadProperties(T entity) throws TopiaException { + for (String prop : getPropertiesToLoad()) { + if (log.isTraceEnabled()) { + log.trace("load property " + prop + " ..."); + } + List<String> str = Arrays.asList(prop.split("\\.")); + Iterator<String> it = str.iterator(); + TopiaEntity currEntity = entity; + while (it.hasNext()) { + String s = it.next(); + if (log.isTraceEnabled()) { + log.trace("Current entity : " + currEntity.getClass().getSimpleName()); + log.trace("Current loading : " + s); + } + if (it.hasNext()) { + currEntity = loadEntityProperty(currEntity, s); + } else { + loadProperty(currEntity, s); + } + } + } + } + + /** + * Load a property of type TopiaEntity from an other entity. + * + * @param <T> type of the entity extends TopiaEntity + * @param entity used to load the property + * @param property name of the property in the entity + * @return a TopiaEntity corresponding to the property loaded + * @throws TopiaException + */ + protected <T extends TopiaEntity> TopiaEntity loadEntityProperty(T entity, String property) throws TopiaException { + return (TopiaEntity)loadProperty(entity, property); + } + + /** + * Load a property from an entity. + * + * @param <T> type of the entity extends TopiaEntity + * @param entity used to load the property + * @param property name of the property in the entity + * @return an Object corresponding to the property loaded + * @throws TopiaException + */ + protected <T extends TopiaEntity> Object loadProperty(T entity, String property) throws TopiaException { + try { + Object res = PropertyUtils.getProperty(entity, property); + if (log.isTraceEnabled()) { + log.trace("load property '" + property + "' for '" + entity.getClass().getSimpleName() + "'"); + } + if (Collection.class.isAssignableFrom(res.getClass())) { + Collection list = (Collection) res; + list.size(); + } + return res; + } catch (IllegalAccessException eee) { + throw new TopiaException("Illegal access on property " + property + " from entity " + entity.getClass().getName(), eee); + } catch (InvocationTargetException eee) { + throw new TopiaException("Invocation error on entity " + entity.getClass().getName() + " for property " + property, eee); + } catch (NoSuchMethodException eee) { + throw new TopiaException("Getter method does not exist for property " + property + " from entity " + entity.getClass().getName(), eee); + } + } + + /** + * Execute the query and get a Map of entity with key type in argument. Some properties will be loaded if they are + * prealably set using ${@link #addLoad(java.lang.String[]) }. + * + * @param <K> the type of the map key + * @param <T> the type of entity, value of the map + * @param transaction the TopiaContext to use for execution + * @param entityClass the class of the TopiaEntity used for return + * @param keyName the property name of the key in the entity + * @param keyClass the key class for the result map + * @return a Map with the key type defined and the entity in value + * @throws TopiaException + * @throws ClassCastException + */ + public <K, T extends TopiaEntity> Map<K, T> executeToEntityMap(TopiaContext transaction, Class<T> entityClass, String keyName, Class<K> keyClass) + throws TopiaException, ClassCastException { + + Map<K, T> results = new HashMap<K, T>(); + //for (PropertyDescriptor) + for (T elmt : executeToEntityList(transaction, entityClass)) { + Object value = loadProperty(elmt, keyName); + if (value != null && !keyClass.isAssignableFrom(value.getClass())) { + throw new ClassCastException("Invalid cast for " + keyClass.getName()); + } + results.put((K)value, elmt); + } + return results; + } + + /** + * Execute the query and get a Map of entity with topiaId in key. Some properties will be loaded if they are + * prealably set using ${@link #addLoad(java.lang.String[]) }. + * + * @param <T> the type of entity, value of the map + * @param transaction the TopiaContext to use for execution + * @param entityClass the class of the TopiaEntity used for return + * @return a Map with the key type defined and the entity in value + * @throws TopiaException + * @throws ClassCastException + */ + public <T extends TopiaEntity> Map<String, T> executeToEntityMap(TopiaContext transaction, Class<T> entityClass) + throws TopiaException, ClassCastException { + return executeToEntityMap(transaction, entityClass, TopiaEntity.TOPIA_ID, String.class); + } + + /** + * Execute the query and get the first result entity. Some properties will be loaded if they are + * prealably set using ${@link #addLoad(java.lang.String[]) }. + * * @param <T> the type of TopiaEntity to return * @param transaction the TopiaContext to use for execution * @param entityClass the class of the TopiaEntity used for return type * @return a TopiaEntity corresponding to the entityClass in argument * @throws TopiaException + * @throws ClassCastException */ - public <T extends TopiaEntity> T executeToEntity(TopiaContext transaction, Class<T> entityClass) throws TopiaException { + public <T extends TopiaEntity> T executeToEntity(TopiaContext transaction, Class<T> entityClass) + throws TopiaException, ClassCastException { List<T> results = executeToEntityList(transaction, entityClass); return !results.isEmpty() ? results.get(0) : null; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2009-12-24 15:57:38 UTC (rev 160) @@ -22,7 +22,6 @@ package fr.ifremer.suiviobsmer.impl; import com.csvreader.CsvReader; -import fr.ifremer.suiviobsmer.DataLoader; import fr.ifremer.suiviobsmer.QueryBuilder; import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException; import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type; @@ -72,6 +71,8 @@ protected TopiaContext rootContext; + // CREATE UNIQUE INDEX boat_immatriculation_idx ON BOAT(IMMATRICULATION) + public ServiceBoatImpl() throws SuiviObsmerException { rootContext = SuiviObsmerContext.getTopiaRootContext(); } @@ -128,10 +129,7 @@ addParam("booleanTrue", Boolean.TRUE); } - List<Boat> boats = query.executeToEntityList(transaction, Boat.class); - for (Boat boat : boats) { - results.put(boat.getImmatriculation(), boat); - } + results = query.executeToEntityMap(transaction, Boat.class, Boat.IMMATRICULATION, Integer.class); transaction.closeContext(); } catch (Exception eee) { @@ -200,11 +198,11 @@ } // Last contact - TopiaQuery query = QueryBuilder.createQueryLastContactForBoat(boat, company); + TopiaQuery query = QueryBuilder.createQueryLastContactForBoat(boat, company). + addLoad(Contact.SAMPLE_ROW, Contact.USER); Contact contact = query.executeToEntity(transaction, Contact.class); if (contact != null) { - DataLoader.loadContactForBoatInfos(contact); result.setLastContact(contact); } @@ -422,15 +420,6 @@ try { transaction = rootContext.beginTransaction(); -// String activityCalendarClassName = ActivityCalendar.class.getName(); -// List results = transaction.find( -// "FROM " + activityCalendarClassName + " A WHERE A.boat = :boat AND A.year = " + -// "(SELECT MAX(B.year) FROM " + activityCalendarClassName + " B " + -// " WHERE B.boat = A.boat GROUP BY B.boat)", -// "boat", boat); -// -// result = (ActivityCalendar) results.get(0); - String activityCalendarClassName = ActivityCalendar.class.getName(); TopiaQuery query = new TopiaQuery(activityCalendarClassName + " A"). add("A.boat", boat); @@ -442,9 +431,21 @@ query.add("A.year = (" + subquery.fullQuery() + ")"); + query.addLoad(ActivityCalendar.BOAT); result = query.executeToEntity(transaction, ActivityCalendar.class); - DataLoader.loadActivityCalendar(result); + // load other complex data from collections + List<ActivityMonth> months = result.getActivityMonth(); + for (ActivityMonth month : months) { + if (month.getActive()) { + List<ActivityProfession> professions = month.getActivityProfession(); + for (ActivityProfession profession : professions) { + List<ActivityZone> zones = profession.getActivityZone(); + zones.size(); + } + } + } + transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java 2009-12-24 15:57:38 UTC (rev 160) @@ -21,10 +21,10 @@ package fr.ifremer.suiviobsmer.impl; -import fr.ifremer.suiviobsmer.DataLoader; import fr.ifremer.suiviobsmer.SuiviObsmerException; import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper; import fr.ifremer.suiviobsmer.SuiviObsmerContext; +import fr.ifremer.suiviobsmer.TopiaQuery; import fr.ifremer.suiviobsmer.bean.states.ContactStateEnum; import fr.ifremer.suiviobsmer.entity.Boat; import fr.ifremer.suiviobsmer.entity.Company; @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.persistence.TopiaEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,23 +70,15 @@ try { transaction = rootContext.beginTransaction(); - ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); + TopiaQuery query = new TopiaQuery(Contact.class).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE); - if (company == null) { - for (Contact contact : dao.findAll()) { - DataLoader.loadContactForFindByFilters(contact); - results.put(contact.getTopiaId(), contact); - } - } else { - List list = transaction.find("FROM ContactImpl WHERE user.company = :company", - "company", company); - for (Object o : list) { - Contact contact = (Contact)o; - DataLoader.loadContactForFindByFilters(contact); - results.put(contact.getTopiaId(), contact); - } + if (company != null) { + query.add("user.company", company); } + query.addLoad("user.company", "sampleRow.program", "sampleRow.profession", "sampleRow.company"); + results = query.executeToEntityMap(transaction, Contact.class); + transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, @@ -122,6 +115,10 @@ ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); + if (log.isDebugEnabled()) { + log.debug("Create date : " + contact.getTopiaCreateDate()); + } + SuiviObsmerContext.prepareTopiaId(Contact.class, contact); if (delete) { dao.delete(contact); Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java 2009-12-24 15:57:38 UTC (rev 160) @@ -44,11 +44,10 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; +import org.nuiton.topia.persistence.util.EntityLoador; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -348,12 +347,9 @@ @Override public Profession getNewProfession(Profession profession) { Profession newProfession = new ProfessionImpl(); - newProfession.setCodeDCF5(profession.getCodeDCF5()); - newProfession.setLibelle(profession.getLibelle()); - newProfession.setOther(profession.getOther()); - newProfession.setMeshSize(profession.getMeshSize()); - newProfession.setSize(profession.getSize()); - newProfession.setSpecies(profession.getSpecies()); + EntityLoador<Profession> loador = EntityLoador.newEntityLoador(Profession.class, + Profession.CODE_DCF5, Profession.LIBELLE, Profession.MESH_SIZE, Profession.OTHER, Profession.SIZE, Profession.SPECIES); + loador.load(profession, newProfession, false); return newProfession; } Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo =================================================================== (Binary files differ) Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java =================================================================== --- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImplTest.java 2009-12-24 15:57:38 UTC (rev 160) @@ -51,6 +51,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.junit.After; Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImplTest.java =================================================================== --- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImplTest.java 2009-12-23 17:52:56 UTC (rev 159) +++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImplTest.java 2009-12-24 15:57:38 UTC (rev 160) @@ -54,6 +54,7 @@ import java.util.List; import org.junit.After; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -359,6 +360,37 @@ } @Test + public void testGetNewProfession() throws Exception { + log.info("getNewProfession"); + + /** PREPARE DATA **/ + + TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); + + ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction); + + Profession profession = dao.create( + Profession.CODE_DCF5, "OBR", + Profession.LIBELLE, "Fileyage en barre", + Profession.MESH_SIZE, "< 80", + Profession.OTHER, "90mm", + Profession.SPECIES, "barre, lieu noir, saumon des plages"); + + transaction.commitTransaction(); + transaction.closeContext(); + + /** EXEC METHOD **/ + Profession newProfession = service.getNewProfession(profession); + Assert.assertNotSame(profession, newProfession); + Assert.assertEquals("OBR", newProfession.getCodeDCF5()); + Assert.assertEquals("Fileyage en barre", newProfession.getLibelle()); + Assert.assertEquals("< 80", newProfession.getMeshSize()); + Assert.assertEquals("90mm", newProfession.getOther()); + Assert.assertEquals("barre, lieu noir, saumon des plages", newProfession.getSpecies()); + + } + + @Test public void testDeleteSampleRow() throws Exception { log.info("deleteSampleRow");
participants (1)
-
fdesbois@users.labs.libre-entreprise.org