Package info.archinnov.achilles.internal.metadata.holder

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta


        validator.validateNoDuplicatePropertyName(context);
        validator.validateIndexIfSet(context);

        Class<?> fieldType = field.getType();
        PropertyMeta propertyMeta;

        if (List.class.isAssignableFrom(fieldType)) {
            propertyMeta = parseListProperty(context);
        } else if (Set.class.isAssignableFrom(fieldType)) {
            propertyMeta = parseSetProperty(context);
        } else if (Map.class.isAssignableFrom(fieldType)) {
            propertyMeta = parseMapProperty(context);
        } else if (Counter.class.isAssignableFrom(fieldType)) {
            propertyMeta = parseCounterProperty(context);
        } else if (context.isEmbeddedId()) {
            propertyMeta = parseEmbeddedId(context);
        } else if (context.isPrimaryKey()) {
            propertyMeta = parseId(context);
        } else {
            propertyMeta = parseSimpleProperty(context);
            String indexName = getIndexName(field);
            if (indexName != null) {
                propertyMeta.setIndexProperties(new IndexProperties(indexName, propertyMeta.getCQL3ColumnName()));
            }
        }
        context.getPropertyMetas().put(context.getCurrentPropertyName(), propertyMeta);

        validator.validateNoDuplicateCQLName(context);
View Full Code Here


    protected PropertyMeta parseId(PropertyParsingContext context) {
        log.debug("Parsing property {} as id of entity class {}", context.getCurrentPropertyName(), context
                .getCurrentEntityClass().getCanonicalName());

        PropertyMeta idMeta = parseSimpleProperty(context);
        idMeta.setType(ID);
        Id id = context.getCurrentField().getAnnotation(Id.class);
        String propertyName = StringUtils.isNotBlank(id.name()) ? id.name() : context.getCurrentPropertyName();
        idMeta.setPropertyName(propertyName);

        return idMeta;
    }
View Full Code Here

        Method[] accessors = entityIntrospector.findAccessors(entityClass, field);
        PropertyType type = EMBEDDED_ID;

        EmbeddedIdProperties embeddedIdProperties = extractEmbeddedIdProperties(embeddedIdClass, context);
        PropertyMeta propertyMeta = factory().objectMapper(context.getCurrentObjectMapper()).type(type)
                .propertyName(context.getCurrentPropertyName()).embeddedIdProperties(embeddedIdProperties)
                .entityClassName(context.getCurrentEntityClass().getCanonicalName()).accessors(accessors).field(field)
                .consistencyLevels(context.getCurrentConsistencyLevels()).build(Void.class, embeddedIdClass);

        log.trace("Built embedded id property meta for property {} of entity class {} : {}",
                propertyMeta.getPropertyName(), context.getCurrentEntityClass().getCanonicalName(), propertyMeta);
        return propertyMeta;
    }
View Full Code Here

        Method[] accessors = entityIntrospector.findAccessors(entityClass, field);
        final Codec simpleCodec = codecFactory.parseSimpleField(context);
        final Class<?> cql3ValueType = codecFactory.determineCQL3ValueType(simpleCodec, timeUUID);
        PropertyType type = SIMPLE;

        PropertyMeta propertyMeta = factory().objectMapper(context.getCurrentObjectMapper()).type(type)
                .propertyName(context.getCurrentPropertyName()).cqlColumnName(context.getCurrentCQL3ColumnName())
                .entityClassName(context.getCurrentEntityClass().getCanonicalName()).accessors(accessors)
                .consistencyLevels(context.getCurrentConsistencyLevels()).field(field).timeuuid(timeUUID)
                .staticColumn(staticColumn).simpleCodec(simpleCodec).cql3ValueClass(cql3ValueType)
                .build(Void.class, field.getType());

        log.trace("Built simple property meta for property {} of entity class {} : {}", propertyMeta.getPropertyName(),
                context.getCurrentEntityClass().getCanonicalName(), propertyMeta);
        return propertyMeta;
    }
