Kommentare angepasst
This commit is contained in:
@@ -26,7 +26,7 @@ public class Hooks
|
|||||||
@Entrypoint( entrypoint = "hook_insert_entry_10" )
|
@Entrypoint( entrypoint = "hook_insert_entry_10" )
|
||||||
public int hookInsertEntry10(D3Interface d3, User user, DocumentType docType, Document doc)
|
public int hookInsertEntry10(D3Interface d3, User user, DocumentType docType, Document doc)
|
||||||
{
|
{
|
||||||
d3.log.error("START | hookInsertEntry10 ");
|
d3.log.info("START | hookInsertEntry10 ");
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// Prüfung, ob Ablage erlaubt ist / Geräte-/Produktakte | calb d.velop 2025.12.17 START
|
// Prüfung, ob Ablage erlaubt ist / Geräte-/Produktakte | calb d.velop 2025.12.17 START
|
||||||
@@ -110,7 +110,7 @@ public class Hooks
|
|||||||
|
|
||||||
String dokumentarten_geraeteakte_pruef = "DCHEA;DCHEP;DCHLP;DCHEC;DDFAD;DLAUF;DPDK1;DPDK2;DPDK3;DPDW1;DPDW2;DPDW3;DPRSP;DPR01;DTYPD;DTYPS;DVSAK";
|
String dokumentarten_geraeteakte_pruef = "DCHEA;DCHEP;DCHLP;DCHEC;DDFAD;DLAUF;DPDK1;DPDK2;DPDK3;DPDW1;DPDW2;DPDW3;DPRSP;DPR01;DTYPD;DTYPS;DVSAK";
|
||||||
|
|
||||||
// Eindeutig: Auftrags-Nr., Vertriebsbelegposition, Materialnummer, Fertigungsauftragsnummer und wenn angegeben, Serialnummer, außerdem Dokumentart ist eindeutig
|
// Eindeutig: Dokumentart, Auftrags-Nr., Vertriebsbelegposition, Materialnummer, Fertigungsauftragsnummer und, wenn angegeben, Serialnummer
|
||||||
if ( dokumentarten_geraeteakte_pruef.contains( docType.id() ) )
|
if ( dokumentarten_geraeteakte_pruef.contains( docType.id() ) )
|
||||||
{
|
{
|
||||||
def where = "";
|
def where = "";
|
||||||
@@ -139,7 +139,7 @@ public class Hooks
|
|||||||
// Prüfung ob Doppelablage bei Dokumentarten, bei denen das nicht vorgesehen ist / Geräte-/Produktakte | calb d.velop 2025.12.17 ENDE
|
// Prüfung ob Doppelablage bei Dokumentarten, bei denen das nicht vorgesehen ist / Geräte-/Produktakte | calb d.velop 2025.12.17 ENDE
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
d3.log.error("ENDE | hookInsertEntry10 ");
|
d3.log.info("ENDE | hookInsertEntry10 ");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
85
_Vorlagen/Groovy-Skripte/Beispiel für Dokumentklasse.groovy
Normal file
85
_Vorlagen/Groovy-Skripte/Beispiel für Dokumentklasse.groovy
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import com.dvelop.d3.server.Document
|
||||||
|
import com.dvelop.d3.server.DocumentClass
|
||||||
|
import com.dvelop.d3.server.DocumentType
|
||||||
|
import com.dvelop.d3.server.RepositoryField
|
||||||
|
import com.dvelop.d3.server.User
|
||||||
|
import com.dvelop.d3.server.UserGroup
|
||||||
|
import com.dvelop.d3.server.ValueSet
|
||||||
|
import com.dvelop.d3.server.core.D3Interface
|
||||||
|
|
||||||
|
class ValueSets {
|
||||||
|
|
||||||
|
@ValueSet(entrypoint = "AllowedVendorNumbers")
|
||||||
|
def allowedVendorNumbers(D3Interface d3, RepositoryField repoField, User user, DocumentType docType, Integer rowNo, Integer validate, Document attribContext) {
|
||||||
|
d3.log.warn("allowedVendorNumbers ValueSet reached")
|
||||||
|
def credNumbers = new LinkedList<String>()
|
||||||
|
|
||||||
|
// Gruppenberechtigungen aus DB lesen
|
||||||
|
def groups = user.groups
|
||||||
|
|
||||||
|
// Alle erlaubten Kreditorennummern hinzufügen
|
||||||
|
for (UserGroup group in groups) {
|
||||||
|
def groupResult = d3.sql.executeAndGet("SELECT KREDNR FROM STU_KREDITOREN_BERECHTIGUNGEN WHERE USERORGROUP = '${group.id()}'")
|
||||||
|
groupResult.forEach({ row ->
|
||||||
|
def value = row.get("KREDNR").toString()
|
||||||
|
if (!credNumbers.contains(value)) {
|
||||||
|
credNumbers.add(value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Userberechtigungen aus DB lesen
|
||||||
|
def userResult = d3.sql.executeAndGet("SELECT KREDNR FROM STU_KREDITOREN_BERECHTIGUNGEN WHERE USERORGROUP = '${user.id()}'")
|
||||||
|
userResult.forEach({ row ->
|
||||||
|
def value = row.get("KREDNR").toString()
|
||||||
|
if (!credNumbers.contains(value)) {
|
||||||
|
credNumbers.add(value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Ergebnis zurückgeben
|
||||||
|
repoField.provideValuesForValueSet(credNumbers)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rückgabe von 1 = Berechtigt, 0 = Zugriff verweigert
|
||||||
|
@DocumentClass(entrypoint = "vendorNumberAllowed")
|
||||||
|
int vendorNumberIsAllowed(D3Interface d3, String value, DocumentType docType, String userId, Document doc){
|
||||||
|
if (userId == null || userId == "") {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null || value == "") {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prüfe ob Kreditorennummer in User-Berechtigungen vorkommt, wenn ja Berechtigen (1)
|
||||||
|
def userResult = d3.sql.executeAndGet("SELECT KREDNR FROM STU_KREDITOREN_BERECHTIGUNGEN WHERE USERORGROUP = '${userId}'")
|
||||||
|
for (def row in userResult) {
|
||||||
|
d3.log.debug("current value: $value")
|
||||||
|
d3.log.debug("current row value: ${row.get("KREDNR").toString()}")
|
||||||
|
if (value == row.get("KREDNR").toString()) {
|
||||||
|
d3.log.debug("returning 1 for user")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gruppenzugehörigkeiten aus d.3 lesen
|
||||||
|
def groups = d3.archive.getUser(userId).groups
|
||||||
|
|
||||||
|
// Prüfe ob Kreditorennummer in Gruppen-Berechtigungen vorkommt, wenn ja Berechtigen (1)
|
||||||
|
for (UserGroup group in groups) {
|
||||||
|
def groupResult = d3.sql.executeAndGet("SELECT KREDNR FROM STU_KREDITOREN_BERECHTIGUNGEN WHERE USERORGROUP = '${group.id()}'")
|
||||||
|
for (def row in groupResult) {
|
||||||
|
d3.log.debug("current value: $value")
|
||||||
|
d3.log.debug("current row value: ${row.get("KREDNR").toString()}")
|
||||||
|
if (value.equalsIgnoreCase(row.get("KREDNR").toString().trim())) {
|
||||||
|
d3.log.debug("returning 1 for group ${group.id()}")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keine Berechtigung für Kreditorennummer gefunden, als nicht berechtigt zurückgeben
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user