本文整理汇总了Java中com.orm.query.Select类的典型用法代码示例。如果您正苦于以下问题:Java Select类的具体用法?Java Select怎么用?Java Select使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Select类属于com.orm.query包,在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchUnusedQuotes
import com.orm.query.Select; //导入依赖的package包/类
@Override
public void fetchUnusedQuotes(final Category category, final Callback<List<Quote>> callback) {
Condition [] conditions = new Condition[2];
conditions[0] = Condition.prop(NamingHelper.toSQLNameDefault("used")).eq("0");
conditions[1] = Condition.prop(NamingHelper.toSQLNameDefault("category")).eq(category.getId());
final List<Quote> unusedQuotesFromCategory = Select.from(Quote.class).where(conditions).list();
if (unusedQuotesFromCategory != null && !unusedQuotesFromCategory.isEmpty()) {
callback.onSuccess(unusedQuotesFromCategory);
} else if (category.source == Category.Source.BRAINY_QUOTE) {
fetchNewQuotes(category, new Callback<List<Quote>>() {
@Override
public void onSuccess(List<Quote> quotes) {
callback.onSuccess(quotes);
}
@Override
public void onError(LWQError error) {
callback.onError(error);
}
});
} else {
// It's not an error, just no return.
callback.onSuccess(new ArrayList<Quote>());
}
}
示例2: bindTo
import com.orm.query.Select; //导入依赖的package包/类
void bindTo(UserAlbum userAlbum) {
boundTo = userAlbum;
imageSourceName.setText(userAlbum.name);
imageSourceName.setFocusable(true);
imageSourceName.setFocusableInTouchMode(true);
removeSource.setVisibility(View.VISIBLE);
useImageSource.setChecked(userAlbum.active);
imageSource.setImageBitmap(
ImageLoader.getInstance().loadImageSync(
Select.from(UserPhoto.class)
.where (
Condition.prop(
NamingHelper.toSQLNameDefault("album")
).eq(userAlbum)
).first().uri)
);
}
示例3: getCategories
import com.orm.query.Select; //导入依赖的package包/类
public List<Category> getCategories()
{
List<Category> categories = Select.from(Category.class).orderBy("name").list();
List<Category> validCategories = new ArrayList<>();
for (Category category : categories)
{
if (category.isValid())
{
validCategories.add(category);
}
}
return validCategories;
}
示例4: deleteStory
import com.orm.query.Select; //导入依赖的package包/类
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();
}
});
});
}
示例5: getLoggedInProfileItem
import com.orm.query.Select; //导入依赖的package包/类
IProfile[] getLoggedInProfileItem() {
if (mLoggedInProfiles == null) {
mLoggedInProfiles = new IProfile[2];
User currentUser = Select.from(User.class).first();
ProfileDrawerItem profileDrawerItem = new ProfileDrawerItem().withIdentifier(LOGGED_IN_PROFILE_ITEM)
.withIcon(TextDrawable.builder()
.buildRound(String.valueOf(currentUser.getUserName().charAt(0)),
mResources.getColor(R.color.colorPrimaryDark)))
.withName(currentUser.getUserName());
ProfileSettingDrawerItem logoutDrawerItem = new ProfileSettingDrawerItem().withIdentifier(LOG_OUT_PROFILE_ITEM)
.withName("Logout")
.withDescription("Logout of current account")
.withIcon(mResources.getDrawable(R.drawable.ic_close));
mLoggedInProfiles[0] = profileDrawerItem;
mLoggedInProfiles[1] = logoutDrawerItem;
}
return mLoggedInProfiles;
}
示例6: getByName
import com.orm.query.Select; //导入依赖的package包/类
/**
* Finds transport mode by name.
* @param name name of the transport mode to be searched
* @return transport mode with the given name
*/
public static TransportMode getByName(String name) {
List<TransportMode> modes = Select.from(TransportMode.class)
.where(Condition.prop("name").eq(name))
.limit("1")
.list();
return modes.get(0);
}
示例7: getLatestRouteSearch
import com.orm.query.Select; //导入依赖的package包/类
/**
* Returns the latest routesearch from the database based on custom query,
* or null if there is none.
* @param query custom query
* @return result of the query
*/
private static RouteSearch getLatestRouteSearch(Select<RouteSearch> query) {
List<RouteSearch> routesearches = query.list();
assert routesearches.size() <= 1 : "Invalid SQL query: only one or zero entities should have been returned!";
if (routesearches.size() == 0) {
return null;
}
return routesearches.get(0);
}
示例8: getRouteSearchesByStartlocation
import com.orm.query.Select; //导入依赖的package包/类
/**
* Returns a list of routesearches where the nearestKnownLocation matches the given one.
*
* @param startLocation StartLocation of the routesearches
* @return List of routesearches
*/
public static List<RouteSearch> getRouteSearchesByStartlocation(String startLocation) {
return Select.from(RouteSearch.class)
.where(Condition.prop("startlocation").eq(startLocation))
.orderBy("timestamp DESC")
.list();
}
示例9: getRouteSearchesByDestination
import com.orm.query.Select; //导入依赖的package包/类
/**
* Returns a list of routesearches where the destination matches the given one.
*
* @param destination destination of the routesearches
* @return List of routesearches
*/
public static List<RouteSearch> getRouteSearchesByDestination(String destination) {
return Select.from(RouteSearch.class)
.where(Condition.prop("destination").eq(destination))
.orderBy("timestamp DESC")
.list();
}
示例10: getRouteSearchesByStartlocationAndDestination
import com.orm.query.Select; //导入依赖的package包/类
/**
* Returns a list of routesearches where the startlocation and destination matches the given ones.
*
* @param startLocation Start location of the routesearch
* @param destination Destination of the routesearch
* @return List of routesearches
*/
public static List<RouteSearch> getRouteSearchesByStartlocationAndDestination(String startLocation, String destination) {
return Select.from(RouteSearch.class)
.where(Condition.prop("startlocation").eq(startLocation))
.where(Condition.prop("destination").eq(destination))
.orderBy("timestamp DESC")
.list();
}
示例11: getAll
import com.orm.query.Select; //导入依赖的package包/类
/**
* Retrieves all RouteSearches with the given mode
* @param mode 0 for intracity, 1 for intercity
* @return list of routeSearches
*/
public static List<RouteSearch> getAll(int mode) {
return Select.from(RouteSearch.class)
.where(Condition.prop("mode").eq(mode))
.orderBy("timestamp DESC")
.list();
}
示例12: incrementAppCount
import com.orm.query.Select; //导入依赖的package包/类
public static void incrementAppCount(String packageName, String name) {
String identifier = AppPersistent.generateIdentifier(packageName, name);
AppPersistent appPersistent = Select.from(AppPersistent.class).where(Condition.prop(NamingHelper.toSQLNameDefault("mIdentifier")).eq(identifier)).first();
if (appPersistent != null) {
appPersistent.setOpenCount(appPersistent.getOpenCount() + 1);
appPersistent.save();
} else {
AppPersistent newAppPersistent = new AppPersistent(packageName, name, DEFAULT_OPEN_COUNT, DEFAULT_ORDER_NUMBER, DEFAULT_APP_VISIBILITY);
newAppPersistent.save();
}
}
示例13: setAppOrderNumber
import com.orm.query.Select; //导入依赖的package包/类
public static void setAppOrderNumber(String packageName, String name, int orderNumber) {
String identifier = AppPersistent.generateIdentifier(packageName, name);
AppPersistent appPersistent = Select.from(AppPersistent.class).where(Condition.prop(NamingHelper.toSQLNameDefault("mIdentifier")).eq(identifier)).first();
if (appPersistent != null) {
appPersistent.setOrderNumber(orderNumber);
appPersistent.save();
} else {
AppPersistent newAppPersistent = new AppPersistent(packageName, name, DEFAULT_OPEN_COUNT, DEFAULT_ORDER_NUMBER, DEFAULT_APP_VISIBILITY);
newAppPersistent.save();
}
}
示例14: getAppVisibility
import com.orm.query.Select; //导入依赖的package包/类
public static boolean getAppVisibility(String packageName, String name) {
String identifier = AppPersistent.generateIdentifier(packageName, name);
AppPersistent appPersistent = Select.from(AppPersistent.class).where(Condition.prop(NamingHelper.toSQLNameDefault("mIdentifier")).eq(identifier)).first();
if (appPersistent != null) {
return appPersistent.isAppVisible();
} else {
return true;
}
}
示例15: setAppVisibility
import com.orm.query.Select; //导入依赖的package包/类
public static void setAppVisibility(String packageName, String name, boolean mHideApp) {
String identifier = AppPersistent.generateIdentifier(packageName, name);
AppPersistent appPersistent = Select.from(AppPersistent.class).where(Condition.prop(NamingHelper.toSQLNameDefault("mIdentifier")).eq(identifier)).first();
if (appPersistent != null) {
appPersistent.setAppVisible(mHideApp);
appPersistent.save();
} else {
AppPersistent newAppPersistent = new AppPersistent(packageName, name, DEFAULT_OPEN_COUNT, DEFAULT_ORDER_NUMBER, mHideApp);
newAppPersistent.save();
}
}