Search in sources :

Example 6 with RiderRanking

use of ch.hsr.sa.radiotour.dataaccess.models.RiderRanking in project app by TourLive.

the class Parser method updateRiderConnectionRankByOfficalGap.

public static String updateRiderConnectionRankByOfficalGap() throws InterruptedException {
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                RealmList<RiderStageConnection> connections = Context.getAllRiderStageConnections();
                connections.sort(new RiderStageConnectionComparatorOfficalGap());
                for (int i = 0; i < connections.size(); i++) {
                    RiderRanking rankingOfficial = new RiderRanking();
                    rankingOfficial.setType(RankingType.OFFICAL);
                    rankingOfficial.setRank(i + 1);
                    synchronized (this) {
                        Context.addRiderRanking(rankingOfficial);
                    }
                    RiderRanking realmRiderRanking = Context.getRiderRanking(rankingOfficial);
                    Context.updateRiderStageConnectionRanking(realmRiderRanking, connections.get(i));
                }
            } catch (Exception e) {
                Log.d(Parser.class.getSimpleName(), "APP - PARSER - RIDERCONNECTION - " + e.getMessage());
            }
        }
    };
    Thread threadRanking = new Thread(runnable);
    threadRanking.start();
    threadRanking.join();
    return "success";
}
Also used : RiderStageConnectionComparatorOfficalGap(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorOfficalGap) RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) JSONException(org.json.JSONException)

Example 7 with RiderRanking

use of ch.hsr.sa.radiotour.dataaccess.models.RiderRanking in project app by TourLive.

the class Parser method updateRiderConnectionRankByBestSwiss.

public static String updateRiderConnectionRankByBestSwiss() throws InterruptedException {
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                RealmList<RiderStageConnection> connections = Context.getAllRiderStageConnections();
                connections.sort(new RiderStageConnectionComparatorVirtualGap());
                int rank = 1;
                for (int i = 0; i < connections.size(); i++) {
                    if (connections.get(i).getRiders().getCountry().equals("SUI")) {
                        RiderRanking rankingSwiss = new RiderRanking();
                        rankingSwiss.setType(RankingType.SWISS);
                        rankingSwiss.setRank(rank);
                        rank++;
                        synchronized (this) {
                            Context.addRiderRanking(rankingSwiss);
                        }
                        RiderRanking realmRiderRanking = Context.getRiderRanking(rankingSwiss);
                        Context.updateRiderStageConnectionRanking(realmRiderRanking, connections.get(i));
                    }
                }
            } catch (Exception e) {
                Log.d(Parser.class.getSimpleName(), "APP - PARSER - RIDERCONNECTION - " + e.getMessage());
            }
        }
    };
    Thread threadRanking = new Thread(runnable);
    threadRanking.start();
    threadRanking.join();
    return "success";
}
Also used : RiderStageConnectionComparatorVirtualGap(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorVirtualGap) RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) JSONException(org.json.JSONException)

Example 8 with RiderRanking

use of ch.hsr.sa.radiotour.dataaccess.models.RiderRanking in project app by TourLive.

the class Parser method updateRiderConnectionRankByMountainPoints.

public static String updateRiderConnectionRankByMountainPoints() throws InterruptedException {
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                RealmList<RiderStageConnection> connections = Context.getAllRiderStageConnections();
                connections.sort(new RiderStageConnectionComparatorMountainPoints());
                for (int i = 0; i < connections.size(); i++) {
                    RiderRanking rankingMountain = new RiderRanking();
                    rankingMountain.setType(RankingType.MOUNTAIN);
                    rankingMountain.setRank(i + 1);
                    synchronized (this) {
                        Context.addRiderRanking(rankingMountain);
                    }
                    RiderRanking realmRiderRanking = Context.getRiderRanking(rankingMountain);
                    Context.updateRiderStageConnectionRanking(realmRiderRanking, connections.get(i));
                }
            } catch (Exception e) {
                Log.d(Parser.class.getSimpleName(), "APP - PARSER - RIDERCONNECTION - " + e.getMessage());
            }
        }
    };
    Thread threadRanking = new Thread(runnable);
    threadRanking.start();
    threadRanking.join();
    return "success";
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) RiderStageConnectionComparatorMountainPoints(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorMountainPoints) JSONException(org.json.JSONException)

