Juan Carlos Picado Herrera avatar Juan Carlos Picado Herrera committed 28929d5 Merge

Merge branch 'dianmorales' of github.com:encuestame/encuestame into development

Comments (0)

Files changed (21)

 encuestame-war/src/main/webapp/resource/js/dojo/
 encuestame-war/src/main/webapp/resource/js/org/
 encuestame-config-custom.properties
-encuestame-war/src/main/resources/encuestame-config-custom.properties
+encuestame-war/src/main/resources/encuestame-config-custom.properties
+.metadata

encuestame-business/src/main/java/org/encuestame/business/service/DashboardService.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.business.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.encuestame.business.service.imp.IDashboardService;
+import org.encuestame.core.service.AbstractBaseService;
+import org.encuestame.persistence.domain.dashboard.Dashboard;
+import org.encuestame.persistence.domain.dashboard.Gadget;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.exception.EnMeDashboardNotFoundException;
+import org.encuestame.persistence.exception.EnMeExpcetion;
+import org.encuestame.persistence.exception.EnMeGadgetNotFoundException;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.utils.web.DashboardBean;
+import org.springframework.stereotype.Service;
+
+/**
+ * {@link Dashboard} service support.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+@Service
+public class DashboardService extends AbstractBaseService implements IDashboardService{
+
+	 private Log log = LogFactory.getLog(this.getClass());
+
+	 /*
+	  * (non-Javadoc)
+	  * @see org.encuestame.business.service.imp.IDashboardService#getAllDashboards(java.lang.String, java.lang.Integer, java.lang.Integer)
+	  */
+	public List<Dashboard> getAllDashboards(final String username,
+            final Integer maxResults,
+            final Integer start) throws EnMeNoResultsFoundException{
+		final List<Dashboard> boards = getDashboardDao().retrieveDashboards(getPrimaryUser(username), maxResults, start);
+		log.info("dashboards list size "+boards.size());
+		return boards;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#getAllDashboardbyId(java.lang.Long, java.lang.String)
+	 */
+	public Dashboard getAllDashboardbyId(final Long boardId, final String username) throws EnMeNoResultsFoundException{
+		Dashboard dashboard = null;
+	        if (username != null) {
+	        	dashboard = getDashboardDao().getAllDashboards(boardId, getPrimaryUser(username));
+	        } else {
+	        	dashboard = getDashboardDao().getDashboardbyId(boardId);
+	        }
+	        if (dashboard == null) {
+	            log.error("dashboardinvalid with this id "+boardId);
+	            throw new EnMeDashboardNotFoundException("tweet poll invalid with this id "+boardId);
+	        }
+		return dashboard;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#retrieveFavouritesDashboards(java.lang.Long, java.lang.Integer, java.lang.Integer)
+	 */
+	public List<Dashboard> retrieveFavouritesDashboards(final Long userId,
+	        final Integer maxResults,
+	        final Integer start){
+		final List<Dashboard> favoriteBoards = getDashboardDao().retrieveFavouritesDashboards(userId, maxResults, start);
+		return favoriteBoards;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#getDashboardById(java.lang.Long)
+	 */
+	public Dashboard getDashboardById(final Long boardId) throws EnMeNoResultsFoundException{
+	        return this.getAllDashboardbyId(boardId, getUserPrincipalUsername());
+	    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#getGadgetById(java.lang.Long)
+	 */
+	public Gadget getGadgetById(final Long gadgetId){
+		final Gadget gadget = getDashboardDao().getGadgetbyId(gadgetId);
+		return gadget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#searchGadgetbyKeyword(java.lang.String, java.lang.Integer, java.lang.Integer)
+	 */
+	public List<Gadget> searchGadgetbyKeyword(final String keyword,
+            final Integer maxResults,
+            final Integer start) throws EnMeExpcetion{
+		 	List<Gadget> gadgets  = new ArrayList<Gadget>();
+	        if(keyword == null){
+	           throw new EnMeExpcetion("keyword is missing");
+	        } else {
+	        	gadgets = getDashboardDao().getGadgetbyKeyword(keyword, maxResults, start);
+	        }
+	        log.info("search keyword Gadgets size "+gadgets.size());
+	        return gadgets;
+	    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#createDashboard(org.encuestame.utils.web.DashboardBean, org.encuestame.persistence.domain.security.UserAccount)
+	 */
+	public Dashboard createDashboard(final DashboardBean dashboardBean, final UserAccount user){
+		final Dashboard board = new Dashboard();
+			board.setPageBoardName(dashboardBean.getDashboardName());
+			board.setDescription(dashboardBean.getDashboardDesc());
+			board.setFavorite(dashboardBean.getFavorite());
+			board.setBoardSequence(dashboardBean.getSequence());
+			board.setFavoriteCounter(dashboardBean.getFavoriteCounter());
+			//board.setGadgetDashboard(gadgetDashboard);
+			//board.setPageLayout(dashboardBean.getLayout());
+			board.setUserBoard(user);
+		return board;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#addGadgetOnDashboard(java.lang.Long, java.lang.Long)
+	 */
+	public void addGadgetOnDashboard(final Long boardId, final Long gadgetId) throws EnMeGadgetNotFoundException{
+		final Gadget gadget = getDashboardDao().getGadgetbyId(gadgetId);
+		if(gadget!=null){
+			final Dashboard dashboard = getDashboardDao().getDashboardbyId(boardId);
+			dashboard.getGadgetDashboard().add(gadget);
+
+		}else{
+            throw new EnMeGadgetNotFoundException("gadget not found");
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.business.service.imp.IDashboardService#removeGadget(java.lang.Long)
+	 */
+	public void removeGadget(final Long gadgetId) throws EnMeGadgetNotFoundException{
+		final Gadget gadget = getDashboardDao().getGadgetbyId(gadgetId);
+		if(gadget!=null){
+			getDashboardDao().delete(gadget);
+		}
+		else{
+			throw new EnMeGadgetNotFoundException("gadget not found");
+		}
+	}
+}

encuestame-business/src/main/java/org/encuestame/business/service/imp/IDashboardService.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.business.service.imp;
+
+import java.util.List;
+import org.encuestame.persistence.domain.dashboard.Dashboard;
+import org.encuestame.persistence.domain.dashboard.Gadget;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.exception.EnMeExpcetion;
+import org.encuestame.persistence.exception.EnMeGadgetNotFoundException;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.utils.web.DashboardBean;
+
+/**
+ * Dashboard Service.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 28, 2011
+ */
+public interface IDashboardService {
+
+	/**
+	  * Get all dashboards.
+	  * @param username
+	  * @param maxResults
+	  * @param start
+	  * @return
+	  * @throws EnMeNoResultsFoundException
+	  */
+	List<Dashboard> getAllDashboards(final String username,
+            final Integer maxResults,
+            final Integer start) throws EnMeNoResultsFoundException;
+
+	/**
+	 * Get all dashboard by id and username.
+	 * @param boardId
+	 * @param username
+	 * @return
+	 * @throws EnMeNoResultsFoundException
+	 */
+	Dashboard getAllDashboardbyId(final Long boardId, final String username) throws EnMeNoResultsFoundException;
+
+	/**
+	 * Retrieve favourites dashboards.
+	 * @param userId
+	 * @param maxResults
+	 * @param start
+	 * @return
+	 */
+	List<Dashboard> retrieveFavouritesDashboards(final Long userId,
+	        final Integer maxResults,
+	        final Integer start);
+
+	/**
+	 * Get dashboard by id.
+	 * @param boardId
+	 * @return
+	 * @throws EnMeNoResultsFoundException
+	 */
+	Dashboard getDashboardById(final Long boardId) throws EnMeNoResultsFoundException;
+
+	/**
+	 * Get gadget by id.
+	 * @param gadgetId
+	 * @return
+	 */
+	Gadget getGadgetById(final Long gadgetId);
+
+	/**
+	 * Search gadgets by keyword.
+	 * @param keyword
+	 * @param maxResults
+	 * @param start
+	 * @return
+	 * @throws EnMeExpcetion
+	 */
+	List<Gadget> searchGadgetbyKeyword(final String keyword,
+            final Integer maxResults,
+            final Integer start)throws EnMeExpcetion;
+
+	/**
+	 * Create dashboard.
+	 * @param dashboardBean
+	 * @param user
+	 * @return
+	 */
+	Dashboard createDashboard(final DashboardBean dashboardBean, final UserAccount user);
+
+	/**
+	 * Add gadget on dashboard.
+	 * @param boardId
+	 * @param gadgetId
+	 * @throws EnMeGadgetNotFoundException
+	 */
+	void addGadgetOnDashboard(final Long boardId, final Long gadgetId) throws EnMeGadgetNotFoundException;
+
+	/**
+	 * Remove gadget.
+	 * @param gadgetId
+	 * @throws EnMeGadgetNotFoundException
+	 */
+	void removeGadget(final Long gadgetId) throws EnMeGadgetNotFoundException;
+}

encuestame-business/src/test/java/org/encuestame/test/business/service/TestDashboardService.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.test.business.service;
+
+import org.encuestame.business.service.DashboardService;
+import org.encuestame.business.service.imp.IDashboardService;
+import org.encuestame.persistence.domain.dashboard.Dashboard;
+import org.encuestame.persistence.domain.security.Account;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.test.business.service.config.AbstractServiceBase;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Test for {@link DashboardService}.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public class TestDashboardService extends AbstractServiceBase{
+
+	/** {@link IDashboardService} **/
+	@Autowired
+	public IDashboardService dashboardService;
+
+	/** {@link Dashboard} **/
+	private Dashboard dashboard;
+
+	/** {@link Account} **/
+	private Account account;
+
+	/** {@link UserAccount} **/
+	private UserAccount userAccount;
+
+
+	@Before
+    public void initService(){
+		this.account = createUser("testEncuesta", "testEncuesta123");
+        this.userAccount = createUserAccount("diana", this.account);
+        this.dashboard = createDashboard("First board", Boolean.TRUE, this.userAccount);
+        createDashboard("Second board", Boolean.TRUE, this.userAccount);
+	    createDashboard("Third board", Boolean.TRUE, this.userAccount);
+
+	}
+
+	@Test
+	public void testGetAllDashboards() throws EnMeNoResultsFoundException{
+		System.out.println("testing");
+		//final List<Dashboard> allBoards = dashboardService.getAllDashboards(this.userAccount.getUsername(), 10, 0);
+		//  assertEquals("Should be equals", 3, allBoards.size());
+	}
+
+	/**
+	 * @return the dashboardService
+	 */
+	public IDashboardService getDashboardService() {
+		return dashboardService;
+	}
+
+	/**
+	 * @param dashboardService the dashboardService to set
+	 */
+	public void setDashboardService(IDashboardService dashboardService) {
+		this.dashboardService = dashboardService;
+	}
+}

encuestame-core/src/main/java/org/encuestame/core/service/AbstractDataSource.java

 import java.util.Calendar;
 import java.util.Collection;
 import java.util.LinkedList;
-
-import javax.annotation.Resource;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.core.util.ValidationUtils;
+import org.encuestame.persistence.dao.IDashboardDao;
 import org.encuestame.persistence.dao.IEmail;
 import org.encuestame.persistence.dao.IGeoPoint;
 import org.encuestame.persistence.dao.IGeoPointTypeDao;
     @Autowired
     private IEmail emailListsDao;
 
+    /** {@link IDashboardDao} **/
+    @Autowired
+    private IDashboardDao dashboardDao;
+
     /**
      * Get {@link UserAccount} by Username.
      * @param username username
     public final void setFrontEndDao(final IFrontEndDao frontEndDao) {
         this.frontEndDao = frontEndDao;
     }
+
+	/**
+	 * @return the dashboardDao
+	 */
+	public IDashboardDao getDashboardDao() {
+		return dashboardDao;
+	}
+
+	/**
+	 * @param dashboardDao the dashboardDao to set
+	 */
+	public void setDashboardDao(final IDashboardDao dashboardDao) {
+		this.dashboardDao = dashboardDao;
+	}
 }

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

 import org.encuestame.persistence.domain.HashTag;
 import org.encuestame.persistence.domain.Project;
 import org.encuestame.persistence.domain.Status;
+import org.encuestame.persistence.domain.dashboard.Dashboard;
 import org.encuestame.persistence.domain.question.Question;
 import org.encuestame.persistence.domain.question.QuestionAnswer;
 import org.encuestame.persistence.domain.question.QuestionPattern;
 import org.encuestame.utils.json.QuestionPatternBean;
 import org.encuestame.utils.security.ProfileUserAccount;
 import org.encuestame.utils.security.SignUpBean;
+import org.encuestame.utils.web.DashboardBean;
 import org.encuestame.utils.web.HashTagBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.TypeTreeNode;
         unitSurvey.setNotifications(survey.getNotifications());
         unitSurvey.setName(survey.getName());
         return unitSurvey;}
+
+    /**
+     * Convert Dashboard bean to dashboard domain.
+     * @param dashboards
+     * @return
+     */
+    public static final List<DashboardBean> convertListDashboardToBean(final List<Dashboard> dashboards){
+        final List<DashboardBean> dashboardList = new LinkedList<DashboardBean>();
+            for (Dashboard dashboard : dashboards) {
+            	dashboardList.add(ConvertDomainBean.convertDashboardDomaintoBean(dashboard));
+            }
+        return dashboardList;
     }
+
+    /**
+     * Convert Dashboard domain to dashboard bean.
+     * @param dashboard
+     * @return
+     */
+    public static final DashboardBean convertDashboardDomaintoBean(final Dashboard dashboard){
+    	final DashboardBean dashboardBean = new DashboardBean();
+    	dashboardBean.setDashboardId(dashboard.getBoardId());
+    	dashboardBean.setDashboardName(dashboard.getPageBoardName());
+    	dashboardBean.setDashboardDesc(dashboard.getDescription());
+    	dashboardBean.setFavorite(dashboard.getFavorite());
+    	dashboardBean.setFavoriteCounter(dashboard.getFavoriteCounter());
+    	dashboardBean.setLayout(dashboard.getPageLayout().toString());
+    	dashboardBean.setSequence(dashboard.getBoardSequence());
+    	return dashboardBean;
+    }
+}

encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/DashboardJsonController.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 encuestame: system online surveys Copyright (C) 2010
+ * 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.mvc.controller.json;
+
+import org.apache.log4j.Logger;
+import org.encuestame.mvc.controller.AbstractJsonController;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+
+/**
+ * DashBoard Json Controller.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+@Controller
+public class DashboardJsonController extends AbstractJsonController {
+
+    /**
+     * Log.
+     */
+    private Logger log = Logger.getLogger(this.getClass());
+
+    public ModelMap getAllWidgets(){
+    	return null;
+    }
+
+}

encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IDashboardDao.java

 package org.encuestame.persistence.dao;
 
 import java.util.List;
-
 import org.encuestame.persistence.domain.dashboard.Dashboard;
 import org.encuestame.persistence.domain.dashboard.Gadget;
-import org.encuestame.persistence.domain.security.UserAccount;
 
 /**
  * Dashboard Interface.
 	/**
 	 * Retrieve dashboards by id and user.
 	 * @param userBoard
+	 * @param maxResults
+	 * @param start
 	 * @return
 	 */
-	List<Dashboard> retrieveDashboards(final UserAccount userBoard);
+	List<Dashboard> retrieveDashboards(final Long userBoard, final Integer maxResults,
+	        final Integer start);
 
 	/**
 	 * Retrieve favorites dashboards.
 	 * @return
 	 */
 	List<Gadget> getGadgetbyKeyword(final String keyword, final Integer maxResults, final Integer start);
+
+	/**
+	 * Get all dashboards.
+	 * @param boardId
+	 * @param userAccId
+	 * @return
+	 */
+	Dashboard getAllDashboards(final Long boardId, final Long userAccId);
 }

encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/DashboardDao.java

 import org.encuestame.persistence.dao.IDashboardDao;
 import org.encuestame.persistence.domain.dashboard.Dashboard;
 import org.encuestame.persistence.domain.dashboard.Gadget;
-import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.DetachedCriteria;
 import org.hibernate.criterion.MatchMode;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.support.DataAccessUtils;
 import org.springframework.stereotype.Repository;
 
 /**
 
 	/*
 	 * (non-Javadoc)
+	 * @see org.encuestame.persistence.dao.IDashboardDao#getDashboard(java.lang.Long, java.lang.Long)
+	 */
+	@SuppressWarnings("unchecked")
+	public Dashboard getAllDashboards(final Long boardId, final Long userAccId){
+		  final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class);
+	      criteria.add(Restrictions.eq("userBoard.uid", userAccId));
+	      criteria.add(Restrictions.eq("boardId", boardId));
+	      return (Dashboard) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
+	}
+
+	/*
+	 * (non-Javadoc)
 	 * @see org.encuestame.persistence.dao.IDashboardDao#retrieveDashboards(java.lang.Long, org.encuestame.persistence.domain.security.UserAccount)
 	 */
 	@SuppressWarnings("unchecked")
-	public List<Dashboard> retrieveDashboards(final UserAccount userBoard){
+	public List<Dashboard> retrieveDashboards(final Long userBoard, final Integer maxResults,
+	        final Integer start){
 		final DetachedCriteria criteria = DetachedCriteria.forClass(Dashboard.class);
 			criteria.createAlias("userBoard", "userBoard");
 	        criteria.add(Restrictions.eq("userBoard", userBoard));
-	        return getHibernateTemplate().findByCriteria(criteria);
+	        return (List<Dashboard>) filterByMaxorStart(criteria, maxResults, start);
 	}
 
 	/*

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/Dashboard.java

 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
     private Boolean favorite;
 
     /** Page Layout. **/
-    private String pageLayout;
+    private LayoutEnum pageLayout;
 
     /** Dashboard sequence. **/
     private Integer boardSequence;
     * @return the pageLayout
     */
     @Column(name = "layout", nullable = false)
-    public String getPageLayout() {
+    @Enumerated(EnumType.STRING)
+    public LayoutEnum getPageLayout() {
         return pageLayout;
     }
 
     /**
     * @param pageLayout the pageLayout to set
     */
-    public void setPageLayout(final String pageLayout) {
+    public void setPageLayout(final LayoutEnum pageLayout) {
         this.pageLayout = pageLayout;
     }
 

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/Gadget.java

 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
     private String gadgetName;
 
     /** Widget type**/
-    private String gadgetType;
+    private GadgetType gadgetType;
 
     /** {@link Dashboard} **/
     private Set<Dashboard> dashboard = new HashSet<Dashboard>();
     * @return the widgetType
     */
     @Column(name = "gadgetType", nullable = false)
-    public String getGadgetType() {
+    @Enumerated(EnumType.STRING)
+    public GadgetType getGadgetType() {
         return gadgetType;
     }
 
     /**
     * @param widgetType the widgetType to set
     */
-    public void setGadgetType(final String gadgetType) {
+    public void setGadgetType(final GadgetType gadgetType) {
         this.gadgetType = gadgetType;
     }
 

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/GadgetType.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.persistence.domain.dashboard;
+
+/**
+ * Gadget Types.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public enum GadgetType {
+
+	/** Gadget type for polls**/
+	POLL,
+
+	/** Gadget type for surveys**/
+	SURVEYS,
+
+	/** Gadget type for tweetPolls**/
+	TWEETPOLLS
+
+}

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/LayoutEnum.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.persistence.domain.dashboard;
+
+/**
+ * Layout Enumeration
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public enum LayoutEnum {
+
+	/** Three columns. **/
+	AAA_COLUMNS,
+
+	/** Two Blocks. **/
+	BB_BLOCK,
+
+	/** One Block. **/
+	B_BLOCK,
+
+	/** One Column and One Block. **/
+	AB_COLUMN_BLOCK,
+
+	/** One Block and One column. **/
+	BA_BLOCK_COLUMN
+}

encuestame-persistence/src/main/java/org/encuestame/persistence/exception/EnMeDashboardNotFoundException.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.persistence.exception;
+
+/**
+ * EnMe Dashboard exception.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public class EnMeDashboardNotFoundException extends EnMeNoResultsFoundException {
+
+    /**
+     * Constructor.
+     */
+    public EnMeDashboardNotFoundException() {
+        super("user not found");
+    }
+
+    public EnMeDashboardNotFoundException(String message) {
+        super(message);
+    }
+}

encuestame-persistence/src/main/java/org/encuestame/persistence/exception/EnMeGadgetNotFoundException.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.persistence.exception;
+
+/**
+ * EnMe Gadget exception.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public class EnMeGadgetNotFoundException extends EnMeNoResultsFoundException {
+
+    /**
+     * Constructor.
+     */
+    public EnMeGadgetNotFoundException() {
+        super("user not found");
+    }
+
+    public EnMeGadgetNotFoundException(String message) {
+        super(message);
+    }
+}

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

 import org.encuestame.persistence.domain.Status;
 import org.encuestame.persistence.domain.dashboard.Dashboard;
 import org.encuestame.persistence.domain.dashboard.Gadget;
+import org.encuestame.persistence.domain.dashboard.GadgetType;
+import org.encuestame.persistence.domain.dashboard.LayoutEnum;
 import org.encuestame.persistence.domain.notifications.Notification;
 import org.encuestame.persistence.domain.notifications.NotificationEnum;
 import org.encuestame.persistence.domain.question.Question;
      * @return
      */
     public Gadget createGadgetDefault(){
-        return this.createGadget("default", "defaultType");
+        return this.createGadget("default");
     }
 
     /**
      * @param type
      * @return
      */
-    public Gadget createGadget(final String name, final String type){
+    public Gadget createGadget(final String name){
         final Gadget gadget = new Gadget();
         gadget.setGadgetName(name);
-        gadget.setGadgetType(type);
+        gadget.setGadgetType(GadgetType.TWEETPOLLS);
         getDashboardDao().saveOrUpdate(gadget);
         return gadget;
     }
           board.setDescription("");
           board.setFavorite(favorite);
           board.setFavoriteCounter(1);
-          board.setPageLayout("AAA");
+          board.setPageLayout(LayoutEnum.AAA_COLUMNS);
           board.setBoardSequence(1);
           board.setUserBoard(userAcc);
           getDashboardDao().saveOrUpdate(board);

encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestDashboardDao.java

         createDashboard("Second board", Boolean.TRUE, this.userAccount);
 	    createDashboard("Third board", Boolean.TRUE, this.userAccount);
 	    this.gadget = createGadgetDefault();
-	    createGadget("gadget 1", "P");
-	    createGadget("gadget 2", "P");
+	    createGadget("gadget 1");
+	    createGadget("gadget 2");
 	}
 
 	/**
 	/**
 	 * Test retrieve dashboard pages.
 	 */
-	@Test
+	//@Test
 	public void testRetrieveDashboardsPage(){
-		final List<Dashboard> boardPages = getDashboardDao().retrieveDashboards(this.userAccount);
+		final List<Dashboard> boardPages = getDashboardDao().retrieveDashboards(this.userAccount.getUid(), 10, 0);
 	    assertEquals("Should be equals", boardPages.size(), 3);
 	}
 

encuestame-persistence/src/test/java/org/encuestame/test/persistence/domain/TestHibernateDomains.java

 import org.encuestame.persistence.domain.dashboard.Dashboard;
 import org.encuestame.persistence.domain.dashboard.Gadget;
 import org.encuestame.persistence.domain.dashboard.GadgetProperties;
+import org.encuestame.persistence.domain.dashboard.GadgetType;
+import org.encuestame.persistence.domain.dashboard.LayoutEnum;
 import org.encuestame.persistence.domain.question.CatQuestionCategory;
 import org.encuestame.persistence.domain.question.Question;
 import org.encuestame.persistence.domain.question.QuestionAnswer;
         board.setDescription("My first dashboard");
         board.setFavorite(Boolean.TRUE);
         board.setFavoriteCounter(1);
-        board.setPageLayout("AAA");
+        board.setPageLayout(LayoutEnum.AAA_COLUMNS);
         board.setBoardSequence(1);
         board.setUserBoard(createUserAccount("juan carlos", createAccount()));
-        board.getGadgetDashboard().add(createGadgetDefault());
         getDashboardDao().saveOrUpdate(board);
       }
 
      public void testGadget(){
         final Gadget gadget = new Gadget();
         gadget.setGadgetName("Notifications");
-        gadget.setGadgetType("Poll");
+        gadget.setGadgetType(GadgetType.TWEETPOLLS);
         getDashboardDao().saveOrUpdate(gadget);
      }
 

encuestame-utils/src/main/java/org/encuestame/utils/web/DashboardBean.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2010
+ * 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.web;
+
+import java.io.Serializable;
+
+/**
+ * Unit Dashboard.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 29, 2011
+ */
+public class DashboardBean implements Serializable {
+
+	/**
+	 * Serial
+	 */
+	private static final long serialVersionUID = 8091000998249747994L;
+
+	/** Dashboard id. **/
+	private Long dashboardId;
+
+	/** Dashboard name. **/
+	private String dashboardName;
+
+	/** Favorite dashboard. **/
+	private Boolean favorite;
+
+	/** Dashboard descrtiption. **/
+	private String dashboardDesc;
+
+	/** Dashboard layout. **/
+	private String layout;
+
+	/** Sequence. **/
+	private Integer sequence;
+
+	/** Favorite dashboard counter **/
+	private Integer favoriteCounter;
+
+	/** User**/
+	private UserAccountBean secUser;
+
+	/**
+	 * @return the dashboardId
+	 */
+	public Long getDashboardId() {
+		return dashboardId;
+	}
+
+	/**
+	 * @param dashboardId the dashboardId to set
+	 */
+	public void setDashboardId(final Long dashboardId) {
+		this.dashboardId = dashboardId;
+	}
+
+	/**
+	 * @return the dashboardName
+	 */
+	public String getDashboardName() {
+		return dashboardName;
+	}
+
+	/**
+	 * @param dashboardName the dashboardName to set
+	 */
+	public void setDashboardName(final String dashboardName) {
+		this.dashboardName = dashboardName;
+	}
+
+	/**
+	 * @return the favorite
+	 */
+	public Boolean getFavorite() {
+		return favorite;
+	}
+
+	/**
+	 * @param favorite the favorite to set
+	 */
+	public void setFavorite(final Boolean favorite) {
+		this.favorite = favorite;
+	}
+
+	/**
+	 * @return the dashboardDesc
+	 */
+	public String getDashboardDesc() {
+		return dashboardDesc;
+	}
+
+	/**
+	 * @param dashboardDesc the dashboardDesc to set
+	 */
+	public void setDashboardDesc(final String dashboardDesc) {
+		this.dashboardDesc = dashboardDesc;
+	}
+
+	/**
+	 * @return the layout
+	 */
+	public String getLayout() {
+		return layout;
+	}
+
+	/**
+	 * @param layout the layout to set
+	 */
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	/**
+	 * @return the sequence
+	 */
+	public Integer getSequence() {
+		return sequence;
+	}
+
+	/**
+	 * @param sequence the sequence to set
+	 */
+	public void setSequence(final Integer sequence) {
+		this.sequence = sequence;
+	}
+
+	/**
+	 * @return the favoriteCounter
+	 */
+	public Integer getFavoriteCounter() {
+		return favoriteCounter;
+	}
+
+	/**
+	 * @param favoriteCounter the favoriteCounter to set
+	 */
+	public void setFavoriteCounter(Integer favoriteCounter) {
+		this.favoriteCounter = favoriteCounter;
+	}
+
+	/**
+	 * @return the secUser
+	 */
+	public UserAccountBean getSecUser() {
+		return secUser;
+	}
+
+	/**
+	 * @param secUser the secUser to set
+	 */
+	public void setSecUser(final UserAccountBean secUser) {
+		this.secUser = secUser;
+	}
+}

encuestame-utils/src/test/java/org/encuestame/utils/AbstractBaseUtils.java

 
 import org.encuestame.utils.json.QuestionBean;
 import org.encuestame.utils.json.QuestionPatternBean;
+import org.encuestame.utils.web.DashboardBean;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.UnitEmails;
 import org.encuestame.utils.web.UnitGroupBean;
 import org.encuestame.utils.web.UnitLocationTypeBean;
 import org.encuestame.utils.web.PollBean;
 import org.encuestame.utils.web.UnitProjectBean;
+import org.encuestame.utils.web.UserAccountBean;
 
 import junit.framework.TestCase;
 
         return unitEmails;
      }
 
+     /**
+      * Create unit poll complete.
+      * @param closeNotification
+      * @param completedPoll
+      * @param creationDate
+      * @param finishDate
+      * @param hashTags
+      * @param idPoll
+      * @param publishPoll
+      * @param questionBean
+      * @param showResultsPoll
+      * @return
+      */
      public PollBean createUnitPollComplete(
              final Boolean closeNotification,
              final Boolean completedPoll,
 
      }
 
+     /**
+      * Create dashboard bean.
+      * @param dashboardName
+      * @param dashboardDesc
+      * @param favorite
+      * @param layout
+      * @param sequence
+      * @param counter
+      * @return
+      */
+     public DashboardBean createDashboardBean(
+    		 final String dashboardName,
+    		 final String dashboardDesc,
+    		 final Boolean favorite,
+    		 final String layout,
+    		 final Integer sequence,
+    		 final Integer counter){
+    	 final DashboardBean dashboardBean = new DashboardBean();
+    	 dashboardBean.setDashboardName(dashboardName);
+    	 dashboardBean.setDashboardDesc(dashboardDesc);
+    	 dashboardBean.setFavorite(favorite);
+    	 dashboardBean.setLayout(layout);
+    	 dashboardBean.setSequence(sequence);
+    	 dashboardBean.setFavoriteCounter(counter);
+    	 return dashboardBean;
+     }
 }

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

 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
