/** * <pre> * { "$or": [{ field: <field>, regex: <^string$>, caseInsensitive: <caseInsensitive>, ... }, ... ]} * </pre> */ public static Query withStrings(String field, String[] values, boolean caseInsensitive) { if (caseInsensitive) { List<Query> regexList = new ArrayList<Query>(); for (String value : values) { regexList.add(withString(field, value, true)); } return Query.or(regexList); } else { return Query.withValues(field, Query.in, Literal.values(values)); } }
@Override public String createRangeQuery(Date startDate, Date endDate) { StringTokenizer tkz = new StringTokenizer(getMigrationConfiguration().getTimestampFieldName(), ", "); List<Query> ql = new ArrayList<>(); while (tkz.hasMoreTokens()) { String tok = tkz.nextToken(); ql.add(Query.and(Query.withValue(tok, Query.gte, startDate), Query.withValue(tok, Query.lt, endDate))); } if (ql.size() == 1) { return ql.get(0).toString(); } else { return Query.or(ql).toString(); } }
private void doDestinationDocumentFetch(List<Identity> ids, List<JsonNode> dest) throws Exception { if (ids != null && !ids.isEmpty()) { DataFindRequest destinationRequest = new DataFindRequest(getMigrationConfiguration().getDestinationEntityName(), getMigrationConfiguration().getDestinationEntityVersion()); List<Query> requestConditions = new ArrayList<>(); for (Identity id : ids) { List<Query> docConditions = new ArrayList<>(); int i = 0; for (String keyField : getMigrationConfiguration().getDestinationIdentityFields()) { Object v = id.get(i); Query docQuery = Query.withValue(keyField, Query.eq, v == null ? null : v.toString()); docConditions.add(docQuery); i++; } requestConditions.add(Query.and(docConditions)); } destinationRequest.where(Query.or(requestConditions)); destinationRequest.select(Projection.includeFieldRecursively("*"), Projection.excludeField("objectType")); LOGGER.debug("Fetching destination docs {}", destinationRequest.getBody()); JsonNode[] nodes = getDestCli().data(destinationRequest, JsonNode[].class); if (nodes != null) { LOGGER.debug("There are {} destination docs", nodes.length); for (JsonNode node : nodes) { dest.add(node); } } } }
DataFindRequest req = new DataFindRequest("migrationJob", null); req.where(Query.and(Query.withValue("status", Query.eq, MigrationJob.STATE_AVAILABLE), Query.or(qlist))); req.select(Projection.includeFieldRecursively("*")); MigrationJob[] dups = null;