List of usage examples for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBMapper save
@Override public <T> void save(T object)
From source file:chatbot.ServiceAlertHandler.java
License:Open Source License
private void FindCasesActive(DynamoDBMapper mapper, String sTeamID) throws Exception { System.out.println("Finding Active Cases ..."); Map<String, AttributeValue> eav = new HashMap<String, AttributeValue>(); eav.put(":val1", new AttributeValue().withS("ACTIVE")); eav.put(":val2", new AttributeValue().withS(sTeamID)); DynamoDBScanExpression scanExpression = new DynamoDBScanExpression() .withFilterExpression("CASE_STATE = :val1 and TEAM_ID = :val2").withExpressionAttributeValues(eav); List<Case> scanResult = mapper.scan(Case.class, scanExpression); for (Case objCase : scanResult) { System.out.println(objCase); System.out.println("ID " + objCase.getId()); objIDList.put(objCase.getId(), ""); objCase.setStatus("INACTIVE"); mapper.save(objCase); }// w w w .j av a2 s . c o m }
From source file:com.github.sporcina.mule.modules.DynamoDBConnector.java
License:Open Source License
/** * Save a document to a DynamoDB table/* w ww.j ava2s. com*/ * <p/> * {@sample.xml ../../../doc/DynamoDB-connector.xml.sample dynamodb:save-document} * * @param tableName * the table to update * @param document * the object to save to the table as a document. If not explicitly provided, it defaults to PAYLOAD. * * @return Object the place that was stored */ @Processor public Object saveDocument(final String tableName, @Optional @Default(PAYLOAD) final Object document) { DynamoDBMapper mapper = getDbObjectMapper(tableName); mapper.save(document); // the document is automatically updated with the data that was stored in DynamoDB return document; }
From source file:com.kirana.dao.OrderDaoImpl.java
@Override public boolean addOrder(Order order) throws Exception { boolean status = false; DynamoDBMapper mapper = new DynamoDBMapper(dbClient); mapper.save(order); status = true;//w ww . j a v a 2 s .co m return status; }
From source file:com.xpeppers.motorvehicle.services.BikeResource.java
@PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)/*from w w w . j ava2s. c o m*/ public Response putBikes(@PathParam("id") String id, String content) throws IOException { System.out.println("PUT /bikes/" + id); //Mapping resource on DynamoDB table DynamoDBMapper db_mapper = new DynamoDBMapper(client); ObjectMapper obj_mapper = new ObjectMapper(); BikeMapper bike = obj_mapper.readValue(content, BikeMapper.class); bike.setId(id); try { db_mapper.save(bike); //If a new resource is created //the origin server MUST inform the user agent via the 201 response return Response.created(context.getAbsolutePath()).build(); } catch (AmazonServiceException ase) { Logger.getLogger(ase.getErrorMessage()); return Response.status(500).build(); } }
From source file:com.xpeppers.motorvehicle.services.CarResource.java
@PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)//from w w w . j a va 2s. c om public Response putCars(@PathParam("id") String id, String content) throws IOException { System.out.println("PUT /cars/" + id); //Mapping resource on DynamoDB table DynamoDBMapper db_mapper = new DynamoDBMapper(client); ObjectMapper obj_mapper = new ObjectMapper(); CarMapper car = obj_mapper.readValue(content, CarMapper.class); car.setId(id); try { db_mapper.save(car); //If a new resource is created //the origin server MUST inform the user agent via the 201 response return Response.created(context.getAbsolutePath()).build(); } catch (AmazonServiceException ase) { Logger.getLogger(ase.getErrorMessage()); return Response.status(500).build(); } }
From source file:it.simona.magazzinosrv.BorsaResource.java
@PUT @Consumes(MediaType.APPLICATION_JSON)//from ww w. ja v a 2 s. c om public Response putBorsa(String content) throws IOException { System.out.println("PUT/borsa"); //questo mi serve per collegare il database DynamoDBMapper db_mapper = new DynamoDBMapper(client); //questo mi serve per andare a prendere il json del mio webservice quindi far un'operazione di deserializzazione ObjectMapper obj_mapper = new ObjectMapper(); //Leggo il mio json in formato mapper in maniera tale che questo oggetto possa comunicare con il db BorsaMapper borsa = obj_mapper.readValue(content, BorsaMapper.class); //mi prendo l'id dal json borsa.setId(borsa.getId()); try { //salva l'oggetto come leggile dal db db_mapper.save(borsa); //return Response.created(content.getAbsolutePath()).build(); return Response.status(201).entity(content).build(); } catch (AmazonServiceException ase) { // Logger.getLogger(ase.getErrorMessage()); System.err.println("Failed to retrieve items: "); return Response.status(500).build(); } }
From source file:lifecounter.database.LifeCounterDynamoDbClient.java
License:Open Source License
/** * Stores an item to DynamoDB./* w ww .j av a 2 s . co m*/ * * @param tableItem */ public void saveItem(final LifeCounterUserDataItem tableItem) { DynamoDBMapper mapper = createDynamoDBMapper(); mapper.save(tableItem); }
From source file:org.apache.gora.dynamodb.store.DynamoDBNativeStore.java
License:Apache License
/** * Puts an object identified by a key// ww w . j a v a 2 s.c o m * * @param key * @param obj */ @Override public void put(K key, T obj) throws GoraException { try { Object hashKey = getHashKey(key, obj); Object rangeKey = getRangeKey(key, obj); if (hashKey != null) { DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBStoreHandler.getDynamoDbClient()); if (rangeKey != null) { mapper.load(persistentClass, hashKey, rangeKey); } else { mapper.load(persistentClass, hashKey); } mapper.save(obj); } else throw new GoraException("No HashKey found in Key nor in Object."); } catch (Exception e) { throw new GoraException(e); } }
From source file:org.diksha.common.dyutils.DyDBUtils.java
License:Apache License
public static void reconcileFix(String configId) { ArrayList<String> listOpenExecutionsFromDynamo = listOpenExecutionsFromDynamo(configId); ArrayList<String> listOpenExecutionsFromSWF = SchedulerUDE.listOpenExecutionsFromSWF(configId); listOpenExecutionsFromDynamo.removeAll(listOpenExecutionsFromSWF); for (int cnt = 0; cnt < listOpenExecutionsFromDynamo.size(); cnt++) { System.out.println(" Now fixing... " + listOpenExecutionsFromDynamo.get(cnt)); DynamoDBMapper mapper = DyDBUtils.getDynamoDBMapper(); SchedulerWorkflowState schedulerWorkflowState = mapper.load(SchedulerWorkflowState.class, listOpenExecutionsFromDynamo.get(cnt)); schedulerWorkflowState.setLoopState("CLOSED"); mapper.save(schedulerWorkflowState); }//w w w. ja v a2s . c om }
From source file:org.diksha.common.dyutils.DyDBUtils.java
License:Apache License
public static void createSchedulerConfig(String[] args) { DynamoDBMapper mapper = getDynamoDBMapper(); SchedulerConfig schedulerConfig = new SchedulerConfig(args); mapper.save(schedulerConfig); }