コード例 #1
0
  @Test
  public void testSortableField() throws Exception {
    FullTextSession s = Search.getFullTextSession(openSession());
    Transaction tx = s.beginTransaction();

    Item item1 = new Item();
    item1.setId(3);
    item1.setPrice((short) 3454);
    s.persist(item1);

    Item item2 = new Item();
    item2.setId(2);
    item2.setPrice((short) 3354);
    s.persist(item2);

    Item item3 = new Item();
    item3.setId(1);
    item3.setPrice((short) 3554);
    s.persist(item3);

    tx.commit();
    s.clear();

    tx = s.beginTransaction();

    Query q =
        s.getSearchFactory().buildQueryBuilder().forEntity(Item.class).get().all().createQuery();
    FullTextQuery query = s.createFullTextQuery(q, Item.class);
    query.setSort(new Sort(new SortField("price", SortField.Type.INT)));

    List<?> results = query.list();
    assertThat(results)
        .onProperty("price")
        .describedAs("Sortable field via programmatic config")
        .containsExactly((short) 3354, (short) 3454, (short) 3554);

    query.setSort(new Sort(new SortField("id", SortField.Type.STRING)));

    results = query.list();
    assertThat(results)
        .onProperty("id")
        .describedAs("Sortable field via programmatic config")
        .containsExactly(1, 2, 3);

    s.delete(results.get(0));
    s.delete(results.get(1));
    s.delete(results.get(2));
    tx.commit();
    s.close();
  }
コード例 #2
0
ファイル: Item.java プロジェクト: pttravis/ds-armor
 public static Item getNoneItem() {
   Item item = new Item();
   item.setName("None");
   item.setEnabled(true);
   item.setId(-1);
   return item;
 }
