Skip to content

Commit

Permalink
First commit for Impetus#347
Browse files Browse the repository at this point in the history
  • Loading branch information
mevivs committed Aug 8, 2013
1 parent 40d5b07 commit c1b1a24
Show file tree
Hide file tree
Showing 16 changed files with 623 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
*
* Query implementation for Cassandra.
*/
@SuppressWarnings("unchecked")
public class CassQuery extends QueryImpl
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ protected Object createPoolOrConnection()

Properties props = persistenceUnitMetadata.getProperties();
String keyspace = null;

if (externalProperties != null)
{
keyspace = (String) externalProperties.get(PersistenceProperties.KUNDERA_KEYSPACE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void assertOnTokenScroll()

private void assertOnTokenScroll(String queryClause, int expected)
{
Query<Token> query = (Query<Token>) em.createQuery(queryClause,
Query query = (Query) em.createQuery(queryClause,
Token.class);

int count=0;
Expand Down Expand Up @@ -201,7 +201,7 @@ private void onScroll()

private void assertOnScroll(final String queryWithoutClause, int expectedCount)
{
Query<PersonCassandra> query = (Query<PersonCassandra>) em.createQuery(queryWithoutClause,
Query query = (Query) em.createQuery(queryWithoutClause,
PersonCassandra.class);

assertOnFetch(query, 0, expectedCount);
Expand All @@ -214,7 +214,7 @@ private void assertOnScroll(final String queryWithoutClause, int expectedCount)

}

private void assertOnFetch(Query<PersonCassandra> query, Integer fetchSize, int available)
private void assertOnFetch(Query query, Integer fetchSize, int available)
{
query.setFetchSize(fetchSize);
int counter=0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author vivek.mishra
*
*/
public class KunderaTypedQuery<X> implements TypedQuery<X>, com.impetus.kundera.query.Query<X>
public class KunderaTypedQuery<X> implements TypedQuery<X>, com.impetus.kundera.query.Query
{
/**
* Query instance.
Expand Down Expand Up @@ -449,26 +449,26 @@ public TypedQuery<X> setParameter(int arg0, Date arg1, TemporalType arg2)
@Override
public void setFetchSize(Integer fetchsize)
{
((com.impetus.kundera.query.Query<X>)query).setFetchSize(fetchsize);
((com.impetus.kundera.query.Query)query).setFetchSize(fetchsize);
}

@Override
public Integer getFetchSize()
{
return ((com.impetus.kundera.query.Query<X>)query).getFetchSize();
return ((com.impetus.kundera.query.Query)query).getFetchSize();
}

@Override
public void close()
{
((com.impetus.kundera.query.Query<X>)query).close();
((com.impetus.kundera.query.Query)query).close();

}

@Override
public Iterator<X> iterate()
{
return ((com.impetus.kundera.query.Query<X>)query).iterate();
return ((com.impetus.kundera.query.Query)query).iterate();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
* support pagination.
*
* @author Kuldeep.Mishra
*
* @param <E>
*/
public interface Query<E>
public interface Query
{
/**
* To set fetch size for query.
Expand All @@ -48,6 +46,6 @@ public interface Query<E>
*
* @return
*/
Iterator<E> iterate();
<E> Iterator<E> iterate();

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* @author vivek.mishra
* @param <E>
*/
public abstract class QueryImpl<E> implements Query, com.impetus.kundera.query.Query<E>
public abstract class QueryImpl<E> implements Query, com.impetus.kundera.query.Query
{

/** The query. */
Expand Down Expand Up @@ -1083,5 +1083,5 @@ public Integer getFetchSize()

public abstract void close();

public abstract Iterator<E> iterate();
public abstract <E> Iterator<E> iterate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
package com.impetus.kundera;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.LockModeType;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;

import junit.framework.Assert;

Expand Down
85 changes: 85 additions & 0 deletions kundera-elastic-search/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>kundera</artifactId>
<groupId>com.impetus</groupId>
<version>2.7-SNAPSHOT</version>
</parent>
<groupId>com.impetus.client</groupId>
<artifactId>kundera-elastic-search</artifactId>
<name>kundera-elastic-search</name>
<url>http://maven.apache.org</url>

<properties>
<es.version>0.90.3</es.version>
</properties>

<dependencies>
<!-- Kundera dependencies -->
<dependency>
<groupId>com.impetus.core</groupId>
<artifactId>kundera-core</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
</exclusion>
</exclusions>

</dependency>

<!-- ES dependencies -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${es.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- contiperf dependency should not be here -->
<dependency>
<groupId>org.databene</groupId>
<artifactId>contiperf</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Assembly build -->
<build>
<plugins>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default. -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*******************************************************************************
* * Copyright 2013 Impetus Infotech.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
******************************************************************************/
package com.impetus.client.es;

import java.util.List;
import java.util.Map;

import org.elasticsearch.client.transport.TransportClient;

import com.impetus.kundera.client.Client;
import com.impetus.kundera.client.ClientBase;
import com.impetus.kundera.db.RelationHolder;
import com.impetus.kundera.metadata.model.EntityMetadata;
import com.impetus.kundera.persistence.EntityReader;
import com.impetus.kundera.persistence.context.jointable.JoinTableData;

/**
* @author vivek.mishra
* Elastic search client implementation on {@link Client}
*
*/
public class ESClient extends ClientBase implements Client<ESQuery>
{

private ESClientFactory factory;
private TransportClient txClient;

ESClient(final ESClientFactory factory, final TransportClient client)
{
this.factory = factory;
this.txClient = client;
}

@Override
protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
{

}

@Override
public Object find(Class entityClass, Object key)
{
return null;
}

@Override
public <E> List<E> findAll(Class<E> entityClass, String[] columnsToSelect, Object... keys)
{
// TODO Auto-generated method stub
return null;
}

@Override
public <E> List<E> find(Class<E> entityClass, Map<String, String> embeddedColumnMap)
{
// TODO Auto-generated method stub
return null;
}

@Override
public void close()
{
// TODO Auto-generated method stub

}

@Override
public void delete(Object entity, Object pKey)
{
// TODO Auto-generated method stub

}

@Override
public void persistJoinTable(JoinTableData joinTableData)
{
// TODO Auto-generated method stub

}

@Override
public <E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName, String columnName,
Object pKeyColumnValue, Class columnJavaType)
{
// TODO Auto-generated method stub
return null;
}

@Override
public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
Object columnValue, Class entityClazz)
{
// TODO Auto-generated method stub
return null;
}

@Override
public void deleteByColumn(String schemaName, String tableName, String columnName, Object columnValue)
{
// TODO Auto-generated method stub

}

@Override
public List<Object> findByRelation(String colName, Object colValue, Class entityClazz)
{
// TODO Auto-generated method stub
return null;
}

@Override
public EntityReader getReader()
{
// TODO Auto-generated method stub
return null;
}

@Override
public Class<ESQuery> getQueryImplementor()
{
return ESQuery.class;
}

}
Loading

0 comments on commit c1b1a24

Please sign in to comment.