Subversion Repositories bacoAlunos

Rev

Rev 684 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.services.surveys;

import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.SurveyStatsGraphic;
import pt.estgp.estgweb.domain.SurveyStructuralNode;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.SurveyStatsGraphicView;
import pt.estgp.estgweb.domain.views.SurveyStructuralNodeView;
import pt.utl.ist.berserk.logic.serviceManager.IService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: Duarte Santos
 * @date: 13-08-2011
 * @time: 1:43
 * @email: a12564 [at] estgp [dot] pt
 */


public class LoadSurveyNodeGraphsService implements IService
{
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(LoadSurveyNodeGraphsService.class);

    public List<SurveyStatsGraphicView> run(long surveyId, long nodeId, UserSession userSession)
    {
        SurveyStructuralNode node = DaoFactory.getSurveyStructuralNodeDaoImpl().load(nodeId);

        if(node != null)
        {
            List<SurveyStatsGraphicView> surveyStatsGraphicViews = new ArrayList<SurveyStatsGraphicView>();
            for(SurveyStatsGraphic g : node.getGraphics())
            {
                SurveyStructuralNodeView nodeView = new SurveyStructuralNodeView(g.getStructuralNode());
                SurveyStatsGraphicView surveyStatsGraphicView = new SurveyStatsGraphicView(g);
                surveyStatsGraphicView.setStructuralNodeView(nodeView);
                surveyStatsGraphicViews.add(surveyStatsGraphicView);
            }
            return surveyStatsGraphicViews;
        }
        return null;
    }
}