public BusinessObjectService getBusinessObjectService() { if(businessObjectService == null) { businessObjectService = KRADServiceLocator.getBusinessObjectService(); } return businessObjectService; }
public BusinessObjectService getBusinessObjectService() { if (null == businessObjectService) { businessObjectService = KRADServiceLocator.getBusinessObjectService(); } return businessObjectService; }
private RemoteSwipeDevice getRemoteSwipeDeviceUsingIpAddress(String ipAddress){ Map<String, String> fields = new HashMap<String, String>(); fields.put("ipAddress", ipAddress); RemoteSwipeDevice remoteSwipeDevice = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(RemoteSwipeDevice.class, fields); return remoteSwipeDevice; }
@Override public void saveOrUpdate(LeavePayout payout) { KRADServiceLocator.getBusinessObjectService().save(payout); }
@Override public void saveOrUpdate(BalanceTransfer balanceTransfer) { KRADServiceLocator.getBusinessObjectService().save(balanceTransfer); }
public void serializeToCSV() throws FileNotFoundException { // Fetching data using BO service Collection timeBlocks = KRADServiceLocator.getBusinessObjectService() .findAll(TimeBlockBo.class); Iterator<TimeBlockBo> itr = timeBlocks.iterator(); while (itr.hasNext()) { TimeBlockBo timeBlockObj = itr.next(); try { // Create file FileWriter fstream = new FileWriter(System.getProperty("user.home") + "\\TimeBlockData.csv", true); BufferedWriter out = new BufferedWriter(fstream); out.write(timeBlockObj.toCSVString()); // Close the output BufferedWriter out.close(); } catch (Exception e) {// Catch exception if any e.printStackTrace(); } } }
@Override public void heartbeat(@Context HttpServletRequest hsr) { LOG.info("heartbeat - Start"); String ipAddress = hsr.getRemoteAddr(); String fwdIp = hsr.getHeader("X-Forwarded-For"); if (fwdIp != null) { ipAddress = fwdIp; } LOG.info("heartbeat - IP Address:"+ipAddress); RemoteSwipeDevice remoteSwipeDevice = getRemoteSwipeDeviceUsingIpAddress(ipAddress); if (checkValidRemoteDevice(remoteSwipeDevice)) { remoteSwipeDevice.setLastSeenOnline(new Timestamp(System.currentTimeMillis()).toString()); KRADServiceLocator.getBusinessObjectService().save(remoteSwipeDevice); LOG.info("heartbeat - Valid remote device"); } else LOG.info("heartbeat - Invalid remote device"); }
protected List<LeaveBlockBo> saveLeaveBlockBos(List<LeaveBlockBo> leaveBlocks) { List<LeaveBlockBo> savedLeaveBlocks = new ArrayList<LeaveBlockBo>(); Collection<LeaveBlockBo> savedObjects = (Collection<LeaveBlockBo>) KRADServiceLocator.getBusinessObjectService().save(leaveBlocks); List<LeaveBlockHistory> leaveBlockHistories = new ArrayList<LeaveBlockHistory>(); for (LeaveBlockBo leaveBlock : leaveBlocks) { LeaveBlockHistory lbh = new LeaveBlockHistory(leaveBlock); lbh.setAction(HrConstants.ACTION.ADD); leaveBlockHistories.add(lbh); HrServiceLocator.getHRPermissionService().updateLeaveBlockPermissions(CalendarBlockPermissions.newInstance(leaveBlock.getLmLeaveBlockId())); } KRADServiceLocator.getBusinessObjectService().save(leaveBlockHistories); savedLeaveBlocks.addAll(savedObjects); return savedLeaveBlocks; }
@Override public TimeBlock updateTimeBlock(TimeBlock tb) { if (tb == null) { return null; } return TimeBlockBo.to(KRADServiceLocator.getBusinessObjectService().save(TimeBlockBo.from(tb))); }
@Override public void saveBusinessObject() { ClockLogBo clockLog = (ClockLogBo) this.getBusinessObject(); clockLog.setTkClockLogId(null); clockLog.setTimestamp(null); KRADServiceLocator.getBusinessObjectService().save(clockLog); }
public void remove(String timeBlockId) { Criteria removalCriteria = new Criteria(); removalCriteria.addEqualTo("tkTimeBlockId", timeBlockId); Query query = QueryFactory.newQuery(TimeHourDetailBo.class, removalCriteria); List<TimeHourDetailBo> deleteList = (List<TimeHourDetailBo>) this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if(CollectionUtils.isNotEmpty(deleteList)) { KRADServiceLocator.getBusinessObjectService().delete(deleteList); } // this.getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(TimeHourDetailBo.class, removalCriteria)); }
@Override public void saveBusinessObject() { ClockLocationRule clr = (ClockLocationRule) this.getBusinessObject(); List<ClockLocationRuleIpAddress> ips = clr.getIpAddresses(); super.saveBusinessObject(); if(!ips.isEmpty()) { for(ClockLocationRuleIpAddress ipAddress : ips) { ipAddress.setTkClockLocationRuleId(clr.getTkClockLocationRuleId()); KRADServiceLocator.getBusinessObjectService().save(ipAddress); } CacheUtils.flushCache(ClockLocationRule.CACHE_NAME); } } }
@Override public void deleteTimeBlockAndHandleMissedPunch(TimeBlock timeBlock, boolean ignoreMissedPunch) { TimeBlockBo timeBlockBo = TimeBlockBo.from(timeBlock); //Add note to timesheet if approver deleted the timeblock. if (timeBlock.isClockedByMissedPunch() && !ignoreMissedPunch) { TkServiceLocator.getMissedPunchDocumentService().cancelMissedPunchDocumentWithDocumentId(timeBlock.getMissedPunchDocId()); } addNote(timeBlockBo, "deleted"); KRADServiceLocator.getBusinessObjectService().delete(timeBlockBo); }
@Override public LeaveBlock saveLeaveBlock(LeaveBlock leaveBlock, String principalId) { LeaveBlockBo savedLeaveBlock = null; LeaveBlockBo existingLB = LeaveBlockBo.from(leaveBlock); // first delete and create new entry in the database KRADServiceLocator.getBusinessObjectService().delete(existingLB); // create new existingLB.setLmLeaveBlockId(null); existingLB.setTimestamp(TKUtils.getCurrentTimestamp()); existingLB.setPrincipalIdModified(principalId); savedLeaveBlock = KRADServiceLocator.getBusinessObjectService().save(existingLB); // save history LeaveBlockHistory lbh = new LeaveBlockHistory(existingLB); lbh.setAction(HrConstants.ACTION.MODIFIED); LmServiceLocator.getLeaveBlockHistoryService().saveLeaveBlockHistory(lbh); return LeaveBlockBo.to(savedLeaveBlock); }
@Override public List<TimeBlock> saveTimeBlocks(List<TimeBlock> tbList) { List<TimeBlockBo> savedTimeBlocks = new ArrayList<TimeBlockBo>(); for (TimeBlock tb : tbList) { TimeBlockBo tbBo = TimeBlockBo.from(tb); if (StringUtils.isNotEmpty(tb.getTkTimeBlockId())) { HrServiceLocator.getHRPermissionService().updateTimeBlockPermissions(CalendarBlockPermissions.newInstance(tb.getTkTimeBlockId())); } TkServiceLocator.getTimeHourDetailService().removeTimeHourDetails(tb.getTkTimeBlockId()); savedTimeBlocks.add(KRADServiceLocator.getBusinessObjectService().save(tbBo)); for(TimeBlockHistory tbh : tbBo.getTimeBlockHistories()){ TkServiceLocator.getTimeBlockHistoryService().saveTimeBlockHistory(tbh); } } return ModelObjectUtils.transform(savedTimeBlocks, toTimeBlock); }
@Override public void updatePrincipalAccrualRanInfo(String principalId) { PrincipalAccrualRan par = this.getLastPrincipalAccrualRan(principalId); if(par == null) { // no data for last ran par = new PrincipalAccrualRan(); par.setPrincipalId(principalId); par.setLastRanTs(TKUtils.getCurrentTimestamp()); } else { par.setLastRanTs(TKUtils.getCurrentTimestamp()); } KRADServiceLocator.getBusinessObjectService().save(par); }
@Override public ClockLog saveClockLog(ClockLog clockLog, boolean missedPunch) throws InvalidClockLogException { if (clockLog == null) { return null; } try { if (StringUtils.equals(clockLog.getPrincipalId(), clockLog.getUserPrincipalId())) { invalidIpCheck(clockLog.getGroupKeyCode(), clockLog.getDept(), clockLog.getWorkArea(), clockLog.getPrincipalId(), clockLog.getJobNumber(), clockLog.getIpAddress(), LocalDate.now(), missedPunch); } } catch (InvalidClockLogException e) { throw new RuntimeException("Could not take the action as Action taken from an invalid IP address."); } ClockLogBo bo = ClockLogBo.from(clockLog); bo = KRADServiceLocator.getBusinessObjectService().save(bo); return ClockLogBo.to(bo); }
@Override public TimeHourDetail saveTimeHourDetail(TimeBlock tb) { TimeHourDetailBo td = new TimeHourDetailBo(); td.setTkTimeBlockId(tb.getTkTimeBlockId()); td.setEarnCode(tb.getEarnCode()); td.setHours(tb.getHours()); td.setTotalMinutes(tb.getTotalMinutes()); td.setAmount(tb.getAmount()); TimeHourDetailBo timeHourDetailBo = KRADServiceLocator.getBusinessObjectService().save(td); return TimeHourDetailBo.to(timeHourDetailBo); }
protected LeaveCalendarDocument initiateWorkflowDocument(String principalId, DateTime payBeginDate, DateTime payEndDate, CalendarEntry calendarEntry, String documentType, String title) throws WorkflowException { LeaveCalendarDocument leaveCalendarDocument; WorkflowDocument workflowDocument; workflowDocument = WorkflowDocumentFactory.createDocument(principalId, documentType, title); String status = workflowDocument.getStatus().getCode(); LeaveCalendarDocumentHeader documentHeader = new LeaveCalendarDocumentHeader(workflowDocument.getDocumentId(), principalId, payBeginDate.toDate(), payEndDate.toDate(), status); documentHeader.setDocumentId(workflowDocument.getDocumentId()); documentHeader.setDocumentStatus(HrConstants.ROUTE_STATUS.INITIATED); KRADServiceLocator.getBusinessObjectService().save(documentHeader); leaveCalendarDocument = new LeaveCalendarDocument(documentHeader); leaveCalendarDocument.setCalendarEntry(calendarEntry); loadLeaveCalendarDocumentData(leaveCalendarDocument, principalId, calendarEntry); TkServiceLocator.getTkSearchableAttributeService().updateSearchableAttribute(leaveCalendarDocument, payEndDate.toLocalDate()); updateLeaveBlockDocumentIds(principalId, payBeginDate.toLocalDate(), payEndDate.toLocalDate(), workflowDocument.getDocumentId()); updatePlannedLeaveBlocks(principalId, payBeginDate.toLocalDate(), payEndDate.toLocalDate()); return leaveCalendarDocument; }
@Override public void deleteLunchDeduction(String tkTimeHourDetailId) { TimeHourDetail thd = TkServiceLocator.getTimeHourDetailService().getTimeHourDetail(tkTimeHourDetailId); TimeBlockBo tb = getTimeBlockBo(thd.getTkTimeBlockId()); //clear any timeblock permissions HrServiceLocator.getHRPermissionService().updateTimeBlockPermissions(CalendarBlockPermissions.newInstance(tb.getTkTimeBlockId())); // mark the lunch deleted as Y tb.setLunchDeleted(true); // save the change KRADServiceLocator.getBusinessObjectService().save(tb); // remove the related time hour detail row with the lunch deduction TkServiceLocator.getTimeHourDetailService().removeTimeHourDetail(thd.getTkTimeHourDetailId()); } /*@Override