diff --git a/Toolbox Migration/bcp.fmt b/Toolbox Migration/bcp.fmt index 4f504d6..d72db44 100644 Binary files a/Toolbox Migration/bcp.fmt and b/Toolbox Migration/bcp.fmt differ diff --git a/Toolbox Migration/src/com/bayer/edam/ToolboxFileExporter.java b/Toolbox Migration/src/com/bayer/edam/ToolboxFileExporter.java index a07dfbe..dfaf46d 100644 --- a/Toolbox Migration/src/com/bayer/edam/ToolboxFileExporter.java +++ b/Toolbox Migration/src/com/bayer/edam/ToolboxFileExporter.java @@ -12,7 +12,7 @@ public class ToolboxFileExporter { private List rows; - private String baseDir = "I:\\ToolboxAssets"; + private String baseDir = "I:\\Toolbox\\Assets"; // Formatdatei generiert mit // bcp "SELECT OriginalImage FROM AssetImages WHERE AssetID=586" queryout Image.jpg -S MOVNCG -d Bayertoolbox_prod -T -x @@ -24,26 +24,27 @@ public class ToolboxFileExporter { // bcp "SELECT OriginalImage FROM AssetImages WHERE AssetID=586" queryout Image5.jpg -S MOVNCG -d Bayertoolbox_prod -T -f bcp.fmt private String command1 = "bcp \"SELECT OriginalImage FROM AssetImages WHERE AssetID="; - private String command2 = "\" queryout "; - private String command3 = " -S MOVNCG -d Bayertoolbox_prod -T -f bcp.fmt"; + private String command2 = "\" queryout \""; + private String command3 = "\" -S MOVNCG -d Bayertoolbox_prod -T -f bcp.fmt"; private File workingDir = new File(baseDir); public ToolboxFileExporter() throws Exception { readList(); - for (int i=0; i < 3; i++) { - getImage(rows.get(188+i)[1]); + for (String[] row : rows) { + getImage(row[1], row[3]); } } - private void getImage(String assetId) throws Exception { - System.out.println("AssetID: " + assetId); + private void getImage(String assetId, String originalFilenname) throws Exception { + System.out.println("AssetID: " + assetId + " OriginalFilename: '" + originalFilenname + "'"); + // TODO Check if file already exists (bcp just overwrites existing files) - Process process = Runtime.getRuntime().exec(command1 + assetId + command2 + "Test5.jpg" + command3, null, workingDir); + Process process = Runtime.getRuntime().exec(command1 + assetId + command2 + assetId + command3, null, workingDir); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); @@ -62,7 +63,7 @@ public class ToolboxFileExporter { CsvParser parser = new CsvParser(settings); - rows = parser.parseAll(new File("I:\\ToolboxAssets\\AssetImages.csv")); + rows = parser.parseAll(new File("I:\\Toolbox\\AssetImages.csv")); }