Java 类com.mongodb.QueryOperators 实例源码

项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> allImagesFor(Product product, CatalogMediaType... catalogMediaTypes) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.IMAGE_JPEG);
    mimeTypes.add(MimeType.IMAGE_GIF);
    mimeTypes.add(MimeType.IMAGE_PNG);
    mimeTypes.add(MimeType.IMAGE_BMP);
    mimeTypes.add(MimeType.IMAGE_TIFF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    if (catalogMediaTypes != null && catalogMediaTypes.length > 0) {
        List<Id> catMediaTypeIds = Ids.toIdList(catalogMediaTypes);

        DBObject inClause2 = new BasicDBObject();
        inClause2.put(QueryOperators.IN, catMediaTypeIds);
        filter.put(Col.MEDIA_TYPE_IDS, inClause2);
    }

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> allImagesFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.IMAGE_JPEG);
    mimeTypes.add(MimeType.IMAGE_GIF);
    mimeTypes.add(MimeType.IMAGE_PNG);
    mimeTypes.add(MimeType.IMAGE_BMP);
    mimeTypes.add(MimeType.IMAGE_TIFF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> enabledImagesFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.IMAGE_JPEG);
    mimeTypes.add(MimeType.IMAGE_GIF);
    mimeTypes.add(MimeType.IMAGE_PNG);
    mimeTypes.add(MimeType.IMAGE_BMP);
    mimeTypes.add(MimeType.IMAGE_TIFF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);
    filter.put(Col.PRODUCT_ID, product.getId());

    Map<String, Object> inClause = new LinkedHashMap<>();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> enabledImagesFor(Id... productIds) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.IMAGE_JPEG);
    mimeTypes.add(MimeType.IMAGE_GIF);
    mimeTypes.add(MimeType.IMAGE_PNG);
    mimeTypes.add(MimeType.IMAGE_BMP);
    mimeTypes.add(MimeType.IMAGE_TIFF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);

    Map<String, Object> inClause = new LinkedHashMap<>();
    inClause.put(QueryOperators.IN, productIds);
    filter.put(Col.PRODUCT_ID, inClause);

    Map<String, Object> inClause2 = new LinkedHashMap<>();
    inClause2.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause2);

    return simpleContextFind(CatalogMediaAsset.class, filter,
        QueryOptions.builder().singleQueryField(Col.PRODUCT_ID).build());
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> allVideosFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.VIDEO_WEBM);
    mimeTypes.add(MimeType.VIDEO_MP4);
    mimeTypes.add(MimeType.VIDEO_OGG);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> enabledVideosFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.VIDEO_WEBM);
    mimeTypes.add(MimeType.VIDEO_MP4);
    mimeTypes.add(MimeType.VIDEO_OGG);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:AbstractMongoDao.java   
