// Path: environment.monitor.runner/src/main/java/org/yagel/monitor/mongo/DocumentMapper.java
// public static Document resourceToDocument(Resource resource) {
//   return new Document("_id", resource.getId()).append("name", resource.getName());
// }
// 
// Path: environment.monitor.core/src/main/java/org/yagel/monitor/Resource.java
// public interface Resource {
// 
//   String getId();
// 
//   String getName();
// 
// }


import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.in;
import static org.yagel.monitor.mongo.DocumentMapper.resourceToDocument;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.ReplaceOneModel;
import com.mongodb.client.model.UpdateOptions;
import org.bson.Document;
import org.yagel.monitor.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
package org.yagel.monitor.mongo;




public class ResourceDAO extends AbstractDAO {

  private final static String COLLECTION_NAME = "Resources";
  private MongoCollection<Document> thisCollection;

  public ResourceDAO(MongoDatabase db) {
    super(db);
    thisCollection = db.getCollection(COLLECTION_NAME);
  }


  /**
   * Inserts new resource to DB, or else updates existing resource description if existing ID was used
   *
   * @param resource resource to be upserted
   */
  public synchronized void insert(Resource resource) {
    this.thisCollection.replaceOne(
        eq("_id", resource.getId()),
// Path: environment.monitor.runner/src/main/java/org/yagel/monitor/mongo/DocumentMapper.java
// public static Document resourceToDocument(Resource resource) {
//   return new Document("_id", resource.getId()).append("name", resource.getName());
// }
// 
// Path: environment.monitor.core/src/main/java/org/yagel/monitor/Resource.java
// public interface Resource {
// 
//   String getId();
// 
//   String getName();
// 
// }


// Path: environment.monitor.runner/src/main/java/org/yagel/monitor/mongo/ResourceDAO.java
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.in;
import static org.yagel.monitor.mongo.DocumentMapper.resourceToDocument;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.ReplaceOneModel;
import com.mongodb.client.model.UpdateOptions;
import org.bson.Document;
import org.yagel.monitor.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

package org.yagel.monitor.mongo;




public class ResourceDAO extends AbstractDAO {

  private final static String COLLECTION_NAME = "Resources";
  private MongoCollection<Document> thisCollection;

  public ResourceDAO(MongoDatabase db) {
    super(db);
    thisCollection = db.getCollection(COLLECTION_NAME);
  }


  /**
   * Inserts new resource to DB, or else updates existing resource description if existing ID was used
   *
   * @param resource resource to be upserted
   */
  public synchronized void insert(Resource resource) {
    this.thisCollection.replaceOne(
        eq("_id", resource.getId()),
        resourceToDocument(resource),