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


Java CouchbaseLiteException类代码示例

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


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

示例1: create

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private ListEntity create(String title) throws CouchbaseLiteException {
    String currentTimeString = mDateFormatter.format(new Date());

    ListEntity mList = ListEntity.create().
            setCreatedAt(currentTimeString).
            setMembers(new ArrayList<String>()).setTitle(title);
    mList.setSub(SubEntity.create().setTest("test"));
    ArrayList<SubEntity> sub = new ArrayList<>();
    sub.add(SubEntity.create().setTest("rs"));
    mList.setListSub(sub);

    Application application = (Application) getApplication();
    String userId = application.getCurrentUserId();
    if (userId != null)
        mList.setOwner("p:" + userId);

    mList.save();

    return mList;
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:21,代码来源:ListActivity.java

示例2: loginAsFacebookUser

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
public void loginAsFacebookUser(Activity activity, String token, String userId, String name) {
    setCurrentUserId(userId);
    setDatabase(getUserDatabase(userId));

    String profileDocID = "p:" + userId;
    Document profile = mDatabase.getExistingDocument(profileDocID);
    if (profile == null) {
        try {
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put("type", "profile");
            properties.put("user_id", userId);
            properties.put("name", name);

            profile = mDatabase.getDocument(profileDocID);
            profile.putProperties(properties);

            // Migrate guest data to user:
            UserProfile.migrateGuestData(getUserDatabase(GUEST_DATABASE_NAME), profile);
        } catch (CouchbaseLiteException e) {
            Log.e(TAG, "Cannot create a new user profile", e);
        }
    }

    startReplication(AuthenticatorFactory.createFacebookAuthenticator(token));
    login(activity);
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:27,代码来源:Application.java

示例3: addMember

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private void addMember(Document user) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(mList.getProperties());

    List<String> members = (List<String>) properties.get("members");
    if (members == null) {
        members = new ArrayList<String>();
        properties.put("members", members);
    }
    members.add(user.getId());

    try {
        mList.putProperties(properties);
    } catch (CouchbaseLiteException e) {
        Log.e(Application.TAG, "Cannot add member to the list", e);
    }
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:18,代码来源:ShareActivity.java

示例4: createTask

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private void createTask(String title, Bitmap image, String listId) {
    String currentTimeString = mDateFormatter.format(new Date());

    TaskEntity task = TaskEntity.create()
            .setType("task")
            .setCreatedAt(currentTimeString)
            .setTitle(title)
            .setChecked(Boolean.FALSE)
            .setListId(listId);

    if (image != null) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        image.compress(Bitmap.CompressFormat.JPEG, 50, out);
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        task.setImage(in);
    }

    try {
        task.save();
    } catch (CouchbaseLiteException e) {
        Log.e(Application.TAG, "Cannot create new task", e);
    }
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:24,代码来源:TaskActivity.java

示例5: attachImage

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private void attachImage(TaskEntity task, Bitmap image) {
    if (task == null || image == null) return;



    ByteArrayOutputStream out = new ByteArrayOutputStream();
    image.compress(Bitmap.CompressFormat.JPEG, 50, out);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    task.setImage(in);

    try {
        task.save();
    } catch (CouchbaseLiteException e) {
        Log.e(Application.TAG, "Cannot attach image", e);
    }
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:17,代码来源:TaskActivity.java

示例6: searchAllPostsOrderByDate

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例7: loadInBackground

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例8: getContactDocumentByEmail

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例9: getMessagesByGame

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例10: getGameDocumentByModelId

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例11: getGamesByContactQuery

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的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

示例12: addObjects

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private void addObjects() {
    for (int row = 0; row < numberOfObjects; row++) {
        final int testRow = row;
        database.runInTransaction(new TransactionalTask() {
            @Override
            public boolean run() {
                Document document = database.createDocument();
                Map<String, Object> docContent = new HashMap<String, Object>();
                docContent.put("id", testRow);
                docContent.put("name", dataGenerator.getEmployeeName(testRow));
                docContent.put("age", dataGenerator.getEmployeeAge(testRow));
                docContent.put("hired", dataGenerator.getHiredBool(testRow));
                try {
                    document.putProperties(docContent);
                } catch (CouchbaseLiteException e) {
                    throw new RuntimeException("Cannot add object to CouchBase Lite.");
                }
                return true;
            }
        });
    }
}
 
开发者ID:realm,项目名称:realm-java-benchmarks,代码行数:23,代码来源:TestCouch.java

示例13: saveContactInfo

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private boolean saveContactInfo(String firstName, String lastName, String phoneNumber) {
    Document document = mDatabase.getDocument(CONTACT_INFO_DOCUMENT_ID);

    Map<String, Object> properties = new HashMap();
    properties.put(FIELD_FIRST_NAME, firstName);
    properties.put(FIELD_LAST_NAME, lastName);
    properties.put(FIELD_PHONE_NUMBER, phoneNumber);
    try {
        document.putProperties(properties);
        return true;
    } catch (CouchbaseLiteException e) {
        Log.e(TAG, "Cannot save document", e);
        return false;
    }

}
 
开发者ID:trinhlbk1991,项目名称:DemoCouchbaseLite,代码行数:17,代码来源:FirstDemoActivity.java

示例14: updateContactInfo

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private boolean updateContactInfo(String firstName, String lastName, String phoneNumber) {
    Document document = mDatabase.getDocument(CONTACT_INFO_DOCUMENT_ID);

    Map<String, Object> properties = new HashMap();
    properties.putAll(document.getProperties());
    properties.put(FIELD_FIRST_NAME, firstName);
    properties.put(FIELD_LAST_NAME, lastName);
    properties.put(FIELD_PHONE_NUMBER, phoneNumber);
    try {
        document.putProperties(properties);
        return true;
    } catch (CouchbaseLiteException e) {
        Log.e(TAG, "Cannot save document", e);
        return false;
    }

}
 
开发者ID:trinhlbk1991,项目名称:DemoCouchbaseLite,代码行数:18,代码来源:FirstDemoActivity.java

示例15: saveAvatar

import com.couchbase.lite.CouchbaseLiteException; //导入依赖的package包/类
private void saveAvatar() {
    Document doc = mDatabase.getDocument(CONTACT_INFO_DOCUMENT_ID);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Bitmap bitmap = ((BitmapDrawable) mImgAvatar.getDrawable()).getBitmap();
    bitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, bos);
    byte[] bitmapdata = bos.toByteArray();
    ByteArrayInputStream bs = new ByteArrayInputStream(bitmapdata);

    try {
        UnsavedRevision newRev = doc.getCurrentRevision().createRevision();
        newRev.setAttachment("avatar.jpg", "image/jpeg", bs);
        newRev.save();
    } catch (CouchbaseLiteException e) {
        Log.e(TAG, "Cannot save attachment", e);
    }
}
 
开发者ID:trinhlbk1991,项目名称:DemoCouchbaseLite,代码行数:17,代码来源:FirstDemoActivity.java


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