List of usage examples for com.amazonaws.services.simpledb.model ReplaceableAttribute ReplaceableAttribute
public ReplaceableAttribute(String name, String value, Boolean replace)
From source file:SimpleDBExample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*//from www. j a v a 2s . c o m * This credentials provider implementation loads your AWS credentials * from a properties file at the root of your classpath. * * Important: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this * sample. * http://aws.amazon.com/security-credentials */ AmazonSimpleDB sdb = new AmazonSimpleDBClient(new ClasspathPropertiesFileCredentialsProvider()); Region usWest2 = Region.getRegion(Regions.US_WEST_2); sdb.setRegion(usWest2); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { // Create a domain String myDomain = "MyStore"; System.out.println("Creating domain called " + myDomain + ".\n"); sdb.createDomain(new CreateDomainRequest(myDomain)); // List domains System.out.println("Listing all domains in your account:\n"); for (String domainName : sdb.listDomains().getDomainNames()) { System.out.println(" " + domainName); } System.out.println(); // Put data into a domain System.out.println("Putting data into " + myDomain + " domain.\n"); sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomain, createSampleData())); // Select data from a domain // Notice the use of backticks around the domain name in our select expression. String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" Item"); System.out.println(" Name: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } System.out.println(); // Delete values from an attribute System.out.println("Deleting Blue attributes in Item_O3.\n"); Attribute deleteValueAttribute = new Attribute("Color", "Blue"); sdb.deleteAttributes( new DeleteAttributesRequest(myDomain, "Item_03").withAttributes(deleteValueAttribute)); // Delete an attribute and all of its values System.out.println("Deleting attribute Year in Item_O3.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03") .withAttributes(new Attribute().withName("Year"))); // Replace an attribute System.out.println("Replacing Size of Item_03 with Medium.\n"); List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); sdb.putAttributes(new PutAttributesRequest(myDomain, "Item_03", replaceableAttributes)); // Delete an item and all of its attributes System.out.println("Deleting Item_03.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03")); // Delete a domain System.out.println("Deleting " + myDomain + " domain.\n"); sdb.deleteDomain(new DeleteDomainRequest(myDomain)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:SimpleDBExample.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * * @return An array of sample item data. *//*from ww w . j av a2 s . c om*/ private static List<ReplaceableItem> createSampleData() { List<ReplaceableItem> sampleData = new ArrayList<ReplaceableItem>(); sampleData.add(new ReplaceableItem("Item_01").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Sweater", true), new ReplaceableAttribute("Name", "Cathair Sweater", true), new ReplaceableAttribute("Color", "Siamese", true), new ReplaceableAttribute("Size", "Small", true), new ReplaceableAttribute("Size", "Medium", true), new ReplaceableAttribute("Size", "Large", true))); sampleData.add(new ReplaceableItem("Item_02").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Designer Jeans", true), new ReplaceableAttribute("Color", "Paisley Acid Wash", true), new ReplaceableAttribute("Size", "30x32", true), new ReplaceableAttribute("Size", "32x32", true), new ReplaceableAttribute("Size", "32x34", true))); sampleData.add(new ReplaceableItem("Item_03").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Sweatpants", true), new ReplaceableAttribute("Color", "Blue", true), new ReplaceableAttribute("Color", "Yellow", true), new ReplaceableAttribute("Color", "Pink", true), new ReplaceableAttribute("Size", "Large", true), new ReplaceableAttribute("Year", "2006", true), new ReplaceableAttribute("Year", "2007", true))); sampleData.add(new ReplaceableItem("Item_04").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Engine", true), new ReplaceableAttribute("Name", "Turbos", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); sampleData.add(new ReplaceableItem("Item_05").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Emissions", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); return sampleData; }
From source file:SimpleDBWrite.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * * @return An array of sample item data. * @throws IOException /*from w w w . j a va 2 s. c o m*/ */ public static List<ReplaceableItem> createData(String searchItem) throws IOException { List<ReplaceableItem> Data = new ArrayList<ReplaceableItem>(); PriceParser myParser = new PriceParser(); ArrayList<resultItem> prodResultItems = myParser.Query2(searchItem, "1"); for (resultItem e : prodResultItems) { Data.add(new ReplaceableItem(e.name).withAttributes( new ReplaceableAttribute("Keyword", searchItem, true), new ReplaceableAttribute("Price", e.price, true), new ReplaceableAttribute("Site", "Walmart", true))); } return Data; }
From source file:SimpleDBPerformanceSample.java
License:Apache License
public static void main(String[] args) throws Exception { AmazonSimpleDB sdb = new AmazonSimpleDBClient( new PropertiesCredentials(SimpleDBSample.class.getResourceAsStream("AwsCredentials.properties"))); // ?[WGh|Cgw//from w w w . j ava 2s . c om sdb.setEndpoint(args[0]); int roopCount = 100; long insertTimeSum = 0; long selectTimeSum = 0; long updateTimeSum = 0; long deleteTimeSum = 0; long startTime; long finishedTime; try { // h?C?? String myDomain = "MyStore"; sdb.createDomain(new CreateDomainRequest(myDomain)); for (int i = 0; i < roopCount; i++) { // ?f?[^ sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomain, createSampleData())); // f?[^1?}(PutAttributes API) ReplaceableItem rItem = new ReplaceableItem("Item_06").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Exhaust", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "TT Coupe", true), new ReplaceableAttribute("Year", "2009", true), new ReplaceableAttribute("Year", "2010", true), new ReplaceableAttribute("Year", "2011", true)); PutAttributesRequest putAttributesRequest = new PutAttributesRequest(myDomain, rItem.getName(), rItem.getAttributes()); startTime = System.currentTimeMillis(); sdb.putAttributes(putAttributesRequest); finishedTime = System.currentTimeMillis(); insertTimeSum += finishedTime - startTime; // f?[^?iSelect API) String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'"; SelectRequest selectRequest = new SelectRequest(selectExpression); startTime = System.currentTimeMillis(); sdb.select(selectRequest); finishedTime = System.currentTimeMillis(); selectTimeSum += finishedTime - startTime; // f?[^?X?V(PutAttributes API) List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); startTime = System.currentTimeMillis(); sdb.putAttributes(new PutAttributesRequest(myDomain, "Item_03", replaceableAttributes)); finishedTime = System.currentTimeMillis(); updateTimeSum += finishedTime - startTime; // f?[^??(DeleteAttributes API) startTime = System.currentTimeMillis(); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03")); finishedTime = System.currentTimeMillis(); deleteTimeSum += finishedTime - startTime; // f?[^?? sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(myDomain, deleteSampleData())); } // h?C?? sdb.deleteDomain(new DeleteDomainRequest(myDomain)); System.out.println("insert:AVG:" + (float) insertTimeSum / roopCount); System.out.println("select:AVG:" + (float) selectTimeSum / roopCount); System.out.println("update:AVG:" + (float) updateTimeSum / roopCount); System.out.println("delete:AVG:" + (float) deleteTimeSum / roopCount); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/*from w w w . j ava2 s . c o m*/ * Important: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this * sample. * http://aws.amazon.com/security-credentials */ AmazonSimpleDB sdb = new AmazonSimpleDBClient( new PropertiesCredentials(SimpleDBSample.class.getResourceAsStream("AwsCredentials.properties"))); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { // Create a domain String myDomain = "MyStore"; System.out.println("Creating domain called " + myDomain + ".\n"); sdb.createDomain(new CreateDomainRequest(myDomain)); // List domains System.out.println("Listing all domains in your account:\n"); for (String domainName : sdb.listDomains().getDomainNames()) { System.out.println(" " + domainName); } System.out.println(); // Put data into a domain System.out.println("Putting data into " + myDomain + " domain.\n"); sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomain, createSampleData())); // Select data from a domain // Notice the use of backticks around the domain name in our select expression. String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" Item"); System.out.println(" Name: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } System.out.println(); // Delete values from an attribute System.out.println("Deleting Blue attributes in Item_O3.\n"); Attribute deleteValueAttribute = new Attribute("Color", "Blue"); sdb.deleteAttributes( new DeleteAttributesRequest(myDomain, "Item_03").withAttributes(deleteValueAttribute)); // Delete an attribute and all of its values System.out.println("Deleting attribute Year in Item_O3.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03") .withAttributes(new Attribute().withName("Year"))); // Replace an attribute System.out.println("Replacing Size of Item_03 with Medium.\n"); List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); sdb.putAttributes(new PutAttributesRequest(myDomain, "Item_03", replaceableAttributes)); // Delete an item and all of its attributes System.out.println("Deleting Item_03.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03")); // Delete a domain System.out.println("Deleting " + myDomain + " domain.\n"); sdb.deleteDomain(new DeleteDomainRequest(myDomain)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:aws.sample.SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*// ww w . j a v a2s.co m * Important: Be sure to fill in your AWS access credentials in the AwsCredentials.properties file before you try to run this sample. http://aws.amazon.com/security-credentials */ AmazonSimpleDB sdb = new AmazonSimpleDBClient( new PropertiesCredentials(SimpleDBSample.class.getResourceAsStream("AwsCredentials.properties"))); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { // Create a domain String myDomain = "MyStore"; System.out.println("Creating domain called " + myDomain + ".\n"); sdb.createDomain(new CreateDomainRequest(myDomain)); // List domains System.out.println("Listing all domains in your account:\n"); for (String domainName : sdb.listDomains().getDomainNames()) { System.out.println(" " + domainName); } System.out.println(); // Put data into a domain System.out.println("Putting data into " + myDomain + " domain.\n"); sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomain, createSampleData())); // Select data from a domain // Notice the use of backticks around the domain name in our select expression. String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" Item"); System.out.println(" Name: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } System.out.println(); // Delete values from an attribute System.out.println("Deleting Blue attributes in Item_O3.\n"); Attribute deleteValueAttribute = new Attribute("Color", "Blue"); sdb.deleteAttributes( new DeleteAttributesRequest(myDomain, "Item_03").withAttributes(deleteValueAttribute)); // Delete an attribute and all of its values System.out.println("Deleting attribute Year in Item_O3.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03") .withAttributes(new Attribute().withName("Year"))); // Replace an attribute System.out.println("Replacing Size of Item_03 with Medium.\n"); List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); sdb.putAttributes(new PutAttributesRequest(myDomain, "Item_03", replaceableAttributes)); // Delete an item and all of its attributes System.out.println("Deleting Item_03.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03")); // Delete a domain System.out.println("Deleting " + myDomain + " domain.\n"); sdb.deleteDomain(new DeleteDomainRequest(myDomain)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:bench.auth.SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/*www . java 2 s . co m*/ * Important: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this sample. * http://aws.amazon.com/security-credentials */ String home = System.getProperty("user.home"); String props = home + "/.amazon/AwsCredentials.properties"; System.out.println("props = " + props); URL url = new File(props).toURI().toURL(); System.out.println("url = " + url); final AWSCredentials credentials = new PropertiesCredentials(url.openStream()); final AmazonSimpleDB sdb = new AmazonSimpleDBClient(credentials); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { // Create a domain String domain = "domain-tester"; System.out.println("Creating domain called " + domain + ".\n"); sdb.createDomain(new CreateDomainRequest(domain)); // List domains System.out.println("Listing all domains in your account:\n"); for (String domainName : sdb.listDomains().getDomainNames()) { System.out.println(" " + domainName); } System.out.println(); // Put data into a domain System.out.println("Putting data into " + domain + " domain.\n"); sdb.batchPutAttributes( // new BatchPutAttributesRequest(domain, createSampleData())); // Select data from a domain // Notice the use of backticks around the domain name in our select // expression. String selectExpression = // "select * from `" + domain + "` where Category = 'Clothes'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" Item"); System.out.println(" Name: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } System.out.println(); // Delete values from an attribute System.out.println("Deleting Blue attributes in Item_O3.\n"); Attribute deleteValueAttribute = new Attribute("Color", "Blue"); sdb.deleteAttributes( new DeleteAttributesRequest(domain, "Item_03").withAttributes(deleteValueAttribute)); // Delete an attribute and all of its values System.out.println("Deleting attribute Year in Item_O3.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(domain, "Item_03") .withAttributes(new Attribute().withName("Year"))); // Replace an attribute System.out.println("Replacing Size of Item_03 with Medium.\n"); List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); sdb.putAttributes(new PutAttributesRequest(domain, "Item_03", replaceableAttributes)); // Delete an item and all of its attributes System.out.println("Deleting Item_03.\n"); sdb.deleteAttributes(new DeleteAttributesRequest(domain, "Item_03")); // Delete a domain // System.out.println("Deleting " + myDomain + " domain.\n"); // sdb.deleteDomain(new DeleteDomainRequest(myDomain)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:bench.auth.SimpleDBSample.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * //from www . j a v a 2s . c o m * @return An array of sample item data. */ private static List<ReplaceableItem> createSampleData() { List<ReplaceableItem> dataList = new ArrayList<ReplaceableItem>(); dataList.add(new ReplaceableItem("Item_01").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Sweater", true), new ReplaceableAttribute("Name", "Cathair Sweater", true), new ReplaceableAttribute("Color", "Siamese", true), new ReplaceableAttribute("Size", "Small", true), new ReplaceableAttribute("Size", "Medium", true), new ReplaceableAttribute("Size", "Large", true))); dataList.add(new ReplaceableItem("Item_02").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Designer Jeans", true), new ReplaceableAttribute("Color", "Paisley Acid Wash", true), new ReplaceableAttribute("Size", "30x32", true), new ReplaceableAttribute("Size", "32x32", true), new ReplaceableAttribute("Size", "32x34", true))); dataList.add(new ReplaceableItem("Item_03").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Sweatpants", true), new ReplaceableAttribute("Color", "Blue", true), new ReplaceableAttribute("Color", "Yellow", true), new ReplaceableAttribute("Color", "Pink", true), new ReplaceableAttribute("Size", "Large", true), new ReplaceableAttribute("Year", "2006", true), new ReplaceableAttribute("Year", "2007", true))); dataList.add(new ReplaceableItem("Item_04").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Engine", true), new ReplaceableAttribute("Name", "Turbos", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); dataList.add(new ReplaceableItem("Item_05").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Emissions", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); return dataList; }
From source file:br.com.ingenieux.mojo.simpledb.cmd.PutAttributesCommand.java
License:Apache License
private Collection<ReplaceableAttribute> getAttributesFrom(ArrayNode attributesNode, boolean replaceP) { List<ReplaceableAttribute> attributeList = new ArrayList<ReplaceableAttribute>(); for (int i = 0; i < attributesNode.size(); i++) { ObjectNode objectNode = (ObjectNode) attributesNode.get(i); Iterator<String> itFieldName = objectNode.fieldNames(); while (itFieldName.hasNext()) { String key = itFieldName.next(); JsonNode valueNode = objectNode.get(key); if (valueNode.isValueNode()) { attributeList.add(new ReplaceableAttribute(key, valueNode.asText(), replaceP)); } else if (valueNode.isArray()) { for (int j = 0; j < valueNode.size(); j++) { JsonNode scalarValueNode = valueNode.get(j); attributeList.add(new ReplaceableAttribute(key, scalarValueNode.asText(), replaceP)); }//from w w w .j a v a2s.com } } } return attributeList; }
From source file:c3.ops.priam.aws.SDBInstanceData.java
License:Apache License
protected List<ReplaceableAttribute> createAttributesToRegister(PriamInstance instance) { instance.setUpdatetime(new Date().getTime()); List<ReplaceableAttribute> attrs = new ArrayList<ReplaceableAttribute>(); attrs.add(new ReplaceableAttribute(Attributes.INSTANCE_ID, instance.getInstanceId(), false)); attrs.add(new ReplaceableAttribute(Attributes.TOKEN, instance.getToken(), true)); attrs.add(new ReplaceableAttribute(Attributes.APP_ID, instance.getApp(), true)); attrs.add(new ReplaceableAttribute(Attributes.ID, Integer.toString(instance.getId()), true)); attrs.add(new ReplaceableAttribute(Attributes.AVAILABILITY_ZONE, instance.getRac(), true)); attrs.add(new ReplaceableAttribute(Attributes.ELASTIC_IP, instance.getHostIP(), true)); attrs.add(new ReplaceableAttribute(Attributes.HOSTNAME, instance.getHostName(), true)); attrs.add(new ReplaceableAttribute(Attributes.LOCATION, instance.getDC(), true)); attrs.add(new ReplaceableAttribute(Attributes.UPDATE_TS, Long.toString(instance.getUpdatetime()), true)); return attrs; }