Commits

Juan Carlos Picado Herrera  committed 48aa610

ENCUESTAME-272 in progress

  • Participants
  • Parent commits e7ae4a2

Comments (0)

Files changed (23)

File encuestame-business/src/main/java/org/encuestame/business/service/AbstractBaseService.java

      */
     public TweetPollBean  convertTweetPollRelativeTime(final TweetPollBean tpbean, final HttpServletRequest request){
         final HashMap<Integer, RelativeTimeEnum> relativeTime =  DateUtil.getRelativeTime(tpbean.getCreatedDateAt());
+        @SuppressWarnings("rawtypes")
         final Iterator it = relativeTime.entrySet().iterator();
         while (it.hasNext()) {
+            @SuppressWarnings("unchecked")
             final Map.Entry<Integer, RelativeTimeEnum> e = (Map.Entry<Integer, RelativeTimeEnum>)it.next();
-            log.debug("--"+e.getKey() + "**" + e.getValue());
+            if (log.isDebugEnabled()) {
+                log.debug("--"+e.getKey() + "**" + e.getValue());
+            }
             tpbean.setRelativeTime(convertRelativeTimeMessage(e.getValue(), e.getKey(), request));
         }
         return tpbean;
               }
               return unitLists;
           } else {
-              throw new EnMeExpcetion("Email List is null");
+              throw new EnMeExpcetion("email list is not valid");
           }
       }
 

File encuestame-business/src/main/java/org/encuestame/business/service/SecurityService.java

 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import org.encuestame.core.security.util.EnMePasswordUtils;
 import org.encuestame.core.security.util.PasswordGenerator;
 import org.encuestame.core.util.ConvertDomainBean;
-import org.encuestame.core.util.ConvertDomainsToSecurityContext;
 import org.encuestame.core.util.SocialUtils;
 import org.encuestame.persistence.domain.EnMePermission;
 import org.encuestame.persistence.domain.notifications.Notification;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.persistence.exception.IllegalSocialActionException;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.oauth.AccessGrant;
 import org.encuestame.utils.security.SignUpBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.social.SocialUserProfile;
 import org.encuestame.utils.web.UnitGroupBean;
 import org.encuestame.utils.web.UnitLists;
 import org.encuestame.utils.web.UserAccountBean;
 import org.jasypt.util.password.StrongPasswordEncryptor;
 import org.springframework.mail.MailSendException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Assert;
      * (non-Javadoc)
      * @see org.encuestame.business.service.imp.SecurityOperations#getUserLoggedVerifiedTwitterAccount(java.lang.String, org.encuestame.persistence.domain.social.SocialProvider)
      */
