Example usage for java.util SortedMap firstKey

List of usage examples for java.util SortedMap firstKey

Introduction

In this page you can find the example usage for java.util SortedMap firstKey.

Prototype

K firstKey();

Source Link

Document

Returns the first (lowest) key currently in this map.

Usage

From source file:hudson.plugins.jobConfigHistory.FileHistoryDaoTest.java

/**
 * Test of getJobHistory method, of class FileHistoryDao.
 *///from   w w  w  . java 2s  .c  o m
@Test
public void testGetJobHistory() {
    final SortedMap<String, HistoryDescr> result = sutWithUserAndNoDuplicateHistory.getJobHistory("Test1");
    assertEquals(5, result.size());
    assertEquals("2012-11-21_11-29-12", result.firstKey());
}

From source file:hudson.plugins.jobConfigHistory.FileHistoryDaoTest.java

/**
 * Test of getSystemHistory method, of class FileHistoryDao.
 *//*from   w w  w.  j ava  2  s  . c  o m*/
@Test
public void testGetSystemHistory() {
    final SortedMap<String, HistoryDescr> result = sutWithUserAndNoDuplicateHistory.getSystemHistory("config");
    assertEquals(5, result.size());
    assertEquals("2013-01-18_17-34-22", result.firstKey());
}

From source file:edu.umd.cfar.lamp.viper.util.Range.java

/**
 * Gets the range shared by this and the specified 
 * range./* ww w .  j a v a 2s . c  o m*/
 * @param list the list to intersect with
 * @return the shared range
 */
