neat little bugs

This commit is contained in:
gexce
2017-08-30 10:16:05 +02:00
parent 1812bdbbaa
commit 5e8acbf9f3
2 changed files with 43 additions and 33 deletions
@@ -16,7 +16,7 @@ public class CropScienceAsset {
String byr_cs_releaseDate;
String byr_cs_retireDate;
String byr_cs_businessUnit;
String byr_cs_license_classification;
//String byr_cs_license_classification;
String byr_cs_description;
String byr_cs_keywords_tl;
String byr_campaignYearLabel; // TODO needs to be verified with Delaware
@@ -29,12 +29,12 @@ import com.univocity.parsers.csv.CsvWriterSettings;
public class ToolboxImportFileGenerator {
private static Logger log = Logger.getLogger(ToolboxImportFileGenerator.class);
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export - TESTSET.csv";
private static String logfilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export - TESTSET.log";
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export.csv";
private static String logfilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export.log";
private static String licenseGuidsFilePath = "C:\\Temp\\Migration CS - SQL Server\\Release_GUIDs.csv";
// XXX Spreadsheet needs be be named "Records" in Excel for the importer
private static String importFilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export - TESTSET-IMPORT.csv";
private static String importFilePath = "C:\\Temp\\Migration CS - PhotoGallery\\all imported IDs - toolbox export-IMPORT.csv";
private static String uploadPath = "/Resources/Upload/ToolboxMigration";
private static final Map<String, String> brandMap;
@@ -1079,8 +1079,6 @@ public class ToolboxImportFileGenerator {
if (!line[17].equals("NULL"))
asset.byr_cs_retireDate = outputDateFormat.format(inputDateFormat.parse(line[17]));
asset.byr_cs_license_classification = "";
asset.byr_campaignYearLabel = line[18];
if (!line[19].equals("NULL"))
@@ -1133,6 +1131,9 @@ public class ToolboxImportFileGenerator {
noAssetType++;
log.warn(asset.toolboxAssetId + ", line " + lineNo + ": Could not map category '" + assetCategory + "' to any asset type");
}
asset.byr_licenseScope = "US";
asset.byr_licenseOwner = "Bayer CropScience LP";
assets.put(assetId, asset);
}
@@ -1177,29 +1178,33 @@ public class ToolboxImportFileGenerator {
if (!line[34].equals("NULL")) {
if (licenses.containsKey(line[34])) {
asset.licenseRecords.add(licenses.get(line[34]));
if (line[30].equals("1"))
asset.licenseTypes.add("License Agreement");
else if (line[30].equals("2"))
asset.licenseTypes.add("Written permission release");
else if (line[30].equals("3"))
asset.licenseTypes.add("Testimonial release");
else if (line[30].equals("4"))
asset.licenseTypes.add("Location release");
else if (line[30].equals("5"))
asset.licenseTypes.add("Talent/Music release");
asset.byr_licenseScope = "US";
asset.byr_licenseOwner = "Bayer CropScience LP";
if (asset.byr_licenseInformation.length() > 0)
asset.byr_licenseInformation += "\n";
asset.byr_licenseInformation += "License imported from Toolbox. Licensor: " + line[32] + ", Creator/Company: " + line[36] + " " + line[37] + "/" + line[38] + ", Toolbox upload date: " + outputDateFormat.format(inputDateFormat.parse(line[33]));
if (asset.licenseRecords.add(licenses.get(line[34]))) {
if (line[30].equals("1"))
asset.licenseTypes.add("License Agreement");
else if (line[30].equals("2"))
asset.licenseTypes.add("Written permission release");
else if (line[30].equals("3"))
asset.licenseTypes.add("Testimonial release");
else if (line[30].equals("4"))
asset.licenseTypes.add("Location release");
else if (line[30].equals("5"))
asset.licenseTypes.add("Talent/Music release");
if (asset.byr_licenseInformation.length() > 0)
asset.byr_licenseInformation += "\n";
asset.byr_licenseInformation += "License imported from Toolbox. Licensor: " + line[32] + ", Creator/Company: "
+ line[36] + " " + line[37] + "/" + line[38] + ", Toolbox upload date: "
+ outputDateFormat.format(inputDateFormat.parse(line[33]));
if (asset.byr_licenseInformation.length() > 3800)
log.error("Asset ID " + asset.toolboxAssetId + ": License information too long - "
+ asset.byr_licenseInformation.length());
}
}
else {
log.error(asset.toolboxAssetId + ", line " + lineNo + ": No GUID for release file " + line[34]);
log.error("Asset ID " + asset.toolboxAssetId + ", line " + lineNo + ": Could not find release file " + line[34]);
releaseMissing++;
}
}
@@ -1222,6 +1227,10 @@ public class ToolboxImportFileGenerator {
private void writeImportFile() {
List<Object[]> csvOutputList = new ArrayList<Object[]>();
for (CropScienceAsset asset : assets.values()) {
// XXX This filename is broken (because of the question mark)
if (asset.filename.equals("Texas Cotton Growers Achieve Excellence with FiberMax?.mp4"))
asset.filename = "CR0715FIBMAXA232V00R0.MP4";
String brands = "";
for (String brand : asset.brands) {
@@ -1248,12 +1257,13 @@ public class ToolboxImportFileGenerator {
}
String[] csvLine = new String[] { asset.assetPath, asset.filename, asset.appendClassification, asset.byr_Title,
asset.byr_MarketingId, asset.byr_cs_assetApproval, asset.byr_cs_license_classification, asset.byr_cs_businessUnit,
String[] csvLine = new String[] { asset.assetPath, asset.filename, /*asset.appendClassification, asset.byr_Title,
asset.byr_MarketingId, asset.byr_cs_assetApproval, asset.byr_cs_businessUnit,
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_cs_warehouseAvailable,
asset.byr_cs_country, licenseRecords, licenseTypes, asset.byr_licenseScope, asset.byr_licenseOwner,
asset.byr_cs_country,*/ licenseRecords, licenseTypes, asset.byr_licenseScope, asset.byr_licenseOwner,
asset.byr_licenseInformation };
csvOutputList.add(csvLine);
}
@@ -1261,11 +1271,11 @@ public class ToolboxImportFileGenerator {
writerSettings.setFormat(parserSettings.getFormat());
CsvWriter writer = new CsvWriter(new File(importFilePath), writerSettings);
writer.writeHeaders("Assetpath", "Filename", "Append Classification", "fields|byr_Title", "fields|byr_MarketingId",
"fields|byr_cs_assetApproval", "fields|byr_cs_licenseType", "fields|byr_cs_businessUnit", "fields|byr_cs_brand",
writer.writeHeaders("Assetpath", "Filename", /*"Append Classification", "fields|byr_Title", "fields|byr_MarketingId",
"fields|byr_cs_assetApproval", "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_campaignTitleLabel", "fields|byr_cs_IsShouldBePublished",
"fields|byr_cs_warehouseAvailable", "fields|byr_cs_country", "fields|byr_cs_licenseRecord", "fields|byr_cs_licenseType",
"fields|byr_cs_warehouseAvailable", "fields|byr_cs_country",*/ "fields|byr_cs_licenseRecord", "fields|byr_cs_licenseType",
"fields|byr_licenseScope", "fields|byr_licenseOwner", "fields|byr_licenseInformation");
writer.writeRowsAndClose(csvOutputList);
}