com.ptc.wgmecad.xml
Class DocCreationHelper

java.lang.Object
  extended bycom.ptc.wgmecad.xml.DocCreationHelper

public class DocCreationHelper
extends Object

Created by IntelliJ IDEA. User: barky Date: Aug 19, 2003 Time: 4:11:53 PM To change this template use Options | File Templates. 20-Jan-2004 tguski changed to add Describes tag & reference DTD on server


Field Summary
private static HashMap _itemToDocMap
           
private static String[] elementOrder
           
(package private) static org.apache.log4j.Logger logger
           
private  URL windchillSystem
           
private  Document xmldoc
           
 
Constructor Summary
DocCreationHelper(URL windchillSystem)
           
 
Method Summary
 void addFileItem(Element ecadDesign, ECADContentItem item, File root)
          search for each doc in the ecadDesign add the file item
private  void addFileItemToDoc(Element doc, ECADContentItem item, File root)
          add a file item to the file group within this doc it it exists, else create the file group with this item as its only member.
private  void appendChildren(Element e, Element[] children)
           
 Element createAssembly(DesignAll dsn, String assemblyNumber, String assemblyName, String assemblyRevision, String assemblyDescription)
          create an assembly element
 Element createAttribute(String name, String value)
          create an attribure node
 Element createBoard(DesignAll dsn)
          create a Board Element
 Element createComponent(Object[] refDess, String number, String name, String qty)
          create a component based on an array of refDes' and a number
 Element createContent(File fn, File root)
          create a content xml node
 Element createDescribes(String number, String version, String view)
          create a describes xml node
 Element createECADDesign(DesignAll dsn, Element board, Element schematic, ArrayList assemblies)
          create the ECAD Design
 Element createECADDesignBlank(DesignAll dsn, Collection asmList, boolean createSchematic, boolean createBoard)
           
 Element createECADDesignDesign(DesignAll dsn, boolean createAssembly, boolean createSchematic, boolean createBoard)
           
 Element createFileGroup(File[] files, String name, String describes, File root, Element parentDoc)
          create a files xml node
 Element createFileGroup(File[] files, String name, String describes, File root, Element parentDoc, String type)
           
 Element createRefDes(String refDes)
          create a refDes node
 Element createSchematic(DesignAll dsn)
          create a Schematic Element
static boolean doesIBADefinitionExist(String name)
           
 Element findChildWithAttribute(Element root, String tag, String attrName, String attrVal)
          look for an immediate child of the root which has the specified tag and the attribute name/value pair.
static HashMap getDocTypeToTagMap()
           
 Vector getSubElements(Element root, String[] childTags)
          walk down the chain of child tags returning a vector of all the elements which have the specified heirarchy of tags.
static void insertChildInOrder(Element parent, Element child)
           
static boolean isInOrder(Node first, Node second)
           
static boolean isInOrder(String first, String second)
           
static boolean validateAttribute(String attributeName, String attributeValue)
           
 void writeECADDesignXMLFile(File outputFile, Element ecadDesign)
          persist this ecadDesign to a file in XML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmldoc

private Document xmldoc

windchillSystem

private URL windchillSystem

logger

static org.apache.log4j.Logger logger

elementOrder

private static final String[] elementOrder

_itemToDocMap

private static HashMap _itemToDocMap
Constructor Detail

DocCreationHelper

public DocCreationHelper(URL windchillSystem)
Method Detail

isInOrder

public static boolean isInOrder(Node first,
                                Node second)
                         throws InvalidArgumentException
Throws:
InvalidArgumentException

isInOrder

public static boolean isInOrder(String first,
                                String second)
                         throws InvalidArgumentException
Throws:
InvalidArgumentException

createAttribute

public Element createAttribute(String name,
                               String value)
create an attribure node

Parameters:
name -
value -
Returns:
the Attribute Node

createRefDes

public Element createRefDes(String refDes)
create a refDes node

Parameters:
refDes -
Returns:
the Attribute Node

createComponent

public Element createComponent(Object[] refDess,
                               String number,
                               String name,
                               String qty)
                        throws XMLCompWithNoRefdesException