-    public List<SocialAccountBean> getUserLoggedVerifiedSocialAccounts(final SocialProvider provider)
+    public List<SocialAccountBean> getValidSocialAccounts(
+            final SocialProvider provider,
+            final Boolean addStats)
              throws EnMeNoResultsFoundException{
         final List<SocialAccount> socialAccounts = getAccountDao()
                 .getSocialVerifiedAccountByUserAccount(getUserAccount(getUserPrincipalUsername()).getAccount(), provider);
         log.debug("social provider verified:{"+socialAccounts.size());
+        final List<SocialAccountBean> accounts = new ArrayList<SocialAccountBean>();
+        if ( addStats) {
+            accounts.addAll(this.addSocialStats(socialAccounts));
+        } else {
+            accounts.addAll(ConvertDomainBean.convertListSocialAccountsToBean(socialAccounts));
+        }
         return ConvertDomainBean.convertListSocialAccountsToBean(socialAccounts);
    }
 
     /**
+     * Add social stats.
+     * @param socialAccount {@link SocialAccount}.
+     * @return list of social accounts.
+     */
+    private List<SocialAccountBean> addSocialStats(final List<SocialAccount> socialAccounts) {
+        final List<SocialAccountBean> accounts = new ArrayList<SocialAccountBean>();
+        for (SocialAccount socialAccount : socialAccounts) {
+            final HashMap<String, Long> stats = getAccountDao().getSocialAccountStats(socialAccount);
+            final SocialAccountBean bean = ConvertDomainBean.convertSocialAccountToBean(socialAccount);
+            bean.setTweetpoll(stats.get("tweetpoll"));
+            bean.setPoll(stats.get("poll"));
+            bean.setSurvey(stats.get("survey"));
+            accounts.add(bean);
+        }
+        return accounts;
+    }
+
+    /**
      * Get {@link UserAccount} by confirmation code.
      * @param inviteCode
      * @return

File encuestame-business/src/main/java/org/encuestame/business/service/TweetPollService.java

 import org.encuestame.utils.json.FolderBean;
 import org.encuestame.utils.json.LinksSocialBean;
 import org.encuestame.utils.json.QuestionBean;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollAnswerSwitchBean;
 import org.encuestame.utils.json.TweetPollBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.TweetPollResultsBean;
 import org.encuestame.utils.web.UnitTweetPollResult;
          if (socialAccount != null && tweetPoll != null) {
              log.debug("socialAccount Account NAME:{"+socialAccount.getSocialAccountName());
              //adding social account
-             publishedStatus.setTwitterAccount(socialAccount);
+             publishedStatus.setSocialAccount(socialAccount);
              try {
                  log.debug("publishTweetPoll Publishing... "+tweetText.length());
                  final TweetPublishedMetadata metadata = publicTweetPoll(tweetText, socialAccount);
           log.debug("getTweetPollLinks "+tweetPollSavedPublishedStatus.toString());
           final LinksSocialBean linksSocialBean = new LinksSocialBean();
             linksSocialBean.setProvider(tweetPollSavedPublishedStatus
-                    .getTwitterAccount().getAccounType().name());
+                    .getSocialAccount().getAccounType().name());
             linksSocialBean.setLink(SocialUtils.getSocialTweetPublishedUrl(
                     tweetPollSavedPublishedStatus.getTweetId(),
-                    tweetPollSavedPublishedStatus.getTwitterAccount()
+                    tweetPollSavedPublishedStatus.getSocialAccount()
                             .getSocialAccountName(),
-                    tweetPollSavedPublishedStatus.getTwitterAccount()
+                    tweetPollSavedPublishedStatus.getSocialAccount()
                             .getAccounType()));
           linksBean.add(linksSocialBean);
           log.debug("getTweetPollLinks "+linksSocialBean.toString());

File encuestame-business/src/main/java/org/encuestame/business/service/imp/ITweetPollService.java

 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.utils.json.FolderBean;
 import org.encuestame.utils.json.LinksSocialBean;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.TweetPollResultsBean;
 import org.encuestame.utils.web.UnitTweetPollResult;

File encuestame-business/src/main/java/org/encuestame/business/service/imp/SecurityOperations.java

 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.persistence.exception.IllegalSocialActionException;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.oauth.AccessGrant;
 import org.encuestame.utils.security.SignUpBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.social.SocialUserProfile;
 import org.encuestame.utils.web.UnitGroupBean;
 import org.encuestame.utils.web.UnitLists;
 
     /**
      * Get User Logged Verified Social Accounts.
-     * @param username username
+     * @param addStats add stats
      * @param socialProvider
      * @return
      * @throws EnMeNoResultsFoundException
      */