コード例 #3
0
ファイル: DatabaseConect.java プロジェクト: nischal426/test
  public ArrayList<Item> getItem() {
    ArrayList<Item> items = new ArrayList<Item>();
    try {

      Statement stmt = null;
      Connection conn = null;
      ResultSet rs = null;
      String connectionUrl = "jdbc:mysql://localhost:3306/mall";

      Class.forName("com.mysql.jdbc.Driver");
      conn = (Connection) DriverManager.getConnection(connectionUrl, "root", "buki");
      System.out.println("Connection made to database..............Item Item");

      stmt = conn.createStatement();
      rs = stmt.executeQuery("select * from sports_center ");

      while (rs.next()) {
        Item item = new Item();
        item.setId(rs.getInt("item_id"));
        item.setItem_name(rs.getString("item_name"));
        item.setItem_price(rs.getInt("item_price"));
        items.add(item);
      }
      rs.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return items;
  }
コード例 #4
0
ファイル: Items.java プロジェクト: Malya/RechercheInfo
 protected Map<String, Item<U>> map() throws DBException {
   if (this.update == null) {
     this.update = new HashMap<String, Item<U>>();
     new Query(this.db, "map()", this.query()) {
       @Override
       protected void process(ResultSet rs) throws DBException, SQLException {
         while (rs.next()) {
           key = rs.getInt(1);
           String name = rs.getString(2);
           Item<U> item = insert.remove(name);
           if (item != null) {
             item.setId(key);
             refresh(item.getUnique(), rs);
             update.put(name, item);
           }
         }
         key += 1;
       }
     }.execute();
     for (Item<U> item : this.insert.values()) {
       item.setId(this.key);
       this.key += 1;
     }
   }
   return this.update;
 }
コード例 #5
0
ファイル: Item.java プロジェクト: pttravis/ds-armor
 public static Item getAnyItem() {
   Item item = new Item();
   item.setName("Any");
   item.setEnabled(true);
   item.setId(-2);
   return item;
 }
コード例 #6
0
  @Override
  public long create(Item item) {
    long key = getLastId();
    key++;
    item.setId(key);
    items.put(key, item);

    return key;
  }
コード例 #7
0
ファイル: ArrayStorage.java プロジェクト: veltzer/demos-java
 @Override
 public void saveItem(Item i) {
   // put the item in the last place
   int length = array.length;
   i.setId(length);
   Item[] newarray = new Item[length + 1];
   System.arraycopy(array, 0, newarray, 0, length);
   newarray[length] = i;
   array = newarray;
 }
コード例 #8
0
ファイル: ItemDAO.java プロジェクト: Noskire/Transporte
  private Item cursorToItem(Cursor cursor) {
    Item item = new Item();
    item.setId(cursor.getLong(0));
    item.setNome(cursor.getString(1));
    item.setComp(cursor.getDouble(2));
    item.setLarg(cursor.getDouble(3));
    item.setAlt(cursor.getDouble(4));
    item.setPeso(cursor.getDouble(5));
    item.setQuant(cursor.getLong(6));
    item.setEstagio(cursor.getLong(7));

    return item;
  }
コード例 #9
0
  private List<Item> queryItems(int tunnelId, int tunnelSectionId) {
    List<LinePipe> linePipes =
        m_linePipeService.queryLimitedLinePipes(tunnelId, tunnelSectionId, 0, Integer.MAX_VALUE);
    List<Item> items = new ArrayList<Item>();

    for (LinePipe channel : linePipes) {
      Item item = new Item();

      item.setId(channel.getId());
      item.setName(channel.getName());
      items.add(item);
    }
    return items;
  }
コード例 #10
0
  /**
   * An insert operation to the MDSItemStorage.
   *
   * @param id
   * @param price
   * @param description
   * @param size
   * @return
   */
  int insert(long id, double price, long[] description, int size) {

    if (find(id) != 0) {
      Item previousItem = findItem(id);

      Double previousPrice = previousItem.getPrice();
      List<Long> previousDescription = previousItem.getDescription();

      if (size > 0) {
        Integer previousDescriptionHash = previousItem.getDescriptionHash();

        // Description of item is in description[0..size-1]. copy them into your data structure.
        previousItem.setDescription(size, (size == 0) ? null : description);

        // adjust previousDescription
        getStorage()
            .updateDescriptionDataSet(
                previousItem,
                previousDescription,
                price,
                (previousPrice == price ? null : previousPrice));

        // adjust previousPrice
        getStorage().updatePriceDataSet(previousItem, previousPrice);

        // refresh and re-check associated same-same hash with the previous item.
        getStorage().addressSameSameHashing(previousItem, previousDescriptionHash);
      } else {
        if (previousPrice != price) {
          if (size == 0)
            getStorage().updateDescriptionDataSet(previousItem, null, price, previousPrice);

          // adjust previousPrice
          getStorage().updatePriceDataSet(previousItem, previousPrice);
        }
      }

      return 0;
    }

    // create the Item object.
    Item item = new Item();
    item.setId(id).setPrice(price).setDescription(size, (size == 0) ? null : description);

    // register new item
    getStorage().registerItem(item);

    return 1;
  }
コード例 #11
0
 public void inflateMenu(int menu) {
   MenuInflater menuInflater = new SupportMenuInflater(getContext());
   MenuBuilder menuBuilder = new MenuBuilder(getContext());
   menuInflater.inflate(menu, menuBuilder);
   List<Item> items = new ArrayList<>();
   for (int i = 0; i < menuBuilder.size(); i++) {
     MenuItem menuItem = menuBuilder.getItem(i);
     Item item = new Item();
     item.setId(menuItem.getItemId());
     item.setIcon(menuItem.getIcon());
     item.setTitle(menuItem.getTitle().toString());
     items.add(item);
   }
   addItems(items);
 }
コード例 #12
0
  private List<Item> queryItems(int tunnelId, int tunnelSectionId) {
    List<SaddleWeight> saddleWeights =
        m_saddleWeightService.queryLimitedSaddleWeights(
            tunnelId, tunnelSectionId, 0, Integer.MAX_VALUE);
    List<Item> items = new ArrayList<Item>();

    for (SaddleWeight channel : saddleWeights) {
      Item item = new Item();

      item.setId(channel.getId());
      item.setName(channel.getName());
      items.add(item);
    }
    return items;
  }
コード例 #13
0
ファイル: Items.java プロジェクト: Malya/RechercheInfo
 public Item<U> get(String name) {
   Item<U> item = this.insert.get(name);
   if (item == null) {
     if (this.update != null) {
       item = this.update.get(name);
     }
     if (item == null) {
       item = item(name);
       this.insert.put(name, item);
       if (this.justCreated()) {
         item.setId(this.key);
         this.key += 1;
       }
     }
   }
   return item;
 }
コード例 #14
0
ファイル: SwitchItemTag.java プロジェクト: LuckTiger/frame
 @Override
 public int doEndTag() throws JspException {
   SwitchPanelTag panel = (SwitchPanelTag) findAncestorWithClass(this, SwitchPanelTag.class);
   if (panel == null) {
     throw new JspTagException("SwitchItem标签不能单独使用");
   }
   Item item = new Item();
   item.setId(this.id);
   item.setHeader(header);
   item.setOnclick(onclick);
   item.setClosable(closable);
   if (this.bodyContent != null) {
     item.setContent(this.bodyContent.getString());
   }
   panel.addItem(item);
   this.id = null;
   return super.doEndTag();
 }
コード例 #15
0
  /**
   * Month conversion from jaxb model to entity object.
   *
   * @param model jaxb model of month
   * @return month entity object
   */
  public static org.kaleta.scheduler.backend.entity.Month transformMonthToData(Month model) {
    org.kaleta.scheduler.backend.entity.Month data =
        new org.kaleta.scheduler.backend.entity.Month();

    data.setId(Integer.valueOf(model.getId()));
    data.setName(model.getSpecification().getName());
    data.setDaysNumber(Integer.valueOf(model.getSpecification().getDays()));
    data.setDayStartsWith(Integer.valueOf(model.getSpecification().getFirstDay()));
    for (Month.Specification.FreeDay freeDay : model.getSpecification().getFreeDayList()) {
      data.getPublicFreeDays().add(Integer.valueOf(freeDay.getDay()));
    }

    for (Month.Schedule.Task modelTask : model.getSchedule().getTaskList()) {
      Task task = new Task();
      task.setId(Integer.valueOf(modelTask.getId()));
      task.setType(modelTask.getType());
      task.setDescription(modelTask.getDescription());
      task.setDay(Integer.valueOf(modelTask.getDay()));
      Time starts = new Time();
      starts.setFromString(modelTask.getStarts());
      task.setStarts(starts);
      Time duration = new Time();
      duration.setFromString(modelTask.getDuration());
      task.setDuration(duration);
      task.setPriority(Boolean.valueOf(modelTask.getPriority()));
      task.setSuccessful(Boolean.valueOf(modelTask.getSuccessful()));
      data.getTasks().add(task);
    }

    for (Month.Accounting.Item modelItem : model.getAccounting().getItemList()) {
      Item item = new Item();
      item.setId(Integer.valueOf(modelItem.getId()));
      item.setType(modelItem.getType());
      item.setDescription(modelItem.getDescription());
      item.setDay(Integer.valueOf(modelItem.getDay()));
      item.setIncome(Boolean.valueOf(modelItem.getIncome()));
      item.setAmount(new BigDecimal(modelItem.getAmount()));
      data.getItems().add(item);
    }

    return data;
  }
コード例 #16
0
  /**
   * Adds a new item to the user
   *
   * @param item the new item
   */
  public void addItem(Item item) {

    if (items.contains(item)) {
      return;
    }

    // first increment the gameCount so the new item has the newly incremented game value.
    incrementGameCount();

    if (item.getId().contains("NO_INTERNET")) {
      //  don't change id
      items.add(item);
    } else {

      // Refresh the item list owned by this user in case of any recent changes
      // Grab the items from the controller.
      ItemController.GetItems getItems = new ItemController.GetItems();
      getItems.execute(getItems.MODE_GET_MY_ITEMS, username);

      UserController.setCurrentUser(this);

      try {
        items = getItems.get();
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      }
      // set to item's ID before sending to controller
      item.setId(getUsername() + (char) 31 + getGameCount());
      items.add(item);
      // Post the new item information
      // Set the item via the controller.
      ItemController.AddItem addItem = new ItemController.AddItem();
      addItem.execute(item);

      // Adds the Item to the user
      UserController.UpdateUserProfile updateUserProfile = new UserController.UpdateUserProfile();
      updateUserProfile.execute(this);
    }
  }
コード例 #17
0
  @Test
  public void testIndexEmbedded() throws Exception {
    FullTextSession s = Search.getFullTextSession(openSession());
    Transaction tx = s.beginTransaction();

    ProductCatalog productCatalog = new ProductCatalog();
    productCatalog.setName("Cars");
    Item item = new Item();
    item.setId(1);
    item.setDescription("Ferrari");
    item.setProductCatalog(productCatalog);
    productCatalog.addItem(item);

    s.persist(item);
    s.persist(productCatalog);
    tx.commit();

    s.clear();

    tx = s.beginTransaction();

    QueryParser parser = new QueryParser("id", TestConstants.standardAnalyzer);
    org.apache.lucene.search.Query luceneQuery = parser.parse("items.description:Ferrari");
    FullTextQuery query =
        s.createFullTextQuery(luceneQuery).setProjection(FullTextQuery.THIS, FullTextQuery.SCORE);
    assertEquals("expecting 1 results", 1, query.getResultSize());

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.list();

    for (Object[] result : results) {
      s.delete(result[0]);
    }
    tx.commit();
    s.close();
  }
コード例 #18
0
ファイル: ItemDao.java プロジェクト: bleathem/faces
 public void create(Item item) {
   item.setId(index);
   itemMap.put(5, item);
   index++;
 }
コード例 #19
0
 public void addItem(Item item) {
   item.setId(items.size() + 1);
   items.add(item);
 }
コード例 #20
0
ファイル: ViewShop.java プロジェクト: moguonyanko/moglabo
 public void add() {
   int newId = list.isEmpty() ? 1 : list.get(list.size() - 1).getId() + 1;
   nowItem.setId(newId);
   list.add(nowItem);
   resetItem();
 }