private DBObject createBetweenFilter(Object value) {
    JSONObject dateRange = parseDateRange(value);

    org.joda.time.format.DateTimeFormatter parser = ISODateTimeFormat.dateTime();

    BasicDBObjectBuilder start = BasicDBObjectBuilder.start();

    if (dateRange.get("startDate") != null) {
        DateTime startDate = parser.parseDateTime((String) dateRange.get("startDate"));
        start.add(QueryOperators.GTE, startDate.toDate());
    }

    if (dateRange.get("endDate") != null) {
        DateTime endDate = parser.parseDateTime((String) dateRange.get("endDate"));
        start.add(QueryOperators.LTE, endDate.toDate());
    }

    return start.get();
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> thatAreMandatory(AttributeTargetObject targetObject, QueryOptions queryOptions,
    boolean includeOptOutAttributes) {
    Map<String, Object> filter = new LinkedHashMap<String, Object>();
    filter.put(Attribute.Col.ENABLED, true);

    if (includeOptOutAttributes) {
        Map<String, int[]> in = new LinkedHashMap<>();
        in.put(QueryOperators.IN, new int[] { InputType.MANDATORY.toId(), InputType.OPTOUT.toId() });

        filter.put(Attribute.Col.INPUT_TYPE, in);
    } else {
        filter.put(Attribute.Col.INPUT_TYPE, InputType.MANDATORY.toId());
    }

    if (targetObject != null) {
        filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
    }

    return multiContextFind(Attribute.class, filter, Attribute.Col.CODE);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> thatAreMandatoryAndEditable(AttributeTargetObject targetObject, QueryOptions queryOptions,
    boolean includeOptOutAttributes) {
    Map<String, Object> filter = new LinkedHashMap<String, Object>();
    filter.put(Attribute.Col.ENABLED, true);
    filter.put(Attribute.Col.EDITABLE, true);

    if (includeOptOutAttributes) {
        Map<String, int[]> in = new LinkedHashMap<>();
        in.put(QueryOperators.IN, new int[] { InputType.MANDATORY.toId(), InputType.OPTOUT.toId() });

        filter.put(Attribute.Col.INPUT_TYPE, in);
    } else {
        filter.put(Attribute.Col.INPUT_TYPE, InputType.MANDATORY.toId());
    }

    if (targetObject != null) {
        filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
    }

    return multiContextFind(Attribute.class, filter, Attribute.Col.CODE, queryOptions);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> forSearchFilter(List<AttributeTargetObject> targetObjects) {
    List<Map<String, Object>> filters = new ArrayList<>();

    for (AttributeTargetObject targetObject : targetObjects) {
        Map<String, Object> filter = new LinkedHashMap<>();
        filter.put(Attribute.Col.ENABLED, true);
        filter.put(Attribute.Col.INCLUDE_IN_SEARCH_FILTER, true);
        filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
        filters.add(filter);
    }

    Map<String, Object> orFilter = new LinkedHashMap<>();
    orFilter.put(QueryOperators.OR, filters);

    return multiContextFind(Attribute.class, orFilter, Attribute.Col.CODE);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> forProductListFilter(List<AttributeTargetObject> targetObjects) {
    List<Map<String, Object>> filters = new ArrayList<>();

    for (AttributeTargetObject targetObject : targetObjects) {
        Map<String, Object> filter = new LinkedHashMap<>();
        filter.put(Attribute.Col.ENABLED, true);
        filter.put(Attribute.Col.INCLUDE_IN_PRODUCT_LIST_FILTER, true);
        filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
        filters.add(filter);
    }

    Map<String, Object> orFilter = new LinkedHashMap<>();
    orFilter.put(QueryOperators.OR, filters);

    return multiContextFind(Attribute.class, orFilter, Attribute.Col.CODE);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> forSearchFilter(String... targetObjectCodes) {
    List<Map<String, Object>> filters = new ArrayList<>();

    for (String targetObjectCode : targetObjectCodes) {

        AttributeTargetObject targetObject = attributeTargetObjects.havingCode(targetObjectCode);

        if (targetObject != null) {
            Map<String, Object> filter = new LinkedHashMap<>();
            filter.put(Attribute.Col.ENABLED, true);
            filter.put(Attribute.Col.INCLUDE_IN_SEARCH_FILTER, true);
            filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
            filters.add(filter);
        }
    }

    Map<String, Object> orFilter = new LinkedHashMap<>();
    orFilter.put(QueryOperators.OR, filters);

    return multiContextFind(Attribute.class, orFilter, Attribute.Col.CODE);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAttributes.java   
@Override
public List<Attribute> forProductListFilter(String... targetObjectCodes) {
    List<Map<String, Object>> filters = new ArrayList<>();

    for (String targetObjectCode : targetObjectCodes) {

        AttributeTargetObject targetObject = attributeTargetObjects.havingCode(targetObjectCode);

        if (targetObject != null) {
            Map<String, Object> filter = new LinkedHashMap<>();
            filter.put(Attribute.Col.ENABLED, true);
            filter.put(Attribute.Col.INCLUDE_IN_PRODUCT_LIST_FILTER, true);
            filter.put(Attribute.Col.TARGET_OBJECT_ID, targetObject.getId());
            filters.add(filter);
        }
    }

    Map<String, Object> orFilter = new LinkedHashMap<>();
    orFilter.put(QueryOperators.OR, filters);

    return multiContextFind(Attribute.class, orFilter, Attribute.Col.CODE);
}
项目:render    文件:RenderDao.java   
public void removeTilesWithIds(final StackId stackId,
                               final List<String> tileIds)
        throws IllegalArgumentException {

    MongoUtil.validateRequiredParameter("stackId", stackId);
    MongoUtil.validateRequiredParameter("tileIds", tileIds);

    final MongoCollection<Document> tileCollection = getTileCollection(stackId);
    final Document tileQuery = new Document("tileId",
                                            new Document(QueryOperators.IN,
                                                         tileIds));
    final Document tileQueryForLog = new Document("tileId",
                                                  new Document(QueryOperators.IN,
                                                               Arrays.asList("list of",
                                                                             tileIds.size() + " tileIds")));
    final DeleteResult removeResult = tileCollection.deleteMany(tileQuery);

    LOG.debug("removeTilesWithIds: {}.remove({}) deleted {} document(s)",
              MongoUtil.fullName(tileCollection), tileQueryForLog.toJson(), removeResult.getDeletedCount());
}
项目:render    文件:RenderDao.java   
private List<TransformSpec> getTransformSpecs(final MongoCollection<Document> transformCollection,
                                              final Set<String> specIds) {
    final int specCount = specIds.size();
    final List<TransformSpec> transformSpecList = new ArrayList<>(specCount);
    if (specCount > 0) {

        final Document transformQuery = new Document();
        transformQuery.put("id", new Document(QueryOperators.IN, specIds));

        LOG.debug("getTransformSpecs: {}.find({})",
                  MongoUtil.fullName(transformCollection), transformQuery.toJson());

        try (MongoCursor<Document> cursor = transformCollection.find(transformQuery).iterator()) {
            Document document;
            TransformSpec transformSpec;
            while (cursor.hasNext()) {
                document = cursor.next();
                transformSpec = TransformSpec.fromJson(document.toJson());
                transformSpecList.add(transformSpec);
            }
        }

    }

    return transformSpecList;
}
项目:GitHub    文件:Support.java   
@Override
public ConstraintBuilder in(String name, boolean negate, Iterable<?> values) {
  addContraint(name,
      new Document(
          negate ? QueryOperators.NIN : QueryOperators.IN,
          ImmutableSet.copyOf(unwrapBsonableIterable(values))));
  return this;
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAccounts.java   
@Override
public List<Account> havingUsername(String username, Merchant merchant) {
    if (username == null || merchant == null)
        return null;

    Map<String, Object> in = new HashMap<>();
    in.put(QueryOperators.IN, new Id[] { merchant.getId() });

    Map<String, Object> filter = new HashMap<>();
    filter.put(Account.Column.USERNAME, username);
    filter.put(Account.Column.ENABLED, true);
    filter.put(GlobalColumn.MERCHANT_ID, in);

    return find(Account.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAccounts.java   
@Override
public List<Account> havingUsername(String username, Store store) {
    if (username == null || store == null)
        return null;

    Map<String, Object> in = new HashMap<>();
    in.put(QueryOperators.IN, new Id[] { store.getId() });

    Map<String, Object> filter = new HashMap<>();
    filter.put(Account.Column.USERNAME, username);
    filter.put(Account.Column.ENABLED, true);
    filter.put(GlobalColumn.STORE_ID, in);

    return find(Account.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultAccounts.java   
@Override
public List<Account> havingUsername(String username, RequestContext reqCtx) {
    if (username == null || reqCtx == null)
        return null;

    Map<String, Object> in = new HashMap<>();
    in.put(QueryOperators.IN, new Id[] { reqCtx.getId() });

    Map<String, Object> filter = new HashMap<>();
    filter.put(Account.Column.USERNAME, username);
    filter.put(Account.Column.ENABLED, true);
    filter.put(GlobalColumn.REQUEST_CONTEXT_ID, in);

    return find(Account.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultNewsSubscribers.java   
@Override
public NewsSubscriber thatBelongTo(String email, Store store) {
    Map<String, Object> in = new HashMap<>();
    in.put(QueryOperators.IN, new Id[] { store.getId() });

    Map<String, Object> filter = new HashMap<>();
    filter.put(NewsSubscriber.Col.EMAIL, email);
    filter.put(GlobalColumn.STORE_ID, in);

    return findOne(NewsSubscriber.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> enabledImagesFor(Product product, CatalogMediaType... catalogMediaTypes) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.IMAGE_JPEG);
    mimeTypes.add(MimeType.IMAGE_GIF);
    mimeTypes.add(MimeType.IMAGE_PNG);
    mimeTypes.add(MimeType.IMAGE_BMP);
    mimeTypes.add(MimeType.IMAGE_TIFF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    if (catalogMediaTypes != null && catalogMediaTypes.length > 0) {
        List<Id> catMediaTypeIds = Ids.toIdList(catalogMediaTypes);

        DBObject inClause2 = new BasicDBObject();
        inClause2.put("$in", catMediaTypeIds);
        filter.put(Col.MEDIA_TYPE_IDS, inClause2);
    }

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> allDocumentsFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.APPLICATION_PDF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> enabledDocumentsFor(Product product) {
    List<String> mimeTypes = new ArrayList<>();
    mimeTypes.add(MimeType.APPLICATION_PDF);

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);
    filter.put(Col.PRODUCT_ID, product.getId());

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, mimeTypes);
    filter.put(Col.MIME_TYPE, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> assetsThatBelongTo(Id... productIds) {
    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.ENABLED, true);

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, productIds);
    filter.put(Col.PRODUCT_ID, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultCatalogMedia.java   
@Override
public List<CatalogMediaAsset> allAssetsThatBelongTo(Id... productIds) {
    Map<String, Object> filter = new LinkedHashMap<>();

    DBObject inClause = new BasicDBObject();
    inClause.put(QueryOperators.IN, productIds);
    filter.put(Col.PRODUCT_ID, inClause);

    return simpleContextFind(CatalogMediaAsset.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:DefaultProducts.java   
@Override
public List<Product> havingProgrammeChildProduct(Product childProduct) {
    if (childProduct == null || childProduct.getId() == null)
        return null;

    Map<String, Object> in = new LinkedHashMap<>();
    in.put(QueryOperators.IN, new Id[] { childProduct.getId() });

    Map<String, Object> filter = new LinkedHashMap<>();
    filter.put(Col.PROGRAMME_PRODUCTS, in);
    filter.put(Product.Col.DELETED, false);
    filter.put(Product.Col.TYPE, ProductType.PROGRAMME.toId());

    return simpleContextFind(Product.class, filter);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:PostgresRepositorySupport.java   
protected <T extends MultiContextModel> Map<String, Object> getNotInClauseForAlreadyFetchedResults(
    List<T> resultObjects, String distinctFieldName) {
    List<Object> values = getValuesByDistinctField(resultObjects, distinctFieldName);

    Map<String, Object> notInClause = new LinkedHashMap<>();

    if (values != null && values.size() > 0) {
        notInClause.put(QueryOperators.NIN, values);
    }

    return notInClause;
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MySqlRepositorySupport.java   
protected <T extends MultiContextModel> Map<String, Object> getNotInClauseForAlreadyFetchedResults(
    List<T> resultObjects, String distinctFieldName) {
    List<Object> values = getValuesByDistinctField(resultObjects, distinctFieldName);

    Map<String, Object> notInClause = new LinkedHashMap<>();

    if (values != null && values.size() > 0) {
        notInClause.put(QueryOperators.NIN, values);
    }

    return notInClause;
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:AbstractMongoDao.java   
@Override
public <T extends Model> List<T> findSnapshots(Class<T> modelClass, Id id, Integer[] versions,
    QueryOptions queryOptions) {
    Map<String, Object> inClause = new HashMap<>();
    inClause.put(QueryOperators.IN, versions);

    Map<String, Object> filter = new HashMap<>();
    filter.put(GlobalColumn.HISTORY_ID, id);
    filter.put(GlobalColumn.VERSION, inClause);

    return findSnapshots(modelClass, filter, queryOptions);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:AbstractMongoDao.java   
/**
 * Build query filter from map.
 */
protected <T extends Model> DBObject buildQueryFilter(Class<T> modelClass, Map<String, Object> filter,
    QueryOptions queryOptions) {
    DBObject dbObject = new BasicDBObject();

    if (filter != null && filter.size() > 0) {
        List<ColumnInfo> columns = Annotations.getColumns(modelClass);

        Set<String> filterKeys = filter.keySet();

        for (String key : filterKeys) {
            Object value = filter.get(key);

            if (value == null) {
                dbObject.put(Models.columnName(columns, key), value);
            } else if (value instanceof String && ObjectId.isValid((String) value)) {
                dbObject.put(Models.columnName(columns, key), new ObjectId((String) filter.get(key)));
            } else if (isDateRange(value)) {
                DBObject between = createBetweenFilter(value);

                dbObject.put(Models.columnName(columns, key), between);
            }
            // TODO
            else if ((value instanceof Collection || value.getClass().isArray()) && !key.equals(QueryOperators.IN)
                && !key.equals(QueryOperators.AND) && !key.equals(QueryOperators.OR)) {
                dbObject.put(Models.columnName(columns, key), new BasicDBObject(QueryOperators.IN, value));
            } else if (isProbableBoolean(key, filter.get(key))) {
                dbObject.put(Models.columnName(columns, key), TypeConverter.asBoolean(filter.get(key)));
            } else {
                processFilterPart(modelClass, key, Models.columnName(columns, key), filter.get(key), dbObject,
                    queryOptions);

                // dbObject.put(columnName(columns, key),
                // processCommandIfExists(filter.get(key)));
            }
        }
    }

    return dbObject;
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addCtxObjFilter(Map<String, Object> targetFilter, String key, Object value) {
    Map<String, Object> valuePart = new LinkedHashMap<String, Object>();
    valuePart.put(ContextObject.VALUE, value);
    Map<String, Object> elemMatchPart = new LinkedHashMap<String, Object>();
    elemMatchPart.put(QueryOperators.ELEM_MATCH, valuePart);

    targetFilter.put(key, elemMatchPart);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addCtxObjFilter(Map<String, Object> targetFilter, String key, Object value, String language) {
    Map<String, Object> valuePart = new LinkedHashMap<String, Object>();
    valuePart.put(ContextObject.VALUE, value);
    valuePart.put(ContextObject.LANGUAGE, language);

    Map<String, Object> elemMatchPart = new LinkedHashMap<String, Object>();
    elemMatchPart.put(QueryOperators.ELEM_MATCH, valuePart);

    targetFilter.put(key, elemMatchPart);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addCtxObjFilter(Map<String, Object> targetFilter, String key, Object value, Store store) {
    Map<String, Object> valuePart = new LinkedHashMap<String, Object>();
    valuePart.put(ContextObject.VALUE, value);
    valuePart.put(ContextObject.STORE, store.getId());

    Map<String, Object> elemMatchPart = new LinkedHashMap<String, Object>();
    elemMatchPart.put(QueryOperators.ELEM_MATCH, valuePart);

    targetFilter.put(key, elemMatchPart);
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addMerchantFilter(Map<String, Object> targetFilter, Merchant merchant) {
    if (merchant == null) {
        ApplicationContext appCtx = App.get().context();
        merchant = appCtx.getMerchant();
    }

    if (merchant != null && merchant.getId() != null) {
        DBObject inClause = new BasicDBObject();
        inClause.put(QueryOperators.IN, new Id[] { merchant.getId() });

        targetFilter.put(GlobalColumn.MERCHANT_ID, inClause);
    }
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addStoreFilter(Map<String, Object> targetFilter, Store store) {
    if (store == null) {
        ApplicationContext appCtx = App.get().context();
        store = appCtx.getStore();
    }

    if (store != null && store.getId() != null) {
        DBObject inClause = new BasicDBObject();
        inClause.put(QueryOperators.IN, new Id[] { store.getId() });

        targetFilter.put(GlobalColumn.STORE_ID, inClause);
    }
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoQueries.java   
public static void addRequestContextFilter(Map<String, Object> targetFilter, RequestContext reqCtx) {
    if (reqCtx == null) {
        ApplicationContext appCtx = App.get().context();
        reqCtx = appCtx.getRequestContext();
    }

    if (reqCtx != null && reqCtx.getId() != null) {
        DBObject inClause = new BasicDBObject();
        inClause.put(QueryOperators.IN, new Id[] { reqCtx.getId() });

        targetFilter.put(GlobalColumn.REQUEST_CONTEXT_ID, inClause);
    }
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoRepositorySupport.java   
protected <T extends MultiContextModel> Map<String, Object> getNotInClauseForAlreadyFetchedResults(
    List<T> resultObjects, String distinctFieldName) {
    List<Object> values = getValuesByDistinctField(resultObjects, distinctFieldName);

    Map<String, Object> notInClause = new LinkedHashMap<>();

    if (values != null && values.size() > 0) {
        notInClause.put(QueryOperators.NIN, values);
    }

    return notInClause;
}
项目:geeCommerce-Java-Shop-Software-and-PIM    文件:MongoRepositorySupport.java   
@SuppressWarnings("unchecked")
public void appendAttributeCondition(AttributeTargetObject targetObject, String attributeCode, Object value,
    Map<String, Object> query) {
    Map<String, Object> attributes = (Map<String, Object>) query
        .get(AttributeSupport.AttributeSupportColumn.ATTRIBUTES);

    // ---------------------------------------------------------------
    // As this may not be the first command to set an attribute query,
    // we make sure that we always add to an existing list.
    // ---------------------------------------------------------------
    if (attributes == null) {
        attributes = new LinkedHashMap<>();
        attributes.put(QueryOperators.ALL, new ArrayList<>());
        query.put(AttributeSupport.AttributeSupportColumn.ATTRIBUTES, attributes);
    }

    List<Map<String, Object>> allAttributes = (List<Map<String, Object>>) attributes.get(QueryOperators.ALL);

    // ---------------------------------------------------------------
    // Build the actual attribute value query part.
    // ---------------------------------------------------------------

    Map<String, Object> valueMap = new LinkedHashMap<>();
    valueMap.put(FIELD_VAL, value);

    Id attributeId = Attributes.getAttributeId(targetObject.getId(), attributeCode);

    Map<String, Object> attrVal = new LinkedHashMap<>();
    attrVal.put(FIELD_ATTR_ID, attributeId);
    attrVal.put(FIELD_VAL, elemMatch(valueMap));

    allAttributes.add(elemMatch(attrVal));
}
项目:render    文件:RenderDao.java   
public void cloneStack(final StackId fromStackId,
                       final StackId toStackId,
                       final List<Double> zValues,
                       final Boolean skipTransforms)
        throws IllegalArgumentException, IllegalStateException {

    MongoUtil.validateRequiredParameter("fromStackId", fromStackId);
    MongoUtil.validateRequiredParameter("toStackId", toStackId);

    if ((skipTransforms == null) || (! skipTransforms)) {
        final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId);
        final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId);
        cloneCollection(fromTransformCollection, toTransformCollection, new Document());
    }

    final Document filterQuery = new Document();
    if ((zValues != null) && (zValues.size() > 0)) {
        final BasicDBList list = new BasicDBList();
        list.addAll(zValues);
        final Document zFilter = new Document(QueryOperators.IN, list);
        filterQuery.append("z", zFilter);
    }

    final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId);
    final MongoCollection<Document> toTileCollection = getTileCollection(toStackId);
    cloneCollection(fromTileCollection, toTileCollection, filterQuery);
}
项目:render    文件:MatchDao.java   
private Document getOutsideGroupQuery(final String groupId) {
    final List<Document> queryList = new ArrayList<>();
    queryList.add(new Document("pGroupId", groupId).append(
            "qGroupId", new Document(QueryOperators.NE, groupId)));
    queryList.add(new Document("qGroupId", groupId).append(
            "pGroupId", new Document(QueryOperators.NE, groupId)));
    return new Document(QueryOperators.OR, queryList);
}