Professional Documents
Culture Documents
Dynamo DBD Aoi MPL
Dynamo DBD Aoi MPL
dao;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.QueryRequest;
import com.amazonaws.services.dynamodbv2.model.QueryResult;
import com.morrisons.supplychain.walltowall.model.StoreList;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
public class DynamoDbDaoImpl implements IDynamoDbDao {
private static final Logger LOGGER =
LoggerFactory.getLogger(DynamoDbDaoImpl.class);
private static final String TABLE_NAME =
"STAGE.supplychain.walltowall.count.extract";
@SuppressWarnings("unchecked")
@Override
public List<StoreList> getStoresById(BigDecimal sequenceId) {
LOGGER.info("Inside DynamoDbDaoImpl -> inside getStoresById() ->
sequenceId : {}", sequenceId);
return (List<StoreList>) mapper.load(StoreList.class, sequenceId);
}
@SuppressWarnings("unchecked")
@Override
public List<StoreList> getStoresByCountId(String countId,String sortId) {
LOGGER.info("Inside DynamoDbDaoImpl -> inside getStoresByCountId() ->
countId : {}", countId);
return (List<StoreList>) mapper.load(StoreList.class, countId,sortId);
}
public StoreList getStoresByCountId1(String countId,String sortId) {
LOGGER.info("Inside DynamoDbDaoImpl -> inside getStoresByCountId() ->
countId : {}", countId);
return mapper.load(StoreList.class, countId,sortId);
}
@Override
public List<StoreList> getStoresByDate(Date countStartDate, Date
countEndDate) {
LOGGER.info("Inside DynamoDbDaoImpl -> inside getStoresByDate() ->
countStartDate : {}", countStartDate);
expressionAttributesNames.put("#countDate", "countDate");
Map<String, AttributeValue> expressionAttributeValues = new
HashMap<>();
expressionAttributeValues.put(":countStartDate", new
AttributeValue().withS(countStartDate.toString()));
expressionAttributeValues.put(":countEndDate", new
AttributeValue().withS(countEndDate.toString()));