diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index 6cc8087d7753dab09bf7f85d37d3072b5a381b78..10f8654b0ad82f174b74f3a1b584b6c5a19823cd 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Address_entity</name> <title>Addresses</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <recordContainerType>DB</recordContainerType> - <caption>Addresses</caption> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Address_entity/conditionProcess.js</conditionProcess> + <recordContainerType>DB</recordContainerType> + <caption>Addresses</caption> <entityFields> <entityField> <name>ADDRESS</name> diff --git a/entity/Appointment_entity/Appointment_entity.aod b/entity/Appointment_entity/Appointment_entity.aod index 2a647e86736f41237906541f5af57bd137c1b655..c63b1d39cd7093c26ec4ed3c7ad42e9c882c751e 100644 --- a/entity/Appointment_entity/Appointment_entity.aod +++ b/entity/Appointment_entity/Appointment_entity.aod @@ -1,10 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Appointment_entity</name> <title>Termin</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <recordContainerType>JDITO</recordContainerType> - <caption>Termin</caption> <alias>Data_alias</alias> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> <fields> @@ -25,11 +23,18 @@ <element>CLASSIFICATION</element> <element>TRANSPARENCY</element> <element>CATEGORIES</element> + <element>RRULE</element> + <element>RECURRENCEID</element> + <element>SAFESCOPEFIELD</element> + <element>MASTERBEGIN</element> + <element>MASTEREND</element> </fields> <contentProcess>%aditoprj%/entity/Appointment_entity/contentProcess.js</contentProcess> <onInsert>%aditoprj%/entity/Appointment_entity/onInsert.js</onInsert> <onUpdate>%aditoprj%/entity/Appointment_entity/onUpdate.js</onUpdate> <onDelete>%aditoprj%/entity/Appointment_entity/onDelete.js</onDelete> + <recordContainerType>JDITO</recordContainerType> + <caption>Termin</caption> <entityFields> <entityField> <name>SUMMARY</name> @@ -112,7 +117,6 @@ <onActionProcess>%aditoprj%/entity/Appointment_entity/entityfields/partstatactiongroup/children/accept/onActionProcess.js</onActionProcess> <actionOrder v="0" /> <caption>zusagen</caption> - <icon>VAADIN:CHECK</icon> <iconId>VAADIN:CHECK</iconId> </entityActionField> <entityActionField> @@ -121,7 +125,6 @@ <description></description> <onActionProcess>%aditoprj%/entity/Appointment_entity/entityfields/partstatactiongroup/children/decline/onActionProcess.js</onActionProcess> <caption>absagen</caption> - <icon>VAADIN:CLOSE</icon> <iconId>VAADIN:CLOSE</iconId> </entityActionField> <entityActionField> @@ -129,7 +132,6 @@ <fieldType>ACTION</fieldType> <onActionProcess>%aditoprj%/entity/Appointment_entity/entityfields/partstatactiongroup/children/tentative/onActionProcess.js</onActionProcess> <caption>vielleicht</caption> - <icon>VAADIN:QUESTION</icon> <iconId>VAADIN:QUESTION</iconId> </entityActionField> </children> @@ -137,5 +139,34 @@ <entityIncomingField> <name>#INCOMING</name> </entityIncomingField> + <entityParameter> + <name>masterEntry</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityField> + <name>ORGANIZER</name> + <fieldName>ORGANIZER</fieldName> + </entityField> + <entityField> + <name>RRULE</name> + <fieldName>RRULE</fieldName> + </entityField> + <entityField> + <name>RECURRENCEID</name> + <fieldName>RECURRENCEID</fieldName> + </entityField> + <entityField> + <name>SAFESCOPEFIELD</name> + <fieldName>SAFESCOPEFIELD</fieldName> + </entityField> + <entityField> + <name>MASTERBEGIN</name> + <fieldName>MASTERBEGIN</fieldName> + </entityField> + <entityField> + <name>MASTEREND</name> + <fieldName>MASTEREND</fieldName> + </entityField> </entityFields> </entity> diff --git a/entity/Appointment_entity/contentProcess.js b/entity/Appointment_entity/contentProcess.js index 927ff03b31f8e3c4ae557c6c99f25a076cbca914..4554846ac42d01cd24776f6ce38b36b01b4531cf 100644 --- a/entity/Appointment_entity/contentProcess.js +++ b/entity/Appointment_entity/contentProcess.js @@ -6,9 +6,16 @@ import("system.datetime"); import("system.eMath"); import("system.util"); +// $param.entry is potentially a recurrence exception. if(vars.exists("$param.entry")) { var entry = JSON.parse(vars.getString("$param.entry")); + var masterEntry = null; + if (vars.exists("$param.masterEntry") && vars.get("$param.masterEntry") != "") { + masterEntry = JSON.parse(vars.get("$param.masterEntry")); + } + + logging.log("Appointment is recurrence exception: " + (masterEntry != null)) var uid = entry[calendars.ID]; var summary = entry[calendars.SUMMARY]; @@ -17,7 +24,7 @@ if(vars.exists("$param.entry")) var enddate = entry[calendars.DTEND]; var links = entry[calendars.LINKS]; var description = entry[calendars.DESCRIPTION]; - var organizer = entry[calendars.ORGANIZER2]; + var organizer = entry[calendars.ORGANIZER2]["paramvalue"]; var status = entry[calendars.STATUS]; var location = entry[calendars.LOCATION]; var reminder = entry[calendars.REMINDER]; @@ -26,11 +33,24 @@ if(vars.exists("$param.entry")) var transparency = entry[calendars.TRANSPARENCY]; var categories = entry[calendars.CATEGORIES]; + var masterBegin = masterEntry != null ? masterEntry[calendars.DTSTART] : null + var masterEnd = masterEntry != null ? masterEntry[calendars.DTEND] : null + + // Recurrence + var recurrenceID = entry[calendars.RECURRENCEID]; + var rrule = null; + if (masterEntry != null) { // Entry is a recurrence exception, therefore get rrule from master + rrule = masterEntry[calendars.RRULE] != null ? masterEntry[calendars.RRULE][0] : null; + } else { + rrule = entry[calendars.RRULE] != null ? entry[calendars.RRULE][0] : null; + } + //@TODO Icon - result.object([ - [uid, '', '', attendees.length, startdate, enddate, summary, organizer, attendees, status, links, description, location, '', classification, transparency, categories] //reminder, remindercheck - ]); + [uid, '', '', attendees.length, startdate, enddate, summary, organizer, + attendees, status, links, description, location, '', classification, + transparency, categories, rrule, recurrenceID, null, masterBegin, masterEnd] //reminder, remindercheck + ]); } else { diff --git a/entity/Appointment_entity/entityfields/categories/valueProcess.js b/entity/Appointment_entity/entityfields/categories/valueProcess.js index 6e54dcd0b4fefaf6c86753a468b6a549ee231929..064e4914d6c19cdc8841cf1aeab99818618da376 100644 --- a/entity/Appointment_entity/entityfields/categories/valueProcess.js +++ b/entity/Appointment_entity/entityfields/categories/valueProcess.js @@ -3,5 +3,6 @@ import("system.result"); import("system.vars"); import("system.calendars"); -var categs = JSON.parse(vars.getString("param.entry"))[calendars.CATEGORIES]; -result.string(categs); +var categs = JSON.parse(vars.getString("$param.entry"))[calendars.CATEGORIES]; +logging.log("categs -> "+ categs); +result.string(categs); \ No newline at end of file diff --git a/entity/Appointment_entity/entityfields/partstatactiongroup/children/accept/onActionProcess.js b/entity/Appointment_entity/entityfields/partstatactiongroup/children/accept/onActionProcess.js index 4ee04f054f1217ca5ce2f61235174720e00b8e00..fd31c4af45f3b051737a82014287d7c34b8ee7ff 100644 --- a/entity/Appointment_entity/entityfields/partstatactiongroup/children/accept/onActionProcess.js +++ b/entity/Appointment_entity/entityfields/partstatactiongroup/children/accept/onActionProcess.js @@ -10,8 +10,15 @@ var currentUserEncodedString = calendars.getCalendarUser(vars.getString("$sys.us var currentUserDecodedArray = text.decodeMS(currentUserEncodedString); var currentUserUri = currentUserDecodedArray[0]; -var currentAttendees = vars.get("$field.ATTENDEES"); -var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, "ACCEPTED"); +var newState = "ACCEPTED"; -appointmentUtil.sendExchangedAction(vars.get("$param.entry")); -neon.setFieldValue("$field.ATTENDEES", updatedAttendees); +if(calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS) +{ + appointmentUtil.sendExchangedAction(vars.get("$param.entry"), newState); +} +else +{ + var currentAttendees = vars.get("$field.ATTENDEES"); + var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, newState); + neon.setFieldValue("$field.ATTENDEES", updatedAttendees); +} diff --git a/entity/Appointment_entity/entityfields/partstatactiongroup/children/decline/onActionProcess.js b/entity/Appointment_entity/entityfields/partstatactiongroup/children/decline/onActionProcess.js index 4c8288f8a49b6b59e2fcc0f1dd060a70949568f0..831a49bcec9981e3429d24f4afe98c398739698d 100644 --- a/entity/Appointment_entity/entityfields/partstatactiongroup/children/decline/onActionProcess.js +++ b/entity/Appointment_entity/entityfields/partstatactiongroup/children/decline/onActionProcess.js @@ -10,8 +10,15 @@ var currentUserEncodedString = calendars.getCalendarUser(vars.getString("$sys.us var currentUserDecodedArray = text.decodeMS(currentUserEncodedString); var currentUserUri = currentUserDecodedArray[0]; -var currentAttendees = vars.get("$field.ATTENDEES"); -var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, "DECLINED"); +var newState = "DECLINED"; -appointmentUtil.sendExchangedAction(vars.get("$param.entry")); -neon.setFieldValue("$field.ATTENDEES", updatedAttendees); +if(calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS) +{ + appointmentUtil.sendExchangedAction(vars.get("$param.entry"), newState); +} +else +{ + var currentAttendees = vars.get("$field.ATTENDEES"); + var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, newState); + neon.setFieldValue("$field.ATTENDEES", updatedAttendees); +} diff --git a/entity/Appointment_entity/entityfields/partstatactiongroup/children/tentative/onActionProcess.js b/entity/Appointment_entity/entityfields/partstatactiongroup/children/tentative/onActionProcess.js index 9fdc8598e107ef80c6e91de3743de711adfde54e..24a1e6e1c9ef39f826600b5c1a01d5a7fc57d506 100644 --- a/entity/Appointment_entity/entityfields/partstatactiongroup/children/tentative/onActionProcess.js +++ b/entity/Appointment_entity/entityfields/partstatactiongroup/children/tentative/onActionProcess.js @@ -10,8 +10,15 @@ var currentUserEncodedString = calendars.getCalendarUser(vars.getString("$sys.us var currentUserDecodedArray = text.decodeMS(currentUserEncodedString); var currentUserUri = currentUserDecodedArray[0]; -var currentAttendees = vars.get("$field.ATTENDEES"); -var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, "TENTATIVE"); +var newState = "TENTATIVE"; -appointmentUtil.sendExchangedAction(vars.get("$param.entry")); -neon.setFieldValue("$field.ATTENDEES", updatedAttendees); \ No newline at end of file +if(calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS) +{ + appointmentUtil.sendExchangedAction(vars.get("$param.entry"), newState); +} +else +{ + var currentAttendees = vars.get("$field.ATTENDEES"); + var updatedAttendees = appointmentUtil.setPartStat(currentUserUri, currentAttendees, newState); + neon.setFieldValue("$field.ATTENDEES", updatedAttendees); +} \ No newline at end of file diff --git a/entity/Appointment_entity/onUpdate.js b/entity/Appointment_entity/onUpdate.js index 14e610ccd1b99d5f6c0a50d5c0daa05ac32dc43c..48860685efadbc2c593a112cf29f3dec01961596 100644 --- a/entity/Appointment_entity/onUpdate.js +++ b/entity/Appointment_entity/onUpdate.js @@ -13,9 +13,9 @@ import("system.tools"); // Dieser Prozess speichert die im Frame angezeigten Daten // Je nach Modus (INSERT, EDIT) wird ein neuer Datensatz angelegt oder der alte editiert -if(vars.exists("param.entry")) +if(vars.exists("$param.entry")) { - var event = JSON.parse(vars.getString("param.entry")); + var event = JSON.parse(vars.getString("$param.entry")); var ok = false; if ( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS && event[calendars.ORGANIZER2]["cn"] != event[calendars.USER2]["cn"]) diff --git a/entity/Comm_entity/Comm_entity.aod b/entity/Comm_entity/Comm_entity.aod index c8e8ab8a1280bd4d3acf578d04f850279cff51b7..7441cfe350ac876895a30a000ae9d33185f74c4c 100644 --- a/entity/Comm_entity/Comm_entity.aod +++ b/entity/Comm_entity/Comm_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Comm_entity</name> <title>Communication</title> <majorModelMode>DISTRIBUTED</majorModelMode> @@ -15,7 +15,7 @@ <columnName>ADDR</columnName> <caption>${COMM_ADDRESS}</caption> <contentTypeProcess>%aditoprj%/entity/Comm_entity/entityfields/addr/contentTypeProcess.js</contentTypeProcess> - <valueProcess>%aditoprj%/entity/Comm_entity/entityfields/addr/valueProcess.js</valueProcess> + <onValidation>%aditoprj%/entity/Comm_entity/entityfields/addr/onValidation.js</onValidation> </entityField> <entityField> <name>COMMID</name> @@ -41,6 +41,7 @@ <columnName>MEDIUM_ID</columnName> <caption>Medium</caption> <possibleItemsProcess>%aditoprj%/entity/Comm_entity/entityfields/medium_id/possibleItemsProcess.js</possibleItemsProcess> + <valueProcess>%aditoprj%/entity/Comm_entity/entityfields/medium_id/valueProcess.js</valueProcess> </entityField> <entityField> <name>RELATION_ID</name> @@ -87,6 +88,12 @@ So, for only showing telephone-types you&apos;ve to specify this parameter w <entityIncomingField> <name>#INCOMING</name> </entityIncomingField> + <entityParameter> + <name>RelationsMainCountry_param</name> + <code>%aditoprj%/entity/Comm_entity/entityfields/relationsmaincountry_param/code.js</code> + <mandatory v="false" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <linkInformation> <linkInformation> diff --git a/entity/Comm_entity/conditionProcess.js b/entity/Comm_entity/conditionProcess.js index 7ab504b7b04216aec94e4d2dbbcba228e8c50819..52f44d3905881512659a8e605db36eb05e32a336 100644 --- a/entity/Comm_entity/conditionProcess.js +++ b/entity/Comm_entity/conditionProcess.js @@ -1,42 +1,38 @@ -import("system.logging"); -import("system.text"); -import("system.result"); -import("system.vars"); -import("Sql_lib"); -import("Keyword_lib"); - -var cond, relId, mediumCategories, keywordUtil; - - - -cond = ""; -if(vars.exists("$param.RelId_param")){ - - relId = vars.get("$param.RelId_param"); - - if (relId != null && relId != "" && relId != undefined) - { - cond += " and COMM.RELATION_ID in ('" + relId + "')";//TODO: quoting/prevent sql-injection - } -} -if (vars.exists("$param.MediumCategoriesFilter_param")){ - - mediumCategories = vars.get("$param.MediumCategoriesFilter_param"); - if (mediumCategories != null && mediumCategories != "" && mediumCategories != undefined) - { - - mediumCategories = text.decodeMS(mediumCategories); - keywordUtil = new KeywordUtils(); - var kwd = keywordUtil.createKeyword("COMM.MEDIUM"); - kwd.filter(function(id, name, customs){ - return mediumCategories.indexOf(customs.category) > -1; - }); - mediumIds = kwd.toArray("id"); - if (mediumIds.length == 0) - throw new Error();//TODO: add message - - cond += " and COMM.MEDIUM_ID in (" + mediumIds.join(", ") + ")"; - } -} - -result.string(cond ? "1 = 1 " + cond: "1 = 2"); \ No newline at end of file +import("system.db"); +import("system.logging"); +import("system.text"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); +import("Keyword_lib"); + +var cond, relId, mediumCategories, keywordUtil, condStr; + +cond = new SqlCondition(); +if(vars.exists("$param.RelId_param")){ + relId = vars.get("$param.RelId_param"); + + if (relId != null && relId != ""){ + cond.andPrepare("COMM.RELATION_ID", "# = ?", relId); + } +} + +if (vars.exists("$param.MediumCategoriesFilter_param")){ + mediumCategories = vars.get("$param.MediumCategoriesFilter_param"); + if (mediumCategories != null && mediumCategories != "") { + mediumCategories = text.decodeMS(mediumCategories); + keywordUtil = new KeywordUtils(); + var kwd = keywordUtil.createKeyword("COMM.MEDIUM"); + kwd.filter(function(id, name, customs){ + return mediumCategories.indexOf(customs.category) > -1; + }); + mediumIds = kwd.toArray("id"); + if (mediumIds.length == 0) + throw new Error();//TODO: add message + + cond.and("COMM.MEDIUM_ID in (" + mediumIds.join(", ") + ")"); + } +} + +condStr = db.translateCondition([cond.toString("1 = 2"), cond.preparedValues]);//TODO: this should not be necessary in the future +result.string(condStr); \ No newline at end of file diff --git a/entity/Comm_entity/entityfields/addr/contentTypeProcess.js b/entity/Comm_entity/entityfields/addr/contentTypeProcess.js index 06a2fe06be4ffc09f15cfc7d2fcc671bdf6456dc..d447305cf063f92a6dc121a43b9a4df1f5f706b7 100644 --- a/entity/Comm_entity/entityfields/addr/contentTypeProcess.js +++ b/entity/Comm_entity/entityfields/addr/contentTypeProcess.js @@ -3,26 +3,12 @@ import("system.vars"); import("system.result"); import("system.neon"); -var keywordUtils, category, medium, contentType; +var keywordUtils, medium, contentType; //TODO: add constants for contentTypes #1022547 medium = vars.get("$field.MEDIUM_ID"); if (medium){ keywordUtils = new KeywordUtils(); - category = keywordUtils.createKeyword("COMM.MEDIUM").getPropForKey(medium, "category", true); - switch (category) { - case "PHONE": - contentType = "TELEPHONE"; - break; - case "EMAIL": - contentType = "EMAIL"; - break; - case "WEBSITE": - contentType = "LINK"; - break; - default: - contentType = "TEXT"; - break; - } + contentType = keywordUtils.createKeyword("COMM.MEDIUM").getPropForKey(medium, "contentType", true) || "TEXT"; } else { contentType = "TEXT"; diff --git a/entity/Comm_entity/entityfields/addr/onValidation.js b/entity/Comm_entity/entityfields/addr/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..b99bc84225439980d4ed10a88a6a45f9f30c082a --- /dev/null +++ b/entity/Comm_entity/entityfields/addr/onValidation.js @@ -0,0 +1,23 @@ +import("system.logging"); +import("system.translate"); +import("system.vars"); +import("system.net"); +import("system.result"); +import("system.mail"); +import("Keyword_lib"); +import("Comm_lib"); + +var kwdUtil = new KeywordUtils(); +var kwd = kwdUtil.createKeyword("COMM.MEDIUM"); +var commMedium = vars.get("$field.MEDIUM_ID"); +var commCategory = kwd.getPropForKey(commMedium, "contentType", true);//TODO: maybe accessible via $property - then it's not needed to keep this information within the keyword + +var fn = CommValidationUtil.makeValidationFn(commCategory); +if (fn != null){ + var commAddr = vars.get("$local.value");//contains the entered value - the field contains the value only after successfull validation + var additional = CommValidationUtil.getExtensionsBlueprint(); + additional.countryCode = vars.get("$param.RelationsMainCountry_param");//TODO: try to use users language first and then the companies + var res = fn.call(null, commAddr, additional); + if (res != null) + result.string(res); +} \ No newline at end of file diff --git a/entity/Comm_entity/entityfields/medium_id/possibleItemsProcess.js b/entity/Comm_entity/entityfields/medium_id/possibleItemsProcess.js index f73dccbca8682450c0237f4b5af827e2d2ae6182..a5f76ab6c894de82dbf14e1c0dcbfd4c21f2b82e 100644 --- a/entity/Comm_entity/entityfields/medium_id/possibleItemsProcess.js +++ b/entity/Comm_entity/entityfields/medium_id/possibleItemsProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.text"); import("system.vars"); import("system.result"); @@ -6,7 +7,7 @@ import("Keyword_lib"); var mediumCategories, kwdUtils, kwd, items; kwdUtils = new KeywordUtils(); -if (vars.exists("$param.MediumCategoriesFilter_param") && (mediumCategories = vars.get("$param.MediumCategoriesFilter_param")) != null){ +if (vars.exists("$param.MediumCategoriesFilter_param") && (mediumCategories = vars.get("$param.MediumCategoriesFilter_param")) != ""){ mediumCategories = text.decodeMS(mediumCategories); kwd = kwdUtils.createKeyword("COMM.MEDIUM"); kwd.filter(function(id, name, customs){ diff --git a/entity/Comm_entity/entityfields/relationsmaincountry_param/code.js b/entity/Comm_entity/entityfields/relationsmaincountry_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..c14118ef254f82f6bbb35c3d32ca5974b113a1d0 --- /dev/null +++ b/entity/Comm_entity/entityfields/relationsmaincountry_param/code.js @@ -0,0 +1,22 @@ +import("system.result"); +import("system.db"); +import("system.logging"); +import("system.vars"); +import("Sql_lib"); + +var relId, country; + +if (vars.exists("$param.RelId_param")) { + relId = vars.get("$param.RelId_param"); + if (relId != "" && relId != null){ + var cond = new SqlCondition(); + cond.andPrepare("RELATION.RELATIONID", "# = ?", relId); + //TODO: this should happen by 1:1 links instead of manually requesting the data by a select + country = db.cell(["select ADDRESS.COUNTRY from ADDRESS " + + "join RELATION on RELATION.ADDRESS_ID = ADDRESS.ADDRESSID " + + cond.toWhereString(), cond.preparedValues]); + + if (country != "") + result.string(country); + } +} \ No newline at end of file diff --git a/entity/Contract_entity/Contract_entity.aod b/entity/Contract_entity/Contract_entity.aod index cc82300d0986c441f01a2b044ab91312c9d7193c..c5490d13fc0d111ef418228350c0751ccfe53cbe 100644 --- a/entity/Contract_entity/Contract_entity.aod +++ b/entity/Contract_entity/Contract_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Contract_entity</name> <title>Contract</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Countries_Entity/Countries_Entity.aod b/entity/Countries_Entity/Countries_Entity.aod index d41286d9045f3cfbf9d979d9f3db16566777d6da..f9778cb9e1d98bd905af70b406ce7406451674c2 100644 --- a/entity/Countries_Entity/Countries_Entity.aod +++ b/entity/Countries_Entity/Countries_Entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Countries_Entity</name> <title>Countries</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Gender_keyword/Gender_keyword.aod b/entity/Gender_keyword/Gender_keyword.aod index 044ab6dfe51ff3ae9dfd2a92cbf65f8601c750da..4f487bf216e65e2c3c9073aeb28478971e9c2800 100644 --- a/entity/Gender_keyword/Gender_keyword.aod +++ b/entity/Gender_keyword/Gender_keyword.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Gender_keyword</name> <majorModelMode>DISTRIBUTED</majorModelMode> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> diff --git a/entity/History_entity/History_entity.aod b/entity/History_entity/History_entity.aod index 9d4131bdaf67a55f19ea7f277342545576757948..fe9f04dc945a48ba9a0fd0a7aa9df43fb2d57a25 100644 --- a/entity/History_entity/History_entity.aod +++ b/entity/History_entity/History_entity.aod @@ -1,17 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>History_entity</name> <title>History</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <recordContainerType>DB</recordContainerType> - <caption>History</caption> - <iconId>NEON:HISTORY</iconId> - <imageProcess>%aditoprj%/entity/History_entity/imageProcess.js</imageProcess> <alias>Data_alias</alias> <fromClauseProcess>%aditoprj%/entity/History_entity/fromClauseProcess.js</fromClauseProcess> <conditionProcess>%aditoprj%/entity/History_entity/conditionProcess.js</conditionProcess> <onDBInsert>%aditoprj%/entity/History_entity/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/History_entity/onDBDelete.js</onDBDelete> + <recordContainerType>DB</recordContainerType> + <caption>History</caption> + <iconId>NEON:HISTORY</iconId> + <imageProcess>%aditoprj%/entity/History_entity/imageProcess.js</imageProcess> <entityFields> <entityField> <name>DIRECTION</name> diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 3fcc7bafc9d8cf36c79a38e03f1de41d71b27cd3..a5e954badf21f6d01a0656b6d78f039c397a88a7 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Offer_entity</name> <title>Offer</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index 1b5b708ced210c497497f8a9b241ce03c0be477b..206e426134b28f34b15c6b34a01f84f74246e0cc 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Offeritem_entity</name> <title>Offeritem</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Options_Entity/Options_Entity.aod b/entity/Options_Entity/Options_Entity.aod index a1f5e63ded38ae5869c80e41f31aadb12810c588..3712683649290ce89c0daff0f3803bfec96b3362 100644 --- a/entity/Options_Entity/Options_Entity.aod +++ b/entity/Options_Entity/Options_Entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Options_Entity</name> <title>Options</title> <description></description> diff --git a/entity/Org_entity/Org_entity.aod b/entity/Org_entity/Org_entity.aod index 4807ae7a89ab1c194c3a78b40d896af4f3b64b96..857f8573e8b1395215ce18af443c5a5049fcc7da 100644 --- a/entity/Org_entity/Org_entity.aod +++ b/entity/Org_entity/Org_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Org_entity</name> <title>Company</title> <majorModelMode>DISTRIBUTED</majorModelMode> @@ -51,6 +51,7 @@ <tableName>ORG</tableName> <columnName>NAME</columnName> <caption>Name</caption> + <mandatory v="true" /> </entityField> <entityField> <name>ORGID</name> @@ -259,6 +260,66 @@ </entityParameter> </children> </entityOutgoingField> + <entityOutgoingField> + <name>OrgCommEmail_dfo</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <caption>Communication E-Mail</caption> + <dependency> + <name>dependency</name> + <entityName>Comm_entity</entityName> + <fieldName>#INCOMING</fieldName> + </dependency> + <children> + <entityParameter> + <name>RelId_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommemail_dfo/children/relid_param/code.js</code> + </entityParameter> + <entityParameter> + <name>MediumCategoriesFilter_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommemail_dfo/children/mediumcategoriesfilter_param/code.js</code> + </entityParameter> + </children> + </entityOutgoingField> + <entityOutgoingField> + <name>OrgCommPhone_dfo</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <caption>Communication Phone</caption> + <dependency> + <name>dependency</name> + <entityName>Comm_entity</entityName> + <fieldName>#INCOMING</fieldName> + </dependency> + <children> + <entityParameter> + <name>RelId_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommphone_dfo/children/relid_param/code.js</code> + </entityParameter> + <entityParameter> + <name>MediumCategoriesFilter_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommphone_dfo/children/mediumcategoriesfilter_param/code.js</code> + </entityParameter> + </children> + </entityOutgoingField> + <entityOutgoingField> + <name>OrgCommOthers_dfo</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <caption>Communication Other</caption> + <dependency> + <name>dependency</name> + <entityName>Comm_entity</entityName> + <fieldName>#INCOMING</fieldName> + </dependency> + <children> + <entityParameter> + <name>RelId_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommothers_dfo/children/relid_param/code.js</code> + </entityParameter> + <entityParameter> + <name>MediumCategoriesFilter_param</name> + <code>%aditoprj%/entity/Org_entity/entityfields/orgcommothers_dfo/children/mediumcategoriesfilter_param/code.js</code> + </entityParameter> + </children> + </entityOutgoingField> <entityOutgoingField> <name>OrgContract_dfo</name> <fieldType>DEPENDENCY_OUT</fieldType> diff --git a/entity/Org_entity/entityfields/orgcommemail_dfo/children/mediumcategoriesfilter_param/code.js b/entity/Org_entity/entityfields/orgcommemail_dfo/children/mediumcategoriesfilter_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..aaff61e4c8898ae395726ecc423de32a449ffedb --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommemail_dfo/children/mediumcategoriesfilter_param/code.js @@ -0,0 +1,4 @@ +import("system.text"); +import("system.result"); + +result.string(text.encodeMS(["EMAIL"])); diff --git a/entity/Org_entity/entityfields/orgcommemail_dfo/children/relid_param/code.js b/entity/Org_entity/entityfields/orgcommemail_dfo/children/relid_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..c618e8d6e5ce719d68e284f7c5b4b050c95b25d3 --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommemail_dfo/children/relid_param/code.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.RELATIONID")); \ No newline at end of file diff --git a/entity/Org_entity/entityfields/orgcommothers_dfo/children/mediumcategoriesfilter_param/code.js b/entity/Org_entity/entityfields/orgcommothers_dfo/children/mediumcategoriesfilter_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..4f54b7ffc8acbf3d404f6d45dea8b79e991ca573 --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommothers_dfo/children/mediumcategoriesfilter_param/code.js @@ -0,0 +1,4 @@ +import("system.text"); +import("system.result"); + +result.string(text.encodeMS(["OTHER"])); diff --git a/entity/Org_entity/entityfields/orgcommothers_dfo/children/relid_param/code.js b/entity/Org_entity/entityfields/orgcommothers_dfo/children/relid_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..c618e8d6e5ce719d68e284f7c5b4b050c95b25d3 --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommothers_dfo/children/relid_param/code.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.RELATIONID")); \ No newline at end of file diff --git a/entity/Org_entity/entityfields/orgcommphone_dfo/children/mediumcategoriesfilter_param/code.js b/entity/Org_entity/entityfields/orgcommphone_dfo/children/mediumcategoriesfilter_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..10d8f95a8428f41e01924b5a23ed0082fed74b2f --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommphone_dfo/children/mediumcategoriesfilter_param/code.js @@ -0,0 +1,4 @@ +import("system.text"); +import("system.result"); + +result.string(text.encodeMS(["PHONE"])); diff --git a/entity/Org_entity/entityfields/orgcommphone_dfo/children/relid_param/code.js b/entity/Org_entity/entityfields/orgcommphone_dfo/children/relid_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..c618e8d6e5ce719d68e284f7c5b4b050c95b25d3 --- /dev/null +++ b/entity/Org_entity/entityfields/orgcommphone_dfo/children/relid_param/code.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.RELATIONID")); \ No newline at end of file diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod index 53eefff3e9a0536965f4a03d72fe853d1d0e2104..a564609fab5bf434e8475e3ae7174071b01902d3 100644 --- a/entity/Pers_entity/Pers_entity.aod +++ b/entity/Pers_entity/Pers_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Pers_entity</name> <title>Contact</title> <majorModelMode>DISTRIBUTED</majorModelMode> @@ -49,7 +49,6 @@ <columnName>GENDER</columnName> <caption>Gender</caption> <outgoingField>PersGender_dfo</outgoingField> - <possibleItemsProcess>%aditoprj%/entity/Pers_entity/entityfields/gender/possibleItemsProcess.js</possibleItemsProcess> </entityField> <entityField> <name>LASTNAME</name> @@ -391,21 +390,29 @@ <entityIncomingField> <name>#INCOMING</name> </entityIncomingField> + <entityField> + <name>LANGUAGE</name> + <tableName>RELATION</tableName> + <columnName>LANGUAGE</columnName> + <caption>Language</caption> + <mandatory v="true" /> + <possibleItemsProcess>%aditoprj%/entity/Pers_entity/entityfields/language/possibleItemsProcess.js</possibleItemsProcess> + </entityField> </entityFields> <linkInformation> <linkInformation> - <name>ffff1758-e84e-47d8-a957-5989d0be7092</name> + <name>9ce0dfd2-192d-4446-8b2d-a4c053abc44a</name> <tableName>PERS</tableName> <primaryKey>PERSID</primaryKey> </linkInformation> <linkInformation> - <name>5547b8d7-5145-4eb7-8698-c92674b4691f</name> + <name>348312a8-6392-4adb-af69-75cbcfc5b65b</name> <tableName>RELATION</tableName> <primaryKey>RELATIONID</primaryKey> <isUIDTable v="true" /> </linkInformation> <linkInformation> - <name>dae8e70a-ec76-4c53-9799-ee04bfbe3bd2</name> + <name>edf5e4f3-993d-4097-b59d-a100d5222cad</name> <tableName>ORG</tableName> <primaryKey>ORGID</primaryKey> <readonly v="true" /> diff --git a/entity/Pers_entity/entityfields/gender/possibleItemsProcess.js b/entity/Pers_entity/entityfields/gender/possibleItemsProcess.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/entity/Pers_entity/entityfields/language/possibleItemsProcess.js b/entity/Pers_entity/entityfields/language/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..26992f2c6cfc67f4cbfae11030af30b34b7c553d --- /dev/null +++ b/entity/Pers_entity/entityfields/language/possibleItemsProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("Keyword_lib"); + +var kwdUtils, items; + +kwdUtils = new KeywordUtils(); +items = kwdUtils.getStandardArray("LANGUAGE"); +result.object(items); \ No newline at end of file diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod index 02d326e17c0fcd179f2cdcd9f38317894c43f969..b329898832b46fcb125df74c5839e5ec55f51c0d 100644 --- a/entity/Product_entity/Product_entity.aod +++ b/entity/Product_entity/Product_entity.aod @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Product_entity</name> <title>Product</title> <majorModelMode>DISTRIBUTED</majorModelMode> + <alias>Data_alias</alias> <recordContainerType>DB</recordContainerType> <caption>Product</caption> <iconId>VAADIN:HAMMER</iconId> - <alias>Data_alias</alias> <entityFields> <entityField> <name>ADVERTISING</name> diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod index 18c204977a78bd7d91d1261dd0a6f805b6d741c7..029ac867926eab7b3e24021a7b42cd0b3202cbbe 100644 --- a/entity/Productprice_entity/Productprice_entity.aod +++ b/entity/Productprice_entity/Productprice_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Productprice_entity</name> <title>Price list</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index 2398361961635ff3eb850c159d96d34527f31ea7..f81960ed2babb095dd7430b9bb443b2d9c4815f7 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Salesproject_entity</name> <title>Salesproject</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/entity/Social_entity/Social_entity.aod b/entity/Social_entity/Social_entity.aod index 787822ab61170dafd42eb8cb733ed51144a495d4..4b500fab944187cb9e8fd43ded8a56f35b2d75b8 100644 --- a/entity/Social_entity/Social_entity.aod +++ b/entity/Social_entity/Social_entity.aod @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Social_entity</name> <title>Social</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <recordContainerType>NONE</recordContainerType> - <caption>Social Media</caption> <indexGroup></indexGroup> <patternExtensionProcess></patternExtensionProcess> <fields> <element>UID</element> </fields> <contentProcess>%aditoprj%/entity/Social_entity/contentProcess.js</contentProcess> + <recordContainerType>NONE</recordContainerType> + <caption>Social Media</caption> <entityFields> <entityField> <name>TWITTER_TIMELINE</name> diff --git a/entity/Stock_entity/Stock_entity.aod b/entity/Stock_entity/Stock_entity.aod index 72a126bb04dd0ff96c22a297fea745d32c5cae08..4942e5aa72153edeca4529e1cdf8f8058f038173 100644 --- a/entity/Stock_entity/Stock_entity.aod +++ b/entity/Stock_entity/Stock_entity.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.3"> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.4"> <name>Stock_entity</name> <title>Stock</title> <majorModelMode>DISTRIBUTED</majorModelMode> diff --git a/neonDashboard/MeinDashboard/MeinDashboard.aod b/neonDashboard/MeinDashboard/MeinDashboard.aod index d2a8c2df1da95467d60cc67beebeb40bef8056ed..de416ab86fe483a5903d9d702aeeb8a306f00fe4 100644 --- a/neonDashboard/MeinDashboard/MeinDashboard.aod +++ b/neonDashboard/MeinDashboard/MeinDashboard.aod @@ -4,4 +4,5 @@ <title>My Dashboard</title> <majorModelMode>DISTRIBUTED</majorModelMode> <dashboardType>PRIVATE</dashboardType> + <editRoles /> </neonDashboard> diff --git a/neonDashboard/Vertriebsdashboard/Vertriebsdashboard.aod b/neonDashboard/Vertriebsdashboard/Vertriebsdashboard.aod index 8f01de2d20ab81e587c3cfe261f3b67dc59426c2..a7641475646fffc9c37ef2ece0d2b07e35348f32 100644 --- a/neonDashboard/Vertriebsdashboard/Vertriebsdashboard.aod +++ b/neonDashboard/Vertriebsdashboard/Vertriebsdashboard.aod @@ -5,6 +5,10 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <icon>NEON:LOGO_A</icon> <dashboardType>PUBLIC</dashboardType> + <editRoles> + <element>INTERNAL_ADMINISTRATOR</element> + <element>INTERNAL_DASHBOARDSTOREADMIN</element> + </editRoles> <defaultDashlets> <neonDashlet> <name>Dashlet</name> diff --git a/neonView/AppointmentEdit_view/AppointmentEdit_view.aod b/neonView/AppointmentEdit_view/AppointmentEdit_view.aod index a80f04ceffa196310967e8a535a745851e961642..c945aba0b43d4d13ccd561599540f729941b0268 100644 --- a/neonView/AppointmentEdit_view/AppointmentEdit_view.aod +++ b/neonView/AppointmentEdit_view/AppointmentEdit_view.aod @@ -21,7 +21,13 @@ <categoriesField>CATEGORIES</categoriesField> <alldayField>ALLDAY</alldayField> <transparencyField>TRANSPARENCY</transparencyField> + <organizerField>ORGANIZER</organizerField> <favoriteActionGroup1>PartStatActionGroup</favoriteActionGroup1> + <rruleField>RRULE</rruleField> + <recurrenceIdField>RECURRENCEID</recurrenceIdField> + <saveScopeField>SAFESCOPEFIELD</saveScopeField> + <masterBeginField>MASTERBEGIN</masterBeginField> + <masterEndField>MASTEREND</masterEndField> <entityField>#ENTITY</entityField> </appointmentEditViewTemplate> </children> diff --git a/neonView/AppointmentPreview_view/AppointmentPreview_view.aod b/neonView/AppointmentPreview_view/AppointmentPreview_view.aod index 1a532790b8f9277ff1a89f47d72a9a420991e996..d8ed98ea586d51ac7bf868ba55acea911292fe29 100644 --- a/neonView/AppointmentPreview_view/AppointmentPreview_view.aod +++ b/neonView/AppointmentPreview_view/AppointmentPreview_view.aod @@ -20,8 +20,8 @@ <transparencyField>TRANSPARENCY</transparencyField> <statusField>STATUS</statusField> <locationField>LOCATION</locationField> + <organizerField>ORGANIZER</organizerField> <categoriesField>CATEGORIES</categoriesField> - <favoriteActionGroup1>PartStatActionGroup</favoriteActionGroup1> <entityField>#ENTITY</entityField> </appointmentPreviewViewTemplate> </children> diff --git a/neonView/OrgPreview_view/OrgPreview_view.aod b/neonView/OrgPreview_view/OrgPreview_view.aod index 2807fd672f1b75ef82268bceb91ba7827f7919db..dfa831fca34615d5f91a0f9de35496517147640b 100644 --- a/neonView/OrgPreview_view/OrgPreview_view.aod +++ b/neonView/OrgPreview_view/OrgPreview_view.aod @@ -1,52 +1,62 @@ -<?xml version="1.0" encoding="UTF-8"?> -<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0"> - <name>OrgPreview_view</name> - <majorModelMode>DISTRIBUTED</majorModelMode> - <layout> - <boxLayout> - <name>layout</name> - </boxLayout> - </layout> - <children> - <cardViewTemplate> - <name>BasicCard_template</name> - <iconField>IMAGE</iconField> - <titleField>NAME</titleField> - <descriptionField>CUSTOMERCODE_DISPLAY_fieldGroup</descriptionField> - <entityField>#ENTITY</entityField> - </cardViewTemplate> - <neonViewReference> - <name>df605bb6-5d18-4233-abc0-1da82e4910ca</name> - <entityField>OrgAddress_dfo</entityField> - <view>AddressList_view</view> - </neonViewReference> - <neonViewReference> - <name>7fbd6034-4213-41f9-bb0d-c73d55b88d82</name> - <entityField>OrgComm_dfo</entityField> - <view>CommList_view</view> - </neonViewReference> - <genericViewTemplate> - <name>OrgInfo_template</name> - <showDrawer v="true" /> - <entityField>#ENTITY</entityField> - <fields> - <entityFieldLink> - <name>4bad7219-1a3a-4e6e-ae5a-533d3acb6845</name> - <entityField>LANGUAGE</entityField> - </entityFieldLink> - <entityFieldLink> - <name>5a397737-2768-4e16-8c58-890b8a26b4a2</name> - <entityField>STATUS</entityField> - </entityFieldLink> - <entityFieldLink> - <name>89e9aa74-1568-4f74-b42a-a02b13752802</name> - <entityField>TYPE</entityField> - </entityFieldLink> - <entityFieldLink> - <name>180e8467-4eb2-4f89-a59f-ff76b8810925</name> - <entityField>INFO</entityField> - </entityFieldLink> - </fields> - </genericViewTemplate> - </children> -</neonView> +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0"> + <name>OrgPreview_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <cardViewTemplate> + <name>BasicCard_template</name> + <iconField>IMAGE</iconField> + <titleField>NAME</titleField> + <descriptionField>CUSTOMERCODE_DISPLAY_fieldGroup</descriptionField> + <entityField>#ENTITY</entityField> + </cardViewTemplate> + <neonViewReference> + <name>df605bb6-5d18-4233-abc0-1da82e4910ca</name> + <entityField>OrgAddress_dfo</entityField> + <view>AddressList_view</view> + </neonViewReference> + <genericViewTemplate> + <name>OrgInfo_template</name> + <showDrawer v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>4bad7219-1a3a-4e6e-ae5a-533d3acb6845</name> + <entityField>LANGUAGE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>5a397737-2768-4e16-8c58-890b8a26b4a2</name> + <entityField>STATUS</entityField> + </entityFieldLink> + <entityFieldLink> + <name>89e9aa74-1568-4f74-b42a-a02b13752802</name> + <entityField>TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>180e8467-4eb2-4f89-a59f-ff76b8810925</name> + <entityField>INFO</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + <neonViewReference> + <name>7b3f1253-f671-4cf4-83ec-81e229910014</name> + <entityField>OrgCommEmail_dfo</entityField> + <view>CommList_view</view> + </neonViewReference> + <neonViewReference> + <name>23f420cb-fd45-433f-b385-55a49e98744f</name> + <entityField>OrgCommPhone_dfo</entityField> + <view>CommList_view</view> + </neonViewReference> + <neonViewReference> + <name>c45d71cf-b81f-4d75-876d-7f9c26b1eb12</name> + <entityField>OrgCommOthers_dfo</entityField> + <view>CommList_view</view> + </neonViewReference> + </children> +</neonView> diff --git a/neonView/PersEdit_view/PersEdit_view.aod b/neonView/PersEdit_view/PersEdit_view.aod index 95b00ae97314c2df0b4ce8de2d68381ea52db2ba..57bba3ca2f7c0820868ce9810333c1f92f931340 100644 --- a/neonView/PersEdit_view/PersEdit_view.aod +++ b/neonView/PersEdit_view/PersEdit_view.aod @@ -48,6 +48,10 @@ <name>74de507e-75e0-4957-a4fb-7070fa3c5a4a</name> <entityField>DATEOFBIRTH</entityField> </entityFieldLink> + <entityFieldLink> + <name>d8d04e36-de46-48a3-994a-fa72d1f2ea89</name> + <entityField>LANGUAGE</entityField> + </entityFieldLink> </fields> </genericViewTemplate> <neonViewReference> diff --git a/neonView/PersFilter_view/PersFilter_view.aod b/neonView/PersFilter_view/PersFilter_view.aod index b8f86322d84be98eeb9378ec3f60e9846e428644..ec8bc3ee05333157dfc2d475a88446d6f4b00a3a 100644 --- a/neonView/PersFilter_view/PersFilter_view.aod +++ b/neonView/PersFilter_view/PersFilter_view.aod @@ -29,6 +29,9 @@ <children> <tableViewTemplate> <name>PersFilter_template</name> + <favoriteActionGroup1>MyActions</favoriteActionGroup1> + <favoriteActionGroup2>ServusGruppe</favoriteActionGroup2> + <favoriteActionGroup3>HalloGruppe</favoriteActionGroup3> <showHeader v="true" /> <entityField>#ENTITY</entityField> <columns> diff --git a/neonView/PersPreview_view/PersPreview_view.aod b/neonView/PersPreview_view/PersPreview_view.aod index a3b9ca8a3a46aa3e518431f883cebd728a8991b6..786aef8c3fe8ac185a6b7205425777566f88d9b1 100644 --- a/neonView/PersPreview_view/PersPreview_view.aod +++ b/neonView/PersPreview_view/PersPreview_view.aod @@ -66,6 +66,10 @@ <name>5d4e0828-b7fe-4f54-a47a-f9b5838fb1ae</name> <entityField>DATEOFBIRTH</entityField> </entityFieldLink> + <entityFieldLink> + <name>3aa3e89b-91ce-4607-8d76-53ee309a688f</name> + <entityField>LANGUAGE</entityField> + </entityFieldLink> </fields> </genericViewTemplate> </children> diff --git a/others/db_changes/liquibase.properties b/others/db_changes/liquibase.properties deleted file mode 100644 index b917cc1a5872fa27939ecd9f8bc97b27b49003cb..0000000000000000000000000000000000000000 --- a/others/db_changes/liquibase.properties +++ /dev/null @@ -1,8 +0,0 @@ -driver=org.apache.derby.jdbc.ClientDriver -classpath=jdbc/derbyclient-10.14.1.0.jar -url=jdbc:derby://127.0.0.1:1527/basic_data -username=adito -password=adito - - -changeLogFile=masterChangelog.xml \ No newline at end of file diff --git a/others/db_changes/masterChangelog.xml b/others/db_changes/masterChangelog.xml index f7675a5a11231d93c5990ac14ae410754bccb997..13278709b581a055601de549c2c09d3a5d4cbf95 100644 --- a/others/db_changes/masterChangelog.xml +++ b/others/db_changes/masterChangelog.xml @@ -1,6 +1,6 @@ <?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"> - <include file="struct/Create_Pers.xml"/> + <include file="struct/create_pers.xml"/> <include file="struct/create_org.xml"/> <include file="struct/create_history.xml"/> <include file="struct/1022526_orgChange.xml"/> diff --git a/others/db_changes/struct/create_org.xml b/others/db_changes/struct/create_org.xml index ae2a69496b565e19534cbb7dd669833be0129d75..a7fae3e18c4b0ecae19a04586ad5a33f592f6073 100644 --- a/others/db_changes/struct/create_org.xml +++ b/others/db_changes/struct/create_org.xml @@ -2,7 +2,9 @@ <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="j.goderbauer" id="1528803466364-1"> <createTable tableName="ORG"> - <column name="NAME" type="NVARCHAR(255)"/> + <column name="NAME" type="NVARCHAR(255)"> + <constraints nullable="false"/> + </column> <column name="INFO" type="NCLOB"/> <column name="TYPE" type="SMALLINT"/> <column name="CUSTOMERCODE" type="VARCHAR(30)"/> diff --git a/others/db_changes/struct/Create_Pers.xml b/others/db_changes/struct/create_pers.xml similarity index 91% rename from others/db_changes/struct/Create_Pers.xml rename to others/db_changes/struct/create_pers.xml index 2fc0b35392db9b5e910225760dd710850b544013..8fdd0ff9eb3b21528732f9bea02f18867447d3cc 100644 --- a/others/db_changes/struct/Create_Pers.xml +++ b/others/db_changes/struct/create_pers.xml @@ -12,7 +12,9 @@ <column name="USER_NEW" type="VARCHAR(50)"/> <column name="FIRSTNAME" type="VARCHAR(50)"/> <column name="MIDDLENAME" type="VARCHAR(50)"/> - <column name="LASTNAME" type="VARChAR(50)"/> + <column name="LASTNAME" type="VARCHAR(50)"> + <constraints nullable="false"/> + </column> <column name="GENDER" type="VARCHAR(50)"/> <column name="SALUTATION" type="VARCHAR(16)"/> <column name="TITLE" type="VARCHAR(50)"/> diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index 9fb33b2728fdfd126836bddb26f10b1287064351..1ea4864f5a73c766384a342cda26de47674bc33e 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -2,7 +2,7 @@ <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.1"> <name>_____PREFERENCES_PROJECT</name> <majorModelMode>DISTRIBUTED</majorModelMode> - <projectName>xRM-Basic 5</projectName> + <projectName>xRM-Basic-5-1</projectName> <jditoMaxContentSize v="57671680" /> <calendarCategoriesEvent> <entry> diff --git a/process/Appointment_lib/process.js b/process/Appointment_lib/process.js index 43f7d1b94279811306a1cc3eed25e5cb5fe0c90d..476a993b04c8dc887aee6b8479fb1ff8fd49b519 100644 --- a/process/Appointment_lib/process.js +++ b/process/Appointment_lib/process.js @@ -62,13 +62,10 @@ function AppointmentUtils() } - this.sendExchangedAction = function(event) + this.sendExchangedAction = function(event, newState) { - if( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS ) - { - event["X-ADITO-STATUSACTION"] = "ACCEPT"; // "ACCEPT", "DECLINE", "" - event[calendars.AFFECTEDUSERS] = ""; - calendars.updateEntry(event); - } + event["X-ADITO-STATUSACTION"] = newState; // "ACCEPT", "DECLINE", "" + event[calendars.AFFECTEDUSERS] = ""; + calendars.updateEntry(event); } } \ No newline at end of file diff --git a/process/Comm_lib/Comm_lib.aod b/process/Comm_lib/Comm_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..21ab969d90c667d39fe448d4805b9a95d4994f69 --- /dev/null +++ b/process/Comm_lib/Comm_lib.aod @@ -0,0 +1,6 @@ +<?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.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7"> + <name>Comm_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/Comm_lib/process.js</process> +</process> diff --git a/process/Comm_lib/process.js b/process/Comm_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..84b969d635c72e28ad7bffdd2f8b4a03424232b6 --- /dev/null +++ b/process/Comm_lib/process.js @@ -0,0 +1,65 @@ +import("system.translate"); +import("system.net"); +import("system.mail"); +import("system.cti"); + + +/** + * provides somehow static methods for validation of communication data + * do not create an instance of this + */ +function CommValidationUtil(){ +} + +/** + * creates a function depending on a given COMM-category (like PHONE, EMAIL, etc.) or null if no validation-function was defined for the given category + * @param {string} commCategory category that determines which function shall be created, e.g. "EMAIL" + * @return {function} function that receives the following arguments: + * <br/> - commAddress + * <br/> - extensions + * <br/>the function has to return null if everything is OK or a value with details if validation failed + */ +CommValidationUtil.makeValidationFn = function (commCategory){ + var callbackFn; + + switch (commCategory) { + case "EMAIL": + callbackFn = function (addrValue){ +// if (!mail.isValidMailAddress(addrValue)) //TODO: enable JDito-methods +// return translate.text("no valid mail-address format"); + return null; + } + break; + case "LINK": + callbackFn = function (addrValue){ +// if (!net.isValidUrl(addrValue, ["http", "https"]))//TODO: enable JDito-methods +// return translate.text("no valid format"); + return null; + } + break; + case "TELEPHONE": + callbackFn = function (addrValue, ext){ + var country = null; + if (addrValue[0] != "+") //if the number starts with a country-identifier (e.g. +49) no country needs to be specified + country = ext.countryCode; +// if (!cti.isValidPhoneNumber(addrValue, country))//TODO: enable JDito-methods +// return translate.text("no valid phone number"); + return null; + } + break; + default: + callbackFn = null; + break; + } + return callbackFn; +} + +/** + * returns a blueprint for validation extensions; these extensions are needed for validating comm data and can be passed to other functions + * @return {object} a object with properties that have a specific default value; normally you want to overwrite that value + */ +CommValidationUtil.getExtensionsBlueprint = function(){ + return { + countryCode: null + }; +} diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js index 7e8781529f62f054c579424e158129a7a7a8a0c9..d018fbf41aa3d76b6cc9cfcd2b73a16276a8455e 100644 --- a/process/Keyword_lib/process.js +++ b/process/Keyword_lib/process.js @@ -1,352 +1,354 @@ -import("system.translate"); - -/** - * provides methods for interactions with keywords - */ -function KeywordUtils(){ - /** - * returns the default case for keyword-arrays (id and translated name) - * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" - * @return {Array} a 2D array in form of [["id1", "name1"], ["idN", "nameN"]] - * @example - * var kwdUtils, items; - * - * kwdUtils = new KeywordUtils(); - * items = kwdUtils.getStandardArray("ADDRESS.TYPE"); - * result.object(items); - */ - this.getStandardArray = function(keywordType){ - return this.createKeyword(keywordType).toArray(["id", "name"]); - } - - /** - * returns a specific name (translated) - this is normally the view-value - of a given keyword; - * <br/>if the key could not be found an empty string "" is returned - * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" - * @param {String} key id value of the keyword where the view-value shall be searched - * @return {String} representation of the translated name of the keyword-key - * @example - * var kwdUtils, histMedium; - * histMedium = vars.get("$field.MEDIUM"); - * if (histMedium){ - * kwdUtils = new KeywordUtils(); - * result.string(vars.get("$field.SUBJECT") + " (" + kwdUtils.getViewValue("HISTORY.MEDIUM", histMedium) + ")"); - * } - */ - this.getViewValue = function(keywordType, key){ - var k = this.createKeyword(keywordType); - return k.getPropForKey(key, "name") || ""; - } - - /** - * creates an object with methods for interacting with an specific keyword - * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" - * @return {Object} object with the following methods: - * <br/>- toArray - * <br/>- getPropForKey - * <br/>- getPropsForKey - */ - this.createKeyword = function(keywordType){//TODO: rename ot createKeywordObj? - var valueContainer, _toArrayFn, _getPropForKeyFn, _getPropsForKeyFn; - - switch (keywordType){ - case "RELATION.STATUS": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Inactive")) - ,createKeywordEntry("1", translate.text("Active")) - ,createKeywordEntry("2", translate.text("In review")) - ]); - break; - case "COUNTRY": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("DE", translate.text("Germany")) - ,createKeywordEntry("AT", translate.text("Austria")) - ,createKeywordEntry("CH", translate.text("Switzerland")) - ,createKeywordEntry("GB", translate.text("United Kingdom")) - ,createKeywordEntry("NO", translate.text("Norway")) - ]); - break; - case "LANGUAGE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("de", translate.text("German")) - ,createKeywordEntry("de-DE", translate.text("German (Germany)")) - ,createKeywordEntry("de-AT", translate.text("German (Austria)")) - ,createKeywordEntry("en", translate.text("English")) - ,createKeywordEntry("en-GB", translate.text("English (United Kingdom)")) - ,createKeywordEntry("no-NO", translate.text("Norwegian")) - ]); - break; - case "HISTORY.DIRECTION": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("i", translate.text("Incoming")) - ,createKeywordEntry("o", translate.text("Outgoing")) - ]); - break; - case "HISTORY.MEDIUM": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Visit")) - ,createKeywordEntry("1", translate.text("E-Mail")) - ,createKeywordEntry("2", translate.text("Phone")) - ,createKeywordEntry("3", translate.text("Internal")) - ,createKeywordEntry("4", translate.text("Online-Meeting")) - ]); - case "COMM.MEDIUM": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Mobile"), null, {category: "PHONE"}) - ,createKeywordEntry("1", translate.text("E-Mail"), null, {category: "EMAIL"}) - ,createKeywordEntry("2", translate.text("Phone"), null, {category: "PHONE"}) - ,createKeywordEntry("3", translate.text("Internet"), null, {category: "OTHER"}) - ]); - break; - case "ADDRESS.TYPE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Office address")) - ,createKeywordEntry("2", translate.text("Home address")) - ,createKeywordEntry("3", translate.text("Delivery address")) - ,createKeywordEntry("4", translate.text("Post office box")) - ]); - break; - case "ORG.TYPE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Customer")) - ,createKeywordEntry("1", translate.text("Prospect")) - ,createKeywordEntry("2", translate.text("Supplier")) - ,createKeywordEntry("3", translate.text("Other")) - ]); - break; - case "PERS.GENDER": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("f", translate.text("Female")) - ,createKeywordEntry("m", translate.text("Male")) - ,createKeywordEntry("o", translate.text("${GENDER_OTHER}")) - ]); - break; - case "CONTRACT.CONTRACTTYPE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Framework contract")) - ,createKeywordEntry("1", translate.text("Service contract")) - ,createKeywordEntry("2", translate.text("Maintenance contract")) - ]); - break; - case "CONTRACT.CONTRACTSTATUS": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Valid, unlimited")) - ,createKeywordEntry("1", translate.text("Valid, limited")) - ,createKeywordEntry("2", translate.text("Not signed yet")) - ,createKeywordEntry("3", translate.text("None, individual count")) - ,createKeywordEntry("4", translate.text("Cancelled")) - ]); - break; - case "CONTRACT.PAYMENT": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("0", translate.text("Annually")) - ,createKeywordEntry("1", translate.text("Semiannually")) - ,createKeywordEntry("2", translate.text("Quarterly")) - ]); - break; - case "GROUPCODE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Commodity group 1")) - ,createKeywordEntry("2", translate.text("Commodity group 2")) - ,createKeywordEntry("3", translate.text("Commodity group 3")) - ,createKeywordEntry("4", translate.text("Discount")) - ,createKeywordEntry("5", translate.text("Spare parts")) - ,createKeywordEntry("6", translate.text("Service")) - ]); - break; - case "UNIT": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Pieces")) - ,createKeywordEntry("2", translate.text("Kgs")) - ,createKeywordEntry("3", translate.text("Liter")) - ,createKeywordEntry("4", translate.text("Hours")) - ]); - break; - case "PRICELIST": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("${PRICELIST_DEFAULT}")) - ,createKeywordEntry("2", translate.text("Key account")) - ,createKeywordEntry("3", translate.text("Special price list1")) - ,createKeywordEntry("4", translate.text("${PRICELIST_SERVICE}")) - ]); - break; - case "CURRENCY": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("EUR")) - ,createKeywordEntry("2", translate.text("USD")) - ,createKeywordEntry("3", translate.text("CND")) - ,createKeywordEntry("4", translate.text("CHF")) - ]); - break; - case "STOCK.WAREHOUSE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Warehouse 1")) - ,createKeywordEntry("2", translate.text("Warehouse 2")) - ,createKeywordEntry("3", translate.text("Warehouse 3")) - ]); - break; - case "SALESPROJECT.STATUS": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Open")) - ,createKeywordEntry("2", translate.text("Postponed")) - ,createKeywordEntry("3", translate.text("Aborted")) - ,createKeywordEntry("4", translate.text("Partial order")) - ,createKeywordEntry("5", translate.text("Order")) - ,createKeywordEntry("6", translate.text("Lost")) - ]); - break; - case "SALESPROJECT.PHASE": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Project decision")) - ,createKeywordEntry("2", translate.text("Negotiation")) - ,createKeywordEntry("3", translate.text("Workshop")) - ,createKeywordEntry("4", translate.text("Presentation postprocessing")) - ,createKeywordEntry("5", translate.text("Presentation preparation")) - ,createKeywordEntry("6", translate.text("Statement given")) - ,createKeywordEntry("7", translate.text("Specifications in progress")) - ,createKeywordEntry("8", translate.text("Waiting for request")) - ,createKeywordEntry("9", translate.text("Lead")) - ]); - break; - case "OFFER.PROBABILITY": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("0 %"), null, {percentValue: 0}) - ,createKeywordEntry("2", translate.text("25 %"), null, {percentValue: 25}) - ,createKeywordEntry("3", translate.text("50 %"), null, {percentValue: 50}) - ,createKeywordEntry("4", translate.text("75 %"), null, {percentValue: 75}) - ,createKeywordEntry("5", translate.text("100 %"), null, {percentValue: 100}) - ]); - break; - case "OFFER.STATUS": - valueContainer = createKeywordEntriesContainer([ - createKeywordEntry("1", translate.text("Checked")) - ,createKeywordEntry("2", translate.text("Sent")) - ,createKeywordEntry("3", translate.text("Won")) - ,createKeywordEntry("4", translate.text("Lost")) - ]); - break; - default: - throw new Error(translate.withArguments("[%0]the given keyword \"%1\" has no match with the possible keywordlist", [ - arguments.callee.name, keywordType - ])); - break; - } - - - _getPropForKeyFn = function(key, field, isCustom) { - var keyObject; - if (isCustom) - keyObject = valueContainer[key]["customProperties"]; - else - keyObject = valueContainer[key]; - - if (keyObject == undefined) - return undefined; - return keyObject[field]; - }; - - _getPropsForKeyFn = function(key, fields) { - var keyObject, i, l, currentRow, currentField; - - keyObject = valueContainer[key]; - if (keyObject == undefined) - return [];//TODO: throw error instead? - l = fields.length; - currentRow = []; - for (i = 0; i < l; i++){ - currentField = fields[i]; - //check if the passed fieldnames match the existing fieldnames (<=> properties in the object) - //to prevent errors and unexpected behaviour - if (keyObject[currentField]) - currentRow.push(keyObject[currentField]); - else - currentRow.push(""); - } - return currentRow; - }; - - _toArrayFn = function(fields){ - var res, id, currentRow; - - res = []; - if (!fields) - fields = ["id", "name"]; - else if (typeof(fields) == "string"){ - for (id in valueContainer){ - res.push(_getPropForKeyFn(id, fields)); - } - return res; - } - - for (id in valueContainer){ - currentRow = _getPropsForKeyFn(id, fields); - res.push(currentRow); - } - return res; - }; - - return { - /** - * toArray - */ - toArray: _toArrayFn - ,getPropForKey: _getPropForKeyFn - ,getPropsForKey: _getPropsForKeyFn - ,filter: function (callbackFn, thisArg){ - for (id in valueContainer){ - if (false == callbackFn.call(thisArg, valueContainer[id].id, valueContainer[id].name, valueContainer[id].customProperties, - valueContainer[id], valueContainer)){ - delete valueContainer[id]; - } - } - return this; - } - }; - }; - - /** - * internal function for creating an object that represents a keyword entry - * @param {String} id represents the key of an entry; a KeywordEntriesContainer can contain the same key only once - * @param {String} name represents the translated name of an entry; this is in most cases the view-value - * @param {String} [description=""] description text for describing the keyword - * @param {Object} [customProperties=null] an Object with additional properties; these can be virtually anything - * @return {Object} object that represents a single keyword entry; normally severel entries are cumulated in a "keywordEntriesContainer" - */ - function createKeywordEntry(id, name, description, customProperties){ - //TODO: verify if mandatory-checks are really that usefull or can at least be made easier - if (!id) - throw new Error(translate.withArguments("the param \"%0\" in \"%1\" is mandatory and has to be set", [ - "id", arguments.callee.name - ])); - if (!name) - throw new Error(translate.withArguments("the param \"%0\" in \"%1\" is mandatory and has to be set", [ - "name", arguments.callee.name - ])); - - return { - id: id - ,name: name - ,description: description || "" - ,customProperties: customProperties - }; - } - - /** - * internal function for creating an object that represents a container of several keywordEntries - * @param {Array} keywordEntries an Array of keywordEntry-objects (as they are created by "createKeywordEntry" - * @return {Object} object that contains several keywordEntries - */ - function createKeywordEntriesContainer(keywordEntries){ - var res, i, l, id; - - res = {}; - for (i = 0, l = keywordEntries.length; i < l; i++){ - id = keywordEntries[i].id; - if (res[id] != undefined){ - throw new Error("the given id is not unique since it already exists"); - } - res[id] = keywordEntries[i]; - } - return res; - } +import("system.translate"); +import("system.neon"); + +/** + * provides methods for interactions with keywords + */ +function KeywordUtils(){ + /** + * returns the default case for keyword-arrays (id and translated name) + * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" + * @return {Array} a 2D array in form of [["id1", "name1"], ["idN", "nameN"]] + * @example + * var kwdUtils, items; + * + * kwdUtils = new KeywordUtils(); + * items = kwdUtils.getStandardArray("ADDRESS.TYPE"); + * result.object(items); + */ + this.getStandardArray = function(keywordType){ + return this.createKeyword(keywordType).toArray(["id", "name"]); + } + + /** + * returns a specific name (translated) - this is normally the view-value - of a given keyword; + * <br/>if the key could not be found an empty string "" is returned + * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" + * @param {String} key id value of the keyword where the view-value shall be searched + * @return {String} representation of the translated name of the keyword-key + * @example + * var kwdUtils, histMedium; + * histMedium = vars.get("$field.MEDIUM"); + * if (histMedium){ + * kwdUtils = new KeywordUtils(); + * result.string(vars.get("$field.SUBJECT") + " (" + kwdUtils.getViewValue("HISTORY.MEDIUM", histMedium) + ")"); + * } + */ + this.getViewValue = function(keywordType, key){ + var k = this.createKeyword(keywordType); + return k.getPropForKey(key, "name") || ""; + } + + /** + * creates an object with methods for interacting with an specific keyword + * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" + * @return {Object} object with the following methods: + * <br/>- toArray + * <br/>- getPropForKey + * <br/>- getPropsForKey + * <br/>- filter + */ + this.createKeyword = function(keywordType){//TODO: rename ot createKeywordObj? + var valueContainer, _toArrayFn, _getPropForKeyFn, _getPropsForKeyFn; + + switch (keywordType){ + case "RELATION.STATUS": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Inactive")) + ,createKeywordEntry("1", translate.text("Active")) + ,createKeywordEntry("2", translate.text("In review")) + ]); + break; + case "COUNTRY": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("DE", translate.text("Germany")) + ,createKeywordEntry("AT", translate.text("Austria")) + ,createKeywordEntry("CH", translate.text("Switzerland")) + ,createKeywordEntry("GB", translate.text("United Kingdom")) + ,createKeywordEntry("NO", translate.text("Norway")) + ]); + break; + case "LANGUAGE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("de", translate.text("German")) + ,createKeywordEntry("de-DE", translate.text("German (Germany)")) + ,createKeywordEntry("de-AT", translate.text("German (Austria)")) + ,createKeywordEntry("en", translate.text("English")) + ,createKeywordEntry("en-GB", translate.text("English (United Kingdom)")) + ,createKeywordEntry("no-NO", translate.text("Norwegian")) + ]); + break; + case "HISTORY.DIRECTION": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("i", translate.text("Incoming")) + ,createKeywordEntry("o", translate.text("Outgoing")) + ]); + break; + case "HISTORY.MEDIUM": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Visit")) + ,createKeywordEntry("1", translate.text("E-Mail")) + ,createKeywordEntry("2", translate.text("Phone")) + ,createKeywordEntry("3", translate.text("Internal")) + ,createKeywordEntry("4", translate.text("Online-Meeting")) + ]); + case "COMM.MEDIUM": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Mobile"), null, {category: "PHONE", contentType: "TELEPHONE"}) + ,createKeywordEntry("1", translate.text("E-Mail"), null, {category: "EMAIL", contentType: "EMAIL"}) + ,createKeywordEntry("2", translate.text("Phone"), null, {category: "PHONE", contentType: "TELEPHONE"}) + ,createKeywordEntry("3", translate.text("Internet"), null, {category: "OTHER", contentType: "LINK"}) + ]); + break; + case "ADDRESS.TYPE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Office address")) + ,createKeywordEntry("2", translate.text("Home address")) + ,createKeywordEntry("3", translate.text("Delivery address")) + ,createKeywordEntry("4", translate.text("Post office box")) + ]); + break; + case "ORG.TYPE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Customer")) + ,createKeywordEntry("1", translate.text("Prospect")) + ,createKeywordEntry("2", translate.text("Supplier")) + ,createKeywordEntry("3", translate.text("Other"))//TODO: key as ${} + ]); + break; + case "PERS.GENDER": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("f", translate.text("Female")) + ,createKeywordEntry("m", translate.text("Male")) + ,createKeywordEntry("o", translate.text("${GENDER_OTHER}")) + ]); + break; + case "CONTRACT.CONTRACTTYPE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Framework contract")) + ,createKeywordEntry("1", translate.text("Service contract")) + ,createKeywordEntry("2", translate.text("Maintenance contract")) + ]); + break; + case "CONTRACT.CONTRACTSTATUS": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Valid, unlimited")) + ,createKeywordEntry("1", translate.text("Valid, limited")) + ,createKeywordEntry("2", translate.text("Not signed yet")) + ,createKeywordEntry("3", translate.text("None, individual count")) + ,createKeywordEntry("4", translate.text("Cancelled")) + ]); + break; + case "CONTRACT.PAYMENT": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("0", translate.text("Annually")) + ,createKeywordEntry("1", translate.text("Semiannually")) + ,createKeywordEntry("2", translate.text("Quarterly")) + ]); + break; + case "GROUPCODE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Commodity group 1")) + ,createKeywordEntry("2", translate.text("Commodity group 2")) + ,createKeywordEntry("3", translate.text("Commodity group 3")) + ,createKeywordEntry("4", translate.text("Discount")) + ,createKeywordEntry("5", translate.text("Spare parts")) + ,createKeywordEntry("6", translate.text("Service")) + ]); + break; + case "UNIT": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Pieces")) + ,createKeywordEntry("2", translate.text("Kgs")) + ,createKeywordEntry("3", translate.text("Liter")) + ,createKeywordEntry("4", translate.text("Hours")) + ]); + break; + case "PRICELIST": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("${PRICELIST_DEFAULT}")) + ,createKeywordEntry("2", translate.text("Key account")) + ,createKeywordEntry("3", translate.text("Special price list1")) + ,createKeywordEntry("4", translate.text("${PRICELIST_SERVICE}")) + ]); + break; + case "CURRENCY": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("EUR")) + ,createKeywordEntry("2", translate.text("USD")) + ,createKeywordEntry("3", translate.text("CND")) + ,createKeywordEntry("4", translate.text("CHF")) + ]); + break; + case "STOCK.WAREHOUSE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Warehouse 1")) + ,createKeywordEntry("2", translate.text("Warehouse 2")) + ,createKeywordEntry("3", translate.text("Warehouse 3")) + ]); + break; + case "SALESPROJECT.STATUS": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Open")) + ,createKeywordEntry("2", translate.text("Postponed")) + ,createKeywordEntry("3", translate.text("Aborted")) + ,createKeywordEntry("4", translate.text("Partial order")) + ,createKeywordEntry("5", translate.text("Order")) + ,createKeywordEntry("6", translate.text("Lost")) + ]); + break; + case "SALESPROJECT.PHASE": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Project decision")) + ,createKeywordEntry("2", translate.text("Negotiation")) + ,createKeywordEntry("3", translate.text("Workshop")) + ,createKeywordEntry("4", translate.text("Presentation postprocessing")) + ,createKeywordEntry("5", translate.text("Presentation preparation")) + ,createKeywordEntry("6", translate.text("Statement given")) + ,createKeywordEntry("7", translate.text("Specifications in progress")) + ,createKeywordEntry("8", translate.text("Waiting for request")) + ,createKeywordEntry("9", translate.text("Lead")) + ]); + break; + case "OFFER.PROBABILITY": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("0 %"), null, {percentValue: 0}) + ,createKeywordEntry("2", translate.text("25 %"), null, {percentValue: 25}) + ,createKeywordEntry("3", translate.text("50 %"), null, {percentValue: 50}) + ,createKeywordEntry("4", translate.text("75 %"), null, {percentValue: 75}) + ,createKeywordEntry("5", translate.text("100 %"), null, {percentValue: 100}) + ]); + break; + case "OFFER.STATUS": + valueContainer = createKeywordEntriesContainer([ + createKeywordEntry("1", translate.text("Checked")) + ,createKeywordEntry("2", translate.text("Sent")) + ,createKeywordEntry("3", translate.text("Won")) + ,createKeywordEntry("4", translate.text("Lost")) + ]); + break; + default: + throw new Error(translate.withArguments("[%0]the given keyword \"%1\" has no match with the possible keywordlist", [ + arguments.callee.name, keywordType + ])); + break; + } + + + _getPropForKeyFn = function(key, field, isCustom) { + var keyObject; + if (isCustom) + keyObject = valueContainer[key]["customProperties"]; + else + keyObject = valueContainer[key]; + + if (keyObject == undefined) + return undefined; + return keyObject[field]; + }; + + _getPropsForKeyFn = function(key, fields) { + var keyObject, i, l, currentRow, currentField; + + keyObject = valueContainer[key]; + if (keyObject == undefined) + return [];//TODO: throw error instead? + l = fields.length; + currentRow = []; + for (i = 0; i < l; i++){ + currentField = fields[i]; + //check if the passed fieldnames match the existing fieldnames (<=> properties in the object) + //to prevent errors and unexpected behaviour + if (keyObject[currentField]) + currentRow.push(keyObject[currentField]); + else + currentRow.push(""); + } + return currentRow; + }; + + _toArrayFn = function(fields){ + var res, id, currentRow; + + res = []; + if (!fields) + fields = ["id", "name"]; + else if (typeof(fields) == "string"){ + for (id in valueContainer){ + res.push(_getPropForKeyFn(id, fields)); + } + return res; + } + + for (id in valueContainer){ + currentRow = _getPropsForKeyFn(id, fields); + res.push(currentRow); + } + return res; + }; + + return { + /** + * toArray + */ + toArray: _toArrayFn + ,getPropForKey: _getPropForKeyFn + ,getPropsForKey: _getPropsForKeyFn + ,filter: function (callbackFn, thisArg){ + for (id in valueContainer){ + if (false == callbackFn.call(thisArg, valueContainer[id].id, valueContainer[id].name, valueContainer[id].customProperties, + valueContainer[id], valueContainer)){ + delete valueContainer[id]; + } + } + return this; + } + }; + }; + + /** + * internal function for creating an object that represents a keyword entry + * @param {String} id represents the key of an entry; a KeywordEntriesContainer can contain the same key only once + * @param {String} name represents the translated name of an entry; this is in most cases the view-value + * @param {String} [description=""] description text for describing the keyword + * @param {Object} [customProperties=null] an Object with additional properties; these can be virtually anything + * @return {Object} object that represents a single keyword entry; normally severel entries are cumulated in a "keywordEntriesContainer" + */ + function createKeywordEntry(id, name, description, customProperties){ + //TODO: verify if mandatory-checks are really that usefull or can at least be made easier + if (!id) + throw new Error(translate.withArguments("the param \"%0\" in \"%1\" is mandatory and has to be set", [ + "id", arguments.callee.name + ])); + if (!name) + throw new Error(translate.withArguments("the param \"%0\" in \"%1\" is mandatory and has to be set", [ + "name", arguments.callee.name + ])); + + return { + id: id + ,name: name + ,description: description || "" + ,customProperties: customProperties + }; + } + + /** + * internal function for creating an object that represents a container of several keywordEntries + * @param {Array} keywordEntries an Array of keywordEntry-objects (as they are created by "createKeywordEntry" + * @return {Object} object that contains several keywordEntries + */ + function createKeywordEntriesContainer(keywordEntries){ + var res, i, l, id; + + res = {}; + for (i = 0, l = keywordEntries.length; i < l; i++){ + id = keywordEntries[i].id; + if (res[id] != undefined){ + throw new Error("the given id is not unique since it already exists"); + } + res[id] = keywordEntries[i]; + } + return res; + } } \ No newline at end of file diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 9187a8f49e56fa987f4fb7cb83c30a79153dfda4..4181790956d0d67fc930d95ce5d5e75d4ad2f20e 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -4,7 +4,8 @@ import("system.db"); import("system.datetime"); import("system.tools"); import("system.SQLTYPES"); -import("Util_lib") +import("system.text"); +import("Util_lib"); /** * Object for easier handling of conditions; @@ -12,8 +13,10 @@ import("Util_lib") * you don't need to append a "1=1" condition or similar; * @example //TODO: add missing example */ -function SqlCondition(){ +function SqlCondition(alias){ this._sqlStorage = ""; + this.preparedValues = []; + this.alias = alias; } /** * append with SQL-and; no paranthesize of existing conditions is done @@ -28,6 +31,22 @@ SqlCondition.prototype.and = function(cond){ this._sqlStorage += cond; return this; } + +/** + * same as the "and"-function but with preparedStatement functionality + * @param {String} field the database field as "tablename.columnname"; e.g. "ORG.NAME" + * @param {String} cond the strucutre of the SQL condition as preparedString, you can use a number sign "#" as placeholder for you fieldname; + * e.g. "# > ?"; escaping the number sign is possible with a backslash "\" + * @param {String} value the value that shall be set into the prepared statement + * @param {Numeric} [fieldType] SQL-column-type; if the fieldType is not given it's loaded automatically; + * please note that this can be a performace issue if it happens a lot of times (e.g. in aloop) + * @return {Object} current SqlCondition-object + */ +SqlCondition.prototype.andPrepare = function(field, cond, value, fieldType){ + cond = this._prepare(field, cond, value, fieldType); + return this.and(cond); +} + /** * append with SQL-or; Also paranthesize the existing conditions * @param {String} cond the condition string which shall be appended @@ -42,6 +61,21 @@ SqlCondition.prototype.or = function(cond){ this._sqlStorage = cond; return this; } + +/** + * same as the "or"-function but with preparedStatement functionality + * @param {String} field the database field as "tablename.columnname"; e.g. "ORG.NAME" + * @param {String} cond the strucutre of the SQL condition as preparedString, you can use a number sign "#" as placeholder for you fieldname; + * e.g. "# > ?"; escaping the number sign is possible with a backslash "\" + * @param {String} value the value that shall be set into the prepared statement + * @param {Numeric} [fieldType] SQL-column-type; if the fieldType is not given it's loaded automatically; + * please note that this can be a performace issue if it happens a lot of times (e.g. in aloop) + * @return {Object} current SqlCondition-object + */ +SqlCondition.prototype.orPrepare = function(field, cond, value, fieldType){ + cond = this._prepare(field, cond, value, fieldType); + return this.or(cond); +} /** * ready to use string; does not contain a where keyword at the beginning * @param {String} alternativeCond condition that is returned when nothing has been appended @@ -66,6 +100,44 @@ SqlCondition.prototype.toWhereString = function(alternativeCond){ return cond; } +/** + * hidden function for composing preparedStatements + * @param {String} field the database field as "tablename.columnname"; e.g. "ORG.NAME" + * @param {String} cond the strucutre of the SQL condition as preparedString, you can use a number sign "#" as placeholder for you fieldname; + * e.g. "# > ?"; escaping the number sign is possible with a backslash "\" + * @param {String} value the value that shall be set into the prepared statement + * @param {Numeric} [fieldType] SQL-column-type; if the fieldType is not given it's loaded automatically; + * please note that this can be a performace issue if it happens a lot of times (e.g. in aloop) + * @return {String} the replaced SQL-condition string (replace # by the fieldname) + */ +SqlCondition.prototype._prepare = function(field, cond, value, fieldType){ + //this function looks more complex (and slower) than it actually is + /* the following regex looks like this after javascript-escaping of the backslash: (?<!\\)((?:\\\\)*)# + the regexp searches for the unescaped character and these characters are replaced by the field name + + examples: + --------------------- + | # --match | + | \# --no-match | + | \\# --match | + | \\\# --no-match | + | \\\\# --match | + --------------------- + */ + //use replaceAll because it's faster and supports negative lookbehinds + cond = text.replaceAll(cond, { + //manually readd the replaced backslashes by using a group reference, because they a part of the match and therefore replaced by "replaceAll" + //since the field COULD contain already a group reference (I think this is extremely uncommon; + //probably that never happens but better stay save): escape that references within the fieldname + "(?<!\\\\)((?:\\\\\\\\)*)#": "$1" + text.replaceAll(field, {"$1": "\\$1"}), + //now that we've replaced the correct field placeholder let's replace the escaped number sign "\#" to a normal number sign "#" + "\\\\#": "#" + }); + type = fieldType || SqlUtils.getSingleColumnType(field, undefined, this.alias); + this.preparedValues.push([value.toString(), type]); + return cond; +} + function SqlMaskingUtils(){ //TODO: use callbacks for different handling? /** @@ -218,6 +290,42 @@ function SqlMaskingUtils(){ } } +function SqlUtils(){ +} + +SqlUtils.getSingleColumnType = function(fieldOrTableName, columnName, alias) +{ + var tableName, fieldVarType; + if (columnName == undefined){ + fieldVarType = typeof(fieldOrTableName); + if (fieldVarType == "string") + fieldOrTableName = text.split(fieldOrTableName, "\\."); + else if (fieldVarType != "object"){ + throw new TypeError();//TODO: add message + } + + if (fieldOrTableName.hasOwnProperty("length") && fieldOrTableName.length == 2) + { + tableName = fieldOrTableName[0]; + columnName = fieldOrTableName[1]; + } + else + throw new TypeError();//TODO: add message + } + else + tableName = fieldOrTableName; + + if (typeof(columnName) != "string") + throw new TypeError();//TODO: add message + if (typeof(tableName) != "string") + throw new TypeError();//TODO: add message + + if (alias == undefined) + alias = db.getCurrentAlias(); + + return db.getColumnTypes(tableName, [columnName], alias)[0]; +} + /** *Class containing utilities for SQL *@deprecated use SqlMaskingUtils