Package com.impetus.kundera.metadata.model.attributes

Examples of com.impetus.kundera.metadata.model.attributes.AbstractAttribute


                EmbeddableType embeddable = metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
                Iterator<Attribute> iter = embeddable.getAttributes().iterator();
                Object compoundKey = m.getIdAttribute().getBindableJavaType().newInstance();
                while (iter.hasNext())
                {
                    AbstractAttribute compositeAttrib = (AbstractAttribute) iter.next();
                    Object value = ((BasicDBObject) rowKey).get(compositeAttrib.getJPAColumnName());
                    PropertyAccessorHelper.set(compoundKey, (Field) compositeAttrib.getJavaMember(), value);
                }
                PropertyAccessorHelper.setId(entity, m, compoundKey);
            }
            else
            {
View Full Code Here


            {
                EmbeddableType embeddable = metaModel.embeddable(((AbstractAttribute) attribute).getBindableJavaType());
                Iterator<Attribute> attributeIter = embeddable.getAttributes().iterator();
                while (attributeIter.hasNext())
                {
                    AbstractAttribute attrib = (AbstractAttribute) attributeIter.next();

                    if (viaColumnName && attrib.getName().equals(embeddedFieldName))
                    {
                        if (nestedEmbeddedFieldName != null
                                && ((MetamodelImpl) metaModel).isEmbeddable(((AbstractAttribute) attrib)
                                        .getBindableJavaType()))
                        {
                            EmbeddableType nestedEmbeddable = metaModel.embeddable(((AbstractAttribute) attrib)
                                    .getBindableJavaType());
                            Iterator<Attribute> iter = embeddable.getAttributes().iterator();
                            while (iter.hasNext())
                            {
                                AbstractAttribute nestedAttribute = (AbstractAttribute) iter.next();

                                if (viaColumnName && nestedAttribute.getName().equals(embeddedFieldName))
                                {
                                    return nestedAttribute.getName();
                                }

                                if (!viaColumnName && nestedAttribute.getJPAColumnName().equals(embeddedFieldName))
                                {
                                    return nestedAttribute.getName();
                                }
                            }
                        }
                        else if (nestedEmbeddedFieldName != null
                                && !((MetamodelImpl) metaModel).isEmbeddable(((AbstractAttribute) attrib)
View Full Code Here

        Iterator<Attribute> iter = superColumn.getAttributes().iterator();

        while (iter.hasNext())
        {
            AbstractAttribute column = (AbstractAttribute) iter.next();

            Field field = (Field) column.getJavaMember();
            String name = column.getJPAColumnName();
            byte[] value = null;
            try
            {
                value = PropertyAccessorHelper.get(superColumnObject, field);
            }
View Full Code Here

     * @param value
     * @return
     */
    private byte[] getBytes(String jpaFieldName, EntityMetadata m, Object value)
    {
        AbstractAttribute idCol = (AbstractAttribute) m.getIdAttribute();
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                m.getPersistenceUnit());

        EntityType entity = metaModel.entity(m.getEntityClazz());
        Class fieldClazz = null;
        if (idCol.getName().equals(jpaFieldName))
        {
            Field f = (Field) idCol.getJavaMember();

            if (metaModel.isEmbeddable(idCol.getBindableJavaType()))
            {
                fieldClazz = String.class;
                Map<Attribute, List<Object>> columnValues = new HashMap<Attribute, List<Object>>();
                Field[] fields = m.getIdAttribute().getBindableJavaType().getDeclaredFields();
                EmbeddableType embeddable = metaModel.embeddable(m.getIdAttribute().getBindableJavaType());

                StringBuilder compositeKey = new StringBuilder();
                for (Field field : fields)
                {
                    if (!ReflectUtils.isTransientOrStatic(field))
                    {
                        AbstractAttribute attrib = (AbstractAttribute) embeddable.getAttribute(field.getName());
                        Object obj = PropertyAccessorHelper.getObject(value, field);
                        compositeKey.append(
                                PropertyAccessorHelper.fromSourceToTargetClass(String.class,
                                        attrib.getBindableJavaType(), obj)).append("\001");
                    }
                }
                compositeKey.delete(compositeKey.lastIndexOf("\001"), compositeKey.length());
                value = compositeKey.toString();
            }
View Full Code Here

                    Iterator<Attribute> iter = embeddable.getAttributes().iterator();
                    Object compoundKey = m.getIdAttribute().getBindableJavaType().newInstance();
                    while (iter.hasNext())
                    {
                        Attribute attr = iter.next();
                        AbstractAttribute compositeAbstractAttrib = (AbstractAttribute) attr;
                        Object value = valueMap.get(compositeAbstractAttrib.getJPAColumnName()) == null ? valueMap
                                .get(compositeAbstractAttrib.getJPAColumnName().toUpperCase()) == null ? valueMap
                                .get(compositeAbstractAttrib.getJPAColumnName().toLowerCase()) : valueMap
                                .get(compositeAbstractAttrib.getJPAColumnName().toUpperCase()) : valueMap
                                .get(compositeAbstractAttrib.getJPAColumnName());
                        setFieldValue(compoundKey, value, attr);
                    }
                    PropertyAccessorHelper.setId(entity, m, compoundKey);
                }
                else
View Full Code Here

                    if (results[i].indexOf(".") > 0)
                    {
                        String fieldName = results[i].substring(0, results[i].indexOf("."));
                        String embeddedFieldName = results[i].substring(results[i].indexOf(".") + 1,
                                results[i].length());
                        AbstractAttribute attribute = (AbstractAttribute) entity.getAttribute(fieldName);
                        EmbeddableType embeddable = metamodel.embeddable(attribute.getBindableJavaType());
                        Attribute embeddableAttribute = embeddable.getAttribute(embeddedFieldName);
                        columns.add(((AbstractAttribute) embeddableAttribute).getJPAColumnName());
                    }
                    else
                    {
View Full Code Here

        // If partition key part age given in query, i.e. restriction on
        // id.compositekey.compositePartitionkey.partitionkeyColumn.
        if (fieldName.indexOf(".") > 0)
        {
            String compositePartitionkeyName = fieldName.substring(0, fieldName.indexOf("."));
            AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(compositePartitionkeyName);
            fieldName = fieldName.substring(fieldName.indexOf(".") + 1);

            EmbeddableType compositePartitionkey = metamodel.embeddable(attribute.getBindableJavaType());

            attribute = (AbstractAttribute) compositePartitionkey.getAttribute(fieldName);

            String columnName = attribute.getJPAColumnName();

            isPresent = buildWhereClause(builder, isPresent, translator, condition, value, useInClause, attribute,
                    columnName, false);
        }
        // if composite partition key object is given in query, i.e. restriction
        // on id.compositekey.compositePartitionkey
        else if (metamodel.isEmbeddable(((AbstractAttribute) keyObj.getAttribute(fieldName)).getBindableJavaType()))
        {
            AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName);
            Set<Attribute> attributes = metamodel.embeddable(attribute.getBindableJavaType()).getAttributes();

            if (!useInClause)
            {
                // Iterating and appending each column of composite partition
                // key in query builder.
                for (Attribute nestedAttribute : attributes)
                {
                    String columnName = ((AbstractAttribute) nestedAttribute).getJPAColumnName();
                    Object valueObject = PropertyAccessorHelper.getObject(value.isEmpty() ? null : value.get(0),
                            (Field) nestedAttribute.getJavaMember());
                    translator.buildWhereClause(builder, nestedAttribute.getJavaType(), columnName, valueObject,
                            condition, false);
                }
            }
            else
            {
                throw new IllegalArgumentException("In clause is not supported on first part of partition key.");
            }
            isPresent = true;
        }
        // if Not a composite partition key,
        // id.compositekey.partitionkey/clusterKey.
        else
        {
            AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName);
            String columnName = attribute.getJPAColumnName();
            isPresent = buildWhereClause(builder, isPresent, translator, condition, value, useInClause, attribute,
                    columnName, false);
        }
        return isPresent;
    }
View Full Code Here

                    String propertyName = orderColumnName.substring(0, orderColumnName.indexOf("."));
                    Attribute embeddableAttribute = metaModel.getEntityAttribute(m.getEntityClazz(), propertyName);
                    EmbeddableType embeddableType = metaModel.embeddable(((AbstractAttribute) embeddableAttribute)
                            .getBindableJavaType());
                    orderColumnName = orderColumnName.substring(orderColumnName.indexOf(".") + 1);
                    AbstractAttribute attribute = (AbstractAttribute) embeddableType.getAttribute(orderColumnName);
                    orderByColumnName = attribute.getJPAColumnName();

                }
                else
                {
                    Attribute attribute = metaModel.getEntityAttribute(m.getEntityClazz(), orderColumnName);
View Full Code Here

TOP

Related Classes of com.impetus.kundera.metadata.model.attributes.AbstractAttribute

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.