Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GeoProvisioningService {

Logger LOGGER = Logger.getLogger(GeoProvisioningService.class);

private static final ApplicationContext COPII_CONTEXT = new ClassPathXmlApplicationContext("copII-dao-context.xml");
private static final ApplicationContext COPIII_CONTEXT = new ClassPathXmlApplicationContext("copIII-dao-context.xml");

public GeoProvisioningService() {

Expand All @@ -28,7 +28,7 @@ public GeoProvisioningService() {
public DSFLAreas getArea(double lat, double lng) throws AreaNotFoundException {
LOGGER.debug("lat: "+ lat);
LOGGER.debug("lng: "+ lng);
GeoInfoDao geoInfoDao = (GeoInfoDao) COPII_CONTEXT.getBean("geoInfoDao");
GeoInfoDao geoInfoDao = (GeoInfoDao) COPIII_CONTEXT.getBean("geoInfoDao");
String area = geoInfoDao.getAreaDetails(lat, lng)[1].toString();
DSFLAreas enumArea = Areas.getAreaEnumByName(area);
return enumArea;
Expand All @@ -37,7 +37,7 @@ public DSFLAreas getArea(double lat, double lng) throws AreaNotFoundException {
public Object[] getAreaDetailsForPoint(double lat, double lng) throws AreaNotFoundException {
LOGGER.debug("lat: "+ lat);
LOGGER.debug("lng: " + lng);
GeoInfoDao geoInfoDao = (GeoInfoDao) COPII_CONTEXT.getBean("geoInfoDao");
GeoInfoDao geoInfoDao = (GeoInfoDao) COPIII_CONTEXT.getBean("geoInfoDao");
return geoInfoDao.getAreaDetails(lat, lng);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class UserProvisioningService {

Logger LOGGER = LoggerFactory.getLogger(UserProvisioningService.class);

private static final ApplicationContext COPII_CONTEXT = new ClassPathXmlApplicationContext("copII-dao-context.xml");
private static final ApplicationContext COPIII_CONTEXT = new ClassPathXmlApplicationContext("copIII-dao-context.xml");

public UserProvisioningService() {}

Expand All @@ -43,7 +43,7 @@ public UserProvisioningService() {}
*/
public void createUser(User user) throws UserProvisioningServiceException {

UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
LOGGER.trace("createUser successfully retrieved UserDao from Spring application context");

try {
Expand All @@ -66,7 +66,7 @@ public void createUser(User user) throws UserProvisioningServiceException {
*/
public User getUserByPid(String pid) throws UserProvisioningServiceException {

UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
LOGGER.trace("getUserByPid successfully retrieved UserDao from Spring application context");
User user;
try {
Expand All @@ -91,7 +91,7 @@ public User getUserByPid(String pid) throws UserProvisioningServiceException {
*/
public String getUserNameByPid(String pid) throws UserProvisioningServiceException {

UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
LOGGER.trace("getUserByPid successfully retrieved UserDao from Spring application context");
String userName = null;
try {
Expand All @@ -117,7 +117,7 @@ public String getUserNameByPid(String pid) throws UserProvisioningServiceExcepti
* @return the list of Hibernate Users.
*/
public List<User> getUsersForTopList(int numberOfUsers) {
UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
List<User> x = userDao.getUsers(numberOfUsers);

return x;
Expand All @@ -131,7 +131,7 @@ public List<User> getUsersForTopList(int numberOfUsers) {
* @return the list of Hibernate Users.
*/
public List<User> getUsersFromAreaForTopList(int numberOfUsers, DSFLAreas aSpecificArea) {
UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
List<User> x = userDao.getUsers(numberOfUsers, aSpecificArea);

return x;
Expand All @@ -147,7 +147,7 @@ public List<User> getUsersFromAreaForTopList(int numberOfUsers, DSFLAreas aSpeci
*/
public UserRole getUserRole(int userRoleId) throws UserProvisioningServiceException {

UserRoleDao userRoleDao = (UserRoleDao) COPII_CONTEXT.getBean("userRoleDao");
UserRoleDao userRoleDao = (UserRoleDao) COPIII_CONTEXT.getBean("userRoleDao");
UserRole userRole;
try {
LOGGER.debug("Calling DAO layer to get user role {}", userRoleId);
Expand All @@ -163,7 +163,7 @@ public UserRole getUserRole(int userRoleId) throws UserProvisioningServiceExcept
@Deprecated
public void updateScore(String pid, String points) {
LOGGER.debug("adding " + points + " points for user " + pid);
UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");

User user = userDao.getUser(pid);
LOGGER.debug("user: " + user);
Expand All @@ -180,7 +180,7 @@ public void updateScore(String pid, String points) {
*/
public void updateScore(String pid, String points, DSFLAreas aSpecificArea) {
LOGGER.debug("adding " + points + " points for user " + pid);
UserDao userDao = (UserDao) COPII_CONTEXT.getBean("userDao");
UserDao userDao = (UserDao) COPIII_CONTEXT.getBean("userDao");
LOGGER.debug("aSpecificArea = {}", aSpecificArea.toString());

User user = userDao.getUser(pid);
Expand Down
47 changes: 47 additions & 0 deletions src/main/resources/copIII-dao-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:postgresql://localhost:25432/cop"/>
<property name="user" value="cop"/>
<property name="password" value="cop123"/>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<value>hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect</value>
</property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="dataSource" ref="dataSource"/>
</bean>

<tx:annotation-driven />

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<bean id="userDao" class="dk.kb.cop3.backend.crud.database.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="userRoleDao" class="dk.kb.cop3.backend.crud.database.UserRoleDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="geoInfoDao" class="dk.kb.cop3.backend.crud.database.GeoInfoDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>