List of usage examples for java.lang Integer longValue
public long longValue()
From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java
/** * Returns the last build date on the repodata for a channel * @param loggedInUser The current user//from ww w . ja va 2 s . com * @param id - id of channel wanted * @throws NoSuchChannelException thrown if no channel is found. * @return the build date on the repodata of the channel requested * * @xmlrpc.doc Returns the last build date of the repomd.xml file * for the given channel as a localised string. * @xmlrpc.param #session_key() * @xmlrpc.param #param_desc("int", "id", "id of channel wanted") * @xmlrpc.returntype the last build date of the repomd.xml file * as a localised string */ public String getChannelLastBuildById(User loggedInUser, Integer id) throws NoSuchChannelException { String repoLastBuild = ChannelManager.getRepoLastBuild(lookupChannelById(loggedInUser, id.longValue())); if (repoLastBuild == null) { return ""; } return repoLastBuild; }
From source file:com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler.java
/** * Allows to modify channel attributes//ww w . j a v a2 s . c om * @param loggedInUser The current user * @param channelId id of channel to be modified * @param details map of channel attributes to be changed * @return 1 if edit was successful, exception thrown otherwise * * @xmlrpc.doc Allows to modify channel attributes * @xmlrpc.param #session_key() * @xmlrpc.param #param_desc("int", "channelId", "channel id") * @xmlrpc.param * #struct("channel_map") * #prop_desc("string", "checksum_label", "new channel repository checksum label * (optional)") * #prop_desc("string", "name", "new channel name (optional)") * #prop_desc("string", "summary", "new channel summary (optional)") * #prop_desc("string", "description", "new channel description (optional)") * #prop_desc("string", "maintainer_name", "new channel maintainer name * (optional)") * #prop_desc("string", "maintainer_email", "new channel email address * (optional)") * #prop_desc("string", "maintainer_phone", "new channel phone number (optional)") * #prop_desc("string", "gpg_key_url", "new channel gpg key url (optional)") * #prop_desc("string", "gpg_key_id", "new channel gpg key id (optional)") * #prop_desc("string", "gpg_key_fp", "new channel gpg key fingerprint * (optional)") * #struct_end() *@xmlrpc.returntype #return_int_success() */ public int setDetails(User loggedInUser, Integer channelId, Map<String, String> details) { Channel channel = lookupChannelById(loggedInUser, channelId.longValue()); Set<String> validKeys = new HashSet<String>(); validKeys.add("checksum_label"); validKeys.add("name"); validKeys.add("summary"); validKeys.add("description"); validKeys.add("maintainer_name"); validKeys.add("maintainer_email"); validKeys.add("maintainer_phone"); validKeys.add("gpg_key_url"); validKeys.add("gpg_key_id"); validKeys.add("gpg_key_fp"); validateMap(validKeys, details); UpdateChannelCommand ucc = new UpdateChannelCommand(loggedInUser, channel); if (details.containsKey("checksum_label")) { ucc.setChecksumLabel(details.get("checksum_label")); } if (details.containsKey("name")) { ucc.setName(details.get("name")); } if (details.containsKey("summary")) { ucc.setSummary(details.get("summary")); } if (details.containsKey("description")) { ucc.setDescription(details.get("description")); } if (details.containsKey("maintainer_name")) { ucc.setMaintainerName(details.get("maintainer_name")); } if (details.containsKey("maintainer_email")) { ucc.setMaintainerEmail(details.get("maintainer_email")); } if (details.containsKey("maintainer_phone")) { ucc.setMaintainerPhone(details.get("maintainer_phone")); } if (details.containsKey("gpg_key_url")) { ucc.setGpgKeyUrl(details.get("gpg_key_url")); } if (details.containsKey("gpg_key_id")) { ucc.setGpgKeyId(details.get("gpg_key_id")); } if (details.containsKey("gpg_key_fp")) { ucc.setGpgKeyFp(details.get("gpg_key_fp")); } ucc.update(channelId.longValue()); return 1; }
From source file:org.egov.dao.budget.BudgetDetailsHibernateDAO.java
private String prepareQueryToGetBudgetDetails(final Integer departmentid, final Long functionid, final Integer functionaryid, final Integer schemeid, final Integer subschemeid, final Integer boundaryid, final Integer fundid) { StringBuilder query = new StringBuilder(); if (departmentid != null) { query = query//w ww .j a v a 2s . c o m .append(getQuery(Department.class, departmentid.longValue(), " and bd.executingDepartment=")); } if (functionid != null) { query = query.append(getQuery(CFunction.class, functionid, " and bd.function=")); } if (functionaryid != null) { query = query.append(getQuery(Functionary.class, functionaryid, " and bd.functionary=")); } if (fundid != null) { query = query.append(getQuery(Fund.class, fundid, " and bd.fund=")); } if (schemeid != null) { query = query.append(getQuery(Scheme.class, schemeid, " and bd.scheme=")); } if (subschemeid != null) { query = query.append(getQuery(SubScheme.class, subschemeid, " and bd.subScheme=")); } if (boundaryid != null) { query = query.append(getQuery(Boundary.class, boundaryid.longValue(), " and bd.boundary=")); } return query.append(" and bd.budget.status.description='Approved' and bd.status.description='Approved' ") .toString(); }
From source file:org.nuclos.server.ruleengine.RuleInterface.java
/** * add a new entry in the task list//from w w w . j ava 2 s . c o m * @param sTask * @param sOwner * @param sDelegator * @param dScheduled * @param dCompleted * @param collTaskObjects * @deprecated use addTask(String sTask, String sOwner, String sDelegator, java.util.Date dScheduled, java.util.Date dCompleted, Integer iPriority, Integer iVisibility, String description, Integer taskstatusId, String taskstatus, Collection<Pair<String, Long>> collTaskObjects) */ @Deprecated public void addTask(String sTask, String sOwner, String sDelegator, java.util.Date dScheduled, java.util.Date dCompleted, Integer iPriority, Integer iVisibility, Collection<Integer> collTaskObjects, String description, Integer taskstatusId, String taskstatus) { ArrayList<Pair<String, Long>> objects = new ArrayList<Pair<String, Long>>(); for (Integer iGenericObject : collTaskObjects) { try { int entityId = getGenericObjectFacade().getModuleContainingGenericObject(iGenericObject); objects.add(new Pair<String, Long>(Modules.getInstance().getEntityNameByModuleId(entityId), iGenericObject.longValue())); } catch (CommonFinderException ex) { throw new NuclosFatalRuleException(ex); } } addTask(sTask, sOwner, sDelegator, dScheduled, dCompleted, iPriority, iVisibility, description, taskstatusId, taskstatus, objects); }
From source file:com.cloud.network.vpc.NetworkACLServiceImpl.java
private void validateNetworkACLItem(final Integer portStart, final Integer portEnd, final List<String> sourceCidrList, final String protocol, final Integer icmpCode, final Integer icmpType, final String action, final Integer number) { if (portStart != null && !NetUtils.isValidPort(portStart)) { throw new InvalidParameterValueException("publicPort is an invalid value: " + portStart); }//from w ww .jav a2 s . co m if (portEnd != null && !NetUtils.isValidPort(portEnd)) { throw new InvalidParameterValueException("Public port range is an invalid value: " + portEnd); } // start port can't be bigger than end port if (portStart != null && portEnd != null && portStart > portEnd) { throw new InvalidParameterValueException("Start port can't be bigger than end port"); } // start port and end port must be null for protocol = 'all' if ((portStart != null || portEnd != null) && protocol != null && protocol.equalsIgnoreCase("all")) { throw new InvalidParameterValueException("start port and end port must be null if protocol = 'all'"); } if (sourceCidrList != null) { for (final String cidr : sourceCidrList) { if (!NetUtils.isValidCIDR(cidr)) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Source cidrs formatting error " + cidr); } } } //Validate Protocol if (protocol != null) { //Check if protocol is a number if (StringUtils.isNumeric(protocol)) { final int protoNumber = Integer.parseInt(protocol); if (protoNumber < 0 || protoNumber > 255) { throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber); } } else { //Protocol is not number //Check for valid protocol strings final String supportedProtocols = "tcp,udp,icmp,all"; if (!supportedProtocols.contains(protocol.toLowerCase())) { throw new InvalidParameterValueException("Invalid protocol: " + protocol); } } // icmp code and icmp type can't be passed in for any other protocol rather than icmp if (!protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (icmpCode != null || icmpType != null)) { throw new InvalidParameterValueException( "Can specify icmpCode and icmpType for ICMP protocol only"); } if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (portStart != null || portEnd != null)) { throw new InvalidParameterValueException("Can't specify start/end port when protocol is ICMP"); } } //validate icmp code and type if (icmpType != null) { if (icmpType.longValue() != -1 && !NetUtils.validateIcmpType(icmpType.longValue())) { throw new InvalidParameterValueException("Invalid icmp type; should belong to [0-255] range"); } if (icmpCode != null) { if (icmpCode.longValue() != -1 && !NetUtils.validateIcmpCode(icmpCode.longValue())) { throw new InvalidParameterValueException( "Invalid icmp code; should belong to [0-15] range and can" + " be defined when icmpType belongs to [0-40] range"); } } } //Check ofr valid action Allow/Deny if (action != null) { if (!("Allow".equalsIgnoreCase(action) || "Deny".equalsIgnoreCase(action))) { throw new InvalidParameterValueException("Invalid action. Allowed actions are Allow and Deny"); } } //Check for valid number if (number != null && number < 1) { throw new InvalidParameterValueException("Invalid number. Number cannot be < 1"); } }
From source file:org.lilyproject.indexer.engine.test.IndexerTest.java
private void verifyMatchResultCounts() throws Exception { List<String> results = Lists.newArrayList(); boolean allOk = true; commitIndex();// w w w. j a va2 s .co m for (String condition : matchResultCounts.keySet()) { Integer expected = matchResultCounts.get(condition); long numFound = getQueryResponse(condition).getResults().getNumFound(); if (numFound == expected.longValue()) { results.add("OK: " + condition + " => " + expected); } else { results.add("ERROR: " + condition + " => " + numFound + " in stead of " + expected); allOk = false; } } if (!allOk) { fail(Joiner.on("\n").join(results)); } }
From source file:org.egov.services.payment.PaymentService.java
@Transactional public Paymentheader createPaymentHeader(final CVoucherHeader voucherHeader, final Integer bankaccountId, final String type, final BigDecimal amount) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Starting createPaymentHeader..."); Paymentheader paymentheader = new Paymentheader(); paymentheader.setType(type);/* w w w .j a v a 2 s . co m*/ paymentheader.setVoucherheader(voucherHeader); final Bankaccount bankaccount = (Bankaccount) getSession().load(Bankaccount.class, bankaccountId.longValue()); paymentheader.setBankaccount(bankaccount); paymentheader.setPaymentAmount(amount); applyAuditing(paymentheader); create(paymentheader); if (LOGGER.isDebugEnabled()) LOGGER.debug("Completed createPaymentHeader."); return paymentheader; }
From source file:org.egov.egf.commons.EgovCommon.java
@SuppressWarnings("unchecked") public BigDecimal getAccountBalanceFromLedger(final Date VoucherDate, final Integer bankId, final BigDecimal amount, final Long paymentId) { if (LOGGER.isDebugEnabled()) LOGGER.debug("EgovCommon | getCashBalance"); BigDecimal opeAvailable = BigDecimal.ZERO; BigDecimal bankBalance = BigDecimal.ZERO; try {/*from w w w .j av a 2 s .c om*/ final StringBuffer opBalncQuery1 = new StringBuffer(300); opBalncQuery1.append( "SELECT CASE WHEN sum(openingdebitbalance) is null THEN 0 ELSE sum(openingdebitbalance) END -") .append(" CASE WHEN sum(openingcreditbalance) is null THEN 0 ELSE sum(openingcreditbalance) END as openingBalance from TransactionSummary") .append(" where financialyear.id = ( select id from CFinancialYear where startingDate <= '") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("' AND endingDate >='") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)) .append("') and glcodeid.id=(select chartofaccounts.id from Bankaccount where id=? )"); final List<Object> tsummarylist = getPersistenceService().findAllBy(opBalncQuery1.toString(), bankId.longValue()); opeAvailable = BigDecimal.valueOf(Double.parseDouble(tsummarylist.get(0).toString())); if (LOGGER.isDebugEnabled()) LOGGER.debug("opeAvailable :" + opeAvailable); final StringBuffer opBalncQuery2 = new StringBuffer(300); List<Object> list = getPersistenceService() .findAllBy("select chartofaccounts.id from Bankaccount where id=?", bankId.longValue()); final Integer glcodeid = Integer.valueOf(list.get(0).toString()); final List<AppConfigValues> appList = appConfigValuesService .getConfigValuesByModuleAndKey(FinancialConstants.MODULE_NAME_APPCONFIG, "statusexcludeReport"); final String statusExclude = appList.get(0).getValue(); opBalncQuery2.append( "SELECT (CASE WHEN sum(gl.debitAmount) is null THEN 0 ELSE sum(gl.debitAmount) END - CASE WHEN sum(gl.creditAmount) is null THEN 0 ELSE sum(gl.creditAmount) END)") .append(" as amount FROM CGeneralLedger gl , CVoucherHeader vh WHERE gl.voucherHeaderId.id=vh.id and gl.glcodeId=? ") .append(" and vh.voucherDate >= (select startingDate from CFinancialYear where startingDate <= '") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("' AND endingDate >='") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("') and vh.voucherDate <='") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("'and vh.status not in (") .append(statusExclude).append(")"); final CChartOfAccounts coa = (CChartOfAccounts) persistenceService .find("from CChartOfAccounts where id=?", Long.valueOf(glcodeid)); list = getPersistenceService().findAllBy(opBalncQuery2.toString(), coa); bankBalance = BigDecimal.valueOf(Double.parseDouble(list.get(0).toString())); bankBalance = opeAvailable.add(bankBalance); // get the preapproved voucher amount also, if payment workflow // status in FMU level.... and subtract the amount from the balance // . boolean amountTobeInclude = false; if (paymentId != null) { // get the payment wf status final State s = (State) persistenceService.find( " from org.egov.infra.workflow.entity.State where id in (select state.id from Paymentheader where id=?) ", paymentId); String paymentWFStatus = ""; final List<AppConfigValues> paymentStatusList = appConfigValuesService .getConfigValuesByModuleAndKey(FinancialConstants.MODULE_NAME_APPCONFIG, "PAYMENT_WF_STATUS_FOR_BANK_BALANCE_CHECK"); for (final AppConfigValues values : paymentStatusList) { if (s.getValue().equals(values.getValue())) amountTobeInclude = true; paymentWFStatus = paymentWFStatus + "'" + values.getValue() + "',"; } if (!paymentWFStatus.equals("")) paymentWFStatus = paymentWFStatus.substring(0, paymentWFStatus.length() - 1); final List<AppConfigValues> preAppList = appConfigValuesService.getConfigValuesByModuleAndKey( FinancialConstants.MODULE_NAME_APPCONFIG, "PREAPPROVEDVOUCHERSTATUS"); final String preApprovedStatus = preAppList.get(0).getValue(); final StringBuffer paymentQuery = new StringBuffer(400); paymentQuery.append( "SELECT (CASE WHEN sum(gl.debitAmount) is null THEN 0 ELSE sum(gl.debitAmount) END - CASE WHEN sum(gl.creditAmount) is null THEN 0 ELSE sum(gl.creditAmount) END )") .append(" as amount FROM CGeneralLedger gl , CVoucherHeader vh,Paymentheader ph WHERE gl.voucherHeaderId.id=vh.id and ph.voucherheader.id=vh.id and gl.glcodeId=? ") .append(" and vh.voucherDate >= (select startingDate from CFinancialYear where startingDate <= '") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("' AND endingDate >='") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("') and vh.voucherDate <='") .append(Constants.DDMMYYYYFORMAT1.format(VoucherDate)).append("'and vh.status in (") .append(preApprovedStatus).append(")") .append(" and ph.state in (from org.egov.infra.workflow.entity.State where type='Paymentheader' and value in (") .append(paymentWFStatus).append(") )"); list = getPersistenceService().findAllBy(paymentQuery.toString(), coa); bankBalance = bankBalance.subtract(BigDecimal.valueOf(Math.abs((Double) list.get(0)))); final Integer voucherStatus = (Integer) persistenceService.find( "select status from CVoucherHeader where id in (select voucherheader.id from Paymentheader where id=?)", paymentId); // if voucher is not preapproved and status is 0 then it is // modify so add the amount if (voucherStatus == 0) amountTobeInclude = true; // if payment workflow status in FMU level.... and add the // transaction amount to it. if (amountTobeInclude) bankBalance = bankBalance.add(amount); } if (LOGGER.isDebugEnabled()) LOGGER.debug("bankBalance :" + bankBalance); } catch (final Exception e) { if (LOGGER.isDebugEnabled()) LOGGER.debug("exception occuered while geeting cash balance" + e.getMessage(), e); throw new HibernateException(e); } return bankBalance; }
From source file:org.oscarehr.ws.rest.NotesService.java
@POST @Path("/ticklerSaveNote") @Produces("application/json") @Consumes("application/json") public GenericRESTResponse ticklerSaveNote(JSONObject json) { if (!securityInfoManager.hasPrivilege(getLoggedInInfo(), "_tickler", "w", null)) { throw new RuntimeException("Access Denied"); }/*from w ww . j a v a 2 s. c o m*/ if (!securityInfoManager.hasPrivilege(getLoggedInInfo(), "_eChart", "w", null)) { throw new RuntimeException("Access Denied"); } logger.info("The config " + json.toString()); String strNote = json.getString("note"); Integer noteId = json.getInt("noteId"); logger.info("want to save note id " + noteId + " with value " + strNote); JSONObject tickler = json.getJSONObject("tickler"); Integer ticklerId = tickler.getInt("id"); Integer demographicNo = tickler.getInt("demographicNo"); logger.info("tickler id " + ticklerId + ", demographicNo " + demographicNo); Date creationDate = new Date(); LoggedInInfo loggedInInfo = this.getLoggedInInfo(); Provider loggedInProvider = loggedInInfo.getLoggedInProvider(); String revision = "1"; String history = strNote; String uuid = null; if (noteId != null && noteId.intValue() > 0) { CaseManagementNote existingNote = caseManagementMgr.getNote(String.valueOf(noteId)); revision = String.valueOf(Integer.valueOf(existingNote.getRevision()).intValue() + 1); history = strNote + "\n" + existingNote.getHistory(); uuid = existingNote.getUuid(); } CaseManagementNote cmn = new CaseManagementNote(); cmn.setAppointmentNo(0); cmn.setArchived(false); cmn.setCreate_date(creationDate); cmn.setDemographic_no(String.valueOf(demographicNo)); cmn.setEncounter_type(EncounterUtil.EncounterType.FACE_TO_FACE_WITH_CLIENT.getOldDbValue()); cmn.setNote(strNote); cmn.setObservation_date(creationDate); cmn.setProviderNo(loggedInProvider.getProviderNo()); cmn.setRevision(revision); cmn.setSigned(true); cmn.setSigning_provider_no(loggedInProvider.getProviderNo()); cmn.setUpdate_date(creationDate); cmn.setHistory(history); //just doing this because the other code does it. cmn.setReporter_program_team("null"); cmn.setUuid(uuid); ProgramProvider pp = programManager2.getCurrentProgramInDomain(getLoggedInInfo(), getLoggedInInfo().getLoggedInProviderNo()); if (pp != null) { cmn.setProgram_no(String.valueOf(pp.getProgramId())); } else { List<ProgramProvider> ppList = programManager2.getProgramDomain(getLoggedInInfo(), getLoggedInInfo().getLoggedInProviderNo()); if (ppList != null && ppList.size() > 0) { cmn.setProgram_no(String.valueOf(ppList.get(0).getProgramId())); } } //weird place for it , but for now. CaseManagementEntryAction.determineNoteRole(cmn, loggedInProvider.getProviderNo(), String.valueOf(demographicNo)); caseManagementMgr.saveNoteSimple(cmn); logger.info("note id is " + cmn.getId()); //save link, so we know what tickler this note is linked to CaseManagementNoteLink link = new CaseManagementNoteLink(); link.setNoteId(cmn.getId()); link.setTableId(ticklerId.longValue()); link.setTableName(CaseManagementNoteLink.TICKLER); CaseManagementNoteLinkDAO caseManagementNoteLinkDao = (CaseManagementNoteLinkDAO) SpringUtils .getBean("CaseManagementNoteLinkDAO"); caseManagementNoteLinkDao.save(link); Issue issue = this.issueDao.findIssueByTypeAndCode("system", "TicklerNote"); if (issue == null) { logger.warn("missing TicklerNote issue, please run all database updates"); return null; } CaseManagementIssue cmi = caseManagementMgr.getIssueById(demographicNo.toString(), issue.getId().toString()); if (cmi == null) { //save issue..this will make it a "cpp looking" issue in the eChart cmi = new CaseManagementIssue(); cmi.setAcute(false); cmi.setCertain(false); cmi.setDemographic_no(String.valueOf(demographicNo)); cmi.setIssue_id(issue.getId()); cmi.setMajor(false); cmi.setProgram_id(Integer.parseInt(cmn.getProgram_no())); cmi.setResolved(false); cmi.setType(issue.getRole()); cmi.setUpdate_date(creationDate); caseManagementMgr.saveCaseIssue(cmi); } cmn.getIssues().add(cmi); caseManagementMgr.updateNote(cmn); return new GenericRESTResponse(); }