Commits

Juan Carlos Picado Herrera  committed 23accda Merge

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

  • Participants
  • Parent commits 4931846, 669c0bc

Comments (0)

Files changed (10)

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IDashboardDao.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.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.
+ * @author Morales,Diana Paola paolaATencuestame.org
+ * @since July 27, 2011
+ */
+public interface IDashboardDao extends IBaseDao {
+
+	/**
+	 * Get dashboard by id.
+	 * @param boardId
+	 * @return
+	 */
+	Dashboard getDashboardbyId(final Long boardId);
+
+	/**
+	 * Retrieve dashboards by id and user.
+	 * @param userBoard
+	 * @return
+	 */
+	List<Dashboard> retrieveDashboards(final UserAccount userBoard);
+
+	/**
+	 * Retrieve favorites dashboards.
+	 * @param userId
+	 * @param maxResults
+	 * @param start
+	 * @return
+	 */
+	List<Dashboard> retrieveFavouritesDashboards(
+	            final Long userId,
+	            final Integer maxResults,
+	            final Integer start);
+
+	/**
+	 * Get gadget by id.
+	 * @param gadgetId
+	 * @return
+	 */
+	Gadget getGadgetbyId(final Long gadgetId);
+
+	/**
+	 * Get gadget by keyword.
+	 * @param keyword
+	 * @param maxResults
+	 * @param start
+	 * @return
+	 */
+	List<Gadget> getGadgetbyKeyword(final String keyword, final Integer maxResults, final Integer start);
+}

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/DashboardDao.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.dao.imp;
+
+import java.util.List;
+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.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.stereotype.Repository;
+
+/**
+ * Dashboard Dao.
+ * @author Morales,Diana Paola paolaATencuestame.org
+ * @since July 27, 2011
+ */
+@Repository("dashboardDao")
+public class DashboardDao extends AbstractHibernateDaoSupport implements IDashboardDao {
+
+	@Autowired
+	public DashboardDao(SessionFactory sessionFactory) {
+		setSessionFactory(sessionFactory);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.persistence.dao.IDashboardDao#getDashboardbyId(java.lang.Long)
+	 */
+	public Dashboard getDashboardbyId(final Long boardId){
+	 		return (Dashboard) getHibernateTemplate().get(Dashboard.class, boardId);
+	 }
+
+	/*
+	 * (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){
+		final DetachedCriteria criteria = DetachedCriteria.forClass(Dashboard.class);
+			criteria.createAlias("userBoard", "userBoard");
+	        criteria.add(Restrictions.eq("userBoard", userBoard));
+	        return getHibernateTemplate().findByCriteria(criteria);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.persistence.dao.IDashboardDao#retrieveFavouritesDashboards(java.lang.Long, java.lang.Integer, java.lang.Integer)
+	 */
+	@SuppressWarnings("unchecked")
+	public List<Dashboard> retrieveFavouritesDashboards(
+			final Long userId,
+	        final Integer maxResults,
+	        final Integer start){
+	        final DetachedCriteria criteria = DetachedCriteria.forClass(Dashboard.class);
+	        criteria.createAlias("userBoard","userBoard");
+	        criteria.add(Restrictions.eq("favorite", Boolean.TRUE));
+	        criteria.add(Restrictions.eq("userBoard.uid", userId));
+	        return (List<Dashboard>) filterByMaxorStart(criteria, maxResults, start);
+	    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.persistence.dao.IDashboardDao#getGadgetbyId(java.lang.Long)
+	 */
+	public Gadget getGadgetbyId(final Long gadgetId){
+ 		return (Gadget) getHibernateTemplate().get(Gadget.class, gadgetId);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.encuestame.persistence.dao.IDashboardDao#getGadgetbyKeyword(java.lang.String, java.lang.Integer, java.lang.Integer)
+	 */
+	@SuppressWarnings("unchecked")
+	public List<Gadget> getGadgetbyKeyword(final String keyword, final Integer maxResults, final Integer start){
+		  final DetachedCriteria criteria = DetachedCriteria.forClass(Gadget.class);
+	        //criteria.createAlias("gadgetName","gadgetName");
+	        criteria.add(Restrictions.like("gadgetName", keyword, MatchMode.ANYWHERE));
+	        return (List<Gadget>) filterByMaxorStart(criteria, maxResults, start);
+	    }
+}

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/Dashboard.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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import org.encuestame.persistence.domain.security.UserAccount;
+
+/**
+ * Dashboard domain.
+ *
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 27, 2011
+ */
+@Entity
+@Table(name = "dashboard")
+public class Dashboard {
+
+    /** Dashboard Id. **/
+    private Long boardId;
+
+    /** Dashboard name. **/
+    private String pageBoardName;
+
+    /** Dashboard description. **/
+    private String description;
+
+    /** Favorite. **/
+    private Boolean favorite;
+
+    /** Page Layout. **/
+    private String pageLayout;
+
+    /** Dashboard sequence. **/
+    private Integer boardSequence;
+
+    /** Favorite counter. **/
+    private Integer favoriteCounter;
+
+    /** {@link UserAccount} **/
+    private UserAccount userBoard;
+
+    private Set<Gadget> gadgetDashboard = new HashSet<Gadget>();
+
+    /**
+    * @return the boardId
+    */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "dashboardId", unique = true, nullable = true)
+    public Long getBoardId() {
+        return boardId;
+    }
+
+    /**
+    * @param boardId the boardId to set
+    */
+    public void setBoardId(final Long boardId) {
+        this.boardId = boardId;
+    }
+
+    /**
+    * @return the pageBoardName
+    */
+    @Column(name = "dashboardName", nullable = false)
+    public String getPageBoardName() {
+        return pageBoardName;
+    }
+
+    /**
+    * @param pageBoardName the pageBoardName to set
+    */
+    public void setPageBoardName(final String pageBoardName) {
+        this.pageBoardName = pageBoardName;
+    }
+
+    /**
+    * @return the description
+    */
+    @Column(name = "description", nullable = false)
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+    * @param description the description to set
+    */
+    public void setDescription(final String description) {
+        this.description = description;
+    }
+
+    /**
+    * @return the favorite
+    */
+    @Column(name = "favorite", nullable = false)
+    public Boolean getFavorite() {
+        return favorite;
+    }
+
+    /**
+    * @param favorite the favorite to set
+    */
+    public void setFavorite(final Boolean favorite) {
+        this.favorite = favorite;
+    }
+
+    /**
+    * @return the pageLayout
+    */
+    @Column(name = "layout", nullable = false)
+    public String getPageLayout() {
+        return pageLayout;
+    }
+
+    /**
+    * @param pageLayout the pageLayout to set
+    */
+    public void setPageLayout(final String pageLayout) {
+        this.pageLayout = pageLayout;
+    }
+
+    /**
+    * @return the boardSequence
+    */
+    @Column(name = "sequence", nullable = false)
+    public Integer getBoardSequence() {
+        return boardSequence;
+    }
+
+    /**
+    * @param boardSequence the boardSequence to set
+    */
+    public void setBoardSequence(final Integer boardSequence) {
+        this.boardSequence = boardSequence;
+    }
+
+    /**
+    * @return the favoriteCounter
+    */
+    @Column(name = "favorite_counter", nullable = false)
+    public Integer getFavoriteCounter() {
+        return favoriteCounter;
+    }
+
+    /**
+    * @param favoriteCounter the favoriteCounter to set
+    */
+    public void setFavoriteCounter(final Integer favoriteCounter) {
+        this.favoriteCounter = favoriteCounter;
+    }
+
+    /**
+    * @return the userBoard
+    */
+    @ManyToOne()
+    public UserAccount getUserBoard() {
+        return userBoard;
+    }
+
+    /**
+    * @param userBoard the userBoard to set
+    */
+    public void setUserBoard(final UserAccount userBoard) {
+        this.userBoard = userBoard;
+    }
+
+    /**
+    * @return the widgetDashboard
+    */
+    @ManyToMany(cascade=CascadeType.ALL)
+    @JoinTable(name="dashboard_gadget",
+               joinColumns={@JoinColumn(name="dashboardId")},
+               inverseJoinColumns={@JoinColumn(name="gadgetId")})
+    public Set<Gadget> getGadgetDashboard() {
+        return gadgetDashboard;
+    }
+
+    /**
+    * @param widgetDashboard the widgetDashboard to set
+    */
+    public void setGadgetDashboard(Set<Gadget> gadgetDashboard) {
+        this.gadgetDashboard = gadgetDashboard;
+    }
+}

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/Gadget.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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+/**
+ * Widget domain.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 27, 2011
+ */
+@Entity
+@Table(name = "gadget")
+public class Gadget {
+
+    /** Widget id.**/
+    private Long gadgetId;
+
+    /** Widget name. **/
+    private String gadgetName;
+
+    /** Widget type**/
+    private String gadgetType;
+
+    /** {@link Dashboard} **/
+    private Set<Dashboard> dashboard = new HashSet<Dashboard>();
+
+    /**
+    * @return the widgetId
+    */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "gadgetId", unique = true, nullable = true)
+    public Long getGadgetId() {
+        return gadgetId;
+    }
+
+    /**
+    * @param widgetId the widgetId to set
+    */
+    public void setGadgetId(final Long gadgetId) {
+        this.gadgetId = gadgetId;
+    }
+
+    /**
+    * @return the widgetName
+    */
+    @Column(name = "gadgetName", nullable = false)
+    public String getGadgetName() {
+        return gadgetName;
+    }
+
+    /**
+    * @param widgetName the widgetName to set
+    */
+    public void setGadgetName(final String gadgetName) {
+        this.gadgetName = gadgetName;
+    }
+
+    /**
+    * @return the widgetType
+    */
+    @Column(name = "gadgetType", nullable = false)
+    public String getGadgetType() {
+        return gadgetType;
+    }
+
+    /**
+    * @param widgetType the widgetType to set
+    */
+    public void setGadgetType(final String gadgetType) {
+        this.gadgetType = gadgetType;
+    }
+
+	/**
+	 * @return the dashboard
+	 */
+    @ManyToMany(cascade = CascadeType.ALL)
+	public Set<Dashboard> getDashboard() {
+		return dashboard;
+	}
+
+	/**
+	 * @param dashboard the dashboard to set
+	 */
+	public void setDashboard(final Set<Dashboard> dashboard) {
+		this.dashboard = dashboard;
+	}
+}

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/dashboard/GadgetProperties.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;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.encuestame.persistence.domain.security.UserAccount;
+
+/**
+ * Widget properties.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 27, 2011
+ */
+@Entity
+@Table(name = "gadget_properties")
+public class GadgetProperties {
+
+    /** Widget preference id. **/
+    private Long propertyId;
+
+    /** Widget property name. **/
+    private String gadgetPropName;
+
+    /** Widget property value**/
+    private String gadgetPropValue;
+
+    /** {@link Gadget} **/
+    private Gadget gadget;
+
+    /** {@link UserAccount} **/
+    private UserAccount userAccount;
+
+    /**
+    * @return the preferenceId
+    */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "propertyId", unique = true, nullable = true)
+    public Long getPropertyId() {
+        return propertyId;
+    }
+
+    /**
+    * @param preferenceId the preferenceId to set
+    */
+    public void setPropertyId(Long propertyId) {
+        this.propertyId = propertyId;
+    }
+
+    /**
+    * @return the prefName
+    */
+    @Column(name = "gadget_prop_name", nullable = false)
+    public String getGadgetPropName() {
+        return gadgetPropName;
+    }
+
+    /**
+    * @param prefName the prefName to set
+    */
+    public void setGadgetPropName(String gadgetPropName) {
+        this.gadgetPropName = gadgetPropName;
+    }
+
+    /**
+    * @return the prefValue
+    */
+    @Column(name = "gadget_prop_value", nullable = false)
+    public String getGadgetPropValue() {
+        return gadgetPropValue;
+    }
+
+    /**
+    * @param prefValue the prefValue to set
+    */
+    public void setGadgetPropValue(String gadgetPropValue) {
+        this.gadgetPropValue = gadgetPropValue;
+    }
+
+    /**
+    * @return the widget
+    */
+    @ManyToOne()
+    public Gadget getGadget() {
+        return gadget;
+    }
+
+    /**
+    * @param widget the widget to set
+    */
+    public void setGadget(Gadget gadget) {
+        this.gadget = gadget;
+    }
+
+    /**
+    * @return the userAccount
+    */
+    @ManyToOne()
+    public UserAccount getUserAccount() {
+        return userAccount;
+    }
+
+    /**
+    * @param userAccount the userAccount to set
+    */
+    public void setUserAccount(UserAccount userAccount) {
+        this.userAccount = userAccount;
+    }
+}

