/** * Load migration configuration based on its id */ public MigrationConfiguration loadMigrationConfiguration(String migrationConfigurationId) throws IOException, LightblueException { DataFindRequest findRequest = new DataFindRequest("migrationConfiguration", null); findRequest.where(Query.withValue("_id", Query.eq, migrationConfigurationId)); findRequest.select(Projection.includeFieldRecursively("*")); LOGGER.debug("Loading configuration"); return lightblueClient.data(findRequest, MigrationConfiguration.class); }
/** * Read configurations from the database whose name matches this instance * name */ public MigrationConfiguration[] getMigrationConfigurations() throws IOException, LightblueException { DataFindRequest findRequest = new DataFindRequest("migrationConfiguration", null); findRequest.where(Query.withValue("consistencyCheckerName", Query.eq, cfg.getName())); findRequest.select(Projection.includeFieldRecursively("*")); LOGGER.debug("Loading configuration:{}", findRequest.getBody()); return lightblueClient.data(findRequest, MigrationConfiguration[].class); }
@Override public List<JsonNode> getSourceDocuments() { LOGGER.debug("Retrieving source docs"); try { DataFindRequest sourceRequest = new DataFindRequest(getMigrationConfiguration().getSourceEntityName(), getMigrationConfiguration().getSourceEntityVersion()); sourceRequest.where(Query.query((ContainerNode) JSON.toJsonNode(getMigrationJob().getQuery()))); sourceRequest.select(Projection.includeFieldRecursively("*"), Projection.excludeField("objectType")); LOGGER.debug("Source docs retrieval req: {}", sourceRequest.getBody()); JsonNode[] results = getSourceCli().data(sourceRequest, JsonNode[].class); LOGGER.debug("There are {} source docs", results.length); return Arrays.asList(results); } catch (Exception e) { LOGGER.error("Error while retrieving source documents:{}", e); throw new RuntimeException("Cannot retrieve source documents:" + e); } }
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); } } } }
req.where(Query.and(Query.withValue("status", Query.eq, MigrationJob.STATE_AVAILABLE), Query.or(qlist))); req.select(Projection.includeFieldRecursively("*")); MigrationJob[] dups = null; try {
/** * Read a configuration from the database whose name matches the the given * configuration name */ public MigrationConfiguration getMigrationConfiguration(String configurationName) throws IOException, LightblueException { DataFindRequest findRequest = new DataFindRequest("migrationConfiguration", null); findRequest.where(Query.and( Query.withValue("configurationName", Query.eq, configurationName), Query.withValue("consistencyCheckerName", Query.eq, cfg.getName())) ); findRequest.select(Projection.includeFieldRecursively("*")); LOGGER.debug("Loading configuration:{}", findRequest.getBody()); return lightblueClient.data(findRequest, MigrationConfiguration.class); }