<commit_before>package ge.edu.freeuni.taxi.dispatcher;

import java.util.Date;

import ge.edu.freeuni.taxi.Location;
import ge.edu.freeuni.taxi.Passenger;
import ge.edu.freeuni.taxi.PassengerOrder;
import ge.edu.freeuni.taxi.core.Message;
import ge.edu.freeuni.taxi.manager.OrderManager;

public class OrderMessageListener implements IncomingMessageListener {


    /**
     * ტვიტერიდან შემოსული მესიჯი დამუშავდება და გაეგზავნება
     * ოპერატორს რომელიც ამის შემდეგ გადაწყვეტს თვითონ
     * მიამაგროს შეკვეთაზე მძღოლი, ტვიტერის საშუალებით მოხდეს
     * არჩევა თუ რაციის მეშვეობით.
     * @param message
     */
	@Override
	public void onIncomingMessage(Message message) {
        OrderManager manager = OrderManager.getInstance();
        PassengerOrder order = new PassengerOrder();
        order.setAmount(10);
        order.setCreateTime(new Date());
        Location location = new Location();
        location.setName("");
        location.setLongitude(message.getLocation().getLongitude());
        location.setLatitude(message.getLocation().getLatitude());
        Passenger passenger = new Passenger();
        passenger.setInfo(message.getSender());
        passenger.setLocation(location);
        order.setPassenger(passenger);
        order.setPassenger(passenger);
        order.setIncoming(true);
        manager.updateOrder(order);
        /**
         *  TODO in Message should be amount of order and Destination Location
         *  TODO this features should be done by <NAME>
         *  TODO Message should be parsed if message is not parsed correctly the message
         *  TODO should be sent to operator in order not to loose order of client
         */
	}

}<commit_msg>#19 updated order message listener<commit_after>package ge.edu.freeuni.taxi.dispatcher;

import java.util.Date;

import ge.edu.freeuni.taxi.core.Message;
import ge.edu.freeuni.taxi.core.OrderMessage;

import ge.edu.freeuni.taxi.Location;
import ge.edu.freeuni.taxi.Passenger;
import ge.edu.freeuni.taxi.PassengerOrder;

import ge.edu.freeuni.taxi.manager.OrderManager;

/**
 * @author - <NAME>, <NAME>
 *
 * this class is called  when user orders taxi from twitter
 */
public class OrderMessageListener implements IncomingMessageListener {
    private final OrderManager orderManager = OrderManager.getInstance();

	@Override
	public void onIncomingMessage(Message message) {
        OrderMessage orderMessage = (OrderMessage) message;
        PassengerOrder order = getPassengerOrder(orderMessage);
        orderManager.createOrderWithoutDriver(order);
	}

    private PassengerOrder getPassengerOrder(OrderMessage orderMessage) {
        PassengerOrder order = new PassengerOrder();

        order.setPassenger(getPassenger(orderMessage));
        order.setAmount(orderMessage.getFare());
        order.setCreateTime(new Date());
        order.setDestination(getDestination(orderMessage));
        order.setIncoming(true);

        return order;
    }

    private Passenger getPassenger(OrderMessage orderMessage) {
        Passenger passenger = new Passenger();

        passenger.setInfo(orderMessage.getSender());
        passenger.setLocation(getOrigin(orderMessage));

        return passenger;
    }

    private Location getOrigin(OrderMessage orderMessage) {
        Location location = new Location();

        location.setName(orderMessage.getOrigin());

        if (orderMessage.getLocation() != null) {
            location.setLongitude(orderMessage.getLocation().getLongitude());
            location.setLatitude(orderMessage.getLocation().getLatitude());
        }

        return location;
    }

    private Location getDestination(OrderMessage orderMessage) {
        Location location = new Location();

        location.setName(orderMessage.getDestination());

        return location;
    }
}
{'fraction_non_alphanumeric': 0.09288900551036473, 'fraction_numerical': 0.0010495932826029913, 'mean_word_length': 3.3765786452353614, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '19740', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1192, 'n_words': 232}