// Path: src/main/java/net/nextpulse/jadmin/FormPostEntry.java
// public class FormPostEntry {
//   
//   /**
//    * Key value(s) for this post entry, i.e. the object id, non-editable values.
//    */
//   private LinkedHashMap<String, String> keyValues = new LinkedHashMap<>();
//   /**
//    * Editable values of a resource, i.e. an editable name field.
//    */
//   private LinkedHashMap<String, String> values = new LinkedHashMap<>();
//   
//   public FormPostEntry() {
//   }
//   
//   /**
//    * @return map of unescaped post values
//    */
//   public LinkedHashMap<String, String> getValues() {
//     return values;
//   }
//   
//   public void addValue(String columnName, String value) {
//     values.put(columnName, value);
//   }
//   
//   /**
//    * @return map of unescaped values that make up the identifier of this row
//    */
//   public LinkedHashMap<String, String> getKeyValues() {
//     return keyValues;
//   }
//   
//   /**
//    * Adds a new user supplied value for the specified column.
//    *
//    * @param columnName column name
//    * @param value      user provided value
//    */
//   public void addKeyValue(String columnName, String value) {
//     keyValues.put(columnName, value);
//   }
//   
//   /**
//    * Returns a Map with column keys linked to the submitted values.
//    *
//    * @return this entry as map of column name to value
//    */
//   public Map<String, String> toPropertiesMap() {
//     LinkedHashMap<String, String> output = new LinkedHashMap<>();
//     output.putAll(keyValues);
//     output.putAll(values);
//     return output;
//   }
// }


import net.nextpulse.jadmin.FormPostEntry;
import java.util.*;
import java.util.stream.Collectors;
package net.nextpulse.jadmin.dao;



/**
 * Example DAO that provides access to an in-memory representation of objects, which are kept in insertion order.
 * May be used for testing purposes or as an example implementation.
 *
 * @author yholkamp
 */
public class InMemoryDAO extends AbstractDAO {
  
  private LinkedHashMap<DatabaseEntryKey, DatabaseEntry> objects = new LinkedHashMap<>();
  
  /**
   * Generic compare function for two objects of unknown types. Returns a negative integer, zero, or a positive integer
   * as the first object is less than, equal to, or greater than the second object.
   *
   * @param o1 first object to compare
   * @param o2 second object to compare
   * @return a negative integer, zero, or a positive integer as o1 is less than, equal to, or greater than the o2 object.
   */
  protected static int genericCompare(Object o1, Object o2) {
    if(o1 == o2) {
      return 0;
    } else if(o1 == null) {
      return -1;
    } else if(o2 == null) {
      return 1;
    } else if(o1 instanceof Comparable && o2 instanceof Comparable && o1.getClass().equals(o2.getClass())) {
      return ((Comparable) o1).compareTo(o2);
    } else {
      // default to simply sorting based on the object's class name as a fall back
      return o1.getClass().getName().compareTo(o2.getClass().getName());
    }
  }
  
  /**
   * Retrieves a single DatabaseEntry using the primary key(s) of the resourceSchemaProvider.
   *
   * @param keys primary key(s)
   * @return either an empty optional object or the object represented by the provided keys.
   * @throws DataAccessException if an error occurred while retrieving the object or the provided keys are invalid.
   */
  @Override
// Path: src/main/java/net/nextpulse/jadmin/FormPostEntry.java
// public class FormPostEntry {
//   
//   /**
//    * Key value(s) for this post entry, i.e. the object id, non-editable values.
//    */
//   private LinkedHashMap<String, String> keyValues = new LinkedHashMap<>();
//   /**
//    * Editable values of a resource, i.e. an editable name field.
//    */
//   private LinkedHashMap<String, String> values = new LinkedHashMap<>();
//   
//   public FormPostEntry() {
//   }
//   
//   /**
//    * @return map of unescaped post values
//    */
//   public LinkedHashMap<String, String> getValues() {
//     return values;
//   }
//   
//   public void addValue(String columnName, String value) {
//     values.put(columnName, value);
//   }
//   
//   /**
//    * @return map of unescaped values that make up the identifier of this row
//    */
//   public LinkedHashMap<String, String> getKeyValues() {
//     return keyValues;
//   }
//   
//   /**
//    * Adds a new user supplied value for the specified column.
//    *
//    * @param columnName column name
//    * @param value      user provided value
//    */
//   public void addKeyValue(String columnName, String value) {
//     keyValues.put(columnName, value);
//   }
//   
//   /**
//    * Returns a Map with column keys linked to the submitted values.
//    *
//    * @return this entry as map of column name to value
//    */
//   public Map<String, String> toPropertiesMap() {
//     LinkedHashMap<String, String> output = new LinkedHashMap<>();
//     output.putAll(keyValues);
//     output.putAll(values);
//     return output;
//   }
// }


// Path: src/main/java/net/nextpulse/jadmin/dao/InMemoryDAO.java
import net.nextpulse.jadmin.FormPostEntry;
import java.util.*;
import java.util.stream.Collectors;

package net.nextpulse.jadmin.dao;



/**
 * Example DAO that provides access to an in-memory representation of objects, which are kept in insertion order.
 * May be used for testing purposes or as an example implementation.
 *
 * @author yholkamp
 */
public class InMemoryDAO extends AbstractDAO {
  
  private LinkedHashMap<DatabaseEntryKey, DatabaseEntry> objects = new LinkedHashMap<>();
  
  /**
   * Generic compare function for two objects of unknown types. Returns a negative integer, zero, or a positive integer
   * as the first object is less than, equal to, or greater than the second object.
   *
   * @param o1 first object to compare
   * @param o2 second object to compare
   * @return a negative integer, zero, or a positive integer as o1 is less than, equal to, or greater than the o2 object.
   */
  protected static int genericCompare(Object o1, Object o2) {
    if(o1 == o2) {
      return 0;
    } else if(o1 == null) {
      return -1;
    } else if(o2 == null) {
      return 1;
    } else if(o1 instanceof Comparable && o2 instanceof Comparable && o1.getClass().equals(o2.getClass())) {
      return ((Comparable) o1).compareTo(o2);
    } else {
      // default to simply sorting based on the object's class name as a fall back
      return o1.getClass().getName().compareTo(o2.getClass().getName());
    }
  }
  
  /**
   * Retrieves a single DatabaseEntry using the primary key(s) of the resourceSchemaProvider.
   *
   * @param keys primary key(s)
   * @return either an empty optional object or the object represented by the provided keys.
   * @throws DataAccessException if an error occurred while retrieving the object or the provided keys are invalid.
   */
  @Override
  public Optional<DatabaseEntry> selectOne(Object... keys) throws DataAccessException {