Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn F. Cook2011-08-02 16:05:32 -0400
committerRyan D. Brooks2011-08-02 16:05:32 -0400
commit694def2db13d9e45fe118fd4b8f508471582ca5e (patch)
treed8f71854f9bd446da01e86dfc3016a50a728847f /plugins/org.eclipse.osee.framework.database
parent79e69c9c937d627f25e69cd63c3c10fe23a6a890 (diff)
downloadorg.eclipse.osee-694def2db13d9e45fe118fd4b8f508471582ca5e.tar.gz
org.eclipse.osee-694def2db13d9e45fe118fd4b8f508471582ca5e.tar.xz
org.eclipse.osee-694def2db13d9e45fe118fd4b8f508471582ca5e.zip
refinement[bgz_350331]: Migrate ParseWindowsDirectoryListing to server side command line
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database')
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ParseWindowsDirectoryListingOperation.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ParseWindowsDirectoryListingOperation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ParseWindowsDirectoryListingOperation.java
new file mode 100644
index 00000000000..38efe03be22
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ParseWindowsDirectoryListingOperation.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.operation;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Shawn F. Cook
+ */
+public class ParseWindowsDirectoryListingOperation extends AbstractDbTxOperation {
+ private static final String DIRECTORY_PREFIX = " Directory of Y:\\";
+ private final String listingFile;
+
+ public ParseWindowsDirectoryListingOperation(IOseeDatabaseService databaseService, IOseeCachingService cachingService, OperationLogger logger, String listingFile) {
+ super(databaseService, "Parsing Windows Directory Listing", Activator.PLUGIN_ID, logger);
+ this.listingFile = listingFile;
+ }
+
+ @Override
+ protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
+
+ log();
+ log("Parsing windows directory listing:");
+
+ Matcher matcher = Pattern.compile("(\\d+/\\d+/\\d+).*<DIR>.*?SW\\\\(\\S+)\\s+(.*)").matcher("");
+ BufferedWriter writer;
+ try {
+ writer = new BufferedWriter(new FileWriter(Lib.removeExtension(listingFile) + ".csv"));
+
+ String path = null;
+ for (String line : Lib.readListFromFile(listingFile)) {
+ if (line.startsWith(DIRECTORY_PREFIX)) {
+ path = line.substring(DIRECTORY_PREFIX.length());
+ } else {
+ matcher.reset(line);
+ if (matcher.find()) {
+ String summary = matcher.group(1) + "|" + matcher.group(2) + "|" + path + "\\" + matcher.group(3);
+ if (!summary.endsWith(".")) {
+ writer.write(summary);
+ writer.write(Lib.lineSeparator);
+ }
+ }
+ }
+ }
+ writer.close();
+ } catch (IOException ex) {
+ log("ParseWindowsDirectoryListingOperation::doTxWork: Caught IOException:" + ex.toString());
+ } finally {
+ log("...done.");
+ }
+ }
+}

Back to the top