List of usage examples for java.lang Long intValue
public int intValue()
From source file:com.axelor.studio.service.data.importer.FormImporter.java
private ViewItem setNestedField(ViewPanel lastPanel, String parentField, ViewItem viewItem) throws AxelorException { log.debug("Last panel: {}", lastPanel); ViewItem relationalField = viewItemRepo.all() .filter("self.viewPanel = ?1 and LOWER(self.name) = ?2", lastPanel, parentField.toLowerCase()) .fetchOne();/*from w ww.j a v a 2 s . c o m*/ if (relationalField == null) { throw new AxelorException(I18n.get("No parent field found '%s' for nested editor"), 1, parentField); } viewItem.setNestedField(relationalField); Long sequence = viewItemRepo.all().filter("self.nestedField = ?1", relationalField).count(); viewItem.setSequence(sequence.intValue()); return viewItem; }
From source file:iddb.runtime.db.model.dao.impl.mysql.PenaltyDAOImpl.java
@Override public List<Penalty> findByType(Long type, int offset, int limit, int[] count) { String sqlCount = "select count(id) from penalty where type = ?"; String sql = "select * from penalty where type = ? order by created desc limit ?,?"; Connection conn = null;//from ww w. j a v a 2 s .c o m List<Penalty> list = new ArrayList<Penalty>(); try { conn = ConnectionFactory.getSecondaryConnection(); PreparedStatement stC = conn.prepareStatement(sqlCount); stC.setInt(1, type.intValue()); ResultSet rsC = stC.executeQuery(sqlCount); if (rsC.next()) { count[0] = rsC.getInt(1); } PreparedStatement st = conn.prepareStatement(sql); stC.setInt(1, type.intValue()); st.setInt(2, offset); st.setInt(3, limit); ResultSet rs = st.executeQuery(); while (rs.next()) { Penalty penalty = new Penalty(); loadPenalty(penalty, rs); list.add(penalty); } } catch (SQLException e) { logger.error("findByType: {}", e); } catch (IOException e) { logger.error("findByType: {}", e); } finally { try { if (conn != null) conn.close(); } catch (Exception e) { } } return list; }
From source file:com.nec.harvest.service.impl.MonthlySalesServiceImpl.java
/** {@inheritDoc} */ @Override//w ww . j a v a2 s . co m public int findByOrgCodeAndMonth(String strCode, String month, Integer... ugKbns) throws ServiceException { if (StringUtils.isEmpty(strCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(month)) { throw new IllegalArgumentException("Month must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; Long result = 0L; try { tx = session.beginTransaction(); Integer ugKbn = ugKbns.length > 0 ? ugKbns[0] : 2; Query namedQuery = repository.getNamedQuery(session, SqlConstants.SQL_FIND_MONTHLY_SALES_BY_ORGANIZATION_AND_MONTH); namedQuery.setString("strCode", strCode); namedQuery.setString("getSudo", month); namedQuery.setInteger("ugKbn", ugKbn); result = (Long) namedQuery.uniqueResult(); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "An exception occured while count sales change for organization " + strCode + " month " + month, ex); } finally { HibernateSessionManager.closeSession(session); } return result.intValue(); }
From source file:module.mailtracking.presentationTier.MailTrackingAction.java
private byte[] consumeStream(Long fileSize, InputStream stream) throws IOException { byte[] content = new byte[fileSize.intValue()]; stream.read(content);//from www . j a v a2 s.com return content; }
From source file:com.founder.fix.fixflow.service.impl.FlowCenterServiceImpl.java
public Map<String, Object> queryPlaceOnFile(Map<String, Object> filter) throws SQLException { Map<String, Object> result = new HashMap<String, Object>(); String userId = (String) filter.get("userId"); String processType = StringUtil.getString(filter.get("processType")); ProcessEngine engine = getProcessEngine(userId); try {/*from w ww . j av a 2 s . c o m*/ ProcessInstanceQuery tq = engine.getRuntimeService().createProcessInstanceQuery(); String bizKey = StringUtil.getString(filter.get("BIZ_KEY")); //? if (StringUtil.isNotEmpty(bizKey)) tq.processInstanceBusinessKey(bizKey); String initor = StringUtil.getString(filter.get("initor")); //? if (StringUtil.isNotEmpty(initor)) tq.initiator(initor); Date dates = null; Date datee = null; String dss = StringUtil.getString(filter.get("arrivalTimeS")); String dse = StringUtil.getString(filter.get("arrivalTimeE")); if (StringUtil.isNotEmpty(dss)) { dates = DateUtil.stringToDate(dss, "yyyy-MM-dd"); } if (StringUtil.isNotEmpty(dse)) { String endTime = "235959999"; dse += endTime; datee = DateUtil.stringToDate(dse, "yyyy-MM-ddHHmmssSSS"); } if (dates != null) tq.archiveTimeBefore(dates); if (datee != null) tq.archiveTimeAfter(datee); String processDefinitionKey = StringUtil.getString(filter.get("processDefinitionKey")); //? if (StringUtil.isNotEmpty(processDefinitionKey)) tq.processDefinitionKey(processDefinitionKey); String processInstanceId = StringUtil.getString(filter.get("processInstanceId")); //?? if (StringUtil.isNotEmpty(processInstanceId)) tq.processInstanceId(processInstanceId); String subject = StringUtil.getString(filter.get("subject")); // if (StringUtil.isNotEmpty(subject)) tq.subjectLike(subject); String pageI = StringUtil.getString(filter.get("pageIndex")); String rowI = StringUtil.getString(filter.get("pageSize")); int pageIndex = 1; int rowNum = 15; if (StringUtil.isNotEmpty(pageI)) { pageIndex = Integer.valueOf(pageI); } if (StringUtil.isNotEmpty(rowI)) { rowNum = Integer.valueOf(rowI); } if (filter.get("ended") != null) tq.isEnd(); List<ProcessInstance> instances = null; if (StringUtil.isNotEmpty(processType)) { if (processType.equals("initor")) tq.initiator(userId); else tq.taskParticipants(userId); } tq.his(); instances = tq.listPagination(pageIndex, rowNum); Long count = tq.count(); List<Map<String, Object>> instanceMaps = new ArrayList<Map<String, Object>>(); Pagination page = new Pagination(pageIndex, rowNum); page.setTotal(count.intValue()); IdentityService identityService = engine.getIdentityService(); for (ProcessInstance tmp : instances) { Map<String, Object> persistentState = tmp.getPersistentState(); ProcessEngine processEngine = ProcessEngineManagement.getDefaultProcessEngine(); String processDefinitionId = tmp.getProcessDefinitionId(); ProcessDefinitionBehavior processDefinitionBehavior = processEngine.getModelService() .getProcessDefinition(processDefinitionId); String processDefinitionName = processDefinitionBehavior.getName(); persistentState.put("processDefinitionName", processDefinitionName); UserTo user = identityService.getUserTo(tmp.getStartAuthor()); if (user != null) { persistentState.put("startAuthorName", user.getUserName()); } else { persistentState.put("startAuthorName", tmp.getStartAuthor()); } instanceMaps.add(persistentState); } result.put("dataList", instanceMaps); result.put("pageInfo", page); } finally { closeProcessEngine(); } return result; }
From source file:com.ibm.asset.trails.service.impl.ReconServiceImpl.java
private boolean validateScheduleF4WorkingAlertAndCrossAccountAlert(AlertUnlicensedSw workingAlert, AlertUnlicensedSw relatedAlert) { boolean validateScheduleF4WorkingAlertAndCrossAccountAlertFlag = false; ScheduleF scheduleF4WorkingAlert = vSwLparDAO.getMachineLevelScheduleF( workingAlert.getInstalledSoftware().getSoftwareLpar().getAccount(), workingAlert.getInstalledSoftware().getSoftware().getSoftwareName(), workingAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getOwner(), workingAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware() .getMachineType().getName(), workingAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getSerial(), workingAlert.getInstalledSoftware().getSoftware().getManufacturerId().getManufacturerName()); ScheduleF scheduleF4RelatedAlert = vSwLparDAO.getMachineLevelScheduleF( relatedAlert.getInstalledSoftware().getSoftwareLpar().getAccount(), relatedAlert.getInstalledSoftware().getSoftware().getSoftwareName(), relatedAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getOwner(), relatedAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware() .getMachineType().getName(), relatedAlert.getInstalledSoftware().getSoftwareLpar().getHardwareLpar().getHardware().getSerial(), relatedAlert.getInstalledSoftware().getSoftware().getManufacturerId().getManufacturerName()); if (scheduleF4WorkingAlert != null && scheduleF4RelatedAlert != null) { Long scopeId4WorkingAlert = scheduleF4WorkingAlert.getScope().getId(); Long scopeId4RelatedAlert = scheduleF4RelatedAlert.getScope().getId(); if (scopeId4WorkingAlert.intValue() == 3// Working Alert Scope must // be IBM owned, IBM managed && scopeId4RelatedAlert.intValue() == 3// Cross Account // Alert Scope must // be IBM owned, IBM // managed ) {/*ww w. j a v a 2 s. co m*/ validateScheduleF4WorkingAlertAndCrossAccountAlertFlag = true; } } return validateScheduleF4WorkingAlertAndCrossAccountAlertFlag; }
From source file:cz.lbenda.dataman.db.RowDesc.java
@SuppressWarnings({ "unchecked", "RedundantCast" }) private <T> T repairClassOfValue(ColumnDesc column, T value) { if (value == null) { return null; }// www . j a va2s . c o m if (column.getDataType().getJavaClass().equals(value.getClass())) { return value; } if (column.getDataType() == ColumnType.TIME) { if (value instanceof LocalTime) { return (T) (Object) java.sql.Time.valueOf((LocalTime) value); } } else if (column.getDataType() == ColumnType.DATE) { if (value instanceof LocalDate) { return (T) (Object) java.sql.Date.valueOf((LocalDate) value); } } else if (column.getDataType() == ColumnType.TIMESTAMP) { if (value instanceof LocalDateTime) { return (T) (Object) java.sql.Timestamp.valueOf((LocalDateTime) value); } } else { Long val; if (value instanceof Long) { val = (Long) value; } else if (value instanceof Integer) { val = ((Integer) value).longValue(); } else if (value instanceof Short) { val = ((Short) value).longValue(); } else if (value instanceof Byte) { val = ((Byte) value).longValue(); } else { return value; } if (column.getDataType() == ColumnType.INTEGER) { return (T) (Object) val.intValue(); } if (column.getDataType() == ColumnType.BYTE) { return (T) (Object) val.byteValue(); } if (column.getDataType() == ColumnType.SHORT) { return (T) (Object) val.shortValue(); } } return value; }
From source file:com.intuit.tank.vm.settings.AgentConfigCpTest.java
/** * Run the Long getConnectionTimeout() method test. * /* w w w . j a v a 2 s . c o m*/ * @throws Exception * * @generatedBy CodePro at 9/3/14 3:44 PM */ @Test public void testGetConnectionTimeout_1() throws Exception { AgentConfig fixture = new AgentConfig(new HierarchicalConfiguration()); fixture.setResultsTypeMap(new HashMap()); Long result = fixture.getConnectionTimeout(); assertNotNull(result); assertEquals("40000", result.toString()); assertEquals((byte) 64, result.byteValue()); assertEquals((short) -25536, result.shortValue()); assertEquals(40000, result.intValue()); assertEquals(40000L, result.longValue()); assertEquals(40000.0f, result.floatValue(), 1.0f); assertEquals(40000.0, result.doubleValue(), 1.0); }
From source file:com.glaf.core.service.impl.MxSysDataTableServiceImpl.java
@Transactional public void saveData(String datatableId, Map<String, Object> dataMap) { SysDataTable dataTable = this.getDataTableById(datatableId); Map<String, Object> newData = new HashMap<String, Object>(); Set<Entry<String, Object>> entrySet = dataMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); if (value != null) { newData.put(key, value);/* w w w. j a v a2 s. c o m*/ newData.put(key.toUpperCase(), value); } } SysDataField idField = null; List<SysDataField> fields = dataTable.getFields(); if (fields != null && !fields.isEmpty()) { for (SysDataField field : fields) { if (StringUtils.equalsIgnoreCase("1", field.getPrimaryKey()) || StringUtils.equalsIgnoreCase("Y", field.getPrimaryKey()) || StringUtils.equalsIgnoreCase("true", field.getPrimaryKey())) { idField = field; break; } } } if (idField == null) { throw new java.lang.RuntimeException("primary key not found."); } Object idValue = newData.get(idField.getColumnName().toUpperCase()); if (idValue == null) { idValue = newData.get(idField.getName().toUpperCase()); } TableModel row = new TableModel(); row.setTableName(dataTable.getTablename()); ColumnModel col01 = new ColumnModel(); col01.setColumnName(idField.getColumnName()); if (idValue == null) { if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) { col01.setJavaType("Long"); Long id = idGenerator.nextId(); col01.setIntValue(id.intValue()); col01.setValue(Integer.valueOf(id.intValue())); } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) { col01.setJavaType("Long"); Long id = idGenerator.nextId(); col01.setLongValue(id); col01.setValue(id); } else { col01.setJavaType("String"); String id = idGenerator.getNextId(); col01.setStringValue(id); col01.setValue(id); } row.setIdColumn(col01); row.addColumn(col01); } else { if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) { col01.setJavaType("Long"); String id = idValue.toString(); col01.setIntValue(Integer.parseInt(id)); col01.setValue(col01.getIntValue()); } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) { col01.setJavaType("Long"); String id = idValue.toString(); col01.setLongValue(Long.parseLong(id)); col01.setValue(col01.getLongValue()); } else { col01.setJavaType("String"); String id = idValue.toString(); col01.setStringValue(id); col01.setValue(id); } row.setIdColumn(col01); row.addColumn(col01); } if (fields != null && !fields.isEmpty()) { for (SysDataField field : fields) { if (StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) { continue; } String name = field.getColumnName().toUpperCase(); String javaType = field.getDataType(); ColumnModel c = new ColumnModel(); c.setColumnName(field.getColumnName()); c.setJavaType(javaType); Object value = newData.get(name); if (value != null) { if ("Integer".equals(javaType)) { value = ParamUtils.getInt(newData, name); } else if ("Long".equals(javaType)) { value = ParamUtils.getLong(newData, name); } else if ("Double".equals(javaType)) { value = ParamUtils.getDouble(newData, name); } else if ("Date".equals(javaType)) { value = ParamUtils.getTimestamp(newData, name); } else if ("String".equals(javaType)) { value = ParamUtils.getString(newData, name); } else if ("Clob".equals(javaType)) { value = ParamUtils.getString(newData, name); } c.setValue(value); row.addColumn(c); } else { name = field.getName().toUpperCase(); value = newData.get(name); if (value != null) { if ("Integer".equals(javaType)) { value = ParamUtils.getInt(newData, name); } else if ("Long".equals(javaType)) { value = ParamUtils.getLong(newData, name); } else if ("Double".equals(javaType)) { value = ParamUtils.getDouble(newData, name); } else if ("Date".equals(javaType)) { value = ParamUtils.getTimestamp(newData, name); } else if ("String".equals(javaType)) { value = ParamUtils.getString(newData, name); } else if ("Clob".equals(javaType)) { value = ParamUtils.getString(newData, name); } c.setValue(value); row.addColumn(c); } } } } if (idValue == null) { tableDataMapper.insertTableData(row); } else { tableDataMapper.updateTableDataByPrimaryKey(row); } }
From source file:com.maestrodev.maestrocontinuumplugin.ContinuumWorker.java
private ProjectSummary getProjectSummary(JSONObject context) throws Exception { ProjectSummary project;//from ww w .j av a 2 s . c o m Long projectId = (Long) context.get(CONTINUUM_PROJECT_ID); if (projectId != null) { project = client.getProjectSummary(projectId.intValue()); } else { String projectGroupName = getGroupName(); writeOutput("Searching For Project Group " + projectGroupName + "\n"); ProjectGroupSummary projectGroup = getProjectGroup(projectGroupName); writeOutput("Found Project Group " + projectGroup.getName() + "\n"); String projectName = getProjectName(); writeOutput("Searching For Project " + projectName + "\n"); project = getProjectSummary(projectName, projectGroup); } writeOutput("Found Project " + project.getName() + " (" + project.getId() + ")\n"); return project; }