001: package org.enhydra.dm.business;
002:
003: import org.enhydra.dm.api.AppUser;
004: import org.enhydra.dm.api.exceptions.BaseException;
005: import org.enhydra.dm.business.exceptions.DatabaseException;
006: import org.enhydra.dm.data.AppUserDO;
007:
008: import com.lutris.appserver.server.sql.DatabaseManagerException;
009: import com.lutris.appserver.server.sql.ObjectIdException;
010: import com.lutris.dods.builder.generator.query.DataObjectException;
011:
012: /**
013: * Implementation of AppUser interface.
014: *
015: * @author Svjetlana Milidrag
016: */
017:
018: public class AppUserImpl implements AppUser {
019:
020: String id;
021:
022: String firstname;
023:
024: String lastname;
025:
026: String username;
027:
028: String password;
029:
030: String role;
031:
032: public AppUserImpl() {
033:
034: }
035:
036: public AppUserImpl(AppUserDO userDO) throws BaseException {
037: try {
038: setId(userDO.get_OId().toString());
039: setFirstname(userDO.getFIRSTNAME());
040: setLastname(userDO.getLASTNAME());
041: setUsername(userDO.getUSERNAME());
042: setPassword(userDO.getPASSWORD());
043: setRole(userDO.getROLE());
044: } catch (Exception e) {
045: throw new DatabaseException(e);
046: }
047: }
048:
049: public String getFirstname() {
050: return firstname;
051: }
052:
053: public void setFirstname(String firstname) {
054: this .firstname = firstname;
055: }
056:
057: public String getLastname() {
058: return lastname;
059: }
060:
061: public void setLastname(String lastname) {
062: this .lastname = lastname;
063: }
064:
065: public String getId() {
066: return id;
067: }
068:
069: public void setId(String id) {
070: this .id = id;
071: }
072:
073: public String getPassword() {
074: return password;
075: }
076:
077: public void setPassword(String password) {
078: this .password = password;
079: }
080:
081: public String getRole() {
082: return role;
083: }
084:
085: public void setRole(String role) {
086: this .role = role;
087: }
088:
089: public String getUsername() {
090: return username;
091: }
092:
093: public void setUsername(String username) {
094: this .username = username;
095: }
096:
097: public AppUserDO createDO() throws BaseException {
098: try {
099: AppUserDO userDO = AppUserDO.createVirgin();
100: userDO.setFIRSTNAME(this .getFirstname());
101: userDO.setLASTNAME(this .getLastname());
102: userDO.setUSERNAME(this .getUsername());
103: userDO.setPASSWORD(this .getPassword());
104: userDO.setROLE(this .getRole());
105:
106: return userDO;
107: } catch (DatabaseManagerException e) {
108: throw new DatabaseException(e);
109: } catch (ObjectIdException e) {
110: throw new DatabaseException(e);
111: } catch (DataObjectException e) {
112: throw new DatabaseException(e);
113: }
114: }
115: }
|