public Range intersect(IntervalIndexList list) {
    // Note that each span in a range must
    // have a gap before it. this means it is 
    // ease enough to just follow the heuristic:
    // get span to add, advance to latest pointer,
    // get span to add.
    Range newRange = new Range();
    if (this.isEmpty() || list.isEmpty()) {
        return newRange;
    }
    SortedMap A = this.spans;
    Comparable aNextStart = (Comparable) A.firstKey();
    Comparable aNextEnd = (Comparable) A.get(aNextStart);
    Iterator B = list.iterator();
    if (!B.hasNext()) {
        return newRange;
    }
    Interval b = (Interval) B.next();
    if (b.isEmpty()) {
        throw new AssertionError();
    }
    Comparable bNextStart = b.getStart();
    Comparable bNextEnd = b.getEnd();

    while (aNextStart != null && bNextStart != null) {
        double diffStartStart = aNextStart.compareTo(bNextStart);
        double diffEndEnd = aNextEnd.compareTo(bNextEnd);
        if (diffStartStart == 0) {
            // both start at the same time
            if (diffEndEnd == 0) {
                newRange.add(aNextStart, aNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            } else if (diffEndEnd < 0) {
                // a stops before b
                newRange.add(aNextStart, aNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
            } else {
                // b stops before a
                newRange.add(bNextStart, bNextEnd);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            }
        } else if (diffStartStart < 0) {
            // a starts before b
            double diffEndStart = aNextEnd.compareTo(bNextStart);
            if (diffEndStart <= 0) {
                // skip ahead, since there is no
                // chance of overlap here
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
            } else if (diffEndEnd == 0) {
                newRange.add(bNextStart, bNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            } else if (diffEndEnd < 0) {
                // a ends before b does, but after b starts
                newRange.add(bNextStart, aNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
            } else {
                // a ends after b does
                newRange.add(bNextStart, bNextEnd);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            }
        } else {
            // a starts after b does
            double diffStartEnd = aNextStart.compareTo(bNextEnd);
            if (diffStartEnd >= 0) {
                // skip ahead, since there is no
                // chance of overlap here
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            } else if (diffEndEnd == 0) {
                // both end at the same moment
                newRange.add(aNextStart, aNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            } else if (diffEndEnd < 0) {
                // a is a subset of b
                newRange.add(aNextStart, aNextEnd);
                aNextStart = this.firstAfterOrAt(aNextEnd);
                aNextEnd = this.endOf(aNextStart);
            } else {
                // a ends after b does
                newRange.add(aNextStart, bNextEnd);
                bNextStart = list.firstAfterOrAt(bNextEnd);
                bNextEnd = list.endOf(bNextStart);
            }
        }
        if ((aNextStart != null && bNextStart != null) && (aNextEnd == null || bNextEnd == null)) {
            throw new AssertionError();
        }
    }
    return newRange;
}

From source file:org.runnerup.export.format.RunKeeper.java

public static ActivityEntity parseToActivity(JSONObject response, double unitMeters) throws JSONException {
    ActivityEntity newActivity = new ActivityEntity();
    newActivity.setSport(RunKeeperSynchronizer.runkeeper2sportMap.get(response.getString("type")).getDbValue());
    if (response.has("notes")) {
        newActivity.setComment(response.getString("notes"));
    }//from   w  ww.  j av  a 2  s  .c  o  m
    newActivity.setTime((long) Float.parseFloat(response.getString("duration")));
    newActivity.setDistance(Float.parseFloat(response.getString("total_distance")));

    String startTime = response.getString("start_time");
    SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US);
    try {
        newActivity.setStartTime(format.parse(startTime));
    } catch (ParseException e) {
        Log.e(Constants.LOG, e.getMessage());
        return null;
    }

    List<LapEntity> laps = new ArrayList<LapEntity>();
    List<LocationEntity> locations = new ArrayList<LocationEntity>();

    JSONArray distance = response.getJSONArray("distance");
    JSONArray path = response.getJSONArray("path");
    JSONArray hr = response.getJSONArray("heart_rate");

    SortedMap<Long, HashMap<String, String>> pointsValueMap = createPointsMap(distance, path, hr);
    Iterator<Map.Entry<Long, HashMap<String, String>>> points = pointsValueMap.entrySet().iterator();

    //lap hr
    int maxHr = 0;
    int sumHr = 0;
    int count = 0;
    //point speed
    long time = 0;
    float meters = 0.0f;
    //activity hr
    int maxHrOverall = 0;
    int sumHrOverall = 0;
    int countOverall = 0;

    while (points.hasNext()) {
        Map.Entry<Long, HashMap<String, String>> timePoint = points.next();
        HashMap<String, String> values = timePoint.getValue();

        LocationEntity lv = new LocationEntity();
        lv.setActivityId(newActivity.getId());
        lv.setTime(TimeUnit.SECONDS.toMillis(newActivity.getStartTime()) + timePoint.getKey());

        String dist = values.get("distance");
        if (dist == null) {
            continue;
        }
        String lat = values.get("latitude");
        String lon = values.get("longitude");
        String alt = values.get("altitude");
        String heart = values.get("heart_rate");
        String type = values.get("type");

        if (lat == null || lon == null) {
            continue;
        } else {
            lv.setLatitude(Double.valueOf(lat));
            lv.setLongitude(Double.valueOf(lon));
        }
        if (alt != null) {
            lv.setAltitude(Double.valueOf(alt));
        }

        if (pointsValueMap.firstKey().equals(timePoint.getKey())) {
            lv.setType(DB.LOCATION.TYPE_START);
        } else if (!points.hasNext()) {
            lv.setType(DB.LOCATION.TYPE_END);
        } else if (type != null) {
            lv.setType(RunKeeperSynchronizer.POINT_TYPE.get(type));
        }
        // lap and activity max and avg hr
        if (heart != null) {
            lv.setHr(Integer.valueOf(heart));
            maxHr = Math.max(maxHr, lv.getHr());
            maxHrOverall = Math.max(maxHrOverall, lv.getHr());
            sumHr += lv.getHr();
            sumHrOverall += lv.getHr();
            count++;
            countOverall++;
        }

        meters = Float.valueOf(dist) - meters;
        time = timePoint.getKey() - time;
        if (time > 0) {
            float speed = meters / (float) TimeUnit.MILLISECONDS.toSeconds(time);
            BigDecimal s = new BigDecimal(speed);
            s = s.setScale(2, BigDecimal.ROUND_UP);
            lv.setSpeed(s.floatValue());
        }

        // create lap if distance greater than configured lap distance

        if (Float.valueOf(dist) >= unitMeters * laps.size()) {
            LapEntity newLap = new LapEntity();
            newLap.setLap(laps.size());
            newLap.setDistance(Float.valueOf(dist));
            newLap.setTime((int) TimeUnit.MILLISECONDS.toSeconds(timePoint.getKey()));
            newLap.setActivityId(newActivity.getId());
            laps.add(newLap);

            // update previous lap with duration and distance
            if (laps.size() > 1) {
                LapEntity previousLap = laps.get(laps.size() - 2);
                previousLap.setDistance(Float.valueOf(dist) - previousLap.getDistance());
                previousLap.setTime(
                        (int) TimeUnit.MILLISECONDS.toSeconds(timePoint.getKey()) - previousLap.getTime());

                if (hr != null && hr.length() > 0) {
                    previousLap.setMaxHr(maxHr);
                    previousLap.setAvgHr(sumHr / count);
                }
                maxHr = 0;
                sumHr = 0;
                count = 0;
            }
        }
        // update last lap with duration and distance
        if (!points.hasNext()) {
            LapEntity previousLap = laps.get(laps.size() - 1);
            previousLap.setDistance(Float.valueOf(dist) - previousLap.getDistance());
            previousLap
                    .setTime((int) TimeUnit.MILLISECONDS.toSeconds(timePoint.getKey()) - previousLap.getTime());

            if (hr != null && hr.length() > 0) {
                previousLap.setMaxHr(maxHr);
                previousLap.setAvgHr(sumHr / count);
            }
        }

        lv.setLap(laps.size() - 1);

        locations.add(lv);
    }
    // calculate avg and max hr
    // update the activity
    newActivity.setMaxHr(maxHrOverall);
    if (countOverall > 0) {
        newActivity.setAvgHr(sumHrOverall / countOverall);
    }

    newActivity.putPoints(locations);
    newActivity.putLaps(laps);

    return newActivity;
}

From source file:org.apache.hadoop.hbase.replication.regionserver.TestReplicationSourceManager.java

@Test
public void testNodeFailoverDeadServerParsing() throws Exception {
    LOG.debug("testNodeFailoverDeadServerParsing");
    conf.setBoolean(HConstants.ZOOKEEPER_USEMULTI, true);
    final Server server = new DummyServer("ec2-54-234-230-108.compute-1.amazonaws.com");
    ReplicationQueues repQueues = ReplicationFactory.getReplicationQueues(server.getZooKeeper(), conf, server);
    repQueues.init(server.getServerName().toString());
    // populate some znodes in the peer znode
    files.add("log1");
    files.add("log2");
    for (String file : files) {
        repQueues.addLog("1", file);
    }//from   w ww .j ava2 s  .co  m

    // create 3 DummyServers
    Server s1 = new DummyServer("ip-10-8-101-114.ec2.internal");
    Server s2 = new DummyServer("ec2-107-20-52-47.compute-1.amazonaws.com");
    Server s3 = new DummyServer("ec2-23-20-187-167.compute-1.amazonaws.com");

    // simulate three servers fail sequentially
    ReplicationQueues rq1 = ReplicationFactory.getReplicationQueues(s1.getZooKeeper(), s1.getConfiguration(),
            s1);
    rq1.init(s1.getServerName().toString());
    SortedMap<String, SortedSet<String>> testMap = rq1.claimQueues(server.getServerName().getServerName());
    ReplicationQueues rq2 = ReplicationFactory.getReplicationQueues(s2.getZooKeeper(), s2.getConfiguration(),
            s2);
    rq2.init(s2.getServerName().toString());
    testMap = rq2.claimQueues(s1.getServerName().getServerName());
    ReplicationQueues rq3 = ReplicationFactory.getReplicationQueues(s3.getZooKeeper(), s3.getConfiguration(),
            s3);
    rq3.init(s3.getServerName().toString());
    testMap = rq3.claimQueues(s2.getServerName().getServerName());

    ReplicationQueueInfo replicationQueueInfo = new ReplicationQueueInfo(testMap.firstKey());
    List<String> result = replicationQueueInfo.getDeadRegionServers();

    // verify
    assertTrue(result.contains(server.getServerName().getServerName()));
    assertTrue(result.contains(s1.getServerName().getServerName()));
    assertTrue(result.contains(s2.getServerName().getServerName()));

    server.abort("", null);
}

From source file:org.web4thejob.web.util.ToolbarRenderer.java

@Override
public void render() {
    final boolean isEmpty = isEmpty();
    if (toolbar != null && isEmpty) {
        reset();/*from   www.  j  a  v a  2  s. c  o  m*/
        return;
    } else if (toolbar != null || isEmpty) {
        return;
    }

    toolbar = new Toolbar();
    toolbar.setAlign(align);
    container.insertBefore(toolbar, container.getFirstChild());

    if (!HtmlViewPanel.class.isInstance(getPrimaryOwner())) {
        toolbar.setStyle("border-width: 0;");
    }

    SortedMap<CommandEnum, List<Command>> map = mergeCommands();

    for (final CommandEnum id : map.keySet()) {
        CommandDecorator commandDecorator = null;
        if (map.get(id).size() == 1) {
            commandDecorator = getDecorator(map.get(id).get(0));
        } else {
            for (Command command : map.get(id)) {
                if (commandDecorator == null) {
                    commandDecorator = new DefaultDropdownCommandDecorator(command);
                } else {
                    ((DropdownCommandDecorator) commandDecorator).add(command);
                }
            }
        }

        if (id.isRequiresStartSeparator() && id != map.firstKey() && !isPreviousSeparator()) {
            addSeparator();
        }

        if (commandDecorator != null) {
            commandDecorator.attach(toolbar);
            commandDecorator.addMessageListener(this);
            commandDecorator.render();
        }

        if (id.isRequiresEndSeparator() && id != map.lastKey()) {
            addSeparator();
        }

        Space space = new Space();
        space.setSpacing("8px");
        space.setParent(toolbar);
    }
}

From source file:org.n52.ifgicopter.spf.input.InputPluginCollector.java

/**
 * @param newData/*from w  w w . j  av  a  2  s. co m*/
 *        new data
 * @throws Exception
 *         if processing failed
 */
public void addNewData(final Map<String, Object> newData) {

    /*
     * do we have IPositionListeners?
     */
    if (this.engine.getPositionListeners().size() > 0) {
        if (InputPluginCollector.this.plugin.isMobile()) {
            final Object first = newData
                    .get(InputPluginCollector.this.plugin.getLocation().getFirstCoordinateName());
            final Object second = newData
                    .get(InputPluginCollector.this.plugin.getLocation().getSecondCoordinateName());

            /*
             * start a new thread to avoid blocking
             */
            SPFRegistry.getInstance().getThreadPool().submitTask(new Runnable() {
                @Override
                public void run() {
                    if (first != null && second != null) {
                        for (IPositionListener ipl : InputPluginCollector.this.engine.getPositionListeners()) {
                            ipl.positionUpdate(InputPluginCollector.this.plugin, newData);
                        }
                    }
                }
            });

        }
    }

    /*
     * we need to check which type the time parameter is of
     */
    Object tmp = newData.get(InputPluginCollector.this.plugin.getTime().getProperty());

    Long time = null;
    if (tmp instanceof Long) {
        time = (Long) tmp;
    } else if (tmp instanceof String) {
        try {
            /*
             * try millis as string
             */
            time = Long.valueOf((String) tmp);
        } catch (NumberFormatException e) {
            /*
             * try iso-date
             */
            time = Long.valueOf(new DateTime(tmp).getMillis());
        }
    } else if (tmp instanceof Date) {
        time = Long.valueOf(new DateTime(tmp).getMillis());
    } else if (tmp instanceof DateTime) {
        time = Long.valueOf(((DateTime) tmp).getMillis());
    }

    if (time == null) {
        log.warn("Could not process the timestamp '" + tmp + "'. Using current system time.");
        time = Long.valueOf(System.currentTimeMillis());
    }

    synchronized (InputPluginCollector.this.itemCollection) {

        /*
         * check for p'n'p feature
         */
        if (this.plugAndPlayBehaviour) {
            for (String key : newData.keySet()) {
                if (!InputPluginCollector.this.plugin.getInputProperties().contains(key)) {
                    /*
                     * try to recognize unknown property
                     */
                    PNPDialog pnp = this.engine.doPNP(key);

                    if (pnp.isCanceled()) {
                        /*
                         * the dialog was cancelled continue
                         */
                        continue;
                    }

                    Item item = new Item(key);
                    item.setDataType(pnp.getDatatype());
                    item.setDefinition(pnp.getDefintion());
                    item.setUom(pnp.getUom());

                    /*
                     * add to the plugin description
                     */
                    if (pnp.isOutput()) {
                        InputPluginCollector.this.plugin.addOutputProperty(item);
                    } else if (pnp.isMandatory()) {
                        InputPluginCollector.this.plugin.addMandatoryProperty(item);
                    } else {
                        InputPluginCollector.this.plugin.addInputProperty(item);
                    }

                    InputPluginCollector.this.itemCollection.put(key, new TreeMap<Long, Object>());
                }
            }
        }

        for (Entry<String, Object> entry : newData.entrySet()) {
            if (!entry.getKey().equals(InputPluginCollector.this.plugin.getTime().getProperty())) {
                if (!InputPluginCollector.this.plugin.getInputProperties().contains(entry.getKey())) {
                    continue;
                }
                Map<Long, Object> collection = InputPluginCollector.this.itemCollection.get(entry.getKey());

                /*
                 * put the data of this item to this itemlist.
                 */
                collection.put(time, entry.getValue());
            }
        }

        /*
         * first check if there is minimum one item per mandatory property in the Collector. if not
         * checked, we will be stuck with a deadlock in the OnAvailableOutputThread.
         */
        if (!InputPluginCollector.this.hasMandatories) {
            if (InputPluginCollector.this.plugin.getMandatoryProperties().size() == 0) {
                InputPluginCollector.this.hasMandatories = true;
            }
            for (String prop : InputPluginCollector.this.plugin.getMandatoryProperties()) {
                SortedMap<Long, Object> data = InputPluginCollector.this.itemCollection.get(prop);
                if (!data.isEmpty() && data.firstKey().longValue() <= time.longValue()) {
                    /*
                     * ok, continue;
                     */
                    InputPluginCollector.this.hasMandatories = true;
                } else {
                    InputPluginCollector.this.hasMandatories = false;
                    return;
                }
            }
        }
    }

    if (InputPluginCollector.this.availabilityBehaviour) {
        /*
         * check if outputItems are here
         */
        Set<String> containsOutputs = new HashSet<String>();

        for (String prop : InputPluginCollector.this.plugin.getOutputProperties()) {
            if (newData.keySet().contains(prop)) {
                containsOutputs.add(prop);
            }
        }

        if (containsOutputs.size() > 0) {
            /*
             * This is an output creating property!!
             * 
             * start new thread and put register all items
             */
            if (InputPluginCollector.this.activeTimestamps.contains(time)) {
                /*
                 * do not create a thread if we already have one for this timestamp -> data would be
                 * duplicated
                 */
                return;
            }
            OnAvailableOutputThread ot = new OnAvailableOutputThread(time);
            for (String item : newData.keySet()) {
                /*
                 * register items at the new thread only add outputProperties or mandatoryProperties items
                 * (others should not be included in this data tuple)
                 */
                if (containsOutputs.contains(item)
                        || InputPluginCollector.this.plugin.getMandatoryProperties().contains(item)) {
                    ot.registerItem(item);
                }
            }
            synchronized (InputPluginCollector.this.outputThreads) {
                InputPluginCollector.this.outputThreads.add(ot);
            }
            SPFRegistry.getInstance().getThreadPool().submitTask(ot);
        } else {
            /*
             * register at the threads - perhaps one or more are waiting
             */
            synchronized (InputPluginCollector.this.outputThreads) {
                for (OnAvailableOutputThread ot : InputPluginCollector.this.outputThreads) {
                    for (String item : newData.keySet()) {

                        if (newData.get(item) == null)
                            continue;
                        /*
                         * only add mandatoryProperties. the other will not be added at this data tuple.
                         */
                        if (InputPluginCollector.this.plugin.getMandatoryProperties().contains(item)) {
                            ot.registerItem(item);
                        }
                    }
                }
            }
        }
    }

}

From source file:edu.umd.cfar.lamp.viper.util.Range.java

/**
 * @see java.util.Set#contains(java.lang.Object)
 *///from www.j  ava  2 s . co m
public boolean contains(Object o) {
    if (spans.size() == 0) {
        return false;
    } else if (o instanceof Comparable) {
        SortedMap m = spans.headMap(o);
        if (m.size() > 0) {
            Comparable e = (Comparable) m.get(m.lastKey());
            if (e.compareTo(o) > 0) {
                return true;
            }
        }
        m = spans.tailMap(o);
        if (m.size() > 0) {
            Comparable s = (Comparable) m.firstKey();
            return s.compareTo(o) == 0;
        }
        return false;
    } else {
        return withinRange((Interval) o);
    }
}

From source file:org.onebusaway.admin.service.bundle.hastus.HastusGtfsFactory.java

private void processStopTimesForTrip(Map<String, Integer> timepointPositions, PttTrip pttTrip, String tripIdRaw,
        RouteStopSequence stopSequence, Trip trip) throws ParseException {

    SortedMap<Integer, Integer> arrivalTimesByTimepointPosition = computeTimepointPositionToScheduleTimep(
            pttTrip);//from  w w  w  . jav  a 2  s. c  o m

    if (arrivalTimesByTimepointPosition.size() < 2) {
        _log.warn("less than two timepoints specified for trip: id=" + trip.getId());
        return;
    }

    int firstTimepointPosition = arrivalTimesByTimepointPosition.firstKey();
    int lastTimepointPosition = arrivalTimesByTimepointPosition.lastKey();

    int firstStopIndex = Integer.MAX_VALUE;
    int lastStopIndex = Integer.MIN_VALUE;

    /**
     * Find the bounds on the set of stops that have stop times defined
     */
    List<RouteStopSequenceItem> items = stopSequence.getItems();

    for (int index = 0; index < items.size(); index++) {
        RouteStopSequenceItem item = items.get(index);
        Integer time = getScheduledTimeForTimepoint(item, timepointPositions, arrivalTimesByTimepointPosition);

        if (time != null) {
            firstStopIndex = Math.min(firstStopIndex, index);
            lastStopIndex = Math.max(lastStopIndex, index);
        }
    }

    StopTime first = null;
    StopTime last = null;

    for (int index = firstStopIndex; index < lastStopIndex + 1; index++) {
        RouteStopSequenceItem item = items.get(index);

        Integer time = getScheduledTimeForTimepoint(item, timepointPositions, arrivalTimesByTimepointPosition);
        Stop stop = _dao.getStopForId(id(Long.toString(item.getStopId())));

        StopTime stopTime = new StopTime();
        stopTime.setStop(stop);
        stopTime.setStopSequence(index - firstStopIndex);
        stopTime.setTrip(trip);

        if ("N".equals(item.getBoarding())) {
            // timepoint -- not for pickup/drop off
            stopTime.setDropOffType(1);
            stopTime.setPickupType(1);
            _timepointIds.add(id(Long.toString(item.getStopId())));
        } else if ("A".equals(item.getBoarding())) {
            stopTime.setDropOffType(0);
            stopTime.setPickupType(1);
        } else if ("B".equals(item.getBoarding())) {
            stopTime.setDropOffType(1);
            stopTime.setPickupType(0);
        } else if ("E".equals(item.getBoarding())) {
            stopTime.setDropOffType(0);
            stopTime.setPickupType(0);
        } //else we don't set it, it defaults

        if (time != null) {
            stopTime.setArrivalTime(time);
            stopTime.setDepartureTime(time);
        }
        if (!"N".equals(item.getBoarding())) {
            // if we are a timepoint, don't bother adding the stop to the GTFS
            _dao.saveEntity(stopTime);
        } else {
            _log.info("skipping stop " + item.getStopId() + " on trip " + trip.getId().getId()
                    + " as it has no boarding");
            stopTime = null;
        }

        if (first == null)
            first = stopTime;
        last = stopTime;
    }

    if (!first.isDepartureTimeSet()) {
        _log.warn("departure time for first StopTime is not set: stop=" + first.getStop().getId() + " trip="
                + tripIdRaw + " firstPosition=" + firstTimepointPosition + " lastPosition="
                + lastTimepointPosition);
        for (RouteStopSequenceItem item : stopSequence)
            _log.warn("  stop=" + item.getStopId() + " timepoint=" + item.getTimePoint() + " pos="
                    + timepointPositions.get(item.getTimePoint()));
    }

    if (!last.isArrivalTimeSet()) {
        _log.warn("arrival time for last StopTime is not set: stop=" + last.getStop().getId() + " trip="
                + tripIdRaw + " firstPosition=" + firstTimepointPosition + " lastPosition="
                + lastTimepointPosition);
        for (RouteStopSequenceItem item : stopSequence)
            _log.warn("  stop=" + item.getStopId() + " timepoint=" + item.getTimePoint() + " pos="
                    + timepointPositions.get(item.getTimePoint()));
    }
}

From source file:org.jahia.modules.modulemanager.flow.ModuleManagementFlowHandler.java

/**
 * Returns a map, keyed by the module name, with all available module updates.
 *
 * @return a map, keyed by the module name, with all available module updates
 *//*from w ww.ja  v a 2  s.  c o m*/
public Map<String, Module> getAvailableUpdates() {
    Map<String, Module> availableUpdate = new HashMap<String, Module>();
    Map<String, SortedMap<ModuleVersion, JahiaTemplatesPackage>> moduleStates = templateManagerService
            .getTemplatePackageRegistry().getAllModuleVersions();
    for (String key : moduleStates.keySet()) {
        SortedMap<ModuleVersion, JahiaTemplatesPackage> moduleVersions = moduleStates.get(key);
        Module forgeModule = forgeService.findModule(key,
                moduleVersions.get(moduleVersions.firstKey()).getGroupId());
        if (forgeModule != null) {
            ModuleVersion forgeVersion = new ModuleVersion(forgeModule.getVersion());
            if (!isSameOrNewerVersionPresent(key, forgeVersion)) {
                availableUpdate.put(key, forgeModule);
            }
        }
    }
    return availableUpdate;
}