From fcb5bc00cd5ad60852e76cf8a02010a01c77bd69 Mon Sep 17 00:00:00 2001 From: "b.ulrich" <b.ulrich@adito.de> Date: Tue, 19 Jan 2021 14:50:37 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20xRM][TicketNr.:?= =?UTF-8?q?=201071004][Klassifizierung:=20M=C3=B6glichkeit=20einen=20besti?= =?UTF-8?q?mmten=20Datensatz=20zu=20aktualisieren]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .liquibase/Data_alias/changelog.xml | 2 +- .../Classification_entity.aod | 13 +++ .../onActionProcess.js | 23 ++++ process/Classification_lib/process.js | 7 +- .../process.js | 103 ++++++++++++------ 5 files changed, 110 insertions(+), 38 deletions(-) create mode 100644 entity/Classification_entity/entityfields/fitlerviewactiongroup/children/refreshclassificationsofthisdataset/onActionProcess.js diff --git a/.liquibase/Data_alias/changelog.xml b/.liquibase/Data_alias/changelog.xml index e49dccc3c73..c6e5850fd70 100644 --- a/.liquibase/Data_alias/changelog.xml +++ b/.liquibase/Data_alias/changelog.xml @@ -22,5 +22,5 @@ <include relativeToChangelogFile="true" file="basic/2021.0.0/changelog.xml"/> <!--enable this only when you definetly want to overwrite the existing data with demo records:--> - <!--<include relativeToChangelogFile="true" file="basic/_demoData/changelog.xml" context="example"/>--> + <include relativeToChangelogFile="true" file="basic/_demoData/changelog.xml" context="example"/> </databaseChangeLog> diff --git a/entity/Classification_entity/Classification_entity.aod b/entity/Classification_entity/Classification_entity.aod index f742a84e6a9..7982c0fd617 100644 --- a/entity/Classification_entity/Classification_entity.aod +++ b/entity/Classification_entity/Classification_entity.aod @@ -154,6 +154,19 @@ <entityField> <name>DISPLAYVALUE</name> </entityField> + <entityActionGroup> + <name>fitlerviewActionGroup</name> + <title>Action</title> + <children> + <entityActionField> + <name>refreshClassificationsOfThisDataset</name> + <title>refresh classifications</title> + <onActionProcess>%aditoprj%/entity/Classification_entity/entityfields/fitlerviewactiongroup/children/refreshclassificationsofthisdataset/onActionProcess.js</onActionProcess> + <isObjectAction v="false" /> + <iconId>VAADIN:REFRESH</iconId> + </entityActionField> + </children> + </entityActionGroup> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/Classification_entity/entityfields/fitlerviewactiongroup/children/refreshclassificationsofthisdataset/onActionProcess.js b/entity/Classification_entity/entityfields/fitlerviewactiongroup/children/refreshclassificationsofthisdataset/onActionProcess.js new file mode 100644 index 00000000000..8fe0c851e97 --- /dev/null +++ b/entity/Classification_entity/entityfields/fitlerviewactiongroup/children/refreshclassificationsofthisdataset/onActionProcess.js @@ -0,0 +1,23 @@ +import("system.process"); +import("system.question"); +import("system.text"); +import("system.translate"); +import("system.util"); +import("system.vars"); + +var params = { + "refreshSingleRecord_param" : true, + "ObjectRowid_param" : vars.get("$param.ObjectRowid_param"), + "ObjectType_param" : vars.get("$param.ObjectType_param")} + +var processConfig = process.createStartAsyncConfig() + .setName("updateClassifications_serverProcess") + .setUser( vars.get("$sys.user")) + .setThreadPriority(process.THREADPRIORITY_LOW) + .setTimerType(process.TIMERTYPE_SERVER) + .setLocalVariables(params); + + +process.startAsync(processConfig); + +//question.showMessage(translate.text("Serverprocess has been started"), question.INFORMATION, translate.text("Classification")); \ No newline at end of file diff --git a/process/Classification_lib/process.js b/process/Classification_lib/process.js index c0754df5bf4..25419ec3b80 100644 --- a/process/Classification_lib/process.js +++ b/process/Classification_lib/process.js @@ -309,8 +309,11 @@ ClassificationUtils.setClassificationStorageDatasetsOutdated = function (pTarget //set outdated flag for the classificationStorage datasets if(relevantForClassification && classificationStorageIds.length > 0) // also check for the classificationStorageIds.length since it could be empty { - var cond = newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", classificationStorageIds, SqlBuilder.IN()); - cond.updateData(true, "CLASSIFICATIONSTORAGE", ["OUTDATED"], null, [1]); + for (i = 0; i < classificationStorageIds.length; i++) + { + var cond = newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", classificationStorageIds[i], SqlBuilder.IN()); + cond.updateData(true, "CLASSIFICATIONSTORAGE", ["OUTDATED"], null, [1]); + } } }; diff --git a/process/updateClassifications_serverProcess/process.js b/process/updateClassifications_serverProcess/process.js index db4ab9c2787..4bcfa2bb221 100644 --- a/process/updateClassifications_serverProcess/process.js +++ b/process/updateClassifications_serverProcess/process.js @@ -1,3 +1,4 @@ +import("system.vars"); import("Context_lib"); import("system.util"); import("Util_lib"); @@ -50,12 +51,26 @@ achievedScoresStmt, position, bestPossibleScoreStmt, storedClassificationFlag, d var table = "CLASSIFICATIONSTORAGE"; var column = ["CLASSIFICATIONVALUE"]; var runUpdating = 0; - +var singleRefresh = false; +if(vars.exists("$local.refreshSingleRecord_param") && vars.get("$local.refreshSingleRecord_param")) +{ + singleRefresh = vars.get("$local.refreshSingleRecord_param"); +} //all classificationgroups and their object_type that have atleast one classificationtype with the outdated flag set -outdatedGroupsAndObjectTypes = newSelect("CLASSIFICATIONTYPE.OBJECT_TYPE, CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE.FILTER") +if(!singleRefresh) +{ + outdatedGroupsAndObjectTypes = newSelect("CLASSIFICATIONTYPE.OBJECT_TYPE, CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE.FILTER") .from("CLASSIFICATIONTYPE") .where("CLASSIFICATIONTYPE.OUTDATED", 1) .table(); +} +else +{ + outdatedGroupsAndObjectTypes = newSelect("CLASSIFICATIONTYPE.OBJECT_TYPE, CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE.FILTER") + .from("CLASSIFICATIONTYPE") + .where("CLASSIFICATIONTYPE.OBJECT_TYPE", vars.get("$local.ObjectType_param")) + .table(); +} objectTypesThatNeedUpdate = []; for (i = 0; i < outdatedGroupsAndObjectTypes.length; i++) @@ -95,41 +110,42 @@ for (i = 0; i < outdatedGroupsAndObjectTypes.length; i++) helperObject[classificationTypeId] = ""; } } - -//object_type, object_rowId, classificationstorageId and the classificationstring (e.g. "ACB") of the classificationStorage datasets that habe the outdated flag set -outdatedStoredClassifications = newSelect("CLASSIFICATIONSTORAGE.OBJECT_TYPE, CLASSIFICATIONSTORAGE.OBJECT_ROWID, \n\ - CLASSIFICATIONSTORAGE.CLASSIFICATIONSTORAGEID, CLASSIFICATIONSTORAGE.CLASSIFICATIONVALUE") - .from("CLASSIFICATIONSTORAGE") - .where("CLASSIFICATIONSTORAGE.OUTDATED", 1) - .orderBy("OBJECT_TYPE") - .table(); -helperObject = {}; -if(outdatedStoredClassifications) +if(!singleRefresh) { - //build classificationStorageObject out of outdatedStoredClassifications - for (i = 0; i < outdatedStoredClassifications.length; i++) + //object_type, object_rowId, classificationstorageId and the classificationstring (e.g. "ACB") of the classificationStorage datasets that habe the outdated flag set + outdatedStoredClassifications = newSelect("CLASSIFICATIONSTORAGE.OBJECT_TYPE, CLASSIFICATIONSTORAGE.OBJECT_ROWID, \n\ + CLASSIFICATIONSTORAGE.CLASSIFICATIONSTORAGEID, CLASSIFICATIONSTORAGE.CLASSIFICATIONVALUE") + .from("CLASSIFICATIONSTORAGE") + .where("CLASSIFICATIONSTORAGE.OUTDATED", 1) + .orderBy("OBJECT_TYPE") + .table(); + helperObject = {}; + if(outdatedStoredClassifications) { - for (ii = 0; ii < outdatedStoredClassifications[i].length; ii++) + //build classificationStorageObject out of outdatedStoredClassifications + for (i = 0; i < outdatedStoredClassifications.length; i++) { - [object_type, object_rowId, classificationStorageId, classificationScore] = outdatedStoredClassifications[i]; - - if(!helperObject.hasOwnProperty(object_type)) //objectType + for (ii = 0; ii < outdatedStoredClassifications[i].length; ii++) { - classificationStorageObject[object_type] = {}; //puts objectType in classificationStorageObject and already initializes the object that later get's filled with the groups and their types - helperObject[object_type] = ""; - objectTypes.push(object_type); //also push all the objectTypes in an Array for later (the updating happens one objectType at a time) + [object_type, object_rowId, classificationStorageId, classificationScore] = outdatedStoredClassifications[i]; - } - if(!helperObject.hasOwnProperty(object_rowId)) //objectRowId - { - classificationStorageObject[object_type][object_rowId] = [classificationStorageId, classificationScore]; //same logic as before - helperObject[object_rowId] = ""; - objectRowIdArray.push(object_rowId); //also push all the objectTypes in an Array for later + if(!helperObject.hasOwnProperty(object_type)) //objectType + { + classificationStorageObject[object_type] = {}; //puts objectType in classificationStorageObject and already initializes the object that later get's filled with the groups and their types + helperObject[object_type] = ""; + objectTypes.push(object_type); //also push all the objectTypes in an Array for later (the updating happens one objectType at a time) + + } + if(!helperObject.hasOwnProperty(object_rowId)) //objectRowId + { + classificationStorageObject[object_type][object_rowId] = [classificationStorageId, classificationScore]; //same logic as before + helperObject[object_rowId] = ""; + objectRowIdArray.push(object_rowId); //also push all the objectTypes in an Array for later + } } } } -} - +} if(outdatedStoredClassifications.length > 0) { storedClassificationFlag = true; //this variable can easily be checked to see what we are updating @@ -225,8 +241,14 @@ for (xyz = 0; xyz < runUpdating; xyz++) } if(!storedClassificationFlag) // we already habe the classificationStorageObject if we are updating for the outdated classificationStorage { + let condIfSingle; + if(vars.exists("$local.ObjectRowid_param") && vars.get("$local.ObjectRowid_param")) + { + condIfSingle = newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", vars.get("$local.ObjectRowid_param")); + } classificationStorageArray = newSelect("OBJECT_TYPE, OBJECT_ROWID, CLASSIFICATIONSTORAGEID, CLASSIFICATIONVALUE") .from("CLASSIFICATIONSTORAGE") + .whereIfSet(condIfSingle) .orderBy("OBJECT_TYPE") .table(); helperObject = {}; //resets the helper object @@ -479,14 +501,17 @@ for (xyz = 0; xyz < runUpdating; xyz++) } } } - - if(!storedClassificationFlag) + if(singleRefresh) { - correctCondition = newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID", groupsThatNeedUpdate, SqlBuilder.IN()) + correctCondition = newWhere(currentObjectColumn, vars.get("$local.ObjectRowid_param")); + } + else if(!storedClassificationFlag) + { + correctCondition = newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID", groupsThatNeedUpdate, SqlBuilder.IN()); } else { - correctCondition = newWhere(currentObjectColumn, objectRowIdArray, SqlBuilder.IN()) + correctCondition = newWhere(currentObjectColumn, objectRowIdArray, SqlBuilder.IN()); } achievedScoresStmt = newSelect(currentObjectColumn + ", CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, \n\ @@ -632,7 +657,7 @@ for (xyz = 0; xyz < runUpdating; xyz++) } } - if(!storedClassificationFlag) + if(!storedClassificationFlag && !singleRefresh) { for (i = 0; i < scoreArray.length; i++) { let cond = newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", scoreArray[i][2]); @@ -809,10 +834,18 @@ function _buildBestPossibleScoresGroupObjFn(pBatchData, pBatchNum) function _insertPersistendClassificationDataIfNeeded() { - var objectsWithClassification = newSelect("distinct CLASSIFICATION.OBJECT_ROWID") + var objectsWithClassification; + if(singleRefresh) + { + objectsWithClassification = [vars.get("$local.ObjectRowid_param")]; + } + else + { + objectsWithClassification = newSelect("distinct CLASSIFICATION.OBJECT_ROWID") .from("CLASSIFICATION") .where("CLASSIFICATION.OBJECT_TYPE", objectTypes[i]) .arrayColumn(); + } for (z = 0; z < objectsWithClassification.length; z++) { uid = objectsWithClassification[z]; -- GitLab