create a component based on an array of refDes' and a number

Parameters:
refDess -
number -
Returns:
Throws:
XMLCompWithNoRefdesException

createContent

public Element createContent(File fn,
                             File root)
create a content xml node

Parameters:
fn - File object representing the path to the file in the file system
Returns:

createFileGroup

public Element createFileGroup(File[] files,
                               String name,
                               String describes,
                               File root,
                               Element parentDoc)
create a files xml node

Parameters:
files - File objects representing the path to the file in the file system
name - Name of the fileGroup
Returns:

createFileGroup

public Element createFileGroup(File[] files,
                               String name,
                               String describes,
                               File root,
                               Element parentDoc,
                               String type)

createDescribes

public Element createDescribes(String number,
                               String version,
                               String view)
                        throws InvalidArgumentException
create a describes xml node

Parameters:
number - - number of the part that the EPMDocument describes (REQUIRED)
version - - version of the part - if null LATEST is used (OPTIONAL)
view - - view of the part - if null view from ecad props used (OPTIONAL)
Returns:
nickv todo:
Throws:
InvalidArgumentException

appendChildren

private void appendChildren(Element e,
                            Element[] children)

createBoard

public Element createBoard(DesignAll dsn)
create a Board Element

Returns:

createSchematic

public Element createSchematic(DesignAll dsn)
create a Schematic Element

Returns:

createAssembly

public Element createAssembly(DesignAll dsn,
                              String assemblyNumber,
                              String assemblyName,
                              String assemblyRevision,
                              String assemblyDescription)
create an assembly element

Returns:

createECADDesignDesign

public Element createECADDesignDesign(DesignAll dsn,
                                      boolean createAssembly,
                                      boolean createSchematic,
                                      boolean createBoard)
                               throws InvalidDesignArgumentException,
                                      IOException,
                                      VariantFileBadFormatException
Throws:
InvalidDesignArgumentException
IOException
VariantFileBadFormatException

createECADDesignBlank

public Element createECADDesignBlank(DesignAll dsn,
                                     Collection asmList,
                                     boolean createSchematic,
                                     boolean createBoard)
                              throws InvalidDesignArgumentException
Throws:
InvalidDesignArgumentException

createECADDesign

public Element createECADDesign(DesignAll dsn,
                                Element board,
                                Element schematic,
                                ArrayList assemblies)
                         throws InvalidDesignArgumentException
create the ECAD Design

Parameters:
board -
schematic -
Returns:
Throws:
InvalidDesignArgumentException

writeECADDesignXMLFile

public void writeECADDesignXMLFile(File outputFile,
                                   Element ecadDesign)
                            throws IOException
persist this ecadDesign to a file in XML

Parameters:
outputFile -
ecadDesign -
Throws:
IOException

getDocTypeToTagMap

public static HashMap getDocTypeToTagMap()

addFileItem

public void addFileItem(Element ecadDesign,
                        ECADContentItem item,
                        File root)
search for each doc in the ecadDesign add the file item

Parameters:
ecadDesign -
item -

addFileItemToDoc

private void addFileItemToDoc(Element doc,
                              ECADContentItem item,
                              File root)
add a file item to the file group within this doc it it exists, else create the file group with this item as its only member.

Parameters:
doc -
item -

findChildWithAttribute

public Element findChildWithAttribute(Element root,
                                      String tag,
                                      String attrName,
                                      String attrVal)
look for an immediate child of the root which has the specified tag and the attribute name/value pair. return it, or null if not found.

Parameters:
root -
tag -
attrName -
attrVal -
Returns:

getSubElements

public Vector getSubElements(Element root,
                             String[] childTags)
walk down the chain of child tags returning a vector of all the elements which have the specified heirarchy of tags. If the childTags is empty or null the root tag will be returned.

Parameters:
root -
childTags -

insertChildInOrder

public static void insertChildInOrder(Element parent,
                                      Element child)

doesIBADefinitionExist

public static boolean doesIBADefinitionExist(String name)

validateAttribute

public static boolean validateAttribute(String attributeName,
                                        String attributeValue)