CropReleaseCopyTool
This commit is contained in:
@@ -0,0 +1,85 @@
|
|||||||
|
package com.bayer.edam.excelimport;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.BasicConfigurator;
|
||||||
|
import org.apache.log4j.ConsoleAppender;
|
||||||
|
import org.apache.log4j.Layout;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.log4j.PatternLayout;
|
||||||
|
import org.apache.log4j.RollingFileAppender;
|
||||||
|
|
||||||
|
import com.univocity.parsers.csv.CsvParser;
|
||||||
|
import com.univocity.parsers.csv.CsvParserSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the file names of the release files from an Toolbox SQL export and copies the actual files another directory. This is used to sort
|
||||||
|
* out which release files are actually in use and need to be uploaded to eDAM.
|
||||||
|
*
|
||||||
|
* @author gexce
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CropReleaseCopyTool {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(CropReleaseCopyTool.class);
|
||||||
|
private static String logfilePath = "C:\\Temp\\Migration CS - SQL Server\\export_2017-08-23_incl_Releases.releasecopytool.log";
|
||||||
|
|
||||||
|
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export_2017-08-23_incl_Releases.csv";
|
||||||
|
|
||||||
|
private CsvParserSettings parserSettings = new CsvParserSettings();
|
||||||
|
private List<String[]> inputRows;
|
||||||
|
|
||||||
|
HashSet<Integer> copiedReleases = new HashSet<Integer>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public CropReleaseCopyTool() {
|
||||||
|
readToolboxExport();
|
||||||
|
|
||||||
|
int lineNo = 0;
|
||||||
|
|
||||||
|
for (String[] line : inputRows) {
|
||||||
|
lineNo++;
|
||||||
|
if (!line[28].equals("NULL")) {
|
||||||
|
int releaseId = Integer.parseInt(line[28]);
|
||||||
|
|
||||||
|
if (!copiedReleases.contains(releaseId)) {
|
||||||
|
copiedReleases.add(releaseId);
|
||||||
|
log.info(line[0] + " '" + line[1] + "' --> " + line[28] + " '" + line[29] + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("noReleases: " + copiedReleases.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readToolboxExport() {
|
||||||
|
parserSettings.getFormat().setLineSeparator("\r\n");
|
||||||
|
parserSettings.getFormat().setDelimiter(';');
|
||||||
|
parserSettings.getFormat().setCharToEscapeQuoteEscaping('"');
|
||||||
|
parserSettings.setHeaderExtractionEnabled(false);
|
||||||
|
|
||||||
|
CsvParser parser = new CsvParser(parserSettings);
|
||||||
|
|
||||||
|
inputRows = parser.parseAll(new File(toolboxExportFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
Layout layout = new PatternLayout("%d{ISO8601} - %p %m%n"); // "%d{ISO8601} - %p %m%n"
|
||||||
|
BasicConfigurator.configure(new ConsoleAppender(layout));
|
||||||
|
BasicConfigurator.configure(new RollingFileAppender(layout, logfilePath, false));
|
||||||
|
log.setLevel(Level.INFO);
|
||||||
|
|
||||||
|
new CropReleaseCopyTool();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,13 +29,13 @@ 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-leftover.csv";
|
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export_2017-08-22_missing_files.csv";
|
||||||
|
|
||||||
// XXX Spreadsheet needs be be named "Records" in Excel for the importer
|
// XXX Spreadsheet needs be be named "Records" in Excel for the importer
|
||||||
private static String importFilePath = "C:\\Temp\\Migration CS - SQL Server\\importFile-prod_LEFTOVER.csv";
|
private static String importFilePath = "C:\\Temp\\Migration CS - SQL Server\\export_2017-08-22_missing_files-IMPORT.csv";
|
||||||
|
|
||||||
private static String logfilePath = "C:\\Temp\\Migration CS - SQL Server\\importFile-prod_LEFTOVER.log";
|
private static String logfilePath = "C:\\Temp\\Migration CS - SQL Server\\export_2017-08-22_missing_files.log";
|
||||||
private static String uploadPath = "/Resources/Upload/ToolboxMigration";
|
private static String uploadPath = "/Resources/Upload/ToolboxMigration2";
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -18,6 +18,15 @@ a.CreatedOn, a.CreatedByUserID, a.UpdatedOn, a.UpdatedByUserID, a.CopyClaimFileN
|
|||||||
,ast.AssetStatusName
|
,ast.AssetStatusName
|
||||||
,aty.AssetTypeName
|
,aty.AssetTypeName
|
||||||
,org.OrganizationName
|
,org.OrganizationName
|
||||||
|
,rel.ReleaseID
|
||||||
|
,rel.ReleaseName
|
||||||
|
,rel.ReleaseTypeID
|
||||||
|
,rel.ReleaseStatusID
|
||||||
|
,rel.Licensor
|
||||||
|
,rel.CreatedDate
|
||||||
|
,rel.FileName
|
||||||
|
,rel.FilePath
|
||||||
|
|
||||||
|
|
||||||
FROM Assets a
|
FROM Assets a
|
||||||
LEFT JOIN AssetCategories c ON a.AssetCategoryID = c.AssetCategoryID
|
LEFT JOIN AssetCategories c ON a.AssetCategoryID = c.AssetCategoryID
|
||||||
@@ -38,6 +47,8 @@ LEFT JOIN AssetGroupSecurityFunctionMap agsfm ON a.AssetID = agsfm.AssetID
|
|||||||
LEFT JOIN Organizations org ON org.OrganizationID = agsfm.OrganizationID
|
LEFT JOIN Organizations org ON org.OrganizationID = agsfm.OrganizationID
|
||||||
LEFT JOIN Groups grp ON grp.GroupID = agsfm.GroupID
|
LEFT JOIN Groups grp ON grp.GroupID = agsfm.GroupID
|
||||||
--LEFT JOIN SecurityFunctions sf ON sf.SecurityFunctionID = agsfm.SecurityFunctionID
|
--LEFT JOIN SecurityFunctions sf ON sf.SecurityFunctionID = agsfm.SecurityFunctionID
|
||||||
|
LEFT JOIN AssetRelease arel ON a.AssetID = arel.AssetID
|
||||||
|
LEFT JOIN Release rel ON arel.ReleaseID = rel.ReleaseID
|
||||||
|
|
||||||
|
|
||||||
WHERE
|
WHERE
|
||||||
@@ -47,6 +58,7 @@ AND a.isDeleted = 0
|
|||||||
AND (a.FocusID IS NULL OR a.FocusID != 3 OR (a.FocusID = 3 AND a.CreatedOn > Convert(datetime, '2016-01-01')))
|
AND (a.FocusID IS NULL OR a.FocusID != 3 OR (a.FocusID = 3 AND a.CreatedOn > Convert(datetime, '2016-01-01')))
|
||||||
AND grp.GroupName != 'Administrator'
|
AND grp.GroupName != 'Administrator'
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AND a.AssetID IN (24024,24014,24007,23933,23932,23830,23826,23805,23804,
|
AND a.AssetID IN (24024,24014,24007,23933,23932,23830,23826,23805,23804,
|
||||||
23803,23802,23801,23800,23799,23797,23751,23707,23688,23657,23629,23622,
|
23803,23802,23801,23800,23799,23797,23751,23707,23688,23657,23629,23622,
|
||||||
|
|||||||
Reference in New Issue
Block a user