/** * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.ese.ils.beta.service.impl; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.faces.model.SelectItem; import com.ese.ils.beta.model.Question; import com.ese.ils.beta.service.base.QuestionLocalServiceBaseImpl; import com.ese.ils.beta.service.persistence.QuestionUtil; import com.liferay.counter.service.CounterLocalServiceUtil; import com.liferay.portal.kernel.exception.SystemException; /** * The implementation of the question local service. * * <p> * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.ese.ils.beta.service.QuestionLocalService} interface. * * <p> * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM. * </p> * * @author edik * @see com.ese.ils.beta.service.base.QuestionLocalServiceBaseImpl * @see com.ese.ils.beta.service.QuestionLocalServiceUtil */ public class QuestionLocalServiceImpl extends QuestionLocalServiceBaseImpl { /* * NOTE FOR DEVELOPERS: * * Never reference this interface directly. Always use {@link com.ese.ils.beta.service.QuestionLocalServiceUtil} to access the question local service. */ public List<Question> fetchQuestionItems(long moduleId){ System.out.println("Hole Fragen im Service f�r " + moduleId); List<Question> questionList = new ArrayList<Question>(); try { questionList = questionPersistence.findByModule(moduleId); } catch (SystemException e) { e.printStackTrace(); } return questionList; } public void askQuestion(long userId, long moduleId, String text, long slideId){ try { long questionId = CounterLocalServiceUtil.increment(Question.class.getName()); Question question = questionPersistence.create(questionId); question.setModuleId(moduleId); question.setUserId(userId); question.setQuestionText(text); question.setSlideId(slideId); questionPersistence.update(question, false); } catch (SystemException e) { e.printStackTrace(); } } }