File encuestame-persistence/src/main/resources/spring-test/encuestame-test-hibernate-context.xml

                 <value>org.encuestame.persistence.domain.notifications.Notification</value>
                 <value>org.encuestame.persistence.domain.Attachment</value>
                 <value>org.encuestame.persistence.domain.HashTagHits</value>
+                <value>org.encuestame.persistence.domain.dashboard.Dashboard</value>
+                <value>org.encuestame.persistence.domain.dashboard.Gadget</value>
+                <value>org.encuestame.persistence.domain.dashboard.GadgetProperties</value>
             </list>
         </property>
         <property name="hibernateProperties">

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

 import org.apache.commons.lang.math.RandomUtils;
 import org.encuestame.persistence.dao.IAccountDao;
 import org.encuestame.persistence.dao.IClientDao;
+import org.encuestame.persistence.dao.IDashboardDao;
 import org.encuestame.persistence.dao.IEmail;
 import org.encuestame.persistence.dao.IFrontEndDao;
 import org.encuestame.persistence.dao.IGeoPoint;
 import org.encuestame.persistence.dao.ISurveyFormatDao;
 import org.encuestame.persistence.dao.ITweetPoll;
 import org.encuestame.persistence.dao.imp.ClientDao;
+import org.encuestame.persistence.dao.imp.DashboardDao;
 import org.encuestame.persistence.dao.imp.EmailDao;
 import org.encuestame.persistence.dao.imp.FrontEndDao;
 import org.encuestame.persistence.dao.imp.PollDao;
 import org.encuestame.persistence.domain.Project;
 import org.encuestame.persistence.domain.Project.Priority;
 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.notifications.Notification;
 import org.encuestame.persistence.domain.notifications.NotificationEnum;
 import org.encuestame.persistence.domain.question.Question;
     @Autowired
     private IFrontEndDao frontEndDao;
 
