com.ptc.wgmecad
Class ProcessManager

java.lang.Object
  extended bycom.ptc.wgmecad.ProcessManager
All Implemented Interfaces:
IRegisterProgress

public class ProcessManager
extends Object
implements IRegisterProgress

Created by IntelliJ IDEA. User: barky Date: Jan 8, 2003 Time: 3:37:51 PM To change this template use Options | File Templates. Change History: 2004.02.12 Nickv: added bom template processing


Field Summary
private static FileFilter emptyFilter
           
protected  FileManager fileMgr
           
static int HOOKRESPONSEDIALOG_X_LOCATION
           
static int HOOKRESPONSEDIALOG_Y_LOCATION
           
private static ProcessManager instance
           
(package private) static org.apache.log4j.Logger logger
           
private static int nominalZipSize
           
static String POST
           
static String POST_FUNC
           
static String PRE
           
static String PRE_FUNC
           
static String PRE_LOAD
           
protected static String separator
           
static String templateBOMName
           
static int zipWriteBlockSize
           
 
Constructor Summary
private ProcessManager()
           
 
Method Summary
private  void copyFileAndSubstitute(InputStream is, OutputStream os, String fromName, String toName, String fromNum, String toNum)
           
private  boolean execute(DesignAll _design, String[] commandAndArgs, PrintStream output)
          return true on execution of the command without any exceptions being thrown
static boolean execute(String command, PrintStream output, String[] env, boolean waitFlag)
          return true on execution of the command without any exceptions being thrown
 boolean executeBOM(DesignAll _design, File cpmFile, File output, File tempDir, PrintStream outputStream)
           
 boolean executeHook(DesignAll _design, String function, String when)
          Execute the appropriate hook function
 boolean executeInternalHook(DesignAll _design, String function, String when, String _ecadTool, String _command)
          Execute the appropriate hook function
 boolean executeOhio(String fileName)
          Execute the appropriate hook function
 boolean executeUnzip(String fileName)
          Execute the appropriate hook function
 boolean extractPkgFile(File pkgFile, File toLocation)
          This method basically unzips the file into the target toLocation directory
private  String[] getCommandEnvironment(DesignAll _design, String command, String function, String when, String _ecadTool)
          provide 4 args to the tools being called: WGM function being executed where in the process it is the main Assembly number the project location or file
static Vector getDirectoryContent(File root)
          recursively traverses a directory (root) and creates a vector of all files/subdirectories it contains.
static Vector getDirectoryContent(File root, FileFilter filter, boolean traverseSubDirectories)
          filtered version of getDirectorContent.
private  File[] getFilesForDirectory(File inputFile, File excludeDir)
           
static File[] getFilesForDirectory(File inputFile, Vector excludeDirs)
          handle multiple exclude directories
static ProcessManager getInstance()
           
static ProgressMonitor getProgressMonitor(String resourceKey, int blocks)
           
static ProgressMonitor getProgressMonitor(String resourceKey, int blocks, String fileName)
           
static Object[] getTemplateBomTotaledProperties()
          parse the template bom and pull out the properties that have a total associated with them
 int getTotalInitTime()
           
 int getTotalOperation()
           
 int getTotalPre()
           
 FilterInputStream getZStream(File pkgFile)
           
static void main(String[] args)
           
private  boolean processCommandOutput(String commandOutputString, String commandArgument)
          when a hook executes and returns a status, we need to parse it.
static boolean recursiveDeleteDirectory(File dir)
           
static boolean recursiveDeleteDirectory(File dir, File[] excl)
           
private  boolean showHookResponseDialog(String errorType, boolean aButton, boolean cButton, String message, String commandArgument)
           
private  String substCommandMacros(String command)
           
 Vector writeZipFile(File zipFile, File root, File[] inputFiles, ZipOutputStream zipout, HashMap alreadyArchived)
           
 Vector writeZipFile(File zipFile, File inputFile, File excludeDir, ZipOutputStream zipout, HashMap alreadyArchived)
           
 Vector writeZipFile(File zipFile, File inputFile, Vector excludeDirs, ZipOutputStream zipout, HashMap alreadyArchived)
          Allow multiple exclude directories
 Vector writeZipFile(File zipFile, File inputFile, ZipOutputStream zipout, HashMap alreadyArchived)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileMgr

