/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ee.tlu.htk.dippler.course; import ee.tlu.htk.dippler.backoffice.StatusCodes; import ee.tlu.htk.dippler.entities.Course; import ee.tlu.htk.dippler.entities.User; import ee.tlu.htk.dippler.managers.UserManagerLocal; import javax.ejb.EJB; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; /** * * @author metz */ enum AnalyticsActions { LOAD } @Stateless public class AnalyticsManager implements AnalyticsManagerLocal { @PersistenceContext private EntityManager em; @EJB private UserManagerLocal userManager; public static final Integer LOAD = 1; @Override public String manageAnalytics(String action, String data, User user) { switch (AnalyticsActions.valueOf(action)) { case LOAD: if (userManager.hasPermission(user, LOAD)) { //return this.loadCourse(data); } else { return StatusCodes.respond(StatusCodes.OPERATION_NOT_ALLOWED, "No rights for load analytics"); } default: return StatusCodes.respond(StatusCodes.OPERATION_NOT_ALLOWED, ""); } } @Override public String loadLatestInfo(Course course) { String xml = ""; try { /*xml += ""; xml += "1"; xml += "<![CDATA[Analysis 1]]>"; xml += ""; xml += ""; xml += "2"; xml += "<![CDATA[Analysis 2]]>"; xml += "";*/ } catch (Throwable t) { t.printStackTrace(System.out); } xml += ""; return xml; } }