Example usage for java.lang Long intValue

List of usage examples for java.lang Long intValue

Introduction

In this page you can find the example usage for java.lang Long intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Long as an int after a narrowing primitive conversion.

Usage

From source file:org.asqatasun.entity.service.audit.ContentDataServiceImpl.java

/**
 * //w ww .  jav a  2  s .  c  om
 * @param webResourceId
 * @param startValue
 * @param windowSize
 * @param beginProcessDate
 * @param getContentWithRelatedContent
 * @param getContentWithNullDom
 * @return 
 */
private List<Content> getContentList(Long webResourceId, Long startValue, int windowSize,
        boolean getContentWithRelatedContent, boolean getContentWithNullDom) {

    Date beginProcessDate = Calendar.getInstance().getTime();
    List<Content> contentList = new ArrayList<>();

    // First we retrieve a list of Ids
    Collection<Long> contentIdList = this.getSSPIdsFromWebResource(webResourceId, HttpStatus.SC_OK,
            startValue.intValue(), windowSize);

    // we retrieve each content from its ID and add it to the contentList 
    // that will be returned
    for (Long id : contentIdList) {
        Content content;
        if (getContentWithRelatedContent) {
            content = this.readWithRelatedContent(id, true);
        } else {
            content = this.read(id);
        }
        if (content != null && (getContentWithNullDom || (!getContentWithNullDom && content instanceof SSP
                && StringUtils.isNotEmpty(((SSP) content).getDOM())))) {
            contentList.add(content);
        }
    }

    if (LOGGER.isDebugEnabled()) {
        long length = 0;
        int nbOfResources = 0;
        for (Content content : contentList) {
            if (((SSP) content).getDOM() != null) {
                length += ((SSP) content).getDOM().length();
                if (getContentWithRelatedContent) {
                    nbOfResources += ((SSP) content).getRelatedContentSet().size();
                }
            }
        }
        StringBuilder debugMessage = new StringBuilder("Retrieving  ").append(contentList.size())
                .append(" SSP took ")
                .append(Calendar.getInstance().getTime().getTime() - beginProcessDate.getTime())
                .append(" ms and working on ").append(length).append(" characters");
        if (getContentWithRelatedContent) {
            debugMessage.append(" and ");
            debugMessage.append(nbOfResources);
            debugMessage.append(" relatedContent ");
        }
        LOGGER.debug(debugMessage.toString());
    }
    return contentList;
}

From source file:eu.supersede.dm.DMGame.java

public User getUser(Long userId, String tenantId, AuthorizationToken token) {
    if (jpa == null) {
        System.out.println("jpa null");
        return null;
    }//from  w  ww  .j a v a 2  s . co  m

    if (jpa.proxy == null) {
        System.out.println("jpa proxy null");
        return null;
    }

    eu.supersede.integration.api.datastore.fe.types.User proxyUser = jpa.proxy.getFEDataStoreProxy()
            .getUser(tenantId, userId.intValue(), true, token);

    if (proxyUser == null) {
        throw new NotFoundException("Can't find user with id " + userId);
    }

    User user = jpa.users.findOne(userId);

    if (user == null) {
        // Save the user in the database if it is not already present
        user = new User(userId);
        user.setName(proxyUser.getFirst_name() + " " + proxyUser.getLast_name());
        user.setEmail(proxyUser.getEmail());
        return jpa.users.save(user);
    } else {
        return user;
    }
}

From source file:com.hortonworks.registries.schemaregistry.avro.ConfluentRegistryCompatibleResourceTest.java

@Test
public void testConfluentApis() throws Exception {
    List<String> schemas = Arrays
            .stream(new String[] { "/device.avsc", "/device-compat.avsc", "/device-incompat.avsc" }).map(x -> {
                try {
                    return fetchSchema(x);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }/*from  w  ww .j a v a2 s .  c om*/
            }).collect(Collectors.toList());

    ObjectMapper objectMapper = new ObjectMapper();
    List<String> subjects = new ArrayList<>();
    for (String schemaText : schemas) {
        String subjectName = UUID.randomUUID().toString();
        subjects.add(subjectName);

        // check post schema version
        Long schemaId = objectMapper
                .readValue(postSubjectSchema(subjectName, schemaText).readEntity(String.class), Id.class)
                .getId();

        // check get version api
        Schema schemaVersionEntry = getVersion(subjectName, "latest");

        Assert.assertEquals(subjectName, schemaVersionEntry.getSubject());
        Assert.assertEquals(schemaId.intValue(), schemaVersionEntry.getId().intValue());
        org.apache.avro.Schema recvdSchema = new org.apache.avro.Schema.Parser()
                .parse(schemaVersionEntry.getSchema());
        org.apache.avro.Schema regdSchema = new org.apache.avro.Schema.Parser().parse(schemaText);
        Assert.assertEquals(regdSchema, recvdSchema);
    }

    // check all registered subjects
    List<String> recvdSubjects = getAllSubjects();
    Assert.assertEquals(new HashSet<>(subjects), new HashSet<>(recvdSubjects));
}

From source file:de.bps.webservices.clients.onyxreporter.OnyxReporterConnector.java

private ResultsForStudent getStudentWithResult(Identity student, File resultFile) {
    ResultsForStudent resForStudent = null;
    Long fileLength = resultFile.length();
    byte[] resultFileStream = new byte[fileLength.intValue()];
    java.io.FileInputStream inp = null;

    try {/*from  w w  w.j  ava  2 s .  co  m*/
        inp = new java.io.FileInputStream(resultFile);
        inp.read(resultFileStream);

        //<OLATCE-1089>
        String lastname = student.getUser().getProperty(UserConstants.LASTNAME, null);
        String firstname = student.getUser().getProperty(UserConstants.FIRSTNAME, null);
        lastname = lastname != null && lastname.length() > 0 ? lastname : NONAME;
        firstname = firstname != null && firstname.length() > 0 ? firstname : NONAME;

        resForStudent = new ResultsForStudent();
        //<OLATCE-1169>
        resForStudent.setFirstname(firstname);
        resForStudent.setLastname(lastname);
        //</OLATCE-1169>
        //</OLATCE-1089>
        //resForStudent.setStudentId(String.valueOf(student.getKey()));
        String filename = resultFile.getName();
        Matcher matcher = pattern.matcher(filename);
        String assessmentId = null;
        if (matcher.matches()) {
            assessmentId = matcher.group(2);
        } else {
            final Long key = student.getKey();
            log.warn("Could not determine assessment ID from unexpected file name " + filename);
            assessmentId = String.valueOf(key);
        }
        resForStudent.setStudentId(assessmentId);

        resForStudent.setGroupname("");
        resForStudent.setTutorname("");
        resForStudent.setResultsFile(resultFileStream);

    } catch (FileNotFoundException e) {
        log.error("Missing file: " + resultFile.getAbsolutePath(), e);
    } catch (IOException e) {
        log.error("Error copying file: " + resultFile.getAbsolutePath(), e);
    } finally {
        IOUtils.closeQuietly(inp);
    }
    return resForStudent;

}

From source file:architecture.ee.web.community.page.dao.jdbc.JdbcPageDao.java