-    List<SocialAccountBean> getUserLoggedVerifiedSocialAccounts(
-            final SocialProvider socialProvider) throws EnMeNoResultsFoundException;
+    List<SocialAccountBean> getValidSocialAccounts(
+            final SocialProvider socialProvider,
+            final Boolean addStats) throws EnMeNoResultsFoundException;
 
     /**
      * Retrieve Total Own Users.

File encuestame-business/src/test/java/org/encuestame/test/business/service/TestTweetPollService.java

 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.test.business.service.config.AbstractServiceBase;
 import org.encuestame.utils.json.QuestionBean;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollBean;
 import org.encuestame.utils.json.QuestionPatternBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.TweetPollResultsBean;
 import org.encuestame.utils.web.UnitTweetPollResult;

File encuestame-core/src/main/java/org/encuestame/core/service/SocialOperations.java

 
 import org.encuestame.persistence.domain.social.SocialProvider;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
-import org.encuestame.utils.security.SocialAccountBean;
+import org.encuestame.utils.json.SocialAccountBean;
 
 
 /**

File encuestame-core/src/main/java/org/encuestame/core/util/ConvertDomainBean.java

 import org.encuestame.utils.DateUtil;
 import org.encuestame.utils.json.FolderBean;
 import org.encuestame.utils.json.QuestionBean;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollAnswerSwitchBean;
 import org.encuestame.utils.json.TweetPollBean;
 import org.encuestame.utils.json.QuestionPatternBean;
 import org.encuestame.utils.security.ProfileUserAccount;
 import org.encuestame.utils.security.SignUpBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.HashTagBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.TypeTreeNode;

File encuestame-core/src/main/java/org/encuestame/core/util/ConvertDomainToJson.java

         tweetResponse.textTweeted = savedPublishedStatus.getTweetContent();
         tweetResponse.statusTweet = savedPublishedStatus.getStatus().name();
         tweetResponse.statusDescriptionTweet = savedPublishedStatus.getDescriptionStatus();
-        tweetResponse.socialAccountId = savedPublishedStatus.getTwitterAccount().getId();
+        tweetResponse.socialAccountId = savedPublishedStatus.getSocialAccount().getId();
         tweetResponse.sourceTweet = savedPublishedStatus.getApiType().name();
         tweetResponse.tweetId = savedPublishedStatus.getTweetId();
         tweetResponse.tweetUrl = SocialUtils.getSocialTweetPublishedUrl(savedPublishedStatus.getTweetId(),
-                savedPublishedStatus.getTwitterAccount().getSocialAccountName(),
-                savedPublishedStatus.getTwitterAccount().getAccounType());
-        tweetResponse.socialAccountName = savedPublishedStatus.getTwitterAccount().getSocialAccountName();
+                savedPublishedStatus.getSocialAccount().getSocialAccountName(),
+                savedPublishedStatus.getSocialAccount().getAccounType());
+        tweetResponse.socialAccountName = savedPublishedStatus.getSocialAccount().getSocialAccountName();
         return tweetResponse;
     }
 }

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/survey/TweetPollJsonController.java

 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.utils.ShortUrlProvider;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/social/json/SocialAccountsJsonController.java

 import org.encuestame.persistence.domain.social.SocialProvider;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.IllegalSocialActionException;
-import org.encuestame.utils.security.SocialAccountBean;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import twitter4j.Twitter;
-import twitter4j.http.RequestToken;
-
 
 /**
  * Social Account Json Service.
     private Logger log = Logger.getLogger(this.getClass());
 
     /**
-     * Change state of social account.
+     * Change state / remove / disable / enable of social account.
      * @param type
      * @param socialAccountId
      * @param request
         return returnData();
     }
 
-    /**
-     * Return Social Valid Accounts.
-     * @param request
-     * @param response
-     * @param provider
-     * @return
-     * @throws JsonGenerationException
-     * @throws JsonMappingException
-     * @throws IOException
-     */
-    @PreAuthorize("hasRole('ENCUESTAME_USER')")
-    @RequestMapping(value = "/api/common/social/confirmed-accounts.json", method = RequestMethod.GET)
-    public ModelMap get(
-            HttpServletRequest request,
-            HttpServletResponse response,
-            @RequestParam(value = "provider", required = false) String provider)
-            throws JsonGenerationException, JsonMappingException, IOException {
-        try {
-           final List<SocialAccountBean> accounts = getSecurityService()
-                   .getUserLoggedVerifiedSocialAccounts(SocialProvider.getProvider(provider));
-             setItemReadStoreResponse("socialAccounts", "id", accounts);
-             log.debug("Twitter Accounts Loaded");
-        } catch (Exception e) {
-            log.error(e);
-            e.printStackTrace();
-            setError(e.getMessage(), response);
-        }
-        return returnData();
-    }
 
     /**
      * Return Social Valid Accounts.
             throws JsonGenerationException, JsonMappingException, IOException {
         try {
             final List<SocialAccountBean> accounts = getSecurityService()
-            .getUserLoggedVerifiedSocialAccounts(SocialProvider.getProvider(provider));
+                    .getValidSocialAccounts(
+                            SocialProvider.getProvider(provider), true);
             setItemReadStoreResponse("socialAccounts", "id", accounts);
-             log.debug("Twitter Accounts Loaded");
         } catch (Exception e) {
             log.error(e);
             e.printStackTrace();

File encuestame-mvc/src/test/java/org/encuestame/mvc/test/json/SocialAccountsJsonControllerTestCase.java

       @Before
       public void beforeSocialTest(){
           this.socialAccount = createDefaultSettedSocialAccount(getSpringSecurityLoggedUserAccount());
-          SocialAccount socialAccount2 = createSocialProviderAccount(getSpringSecurityLoggedUserAccount(), SocialProvider.TWITTER);
-      }
-
-      /**
-       *
-       * @throws ServletException
-       * @throws IOException
-       */
-      @Test
-      public void testLoadSocialConfirmedAccounts() throws ServletException, IOException{
-          initService("/api/common/social/confirmed-accounts.json", MethodJson.GET);
-          setParameter("provider", "twitter");
-          final org.json.simple.JSONObject response = callJsonService();
-          System.out.println(response);
-          //{"error":{},"success":{"items":[],"label":"socialAccounts","identifier":"id"}}
-          org.json.simple.JSONArray list = (org.json.simple.JSONArray) getSucess(response).get("items");
-          Assert.assertEquals(list.size(), 2);
+          createSocialProviderAccount(getSpringSecurityLoggedUserAccount(), SocialProvider.TWITTER);
       }
 
       /**

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IAccountDao.java

 package org.encuestame.persistence.dao;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 import org.encuestame.persistence.dao.imp.AccountDaoImp;
      * @return
      */
     List<UserAccount> getUserAccountsbyStatus(final Boolean status, final Date beforeDate, final Date afterDate);
+
+    /**
+     * Get social accounts stats.
+     * @param socialAccount {@link SocialAccount}.
+     * @return
+     */
+    HashMap<String, Long> getSocialAccountStats(final SocialAccount socialAccount);
 
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/AbstractSocialAccount.java

 package org.encuestame.persistence.dao.imp;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.Assert;
 import org.encuestame.persistence.domain.security.SocialAccount.TypeAuth;
 import org.encuestame.persistence.domain.security.UserAccount;
 import org.encuestame.persistence.domain.social.SocialProvider;
