// Path: src/main/java/at/grahsl/kafka/connect/mongodb/cdc/CdcOperation.java
// public interface CdcOperation {
// 
//     WriteModel<BsonDocument> perform(SinkDocument doc);
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/cdc/debezium/OperationType.java
// public enum OperationType {
// 
//     CREATE("c"),
//     READ("r"),
//     UPDATE("u"),
//     DELETE("d");
// 
//     private final String text;
// 
//     OperationType(String text) {
//         this.text = text;
//     }
// 
//     String type() {
//         return this.text;
//     }
// 
//     public static OperationType fromText(String text) {
//         switch(text) {
//             case "c": return CREATE;
//             case "r": return READ;
//             case "u": return UPDATE;
//             case "d": return DELETE;
//             default:
//                 throw new IllegalArgumentException(
//                         "error: unknown operation type " + text
//                 );
//         }
//     }
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }


import at.grahsl.kafka.connect.mongodb.cdc.CdcOperation;
import at.grahsl.kafka.connect.mongodb.cdc.debezium.OperationType;
import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import com.mongodb.client.model.ReplaceOneModel;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import org.apache.kafka.connect.errors.DataException;
import org.bson.BsonDocument;
/*
 * Copyright (c) 2017. Hans-Peter Grahsl (grahslhp@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package at.grahsl.kafka.connect.mongodb.cdc.debezium.rdbms;


public class RdbmsUpdate implements CdcOperation {

    private static final UpdateOptions UPDATE_OPTIONS =
            new UpdateOptions().upsert(true);

// Path: src/main/java/at/grahsl/kafka/connect/mongodb/cdc/CdcOperation.java
// public interface CdcOperation {
// 
//     WriteModel<BsonDocument> perform(SinkDocument doc);
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/cdc/debezium/OperationType.java
// public enum OperationType {
// 
//     CREATE("c"),
//     READ("r"),
//     UPDATE("u"),
//     DELETE("d");
// 
//     private final String text;
// 
//     OperationType(String text) {
//         this.text = text;
//     }
// 
//     String type() {
//         return this.text;
//     }
// 
//     public static OperationType fromText(String text) {
//         switch(text) {
//             case "c": return CREATE;
//             case "r": return READ;
//             case "u": return UPDATE;
//             case "d": return DELETE;
//             default:
//                 throw new IllegalArgumentException(
//                         "error: unknown operation type " + text
//                 );
//         }
//     }
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }


// Path: src/main/java/at/grahsl/kafka/connect/mongodb/cdc/debezium/rdbms/RdbmsUpdate.java
import at.grahsl.kafka.connect.mongodb.cdc.CdcOperation;
import at.grahsl.kafka.connect.mongodb.cdc.debezium.OperationType;
import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import com.mongodb.client.model.ReplaceOneModel;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import org.apache.kafka.connect.errors.DataException;
import org.bson.BsonDocument;

/*
 * Copyright (c) 2017. Hans-Peter Grahsl (grahslhp@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package at.grahsl.kafka.connect.mongodb.cdc.debezium.rdbms;


public class RdbmsUpdate implements CdcOperation {

    private static final UpdateOptions UPDATE_OPTIONS =
            new UpdateOptions().upsert(true);

    @Override