/**
* 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.Date;
import java.util.Iterator;
import java.util.List;
import javax.faces.model.SelectItem;
import com.ese.ils.beta.model.Module;
import com.ese.ils.beta.service.base.ModuleLocalServiceBaseImpl;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry;
/**
* The implementation of the module 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.eserve.ils.beta.service.ModuleLocalService} 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.eserve.ils.beta.service.base.ModuleLocalServiceBaseImpl
* @see com.eserve.ils.beta.service.ModuleLocalServiceUtil
*/
public class ModuleLocalServiceImpl extends ModuleLocalServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link com.eserve.ils.beta.service.ModuleLocalServiceUtil} to access the module local service.
*/
public List<Module> fetchItemsByUser(long userId){
//an dieser Stelle werden alle angelegten Module gefetcht
//eine Zuordnung von User zu Modul ist nicht implementiert
List <Module> moduleList = new ArrayList<Module>();
try {
moduleList = modulePersistence.findAll();
} catch (SystemException e) {
e.printStackTrace();
}
return moduleList;
}
/**
* Adds a Module to the Database
* @param lecturerUserId must be the id of the lecturer
* @param moduleTitle defines the title of the module
* @param additionalInfo is for additional info of the module e.g description
* @param createDate must be the current date
*/
public void addModule(int lecturerUserId, String moduleTitle, String additionalInfo, Date createDate) {
long moduleId;
try {
moduleId = CounterLocalServiceUtil.increment(Module.class.getName());
Module module = modulePersistence.create(moduleId);
//Setting properties of the new Modul
module.setModuleTitle(moduleTitle);
module.setLecturerUserId(lecturerUserId);
module.setAdditionalInfo(additionalInfo);
module.setCreateDate(createDate);
modulePersistence.update(module, false);
System.out.println("Modul hinzugef�gt...");
} catch (SystemException e) {
e.printStackTrace();
}
}
public List<Module> fetchModulesByLecturerUser(long lecturerUserId) {
List<Module> moduleListLecturer = new ArrayList<Module>();
try {
moduleListLecturer = modulePersistence.findByByLecturer(lecturerUserId);
} catch (SystemException sysEx) {
sysEx.printStackTrace();
System.out.println("Beim holen der Module f�r die lecturer ID " + lecturerUserId
+ " ist ein Fehler unterlaufen." );
}
return moduleListLecturer;
}
}