Package org.hivedb.configuration

Examples of org.hivedb.configuration.EntityConfig


  }
 
  @Test
  public void findByProperties() throws Exception {
    final Object instance = getPersistentInstance();
    final EntityConfig entityConfig = config.getEntityConfig(clazz);
    Service s = getClient();
    Collection<EntityIndexConfig> entityIndexConfigs = getFilteredEntityIndexConfigs(entityConfig);
    RingIteratorable<EntityIndexConfig> entityIndexConfigIterator2 = makeEntityIndexConfigRingIterable(instance, entityIndexConfigs);
    RingIteratorable<EntityIndexConfig> entityIndexConfigIterator3 = makeEntityIndexConfigRingIterable(instance, entityIndexConfigs);
    entityIndexConfigIterator2.next();
View Full Code Here


      validate(expectedMap.get(key), actualMap.get(key), arguments);
    }
  }
 
  protected void validate(ServiceContainer expected, ServiceContainer actual, Collection<String> arguments) {
    final EntityConfig entityConfig = config.getEntityConfig(clazz);
    Assert.assertEquals(expected.getVersion(), actual.getVersion());
    Assert.assertEquals(
        ReflectionTools.getDifferingFields(expected.getInstance(), actual.getInstance(), (Class<Object>)clazz).toString(),
        expected.getInstance().hashCode(),
        actual.getInstance().hashCode());
    Assert.assertEquals(String.format("Testing using the following arguments: %s", arguments), entityConfig.getId(expected.getInstance()), entityConfig.getId(actual.getInstance()));
    //Assert.assertEquals(expected.getInstance().getDescription(), actual.getInstance().getDescription());
  }
View Full Code Here

    return (Service)factory.create();
  }

  protected Map<Object, ServiceContainer> getInstanceHashCodeMap(ServiceResponse expected) {
    final GenerateInstance<T> g = new GenerateInstance<T>(clazz);
    final EntityConfig entityConfig = config.getEntityConfig(clazz);
    return Transform.toMap(
    new Unary<ServiceContainer, Object>(){
      public Object f(ServiceContainer item) {
        return entityConfig.getId(item.getInstance());
      }},
 
    new Unary<ServiceContainer, ServiceContainer>(){
      public ServiceContainer f(ServiceContainer item) {
        return createServiceContainer(g.generateAndCopyProperties(item.getInstance()), item.getVersion());
View Full Code Here

    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
    final Class<?> resolvedEntityInterface = new EntityResolver(hiveConfig).resolveToEntityOrRelatedEntity(clazz);
    if (resolvedEntityInterface != null) {
      EntityConfig config = hiveConfig.getEntityConfig(resolvedEntityInterface);
      Collection<Integer> ids = (config.isPartitioningResource())
        ? hive.directory().getNodeIdsOfPrimaryIndexKey(data.getId())
        : hive.directory().getNodeIdsOfResourceId(config.getResourceName(), data.getId());
      return Lists.newArrayList(Transform.map(nodeIdToShardIdConverter(), ids));
    } else {
      // Only for Hibernate entities that are not Hive entities, but are used for secondary indexes
      for (EntityConfig entityConfig : hiveConfig.getEntityConfigs()) {
        for (EntityIndexConfig entityIndexConfig : entityConfig.getEntityIndexConfigs()) {
View Full Code Here

  public void postFlush(Iterator entities) throws CallbackException {
    while (entities.hasNext()) {
      Object entity = entities.next();
      Class<?> resolvedClass = resolveEntityClass(entity.getClass());
      if (resolvedClass != null) {
        final EntityConfig entityConfig = hiveConfig.getEntityConfig(resolvedClass);
        if (indexer.exists(entityConfig, entity))
          updateIndexes(entity);
        else
          insertIndexes(entity);
      }
View Full Code Here

  private void updateIndexes(Object entity) {
    try {
      final Class<?> resolvedEntityClass = resolveEntityClass(entity.getClass());
      if (resolvedEntityClass != null) {
        final EntityConfig entityConfig = hiveConfig.getEntityConfig(entity.getClass());
        if (indexer.idExists(entityConfig, entityConfig.getId(entity)))
          indexer.updatePartitionDimensionIndexIfNeeded(hiveConfig.getEntityConfig(resolvedEntityClass), entity);
        indexer.update(entityConfig, entity);
      }
    } catch (HiveLockableException e) {
      throw new CallbackException(e);
View Full Code Here

    return count;
  }

  public Collection<Object> findByPropertyRange(final String propertyName, final Object minValue, final Object maxValue) {
    // Use an AllShardsresolutionStrategy + Criteria
    final EntityConfig entityConfig = config;
    final EntityIndexConfig indexConfig = config.getEntityIndexConfig(propertyName);
    Session session = factory.openAllShardsSession();
    QueryCallback callback;
    if (isPrimitiveCollection(propertyName)) {
      callback = new QueryCallback() {
        @SuppressWarnings("unchecked")
        public Collection<Object> execute(Session session) {
          Query query = session.createQuery(String.format("from %s as x where x.%s between (:minValue, :maxValue)",
              entityConfig.getRepresentedInterface().getSimpleName(),
              indexConfig.getIndexName())
          ).setEntity("minValue", minValue).setEntity("maxValue", maxValue);
          return query.list();
        }
      };
View Full Code Here

    return (Integer) Atom.getFirstOrThrow(queryInTransaction(query, session));
  }

  public Collection<Object> findByPropertyRange(final String propertyName, final Object minValue, final Object maxValue, final Integer firstResult, final Integer maxResults) {
    // Use an AllShardsresolutionStrategy + Criteria
    final EntityConfig entityConfig = config;
    final EntityIndexConfig indexConfig = config.getEntityIndexConfig(propertyName);
    Session session = factory.openAllShardsSession();
    QueryCallback callback;
    if (isPrimitiveCollection(propertyName)) {
      callback = new QueryCallback() {
        @SuppressWarnings("unchecked")
        public Collection<Object> execute(Session session) {
          Query query = session.createQuery(String.format("from %s as x where %s between (:minValue, :maxValue) order by x.%s asc limit %s, %s",
              entityConfig.getRepresentedInterface().getSimpleName(),
              indexConfig.getIndexName(),
              entityConfig.getIdPropertyName(),
              firstResult,
              maxResults)
          ).setEntity("minValue", minValue).setEntity("maxValue", maxValue);
          return query.list();
        }
View Full Code Here

  public void postFlush(Iterator entities) throws CallbackException {
    while (entities.hasNext()) {
      Object entity = entities.next();
      Class<?> resolvedClass = resolveEntityClass(entity.getClass());
      if (resolvedClass != null) {
        final EntityConfig entityConfig = hiveConfig.getEntityConfig(resolvedClass);
        if (indexer.exists(entityConfig, entity))
          updateIndexes(entity);
        else
          insertIndexes(entity);
      }
View Full Code Here

  private void updateIndexes(Object entity) {
    try {
      final Class<?> resolvedEntityClass = resolveEntityClass(entity.getClass());
      if (resolvedEntityClass != null) {
        final EntityConfig entityConfig = hiveConfig.getEntityConfig(entity.getClass());
        if (indexer.idExists(entityConfig, entityConfig.getId(entity)))
          indexer.updatePartitionDimensionIndexIfNeeded(hiveConfig.getEntityConfig(resolvedEntityClass), entity);
        indexer.update(entityConfig, entity);
      }
    } catch (HiveLockableException e) {
      throw new CallbackException(e);
View Full Code Here

TOP

Related Classes of org.hivedb.configuration.EntityConfig

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.