List of usage examples for com.amazonaws.services.simpledb.model Item getAttributes
public java.util.List<Attribute> getAttributes()
From source file:SimpleDBExample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/* w w w.ja va 2s . c om*/ * 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:SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/*from w ww . j av a 2 s .c om*/ * 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:assign1.simpledb.java
License:Open Source License
public static void main(String[] args) throws InterruptedException { ArrayList<record> result = new ArrayList<record>(); AWSCredentials credentials = null;/*w w w . j av a 2 s . c o m*/ try { credentials = new PropertiesCredentials( simpledb.class.getResourceAsStream("AwsCredentials.properties")); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/huanglin/.aws/credentials), and is in valid format.", e); } AmazonSimpleDB sdb = new AmazonSimpleDBClient(credentials); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { String myDomain = "MyStore"; String selectExpression = "select count(*) from " + myDomain + " where content like '%news%'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" itemIndex: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } } 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:assign1.simpledb.java
License:Open Source License
public List<record> query(String word) throws Exception { /*//from ww w .j av a2 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*/ ArrayList<record> result = new ArrayList<record>(); AWSCredentials credentials = null; try { credentials = new PropertiesCredentials( simpledb.class.getResourceAsStream("AwsCredentials.properties")); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/huanglin/.aws/credentials), and is in valid format.", e); } AmazonSimpleDB sdb = new AmazonSimpleDBClient(credentials); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); String myDomain = "MyStore"; String filter = word; String nextToken = null; SelectResult selectResult = null; do { String selectExpression = ""; if (word.equals("all")) selectExpression = "select * from MyStore LIMIT 2500"; else selectExpression = "select * from " + myDomain + " where content like '%" + filter + "%' LIMIT 2500"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); selectRequest.setNextToken(nextToken); selectResult = sdb.select(selectRequest); nextToken = selectResult.getNextToken(); List<Item> list = selectResult.getItems(); for (Item item : list) { System.out.println(" itemIndex: " + item.getName()); List<Attribute> attributeTmp = new ArrayList<Attribute>(); attributeTmp = item.getAttributes(); record tmp = new record(); for (int i = 0; i < 5; i++) { if (attributeTmp.get(i).getName().equals("content")) tmp.content = attributeTmp.get(i).getValue(); else if (attributeTmp.get(i).getName().equals("geoLat")) tmp.x = Double.parseDouble(attributeTmp.get(i).getValue()); else if (attributeTmp.get(i).getName().equals("Username")) tmp.username = attributeTmp.get(i).getValue(); else if (attributeTmp.get(i).getName().equals("Location")) tmp.location = attributeTmp.get(i).getValue(); else tmp.y = Double.parseDouble(attributeTmp.get(i).getValue()); } result.add(tmp); } } while (nextToken != null); return result; }
From source file:assign1.simpledb1.java
License:Open Source License
public static void main(String[] args) throws InterruptedException { ArrayList<record> result = new ArrayList<record>(); AWSCredentials credentials = null;//from w w w .j a va2s . c o m try { credentials = new PropertiesCredentials( simpledb.class.getResourceAsStream("AwsCredentials.properties")); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/huanglin/.aws/credentials), and is in valid format.", e); } AmazonSimpleDB sdb = new AmazonSimpleDBClient(credentials); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); try { String myDomain = "Twitter"; String selectExpression = "select count(*) from " + myDomain + " where content like '%news%'"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); for (Item item : sdb.select(selectRequest).getItems()) { System.out.println(" itemIndex: " + item.getName()); for (Attribute attribute : item.getAttributes()) { System.out.println(" Attribute"); System.out.println(" Name: " + attribute.getName()); System.out.println(" Value: " + attribute.getValue()); } } } 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:assign1.simpledb1.java
License:Open Source License
public List<record> query(String word) throws Exception { /*//from w w w .java 2s . c om * 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*/ ArrayList<record> result = new ArrayList<record>(); AWSCredentials credentials = null; try { credentials = new PropertiesCredentials( simpledb.class.getResourceAsStream("AwsCredentials.properties")); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/huanglin/.aws/credentials), and is in valid format.", e); } AmazonSimpleDB sdb = new AmazonSimpleDBClient(credentials); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SimpleDB"); System.out.println("===========================================\n"); String myDomain = "Twitter"; String filter = word; String nextToken = null; SelectResult selectResult = null; do { String selectExpression = ""; if (word.equals("all")) selectExpression = "select * from MyStore LIMIT 2500"; else selectExpression = "select * from " + myDomain + " where content like '%" + filter + "%' LIMIT 2500"; System.out.println("Selecting: " + selectExpression + "\n"); SelectRequest selectRequest = new SelectRequest(selectExpression); selectRequest.setNextToken(nextToken); selectResult = sdb.select(selectRequest); nextToken = selectResult.getNextToken(); List<Item> list = selectResult.getItems(); for (Item item : list) { System.out.println(" itemIndex: " + item.getName()); List<Attribute> attributeTmp = new ArrayList<Attribute>(); attributeTmp = item.getAttributes(); record tmp = new record(); for (int i = 0; i < 5; i++) { if (attributeTmp.get(i).getName().equals("content")) tmp.content = attributeTmp.get(i).getValue(); else if (attributeTmp.get(i).getName().equals("geoLat")) tmp.x = Double.parseDouble(attributeTmp.get(i).getValue()); else if (attributeTmp.get(i).getName().equals("Username")) tmp.username = attributeTmp.get(i).getValue(); else if (attributeTmp.get(i).getName().equals("Location")) tmp.location = attributeTmp.get(i).getValue(); else tmp.y = Double.parseDouble(attributeTmp.get(i).getValue()); } result.add(tmp); } } while (nextToken != null); return result; }
From source file:aws.sample.SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/*ww w . j a va 2 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:bench.auth.SimpleDBSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*//from ww w. j av a 2 s .c om * 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:br.com.ingenieux.mojo.simpledb.cmd.DumpDomainCommand.java
License:Apache License
private void appendResult(ArrayNode rootNode, Item item) { ObjectNode rootObjectNode = mapper.createObjectNode(); rootObjectNode.put("name", item.getName()); Map<String, List<String>> replaceAttributes = new TreeMap<String, List<String>>(); /*/*from ww w .j a v a 2s . c o m*/ * Zips It */ for (Attribute a : item.getAttributes()) { String key = a.getName(); String value = a.getValue(); if (replaceAttributes.containsKey(key)) { replaceAttributes.get(key).add(value); } else { replaceAttributes.put(key, new ArrayList<String>(Arrays.asList(value))); } } /* * Formats and dumps */ ObjectNode rootReplaceNode = mapper.createObjectNode(); for (String k : replaceAttributes.keySet()) { List<String> valueList = replaceAttributes.get(k); if (1 == valueList.size()) { rootReplaceNode.put(k, valueList.get(0)); } else { ArrayNode valueArrayNode = mapper.createArrayNode(); for (String value : valueList) valueArrayNode.add(value); rootReplaceNode.put(k, valueArrayNode); } } ArrayNode replaceNode = mapper.createArrayNode(); replaceNode.add(rootReplaceNode); rootObjectNode.put("replace", replaceNode); rootNode.add(rootObjectNode); }
From source file:c3.ops.priam.aws.SDBInstanceData.java
License:Apache License
/** * Convert a simpledb item to PriamInstance * * @param item//from w w w . j a va 2 s . com * @return */ public PriamInstance transform(Item item) { PriamInstance ins = new PriamInstance(); Iterator<Attribute> attrs = item.getAttributes().iterator(); while (attrs.hasNext()) { Attribute att = attrs.next(); if (att.getName().equals(Attributes.INSTANCE_ID)) ins.setInstanceId(att.getValue()); else if (att.getName().equals(Attributes.TOKEN)) ins.setToken(att.getValue()); else if (att.getName().equals(Attributes.APP_ID)) ins.setApp(att.getValue()); else if (att.getName().equals(Attributes.ID)) ins.setId(Integer.parseInt(att.getValue())); else if (att.getName().equals(Attributes.AVAILABILITY_ZONE)) ins.setRac(att.getValue()); else if (att.getName().equals(Attributes.ELASTIC_IP)) ins.setHostIP(att.getValue()); else if (att.getName().equals(Attributes.HOSTNAME)) ins.setHost(att.getValue()); else if (att.getName().equals(Attributes.LOCATION)) ins.setDC(att.getValue()); else if (att.getName().equals(Attributes.UPDATE_TS)) ins.setUpdatetime(Long.parseLong(att.getValue())); } return ins; }