protected FileManager fileMgr

zipWriteBlockSize

public static final int zipWriteBlockSize
See Also:
Constant Field Values

emptyFilter

private static final FileFilter emptyFilter

templateBOMName

public static final String templateBOMName
See Also:
Constant Field Values

PRE_LOAD

public static final String PRE_LOAD
See Also:
Constant Field Values

PRE

public static final String PRE
See Also:
Constant Field Values

PRE_FUNC

public static final String PRE_FUNC
See Also:
Constant Field Values

POST

public static final String POST
See Also:
Constant Field Values

POST_FUNC

public static final String POST_FUNC
See Also:
Constant Field Values

HOOKRESPONSEDIALOG_X_LOCATION

public static final int HOOKRESPONSEDIALOG_X_LOCATION
See Also:
Constant Field Values

HOOKRESPONSEDIALOG_Y_LOCATION

public static final int HOOKRESPONSEDIALOG_Y_LOCATION
See Also:
Constant Field Values

separator

protected static final String separator
See Also:
Constant Field Values

instance

private static ProcessManager instance

logger

static org.apache.log4j.Logger logger

nominalZipSize

private static final int nominalZipSize
See Also:
Constant Field Values
Constructor Detail

ProcessManager

private ProcessManager()
Method Detail

getInstance

public static ProcessManager getInstance()

recursiveDeleteDirectory

public static boolean recursiveDeleteDirectory(File dir)

recursiveDeleteDirectory

public static boolean recursiveDeleteDirectory(File dir,
                                               File[] excl)

getDirectoryContent

public static Vector getDirectoryContent(File root)
recursively traverses a directory (root) and creates a vector of all files/subdirectories it contains. The root will also be included

Parameters:
root - - directory to traverse
Returns:
Vector of File's representing the directore and its contents

getDirectoryContent

public static Vector getDirectoryContent(File root,
                                         FileFilter filter,
                                         boolean traverseSubDirectories)
filtered version of getDirectorContent.

Parameters:
root -
filter -
traverseSubDirectories - - true to cause it to enumerate the files of the subdirectories
Returns:

writeZipFile

public Vector writeZipFile(File zipFile,
                           File inputFile,
                           ZipOutputStream zipout,
                           HashMap alreadyArchived)
                    throws IOException,
                           FileNotFoundException,
                           zipFileCreationInterruptedException
Throws:
IOException
FileNotFoundException
zipFileCreationInterruptedException

writeZipFile

public Vector writeZipFile(File zipFile,
                           File inputFile,
                           File excludeDir,
                           ZipOutputStream zipout,
                           HashMap alreadyArchived)
                    throws IOException,
                           FileNotFoundException,
                           zipFileCreationInterruptedException
Throws:
IOException
FileNotFoundException
zipFileCreationInterruptedException

writeZipFile

public Vector writeZipFile(File zipFile,
                           File inputFile,
                           Vector excludeDirs,
                           ZipOutputStream zipout,
                           HashMap alreadyArchived)
                    throws IOException,
                           FileNotFoundException,
                           zipFileCreationInterruptedException
Allow multiple exclude directories

Parameters:
zipFile -
inputFile -
excludeDirs -
Returns:
Throws:
IOException
FileNotFoundException
zipFileCreationInterruptedException

getFilesForDirectory

private File[] getFilesForDirectory(File inputFile,
                                    File excludeDir)

getFilesForDirectory

public static File[] getFilesForDirectory(File inputFile,
                                          Vector excludeDirs)
handle multiple exclude directories

Parameters:
inputFile -
excludeDirs -
Returns:

getZStream

public FilterInputStream getZStream(File pkgFile)
                             throws IOException
Throws:
IOException

extractPkgFile

public boolean extractPkgFile(File pkgFile,
                              File toLocation)
                       throws IOException,
                              FileNotFoundException,
                              CancelledException
This method basically unzips the file into the target toLocation directory

Parameters:
toLocation - this is where the zip file will be unzipped to. Will be created if not already existing.
Returns:
Throws:
IOException
FileNotFoundException
CancelledException

getProgressMonitor

public static ProgressMonitor getProgressMonitor(String resourceKey,
                                                 int blocks)

