Package org.apache.gora.dynamodb.store.DynamoDBMapping

Examples of org.apache.gora.dynamodb.store.DynamoDBMapping.DynamoDBMappingBuilder


   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  private DynamoDBMapping readMapping() throws IOException {

    DynamoDBMappingBuilder mappingBuilder = new DynamoDBMappingBuilder();

    try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(getClass().getClassLoader().getResourceAsStream(MAPPING_FILE));
     
      Element root = doc.getRootElement();

      List<Element> tableElements = root.getChildren("table");
      for(Element tableElement : tableElements) {
   
        String tableName = tableElement.getAttributeValue("name");
        long readCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
        long writeCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
   
        mappingBuilder.setTableName(tableName);
        mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits, writeCapacUnits);
        LOG.debug("Basic table properties have been set: Name, and Provisioned throughput.");
   
        // Retrieving key's features
        List<Element> fieldElements = tableElement.getChildren("key");
        for(Element fieldElement : fieldElements) {
          String keyName  = fieldElement.getAttributeValue("name");
          String keyType  = fieldElement.getAttributeValue("type");
          String keyAttrType  = fieldElement.getAttributeValue("att-type");
          if(keyType.equals("hash"))
            mappingBuilder.setHashKeySchema(tableName, keyName, keyAttrType);
          else if(keyType.equals("hashrange"))
            mappingBuilder.setHashRangeKeySchema(tableName, keyName, keyAttrType);
        }
        LOG.debug("Table key schemas have been set.");
   
        // Retrieving attributes
        fieldElements = tableElement.getChildren("attribute");
        for(Element fieldElement : fieldElements) {
          String attributeName  = fieldElement.getAttributeValue("name");
          String attributeType = fieldElement.getAttributeValue("type");
          mappingBuilder.addAttribute(tableName, attributeName, attributeType, 0);
        }
        LOG.debug("Table attributes have been read.");
      }

    } catch(IOException ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw ex;

    } catch(Exception ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw new IOException(ex);
    }

    return mappingBuilder.build();
  }
View Full Code Here


   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  private DynamoDBMapping readMapping() throws IOException {

    DynamoDBMappingBuilder mappingBuilder = new DynamoDBMappingBuilder();

    try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(getClass().getClassLoader().getResourceAsStream(MAPPING_FILE));
     
      Element root = doc.getRootElement();

      List<Element> tableElements = root.getChildren("table");
      for(Element tableElement : tableElements) {
   
        String tableName = tableElement.getAttributeValue("name");
        long readCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
        long writeCapacUnits = Long.parseLong(tableElement.getAttributeValue("writecunit"));
   
        mappingBuilder.setTableName(tableName);
        mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits, writeCapacUnits);
        LOG.debug("Basic table properties have been set: Name, and Provisioned throughput.");
   
        // Retrieving key's features
        List<Element> fieldElements = tableElement.getChildren("key");
        for(Element fieldElement : fieldElements) {
          String keyName  = fieldElement.getAttributeValue("name");
          String keyType  = fieldElement.getAttributeValue("type");
          String keyAttrType  = fieldElement.getAttributeValue("att-type");
          if(keyType.equals("hash"))
            mappingBuilder.setHashKeySchema(tableName, keyName, keyAttrType);
          else if(keyType.equals("hashrange"))
            mappingBuilder.setHashRangeKeySchema(tableName, keyName, keyAttrType);
        }
        LOG.debug("Table key schemas have been set.");
   
        // Retrieving attributes
        fieldElements = tableElement.getChildren("attribute");
        for(Element fieldElement : fieldElements) {
          String attributeName  = fieldElement.getAttributeValue("name");
          String attributeType = fieldElement.getAttributeValue("type");
          mappingBuilder.addAttribute(tableName, attributeName, attributeType, 0);
        }
        LOG.debug("Table attributes have been read.");
      }

    } catch(IOException ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw ex;

    } catch(Exception ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw new IOException(ex);
    }

    return mappingBuilder.build();
  }