+    /** {@link DashboardDao} **/
+    @Autowired
+    private IDashboardDao dashboardDao;
+
     /**
      * Get Property.
      * @param property
         return createSecondaryUserGroup(name, name.replace(" ", "")+"."+RandomStringUtils.randomNumeric(6)+"@users.com", secUser, group);
     }
 
+    /**
+     * Create gadget default.
+     * @return
+     */
+    public Gadget createGadgetDefault(){
+        return this.createGadget("default", "defaultType");
+    }
 
+    /**
+     * Create gadget.
+     * @param name
+     * @param type
+     * @return
+     */
+    public Gadget createGadget(final String name, final String type){
+        final Gadget gadget = new Gadget();
+        gadget.setGadgetName(name);
+        gadget.setGadgetType(type);
+        getDashboardDao().saveOrUpdate(gadget);
+        return gadget;
+    }
+
+    /**
+     * Create dashboard.
+     * @param boardName
+     * @param favorite
+     * @param userAcc
+     * @return
+     */
+    public Dashboard createDashboard(final String boardName,  final Boolean favorite, final UserAccount userAcc){
+        final Dashboard board = new Dashboard();
+        board.setPageBoardName(boardName);
+          board.setDescription("");
+          board.setFavorite(favorite);
+          board.setFavoriteCounter(1);
+          board.setPageLayout("AAA");
+          board.setBoardSequence(1);
+          board.setUserBoard(userAcc);
+          getDashboardDao().saveOrUpdate(board);
+        return board;
+    }
+
+    /**
+     * Create dashboard default.
+     * @param userAcc
+     * @return
+     */
+    public Dashboard createDashboardDefault(final UserAccount userAcc){
+        return this.createDashboard("Board default", Boolean.TRUE, userAcc);
+    }
 
     /**
      * Create Secondary User.
        getHashTagDao().saveOrUpdate(tagHits);
        return tagHits;
     }
+
+    /**
+    * @return the dashboardDao
+    */
+    public IDashboardDao getDashboardDao() {
+        return dashboardDao;
+    }
+
+    /**
+    * @param dashboardDao the dashboardDao to set
+    */
+    public void setDashboardDao(final IDashboardDao dashboardDao) {
+        this.dashboardDao = dashboardDao;
+    }
 }

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestDashboardDao.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.persistence.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.List;
+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.Account;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.test.config.AbstractBase;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Test Dashboard Dao.
+ * @author Morales,Diana Paola paola@encuestame.org
+ * @since  July 28, 2011
+ */
+public class TestDashboardDao extends AbstractBase {
+
+	 /** {@link IDashboardDao} **/
+	@Autowired
+	IDashboardDao dashboard;
+
+	/** {@link UserAccount} **/
+	private UserAccount userAccount;
+
+	/** {@link Account} **/
+	private Account account;
+
+	/** {@link Dashboard} **/
+	private Dashboard board;
+
+	/** {@link Gadget} **/
+	private Gadget gadget;
+
+	@Before
+    public void initService(){
+		this.account = createUser("testEncuesta", "testEncuesta123");
+        this.userAccount = createUserAccount("diana", this.account);
+        this.board = createDashboard("First board", Boolean.TRUE, this.userAccount);
+        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");
+	}
+
+	/**
+	 * Test retrieve dashboard by id.
+	 */
+	@Test
+	public void testGetDashboardbyId(){
+		final Dashboard dashboard = getDashboardDao().getDashboardbyId(this.board.getBoardId());
+		  assertNotNull(dashboard);
+		  assertEquals("Should be equals", dashboard.getBoardId(), this.board.getBoardId());
+	}
+
+	/**
+	 * Test retrieve dashboard pages.
+	 */
+	@Test
+	public void testRetrieveDashboardsPage(){
+		final List<Dashboard> boardPages = getDashboardDao().retrieveDashboards(this.userAccount);
+	    assertEquals("Should be equals", boardPages.size(), 3);
+	}
+
+	/**
+	 * Test Retrieve favorite dashboards.
+	 */
+	@Test
+	public void testRetrieveFavouritesDashboards(){
+		final List<Dashboard> favoriteBoards = getDashboardDao().retrieveFavouritesDashboards(this.userAccount.getUid(), 10, 0);
+		assertEquals("Should be equals", favoriteBoards.size(), 3);
+	}
+
+	/**
+	 * Test Retrieve gadgets by keyword.
+	 */
+	@Test
+	public void testGetGadgetbyKeyword(){
+		final List<Gadget> gadgets = getDashboardDao().getGadgetbyKeyword("gadget", 10, 0);
+		assertEquals("Should be equals", gadgets.size(), 2);
+	}
+
+	/**
+	 * Test get gadget by id.
+	 */
+	@Test
+	public void testGetGadgetbyId(){
+		final Gadget gad = getDashboardDao().getGadgetbyId(this.gadget.getGadgetId());
+		assertEquals("Should be equals", gad.getGadgetId(), this.gadget.getGadgetId());
+	}
+}

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

 import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.Project;
 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.GadgetProperties;
 import org.encuestame.persistence.domain.question.CatQuestionCategory;
 import org.encuestame.persistence.domain.question.Question;
 import org.encuestame.persistence.domain.question.QuestionAnswer;
         assertNotNull(tag.getHashTagId());
      }
 
-     /** HashTag domain. **/
+     /** HashTag hits domain. **/
      @Test
      public void testHashTagHits(){
         final Date hitDate = new Date();
         getHashTagDao().saveOrUpdate(tagHits);
         assertNotNull(tagHits.getHashTagId());
      }
+
+     /** Dashboard domain. **/
+     @Test
+     public void testDashboard(){
+        final Dashboard board = new Dashboard();
+        board.setPageBoardName("First dashboard");
+        board.setDescription("My first dashboard");
+        board.setFavorite(Boolean.TRUE);
+        board.setFavoriteCounter(1);
+        board.setPageLayout("AAA");
+        board.setBoardSequence(1);
+        board.setUserBoard(createUserAccount("juan carlos", createAccount()));
+        board.getGadgetDashboard().add(createGadgetDefault());
+        getDashboardDao().saveOrUpdate(board);
+      }
+
+     /** Gadget domain **/
+     @Test
+     public void testGadget(){
+        final Gadget gadget = new Gadget();
+        gadget.setGadgetName("Notifications");
+        gadget.setGadgetType("Poll");
+        getDashboardDao().saveOrUpdate(gadget);
+     }
+
+     /** Gadget Properties **/
+     @Test
+     public void testGadgetProperties(){
+    	 final GadgetProperties gadgetProp = new GadgetProperties();
+    	 gadgetProp.setGadgetPropName("maxResults");
+    	 gadgetProp.setGadgetPropValue("10");
+    	 gadgetProp.setUserAccount(createUserAccount("diana paola", createAccount()));
+    	 gadgetProp.setGadget(createGadgetDefault());
+    	 getDashboardDao().saveOrUpdate(gadgetProp);
+     }
 }

File encuestame-war/src/main/webapp/WEB-INF/spring/encuestame-hibernate-context.xml

                 <value>org.encuestame.persistence.domain.notifications.Notification</value>
                 <value>org.encuestame.persistence.domain.Attachment</value>
                 <value>org.encuestame.persistence.domain.HashTagHits</value>
+                <value>org.encuestame.persistence.domain.dashboard.Dashboard</value>
+                <value>org.encuestame.persistence.domain.dashboard.Gadget</value>
+                <value>org.encuestame.persistence.domain.dashboard.GadgetProperties</value>
             </list>
         </property>
         <property name="hibernateProperties">