@Override public <T> T save(T dataObject) { if (dataObject instanceof Collection) { Collection<Object> newList = new ArrayList<Object>(((Collection) dataObject).size()); for (Object obj : (Collection<?>) dataObject) { newList.add(save(obj)); } return (T) newList; } else { return (T) businessObjectService.save((PersistableBusinessObject) dataObject); } }
@Override public void saveOrUpdate(LeavePayout payout) { KRADServiceLocator.getBusinessObjectService().save(payout); }
@Override public void saveOrUpdate(BalanceTransfer balanceTransfer) { KRADServiceLocator.getBusinessObjectService().save(balanceTransfer); }
@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"); }
/** * @see org.kuali.rice.krad.maintenance.Maintainable#saveBusinessObject() */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void saveBusinessObject() { BusinessObjectService boService = KNSServiceLocator.getBusinessObjectService(); GlobalBusinessObject gbo = (GlobalBusinessObject) businessObject; // delete any indicated BOs List bosToDeactivate = gbo.generateDeactivationsToPersist(); if (bosToDeactivate != null) { if (!bosToDeactivate.isEmpty()) { boService.save(bosToDeactivate); } } // persist any indicated BOs List bosToPersist = gbo.generateGlobalChangesToPersist(); if (bosToPersist != null) { if (!bosToPersist.isEmpty()) { boService.save(bosToPersist); } } }
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); }
@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 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 void updateLeaveBlock(LeaveBlock leaveBlock, String principalId) { LeaveBlockBo leaveBlockBo = LeaveBlockBo.from(leaveBlock); //verify that if leave block is usage, leave amount is negative leaveBlockBo.setLeaveAmount(negateHoursIfNecessary(leaveBlock.getLeaveBlockType(), leaveBlock.getLeaveAmount())); // Make entry into LeaveBlockHistory table LeaveBlockHistory leaveBlockHistory = new LeaveBlockHistory(leaveBlockBo); leaveBlockHistory.setPrincipalIdDeleted(principalId); leaveBlockHistory.setTimestampDeleted(TKUtils.getCurrentTimestamp()); leaveBlockHistory.setAction(HrConstants.ACTION.MODIFIED); KRADServiceLocator.getBusinessObjectService().save(leaveBlockBo); // creating history KRADServiceLocator.getBusinessObjectService().save(leaveBlockHistory); if(leaveBlockBo.getLeaveBlockType().equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_CALENDAR) || leaveBlockBo.getLeaveBlockType().equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR)){ String userCompositName = ""; if (StringUtils.isNotEmpty(principalId)) { EntityNamePrincipalName entName = KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(principalId); if (entName != null && entName.getDefaultName() != null) { userCompositName = entName.getDefaultName().getCompositeName(); } } addNote(leaveBlockBo.getDocumentId(), leaveBlockBo.getPrincipalId(), "LeaveBlock on " + leaveBlock.getLeaveLocalDate() + " was updated on this Leave Calendar by " + userCompositName + " on your behalf", principalId); } }
@Override public void saveBusinessObject() { SystemLunchRule sysLunchRule = (SystemLunchRule)this.getBusinessObject(); if(sysLunchRule.getTkSystemLunchRuleId()!=null && sysLunchRule.isActive()){ SystemLunchRule oldSystemLunchRule = TkServiceLocator.getSystemLunchRuleService().getSystemLunchRule(sysLunchRule.getTkSystemLunchRuleId()); if(sysLunchRule.getEffectiveDate().equals(oldSystemLunchRule.getEffectiveDate())){ sysLunchRule.setTimestamp(null); } else{ if(oldSystemLunchRule!=null){ oldSystemLunchRule.setActive(false); //NOTE this is done to prevent the timestamp of the inactive one to be greater than the oldSystemLunchRule.setTimestamp(TKUtils.subtractOneSecondFromTimestamp(TKUtils.getCurrentTimestamp())); oldSystemLunchRule.setEffectiveDate(sysLunchRule.getEffectiveDate()); KRADServiceLocator.getBusinessObjectService().save(oldSystemLunchRule); } sysLunchRule.setTimestamp(TKUtils.getCurrentTimestamp()); sysLunchRule.setTkSystemLunchRuleId(null); } } KRADServiceLocator.getBusinessObjectService().save(sysLunchRule); CacheUtils.flushCache(SystemLunchRule.CACHE_NAME); }
@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 protected PrincipalBo constructPrincipal(Element userElement, String entityId) { String principalId = userElement.getChildTextTrim(WORKFLOW_ID_ELEMENT, NAMESPACE); if (principalId == null) { principalId = userElement.getChildTextTrim(PRINCIPAL_ID_ELEMENT, NAMESPACE); } String principalName = userElement.getChildTextTrim(AUTHENTICATION_ID_ELEMENT, NAMESPACE); if (principalName == null) { principalName = userElement.getChildTextTrim(PRINCIPAL_NAME_ELEMENT, NAMESPACE); } String password= userElement.getChildTextTrim(PASSWORD_ELEMENT, NAMESPACE); PrincipalBo principal = new PrincipalBo(); principal.setActive(true); principal.setPrincipalId(principalId); principal.setPrincipalName(principalName); principal.setEntityId(entityId); try { principal.setPassword(CoreApiServiceLocator.getEncryptionService().hash(password)+HASH_SUFFIX); } catch (GeneralSecurityException e) { LOG.warn("Error hashing password.",e); } KRADServiceLocator.getBusinessObjectService().save(principal); return principal; } }
@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
@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 void deleteLeaveBlock(String leaveBlockId, String principalId) { LeaveBlockBo leaveBlock = getLeaveBlockBo(leaveBlockId); // leaveBlock.setPrincipalIdModified(HrContext.getTargetPrincipalId()); // leaveBlock.setTimestamp(TKUtils.getCurrentTimestamp()); // Make entry into LeaveBlockHistory table LeaveBlockHistory leaveBlockHistory = new LeaveBlockHistory(leaveBlock); leaveBlockHistory.setPrincipalIdDeleted(principalId); leaveBlockHistory.setTimestampDeleted(TKUtils.getCurrentTimestamp()); leaveBlockHistory.setAction(HrConstants.ACTION.DELETE); String principalName = KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(principalId).getDefaultName().getCompositeName(); addNote(leaveBlock.getDocumentId(), leaveBlock.getPrincipalId(), "LeaveBlock on " + leaveBlock.getLeaveLocalDate() + " was deleted on this Leave Calendar by " + principalName + " on your behalf", principalId); // deleting leaveblock KRADServiceLocator.getBusinessObjectService().delete(leaveBlock); // creating history KRADServiceLocator.getBusinessObjectService().save(leaveBlockHistory); }