Skip to content
Snippets Groups Projects
Commit 813dc641 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

exportToLiquibase moved from Sql_lib to own lib

parent af29444c
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>Liquibase_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/Liquibase_lib/process.js</process>
</process>
import("system.SQLTYPES");
import("system.db");
import("system.util");
function LiquiUtils(){}
LiquiUtils.exportToLiquibase = function(pAuthor, pTableName, pColumns, pNewUUIDForIndexes, pCondition)
{
if(!pNewUUIDForIndexes)
pNewUUIDForIndexes = []
var xmlData = <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"/>;
xmlData.changeSet.@author = pAuthor
xmlData.changeSet.@id = util.getNewUUID()
var dbData = db.table("select " + pColumns.join(", ") + " from " + pTableName + " " + (pCondition ? pCondition : ""));
var types = db.getColumnTypes(pTableName, pColumns);
dbData.forEach(function(pRow) {
var node = <insert/>;
node.@tableName = pTableName;
for (let i = 0; i < pColumns.length; i++)
{
var value = "";
for (j = 0; j < pNewUUIDForIndexes.length; j++) {
if (i == pNewUUIDForIndexes[j])
{
value = util.getNewUUID();
break;
}
}
if (!value)
value = pRow[i];
var col = <column/>;
col.@name = pColumns[i];
// do not add value if null
if (value)
{
if (SQLTYPES.isNumberType(types[i]))
col.@valueNumeric = value;
else
col.@value = value;
}
node.appendChild(col);
}
this.appendChild(node);
}, xmlData.changeSet);
return xmlData.toXMLString()
};
......@@ -1495,56 +1495,3 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale)
resSql = [resSql, preparedValues];
return resSql;
};
SqlUtils.exportToLiquibase = function(pAuthor, pTableName, pColumns, pNewUUIDForIndexes, pCondition)
{
if(!pNewUUIDForIndexes)
pNewUUIDForIndexes = []
var xmlData = <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
</databaseChangeLog>;
xmlData.changeSet.@author = pAuthor
xmlData.changeSet.@id = util.getNewUUID()
var dbData = db.table("select " + pColumns.join(", ") + " from " + pTableName + " " + (pCondition ? pCondition : ""));
var types = db.getColumnTypes(pTableName, pColumns);
dbData.forEach(function(pRow) {
var node = <insert></insert>;
node.@tableName = pTableName;
for (let i = 0; i < pColumns.length; i++)
{
var value = "";
for (j = 0; j < pNewUUIDForIndexes.length; j++) {
if (i == pNewUUIDForIndexes[j])
{
value = util.getNewUUID();
break;
}
}
if (!value)
value = pRow[i];
var col = <column/>;
col.@name = pColumns[i];
// do not add value if null
if (value)
{
if (SQLTYPES.isNumberType(types[i]))
col.@valueNumeric = value;
else
col.@value = value;
}
node.appendChild(col);
}
this.appendChild(node);
}, xmlData.changeSet);
return xmlData.toXMLString()
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment