Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -11,12 +11,11 @@
#include <grantlee/engine.h>
using namespace CodeGen;
GeneratorGrantleeBase::GeneratorGrantleeBase(const char *loggerName)
: m_engine(new Grantlee::Engine)
GeneratorGrantleeBase::GeneratorGrantleeBase(const char *loggerName) : m_engine(new Grantlee::Engine)
, m_ctx(new Grantlee::Context)
, m_structBuilder(nullptr)
.getNGLLogger(loggerName))
{
.getNGLLogger(loggerName)),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
}
GeneratorGrantleeBase::~GeneratorGrantleeBase()
@@ -48,7 +47,7 @@ bool GeneratorGrantleeBase::setTemplate(const QString &templateName, const QStri
m_template = m_engine->newTemplate(tmpl, QStringLiteral("myTemplate"));
if (m_template->error())
{
WARNING_LOG() << "Error parsing template '" << templateName
WARNING_LOG(m_logger) << "Error parsing template '" << templateName
<< "': " << m_template->errorString();
return false;
}
@@ -88,7 +87,7 @@ bool GeneratorGrantleeBase::generateData(const QString &templateName,
QFile f(outDirectory + QLatin1Char('/') + outFilename);
if (!f.open(QIODevice::WriteOnly))
{
ERROR_LOG() << "Error opening file '" << f.fileName() << "' for writing: "
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: "
<< f.errorString() << "(" << f.error() << ")";
return false;
}
@@ -96,7 +95,7 @@ bool GeneratorGrantleeBase::generateData(const QString &templateName,
f.write(outData);
f.close();
DEBUG_LOG() << "Written data to " << f.fileName();
DEBUG_LOG(m_logger) << "Written data to " << f.fileName();
return true;
}
@@ -105,7 +104,7 @@ bool GeneratorGrantleeBase::readFile(const QString &filename, QString &data) con
QFile f(filename);
if (!f.open(QIODevice::ReadOnly))
{
ERROR_LOG() << "Error opening file " << filename
ERROR_LOG(m_logger) << "Error opening file " << filename
<< " - error: " << f.errorString();
return false;
}
@@ -121,7 +120,7 @@ bool GeneratorGrantleeBase::getFilenameFromData(const QString &dataToParse, QStr
int idx = dataToParse.indexOf(filenameMarker);
if (idx < 0)
{
ERROR_LOG() << "Could not find marker '" << filenameMarker
ERROR_LOG(m_logger) << "Could not find marker '" << filenameMarker
<< "' in data!";
return false;
}
@@ -129,7 +128,7 @@ bool GeneratorGrantleeBase::getFilenameFromData(const QString &dataToParse, QStr
int endIdx = dataToParse.indexOf(QLatin1Char('\n'), idx);
if (endIdx < 0)
{
ERROR_LOG() << "Could not find end marker '\\n' in data!";
ERROR_LOG(m_logger) << "Could not find end marker '\\n' in data!";
return false;
}
filename = dataToParse.mid(idx, endIdx - idx).trimmed();
@@ -160,12 +159,12 @@ void GeneratorGrantleeBase::addCustomFunctions(const QVector<CustomServiceFuncti
break;
case CustomServiceFunctionInformation::Type::DbNotify:
WARNING_LOG() << "Internal error - Trying to handle DbNotify in addCustomFunctions(): "
WARNING_LOG(m_logger) << "Internal error - Trying to handle DbNotify in addCustomFunctions(): "
<< csfi.methodName;
delete customFunctionWrapper;
break;
}
DEBUG_LOG() << "Added custom db function " << csfi.methodName;
DEBUG_LOG(m_logger) << "Added custom db function " << csfi.methodName;
}
m_ctx->insert(QStringLiteral("custom_dtc_procs"), vlCustomDtcFunctions);
m_ctx->insert(QStringLiteral("custom_db_procs"), vlCustomDbFunctions);
@@ -185,17 +184,17 @@ void GeneratorGrantleeBase::exportUsedServices(const XmlReader *reader)
const int idx = fullPath.lastIndexOf(QLatin1Char('.'));
if (idx < 0)
{
ERROR_LOG() << "Could not parse file path: " << fullPath;
ERROR_LOG(m_logger) << "Could not parse file path: " << fullPath;
continue;
}
const QString idlFile = fullPath.left(idx);
if (idlFile.isEmpty())
{
WARNING_LOG() << "Could not find idl file for service " << svc;
WARNING_LOG(m_logger) << "Could not find idl file for service " << svc;
continue;
}
idlServicesWrapper->addService(svc, idlFile);
DEBUG_LOG() << "Added service " << svc;
DEBUG_LOG(m_logger) << "Added service " << svc;
}
m_ctx->insert(QStringLiteral("ext_services"), idlServicesWrapper);
}
@@ -35,6 +35,7 @@ public:
const QString &outDirectory);
protected:
NGL::INGLLogger &m_logger;
explicit GeneratorGrantleeBase(const char *loggerName);
bool initInternal(const XmlReader *reader, StructBuilder *structBuilder);
@@ -43,6 +44,7 @@ protected:
void addCustomFunctions(const QVector<CustomServiceFunctionInformation> &customFunctions);
void exportUsedServices(const XmlReader *reader);
protected:
NGL::INGLLogger &m_logger;
Grantlee::Engine *m_engine;
Grantlee::Context *m_ctx;
Grantlee::Template m_template;
@@ -19,13 +19,12 @@ static QString getExerciseSchemaName(int exerciseId)
return QStringLiteral("ex_") + QString::number(exerciseId);
}
SqlGenerator::SqlGenerator(XmlReader *xmlReader, StructBuilder *structBuilder)
: m_xmlReader(xmlReader)
SqlGenerator::SqlGenerator(XmlReader *xmlReader, StructBuilder *structBuilder) : m_xmlReader(xmlReader)
, m_structBuilder(structBuilder)
, m_createdByXmlFile(false)
, m_isValid(true)
, m_exerciseId(0)
{}
, m_exerciseId(0),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
SqlGenerator::SqlGenerator(const QString &xmlFile)
: m_xmlReader(new XmlReader)
@@ -49,7 +48,7 @@ SqlGenerator::~SqlGenerator()
bool SqlGenerator::generateData(int exerciseId)
{
DEBUG_LOG() << "Generating SQL data for service " << getServiceAbbr() << " in exercise " << exerciseId << ", this: " << this;
DEBUG_LOG(m_logger) << "Generating SQL data for service " << getServiceAbbr() << " in exercise " << exerciseId << ", this: " << this;
m_exerciseId = exerciseId;
m_sqlGlobal = SqlStatements();
@@ -134,11 +133,11 @@ bool SqlGenerator::handleViews()
bool SqlGenerator::handleView(const ViewInformation &vi)
{
DEBUG_LOG() << "Handle view " << vi.name;
DEBUG_LOG(m_logger) << "Handle view " << vi.name;
const QString parent = vi.baseTable;
DEBUG_LOG() << "Parent = " << parent;
DEBUG_LOG(m_logger) << "Parent = " << parent;
if (!parent.isEmpty())
{
@@ -146,7 +145,7 @@ bool SqlGenerator::handleView(const ViewInformation &vi)
const QString createViewStmt(QStringLiteral("CREATE OR REPLACE VIEW %1 AS SELECT %2\nFROM %3\nWHERE %4;\n"));
const QString dropViewStmt(QStringLiteral("DROP VIEW IF EXISTS %1;"));
DEBUG_LOG() << "csi.primaryTable = " << csi.primaryTable.data()->name;
DEBUG_LOG(m_logger) << "csi.primaryTable = " << csi.primaryTable.data()->name;
if (!csi.primaryTable.isNull())
{
@@ -166,7 +165,7 @@ bool SqlGenerator::handleView(const ViewInformation &vi)
fqColumnNames += mi.db.table + QLatin1Char('.') + mi.db.columnName + QLatin1String(" AS ") + mi.db.getColumnNameView();
}
DEBUG_LOG() << "fqColumnNames = " << fqColumnNames.join(QStringLiteral(", "));
DEBUG_LOG(m_logger) << "fqColumnNames = " << fqColumnNames.join(QStringLiteral(", "));
if (!whereConditions.isEmpty())
@@ -185,11 +184,11 @@ bool SqlGenerator::handleView(const ViewInformation &vi)
bool SqlGenerator::handleTable(const CompleteTableInformation &cti)
{
DEBUG_LOG() << "Handle table " << cti.name;
DEBUG_LOG(m_logger) << "Handle table " << cti.name;
if (cti.columns.isEmpty())
{
WARNING_LOG() << "Table " << cti.name
WARNING_LOG(m_logger) << "Table " << cti.name
<< " has no DatabaseServiceStruct - not generating anything for this!";
return true;
}
@@ -532,11 +531,11 @@ bool SqlGenerator::handleEnumeration(const EnumInformation &ei)
QStringList SqlGenerator::handleEnumeration(const EnumInformation &ei, const QString &dbSchema) const
{
DEBUG_LOG() << "Handle enumeration " << ei.enumName;
DEBUG_LOG(m_logger) << "Handle enumeration " << ei.enumName;
if (ei.tableName.isEmpty())
{
INFO_LOG() << "No table for enumeration " << ei.enumName << " - not creating inserts for this enum";
INFO_LOG(m_logger) << "No table for enumeration " << ei.enumName << " - not creating inserts for this enum";
return QStringList();
}
@@ -565,7 +564,7 @@ bool SqlGenerator::generateDbNotifications(const QString &tableName,
if (notification.paramNames.isEmpty() ||
notification.paramNames.size() > 1)
{
ERROR_LOG() << "Can not handle more than one parameter";
ERROR_LOG(m_logger) << "Can not handle more than one parameter";
continue;
}
generateDbNotification(notification, ed);
@@ -705,7 +704,7 @@ QStringList SqlGenerator::getDbSettings(const QString &dbSchema) const
QStringList SqlGenerator::getAllSqlStmts(const QString &dbSchema, ExerciseDependency ed) const
{
DEBUG_LOG() << "Creating statements for service " << getServiceAbbr() << " in exercise " << m_exerciseId << ", this: " << this;
DEBUG_LOG(m_logger) << "Creating statements for service " << getServiceAbbr() << " in exercise " << m_exerciseId << ", this: " << this;
QStringList data;
@@ -796,7 +795,7 @@ bool SqlGenerator::writeSql(const QString &filePath, ExerciseDependency ed)
const SqlStatements &sql = getStatements(ed);
if (sql.isEmpty())
{
DEBUG_LOG() << "Sql file is emtpy: " << sqlFile;
DEBUG_LOG(m_logger) << "Sql file is emtpy: " << sqlFile;
return writeFile(sqlFile, QString());
}
@@ -806,7 +805,7 @@ bool SqlGenerator::writeSql(const QString &filePath, ExerciseDependency ed)
getExerciseSchemaName(m_exerciseId) :
getServiceAbbr());
INFO_LOG() << "Creating sql-stmt for schema (" << dbSchema << ")";
INFO_LOG(m_logger) << "Creating sql-stmt for schema (" << dbSchema << ")";
return writeSqlToFile(dbSchema, sqlFile, ed);
}
@@ -929,7 +928,7 @@ bool SqlGenerator::writeFile(const QString &fn, const QString &content) const
QFile f(fn);
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
ERROR_LOG() << "Error opening file '" << f.fileName() << "' for writing: "
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: "
<< f.errorString();
return false;
}
@@ -106,6 +106,7 @@ public:
protected:
NGL::INGLLogger &m_logger;
private:
bool handleTables();
bool handleViews();
@@ -200,6 +200,8 @@ StructBuilder::StructBuilder(XmlReader *xmlReader)
: m_needPoint3d(false)
, m_needPgArrayInclude(false)
, m_xmlReader(xmlReader)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CodeGen.StructBuilder"))
, m_loggerCSV(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("fileCSV"))
{}
bool StructBuilder::buildStructures()
@@ -266,7 +268,7 @@ bool StructBuilder::buildStructures()
const ServiceTypeStruct sts = extractServiceAndTypeFromTypename(tti.name);
if (!sts.isExternalType())
{
ERROR_LOG() << "Invalid external topic type name: '" << tti.name << "'";
ERROR_LOG(m_logger) << "Invalid external topic type name: '" << tti.name << "'";
return false;
}
if (!handleIdlStructInfo(tti, m_externalTopicTypes, sts.service))
@@ -287,7 +289,7 @@ bool StructBuilder::handleEnum(const EnumInformation &ei)
QSharedPointer<TableInformation> ti = m_xmlReader->getTable(ei.tableName);
if (ti.isNull())
{
WARNING_LOG() << "Could not find table information for enum: "
WARNING_LOG(m_logger) << "Could not find table information for enum: "
<< ei.enumName << ", table: " << ei.tableName;
return false;
}
@@ -323,12 +325,12 @@ EnumInformation StructBuilder::enumInformationByType(const QString &type, bool c
{
if (!checkExternals)
{
ERROR_LOG() << "Could not find enumeration '" << type << "'";
ERROR_LOG(m_logger) << "Could not find enumeration '" << type << "'";
return EnumInformation();
}
if (extInfo.type.isEmpty())
{
WARNING_LOG() << "Could not parse external enumeration '" << type << "'";
WARNING_LOG(m_logger) << "Could not parse external enumeration '" << type << "'";
return EnumInformation();
}
return m_xmlReader->getExternalEnumeration(extInfo.service, extInfo.type, verbose);
@@ -340,13 +342,13 @@ EnumInformation StructBuilder::enumInformationByType(const QString &type, bool c
return ei;
}
if (verbose)
ERROR_LOG() << "Could not find enumeration '" << type << "'";
ERROR_LOG(m_logger) << "Could not find enumeration '" << type << "'";
return EnumInformation();
}
CompleteTopicTypeInformation StructBuilder::topicTypeInformationByStructType(const QString &type, bool checkExternals)
{
DEBUG_LOG() << "topicTypeInformationByStructType(" << type << ")";
DEBUG_LOG(m_logger) << "topicTypeInformationByStructType(" << type << ")";
if (type.isEmpty())
return CompleteTopicTypeInformation();
@@ -364,26 +366,26 @@ CompleteTopicTypeInformation StructBuilder::topicTypeInformationByStructType(con
return csi;
}
DEBUG_LOG() << "Type '" << type << "' not found in idlStructs - maybe not yet exported or an enum";
DEBUG_LOG(m_logger) << "Type '" << type << "' not found in idlStructs - maybe not yet exported or an enum";
const QVector<TopicTypeInformation> idlStructsToGenerate = m_xmlReader->getIdlStructToGenerate();
for (const TopicTypeInformation &tti : idlStructsToGenerate)
{
if (tti.name == type)
{
DEBUG_LOG() << "Found not yet exported type " << type;
DEBUG_LOG(m_logger) << "Found not yet exported type " << type;
if (!handleIdlStructInfo(tti, m_topicTypeInfos))
return CompleteTopicTypeInformation();
return topicTypeInformationByStructType(type);
}
}
ERROR_LOG() << "Could not find type '" << type << "' in idlStructs";
ERROR_LOG(m_logger) << "Could not find type '" << type << "' in idlStructs";
return CompleteTopicTypeInformation();
}
CompleteTopicTypeInformation StructBuilder::externalTopicTypeByStructType(const ServiceTypeStruct &sts)
{
const QString typeToSearch = sts.fqType();
DEBUG_LOG() << "externalTopicTypeByStructType " << typeToSearch;
DEBUG_LOG(m_logger) << "externalTopicTypeByStructType " << typeToSearch;
for (const CompleteTopicTypeInformation &ctti : std::as_const(m_externalTopicTypes))
{
if (ctti.name == typeToSearch)
@@ -396,13 +398,13 @@ CompleteTopicTypeInformation StructBuilder::externalTopicTypeByStructType(const
bool StructBuilder::loadExternalTopicType(const ServiceTypeStruct &sts)
{
DEBUG_LOG() << "loadExternalTopicType(" << sts.fqType() << ")";
DEBUG_LOG(m_logger) << "loadExternalTopicType(" << sts.fqType() << ")";
const TopicTypeInformation tti = m_xmlReader->loadExternalTopicType(sts.service, sts.type);
if (!tti.isValid())
{
DEBUG_LOG() << "Could not find external topic '" << sts.fqType() << "'";
DEBUG_LOG(m_logger) << "Could not find external topic '" << sts.fqType() << "'";
return false;
}
@@ -473,11 +475,11 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
QVector<QString> tableNames;
if (!getColumnsFromTable(ssi.primaryTable, columns, tableNames))
{
WARNING_LOG() << "Could not retrieve columns from table "
WARNING_LOG(m_logger) << "Could not retrieve columns from table "
<< ssi.primaryTable;
return false;
}
DEBUG_LOG() << "Got " << columns.size() << " columns for table "
DEBUG_LOG(m_logger) << "Got " << columns.size() << " columns for table "
<< ssi.primaryTable;
QSet<QString> sqlTables;
@@ -487,12 +489,12 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
MemberInformation miPkFirstTable, miPkLastTable;
for (const ColumnInformationEx &ci : std::as_const(columns))
{
DEBUG_LOG() << "handling column " << ci.columnName;
DEBUG_LOG(m_logger) << "handling column " << ci.columnName;
const QSharedPointer<TableInformation> ti = ci.table;
if (ti.isNull())
{
WARNING_LOG() << "Could not find table for column " << ci.columnName
WARNING_LOG(m_logger) << "Could not find table for column " << ci.columnName
<< " primary table is " << ssi.primaryTable.data();
return false;
}
@@ -560,14 +562,14 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
camelCaseString(fki->destination.tableName, true);
EnumInformation ei = enumInformationByType(enumType, true, false);
DEBUG_LOG() << "Checking if " << enumType << " is an enum: " << ei.isValid();
DEBUG_LOG(m_logger) << "Checking if " << enumType << " is an enum: " << ei.isValid();
if (!ei.isValid() && fki->destination.tableName.contains(QLatin1Char('_')))
{
enumType = fki->destination.service + QStringLiteral("::") +
camelCaseString(fki->destination.tableName.section(QLatin1Char('_'), 1), true);
ei = enumInformationByType(enumType, true, false);
DEBUG_LOG() << "Checking if " << enumType << " is an enum: " << ei.isValid();
DEBUG_LOG(m_logger) << "Checking if " << enumType << " is an enum: " << ei.isValid();
}
if (ei.isValid() &&
ei.tableName == fki->destination.tableName)
@@ -676,8 +678,8 @@ bool StructBuilder::handleIdlStructInfo(const TopicTypeInformation &tti,
if (idlData.isKey && idlData.isOptional)
{
ERROR_LOG() << "Column option isKey & isOptional are mutually exclusive!";
ERROR_LOG() << "Change column '" << tti.name << "."
ERROR_LOG(m_logger) << "Column option isKey & isOptional are mutually exclusive!";
ERROR_LOG(m_logger) << "Change column '" << tti.name << "."
<< idlData.name << "'' to have either key or optional parameter ";
return false;
}
@@ -1045,7 +1047,7 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
}
else
{
ERROR_LOG() << "Unknown cpp datatype: " << mi.cpp.type;
ERROR_LOG(m_logger) << "Unknown cpp datatype: " << mi.cpp.type;
return false;
}
return true;
@@ -1080,7 +1082,7 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
const CompleteTopicTypeInformation cttiChild = topicTypeInformationByStructType(member.type);
if (!cttiChild.isValid())
{
ERROR_LOG() << "Can not find structure '" << member.type << "'";
ERROR_LOG(m_logger) << "Can not find structure '" << member.type << "'";
continue;
}
QString pre;
@@ -1100,7 +1102,7 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
const CompleteTopicTypeInformation &cttiChild = topicTypeInformationByStructType(member.dataTypeInfo->innerDataType()->idlType());
if (!cttiChild.isValid())
{
ERROR_LOG() << "Can not find structure '" << member.type << "'";
ERROR_LOG(m_logger) << "Can not find structure '" << member.type << "'";
continue;
}
buildDbTableInformationFromIdlData(cttiChild,
@@ -1194,7 +1196,7 @@ bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopic
const CompleteTopicTypeInformation cttiChild = topicTypeInformationByStructType(member.type);
if (!cttiChild.isValid())
{
ERROR_LOG() << "Can not find structure '" << member.type << "'";
ERROR_LOG(m_logger) << "Can not find structure '" << member.type << "'";
continue;
}
if (!buildJSonStructureInformationFromIdlData(cttiChild))
@@ -1221,7 +1223,7 @@ bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopic
return false;
}
else
WARNING_LOG() << "Can not find structure '" << member.type << "'";
WARNING_LOG(m_logger) << "Can not find structure '" << member.type << "'";
}
@@ -1316,11 +1318,11 @@ QMap<QString, CompleteTableInformation> StructBuilder::getRecordingTopicTables()
continue;
if (!ctti.isDataObject)
{
WARNING_LOG() << "Trying to record topic '" << ctti.name
WARNING_LOG(m_logger) << "Trying to record topic '" << ctti.name
<< "' which is not directly published - ignoring!";
continue;
}
DEBUG_LOG() << "Rec table: " << ctti.name;
DEBUG_LOG(m_logger) << "Rec table: " << ctti.name;
miPrimaryKey.db.table = ctti.name;
ret.insert(ctti.name, getRecordingTopicTable(ctti, miPrimaryKey));
}
@@ -1402,7 +1404,7 @@ StructBuilder::ServiceTypeStruct StructBuilder::extractServiceAndTypeFromTypenam
extTypeRef = sl.at(1);
}
else
WARNING_LOG() << "Error parsing type: " << type;
WARNING_LOG(m_logger) << "Error parsing type: " << type;
StructBuilder::ServiceTypeStruct ret;
if (!extServiceRef.isEmpty())
{
@@ -335,5 +335,7 @@ private:
bool m_needPgArrayInclude;
XmlReader *m_xmlReader;
NGL::INGLLogger &m_logger;
NGL::INGLLogger &m_loggerCSV;
};
}
@@ -31,8 +31,7 @@ private:
const QByteArray m_msg;
};
XmlReader::XmlReader()
{}
XmlReader::XmlReader() : m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
bool XmlReader::readServiceFile(const QString &svcFile,
const QString &idlServiceInfoFile,
@@ -79,18 +78,18 @@ bool XmlReader::readServiceFile(const QString &svcFile,
QFile f(svcFile);
if (!f.exists())
{
ERROR_LOG() << "Service file '" << svcFile << "' not found!";
ERROR_LOG(m_logger) << "Service file '" << svcFile << "' not found!";
return false;
}
if (!f.open(QIODevice::ReadOnly))
{
m_errorString = QLatin1String("Can not open service file '") + svcFile +
QLatin1String("' for reading: ") + f.errorString();
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
INFO_LOG() << "SvcFile: " << svcFile;
INFO_LOG(m_logger) << "SvcFile: " << svcFile;
QString errMsg;
@@ -102,7 +101,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
m_errorString = QLatin1String("Error parsing service file '") + svcFile + QLatin1String("': ") +
errMsg + QLatin1String(" at ") + QString::number(errLine) +
QLatin1Char(':') + QString::number(errColumn);
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -118,7 +117,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
{
m_errorString = QLatin1String("Xml file '") + svcFile +
QLatin1String("' is not a valid service file: service name/namespace is missing");
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
m_svcNamespace = getAttribute(domRoot, QStringLiteral("namespace"));
@@ -129,13 +128,13 @@ bool XmlReader::readServiceFile(const QString &svcFile,
QString devModeStr = getAttribute(domRoot, QStringLiteral("devMode"), true);
m_svcDevMode = devModeStr == QStringLiteral("1") ||
devModeStr == QStringLiteral("true");
INFO_LOG() << "devMode: " << m_svcDevMode;
INFO_LOG(m_logger) << "devMode: " << m_svcDevMode;
const QString groupNamesString = getAttribute(domRoot, QStringLiteral("groups"), true);
if (!groupNamesString.isEmpty())
{
m_groupNames = groupNamesString.split(QLatin1Char(','), Qt::SkipEmptyParts);
INFO_LOG() << "groups: " << groupNamesString;
INFO_LOG(m_logger) << "groups: " << groupNamesString;
}
else
m_groupNames.clear();
@@ -150,12 +149,12 @@ bool XmlReader::readServiceFile(const QString &svcFile,
if (m_exerciseDependency != ExerciseDependency::Global &&
m_exerciseDependency != ExerciseDependency::GlobalAndExercise)
{
WARNING_LOG() << "Service " << getServiceNamespace()
WARNING_LOG(m_logger) << "Service " << getServiceNamespace()
<< " is not marked as exercise independent but should be started in group Core/Master";
}
}
INFO_LOG() << "exerciseDependency: " << (int)m_exerciseDependency;
INFO_LOG(m_logger) << "exerciseDependency: " << (int)m_exerciseDependency;
if ( domRoot.hasAttribute(QStringLiteral("prio")))
{
m_prio = getAttribute(domRoot, QStringLiteral("prio"), 0).toInt();
@@ -167,7 +166,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing dbServiceStructs: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -178,7 +177,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing dbtables: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -189,7 +188,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing dbviews: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -200,7 +199,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing enumerations: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -211,7 +210,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing custom dtc functions: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -222,7 +221,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing idl strucs: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -233,7 +232,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
catch (const XmlReaderException &ex)
{
m_errorString = QLatin1String("Error parsing function topics: ") + QLatin1String(ex.what());
ERROR_LOG() << m_errorString;
ERROR_LOG(m_logger) << m_errorString;
return false;
}
@@ -331,7 +330,7 @@ void XmlReader::parseDBSserviceStructs(const QDomElement &rootElement)
domDbStruct = domDbStruct.nextSiblingElement(domDbStruct.tagName());
}
INFO_LOG() << "Read " << m_structsToGenerate.size() << " database service struct(s)";
INFO_LOG(m_logger) << "Read " << m_structsToGenerate.size() << " database service struct(s)";
}
void XmlReader::parseDBTables(const QDomElement &rootElement)
@@ -373,7 +372,7 @@ void XmlReader::parseDBTables(const QDomElement &rootElement)
domDbTable = domDbTable.nextSiblingElement(domDbTable.tagName());
}
INFO_LOG() << "Read " << m_tables.size() << " database table(s)";
INFO_LOG(m_logger) << "Read " << m_tables.size() << " database table(s)";
}
void XmlReader::parseDBViews(const QDomElement &rootElement)
@@ -393,7 +392,7 @@ void XmlReader::parseDBViews(const QDomElement &rootElement)
vi->filter = getAttribute(domDbView, QStringLiteral("filter"));
vi->exerciseDependency = string2ExerciseDependency(getAttribute(domDbView, QStringLiteral("exerciseDependency"), true));
DEBUG_LOG() << "Base table = " << vi->baseTable;
DEBUG_LOG(m_logger) << "Base table = " << vi->baseTable;
m_views.insert(vi->name, vi);
@@ -401,7 +400,7 @@ void XmlReader::parseDBViews(const QDomElement &rootElement)
domDbView = domDbView.nextSiblingElement(domDbView.tagName());
}
INFO_LOG() << "Read " << m_views.size() << " database view(s)";
INFO_LOG(m_logger) << "Read " << m_views.size() << " database view(s)";
}
void XmlReader::parseEnumerations(const QDomElement &rootElement)
@@ -432,7 +431,7 @@ void XmlReader::parseEnumerations(const QDomElement &rootElement)
domEnum = domEnum.nextSiblingElement(domEnum.tagName());
}
INFO_LOG() << "Read " << m_enumerations.size() << " enumeration(s)";
INFO_LOG(m_logger) << "Read " << m_enumerations.size() << " enumeration(s)";
}
void XmlReader::parseCustomDtcFunctions(const QDomElement &rootElement)
@@ -452,7 +451,7 @@ void XmlReader::parseCustomDtcFunctions(const QDomElement &rootElement)
}
domElement = domElement.nextSiblingElement(domElement.tagName());
}
INFO_LOG() << "Read " << m_enumerations.size() << " customDtcFunction(s)";
INFO_LOG(m_logger) << "Read " << m_enumerations.size() << " customDtcFunction(s)";
}
@@ -510,7 +509,7 @@ void XmlReader::parseTopicTypes(const QDomElement &rootElement)
}
INFO_LOG() << "Read " << m_idlStructsToGenerate.size() << " idl struct(s)";
INFO_LOG(m_logger) << "Read " << m_idlStructsToGenerate.size() << " idl struct(s)";
}
void XmlReader::parseFunctionTopics(const QDomElement &rootElement)
@@ -566,7 +565,7 @@ ColumnInformation XmlReader::parseTableColumn(const QDomElement &column, const Q
}
if (ci.columnName.toLower() != ci.columnName)
WARNING_LOG() << "Column " << ci.columnName << " in Table "
WARNING_LOG(m_logger) << "Column " << ci.columnName << " in Table "
<< tableName << " has has upper-case chars which is not allowed!";
return ci;
@@ -726,18 +725,18 @@ DbNotifcationInformation XmlReader::parseDbNotification(const QDomElement &custo
TopicTypeInformation XmlReader::loadExternalTopicType(const QString &externalServiceName, const QString &topicTypeName)
{
DEBUG_LOG() << "externalServiceName: " << externalServiceName << ", topicTypeName: " << topicTypeName;
DEBUG_LOG(m_logger) << "externalServiceName: " << externalServiceName << ", topicTypeName: " << topicTypeName;
if (!loadExternalService(externalServiceName))
{
WARNING_LOG() << "Could not find service " << externalServiceName
WARNING_LOG(m_logger) << "Could not find service " << externalServiceName
<< " referenced by external topic " << topicTypeName;
return TopicTypeInformation();
}
auto extXmlReader = m_externalXmlInformations.value(externalServiceName);
if (!extXmlReader)
{
ERROR_LOG() << "Could not find service xml file for service '" << externalServiceName << "'";
ERROR_LOG(m_logger) << "Could not find service xml file for service '" << externalServiceName << "'";
return TopicTypeInformation();
}
@@ -749,7 +748,7 @@ TopicTypeInformation XmlReader::loadExternalTopicType(const QString &externalSer
m_usedServices[externalServiceName] = true;
return tti;
}
WARNING_LOG() << "Could not find topic " << topicTypeName
WARNING_LOG(m_logger) << "Could not find topic " << topicTypeName
<< " in external service definition for service "
<< externalServiceName;
return TopicTypeInformation();
@@ -757,18 +756,18 @@ TopicTypeInformation XmlReader::loadExternalTopicType(const QString &externalSer
EnumInformation XmlReader::getExternalEnumeration(const QString &externalServiceName, const QString &enumName, bool verbose)
{
DEBUG_LOG() << "externalServiceName: " << externalServiceName << ", topicTypeName: " << enumName;
DEBUG_LOG(m_logger) << "externalServiceName: " << externalServiceName << ", topicTypeName: " << enumName;
if (!loadExternalService(externalServiceName))
{
WARNING_LOG() << "Could not find service '" << externalServiceName << "'"
WARNING_LOG(m_logger) << "Could not find service '" << externalServiceName << "'"
<< " referenced by external enumeration " << enumName;
return EnumInformation();
}
auto extXmlReader = m_externalXmlInformations.value(externalServiceName);
if (!extXmlReader)
{
ERROR_LOG() << "Could not find service xml file for service '" << externalServiceName << "'";
ERROR_LOG(m_logger) << "Could not find service xml file for service '" << externalServiceName << "'";
return EnumInformation();
}
@@ -783,7 +782,7 @@ EnumInformation XmlReader::getExternalEnumeration(const QString &externalService
}
if (verbose)
{
WARNING_LOG() << "Could not find enumeration " << enumName
WARNING_LOG(m_logger) << "Could not find enumeration " << enumName
<< " in external service definition for '"
<< externalServiceName << "'";
}
@@ -821,11 +820,11 @@ bool XmlReader::loadExternalService(const QString &serviceName)
if (fileName.isEmpty())
return false;
DEBUG_LOG() << "xml file for " << serviceName << ": " << fileName;
DEBUG_LOG(m_logger) << "xml file for " << serviceName << ": " << fileName;
auto extXmlReader = QSharedPointer<XmlReader>(new XmlReader);
if (!extXmlReader->readServiceFile(fileName, QString(), this))
{
WARNING_LOG() << "Error reading service file " << fileName
WARNING_LOG(m_logger) << "Error reading service file " << fileName
<< " for service " << serviceName;
return false;
}
@@ -842,7 +841,7 @@ void XmlReader::loadIdlInfofile(const QString &idlServiceInfoFile)
QFile f(idlServiceInfoFile);
if (!f.open(QIODevice::ReadOnly))
{
WARNING_LOG() << "Could not read idl service info file " << idlServiceInfoFile;
WARNING_LOG(m_logger) << "Could not read idl service info file " << idlServiceInfoFile;
return;
}
const QList<QByteArray> files = f.readAll().split('\n');
@@ -859,7 +858,7 @@ void XmlReader::loadIdlInfofile(const QString &idlServiceInfoFile)
{
const auto svcAbbreveation = fn.split(QLatin1Char('.')).at(0).split(QLatin1Char('_')).at(0);
m_xmlFiles[svcAbbreveation] = fileName;
DEBUG_LOG() << "xml: " << svcAbbreveation << " = " << fileName;
DEBUG_LOG(m_logger) << "xml: " << svcAbbreveation << " = " << fileName;
}
else
{
@@ -867,7 +866,7 @@ void XmlReader::loadIdlInfofile(const QString &idlServiceInfoFile)
if (svcAbbreveation.endsWith(QLatin1String("_enums")))
continue;
m_idlFiles[svcAbbreveation] = fileName;
DEBUG_LOG() << "idl: " << svcAbbreveation << " = " << fileName;
DEBUG_LOG(m_logger) << "idl: " << svcAbbreveation << " = " << fileName;
}
}
}
@@ -893,7 +892,7 @@ void XmlReader::getServiceNameInfoFromFilePath(const QStringList &parts)
const QString abbreviation = parts.last().split(QLatin1Char('.')).first().split(QLatin1Char('_')).first();
const QString serviceName = parts.at(parts.size() - 2);
DEBUG_LOG() << "serviceName: " << serviceName << " = " << abbreviation;
DEBUG_LOG(m_logger) << "serviceName: " << serviceName << " = " << abbreviation;
m_fullServiceName2Abbreviation[serviceName] = abbreviation;
}
@@ -359,6 +359,7 @@ public:
XmlReader &operator=(const XmlReader &) = delete;
private:
NGL::INGLLogger &m_logger;
void parseDBSserviceStructs(const QDomElement &rootElement);
void parseDBTables(const QDomElement &rootElement);
void parseDBViews(const QDomElement &rootElement);
@@ -77,20 +77,20 @@ int main(int argc, char **argv)
QScopedPointer<CodeGen::XmlReader> reader(new CodeGen::XmlReader);
DEBUG_LOG() << "ServiceFile: " << options.serviceFile();
DEBUG_LOG() << "IdlInfoFile: " << options.idlInfoFile();
DEBUG_LOG(m_logger) << "ServiceFile: " << options.serviceFile();
DEBUG_LOG(m_logger) << "IdlInfoFile: " << options.idlInfoFile();
if (!reader->readServiceFile(options.serviceFile(), options.idlInfoFile()))
{
ERROR_LOG() << "Error parsing service file '" << options.serviceFile()
ERROR_LOG(m_logger) << "Error parsing service file '" << options.serviceFile()
<< ": " << reader->errorString();
return 2;
}
QDir dir(options.outDir());
DEBUG_LOG() << "Directory: " << options.outDir();
DEBUG_LOG(m_logger) << "Directory: " << options.outDir();
if (!dir.exists() && !dir.mkpath(options.outDir()))
{
ERROR_LOG() << "Directory '" << options.outDir()
ERROR_LOG(m_logger) << "Directory '" << options.outDir()
<< "' does not exist and can not be created!";
return 3;
}
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
QScopedPointer<CodeGen::StructBuilder> structBuilder(new CodeGen::StructBuilder(reader.data()));
if (!structBuilder->buildStructures())
{
ERROR_LOG() << "Error building up structures";
ERROR_LOG(m_logger) << "Error building up structures";
return 4;
}
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
{
ERROR_LOG() << "Error while writing sql information for service " << sql.getServiceAbbr();
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
return 10;
}
@@ -133,7 +133,7 @@ int main(int argc, char **argv)
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
{
ERROR_LOG() << "Error while writing sql information for service " << sql.getServiceAbbr();
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
return 10;
}
@@ -141,20 +141,20 @@ int main(int argc, char **argv)
sql.generateData(0);
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Global))
{
ERROR_LOG() << "Error while writing sql information for service " << sql.getServiceAbbr();
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
return 10;
}
return 0;
}
else
{
ERROR_LOG() << "Invalid action '" << options.action() << "' given!";
ERROR_LOG(m_logger) << "Invalid action '" << options.action() << "' given!";
return 5;
}
if (!generator->init(reader.data(), structBuilder.data()))
{
ERROR_LOG() << "Error initializing generator!";
ERROR_LOG(m_logger) << "Error initializing generator!";
return 6;
}