Skip to content

Commit

Permalink
Merge pull request #64 from jazz-community/OpenCSV-Update
Browse files Browse the repository at this point in the history
Open csv update
  • Loading branch information
rsjazz authored Feb 16, 2024
2 parents e74a085 + 0639df9 commit 402244a
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 91 deletions.
1 change: 1 addition & 0 deletions com.ibm.js.team.workitem.commandline/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/EWMCommon"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JenaCore"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JunoAll"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Commons-lang"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="com.ibm.js.team.workitem.commandline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-exportworkitems repository=&quot;https://elmratelimha11.fyre.ibm.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;JKE Banking (Change Management)&quot; exportFile=&quot;C:\aaTemp\Export\Test.csv&quot; query=&quot;All&quot; delimiter=&quot;;&quot; /allColumns /ignoreErrors"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-exportworkitems repository=&quot;https://elmratelimha11.fyre.ibm.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;JKE Banking (Change Management)&quot; exportFile=&quot;C:\aaTemp\Export\Test.csv&quot; query=&quot;All&quot; /allColumns /ignoreErrors"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/main/java/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-exportworkitems /ignoreErrors repository=&quot;https://elm.example.com:9443/ccm&quot; user=myadmin password=myadmin projectArea=&quot;JKE Banking (Change Management)&quot; exportFile=&quot;C:\Temp\exporttest\MyQueryAllAttributes.csv&quot; query=&quot;MyQuery&quot; delimiter=&quot;;&quot; /allColumns /suppressAttributeExceptions"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/main/java/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="com.ibm.js.team.workitem.commandline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-exportworkitems /ignoreErrors repository=&quot;https://elm.example.com:9443/ccm&quot; user=myadmin password=myadmin projectArea=&quot;JKE Banking (Change Management)&quot; exportFile=&quot;C:\Temp\exporttest\MyQueryAllAttributes.csv&quot; query=&quot;MyQuery&quot; delimiter=&quot;;&quot; /allColumns /suppressAttributeExceptions"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-importworkitems /ignoreErrors repository=&quot;https://clm.example.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;JKE Banking (Change Management)&quot; importFile=&quot;C:\aaTemp\Export\EmptyWorkItem.csv&quot; delimiter=&quot;;&quot; /ignoreemptycolumnvalues"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/main/java/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="com.ibm.js.team.workitem.commandline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-importworkitems /ignoreErrors repository=&quot;https://clm.example.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;JKE Banking (Change Management)&quot; importFile=&quot;C:\aaTemp\Export\EmptyWorkItem.csv&quot; delimiter=&quot;;&quot; /ignoreemptycolumnvalues"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-importworkitems /ignoreErrors repository=&quot;https://clm.example.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;JKE Banking (Change Management)&quot; importFile=&quot;c:\aaTemp\Export\Test.csv&quot; delimiter=&quot;;&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.js.team.workitem.commandline/src/main/java/com/ibm/js/team/workitem/commandline/WorkitemCommandLine.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="com.ibm.js.team.workitem.commandline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-importworkitems /ignoreErrors repository=&quot;https://elmratelimha11.fyre.ibm.com:9443/ccm&quot; user=ralph password=ralph projectArea=&quot;Safe&quot; importFile=&quot;c:\aaTemp\Export\Test.csv&quot; delimiter=&quot;;&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.js.team.workitem.commandline.WorkitemCommandLine"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="com.ibm.js.team.workitem.commandline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-update /ignoreErrors repository=&quot;https://elmratelimha11.fyre.ibm.com:9443/ccm&quot; user=ralph password=ralph id=175 @link_child:add=92"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-update /ignoreErrors repository=&quot;https://clm.example.com:9443/ccm&quot; user=ralph password=ralph id=91 @link_mentions:add=92"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.js.team.workitem.commandline"/>
</launchConfiguration>
36 changes: 12 additions & 24 deletions com.ibm.js.team.workitem.commandline/lib/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
WCL uses some libraries that don't ship with it to export and import.

To run the the work item exporter and importer
To run the the work item exporter and importer download and collect the following jar files. Place them all into a folder e.g. C:\Dev\WCL_ExternalLibs.

1. Download opencsv from
http://sourceforge.net/projects/opencsv/files/opencsv/3.7/
1. Download opencsv from https://mvnrepository.com/artifact/com.opencsv/opencsv

It is possible to use the latest version 4.3.2 from https://sourceforge.net/projects/opencsv/files/opencsv/
It is possible to use the version or later

