当前位置: 首页>>代码示例>>Java>>正文


Java QueryRow类代码示例

本文整理汇总了Java中com.couchbase.lite.QueryRow的典型用法代码示例。如果您正苦于以下问题:Java QueryRow类的具体用法?Java QueryRow怎么用?Java QueryRow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QueryRow类属于com.couchbase.lite包,在下文中一共展示了QueryRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchAllPostsOrderByDate

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
@Override
protected List<Post> searchAllPostsOrderByDate() {
    List<Post> postList = new ArrayList<>();
    try {
        Query query = couchDbPost.createAllDocumentsQuery();
        query.setAllDocsMode(Query.AllDocsMode.ONLY_CONFLICTS);
        QueryEnumerator result = query.run();
        for (Iterator<QueryRow> it = result; it.hasNext();) {
            QueryRow row = it.next();
            postList.add(fillPost(row.getDocument(), row.getDocumentId()));
        }
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }
    Collections.sort(postList, new PostComparator());
    return postList;
}
 
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:18,代码来源:CouchbaseLite.java

示例2: loadInBackground

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
@Override
public List<QueryRow> loadInBackground() {
	try {
		List<QueryRow> ret = new ArrayList<QueryRow>();
		QueryEnumerator enumerator = query.run();
		if (enumerator != null) { 
			while (enumerator.hasNext()) {
				QueryRow row = enumerator.next();
				ret.add(row);
			}
		}
		return ret;
	} catch (CouchbaseLiteException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:17,代码来源:DataLoader.java

示例3: getContactDocumentByEmail

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public Document getContactDocumentByEmail(String email) {
    Query query = contactView.createQuery();
    query.setStartKey(email);
    query.setEndKey(email);
    QueryEnumerator enumerator;
    try {
        enumerator = query.run();
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    Document ret = null;
    if (enumerator.hasNext()) {
        QueryRow row = enumerator.next();
        ret = row.getDocument();
    }
    return ret;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:18,代码来源:DataServiceImpl.java

示例4: getMessagesByGame

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public List<Document> getMessagesByGame(String modelId) {
    Query query = messageByGameView.createQuery();
    query.setStartKey(modelId);
    query.setEndKey(modelId);
    QueryEnumerator enumerator;
    try {
        enumerator = query.run();
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    List<Document> ret = new ArrayList<>();
    while (enumerator.hasNext()) {
        QueryRow row = enumerator.next();
        ret.add(row.getDocument());
    }
    Collections.sort(ret, new Comparator<Document>() {
        @Override
        public int compare(Document left, Document right) {
            return ((String) left.getProperty("id")).compareTo((String) right.getProperty("id"));
        }
    });
    return ret;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:24,代码来源:DataServiceImpl.java

示例5: getGameDocumentByModelId

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public Document getGameDocumentByModelId(String id) {
    Query query = gameView.createQuery();
    query.setStartKey(id);
    query.setEndKey(id);
    query.setEndKey(id);
    QueryEnumerator enumerator;
    try {
        enumerator = query.run();
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    Document ret = null;
    if (enumerator.hasNext()) {
        QueryRow row = enumerator.next();
        ret = row.getDocument();
    }
    return ret;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:19,代码来源:DataServiceImpl.java

示例6: getGamesByContactQuery

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public Query getGamesByContactQuery(String email) {
    final Query gameQueryByContact = gameIdsByContactView.createQuery();
    gameQueryByContact.setStartKey(email);
    gameQueryByContact.setEndKey(email);
    gameQueryByContact.setDescending(true);
    gameQueryByContact.setGroupLevel(1);

    Query gameQuery = gameView.createQuery();
    try {
        List<Object> keys = Collections.emptyList();
        if (gameQueryByContact != null) {
            QueryEnumerator run = gameQueryByContact.run();
            if (run != null) {
                QueryRow next = run.next();
                if (next != null) {
                    keys = (List<Object>) next.getValue();
                }
            }
        }
        gameQuery.setKeys(keys);
    } catch (CouchbaseLiteException e) {
        throw new RuntimeException(e);
    }
    return gameQuery;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:26,代码来源:DataServiceImpl.java

示例7: startLiveQuery

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public void startLiveQuery() {
    View airportsView = mDatabase.getView(AIRPORTS_VIEW);
    LiveQuery liveQuery = airportsView.createQuery().toLiveQuery();
    liveQuery.setDescending(false);

    liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
        @Override
        public void changed(LiveQuery.ChangeEvent event) {
            List<Airport> airports = new ArrayList<>();
            for (Iterator<QueryRow> it = event.getRows(); it.hasNext(); ) {
                QueryRow row = it.next();

                airports.add(new Airport((LazyJsonObject) row.getValue()));
            }

            if (mAirportsListener != null) {
                mAirportsListener.onChanged(airports);
            }
        }
    });

    liveQuery.start();
}
 
开发者ID:Ryanair,项目名称:resource-sync-example,代码行数:24,代码来源:StorageManager.java

示例8: startLiveQuery

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
private void startLiveQuery() {

        if (liveQuery == null) {

            liveQuery = viewItemsByDate.createQuery().toLiveQuery();

            liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
                public void changed(final LiveQuery.ChangeEvent event) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            kitchenSyncArrayAdapter.clear();
                            for (Iterator<QueryRow> it = event.getRows(); it.hasNext();) {
                                kitchenSyncArrayAdapter.add(it.next());
                            }
                            kitchenSyncArrayAdapter.notifyDataSetChanged();
                        }
                    });
                }
            });

            liveQuery.start();

        }

    }
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:26,代码来源:MainActivity.java

示例9: onItemClick

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
/**
 * Handle click on item in list
 */
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {

    // Step 10 code goes here
    // This code handles checkbox touches.  Couchbase Lite documents are like versioned-maps.
    // To change a Document, add a new Revision.
    QueryRow row = (QueryRow) adapterView.getItemAtPosition(position);
    Document document = row.getDocument();
    Map<String, Object> newProperties = new HashMap<String, Object>(document.getProperties());

    boolean checked = ((Boolean) newProperties.get("check")).booleanValue();
    newProperties.put("check", !checked);

    try {
        document.putProperties(newProperties);
        kitchenSyncArrayAdapter.notifyDataSetChanged();
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), "Error updating database, see logs for details", Toast.LENGTH_LONG).show();
        Log.e(TAG, "Error updating database", e);
    }

}
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:25,代码来源:MainActivity.java

