Warning, /pim/akonadi/src/server/storage/schema-source.xsl is written in an unsupported language. File is not indexed.
0001 <!-- 0002 SPDX-FileCopyrightText: 2013 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 --> 0006 0007 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 0008 version="1.0"> 0009 <xsl:output method="text" encoding="utf-8"/> 0010 0011 <xsl:template name="data-type"> 0012 <xsl:choose> 0013 <xsl:when test="@type = 'enum'"><xsl:value-of select="@enumType"/></xsl:when> 0014 <xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise> 0015 </xsl:choose> 0016 </xsl:template> 0017 0018 <xsl:template name="schema-source"> 0019 #include "<xsl:value-of select="$fileName"/>.h" 0020 0021 using namespace Akonadi::Server; 0022 0023 QList<TableDescription> <xsl:value-of select="$className"/>::tables() 0024 { 0025 QList<TableDescription> tabs; 0026 tabs.reserve(<xsl:value-of select="count(database/table)"/>); 0027 <xsl:for-each select="database/table"> 0028 { 0029 TableDescription t; 0030 t.name = QStringLiteral("<xsl:value-of select="@name"/>Table"); 0031 0032 t.columns.reserve(<xsl:value-of select="count(column)"/>); 0033 <xsl:for-each select="column"> 0034 { 0035 ColumnDescription c; 0036 c.name = QStringLiteral("<xsl:value-of select="@name"/>"); 0037 c.type = QStringLiteral("<xsl:call-template name="data-type"/>"); 0038 <xsl:if test="@size"> 0039 c.size = <xsl:value-of select="@size"/>; 0040 </xsl:if> 0041 <xsl:if test="@allowNull"> 0042 c.allowNull = <xsl:value-of select="@allowNull"/>; 0043 </xsl:if> 0044 <xsl:if test="@isAutoIncrement"> 0045 c.isAutoIncrement = <xsl:value-of select="@isAutoIncrement"/>; 0046 </xsl:if> 0047 <xsl:if test="@isPrimaryKey"> 0048 c.isPrimaryKey = <xsl:value-of select="@isPrimaryKey"/>; 0049 </xsl:if> 0050 <xsl:if test="@isUnique"> 0051 c.isUnique = <xsl:value-of select="@isUnique"/>; 0052 </xsl:if> 0053 <xsl:if test="@type = 'enum'"> 0054 c.isEnum = true; 0055 </xsl:if> 0056 <xsl:if test="@refTable"> 0057 c.refTable = QStringLiteral("<xsl:value-of select="@refTable"/>"); 0058 </xsl:if> 0059 <xsl:if test="@refColumn"> 0060 c.refColumn = QStringLiteral("<xsl:value-of select="@refColumn"/>"); 0061 </xsl:if> 0062 <xsl:if test="@default"> 0063 c.defaultValue = QStringLiteral("<xsl:value-of select="@default"/>"); 0064 </xsl:if> 0065 <xsl:if test="@onUpdate"> 0066 c.onUpdate = ColumnDescription::<xsl:value-of select="@onUpdate"/>; 0067 </xsl:if> 0068 <xsl:if test="@onDelete"> 0069 c.onDelete = ColumnDescription::<xsl:value-of select="@onDelete"/>; 0070 </xsl:if> 0071 <xsl:if test="@noUpdate"> 0072 c.noUpdate = <xsl:value-of select="@noUpdate"/>; 0073 </xsl:if> 0074 0075 <xsl:if test="@type = 'enum'"> 0076 c.enumValueMap = { 0077 <xsl:for-each select="../enum"> 0078 <xsl:for-each select="value"> 0079 { QStringLiteral("<xsl:value-of select="../@name"/>::<xsl:value-of select="@name"/>"), 0080 <xsl:choose> 0081 <xsl:when test="@value"><xsl:value-of select="@value"/></xsl:when> 0082 <xsl:otherwise><xsl:value-of select="position() - 1"/></xsl:otherwise> 0083 </xsl:choose> }<xsl:if test="position() != last()">,</xsl:if> 0084 </xsl:for-each> 0085 </xsl:for-each> 0086 }; 0087 </xsl:if> 0088 0089 t.columns.push_back(c); 0090 } 0091 </xsl:for-each> 0092 0093 <xsl:if test="count(index) > 0"> 0094 <xsl:if test="count(index) > 0"> 0095 <xsl:call-template name="indexes"> 0096 <xsl:with-param name="var">t</xsl:with-param> 0097 </xsl:call-template> 0098 </xsl:if> 0099 </xsl:if> 0100 0101 <xsl:if test="count(data) > 0"> 0102 t.data.reserve(<xsl:value-of select="count(data)"/>); 0103 <xsl:for-each select="data"> 0104 { 0105 const QStringList columns = QStringLiteral("<xsl:value-of select="@columns"/>").split( QLatin1Char( ',' ), Qt::SkipEmptyParts ); 0106 const QStringList values = QStringLiteral("<xsl:value-of select="@values"/>").split( QLatin1Char( ',' ), Qt::SkipEmptyParts ); 0107 Q_ASSERT( columns.count() == values.count() ); 0108 0109 DataDescription d; 0110 for ( int i = 0; i < columns.size(); ++i ) { 0111 d.data.insert( columns.at( i ), values.at( i ) ); 0112 } 0113 t.data.push_back(d); 0114 } 0115 </xsl:for-each> 0116 </xsl:if> 0117 0118 tabs.push_back(t); 0119 } 0120 </xsl:for-each> 0121 return tabs; 0122 } 0123 0124 QList<RelationDescription> <xsl:value-of select="$className"/>::relations() 0125 { 0126 QList<RelationDescription> rels; 0127 rels.reserve(<xsl:value-of select="count(database/relation)"/>); 0128 <xsl:for-each select="database/relation"> 0129 { 0130 RelationDescription r; 0131 r.firstTable = QStringLiteral("<xsl:value-of select="@table1"/>"); 0132 r.firstColumn = QStringLiteral("<xsl:value-of select="@column1"/>"); 0133 r.secondTable = QStringLiteral("<xsl:value-of select="@table2"/>"); 0134 r.secondColumn = QStringLiteral("<xsl:value-of select="@column2"/>"); 0135 <xsl:if test="count(index) > 0"> 0136 <xsl:call-template name="indexes"> 0137 <xsl:with-param name="var">r</xsl:with-param> 0138 </xsl:call-template> 0139 </xsl:if> 0140 rels.push_back(r); 0141 0142 } 0143 </xsl:for-each> 0144 return rels; 0145 } 0146 0147 </xsl:template> 0148 </xsl:stylesheet> 0149