Rename the jar file e.g. opencsv-3.7.jar to opencsv.jar
2.a Download apache commons-text 1.11 or later from https://commons.apache.org/proper/commons-text/download_text.cgi
Extract the zip file and locate the file commons-text1-*.jar

1.a Copy the library file opencsv.jar into /com.ibm.js.team.workitem.commandline/lib to be able to run from Eclipse.
1.b Place the library opencsv.jar into the folder lib in the WCL folder (see /com.ibm.js.team.workitem.commandline/ReadMe - HowToRelease.txt).

2. Download apache commons-text from
https://commons.apache.org/proper/commons-text/download_text.cgi

Rename the jar file e.g. commons-lang3-3.1.jar to commons-lang.jar
The org.apache.commons.lang jar can also be found in the EWM server install.

1.a Copy the library file commons-lang.jar into /com.ibm.js.team.workitem.commandline/lib to be able to run from Eclipse.
1.b Place the library commons-lang.jar into the folder lib in the WCL folder (see /com.ibm.js.team.workitem.commandline/ReadMe - HowToRelease.txt).
2.b Download apache commons-lang 3.14 or later from https://commons.apache.org/lang/download_lang.cgi
Extract the zip file and locate the file commons-lang3-*.jar

3. Pull in juno-all jar from the EWM server install.

3.a Copy the library file juno-all*.jar from /support/mxbean-datacollection/jarlib/ from the EWM server install into /com.ibm.js.team.workitem.commandline/lib to be able to run from Eclipse.
3.b Place the library juno-all*.jar from /support/mxbean-datacollection/jarlib/ from the EWM server install into the folder lib in the WCL folder (see /com.ibm.js.team.workitem.commandline/ReadMe - HowToRelease.txt).

4. Pull in jena-core jar from EWM server install.

4.a Copy the library file jena-core*.jar or com.hp.hpl.jena*.jar from server/conf/ccm/sites/update-site/plugins/ from the EWM server install into /com.ibm.js.team.workitem.commandline/lib to be able to run from Eclipse.
4.b Place the library jena-core*.jar from server/conf/ccm/sites/update-site/plugins/ from the EWM server install into the folder lib in the WCL folder (see /com.ibm.js.team.workitem.commandline/ReadMe - HowToRelease.txt).

5. Pull in extra required EWM common jars

5.a Copy the library file com.ibm.team.apt.common_*.jar and com.ibm.team.tpt.common_*.jar from server/conf/ccm/sites/update-site/plugins/ from the EWM server install into /com.ibm.js.team.workitem.commandline/lib to be able to run from Eclipse.
5.b Place the library com.ibm.team.apt.common_*.jar and com.ibm.team.tpt.common_*.jar from server/conf/ccm/sites/update-site/plugins/ from the EWM server install into the folder lib in the WCL folder (see /com.ibm.js.team.workitem.commandline/ReadMe - HowToRelease.txt).
Copy the library file com.ibm.team.apt.common_*.jar and com.ibm.team.tpt.common_*.jar from server/conf/ccm/sites/update-site/plugins/ from the EWM server install into your folder

To use the files in a released WCL copy these files into the folder WCL/lib.

To use the files in an Eclipse workspace with WCL follow https://github.com/jazz-community/work-item-command-line/blob/master/README.md#prerequisites and add the files to your class path.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public interface IWorkItemCommandLineConstants {
public static final String DEFAULT_ENCODING_UTF_16LE = "UTF-16LE";

// The default Quote character
public static final char DEFAULT_QUOTE_CHAR = '"';
public static final char DEFAULT_CSV_QUOTE_CHAR = '"';

