Package org.lazan.t5.stitch.demo.entities

Examples of org.lazan.t5.stitch.demo.entities.Item


  }

  private void addCategories(Map<String, Category> catCache, String[] categories) {
    for (String categoryEntry : categories) {
      String[] hierarchy = categoryEntry.split("/");
      Category parentCategory = null;
      for (String categoryName : hierarchy) {
        Category category = catCache.get(categoryName);
        if (category == null) {
          category = new Category();
          category.setName(categoryName);
          category.setParentCategory(parentCategory);
          session.save(category);
         
          catCache.put(categoryName, category);
        }
        parentCategory = category;
View Full Code Here


  private void addItems(Map<String, Category> catCache, String[] items) {
    for (String itemString : items) {
      String[] row = itemString.split("\\|");

      Category category = catCache.get(row[0]);
      Item item = new Item();
      item.setCategory(category);
      item.setName(row[1]);
      item.setPrice(new BigDecimal(row[2]));
      item.setDescription(row[3]);
View Full Code Here

   */
  public List<ItemTreeNode> getChildren(ItemTreeNode value) {
    if (value.isLeaf()) {
      return Collections.emptyList();
    }
    Category category = value.getCategory();
    List<ItemTreeNode> children = new ArrayList<ItemTreeNode>();

    // add the categories
    children.addAll(findCategoryNodes(category, null));
   
    // lookup the child items
    for (Item item : category.getItems()) {
      children.add(new ItemTreeNode(item));
    }

    return children;
  }
View Full Code Here

    return String.valueOf(value.getCategory().getCategoryId());
  }
 
  public ItemTreeNode toValue(String clientValue) {
    Long categoryId = Long.parseLong(clientValue);
    Category category = (Category) session.get(Category.class, categoryId);
    List<ItemTreeNode> nodes = findCategoryNodes(null,  category);
    if (nodes.size() == 1) {
      return nodes.get(0);
    }
    throw new IllegalStateException(
View Full Code Here

      "group by " +
        "childCategory.categoryId, childCategory.name, childCategory.parentCategory " +
      "order by childCategory.name";
   
    String whereClause;
    Category param = null;
    if (childCategory != null) {
      whereClause = "childCategory = ?";
      param = childCategory;
    } else if (parentCategory != null) {
      whereClause = "childCategory.parentCategory = ?";
      param = parentCategory;
    } else {
      whereClause = "childCategory.parentCategory is null";
    }
    String hql = String.format(hqlTemplate, whereClause);
    Query query = session.createQuery(hql);
    if (param != null) {
      query.setParameter(0, param);
    }
    List<Object[]> results = query.list();
    for (Object[] row : results) {
      Category current = (Category) row[0];
      int grandChildCategoryCount = ((Number) row[1]).intValue();
      int itemCount = ((Number) row[2]).intValue();
     
      ItemTreeNode treeNode =
          new ItemTreeNode(current, grandChildCategoryCount, itemCount);
View Full Code Here

  private void addItems(Map<String, Category> catCache, String[] items) {
    for (String itemString : items) {
      String[] row = itemString.split("\\|");

      Category category = catCache.get(row[0]);
      Item item = new Item();
      item.setCategory(category);
      item.setName(row[1]);
      item.setPrice(new BigDecimal(row[2]));
      item.setDescription(row[3]);
      session.save(item);
    }
  }
View Full Code Here

 
  @Inject
  private Block itemBlock;
 
  public TreeModel<ItemTreeNode> getTreeModel() {
    ItemTreeSource source = new ItemTreeSource(session);
    return new LazyTreeModel<ItemTreeNode>(source, source);
  }
View Full Code Here

  }
 
  void onValidateFromGenericField(String value) {
    if (value == null || !value.toLowerCase().startsWith("a")) {
      String fieldName = getFieldName(genericField.getControlName());
      Field fieldSnapshot = new FieldSnapshot(genericField);
      form.recordError(fieldSnapshot, fieldName + " must start with 'a'");
    }
  }
View Full Code Here

    }
    return new CollectionGridDataSource(allRecords);
  }
 
  public PagerModel getPagerModel() {
    return new DefaultPagerModel(2, 1, 2);
  }
View Full Code Here

  /**
   * Set the background color of every cell
   */
  public GridCellDecorator getCellDecorator() {
    return new GridCellDecorator() {
      public void decorate(Element cellElement, Object rowObject, int rowIndex, String propertyName, int colIndex) {
        String color;
        if (rowIndex % 2 == 0) {
          color = colIndex % 2 == 0 ? YELLOW : RED;
        } else {
View Full Code Here

TOP

Related Classes of org.lazan.t5.stitch.demo.entities.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.