示例10: queryCities

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
private void queryCities() {
    final Query query = database.getView(CITIES_VIEW).createQuery();
    query.setGroupLevel(1);

    LiveQuery liveQuery = query.toLiveQuery();
    liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
        @Override
        public void changed(LiveQuery.ChangeEvent event) {
            try {
                QueryEnumerator enumeration = query.run();
                for (QueryRow row : enumeration) {
                    Log.d("CityExplorer", "Row is " + row.getValue() + " and key " + row.getKey());
                }

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

    liveQuery.start();
}
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:23,代码来源:SyncManager.java

示例11: onBindViewHolder

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
/**
 * Use the position to get the corresponding query row and populate the ViewHolder that
 * was created above.
 * @param holder
 * @param position
 */
@Override
public void onBindViewHolder(ViewHolder holder, int position) {

    final QueryRow row = (QueryRow) getItem(position);

    /** TODO: This is a hack to populate the result of the ratings or conflicts view query,
     ** have two different recycler view adapters instead. */
    holder.ratingValue.setText(String.valueOf(row.getKey()));
    if (row.getValue() == null) {
        try {
            int conflicts = row.getDocument().getConflictingRevisions().size();
            holder.totalRatings.setText(String.valueOf(conflicts - 1));
        } catch (CouchbaseLiteException e) {
            e.printStackTrace();
        }

    } else {
        holder.totalRatings.setText(String.valueOf(row.getValue()));
    }
}
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:27,代码来源:RatingsAdapter.java

示例12: initializePuzzleTypes

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
@NonNull
private static Completable initializePuzzleTypes(Context context, Database database) {
    return Completable.create(completableSubscriber -> {
        Query puzzleTypesQuery = database.getView(VIEW_PUZZLETYPES).createQuery();
        puzzleTypesQuery.runAsync((rows, error) -> {
            if (!rows.hasNext()) {
                try {
                    initializeFirstRun(context);
                    completableSubscriber.onCompleted();
                } catch (CouchbaseLiteException | IOException e) {
                    completableSubscriber.onError(e);
                }
            } else {
                List<PuzzleType> puzzleTypes = new ArrayList<>();
                for (QueryRow row : rows) {
                    PuzzleType type = PuzzleType.fromDoc(row.getDocument(), PuzzleType.class);
                    puzzleTypes.add(type);
                }

                sPuzzleTypes = puzzleTypes;

                completableSubscriber.onCompleted();
            }
        });
    }).subscribeOn(Schedulers.io());
}
 
开发者ID:plusCubed,项目名称:plusTimer,代码行数:27,代码来源:PuzzleType.java

示例13: initialize_firstRunPreCouchbase

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
@Test
public void initialize_firstRunPreCouchbase() throws CouchbaseLiteException, IOException {
    Context context = InstrumentationRegistry.getTargetContext();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    preferences.edit().putInt("pref_version_code", 23).apply();

    PuzzleType.initialize(context);

    Query puzzleTypesQuery = App.getDatabase(context).getView("puzzletypes").createQuery();
    QueryEnumerator rows = puzzleTypesQuery.run();
    for (QueryRow row : rows) {
        Log.d("Test", row.getDocument().getUserProperties().toString());

        //Actual stuff to test?
    }
}
 
开发者ID:plusCubed,项目名称:plusTimer,代码行数:18,代码来源:PuzzleTypeTest.java

示例14: deleteList

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
private void deleteList(final Document list) {
    Application application = (Application) getApplication();
    final Query query = application.getTasksView().createQuery();
    query.setDescending(true);

    List<Object> startKeys = new ArrayList<Object>();
    startKeys.add(list.getId());
    startKeys.add(new HashMap<String, Object>());

    List<Object> endKeys = new ArrayList<Object>();
    endKeys.add(list.getId());

    query.setStartKey(startKeys);
    query.setEndKey(endKeys);

    mDatabase.runInTransaction(new TransactionalTask() {
        @Override
        public boolean run() {
            try {
                QueryEnumerator tasks = query.run();
                while (tasks.hasNext()) {
                    QueryRow task = tasks.next();
                    task.getDocument().getCurrentRevision().deleteDocument();
                }
                list.delete();
            } catch (CouchbaseLiteException e) {
                Log.e(Application.TAG, "Cannot delete list", e);
                return false;
            }
            return true;
        }
    });
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:34,代码来源:ListActivity.java

示例15: migrateGuestData

import com.couchbase.lite.QueryRow; //导入依赖的package包/类
public static boolean migrateGuestData(final Database guestDb, final Document profile) {
    boolean success = true;
    final Database userDB = profile.getDatabase();
    if (guestDb.getLastSequenceNumber() > 0 && userDB.getLastSequenceNumber() == 0) {
        success = userDB.runInTransaction(new TransactionalTask() {
            @Override
            public boolean run() {
                try {
                    QueryEnumerator rows = guestDb.createAllDocumentsQuery().run();
                    for (QueryRow row : rows) {
                        Document doc = row.getDocument();
                        Document newDoc = userDB.getDocument(doc.getId());
                        newDoc.putProperties(doc.getUserProperties());

                        List<Attachment> attachments = doc.getCurrentRevision().getAttachments();
                        if (attachments.size() > 0) {
                            UnsavedRevision rev = newDoc.getCurrentRevision().createRevision();
                            for (Attachment attachment : attachments) {
                                rev.setAttachment(
                                        attachment.getName(),
                                        attachment.getContentType(),
                                        attachment.getContent());
                            }
                            rev.save();
                        }
                    }
                    // Delete guest database:
                    guestDb.delete();
                } catch (CouchbaseLiteException e) {
                    Log.e(Application.TAG, "Error when migrating guest data to user", e);
                    return false;
                }
                return true;
            }
        });
    }
    return success;
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:39,代码来源:UserProfile.java


注:本文中的com.couchbase.lite.QueryRow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。