-
 import org.encuestame.utils.json.QuestionBean;
 import org.encuestame.utils.json.ResumeResultTweetPoll;
 import org.encuestame.utils.json.SocialAccountBean;
 import org.encuestame.utils.security.SignUpBean;
 import org.encuestame.utils.security.ForgotPasswordBean;
 import org.encuestame.utils.vote.UtilVoteCaptcha;
+import org.encuestame.utils.web.DashboardBean;
 import org.encuestame.utils.web.TypeTreeNode;
 import org.encuestame.utils.web.QuestionAnswerBean;
 import org.encuestame.utils.web.UnitCatStateBean;
         assertNotNull(oa.getAuthorizingAccountId());
     }
 
+    /**
+     * Test {@link DashboardBean}
+     */
+    @Test
+    public void testDashboardBean(){
+    	final DashboardBean boardBean = new DashboardBean();
+    	boardBean.setDashboardName("My Dashboard");
+    	boardBean.setDashboardDesc("My First Dashboard");
+    	boardBean.setFavorite(Boolean.TRUE);
+    	boardBean.setLayout("AAA");
+    	boardBean.setSequence(1);
+    	boardBean.setFavoriteCounter(5);
+    	//boardBean.setSecUser(create)
+    	 assertNotNull(boardBean.getDashboardName());
+    	 assertNotNull(boardBean.getDashboardDesc());
+    	 assertNotNull(boardBean.getFavorite());
+    	 assertNotNull(boardBean.getLayout());
+    	 assertNotNull(boardBean.getSequence());
+    }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.