UniNet – a Sakai plugin built on Spring and Hibernate

UniNet is a university-scoped social network built on Spring and Hibernate and integrated into Sakai portal as a independent module.

The purpose of UniNet is  to provide a communication channel where students can contact with each other seeking help ,  looking for other students (from the same country, or city;  speaking the same language; doing the course or subject;  having some skills or interest) or to team up a group (of their interest or to do a project).

Sakai is a community of academic institutions, commercial organizations and individuals who work together to develop a common Collaboration and Learning Environment (CLE). The Sakai CLE is a free, community source, educational software platform distributed under the Educational Community License (a type of open source license). The Sakai CLE is used for teaching, research and collaboration. Systems of this type are also known as Course Management Systems (CMS), Learning Management Systems (LMS), or Virtual Learning Environments (VLE).

Sakai is a Java-based, service-oriented application suite that is designed to be scalable, reliable, interoperable and extensible. Version 1.0 was released in March 2005.

As of July 2007, Sakai is in production at over 150 institutions and being piloted by over 100 more.

UniNet is developed on the MVC model of Spring framework and Object Mapping technique of Hibernate framework. The module follows Sakai standards and integrated into Sakai project as a plug-in tool.

During the development and testing phase, the module used Tomcat as virtual web server, MySQL as database server and Maven as deployment tool. Project timeline and management activities has been done through Trac; code version was controlled by Subversion through Eclipse plug-in (Subclipse).

System Architecture:

Description:

  • when a student enrolls in a course, he will automatically has a UniNet page but it is up to him to activate his page or not.
  • UniNet page contain the contents about Personal information, Group list, Course information, Subject information , Interests, Skills

Functionalities:

  • User can customize the information he wants to post on his page (except Course information) : he can choose what information to be displayed; upload his represent pictures; write and edit entries, upload images in the entry
  • User can search for students from any countries or cities; for students who are doing the same course or units with him; for students with specific interests; for students with specific skills
  • User can create a group and give a description about the group such as, then he could invite other users to join his group. Each group will have a group page where all members can write entries and upload images about the group activities.
  • When join a group, user can send internal emails to all members of group as well as receive emails from others

MVC structure
uninet_5

Sample code

Model : UserManager.java

JAVA:
package model;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import java.util.*;
/**
* Model : class UserManager
*/

public class UserManager {

public UserManager(){}

public List getUserList(){
List list = null;
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
try
{
list = session.createQuery("from User").list();
session.getTransaction().commit();
}
catch (HibernateException e)
{
session.getTransaction().rollback();
throw e;
}
Collections.sort(list);
return list;
}
}

Controller: UserController.java

JAVA:
package controller;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.*;
import model.*;

public class UserController implements Controller{
private UserManager userManager;
protected final Log logger = LogFactory.getLog(getClass());

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String dateSt = (new java.util.Date().toString());
logger.info("User access homepage on: " + dateSt);

Map myModel = new HashMap();
int userID= Integer.parseInt((String)request.getParameter("id"));
int home = request.getSession(true).getAttribute("home")!=null?
(Integer)request.getSession(true).getAttribute("home"):0;

if (home==0){
home = userID;
}
User user= userManager.getUser(userID);
myModel.put("home", home);
myModel.put("user", user);
int state = user.getState();
if(state==0 && home!=userID){
request.getSession(true).setAttribute("home",home);
String rs = "This user has not been activated";
myModel.put("notActive", rs);
return new ModelAndView("activate", "ToActivate", myModel);

}
else if(state==0 && home==userID) {
String rs ="Click the following link to activate your UniNet";
myModel.put("doActive", rs);
return new ModelAndView("activate", "ToActivate", myModel);
}
else{
request.getSession(true).setAttribute("home",home);
List subList = userManager.getSubList(userID);
List skillList = userManager.getSkillList(userID);
List intList= userManager.getIntList(userID);
List courseList = userManager.getCourseList(userID);
List groupList = userManager.getGroupList(userID);
List newMsg = userManager.getMessageOfUser(userID,0);

myModel.put("subList", subList);
myModel.put("courseList", courseList);
myModel.put("skillList", skillList);
myModel.put("intList", intList);
myModel.put("groupList", groupList);
myModel.put("newMsg",newMsg.size());

return new ModelAndView("home", "Home", myModel);
}
}

public void setUserManager(UserManager uMage) {
userManager = uMage;
}

public UserManager getUserManager() {
return userManager;
}

}

View: search.jsp

HTML:
<%@ include file="include/include.jsp" %>

<fmt:message key="search"/>
<div class="body_container">
<div class="header">SEARCH RESULT</div>
<a class="home" href="/uninet/home.htm?id=&lt;c:out value="></a>"&gt;Home
<div class="main">
<div class="info">
<ul>
    <li> <a href="/uninet/home.htm?id=&lt;c:out value=">
"&gt;</a></li>
</ul>
</div>
</div>
</div>

Screen shot

uninet_1Home page

uninet_3

Message Box

Download:  sakai-uninet.rar

NDLoc, 29/06/2009

June 29, 2009    Posted in: Web Development

Leave a Reply