+import org.encuestame.persistence.domain.tweetpoll.TweetPollSavedPublishedStatus;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.utils.oauth.AccessGrant;
 import org.encuestame.utils.oauth.OAuth1Token;
 import org.encuestame.utils.social.SocialUserProfile;
 import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.dao.support.DataAccessUtils;
 
             final SocialProvider socialProvider,
             final String socialProfileId){
         final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
-        log.debug("accounType: "+socialProvider);
-        log.debug("socialProfileId: "+socialProfileId);
         criteria.add(Restrictions.eq("accounType", socialProvider));
         criteria.add(Restrictions.eq("socialProfileId", socialProfileId));
         return (SocialAccount) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
     public final SocialAccount getSocialAccount(
             final Long socialAccountId,
             final Account account){
-        log.debug("account "+account.getUid());
-        log.debug("socialAccountId "+socialAccountId);
         final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
         criteria.add(Restrictions.eq("account", account));
         criteria.add(Restrictions.eq("id", socialAccountId));
     public final SocialAccount getSocialAccount(
             final Long socialAccountId,
             final Account account,
-            final UserAccount userAccount){
-        log.debug("account "+account.getUid());
-        log.debug("socialAccountId "+socialAccountId);
+            final UserAccount userAccount) {
         final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
         criteria.add(Restrictions.eq("account", account));
         criteria.add(Restrictions.eq("userOwner", userAccount));
     @SuppressWarnings("unchecked")
     public final SocialAccount getSocialAccount(
             final Long socialProfileId,
-            final UserAccount userAccount){
-        log.debug("socialProfileId "+socialProfileId);
-        log.debug("userOwner "+userAccount.getUsername());
+            final UserAccount userAccount) {
         final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
         criteria.add(Restrictions.eq("userOwner", userAccount));
         criteria.add(Restrictions.eq("socialProfileId", socialProfileId));
     }
 
    /**
-    *
+    * Create new social account.
     * @param socialAccountId
     * @param token
     * @param tokenSecret
          return (SocialAccount) DataAccessUtils.uniqueResult(getHibernateTemplate()
                  .findByCriteria(criteria));
     }
+
+    /**
+     * Get social accounts stats.
+     * @param socialAccount {@link SocialAccount}.
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public HashMap<String, Long> getSocialAccountStats(final SocialAccount socialAccount) {
+        final HashMap<String, Long> stats = new HashMap<String, Long>();
+        log.debug("getSocialAccountStats "+socialAccount.getId());
+        final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPollSavedPublishedStatus.class);
+        criteria.add(Restrictions.eq("socialAccount", socialAccount));
+        criteria.setProjection(Projections.id());
+        final List<Long> tweetPollstats = getHibernateTemplate().findByCriteria(criteria);
+        log.debug("getSocialAccountStats "+tweetPollstats.size());
+        log.debug("getSocialAccountStats "+tweetPollstats);
+        if(tweetPollstats.size() > 0) {
+            stats.put("tweetpoll", Long.valueOf(tweetPollstats.get(0).toString()));
+        } else {
+            stats.put("tweetpoll", 0L);
+        }
+      //TODO: in the future we can add another stats.
+        stats.put("poll", 0L);
+        stats.put("survey", 0L);
+        log.debug("getSocialAccountStats stats"+stats);
+        return stats;
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/tweetpoll/TweetPollSavedPublishedStatus.java

     private Long id;
 
     /** {@link SocialAccount}. **/
-    private SocialAccount twitterAccount;
+    private SocialAccount socialAccount;
 
     /** {@link TweetPoll}. **/
     private TweetPoll tweetPoll;
      * @return the twitterAccount
      */
     @ManyToOne(cascade = CascadeType.MERGE)
-    public SocialAccount getTwitterAccount() {
-        return twitterAccount;
+    public SocialAccount getSocialAccount() {
+        return socialAccount;
     }
 
     /**
      * @param twitterAccount the twitterAccount to set
      */
-    public void setTwitterAccount(SocialAccount twitterAccount) {
-        this.twitterAccount = twitterAccount;
+    public void setSocialAccount(final SocialAccount socialAccount) {
+        this.socialAccount = socialAccount;
     }
 
     /**
     @Override
     public String toString() {
         return "TweetPollSavedPublishedStatus [id=" + id + ", socialAccount="
-                + twitterAccount.toString() + ", tweetPoll=" + tweetPoll.toString()
+                + socialAccount.toString() + ", tweetPoll=" + tweetPoll.toString()
                 + ", tweetContent=" + tweetContent + ", tweetId=" + tweetId
                 + ", apiType=" + apiType + ", status=" + status
                 + ", descriptionStatus=" + descriptionStatus

File encuestame-persistence/src/test/java/org/encuestame/test/config/AbstractBase.java

         publishedStatus.setTweetPoll(tweetPoll);
         publishedStatus.setStatus(org.encuestame.persistence.domain.tweetpoll.Status.SUCCESS);
         publishedStatus.setTweetContent(tweetText);
-        publishedStatus.setTwitterAccount(socialAccount);
+        publishedStatus.setSocialAccount(socialAccount);
         publishedStatus.setTweetId(RandomStringUtils.randomAlphabetic(18));
         publishedStatus.setPublicationDateTweet(new Date());
         getTweetPoll().saveOrUpdate(publishedStatus);

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestUserDao.java

 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 import org.encuestame.persistence.dao.imp.AccountDaoImp;
     }
 
     /**
+     *
+     */
+    @Test
+    public void testgetSocialAccountStats() {
+        createTweetPollPublicated(true, true, null, userAccount, createQuestion("test", this.userAccount.getAccount()));
+        createTweetPollSavedPublishedSTatus(tweetPoll, "12345", this.socialAccount, "hello encuestame");
+        final HashMap<String, Long> d = getAccountDao().getSocialAccountStats(this.socialAccount);
+    }
+
+    /**
      * Test get user account list by status.
      */
     @Test
         createdAt.add(Calendar.MONTH, +12);
         createUserAccount(Boolean.FALSE, createdAt.getTime() ,"user 4", this.account);
 
-        System.out.println("Current Date ------>"+  currentDate.getTime());
-        System.out.println("Account Value  property------>"+ beforeDate.getTime());
-
         final List<UserAccount> userAcc = getAccountDao().getUserAccountsbyStatus(Boolean.FALSE, beforeDate.getTime(), currentDate.getTime());
            //10 + 1 on @Before.
-        System.out.println("DisableUser Accounts size--->"+ userAcc.size());
         assertEquals("Should be equals", 5, userAcc.size());
            if(log.isDebugEnabled()){
                for (UserAccount userStatus : userAcc) {

File encuestame-utils/src/main/java/org/encuestame/utils/json/GlobalStats.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 encuestame: system online surveys Copyright (C) 2011
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.utils.json;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Global stats..
+ * @author Picado, Juan juanATencuestame.org
+ * @since 28/07/2011
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public abstract class GlobalStats {
+
+    @JsonProperty(value = "tweetpoll")
+    private Long tweetpoll;
+    @JsonProperty(value = "poll")
+    private Long poll;
+    @JsonProperty(value = "survey")
+    private Long survey;
+    /**
+     * @return the tweetpoll
+     */
+    @JsonIgnore
+    public Long getTweetpoll() {
+        return tweetpoll;
+    }
+    /**
+     * @param tweetpoll the tweetpoll to set
+     */
+    public void setTweetpoll(final Long tweetpoll) {
+        this.tweetpoll = tweetpoll;
+    }
+    /**
+     * @return the poll
+     */
+    @JsonIgnore
+    public Long getPoll() {
+        return poll;
+    }
+    /**
+     * @param poll the poll to set
+     */
+    public void setPoll(final Long poll) {
+        this.poll = poll;
+    }
+    /**
+     * @return the survey
+     */
+    @JsonIgnore
+    public Long getSurvey() {
+        return survey;
+    }
+    /**
+     * @param survey the survey to set
+     */
+    public void setSurvey(final Long survey) {
+        this.survey = survey;
+    }
+}

File encuestame-utils/src/main/java/org/encuestame/utils/json/SocialAccountBean.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.utils.json;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+
+/**
+ * Social Account Bean.
+ *
+ * @author Picado, Juan juanATencuestame.org
+ * @since Jun 26, 2010 5:15:12 PM
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class SocialAccountBean extends GlobalStats implements Serializable {
+
+    /**
+     * Serial.
+     */
+    private static final long serialVersionUID = 4250537795415299836L;
+
+    @JsonProperty(value = "id")
+    private Long accountId;
+
+    @JsonProperty(value = "account")
+    private String account;
+
+    @JsonProperty(value = "type")
+    private String type;
+
+    @JsonProperty(value = "type_account")
+    private String typeAccount;
+
+    @JsonProperty(value = "description")
+    private String  descriptionProfile;
+
+    @JsonProperty(value = "email")
+    private String  email;
+
+    @JsonProperty(value = "default_selected")
+    private Boolean  defaultSelected;
+
+    @JsonProperty(value = "date_created")
+    @JsonDeserialize(using = JsonDateDeserializer.class)
+    private Date addedAccount;
+
+    @JsonProperty(value = "picture_url")
+    private String prictureUrl;
+
+    @JsonProperty(value = "profile_picture_url")
+    private String  profilePictureUrl;
+
+    @JsonProperty(value = "profile_thumbnail_picture")
+    private String  profileThumbnailPictureUrl;
+
+    @JsonProperty(value = "real_name")
+    private String realName;
+
+    @JsonProperty(value = "social_username")
+    private String socialAccountName;
+
+    @JsonProperty(value = "url")
+    private String socialProfileUrl;
+
+    /**
+     * Constructor.
+     */
+    public SocialAccountBean() {
+    }
+
+
+    /**
+     * @param accountId the accountId to set
+     */
+    public void setAccountId(final Long accountId) {
+        this.accountId = accountId;
+    }
+
+
+    /**
+     * @param account the account to set
+     */
+    public void setAccount(final String account) {
+        this.account = account;
+    }
+
+
+    /**
+     * @param type the type to set
+     */
+    public void setType(final String type) {
+        this.type = type;
+    }
+
+
+    /**
+     * @param typeAccount the typeAccount to set
+     */
+    public void setTypeAccount(final String typeAccount) {
+        this.typeAccount = typeAccount;
+    }
+
+
+    /**
+     * @param descriptionProfile the descriptionProfile to set
+     */
+    public void setDescriptionProfile(final String descriptionProfile) {
+        this.descriptionProfile = descriptionProfile;
+    }
+
+
+    /**
+     * @param email the email to set
+     */
+    public void setEmail(final String email) {
+        this.email = email;
+    }
+
+
+    /**
+     * @param defaultSelected the defaultSelected to set
+     */
+    public void setDefaultSelected(final Boolean defaultSelected) {
+        this.defaultSelected = defaultSelected;
+    }
+
+
+    /**
+     * @param addedAccount the addedAccount to set
+     */
+    public void setAddedAccount(final Date addedAccount) {
+        this.addedAccount = addedAccount;
+    }
+
+
+    /**
+     * @param prictureUrl the prictureUrl to set
+     */
+    public void setPrictureUrl(final String prictureUrl) {
+        this.prictureUrl = prictureUrl;
+    }
+
+
+    /**
+     * @param profilePictureUrl the profilePictureUrl to set
+     */
+    public void setProfilePictureUrl(final String profilePictureUrl) {
+        this.profilePictureUrl = profilePictureUrl;
+    }
+
+
+    /**
+     * @param profileThumbnailPictureUrl the profileThumbnailPictureUrl to set
+     */
+    public void setProfileThumbnailPictureUrl(final String profileThumbnailPictureUrl) {
+        this.profileThumbnailPictureUrl = profileThumbnailPictureUrl;
+    }
+
+
+    /**
+     * @param realName the realName to set
+     */
+    public void setRealName(String realName) {
+        this.realName = realName;
+    }
+
+
+    /**
+     * @param socialAccountName the socialAccountName to set
+     */
+    public void setSocialAccountName(final String socialAccountName) {
+        this.socialAccountName = socialAccountName;
+    }
+
+
+    /**
+     * @return the accountId
+     */
+    @JsonIgnore
+    public Long getAccountId() {
+        return accountId;
+    }
+
+
+    /**
+     * @return the account
+     */
+    @JsonIgnore
+    public String getAccount() {
+        return account;
+    }
+
+
+    /**
+     * @return the type
+     */
+    @JsonIgnore
+    public String getType() {
+        return type;
+    }
+
+
+    /**
+     * @return the typeAccount
+     */
+    @JsonIgnore
+    public String getTypeAccount() {
+        return typeAccount;
+    }
+
+
+    /**
+     * @return the descriptionProfile
+     */
+     @JsonIgnore
+    public String getDescriptionProfile() {
+        return descriptionProfile;
+    }
+
+
+    /**
+     * @return the email
+     */
+    @JsonIgnore
+    public String getEmail() {
+        return email;
+    }
+
+
+    /**
+     * @return the defaultSelected
+     */
+    @JsonIgnore
+    public Boolean getDefaultSelected() {
+        return defaultSelected;
+    }
+
+
+    /**
+     * @return the addedAccount
+     */
+    @JsonIgnore
+    public Date getAddedAccount() {
+        return addedAccount;
+    }
+
+
+    /**
+     * @return the prictureUrl
+     */
+    @JsonIgnore
+    public String getPrictureUrl() {
+        return prictureUrl;
+    }
+
+
+    /**
+     * @return the profilePictureUrl
+     */
+    @JsonIgnore
+    public String getProfilePictureUrl() {
+        return profilePictureUrl;
+    }
+
+
+    /**
+     * @return the profileThumbnailPictureUrl
+     */
+    @JsonIgnore
+    public String getProfileThumbnailPictureUrl() {
+        return profileThumbnailPictureUrl;
+    }
+
+
+    /**
+     * @return the realName
+     */
+    @JsonIgnore
+    public String getRealName() {
+        return realName;
+    }
+
+
+    /**
+     * @return the socialAccountName
+     */
+    @JsonIgnore
+    public String getSocialAccountName() {
+        return socialAccountName;
+    }
+
+
+    /**
+     * @return the socialProfileUrl
+     */
+    public String getSocialProfileUrl() {
+        return socialProfileUrl;
+    }
+
+
+    /**
+     * @param socialProfileUrl the socialProfileUrl to set
+     */
+    public void setSocialProfileUrl(final String socialProfileUrl) {
+        this.socialProfileUrl = socialProfileUrl;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "SocialAccountBean [accountId=" + accountId + ", account="
+                + account + ", type=" + type + ", typeAccount=" + typeAccount
+                + ", descriptionProfile=" + descriptionProfile + ", email="
+                + email + ", defaultSelected=" + defaultSelected
+                + ", addedAccount=" + addedAccount + ", prictureUrl="
+                + prictureUrl + ", profilePictureUrl=" + profilePictureUrl
+                + ", profileThumbnailPictureUrl=" + profileThumbnailPictureUrl
+                + ", realName=" + realName + ", socialAccountName="
+                + socialAccountName + ", socialProfileUrl=" + socialProfileUrl
+                + "]";
+    }
+}

File encuestame-utils/src/main/java/org/encuestame/utils/security/SocialAccountBean.java

-/*
- ************************************************************************************
- * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
- * encuestame Development Team.
- * Licensed under the Apache Software License version 2.0
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to  in writing,  software  distributed
- * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
- * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
- * specific language governing permissions and limitations under the License.
- ************************************************************************************
- */
-package org.encuestame.utils.security;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
-import org.encuestame.utils.json.JsonDateDeserializer;
-
-/**
- * Social Account Bean.
- *
- * @author Picado, Juan juanATencuestame.org
- * @since Jun 26, 2010 5:15:12 PM
- */
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class SocialAccountBean implements Serializable {
-
-    /**
-     * Serial.
-     */
-    private static final long serialVersionUID = 4250537795415299836L;
-
-    @JsonProperty(value = "id")
-    private Long accountId;
-
-    @JsonProperty(value = "account")
-    private String account;
-
-    @JsonProperty(value = "type")
-    private String type;
-
-    @JsonProperty(value = "type_account")
-    private String typeAccount;
-
-    @JsonProperty(value = "description")
-    private String  descriptionProfile;
-
-    @JsonProperty(value = "email")
-    private String  email;
-
-    @JsonProperty(value = "default_selected")
-    private Boolean  defaultSelected;
-
-    @JsonProperty(value = "date_created")
-    @JsonDeserialize(using = JsonDateDeserializer.class)
-    private Date addedAccount;
-
-    @JsonProperty(value = "picture_url")
-    private String prictureUrl;
-
-    @JsonProperty(value = "profile_picture_url")
-    private String  profilePictureUrl;
-
-    @JsonProperty(value = "profile_thumbnail_picture")
-    private String  profileThumbnailPictureUrl;
-
-    @JsonProperty(value = "real_name")
-    private String realName;
-
-    @JsonProperty(value = "social_username")
-    private String socialAccountName;
-
-    @JsonProperty(value = "url")
-    private String socialProfileUrl;
-
-    /**
-     * Constructor.
-     */
-    public SocialAccountBean() {
-    }
-
-
-    /**
-     * @param accountId the accountId to set
-     */
-    public void setAccountId(final Long accountId) {
-        this.accountId = accountId;
-    }
-
-
-    /**
-     * @param account the account to set
-     */
-    public void setAccount(final String account) {
-        this.account = account;
-    }
-
-
-    /**
-     * @param type the type to set
-     */
-    public void setType(final String type) {
-        this.type = type;
-    }
-
-
-    /**
-     * @param typeAccount the typeAccount to set
-     */
-    public void setTypeAccount(final String typeAccount) {
-        this.typeAccount = typeAccount;
-    }
-
-
-    /**
-     * @param descriptionProfile the descriptionProfile to set
-     */
-    public void setDescriptionProfile(final String descriptionProfile) {
-        this.descriptionProfile = descriptionProfile;
-    }
-
-
-    /**
-     * @param email the email to set
-     */
-    public void setEmail(final String email) {
-        this.email = email;
-    }
-
-
-    /**
-     * @param defaultSelected the defaultSelected to set
-     */
-    public void setDefaultSelected(final Boolean defaultSelected) {
-        this.defaultSelected = defaultSelected;
-    }
-
-
-    /**
-     * @param addedAccount the addedAccount to set
-     */
-    public void setAddedAccount(final Date addedAccount) {
-        this.addedAccount = addedAccount;
-    }
-
-
-    /**
-     * @param prictureUrl the prictureUrl to set
-     */
-    public void setPrictureUrl(final String prictureUrl) {
-        this.prictureUrl = prictureUrl;
-    }
-
-
-    /**
-     * @param profilePictureUrl the profilePictureUrl to set
-     */
-    public void setProfilePictureUrl(final String profilePictureUrl) {
-        this.profilePictureUrl = profilePictureUrl;
-    }
-
-
-    /**
-     * @param profileThumbnailPictureUrl the profileThumbnailPictureUrl to set
-     */
-    public void setProfileThumbnailPictureUrl(final String profileThumbnailPictureUrl) {
-        this.profileThumbnailPictureUrl = profileThumbnailPictureUrl;
-    }
-
-
-    /**
-     * @param realName the realName to set
-     */
-    public void setRealName(String realName) {
-        this.realName = realName;
-    }
-
-
-    /**
-     * @param socialAccountName the socialAccountName to set
-     */
-    public void setSocialAccountName(final String socialAccountName) {
-        this.socialAccountName = socialAccountName;
-    }
-
-
-    /**
-     * @return the accountId
-     */
-    @JsonIgnore
-    public Long getAccountId() {
-        return accountId;
-    }
-
-
-    /**
-     * @return the account
-     */
-    @JsonIgnore
-    public String getAccount() {
-        return account;
-    }
-
-
-    /**
-     * @return the type
-     */
-    @JsonIgnore
-    public String getType() {
-        return type;
-    }
-
-
-    /**
-     * @return the typeAccount
-     */
-    @JsonIgnore
-    public String getTypeAccount() {
-        return typeAccount;
-    }
-
-
-    /**
-     * @return the descriptionProfile
-     */
-     @JsonIgnore
-    public String getDescriptionProfile() {
-        return descriptionProfile;
-    }
-
-
-    /**
-     * @return the email
-     */
-    @JsonIgnore
-    public String getEmail() {
-        return email;
-    }
-
-
-    /**
-     * @return the defaultSelected
-     */
-    @JsonIgnore
-    public Boolean getDefaultSelected() {
-        return defaultSelected;
-    }
-
-
-    /**
-     * @return the addedAccount
-     */
-    @JsonIgnore
-    public Date getAddedAccount() {
-        return addedAccount;
-    }
-
-
-    /**
-     * @return the prictureUrl
-     */
-    @JsonIgnore
-    public String getPrictureUrl() {
-        return prictureUrl;
-    }
-
-
-    /**
-     * @return the profilePictureUrl
-     */
-    @JsonIgnore
-    public String getProfilePictureUrl() {
-        return profilePictureUrl;
-    }
-
-
-    /**
-     * @return the profileThumbnailPictureUrl
-     */
-    @JsonIgnore
-    public String getProfileThumbnailPictureUrl() {
-        return profileThumbnailPictureUrl;
-    }
-
-
-    /**
-     * @return the realName
-     */
-    @JsonIgnore
-    public String getRealName() {
-        return realName;
-    }
-
-
-    /**
-     * @return the socialAccountName
-     */
-    @JsonIgnore
-    public String getSocialAccountName() {
-        return socialAccountName;
-    }
-
-
-    /**
-     * @return the socialProfileUrl
-     */
-    public String getSocialProfileUrl() {
-        return socialProfileUrl;
-    }
-
-
-    /**
-     * @param socialProfileUrl the socialProfileUrl to set
-     */
-    public void setSocialProfileUrl(final String socialProfileUrl) {
-        this.socialProfileUrl = socialProfileUrl;
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "SocialAccountBean [accountId=" + accountId + ", account="
-                + account + ", type=" + type + ", typeAccount=" + typeAccount
-                + ", descriptionProfile=" + descriptionProfile + ", email="
-                + email + ", defaultSelected=" + defaultSelected
-                + ", addedAccount=" + addedAccount + ", prictureUrl="
-                + prictureUrl + ", profilePictureUrl=" + profilePictureUrl
-                + ", profileThumbnailPictureUrl=" + profileThumbnailPictureUrl
-                + ", realName=" + realName + ", socialAccountName="
-                + socialAccountName + ", socialProfileUrl=" + socialProfileUrl
-                + "]";
-    }
-}

File encuestame-utils/src/test/java/org/encuestame/utils/TestUnitBeans.java

 
 import org.encuestame.utils.json.QuestionBean;
 import org.encuestame.utils.json.ResumeResultTweetPoll;
+import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.json.TweetPollBean;
 import org.encuestame.utils.json.QuestionPatternBean;
 import org.encuestame.utils.mail.InvitationBean;
 import org.encuestame.utils.oauth.StandardOAuthSession;
 import org.encuestame.utils.security.SignUpBean;
 import org.encuestame.utils.security.ForgotPasswordBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.vote.UtilVoteCaptcha;
 import org.encuestame.utils.web.TypeTreeNode;
 import org.encuestame.utils.web.QuestionAnswerBean;

File encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons.js

 encuestame.service.list.removePermission = encuestame.contextWidget()+"/api/admon/remove-permission.json";
 encuestame.service.list.hashtags = encuestame.contextWidget()+"/api/common/hashtags.json";
 encuestame.service.list.cloud = encuestame.contextWidget()+"/api/common/hashtags/cloud.json";
-//TODO: replace twitter encuestame.service.list.socialAccounts
-encuestame.service.list.socialAccounts = encuestame.contextWidget()+"/api/common/social/confirmed-accounts.json";
 encuestame.service.list.allSocialAccount = encuestame.contextWidget()+"/api/common/social/accounts.json";
 
 //tweetpoll service

File encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons/social/SocialAccountPicker.js

                 console.debug("error", error);
             };
             encuestame.service.xhrGet(
-                    encuestame.service.list.socialAccounts, {}, load, error);
+                    encuestame.service.list.allSocialAccount, {}, load, error);
        },
 
        /*