/*** * Create the table and the associated indexes if it does not already exist * @param reflections * @param clazz */ private CreateTableResult createTable(Class<?> clazz) { final String tableName = this.getClassAnnotationValue(clazz, DynamoDBTable.class, String.class, "tableName"); final Method hashKeyMember = this.getMethodForAnnotation(clazz, DynamoDBHashKey.class); final DynamoDBHashKey hashKeyAnno = hashKeyMember.getAnnotation(DynamoDBHashKey.class); final String hashKeyName = this.getAnnotationValue(hashKeyAnno, "attributeName", String.class); String rangeKeyName = null; final Method rangeKeyMember = this.getMethodForAnnotation(clazz, DynamoDBRangeKey.class); if(rangeKeyMember!=null){ DynamoDBRangeKey rangeKeyAnno = rangeKeyMember.getAnnotation(DynamoDBRangeKey.class); rangeKeyName = this.getAnnotationValue(rangeKeyAnno, "attributeName", String.class); } final Set<Method> hashKeyIndexFields = this.getMethodsAnnotatedWith(DynamoDBIndexHashKey.class, clazz); final Set<Method> rangeKeyIndexFields = this.getMethodsAnnotatedWith(DynamoDBIndexRangeKey.class, clazz); final Map<String, GlobalIndex> globalIndexes = this.createGlobalIndexes(hashKeyIndexFields, rangeKeyIndexFields, clazz); final Map<String, RangeKeyIndexField> localIndexes = this.createLocalIndexMap(rangeKeyIndexFields); final CreateTableRequest tableRequest = this.createCreateTableRequest(tableName, hashKeyName, rangeKeyName, globalIndexes, localIndexes); final CreateTableResult result = this.client.createTable(tableRequest); return result; }
@Override protected boolean shouldCreatePersistentEntityFor(TypeInformation<?> type) { boolean hasHashKey = false; boolean hasRangeKey = false; for (Method method : type.getType().getMethods()) { if (method.isAnnotationPresent(DynamoDBHashKey.class)) hasHashKey = true; if (method.isAnnotationPresent(DynamoDBRangeKey.class)) hasRangeKey = true; } for (Field field : type.getType().getFields()) { if (field.isAnnotationPresent(DynamoDBHashKey.class)) hasHashKey = true; if (field.isAnnotationPresent(DynamoDBRangeKey.class)) hasRangeKey = true; } return type.getType().isAnnotationPresent(DynamoDBTable.class) || (hasHashKey && hasRangeKey); }
public DynamoDBHashAndRangeKeyExtractingEntityMetadataImpl(final Class<T> domainType) { super(domainType); this.hashAndRangeKeyMethodExtractor = new DynamoDBHashAndRangeKeyMethodExtractorImpl<T>(getJavaType()); ReflectionUtils.doWithMethods(domainType, new MethodCallback() { public void doWith(Method method) { if (method.getAnnotation(DynamoDBHashKey.class) != null) { String setterMethodName = toSetterMethodNameFromAccessorMethod(method); if (setterMethodName != null) { hashKeySetterMethod = ReflectionUtils.findMethod(domainType, setterMethodName, method.getReturnType()); } } } }); ReflectionUtils.doWithFields(domainType, new FieldCallback() { public void doWith(Field field) { if (field.getAnnotation(DynamoDBHashKey.class) != null) { hashKeyField = ReflectionUtils.findField(domainType, field.getName()); } } }); Assert.isTrue(hashKeySetterMethod != null || hashKeyField != null, "Unable to find hash key field or setter method on " + domainType + "!"); Assert.isTrue(hashKeySetterMethod == null || hashKeyField == null, "Found both hash key field and setter method on " + domainType + "!"); }
@DynamoDBHashKey @DynamoDBIndexHashKey ( globalSecondaryIndexNames = { "GSI-primary-hash-index-range-1", "GSI-primary-hash-index-range-2"} ) public String getPrimaryHashKey() { return primaryHashKey; }
public String getOverriddenAttributeName(Method method) { if (method != null) { if (method.getAnnotation(DynamoDBAttribute.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBAttribute.class).attributeName())) { return method.getAnnotation(DynamoDBAttribute.class).attributeName(); } if (method.getAnnotation(DynamoDBHashKey.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBHashKey.class).attributeName())) { return method.getAnnotation(DynamoDBHashKey.class).attributeName(); } if (method.getAnnotation(DynamoDBRangeKey.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBRangeKey.class).attributeName())) { return method.getAnnotation(DynamoDBRangeKey.class).attributeName(); } if (method.getAnnotation(DynamoDBIndexRangeKey.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBIndexRangeKey.class).attributeName())) { return method.getAnnotation(DynamoDBIndexRangeKey.class).attributeName(); } if (method.getAnnotation(DynamoDBIndexHashKey.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBIndexHashKey.class).attributeName())) { return method.getAnnotation(DynamoDBIndexHashKey.class).attributeName(); } if (method.getAnnotation(DynamoDBVersionAttribute.class) != null && StringUtils.isNotEmpty(method.getAnnotation(DynamoDBVersionAttribute.class).attributeName())) { return method.getAnnotation(DynamoDBVersionAttribute.class).attributeName(); } } return null; }
@DynamoDBHashKey public String getId() { return id; }
/** * The UUID that uniquely identifies this item. * * @return The UUID. */ @DynamoDBHashKey(attributeName = "Uuid") @DynamoDBAutoGeneratedKey public String getUuid() { return uuid; }
@DynamoDBHashKey(attributeName = "order_id") public String getOrderId() { return orderId; }
@DynamoDBHashKey(attributeName = "product_id") public String getProductId() { return productId; }
@DynamoDBHashKey(attributeName="user_id") public String getUserId() { return userId; }
@Override @DynamoDBHashKey(attributeName = "user_id") public String getUserId() { return super.getUserId(); }
@DynamoDBHashKey(attributeName = "_id") public String getId() { return id; }
@DynamoDBAutoGeneratedKey @DynamoDBHashKey(attributeName = "RequestID") public String getRequestID() { return requestID; }
@DynamoDBHashKey public String getDomainName() { return domainName; }
@DynamoDBHashKey public String getJsessionId() { return jsessionId; }
@DynamoDBHashKey public String getEmail() { return email; }
@DynamoDBHashKey() public String getFileName() { return fileName; }
@DynamoDBHashKey() public String getConfigurationId() { return configurationId; }
@DynamoDBHashKey(attributeName = "electronictaxreceiptarchive_id") public String getId() { return id; }
@DynamoDBAutoGeneratedKey() @DynamoDBHashKey(attributeName = "electronictaxreceipt_id") public String getId() { return id; }
@DynamoDBHashKey(attributeName = "taxreceiptarchive_id") public String getId() { return id; }
@DynamoDBAutoGeneratedKey() @DynamoDBHashKey(attributeName = "taxreceipt_id") public String getId() { return id; }
@DynamoDBHashKey @DynamoDBAutoGeneratedKey public String getId() { return id; }
@DynamoDBHashKey(attributeName = "uid") public String getUid() { return uid; }
@DynamoDBHashKey(attributeName = "id") public String getId() { return id; }
@DynamoDBHashKey(attributeName = "mesh") public String getMesh() { return mesh; }
@DynamoDBHashKey(attributeName = "pmid") public Long getPmid() { return pmid; }
@DynamoDBHashKey(attributeName = "institution") public String getInstitution() { return institution; }
@DynamoDBHashKey public String getToken() { return token; }
@DynamoDBHashKey public String getIdHistoria() { return idHistoria; }