本文整理汇总了Java中com.raizlabs.android.dbflow.sql.language.Select类的典型用法代码示例。如果您正苦于以下问题:Java Select类的具体用法?Java Select怎么用?Java Select使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Select类属于com.raizlabs.android.dbflow.sql.language包,在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateRecipe
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
@Test
public void testUpdateRecipe() throws Exception {
String newRecipeId = "id1";
String titleBefore = "title before update";
String titleAfter = "title after update";
Recipe recipe = new Recipe();
recipe.setRecipeId(newRecipeId);
recipe.setTitle(titleBefore);
recipe.save();
recipe.setTitle(titleAfter);
repository.updateRecipe(recipe);
Recipe recipeFromDB = new Select()
.from(Recipe.class)
.where(Recipe_Table.recipeId.is(newRecipeId))
.querySingle();
assertEquals(titleAfter, recipeFromDB.getTitle());
verify(eventBus).post(recipeListEventArgumentCaptor.capture());
RecipeListEvent event = recipeListEventArgumentCaptor.getValue();
assertEquals(RecipeListEvent.UPDATE_EVENT, event.getType());
recipe.delete();
}
示例2: getMarketGroupsForParent
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public static ArrayList<MarketGroup> getMarketGroupsForParent(Long parentId) {
Condition condition = parentId != null ? MarketGroupEntry_Table.parentId.eq(parentId) :
MarketGroupEntry_Table.parentId.isNull();
List<MarketGroupEntry> groups = new Select()
.from(MarketGroupEntry.class)
.where(condition)
.orderBy(OrderBy.fromProperty(MarketGroupEntry_Table.name).ascending())
.queryList();
ArrayList<MarketGroup> builtGroups = new ArrayList<>(groups.size());
for (MarketGroupEntry entry : groups) {
builtGroups.add(buildMarketGroup(entry));
}
return builtGroups;
}
示例3: getRecentlyPlayed
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public List<EpisodeBaseModel> getRecentlyPlayed() {
FlowCursorList<PlayHistory> cursor = new FlowCursorList<>(false,
(new Select()).from(PlayHistory.class)
.orderBy("CASE WHEN "+PlayHistory$Table.PROGRESS+" >= 75 THEN 1 ELSE 0 END ASC, "+PlayHistory$Table.TIMESTAMP+" DESC")
.limit(30));
List<EpisodeBaseModel> recent = new ArrayList<>();
for (int i = 0, k = cursor.getCount(); i < k; i++) {
PlayHistory history = cursor.getItem(i);
EpisodeBaseModel ep = getEpisode(history.href);
if (ep != null) {
if (history.progress < 75) {
ep.setResumePosition(history.position);
}
ep.setRecent(true);
recent.add(ep);
}
}
return recent;
}
示例4: findProgramUIDByDataElementUID
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
/**
* Find the associated program given a dataelement UID
*
* @param dataElementUID
* @return
*/
public static String findProgramUIDByDataElementUID(String dataElementUID) {
//Find the right 'uid' of the dataelement program
Program program = new Select().from(Program.class).as("p")
.join(ProgramStage.class, Join.JoinType.LEFT).as("ps")
.on(Condition.column(ColumnAlias.columnWithTable("p", Program$Table.ID))
.eq(ColumnAlias.columnWithTable("ps", ProgramStage$Table.PROGRAM)))
.join(ProgramStageDataElement.class, Join.JoinType.LEFT).as("psd")
.on(Condition.column(ColumnAlias.columnWithTable("psd", ProgramStageDataElement$Table.PROGRAMSTAGE))
.eq(ColumnAlias.columnWithTable("ps", ProgramStage$Table.ID)))
.where(Condition.column(ColumnAlias.columnWithTable("psd", ProgramStageDataElement$Table.DATAELEMENT)).eq(dataElementUID))
.querySingle();
if (program == null) {
return null;
}
return program.getUid();
}
示例5: findProgramStageSection
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
/**
* Find the associated programStageSection (tab)UID given a dataelement UID
*
* @return
*/
public String findProgramStageSection() {
List<ProgramStageSection> programStageSections = new Select().from(ProgramStageSection.class).as("pss")
.join(ProgramStageDataElement.class, Join.JoinType.LEFT).as("psde")
.on(Condition.column(ColumnAlias.columnWithTable("pss", ProgramStageSection$Table.ID))
.eq(ColumnAlias.columnWithTable("psde", ProgramStageDataElement$Table.PROGRAMSTAGESECTION)))
.where(Condition.column(ColumnAlias.columnWithTable("psde", ProgramStageDataElement$Table.DATAELEMENT)).eq(getDataElement().getUid()))
.queryList();
if (programStageSections == null) {
return null;
}
for(ProgramStageSection programStageSection:programStageSections){
if(MetaDataController.getProgramStage(programStageSection.getProgramStage()).getProgram().getUid().equals(programUid))
return programStageSection.getUid();
}
return null;
}
示例6: prepareSurveyInfo
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
/**
* Prepares required data to show a survey completely (tabs and composite scores).
*/
private void prepareSurveyInfo(String module){
Log.d(TAG, "prepareSurveyInfo (Thread:" + Thread.currentThread().getId() + ")");
//register composite scores for current survey and module
List<CompositeScore> compositeScores = CompositeScore.list();
Survey survey = Session.getSurveyByModule(module);
ScoreRegister.registerCompositeScores(compositeScores,survey.getId_survey(),module);
//Get tabs for current program & register them (scores)
List<Tab> tabs = Tab.getTabsBySession(module);
List<Tab> allTabs = new Select().all().from(Tab.class).where(Condition.column(Tab$Table.ID_PROGRAM).eq(survey.getProgram().getId_program())).queryList();
//register tabs scores for current survey and module
ScoreRegister.registerTabScores(tabs, survey.getId_survey(), module);
//Since intents does NOT admit NON serializable as values we use Session instead
Session.putServiceValue(PREPARE_SURVEY_ACTION_COMPOSITE_SCORES, compositeScores);
Session.putServiceValue(PREPARE_SURVEY_ACTION_TABS, tabs);
Session.putServiceValue(PREPARE_ALL_TABS, allTabs);
//Returning result to anyone listening
Intent resultIntent = new Intent(PREPARE_SURVEY_ACTION);
LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
示例7: onCreate
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create organization
Organization organization = new Organization();
organization.setId(1);
organization.setName("ApricotLabs");
organization.save();
// Create user
User user = new User();
user.setName("Nikhil Bhutani");
user.setOrganization(organization);
user.save();
Organization org = new Select().from(Organization.class)
.where(Organization_Table.id.eq(1))
.querySingle();
System.out.println(org.getName());
System.out.println(user.getName());
}
示例8: findOrganisationUnitAttributeValueByCode
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
/**
* Finds the value of an attribute with the given code in a dataElement
* @param code
* @return
*/
public String findOrganisationUnitAttributeValueByCode(String code){
OrganisationUnitAttributeValue organisationUnitAttributeValue = new Select().from(OrganisationUnitAttributeValue.class).as("o")
.join(Attribute.class, Join.JoinType.LEFT).as("a")
.on(Condition.column(ColumnAlias.columnWithTable("o", OrganisationUnitAttributeValue$Table.ATTRIBUTEID))
.eq(ColumnAlias.columnWithTable("a", Attribute$Table.ID)))
.where(Condition.column(ColumnAlias.columnWithTable("a", Attribute$Table.CODE))
.eq(code))
.and(Condition.column(ColumnAlias.columnWithTable("o", OrganisationUnitAttributeValue$Table.ORGANISATIONUNIT)).is(this.getOrgUnit().getId()))
.querySingle();
if(organisationUnitAttributeValue==null){
return "";
}
return organisationUnitAttributeValue.getValue();
}
示例9: listAllByTabsWithoutCs
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public static List<Question> listAllByTabsWithoutCs(List<Tab> tabs) {
if (tabs == null || tabs.size() == 0) {
return new ArrayList();
}
Iterator<Tab> iterator = tabs.iterator();
In in = Condition.column(ColumnAlias.columnWithTable("t", Tab$Table.ID_TAB)).in(Long.toString(iterator.next().getId_tab()));
while (iterator.hasNext()) {
in.and(Long.toString(iterator.next().getId_tab()));
}
return new Select().from(Question.class).as("q")
.join(Header.class, Join.JoinType.LEFT).as("h")
.on(Condition.column(ColumnAlias.columnWithTable("q", Question$Table.ID_HEADER))
.eq(ColumnAlias.columnWithTable("h", Header$Table.ID_HEADER)))
.join(Tab.class, Join.JoinType.LEFT).as("t")
.on(Condition.column(ColumnAlias.columnWithTable("h", Header$Table.ID_TAB))
.eq(ColumnAlias.columnWithTable("t", Tab$Table.ID_TAB)))
.where(in)
.and(Condition.column(Question$Table.ID_COMPOSITE_SCORE).isNull())
.orderBy(Tab$Table.ORDER_POS)
.orderBy(Question$Table.ORDER_POS).queryList();
}
示例10: getProductivityPosition
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public Integer getProductivityPosition() {
ProgramAttributeValue programAttributeValue = new Select().from(ProgramAttributeValue.class).as("p")
.join(Attribute.class, Join.JoinType.LEFT).as("a")
.on(Condition.column(ColumnAlias.columnWithTable("p", ProgramAttributeValue$Table.ATTRIBUTEID))
.eq(ColumnAlias.columnWithTable("a", Attribute$Table.ID)))
.where(Condition.column(ColumnAlias.columnWithTable("a", Attribute$Table.CODE))
.eq(PROGRAM_PRODUCTIVITY_POSITION_ATTRIBUTE_CODE))
.and(Condition.column(ColumnAlias.columnWithTable("p", ProgramAttributeValue$Table.PROGRAM)).is(this.getProgram().getUid()))
.querySingle();
if(programAttributeValue==null){
return null;
}
try {
return Integer.parseInt(programAttributeValue.getValue());
}catch(Exception ex){
Log.e(TAG, String.format("getProductivityPosition(%s) -> %s", this.getProgram().getUid(), ex.getMessage()));
return null;
}
}
示例11: getProductivity
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
/**
* Helper method to get the productivity for a given survey.
* If its orgunit + program combination does NOT have a productivity value then returns 0
* @param survey
* @return
*/
public static Integer getProductivity(Survey survey){
if(survey==null){
return DEFAULT_PRODUCTIVITY;
}
OrgUnit orgUnit = survey.getOrgUnit();
if(orgUnit==null){
return DEFAULT_PRODUCTIVITY;
}
Program program = survey.getProgram();
if(program==null){
return DEFAULT_PRODUCTIVITY;
}
OrgUnitProgramRelation orgUnitProgramRelation = new Select().from(OrgUnitProgramRelation.class)
.where(Condition.column(OrgUnitProgramRelation$Table.ID_ORG_UNIT).eq(orgUnit.getId_org_unit()))
.and(Condition.column(OrgUnitProgramRelation$Table.ID_PROGRAM).eq(program.getId_program())).querySingle();
if(orgUnitProgramRelation==null){
return DEFAULT_PRODUCTIVITY;
}
return orgUnitProgramRelation.getProductivity();
}
示例12: getFun_Girly
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public static List<Results> getFun_Girly() {
List<Results> results = new ArrayList<>();
List<GirlyDbBean> girlyDbBeen = new Select().from(GirlyDbBean.class).queryList();
for (int i = 0; i < girlyDbBeen.size(); i++) {
Results result = new Results();
result.setWho(girlyDbBeen.get(i).who);
result.setPublishedAt(girlyDbBeen.get(i).publishedAt);
result.setDesc(girlyDbBeen.get(i).desc);
result.setType(girlyDbBeen.get(i).type);
result.setUrl(girlyDbBeen.get(i).url);
result.setUsed(girlyDbBeen.get(i).used);
result.set_id(girlyDbBeen.get(i).objectId);
result.setCreatedAt(girlyDbBeen.get(i).createdAt);
results.add(result);
}
return results;
}
示例13: getFun_Part
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public static List<Results> getFun_Part() {
List<Results> results = new ArrayList<>();
List<PartDbBean> partDbBeen = new Select().from(PartDbBean.class).queryList();
for (int i = 0; i < partDbBeen.size(); i++) {
Results result = new Results();
result.setWho(partDbBeen.get(i).who);
result.setPublishedAt(partDbBeen.get(i).publishedAt);
result.setDesc(partDbBeen.get(i).desc);
result.setType(partDbBeen.get(i).type);
result.setUrl(partDbBeen.get(i).url);
result.setUsed(partDbBeen.get(i).used);
result.set_id(partDbBeen.get(i).objectId);
result.setCreatedAt(partDbBeen.get(i).createdAt);
results.add(result);
}
return results;
}
示例14: getFun_Real
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
public static List<List<Results>> getFun_Real() {
List<RealDbBean> realDbBeen = new Select().from(RealDbBean.class).queryList();
List<List<Results>> results_list = new ArrayList<>();
for (int i = 0; i < realDbBeen.size() / 3; i++) {
List<Results> results = new ArrayList<>();
for (int j = 0; j < 3; j++) {
int k= 3*i+j;
Results result = new Results();
result.setWho(realDbBeen.get(k).who);
result.setPublishedAt(realDbBeen.get(k).publishedAt);
result.setDesc(realDbBeen.get(k).desc);
result.setType(realDbBeen.get(k).type);
result.setUrl(realDbBeen.get(k).url);
result.setUsed(realDbBeen.get(k).used);
result.set_id(realDbBeen.get(k).objectId);
result.setCreatedAt(realDbBeen.get(k).createdAt);
results.add(result);
}
results_list.add(results);
}
return results_list;
}
示例15: onInsert
import com.raizlabs.android.dbflow.sql.language.Select; //导入依赖的package包/类
@Test
public void onInsert() {
UserModel people = new UserModel();
people.name = "张三";
people.sex = 1;
people.save();// 添加对象,一条一条保存
Assert.assertEquals(1, new Select(Method.count()).from(UserModel.class).count());
}