Merging conflict


#1

Hey guys, i am trying to merge documents together due to conflict. i read online here at the tutorial and tried to use it. http://developer.couchbase.com/documentation/mobile/current/develop/guides/couchbase-lite/native-api/document/index.html.

But i am stuck at this line.
Map<String, Object> mergedProps = mergeRevisions(conflicts);

what is this" mergeRevisions(conflicts);" it seems to me that its a method. what code is there inside this method?


#2

That’s a placeholder for whatever you are doing to actually resolve the conflict. I.e. it should produce a single set of properties that contains the appropriate merged data. The details are dependent on your app’s data model.


#3

Jens,

For example, there is phone A and phone B

Phone A creates a document and have a bitmap attachment. Rev no.#2-345
Phone A syncs to the document and attachment to the sever.

When Phone B syncs down that same particular document. Will its Rev no be the same? or they will create a totally new Rev?


#4

It’s the same revID.


#5

The reason i ask is because i am not able to get my attachment of a particular document when i replicate that document down to the phone. My code is below. I first want to retrieve the name of the photo from the document. Then i get the attachment of the document which i set as the “name.jpg”. Could you see if i am am doing anything wrong? .

Document doc = database.getDocument(Cat);
try {
String array = (String) doc.getProperty(Cat);
myObjects =mapper.readValue(array, new TypeReference<List>(){});
} catch (Exception e) {
Log.d(TAG, "Error retrieving all table… +: " + e);
}
Revision rev = doc.getCurrentRevision();
for(int i =0; i < myObjects.size();i++) {
Attachment att1 = rev.getAttachment(myObjects.get(i).getName() + “.jpg”);
InputStream is1 = null;
if (att1 != null) {
try {
is1 = att1.getContent();
BufferedInputStream bufferedInputStream1 = new BufferedInputStream(is1);
Bitmap bmp1 = BitmapFactory.decodeStream(bufferedInputStream1);
allbits.add(bmp1);
} catch (CouchbaseLiteException e1) {
e1.printStackTrace();
}
}