Skip to content

Instantly share code, notes, and snippets.

@theresajayne
Created November 1, 2011 15:57
Show Gist options
  • Save theresajayne/1330920 to your computer and use it in GitHub Desktop.
Save theresajayne/1330920 to your computer and use it in GitHub Desktop.
UserRolesAssembler
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.co.inbrand.service.impl;
import uk.co.inbrand.dao.UserRolesDao;
import uk.co.inbrand.dto.UserRolesBase;
import uk.co.inbrand.model.UserRoles;
/**
*
* @author Thersa Jayne Forster
*/
public class UserRolesAssembler {
private UserRolesDao userRolesDao;
public UserRolesAssembler(UserRolesDao userRolesDao) {
this.userRolesDao = userRolesDao;
}
public void populateDomainFromBase(UserRoles domain, UserRolesBase dto) {
UserRoles domaintest = userRolesDao.getRecordById(dto.getId());
if (domaintest!=null) {
domain = domaintest;
}
domain.setId(dto.getId());
domain.setDescription(dto.getDescription());
domain.setRole_code(dto.getRole_code());
domain.setRole_value(dto.getRole_value());
}
public void extractBaseFromDomain(UserRoles domain, UserRolesBase dto) {
dto.setId(domain.getId());
dto.setRole_code(domain.getRole_code());
dto.setDescription(domain.getDescription());
dto.setRole_value(domain.getRole_value());
}
}
UserRolesBase
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.co.inbrand.dto;
import java.io.Serializable;
/**
*
* @author Thersa Jayne Forster
*/
public class UserRolesBase implements Serializable{
private int id;
private String description;
private String role_code;
private int role_value;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the role_code
*/
public String getRole_code() {
return role_code;
}
/**
* @param role_code the role_code to set
*/
public void setRole_code(String role_code) {
this.role_code = role_code;
}
/**
* @return the role_value
*/
public int getRole_value() {
return role_value;
}
/**
* @param role_value the role_value to set
*/
public void setRole_value(int role_value) {
this.role_value = role_value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment