@SuppressWarnings("unchecked") public List<Employee> findByCriteria(Employee employee) { Criteria c = getCurrentSession().createCriteria(Employee.class); if (!StringUtils.isNullOrEmpty(employee.getNameEng())) { c.add(Restrictions.like("nameEng", "%" + employee.getNameEng() + "%")); } return c.list(); }
@RequestMapping(value = "/family/{id}", method = RequestMethod.GET) public String initEmpFamily( Locale locale, @ModelAttribute(value = "family") Family family, ModelMap model, @PathVariable("id") Integer id, @ModelAttribute FamilyDto familyDto) { // init page for display page logger.info("Welcome to employee family(list) locale: " + locale); Employee employee = employeeService.findById(id); List<MasRelationType> masRelationTypeList = masRelationService.findAll(); model.addAttribute("family", family); model.addAttribute("masRelationTypeList", masRelationTypeList); model.addAttribute("appId", employee.getApplicant().getId()); familyDto.setEmployeeId(id); model.addAttribute("id", familyDto.getEmployeeId()); return "/family/familychange"; }
@Before public void setUp() { employee = new Employee(); employee.setIdCard("115310905001-9"); employee.setNameThai("อภิวาท์"); employee.setNameEng("apiva"); employee.setNicknameThai("va"); employee.setNicknameEng("va"); employee.setSurnameThai("กิมเกถนอม"); employee.setSurnameEng("kimkatanom"); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); String dateInString = "31-08-1982"; Date date = null; try { date = sdf.parse(dateInString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } employee.setDateOfBirth(date); employee.setEmail("*****@*****.**"); employee.setEmergencyContact("mom"); employee.setEmployeeCode("EMP-09"); employee.setStatusemp("Employee"); employee.setTelHome("089-0851022"); employee.setTelMobile("089-0851022"); employee.setEmergencyContactPhoneNumber("089-085-1022"); employee.setAuditFlag("C"); employee.setCreatedBy(1); employee.setCreatedTimeStamp(Calendar.getInstance().getTime()); MasTechnology masTechnology = new MasTechnology(); masTechnology.setName("java"); masTechnology.setCode("001A"); masTechnology.setIsActive(true); masTechnology.setAuditFlag("C"); masTechnology.setCreatedBy(0); Calendar cal = Calendar.getInstance(); masTechnology.setCreatedTimeStamp(cal.getTime()); masTechnologyRepository.create(masTechnology); mastec = masTechnology.getId(); MasTechnology mTechnology = masTechnologyRepository.find(mastec); MasJoblevel masJoblevel = new MasJoblevel(); masJoblevel.setName("CEO"); masJoblevel.setIsActive(true); masJoblevel.setCode("01"); masJoblevel.setAuditFlag("C"); masJoblevel.setCreatedBy(1); masJoblevel.setCreatedTimeStamp(Calendar.getInstance().getTime()); masJoblevel.setCode("Division-01"); masJoblevelRepository.create(masJoblevel); masjobId = masJoblevel.getId(); MasJoblevel mJob = masJoblevelRepository.find(masjobId); Applicant applicant = new Applicant(); applicant.setCreatedBy(1); applicant.setCreatedTimeStamp(Calendar.getInstance().getTime()); applicant.setAuditFlag("C"); applicant.setCardId("115310905001-9"); applicant.setTechnology(mTechnology); applicant.setJoblevel(mJob); applicantRepository.create(applicant); int appId = applicant.getId(); Applicant applicant1 = applicantRepository.find(appId); Hibernate.initialize(applicant1); employee.setApplicant(applicant1); MasDivision masDivision = new MasDivision(); masDivision.setName("CEO"); masDivision.setIsActive(true); masDivision.setCode("01"); masDivision.setAuditFlag("C"); masDivision.setCreatedBy(1); masDivision.setCreatedTimeStamp(Calendar.getInstance().getTime()); masDivision.setCode("Division-01"); masDivisionRepository.create(masDivision); int masDivisionId = masDivision.getId(); masDivisionRepository.find(masDivisionId); employee.setMasDivision(masDivision); employee.setMasJoblevel(mJob); employeeRepository.create(employee); Calendar calendarStartDate = new GregorianCalendar(2013, 10, 28); // GregorianCalendar jan=0,12=Jan Calendar calendarEndDate = new GregorianCalendar(2014, 11, 28); Site site = new Site(); site.setProjectName("Augmentis-01"); site.setStartDate(calendarStartDate.getTime()); site.setEndDate(calendarEndDate.getTime()); site.setProjectOwner("Augmentis"); site.setProjectOwnerContact("PM"); site.setEmployee(employee); site.setAuditFlag("C"); site.setCreatedBy(1); site.setCreatedTimeStamp(Calendar.getInstance().getTime()); siteRepository.create(site); id = site.getId(); }