Package org.encuestame.persistence.domain.dashboard

Examples of org.encuestame.persistence.domain.dashboard.Gadget


            @PathVariable final String gadgetId,
            HttpServletRequest request,
            HttpServletResponse response){
        try {
             final Map<String, Object> jsonResponse = new HashMap<String, Object>();
             final Gadget gadget = getDashboardService().addGadgetOnDashboard(boardId, String.valueOf(gadgetId));
             jsonResponse.put("gadget", ConvertDomainBean.convertGadgetDomaintoBean(gadget));
             setItemResponse(jsonResponse);
        } catch (Exception e) {
             log.error(e);
             setError(e.getMessage(), response);
View Full Code Here


     */
    @Test
    public void testAddGadgetOnDashboard() throws ServletException, IOException{
    final Dashboard myBoard = createDashboard("My Third board",
        Boolean.TRUE, getSpringSecurityLoggedUserAccount());
    final Gadget myGadget = createGadgetDefault(myBoard);
    initService("/api/common/stream/gadget.json", MethodJson.POST);
    setParameter("id", myBoard.getBoardId().toString());
    final JSONObject response = callJsonService();
    final JSONObject success = getSucess(response);
    final JSONObject gadget = (JSONObject) success.get("gadget");
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testMoveGadgetOnDashboard() throws ServletException, IOException{
        final Dashboard myBoard = createDashboard("My Surveys board", Boolean.TRUE, getSpringSecurityLoggedUserAccount());
        final Gadget myGadget = createGadgetDefault(myBoard);
        initService("/api/common/" + myGadget.getGadgetId().toString() + "/gadget.json", MethodJson.PUT);
        setParameter("position", "3" );
        setParameter("column""2");
        setParameter("dashboardId", myBoard.getBoardId().toString());
        final JSONObject response = callJsonService();
        assertSuccessResponse(response);
View Full Code Here

     * @throws ServletException
     */
    @Test
    public void testRemoveGadgetOnDashboard() throws ServletException, IOException{
        final Dashboard tpBoard = createDashboard("My TweetPoll board", Boolean.TRUE, getSpringSecurityLoggedUserAccount());
        final Gadget myGadget = createGadgetDefault(tpBoard);
        initService("/api/common/" + myGadget.getGadgetId().toString() + "/gadget.json", MethodJson.DELETE);
        //setParameter("gadgetId", myGadget.getGadgetId().toString() );
        setParameter("dashboardId", tpBoard.getBoardId().toString());
        final JSONObject response = callJsonService();
        assertSuccessResponse(response);
    }
View Full Code Here

     * @param name
     * @param type
     * @return
     */
    public Gadget createGadget(final String name, final Dashboard board){
        final Gadget gadget = new Gadget();
        gadget.setGadgetName(name);
        gadget.setGadgetType(GadgetType.getGadgetType("stream"));
        gadget.setGadgetColumn(2);
        gadget.setGadgetColor("default");
        gadget.setGadgetPosition(0);
        gadget.setDashboard(board);
        getDashboardDao().saveOrUpdate(gadget);
        return gadget;
    }
View Full Code Here

     /**
     * Test get gadget by id.
     */
    @Test
    public void testGetGadgetById(){
        final Gadget gad = dashboardService.getGadgetById(this.gadget.getGadgetId());
        assertNotNull(gadget);
        assertEquals("Should be equals", this.gadget.getGadgetId(), gad.getGadgetId());
    }
View Full Code Here

    /*
     * (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;
    }
View Full Code Here

     */
    public Gadget addGadgetOnDashboard(final Long boardId, final String gadgetId) throws EnMeNoResultsFoundException{
        final Properties gProperties = GadgetsLoader.getDirectoy(gadgetId);
        if (gProperties != null) {
            final Dashboard dashboard = getDashboardDao().getDashboardbyId(boardId);
            final Gadget gadget = createNewGadget(gProperties, dashboard);
            if (gadget.getGadgetType().equals(GadgetType.ACTIVITY_STREAM)) {
                createProperty(gadget, "permissions", gProperties.getProperty("permissions"));
            } else if (gadget.getGadgetType().equals(GadgetType.COMMENTS)) {
                createProperty(gadget, "permissions", gProperties.getProperty("permissions"));
            } else if (gadget.getGadgetType().equals(GadgetType.TWEETPOLLS_VOTES)) {
                createProperty(gadget, "permissions", gProperties.getProperty("permissions"));
            } else {
                throw new EnMeNoResultsFoundException("gadget not found");
            }
            return gadget;
View Full Code Here

     *
     * @param gProperties
     * @return
     */
    private Gadget createNewGadget(final Properties gProperties, final Dashboard dashboard) {
        final Gadget gadget = new Gadget();
        gadget.setGadgetColumn(1);
        gadget.setGadgetName(gProperties.getProperty("name"));
        log.debug("widget "+gProperties.getProperty("name"));
        GadgetType d = GadgetType.getGadgetType(gProperties.getProperty("name"));
        log.debug("gadget type: " + d);
        gadget.setGadgetType(d);
        gadget.setGadgetColor(PictureUtils.getRandomHexColor());
        gadget.setStatus(Boolean.TRUE);
        gadget.setGadgetPosition(1);
        gadget.setDashboard(dashboard);
        getDashboardDao().saveOrUpdate(gadget);
        return gadget;
    }
View Full Code Here

     * (non-Javadoc)
     * @see org.encuestame.business.service.imp.IDashboardService#removeGadget(java.lang.Long)
     */
    public void removeGadget(final Long gadgetId, final Long dashboardId) throws EnMeNoResultsFoundException {
        final Dashboard board = this.getDashboardById(dashboardId);
        final Gadget gadget= this.getGadget(gadgetId, board);
        final List<GadgetProperties> prop = getDashboardDao().retrievePropertiesbyGadget(gadget.getGadgetId());
        if(prop.size() > 0){
            for (GadgetProperties gadgetProperties : prop) {
                getDashboardDao().delete(gadgetProperties);
            }
        }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.dashboard.Gadget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.