// Path: environment.monitor.core/src/main/java/org/yagel/monitor/ResourceStatus.java
// public interface ResourceStatus {
// 
//   Resource getResource();
// 
//   void setResource(Resource resource);
// 
//   Status getStatus();
// 
//   void setStatus(Status status);
// 
//   Date getUpdated();
// 
//   void setUpdated(Date updated);
// }


import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.in;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.yagel.monitor.ResourceStatus;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
package org.yagel.monitor.mongo;




public class ResourceLastStatusDAO extends AbstractDAO {

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


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


  /**
   * Remove all last statuses for particular environment
   * @param environmentName name of environment to remove statuses for
   */
  public void delete(String environmentName) {
    thisCollection.deleteMany(eq("environmentName", environmentName));
  }


  /**
   * Replace existing last statuses for environment by new ones
   * @param environmentName environment to update statuses
   * @param resources       new statuses to be set up
   */
// Path: environment.monitor.core/src/main/java/org/yagel/monitor/ResourceStatus.java
// public interface ResourceStatus {
// 
//   Resource getResource();
// 
//   void setResource(Resource resource);
// 
//   Status getStatus();
// 
//   void setStatus(Status status);
// 
//   Date getUpdated();
// 
//   void setUpdated(Date updated);
// }


// Path: environment.monitor.runner/src/main/java/org/yagel/monitor/mongo/ResourceLastStatusDAO.java
import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.in;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.yagel.monitor.ResourceStatus;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

package org.yagel.monitor.mongo;




public class ResourceLastStatusDAO extends AbstractDAO {

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


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


  /**
   * Remove all last statuses for particular environment
   * @param environmentName name of environment to remove statuses for
   */
  public void delete(String environmentName) {
    thisCollection.deleteMany(eq("environmentName", environmentName));
  }


  /**
   * Replace existing last statuses for environment by new ones
   * @param environmentName environment to update statuses
   * @param resources       new statuses to be set up
   */
  public synchronized void insert(final String environmentName, final Collection<ResourceStatus> resources) {