Skip to content
Snippets Groups Projects
Commit 4f6fd4cc authored by Gerhard Bachmaier's avatar Gerhard Bachmaier
Browse files

1066189: Gebiet: Administratives Prüf-Cockpit

parents 753d04eb 772ae952
No related branches found
No related tags found
No related merge requests found
Showing
with 162 additions and 14 deletions
......@@ -23,6 +23,8 @@
<consumer>Organisations</consumer>
<groupable v="true" />
<linkedContext>Person</linkedContext>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/contact_id/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/contact_id/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
......@@ -142,6 +144,12 @@
<entityName>DistrictResponsible_entity</entityName>
<fieldName>DistrictResponsibleAdvisers</fieldName>
</dependency>
<children>
<entityParameter>
<name>DistrictId_param</name>
<valueProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/advisers/children/districtid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
<name>Districts</name>
......@@ -176,6 +184,14 @@
<name>currentOrganisationId_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>ObjectId_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>RowId_param</name>
<expose v="true" />
</entityParameter>
<entityActionGroup>
<name>setStatus</name>
<children>
......
import("system.vars");
import("system.result");
result.string(vars.get("$field.DISTRICT_ID"));
\ No newline at end of file
import("system.result");
import("system.vars");
result.string(vars.get("$param.currentOrganisationId_param"));
\ No newline at end of file
......@@ -6,6 +6,13 @@ import("Sql_lib");
var organisationID = vars.get("$param.currentOrganisationId_param");
var cond = newWhere();
if (vars.exists("$param.RowId_param") && vars.get("$param.RowId_param") && vars.exists("$param.ObjectId_param") && vars.get("$param.ObjectId_param"))
{
cond.and("DISTRICTCONTACT.ADVISER_CONTACT_ID", newSelect("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID")
.from("DISTRICTRESPONSIBLE")
.where("DISTRICTRESPONSIBLE.DISTRICTRESPONSIBLEID", "$param.RowId_param")
, SqlBuilder.IN());
}
if (organisationID)
{
cond.and("DISTRICTCONTACT.CONTACT_ID", organisationID);
......
......@@ -5,6 +5,7 @@
<documentation>%aditoprj%/entity/DistrictResponsible_entity/documentation.adoc</documentation>
<icon>VAADIN:GLOBE</icon>
<title>District Responsible</title>
<grantDeleteProcess>%aditoprj%/entity/DistrictResponsible_entity/grantDeleteProcess.js</grantDeleteProcess>
<contentTitleProcess>%aditoprj%/entity/DistrictResponsible_entity/contentTitleProcess.js</contentTitleProcess>
<iconIdProcess>%aditoprj%/entity/DistrictResponsible_entity/iconIdProcess.js</iconIdProcess>
<image>VAADIN:GLOBE</image>
......@@ -21,6 +22,7 @@
<linkedContext>Person</linkedContext>
<mandatory v="true" />
<selectionMode>SINGLE</selectionMode>
<stateProcess>%aditoprj%/entity/DistrictResponsible_entity/entityfields/employee_contact_id/stateProcess.js</stateProcess>
<displayValueProcess>%aditoprj%/entity/DistrictResponsible_entity/entityfields/employee_contact_id/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
......@@ -209,6 +211,10 @@
<valueProcess>%aditoprj%/entity/DistrictResponsible_entity/entityfields/adviserstates/children/containername_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>ExcludedKeyIdsSubquery_param</name>
<valueProcess>%aditoprj%/entity/DistrictResponsible_entity/entityfields/adviserstates/children/excludedkeyidssubquery_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityField>
......
import("system.result");
import("KeywordRegistry_basic");
import("Sql_lib");
var cond = newSelect("AB_KEYWORD_ENTRY.KEYID")
.from("AB_KEYWORD_ENTRY")
.where("AB_KEYWORD_ENTRY.CONTAINER", $KeywordRegistry.contactStatus())
.and("AB_KEYWORD_ENTRY.KEYID", $KeywordRegistry.contactStatus$inReview(), SqlBuilder.LIKE());
result.string(cond.toString());
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
import("Sql_lib");
import("system.db");
var cond = newWhere();
var test = newSelect("COUNT(*)")
.from("DISTRICTCONTACT")
.join("DISTRICTRESPONSIBLE", "DISTRICTCONTACT.ADVISER_CONTACT_ID = DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID")
.where("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID", vars.get("$field.EMPLOYEE_CONTACT_ID"))
.arrayColumn()[0];
if(test.toString() == 0){
result.string(neon.COMPONENTSTATE_EDITABLE);
}
else{
result.string(neon.COMPONENTSTATE_READONLY);
}
\ No newline at end of file
import("Context_lib");
import("system.vars");
import("system.result");
import("Entity_lib");
var rowId = vars.get("$field.DISTRICTRESPONSIBLEID");
var currentContext = ContextUtils.getCurrentContextId();
var canDelete = new HasLinkedObjectTester()
.andNoEntityRows("DistrictContact_entity", "DistrictContacts", {ObjectId_param : currentContext, RowId_param : rowId}) //District Contact
.validate();
result.string(canDelete);
\ No newline at end of file
import("system.logging");
import("Contact_lib");
import("KeywordRegistry_basic");
import("system.vars");
import("system.util");
......@@ -103,25 +105,35 @@ DistrictUtils.assignDistrictOnServer = function (pArrDistrictIds, pUser)
* Id of the district.<br>
* @param {String} pAppliedFilter <p>
* Filter condition to get the assigned companies.<br>
* @param {String} pContactId (opt) <p>
* Only filled when a special contact-ID should assigned to a district.<br>*
* @return {Object} <p>
* Count of new assigned companies and no longer assigned companies.<br>
*/
DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter)
DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId)
{
if (pContactId == undefined)
pContactId = null;
var newAssigned = 0;
var unchanged = 0;
var invalid = 0;
//Einlesen von allen bereits existierenden automatischen Zuordnungen,
//die nicht auf Status 'zur Prüfung' sthen
var arrExistingIds = new SqlBuilder()
.select("DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID")
.from("DISTRICTCONTACT")
.where("DISTRICTCONTACT.DISTRICT_ID", pDistrictId)
.and ("DISTRICTCONTACT.ORIGIN", $KeywordRegistry.districtOrigin$auto())
.and ("DISTRICTCONTACT.STATUS", $KeywordRegistry.contactStatus$inReview(), SqlBuilder.NOT_EQUAL())
.table();
//die nicht auf Status 'zur Prüfung' stehen
//Nur notwendig, wenn pContactId leer ist. Ansonsten soll ja gezielt ein neuer Datensatz angelegt werden
var arrExistingIds = []
if (!pContactId)
{
arrExistingIds = new SqlBuilder()
.select("DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID")
.from("DISTRICTCONTACT")
.where("DISTRICTCONTACT.DISTRICT_ID", pDistrictId)
.and ("DISTRICTCONTACT.ORIGIN", $KeywordRegistry.districtOrigin$auto())
.and ("DISTRICTCONTACT.STATUS", $KeywordRegistry.contactStatus$inReview(), SqlBuilder.NOT_EQUAL())
.table();
}
//Einlesen aller Betreuer, die dem übergebenen Gebiet zugeordnet sind
var arrResponsibleIds = new SqlBuilder()
.select("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID, DISTRICTRESPONSIBLE.ADVISER_ROLE, " +
......@@ -129,12 +141,13 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter)
.from("DISTRICTRESPONSIBLE")
.where("DISTRICTRESPONSIBLE.DISTRICT_ID", pDistrictId)
.table();
//Aufbereiten des im JSON-Format übergebenen Filters in eine SQL-Condition
var appliedFilterCondition = JSON.parse(pAppliedFilter).filter;
appliedFilterCondition = JSON.stringify(appliedFilterCondition);
appliedFilterCondition = JSON.stringify(appliedFilterCondition);
logging.log("appliedFilterCondition: " + appliedFilterCondition);
var sqlCondition = db.toFilterCondition(appliedFilterCondition, "Organisation_entity")
logging.log("sqlCondition: " + sqlCondition)
//Einlesen der Contact-IDs zu den Firmen, die gemäß Filter diesem Gebiet zugeordnet sind
var arrOrgContactIds = new SqlBuilder()
.selectDistinct("CONTACT.CONTACTID")
......@@ -143,8 +156,9 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter)
.leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID")
.leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID")
.whereIfSet(sqlCondition)
.andIfSet("CONTACT.CONTACTID", pContactId)
.arrayColumn();
logging.log("arrOrgContactIds.length: " + arrOrgContactIds.length)
var insertArray = [];
var colsInsert = [
"DISTRICTCONTACTID",
......@@ -370,4 +384,51 @@ DistrictUtils.setDistrictContactStatus = function (pArrIds, pStatus)
updateArray.push(["DISTRICTCONTACT", colsUpdate, null, valsUpdate, condition.build()]);
}
db.updates(updateArray);
}
/**
* This function will assign a new organisation to all districts, which
* - have the property "auto assignment"
* - and are part of the regarding filter
* @param {String} pOrganisationId <p>
* Organisation-ID of the new Organisation<br>
* @param {String} pUserLogin <p>
* login,who created the new organistion<br>
* @return <none> <p>
*/
DistrictUtils.assignOrganisationToDistrict = function (pOrganisationId, pUserLogin)
{
//contactid zur organisationid ermitteln
var contactId = ContactUtils.getOrgContactId(pOrganisationId);
//alle Filter ermitteln, die auf auto-assignment gleich true gesetzt sind
var allAutoDistricts = newSelect("DISTRICTID")
.from("DISTRICT")
.where("DISTRICT.DISTRICT_AUTOADD", 1)
.arrayColumn();
//TODO: pUserLogin noch bis zum Schreiben von date_new durchschleusen
logging.log("pUerLogin: " + pUserLogin)
//Variante 1
for (var i=0; i<allAutoDistricts.length; i++)
{
logging.log("allAutoDistricts[i]: " + allAutoDistricts[i]);
//pro District den kompletten Filter ermitteln
var districtData = DistrictUtils.getDataFromDistrict(allAutoDistricts[i]);
var completeFilter = DistrictUtils.getAppliedFilter(districtData[0], districtData[1])
//logging.log("completeFilter: " + completeFilter)
//prüfen, ob die neue contactid im filter enthalten wäre
//und im Erfolgsfall die Daten in der districtcontact anlegen
//TODO: pUserLogin als 4ten Parameter übergeben. Wenn gefüllt, diesen als USER_NEW/EDIT setzen, sonst den sys.user verwenden
var res = DistrictUtils.assignDistrict(allAutoDistricts[i], completeFilter, contactId);
}
//Variante 2: Aufruf des Server-Prozessen mit allen Gebieten mit Auto-Zuordnung gleich true
//Wirft den gleichen Fehler wie Variante 1
//TODO: Aus dem pUserLogin noch die Employee-ID ermitteln
//DistrictUtils.assignDistrictOnServer(allAutoDistricts, pUserLogin);
}
\ No newline at end of file
import("District_lib");
import("Loghistory_lib");
import("system.vars");
import("system.process");
......@@ -15,3 +16,9 @@ if (sqlAction != 'X')
{
(new LogHistoryExecutor(tableName, userLogin, columns, newvalues, oldvalues, timestamp, sqlAction, id)).execute();
}
//Ticketnummer: 1066031
//if (sqlAction == 'I' && tableName == 'ORGANISATION')
//{
// DistrictUtils.assignOrganisationToDistrict(id, userLogin);
//}
\ No newline at end of file
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