private void cleanupVersionsOnPublish(Page page) {
    if (page.getVersionId() > 0) {
        try {/*w w  w. j a v a  2s .co  m*/
            int pubishedVersion = getExtendedJdbcTemplate().queryForObject(
                    getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_PUBLISHED_PAGE_VERSION_NUMBER").getSql(),
                    Integer.class, new SqlParameterValue(Types.NUMERIC, page.getPageId()));
            page.setVersionId(pubishedVersion + 1);
        } catch (EmptyResultDataAccessException e) {
            int maxArchiveId = getExtendedJdbcTemplate().queryForObject(
                    getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_MAX_ARCHIVED_PAGE_VERSION_NUMBER").getSql(),
                    Integer.class, new SqlParameterValue(Types.NUMERIC, page.getPageId()));
            if (maxArchiveId > 0)
                page.setVersionId(maxArchiveId + 1);
            else
                page.setVersionId(1);
        }
        List<Long> toDelete = getExtendedJdbcTemplate().queryForList(
                getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_DRAFT_PAGE_VERSIONS").getSql(), Long.class,
                new SqlParameterValue(Types.NUMERIC, page.getPageId()));
        for (Long version : toDelete)
            deleteVersion(page, version.intValue());
    }
    getExtendedJdbcTemplate().update(
            getBoundSql("ARCHITECTURE_COMMUNITY.UPDATE_PAGE_STATE_TO_ARCHIVED").getSql(),
            new SqlParameterValue(Types.NUMERIC, page.getPageId()),
            new SqlParameterValue(Types.NUMERIC, page.getVersionId()));

    getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.UPDATE_PAGE_VISION_NUMBER").getSql(),
            new SqlParameterValue(Types.NUMERIC, page.getVersionId()),
            new SqlParameterValue(Types.NUMERIC, page.getPageId()));

}

From source file:com.vodafone360.people.service.transport.http.photouploadmanager.PhotoUploadManager.java

/**
 * Uploadfile in chnks./*from  ww w  . j  ava2  s .c o  m*/
 * @param request Input.
 * @param reqIds Input.
 * @param uploadid Input.
 * @return boolean for success.
 */
Boolean UploadFileInChunks(final Request request, final List<Integer> reqIds, final Long uploadid) {
    HttpResponse resp = null;
    File mfilname = new File(request.mfileName);
    Boolean merror = false;
    try {
        FileInputStream fin = new FileInputStream(mfilname);
        byte[] arrayBuff = new byte[request.chunkSize];
        Long num = request.mfileSize / new Long(request.chunkSize);
        int offset = 0;
        Integer mchunkNumberToUpload = 1;

        while (mchunkNumber > 1) {
            int sizeread = fin.read(arrayBuff);
            mchunkNumber--;
            offset = offset + sizeread;
            byte[] payload2 = request.getEncodedUploadChunkPayload(arrayBuff, uploadid, mchunkNumberToUpload);
            resp = postHTTPRequest(payload2, mApiUrl, Settings.HTTP_HEADER_CONTENT_TYPE);
            if (print(resp) == HttpStatus.SC_OK) {
                Log.v("http-contentuplaod", "Response-SC_OK");
            } else {
                addErrorToResponseQueue(reqIds);
                merror = true;
                break;
            }
            mchunkNumberToUpload++;
        }
        if (merror == false) {
            Long left = request.mfileSize - offset;
            byte[] lastOfFile = new byte[left.intValue()];
            int sizeread = fin.read(lastOfFile);
            fin.close();
            byte[] payload3 = request.getEncodedUploadChunkPayload(lastOfFile, uploadid, mchunkNumberToUpload);
            resp = postHTTPRequest(payload3, mApiUrl, Settings.HTTP_HEADER_CONTENT_TYPE);
            if (print(resp) == HttpStatus.SC_OK) {
                Log.v("HttpContentUpload", "Correct-Http-Response");
            } else {
                addErrorToResponseQueue(reqIds);
                merror = true;
            }
        }
    } catch (Exception e) {
        merror = true;
        addErrorToResponseQueue(reqIds);
    }
    return merror;
}

From source file:edu.harvard.iq.dvn.core.study.StudyFileServiceBean.java

