Example usage for java.lang Long Long

List of usage examples for java.lang Long Long

Introduction

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

Prototype

@Deprecated(since = "9")
public Long(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Long object that represents the long value indicated by the String parameter.

Usage

From source file:com.ewcms.content.vote.service.PersonService.java

private void updVoteNumber(Person person) {
    List<Record> records = person.getRecords();
    for (Record record : records) {
        String subjectName = record.getSubjectName();
        String subjectValue = record.getSubjectValue();

        String[] recordNames = subjectName.split("_");
        if (recordNames.length == 2) {
            if (recordNames[0].equals("Subject")) {
                if (!recordNames[1].equals("") && StringUtils.isNumeric(recordNames[1])) {
                    Long subjectId = new Long(recordNames[1]);
                    Subject subject = subjectDao.findOne(subjectId);
                    if (subject == null)
                        continue;
                    if (subject.getStatus() == Subject.Status.INPUT) {
                        SubjectItem subjectItem = subjectItemDao
                                .findSubjectItemBySubjectAndInputStatus(subjectId, Subject.Status.INPUT);
                        if (subjectItem == null)
                            continue;
                        subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1);
                        subjectItemDao.save(subjectItem);
                    } else {
                        if (!subjectValue.equals("") && StringUtils.isNumeric(subjectValue)) {
                            Long subjectItemId = new Long(subjectValue);
                            SubjectItem subjectItem = subjectItemDao.findOne(subjectItemId);
                            subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1);
                            subjectItemDao.save(subjectItem);
                        }//ww w .  ja  v  a 2 s.c  o m
                    }
                }
            }
        } else if (recordNames.length == 4) {
            if (recordNames[0].equals("Subject") && recordNames[2].equals("Item")) {
                if (!recordNames[3].equals("") && StringUtils.isNumeric(recordNames[3])) {
                    Long subjectItemId = new Long(recordNames[3]);
                    SubjectItem subjectItem = subjectItemDao.findOne(subjectItemId);
                    subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1);
                    subjectItemDao.save(subjectItem);
                }
            }
        }
    }
}

From source file:org.tsm.concharto.web.flagevent.FlagEventController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    Long eventId = new Long(request.getParameter(REQUEST_ID));
    String username = (String) WebUtils.getSessionAttribute(request, AuthConstants.SESSION_AUTH_USERNAME);
    FlagEventForm flagEventForm = (FlagEventForm) command;

    Event event = saveFlag(flagEventForm, eventId, username);
    //update the event that is in the search results, since we are going back there
    SearchSessionUtil.updateEventInSession(request, event);
    return new ModelAndView(getSuccessView(), errors.getModel());
}

From source file:org.geoserver.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java

public PagingLoadResult<UserGroupModel> getProfiles(int offset, int limit, boolean full)
        throws ApplicationException {

    int start = offset;

    List<UserGroupModel> profileListDTO = new ArrayList<UserGroupModel>();

    if (full) {//from   w  w w .  ja  va2 s .  c o  m
        UserGroupModel all_profile = new UserGroupModel();
        all_profile.setId(-1);
        all_profile.setName("*");
        all_profile.setEnabled(true);
        all_profile.setDateCreation(null);
        profileListDTO.add(all_profile);
    }

    long profilesCount = geofenceRemoteService.getUserGroupAdminService().getCount(null) + 1;

    Long t = new Long(profilesCount);

    int page = (start == 0) ? start : (start / limit);

    List<ShortGroup> profilesList = geofenceRemoteService.getUserGroupAdminService().getList(null, page, limit);

    if (profilesList == null) {
        if (logger.isErrorEnabled()) {
            logger.error("No profile found on server");
        }
        throw new ApplicationException("No profile found on server");
    }

    Iterator<ShortGroup> it = profilesList.iterator();

    while (it.hasNext()) {
        ShortGroup short_profile = it.next();

        org.geoserver.geofence.core.model.UserGroup remote_profile;
        try {
            remote_profile = geofenceRemoteService.getUserGroupAdminService().get(short_profile.getId());
        } catch (NotFoundServiceEx e) {
            if (logger.isErrorEnabled()) {
                logger.error("Details for profile " + short_profile.getName() + " not found on Server!");
            }
            throw new ApplicationException(
                    "Details for profile " + short_profile.getName() + " not found on Server!");
        }

        UserGroupModel local_profile = new UserGroupModel();

        local_profile.setId(short_profile.getId());
        local_profile.setName(remote_profile.getName());
        local_profile.setDateCreation(remote_profile.getDateCreation());
        local_profile.setEnabled(remote_profile.getEnabled());
        // TODO: use specific API methods in order to load UserGroup custom props
        // local_profile.setCustomProps(remote_profile.getCustomProps());

        profileListDTO.add(local_profile);
    }

    return new RpcPageLoadResult<UserGroupModel>(profileListDTO, offset, t.intValue());
}

From source file:com.redhat.rhn.common.db.datasource.test.AdvDataSourceTest.java

private void lookup(String foobar, int id, int size) {
    SelectMode m = ModeFactory.getMode("test_queries", "find_in_table");
    HashMap params = new HashMap();
    params.put("foobar", foobar);
    params.put("id", new Integer(id));
    DataResult<AdvDataSourceDto> dr = m.execute(params);
    assertEquals(size, dr.size());/*from   w w  w  .ja  va 2  s .c  o m*/
    if (size > 0) {
        assertEquals(foobar, dr.get(0).getFoobar());
        assertEquals(new Long(id), dr.get(0).getId());
    }
}

