Package demoapp.domain

Examples of demoapp.domain.Order


            boolean emitted = false;
            Currency eur = Currency.obtain("EUR", dao), usd = Currency.obtain("USD", dao);
            int count = 0;
            for (int i = 0; i < (30 + Math.round(Math.random() * 20)); i++) {
              emitted = !emitted;
                Order o = new Order();
                o.setAmount(new Amount());
                double aux = Math.random();
                try {
                    o.setIdentifier(new I18nText());
                    for (Locale l : supportedLocales) o.getIdentifier().add(l, l + ":" + StringUtils.SHA1(String.valueOf(aux)));
              } catch (Exception e) {};
                o.getAmount().setAmount(aux * 1024 * 1024);
                o.getAmount().setCurrency(aux > 0.5 ? usd : eur);
                o.setOrderNumber(num++);
                o.setPriority(new Rating());
                o.getPriority().setRating(Double.valueOf(Math.round(aux * 10) % 5));
                o.setEmitted(emitted);
                calendar.add(Calendar.DATE, (int) Math.round(aux * 10));
                o.setEmissionDate(calendar.getTime());
                try {
                    o.setClient(aux > 0.5 ? m : f);
                    dao.create(o, false);
                    if (count++ % 25 == 0) {
                        dao.flush();
                        dao.clear();
                    }
                } catch (Exception e) {
                    logger.debug("Failed to add an order: " + o);
                }
            }
            Order o = dao.first(Order.class);
            Document approved = new Document();
            approved.setIdentifier("Seal of approval");
            approved.setMimeType("image/jpeg");
            approved.setCreation(new Date());
            approved.setWidth(300);
            approved.setHeight(315);
            approved.setTemporal(false);
            approved.setLastModified(approved.getCreation());
            try {
                approved.setContents(FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("/seal_approved.jpg")));
                o.setSeal(approved);
                dao.update(o);
            } catch (IOException ex) {
                if (logger.isInfoEnabled()) logger.info("Could not save seal of approval image (thumbnail demo): " + ex.getMessage());
            }
        }
View Full Code Here

TOP

Related Classes of demoapp.domain.Order

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.