com.ptc.windchill.upgrade.gmm
Class GatherMetaModel

java.lang.Object
  extended bycom.ptc.windchill.upgrade.gmm.GatherMetaModel

public class GatherMetaModel
extends Object

Collect XML introspection information reports for all Persistables and bundle them into a single jar file named with the prefix "MetaModel". The suffix of the jar file name will be a representation of the version number. Add an index file named MetaModelIndex.xml to the jar.

Example Usage

At a command-line whose environment is configured to run Windchill, run the command:
    java com.ptc.windchill.upgrade.gmm.GatherMetaModel
or, if the GatherMetaModel.bat file exists:
    GatherMetaModel
Windchill versions prior to 7.0 need to obtain the GatherMetaModel class and all the required supporting classes from a gatherMetaModelTools.jar created by a 7.0 installation or later.


Field Summary
static String CLASS_INFO_REF_ELEM
           
static String CLASS_INFO_REF_LINK_ATTRIB
           
private static int ERROR_CANCELED_OUT
           
private static String errorStack_
           
static String INDEX_LINK_ATTRIB
           
static String INDEX_LINK_VALUE
           
static String INDEX_ROOT_ELEM
           
private static File IndexFile_
           
static String JAR_FILE_INDEX_NAME
           
private static String JAR_FILE_PREFIX
           
private static String R40_INTERFACE
           
private static String R50_INTERFACE
           
private static ReleaseId[] releaseIds_
           
private static int SUCCESS
           
private static File tempDir_
           
private static WTProperties wtProperties_
           
 
Constructor Summary
GatherMetaModel()
           
 
Method Summary
private static void addFilesToJarAndCleanUp()
          Collects all the names of the introspection report XML files located in the tempDir_ with the extension ".xml".
private static void cleanUp(File[] to_be_deleted)
          The contents of the tempDir_ need to be deleted, before the directory can be deleted.
private static void createIndexList(File[] list_of_files)
          Creates a file named MetaModelIndex.xml for the jar.
private static void createTempDirectory()
          Creating a temporary directory to store all the introspection report XML files.
private static void createXmlClassIiGenerator(String to_be_processed)
          Creates the introspection report XML file for the class name that is passed in.
private static void gatherMetaDataIntoFiles()
          Gathering all the descendants of wt.fc.Persistable and creating the introspection report XML files.
private static PrepToolVersionVerifier getAppropriateInterfaceImplementation()
          Looking for the class wt.util.version.WindchillVersion prior to determining which class to load.
private static File getTempDirectory()
          The temporary directory holding the introspection report XML files.
private static WTProperties getWTProperties()
          If the method loadWTProperties() was successful, the wtProperties variable will be set.
private static void loadWTProperties()
          Load the wt.properties, to retrieve the values of the variables located in the file.
static void main(String[] args)
          Command-line entry point.
private static void writeDocumentToStream(Document document, OutputStream output_stream)
          Writing out the document to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IndexFile_

private static File IndexFile_

tempDir_

private static File tempDir_

errorStack_

private static String errorStack_

releaseIds_

private static ReleaseId[] releaseIds_

wtProperties_

private static WTProperties wtProperties_

ERROR_CANCELED_OUT

private static final int ERROR_CANCELED_OUT
See Also:
Constant Field Values

SUCCESS

private static final int SUCCESS
See Also:
Constant Field Values

R50_INTERFACE

private static final String R50_INTERFACE
See Also:
Constant Field Values

R40_INTERFACE

private static final String R40_INTERFACE
See Also:
Constant Field Values

JAR_FILE_PREFIX

private static final String JAR_FILE_PREFIX
See Also:
Constant Field Values

JAR_FILE_INDEX_NAME

public static final String JAR_FILE_INDEX_NAME
See Also:
Constant Field Values

INDEX_ROOT_ELEM

public static final String INDEX_ROOT_ELEM
See Also:
Constant Field Values

INDEX_LINK_ATTRIB

public static final String INDEX_LINK_ATTRIB
See Also:
Constant Field Values

INDEX_LINK_VALUE

public static final String INDEX_LINK_VALUE
See Also:
Constant Field Values

CLASS_INFO_REF_ELEM

public static final String CLASS_INFO_REF_ELEM
See Also:
Constant Field Values

CLASS_INFO_REF_LINK_ATTRIB

public static final String CLASS_INFO_REF_LINK_ATTRIB
See Also:
Constant Field Values
Constructor Detail

GatherMetaModel

public GatherMetaModel()
Method Detail

loadWTProperties

private static void loadWTProperties()
                              throws IOException
Load the wt.properties, to retrieve the values of the variables located in the file. If an error is to occur, the IOException will be thrown from here, but caught in main(String[] args) and will exit.

Throws:
IOException

getWTProperties

private static WTProperties getWTProperties()
If the method loadWTProperties() was successful, the wtProperties variable will be set. Any method or variable that needs a value of a variable in wt.properties will call this method, to retrieve the value. The method or variable would not call loadWTProperties, because it would have to throw the IOException, as well. This way minimizes the number of methods that need to throw the same exception.


createTempDirectory

private static void createTempDirectory()
                                 throws IOException
Creating a temporary directory to store all the introspection report XML files. A pre-decided name is not used, in case it already exists either as a directory or folder. If it does exist in any format, it will not be created.

Throws:
IOException - - will be thrown from main(String[] args)

getTempDirectory

private static File getTempDirectory()
The temporary directory holding the introspection report XML files.


gatherMetaDataIntoFiles

private static void gatherMetaDataIntoFiles()
                                     throws WTException
Gathering all the descendants of wt.fc.Persistable and creating the introspection report XML files.

Throws:
WTException

createXmlClassIiGenerator

private static void createXmlClassIiGenerator(String to_be_processed)
                                       throws WTException
Creates the introspection report XML file for the class name that is passed in. No value is returned because the file is being generated and placed at a location specified by the getTempDirectory().

Parameters:
to_be_processed - String - The class for which an introspection report XML file needs to be created
Throws:
WTException

addFilesToJarAndCleanUp

private static void addFilesToJarAndCleanUp()
                                     throws IOException,
                                            WTException
Collects all the names of the introspection report XML files located in the tempDir_ with the extension ".xml". It creates the jar file to store the introspection report XML files, and then inserts them. It also includes the index file. After everything has been inserted into the jar file, the files within the temporary directory is deleted, and then the directory itself.

Throws:
WTException
IOException

createIndexList

private static void createIndexList(File[] list_of_files)
                             throws IOException,
                                    WTException
Creates a file named MetaModelIndex.xml for the jar. It lists all the classes for which an introspection report XML files were created. It also has a single entry containing the Version for which the introspection report XML files were created.

Throws:
WTException
IOException

writeDocumentToStream

private static void writeDocumentToStream(Document document,
                                          OutputStream output_stream)
                                   throws IOException
Writing out the document to the stream.

Throws:
IOException

cleanUp

private static void cleanUp(File[] to_be_deleted)
The contents of the tempDir_ need to be deleted, before the directory can be deleted.


getAppropriateInterfaceImplementation

private static PrepToolVersionVerifier getAppropriateInterfaceImplementation()
                                                                      throws WTException
Looking for the class wt.util.version.WindchillVersion prior to determining which class to load. If WindchillVersion is not found, the upgrade user will be prompted for the numeric version of the source version. Otherwise, the user will be confirming the Source Version it retrieves from the database. If the appropriate class is not found a descriptive exception will be displayed.

Throws:
WTException

main

public static void main(String[] args)
Command-line entry point.