本文整理了Java中org.springframework.data.gemfire.examples.domain.Order
类的一些代码示例,展示了Order
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order
类的具体详情如下:
包路径:org.springframework.data.gemfire.examples.domain.Order
类名称:Order
暂无
代码示例来源:origin: spring-projects/spring-gemfire-examples
/**
* Create an order
*/
public Order createOrder(Order order) {
Assert.notNull(order, "order cannot be null");
Assert.notNull(order.getId(), "order ID cannot be null");
Assert.notNull(order.getCustomerId(), "order customer ID cannot be null");
Assert.notEmpty(order.getLineItems(), "order must contain at least one line item");
Assert.notNull(order.getBillingAddress(), "order billing address cannot be null");
log.debug("creating new order " + order.getId());
return orderRepository.save(order);
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Override
public void afterCreate(EntryEvent<Long, Order> event) {
Order order = event.getNewValue();
System.err.printf("[%s] made an Order [%s] for [%s]%n",
findCustomerById(order.getCustomerId()), order, order.getLineItems());
}
};
代码示例来源:origin: spring-projects/spring-gemfire-examples
/**
* Create an order
* @param order
* @return
*/
public Order createOrder(Order order) {
Assert.notNull(order, "order cannot be null");
Assert.notNull(order.getId(),"order id cannot be null");
Assert.notNull(order.getCustomerId(), "order customer ID cannot be null");
Assert.notEmpty(order.getLineItems(),"order must contain at least one line item");
log.debug("creating order ID:" + order.getId() );
return orderDao.save(order);
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
macbook.setAttribute("warantee","included");
Order davesOrder = new Order(1L, dave.getId(),new Address("Dave Street","Matthews","USA"));
davesOrder.add(new LineItem(ipad,2));
davesOrder.add(new LineItem(macbook));
Order aliciasFirstOrder = new Order(2L, alicia.getId(),new Address("Alicia Street","Keys","USA"));
aliciasFirstOrder.add(new LineItem(ipod,3));
Order aliciasNextOrder = new Order(3L, alicia.getId(),new Address("Alicia Street","Keys","USA"));
aliciasNextOrder.add(new LineItem(macbook,4));
aliciasNextOrder.add(new LineItem(ipad));
代码示例来源:origin: spring-projects/spring-gemfire-examples
macbook.setAttribute("warantee", "included");
Order davesOrder = new Order(1L, 1L, new Address(
"Dave Street", "Matthews", "USA"));
davesOrder.add(new LineItem(ipad, 2));
davesOrder.add(new LineItem(macbook));
Order aliciasFirstOrder = new Order(2L, 2L, new Address(
"Alicia Street", "Keys", "USA"));
aliciasFirstOrder.add(new LineItem(ipod, 3));
Order aliciasNextOrder = new Order(3L, 2L, new Address(
"Alicia Street", "Keys", "USA"));
aliciasNextOrder.add(new LineItem(macbook, 4));
aliciasNextOrder.add(new LineItem(ipad));
System.in.read();
region.put(davesOrder.getId(), davesOrder);
region.put(aliciasFirstOrder.getId(), aliciasFirstOrder);
region.put(aliciasNextOrder.getId(), aliciasNextOrder);
代码示例来源:origin: spring-projects/spring-gemfire-examples
private static Order newOrder(Customer customer) {
return new Order(id.incrementAndGet(), customer.getId(), customer.getAddresses().iterator().next());
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
private void findOrders() {
log.debug("looking for orders for customer ID 2");
for (Order order: orderService.findOrdersByCustomerId(2L)) {
log.debug("found order ID " + order.getId() + " " +
order.getBillingAddress().getStreet() + " " +
order.getBillingAddress().getCity() + " " +
order.getBillingAddress().getCountry());
for (LineItem lineItem: order.getLineItems()) {
log.debug("product ID:" + lineItem.getProductId() +
" quantity:" + lineItem.getAmount() +
" unit price:" + lineItem.getUnitPrice().setScale(2,BigDecimal.ROUND_DOWN) +
" total price:" + lineItem.getTotal().setScale(2,BigDecimal.ROUND_DOWN));
}
}
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Scheduled(initialDelay = 2000L, fixedRate = 5000L)
public void fulfillOrder() {
int customerIndex = random.nextInt(customerList.size());
Customer customer = save(findCustomer(customerIndex));
Order order = newOrder(customer);
for (int count = Math.max(1, random.nextInt(6)); count > 0; count--) {
int productIndex = random.nextInt(productList.size());
Product product = save(findProduct(productIndex));
order.add(newLineItem(product, Math.max(1, random.nextInt(3))));
}
orders.put(order.getId(), order);
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Override
public String toString() {
return String.valueOf(getId());
}
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Override
public Iterator<LineItem> iterator() {
return getLineItems().iterator();
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
private void createOrders() {
Customer dave = customerService.findByEmailAddress("dave@matthews.com");
Order davesOrder = new Order(1L, dave.getId(),new Address("Dave Street","Matthews","USA"));
Product iPod = productService.findProductsByDescription("notebook").get(0);
davesOrder.add(new LineItem(iPad,2));
davesOrder.add(new LineItem(macBook));
Order aliciasFirstOrder = new Order(2L, alicia.getId(),new Address("Alicia Street","Keys","USA"));
aliciasFirstOrder.add(new LineItem(iPod,3));
Order aliciasNextOrder = new Order(3L, alicia.getId(),new Address("Alicia Street","Keys","USA"));
aliciasNextOrder.add(new LineItem(macBook,4));
aliciasNextOrder.add(new LineItem(iPad));
代码示例来源:origin: spring-projects/spring-gemfire-examples
@SuppressWarnings("unchecked")
public static void main(String args[]) throws IOException {
if (args.length >= 1 && args[0].equalsIgnoreCase("partitionByCountry")) {
log.debug("partitioning by country");
partitionByCountry = true;
}
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext("client/cache-config.xml");
Region<OrderKey,Order> region = context.getBean(Region.class);
//Create some orders
Random rand = new Random(new Date().getTime());
for (long orderId = 1; orderId <= 100; orderId++) {
Address shipTo = new Address("Some Street","Some City",(orderId%3 == 0)?"UK":"US");
Order order = new Order(orderId, (new Long(rand.nextInt(100)+1)),shipTo);
OrderKey orderKey = getOrderKey(orderId,shipTo.getCountry());
region.put(orderKey, order);
}
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
private ContinuousQueryListener newQueryListener(Region<Long, Customer> customers, String qualifier) {
return event -> {
Order order = (Order) event.getNewValue();
System.err.printf("[%s] made an %s Order [%s] for [%s]%n",
findByCustomerId(customers, order.getCustomerId()), qualifier, order, order.getLineItems());
};
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
/**
* Delete an order
*/
public boolean deleteOrder(Order order) {
Assert.notNull(order, "order cannot be null");
Assert.notNull(order.getId(), "order ID cannot be null");
return deleteOrder(order.getId());
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
for (LineItem lineItem: order.getLineItems()) {
if (lineItem.getProductId() == productId) {
total = total.add(lineItem.getTotal());
代码示例来源:origin: spring-projects/spring-gemfire-examples
for (long orderId = 1; orderId <= 100; orderId ++) {
Order order = new Order(orderId,0L,address);
int nLineItems = random.nextInt(3) + 1;
for (int i = 0; i<nLineItems; i++){
long productId = random.nextInt(3) + 1;
log.debug("creating line item for product id " + productId + " quantity " + quantity);
order.add(new LineItem(productRegion.get(productId),quantity));
代码示例来源:origin: spring-projects/spring-gemfire-examples
System.out.println("Press <Enter> to update region " + region.getName());
System.in.read();
region.put(id, new Order(1L, 1L, new Address("street", "city",
"country")));
System.out.println("Press <Enter> to quit");
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Override
public Order save(Order order) {
return orderTemplate.put(order.getId(), order);
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
@Override
public void execute(FunctionContext functionContext) {
ResultSender<BigDecimal> resultSender = functionContext.getResultSender();
String productName = (String)functionContext.getArguments();
log.debug("searching for product name '" + productName + "'");
SelectResults<Product> results = productTemplate.query("name = '" + productName + "'");
if (results.isEmpty()) {
log.warn("cannot find product '" + productName + "'");
resultSender.lastResult(new BigDecimal(0.0));
return;
}
Product product = results.asList().get(0);
long productId = product.getId();
BigDecimal total = new BigDecimal(0.0);
for (Order order: orderRegion.values()) {
for (LineItem lineItem: order.getLineItems()) {
if (lineItem.getProductId() == productId) {
total = total.add(lineItem.getTotal());
}
}
}
resultSender.lastResult(total.setScale(2,BigDecimal.ROUND_CEILING));
}
代码示例来源:origin: spring-projects/spring-gemfire-examples
for (long orderId = 1; orderId <= 100; orderId ++) {
Order order = new Order(orderId,0L,address);
int nLineItems = random.nextInt(3) + 1;
for (int i = 0; i<nLineItems; i++){
long productId = random.nextInt(3) + 1;
log.debug("creating line item for product id " + productId + " quantity " + quantity);
order.add(new LineItem(productRegion.get(productId),quantity));
内容来源于网络,如有侵权,请联系作者删除!