File | Project | Line |
---|
org/apache/torque/engine/database/transform/XmlToAppData.java | Torque Generator | 359 |
org/kuali/core/db/torque/KualiXmlToAppData.java | Torque Generator | 273 |
} else if (rawName.equals("column")) {
currColumn = null;
} else if (rawName.equals("foreign-key")) {
currFK = null;
} else if (rawName.equals("index")) {
currIndex = null;
} else if (rawName.equals("unique")) {
currUnique = null;
}
} catch (Exception e) {
throw new SAXException(e);
}
}
public void setOption(Attributes attributes) {
// Look thru supported model elements in reverse order to
// find one that this option statement applies to.
String key = attributes.getValue("key");
String value = attributes.getValue("value");
if (currUnique != null) {
currUnique.addOption(key, value);
} else if (currIndex != null) {
currIndex.addOption(key, value);
} else if (currFK != null) {
currFK.addOption(key, value);
} else if (currColumn != null) {
currColumn.addOption(key, value);
} else if (currTable != null) {
currTable.addOption(key, value);
} else { // Must be a db level option.
database.addOption(key, value);
}
}
/**
* Handles exception which occur when the xml file is parsed
*
* @param e
* the exception which occured while parsing
* @throws SAXException
* always
*/
public void error(SAXParseException e) throws SAXException {
log.error("Sax parser threw an Exception", e);
throw new SAXException("Error while parsing " + currentXmlFile + " at line " + e.getLineNumber() + " column " + e.getColumnNumber() + " : " + e.getMessage());
}
/**
* When parsing multiple files that use nested <external-schema> tags we need to use a stack to remember some
* values.
*/
private static class ParseStackElement {
private boolean isExternalSchema;
private String currentPackage;
private String currentXmlFile;
private boolean firstPass;
/**
*
* @param parser
*/
public ParseStackElement(KualiXmlToAppData parser) { |
File | Project | Line |
---|
org/apache/torque/engine/database/transform/XmlToAppData.java | Torque Generator | 287 |
org/kuali/core/db/torque/KualiXmlToAppData.java | Torque Generator | 225 |
} else if (rawName.equals("column")) {
currColumn = currTable.addColumn(attributes);
} else if (rawName.equals("inheritance")) {
currColumn.addInheritance(attributes);
} else if (rawName.equals("foreign-key")) {
currFK = currTable.addForeignKey(attributes);
} else if (rawName.equals("reference")) {
currFK.addReference(attributes);
} else if (rawName.equals("index")) {
currIndex = currTable.addIndex(attributes);
} else if (rawName.equals("index-column")) {
currIndex.addColumn(attributes);
} else if (rawName.equals("unique")) {
currUnique = currTable.addUnique(attributes);
} else if (rawName.equals("unique-column")) {
currUnique.addColumn(attributes);
} else if (rawName.equals("id-method-parameter")) {
currTable.addIdMethodParameter(attributes);
} else if (rawName.equals("option")) {
setOption(attributes);
}
} catch (Exception e) {
throw new SAXException(e);
}
}
/**
* Handles closing elements of the xml file.
*
* @param uri
* @param localName
* The local name (without prefix), or the empty string if Namespace processing is not being performed.
* @param rawName
* The qualified name (with prefix), or the empty string if qualified names are not available.
*/
public void endElement(String uri, String localName, String rawName) throws SAXException {
if (log.isDebugEnabled()) {
log.debug("endElement(" + uri + ", " + localName + ", " + rawName + ") called");
}
try {
// Reset working objects to null to allow option to know
// which element it is associated with.
if (rawName.equals("table")) {
currTable = null;
} else if (rawName.equals("view")) { |
File | Project | Line |
---|
org/apache/torque/engine/database/transform/XmlToAppData.java | Torque Generator | 212 |
org/kuali/core/db/torque/KualiXmlToAppData.java | Torque Generator | 165 |
return new ImpexDTDResolver().resolveEntity(publicId, systemId);
} catch (Exception e) {
throw new SAXException(e);
}
}
/**
* Handles opening elements of the xml file.
*
* @param uri
* @param localName
* The local name (without prefix), or the empty string if Namespace processing is not being performed.
* @param rawName
* The qualified name (with prefix), or the empty string if qualified names are not available.
* @param attributes
* The specified or defaulted attributes
*/
public void startElement(String uri, String localName, String rawName, Attributes attributes) throws SAXException {
try {
if (rawName.equals("database")) {
if (isExternalSchema) {
currentPackage = attributes.getValue("package");
if (currentPackage == null) {
currentPackage = defaultPackage;
}
} else {
database.loadFromXML(attributes);
if (database.getPackage() == null) {
database.setPackage(defaultPackage);
}
}
} else if (rawName.equals("external-schema")) {
String xmlFile = attributes.getValue("filename");
if (xmlFile.charAt(0) != '/') {
File f = new File(currentXmlFile);
xmlFile = new File(f.getParent(), xmlFile).getPath();
}
// put current state onto the stack
ParseStackElement.pushState(this);
isExternalSchema = true;
parseResource(xmlFile);
// get the last state from the stack
ParseStackElement.popState(this);
} else if (rawName.equals("domain")) {
Domain domain = new Domain();
domain.loadFromXML(attributes, database.getPlatform());
database.addDomain(domain);
} else if (rawName.equals("table")) {
currTable = database.addTable(attributes);
if (isExternalSchema) {
currTable.setForReferenceOnly(true);
currTable.setPackage(currentPackage);
}
} else if (rawName.equals("view")) { |
File | Project | Line |
---|
org/apache/torque/engine/database/model/Column.java | Torque Generator | 200 |
org/apache/torque/engine/database/model/Table.java | Torque Generator | 519 |
}
/**
* Get the name of the Table
*/
public String getName() {
return name;
}
/**
* Set the name of the Table
*/
public void setName(String newName) {
name = newName;
}
/**
* Get the description for the Table
*/
public String getDescription() {
return description;
}
/**
* Set the description for the Table
*
* @param newDescription
* description for the Table
*/
public void setDescription(String newDescription) {
description = newDescription;
}
/**
* Get name to use in Java sources
*/
public String getJavaName() {
if (javaName == null) {
List inputs = new ArrayList(2);
inputs.add(name);
inputs.add(javaNamingMethod);
try {
javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR, inputs);
} catch (EngineException e) {
log.error(e, e);
}
}
return javaName; |