/*** * 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); }
@Override public Object visit(Path<?> expr, DynamoDBScanExpression scanExpression) { AnnotatedElement element = expr.getAnnotatedElement(); Annotation[] annotations = element.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DynamoDBRangeKey) { return expr.getMetadata().getElement(); } } return expr.getMetadata().getElement(); }
@DynamoDBRangeKey @DynamoDBIndexRangeKey ( globalSecondaryIndexNames = {"GSI-index-hash-primary-range"}, localSecondaryIndexName = "LSI-primary-range" ) public String getPrimaryRangeKey() { return primaryRangeKey; }
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; }
@DynamoDBRangeKey public double getRangeKey() { return rangeKey; }
@DynamoDBRangeKey public String getRangeKey() { return rangeKey; }
@DynamoDBRangeKey public String getPrimaryRangeKey() { return primaryRangeKey; }
@DynamoDBRangeKey public int getRangeKey() { return rangeKey; }
@DynamoDBRangeKey(attributeName="bookId") public String getBookId() { return bookId; }
@DynamoDBRangeKey(attributeName="date") public String getRangeKey() { return date; }
@DynamoDBRangeKey(attributeName="PostTimestamp") @DynamoDBIndexRangeKey(globalSecondaryIndexNames={"CraftId-PostTimestamp-index","FandomId-PostTimestamp-index"}, attributeName="PostTimestamp") public String getPosttimestamp() { return posttimestamp; }
@DynamoDBRangeKey(attributeName="CommentTimestamp") public String getCommentTimestamp() { return commentTimestamp; }
@DynamoDBRangeKey public String getSubject() { return subject; }
@DynamoDBRangeKey(attributeName = "Subject") public String getSubject() { return threadId != null ? threadId.getSubject() : null; }
@DynamoDBRangeKey public String getReplyDateTime() { return replyDateTime; }
@DynamoDBRangeKey(attributeName = "ReplyDateTime") public String getReplyDateTime() { return replyId != null ? replyId.getReplyDateTime() : null; }
@DynamoDBRangeKey(attributeName="ReplyDateTime") public String getReplyDateTime() { return replyDateTime; }
@DynamoDBRangeKey(attributeName="Subject") public String getSubject() { return subject; }
@Override public String getOverriddenAttributeName(final String propertyName) { Method method = findMethod(propertyName); 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(); } } Field field = findField(propertyName); if (field != null) { if (field.getAnnotation(DynamoDBAttribute.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBAttribute.class).attributeName())) { return field.getAnnotation(DynamoDBAttribute.class).attributeName(); } if (field.getAnnotation(DynamoDBHashKey.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBHashKey.class).attributeName())) { return field.getAnnotation(DynamoDBHashKey.class).attributeName(); } if (field.getAnnotation(DynamoDBRangeKey.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBRangeKey.class).attributeName())) { return field.getAnnotation(DynamoDBRangeKey.class).attributeName(); } if (field.getAnnotation(DynamoDBIndexRangeKey.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBIndexRangeKey.class).attributeName())) { return field.getAnnotation(DynamoDBIndexRangeKey.class).attributeName(); } if (field.getAnnotation(DynamoDBIndexHashKey.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBIndexHashKey.class).attributeName())) { return field.getAnnotation(DynamoDBIndexHashKey.class).attributeName(); } if (field.getAnnotation(DynamoDBVersionAttribute.class) != null && StringUtils.isNotEmpty(field.getAnnotation(DynamoDBVersionAttribute.class).attributeName())) { return field.getAnnotation(DynamoDBVersionAttribute.class).attributeName(); } } return null; }
@DynamoDBRangeKey public Object getRangeKey() { return rangeKey; }
@DynamoDBRangeKey public String getRangeKey(){ return null;}
@DynamoDBRangeKey public String getOtherRangeKey(){ return null;}
@DynamoDBRangeKey(attributeName = "range") public String getPlaylistName() { return playlistId != null ? playlistId.getPlaylistName() : null; }
@DynamoDBRangeKey public String getPlaylistName() { return playlistName; }
@Override @DynamoDBRangeKey(attributeName = ATTRIBUTE_NAME_TIMEUTC) public Date getTime() { return time; }
/** * Get rdfTriple * * @return rdfTriple */ @DynamoDBRangeKey(attributeName = "rdf_triple") public String getRdfTriple() { return rdfTriple; }