Permalink
Browse files

location information now loaded from user registration page

  • Loading branch information...
1 parent 0c68f2c commit 1573e6a0bdf5f88b9a0d457905c0128a9f09a7d9 @jbolaky committed Sep 27, 2011
@@ -8,8 +8,6 @@
import java.util.List;
import java.util.Set;
-import javax.annotation.Resource;
-
import org.apache.commons.lang.math.RandomUtils;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
@@ -48,9 +46,6 @@
@Autowired
private PoolsRepository poolsRepository;
- @Resource(name="x")
- private com.javaid.bolaky.domain.pools.entity.Test test;
-
@Before
public void populateUsername() {
Authentication authentication = new UsernamePasswordAuthenticationToken(
@@ -7,4 +7,8 @@
public interface LocationAcl {
Set<LocationVO> getAllCountries();
+
+ Set<LocationVO> getAreas(Long countryId);
+
+ Set<LocationVO> getDistricts(Long areaId);
}
@@ -2,19 +2,37 @@
import java.util.Set;
+import javax.annotation.Resource;
+
import com.javaid.bolaky.carpool.service.acl.location.api.LocationAcl;
import com.javaid.bolaky.carpool.service.vo.LocationVO;
+import com.javaid.bolaky.domain.location.entity.Area;
import com.javaid.bolaky.domain.location.entity.Country;
import com.javaid.bolaky.domain.location.service.api.LocationService;
public class DefaultLocationAcl implements LocationAcl {
+ @Resource(name = "location_domain_DefaultLocationService")
private LocationService locationService;
public Set<LocationVO> getAllCountries() {
Set<Country> countries = locationService.findCountries();
- return LocationAclTranslator.mapCountryVOs(countries);
+ return LocationAclTranslator.mapCountries(countries);
+ }
+
+ public Set<LocationVO> getAreas(Long countryId) {
+
+ Country country = locationService.findCountry(countryId);
+ return LocationAclTranslator.mapAreas(country != null ? country
+ .getAreas() : null);
+ }
+
+ public Set<LocationVO> getDistricts(Long areaId) {
+
+ Area area = locationService.findArea(areaId);
+ return LocationAclTranslator.mapDistricts(area != null ? area
+ .getDistricts() : null);
}
}
@@ -5,25 +5,57 @@
import org.apache.commons.collections15.set.ListOrderedSet;
import com.javaid.bolaky.carpool.service.vo.LocationVO;
+import com.javaid.bolaky.domain.location.entity.Area;
import com.javaid.bolaky.domain.location.entity.Country;
+import com.javaid.bolaky.domain.location.entity.District;
public class LocationAclTranslator {
- public static Set<LocationVO> mapCountryVOs(Set<Country> countries) {
+ public static Set<LocationVO> mapCountries(Set<Country> countries) {
- Set<LocationVO> countryVOs = new ListOrderedSet<LocationVO>();
+ Set<LocationVO> locationVOs = new ListOrderedSet<LocationVO>();
if (countries != null && !countries.isEmpty()) {
for (Country country : countries) {
- LocationVO countryVO = new LocationVO();
- countryVO.setCountryId(country.getCountryId());
- countryVO.setCountryName(country.getCountryName());
- countryVOs.add(countryVO);
+ locationVOs.add(new LocationVO(country.getCountryId(), country
+ .getCountryName(), null, null, null, null));
}
}
- return countryVOs;
+ return locationVOs;
+ }
+
+ public static Set<LocationVO> mapAreas(Set<Area> areas) {
+
+ Set<LocationVO> locationVOs = new ListOrderedSet<LocationVO>();
+
+ if (areas != null && !areas.isEmpty()) {
+
+ for (Area area : areas) {
+
+ locationVOs.add(new LocationVO(null, null, area.getAreaId(),
+ area.getAreaName(), null, null));
+ }
+ }
+
+ return locationVOs;
+ }
+
+ public static Set<LocationVO> mapDistricts(Set<District> districts) {
+
+ Set<LocationVO> locationVOs = new ListOrderedSet<LocationVO>();
+
+ if (districts != null && !districts.isEmpty()) {
+
+ for (District district : districts) {
+
+ locationVOs.add(new LocationVO(null, null, null, null, district
+ .getDistrictId(), district.getDistrictName()));
+ }
+ }
+
+ return locationVOs;
}
}
@@ -19,13 +19,17 @@
Set<CarPoolError> validate(PoolRegistrationVO carPoolRegistrationVO);
Boolean store(UserVO userVO);
-
+
Boolean update(UserVO userVO);
Boolean saveOrUpdate(PoolRegistrationVO poolRegistrationVO);
Set<LocationVO> getAllCountries();
+ Set<LocationVO> getAreas(Long countryId);
+
+ Set<LocationVO> getDistricts(Long areaId);
+
Boolean emailPassword(String firstname, String lastname, String password,
String recipientEmailAddress) throws EmailAclException;
@@ -34,15 +38,15 @@ Boolean emailPassword(String firstname, String lastname, String password,
PoolRegistrationVO createCarpoolRegistrationVO(String username);
PoolRegistrationVO findPoolRegistrationVO(Long poolId);
-
+
void populateGenderAndUsername(PoolRegistrationVO poolRegistrationVO,
String username);
Set<PoolSearchResultVO> findPools(PoolSearchVO poolSearchVO);
Set<PoolVO> findPools(String username);
-
+
PoolVO findPool(Long poolId);
-
+
Boolean sendRequestForPooling(ContactDriverVO contactDriverVO);
}
@@ -35,6 +35,7 @@
@Resource(name = "pools_service_DefaultPoolsAcl")
private PoolsAcl poolsAcl;
+ @Resource(name = "pools_service_DefaultLocationAcl")
private LocationAcl locationAcl;
public Set<CarPoolError> validate(UserVO userVO) {
@@ -53,7 +54,7 @@ public Boolean store(UserVO userVO) {
return userRegistrationAcl.store(userVO);
}
-
+
@Transactional
public Boolean update(UserVO userVO) {
@@ -81,6 +82,18 @@ public void populateGenderAndUsername(
return locationAcl.getAllCountries();
}
+ @Transactional
+ public Set<LocationVO> getAreas(Long countryId) {
+
+ return locationAcl.getAreas(countryId);
+ }
+
+ @Transactional
+ public Set<LocationVO> getDistricts(Long areaId) {
+
+ return locationAcl.getDistricts(areaId);
+ }
+
public Boolean emailPassword(String firstname, String lastname,
String password, String recipientEmailAddress)
throws EmailAclException {
@@ -7,6 +7,7 @@
<import resource="classpath:/default-user-registration-service-context.xml" />
<import resource="classpath:/email-default-context.xml" />
<import resource="classpath:/default-pools-service-context.xml" />
+ <import resource="classpath:/default-location-service-context.xml" />
<import resource="classpath:/default-carpool-service-spring-jpa-config.xml" />
<context:component-scan base-package="com.javaid.bolaky.carpool.service.impl" />
@@ -19,4 +20,7 @@
<bean id="pools_service_DefaultPoolsAcl"
class="com.javaid.bolaky.carpool.service.acl.pools.impl.DefaultPoolsAcl" />
-</beans>
+ <bean id="pools_service_DefaultLocationAcl"
+ class="com.javaid.bolaky.carpool.service.acl.location.impl.DefaultLocationAcl" />
+
+</beans>
@@ -11,9 +11,10 @@
<list>
<value>classpath*:META-INF/user-registration-persistence.xml</value>
<value>classpath*:META-INF/pools-persistence.xml</value>
+ <value>classpath*:META-INF/location-persistence.xml</value>
</list>
</property>
<property name="defaultDataSource" ref="pools_DataSource" />
</bean>
-</beans>
+</beans>

0 comments on commit 1573e6a

Please sign in to comment.