001: // license-header java merge-point
002: /**
003: * This is only generated once! It will never be overwritten.
004: * You can (and have to!) safely modify it by hand.
005: */package org.andromda.timetracker.domain;
006:
007: import java.util.Collection;
008:
009: import org.andromda.timetracker.vo.UserRoleVO;
010:
011: /**
012: * @see org.andromda.timetracker.domain.User
013: */
014: public class UserDaoImpl extends
015: org.andromda.timetracker.domain.UserDaoBase {
016: /**
017: * @see org.andromda.timetracker.domain.UserDao#toUserVO(org.andromda.timetracker.domain.User, org.andromda.timetracker.vo.UserVO)
018: */
019: public void toUserVO(
020: org.andromda.timetracker.domain.User sourceEntity,
021: org.andromda.timetracker.vo.UserVO targetVO) {
022: // @todo verify behavior of toUserVO
023: super .toUserVO(sourceEntity, targetVO);
024: }
025:
026: /**
027: * @see org.andromda.timetracker.domain.UserDao#toUserVO(org.andromda.timetracker.domain.User)
028: */
029: public org.andromda.timetracker.vo.UserVO toUserVO(
030: final org.andromda.timetracker.domain.User entity) {
031: // @todo verify behavior of toUserVO
032: return super .toUserVO(entity);
033: }
034:
035: /**
036: * Retrieves the entity object that is associated with the specified value object
037: * from the object store. If no such entity object exists in the object store,
038: * a new, blank entity is created
039: */
040: private org.andromda.timetracker.domain.User loadUserFromUserVO(
041: org.andromda.timetracker.vo.UserVO userVO) {
042: // @todo implement loadUserFromUserVO
043: throw new java.lang.UnsupportedOperationException(
044: "org.andromda.timetracker.domain.loadUserFromUserVO(org.andromda.timetracker.vo.UserVO) not yet implemented.");
045:
046: /* A typical implementation looks like this:
047: org.andromda.timetracker.domain.User user = this.load(userVO.getId());
048: if (user == null)
049: {
050: user = org.andromda.timetracker.domain.User.Factory.newInstance();
051: }
052: return user;
053: */
054: }
055:
056: /**
057: * @see org.andromda.timetracker.domain.UserDao#userVOToEntity(org.andromda.timetracker.vo.UserVO)
058: */
059: public org.andromda.timetracker.domain.User userVOToEntity(
060: org.andromda.timetracker.vo.UserVO userVO) {
061: // @todo verify behavior of userVOToEntity
062: org.andromda.timetracker.domain.User entity = this
063: .loadUserFromUserVO(userVO);
064: this .userVOToEntity(userVO, entity, true);
065: return entity;
066: }
067:
068: /**
069: * @see org.andromda.timetracker.domain.UserDao#userVOToEntity(org.andromda.timetracker.vo.UserVO, org.andromda.timetracker.domain.User)
070: */
071: public void userVOToEntity(
072: org.andromda.timetracker.vo.UserVO sourceVO,
073: org.andromda.timetracker.domain.User targetEntity,
074: boolean copyIfNull) {
075: // @todo verify behavior of userVOToEntity
076: super .userVOToEntity(sourceVO, targetEntity, copyIfNull);
077: }
078:
079: /**
080: * @see org.andromda.timetracker.domain.UserDao#toUserDetailsVO(org.andromda.timetracker.domain.User, org.andromda.timetracker.vo.UserDetailsVO)
081: */
082: public void toUserDetailsVO(
083: org.andromda.timetracker.domain.User sourceEntity,
084: org.andromda.timetracker.vo.UserDetailsVO targetVO) {
085: super .toUserDetailsVO(sourceEntity, targetVO);
086:
087: // Convert roles
088: Collection srcRoles = sourceEntity.getRoles();
089: UserRoleVO[] targetRoles = new UserRoleVO[srcRoles.size()];
090: int i = 0;
091: for (Object srcRole : srcRoles) {
092: targetRoles[i] = getUserRoleDao().toUserRoleVO(
093: (UserRole) srcRole);
094: i++;
095: }
096: targetVO.setRoles(targetRoles);
097: }
098:
099: /**
100: * @see org.andromda.timetracker.domain.UserDao#toUserDetailsVO(org.andromda.timetracker.domain.User)
101: */
102: public org.andromda.timetracker.vo.UserDetailsVO toUserDetailsVO(
103: final org.andromda.timetracker.domain.User entity) {
104: // @todo verify behavior of toUserDetailsVO
105: return super .toUserDetailsVO(entity);
106: }
107:
108: /**
109: * Retrieves the entity object that is associated with the specified value object
110: * from the object store. If no such entity object exists in the object store,
111: * a new, blank entity is created
112: */
113: private org.andromda.timetracker.domain.User loadUserFromUserDetailsVO(
114: org.andromda.timetracker.vo.UserDetailsVO userDetailsVO) {
115: // @todo implement loadUserFromUserDetailsVO
116: throw new java.lang.UnsupportedOperationException(
117: "org.andromda.timetracker.domain.loadUserFromUserDetailsVO(org.andromda.timetracker.vo.UserDetailsVO) not yet implemented.");
118:
119: /* A typical implementation looks like this:
120: org.andromda.timetracker.domain.User user = this.load(userDetailsVO.getId());
121: if (user == null)
122: {
123: user = org.andromda.timetracker.domain.User.Factory.newInstance();
124: }
125: return user;
126: */
127: }
128:
129: /**
130: * @see org.andromda.timetracker.domain.UserDao#userDetailsVOToEntity(org.andromda.timetracker.vo.UserDetailsVO)
131: */
132: public org.andromda.timetracker.domain.User userDetailsVOToEntity(
133: org.andromda.timetracker.vo.UserDetailsVO userDetailsVO) {
134: // @todo verify behavior of userDetailsVOToEntity
135: org.andromda.timetracker.domain.User entity = this
136: .loadUserFromUserDetailsVO(userDetailsVO);
137: this .userDetailsVOToEntity(userDetailsVO, entity, true);
138: return entity;
139: }
140:
141: /**
142: * @see org.andromda.timetracker.domain.UserDao#userDetailsVOToEntity(org.andromda.timetracker.vo.UserDetailsVO, org.andromda.timetracker.domain.User)
143: */
144: public void userDetailsVOToEntity(
145: org.andromda.timetracker.vo.UserDetailsVO sourceVO,
146: org.andromda.timetracker.domain.User targetEntity,
147: boolean copyIfNull) {
148: // @todo verify behavior of userDetailsVOToEntity
149: super .userDetailsVOToEntity(sourceVO, targetEntity, copyIfNull);
150: }
151:
152: protected User handleGetUserDetails(String username)
153: throws Exception {
154:
155: User user = (User) getSession()
156: .createQuery(
157: "from org.andromda.timetracker.domain.User user left join fetch user.roles where user.username = :username")
158: .setParameter("username", username).uniqueResult();
159: return user;
160: }
161: }
|