Example usage for java.lang Integer longValue

List of usage examples for java.lang Integer longValue

Introduction

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

Prototype

public long longValue() 

Source Link

Document

Returns the value of this Integer as a long after a widening primitive conversion.

Usage

From source file:org.apache.hadoop.hive.ql.udf.UDFToLong.java

public Long evaluate(Integer i) {
    if (i == null) {
        return null;
    } else {/*from   w w  w .ja v  a  2  s .com*/
        return Long.valueOf(i.longValue());
    }
}

From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java

/**
 * Gets a kickstart script/*from w w w.j a v a2 s .c  o  m*/
 * @param org the org doing the request
 * @param id  the id of the script
 * @return the kickstartScript
 */
public static KickstartScript lookupKickstartScript(Org org, Integer id) {
    KickstartScript script = (KickstartScript) HibernateFactory.getSession().load(KickstartScript.class,
            id.longValue());
    if (!org.equals(script.getKsdata().getOrg())) {
        return null;
    }
    return script;
}

From source file:org.sigmah.server.endpoint.gwtrpc.handler.UpdateGlobalExportSettingsHandler.java

@SuppressWarnings("unchecked")
@Override//w  w  w  .ja v  a 2 s . c  om
public CommandResult execute(UpdateGlobalExportSettings cmd, User user) throws CommandException {

    final GlobalExportSettings settings = dao.getGlobalExportSettingsByOrganization(cmd.getOrganizationId());

    // only updates default global export format
    if (cmd.getUpdateDefaultExportFormat()) {
        settings.setDefaultOrganizationExportFormat(cmd.getDefaultOrganizationExportFormat());
        em.merge(settings);
    } else {
        settings.setAutoDeleteFrequency(cmd.getAutoDeleteFrequency());
        settings.setAutoExportFrequency(cmd.getAutoExportFrequency());
        settings.setExportFormat(cmd.getExportFormat());
        em.merge(settings);

        final Map<Integer, Boolean> fieldsMap = cmd.getFieldsMap();
        for (Integer elementid : fieldsMap.keySet()) {
            FlexibleElement element = em.find(FlexibleElement.class, new Long(elementid.longValue()));
            element.setGloballyExportable(fieldsMap.get(elementid));
            em.merge(element);
        }
    }
    return null;
}

From source file:com.mmj.app.biz.service.impl.TopicServiceImpl.java

@Override
public Long add(TopicDO... t) {
    t = ArrayUtils.removeNullElement(t);
    if (Argument.isEmptyArray(t)) {
        return 0l;
    }// ww  w. ja  v a 2s  .  c  o  m
    Integer count = topicDao.insert(t);
    if (t.length == 1) {
        return count.longValue();
    }
    return count == 0 ? 0l : 1l;
}

From source file:com.amazonaws.mturk.cmd.ExtendHITs.java

protected void runCommand(CommandLine cmdLine) throws Exception {
    if (!cmdLine.hasOption(ARG_SUCCESSFILE)) {
        log.error("Missing: -" + ARG_SUCCESSFILE + " [path to success file]");
        System.exit(-1);/*from ww  w .  j  ava 2 s .c  o m*/
    }

    if (!cmdLine.hasOption(ARG_ASSIGNMENTS) && !cmdLine.hasOption(ARG_HOURS)) {
        log.error("Missing parameters: Please specify an option for either -" + ARG_ASSIGNMENTS + " or -"
                + ARG_HOURS);
        System.exit(-1);
    }

    Integer assignments = parseInt(cmdLine, ARG_ASSIGNMENTS);
    Integer hours = parseInt(cmdLine, ARG_HOURS);

    Long seconds = null;
    if (hours != null) {
        seconds = hours.longValue() * 3600;
    }

    log.info("--- Starting to extend HITs ---");

    extendHITs(cmdLine.getOptionValue(ARG_SUCCESSFILE), assignments, seconds);

    // print summary
    log.info("--- Finished to extend HITs ---");
    log.info(String.format("  %d HITs have been extended (added %d assignment(s), %d hour(s))", successCount,
            (assignments == null) ? 0 : assignments, (hours == null) ? 0 : hours));
    log.info(String.format("  %d HITs failed to be extended.", failedCount));
}