getProgressMonitor

public static ProgressMonitor getProgressMonitor(String resourceKey,
                                                 int blocks,
                                                 String fileName)

writeZipFile

public Vector writeZipFile(File zipFile,
                           File root,
                           File[] inputFiles,
                           ZipOutputStream zipout,
                           HashMap alreadyArchived)
                    throws IOException,
                           FileNotFoundException,
                           zipFileCreationInterruptedException
Throws:
IOException
FileNotFoundException
zipFileCreationInterruptedException

getTemplateBomTotaledProperties

public static Object[] getTemplateBomTotaledProperties()
parse the template bom and pull out the properties that have a total associated with them

Returns:
an Object [] of the strings representing the titles of the properties in the bom template with a total.

executeBOM

public boolean executeBOM(DesignAll _design,
                          File cpmFile,
                          File output,
                          File tempDir,
                          PrintStream outputStream)
                   throws InternalBomFailedException
Throws:
InternalBomFailedException

copyFileAndSubstitute

private void copyFileAndSubstitute(InputStream is,
                                   OutputStream os,
                                   String fromName,
                                   String toName,
                                   String fromNum,
                                   String toNum)
                            throws IOException
Throws:
IOException

main

public static void main(String[] args)

executeHook

public boolean executeHook(DesignAll _design,
                           String function,
                           String when)
                    throws ApplicationInvocationException
Execute the appropriate hook function

Parameters:
function - the resource key for the function being executed
when - the resource key for the timing (pre/post/post function etc.)
Returns:
true if on exceptions are thrown
Throws:
ApplicationInvocationException

executeInternalHook

public boolean executeInternalHook(DesignAll _design,
                                   String function,
                                   String when,
                                   String _ecadTool,
                                   String _command)
                            throws ApplicationInvocationException
Execute the appropriate hook function

Parameters:
function - the resource key for the function being executed
when - the resource key for the timing (pre/post/post function etc.)
Returns:
true if on exceptions are thrown
Throws:
ApplicationInvocationException

executeOhio

public boolean executeOhio(String fileName)
                    throws ApplicationInvocationException
Execute the appropriate hook function

Returns:
true if on exceptions are thrown
Throws:
ApplicationInvocationException

executeUnzip

public boolean executeUnzip(String fileName)
                     throws ApplicationInvocationException
Execute the appropriate hook function

Returns:
true if on exceptions are thrown
Throws:
ApplicationInvocationException

processCommandOutput

private boolean processCommandOutput(String commandOutputString,
                                     String commandArgument)
when a hook executes and returns a status, we need to parse it.

Parameters:
commandOutputString -
Returns:

showHookResponseDialog

private boolean showHookResponseDialog(String errorType,
                                       boolean aButton,
                                       boolean cButton,
                                       String message,
                                       String commandArgument)

execute

public static boolean execute(String command,
                              PrintStream output,
                              String[] env,
                              boolean waitFlag)
                       throws ApplicationInvocationException
return true on execution of the command without any exceptions being thrown

Parameters:
command - - the exact command to run
Returns:
Throws:
ApplicationInvocationException - thrown if any exception is thrown while running the command.

execute

private boolean execute(DesignAll _design,
                        String[] commandAndArgs,
                        PrintStream output)
                 throws ApplicationInvocationException
return true on execution of the command without any exceptions being thrown

Parameters:
commandAndArgs - - the exact command to run
Returns:
Throws:
ApplicationInvocationException - thrown if any exception is thrown while running the command.()

getCommandEnvironment

private String[] getCommandEnvironment(DesignAll _design,
                                       String command,
                                       String function,
                                       String when,
                                       String _ecadTool)
provide 4 args to the tools being called: WGM function being executed where in the process it is the main Assembly number the project location or file

Parameters:
function -
when -
Returns:

substCommandMacros

private String substCommandMacros(String command)

getTotalPre

public int getTotalPre()
Specified by:
getTotalPre in interface IRegisterProgress

getTotalOperation

public int getTotalOperation()
Specified by:
getTotalOperation in interface IRegisterProgress

getTotalInitTime

public int getTotalInitTime()
Specified by:
getTotalInitTime in interface IRegisterProgress