Commit 289969bd authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Improved SQL code generation, create and drop script separated.

This is gencastor version 3.2-0.
parent c24e40c2
gencastor (3.2-0) unstable; urgency=low
* Improved SQL code generation, separated scripts for creating and
dropping the schema.
* MySQL generation currently disabled.
-- Giuseppe Lo Presti <giuseppe.lopresti@cern.ch> Wed, 27 Jul 2005 11:00:00 +0200
gencastor (3.1-3) unstable; urgency=low
* Added INITRANS and PCTFREE to all tables in Oracle SQL generation.
-- Giuseppe LO PRESTI <giuseppe.lopresti@cern.ch> Fri, 1 Jul 2005 17:45:53 +0200
-- Giuseppe Lo Presti <giuseppe.lopresti@cern.ch> Fri, 1 Jul 2005 17:45:53 +0200
gencastor (3.1-2) unstable; urgency=low
* Fixed queries involving truncated long entity names.
-- Giuseppe Lo Presti <giuseppe.lopresti@cern.ch> Wed, 1 June 2005 15:00:00 +0200
-- Giuseppe Lo Presti <giuseppe.lopresti@cern.ch> Wed, 1 Jun 2005 15:00:00 +0200
gencastor (3.1-1) unstable; urgency=low
......
gencastor_3.1-3_i386.deb devel optional
gencastor_3.2-0_i386.deb devel optional
......@@ -28,7 +28,7 @@ static KCmdLineOptions options[] = {
int main(int argc, char *argv[]) {
KAboutData aboutData("umbrello", I18N_NOOP("Umbrello UML Modeller - Castor edition"),
"3.1.3", "Umbrello UML Modeller - Castor edition", KAboutData::License_GPL,
"3.2.0", "Umbrello UML Modeller - Castor edition", KAboutData::License_GPL,
I18N_NOOP("2004-2005 Sebastien Ponce & Giuseppe Lo Presti"), 0,
"http://cern.ch/castor");
KCmdLineArgs::init( argc, argv, &aboutData );
......
......@@ -2,7 +2,10 @@
if ("$1" == "-h") then
echo "Usage :"
echo " gencastor [-w castor_workdir] [-h] XMIFile"
echo " gencastor [-w castor_workdir] [-h] [-v|--version] XMIFile"
exit
else if ("$1" == "-v" || "$1" == "--version") then
/usr/bin/gencastor.bin --version
exit
else if ("$1" == "-w") then
set WORKDIR=$2
......@@ -15,17 +18,9 @@ set TMPDIR=`mktemp /tmp/gencastor-XXXXXX`
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}/castor/db
cp ${WORKDIR}/castor/db/oracleTrailer.sql ${TMPDIR}/castor/db/
cp ${WORKDIR}/castor/db/oracleHeader.sql ${TMPDIR}/castor/db/
cp ${WORKDIR}/castor/db/mysqlHeader.sql ${TMPDIR}/castor/db/
cp ${WORKDIR}/castor/db/mysqlTrailer.sql ${TMPDIR}/castor/db/
cp ${WORKDIR}/castor/db/*.sql ${TMPDIR}/castor/db/
/usr/bin/gencastor.bin -o ${TMPDIR} --nocrashhandler ${XMIFILE}
if !($?) then
#echo Abnormal termination
#exit
endif
set pushdsilent
pushd ${TMPDIR}
foreach f (`find . -type f`)
......@@ -47,4 +42,4 @@ foreach f (`find . -type f`)
end
popd
rm -rf ${TMPDIR}
rm -f ${WORKDIR}/castor/db/*Generated*
......@@ -38,25 +38,29 @@ CppCppOraCnvWriter::~CppCppOraCnvWriter() {
void CppCppOraCnvWriter::startSQLFile() {
// Preparing SQL file for creation/deletion of the database
QFile file;
openFile(file,
"castor/db/oracle.sql",
openFile(file, "castor/db/castor_oracle_create.sql",
IO_WriteOnly | IO_Truncate);
QTextStream stream(&file);
insertFileintoStream(stream, "castor/db/oracleHeader.sql");
file.close();
openFile(file, "castor/db/oracleGeneratedHeader.sql",
openFile(file, "castor/db/oracleGeneratedCore_create.sql",
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, "castor/db/oracleGeneratedCore.sql",
openFile(file, "castor/db/oracleGeneratedTrailer_create.sql",
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, "castor/db/castor_oracle_drop.sql",
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, "castor/db/oracleGeneratedTrailer.sql",
openFile(file, "castor/db/oracleGeneratedHeader_drop.sql",
IO_WriteOnly | IO_Truncate);
file.close();
file.close();
openFile(file, "castor/db/oracleGeneratedCore_drop.sql",
IO_WriteOnly | IO_Truncate);
file.close();
}
//=============================================================================
// insertIntoSQLFile
// insertFileIntoStream
//=============================================================================
void CppCppOraCnvWriter::insertFileintoStream(QTextStream &stream,
QString fileName) {
......@@ -77,15 +81,22 @@ void CppCppOraCnvWriter::insertFileintoStream(QTextStream &stream,
void CppCppOraCnvWriter::endSQLFile() {
// Preparing SQL file for creation/deletion of the database
QFile file;
openFile(file,
"castor/db/oracle.sql",
openFile(file, "castor/db/castor_oracle_create.sql",
IO_WriteOnly | IO_Append);
QTextStream stream(&file);
insertFileintoStream(stream, "castor/db/oracleGeneratedHeader.sql");
insertFileintoStream(stream, "castor/db/oracleGeneratedCore.sql");
insertFileintoStream(stream, "castor/db/oracleGeneratedTrailer.sql");
insertFileintoStream(stream, "castor/db/oracleGeneratedCore_create.sql");
insertFileintoStream(stream, "castor/db/oracleGeneratedTrailer_create.sql");
insertFileintoStream(stream, "castor/db/oracleTrailer.sql");
file.close();
openFile(file, "castor/db/castor_oracle_drop.sql",
IO_WriteOnly | IO_Append);
QTextStream streamD(&file);
insertFileintoStream(streamD, "castor/db/oracleHeader_drop.sql");
insertFileintoStream(streamD, "castor/db/oracleGeneratedHeader_drop.sql");
insertFileintoStream(streamD, "castor/db/oracleGeneratedCore_drop.sql");
insertFileintoStream(streamD, "castor/db/oracleTrailer_drop.sql");
file.close();
}
//=============================================================================
......@@ -527,26 +538,36 @@ void CppCppOraCnvWriter::writeConstants() {
// writeSqlStatements
//=============================================================================
void CppCppOraCnvWriter::writeSqlStatements() {
QFile file, hFile, tFile;
openFile(hFile,
"castor/db/oracleGeneratedHeader.sql",
IO_WriteOnly | IO_Append);
QTextStream hStream(&hFile);
QFile file, tFile, fileD, hFileD;
openFile(file,
"castor/db/oracleGeneratedCore.sql",
"castor/db/oracleGeneratedCore_create.sql",
IO_WriteOnly | IO_Append);
QTextStream stream(&file);
openFile(tFile,
"castor/db/oracleGeneratedTrailer.sql",
"castor/db/oracleGeneratedTrailer_create.sql",
IO_WriteOnly | IO_Append);
QTextStream tStream(&tFile);
stream << "/* SQL statements for type "
openFile(hFileD,
"castor/db/oracleGeneratedHeader_drop.sql",
IO_WriteOnly | IO_Append);
QTextStream hStreamD(&hFileD);
openFile(fileD,
"castor/db/oracleGeneratedCore_drop.sql",
IO_WriteOnly | IO_Append);
QTextStream streamD(&fileD);
streamD << "/* SQL statements for type "
<< m_classInfo->className
<< " */"
<< endl
<< "DROP TABLE "
<< m_classInfo->className
<< ";" << endl
<< ";" << endl;
stream << "/* SQL statements for type "
<< m_classInfo->className
<< " */"
<< endl
<< "CREATE TABLE "
<< m_classInfo->className
<< " (";
......@@ -601,7 +622,7 @@ void CppCppOraCnvWriter::writeSqlStatements() {
QString compoundName =
capitalizeFirstLetter(firstMember->typeName).mid(0, 12) + QString("2")
+ capitalizeFirstLetter(secondMember->typeName).mid(0, 13);
stream << getIndent()
streamD << getIndent()
<< "DROP INDEX I_"
<< compoundName
<< "_C;"
......@@ -611,8 +632,8 @@ void CppCppOraCnvWriter::writeSqlStatements() {
<< "_P;"
<< endl << "DROP TABLE "
<< compoundName
<< ";" << endl
<< "CREATE TABLE "
<< ";" << endl;
stream << "CREATE TABLE "
<< compoundName
<< " (Parent INTEGER, Child INTEGER) INITRANS 50 PCTFREE 50;"
<< endl << getIndent()
......@@ -628,7 +649,7 @@ void CppCppOraCnvWriter::writeSqlStatements() {
<< compoundName
<< " (parent);"
<< endl;
hStream << getIndent()
hStreamD << getIndent()
<< "ALTER TABLE "
<< compoundName
<< endl << getIndent()
......@@ -656,9 +677,11 @@ void CppCppOraCnvWriter::writeSqlStatements() {
}
}
stream << endl;
hFile.close();
streamD << endl;
file.close();
tFile.close();
hFileD.close();
fileD.close();
}
//=============================================================================
......
......@@ -262,10 +262,10 @@ void CppWriter::writeClass(UMLClassifier *c) {
QString file = fileName.right(fileName.length()-i);
runGenerator(orahw, "castor/db/ora/Ora" + file + "Cnv.hpp", c);
runGenerator(oracppw, "castor/db/ora/Ora" + file + "Cnv.cpp", c);
runGenerator(myhw, "castor/db/mysql/My" + file + "Cnv.hpp", c);
runGenerator(mycppw, "castor/db/mysql/My" + file + "Cnv.cpp", c);
// runGenerator(odbchw, "castor/db/odbc/Odbc" + file + "Cnv.hpp", c);
// runGenerator(odbccppw, "castor/db/odbc/Odbc" + file + "Cnv.cpp", c);
//runGenerator(pghw, "castor/db/pgsql/Pg" + file + "Cnv.hpp", c);
//runGenerator(pgcppw, "castor/db/pgsql/Pg" + file + "Cnv.cpp", c);
//runGenerator(myhw, "castor/db/mysql/My" + file + "Cnv.hpp", c);
//runGenerator(mycppw, "castor/db/mysql/My" + file + "Cnv.cpp", c);
}
}
UMLObject* obj = m_doc->findUMLObject(QString("castor::IStreamable"),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment