Package services

Examples of services.Item


    private List<Item> catalog = new ArrayList<Item>();

    @Init
    public void init() {
        String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
        catalog.add(new Item("Apple",  currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99), "34.425744,-119.711151"));
        catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55), "25.811018,-80.130844"));
        catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55), "36.596649,-121.8964"));
    }
View Full Code Here


        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart");
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

    public Item get(String key) throws NotFoundException {
        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where id = '" + key + "'");
            if (results.next()) {
                return new Item(results.getString("name"), results.getString("price"));
            } else {
                throw new NotFoundException(key);
            }
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where " + queryString);
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

    public String getTotal() {
        Entry<String, Item>[] entries = getAll();
        double total = 0;
        String currencySymbol = "";
        if (entries.length > 0) {
            Item item = entries[0].getData();
            currencySymbol = item.getPrice().substring(0, 1);
        }
        for (Entry<String, Item> entry : entries) {
            Item item = entry.getData();
            total += Double.valueOf(item.getPrice().substring(1));
        }
        return currencySymbol + total;
    }
View Full Code Here

            Item[] items = goodsCatalog[i].get();

            for (Item item : items) {
                double price = Double.valueOf(item.getPrice().substring(1));
                price = currencyConverter.getConversion("USD", currencyCode, price);
                catalog.addElement(new Item(item.getName(), currencySymbol + price));
            }
        }

        Item[] catalogArray = new Item[catalog.size()];
        catalog.copyInto(catalogArray);
View Full Code Here

TOP

Related Classes of services.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.