@Override public <T> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys) { return (T) businessObjectService.findByPrimaryKey((Class<BusinessObject>) clazz, primaryKeys); }
@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 delete(Object dataObject) { if (dataObject instanceof Collection) { for (Object dobj : (Collection) dataObject) { delete(dobj); } } else { businessObjectService.delete(dataObject); } }
@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); }
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 <T> Collection<T> findMatching(Class<T> clazz, Map<String, ?> fieldValues) { return (Collection<T>) businessObjectService.findMatching((Class<BusinessObject>) clazz, fieldValues); }
@Override public void deleteMatching(Class<?> type, Map<String, ?> fieldValues) { businessObjectService.deleteMatching(type, fieldValues); }
@Override public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField, boolean sortAscending) { return (Collection<T>) businessObjectService.findMatchingOrderBy((Class<BusinessObject>) clazz, fieldValues, sortField, sortAscending); }
@Override public <T> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey) { return (T) businessObjectService.findBySinglePrimaryKey((Class<BusinessObject>) clazz, primaryKey); }
@Override public BusinessObject getReferenceIfExists(Object bo, String referenceName) { if (!(bo instanceof BusinessObject)) { throw new UnsupportedOperationException("getReferenceIfExists only supports BusinessObject in KNS"); } return businessObjectService.getReferenceIfExists((BusinessObject) bo, referenceName); }
@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); }
/** * This method will read all the timeBlock objects from DB and will * serialize it to ObjData.xml file in user home folder * * @throws FileNotFoundException */ public void serializeToXML() 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(); XStream xs = new XStream(new DomDriver()); FileOutputStream fos; // writting it to file temporarily 'temp.xml' file will be created // in user home directory fos = new FileOutputStream(System.getProperty("user.home") + "\\TimeBlockData.xml", true); xs.toXML(timeBlockObj, fos); } }
public String getParameter(String name) { String parameter = ""; try { Map<String, String> criteriaMap = new HashMap<String, String>(); criteriaMap.put("namespaceCode", "OLE-DESC"); criteriaMap.put("componentCode", "Describe"); criteriaMap.put("name", name); List<ParameterBo> parametersList = (List<ParameterBo>) getBusinessObjectService().findMatching(ParameterBo.class, criteriaMap); for (ParameterBo parameterBo : parametersList) { parameter = parameterBo.getValue(); } } catch (Exception e) { LOG.error("Exception while getting parameter value", e); } return parameter; }
@Override public void saveOrUpdate(LeavePayout payout) { KRADServiceLocator.getBusinessObjectService().save(payout); }
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 deleteBusinessObject() { if (businessObject == null) return; KNSServiceLocator.getBusinessObjectService().delete(businessObject); businessObject = null; }
public List getKeyValues() { List keyValues = new ArrayList(); Collection<AccountType> bos = KNSServiceLocator.getBusinessObjectService().findAll( AccountType.class ); keyValues.add(new ConcreteKeyValue("", "")); for ( AccountType typ : bos ) { keyValues.add(new ConcreteKeyValue(typ.getAccountTypeCode(), typ.getName())); } return keyValues; }
@Override public void saveOrUpdate(BalanceTransfer balanceTransfer) { KRADServiceLocator.getBusinessObjectService().save(balanceTransfer); }
public String getChart() { Map<String, String> fields = new HashMap<String, String>(); fields.put("accountNumber", this.account); fields.put("active", "true"); Account account = (Account) getBusinessObjectService().findByPrimaryKey(Account.class, fields); if (account != null && !account.isClosed()) { this.setChart(account.getChartOfAccountsCode()); } else { this.setChart(null); } return chart; }
protected void deleteClockLogAndTimeBlocks(ClockLog clockLog, List<TimeBlock> timeBlocks) { if (clockLog != null) { ClockLogBo bo = ClockLogBo.from(clockLog); businessObjectService.delete(bo); } if (CollectionUtils.isNotEmpty(timeBlocks)) { for (TimeBlock timeBlock : timeBlocks) { timeBlockService.deleteTimeBlockAndHandleMissedPunch(timeBlock, true); } } }