package org.springframework.data.simpledb.core;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.simpledb.AmazonSimpleDB;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.simpledb.repository.support.entityinformation.SimpleDbEntityInformation;

import java.io.Serializable;
import java.util.List;
import org.springframework.util.Assert;

/**
 *
 */

public class SimpleDbOperationsImpl<T, ID extends Serializable> implements SimpleDbOperations {


    private static final Logger LOGGER = LoggerFactory.getLogger(SimpleDbOperationsImpl.class);
    private final DDL ddl;
    private final AmazonSimpleDB sdb;

    public enum DDL{
        drop_create,
        update,
        nothing
    }

    public SimpleDbOperationsImpl(String accessID, String secretKey) {
        this(accessID, secretKey, DDL.nothing.name());
    }

    public SimpleDbOperationsImpl(final String accessID, final String secretKey, String ddl) {
        Assert.notNull(accessID);
        Assert.notNull(secretKey);
        sdb = new AmazonSimpleDBClient(new AWSCredentials() {

            @Override
            public String getAWSAccessKeyId() {
                return accessID;
            }

            @Override
            public String getAWSSecretKey() {
                return secretKey;
            }

        });
        this.ddl = DDL.valueOf(ddl);

    }

    @Override
    public void delete(SimpleDbEntity sdbEntity) {
        logOperation("Delete", sdbEntity);
    }

    @Override
    public Object addItem(SimpleDbEntity entity) {
        logOperation("Add  ", entity);
        return entity.getItem();
    }

    @Override
    public Object updateItem(SimpleDbEntity entity) {
        logOperation("Update", entity);
        return entity.getItem();
    }

    @Override
    public Object findOne(SimpleDbEntityInformation entityInformation, Serializable id) {
        LOGGER.info("FindOne ItemName \"{}\"\"", id);
        return null;
    }

    @Override
    public boolean exists(SimpleDbEntityInformation entityInformation, Serializable id) {
        LOGGER.info("Exists ItemName \"{}\"\"", id);
        return false;
    }

    @Override
    public List findAll(SimpleDbEntityInformation entityInformation, Iterable ids) {
        LOGGER.info("Find All Domain \"{}\"\"", entityInformation.getDomain());
        return null;
    }

    private void logOperation(String operation, SimpleDbEntity<T, ID> entity) {
        LOGGER.info(operation + " \"{}\" ItemName \"{}\"\"", entity.getDomain(), entity.getItemName());
    }

}

@@ -467,17 +467,16 @@
 %0A *%0A */%0A
-%0A
 public c
@@ -564,17 +564,16 @@
 ions %7B%0A%0A
-%0A
     priv
@@ -724,16 +724,87 @@
 eDB sdb;
+%0A    private final String accessID;%0A    private final String secretKey;
 %0A%0A    pu
@@ -816,17 +816,19 @@
 enum DDL
-%7B
+ %7B%0A
 %0A       
@@ -1239,17 +1239,16 @@
 als() %7B%0A
-%0A
         
@@ -1465,33 +1465,32 @@
 ;%0A            %7D%0A
-%0A
         %7D);%0A    
@@ -1502,32 +1502,235 @@
 his.
-ddl = DDL.valueOf(ddl);%0A
+accessID = accessID;%0A        this.secretKey = secretKey;%0A        this.ddl = DDL.valueOf(ddl);%0A    %7D%0A%0A    public String getAccessID() %7B%0A        return accessID;%0A    %7D%0A%0A    public String getSecretKey() %7B%0A        return secretKey;
 %0A   
@@ -2909,11 +2909,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

fix me self