r2991 - in trunk/pollen-business/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/bean main/java/org/chorem/pollen/service test/java/org/chorem/pollen
Author: fdesbois Date: 2010-05-10 15:22:24 +0200 (Mon, 10 May 2010) New Revision: 2991 Url: http://chorem.org/repositories/revision/pollen/2991 Log: Changes from ToPIA-2.4 : use exist methods to test existence + rename getTopiaId() in getId() Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-06 17:24:53 UTC (rev 2990) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-10 13:22:24 UTC (rev 2991) @@ -144,7 +144,7 @@ * @return the property name to use in a TopiaQuery */ public String namePropertyId() { - return nameProperty(TopiaEntity.TOPIA_ID); + return nameProperty(TopiaEntity.ID); } /** @@ -153,7 +153,7 @@ * @return the property name to use in a TopiaQuery */ public String namePropertyCreateDate() { - return nameProperty(TopiaEntity.TOPIA_CREATE_DATE); + return nameProperty(TopiaEntity.CREATE_DATE); } /** Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-06 17:24:53 UTC (rev 2990) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-10 13:22:24 UTC (rev 2991) @@ -113,7 +113,7 @@ */ public void setReference(TopiaEntity entity) { String oldReferenceId = this.referenceId; - this.referenceId = entity.getTopiaId(); + this.referenceId = entity.getId(); propertyChangeSupport.firePropertyChange(PROP_REFERENCE_ID, oldReferenceId, referenceId); } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-06 17:24:53 UTC (rev 2990) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-10 13:22:24 UTC (rev 2991) @@ -74,21 +74,18 @@ // check favoriteList name exist for user UserAccount user = list.getUserAccount(); - int count = dao.createQuery(). - add(FavoriteList.USER_ACCOUNT, user). - add(FavoriteList.NAME, list.getName()). - executeCount(); +// int count = dao.createQuery(). +// add(FavoriteList.USER_ACCOUNT, user). +// add(FavoriteList.NAME, list.getName()). +// executeCount(); // existing list found - if (count > 0) { + if (dao.existByNaturalId(list.getName(), user)) { throw new PollenBusinessException( PollenExceptionType.FAVORITE_LIST_NAME_EXIST, list.getName(), user.getDisplayName()); } - FavoriteList newList = dao.create( - FavoriteList.USER_ACCOUNT, list.getUserAccount(), - FavoriteList.NAME, list.getName()); -// list.setTopiaId(newList.getTopiaId()); + dao.create(list.getName(), list.getUserAccount()); transaction.commitTransaction(); } @@ -98,7 +95,7 @@ FavoriteList list) throws TopiaException { FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction); - FavoriteList listLoaded = dao.findByTopiaId(list.getTopiaId()); + FavoriteList listLoaded = dao.findById(list.getId()); dao.delete(listLoaded); transaction.commitTransaction(); @@ -136,13 +133,12 @@ add(FavoriteParticipant.EMAIL, participant.getEmail()); // Check only on entities different from the one in argument - if (StringUtils.isNotEmpty(participant.getTopiaId())) { - query.add(TopiaEntity.TOPIA_ID, Op.NEQ, participant.getTopiaId()); + if (StringUtils.isNotEmpty(participant.getId())) { + query.add(TopiaEntity.ID, Op.NEQ, participant.getId()); } - int count = query.executeCount(); // existing participant found - if (count > 0) { + if (dao.existByQuery(query)) { // The error type (message) depends on email nullity if (participant.getEmail() == null) { throw new PollenBusinessException( @@ -181,8 +177,8 @@ // Create newParticipant with naturalId FavoriteParticipant newParticipant = dao.create(participant.getName(), - participant.getEmail(), - participant.getFavoriteList()); + participant.getEmail(), + participant.getFavoriteList()); // Set other field newParticipant.setWeight(participant.getWeight()); @@ -197,7 +193,7 @@ FavoriteParticipantDAO dao = PollenDAOHelper.getFavoriteParticipantDAO(transaction); - FavoriteParticipant participantLoaded = dao.findByTopiaId(id); + FavoriteParticipant participantLoaded = dao.findById(id); dao.delete(participantLoaded); @@ -215,7 +211,7 @@ checkFavoriteParticipant(dao, participant); FavoriteParticipant participantLoaded = - dao.findByTopiaId(participant.getTopiaId()); + dao.findById(participant.getId()); // Set all fields except favoriteList that can't be changed participantLoaded.setName(participant.getName()); @@ -234,7 +230,7 @@ FavoriteParticipantDAO dao = PollenDAOHelper.getFavoriteParticipantDAO(transaction); - FavoriteParticipant result = dao.findByTopiaId(id); + FavoriteParticipant result = dao.findById(id); // Load parent list result.getFavoriteList(); Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-06 17:24:53 UTC (rev 2990) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-10 13:22:24 UTC (rev 2991) @@ -105,12 +105,13 @@ */ protected void checkPassword(UserAccountDAO dao, String login, String password) throws TopiaException, PollenBusinessException { - int count = dao.createQuery(). - add(UserAccount.LOGIN, login). - add(UserAccount.PASSWORD, password). - executeCount(); +// int count = dao.createQuery(). +// add(UserAccount.LOGIN, login). +// add(UserAccount.PASSWORD, password). +// executeCount(); // no user found - if (count == 0) { + if (!dao.existByProperties(UserAccount.LOGIN, login, + UserAccount.PASSWORD, password)) { throw new PollenBusinessException( PollenExceptionType.USER_WRONG_PASSWORD, login); } @@ -126,11 +127,11 @@ */ protected void checkLoginNotExist(UserAccountDAO dao, String login) throws PollenBusinessException, TopiaException { - int count = dao.createQuery(). - add(UserAccount.LOGIN, login). - executeCount(); +// int count = dao.createQuery(). +// add(UserAccount.LOGIN, login). +// executeCount(); // existing user found - if (count > 0) { + if (dao.existByNaturalId(login)) { throw new PollenBusinessException( PollenExceptionType.USER_LOGIN_EXIST); } @@ -155,10 +156,10 @@ if (query == null) { query = dao.createQuery(); } - int count = query.add(UserAccount.EMAIL, StringUtils.lowerCase(email)). - executeCount(); + query.add(UserAccount.EMAIL, StringUtils.lowerCase(email)); + // existing user found - if (count > 0) { + if (dao.existByQuery(query)) { throw new PollenBusinessException( PollenExceptionType.USER_EMAIL_EXIST); } @@ -239,6 +240,7 @@ // In case of email change, check if an other user has not already // the new email + // FIXME-fdesbois-20100510 : replace by using id directly TopiaQuery query = dao.createQuery(). add(UserAccount.LOGIN, Op.NEQ, user.getLogin()); checkEmailNotExist(dao, user.getEmail(), query); Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-06 17:24:53 UTC (rev 2990) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-10 13:22:24 UTC (rev 2991) @@ -53,7 +53,7 @@ Assert.assertEquals(builder.getQuery().fullQuery(), "FROM " + UserAccount.class.getName() + - " ORDER BY " + TopiaEntity.TOPIA_CREATE_DATE + " DESC"); + " ORDER BY " + TopiaEntity.CREATE_DATE + " DESC"); } @@ -98,7 +98,7 @@ "SELECT P FROM " + FavoriteParticipant.class.getName() + " P, " + FavoriteList.class.getName() + " L" + " WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT + - ") ORDER BY P." + TopiaEntity.TOPIA_CREATE_DATE + " DESC"); + ") ORDER BY P." + TopiaEntity.CREATE_DATE + " DESC"); log.info("test3 : orderBy name and email desc"); String orderBy = FavoriteParticipant.NAME + ", " + FavoriteParticipant.EMAIL + " desc";
participants (1)
-
fdesbois@users.chorem.org