info.archinnov.achilles.clustered.ClusteredEntityFactory Maven / Gradle / Ivy
package info.archinnov.achilles.clustered;
import info.archinnov.achilles.composite.ThriftCompositeTransformer;
import info.archinnov.achilles.context.ThriftPersistenceContext;
import info.archinnov.achilles.dao.ThriftGenericEntityDao;
import info.archinnov.achilles.entity.metadata.EntityMeta;
import info.archinnov.achilles.entity.metadata.PropertyMeta;
import info.archinnov.achilles.entity.operations.ThriftJoinEntityLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import me.prettyprint.hector.api.beans.Composite;
import me.prettyprint.hector.api.beans.HColumn;
import me.prettyprint.hector.api.beans.HCounterColumn;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
public class ClusteredEntityFactory
{
private ThriftCompositeTransformer transformer = new ThriftCompositeTransformer();
private ThriftJoinEntityLoader joinHelper = new ThriftJoinEntityLoader();
public List buildClusteredEntities(Class entityClass,
ThriftPersistenceContext context,
List> hColumns)
{
PropertyMeta, ?> pm = context.getFirstMeta();
if (hColumns.isEmpty())
{
return new ArrayList();
}
else if (pm.isJoin())
{
return buildJoinClusteredEntities(entityClass, context, hColumns);
}
else
{
return buildSimpleClusteredEntities(entityClass, context, hColumns);
}
}
private List buildSimpleClusteredEntities(Class entityClass,
ThriftPersistenceContext context,
List> hColumns)
{
Function, T> function = transformer
.buildClusteredEntityTransformer(entityClass,
context);
return Lists.transform(hColumns, function);
}
private List buildJoinClusteredEntities(Class entityClass,
ThriftPersistenceContext context,
List> hColumns)
{
PropertyMeta
© 2015 - 2025 Weber Informatics LLC | Privacy Policy