com.orm.query.Condition Java Examples
The following examples show how to use
com.orm.query.Condition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StoryListViewModel.java From hacker-news-android with Apache License 2.0 | 6 votes |
public Observable<Object> deleteStory(Story item) { return Observable.create(subscriber -> { SugarTransactionHelper.doInTansaction(() -> { Select.from(Story.class) .where(Condition.prop(StringUtil.toSQLName("mStoryId")) .eq(item.getStoryId())) .first() .delete(); StoryDetail storyDetail = Select.from(StoryDetail.class) .where(Condition.prop(StringUtil.toSQLName(StoryDetail.STORY_DETAIL_ID)) .eq(item.getStoryId())) .first(); Select.from(Comment.class) .where(Condition.prop(StringUtil.toSQLName("mStoryDetail")) .eq(storyDetail.getId())) .first() .delete(); storyDetail.delete(); if (!subscriber.isUnsubscribed()) { subscriber.onCompleted(); } }); }); }
Example #2
Source File: CommandHistory.java From grblcontroller with GNU General Public License v3.0 | 5 votes |
public static void saveToHistory(String command, String gcode){ CommandHistory commandHistory = Select.from(CommandHistory.class) .where(Condition.prop("gcode").eq(gcode)) .first(); if(commandHistory == null) commandHistory = new CommandHistory(command, gcode); commandHistory.usageCount++; commandHistory.updateLastUsedOn(); commandHistory.save(); }
Example #3
Source File: AppsModel.java From FastAccess with GNU General Public License v3.0 | 5 votes |
public static boolean exists(@NonNull String activityInfoName, @NonNull String packageName) { return Select.from(AppsModel.class) .where(Condition.prop(NamingHelper.toSQLNameDefault("activityInfoName")).eq(activityInfoName)) .and(Condition.prop(NamingHelper.toSQLNameDefault("packageName")).eq(packageName)) .and(Condition.prop(NamingHelper.toSQLNameDefault("folderId")).eq(0)) .first() != null; }
Example #4
Source File: StoryListViewModel.java From hacker-news-android with Apache License 2.0 | 5 votes |
private Observable<Story> getStories(Observable<List<NodeHNAPIStory>> nodeHNAPIStoriesObservable) { return nodeHNAPIStoriesObservable.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .flatMap(Observable::from) .map(Story::fromNodeHNAPIStory) .map(story -> { Story mStoryId = Select.from(Story.class) .where(Condition.prop(StringUtil.toSQLName("mStoryId")).eq(story.getStoryId())) .first(); if (mStoryId != null) { story.setIsSaved(true); } return story; }) .map(story -> { try { if (HackerNewsApplication.getAppComponent().getCacheManager().get(String.valueOf(story.getStoryId()), Story.class) != null) { story.setIsRead(true); } return story; } catch (IOException e) { } return story; }) .doOnNext(story -> { if (mStories == null) { mStories = new ArrayList<>(30); } mStories.add(story); }); }
Example #5
Source File: VideoDetailsFragment.java From Amphitheatre with Apache License 2.0 | 5 votes |
private Map<String, List<Video>> getRelatedMovies(Video video) { List<Video> videos = Select .from(Video.class) .where(Condition.prop("is_matched").eq(1), Condition.prop("is_movie").eq(1)) .list(); Map<String, List<Video>> relatedVideos = new HashMap<String, List<Video>>(); String key = getString(R.string.related_videos); relatedVideos.put(key, new ArrayList<Video>()); if (video.getMovie() != null && !TextUtils.isEmpty(video.getMovie().getFlattenedGenres())) { String[] genresArray = video.getMovie().getFlattenedGenres().split(","); Set<String> genres = new HashSet<String>(Arrays.asList(genresArray)); for (Video vid : videos) { if (vid.getMovie() != null && !TextUtils.isEmpty(vid.getMovie().getFlattenedGenres())) { Set<String> intersection = new HashSet<String>(Arrays.asList( vid.getMovie().getFlattenedGenres().split(","))); intersection.retainAll(genres); if (intersection.size() == genresArray.length && !video.getMovie().getTitle().equals(vid.getMovie().getTitle())) { relatedVideos.get(key).add(vid); } } } } return relatedVideos; }
Example #6
Source File: AppsModel.java From FastAccess with GNU General Public License v3.0 | 4 votes |
public static List<AppsModel> getApps() { return Select.from(AppsModel.class) .where(Condition.prop(NamingHelper.toSQLNameDefault("folderId")).eq(0)) .orderBy(NamingHelper.toSQLNameDefault("indexPosition") + " ASC") .list(); }
Example #7
Source File: AppsModel.java From FastAccess with GNU General Public License v3.0 | 4 votes |
public static List<AppsModel> getApps(long folderId) { return Select.from(AppsModel.class) .where(Condition.prop(NamingHelper.toSQLNameDefault("folderId")).eq(folderId)) .list(); }