Skip to content
Snippets Groups Projects
Commit 5c266cc4 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

merged origin/1070913_ClassificationUpdateServerProcessCompleteRecalculating into 2021.0.0

parents 4678f46e 24f9ec4e
No related branches found
No related tags found
No related merge requests found
......@@ -92,9 +92,17 @@
<children>
<entityActionField>
<name>UpdateClassification</name>
<title>Recalculate all Classifications</title>
<title>Recalculate Classifications</title>
<onActionProcess>%aditoprj%/entity/ClassificationAdmin_entity/entityfields/filterviewactiongroup/children/updateclassification/onActionProcess.js</onActionProcess>
<iconId>VAADIN:AUTOMATION</iconId>
<tooltip>Starts the serverprocess manually, which will recalculate all (potentially) outdated classifications. Use this after changes to the configuration of classifications.</tooltip>
</entityActionField>
<entityActionField>
<name>UpdateAllClassifications</name>
<title>Recalculate all Classifications</title>
<onActionProcess>%aditoprj%/entity/ClassificationAdmin_entity/entityfields/filterviewactiongroup/children/updateallclassifications/onActionProcess.js</onActionProcess>
<iconId>VAADIN:AUTOMATION</iconId>
<tooltip>Starts the serverprocess manually, which will recalculate all classifications from scratch. Only do this after e.g importing data from elsewhere where the outdated flag couldn't been set correctly. Since this can take some time.</tooltip>
</entityActionField>
</children>
</entityActionGroup>
......
import("system.process");
import("system.question");
import("system.text");
import("system.translate");
import("system.util");
import("system.vars");
var execute = question.askYesNo(translate.text("Start Serveprocess"), translate.text("Are you sure you want to recalculate all classifications using the current classificationgradings? This can take some time, since ALL classifications will get freshly calculated and updated if needed."), false);
if(execute)
{
var processConfig = process.createStartAsyncConfig()
.setName("updateClassifications_serverProcess")
.setUser( vars.get("$sys.user"))
.setThreadPriority(process.THREADPRIORITY_LOW)
.setTimerType(process.TIMERTYPE_SERVER)
.setLocalVariables({"recalculateAll_param" : true});
process.startAsync(processConfig);
question.showMessage(translate.text("Serverprocess has been started"), question.INFORMATION, translate.text("Classification"));
}
......@@ -8061,6 +8061,18 @@
<entry>
<key>by sorting</key>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all (potentially) outdated classifications. Use this after changes to the configuration of classifications.</key>
</entry>
<entry>
<key>Recalculate Classifications</key>
</entry>
<entry>
<key>Are you sure you want to recalculate all classifications using the current classificationgradings? This can take some time, since ALL classifications will get freshly calculated and updated if needed.</key>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all classifications from scratch. Only do this after e.g importing data from elsewhere where the outdated flag couldn't been set correctly. Since this can take some time.</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -9552,6 +9552,22 @@ Bitte Datumseingabe prüfen</value>
<key>Recalculate all Classifications</key>
<value>Alle Klassifizierungen neuberechnen</value>
</entry>
<entry>
<key>Recalculate Classifications</key>
<value>Klassifizierungen neuberechnen</value>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all (potentially) outdated classifications. Use this after changes to the configuration of classifications.</key>
<value>Startet den Serverprozess Manuell. Berechnet alle (potenziell) veralteten Klassifizierungen. Benutze dies nach Änderungen an den Klassifizierungseinstellungen.</value>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all classifications from scratch. Only do this after e.g importing data from elsewhere where the outdated flag couldn't been set correctly. Since this can take some time.</key>
<value>Startet den Serverprozess Manuell. Berechnet alle Klassifizierungen neu. Benutze dies nur nach z.B dem Importieren von Daten von ausserhalb des Systems bei denen der outdated flag nciht richtig gesetzt wurde, da dieser Durchlauf länger dauen kann</value>
</entry>
<entry>
<key>Are you sure you want to recalculate all classifications using the current classificationgradings? This can take some time, since ALL classifications will get freshly calculated and updated if needed.</key>
<value>Sind sie sich sicher, dass sie alle Klassifizierungen anhand der konfigurierten Bewertungen neuberechnen willst? Dies kann länger dauern, da ALLE Klassifizierungen neuberechnet werden und wenn nötig geupdated werden.</value>
</entry>
<entry>
<key>Reminder:</key>
<value>Erinnerung:</value>
......
......@@ -8142,6 +8142,18 @@
<entry>
<key>Offer exists</key>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all (potentially) outdated classifications. Use this after changes to the configuration of classifications.</key>
</entry>
<entry>
<key>Recalculate Classifications</key>
</entry>
<entry>
<key>Are you sure you want to recalculate all classifications using the current classificationgradings? This can take some time, since ALL classifications will get freshly calculated and updated if needed.</key>
</entry>
<entry>
<key>Starts the serverprocess manually, which will recalculate all classifications from scratch. Only do this after e.g importing data from elsewhere where the outdated flag couldn't been set correctly. Since this can take some time.</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -30,6 +30,7 @@ var classificationStorageObject = {}; //object to store the classificationstorag
var groupObject = {}; //groupObject is another helper object to store all the groupIds
var outdatedClassificationTypeObj = {};//object to store all outdated classificationtypes (need so we can add empty persisted data later
var alreadyUpdatedTypesObj = {};
var storedClassificationValues = {};
//arrays mainly used for filling the objects
var objectTypes = [];
......@@ -43,6 +44,7 @@ var scoreArray = [];
var objectTypesThatNeedUpdate = [];
var outdatedStoredClassifications = [];
var objectRowIdArray = [];
var objectsThatWillBeUpdated = [];
var object_type, classificationGroupId, classificationTypeId, classificationScoreId, classificationScore, classificationGradingId, score, cond,
classificationGradingMaxScore, classificationGrading, chainedGrading, currentObjectColumn, currentObjectTable, isOrganisation, bestValue, minPercent,
......@@ -52,23 +54,36 @@ var table = "CLASSIFICATIONSTORAGE";
var column = ["CLASSIFICATIONVALUE"];
var runUpdating = 0;
var singleRefresh = false;
var recalculateAll = 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
if(!singleRefresh)
else if(vars.exists("$local.recalculateAll_param") && vars.get("$local.recalculateAll_param"))
{
recalculateAll = vars.get("$local.recalculateAll_param");
}
if(singleRefresh)
{
outdatedGroupsAndObjectTypes = newSelect("CLASSIFICATIONTYPE.OBJECT_TYPE, CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE.FILTER")
.from("CLASSIFICATIONTYPE")
.where("CLASSIFICATIONTYPE.OUTDATED", 1)
.where("CLASSIFICATIONTYPE.OBJECT_TYPE", vars.get("$local.ObjectType_param"))
.table();
}
else
else if(recalculateAll)
{
outdatedGroupsAndObjectTypes = newSelect("CLASSIFICATIONTYPE.OBJECT_TYPE, CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE.FILTER")
.from("CLASSIFICATIONTYPE")
.where("CLASSIFICATIONTYPE.OBJECT_TYPE", vars.get("$local.ObjectType_param"))
.table();
}
else //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")
.from("CLASSIFICATIONTYPE")
.where("CLASSIFICATIONTYPE.OUTDATED", 1)
.table();
}
......@@ -112,13 +127,45 @@ for (i = 0; i < outdatedGroupsAndObjectTypes.length; i++)
}
if(!singleRefresh)
{
//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")
if(recalculateAll)
{
outdatedStoredClassifications = newSelect("CLASSIFICATION.OBJECT_TYPE, CLASSIFICATION.OBJECT_ROWID\n\
,"+ SqlBuilder.caseWhen(newWhere("CLASSIFICATIONSTORAGE.CLASSIFICATIONSTORAGEID is null"))
.then("''")
.elseValue("CLASSIFICATIONSTORAGE.CLASSIFICATIONSTORAGEID")
.toString()+ "\n\
,"+ SqlBuilder.caseWhen(newWhere("CLASSIFICATIONSTORAGE.CLASSIFICATIONVALUE is null"))
.then("''")
.elseValue("CLASSIFICATIONSTORAGE.CLASSIFICATIONVALUE")
.toString()+
", CLASSIFICATION.CLASSIFICATIONTYPE_ID, CLASSIFICATION.VALUE, CLASSIFICATION.SCOREPOINTS")
.from("CLASSIFICATION")
.leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CLASSIFICATION.OBJECT_ROWID")
.orderBy("CLASSIFICATION.OBJECT_TYPE, CLASSIFICATION.OBJECT_ROWID")
.table();
}
else
{
//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();
}
var storedClassificationStorageValues = {};
if(recalculateAll)
{
let storedValuesArray = newSelect("CLASSIFICATIONSTORAGE.OBJECT_ROWID")
.from("CLASSIFICATIONSTORAGE")
.arrayColumn();
storedValuesArray.map(function(objRowId){
storedClassificationStorageValues[objRowId] = "";
});
}
helperObject = {};
if(outdatedStoredClassifications)
{
......@@ -127,13 +174,17 @@ if(!singleRefresh)
{
for (ii = 0; ii < outdatedStoredClassifications[i].length; ii++)
{
[object_type, object_rowId, classificationStorageId, classificationScore] = outdatedStoredClassifications[i];
[object_type, object_rowId, classificationStorageId, classificationScore, classificationTypeId, classificationValue, classificationScorePoints] = outdatedStoredClassifications[i];
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(recalculateAll)
{
storedClassificationValues[object_type] = {};
}
}
if(!helperObject.hasOwnProperty(object_rowId)) //objectRowId
......@@ -141,13 +192,21 @@ if(!singleRefresh)
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(recalculateAll)
{
storedClassificationValues[object_type][object_rowId] = {"classificationTypeId": classificationTypeId, "classificationValue": classificationValue, "classificationScorePoints":classificationScorePoints};
if(!storedClassificationStorageValues.hasOwnProperty(object_rowId))//if the dataset doesn't have an classificationStorage dataset but does have classification datasets -> insert it here
{
db.insertData("CLASSIFICATIONSTORAGE", ["CLASSIFICATIONSTORAGEID", "CLASSIFICATIONVALUE", "OBJECT_ROWID", "OBJECT_TYPE", "OUTDATED"], null, [util.getNewUUID(), "-", object_rowId, object_type, 1])
}
}
}
}
}
}
}
if(outdatedStoredClassifications.length > 0)
}
if(outdatedStoredClassifications.length > 0 && !recalculateAll)
{ storedClassificationFlag = true; //this variable can easily be checked to see what we are updating
runUpdating++;
}
......@@ -497,6 +556,11 @@ for (xyz = 0; xyz < runUpdating; xyz++)
outputInformation[objectTypes[i]].persistentDatasetsUpdated++;
helperObject[uid + classificationTypeId] = "";
if(recalculateAll)
{
// if(storedClassificationValues[objectTypes[i]][uid][""])
}
}
}
}
......@@ -505,13 +569,13 @@ for (xyz = 0; xyz < runUpdating; xyz++)
{
correctCondition = newWhere(currentObjectColumn, vars.get("$local.ObjectRowid_param"));
}
else if(!storedClassificationFlag)
else if(storedClassificationFlag)
{
correctCondition = newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID", groupsThatNeedUpdate, SqlBuilder.IN());
correctCondition = newWhere(currentObjectColumn, objectRowIdArray, SqlBuilder.IN());
}
else
{
correctCondition = newWhere(currentObjectColumn, objectRowIdArray, SqlBuilder.IN());
correctCondition = newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID", groupsThatNeedUpdate, SqlBuilder.IN());
}
achievedScoresStmt = newSelect(currentObjectColumn + ", CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID, \n\
......@@ -543,7 +607,7 @@ for (xyz = 0; xyz < runUpdating; xyz++)
.where(correctCondition);
if(isOrganisation)
bestPossibleScoreStmt.and("CONTACT.PERSON_ID is null");
bestPossibleScoreStmt.orderBy(currentObjectColumn + ", CLASSIFICATIONTYPE.CLASSIFICATIONGROUP_ID");
bestPossibleScoresGroupObj = {};
......@@ -563,7 +627,6 @@ for (xyz = 0; xyz < runUpdating; xyz++)
//If this would be done in the batch function it would result in false classificationstorage-results because not all records for a rowId have been used
for (var row_Id in achievedScoresObj)
{
chainedGrading = classificationStorageObject[objectTypes[i]][row_Id][1];
for (var groupId in achievedScoresObj[row_Id])
......@@ -577,6 +640,10 @@ for (xyz = 0; xyz < runUpdating; xyz++)
break;
}
}
while(chainedGrading.length < position + 1)
{
chainedGrading += "-"
}
if(achievedScoresObj[row_Id][groupId]["Grade"] != undefined)
chainedGrading = StringUtils.replaceAt(chainedGrading, position, achievedScoresObj[row_Id][groupId]["Grade"]); //update the stored classificationString for each dataset
else
......@@ -819,7 +886,7 @@ function _buildBestPossibleScoresGroupObjFn(pBatchData, pBatchNum)
}
if(!helperObject.hasOwnProperty(uid + classificationTypeId)) //classificationType
{
if(_isRelevant() != false)
if(_isRelevant())
{
if(bestPossibleScoresGroupObj[uid][classificationGroupId] == "")
bestPossibleScoresGroupObj[uid][classificationGroupId] = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment