Skip to content
Snippets Groups Projects
Commit 1b6fa51b authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon:
Browse files

merged origin/2020.1.0 into 1054657_FixPersonIndexAffectedReturnNull

parents db8d39a0 f0d5a0b8
No related branches found
No related tags found
No related merge requests found
Showing
with 246 additions and 51 deletions
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
<include relativeToChangelogFile="true" file="changeType_productGroupCodeId.xml" /> <include relativeToChangelogFile="true" file="changeType_productGroupCodeId.xml" />
<include relativeToChangelogFile="true" file="add_WorkflowSignal_variables.xml"/> <include relativeToChangelogFile="true" file="add_WorkflowSignal_variables.xml"/>
<include relativeToChangelogFile="true" file="AlterTablesForTranslation/changelog.xml"/> <include relativeToChangelogFile="true" file="AlterTablesForTranslation/changelog.xml"/>
<include relativeToChangelogFile="true" file="update_Salutation_headline.xml"/>
</databaseChangeLog> </databaseChangeLog>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="s.listl" id="45b6a4a0-f623-412f-ad57-d2fa1db09f62">
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Dr. Ing. {fn} {ln}"/>
<where>SALUTATIONID = '0500939e-5820-457d-a95f-6835b9501df9'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Prof. Dr. {fn} {ln}"/>
<where>SALUTATIONID = '1f19ba34-8346-4620-a10e-fb39fdd0be9b'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Präsident {fn} {ln}"/>
<where>SALUTATIONID = '4b9af3f4-f34a-4170-a28c-ffdbca80c4d3'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Professor {fn} {ln}"/>
<where>SALUTATIONID = '5d9ad542-27b8-4dec-bcbd-a2c7d223f012'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Prof. {fn} {ln}"/>
<where>SALUTATIONID = '75f4f04f-1877-425d-8d5d-56604d0040b2'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Dr. {fn} {ln}"/>
<where>SALUTATIONID = '76fe57c0-cf68-4240-ba6d-eb7d52f46317'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn Bürgermeister {fn} - {ln}"/>
<where>SALUTATIONID = '8feaf27b-1fae-4d8c-a742-9cd023f46409'</where>
</update>
<update tableName="SALUTATION">
<column name="HEADLINE" value="Herrn {fn} {ln}"/>
<where>SALUTATIONID = 'c98c8644-9e00-4715-a775-827a364f5cef'</where>
</update>
</changeSet>
</databaseChangeLog>
<?xml version="1.1" encoding="UTF-8" standalone="no"?> <?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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 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">
<changeSet author="s.leipold" id="3d4baf88-48c0-4ad2-9ceb-72dd8a1a9f6z"> <changeSet author="s.leipold" id="b01f6744-e732-45a2-a550-070fb1f1f2c">
<insert tableName="ASYS_PERMISSIONACTION"> <insert tableName="ASYS_PERMISSIONACTION">
<column name="ASYS_PERMISSIONACTIONID" value="ADMIN_PERMACTION_VIEW_METADATA "/> <column name="ASYS_PERMISSIONACTIONID" value="ADMIN_PERMACTION_VIEW_METADATA "/>
......
...@@ -16,7 +16,7 @@ var childType = vars.get("$param.ChildType_param"); ...@@ -16,7 +16,7 @@ var childType = vars.get("$param.ChildType_param");
var objectType = vars.get("$param.ObjectType_param"); var objectType = vars.get("$param.ObjectType_param");
var filteredIds = vars.getString("$param.FilteredAttributeIds_param") ? JSON.parse(vars.getString("$param.FilteredAttributeIds_param")) : null var filteredIds = vars.getString("$param.FilteredAttributeIds_param") ? JSON.parse(vars.getString("$param.FilteredAttributeIds_param")) : null
var attributeCountObj = vars.get("$param.AttributeCount_param") ? JSON.parse(vars.getString("$param.AttributeCount_param")) : null; var attributeCountObj = vars.get("$param.AttributeCount_param") ? JSON.parse(vars.getString("$param.AttributeCount_param")) : null;
var displaySimpleName = vars.get("$param.DisplaySimpleName_param"); var displaySimpleName = vars.getString("$param.DisplaySimpleName_param") == "true" ? true : false;
var themeObjectRowId = vars.get("$param.ThemeObjectRowId_param"); var themeObjectRowId = vars.get("$param.ThemeObjectRowId_param");
......
...@@ -8,4 +8,4 @@ var contactId = rowdata["CAMPAIGNPARTICIPANT.CONTACT_ID"]; ...@@ -8,4 +8,4 @@ var contactId = rowdata["CAMPAIGNPARTICIPANT.CONTACT_ID"];
var campaignParticipantId = vars.get("$local.uid"); var campaignParticipantId = vars.get("$local.uid");
var previousCampaignstepId = ""; var previousCampaignstepId = "";
CampaignUtils.createLogEntry(campaignId, campaignStepId, contactId, campaignParticipantId, previousCampaignstepId); CampaignUtils.createLogEntry(campaignId, campaignStepId, campaignParticipantId, previousCampaignstepId);
\ No newline at end of file \ No newline at end of file
...@@ -143,6 +143,8 @@ ...@@ -143,6 +143,8 @@
<dbRecordFieldMapping> <dbRecordFieldMapping>
<name>ISO3.value</name> <name>ISO3.value</name>
<recordfield>AB_LANGUAGE.ISO3</recordfield> <recordfield>AB_LANGUAGE.ISO3</recordfield>
<isFilterable v="true" />
<isLookupFilter v="true" />
</dbRecordFieldMapping> </dbRecordFieldMapping>
<dbRecordFieldMapping> <dbRecordFieldMapping>
<name>NAME_LATIN.value</name> <name>NAME_LATIN.value</name>
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</entityActionField> </entityActionField>
<entityActionField> <entityActionField>
<name>setRead</name> <name>setRead</name>
<title>setRead</title> <title>set Read</title>
<description></description> <description></description>
<onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js</onActionProcess> <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" /> <isSelectionAction v="true" />
...@@ -109,14 +109,14 @@ ...@@ -109,14 +109,14 @@
<tooltipProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setread/tooltipProcess.js</tooltipProcess> <tooltipProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setread/tooltipProcess.js</tooltipProcess>
</entityActionField> </entityActionField>
<entityActionField> <entityActionField>
<name>setUnread</name> <name>setNew</name>
<title>setUnread</title> <title>set New</title>
<description></description> <description></description>
<onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js</onActionProcess> <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setnew/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" /> <isSelectionAction v="true" />
<iconId>VAADIN:BOOK</iconId> <iconId>VAADIN:BOOK</iconId>
<tooltip></tooltip> <tooltip></tooltip>
<tooltipProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/tooltipProcess.js</tooltipProcess> <tooltipProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setnew/tooltipProcess.js</tooltipProcess>
</entityActionField> </entityActionField>
</children> </children>
</entityActionGroup> </entityActionGroup>
......
...@@ -1310,9 +1310,6 @@ ...@@ -1310,9 +1310,6 @@
<filterConditionProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js</filterConditionProcess> <filterConditionProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype> <filtertype>BASIC</filtertype>
</filterExtensionSet> </filterExtensionSet>
<filterExtension>
<name>filterExtension</name>
</filterExtension>
</filterExtensions> </filterExtensions>
</dbRecordContainer> </dbRecordContainer>
<indexRecordContainer> <indexRecordContainer>
......
...@@ -52,4 +52,4 @@ else ...@@ -52,4 +52,4 @@ else
} }
result.object(res); result.object(res);
} }
\ No newline at end of file
...@@ -6755,6 +6755,12 @@ ...@@ -6755,6 +6755,12 @@
<entry> <entry>
<key>Sales Projects</key> <key>Sales Projects</key>
</entry> </entry>
<entry>
<key>set Read</key>
</entry>
<entry>
<key>set New</key>
</entry>
</keyValueMap> </keyValueMap>
<font name="Dialog" style="0" size="11" /> <font name="Dialog" style="0" size="11" />
<sqlModels> <sqlModels>
......
...@@ -8659,6 +8659,14 @@ Bitte Datumseingabe prüfen</value> ...@@ -8659,6 +8659,14 @@ Bitte Datumseingabe prüfen</value>
<entry> <entry>
<key>Sales Projects</key> <key>Sales Projects</key>
</entry> </entry>
<entry>
<key>set Read</key>
<value>Gelesen setzen</value>
</entry>
<entry>
<key>set New</key>
<value>Neu setzen</value>
</entry>
</keyValueMap> </keyValueMap>
<font name="Dialog" style="0" size="11" /> <font name="Dialog" style="0" size="11" />
</language> </language>
...@@ -6820,6 +6820,12 @@ ...@@ -6820,6 +6820,12 @@
<entry> <entry>
<key>Sales Projects</key> <key>Sales Projects</key>
</entry> </entry>
<entry>
<key>set Read</key>
</entry>
<entry>
<key>set New</key>
</entry>
</keyValueMap> </keyValueMap>
<font name="Dialog" style="0" size="11" /> <font name="Dialog" style="0" size="11" />
</language> </language>
...@@ -1686,4 +1686,102 @@ AttributeRelationQuery.prototype.insertAttribute = function (pValue, pOmitValida ...@@ -1686,4 +1686,102 @@ AttributeRelationQuery.prototype.insertAttribute = function (pValue, pOmitValida
new SqlBuilder().insertFields(attrData, "AB_ATTRIBUTERELATION", "AB_ATTRIBUTERELATIONID"); new SqlBuilder().insertFields(attrData, "AB_ATTRIBUTERELATION", "AB_ATTRIBUTERELATIONID");
return true; return true;
}
/**
* deletes all attribute relations with the given rowId and objectType
*
* @return {Number} count of deleted rows
*/
AttributeRelationQuery.prototype.deleteAllAttributes = function ()
{
if (!this._rowId)
throw new Error("AttributeRelationQuery: Row id is required for delete");
return newWhere("AB_ATTRIBUTERELATION.OBJECT_ROWID", this._rowId)
.andIfSet("AB_ATTRIBUTERELATION.OBJECT_TYPE", this._objectType)
.deleteData();
}
/**
* Object representing one attribute relation in the database. Don't use this constructor in you own code!
* Instances of this should only be created by functions in this library.
*
* @param {String} pAttributeRelationId attribute relation id
* @param {String} pAttributeId attribute id
* @param {String} pValue value of the attribute
* @param {String} pAttributeName name of the attribute
* @param {String} pAttributeType type of the attribute
* @param {String} pObjectRowId rowId of the linked object
* @param {String} pObjectType context of the linked object
*/
function AttributeRelation (pAttributeRelationId, pAttributeId, pValue, pAttributeName, pAttributeType, pObjectRowId, pObjectType)
{
if (!pAttributeRelationId)
throw new Error("AttributeRelation: pAttributeRelationId must be provided");
this.attributeRelationId = pAttributeRelationId;
this.attributeId = pAttributeId;
this.value = pValue;
this.attributeName = pAttributeName;
this.attributeType = pAttributeType;
this.objectRowId = pObjectRowId;
this.objectType = pObjectType;
this.displayValue = undefined;
this.fullAttributeName = undefined;
}
/**
* updates the value of the attribute in the database
*
* @param {String} pValue the new value of the attribute relation
* @return {Boolean} currently the function always returns true (if some kind of validation is implemented in the future,
* it will return false if the validation fails)
*/
AttributeRelation.prototype.updateAttribute = function (pValue)
{
if (pValue == undefined || pValue == "")
throw new Error("AttributeRelation: no value provided for update");
var attrData = {
"DATE_EDIT" : vars.get("$sys.date"),
"USER_EDIT" : vars.get("$sys.user")
};
var valueField = AttributeTypeUtil.getDatabaseField(this.attributeType);
if (valueField)
attrData[valueField] = pValue;
newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", this.attributeRelationId)
.updateFields(attrData);
return true;
}
/**
* deletes the attribute relation from the database
*
* @param {Boolean} [pOmitValidation=false] if set to true, the function won't check if the min count prohibits the deletion
* @retun {Boolean} true if it was deleted and false if the min count doesn't allow the deletion
*/
AttributeRelation.prototype.deleteAttribute = function (pOmitValidation)
{
if (!pOmitValidation)
{
var minCount = newSelect("MIN_COUNT")
.from("AB_ATTRIBUTEUSAGE")
.where("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", this.attributeId)
.and("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", this.objectType)
.cell();
if (minCount && minCount != 0)
{
let timesUsed = new AttributeRelationQuery(this.objectRowId, this.attributeId, this.objectType).getAttributeCount();
if (timesUsed <= minCount)
return false;
}
}
newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", this.attributeRelationId)
.deleteData();
return true;
} }
\ No newline at end of file
import("system.util");
import("system.translate"); import("system.translate");
import("system.vars"); import("system.vars");
import("system.db"); import("system.db");
...@@ -160,8 +161,6 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId) ...@@ -160,8 +161,6 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId)
* The corresponding campaign id.<br> * The corresponding campaign id.<br>
* @param {String} pCampaignStepId <p> * @param {String} pCampaignStepId <p>
* The current campaign step id.<br> * The current campaign step id.<br>
* @param {String} pContactId <p>
* The contact id,<br>
* @param {String} pCampaignParticipantId <p> * @param {String} pCampaignParticipantId <p>
* The contact id of the campaign participant.<br> * The contact id of the campaign participant.<br>
* @param {String} pPreviousCampaignStepId <p> * @param {String} pPreviousCampaignStepId <p>
...@@ -169,11 +168,11 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId) ...@@ -169,11 +168,11 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId)
* @return {Boolean} <p> * @return {Boolean} <p>
* Returns true in case the entry was successfully made.<br> * Returns true in case the entry was successfully made.<br>
*/ */
CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId, pCampaignParticipantId, pPreviousCampaignStepId) CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pCampaignParticipantId, pPreviousCampaignStepId)
{ {
let colsCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames(); let colsCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames();
let valsCampaignParticipantLog = new Array(pCampaignId, pCampaignStepId, pContactId, pCampaignParticipantId, vars.get("$sys.user"), vars.get("$sys.date"), pPreviousCampaignStepId); let valsCampaignParticipantLog = new Array(util.getNewUUID(), pCampaignId, pCampaignStepId, pCampaignParticipantId, vars.get("$sys.user"), vars.get("$sys.date"), pPreviousCampaignStepId);
let rows = db.insertData("CAMPAIGNPARTICIPANTLOG", colsCampaignParticipantLog, null, valsCampaignParticipantLog); let rows = db.insertData("CAMPAIGNPARTICIPANTLOG", colsCampaignParticipantLog, null, valsCampaignParticipantLog);
return (rows == 1); return (rows == 1);
...@@ -187,7 +186,7 @@ CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId ...@@ -187,7 +186,7 @@ CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId
*/ */
CampaignUtils.getParticipantLogInsertColumnNames = function() CampaignUtils.getParticipantLogInsertColumnNames = function()
{ {
return ["CAMPAIGNPARTICIPANT_ID", "CAMPAIGN_ID", "CAMPAIGNSTEP_ID", "CAMPAIGNPARTICIPANTLOGID", "USER_NEW", "DATE_NEW", "PREVIOUS_CAMPAIGNSTEP_ID"]; return ["CAMPAIGNPARTICIPANTLOGID", "CAMPAIGN_ID", "CAMPAIGNSTEP_ID", "CAMPAIGNPARTICIPANT_ID", "USER_NEW", "DATE_NEW", "PREVIOUS_CAMPAIGNSTEP_ID"];
} }
/** /**
......
...@@ -161,24 +161,18 @@ ContextUtils.getContextConsumer = function(pContextId) ...@@ -161,24 +161,18 @@ ContextUtils.getContextConsumer = function(pContextId)
ContextUtils.loadContentTitle = function(pEntity, pUid, pProvider) ContextUtils.loadContentTitle = function(pEntity, pUid, pProvider)
{ {
if (!pUid) if (!pUid)
{
return ""; return "";
}
var conf = entities.createConfigForLoadingRows() var conf = entities.createConfigForLoadingRows()
.entity(pEntity) .entity(pEntity)
.uid(pUid) .uid(pUid)
.fields(["#CONTENTTITLE"]); .fields(["#CONTENTTITLE"]);
if (pProvider) if (pProvider)
conf.provider(pProvider); conf.provider(pProvider);
if (entities.getRowCount(conf) > 0) var rows = entities.getRows(conf);
{ return rows.length === 1 ? rows[0]["#CONTENTTITLE"] : "";
return entities.getRow(conf)["#CONTENTTITLE"];
}
return "";
} }
/** /**
......
...@@ -22,15 +22,18 @@ function IndexsearchUtils() {} ...@@ -22,15 +22,18 @@ function IndexsearchUtils() {}
*/ */
IndexsearchUtils.getAffectedIdValues = function(fieldname, affectedInfoContainer, updateFn) { IndexsearchUtils.getAffectedIdValues = function(fieldname, affectedInfoContainer, updateFn) {
var affectedIds; var affectedIds;
switch (affectedInfoContainer.action){ switch (affectedInfoContainer.action)
case "I": {
affectedIds = [affectedInfoContainer.newValues[affectedInfoContainer.columns.indexOf(fieldname)]]; case "I":
affectedIds = affectedInfoContainer.newValues[affectedInfoContainer.columns.indexOf(fieldname)];
affectedIds = affectedIds ? [affectedIds] : []
break; break;
case "U": case "U":
affectedIds = updateFn.call(null, affectedInfoContainer.id); affectedIds = updateFn.call(null, affectedInfoContainer.id);
break; break;
case "D": case "D":
affectedIds = [affectedInfoContainer.oldValues[affectedInfoContainer.columns.indexOf(fieldname)]]; affectedIds = affectedInfoContainer.oldValues[affectedInfoContainer.columns.indexOf(fieldname)];
affectedIds = affectedIds ? [affectedIds] : []
break; break;
} }
if(affectedIds.length > 0) if(affectedIds.length > 0)
......
...@@ -646,68 +646,68 @@ var mandatoryErrorTests = new TestSuite([ ...@@ -646,68 +646,68 @@ var mandatoryErrorTests = new TestSuite([
["and without parameter should error", function(pTester) ["and without parameter should error", function(pTester)
{ {
new SqlBuilder().where().or(); new SqlBuilder().where().or();
}, SqlBuilder.ERROR_NO_PARAMETER_PROVIDED()], }, SqlBuilder._ERROR_NO_PARAMETER_PROVIDED()],
["and with null as value should error", function(pTester) ["and with null as value should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", null); new SqlBuilder().where().or("PERSON.FIRSTNAME", null);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with undefined as value should error", function(pTester) ["and with undefined as value should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined); new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with a jdito-var containing null should error", function(pTester) ["and with a jdito-var containing null should error", function(pTester)
{ {
vars.set("$global.TestingVarNull", null); vars.set("$global.TestingVarNull", null);
new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull"); new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull");
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY_JDITO_VAR()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
["and with an empty sql-builder as subquery should error", function(pTester) ["and with an empty sql-builder as subquery should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder()); new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder());
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with an empty prepared statement as subquery should error", function(pTester) ["and with an empty prepared statement as subquery should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]); new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
// or // or
["or without parameter should error", function(pTester) ["or without parameter should error", function(pTester)
{ {
new SqlBuilder().where().or(); new SqlBuilder().where().or();
}, SqlBuilder.ERROR_NO_PARAMETER_PROVIDED()], }, SqlBuilder._ERROR_NO_PARAMETER_PROVIDED()],
["or with null as value should error", function(pTester) ["or with null as value should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", null); new SqlBuilder().where().or("PERSON.FIRSTNAME", null);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with undefined as value should error", function(pTester) ["or with undefined as value should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined); new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with a jdito-var containing null should error", function(pTester) ["or with a jdito-var containing null should error", function(pTester)
{ {
vars.set("$global.TestingVarNull", null); vars.set("$global.TestingVarNull", null);
new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull"); new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull");
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY_JDITO_VAR()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
["or with an empty sql-builder as subquery should error", function(pTester) ["or with an empty sql-builder as subquery should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder()); new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder());
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with an empty prepared statement as subquery should error", function(pTester) ["or with an empty prepared statement as subquery should error", function(pTester)
{ {
new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]); new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()], }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
]); ]);
var inStatementTests = new TestSuite([ var inStatementTests = new TestSuite([
...@@ -766,7 +766,7 @@ var inStatementTests = new TestSuite([ ...@@ -766,7 +766,7 @@ var inStatementTests = new TestSuite([
{ {
new SqlBuilder() new SqlBuilder()
.where("PERSON.LASTNAME", []); .where("PERSON.LASTNAME", []);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()] }, SqlBuilder._ERROR_VALUE_IS_MANDATORY()]
]); ]);
var testConstantFunctions = new TestSuite([ var testConstantFunctions = new TestSuite([
...@@ -886,7 +886,7 @@ var subqueryAsFieldTests = new TestSuite([ ...@@ -886,7 +886,7 @@ var subqueryAsFieldTests = new TestSuite([
.where("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID") .where("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID")
.and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place .and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place
new SqlBuilder().where(subQuery, "val2", "# = ?"); new SqlBuilder().where(subQuery, "val2", "# = ?");
}, SqlBuilder.ERROR_SUBSELECT_AS_FIELD_NO_FIELD_TYPE()], }, SqlBuilder._ERROR_SUBSELECT_AS_FIELD_NO_FIELD_TYPE()],
["Test if a Subselect as field should error if it is not a full select.", function(pTester) ["Test if a Subselect as field should error if it is not a full select.", function(pTester)
{ {
...@@ -895,7 +895,7 @@ var subqueryAsFieldTests = new TestSuite([ ...@@ -895,7 +895,7 @@ var subqueryAsFieldTests = new TestSuite([
.and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place .and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place
new SqlBuilder().where(subQuery, "val2", "# = ?", SQLTYPES.VARCHAR); new SqlBuilder().where(subQuery, "val2", "# = ?", SQLTYPES.VARCHAR);
}, SqlBuilder.ERROR_SUBSELECT_AS_FIELD_NOT_COMPLETE()] }, SqlBuilder._ERROR_SUBSELECT_AS_FIELD_NOT_COMPLETE()]
]); ]);
var conditionFormatTests = new TestSuite([ var conditionFormatTests = new TestSuite([
...@@ -918,17 +918,17 @@ var conditionFormatTests = new TestSuite([ ...@@ -918,17 +918,17 @@ var conditionFormatTests = new TestSuite([
["pCondition should fail if more than one ? exists", function(pTester) ["pCondition should fail if more than one ? exists", function(pTester)
{ {
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? test ?") new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? test ?")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()], }, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()],
["pCondition should fail if more than one # exists", function(pTester) ["pCondition should fail if more than one # exists", function(pTester)
{ {
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "# test #") new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "# test #")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()], }, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()],
["pCondition should fail if # and ? are in wrong order", function(pTester) ["pCondition should fail if # and ? are in wrong order", function(pTester)
{ {
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? = #") new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? = #")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()] }, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()]
]); ]);
var subqueryAliasTests = new TestSuite([ var subqueryAliasTests = new TestSuite([
......
...@@ -53,6 +53,48 @@ function Tester(pCollectionName) ...@@ -53,6 +53,48 @@ function Tester(pCollectionName)
this.currentTestHadAlreadyAssert = false; this.currentTestHadAlreadyAssert = false;
} }
/**
* generates a summary of the test results
*
* @return {Obect}
*/
Tester.prototype.getSummary = function ()
{
var summary = {
failures : 0,
successes : 0,
failedTests : [],
getMessage : function ()
{
var message = "-------------------------\n"
+ (this.failures ? "Test failure" : "Test success")
+ "\n-------------------------\nTests performed: " + (this.successes + this.failures)
+ "\nTests successful: " + this.successes
+ "\nTests failed: " + this.failures;
if (this.failedTests.length)
{
message += "\nFailures:";
this.failedTests.forEach(function (testName)
{
message += "\n\t" + testName;
});
}
return message;
}
}
this.testResults.forEach(function ([testName,, successful])
{
if (successful)
summary.successes++;
else
{
summary.failures++;
summary.failedTests.push(testName);
}
});
return summary;
}
/** /**
* With assert you can test if a variable is the same like an expected value.<br/> * With assert you can test if a variable is the same like an expected value.<br/>
* The test result is added to the Tester<br/> * The test result is added to the Tester<br/>
...@@ -189,4 +231,5 @@ Tester.prototype.printResults = function () ...@@ -189,4 +231,5 @@ Tester.prototype.printResults = function ()
logging.log(message); logging.log(message);
lastTestDescription = pResult[0]; lastTestDescription = pResult[0];
}, this); }, this);
logging.log(this.getSummary().getMessage());
} }
\ No newline at end of file
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