From source file:org.openlmis.performancetesting.builder.ProcessingScheduleBuilder.java

public ProcessingPeriod createPeriod(Integer name, Date startDate, Date endDate,
        ProcessingSchedule monthlySchedule) {
    ProcessingPeriod period = new ProcessingPeriod();
    period.setId(name.longValue());
    period.setName(new SimpleDateFormat("MM-dd-yyyy").format(startDate));
    period.setDescription(randomAlphanumeric(10));
    period.setNumberOfMonths(1);/*from   w  ww.  j a  va2 s. c  om*/
    period.setStartDate(startDate);
    period.setEndDate(endDate);
    period.setScheduleId(monthlySchedule.getId());
    period.setModifiedBy(Long.valueOf(randomNumeric(5)));
    period.setModifiedDate(randomDate());

    return period;
}

From source file:com.springsource.greenhouse.events.load.NFJSLoader.java

@SuppressWarnings("unchecked")
private void loadEventSessionData(int showId, long event, String abbreviation) {
    List<Map<String, Object>> topicMapList = (List<Map<String, Object>>) restTemplate.getForObject(
            "https://springone2gx.com/m/data/show_topics.json?showId={showId}", List.class, showId);
    for (Map<String, Object> topicMap : topicMapList) {
        long sourceId = (Integer) topicMap.get("id");
        String title = (String) topicMap.get("title");
        String description = (String) topicMap.get("summary");
        String hashtag = "#" + abbreviation + sourceId;
        Long venue = null; // TODO: Figure out how to get this from event
        Long sourceTimeslot = topicSlotMap.get(sourceId);
        Long timeslot = timeSlotIdMap.get(sourceTimeslot);
        List<Integer> speakerIds = (List<Integer>) topicMap.get("speakerIds");
        List<Long> leaderIds = new ArrayList<Long>();
        for (Integer speakerId : speakerIds) {
            Long leaderId = leaderIdMap.get(speakerId.longValue());
            if (leaderId != null) {
                leaderIds.add(leaderId);
            } else {
                logger.warn("Unknown speaker ID " + speakerId + ". Not in show_speakers.json feed.");
            }//from  w w  w .ja v a2 s  . c  o m
        }

        EventSessionData eventSessionData = new EventSessionData(event, -1, title, description, hashtag, venue,
                timeslot, PROVIDER_ID, sourceId, leaderIds);
        loaderRepository.loadEventSession(eventSessionData);
    }
}

From source file:org.grails.datastore.mapping.model.types.BasicTypeConverterRegistrar.java

