public static QueryBuilder getQueryBuilder(
     AbstractDao dao, WhereCondition cond, WhereCondition... condmore) {
   setIfLog();
   QueryBuilder qb = dao.queryBuilder();
   qb.where(cond, condmore);
   return qb;
 }
    protected void onPostExecute(String values) {
      // dialogo.hide();
      if (values != null) {
        try {
          JSONObject json = new JSONObject(values);
          if (json.getString("status").equals("OK")) {

            JSONArray result = json.getJSONArray("result");
            JSONObject datos = new JSONObject(result.getString(0));
            JSONObject fields_ = datos.getJSONObject("fields");

            Clientes cliente = new Clientes();
            cliente.setNombres(fields_.getString("nombres"));
            cliente.setApellidos(fields_.getString("apellidos"));
            cliente.setDirección("No disponible");
            cliente.setDocumento("1105683985");
            cliente.setEmail(fields_.getString("email"));
            cliente.setReferencia(datos.getInt("pk"));
            cliente.setTelefono("6700572");

            QueryBuilder qb = DaoAPP.daoSession.getClientesDao().queryBuilder();
            qb.where(ClientesDao.Properties.Referencia.eq(datos.getInt("pk")));
            List<Clientes> clientes = qb.list();
            if (clientes.size() == 0) {
              DaoAPP.daoSession.getClientesDao().insert(cliente);
            }
          }
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
    }
    protected void onPostExecute(String values) {
      // dialogo.hide();
      if (values != null) {
        katana kata = new katana();
        try {
          long fer = kata.crearFincaEnInicio(new JSONObject(values));
          if (fer != 0) {
            QueryBuilder qb = DaoAPP.daoSession.getClientesDao().queryBuilder();
            qb.where(ClientesDao.Properties.Referencia.eq(fer));

            List<Clientes> clientes = qb.list();
            if (clientes.size() == 0) {
              new descargarCliente().execute(String.valueOf(fer));
            }
          }
        } catch (JSONException e) {
          e.printStackTrace();
        }

      } else {
        Toast.makeText(
                MainActivity.this,
                "No hemos podido iniciar sesión, asegurate de estar conectado a internet.",
                Toast.LENGTH_SHORT)
            .show();
      }
    }
Beispiel #4
0
  public Double getPrice(Trader trader, Long unitID) {
    if (trader != null && unitID != null) {
      QueryBuilder<TraderPrice> traderPriceQueryBuilder = traderPriceDao.queryBuilder();
      traderPriceQueryBuilder.where(
          TraderPriceDao.Properties.TraderID.eq(trader.getTraderID()),
          TraderPriceDao.Properties.UnitID.eq(unitID));
      TraderPrice traderPrice = traderPriceQueryBuilder.unique();
      if (traderPrice != null) {
        return traderPrice.getPrice();
      } else {
        Integer level = trader.getLev();
        QueryBuilder<Unit> unitQueryBuilder = unitDao.queryBuilder();
        unitQueryBuilder.where(UnitDao.Properties.UnitID.eq(unitID));
        Unit unit = unitQueryBuilder.unique();

        if (level != null && level != 0) {
          switch (level) {
            case 1:
              if (unit.getLPrice1() == null || unit.getLPrice1().compareTo(0D) == 0)
                return unit.getSPrice();
              return unit.getLPrice1();
            case 2:
              if (unit.getLPrice2() == null || unit.getLPrice2().compareTo(0D) == 0)
                return unit.getSPrice();

              return unit.getLPrice2();
            case 3:
              if (unit.getLPrice3() == null || unit.getLPrice3().compareTo(0D) == 0)
                return unit.getSPrice();
              return unit.getLPrice3();
            case 4:
              if (unit.getLPrice4() == null || unit.getLPrice4().compareTo(0D) == 0)
                return unit.getSPrice();
              return unit.getLPrice4();
            case 5:
              if (unit.getLPrice5() == null || unit.getLPrice5().compareTo(0D) == 0)
                return unit.getSPrice();
              return unit.getLPrice5();
          }
        } else {
          return unit.getSPrice();
        }
      }
    }
    return (double) 0;
  }
 private void getPlayerData(String playerID) {
   QueryBuilder<Player> playerQB =
       CustomApplcation.getDaoSession(mContext).getPlayerDao().queryBuilder();
   playerQB.where(com.kinth.football.dao.PlayerDao.Properties.Uuid.eq(playerID));
   List<Player> list = playerQB.list();
   for (int i = 0; i < list.size(); i++) {
     playerList.add(list.get(i));
   }
 }
 public void testWhereWithSpecialNamesWithValues() {
   QueryBuilder<SpecialNamesEntity> queryBuilder = dao.queryBuilder();
   queryBuilder.where(Properties.Avg.eq("test"));
   queryBuilder.where(Properties.Count.notIn("test", "test2"));
   queryBuilder.where(Properties.Distinct.ge("test"));
   queryBuilder.where(Properties.Index.le("test"));
   queryBuilder.where(Properties.Join.like("test"));
   queryBuilder.where(Properties.On.notEq("test"));
   queryBuilder.where(Properties.Select.in("test", "test2"));
   queryBuilder.where(Properties.Sum.lt(1));
   queryBuilder.where(Properties.Order.gt(1));
   queryBuilder.list();
   queryBuilder.buildCount().count();
   queryBuilder.buildDelete().executeDeleteWithoutDetachingEntities();
 }
 public void testWhereWithSpecialNames() {
   QueryBuilder<SpecialNamesEntity> queryBuilder = dao.queryBuilder();
   queryBuilder.where(Properties.Avg.isNotNull());
   queryBuilder.where(Properties.Count.isNotNull());
   queryBuilder.where(Properties.Distinct.isNotNull());
   queryBuilder.where(Properties.Index.isNotNull());
   queryBuilder.where(Properties.Join.isNotNull());
   queryBuilder.where(Properties.On.isNotNull());
   queryBuilder.where(Properties.Select.isNotNull());
   queryBuilder.where(Properties.Sum.isNotNull());
   queryBuilder.where(Properties.Order.isNotNull());
   queryBuilder.list();
   queryBuilder.buildCount().count();
   queryBuilder.buildDelete().executeDeleteWithoutDetachingEntities();
 }
 /** Internal query to resolve the "downloadInfo" to-many relationship of ThirdGameInfo. */
 public List<ThirdGameDownInfo> _queryThirdGameInfo_DownloadInfo(String gameId) {
   synchronized (this) {
     if (thirdGameInfo_DownloadInfoQuery == null) {
       QueryBuilder<ThirdGameDownInfo> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.GameId.eq(null));
       thirdGameInfo_DownloadInfoQuery = queryBuilder.build();
     }
   }
   Query<ThirdGameDownInfo> query = thirdGameInfo_DownloadInfoQuery.forCurrentThread();
   query.setParameter(0, gameId);
   return query.list();
 }
 /** Internal query to resolve the "locations" to-many relationship of Event. */
 public List<Location> _queryEvent_Locations(long event_id) {
   synchronized (this) {
     if (event_LocationsQuery == null) {
       QueryBuilder<Location> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.Event_id.eq(null));
       event_LocationsQuery = queryBuilder.build();
     }
   }
   Query<Location> query = event_LocationsQuery.forCurrentThread();
   query.setParameter(0, event_id);
   return query.list();
 }
 /** Internal query to resolve the "lectureList" to-many relationship of History. */
 public List<Lecture> _queryHistory_LectureList(String goods_id) {
   synchronized (this) {
     if (history_LectureListQuery == null) {
       QueryBuilder<Lecture> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.Goods_id.eq(null));
       history_LectureListQuery = queryBuilder.build();
     }
   }
   Query<Lecture> query = history_LectureListQuery.forCurrentThread();
   query.setParameter(0, goods_id);
   return query.list();
 }
