List of usage examples for java.lang Long intValue
public int intValue()
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.MafFileProcessor.java
private void insertBiospecimenToFileRelationships(final HashMap<String, BCRID> barcodesOrUuids, final QcContext context, final File mafFile) throws UUIDException { final List<Integer> biospecimenIds; final List<Long> shippedBiospecimenIds; // if center is converted to UUID use the uuids to look up the biospecimen ID if (context.isCenterConvertedToUUID()) { final List<String> uuids = new ArrayList<String>(); for (final BCRID bcrId : barcodesOrUuids.values()) { uuids.add(bcrId.getUUID());/* w ww . java2s . c o m*/ } shippedBiospecimenIds = bcrDataService.getShippedBiospecimenIds(uuids); biospecimenIds = new ArrayList<Integer>(); for (final Long shippedBiospecimenId : shippedBiospecimenIds) { biospecimenIds.add(shippedBiospecimenId.intValue()); } } else { biospecimenIds = BiospecimenHelper.getBiospecimenIds(new ArrayList<BCRID>(barcodesOrUuids.values()), bcrDataService); shippedBiospecimenIds = new ArrayList<Long>(); for (final Integer id : biospecimenIds) { shippedBiospecimenIds.add(id.longValue()); } } // add biospecimen to file relationship into common and disease database BiospecimenHelper.insertBiospecimenFileRelationship(biospecimenIds, context.getArchive().getFilenameToIdToMap().get(mafFile.getName()), bcrDataService, context.getArchive().getTheTumor()); // now shipped biospecimen to file... bcrDataService.addShippedBiospecimensFileRelationship(shippedBiospecimenIds, context.getArchive().getFilenameToIdToMap().get(mafFile.getName())); }
From source file:org.wildfly.camel.test.olingo4.Olingo4IntegrationTest.java
@Test public void testRead() throws Exception { CamelContext camelctx = createCamelContext(); camelctx.addRoutes(new RouteBuilder() { public void configure() { // test routes for read from("direct://readmetadata").to("olingo4://read/$metadata"); from("direct://readdocument").to("olingo4://read/"); from("direct://readentities").to("olingo4://read/People?$top=5&$orderby=FirstName asc"); from("direct://readcount").to("olingo4://read/People/$count"); from("direct://readvalue").to("olingo4://read/People('russellwhyte')/Gender/$value"); from("direct://readsingleprop").to("olingo4://read/Airports('KSFO')/Name"); from("direct://readcomplexprop").to("olingo4://read/Airports('KSFO')/Location"); from("direct://readentitybyid").to("olingo4://read/People('russellwhyte')"); from("direct://callunboundfunction").to("olingo4://read/GetNearestAirport(lat=33,lon=-118)"); }/*from w ww .j a v a 2 s . com*/ }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); final Map<String, Object> headers = new HashMap<String, Object>(); // Read metadata ($metadata) object final Edm metadata = (Edm) template.requestBodyAndHeaders("direct://readmetadata", null, headers); Assert.assertNotNull(metadata); Assert.assertEquals(1, metadata.getSchemas().size()); // Read service document object final ClientServiceDocument document = (ClientServiceDocument) template .requestBodyAndHeaders("direct://readdocument", null, headers); Assert.assertNotNull(document); Assert.assertTrue(document.getEntitySets().size() > 1); LOG.info("Service document has {} entity sets", document.getEntitySets().size()); // Read entity set of the People object final ClientEntitySet entities = (ClientEntitySet) template .requestBodyAndHeaders("direct://readentities", null, headers); Assert.assertNotNull(entities); Assert.assertEquals(5, entities.getEntities().size()); // Read object count with query options passed through header final Long count = (Long) template.requestBodyAndHeaders("direct://readcount", null, headers); Assert.assertEquals(20, count.intValue()); final ClientPrimitiveValue value = (ClientPrimitiveValue) template .requestBodyAndHeaders("direct://readvalue", null, headers); LOG.info("Client value \"{}\" has type {}", value.toString(), value.getTypeName()); Assert.assertEquals("Male", value.asPrimitive().toString()); final ClientPrimitiveValue singleProperty = (ClientPrimitiveValue) template .requestBodyAndHeaders("direct://readsingleprop", null, headers); Assert.assertTrue(singleProperty.isPrimitive()); Assert.assertEquals("San Francisco International Airport", singleProperty.toString()); final ClientComplexValue complexProperty = (ClientComplexValue) template .requestBodyAndHeaders("direct://readcomplexprop", null, headers); Assert.assertTrue(complexProperty.isComplex()); Assert.assertEquals("San Francisco", complexProperty.get("City").getComplexValue().get("Name").getValue().toString()); final ClientEntity entity = (ClientEntity) template.requestBodyAndHeaders("direct://readentitybyid", null, headers); Assert.assertNotNull(entity); Assert.assertEquals("Russell", entity.getProperty("FirstName").getValue().toString()); final ClientEntity unbFuncReturn = (ClientEntity) template .requestBodyAndHeaders("direct://callunboundfunction", null, headers); Assert.assertNotNull(unbFuncReturn); } finally { camelctx.stop(); } }
From source file:com.interaction.example.odata.multicompany.ODataMulticompanyITCase.java
/** * GET item, check link to another entity *//*from www . j a va2 s .c o m*/ @Test public void getFlightScheduleLinksToAirports() throws Exception { ODataConsumer consumer = ODataJerseyConsumer.newBuilder(baseUri).build(); OEntity flightSchedule = consumer.getEntity(FLIGHT_SCHEDULE_ENTITYSET_NAME, 2).execute(); Long id = (Long) flightSchedule.getProperty("flightScheduleID").getValue(); assertEquals(2, id.intValue()); // there should be one link to self (OData4j swallows this) // there should be one link to flights // there should be one link to one departureAirport for this flight schedule // there should be one link to one arrivalAirport for this flight schedule assertTrue(containsLink(flightSchedule.getLinks(), FLIGHT_SCHEDULE_ENTITYSET_NAME + "(" + id + ")/departureAirport", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/Airport")); assertTrue(containsLink(flightSchedule.getLinks(), FLIGHT_SCHEDULE_ENTITYSET_NAME + "(" + id + ")/arrivalAirport", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/Airport")); assertEquals(3, flightSchedule.getLinks().size()); }
From source file:com.jada.admin.customAttribute.CustomAttributeGroupMaintAction.java
public ActionForward removeCustomAttributeDetails(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Throwable { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); CustomAttributeGroupMaintActionForm form = (CustomAttributeGroupMaintActionForm) actionForm; AdminBean adminBean = getAdminBean(request); Site site = adminBean.getSite();//from ww w .j a va 2s . co m JSONEscapeObject jsonResult = new JSONEscapeObject(); jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS); Long customAttribGroupId = Format.getLong(form.getCustomAttribGroupId()); CustomAttributeGroup customAttributeGroup = CustomAttributeGroupDAO.load(site.getSiteId(), customAttribGroupId); String customAttribDetailIds[] = form.getCustomAttribDetailIds(); if (customAttribDetailIds != null) { for (int i = 0; i < customAttribDetailIds.length; i++) { CustomAttributeDetail customAttributeDetail = (CustomAttributeDetail) em .find(CustomAttributeDetail.class, Format.getLong(customAttribDetailIds[i])); if (customAttributeDetail.getCustomAttribute() .getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) { String sql = "select count(*) " + "from ItemAttributeDetail itemAttributeDetail " + "where itemAttributeDetail.customAttributeDetail = :customAttributeDetail " + "and itemAttributeDetail.item.itemTypeCd = :itemTypeCd"; Query query = em.createQuery(sql); query.setParameter("customAttributeDetail", customAttributeDetail); query.setParameter("itemTypeCd", Constants.ITEM_TYPE_SKU); Long count = (Long) query.getSingleResult(); if (count.intValue() > 0) { jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED); jsonResult.put("reason", Constants.WEBSERVICE_REASON_INUSE); streamWebService(response, jsonResult.toHtmlString()); return null; } } String sql = "delete " + "from ItemAttributeDetail itemAttributeDetail " + "where itemAttributeDetail.customAttributeDetail = :customAttributeDetail "; Query query = em.createQuery(sql); query.setParameter("customAttributeDetail", customAttributeDetail); query.executeUpdate(); customAttributeGroup.getCustomAttributeDetails().remove(customAttributeDetail); em.remove(customAttributeDetail); } } streamWebService(response, jsonResult.toHtmlString()); return null; }
From source file:com.maxmind.geoip2.WebServiceClient.java
private <T> T responseFor(String path, InetAddress ipAddress, Class<T> cls) throws GeoIp2Exception, IOException { GenericUrl uri = this.createUri(path, ipAddress); HttpResponse response = this.getResponse(uri); Long contentLength = response.getHeaders().getContentLength(); if (contentLength == null || contentLength.intValue() <= 0) { throw new HttpException("Received a 200 response for " + uri + " but there was no message body.", 200, uri.toURL());//from w w w.ja v a2s.c o m } String body = WebServiceClient.getSuccessBody(response, uri); String ip = ipAddress == null ? null : ipAddress.getHostAddress(); InjectableValues inject = new JsonInjector(locales, ip); try { return mapper.readerFor(cls).with(inject).readValue(body); } catch (IOException e) { throw new GeoIp2Exception("Received a 200 response but not decode it as JSON: " + body, e); } }
From source file:com.jms.notify.dao.impl.BaseDaoImpl.java
/** * ? ./*from w w w . j a v a2 s .c o m*/ */ public PageBean listPage(PageParam pageParam, Map<String, Object> paramMap) { if (paramMap == null) { paramMap = new HashMap<String, Object>(); } // Long totalCount = sessionTemplate.selectOne(getStatement(SQL_LIST_PAGE_COUNT), paramMap); // ? int currentPage = PageBean.checkCurrentPage(totalCount.intValue(), pageParam.getNumPerPage(), pageParam.getPageNum()); pageParam.setPageNum(currentPage); // ?? // ??numPerPage?? int numPerPage = PageBean.checkNumPerPage(pageParam.getNumPerPage()); // ? pageParam.setNumPerPage(numPerPage); // ? // ????SQL? paramMap.put("pageFirst", (pageParam.getPageNum() - 1) * pageParam.getNumPerPage()); paramMap.put("pageSize", pageParam.getNumPerPage()); paramMap.put("startRowNum", (pageParam.getPageNum() - 1) * pageParam.getNumPerPage()); paramMap.put("endRowNum", pageParam.getPageNum() * pageParam.getNumPerPage()); // ?? List<Object> list = sessionTemplate.selectList(getStatement(SQL_LIST_PAGE), paramMap); Object isCount = paramMap.get("isCount"); // ????1:? if (isCount != null && "1".equals(isCount.toString())) { Map<String, Object> countResultMap = sessionTemplate.selectOne(getStatement(SQL_COUNT_BY_PAGE_PARAM), paramMap); return new PageBean(pageParam.getPageNum(), pageParam.getNumPerPage(), totalCount.intValue(), list, countResultMap); } else { // return new PageBean(pageParam.getPageNum(), pageParam.getNumPerPage(), totalCount.intValue(), list); } }
From source file:mp.platform.cyclone.webservices.utils.server.MemberHelper.java
@SuppressWarnings("unchecked") public Member toMember(final RegisterMemberParameters params) { // Find the group MemberGroup group;/* ww w .ja v a2 s.co m*/ try { final ServiceClient client = fetchService.fetch(WebServiceContext.getClient(), ServiceClient.Relationships.MANAGE_GROUPS); final Set<MemberGroup> manageGroups = client.getManageGroups(); final Long groupId = params.getGroupId(); if (groupId == null || groupId.intValue() <= 0) { group = manageGroups.iterator().next(); } else { group = (MemberGroup) groupService.load(groupId); if (!manageGroups.contains(group)) { throw new Exception(); } } } catch (final Exception e) { throw new EntityNotFoundException(); } final MemberUser user = new MemberUser(); user.setUsername(params.getUsername()); final Member member = new Member(); member.setGroup(group); member.setUser(user); member.setName(params.getName()); member.setEmail(params.getEmail()); List<MemberCustomField> fields = (List<MemberCustomField>) customFieldService .listByNature(CustomField.Nature.MEMBER); fields = CustomFieldHelper.onlyForGroup(fields, group); final Collection<MemberCustomFieldValue> fieldValues = fieldHelper.toValueCollection(fields, params.getFields()); member.setCustomValues(fieldValues); return member; }
From source file:com.amazon.unifiedsearch.service.transformers.SRDSTransformer.java
/** * * @param input/* w w w.j a va 2s.c o m*/ * @return Pagination */ private Pagination getPages(SRDSTransformerInput input) { final Pagination paginationEntity = new PaginationEntity(); paginationEntity.setNumPages(StoreSearchConstants.DEFAULT_PAGES_SIZE); List<Page> pageEntities = new ArrayList<Page>(); // set current page final PageEntity currentPageEntity = new PageEntity(); currentPageEntity.setPage(input.getPage().intValue()); currentPageEntity.setType(StoreSearchConstants.CURRENT_PAGE); LinkEntity currentLinkEntity = new LinkEntity(); currentLinkEntity.setText(input.getPage().toString()); currentPageEntity.setLink(currentLinkEntity); pageEntities.add(currentPageEntity); if (input.getStoreSearchResponse().getResults() != null) { final PageEntity nextPageEntity = new PageEntity(); // TODO take from request and set this final Long nextPage = input.getPage() + 1; nextPageEntity.setPage(nextPage.intValue()); nextPageEntity.setType(StoreSearchConstants.NEXT_PAGE); final LinkEntity nextLinkEntity = new LinkEntity(); nextLinkEntity.setText(StoreSearchConstants.NEXT_PAGE_TEXT); String url = "/store?page=" + nextPage.toString() + "&sortBy=" + input.getSort() + "&query=" + input.getKeyword() + "&department=" + input.getAlias(); if (input.getRefinementsMap() != null && !input.getRefinementsMap().isEmpty()) { url += "&filters=" + SRDSTransformerRefinementsBuilder .getRefinementsMapAsString(input.getRefinementsMap(), null); } nextLinkEntity.setUrl(url); nextPageEntity.setLink(nextLinkEntity); pageEntities.add(nextPageEntity); } paginationEntity.setPages(pageEntities); return paginationEntity; }
From source file:com.oltpbenchmark.benchmarks.auctionmark.util.UserIdGenerator.java
/** * Construct a new generator based on the given histogram. * If clientId is not null, then this generator will only return UserIds that are mapped * to that clientId based on the UserId's offset * @param users_per_item_count// w ww.j av a 2 s.co m * @param numClients * @param clientId */ public UserIdGenerator(Histogram<Long> users_per_item_count, int numClients, Integer clientId) { assert (users_per_item_count != null); if (numClients <= 0) throw new IllegalArgumentException("numClients must be more than 0 : " + numClients); if (clientId != null && clientId < 0) throw new IllegalArgumentException("clientId must be more than or equal to 0 : " + clientId); this.numClients = numClients; this.clientId = clientId; Long temp = users_per_item_count.getMaxValue(); if (temp == null) temp = users_per_item_count.getMaxValue(); assert (temp != null) : "Invalid Users Per Item Histogram:\n" + users_per_item_count; this.maxItemCount = temp.intValue(); this.usersPerItemCounts = new int[this.maxItemCount + 2]; for (int i = 0; i < this.usersPerItemCounts.length; i++) { this.usersPerItemCounts[i] = users_per_item_count.get((long) i, 0); } // FOR temp = users_per_item_count.getMinValue(); this.minItemCount = (temp != null ? temp.intValue() : 0); this.totalUsers = users_per_item_count.getSampleCount(); this.setCurrentItemCount(this.minItemCount); }
From source file:cn.chenlichao.web.ssm.service.impl.BaseServiceImpl.java
@Override public PageResults<E> queryPageByExample(PageParams<E> pageParams, Example example) { if (pageParams == null) { throw new IllegalArgumentException("?null"); }// w ww. j a v a 2 s. c om if (example == null) { throw new IllegalArgumentException("?null"); } if (entityClass != null && !entityClass.equals(example.getEntityClass())) { throw new IllegalArgumentException("????"); } LOGGER.trace("example?..."); // ?? int pageNum = pageParams.getPageIndex(); int pageSize = pageParams.getPageSize(); if (pageSize > 100) { LOGGER.warn(", ?[{}] ?, ? 100 ?", pageSize); pageSize = 100; } // PageHelper.startPage(pageNum, pageSize); List<E> results = baseMapper.selectByExample(example); // if (results == null || !(results instanceof Page)) { return new PageResults<>(0, new ArrayList<E>(0), pageParams); } Page page = (Page) results; Long totalCount = page.getTotal(); return new PageResults<>(totalCount.intValue(), results, pageParams); }