List of usage examples for java.lang Long intValue
public int intValue()
From source file:org.zhangmz.pickles.controller.admin.account.AccountController.java
/** * /* w w w . j a va 2 s .com*/ * @Title: delete * @Description: * @param token * @param id * @param ra * @return * @throws * : * :2016127 ?5:03:56 * AOPModelAndView * */ @RequestMapping(value = "/delete/{id}") public ModelAndView delete(@RequestParam("TOKEN") String token, @PathVariable Long id) { ModelAndView result = new ModelAndView("admin/account/index"); String message; // ???? if (accountService.isAdmin(token) && 1 != id.intValue()) { accountService.deleteById(id); message = Messages.DELETE_SUCCESS; } else { message = Messages.MUST_BE_ADMIN + Messages.ADMINISTRATOR_IS_STATIC; } // AOPModelAndView?? Account account = new Account(); List<Account> accountList = accountService.search(account); result.addObject("pageInfo", new PageInfo<Account>(accountList)); result.addObject("queryParam", account); result.addObject("page", account.getPage()); result.addObject("rows", account.getRows()); result.addObject("message", message); result.addObject("TOKEN", token); return result; }
From source file:de.sainth.recipe.backend.rest.controller.FoodControllerTest.java
@Test public void whenUserFetchesAppleThenAppleIsReturned() { Long appleId = apple.getId(); given().auth().preemptive().basic(user.getUsername(), PASSWORD).when().get(BASE_URI + "/{id}", appleId) .then().statusCode(HttpStatus.SC_OK).body("id", is(appleId.intValue())).body("name", is("Apple")) .body("points", is(1.0f)).body("pointsBaseAmount", is(100.0f)); }
From source file:de.sainth.recipe.backend.rest.controller.FoodControllerTest.java
@Test public void whenAdminFetchesAppleThenGramIsReturned() { Long appleId = apple.getId(); given().auth().preemptive().basic(admin.getUsername(), PASSWORD).when().get(BASE_URI + "/{id}", appleId) .then().statusCode(HttpStatus.SC_OK).body("id", is(appleId.intValue())).body("name", is("Apple")) .body("points", is(1.0f)).body("pointsBaseAmount", is(100.0f)); }
From source file:com.act.lcms.v2.fullindex.BuilderTest.java
@Test public void testExtractTriples() throws Exception { // Verify all TMzI triples are stored correctly. Map<Long, TMzI> deserializedTriples = new HashMap<>(); assertEquals("All triples should have entries in the DB", 9, fakeDB.getFakeDB().get(ColumnFamilies.ID_TO_TRIPLE).size()); for (Map.Entry<List<Byte>, byte[]> entry : fakeDB.getFakeDB().get(ColumnFamilies.ID_TO_TRIPLE).entrySet()) { Long id = ByteBuffer.wrap(fakeDB.byteListToArray(entry.getKey())).getLong(); TMzI triple = TMzI.readNextFromByteBuffer(ByteBuffer.wrap(entry.getValue())); Float expectedTime = Double.valueOf(TIMES[id.intValue() / 3]).floatValue(); Double expectedMZ = MZS[id.intValue() / 3][id.intValue() % 3]; Float expectedIntensity = Double.valueOf(INTENSITIES[id.intValue() / 3][id.intValue() % 3]) .floatValue();/*from w w w.j a va2 s .co m*/ assertEquals("Time matches expected", expectedTime, triple.getTime(), FP_TOLERANCE); // No error expected assertEquals("M/z matches expected", expectedMZ, triple.getMz(), FP_TOLERANCE); assertEquals("Intensity matches expected", expectedIntensity, triple.getIntensity(), FP_TOLERANCE); deserializedTriples.put(id, triple); } for (Map.Entry<List<Byte>, byte[]> entry : fakeDB.getFakeDB().get(ColumnFamilies.WINDOW_ID_TO_TRIPLES) .entrySet()) { int windowId = ByteBuffer.wrap(fakeDB.byteListToArray(entry.getKey())).getInt(); MZWindow window = windowIdsToWindows.get(windowId); List<Long> tmziIds = new ArrayList<>(entry.getValue().length / Long.BYTES); ByteBuffer valBuffer = ByteBuffer.wrap(entry.getValue()); while (valBuffer.hasRemaining()) { tmziIds.add(valBuffer.getLong()); } for (Long tripleId : tmziIds) { TMzI triple = deserializedTriples.get(tripleId); assertTrue("Triple m/z falls within range of containing window", triple.getMz() >= window.getMin() && triple.getMz() <= window.getMax()); } } for (Map.Entry<List<Byte>, byte[]> entry : fakeDB.getFakeDB().get(ColumnFamilies.TIMEPOINT_TO_TRIPLES) .entrySet()) { float time = ByteBuffer.wrap(fakeDB.byteListToArray(entry.getKey())).getFloat(); List<Long> tmziIds = new ArrayList<>(entry.getValue().length / Long.BYTES); ByteBuffer valBuffer = ByteBuffer.wrap(entry.getValue()); while (valBuffer.hasRemaining()) { tmziIds.add(valBuffer.getLong()); } for (Long tripleId : tmziIds) { TMzI triple = deserializedTriples.get(tripleId); assertEquals("Triple time matches key time", time, triple.getTime(), FP_TOLERANCE); } } }
From source file:pl.hycom.jira.plugins.gitlab.integration.service.CommitService.java
@Override public List<Commit> getNewCommits(Long projectId) throws SQLException, ParseException, IOException { int pageNumber = 1; boolean indexedCommitEncountered = false; List<Commit> commitsList = new ArrayList<>(); List<Commit> resultList = new ArrayList<>(); do {//from w w w. ja v a 2 s . c o m commitsList = commitRepository.getNewCommits(dao.getProjectConfig(projectId.intValue()), perPage, pageNumber); for (Commit commit : commitsList) { if (!commitSearcher.checkIfCommitIsIndexed(commit.getId())) { resultList.add(commit); } else { indexedCommitEncountered = true; break; } } pageNumber++; } while (commitsList.size() != perPage && !indexedCommitEncountered); return resultList; }
From source file:com.abiquo.server.core.enterprise.EnterpriseDAO.java
public List<Enterprise> findAll(Integer firstElem, final Integer numResults) { // Check if the page requested is bigger than the last one Criteria criteria = createCriteria(); Long total = count(); if (firstElem >= total.intValue()) { firstElem = total.intValue() - numResults; }//from w ww . j av a 2s . c o m criteria.setFirstResult(firstElem); criteria.setMaxResults(numResults); List<Enterprise> result = getResultList(criteria); com.abiquo.server.core.util.PagedList<Enterprise> page = new PagedList<Enterprise>(result); page.setCurrentElement(firstElem); page.setPageSize(numResults); page.setTotalResults(total.intValue()); return page; }
From source file:org.openwms.core.uaa.RoleIT.java
/** * Test of JPA cascade lifecycle. Do not remove already existing User when removing a Role. *//*from w w w . j a v a 2 s.c om*/ @Test public final void testLifecycleRemoveRoleNotUsers() { knownRole.addUser(knownUser); knownRole = entityManager.merge(knownRole); entityManager.remove(knownRole); Long cnt = (Long) entityManager.getEntityManager() .createQuery("select count(r) from Role r where r.name = :rolename") .setParameter("rolename", KNOWN_ROLE).getSingleResult(); Assert.assertEquals("Role must be removed", 0, cnt.intValue()); cnt = (Long) entityManager.getEntityManager() .createQuery("select count(u) from User u where u.username = :username") .setParameter("username", KNOWN_USER).getSingleResult(); Assert.assertEquals("User may not be removed", 1, cnt.intValue()); }
From source file:com.founder.fix.fixflow.service.impl.ProcessDefinitionServiceImpl.java
@SuppressWarnings("rawtypes") public Map<String, Object> getProcessDefitionList(Map<String, Object> params) throws SQLException { Map<String, Object> resultMap = new HashMap<String, Object>(); String userId = StringUtil.getString(params.get("userId")); ProcessEngine processEngine = getProcessEngine(userId); ProcessDefinitionQuery processDefinitionQuery = processEngine.getModelService() .createProcessDefinitionQuery(); try {/* ww w . j a va 2s . c o m*/ String processName = StringUtil.getString(params.get("queryProcessName")); if (StringUtil.isNotEmpty(processName)) { processDefinitionQuery.processDefinitionNameLike(processName); } String processId = StringUtil.getString(params.get("queryProcessId")); if (StringUtil.isNotEmpty(processId)) { processDefinitionQuery.processDefinitionKeyLike(processId); } String processCategory = StringUtil.getString(params.get("queryType")); if (StringUtil.isNotEmpty(processCategory)) { processDefinitionQuery.processDefinitionCategoryLike(processCategory); } String pageI = StringUtil.getString(params.get("pageIndex")); String rowI = StringUtil.getString(params.get("pageSize")); int pageIndex = 1; int rowNum = 15; if (StringUtil.isNotEmpty(pageI)) { pageIndex = Integer.valueOf(pageI); } if (StringUtil.isNotEmpty(rowI)) { rowNum = Integer.valueOf(rowI); } // QueryExpandTo queryExpandTo = new QueryExpandTo(); // // // queryExpandTo.setFieldSql("fixflow_def_deployment.deploy_Time"); // //left join? // queryExpandTo.setLeftJoinSql("left join fixflow_def_deployment on PD.deployment_id = fixflow_def_deployment.id"); // processDefinitionQuery.queryExpandTo(queryExpandTo); processDefinitionQuery.orderByDeploymentTime().desc(); List<ProcessDefinitionBehavior> processDefinitions = processDefinitionQuery.listPagination(pageIndex, rowNum); Long count = processDefinitionQuery.count(); List<Map<String, Object>> processDefinitionList = new ArrayList<Map<String, Object>>(); Pagination page = new Pagination(pageIndex, rowNum); page.setTotal(count.intValue()); for (ProcessDefinitionBehavior processDefinition : processDefinitions) { Map<String, Object> processDefinitonMap = processDefinition.getPersistentState(); processDefinitionList.add(processDefinitonMap); } resultMap.put("dataList", processDefinitionList); resultMap.put("pageInfo", page); } finally { closeProcessEngine(); } return resultMap; }
From source file:de.hh.changeRing.user.User.java
public static User dummyUser(Long i) { User user = new Member(); user.id = i;/* ww w .j a va 2s. c o m*/ user.email = "email" + i + "@sonst-was.de"; user.setPassword("bll" + "lll"); user.firstName = randomName(); user.lastName = randomName(); user.firstNameVisible = new Random().nextBoolean(); user.lastNameVisible = new Random().nextBoolean(); user.emailVisible = new Random().nextBoolean(); user.addressVisible = new Random().nextBoolean(); user.street = randomName(); user.houseNumber = "" + new Random().nextInt(1000); user.plz = new Random().nextInt(99999); user.city = randomName(); user.district = randomName(); user.activated = new DateTime().secondOfMinute().withMinimumValue().plusSeconds(i.intValue()).minusDays(30); return user; }
From source file:com.lynn.dao.BaseDao.java
/** * <HQL>/*from ww w .j av a 2s . c om*/ * @param hql HQL? * @param countHql ?HQL? * @param pageNo * @param pageSize ? * @param values ?Object? * @return PageResults???????List? */ public PageResults<T> findPageByFetchedHql(String hql, String countHql, int pageNo, int pageSize, Object... values) { PageResults<T> retValue = new PageResults<T>(); Query query = this.getSession().createQuery(hql); if (values != null) { for (int i = 0; i < values.length; i++) { query.setParameter(i, values[i]); } } int currentPage = pageNo > 1 ? pageNo : 1; retValue.setCurrentPage(currentPage); retValue.setPageSize(pageSize); if (countHql == null) { ScrollableResults results = query.scroll(); results.last(); retValue.setTotalCount(results.getRowNumber() + 1);// } else { Long count = countByHql(countHql, values); retValue.setTotalCount(count.intValue()); } retValue.resetPageNo(); List<T> itemList = query.setFirstResult((currentPage - 1) * pageSize).setMaxResults(pageSize).list(); if (itemList == null) { itemList = new ArrayList<T>(); } retValue.setResults(itemList); return retValue; }