本文整理汇总了Java中com.amazonaws.services.simpledb.model.SelectRequest类的典型用法代码示例。如果您正苦于以下问题:Java SelectRequest类的具体用法?Java SelectRequest怎么用?Java SelectRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectRequest类属于com.amazonaws.services.simpledb.model包,在下文中一共展示了SelectRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doGet
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
String customerID = request.getParameter("customerID");
BasicAWSCredentials awsCredentials = new BasicAWSCredentials("test", "test");
AmazonSimpleDBClient sdbc = new AmazonSimpleDBClient(awsCredentials);
String query = "select * from invoices where customerID = '"
+ customerID;
SelectResult sdbResult = sdbc.select(new SelectRequest(query)); //BAD
SelectResult sdbResult2 = sdbc.select(new SelectRequest(query, false)); //BAD
SelectRequest sdbRequest = new SelectRequest();
SelectResult sdbResult3 = sdbc.select(sdbRequest.withSelectExpression(query)); //BAD
String query2 = "select * from invoices where customerID = 123";
SelectResult sdbResult4 = sdbc.select(new SelectRequest(query2)); //OK
}catch(Exception e){
System.out.println(e);
}
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:AwsQueryInjection.java
示例2: getPagedItems
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public PagedDatabaseResult getPagedItems(String tableName, Object token, String minRange, String maxRange, String instanceId, String jobId) {
List<Item> ret = new ArrayList<Item>();
String whereClause = null;
if (minRange != null && maxRange != null) {
whereClause = " Timestamp between '" + minRange + "' and '" + maxRange + "' ";
} else if (minRange != null) {
whereClause = " Timestamp >= '" + minRange + "' ";
} else if (maxRange != null) {
whereClause = " Timestamp < '" + maxRange + "' ";
} else {
whereClause = "";
}
SelectRequest request = new SelectRequest("SELECT * from `" + tableName + "`" + whereClause).withConsistentRead(true);
String nextToken = (String) token;
request.withNextToken(nextToken);
SelectResult result = db.select(request);
for (com.amazonaws.services.simpledb.model.Item item : result.getItems()) {
ret.add(resultToItem(item));
}
nextToken = result.getNextToken();
return new PagedDatabaseResult(ret, result.getNextToken());
}
开发者ID:intuit,项目名称:Tank,代码行数:27,代码来源:AmazonSimpleDatabase.java
示例3: queryWithSort
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public <T> List<T> queryWithSort(Class<T> dataClass, String property,
AdminQueryOperator operator, Object parameter, String sortProperty,
AdminSortOperator sortOperator) throws WPBIOException {
SelectRequest selectRequest = new SelectRequest();
Set<String> properties = new HashSet<String>();
properties.add(property);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(property, parameter);
Map<String, AdminQueryOperator> operators = new HashMap<String, AdminQueryOperator>();
operators.put(property, operator);
selectRequest.withConsistentRead(true).withSelectExpression(build_query_with_condition_and_sort("*", dataClass, properties, operators, parameters, sortProperty, sortOperator));
return internalQuery(dataClass, selectRequest);
}
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:17,代码来源:WPBAwsSdbAdminDataStorage.java
示例4: getFeedItemNames
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* Retrieve itemNames for all quotes that were not posted by the user
*
* @param myUserId user ID of the viewer so that their posts do not appear in their main feed
*/
public static List<String> getFeedItemNames(String myUserId) {
SelectRequest selectRequest = new SelectRequest("select itemName() from Quotes where userId != '" + myUserId +
"' and timestamp is not null order by timestamp desc").withConsistentRead(true);
AmazonSimpleDBClient client = getInstance();
if (client != null) {
List<Item> items = client.select(selectRequest).getItems();
List<String> itemNames = new ArrayList<String>();
for (int i = 0; i < items.size(); i++) {
itemNames.add((items.get(i)).getName());
}
return itemNames;
} else return new ArrayList<String>();
}
开发者ID:pgodzin,项目名称:QuotesSocial,代码行数:21,代码来源:SimpleDB.java
示例5: getFollowingFeedItemNames
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* Retrieve quotes posted by posters the user is following
*
* @param myUserId facebook user ID
*/
public static List<String> getFollowingFeedItemNames(String myUserId) {
SelectRequest selectRequestNames = new SelectRequest("select followedId from Following where followerId = '" +
myUserId + "'").withConsistentRead(true);
List<Item> names = getInstance().select(selectRequestNames).getItems();
// Work-around for no nested queries in SimpleDB
String followedSet = "(";
for (int j = 0; j < names.size(); j++) {
followedSet += "'" + names.get(j).getAttributes().get(0).getValue() + "',";
}
followedSet = followedSet.substring(0, followedSet.length() - 1) + ")";
SelectRequest selectRequest = new SelectRequest("select itemName() from Quotes where userId in " + followedSet +
" and timestamp is not null order by timestamp desc").withConsistentRead(true);
List<Item> items = getInstance().select(selectRequest).getItems();
List<String> itemNames = new ArrayList<String>();
for (int i = 0; i < items.size(); i++) {
itemNames.add((items.get(i)).getName());
}
return itemNames;
}
开发者ID:pgodzin,项目名称:QuotesSocial,代码行数:28,代码来源:SimpleDB.java
示例6: findAll
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Override
public ImmutableSet<CassandraInstance> findAll(String ring) {
List<CassandraInstance> instances = Lists.newArrayList();
String nextToken = null;
do {
SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring)))
.withNextToken(nextToken);
SelectResult result = client.select(request);
for (Item item : result.getItems()) {
instances.add(transform(item));
}
nextToken = result.getNextToken();
} while (nextToken != null);
return ImmutableSet.copyOf(instances);
}
开发者ID:signal,项目名称:agathon,代码行数:20,代码来源:SdbCassandraInstanceDao.java
示例7: findAll
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Test
public void findAll() {
List<Item> items = createItems();
SelectResult result = createMock(SelectResult.class);
Capture<SelectRequest> requestCapture = new Capture<SelectRequest>();
expect(domainFactory.createFromRing(RING_NAME)).andReturn(domain(RING_NAME));
expect(simpleDbClient.select(capture(requestCapture))).andReturn(result);
expect(result.getItems()).andReturn(items);
expect(result.getNextToken()).andReturn(null);
replayAll();
Set<CassandraInstance> expected = transform(items);
assertEquals(expected, dao.findAll(RING_NAME));
assertEquals(ALL_QUERY, requestCapture.getValue().getSelectExpression());
assertNull(requestCapture.getValue().getNextToken());
}
开发者ID:signal,项目名称:agathon,代码行数:19,代码来源:SdbCassandraInstanceDaoTest.java
示例8: findById
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Test
public void findById() {
List<Item> items = ImmutableList.of(createItem(1));
SelectResult result = createMock(SelectResult.class);
Capture<SelectRequest> requestCapture = new Capture<SelectRequest>();
expect(domainFactory.createFromRing(RING_NAME)).andReturn(domain(RING_NAME));
expect(simpleDbClient.select(capture(requestCapture))).andReturn(result);
expect(result.getItems()).andStubReturn(items);
replayAll();
Set<CassandraInstance> expected = transform(items);
assertEquals(expected.iterator().next(), dao.findById(RING_NAME, ID));
assertEquals(String.format(SdbCassandraInstanceDao.INSTANCE_QUERY, DOMAIN, ID),
requestCapture.getValue().getSelectExpression());
assertNull(requestCapture.getValue().getNextToken());
}
开发者ID:signal,项目名称:agathon,代码行数:19,代码来源:SdbCassandraInstanceDaoTest.java
示例9: selectsMultipleItems
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* Region.Simple can select items.
* @throws Exception If some problem inside
*/
@Test
public void selectsMultipleItems() throws Exception {
final Domain domain = this.domain();
try {
final String attr = "alpha";
domain.item("first").put(attr, "val-99");
domain.item("second").put("beta", "");
MatcherAssert.assertThat(
domain.select(
new SelectRequest().withSelectExpression(
String.format(
"SELECT * FROM `%s` WHERE `%s` = 'val-99'",
domain.name(), attr
)
).withConsistentRead(true)
),
Matchers.<Item>hasItem(Matchers.hasKey(attr))
);
} finally {
domain.drop();
}
}
开发者ID:jcabi,项目名称:jcabi-simpledb,代码行数:27,代码来源:RegionITCase.java
示例10: selectsManyItems
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* Region.Simple can select many items.
* @throws Exception If some problem inside
*/
@Test
public void selectsManyItems() throws Exception {
final Domain domain = this.domain();
try {
for (int idx = 0; idx < Tv.TEN; ++idx) {
domain.item(String.format("i-%d", idx)).put("hey", "");
}
MatcherAssert.assertThat(
domain.select(
new SelectRequest().withSelectExpression(
String.format("SELECT * FROM `%s`", domain.name())
).withConsistentRead(true)
),
Matchers.<Item>iterableWithSize(Tv.TEN)
);
} finally {
domain.drop();
}
}
开发者ID:jcabi,项目名称:jcabi-simpledb,代码行数:24,代码来源:RegionITCase.java
示例11: testGetAllItemsCorrectlyCallsSimpleDB
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Test
public void testGetAllItemsCorrectlyCallsSimpleDB() throws Exception {
// ARRANGE
initialiseOptimisticPersister();
SelectRequest selectRequest = new SelectRequest();
selectRequest.setConsistentRead(true);
selectRequest.setSelectExpression("select * from `" + testSimpleDBDomainName + "`");
// Configure select result with an item to be returned:
SelectResult selectResult = new SelectResult();
Set<Item> items = new HashSet<>();
Item item = new Item();
String itemDate = "2016-07-23";
item.setName(itemDate);
item.setAttributes(allAttributes);
items.add(item);
selectResult.setItems(items);
mockery.checking(new Expectations() {
{
oneOf(mockSimpleDBClient).select(with(equal(selectRequest)));
will(returnValue(selectResult));
}
});
List<ImmutablePair<String, List<Attribute>>> expectedItems = new ArrayList<>();
ImmutablePair<String, List<Attribute>> pair = new ImmutablePair<>(itemDate, new ArrayList<>(
activeNonVersionAttributes));
expectedItems.add(pair);
// ACT
List<ImmutablePair<String, List<Attribute>>> actualItems = optimisticPersister.getAllItems();
// ASSERT
assertTrue("OptimisticPersister should return the correct items. Actual: " + actualItems
+ ", Expected: " + expectedItems, actualItems.equals(expectedItems));
}
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:39,代码来源:OptimisticPersisterTest.java
示例12: execute
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public void execute() {
SelectRequest request = new SelectRequest()
.withSelectExpression(determineSelectExpression())
.withConsistentRead(determineConsistentRead())
.withNextToken(determineNextToken());
log.trace("Sending request [{}] for exchange [{}]...", request, exchange);
SelectResult result = this.sdbClient.select(request);
log.trace("Received result [{}]", result);
Message msg = getMessageForResponse(exchange);
msg.setHeader(SdbConstants.ITEMS, result.getItems());
msg.setHeader(SdbConstants.NEXT_TOKEN, result.getNextToken());
}
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SelectCommand.java
示例13: select
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Override
public SelectResult select(SelectRequest selectRequest) throws AmazonServiceException, AmazonClientException {
this.selectRequest = selectRequest;
SelectResult result = new SelectResult();
result.setNextToken("TOKEN2");
result.getItems().add(new Item("ITEM1", null));
result.getItems().add(new Item("ITEM2", null));
return result;
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:AmazonSDBClientMock.java
示例14: searchAmazonSimpleDB
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
private Iterator<Item> searchAmazonSimpleDB(boolean users,Filter filter,ArrayList<Attribute> attributes) {
StringBuffer sqlWhere = new StringBuffer();
ArrayList<Object> vals = new ArrayList<Object>();
this.stringFilter(filter.getRoot(),sqlWhere, vals);
StringBuffer SQL = new StringBuffer();
SQL.append("SELECT ");
if (attributes.size() == 0) {
SQL.append("* ");
} else if (attributes.size() == 1 && attributes.get(0).equals("*")) {
SQL.append("* ");
} else if (attributes.size() == 1 && attributes.get(0).getAttribute().getName().equals("1.1")) {
SQL.append("uid ");
} else {
for(Attribute attr : attributes) {
SQL.append(attr.getAttribute().getName()).append(',');
}
SQL.setLength(SQL.length() - 1);
}
SQL.append(" FROM ").append('`');
if (users) {
SQL.append(this.userDomain);
} else {
SQL.append(this.groupDomain);
}
SQL.append("` WHERE ").append(sqlWhere);
if (logger.isDebugEnabled()) {
logger.debug("SQL : " + SQL.toString());
}
SelectResult res = this.sdb.select(new SelectRequest(SQL.toString()));
return res.getItems().iterator();
}
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:40,代码来源:AmazonSimpleDB.java
示例15: hasJobData
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public boolean hasJobData(String tableName, String jobId) {
boolean ret = false;
if (hasTable(tableName)) {
SelectRequest request = new SelectRequest("SELECT * from `" + tableName + "`");
SelectResult result = db.select(request);
ret = !result.getItems().isEmpty();
}
return ret;
}
开发者ID:intuit,项目名称:Tank,代码行数:14,代码来源:AmazonSimpleDatabase.java
示例16: delete
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public <T> void delete(Class<T> dataClass, String property,
AdminQueryOperator operator, Object parameter)
throws WPBIOException {
SelectRequest selectRequest = new SelectRequest();
Set<String> properties = new HashSet<String>();
properties.add(property);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(property, parameter);
Map<String, AdminQueryOperator> operators = new HashMap<String, AdminQueryOperator>();
operators.put(property, operator);
selectRequest.withConsistentRead(true).withSelectExpression(build_query_with_condition("itemName()", dataClass, properties, operators, parameters));
internalDelete(selectRequest);
}
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:16,代码来源:WPBAwsSdbAdminDataStorage.java
示例17: internalQuery
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
private<T> List<T> internalQuery(Class<T> dataClass, SelectRequest selectRequest) throws WPBIOException
{
List<T> result = new ArrayList<T>();
try
{
SelectResult selectResult = null;
do
{
if (selectResult != null)
{
selectRequest.setNextToken(selectResult.getNextToken());
}
selectResult = sdbClient.select(selectRequest);
List<Item> items = selectResult.getItems();
for(Item item: items)
{
T t = copyAttributesToInstance(dataClass, item.getAttributes());
result.add(t);
}
} while (selectResult.getNextToken() != null);
} catch (Exception e)
{
throw new WPBIOException("cannot get all records " + dataClass.getSimpleName(), e);
}
return result;
}
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:29,代码来源:WPBAwsSdbAdminDataStorage.java
示例18: query
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public <T> List<T> query(Class<T> dataClass, String property,
AdminQueryOperator operator, Object parameter)
throws WPBIOException {
SelectRequest selectRequest = new SelectRequest();
Set<String> properties = new HashSet<String>();
properties.add(property);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(property, parameter);
Map<String, AdminQueryOperator> operators = new HashMap<String, AdminQueryOperator>();
operators.put(property, operator);
selectRequest.withConsistentRead(true).withSelectExpression(build_query_with_condition("*", dataClass, properties, operators, parameters));
return internalQuery(dataClass, selectRequest);
}
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:16,代码来源:WPBAwsSdbAdminDataStorage.java
示例19: queryEx
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
public <T> List<T> queryEx(Class<T> dataClass, Set<String> propertyNames,
Map<String, AdminQueryOperator> operators,
Map<String, Object> values) throws WPBIOException {
SelectRequest selectRequest = new SelectRequest();
selectRequest.withConsistentRead(true).withSelectExpression(build_query_with_condition("*", dataClass, propertyNames, operators, values));
return internalQuery(dataClass, selectRequest);
}
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:8,代码来源:WPBAwsSdbAdminDataStorage.java
示例20: getAttributeNamesEmptyStringTest
import com.amazonaws.services.simpledb.model.SelectRequest; //导入依赖的package包/类
@Test @Ignore
public void getAttributeNamesEmptyStringTest() throws Exception {
DomainMetadataResult metadataResult = mock(DomainMetadataResult.class);
SelectResult result = mock(SelectResult.class);
// List itemsList = mock(ArrayList.class);
// Iterator iterator = mock(Iterator.class);
// Attribute
// when(itemsList.iterator()).thenReturn(iterator);
when(metadataResult.getAttributeNameCount()).thenReturn(3);
when(client.select(any(SelectRequest.class))).thenReturn(result);
// when(client.domainMetadata(any(DomainMetadataRequest.class))).thenReturn(metadataResult);
System.out.println(simpleDbApi.getAttributeNames(null));
}
开发者ID:kenweezy,项目名称:teiid,代码行数:16,代码来源:SimpleDbAPIClassTest.java
注:本文中的com.amazonaws.services.simpledb.model.SelectRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论