final fixes
This commit is contained in:
@@ -26,6 +26,14 @@ import net.lingala.zip4j.core.ZipFile;
|
|||||||
import net.lingala.zip4j.exception.ZipException;
|
import net.lingala.zip4j.exception.ZipException;
|
||||||
import net.lingala.zip4j.model.FileHeader;
|
import net.lingala.zip4j.model.FileHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the file names from an Toolbox SQL export and copies the actual files
|
||||||
|
* from a bcp export done with ToolboxFileExporter to another directory,
|
||||||
|
* renaming them to the filenames from the database.
|
||||||
|
*
|
||||||
|
* @author gexce
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class CropAssetCopyTool {
|
public class CropAssetCopyTool {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(CropAssetCopyTool.class);
|
private static Logger log = Logger.getLogger(CropAssetCopyTool.class);
|
||||||
@@ -36,6 +44,7 @@ public class CropAssetCopyTool {
|
|||||||
|
|
||||||
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15.csv";
|
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15.csv";
|
||||||
private static String toolboxExportUpdateFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15-update.csv";
|
private static String toolboxExportUpdateFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15-update.csv";
|
||||||
|
private static String logfilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15-update.copytool.log";
|
||||||
private static String assetPath = "D:\\Toolbox\\Assets";
|
private static String assetPath = "D:\\Toolbox\\Assets";
|
||||||
private static String videoPath = "D:\\Toolbox\\Movies\\";
|
private static String videoPath = "D:\\Toolbox\\Movies\\";
|
||||||
|
|
||||||
@@ -229,11 +238,6 @@ public class CropAssetCopyTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CsvWriter writer = new CsvWriter(new File(toolboxExportUpdateFilePath), writerSettings);
|
CsvWriter writer = new CsvWriter(new File(toolboxExportUpdateFilePath), writerSettings);
|
||||||
// writer.writeHeaders("assetpath", "filename", "append classification", "fields|byr_title", "fields|byr_MarketingId",
|
|
||||||
// "fields|byr_cs_assetApproval", "fields|byr_cs_license_classification", "fields|byr_cs_businessUnit", "fields|byr_cs_brand",
|
|
||||||
// "fields|byr_cs_releaseDate", "fields|byr_cs_retireDate", "fields|byr_cs_Description", "fields|byr_cs_keywords_tl",
|
|
||||||
// "fields|byr_campaignYearLabel", "fields|byr_campaignTitle", "fields|byr_cs_IsShouldBePublished",
|
|
||||||
// "fields|byr_cs_warehouseAvailable");
|
|
||||||
writer.writeRowsAndClose(csvOutputList);
|
writer.writeRowsAndClose(csvOutputList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +245,7 @@ public class CropAssetCopyTool {
|
|||||||
try {
|
try {
|
||||||
Layout layout = new PatternLayout("%d{ISO8601} - %p %m%n"); // "%d{ISO8601} - %p %m%n"
|
Layout layout = new PatternLayout("%d{ISO8601} - %p %m%n"); // "%d{ISO8601} - %p %m%n"
|
||||||
BasicConfigurator.configure(new ConsoleAppender(layout));
|
BasicConfigurator.configure(new ConsoleAppender(layout));
|
||||||
BasicConfigurator.configure(new RollingFileAppender(layout, "D:\\CropAssetCopyTool.log", false));
|
BasicConfigurator.configure(new RollingFileAppender(layout, logfilePath, false));
|
||||||
log.setLevel(Level.INFO);
|
log.setLevel(Level.INFO);
|
||||||
|
|
||||||
new CropAssetCopyTool();
|
new CropAssetCopyTool();
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ public class CropScienceAsset {
|
|||||||
String byr_Title;
|
String byr_Title;
|
||||||
String byr_MarketingId;
|
String byr_MarketingId;
|
||||||
String byr_cs_assetApproval;
|
String byr_cs_assetApproval;
|
||||||
//String byr_cs_brand;
|
|
||||||
String byr_cs_releaseDate;
|
String byr_cs_releaseDate;
|
||||||
String byr_cs_retireDate;
|
String byr_cs_retireDate;
|
||||||
String byr_cs_businessUnit;
|
String byr_cs_businessUnit;
|
||||||
@@ -24,6 +23,7 @@ public class CropScienceAsset {
|
|||||||
String byr_campaignTitle;
|
String byr_campaignTitle;
|
||||||
String byr_cs_IsShouldBePublished;
|
String byr_cs_IsShouldBePublished;
|
||||||
String byr_cs_warehouseAvailable;
|
String byr_cs_warehouseAvailable;
|
||||||
|
String byr_cs_country;
|
||||||
|
|
||||||
HashSet<String> brands = new HashSet<String>();
|
HashSet<String> brands = new HashSet<String>();
|
||||||
HashSet<String> indications = new HashSet<String>();
|
HashSet<String> indications = new HashSet<String>();
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import com.univocity.parsers.csv.CsvWriter;
|
|||||||
import com.univocity.parsers.csv.CsvWriterSettings;
|
import com.univocity.parsers.csv.CsvWriterSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quick and dirty: Remove all files from the import Excel spreadsheet that are not shown in a directory listing.
|
* Quick and dirty: Remove all files from the import Excel spreadsheet that are
|
||||||
|
* not shown in a directory listing.
|
||||||
*
|
*
|
||||||
* @author gezvf
|
* @author gezvf
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ import com.univocity.parsers.csv.CsvWriterSettings;
|
|||||||
public class ToolboxImportFileGenerator {
|
public class ToolboxImportFileGenerator {
|
||||||
private static Logger log = Logger.getLogger(ToolboxImportFileGenerator.class);
|
private static Logger log = Logger.getLogger(ToolboxImportFileGenerator.class);
|
||||||
|
|
||||||
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15-update-smallSet.csv";
|
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15-update.csv";
|
||||||
private static String importFilePath = "C:\\Temp\\Migration CS - SQL Server\\importFile-smallSet.csv";
|
|
||||||
|
// XXX Spreadsheet needs be be named "Records" in Excel for the importer
|
||||||
|
private static String importFilePath = "C:\\Temp\\Migration CS - SQL Server\\importFile-prod.csv";
|
||||||
|
private static String logfilePath = "C:\\Temp\\Migration CS - SQL Server\\importFile-prod.log";
|
||||||
|
|
||||||
private static final Map<String, String> brandMap;
|
private static final Map<String, String> brandMap;
|
||||||
private static final Map<String, String> unitMap;
|
private static final Map<String, String> unitMap;
|
||||||
@@ -1034,7 +1037,7 @@ public class ToolboxImportFileGenerator {
|
|||||||
|
|
||||||
CropScienceAsset asset = assets.get(assetId);
|
CropScienceAsset asset = assets.get(assetId);
|
||||||
|
|
||||||
if (asset == null) { // Fields|byr_cs_country
|
if (asset == null) {
|
||||||
assetsIncluded++;
|
assetsIncluded++;
|
||||||
asset = new CropScienceAsset(assetId);
|
asset = new CropScienceAsset(assetId);
|
||||||
|
|
||||||
@@ -1043,6 +1046,7 @@ public class ToolboxImportFileGenerator {
|
|||||||
|
|
||||||
asset.byr_Title = line[2];
|
asset.byr_Title = line[2];
|
||||||
asset.byr_cs_assetApproval = "Approval Required";
|
asset.byr_cs_assetApproval = "Approval Required";
|
||||||
|
asset.byr_cs_country = "United States";
|
||||||
|
|
||||||
asset.byr_MarketingId = line[3];
|
asset.byr_MarketingId = line[3];
|
||||||
|
|
||||||
@@ -1192,7 +1196,7 @@ public class ToolboxImportFileGenerator {
|
|||||||
asset.byr_MarketingId, asset.byr_cs_assetApproval, asset.byr_cs_license_classification, asset.byr_cs_businessUnit,
|
asset.byr_MarketingId, asset.byr_cs_assetApproval, asset.byr_cs_license_classification, asset.byr_cs_businessUnit,
|
||||||
brands, asset.byr_cs_releaseDate, asset.byr_cs_retireDate, asset.byr_cs_description, asset.byr_cs_keywords_tl,
|
brands, asset.byr_cs_releaseDate, asset.byr_cs_retireDate, asset.byr_cs_description, asset.byr_cs_keywords_tl,
|
||||||
asset.byr_campaignYearLabel, asset.byr_campaignTitle, asset.byr_cs_IsShouldBePublished,
|
asset.byr_campaignYearLabel, asset.byr_campaignTitle, asset.byr_cs_IsShouldBePublished,
|
||||||
asset.byr_cs_warehouseAvailable };
|
asset.byr_cs_warehouseAvailable, asset.byr_cs_country };
|
||||||
csvOutputList.add(csvLine);
|
csvOutputList.add(csvLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,7 +1208,7 @@ public class ToolboxImportFileGenerator {
|
|||||||
"fields|byr_cs_assetApproval", "fields|byr_cs_licenseType", "fields|byr_cs_businessUnit", "fields|byr_cs_brand",
|
"fields|byr_cs_assetApproval", "fields|byr_cs_licenseType", "fields|byr_cs_businessUnit", "fields|byr_cs_brand",
|
||||||
"fields|byr_cs_releaseDate", "fields|byr_cs_retireDate", "fields|byr_cs_Description", "fields|byr_cs_keywords_tl",
|
"fields|byr_cs_releaseDate", "fields|byr_cs_retireDate", "fields|byr_cs_Description", "fields|byr_cs_keywords_tl",
|
||||||
"fields|byr_campaignYearLabel", "fields|byr_campaignTitleLabel", "fields|byr_cs_IsShouldBePublished",
|
"fields|byr_campaignYearLabel", "fields|byr_campaignTitleLabel", "fields|byr_cs_IsShouldBePublished",
|
||||||
"fields|byr_cs_warehouseAvailable");
|
"fields|byr_cs_warehouseAvailable", "fields|byr_cs_country");
|
||||||
writer.writeRowsAndClose(csvOutputList);
|
writer.writeRowsAndClose(csvOutputList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1212,7 +1216,7 @@ public class ToolboxImportFileGenerator {
|
|||||||
try {
|
try {
|
||||||
Layout layout = new PatternLayout("%p %m%n"); // "%d{ISO8601} - %p %m%n"
|
Layout layout = new PatternLayout("%p %m%n"); // "%d{ISO8601} - %p %m%n"
|
||||||
BasicConfigurator.configure(new ConsoleAppender(layout));
|
BasicConfigurator.configure(new ConsoleAppender(layout));
|
||||||
BasicConfigurator.configure(new RollingFileAppender(layout, "C:\\Temp\\Migration CS - SQL Server\\importFile.log", false));
|
BasicConfigurator.configure(new RollingFileAppender(layout, logfilePath, false));
|
||||||
log.setLevel(Level.INFO);
|
log.setLevel(Level.INFO);
|
||||||
|
|
||||||
new ToolboxImportFileGenerator();
|
new ToolboxImportFileGenerator();
|
||||||
|
|||||||
Reference in New Issue
Block a user