Package com.impetus.kundera.annotations

Examples of com.impetus.kundera.annotations.Index


    {
        if (clazz != null)
        {
            metadata.setIndexName(clazz.getSimpleName());
        }
        Index idx = clazz.getAnnotation(Index.class);

        IndexCollection indexes = clazz.getAnnotation(IndexCollection.class);

        EntityType entityType = (EntityType) kunderaMetadata.getApplicationMetadata()
                .getMetaModelBuilder(metadata.getPersistenceUnit()).getManagedTypes().get(clazz);

        List<String> columnsNameToBeIndexed = new ArrayList<String>();

        Map<String, com.impetus.kundera.index.Index> indexedColumnsMap = new HashMap<String, com.impetus.kundera.index.Index>();

        if (null != indexes)
        {
            if (indexes.columns() != null && indexes.columns().length != 0)
            {
                metadata.setIndexable(true);
                for (com.impetus.kundera.index.Index indexedColumn : indexes.columns())
                {
                    if (indexedColumn.type().equals("composite"))
                    {
                        // means comma seperated list of columns
                        metadata.addIndexProperty(
                                prepareCompositeIndexName(indexedColumn.name(), entityType, metadata),
                                populatePropertyIndex(indexedColumn.indexName(), indexedColumn.type(), null, null, null));

                    }
                    else
                    {
                        indexedColumnsMap.put(indexedColumn.name(), indexedColumn);
                    }
                }
            }
        }
        else if (null != idx)
        {
            boolean isIndexable = idx.index();

            if (isIndexable)
            {
                metadata.setIndexable(isIndexable);

                String indexName = idx.name();
                if (indexName != null && !indexName.isEmpty())
                {
                    metadata.setIndexName(indexName);
                }

                if (idx.columns() != null && idx.columns().length != 0)
                {
                    for (String indexedColumn : idx.columns())
                    {
                        columnsNameToBeIndexed.add(indexedColumn);
                    }
                }
            }
View Full Code Here


     * @return list of indexed columns
     */
    public static Map<String, PropertyIndex> getIndexesOnEmbeddable(Class<?> entityClazz)
    {
        Map<String, PropertyIndex> pis = new HashMap<String, PropertyIndex>();
        Index idx = entityClazz.getAnnotation(Index.class);
        IndexCollection indexes = entityClazz.getAnnotation(IndexCollection.class);
        List<String> columnsNameToBeIndexed = null;
        Map<String, com.impetus.kundera.index.Index> columnsToBeIndexed = null;
        if (null != indexes)
        {
            columnsToBeIndexed = new HashMap<String, com.impetus.kundera.index.Index>();
            if (indexes.columns() != null && indexes.columns().length != 0)
            {
                for (com.impetus.kundera.index.Index indexedColumn : indexes.columns())
                {
                    columnsToBeIndexed.put(indexedColumn.name(), indexedColumn);
                }
            }
        }
        if (null != idx)
        {
            columnsNameToBeIndexed = new ArrayList<String>();
            if (idx.columns() != null && idx.columns().length != 0)
            {
                for (String indexedColumn : idx.columns())
                {
                    columnsNameToBeIndexed.add(indexedColumn);
                }
            }
        }
View Full Code Here

    }

    public static boolean isEmbeddedAtributeIndexable(Field embeddedField)
    {
        Class<?> embeddableClass = PropertyAccessorHelper.getGenericClass(embeddedField);
        Index indexAnn = embeddableClass.getAnnotation(Index.class);
        IndexCollection indexCollection = embeddableClass.getAnnotation(IndexCollection.class);
        if (indexCollection != null && indexCollection.columns() != null)
        {
            return true;
        }
        else if (indexAnn != null)
        {
            if (indexAnn.index())
            {
                return true;
            }
        }
        return false;
View Full Code Here

    }

    public static boolean isColumnInEmbeddableIndexable(Field embeddedField, String columnFieldName)
    {
        Class<?> embeddableClass = PropertyAccessorHelper.getGenericClass(embeddedField);
        Index indexAnn = embeddableClass.getAnnotation(Index.class);
        IndexCollection indexCollection = embeddableClass.getAnnotation(IndexCollection.class);
        if (indexCollection != null && indexCollection.columns() != null)
        {
            for (com.impetus.kundera.index.Index column : indexCollection.columns())
            {
                if (columnFieldName != null && column != null && column.name() != null
                        && column.name().equals(columnFieldName))
                {
                    return true;
                }
            }
        }
        else if (indexAnn != null && indexAnn.index())
        {
            String[] columnsToBeIndexed = indexAnn.columns();
            if (columnFieldName != null && Arrays.asList(columnsToBeIndexed).contains(columnFieldName))
            {
                return true;
            }
        }
View Full Code Here

TOP

Related Classes of com.impetus.kundera.annotations.Index

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.