View Full Code Here

   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  private DynamoDBMapping readMapping(File pMapFile) throws IOException {

    DynamoDBMappingBuilder mappingBuilder = new DynamoDBMappingBuilder();

    try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(pMapFile);
     
      Element root = doc.getRootElement();

      List<Element> tableElements = root.getChildren("table");
      for(Element tableElement : tableElements) {
     
      String tableName = tableElement.getAttributeValue("name");
      long readCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
      long writeCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
   
      mappingBuilder.setTableName(tableName);
      mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits, writeCapacUnits);
      log.debug("Basic table properties have been set: Name, and Provisioned throughput.");
   
      // Retrieving key's features
      List<Element> fieldElements = tableElement.getChildren("key");
      for(Element fieldElement : fieldElements) {
        String keyName  = fieldElement.getAttributeValue("name");
        String keyType  = fieldElement.getAttributeValue("type");
        String keyAttrType  = fieldElement.getAttributeValue("att-type");
        if(keyType.equals("hash"))
          mappingBuilder.setHashKeySchema(tableName, keyName, keyAttrType);
        else if(keyType.equals("hashrange"))
          mappingBuilder.setHashRangeKeySchema(tableName, keyName, keyAttrType);
      }
      log.debug("Table key schemas have been set.");
   
      // Retrieving attributes
        fieldElements = tableElement.getChildren("attribute");
        for(Element fieldElement : fieldElements) {
          String attributeName  = fieldElement.getAttributeValue("name");
          String attributeType = fieldElement.getAttributeValue("type");
          mappingBuilder.addAttribute(tableName, attributeName, attributeType, 0);
        }
        log.info("Table attributes have been read.");
      }

    } catch(IOException ex) {
      log.info("Error while performing xml mapping.");
      ex.printStackTrace();
      throw ex;

    } catch(Exception ex) {
      ex.printStackTrace();
      throw new IOException(ex);
    }

    return mappingBuilder.build();
  }
View Full Code Here

   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  private DynamoDBMapping readMapping() throws IOException {

    DynamoDBMappingBuilder mappingBuilder = new DynamoDBMappingBuilder();

    try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(getClass().getClassLoader().getResourceAsStream(MAPPING_FILE));
     
      Element root = doc.getRootElement();

      List<Element> tableElements = root.getChildren("table");
      for(Element tableElement : tableElements) {
   
        String tableName = tableElement.getAttributeValue("name");
        long readCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
        long writeCapacUnits = Long.parseLong(tableElement.getAttributeValue("writecunit"));
   
        mappingBuilder.setTableName(tableName);
        mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits, writeCapacUnits);
        LOG.debug("Basic table properties have been set: Name, and Provisioned throughput.");
   
        // Retrieving key's features
        List<Element> fieldElements = tableElement.getChildren("key");
        for(Element fieldElement : fieldElements) {
          String keyName  = fieldElement.getAttributeValue("name");
          String keyType  = fieldElement.getAttributeValue("type");
          String keyAttrType  = fieldElement.getAttributeValue("att-type");
          if(keyType.equals("hash"))
            mappingBuilder.setHashKeySchema(tableName, keyName, keyAttrType);
          else if(keyType.equals("hashrange"))
            mappingBuilder.setHashRangeKeySchema(tableName, keyName, keyAttrType);
        }
        LOG.debug("Table key schemas have been set.");
   
        // Retrieving attributes
        fieldElements = tableElement.getChildren("attribute");
        for(Element fieldElement : fieldElements) {
          String attributeName  = fieldElement.getAttributeValue("name");
          String attributeType = fieldElement.getAttributeValue("type");
          mappingBuilder.addAttribute(tableName, attributeName, attributeType, 0);
        }
        LOG.debug("Table attributes have been read.");
      }

    } catch(IOException ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw ex;

    } catch(Exception ex) {
      LOG.error("Error while performing xml mapping.");
      ex.printStackTrace();
      throw new IOException(ex);
    }

    return mappingBuilder.build();
  }
View Full Code Here

TOP

Related Classes of org.apache.gora.dynamodb.store.DynamoDBMapping.DynamoDBMappingBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.