Package nl.oneday.data.domain.items

Examples of nl.oneday.data.domain.items.Item


    model.addAttribute("action", "edit");

    LOG.info("item om te editen met id:" + id);

    if (id != null) {
      Item item = itemService.getItemById(id);

      if (item != null) {
        model.addAttribute("id", item.getId());
        model.addAttribute("name", item.getName());
        model.addAttribute("price", item.getPrice());
        model.addAttribute("description", item.getShortDescription());
        return TEMPLATE_ITEM_SHOW_AND_EDIT_FORM;
      }
    }
    return TEMPLATE_ITEM_OVERVIEW;
  }
View Full Code Here


  @Autowired
  private CategoryService categoryService;


  public boolean itemExists(Long id) {
    Item item = itemRepository.findById(id);
    if (item != null) return true;
    return false;
  }
View Full Code Here

    return false;
  }


  public boolean deleteItem(Long id) {
    Item item = null;
    if (itemExists(id)) {
      try {
        item = itemRepository.findById(id);
        itemRepository.delete(item.getId());
        itemRepository.flush();

        if (itemRepository.findById(id) == null) {

          LOG.info("Item verwijderd met id: " + id);
View Full Code Here

    return false;
  }


  public boolean createItem(String name, String price, String description) {
    Item item = new Item();
    item.setName(name);
    try {
      item.setPrice(Float.parseFloat(price));
    }
    catch (NumberFormatException ex) {
      LOG.error("parse error occured while parsing price!");
      item.setPrice(0.0f);
    }
    item.setShortDescription(description);
    Item savedItem = null;
    try {
      savedItem = itemRepository.saveAndFlush(item);
    }
    catch (Exception ex) {
      LOG.error("Item could not be saved due to an error");
    }

    if (savedItem != null && savedItem.getId() != null) {
      LOG.info("nieuwe Item aangemaakt " + savedItem.getId() + "/" + savedItem.getName() + "/" + savedItem.getPrice() + "/"
        + savedItem.getShortDescription());
      return true;
    } else {
      LOG.error("Item niet aangemaakt!");
      return false;
    }
View Full Code Here

  }


  public Item createItem(String name, String price, String description, Long categoryId) {
    Category category = categoryService.findCategoryById(categoryId);
    Item item = new Item();
    item.setName(name);
    item.setCategory(category);
    try {
      item.setPrice(Float.parseFloat(price));
    }
    catch (NumberFormatException ex) {
      LOG.error("parse error occured while parsing price!");
      item.setPrice(0.0f);
    }
    item.setShortDescription(description);
    Item savedItem = null;
    try {
      savedItem = itemRepository.saveAndFlush(item);
    }
    catch (Exception ex) {
      LOG.error("Item could not be saved due to an error");
    }

    if (savedItem != null && savedItem.getId() != null) {
      LOG.info("nieuwe Item aangemaakt " + savedItem.getId() + "/" + savedItem.getName() + "/" + savedItem.getPrice() + "/"
        + savedItem.getShortDescription());
      return savedItem;
    } else {
      LOG.error("Item niet aangemaakt!");
      return null;
    }
View Full Code Here

    }
  }


  public Item getItemById(Long id) {
    Item item = null;
    try {
      item = itemRepository.findById(id);
    }
    catch (Exception ex) {
      LOG.warn("Eroor bij het ophalen van ");
    }
    if (item != null) {
      LOG.info("Item gevonden id:" + item.getId() + " naam:" + item.getName() + " price:" + item.getPrice() + " beschrijving:"
        + item.getShortDescription());
      return item;
    } else {
      LOG.error("Item niet gevonden!");
      return null;
    }
View Full Code Here

TOP

Related Classes of nl.oneday.data.domain.items.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.