diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index ba8e1ba466e21676e3963893b800e1b163ef5e03..aba2faf3f1f4c7b5a116d71dc4cd05a5380a7bb6 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -4099,7 +4099,7 @@ </entry> <entry> <key>Would you really like to clear the forecast and set the state to '%0'?</key> - <value>Möchten Sie wirklich den Forecast löschen und den status auf '%0' setzen?</value> + <value>Möchten Sie wirklich den Forecast löschen und den Status auf '%0' setzen?</value> </entry> <entry> <key>This cannot be undone!</key> diff --git a/process/ImporterMappingFunctions_lib/process.js b/process/ImporterMappingFunctions_lib/process.js index 71eae92e708f21f10f5bfc70eb3abc4d5bddcb40..7d280b00b400c2fa675b863cc9ec90922536b7bb 100644 --- a/process/ImporterMappingFunctions_lib/process.js +++ b/process/ImporterMappingFunctions_lib/process.js @@ -41,13 +41,13 @@ function iKeyword(pObject) { if(!keyword || !container) return true; var sql = "select " + this.getColumnCase("keyid") + " from " + this.getTableCase("ab_keyword_entry") + " where " - + this.getColumnCase("container") + " = ? and " + this.getColumnCase("title") + " = ?"; + + this.getColumnCase("container") + " = ? and " + this.getColumnCase("title") + " = ?"; var id = db.cell([sql, [[container, SQLTYPES.VARCHAR], [keyword, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if(id == "" || id == null) { id = util.getNewUUID(); var columns = [this.getColumnCase("ab_keyword_entryid"), this.getColumnCase("keyid"), this.getColumnCase("container"), - this.getColumnCase("title"), this.getColumnCase("sorting"), this.getColumnCase("isactive"), this.getColumnCase("isessential")]; + this.getColumnCase("title"), this.getColumnCase("sorting"), this.getColumnCase("isactive"), this.getColumnCase("isessential")]; sql = "select max(coalesce(sorting, 0))+1 from ab_keyword_entry where container = ?"; var sort = db.cell([sql, [[container, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if(sort == "") sort = "0"; @@ -91,7 +91,7 @@ function iAttribute(pObject) { var valueColumn = ""; var attributes = attribute.split("."); var columns = [this.getColumnCase("ab_attributeid"), this.getColumnCase("attribute_parent_id"), this.getColumnCase("attribute_name"), - this.getColumnCase("attribute_type"), this.getColumnCase("attribute_level"), this.getColumnCase("attribute_active")]; + this.getColumnCase("attribute_type"), this.getColumnCase("attribute_level"), this.getColumnCase("attribute_active")]; var type = $AttributeTypes.GROUP.toString(); switch (atype) { case $AttributeTypes.TEXT.toString(): @@ -129,12 +129,12 @@ function iAttribute(pObject) { if (i == 0) { var parent = "NULL"; var sql = "select " + this.getColumnCase("ab_attributeid") + " from " + this.getTableCase("ab_attribute") + " where " - + this.getColumnCase("attribute_name") + " = ? and " + this.getColumnCase("attribute_level") + " = 0"; + + this.getColumnCase("attribute_name") + " = ? and " + this.getColumnCase("attribute_level") + " = 0"; id = db.cell([sql, [[attributes[i], SQLTYPES.VARCHAR]]], this.Config.AliasTo); } else { parent = pathToFollow["id"]; sql = "select " + this.getColumnCase("ab_attributeid") + " from " + this.getTableCase("ab_attribute") + " where " - + this.getColumnCase("attribute_name") + " = ? and " + this.getColumnCase("attribute_parent_id") + " = ?"; + + this.getColumnCase("attribute_name") + " = ? and " + this.getColumnCase("attribute_parent_id") + " = ?"; id = db.cell([sql, [[attributes[i], SQLTYPES.VARCHAR], [parent, SQLTYPES.CHAR]]], this.Config.AliasTo); } if (id == "" || id == null) { @@ -152,7 +152,7 @@ function iAttribute(pObject) { if (otype) { var aid = id; sql = "select " + this.getColumnCase("ab_attributeusageid") + " from " + this.getTableCase("ab_attributeusage") + " where " - + this.getColumnCase("ab_attribute_id") + " = ? and " + this.getColumnCase("object_type") + " = ?"; + + this.getColumnCase("ab_attribute_id") + " = ? and " + this.getColumnCase("object_type") + " = ?"; id = db.cell([sql, [[aid, SQLTYPES.CHAR], [otype, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if (id == "" || id == null) { columns = [this.getColumnCase("ab_attributeusageid"), this.getColumnCase("ab_attribute_id"), this.getColumnCase("object_type")]; @@ -161,12 +161,12 @@ function iAttribute(pObject) { if (value && oid) { sql = "select " + this.getColumnCase("ab_attributerelationid") + " from " + this.getTableCase("ab_attributerelation") + " where " - + this.getColumnCase("ab_attribute_id") + " = ? and " + this.getColumnCase("object_rowid") + " = ? and " - + this.getColumnCase("object_type") + " = ?"; + + this.getColumnCase("ab_attribute_id") + " = ? and " + this.getColumnCase("object_rowid") + " = ? and " + + this.getColumnCase("object_type") + " = ?"; id = db.cell([sql, [[aid, SQLTYPES.CHAR], [oid, SQLTYPES.CHAR], [otype, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if (id == "" || id == null) { columns = [this.getColumnCase("ab_attributerelationid"), this.getColumnCase("ab_attribute_id"), this.getColumnCase("object_type"), - this.getColumnCase("object_rowid"), valueColumn]; + this.getColumnCase("object_rowid"), valueColumn]; this.insertData(this.getTableCase("ab_attributerelation"), columns, null, [util.getNewUUID(), aid, otype, oid, value], this.Config.AliasTo); } else if (this.Config.ImportCommand.indexOf("update") != -1) { cond = this.getColumnCase("ab_attributerelationid") + " = '" + id + "'"; @@ -231,9 +231,9 @@ function iKeywordAttribute(pObject) { } var sql = "select " + this.getColumnCase("ab_keyword_attributeid") - + " from " + this.getTableCase("ab_keyword_attribute") - + " where " + this.getColumnCase("name") - + " = ? and " + this.getColumnCase("container") + " = ?"; + + " from " + this.getTableCase("ab_keyword_attribute") + + " where " + this.getColumnCase("name") + + " = ? and " + this.getColumnCase("container") + " = ?"; var attributeId = db.cell([sql, [[keywordAttribute, SQLTYPES.VARCHAR], [keywordContainer, SQLTYPES.VARCHAR]]], this.Config.AliasTo); @@ -241,36 +241,36 @@ function iKeywordAttribute(pObject) { if (attributeId == "" || attributeId == null) { attributeId = util.getNewUUID(); var columns = [this.getColumnCase("ab_keyword_attributeid"), - this.getColumnCase("name"), - this.getColumnCase("container"), - this.getColumnCase("kind")]; + this.getColumnCase("name"), + this.getColumnCase("container"), + this.getColumnCase("kind")]; this.insertData(this.getTableCase("ab_keyword_attribute"), columns, null, - [attributeId, keywordAttribute, keywordContainer, keywordAttributeType], this.Config.AliasTo); + [attributeId, keywordAttribute, keywordContainer, keywordAttributeType], this.Config.AliasTo); } // Creates the entry in AB_KEYWORD_ENTRY and AB_KEYWORD_ATTRIBUTERELATION, case if it not exists. if (keyword && keywordAttrRelValue) { sql = "select " + this.getColumnCase("ab_keyword_entryid") - + " from " + this.getTableCase("ab_keyword_entry") - + " where " + this.getColumnCase("keyid") + " = ?"; + + " from " + this.getTableCase("ab_keyword_entry") + + " where " + this.getColumnCase("keyid") + " = ?"; var keywordId = db.cell([sql, [[keyword, SQLTYPES.CHAR]]], this.Config.AliasTo); if (keywordId == "" || keywordId == null) { sql = "select " + this.getColumnCase("keyid") - + " from " + this.getTableCase("ab_keyword_entry") - + " where " + this.getColumnCase("container") - + " = ? and " + this.getColumnCase("title") + " = ?"; + + " from " + this.getTableCase("ab_keyword_entry") + + " where " + this.getColumnCase("container") + + " = ? and " + this.getColumnCase("title") + " = ?"; keywordId = db.cell([sql, [[keywordContainer, SQLTYPES.VARCHAR], [keyword, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if (keywordId == "" || keywordId == null) { columns = [this.getColumnCase("ab_keyword_entryid"), this.getColumnCase("keyid"), this.getColumnCase("container"), - this.getColumnCase("title"), this.getColumnCase("sorting"), this.getColumnCase("isactive"), - this.getColumnCase("isessential")]; + this.getColumnCase("title"), this.getColumnCase("sorting"), this.getColumnCase("isactive"), + this.getColumnCase("isessential")]; sql = "select max(coalesce(sorting, 0))+1 from ab_keyword_entry where container = ?"; @@ -281,27 +281,27 @@ function iKeywordAttribute(pObject) { keywordId = util.getNewUUID(); this.insertData(this.getTableCase("ab_keyword_entry"), columns, null, - [keywordId, util.getNewUUID(), keywordContainer, keyword, sort, "1", "0"], this.Config.AliasTo); + [keywordId, util.getNewUUID(), keywordContainer, keyword, sort, "1", "0"], this.Config.AliasTo); } } // Creates or updates the keyword attributerelation. sql = "select " + this.getColumnCase("ab_keyword_attributerelationid") - + " from " + this.getTableCase("ab_keyword_attributerelation") - + " where " + this.getColumnCase("ab_keyword_entry_id") - + " = ? and " + this.getColumnCase("ab_keyword_attribute_id") + " = ?"; + + " from " + this.getTableCase("ab_keyword_attributerelation") + + " where " + this.getColumnCase("ab_keyword_entry_id") + + " = ? and " + this.getColumnCase("ab_keyword_attribute_id") + " = ?"; id = db.cell([sql, [[keywordId, SQLTYPES.CHAR], [attributeId, SQLTYPES.CHAR]]], this.Config.AliasTo); if (id == "" || id == null) { columns = [this.getColumnCase("ab_keyword_attributerelationid"), - this.getColumnCase("ab_keyword_entry_id"), - this.getColumnCase("ab_keyword_attribute_id"), - valueColumn]; + this.getColumnCase("ab_keyword_entry_id"), + this.getColumnCase("ab_keyword_attribute_id"), + valueColumn]; id = util.getNewUUID(); this.insertData(this.getTableCase("ab_keyword_attributerelation"), columns, null, - [id, keywordId, attributeId, keywordAttrRelValue], this.Config.AliasTo); + [id, keywordId, attributeId, keywordAttrRelValue], this.Config.AliasTo); } else { if (this.Config.ImportCommand.indexOf("update") != -1) { @@ -340,13 +340,13 @@ function iComm(pObject) { if(!address || !medium || !contact) return true; var sql = "select " + this.getColumnCase("communicationid") + " from " + this.getTableCase("communication") - +" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium_id") + " = ? and " - + this.getColumnCase("isstandard") + " = ? and " + this.getColumnCase("addr") + " = ?" + +" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium_id") + " = ? and " + + this.getColumnCase("isstandard") + " = ? and " + this.getColumnCase("addr") + " = ?" var id = db.cell([sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR], //TODO: define types dynamically and not hardcoded - [standard, SQLTYPES.SMALLINT], [address, SQLTYPES.VARCHAR]]], this.Config.AliasTo); + [standard, SQLTYPES.SMALLINT], [address, SQLTYPES.VARCHAR]]], this.Config.AliasTo); if (id == "" || id == null) { var columns = [this.getColumnCase("communicationid"), this.getColumnCase("addr"), - this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("isstandard")]; + this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("isstandard")]; this.insertData(this.getTableCase("communication"), columns, null, [util.getNewUUID(), address, medium, contact, standard], this.Config.AliasTo); } return true; @@ -354,13 +354,14 @@ function iComm(pObject) { /* * Values of the mapping line: - * reason (optional): The reason. - * medium (required): The medium id. - * contactId (required): The id of the entry in the contact table. - * type (required): Yes or no to communication. + * contact (required): The id of the entry in the contact table. + * restrictionMedium (required): The medium id. + * restrictionReason (optional): The reason. + * startDate (optional): The date when the restrictions begins. + * involvedEmployee (optional): The contact which is responsible for the restriction. * * @name iCommRestriction - * @param {Object} pObject req the mapping line + * @param {Object} pObject (required): Associative Array with required informations. * @return {Boolean} true * */ @@ -368,42 +369,46 @@ function iCommRestriction(pObject) { if (!this.doIfCheck(pObject)) return true; + var restrictionContact = this.InputRecord[pObject.restrictionContact]; var restrictionReason = this.InputRecord[pObject.restrictionReason]; var restrictionMedium = this.InputRecord[pObject.restrictionMedium]; - var contact = this.InputRecord[pObject.contact]; - var restricionType = this.InputRecord[pObject.restricionType]; - - if(reason == undefined) reason = this.resolveSymbol(pObject, pObject.reason); - if(medium == undefined) medium = this.resolveSymbol(pObject, pObject.medium); - if(contact == undefined) contact = this.resolveSymbol(pObject, pObject.contactId); - if(type == undefined) restricionType = this.resolveSymbol(pObject, pObject.restricionType); + var restrictionStartDate = this.InputRecord[pObject.restrictionStartDate]; + var restrictionInvolvedEmployee = this.InputRecord[pObject.restrictionInvolvedEmployee]; - if (!medium || !contact || !type) return true; + if(restrictionContact == undefined) restrictionContact = this.resolveSymbol(pObject, pObject.restrictionContact); + if(restrictionReason == undefined) restrictionReason = this.resolveSymbol(pObject, pObject.restrictionReason); + if(restrictionReason == undefined || restrictionReason == null) restrictionReason = "NULL"; + if(restrictionMedium == undefined) restrictionMedium = this.resolveSymbol(pObject, pObject.restrictionMedium); + if(restrictionStartDate == undefined) restrictionStartDate = this.resolveSymbol(pObject.restrictionStartDate); + if(restrictionStartDate == undefined || restrictionStartDate == null) restrictionStartDate = "NULL"; + if(restrictionInvolvedEmployee == undefined) restrictionInvolvedEmployee = this.resolveSymbol(pObject.restrictionInvolvedEmployee); + if(restrictionInvolvedEmployee == undefined || restrictionInvolvedEmployee == null) restrictionInvolvedEmployee = "NULL"; + if (!restrictionMedium || !restrictionContact) return true; + var alias = this.Config.AliasTo; - var type = this.getColumnCase("type"); - var commRestriction = this.getColumnCase("commrestriction"); - var commRestrictionId = this.getColumnCase("commrestrictionid"); - var contactId = this.getColumnCase("contact_id"); - var medium = this.getColumnCase("medium"); - var dateEdit = this.getColumnCase("date_edit"); - var dateNew = this.getColumnCase("date_new"); - var reason = this.getColumnCase("reason"); - -// var sql = "select top 1 " + this.getColumnCase("type") + " from " + this.getTableCase("commrestriction") -// +" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium") + " = ? order by " -// + this.getColumnCase("date_edit") + " desc, " + this.getColumnCase("date_new") + " desc"; - -// db.cell([sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR]]], this.Config.AliasTo); + var commRestriction = this.getTableCase("commrestriction"); + var commRestrictionId = this.getColumnCase("commrestriction.commrestrictionid"); + var contactId = this.getColumnCase("commrestriction.contact_id"); + var medium = this.getColumnCase("commrestriction.medium"); + var reason = this.getColumnCase("commrestriction.reason"); + var startDate = this.getColumnCase("commrestriction.startdate"); + var involvedEmployee = this.getColumnCase("commrestriction.employee_involved"); + + var id = newSelect(commRestrictionId, alias).from(commRestriction).where(contactId, restrictionContact).and(medium, restrictionMedium).cell(); + var columns = [commRestrictionId, medium, reason, contactId, startDate, involvedEmployee]; + var values = [id, restrictionMedium, restrictionReason, restrictionContact, restrictionStartDate, restrictionInvolvedEmployee]; - var id = newSelect(type, alias).from(commRestriction).where(contactId, contact).and(medium, restrictionMedium) - .orderBy(dateEdit + " desc" + dateNew + " desc").; + if (id == "" || id == null) + { + values[0] = util.getNewUUID(); + this.insertData(commRestriction, columns, null, values, alias); + } + else + { + this.updateData(commRestriction, columns, null, values, alias); + } - if (id == "" || id == null || id != type) { - if(reason == undefined || reason == null) reason = "NULL"; - var columns = [this.getColumnCase("commrestrictionid"), this.getColumnCase("medium"), this.getColumnCase("contact_id"), this.getColumnCase("type"), this.getColumnCase("reason")]; - this.insertData(this.getTableCase("commrestriction"), columns, null, [util.getNewUUID(), medium, contact, type, reason], this.Config.AliasTo); - } return true; } @@ -449,11 +454,11 @@ function iActivityLink(pObject) var configAliasTo = this.Config.AliasTo; var sql = "select " + columnCaseActivityLinkId - +" from " + tableCaseActivityLink - + " where " + columnCaseActivityId - + " = ? and " + columnCaseObjectType - + " = ? and " + columnCaseObjectRowId - + " = ?"; + +" from " + tableCaseActivityLink + + " where " + columnCaseActivityId + + " = ? and " + columnCaseObjectType + + " = ? and " + columnCaseObjectRowId + + " = ?"; var id = db.cell([sql, [[activityId, SQLTYPES.VARCHAR], [objectType, SQLTYPES.VARCHAR], [objectId, SQLTYPES.CHAR]]], configAliasTo); @@ -488,15 +493,15 @@ function iDocumentByPath(pObject){ logging.log(filename + " " + dateNew) } var sql = "select count(" + this.getColumnCase("row_id") + ") from " + this.getTableCase("asys_binaries") - + " where " + this.getColumnCase("row_id") + " = ? and " + this.getColumnCase("filename") + " = ?"; + + " where " + this.getColumnCase("row_id") + " = ? and " + this.getColumnCase("filename") + " = ?"; var count = db.cell([sql, [[row, SQLTYPES.CHAR], [filename, SQLTYPES.VARCHAR]]], this.Config. AliasSys); if(count == 0) { var cols = [this.getColumnCase("Id"), this.getColumnCase("Tablename"), this.getColumnCase("Datasize"), - this.getColumnCase("date_new"), this.getColumnCase("date_edit"), this.getColumnCase("user_new"), - this.getColumnCase("bindata"), this.getColumnCase("containername"), this.getColumnCase("filename"), - this.getColumnCase("row_id"), this.getColumnCase("mimetype")]; + this.getColumnCase("date_new"), this.getColumnCase("date_edit"), this.getColumnCase("user_new"), + this.getColumnCase("bindata"), this.getColumnCase("containername"), this.getColumnCase("filename"), + this.getColumnCase("row_id"), this.getColumnCase("mimetype")]; var vals = [util.getNewUUID(), "$!GENERIC!$", length, dateNew, dateNew, vars.getString("$sys.user"), data, - "DOCUMENT", filename, row, util.getMimeType(filename)]; + "DOCUMENT", filename, row, util.getMimeType(filename)]; db.insertData(this.getTableCase("asys_binaries"), cols, null, vals, this.Config. AliasSys); } } @@ -537,15 +542,15 @@ function iDocument(pObject) if(pObject.Rowid != "" && pObject.Filename != "") db.insertBinary( - pObject.Tablename, - pObject.Container, - this.getOutput(pObject, "Rowid"), - null, - this.InputRecord[pObject.Source], - this.InputRecord[pObject.Filename], - desc, - keyw, - this.Config.AliasTo); + pObject.Tablename, + pObject.Container, + this.getOutput(pObject, "Rowid"), + null, + this.InputRecord[pObject.Source], + this.InputRecord[pObject.Filename], + desc, + keyw, + this.Config.AliasTo); } catch(ex) { @@ -758,17 +763,17 @@ function iJoin(pObject) { if (pObject.Source != undefined) if(this.InputRecord[pObject.Source[i]] != "") - { - if(i > 0 ) s += pObject.Delimiter; - s += this.InputRecord[pObject.Source[i]]; - } + { + if(i > 0 ) s += pObject.Delimiter; + s += this.InputRecord[pObject.Source[i]]; + } if(pObject.Value != undefined) if(this.resolveSymbol(pObject, pObject.Value[i]) != "") - { - if(i > 0 ) s += pObject.Delimiter; - s += this.resolveSymbol(pObject, pObject.Value[i]); - } + { + if(i > 0 ) s += pObject.Delimiter; + s += this.resolveSymbol(pObject, pObject.Value[i]); + } } this.setOutput(pObject, s); diff --git a/process/test_iCommRestriction/process.js b/process/test_iCommRestriction/process.js new file mode 100644 index 0000000000000000000000000000000000000000..3e3c5c98515c35629064e74489141098754033da --- /dev/null +++ b/process/test_iCommRestriction/process.js @@ -0,0 +1,37 @@ +import("system.db"); +import("Importer_lib"); +import("ImporterMappingFunctions_lib"); + +var importerMapping = { + AliasTo: "Data_alias", + DataFunction: function (pCurrentBatchNum) + { + if (pCurrentBatchNum > 1) + return null; + return [ + ["a8a5f214-8165-4627-bee2-bceb3578147e", "cfebe176-0a64-428d-b0ec-bba454d2ca3e", "Testing"], + ["c7ddf982-0e58-4152-b82b-8f5673b0b729", "cb07397b-a976-4960-b8e5-9edf189c5caf", "Testing"] + ]; + }, + ImportCommand: "insert+update", + Mapping: [ + [ iCommRestriction, + { + contact: 0, + restrictionMedium: 1, + restrictionReason: 2 + } + ] + ] +}; + +var imp = new Importer(importerMapping); +imp.Log = "CONSOLE"; +imp.ImportUser = "IMPORTER_TESTER"; +imp.Preview = false; +imp.Debug = true; +imp.LogLevel = imp.LogLevels.Info; + +// MariaDB requires lower table cases +if (db.getDatabaseType("Data_alias") == db.DBTYPE_MARIADB10) imp.TableCase = imp.Cases.Lower; +imp.process(); \ No newline at end of file diff --git a/process/test_iCommRestriction/test_iCommRestriction.aod b/process/test_iCommRestriction/test_iCommRestriction.aod new file mode 100644 index 0000000000000000000000000000000000000000..cc954a462d091f6b3efef2b7797b92a18ae0b2f8 --- /dev/null +++ b/process/test_iCommRestriction/test_iCommRestriction.aod @@ -0,0 +1,9 @@ +<?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>test_iCommRestriction</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/test_iCommRestriction/process.js</process> + <variants> + <element>EXECUTABLE</element> + </variants> +</process>