Package org.hivedb.configuration

Examples of org.hivedb.configuration.EntityIndexConfig


    entityIndexConfigIterator3.next();
    entityIndexConfigIterator3.next();
    for (EntityIndexConfig entityIndexConfig1 : entityIndexConfigs) {
      if (entityIndexConfig1.getIndexValues(instance).size() == 0)
        continue;
      EntityIndexConfig entityIndexConfig2 = entityIndexConfigIterator2.next();
      EntityIndexConfig entityIndexConfig3 = entityIndexConfigIterator3.next();
      validate(
          createServiceResponse(Arrays.asList(instance)),
          invoke(
              client,
              "findByTwoProperties",
              entityIndexConfig1.getPropertyName(),
              Atom.getFirstOrThrow(entityIndexConfig1.getIndexValues(instance)).toString(),
              entityIndexConfig2.getPropertyName(),
              Atom.getFirstOrThrow(entityIndexConfig2.getIndexValues(instance)).toString()
          ),
          Arrays.asList(new String[] {entityIndexConfig1.getPropertyName(), entityIndexConfig2.getPropertyName()}));
   
      validate(
          createServiceResponse(Arrays.asList(instance)),
          invoke(
              client,
              "findByThreeProperties",
              entityIndexConfig1.getPropertyName(),
              Atom.getFirstOrThrow(entityIndexConfig1.getIndexValues(instance)).toString(),
              entityIndexConfig2.getPropertyName(),
              Atom.getFirstOrThrow(entityIndexConfig2.getIndexValues(instance)).toString(),
              entityIndexConfig3.getPropertyName(),
              Atom.getFirstOrThrow(entityIndexConfig3.getIndexValues(instance)).toString()
          ),
          Arrays.asList(new String[] {entityIndexConfig1.getPropertyName(), entityIndexConfig2.getPropertyName(), entityIndexConfig3.getPropertyName()}));
    }
  }
View Full Code Here


  }

  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();
        }
      };
    } else {
View Full Code Here

  }

  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

  protected Collection<Object> queryByProperties(
      String partitioningPropertyName,
      final Map<String, Object> propertyNameValueMap,
      final Integer firstResult, final Integer maxResults,
      final boolean justCount) {
    final EntityIndexConfig entityIndexConfig = resolveEntityIndexConfig(partitioningPropertyName);
    Session session = createSessionForIndex(config, entityIndexConfig, propertyNameValueMap.get(partitioningPropertyName));

    final Map<String, Entry<EntityIndexConfig, Object>> propertyNameEntityIndexConfigValueMap = createPropertyNameToValueMap(propertyNameValueMap);

    QueryCallback query;

    if (Filter.isMatch(new Predicate<String>() {
      public boolean f(String propertyName) {
        return isPrimitiveCollection(propertyName);
      }
    }, propertyNameEntityIndexConfigValueMap.keySet()))
      query = new QueryCallback() {
        public Collection<Object> execute(Session session) {
          Map<String, Object> revisedPropertyNameValueMap = Transform.toMap(
              new Unary<Entry<String, Entry<EntityIndexConfig, Object>>, String>() {
                public String f(Map.Entry<String, Map.Entry<EntityIndexConfig, Object>> item) {
                  return item.getKey();
                }
              },
              new Unary<Entry<String, Entry<EntityIndexConfig, Object>>, Object>() {
                public Object f(Map.Entry<String, Map.Entry<EntityIndexConfig, Object>> item) {
                  return item.getValue().getValue();
                }
              },
              propertyNameEntityIndexConfigValueMap.entrySet());

          return justCount
              ? queryWithHQLRowCount(session, revisedPropertyNameValueMap, firstResult, maxResults)
              : queryWithHQL(session, revisedPropertyNameValueMap, firstResult, maxResults);
        }
      };
    else
      query = new QueryCallback() {
        @SuppressWarnings("unchecked")
        public Collection<Object> execute(Session session) {
          Criteria criteria = session.createCriteria(config.getRepresentedInterface()).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
          for (Entry<EntityIndexConfig, Object> entityIndexConfigValueEntry : propertyNameEntityIndexConfigValueMap.values()) {
            EntityIndexConfig entityIndexConfig = entityIndexConfigValueEntry.getKey();
            Object value = entityIndexConfigValueEntry.getValue();
            addPropertyRestriction(entityIndexConfig, criteria, entityIndexConfig.getPropertyName(), value);
          }
          addPaging(firstResult, maxResults, criteria);
          if (justCount)
            criteria.setProjection(Projections.rowCount());
          return criteria.list();
View Full Code Here

      final Map<String, Object> propertyNameValueMap) {
    return
        Transform.toOrderedMap(
            new Unary<String, Entry<String, Entry<EntityIndexConfig, Object>>>() {
              public Entry<String, Entry<EntityIndexConfig, Object>> f(String propertyName) {
                EntityIndexConfig entityIndexConfig = resolveEntityIndexConfig(propertyName);
                DataIndexDelegate dataIndexDelegate = AnnotationHelper.getAnnotationDeeply(clazz, propertyName, DataIndexDelegate.class);
                EntityIndexConfig resolvedEntityIndexConfig = (dataIndexDelegate != null)
                    ? resolveEntityIndexConfig(dataIndexDelegate.value())
                    : entityIndexConfig;
                return new Pair<String, Entry<EntityIndexConfig, Object>>(
                    resolvedEntityIndexConfig.getPropertyName(),
                    new Pair<EntityIndexConfig, Object>(resolvedEntityIndexConfig, propertyNameValueMap.get(propertyName)));
              }
            }, propertyNameValueMap.keySet());
  }
View Full Code Here

        if (allMethodsWithAnnotation.size() == 0)
          return instance;
        Object modified = new GenerateInstance<Object>((Class<Object>) clazz).generateAndCopyProperties(instance);
        for (Method getter : allMethodsWithAnnotation) {
          String delegatorPropertyName = ReflectionTools.getPropertyNameOfAccessor(getter);
          EntityIndexConfig entityIndexConfig = config.getEntityIndexConfig(delegatorPropertyName);
          String delegatePropertyName = AnnotationHelper.getAnnotationDeeply(clazz, delegatorPropertyName, DataIndexDelegate.class).value();
          GeneratedInstanceInterceptor.setProperty(
              modified,
              delegatePropertyName,
              Filter.grepUnique(entityIndexConfig.getIndexValues(modified)));
        }
        return modified;
      }
    }, instances);
  }
View Full Code Here

    assertEquals(WeatherReport.class, config.getRepresentedInterface());
    assertEquals(Integer.class, config.getIdClass());

    Collection<EntityIndexConfig> indexes = (Collection<EntityIndexConfig>) config.getEntityIndexConfigs();

    EntityIndexConfig temperature = null;
    for (EntityIndexConfig icfg : indexes)
      if ("temperature".equals(icfg.getIndexName())) {
        temperature = icfg;
        break;
      }
    assertNotNull(temperature);
    assertEquals(int.class, temperature.getIndexClass());
    assertEquals(report.getTemperature(), Atom.getFirst(temperature.getIndexValues(report)));

    Filter.grepSingleOrNull(new Predicate<EntityIndexConfig>() {
      public boolean f(EntityIndexConfig entityIndexConfig) {
        return "weatherEventEventId".equals(entityIndexConfig.getIndexName());
      }
View Full Code Here

TOP

Related Classes of org.hivedb.configuration.EntityIndexConfig

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.