// parameter to specify the encoding
public static final String PARAMETER_ENCODING = "encoding";
Expand All @@ -138,6 +138,14 @@ public interface IWorkItemCommandLineConstants {
public static final String PARAMETER_DELIMITER = "delimiter";
public static final String PARAMETER_DELIMITER_EXAMPLE = "\",\"";

// Parameter to specify the separator character
public static final String PARAMETER_SEPARATOR = "separator";
public static final String PARAMETER_SEPARATOR_EXAMPLE = "\",\"";

// The default separator character
public static final char DEFAULT_CSV_SEPERATOR_CHAR = ';';


public static final String SWITCH_EXPORT_SUPPRESS_ATTRIBUTE_EXCEPTIONS = "suppressAttributeExceptions";
public static final String SWITCH_SUPPRESS_MAIL_NOTIFICATION = "skipEmailNotification";

Expand All @@ -159,6 +167,7 @@ public interface IWorkItemCommandLineConstants {

public static final String UNASSIGNED_USER = "Unassigned";

public static final String DEFAULT_CSV_LINE_ENDING = "\n";
//Logging category for the main command initialization.
public static final String GLOBAL_COMMAND_LOGGER = "global.command.logger";
//Logging category for all commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
* This command uses opencsv-2.3jar @see http://opencsv.sourceforge.net/ as
* external library to read the CSV file.
*
* @deprecated
*/
public class ExportCommand extends AbstractTeamRepositoryCommand {

Expand Down Expand Up @@ -85,7 +84,11 @@ public class ExportCommand extends AbstractTeamRepositoryCommand {
// The encoding to be used when saving the file
private String fFileEncoding = IWorkItemCommandLineConstants.DEFAULT_ENCODING_UTF_16LE;
// Delimiter to be used for columns
private char fDelimiter = IWorkItemCommandLineConstants.DEFAULT_DELIMITER;
//private char fDelimiter = IWorkItemCommandLineConstants.DEFAULT_DELIMITER;
private char fCSVEscapeChar = CSVWriter.NO_ESCAPE_CHARACTER;
private String fCSVLineEnding = IWorkItemCommandLineConstants.DEFAULT_CSV_LINE_ENDING;
// Delimiter to be used for columns
private char fCSVDefaultSeparator = IWorkItemCommandLineConstants.DEFAULT_CSV_SEPERATOR_CHAR;
// Export headers as ID's?
private boolean fHeaderAsIDs = false;
// Ignore minor errors?
Expand All @@ -95,6 +98,7 @@ public class ExportCommand extends AbstractTeamRepositoryCommand {
// Suppress Attribute Not found Exception
private boolean fSuppressAttributeErrors = false;
private WorkItemExportHelper fWorkItemExportHelper;
private char fCSVDefaultQuoteChar=IWorkItemCommandLineConstants.DEFAULT_CSV_QUOTE_CHAR;

/**
* The constructor
Expand Down Expand Up @@ -327,7 +331,7 @@ private CSVWriter createWriter(String filePath) throws WorkItemCommandLineExcept
}
// @see http://opencsv.sourceforge.net/
writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(outputFile), getFileEncoding()),
getDelimiter(), getQuoteChar());
getSeparator(), getDelimiter(), getQuoteChar(), getLineEnding());
} catch (UnsupportedEncodingException e) {
throw new WorkItemCommandLineException("Exception creating CSV output writer: " + filePath, e);
} catch (FileNotFoundException e) {
Expand All @@ -336,6 +340,7 @@ private CSVWriter createWriter(String filePath) throws WorkItemCommandLineExcept
return writer;
}


/**
* Perform the export
*
Expand Down Expand Up @@ -455,7 +460,17 @@ private WorkItemExportHelper getWorkItemExportHelper() {
* @return
*/
private char getQuoteChar() {
return IWorkItemCommandLineConstants.DEFAULT_QUOTE_CHAR;
return fCSVDefaultQuoteChar;
}

/**
* Set the default quote character
*
* @return
*/
@SuppressWarnings("unused")
private void setQuoteChar(char quoteChar) {
fCSVDefaultQuoteChar=quoteChar;
}

/**
Expand Down Expand Up @@ -496,7 +511,7 @@ private void setDelimiter(String delimiter) {
throw new WorkItemCommandLineException(
"Can not convert delimiter. Delimiter must have size 1 >" + delimiter + "<");
}
fDelimiter = delimiter.charAt(0);
fCSVDefaultSeparator = delimiter.charAt(0);
}

/**
Expand All @@ -505,7 +520,7 @@ private void setDelimiter(String delimiter) {
* @return
*/
private char getDelimiter() {
return fDelimiter;
return fCSVDefaultSeparator;
}

/**
Expand Down Expand Up @@ -554,4 +569,20 @@ private void setSuppressAttributeErrors(boolean suppressAttributeErrors) {
this.fSuppressAttributeErrors = suppressAttributeErrors;
}

private String getLineEnding() {
return fCSVLineEnding ;
}

private char getSeparator() {
return fCSVDefaultSeparator;
}

public char getfCSVEscapeChar() {
return fCSVEscapeChar;
}

public void setfCSVEscapeChar(char fCSVEscapeChar) {
this.fCSVEscapeChar = fCSVEscapeChar;
}

}
Loading

0 comments on commit 402244a

Please sign in to comment.