From source file:com.birt.airvantage.FleetHistoricalDataConnector.java

public void loadFleetHistoricalData(AVSystem d, String companyUid, AVRequest request, String dataId) {
    String historicalData = request.getFleetAgregatedDatapoints(dataId, companyUid);
    if (Parameters.DEBUG)
        System.out.println("historical:\n" + historicalData);
    JSONObject result;/*from   www . ja v  a 2 s .  c o  m*/
    try {
        result = new JSONObject(historicalData);
        JSONArray datapoints = result.getJSONObject(companyUid).getJSONArray(dataId);

        history = new ArrayList<AVTimestampedData>();
        for (int i = 0; i < datapoints.length(); i++) {
            Long value = null;
            if (!datapoints.getJSONObject(i).isNull("v"))
                value = new Long(datapoints.getJSONObject(i).getLong("v"));
            long timestamp = datapoints.getJSONObject(i).getLong("ts");
            AVTimestampedData data = new AVTimestampedData(d, value, new Date(timestamp));
            history.add(data);
        }
        //d.setHistoricalBlackInkLevel(dataHistory);

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:org.openregistry.core.service.DefaultIdentifierNotificationServiceIntegrationTests.java

@Before
public void setUp() {
    this.simpleJdbcTemplate
            .update("insert into ctx_data_types (id, data_type, description) values(998, 'STATUS', 'ACTIVE')");
    this.simpleJdbcTemplate
            .update("insert into ctx_data_types (id, data_type, description) values(999, 'EMAIL', 'HOME')");
    homeEmailType = this.referenceRepository.getTypeById(new Long(999));
    netIdIdentifierType = this.referenceRepository.findIdentifierType("NETID");
}

From source file:es.tid.fiware.rss.dao.impl.test.ServDeployMopDaoImplTest.java

/**
 * Test method for// w w  w.  ja v  a 2s.c o m
 * {@link es.tid.fiware.rss.dao.impl.ServDeployMopDaoImpl#getServDeployMopFilter(java.lang.Long, java.lang.Long)}.
 */
@Test
public void test10GetServDeployMopFilter() {
    // Call method to test
    List<BmServdeployMop> list = servDeployMopDao.getServDeployMopFilter(new Long(1), new Long(1));

    // Check result
    Assert.assertTrue("Size not equal", list.size() == 3);
    for (int i = 0; i < list.size(); i++) {
        BmServdeployMop servdeployMop = list.get(i);

        long idCustomerType = 1;
        long idDeployment = 0;
        long idMop = 0;
        String defaultYn = "";
        switch (servdeployMop.getNuServiceMopId().intValue()) {
        case 1:
            idCustomerType = 1;
            idDeployment = 1;
            idMop = 1;
            defaultYn = "N";
            break;
        case 2:
            idCustomerType = 1;
            idDeployment = 1;
            idMop = 2;
            defaultYn = "N";
            break;
        case 6:
            idCustomerType = 1;
            idDeployment = 1;
            idMop = 3;
            defaultYn = "N";
            break;
        }

        Assert.assertTrue("Customer type ID not equal",
                servdeployMop.getBmCustomerType().getNuCustomerTypeId() == idCustomerType);
        Assert.assertTrue("Deployment ID not equal",
                servdeployMop.getBmServiceDeployment().getNuDeploymentId() == idDeployment);
        Assert.assertTrue("MOP ID not equal", servdeployMop.getBmMethodsOfPayment().getNuMopId() == idMop);
        Assert.assertTrue("defaultYn not equal", servdeployMop.getTcDefaultYn().compareTo(defaultYn) == 0);
    }

    // call null parameter
    list = servDeployMopDao.getServDeployMopFilter(new Long(1), null);
    Assert.assertNotNull("Size not equal", list);
    Assert.assertTrue("Size not equal", list.size() == 6);
    Assert.assertTrue("Size not equal", list.get(0).getBmServiceDeployment().getNuDeploymentId() == 1);

}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsJnlpCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#execute()
 */// www  .j  a v a 2s . co m
public SdsJnlp execute(final HttpPostRequest httpRequest) {
    final Map<String, String> responseHeaders = this.transport.post(httpRequest);
    final String locationHeader = responseHeaders.get("Location");
    final SdsJnlp sdsJnlp = this.getSdsJnlp();
    // clear the thread local reference to avoid resource leak since we're
    // done executing
    SDS_JNLP.set(null);
    sdsJnlp.setSdsObjectId(new Long(locationHeader.substring(locationHeader.lastIndexOf("/") + 1)));
    return sdsJnlp;
}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsUserCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#execute()
 *//* ww w. j  a  va2 s .co  m*/
public SdsUser execute(final HttpPostRequest httpRequest) {
    final Map<String, String> responseHeaders = this.transport.post(httpRequest);
    final String locationHeader = responseHeaders.get("Location");
    final SdsUser sdsUser = this.getSdsUser();
    // clear the thread local reference to avoid resource leak since we're
    // done executing
    SDS_USER.set(null);
    sdsUser.setSdsObjectId(new Long(locationHeader.substring(locationHeader.lastIndexOf("/") + 1)));
    return sdsUser;
}

From source file:de.iai.ilcd.model.dao.CommonDataStockDao.java

/**
 * Get a root data stock by it's database ID
 * /*  w w w  .j a  v a  2 s.  c om*/
 * @param id
 *            id of data stock to find
 * @return loaded data stock
 */
public RootDataStock getRootDataStockById(long id) {
    EntityManager em = PersistenceUtil.getEntityManager();
    return em.find(RootDataStock.class, new Long(id));
}