public void register(ConverterRegistry registry) {
    registry.addConverter(new Converter<Date, String>() {
        public String convert(Date date) {
            return String.valueOf(date.getTime());
        }/* w  w w.  jav a2 s  .c  om*/
    });

    registry.addConverter(new Converter<Date, Calendar>() {
        public Calendar convert(Date date) {
            final GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime(date);
            return calendar;
        }
    });

    registry.addConverter(new Converter<Integer, Long>() {
        public Long convert(Integer integer) {
            return integer.longValue();
        }
    });

    registry.addConverter(new Converter<Long, Integer>() {
        public Integer convert(Long longValue) {
            return longValue.intValue();
        }
    });

    registry.addConverter(new Converter<Integer, Double>() {
        public Double convert(Integer integer) {
            return integer.doubleValue();
        }
    });

    registry.addConverter(new Converter<CharSequence, Date>() {
        public Date convert(CharSequence s) {
            try {
                final Long time = Long.valueOf(s.toString());
                return new Date(time);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Double>() {
        public Double convert(CharSequence s) {
            try {
                return Double.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Integer>() {
        public Integer convert(CharSequence s) {
            try {
                return Integer.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Long>() {
        public Long convert(CharSequence s) {
            try {
                return Long.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<Object, String>() {
        public String convert(Object o) {
            return o.toString();
        }
    });

    registry.addConverter(new Converter<Calendar, String>() {
        public String convert(Calendar calendar) {
            return String.valueOf(calendar.getTime().getTime());
        }
    });

    registry.addConverter(new Converter<CharSequence, Calendar>() {
        public Calendar convert(CharSequence s) {
            try {
                Date date = new Date(Long.valueOf(s.toString()));
                Calendar c = new GregorianCalendar();
                c.setTime(date);
                return c;
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });
}

From source file:org.openmrs.module.openhmis.inventory.api.impl.ItemStockDetailDataServiceImpl.java

@Override
@Transactional(readOnly = true)// w  w w.ja v a2s .c o  m
@Authorized({ PrivilegeConstants.VIEW_METADATA })
public List<ItemStockSummary> getItemStockSummaryByStockroom(final Stockroom stockroom, PagingInfo pagingInfo) {
    if (stockroom == null) {
        throw new IllegalArgumentException("The stockroom must be defined.");
    }

    // We cannot use a normal Criteria query here because criteria does not support a group by with a having statement
    // so HQL it is!

    if (pagingInfo != null && pagingInfo.shouldLoadRecordCount()) {
        // Load the record count (for paging)
        String countHql = "select 1 " + "from ItemStockDetail as detail " + "where stockroom.id = "
                + stockroom.getId() + " " + "group by item, expiration " + "having sum(detail.quantity) <> 0";
        Query countQuery = getRepository().createQuery(countHql);

        Integer count = countQuery.list().size();

        pagingInfo.setTotalRecordCount(count.longValue());
        pagingInfo.setLoadRecordCount(false);
    }

    // Create the query and optionally add paging
    String hql = "select i, detail.expiration, sum(detail.quantity) as sumQty "
            + "from ItemStockDetail as detail inner join detail.item as i " + "where detail.stockroom.id = "
            + stockroom.getId() + " " + "group by i, detail.expiration " + "having sum(detail.quantity) <> 0"
            + "order by i.name asc, detail.expiration asc";
    Query query = getRepository().createQuery(hql);
    query = this.createPagingQuery(pagingInfo, query);

    List list = query.list();

    // Parse the aggregate query into an ItemStockSummary object
    List<ItemStockSummary> results = new ArrayList<ItemStockSummary>(list.size());
    for (Object obj : list) {
        Object[] row = (Object[]) obj;

        ItemStockSummary summary = new ItemStockSummary();
        summary.setItem((Item) row[0]);

        // If the expiration column is null it does not appear to be included in the row array
        if (row.length == 2) {
            summary.setExpiration(null);
            Integer quantity = Ints.checkedCast((Long) row[1]);
            // skip record if the sum of item stock quantities == 0
            if (quantity != 0) {
                summary.setQuantity(quantity);
            } else {
                continue;
            }
        } else {
            summary.setExpiration((Date) row[1]);
            Integer quantity = Ints.checkedCast((Long) row[2]);
            if (quantity != 0) {
                summary.setQuantity(quantity);
            } else {
                continue;
            }
        }

        results.add(summary);
    }

    // We done.
    return results;
}

From source file:com.redhat.rhn.frontend.xmlrpc.chain.ActionChainRPCCommon.java

/**
 * Resolve packages from IDs./*from  ww w .j av a 2 s.c om*/
 *
 * @param userPackages User packages
 * @param user User of the system
 * @return selectedPackages Map of the selected packages
 */
public List<Map<String, Long>> resolvePackages(List<Integer> userPackages, User user) {
    List<Map<String, Long>> selected = new ArrayList<Map<String, Long>>();
    for (Integer pkgId : userPackages) {
        Map<String, Long> pkgMap = new HashMap<String, Long>();

        Package pkg = PackageManager.lookupByIdAndUser(new Long(pkgId.longValue()), user);
        if (pkg == null) {
            throw new InvalidPackageException(pkgId.toString());
        }

        pkgMap.put("name_id", pkg.getPackageName().getId());
        pkgMap.put("evr_id", pkg.getPackageEvr().getId());
        pkgMap.put("arch_id", pkg.getPackageArch().getId());

        selected.add(pkgMap);
    }

    return selected;
}