{
String sElement = stepElement.getNodeName();
if (sElement.equals("CreateTable"))
{
final CreateTableStep create = new CreateTableStep();
create.setType(parseTableType(XMLUtil.getStringAttr(stepElement, "type"), create.getType()));
create.setName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
create.setAlias(XMLUtil.getStringAttr(stepElement, "alias"));
create.setTablespaceName(XMLUtil.getStringAttr(stepElement, "tablespace"));
create.setIndexspaceName(XMLUtil.getStringAttr(stepElement, "indexspace"));
create.setLongspaceName(XMLUtil.getStringAttr(stepElement, "longspace"));
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "aspects"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(final String sName, final boolean bInclusive)
{
create.addAspectOverride(sName, bInclusive);
}
});
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "pointcuts"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(final String sPattern, final boolean bInclusive)
{
create.addPointcutPattern(sPattern, bInclusive);
}
});
XMLUtil.withFirstChildElement(stepElement, "Columns", false, new ElementHandler()
{
public void handleElement(Element columnsElement)
{
XMLUtil.forEachChildElement(columnsElement, "Column",
getHelper().new ElementHandler("column")
{
public void handleElement(Element columnElement, String sColumnName)
{
ColumnOutline outline = new ColumnOutline();
loadColumnOutline(columnElement, outline, true);
create.addColumnOutline(outline);
}
});
}
});
XMLUtil.withFirstChildElement(stepElement, "Indexes", false, new ElementHandler()
{
public void handleElement(Element indexesElement)
{
XMLUtil.forEachChildElement(indexesElement, "Index",
getHelper().new ElementHandler("index")
{
public void handleElement(Element indexElement, String sIndexName)
{
IndexOutline outline = new IndexOutline();
loadIndexOutline(indexElement, outline);
create.addIndexOutline(outline);
}
});
}
});
XMLUtil.withFirstChildElement(stepElement, "View", false, new ElementHandler()
{
public void handleElement(Element viewElement)
{
final SQLScript script = new SQLScript();
loadSQLScript(viewElement, script);
create.setViewScript(script);
create.setViewAutoUpdated(
XMLUtil.getBooleanAttr(
viewElement, "autoupdated", create.isViewAutoUpdated()));
}
});
String sHints = XMLUtil.getStringAttr(stepElement, "hints");
if (sHints != null)
{
for (StringTokenizer tokenizer = new StringTokenizer(sHints);
tokenizer.hasMoreTokens();)
{
create.addHint(tokenizer.nextToken());
}
}
create.setPrimaryKeyName((create.getType() == Table.ASPECT) ?
XMLUtil.getStringAttr(stepElement, "primaryKey") :
XMLUtil.getReqStringAttr(stepElement, "primaryKey"));
upgrade.addStep(create);
}
else if (sElement.equals("AlterTable"))
{
final AlterTableStep alter = new AlterTableStep();
alter.setType(parseTableType(XMLUtil.getStringAttr(stepElement, "type"), alter.getType()));
alter.setName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
alter.setAlias(XMLUtil.getStringAttr(stepElement, "alias"));
alter.setPrimaryKeyName(XMLUtil.getStringAttr(stepElement, "primaryKey"));
XMLMetadataLoader.parsePatterns(
XMLUtil.getStringAttr(stepElement, "hints"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(String sName, boolean bEnabled)
{
alter.setHint(sName, bEnabled);
}
});
upgrade.addStep(alter);
}
else if (sElement.equals("RenameTable"))
{
RenameTableStep ren = new RenameTableStep();
ren.setOldName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
ren.setNewName(XMLMetadataHelper.getNameAttr(stepElement, "to", XMLMetadataHelper.NAME_DOT));
upgrade.addStep(ren);
}
else if (sElement.equals("DropTable"))
{
DropTableStep drop = new DropTableStep();
drop.setName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
upgrade.addStep(drop);
}
else if (sElement.equals("ApplyTableAspect"))
{
final ApplyTableAspectStep apply = new ApplyTableAspectStep();
apply.setAspectName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
apply.setOverride(XMLUtil.getBooleanAttr(stepElement, "override", apply.isOverride()));
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "pointcuts"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(String sPattern, boolean bInclusive)
{
apply.addPointcutPattern(sPattern, bInclusive);
}
});
loadSQLScripts(stepElement, apply.getScriptHolder());
upgrade.addStep(apply);
}
else if (sElement.equals("RemoveTableAspect"))
{
final RemoveTableAspectStep remove = new RemoveTableAspectStep();
remove.setAspectName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
remove.setOverride(XMLUtil.getBooleanAttr(stepElement, "override", remove.isOverride()));
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "pointcuts"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(String sPattern, boolean bInclusive)
{
remove.addPointcutPattern(sPattern, bInclusive);
}
});
upgrade.addStep(remove);
}
else if (sElement.equals("CreateColumn"))
{
CreateColumnStep create = new CreateColumnStep();
create.setTableName(XMLMetadataHelper.getNameAttr(stepElement, "table", XMLMetadataHelper.NAME_DOT));
ColumnOutline outline = new ColumnOutline();
loadColumnOutline(stepElement, outline, true);
create.setOutline(outline);
loadSQLScripts(stepElement, create.getScriptHolder());
upgrade.addStep(create);
}
else if (sElement.equals("AlterColumn"))
{
AlterColumnStep alter = new AlterColumnStep();
alter.setTableName(XMLMetadataHelper.getNameAttr(stepElement, "table", XMLMetadataHelper.NAME_DOT));
ColumnOutline outline = new ColumnOutline();
loadColumnOutline(stepElement, outline, false);
alter.setOutline(outline);
upgrade.addStep(alter);
}
else if (sElement.equals("RenameColumn"))
{
RenameColumnStep ren = new RenameColumnStep();
ren.setTableName(XMLMetadataHelper.getNameAttr(stepElement, "table", XMLMetadataHelper.NAME_DOT));
ren.setOldName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_ID));
ren.setNewName(XMLMetadataHelper.getNameAttr(stepElement, "to", XMLMetadataHelper.NAME_ID));
upgrade.addStep(ren);
}
else if (sElement.equals("DropColumn"))
{
DropColumnStep drop = new DropColumnStep();
drop.setTableName(XMLMetadataHelper.getNameAttr(stepElement, "table", XMLMetadataHelper.NAME_DOT));
drop.setName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_ID));
upgrade.addStep(drop);
}
else if (sElement.equals("CreateIndex"))
{
CreateIndexStep create = new CreateIndexStep();
create.setTableName(XMLMetadataHelper.getNameAttr(stepElement, "table", XMLMetadataHelper.NAME_DOT));
IndexOutline outline = new IndexOutline();
loadIndexOutline(stepElement, outline);
create.setOutline(outline);
upgrade.addStep(create);
}
else if (sElement.equals("RenameIndex"))
{
RenameIndexStep ren = new RenameIndexStep();
ren.setOldName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
ren.setNewName(XMLMetadataHelper.getNameAttr(stepElement, "to", XMLMetadataHelper.NAME_DOT));
upgrade.addStep(ren);
}
else if (sElement.equals("DropIndex"))
{
DropIndexStep drop = new DropIndexStep();
drop.setName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
upgrade.addStep(drop);
}
else if (sElement.equals("ApplyIndexAspect"))
{
final ApplyIndexAspectStep apply = new ApplyIndexAspectStep();
apply.setAspectName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
apply.setOverride(XMLUtil.getBooleanAttr(stepElement, "override", apply.isOverride()));
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "pointcuts"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(String sPattern, boolean bInclusive)
{
apply.addPointcutPattern(sPattern, bInclusive);
}
});
upgrade.addStep(apply);
}
else if (sElement.equals("RemoveIndexAspect"))
{
final RemoveIndexAspectStep remove = new RemoveIndexAspectStep();
remove.setAspectName(XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
remove.setOverride(XMLUtil.getBooleanAttr(stepElement, "override", remove.isOverride()));
XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(stepElement, "pointcuts"),
new XMLMetadataLoader.PatternHandler()
{
public void handlePattern(String sPattern, boolean bInclusive)
{
remove.addPointcutPattern(sPattern, bInclusive);
}
});
upgrade.addStep(remove);
}
else if (sElement.equals("CreateObject"))
{
CreateObjectStep create = new CreateObjectStep();
SQLScript script = new SQLScript();
create.setName(
XMLMetadataHelper.getNameAttr(stepElement, "name", XMLMetadataHelper.NAME_DOT));
loadSQLScript(stepElement, script);
create.setScript(script);
upgrade.addStep(create);
}
else if (sElement.equals("DropObject"))
{
DropObjectStep drop = new DropObjectStep();