From: <eri...@us...> - 2009-01-08 13:26:25
|
Revision: 1912 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=1912&view=rev Author: erikvaningen Date: 2009-01-08 13:26:21 +0000 (Thu, 08 Jan 2009) Log Message: ----------- created ServiceDao. Added Service to this Dao. Modified Paths: -------------- sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/resources/org/geonetwork/domain/ebrim/informationmodel/core/Identifiable.hbm.xml sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/resources/applicationContext-hibernate-test.xml Added Paths: ----------- sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDao.java sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDaoTest.java Added: sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDao.java =================================================================== --- sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDao.java (rev 0) +++ sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDao.java 2009-01-08 13:26:21 UTC (rev 1912) @@ -0,0 +1,42 @@ +package org.geonetwork.dao.ebrim.informationmodel; + +import java.util.List; + +import org.geonetwork.domain.ebrim.informationmodel.service.Service; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +/** + * + * Dao for Service, ServiceBinding and SpecificationLink + * + * + * @author Erik van Ingen + * + */ +public class ServiceDao extends HibernateDaoSupport { + + /** + * Service + */ + public void saveService(Service service) { + this.getHibernateTemplate().save(service); + } + + public void mergeService(Service service) { + this.getHibernateTemplate().merge(service); + } + + public void deleteService(Service service) { + this.getHibernateTemplate().delete(service); + } + + @SuppressWarnings("unchecked") + public List<Service> loadAllService() { + return this.getHibernateTemplate().loadAll(Service.class); + } + + public Service findServiceById(long id) { + return (Service) this.getHibernateTemplate().load(Service.class, id); + } + +} Modified: sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/resources/org/geonetwork/domain/ebrim/informationmodel/core/Identifiable.hbm.xml =================================================================== --- sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/resources/org/geonetwork/domain/ebrim/informationmodel/core/Identifiable.hbm.xml 2009-01-08 12:01:02 UTC (rev 1911) +++ sandbox/3.0.x/geonetwork-persistence-ebrim/src/main/resources/org/geonetwork/domain/ebrim/informationmodel/core/Identifiable.hbm.xml 2009-01-08 13:26:21 UTC (rev 1912) @@ -236,6 +236,7 @@ </set> </union-subclass> + <union-subclass name="org.geonetwork.domain.ebrim.informationmodel.service.ServiceBinding" table="SERVICE_BINDING"> <comment>ServiceBinding</comment> <component name="accessURI" class="org.geonetwork.domain.ebrim.informationmodel.core.datatype.URI"> @@ -287,6 +288,8 @@ </set> </union-subclass> + + </union-subclass> <union-subclass name="org.geonetwork.domain.ebrim.informationmodel.core.ObjectRef" table="OBJECT_REF"> Added: sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDaoTest.java =================================================================== --- sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDaoTest.java (rev 0) +++ sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/java/org/geonetwork/dao/ebrim/informationmodel/ServiceDaoTest.java 2009-01-08 13:26:21 UTC (rev 1912) @@ -0,0 +1,52 @@ +package org.geonetwork.dao.ebrim.informationmodel; + +import java.util.HashSet; +import java.util.Set; + +import org.geonetwork.dao.ebrim.AbstractDaoTest; +import org.geonetwork.dao.ebrim.provenance.DaoTestDelegate; +import org.geonetwork.domain.ebrim.informationmodel.service.Service; +import org.geonetwork.domain.ebrim.informationmodel.service.ServiceBinding; +import org.geonetwork.domain.ebrim.test.utilities.service.ServiceBindingFactory; +import org.geonetwork.domain.ebrim.test.utilities.service.ServiceFactory; + +public class ServiceDaoTest extends AbstractDaoTest { + + ServiceDao serviceDao; + + public void setServiceDao(ServiceDao serviceDao) { + this.serviceDao = serviceDao; + } + + /** + * Service + */ + public void testSaveService() { + new DaoTestDelegate(serviceDao).testSave(Service.class); + } + + public void testMergeService1() { + Service service = ServiceFactory.create(); + ServiceBinding serviceBinding = ServiceBindingFactory.create(); + Set <ServiceBinding> serviceBindings = new HashSet<ServiceBinding>(); + serviceBindings.add(serviceBinding); + service.setServiceBindings(serviceBindings); + assertEquals(0, serviceDao.loadAllService().size()); + serviceDao.saveService(service); + assertEquals(1, serviceDao.loadAllService().size()); + serviceBinding.getAccessURI().setValue("check"); + serviceDao.mergeService(service); + Service serviceFound = serviceDao.findServiceById(service.getHibernateId()); + ServiceBinding serviceBindingFound = serviceFound.getServiceBindings().iterator().next(); + assertEquals("check", serviceBindingFound.getAccessURI().getValue()); + } + + public void testDeleteService() { + new DaoTestDelegate(serviceDao).testDelete(Service.class); + } + + public void testfindServiceById() { + new DaoTestDelegate(serviceDao).testfindById(Service.class); + } + +} Modified: sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/resources/applicationContext-hibernate-test.xml =================================================================== --- sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/resources/applicationContext-hibernate-test.xml 2009-01-08 12:01:02 UTC (rev 1911) +++ sandbox/3.0.x/geonetwork-persistence-ebrim/src/test/resources/applicationContext-hibernate-test.xml 2009-01-08 13:26:21 UTC (rev 1912) @@ -114,6 +114,7 @@ <bean id="cooperatingRegistriesDao" class="org.geonetwork.dao.ebrim.informationmodel.CooperatingRegistriesDao" parent="hibernateDaoSupport" /> <bean id="eventDao" class="org.geonetwork.dao.ebrim.informationmodel.EventDao" parent="hibernateDaoSupport" /> + <bean id="serviceDao" class="org.geonetwork.dao.ebrim.informationmodel.ServiceDao" parent="hibernateDaoSupport" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |