当前位置: 首页>>代码示例>>Java>>正文


Java Query.FilterPredicate方法代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.Query.FilterPredicate方法的典型用法代码示例。如果您正苦于以下问题:Java Query.FilterPredicate方法的具体用法?Java Query.FilterPredicate怎么用?Java Query.FilterPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.datastore.Query的用法示例。


在下文中一共展示了Query.FilterPredicate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLastStatus

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
private ArrayList<Medicion> getLastStatus(int amountData) {
    // Poner Key estacion + hora_muestra
    Calendar calendarTwoAgo = Calendar.getInstance(TimeZone.getTimeZone("CET"));
    calendarTwoAgo.add(Calendar.DATE, -3);
    Date dateTwoAgo = calendarTwoAgo.getTime();

    // Prepare
    Query.Filter keyFilter = new Query.FilterPredicate(PROPERTY_MEASURE_DATE, Query.FilterOperator.GREATER_THAN, dateTwoAgo);
    Query.Filter no2Filter = new Query.FilterPredicate(PROPERTY_COMPUESTO, Query.FilterOperator.EQUAL, NO2.name());
    List<Query.Filter> filterList = new ArrayList<>();
    filterList.add(keyFilter);
    filterList.add(no2Filter);
    Query.Filter filter = new Query.CompositeFilter(Query.CompositeFilterOperator.AND, filterList);
    Query query = new Query(ENTITY_TYPE_MEDIDAS)
            .setFilter(filter)
            .addSort(PROPERTY_MEASURE_DATE
                    , Query.SortDirection.DESCENDING);

    // Query
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    PreparedQuery pq = datastore.prepare(query);
    // Get results

    List<com.google.appengine.api.datastore.Entity> resultList = pq.asList(FetchOptions.Builder.withLimit(amountData));
    ArrayList<Medicion> result = new ArrayList<>();
    if (resultList.size()!=0) {
        mLogger.info("Watching " + resultList.size() + " last values of ESTADO");
        for (com.google.appengine.api.datastore.Entity item : resultList){
            result.add(new Medicion((Date) item.getProperty(PROPERTY_MEASURE_DATE), (String) item.getProperty(PROPERTY_AVISO), (String) item.getProperty(PROPERTY_AVISO_STATE), (String) item.getProperty(PREPERTY_AVISO_MAX_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW),  (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW_MANUAL) ,isPureMadrid()));
        }
    } else {
        // No hay datos
        mLogger.info("No previous values for ESTADO");
    }
    return result;
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:37,代码来源:GetNewData.java

示例2: doExecute

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
protected Object doExecute(Object[] parameters) {
    Class<?> domainClass = queryMethod.getEntityInformation().getJavaType();
    int paramIndex = 0;
    
    PartTree tree = new PartTree(getQueryMethod().getName(), getQueryMethod().getEntityInformation().getJavaType());
    System.out.println(tree);
    
    List<Filter> orFilters = new ArrayList<Filter>();
    for (Iterator<OrPart> orPartIter = tree.iterator(); orPartIter.hasNext();) {
        OrPart orPart = orPartIter.next();
        
        List<Filter> andFilters = new ArrayList<Filter>();
        for (Iterator<Part> partIter = orPart.iterator(); partIter.hasNext();) {
            Part part = partIter.next();
            PropertyPath propertyPath  = part.getProperty();
            String propName = propertyPath.getSegment();
            Object propValue = parameters[paramIndex++];
            
            FilterOperator operator = getFilterOperation(part);
            Filter filter = new Query.FilterPredicate(propName, operator, propValue);
            andFilters.add(filter);
        }
        if (andFilters.size() == 1) {
            orFilters.add(andFilters.get(0));
        } else if (andFilters.size() >= 2){
            orFilters.add(CompositeFilterOperator.and(andFilters));
        }
    }
    
    com.googlecode.objectify.cmd.Query q = ofy().load().type(domainClass);
    if (orFilters.size() == 1) {
        q = q.filter(orFilters.get(0));
    } else if (orFilters.size() >= 2){
        q = q.filter(CompositeFilterOperator.or(orFilters));
    }
    return q.list();
}
 
开发者ID:nhuttrung,项目名称:spring-data-objectify,代码行数:38,代码来源:ObjectifyRepositoryQuery.java

示例3: getStatusAt

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
@ApiMethod(path = "getStatusAt", name = "getStatusAt", httpMethod = ApiMethod.HttpMethod.GET)
    public ApiMedicion getStatusAt(@Named("amount") Date date) {

        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("CET"));

//         Fix offset
        if (date.getTime() < 1505341800L * 1000){
            date.setTime(date.getTime() - 3600L * 1000);
        }
        date.setTime(date.getTime());

        calendar.setTime(date);
        calendar.setTimeZone(TimeZone.getTimeZone("CET"));



        // Prepare
        Query.FilterPredicate filter = new Query.FilterPredicate(PROPERTY_MEASURE_DATE, Query.FilterOperator.EQUAL, date);
        Query query = new Query(ENTITY_TYPE_MEDIDAS).setFilter(filter);

        // Query
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        PreparedQuery pq = datastore.prepare(query);
        List<Entity> resultList = pq.asList(FetchOptions.Builder.withDefaults());

        ApiMedicion medicion = new Medicion(MainServlet.isPureMadrid());
        for (Entity entity : resultList){

            Map<String, Object> properties = entity.getProperties();
            Map<String, Object> mapMeditions = new HashMap<>();

            String propertyCompuesto = (String) entity.getProperty(PROPERTY_COMPUESTO);
            Compuesto compuesto = Compuesto.withName(propertyCompuesto);

            medicion.setMeasuredAt((Date) entity.getProperty(PROPERTY_MEASURE_DATE));
            medicion.setSavedAtHour((Date) entity.getProperty(PROPERTY_SAVED_AT));
            if (entity.getProperty(PROPERTY_COMPUESTO).equals(Compuesto.NO2)){
                medicion.setAviso((String) entity.getProperty(PROPERTY_AVISO));
                medicion.setAvisoState((String) entity.getProperty(PROPERTY_AVISO_STATE));
                medicion.setAvisoMaxToday((String) entity.getProperty(PREPERTY_AVISO_MAX_TODAY));
                medicion.setEscenarioStateToday((String) entity.getProperty(PROPERTY_ESCENARIO_STATE_TODAY));
                medicion.setEscenarioStateTomorrow((String)  entity.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW));
            }

            for (Map.Entry<String, Object> entry : properties.entrySet()) {
                if(entry.getKey().contains(PROPERTY_ESTACION_BEGINS)){
                    try {
                        mapMeditions.put(entry.getKey(), parseValue(entry.getValue()));
                    } catch (Exception e){
                        mLogger.warning("Error parsing data from Datastore: " + entry.getValue());
                    }
                }
            }
            medicion.put(compuesto,mapMeditions);

        }

        return medicion;
    }
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:60,代码来源:PureMadridApi.java

示例4: toPredicate

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
private Query.Filter toPredicate(Condition condition) {
    return new Query.FilterPredicate(condition.getProperty().getName(), convert(condition), condition.getValue());
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:4,代码来源:FilterCriteriaConverter.java


注:本文中的com.google.appengine.api.datastore.Query.FilterPredicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。