@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; }
@Override public Path getFlowDir(String entityName, String flowName, FlowType flowType) { Path entityDir = project.getEntityDir(entityName); Path typeDir = entityDir.resolve(flowType.toString()); Path flowDir = typeDir.resolve(flowName); return flowDir; }
@JsonIgnore @Override public Path getHubConfigDir() { return hubProject.getHubConfigDir(); }
boolean alreadyInitialized = project.isInitialized(); try { File buildGradle = Paths.get(project.getProjectDirString(), "build.gradle").toFile(); FileUtils.copyDirectory(project.getHubConfigDir().toFile(), project.getProjectDir().resolve(HubProject.HUB_CONFIG_DIR+"-"+gradleVersion).toFile()); FileUtils.copyDirectory(project.getUserConfigDir().toFile(), project.getProjectDir().resolve(HubProject.USER_CONFIG_DIR+"-"+gradleVersion).toFile()); hubConfig.getHubProject().upgradeProject(); List<String> flows = flowManager.updateLegacyFlows(currentVersion); if (updatedFlows != null) {
Path userModulesDir = project.getUserFinalModulesDir(); Path finalTriggersDir = project.getUserDatabaseDir() .resolve(HubConfig.DEFAULT_FINAL_TRIGGERS_DB_NAME) .resolve("triggers"); Path stagingTriggersDir = project.getUserDatabaseDir() .resolve(HubConfig.DEFAULT_STAGING_TRIGGERS_DB_NAME) .resolve("triggers"); Path hubSchemasDir = project.getHubConfigDir().resolve("schemas"); Path hubModulesDir = project.getHubStagingModulesDir();
@Override @Deprecated public String getUserModulesDeployTimestampFile() { return hubProject.getUserModulesDeployTimestampFile(); }
@JsonIgnore @Override public Path getHubEntitiesDir() { return hubProject.getHubEntitiesDir(); }
@Override @Deprecated public String getProjectDir() { return hubProject.getProjectDirString(); }
@JsonIgnore public Path getHubProjectDir() { return hubProject.getProjectDir(); }
@Test public void initializeProject() { assertEquals(0, ((Collection<ProjectInfo>)pc.getProjects().get("projects")).size()); pc.addProject(projectPath); assertEquals(1, ((Collection<ProjectInfo>)pc.getProjects().get("projects")).size()); ObjectMapper objectMapper = new ObjectMapper(); pc.initializeProject(1, objectMapper.valueToTree(adminHubConfig)); // assertTrue(pc.getProject(1).isInitialized()); assertTrue(adminHubConfig.getHubProject().isInitialized()); }
@Override public void createMappingDir(String mappingName) { Path mappingDir = project.getMappingDir(mappingName); mappingDir.toFile().mkdirs(); }
@JsonIgnore @Override public Path getUserDatabaseDir() { return hubProject.getUserDatabaseDir(); }
private HubModuleManager getPropsMgr() { String timestampFile = hubProject.getUserModulesDeployTimestampFile(); HubModuleManager propertiesModuleManager = new HubModuleManager(timestampFile); return propertiesModuleManager; }
@Override public void updateLegacyEntity(String entityName) { Path entityDir = project.getHubEntitiesDir().resolve(entityName); File[] entityFiles = entityDir.toFile().listFiles((dir, name) -> name.matches("[^.]+\\.entity\\.json")); if (entityFiles != null && entityFiles.length == 0) { String fileContents = getFileContent("scaffolding/Entity.json", entityName); writeToFile(fileContents, entityDir.resolve(entityName + ".entity.json").toFile()); } }
private void loadPropertiesFromFile(File propertiesFile, Properties loadedProperties) { InputStream is; try { if (propertiesFile.exists()) { is = new FileInputStream(propertiesFile); loadedProperties.load(is); is.close(); } } catch (IOException e) { throw new DataHubProjectException("No properties file found in project " + hubProject.getProjectDirString()); } }
/** * Need to initialize every module path as being relative to the current project directory. * * @param config */ protected void initializeModulePaths(AppConfig config) { List<String> modulePaths = new ArrayList<>(); Path projectDir = getHubProject().getProjectDir(); for (String modulePath : config.getModulePaths()) { modulePaths.add(projectDir.resolve(modulePath).normalize().toAbsolutePath().toString()); } config.setModulePaths(modulePaths); if (logger.isInfoEnabled()) { logger.info("Module paths: " + modulePaths); } }
@Test public void getProject() { assertEquals(0, ((Collection<ProjectInfo>)pc.getProjects().get("projects")).size()); assertEquals(false, pc.getProjects().keySet().contains("lastProject")); pc.addProject(projectPath); Project project = pc.getProject(1); assertEquals(projectPath, project.path); assertEquals(1, project.id); assertEquals(false, adminHubConfig.getHubProject().isInitialized()); }
@Test public void createMappingDir() { scaffolding.createMappingDir("my-fun-test"); assertTrue(projectDir.exists()); Path mappingDir = project.getMappingDir("my-fun-test"); assertTrue(mappingDir.toFile().exists()); assertEquals( Paths.get(pluginDir.toString(), "mappings", "my-fun-test"), mappingDir); }
@Override public void createEntity(String entityName) { Path entityDir = project.getEntityDir(entityName); entityDir.toFile().mkdirs(); if(entityDir.toFile().exists()){ String fileContents = getFileContent("scaffolding/Entity.json", entityName); writeToFile(fileContents, entityDir.resolve(entityName + ".entity.json").toFile()); } }
private HubModuleManager getPropsMgr() { String timestampFile = hubProject.getUserModulesDeployTimestampFile(); HubModuleManager propertiesModuleManager = new HubModuleManager(timestampFile); return propertiesModuleManager; }