Beispiel #11
0
 /** Internal query to resolve the "trips" to-many relationship of Route. */
 public List<Trip> _queryRoute_Trips(String routeId) {
   synchronized (this) {
     if (route_TripsQuery == null) {
       QueryBuilder<Trip> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.RouteId.eq(null));
       route_TripsQuery = queryBuilder.build();
     }
   }
   Query<Trip> query = route_TripsQuery.forCurrentThread();
   query.setParameter(0, routeId);
   return query.list();
 }
Beispiel #12
0
 /** Internal query to resolve the "rules" to-many relationship of Gesture. */
 public List<Rule> _queryGesture_Rules(long plugin_id) {
   synchronized (this) {
     if (gesture_RulesQuery == null) {
       QueryBuilder<Rule> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.Plugin_id.eq(null));
       gesture_RulesQuery = queryBuilder.build();
     }
   }
   Query<Rule> query = gesture_RulesQuery.forCurrentThread();
   query.setParameter(0, plugin_id);
   return query.list();
 }
Beispiel #13
0
 /** Internal query to resolve the "commentList" to-many relationship of CatPost. */
 public List<Comment> _queryCatPost_CommentList(Long idCatPost) {
   synchronized (this) {
     if (catPost_CommentListQuery == null) {
       QueryBuilder<Comment> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.IdCatPost.eq(null));
       catPost_CommentListQuery = queryBuilder.build();
     }
   }
   Query<Comment> query = catPost_CommentListQuery.forCurrentThread();
   query.setParameter(0, idCatPost);
   return query.list();
 }