Example 9 with RiderRanking

use of ch.hsr.sa.radiotour.dataaccess.models.RiderRanking in project app by TourLive.

the class Parser method updateRiderConnectionRankByTimeInLead.

public static String updateRiderConnectionRankByTimeInLead() throws InterruptedException {
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                RealmList<RiderStageConnection> connections = Context.getAllRiderStageConnections();
                connections.sort(new RiderStageConnectionComparatorTimeInLead());
                for (int i = 0; i < connections.size(); i++) {
                    RiderRanking rankingTimeInLead = new RiderRanking();
                    rankingTimeInLead.setType(RankingType.TIME_IN_LEAD);
                    rankingTimeInLead.setRank(i + 1);
                    synchronized (this) {
                        Context.addRiderRanking(rankingTimeInLead);
                    }
                    RiderRanking realmRiderRanking = Context.getRiderRanking(rankingTimeInLead);
                    Context.updateRiderStageConnectionRanking(realmRiderRanking, connections.get(i));
                }
            } catch (Exception e) {
                Log.d(Parser.class.getSimpleName(), "APP - PARSER - RIDERCONNECTION - " + e.getMessage());
            }
        }
    };
    Thread threadRanking = new Thread(runnable);
    threadRanking.start();
    threadRanking.join();
    return "success";
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) RiderStageConnectionComparatorTimeInLead(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorTimeInLead) JSONException(org.json.JSONException)

Example 10 with RiderRanking

use of ch.hsr.sa.radiotour.dataaccess.models.RiderRanking in project app by TourLive.

the class Parser method updateRiderConnectionRankByMoney.

public static String updateRiderConnectionRankByMoney() throws InterruptedException {
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                RealmList<RiderStageConnection> connections = Context.getAllRiderStageConnections();
                connections.sort(new RiderStageConnectionComparatorMoney());
                for (int i = 0; i < connections.size(); i++) {
                    RiderRanking rankingMoney = new RiderRanking();
                    rankingMoney.setType(RankingType.MONEY);
                    rankingMoney.setRank(i + 1);
                    synchronized (this) {
                        Context.addRiderRanking(rankingMoney);
                    }
                    RiderRanking realmRiderRanking = Context.getRiderRanking(rankingMoney);
                    Context.updateRiderStageConnectionRanking(realmRiderRanking, connections.get(i));
                }
            } catch (Exception e) {
                Log.d(Parser.class.getSimpleName(), "APP - PARSER - RIDERCONNECTION - " + e.getMessage());
            }
        }
    };
    Thread threadRanking = new Thread(runnable);
    threadRanking.start();
    threadRanking.join();
    return "success";
}
Also used : RiderStageConnectionComparatorMoney(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorMoney) RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) JSONException(org.json.JSONException)

Aggregations

RiderRanking (ch.hsr.sa.radiotour.dataaccess.models.RiderRanking)12 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)10 JSONException (org.json.JSONException)8 RiderStageConnectionComparatorVirtualGap (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorVirtualGap)3 Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)2 Realm (io.realm.Realm)2 RiderStageConnectionComparatorDistanceInLead (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorDistanceInLead)1 RiderStageConnectionComparatorMoney (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorMoney)1 RiderStageConnectionComparatorMountainPoints (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorMountainPoints)1 RiderStageConnectionComparatorOfficalGap (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorOfficalGap)1 RiderStageConnectionComparatorPoints (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorPoints)1 RiderStageConnectionComparatorTimeInLead (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorTimeInLead)1 Date (java.util.Date)1 Random (java.util.Random)1 Test (org.junit.Test)1