@Override public HashMap<Enum, Boolean> deployQueryOptions() { // save them first saveQueryOptions(); HashMap<Enum, Boolean> loadedResources = new HashMap<>(); if (deployFinalQueryOptions()) loadedResources.put(DatabaseKind.FINAL, true); if (deployStagingQueryOptions()) loadedResources.put(DatabaseKind.STAGING, true); return loadedResources; }
public boolean deployStagingQueryOptions() { return deployQueryOptions(hubConfig.newStagingClient(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE); }
private List<JsonNode> getModifiedRawEntities(long minimumFileTimestampToLoad) { logger.debug("min modified: " + minimumFileTimestampToLoad); HubModuleManager propsManager = getPropsMgr(); propsManager.setMinimumFileTimestampToLoad(minimumFileTimestampToLoad);
@Override public boolean saveDbIndexes() { try { Path dir = hubConfig.getEntityDatabaseDir(); File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_DATABASE_FILE).toFile(); File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_DATABASE_FILE).toFile(); if (!dir.toFile().exists()) { dir.toFile().mkdirs(); } List<JsonNode> entities = getAllEntities(); if (entities.size() > 0) { DbIndexGenerator generator = new DbIndexGenerator(hubConfig.newReverseFlowClient()); String indexes = generator.getIndexes(entities); // in order to make entity indexes ml-app-deployer compatible, add database-name keys. // ml-app-deployer removes these keys upon sending to marklogic. ObjectNode indexNode = (ObjectNode) mapper.readTree(indexes); indexNode.put("database-name", "%%mlFinalDbName%%"); mapper.writerWithDefaultPrettyPrinter().writeValue(finalFile, indexNode); indexNode.put("database-name", "%%mlStagingDbName%%"); mapper.writerWithDefaultPrettyPrinter().writeValue(stagingFile, indexNode); return true; } } catch (IOException e) { e.printStackTrace(); } return false; }
@Override public boolean saveQueryOptions() { QueryOptionsGenerator generator = new QueryOptionsGenerator(hubConfig.newStagingClient()); try { Path dir = hubProject.getEntityConfigDir(); if (!dir.toFile().exists()) { dir.toFile().mkdirs(); } File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile(); File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile(); long lastModified = Math.max(stagingFile.lastModified(), finalFile.lastModified()); List<JsonNode> entities = getModifiedRawEntities(lastModified); if (entities.size() > 0) { String options = generator.generateOptions(entities); FileUtils.writeStringToFile(stagingFile, options); FileUtils.writeStringToFile(finalFile, options); return true; } } catch (IOException e) { e.printStackTrace(); } return false; }
private boolean deployQueryOptions(DatabaseClient client, String filename) { HubModuleManager propsManager = getPropsMgr(); DefaultModulesLoader modulesLoader = new DefaultModulesLoader(new AssetFileLoader(hubConfig.newFinalClient(), propsManager)); boolean isLoaded = false; modulesLoader.setModulesManager(propsManager); modulesLoader.setShutdownTaskExecutorAfterLoadingModules(false); Path dir = hubProject.getEntityConfigDir(); File stagingFile = Paths.get(dir.toString(), filename).toFile(); if (stagingFile.exists()) { modulesLoader.setDatabaseClient(client); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); if (r != null) { isLoaded = true; } } modulesLoader.setShutdownTaskExecutorAfterLoadingModules(true); modulesLoader.waitForTaskExecutorToFinish(); return isLoaded; }
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); List<JsonNode> entities = getAllEntities(); if (entities.size() > 0) { PiiGenerator piiGenerator = new PiiGenerator(hubConfig.newReverseFlowClient());
public boolean deployFinalQueryOptions() { return deployQueryOptions(hubConfig.newFinalClient(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE); }