Beispiel #14
0
 /** Internal query to resolve the "firsatlarimListesi" to-many relationship of Firsat. */
 public List<Firsatlarim> _queryFirsat_FirsatlarimListesi(Long firsat_id) {
   synchronized (this) {
     if (firsat_FirsatlarimListesiQuery == null) {
       QueryBuilder<Firsatlarim> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.Firsat_id.eq(null));
       firsat_FirsatlarimListesiQuery = queryBuilder.build();
     }
   }
   Query<Firsatlarim> query = firsat_FirsatlarimListesiQuery.forCurrentThread();
   query.setParameter(0, firsat_id);
   return query.list();
 }
 /** Internal query to resolve the "orders" to-many relationship of Customer. */
 public List<Order> _queryCustomer_Orders(long customerId) {
   synchronized (this) {
     if (customer_OrdersQuery == null) {
       QueryBuilder<Order> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.CustomerId.eq(null));
       queryBuilder.orderRaw("T.'DATE' ASC");
       customer_OrdersQuery = queryBuilder.build();
     }
   }
   Query<Order> query = customer_OrdersQuery.forCurrentThread();
   query.setParameter(0, customerId);
   return query.list();
 }
Beispiel #16
0
 /** Internal query to resolve the "feelings" to-many relationship of Location. */
 public List<Feeling> _queryLocation_Feelings(long locationId) {
   synchronized (this) {
     if (location_FeelingsQuery == null) {
       QueryBuilder<Feeling> queryBuilder = queryBuilder();
       queryBuilder.where(Properties.LocationId.eq(null));
       queryBuilder.orderRaw("_id ASC");
       location_FeelingsQuery = queryBuilder.build();
     }
   }
   Query<Feeling> query = location_FeelingsQuery.forCurrentThread();
   query.setParameter(0, locationId);
   return query.list();
 }
 @Override
 public void setUserVisibleHint(boolean isVisibleToUser) {
   super.setUserVisibleHint(isVisibleToUser);
   if (isVisibleToUser && adapter.getItemCount() == 0) {
     QueryBuilder<ChapterEntity> queryBuilder = chapterDao.queryBuilder();
     if (type.getId() != 1) {
       queryBuilder.where(ChapterEntityDao.Properties.TypeId.eq(type.getId()));
     }
     Query<ChapterEntity> query =
         queryBuilder.limit(20).orderDesc(ChapterEntityDao.Properties.SendDate).build();
     adapter.addAll(query.list());
   }
 }
    @Override
    protected List<Player> doInBackground(Void... params) {
      QueryBuilder<TeamPlayer> tpQB =
          CustomApplcation.getDaoSession(mContext).getTeamPlayerDao().queryBuilder();
      tpQB.where(com.kinth.football.dao.TeamPlayerDao.Properties.Team_id.eq(onlyTeam.getUuid()));
      List<TeamPlayer> teamId_playerId_List = tpQB.list();

      if (teamId_playerId_List.size() != 0) {
        for (TeamPlayer teamplayer : teamId_playerId_List) {
          getPlayerData(teamplayer.getPlayer_id());
        }
      }
      return playerList;
    }
 public void deleteOlderThanDate(Date date, boolean flag) {
   date = o.a(date);
   QueryBuilder querybuilder = getEntityDao().queryBuilder();
   WhereCondition wherecondition = WaterLogEntryDao.Properties.LogDate.lt(date);
   if (flag) {
     date =
         WaterLogEntryDao.Properties.EntityStatus.eq(
             Integer.valueOf(com.fitbit.data.domain.Entity.EntityStatus.SYNCED.getCode()));
   } else {
     date = null;
   }
   (new DeleteQueryExt(
           querybuilder.where(wherecondition, new WhereCondition[] {date}).buildDelete()))
       .executeDeleteAndClearCache();
 }
 public void deleteByDate(Date date, boolean flag) {
   Object obj = o.a(date);
   date = o.e(date);
   QueryBuilder querybuilder = getEntityDao().queryBuilder();
   obj = WaterLogEntryDao.Properties.LogDate.between(obj, date);
   if (flag) {
     date =
         WaterLogEntryDao.Properties.EntityStatus.eq(
             Integer.valueOf(com.fitbit.data.domain.Entity.EntityStatus.SYNCED.getCode()));
   } else {
     date = null;
   }
   (new DeleteQueryExt(
           querybuilder
               .where(((WhereCondition) (obj)), new WhereCondition[] {date})
               .buildDelete()))
       .executeDeleteAndClearCache();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    ButterKnife.inject(this, view);

    DatabaseHelper helper = DatabaseHelper.getInstance(getActivity());
    SQLiteDatabase db = helper.getWritableDatabase();
    DaoMaster daoMaster = new DaoMaster(db);
    DaoSession daoSession = daoMaster.newSession();
    GalleryDao galleryDao = daoSession.getGalleryDao();

    QueryBuilder<Gallery> qb = galleryDao.queryBuilder();
    qb.where(GalleryDao.Properties.Starred.eq(true));
    qb.orderDesc(GalleryDao.Properties.Lastread);
    getList().addAll(qb.list());
    notifyDataSetChanged();

    if (getCount() == 0) {
      errorView.setText(R.string.error_no_starred);
    }

    return view;
  }
 /**
  * Deletes all matching entities without detaching them from the identity scope (aka
  * session/cache). Note that this method may lead to stale entity objects in the session cache.
  * Stale entities may be returned when loaded by their primary key, but not using queries.
  *
  * @param dao
  * @param cond
  * @param condmore
  */
 public static void deleteByCondition(
     AbstractDao dao, WhereCondition cond, WhereCondition... condmore) {
   setIfLog();
   QueryBuilder qb = dao.queryBuilder();
   qb.where(cond, condmore).buildDelete().executeDeleteWithoutDetachingEntities();
 }
 public List<DeviceBean> loadAllDeviceBean(String UUIDString) {
   QueryBuilder<DeviceBean> mqBuilder = deviceBeanDao.queryBuilder();
   mqBuilder.where(com.itraing.greendao.DeviceBeanDao.Properties.UUIDString.eq(UUIDString));
   return mqBuilder.list();
 }