View Full Code Here

        final boolean staticColumn = isStaticColumn(field);
        PropertyType type = PropertyType.COUNTER;

        CounterProperties counterProperties = new CounterProperties(context.getCurrentEntityClass().getCanonicalName());

        PropertyMeta propertyMeta = factory().objectMapper(context.getCurrentObjectMapper()).type(type)
                .propertyName(context.getCurrentPropertyName()).cqlColumnName(context.getCurrentCQL3ColumnName())
                .entityClassName(context.getCurrentEntityClass().getCanonicalName()).accessors(accessors).field(field)
                .counterProperties(counterProperties).consistencyLevels(context.getCurrentConsistencyLevels()).staticColumn(staticColumn)
                .cql3ValueClass(Long.class)
                .build(Void.class, field.getType());

        context.hasSimpleCounterType();
        context.getCounterMetas().add(propertyMeta);
        if (context.isCustomConsistencyLevels()) {
            parseSimpleCounterConsistencyLevel(context, propertyMeta);
        }

        log.trace("Built simple property meta for property {} of entity class {} : {}", propertyMeta.getPropertyName(),
                context.getCurrentEntityClass().getCanonicalName(), propertyMeta);
        return propertyMeta;
    }
View Full Code Here

        final ListCodec listCodec = codecFactory.parseListField(context);
        final Class<?> cql3ValueType = codecFactory.determineCQL3ValueType(listCodec, timeUUID);

        PropertyType type = LIST;

        PropertyMeta listMeta = factory().objectMapper(context.getCurrentObjectMapper()).type(type)
                .propertyName(context.getCurrentPropertyName()).cqlColumnName(context.getCurrentCQL3ColumnName())
                .entityClassName(context.getCurrentEntityClass().getCanonicalName())
                .consistencyLevels(context.getCurrentConsistencyLevels()).accessors(accessors).field(field)
                .timeuuid(timeUUID).emptyCollectionAndMapIfNull(emptyCollectionIfNull).staticColumn(staticColumn)
                .listCodec(listCodec).cql3ValueClass(cql3ValueType)
                .build(Void.class, valueClass);

        log.trace("Built list property meta for property {} of entity class {} : {}", listMeta.getPropertyName(),
                context.getCurrentEntityClass().getCanonicalName(), listMeta);

        return listMeta;

    }
View Full Code Here

        String tableName = context.getTableName();
        String tableComment = introspector.inferTableComment(entityClass, "Create table for entity \"" + entityClass.getName() + "\"");
        final InsertStrategy insertStrategy = introspector.getInsertStrategy(entityClass, context);


        PropertyMeta idMeta = null;
        List<Field> inheritedFields = introspector.getInheritedPrivateFields(entityClass);
        for (Field field : inheritedFields) {
            PropertyParsingContext propertyContext = context.newPropertyContext(field);
            if (filter.hasAnnotation(field, Id.class)) {
                propertyContext.setPrimaryKey(true);
View Full Code Here

        log.debug("Build Components meta data for embedded id class {}", embeddedIdClass.getCanonicalName());

        for (Integer order : components.keySet()) {
            Field compositeKeyField = components.get(order);

            final PropertyMeta propertyMeta = propertyParser.parseSimpleProperty(context.duplicateForField(compositeKeyField));

            if (filter.hasAnnotation(compositeKeyField, PartitionKey.class)) {
                partitionKeysBuilder.addPropertyMeta(propertyMeta);
            } else {
                clusteringKeysBuilder.addPropertyMeta(propertyMeta);
            }
        }

        // If not @PartitionKey annotation found, take the first field as default partition key
        if (partitionKeysBuilder.getPropertyMetas().isEmpty()) {
            final PropertyMeta partitionMeta = clusteringKeysBuilder.getPropertyMetas().remove(0);
            partitionKeysBuilder.addPropertyMeta(partitionMeta);
        }
    }
View Full Code Here

    }

    @Test
    public void should_update_table_with_new_simple_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta longColPM = valueClass(Long.class).type(SIMPLE).cqlColumnName("longcol").staticColumn().build();

        when(meta.getAllMetasExceptId()).thenReturn(asList(longColPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
View Full Code Here

    }

    @Test
    public void should_update_table_with_new_indexed_simple_field() throws Exception {
        // Given
        PropertyMeta idMeta = valueClass(Long.class).type(ID).cqlColumnName("id").build();
        PropertyMeta longColPM = valueClass(Long.class).type(SIMPLE).cqlColumnName("longcol").build();
        longColPM.setIndexProperties(new IndexProperties("long_index", "longCol"));

        when(meta.getAllMetasExceptId()).thenReturn(asList(longColPM));
        when(meta.getIdMeta()).thenReturn(idMeta);
        when(tableMeta.getColumns()).thenReturn(Arrays.<ColumnMetadata>asList());
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.internal.metadata.holder.PropertyMeta

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.