public FolderConfig newMessage() { return new FolderConfig(); }
@POST @Path("/folder/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Folder createFolder(FolderName name, @PathParam("path") String path) throws Exception { String fullPath = PathUtils.toFSPathString(Arrays.asList(path, name.toString())); FolderPath folderPath = FolderPath.fromURLPath(homeName, fullPath); final FolderConfig folderConfig = new FolderConfig(); folderConfig.setFullPathList(folderPath.toPathList()); folderConfig.setName(folderPath.getFolderName().getName()); try { namespaceService.addOrUpdateFolder(folderPath.toNamespaceKey(), folderConfig); } catch(NamespaceNotFoundException nfe) { throw new ClientErrorException("Parent folder doesn't exist", nfe); } return newFolder(folderPath, folderConfig, null); }
@POST @Path("/folder/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Folder createFolder(FolderName name, @PathParam("path") String path) throws NamespaceException { String fullPath = PathUtils.toFSPathString(Arrays.asList(path, name.toString())); FolderPath folderPath = FolderPath.fromURLPath(spaceName, fullPath); final FolderConfig folderConfig = new FolderConfig(); folderConfig.setFullPathList(folderPath.toPathList()); folderConfig.setName(folderPath.getFolderName().getName()); try { namespaceService.addOrUpdateFolder(folderPath.toNamespaceKey(), folderConfig); } catch(NamespaceNotFoundException nfe) { throw new ClientErrorException("Parent folder doesn't exist", nfe); } return newFolder(folderPath, folderConfig, null); }
public static FolderConfig getFolderConfig(Folder folder) { FolderConfig config = new FolderConfig(); config.setId(new EntityId(folder.getId())); config.setFullPathList(folder.getPath()); config.setName(Iterables.getLast(folder.getPath())); if (folder.getTag() != null) { config.setTag(folder.getTag()); } return config; }
addOrUpdateFolder(key, new FolderConfig() .setName(components.get(i)) .setFullPathList(fullPathList)
@Override public void deleteDataset(final NamespaceKey datasetPath, String version) throws NamespaceException { NameSpaceContainer container = deleteEntity(datasetPath, DATASET, version, true); if (container.getDataset().getType() == PHYSICAL_DATASET_SOURCE_FOLDER) { // create a folder so that any existing datasets under the folder are now visible addOrUpdateFolder(datasetPath, new FolderConfig() .setFullPathList(datasetPath.getPathComponents()) .setName(datasetPath.getName()) ); } }
public static void addFolder(NamespaceService ns, String name) throws Exception { final FolderConfig folder = new FolderConfig(); final NamespaceKey folderPath = new NamespaceKey(PathUtils.parseFullPath(name)); folder.setName(folderPath.getName()); folder.setFullPathList(folderPath.getPathComponents()); ns.addOrUpdateFolder(folderPath, folder); }
datasetConfig = namespaceService.getDataset(folderPath.toNamespaceKey()); if (datasetConfig.getType() != DatasetType.VIRTUAL_DATASET) { folderConfig = new FolderConfig() .setId(datasetConfig.getId()) .setFullPathList(folderPath.toPathList()) folderConfig = new FolderConfig() .setFullPathList(folderPath.toPathList()) .setName(folderPath.getFolderName().getName());
protected void setSpace() throws NamespaceException, IOException { clearAllDataExceptUser(); final SpaceConfig foo = new SpaceConfig().setName("spacefoo"); SpacePath spacePath = new SpacePath(new SpaceName(foo.getName())); newNamespaceService().addOrUpdateSpace(spacePath.toNamespaceKey(), foo); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar").toNamespaceKey(), new FolderConfig().setName("folderbar").setFullPathList(asList("spacefoo", "folderbar"))); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar.folderbaz").toNamespaceKey(), new FolderConfig().setName("folderbaz").setFullPathList(asList("spacefoo", "folderbar", "folderbaz"))); }
FolderConfig folderConfig1 = new FolderConfig(); folderConfig1.setId(new EntityId("folder-id-1")); folderConfig1.setName("folder1"); FolderConfig folderConfig2 = new FolderConfig(); folderConfig2.setId(new EntityId("folder-id-2")); folderConfig2.setName("folder2"); FolderConfig folderConfig11 = new FolderConfig(); folderConfig11.setId(new EntityId("folder-id-11")); folderConfig11.setName("folder11");
private static void runTests(HomeFileConf homeFileStore) throws Exception { // text file Path textFile = new Path(FileUtils.getResourceAsFile("/datasets/text/comma.txt").getAbsolutePath()); uploadFile(homeFileStore, textFile, "comma", "txt", new TextFileConfig().setFieldDelimiter(","), null); Path csvFile = new Path(FileUtils.getResourceAsFile("/datasets/csv/comma.csv").getAbsolutePath()); uploadFile(homeFileStore, csvFile, "comma1", "csv", new TextFileConfig().setFieldDelimiter(","), null); Path jsonFile = new Path(FileUtils.getResourceAsFile("/datasets/users.json").getAbsolutePath()); uploadFile(homeFileStore, jsonFile, "users", "json", new JsonFileConfig(), null); Path excelFile = new Path(FileUtils.getResourceAsFile("/testfiles/excel.xlsx").getAbsolutePath()); uploadFile(homeFileStore, excelFile, "excel", "xlsx", new ExcelFileConfig(), null); // query files runQuery("comma", 4, 3, null); runQuery("comma1", 4, 3, null); runQuery("users", 3, 2, null); runQuery("excel", 6, 5, null); // add file to folder FolderPath folderPath = new FolderPath(ImmutableList.of(HomeName.getUserHomePath(DEFAULT_USER_NAME).getName(), "testupload")); newNamespaceService().addOrUpdateFolder(folderPath.toNamespaceKey(), new FolderConfig() .setName("testupload") .setFullPathList(folderPath.toPathList())); uploadFile(homeFileStore, textFile, "comma", "txt", new TextFileConfig().setFieldDelimiter(","), folderPath); runQuery("comma", 4, 3, folderPath); }
FolderConfig folderConfig1 = new FolderConfig(); folderConfig1.setId(new EntityId("folder-id-1")); folderConfig1.setName("folder1"); FolderConfig folderConfig2 = new FolderConfig(); folderConfig2.setId(new EntityId("folder-id-2")); folderConfig2.setName("folder2");
public void addCPSource(boolean createFolder) throws Exception { getSourceService().registerSourceWithRuntime(InternalFileConf.create(TEST_SOURCE, new URI("classpath:///acceleration/"), SchemaMutability.ALL, CatalogService.DEFAULT_METADATA_POLICY)); final NamespaceService nsService = getNamespaceService(); final SpaceConfig config = new SpaceConfig().setName(TEST_SPACE); if(!nsService.exists(new SpacePath(config.getName()).toNamespaceKey())) { nsService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); } if (createFolder) { final FolderConfig folderConfig = new FolderConfig().setName(TEST_FOLDER); nsService.addOrUpdateFolder(TEST_FOLDER_PATH.toNamespaceKey(), folderConfig); } }
@Test public void testDownloadWithRelativeDatasetPath() throws Exception { SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("mySpace"); newNamespaceService().addOrUpdateSpace(new NamespaceKey("mySpace"), spaceConfig); FolderConfig folderConfig = new FolderConfig(); List<String> path = Arrays.asList("mySpace", "folder"); folderConfig.setFullPathList(path); folderConfig.setName("folder"); newNamespaceService().addOrUpdateFolder(new NamespaceKey(path), folderConfig); final DatasetPath dsPath = new DatasetPath("mySpace.folder.testVDS"); DatasetUI ds = createDatasetFromSQLAndSave(dsPath,"select * from DG.dsg1 LIMIT 10", asList("cp")); final DatasetPath dsPath2 = new DatasetPath("mySpace.folder.testVDS2"); DatasetUI ds2 = createDatasetFromSQLAndSave(dsPath2,"select * from testVDS", path); Job job = datasetService.prepareDownload(dsPath2, ds2.getDatasetVersion(), DownloadFormat.CSV, 50, SampleDataPopulator.DEFAULT_USER_NAME); job.getData().loadIfNecessary(); DownloadDataResponse downloadDataResponse = datasetService.downloadData(job.getJobAttempt().getInfo().getDownloadInfo(), SampleDataPopulator.DEFAULT_USER_NAME); final List<TestData> downloadedData = readDataCsv(downloadDataResponse.getInput()); assertEquals(10, downloadedData.size()); for (int i = 0; i < 10; ++i) { assertEquals("user" + i, downloadedData.get(i).getUser()); assertEquals(i%25, downloadedData.get(i).getAge()); assertEquals("address" + i, downloadedData.get(i).getAddress()); } }
FolderConfig folderConfig = new FolderConfig(); folderConfig.setFullPathList(path.toPathList()); folderConfig.setName(path.getFolderName().getName()); fileConfig.setOwner(entity.getOwner()); final FolderConfig folderConfig = new FolderConfig(); folderConfig.setId(new EntityId(physicalDatasetConfig.getId())); folderConfig.setFullPathList(folderPath.toPathList());