diff --git a/process/upgrade_ImporterCustomMappingFunctions_lib/process.js b/process/upgrade_ImporterCustomMappingFunctions_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..3859258fd80c9bace8c7beef4a8763b035ae8cdf --- /dev/null +++ b/process/upgrade_ImporterCustomMappingFunctions_lib/process.js @@ -0,0 +1,2069 @@ +import("system.logging"); +import("system.datetime"); +import("KeywordRegistry_basic"); +import("system.SQLTYPES"); +import("system.text"); +import("system.db"); +import("Sql_lib"); +import("ImporterMappingFunctions_lib") +import("Importer_lib"); + +/////////////////////////////////////////////////////////////////// +/// NOT FINAL! /// +/// custom mapping for the import handler /// +/// edit this, since this is serperate for every project /// +/////////////////////////////////////////////////////////////////// +/* +* Run Import in separate Process sp_runImporterMigration +*/ + +var aliasFrom = "Data_aliasOld"; +var aliasTo = "Data_alias"; +// List of Frameids in ADITO5 mapped to contextnames in ADITO2020 +var listFrameIDS = "1;Organisation;2;Person;3;Person;4;Activity;6;Campaign;12;Employee;13;Complaint;14;OFFER;15;Order;" ++"16;Salesproject;17;Leadimport;18;BulkMail;30;Offeritem;33;Contract;40;Product;45;SupportTicket"; +// List of databasetablenames in ADITO5 mapped to databasetablenames in ADITO2020 +var listDbTables = "ORG;ORGANISATION;PERS;PERSON;HISTORY;ACTIVITY;COMPLAINT;TICKET;SALESORDER;ORDER;" ++"RELATION;CONTACT;BULKMAILDEF;BULKMAIL"; +// Condition to import data of the frames in the lists above +var cond = "OBJECT_ID in (1,2,3,4,6,12,13,14,15,16,17,18,30,33,40,45)"; + + +function runImport(pMappingsToRun) +{ + var bindata = false; + var mappingsToRun = getMappings(pMappingsToRun); + + + for each(let tableName in mappingsToRun) + { + logging.log("Start Migration: " + pMappingsToRun); + + var imp = new Importer(tableName); + imp.Log = "CONSOLE"; +// imp.ImportUser = "IMPORT_ADITO2020"; //we don' want to override the former User_New of the data + imp.Preview = false; + imp.Debug = true; + imp.LogLevel = imp.LogLevels.Info; + imp.TableCase = imp.Cases.Upper; + imp.BatchSize = 50000; + //If bindata is imported + if(bindata) + imp.BatchSize = 500; + + //Testing/Debug only + //imp.MaxRows = 10; + imp.setTimeout(5000000, null); + imp.process(); + + logging.log("End Migration: " + pMappingsToRun); + } +} + +function getMappings(pMappingsToRun)//@ToDo refactor +{ + var mappingsObject = []; + + if (pMappingsToRun.find("keyword")){ + mappingsObject.push(getConfig_KEYWORD()); + } + if (pMappingsToRun.find("keyword_additions")){ + mappingsObject.push(getConfig_KeywordAdditions()); + } + if (pMappingsToRun.find("org")){ + mappingsObject.push(getConfig_ORG()); + } + if (pMappingsToRun.find("pers")){ + mappingsObject.push(getConfig_PERS()); + } + if (pMappingsToRun.find("relation")){ + mappingsObject.push(getConfig_RELATION()); + } + if (pMappingsToRun.find("address")){ + mappingsObject.push(getConfig_ADDRESS()); + } + if (pMappingsToRun.find("comm")){ + mappingsObject.push(getConfig_COMM()); + } + if (pMappingsToRun.find("history")){ + mappingsObject.push(getConfig_HISTORY()); + } + if (pMappingsToRun.find("historylink")){ + mappingsObject.push(getConfig_HISTORYLINK()); + } + if (pMappingsToRun.find("offer")){ + mappingsObject.push(getConfig_OFFER()); + } + if (pMappingsToRun.find("complaint")){ + mappingsObject.push(getConfig_COMPLAINT()); + } + if (pMappingsToRun.find("theme")){ + mappingsObject.push(getConfig_THEME()); + } + if (pMappingsToRun.find("history_theme")){ + mappingsObject.push(getConfig_HISTORY_THEME()); + } + if (pMappingsToRun.find("attr")){ + mappingsObject.push(getConfig_ATTR()); + } + if (pMappingsToRun.find("attrlink")){ + mappingsObject.push(getConfig_ATTRLINK()); + } + if (pMappingsToRun.find("objrel")){ + mappingsObject.push(getConfig_OBJECTRELATION()); + } + //-------------- System tables -------------- + if (pMappingsToRun.find("asys_binaries")){ + mappingsObject.push(getConfig_ASYS_BINARIES()); + } + if (pMappingsToRun.find("asys_binaries_data")){ + mappingsObject.push(getConfig_ASYS_BINARIES_Data()); + bindata = true; + } + if (pMappingsToRun.find("asys_calendarbackend")){ + mappingsObject.push(getConfig_ASYS_CALENDARBACKEND()); + } + if (pMappingsToRun.find("asys_calendarlink")){ + mappingsObject.push(getConfig_ASYS_CALENDARLINK()); + } + + return mappingsObject; +} + +/* +* Function to import previous ORG into ORGANISATION +*/ +function getConfig_ORG() { + + return { + DataQuery : + " select " + + " ORGID, " //0 + + " CUSTOMERCODE, " //1 + + " ORGINFO, " //2 + + " ORGNAME, " //3 + + " SALESAREA, " //4 + + " DATE_NEW, " //5 + + " DATE_EDIT, " //6 + + " USER_NEW, " //7 + + " USER_EDIT " //8 + + " from ORG " + + " where ORGID != '0'" // Exclude organisation 'private' as it already exists + + " order by ORGID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "ORGANISATION.ORGANISATIONID", + Key: true + }], //ORGID + [iMove, { + Source: 1, + Target: "ORGANISATION.CUSTOMERCODE" + }], //ORGID + [iMove, { + Source: 2, + Target: "ORGANISATION.INFO" + }], //ORGINFO + [iMove, { + Source: 3, + Target: "ORGANISATION.NAME" + }], //ORGNAME + [iMove, { + Source: 4, + Target: "ORGANISATION.SALESAREA" + }], //SALESAREA + [iMove, { + Source: 5, + Target: "ORGANISATION.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 6, + Target: "ORGANISATION.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 7, + Target: "ORGANISATION.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 8, + Target: "ORGANISATION.USER_EDIT" + }] //USER_EDIT + ] + }; +} + +/* +* Function to import previous PERS into PERSON +*/ +function getConfig_PERS() { + + return { + DataQuery : + " select " + + " PERSID, " //0 + + " FIRSTNAME, " //1 + + " MIDDLENAME, " //2 + + " LASTNAME, " //3 + + " SALUTATION, " //4 + + " TITLE, " //5 + + " DOB, " //6 + + " GENDER, " //7 + + " SUFFIX, " //8 + + " DATE_NEW, " //9 + + " DATE_EDIT, " //10 + + " USER_NEW, " //11 + + " USER_EDIT " //12 + + " from PERS " + + " order by PERSID desc", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "PERSON.PERSONID", + Key: true + }], // PERSID + [iMove, { + Source: 1, + Target: "PERSON.FIRSTNAME" + }],// FIRSTNAME + [iMove, { + Source: 2, + Target: "PERSON.MIDDLENAME" + }], // MIDDLENAME + [iMove, { + Source: 3, + Target: "PERSON.LASTNAME" + }], // LASTNAME + [iMove, { + Source: 4, + Target: "PERSON.SALUTATION" + }], // SALUTATION + [iMove, { + Source: 5, + Target: "PERSON.TITLE" + }], // TITLE + [iMove, { + Source: 6, + Target: "PERSON.DATEOFBIRTH" + }], // DOB + [iDecode, { + Source: 7, + List: "M;m;F;f", + Target: "PERSON.GENDER" + }], // GENDER + [iDecode, { + DoIf: "'{7}' == ''", + Source: 4, + List: "Frau;f;Herr;m", + Target: "PERSON.GENDER" + }], + [iMove, { + Source: 9, + Target: "PERSON.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 10, + Target: "PERSON.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 11, + Target: "PERSON.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 12, + Target: "PERSON.USER_EDIT" + }] //USER_NEW + ] + }; +} + +/* +* Function to import previous RELATION into CONTACT +*/ +function getConfig_RELATION() { + + return { + DataQuery : + " select " + + " RELATIONID, " //0 + + " ORG_ID, " //1 + + " PERS_ID, " //2 + + " DEPARTMENT, " //3 + + " RELPOSITION, " //4 + + " RELTITLE, " //5 + + " LANG, " //6 + + " STATUS, " //7 + + " ADDRESS_ID, " //8 + + " SOURCE, " //9 + + " RELATION.DATE_NEW, " //10 + + " RELATION.DATE_EDIT, " //11 + + " RELATION.USER_NEW, " //12 + + " RELATION.USER_EDIT, " //13 + + " RELATION.LETTERSALUTATION" //14 + + " from RELATION " + + " join ORG on ORGID = ORG_ID " + + " order by RELATIONID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "CONTACT.CONTACTID", + Key: true + }], // RELATIONID + [iMove, { + Source: 1, + Target: "CONTACT.ORGANISATION_ID" + }], // ORG_ID + [iMove, { + Source: 2, + Target: "CONTACT.PERSON_ID" + }], // PERS_ID + [iMove, { + Source: 3, + Target: "CONTACT.DEPARTMENT" + }], // DEPARTMENT + [iMove, { + Source: 4, + Target: "CONTACT.CONTACTPOSITION" + }], // RELPOSITION + [iMove, { + Source: 5, + Target: "CONTACT.CONTACTROLE" + }], // RELTITLE + [iDecode, { + Source: 6, + List: "1;deu;2;eng;3;fra;4;spa", + Target: "CONTACT.ISOLANGUAGE" + }], // LANG + [iDecode, { + Source: 7, + List: "1;CONTACTSTATACTIVE;2;CONTACTSTATINACTIVE;3;CONTACTSTATREVIEW", + Target: "CONTACT.STATUS" + }], // STATUS + [iMove, { + Source: 8, + Target: "CONTACT.ADDRESS_ID" + }], // ADDRESS_ID + [iMove, { + Source: 10, + Target: "CONTACT.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 11, + Target: "CONTACT.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 12, + Target: "CONTACT.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 13, + Target: "CONTACT.USER_EDIT" + }], //USER_EDIT + [iMove, { + Source: 14, + Target: "CONTACT.LETTERSALUTATION" + }] //LETTERSALUTATION + ] + }; +} + +/* +* Function to import previous ADDRESS into ADDRESS +*/ +function getConfig_ADDRESS() { + + return { + DataQuery : + " select " + + " ADDRESSID, " //0 + + " ADDRESSADDITION, " //1 + + " ZIP, " //2 + + " ADDRESS, " //3 + + " DISTRICT, " //4 + + " CITY, " //5 + + " COUNTRY, " //6 + + " RELATION_ID, " //7 + + " ADDRIDENTIFIER, " //8 + + " REGION, " //9 + + " BUILDINGNO, " //10 + + " STATE, " //11 + + " ADDR_TYPE, " //12 + + " ADDRESS.DATE_NEW, " //13 + + " ADDRESS.DATE_EDIT, " //14 + + " ADDRESS.USER_NEW, " //15 + + " ADDRESS.USER_EDIT " //16 + + " from ADDRESS " + + " order by ADDRESSID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "ADDRESS.ADDRESSID", + Key: true + }], // ADDRESSID + [iMove, { + Source: 1, + Target: "ADDRESS.ADDRESSADDITION" + }], // ADDRESSADDITION + [iMove, { + Source: 2, + Target: "ADDRESS.ZIP" + }], //ZIP + [iMove, { + Source: 3, + Target: "ADDRESS.ADDRESS" + }], //ADDRESS + [iMove, { + Source: 4, + Target: "ADDRESS.DISTRICT" + }], // DISTRICT + [iMove, { + Source: 5, + Target: "ADDRESS.CITY" + }], // CITY + [iMove, { + Source: 6, + Target: "ADDRESS.COUNTRY" + }], // COUNTRY + [iMove, { + Source: 7, + Target: "ADDRESS.CONTACT_ID" + }], // RELATION_ID + [iMove, { + Source: 8, + Target: "ADDRESS.ADDRIDENTIFIER" + }], //ADDRIDENTIFIER + [iMove, { + Source: 9, + Target: "ADDRESS.REGION" + }], // REGION + [iMove, { + Source: 10, + Target: "ADDRESS.BUILDINGNO" + }], // BUILDINGNO + [iMove, { + Source: 11, + Target: "ADDRESS.PROVINCE" + }], //STATE + [iDecode, { + Source: 12, + List: "1;OFFICEADDR;2;HOMEADDR;4;DELIVERADDR;8;POSTADDR", + Target: "ADDRESS.ADDR_TYPE" + }], + [iMove, { + Source: 13, + Target: "ADDRESS.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 14, + Target: "ADDRESS.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 15, + Target: "ADDRESS.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 16, + Target: "ADDRESS.USER_EDIT" + }] //USER_EDIT + ] + }; + +} + +/* +* Function to import previous COMM into COMMUNICATION +*/ +function getConfig_COMM() { + + return { + DataQuery : + " select " + + " COMMID, " //0 + + " RELATION_ID, " //1 + + " MEDIUM_ID, " //2 + + " ADDR, " //3 + + " STANDARD, " //4 + + " DATE_NEW, " //5 + + " DATE_EDIT, " //6 + + " USER_NEW, " //7 + + " USER_EDIT " //8 + + " from COMM " + + " order by COMMID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "COMMUNICATION.COMMUNICATIONID", + Key: true + }], // COMMID + [iMove, { + Source: 1, + Target: "COMMUNICATION.CONTACT_ID" + }], // RELATION_ID + [iDecode, { + Source: 2, + List: "1;COMMPHONE;2;COMMPHONE;3;COMMEMAIL;4;COMMINTERNET;5;COMMMOBIL;11;COMMPHONE;12;COMMPHONE;13;COMMEMAIL;" + +"14;COMMINTERNET;15;COMMPHONE;16;COMMEMAIL;17;COMMXING;18;COMMINTERNET;19;COMMINTERNET;20;COMMINTERNET", + Target: "COMMUNICATION.MEDIUM_ID" + }], // MEDIUM_ID + [iMove, { + Source: 3, + Target: "COMMUNICATION.ADDR" + }], // ADDR + [iMove, { + DoIf: "'{4}' == '1'", + Value: "1", + Target: "COMMUNICATION.ISSTANDARD" + }], // STANDARD + [iMove, { + DoIf: "'{4}' != '1'", + Value: "0", + Target: "COMMUNICATION.ISSTANDARD" + }], // STANDARD + [iMove, { + Source: 5, + Target: "COMMUNICATION.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 6, + Target: "COMMUNICATION.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 7, + Target: "COMMUNICATION.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 8, + Target: "COMMUNICATION.USER_EDIT" + }] //USER_EDIT + ] + }; +} + +/* +* Function to import previous HISTORY into ACTIVITY +*/ +function getConfig_HISTORY() { + + return { + DataQuery : + " select " + + " HISTORYID, " //0 + + " RELATION_ID, " //1 + + " ENTRYDATE, " //2 + + " SUBJECT, " //3 + + " INFO, " //4 + + " HISTORY_ID, " //5 + + " MEDIUM, " //6 + + " DIRECTION, " //7 + + " DATE_NEW, " //8 + + " DATE_EDIT, " //9 + + " USER_NEW, " //10 + + " USER_EDIT " //11 + + " from HISTORY " + + " order by HISTORYID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "ACTIVITY.ACTIVITYID", + Key: true + }], // HISTORYID + [iMove, { + Source: 1, + Target: "ACTIVITY.RESPONSIBLE" + }], // RELATION_ID + [iMove, { + Source: 2, + Target: "ACTIVITY.ENTRYDATE" + }], // ENTRYDATE + [iMove, { + Source: 3, + Target: "ACTIVITY.SUBJECT" + }], // SUBJECT + [iMove, { + Source: 4, + Target: "ACTIVITY.INFO" + }], // INFO + [iMove, { + Source: 5, + Target: "ACTIVITY.PARENT_ID" + }], // HISTORY_ID + [iMove, { + DoIf: "'{5}' != ''", + Value: "Activity", + Target: "ACTIVITY.PARENT_CONTEXT" + }], + [iDecode, { + Source: 6, + List: "1;PHONE;2;VISIT;3;LETTER;4;LETTER;5;FAX;8;MAIL;12;MAIL", + Target: "ACTIVITY.CATEGORY" + }], // MEDIUM + [iMove, { + Source: 7, + Target: "ACTIVITY.DIRECTION" + }], // DIRECTION + [iMove, { + Source: 8, + Target: "ACTIVITY.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 9, + Target: "ACTIVITY.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 10, + Target: "ACTIVITY.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 11, + Target: "ACTIVITY.USER_EDIT" + }] //USER_EDIT + ] + }; +} + +/* +* Function to import previous HISTORYLINK into ACTIVITYLINK +*/ +function getConfig_HISTORYLINK() { + + return { + DataQuery : + " select " + + " HISTORYLINKID, " //0 + + " HISTORY_ID, " //1 + + " ROW_ID, " //2 + + " OBJECT_ID, " //3 + + " DATE_NEW, " //4 + + " DATE_EDIT, " //5 + + " USER_NEW, " //6 + + " USER_EDIT " //7 + + " from HISTORYLINK " + + " order by HISTORYLINKID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "ACTIVITYLINK.ACTIVITYLINKID", + Key: true + }], // HISTORYLINKID + [iMove, { + Source: 1, + Target: "ACTIVITYLINK.ACTIVITY_ID" + }], // HISTORY_ID + [iMove, { + Source: 2, + Target: "ACTIVITYLINK.OBJECT_ROWID" + }], // ROW_ID + [iDecode, { + Source: 3, + List: listFrameIDS, + Target: "ACTIVITYLINK.OBJECT_TYPE" + }], // OBJECT_ID + [iMove, { + Source: 4, + Target: "ACTIVITYLINK.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 5, + Target: "ACTIVITYLINK.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 6, + Target: "ACTIVITYLINK.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 7, + Target: "ACTIVITYLINK.USER_EDIT" + }] //USER_EDIT + ] + }; +} + +/* +* Function to import previous OBJECTRELATION into AB_OBJECTRELATION +* Attention! The objectrelations have to be defined in ADITO 2020 first. Then change the IDs and import the relations as shown in the example. +*/ +function getConfig_OBJECTRELATION() { + + return { + DataQuery : + " select " + + " OBJECTRELATIONID, " //0 + + " SOURCE_ID, " //1 + + " DEST_ID, " //2 + + " SOURCE_OBJECT, " //3 + + " DEST_OBJECT, " //4 + + " RELVALUE, " //5 + + " RELDESC, " //6 + + " DATE_NEW, " //7 + + " DATE_EDIT, " //8 + + " USER_NEW, " //9 + + " USER_EDIT " //10 + + " from OBJECTRELATION " + + " order by OBJECTRELATIONID desc", + + + AliasFrom: aliasFrom, + AliasTo: "Data_alias_noaudit", + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "AB_OBJECTRELATION.AB_OBJECTRELATIONID", + Key: true + }], // OBJECTRELATIONID + [iMove, { + Source: 1, + Target: "AB_OBJECTRELATION.OBJECT1_ROWID" + }], // SOURCE_ID + [iMove, { + Source: 2, + Target: "AB_OBJECTRELATION.OBJECT2_ROWID" + }], // DEST_ID + // //Example + // [iMove, { + // DoIf: "'{5}' == '1'", + // Value: "c9b7ce6b-1100-46f6-8498-2da6ac24189e", + // Target: "AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1" + // }], + // [iMove, { + // DoIf: "'{5}' == '1'", + // Value: "259babbd-7827-44d4-b9ec-8245d27b5f70", + // Target: "AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2" + // }] + ] + }; +} + +/* +* Function to import previous COMPLAINT into TASK and TICKET +*/ +function getConfig_COMPLAINT(){ + + return { + DataQuery : + " select " + + " COMPLAINTID, " //0 + + " RELATION_ID, " //1 + + " RESPONSIBLE_ID, " //2 + + " STATUS, " //3 + + " SUBJECT, " //4 + + " DESCRIPTION, " //5 + + " COMPLAINTNUMBER, " //6 + + " DATE_NEW " //7 + + " from COMPLAINT " + + " order by COMPLAINTID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "TASK.TASKID", + Key: true + }], // COMPLAINTID + [iMove, { + Source: 1, + Target: "TASK.REQUESTOR_CONTACT_ID" + }], // RELATION_ID + [iMove, { + Source: 2, + Target: "TASK.EDITOR_CONTACT_ID" + }], // RESPONSIBLE_ID + [iDecode, { + Source: 3, + List: "1;UNASSIGNED;2;IN-PROGRESS;3;WAITING;4;ENDED", + Target: "TASK.STATUS" + }], // STATUS + [iMove, { + Source: 4, + Target: "TASK.SUBJECT" + }], // SUBJECT + [iMove, { + Source: 5, + Target: "TASK.DESCRIPTION" + }], // DESCRIPTION + [iMove, { + Source: 6, + Target: "TICKET.CODE" + }], // COMPLAINTNUMBER + [iMove, { + Source: 7, + Target: "TASK.START_DATE" + }], // DATE_NEW + [iMove, { + Value: "TICKET", + Target: "TASK.KIND" + }], // Link to new dataset in databasetable ticket + [iSql, { + Target: "var.TicketId", + Alias: aliasTo, + Command: "select TICKETID from TICKET where TASK_ID = '{0}'" + }], + [iNewID, { + Target: "var.NewId", + Key: true + }], + [iMove, { + DoIf: "'{var.TicketId}' == ''", + Value: "{var.NewId}", + Target: "TICKET.TICKETID" + }], + [iMove, { + Source: 0, + Target: "TICKET.TASK_ID", + Key: true + }], + [iMove, { + Value: "SUPPORTTICKET", + Target: "TICKET.TICKETTYPE" + }] + ] + }; +} + +/* +* Function to import previous THEME into AB_ATTRIBUTE and AB_ATTRIBUTEUSAGE +*/ +function getConfig_THEME() { + + return { + DataQuery : + " select " + + " THEMEID, " //0 + + " THEME, " //1 + + " THEME_ID, " //2 + + " ISACTIVE, " //3 + + " DESCRIPTION, " //4 + + " THEMESORT " //5 + + " from THEME " + + " where KIND = 1" // Only themes of kind 'History'' + + " order by THEMEID desc", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "AB_ATTRIBUTE.AB_ATTRIBUTEID", + Key: true + }], // THEMEID + [iMove, { + Source: 1, + Target: "AB_ATTRIBUTE.ATTRIBUTE_NAME" + }], // THEME + [iMove, { + Source: 2, + Target: "AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID" + }], // THEME_ID + [iMove, { + DoIf: "'{3}' == 'true'", + Value: "1", + Target: "AB_ATTRIBUTE.ATTRIBUTE_ACTIVE" + }], // ISACTIVE + [iMove, { + DoIf: "'{3}' == 'false'", + Value: "0", + Target: "AB_ATTRIBUTE.ATTRIBUTE_ACTIVE" + }], // ISACTIVE + [iMove, { + Source: 4, + Target: "AB_ATTRIBUTE.ATTRIBUTE_INFO" + }], // DESCRIPTION + [iMove, { + Source: 5, + Target: "AB_ATTRIBUTE.SORTING" + }], // THEMESORT + [iMove, { + Value: "THEME", + Target: "AB_ATTRIBUTE.ATTRIBUTE_TYPE" + }], // Flag in AB_ATTRIBUTE that defines it as a theme + [iInsertUpdate, { // AB_ATTRIBUTEUSAGE + Condition: "AB_ATTRIBUTE_ID = '{0}' and OBJECT_TYPE = 'Activity'", + Table: "AB_ATTRIBUTEUSAGE", + Alias: "Data_alias", + Columns: [ + { + Name: "AB_ATTRIBUTEUSAGEID", + Key: true + }, + { + Source:0, + Name: "AB_ATTRIBUTE_ID" + }, + { + Value: "Activity", + Name: "OBJECT_TYPE" + }, + { + Value: "1", + Name: "MAX_COUNT" + } + ] + }] + ] + }; +} + +/* +* Function to import previous HISTORY_THEME into AB_ATTRIBUTERELATION +*/ +function getConfig_HISTORY_THEME() { + + return { + DataQuery : + " select " + + " HISTORY_THEMEID, " //0 + + " THEME_ID, " //1 + + " HISTORY_ID, " //2 + + " THEME, " //3 + + " DATE_NEW, " //4 + + " DATE_EDIT, " //5 + + " USER_NEW, " //6 + + " USER_EDIT " //7 + + " from HISTORY_THEME " + + " where THEME_ID is not null" + + " order by HISTORY_THEMEID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", + Key: true + }], //HISTORY_THEMEID + [iMove, { + Source: 1, + Target: "AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID" + }], //THEME_ID + [iMove, { + Source: 2, + Target: "AB_ATTRIBUTERELATION.OBJECT_ROWID" + }],//HISTORY_ID + [iMove, { + Source: 3, + Target: "AB_ATTRIBUTERELATION.CHAR_VALUE" + }],//THEME + [iMove, { + Source: 4, + Target: "AB_ATTRIBUTERELATION.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 5, + Target: "AB_ATTRIBUTERELATION.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 6, + Target: "AB_ATTRIBUTERELATION.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 7, + Target: "AB_ATTRIBUTERELATION.USER_EDIT" + }], //USER_EDIT + [iMove, { + Value: "Activity", + Target: "AB_ATTRIBUTERELATION.OBJECT_TYPE" + }] + ] + }; +} + +/* +* Function to import previous ATTR into AB_ATTRIBUTE +* !!!!You must add a condition here, otherwise all of your attributes will be inserted!!!! +*/ +function getConfig_ATTR() { + + return { + DataQuery : + " select " + + " ATTRID, " //0 + + " ATTR_ID, " //1 + + " ATTRNAME, " //2 + + " ATTRCOMPONENT, " //3 + + " ATTRDATADEFINITION, " //4 + + " ATTRDESCRIPTION, " //5 + + " ATTRSORT, " //6 + + " AOACTIVE " //7 + + " from ATTR " + + " order by ATTRID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "AB_ATTRIBUTE.AB_ATTRIBUTEID", + Key: true + }],//ATTRID + [iMove, { + Source: 1, + Target: "AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID" + }],//ATTR_ID + [iMove, { + Source: 2, + Target: "AB_ATTRIBUTE.ATTRIBUTE_NAME" + }],//ATTRNAME + [iDecode, { + Source: 3, + List: "0;GROUP;1;COMBO;2;TEXT;3;BOOLEAN;4;DATE;5;INTEGER;6;NUMBER;7;OBJECTSELECTION", + Target: "AB_ATTRIBUTE.ATTRIBUTE_TYPE" + }],//ATTRCOMPONENT + [iMove, { + DoIf: "'{3}' == ''", + Value: "COMBOVALUE", + Target: "AB_ATTRIBUTE.ATTRIBUTE_TYPE" + }], //ATTRCOMPONENT + [iMove, { + Source: 4, + Target: "AB_ATTRIBUTE.DROPDOWNDEFINITION" + }], // ATTRDATADEFINITION + [iMove, { + Source: 5, + Target: "AB_ATTRIBUTE.ATTRIBUTE_INFO" + }], //ATTRDESCRIPTION + [iMove, { + Source: 6, + Target: "AB_ATTRIBUTE.SORTING" + }],//ATTRSORT + [iMove, { + Source: 7, + Target: "AB_ATTRIBUTE.ATTRIBUTE_ACTIVE" + }] //AOACTIVE + ] + }; +} + +/* +* Function to import previous OFFER into OFFER +*/ +function getConfig_OFFER() { + + return { + DataQuery : + " select " + + " OFFERID, " //0 + + " ADDRESS, " //1 + + " CURRENCY, " //2 + + " DELIVERYTERMS, " //3 + + " FOOTER, " //4 + + " HEADER, " //5 + + " LANGUAGE, " //6 + + " NET, " //7 + + " OFFERCODE, " //8 + + " OFFERDATE, " //9 + + " PAYMENTTERMS, " //10 + + " PROBABILITY, " //11 + + " PROJECT_ID, " //12 + + " RELATION_ID, " //13 + + " REMARK, " //14 + + " STATUS, " //15 + + " VAT, " //16 + + " VERSNR, " //17 + + " DATE_EDIT, " //18 + + " DATE_NEW, " //19 + + " USER_EDIT, " //20 + + " USER_NEW " //21 + + " from OFFER " + + " order by OFFERID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "OFFER.OFFERID", + Key: true + }], // OFFERID + [iMove, { + Source: 1, + Target: "OFFER.ADDRESS" + }], // ADDRESS + [iMove, { + Source: 2, + Target: "OFFER.CURRENCY" + }], // CURRENCY + [iDecode, { + Source: 3, + List: "1;FREE;2;DELIVERYCIF;3;DELIVERYEX", + Target: "OFFER.DELIVERYTERMS" + }],// DELIVERYTERMS + [iMove, { + Source: 4, + Target: "OFFER.FOOTER" + }], // FOOTER + [iMove, { + Source: 5, + Target: "OFFER.HEADER" + }], // HEADER + [iDecode, { + Value: "{6}", + List: "1;deu;2;eng", + Target: "OFFER.ISOLANGUAGE" + }],//LANGUAGE + [iMove, { + Source: 7, + Target: "OFFER.NET" + }], // NET + [iMove, { + Source: 8, + Target: "OFFER.OFFERCODE" + }], // OFFERCODE + [iMove, { + Source: 9, + Target: "OFFER.OFFERDATE" + }], // OFFERDATE + [iDecode, { + Source: 10, + List : "1;PAYTERM7;2;PAYTERM30;3;PAYTERMDISCOUNT", + Target: "OFFER.PAYMENTTERMS" + }], // PAYMENTTERMS + [iDecode, { + Source: 11, + List : "1;0;2;25;3;50;4;75;5;100", + Target: "OFFER.PROBABILITY" + }], // PROBABILITY + [iMove, { + Source: 12, + Target: "OFFER.OBJECT_ROWID" + }], // PROJECT_ID + [iMove, { + Value: "Salesproject", + Target: "OFFER.OBJECT_TYPE" + }], // LINK TO SALESPROJECT + [iMove, { + Source: 13, + Target: "OFFER.CONTACT_ID" + }], // RELATION_ID + [iMove, { + Source: 14, + Target: "OFFER.INFO" + }], // REMARK + [iDecode, { + Source: 15, + List:"1;OFFERSTATCHECK;2;OFFERSTATSENT;3;OFFERSTATSENT;4;OFFERSTATLOST", + Target: "OFFER.STATUS" + }], //STATUS + [iMove, { + Source: 16, + Target: "OFFER.VAT" + }], //VAT + [iMove, { + Source: 17, + Target: "OFFER.VERSNR" + }], // VERSNR + [iMove, { + Source: 18, + Target: "OFFER.DATE_EDIT" + }], //DATE_NEW + [iMove, { + Source: 19, + Target: "OFFER.DATE_NEW" + }], //DATE_EDIT + [iMove, { + Source: 20, + Target: "OFFER.USER_EDIT" + }], //USER_NEW + [iMove, { + Source: 21, + Target: "OFFER.USER_NEW" + }] //USER_EDIT + ] + }; +} + + +/* +* Function to import previous ATTRLINK into AB_ATTRIBUTERELATION +*/ +function getConfig_ATTRLINK() { + + return { + DataQuery : + " select " + + " ATTRLINKID, " //0 + + " ATTR_ID, " //1 + + " OBJECT_ID, " //2 + + " ROW_ID, " //3 + + " VALUE_ID, " //4 + + " VALUE_CHAR, " //5 + + " VALUE_DATE, " //6 + + " VALUE_INT, " //7 + + " VALUE_DOUBLE, " //8 + + " DATE_NEW, " //9 + + " DATE_EDIT, " //10 + + " USER_NEW, " //11 + + " USER_EDIT " //12 + + " from ATTRLINK " + + " where ROW_ID is not null" + + " order by ATTRLINKID desc", + + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", + Key: true + }], // ATTRLINKID + [iMove, { + Source: 1, + Target: "AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID" + }], // ATTR_ID + [iDecode, { + Source: 2, + List: listFrameIDS, + Target: "AB_ATTRIBUTERELATION.OBJECT_TYPE" + }], //OBJECT_ID + [iMove, { + Source: 3, + Target: "AB_ATTRIBUTERELATION.OBJECT_ROWID" + }], //ROW_ID + [iMove, { + Source: 4, + Target: "AB_ATTRIBUTERELATION.ID_VALUE" + }], //VALUE_ID + [iMove, { + DoIf: "'{5}' == 'Y'", + Value: "1", + Target: "AB_ATTRIBUTERELATION.INT_VALUE" + }], // VALUE_CHAR + [iMove, { + DoIf: "'{5}' == 'N'", + Value: "0", + Target: "AB_ATTRIBUTERELATION.INT_VALUE" + }], + [iMove, { + DoIf: "'{5}' != 'N' && '{5}' != 'Y'", + Source: 5, + Target: "AB_ATTRIBUTERELATION.CHAR_VALUE" + }], //@TODO: Aktuell werden auch für Boolean Werte noch die alten Einträge geschireben. Muss berarbeitet werden. + [iMove, { + Source: 6, + Target: "AB_ATTRIBUTERELATION.DATE_VALUE" + }], + [iMove, { + Source: 7, + Target: "AB_ATTRIBUTERELATION.INT_VALUE" + }], + [iMove, { + Source: 8, + Target: "AB_ATTRIBUTERELATION.NUMBER_VALUE" + }], + [iMove, { + Source: 9, + Target: "AB_ATTRIBUTERELATION.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 10, + Target: "AB_ATTRIBUTERELATION.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 11, + Target: "AB_ATTRIBUTERELATION.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 12, + Target: "AB_ATTRIBUTERELATION.USER_EDIT" + }] //USER_EDIT + ] + }; +} + + +/////////////////////////////////////////////////////////////////// +/// Former asys_ and aosys_ tables /// +/// edit this, since this is serperate for every project /// +/////////////////////////////////////////////////////////////////// + +/* +* Function to import previous ASYS_BINARIES into ASYS_BINARIES +* without BINDATA +* because of mandatory (from an administrative viewpoint) +* outsourcing from database to filesystem +* @TODO the binaries have to outsourced BEFORE or simultaneously with the migration +* @TODO documentation +*/ +function getConfig_ASYS_BINARIES() { + + return { + DataQuery : + " select " + + " ID, " //0 + + " FILENAME, " //1 + + " CONTAINERNAME, " //2 + + " DESCRIPTION, " //3 + + " KEYWORD, " //4 + + " ROW_ID, " //5 + + " TABLENAME, " //6 + + " DATE_NEW, " //7 + + " DATE_EDIT, " //8 + + " USER_NEW, " //9 + + " USER_EDIT " //10 + + " from ASYS_BINARIES " + + " order by ID desc", + + + AliasFrom: aliasFrom, + AliasTo: "_____SYSTEMALIAS", + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source: 0, + Target: "ASYS_BINARIES.ID", + Key: true + }], // ID + [iMove, { + Source: 1, + Target: "ASYS_BINARIES.FILENAME" + }], // FILENAME + [iMove, { + Source: 2, + Target: "ASYS_BINARIES.CONTAINERNAME" + }], // CONTAINERNAME + [iMove, { + Source: 3, + Target: "ASYS_BINARIES.DESCRIPTION" + }], // DESCRIPTION + [iMove, { + Source: 4, + Target: "ASYS_BINARIES.KEYWORD" + }], // KEYWORD + [iMove, { + Source: 5, + Target: "ASYS_BINARIES.ROW_ID" + }], // ROW_ID + [iDecode, { + Source: 6, + List: listDbTables, + Target: "var.TABLENAME" + }], //TABLENAME + [iMove, { + DoIf: "'{var.TABLENAME}' == ''", + Source: 6, + Target: "ASYS_BINARIES.TABLENAME" + }], //TABLENAME + [iMove, { + DoIf: "'{var.TABLENAME}' != ''", + Value: "{var.TABLENAME}", + Target: "ASYS_BINARIES.TABLENAME" + }], //TABLENAME + [iMove, { + Source: 7, + Target: "ASYS_BINARIES.DATE_NEW" + }], //DATE_NEW + [iMove, { + Source: 8, + Target: "ASYS_BINARIES.DATE_EDIT" + }], //DATE_EDIT + [iMove, { + Source: 9, + Target: "ASYS_BINARIES.USER_NEW" + }], //USER_NEW + [iMove, { + Source: 10, + Target: "ASYS_BINARIES.USER_EDIT" + }] //USER_EDIT + ] + }; +} + +/* +* Function to import previous tasks from ASYS_CALENDARBACKEND into TASK +* Only tasks that aren't done yet +*/ +function getConfig_ASYS_CALENDARBACKEND() { + + return { + + DataQuery: + "select" + + " DATASETID,"//0 + + " DTEND,"//1 + + " DTSTART,"//2 + + " STATUS,"//3 + + " SUMMARY,"//4 + + " CLASSIFICATION" // 5 + + " from ASYS_CALENDARBACKEND" + + " where entrytype = 2 and (STATUS = 'NEEDS-ACTION' or STATUS = 'IN-PROCESS')" + + " order by ELEMENTUID", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source:0, + Target: "TASK.TASKID", + Key: true + }], //DATASETID + [iMove, { + Source:1, + Target: "TASK.MATURITY_DATE" + }], //DTEND + [iMove, { + Source:2, + Target: "TASK.START_DATE" + }], //DTSTART + [iMove, { + DoIf: "'{3}' == 'NEEDS-ACTION'", + Value: "NEW", + Target: "TASK.STATUS" + }], //STATUS + [iMove, { + DoIf: "'{3}' == 'IN-PROCESS'", + Value: "IN-PROGRESS", + Target: "TASK.STATUS" + }], //STATUS + [iMove, { + Source:4, + Target: "TASK.SUBJECT" + }], //SUBJECT + [iMove, { + Value: "TASK", + Target: "TASK.KIND" + }], //SUMMARY + [iMove, { + Source: 5, + Target: "TASK.PROTECTIONLEVEL" + }] //CLASSIFICATION + ] + } +} +/* +* Function to import previous ASYS_CALENDARLINK into TASKLINK +* Only for tasks that aren't done yet +*/ +function getConfig_ASYS_CALENDARLINK() { + + return { + + DataQuery: + "select" + + " ID," // 0 + + " ENTRYID," // 1 + + " DBTABLENAME," // 2 + + " DBID" // 3 + + " from ASYS_CALENDARLINK" + + " where ENTRYID in (select ELEMENTUID From asys_calendarbackend" + + " where entrytype = 2 and STATUS = 'NEEDS-ACTION' or STATUS = 'IN-PROCESS' )", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source:0, + Target: "TASKLINK.TASKLINKID", + Key: true + }], //ID + [iMove, { + Source:1, + Target: "TASKLINK.TASK_ID" + }], //ENTRYID + [iDecode, { + Source: 2, + List: listDbTables, + Target: "var.OBJECT_TYPE" + }], //TABLENAME + [iMove, { + DoIf: "'{var.OBJECT_TYPE}' == ''", + Source: 2, + Target: "TASKLINK.OBJECT_TYPE" + }], //TABLENAME + [iMove, { + DoIf: "'{var.OBJECT_TYPE}' != ''", + Value: "{var.OBJECT_TYPE}", + Target: "TASKLINK.OBJECT_TYPE" + }], //TABLENAME + [iMove, { + Source:3, + Target: "TASKLINK.OBJECT_ROWID" + }] //DBID + ] + } +} +/* +* Function to import previous KEYWORD into AB_KEYWORD_ENTRY +* A copy of the old databasetable KEYWORD of the reference system is required! (=KEYWORD_OLD) +*/ +function getConfig_KEYWORD(){ + return { + DataQuery: + "SELECT" + + " k1.KEYWORDID," // 0 + + " k1.KEYNAME1," // 1 + + "(SELECT k2.KEYNAME2 FROM KEYWORD k2 WHERE k2.KEYVALUE = k1.KEYTYPE and k2.KEYTYPE = 0) as NAME2," // 2 + + " k1.KEYSORT," // 3 + + " k1.AOACTIVE," // 4 + + " k1.KEYNAME2," // 5 + + " k1.KEYDESCRIPTION," // 6 + + " k1.KEYDETAIL," // 7 + + " k1.KEYVALUE" // 8 + + " FROM KEYWORD k1" + + " WHERE k1.KEYTYPE != 0 " + + " AND k1.KEYTYPE NOT IN " + + " (SELECT KEYVALUE FROM KEYWORD_OLD WHERE KEYTYPE = 0)" + + " ORDER BY k1.KEYTYPE, k1.KEYVALUE", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + Mapping: + [[iNewID, { + Target: "AB_KEYWORD_ENTRY.AB_KEYWORD_ENTRYID" + }], + [iMove, { + Source: 0, + Target: "AB_KEYWORD_ENTRY.KEYID", + Key: true + }],// KEYWORDID + [iMove, { + Source: 1, + Target: "AB_KEYWORD_ENTRY.TITLE" + }],// KEYNAME1 + [iMove, { + Source: 2, + // KEYNAME2 = superordinate keyword + Target: "AB_KEYWORD_ENTRY.CONTAINER" + }], + [iMove, { + Source: 3, + Target: "AB_KEYWORD_ENTRY.SORTING" + }],// KEYSORT + [iMove, { + DoIf: "'{3}' == ''", + Source: 8, + Target: "AB_KEYWORD_ENTRY.SORTING" + }],// KEYSORT is empty => KEYVALUE + [iMove, { + Source: 4, + Target: "AB_KEYWORD_ENTRY.ISACTIVE" + }], // AOACTIVE + [iMove, { + Value: "0", + Target: "AB_KEYWORD_ENTRY.ISESSENTIAL" + }] + ] + } +} +/* + * Function to import columns KEYNAME2, KEYDESCRIPTION, KEYDETAIL from previous KEYWORD into AB_KEYWORD_ATTRIBUTE + */ +function getConfig_KeywordAdditions(){ + return { + DataQuery: + "SELECT" + + " k1.KEYWORDID," // 0 + + "(select k2.KEYNAME2 from KEYWORD k2 where k2.KEYVALUE = k1.KEYTYPE and k2.KEYTYPE = 0) as NAME2," // 1 + + " k1.KEYNAME2," // 2 + + " k1.KEYDESCRIPTION," // 3 + + " k1.KEYDETAIL" // 4 + + " FROM KEYWORD k1" + + " WHERE k1.KEYTYPE != 0 " + + " AND k1.KEYTYPE NOT IN (SELECT KEYVALUE FROM KEYWORD_OLD WHERE KEYTYPE = 0)" + + " ORDER BY k1.KEYTYPE, k1.KEYVALUE", + + AliasFrom: aliasFrom, + AliasTo: aliasTo, + ImportCommand: "insert+update", + Mapping: + [[iKeywordAttribute, { + DoIf: "'{2}' != ''", + attribute: "KEYNAME2", + attributeType: + $KeywordRegistry.keywordAttributeType$longChar(), + keywordContainer: 1, + keyword: 0, + keywordAttrRelValue: 2 + }], + [iKeywordAttribute, { + DoIf: "'{3}' != ''", + attribute: "KEYDESCRIPTION", + attributeType: + $KeywordRegistry.keywordAttributeType$longChar(), + keywordContainer: 1, + keyword: 0, + keywordAttrRelValue: 3 + }], + [iKeywordAttribute, { + DoIf: "'{4}' != ''", + attribute: "KEYDETAIL", + attributeType: + $KeywordRegistry.keywordAttributeType$longChar(), + keywordContainer: 1, + keyword: 0, + keywordAttrRelValue: 4 + }] + ] + } +} +/** + * Function to import previous ASYS_USERS into ASYS_USERS + * Only preferences that are necessary and exclude old roles + */ +function getConfig_ASYS_USERS() +{ + return { + DataQuery: + "select" + + " ID," // 0 + + " GROUPID," // 1 + + " NAME," // 2 + + " PROPKEY," // 3 + + " PROPVAL," // 4 + + " PROPVAL_CLOB"// 5 + + " from asys_users" + + " where GROUPID in ('ROLE','PERSONAL', 'PASSWORD', 'OTHER', 'EXCHANGE', 'BASIC')" + + " and PROPKEY in ('calendarID','email','exchangeAlias','exchangeEMail','firstname','lastname','isActive'," + + " 'name','password','roleNames','title') and PROPVAL != 'XMPP_OK'" , + + AliasFrom: aliasFrom, + AliasTo: "_____SYSTEMALIAS", + ImportCommand: "insert+update", + + Mapping: [ + [iMove, { + Source:0, + Target: "asys_users.ID", + Key: true + }], //ID + [iMove, { + Source:1, + Target: "asys_users.GROUPID" + }], //GROUPID + [iMove, { + Source:2, + Target: "asys_users.NAME" + }], //NAME + [iMove, { + Source:3, + Target: "asys_users.PROPKEY" + }], //PROPKEY + [iMove, { + Source:4, + Target: "asys_users.PROPVAL" + }], //PROPVAL + [iMove, { + Source:5, + Target: "asys_users.PROPVAL_CLOB" + }], //PROPVAL_CLOB + [iMove, { + DoIf: "'{3}' == 'title'", + Value: '"{2}".substr(10)', + Eval: true, + Target: "var.Objectrowid" + }], + [iSql, { + Alias: "_____SYSTEMALIAS", + Command: "select ID from ASYS_USERS" + + " where NAME = '{2}'" + + " and PROPKEY ='contactID'", + Target: "var.LoginID" + }], + [iSql, { + DoIf: "'{3}' == 'title'", + Alias: aliasFrom, + Command: "select RELATION_ID From EMPLOYEE where LOGIN = '{4}'", + Target: "var.Contactid" + }], + [iInsertUpdate, { + DoIf: "'{3}' == 'title' && '{var.Contactid}' != ''", + Condition: "ID = '{var.LoginID}'", + Table: "ASYS_USERS", + Alias: "_____SYSTEMALIAS", + Columns: [ + { + Name: "ID", + Key: true + }, + { + Value: "BASIC", + Name: "GROUPID" + }, //GROUPID + { + Source:2, + Name: "NAME" + }, //NAME + { + Value: "contactID", + Name: "PROPKEY" + }, //PROPKEY + { + Value: "{var.Contactid}", + Name: "PROPVAL" + } + ] + } ] + ] + } +} + +function getConfig_AOSYS_CALENDAR_RIGHTS() { + +} + +//@TODO clarify if date based condition, not all data may be needed +function getConfig_AOSYS_LOGHIST() { + +} + +function getConfig_AOSYS_SYNCCONTACT() { + +} + +//@TODO clarify if needed, might be filled by ADITO core +function getConfig_ASYS_CALENDARSYNC() { + +} + +//@TODO clarify if date based condition, not all data may be needed +//because of new unlinked mail structure may be obsolete +function getConfig_ASYS_MAILREPOSIT() { + +} + +function getConfig_ASYS_NOTIFICATIONS() { + +} + +function getConfig_ASYS_SEQUENCES() { + +} + +function getConfig_ASYS_SYNCSLAVES() { + +} + +function getConfig_ATTROBJECT() { + +} + +function getConfig_BULKMAILDEF() { + +} + +function getConfig_BULKMAILRCPT() { + +} + +function getConfig_CAMPAIGN() { + +} + +function getConfig_CAMPAIGNCOST() { + +} + +function getConfig_CAMPAIGNLOG() { + +} + +function getConfig_CAMPAIGNPARTICIPANT() { + +} + +function getConfig_CAMPAIGNSTEP() { + +} + +function getConfig_COMMRESTRICTION() { + +} + +function getConfig_CONTRACT() { + +} + +function getConfig_COUNTRYINFO() { + +} + +function getConfig_DATA_PRIVACY() { + +} + +function getConfig_KNOWLEDGEMANAGEMENT() { + +} + +function getConfig_KNOWLEDGEMANAGEMENTKEYWORD() { + +} + +function getConfig_NODUPLICATE() { + +} + +function getConfig_OFFERITEM() { + +} + +function getConfig_ORDERITEM() { + +} + +function getConfig_PROD2PROD() { + +} + +function getConfig_PRODUCT() { + +} + +function getConfig_PRODUCTPRICE() { + +} + +function getConfig_SALESORDER() { + +} + +function getConfig_SALESPROJECT() { + +} + +function getConfig_SALUTATION() { + +} + +function getConfig_SPCYCLE() { + +} + +function getConfig_SPFORECAST() { + +} + +function getConfig_SPMEMBER() { + +} + +function getConfig_SPOURCES() { + +} + +function getConfig_STOCK() { + +} + +function getConfig_SUPPORTHISTORY() { + +} + +function getConfig_SUPPORTTICKET() { + +} + +function getConfig_DOCUMENT() { + +} + +function getConfig_UNLINKEDMAIL() { + +} + +/* +* Converts the imported histories infos to html-text +* @param {Integer} pBulksize req defines the bulksize to update the values +* +* @return {void} +*/ + +function migrateActivityInfoToHtml(pBulksize) +{ + var alias = aliasTo; + var arr = db.table("select INFO, ACTIVITYID from ACTIVITY", alias); + var upd = []; + var coltyp = db.getColumnTypes("ACTIVITY", ["INFO"], alias); + var count = 0; + var runs = parseInt(arr.length/pBulksize); + var rest = arr.lentgh - runs*pBulksize; + + //All runs, with a full bulk + for (j = 0; j < runs; j++) { + for (i = count; i < count+pBulksize; i++) { + if(arr[i][0].substr(0,5) != "<html>") + { + var str = "<html><body>" + + arr[i][0].replace(/\r/g, "").replace(/\n/g, "<br>").replace(/( )/g," ") + + "</body></html>"; + upd.push(["ACTIVITY", ["INFO"], coltyp, [str], "ACTIVITYID ='" + arr[i][1] + "'"]); + } + } + db.updates(upd, alias, datetime.ONE_HOUR); + upd = []; + count = count + pBulksize; + } + + //The remaining data + for (i = count; i < count+rest; i++) { + if(arr[i][0].substr(0,5) != "<html>") + { + str = "<html><body>" + + arr[i][0].replace(/\r/g, "").replace(/\n/g, "<br>").replace(/( )/g," ") + + "</body></html>"; + upd.push(["ACTIVITY", ["INFO"], coltyp, [str], "ACTIVITYID ='" + arr[i][1] + "'"]); + } + } + db.updates(upd, alias, datetime.ONE_HOUR); +} + + +/* +* Migrates additional data of Tasks with state 'needs-action' and 'in-process' +* @ToDo why an extra function? +* why not in getConfig_ASYS_CALENDARBACKEND? +*/ + +function migrateTasks(){ + + var data = db.table(newSelect(["DATASETID, VCOMPONENT, ORGANIZER, OWNER"], aliasFrom) + .from("ASYS_CALENDARBACKEND") + .where("ASYS_CALENDARBACKEND.ENTRYTYPE", "2") + .and("ASYS_CALENDARBACKEND.STATUS", "NEEDS-ACTION") + .or("ASYS_CALENDARBACKEND.STATUS", "IN-PROCESS") + .build(), aliasFrom); + + var tbl = "TASK"; + var statements = []; + + for (i = 0; i < data.length; i++) { + + var vals = []; + var cols = []; + var obj = data[i]; + + var valDescription = obj[1].toString().match(new RegExp("DESCRIPTION:" + ".+\r")); + var valPriority = obj[1].toString().match(new RegExp("PRIORITY:.+\r")); + var valProgress = obj[1].toString().match(new RegExp("PROGRESS:.+\r")); + + if(valDescription != null) + { + valDescription = valDescription.toString().split(":")[1].replace(/\\N/g, " ").replace(/\\R/g, " "); + vals.push(valDescription); + cols.push("DESCRIPTION"); + } + if(valPriority != null) + { + valPriority = valPriority.toString().split(":")[1]; + if(valPriority == 0) // Keine + valPriority = "TASKPRIONONE"; + if(valPriority == 1) // Hoch + valPriority = "TASKPRIOHIGH"; + if(valPriority == 5) // Normal + valPriority = "TASKPRIOMEDIUM"; + if(valPriority == 9) // Niedrig + valPriority = "TASKPRIOLOW"; + vals.push(valPriority); + cols.push("PRIORITY"); + } + + if(valProgress != null) + { + valProgress = valProgress.toString().split(":")[1]; + if(valProgress < 25) + valProgress = 0; + else if(valProgress >= 25 && valProgress < 50) + valProgress = 25; + else if(valProgress >= 50 && valProgress < 75) + valProgress = 50; + else if(valProgress >= 75 && valProgress < 100) + valProgress = 75; + else if(valProgress == 100) + valProgress = 100; + else + valProgress = 0; + + vals.push(valProgress); + cols.push("PROGRESS"); + } + + var valReqmail = text.decodeMS(obj[3])[0].substr("mailto:".length); + var valReq = db.cell("SELECT PROPVAL FROM asys_users" + + " WHERE PROPKEY = 'contactId' AND NAME = (SELECT NAME FROM ASYS_USERS WHERE PROPKEY = 'calendarId' " + +" AND PROPVAL = '" + valReqmail +"')", "_____SYSTEMALIAS"); + if(valReq != null) + { + vals.push(valReq); + cols.push("REQUESTOR_CONTACT_ID"); + } + + var valEditormail = text.decodeMS(obj[2])[0].substr("mailto:".length); + var valEditor = db.cell("SELECT PROPVAL FROM asys_users" + + " WHERE PROPKEY = 'contactId' AND NAME = (SELECT NAME FROM ASYS_USERS WHERE PROPKEY = 'calendarId' " + +" AND PROPVAL = '" + valEditormail +"')", "_____SYSTEMALIAS"); + if(valEditor != null) + { + vals.push(valEditor); + cols.push("EDITOR_CONTACT_ID"); + } + + var colTyps = db.getColumnTypes(tbl, cols, aliasTo); + var cond = "TASKID ='" + obj[0] + "'"; + var state = [tbl, cols, colTyps, vals, cond] + statements.push(state) + } + var upd = db.updates(statements, aliasTo); +} \ No newline at end of file diff --git a/process/upgrade_ImporterCustomMappingFunctions_lib/upgrade_ImporterCustomMappingFunctions_lib.aod b/process/upgrade_ImporterCustomMappingFunctions_lib/upgrade_ImporterCustomMappingFunctions_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..8c1406f868edd543fb2ad7a7290cbaee65a5a262 --- /dev/null +++ b/process/upgrade_ImporterCustomMappingFunctions_lib/upgrade_ImporterCustomMappingFunctions_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.2.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.2"> + <name>upgrade_ImporterCustomMappingFunctions_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/upgrade_ImporterCustomMappingFunctions_lib/process.js</process> +</process> diff --git a/process/upgrade_MigrateAllData_serverProcess/process.js b/process/upgrade_MigrateAllData_serverProcess/process.js new file mode 100644 index 0000000000000000000000000000000000000000..75a19cb67a160b8c79dd4712bf84ad0065ba35c0 --- /dev/null +++ b/process/upgrade_MigrateAllData_serverProcess/process.js @@ -0,0 +1,10 @@ +import("upgrade_ImporterCustomMappingFunctions_lib"); + +var myArray = []; + +myArray.push("ORG"); +myArray.push("PERS"); +// the binaries have to outsourced BEFORE or simultaneously with the migration +myArray.push("ASYS_BINARIES"); + +runImport(myArray); \ No newline at end of file diff --git a/process/upgrade_MigrateAllData_serverProcess/upgrade_MigrateAllData_serverProcess.aod b/process/upgrade_MigrateAllData_serverProcess/upgrade_MigrateAllData_serverProcess.aod new file mode 100644 index 0000000000000000000000000000000000000000..dab0271831c16ad56819dab23ae2629d0d894458 --- /dev/null +++ b/process/upgrade_MigrateAllData_serverProcess/upgrade_MigrateAllData_serverProcess.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.2"> + <name>upgrade_MigrateAllData_serverProcess</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/upgrade_MigrateAllData_serverProcess/process.js</process> + <variants> + <element>EXECUTABLE</element> + </variants> +</process>