public Boolean doesStudyHaveSingleTabularFiles(Long studyVersionId) {

    List<Long> subsettableList = new ArrayList();
    Query query = em.createNativeQuery(
            "SELECT count(d.*) FROM  DataTable d, studyfile sf,  studyversion sv where d.studyfile_id = sf.id and sf.study_id = sv.study_id and sv.id = "
                    + studyVersionId + " group by studyfile_id");
    for (Object currentResult : query.getResultList()) {
        subsettableList.add((Long) currentResult);
    }//from  ww w.ja  v a2 s  . co m

    if (!subsettableList.isEmpty()) {
        for (Long fclass : subsettableList) {
            if (fclass.intValue() == 1) {
                return Boolean.TRUE;
            }
        }
    }

    return Boolean.FALSE;

}

From source file:com.zb.app.web.controller.account.AccountCustomerController.java

@RequestMapping(value = "/qqSave.htm", produces = "application/json")
@ResponseBody//from   w  w w. j  a  v  a  2s .  c  o  m
public JsonResult qqSave(@Valid TravelServiceVO service, BindingResult result) {
    Result rs = showErrors(result);
    if (rs.isFailed()) {
        return JsonResultUtils.error(rs.getMessage());
    }
    ObjectUtils.trim(service);
    TravelServiceDO serviceDO = new TravelServiceDO();
    BeanUtils.copyProperties(serviceDO, service);
    serviceDO.setcId(WebUserTools.getCid());
    if (serviceDO.getsIsReceive() == null) {
        serviceDO.setsIsReceive(0);
    }
    if (service.getsId() != null && service.getsId() > 0) {
        companyService.updateById(serviceDO);
        companyService.realDelServiceSite(serviceDO.getsId());
        for (Long l : service.getzId()) {
            TravelServiceSiteDO serviceSiteDO = new TravelServiceSiteDO();
            serviceSiteDO.setsId(serviceDO.getsId().intValue());
            serviceSiteDO.setzId(l.intValue());
            companyService.addServiceSite(serviceSiteDO);
        }
        return JsonResultUtils.success("?!");
    }
    List<TravelServiceDO> list = companyService
            .list(new TravelServiceQuery(WebUserTools.getCid(), service.getsName()));
    if (list != null && list.size() > 0) {
        return JsonResultUtils.error("??!");
    }
    companyService.addService(serviceDO);
    for (Long l : service.getzId()) {
        TravelServiceSiteDO serviceSiteDO = new TravelServiceSiteDO();
        serviceSiteDO.setsId(serviceDO.getsId().intValue());
        serviceSiteDO.setzId(l.intValue());
        companyService.addServiceSite(serviceSiteDO);
    }

    return JsonResultUtils.success("??");
}

From source file:cc.kune.core.server.content.ContentManagerDefault.java

@Override
public SearchResult<Content> searchMime(final String search, final Integer firstResult,
        final Integer maxResults, final String groupShortName, final String mimetype) {
    final List<Content> list = contentFinder.findMime(groupShortName, "%" + search + "%", mimetype, firstResult,
            maxResults);// w w w .  j a  v  a2s . c o  m
    final Long count = contentFinder.findMimeCount(groupShortName, "%" + search + "%", mimetype);
    return new SearchResult<Content>(count.intValue(), list);
}

From source file:cc.kune.core.server.content.ContentManagerDefault.java

@Override
public RateResult rateContent(final User rater, final Long contentId, final Double value)
        throws DefaultException {
    final Content content = finder.getContent(contentId);
    final Rate oldRate = finder.getRate(rater, content);
    if (oldRate == null) {
        final Rate rate = new Rate(rater, content, value);
        super.persist(rate, Rate.class);
    } else {//from   w  w  w . j  a v a 2s. c  om
        oldRate.setValue(value);
        super.persist(oldRate, Rate.class);
    }
    final Double rateAvg = getRateAvg(content);
    final Long rateByUsers = getRateByUsers(content);
    return new RateResult(rateAvg != null ? rateAvg : 0D, rateByUsers != null ? rateByUsers.intValue() : 0,
            value);
}