Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for ERMS-6075 #2227

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions documentation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

**Ticket Date Branch Version(current) Author Feature/Bug Description/Keywords**

6075 23.12.2024 dev 3.5 Andreas Feature Umstellung der Exports auf mehrstufiges Ladeverfahren

6068 23.12.2024 dev 3.5 Andreas Feature Tests und Anpassungen der Titelverwaltung, hieran geknüpfte Bugfixes

6048 23.12.2024 dev 3.5 Andreas Feature Umsetzung der neuen Regeln zur Titelverwaltung

5937 23.12.2024 dev 3.5 Andreas Feature Titelverwaltung auf neue Struktur umgestellt, mehrstufiges Laden der Bestandstitel

6127 19.12.2024 rc-3.4 3.4.16 Moe Bug Benennung Tab in der Lieferanten-Umfrage ändern

6118 19.12.2024 rc-3.4 3.4.16 Moe Bug Rechnungsstellungsabfrage: Button "öffentliche Kontakte anzeigen" umbennen
Expand Down
13 changes: 8 additions & 5 deletions grails-app/controllers/de/laser/MyInstitutionController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1362,9 +1362,10 @@ class MyInstitutionController {
})
def subscriptionsManagement() {
Map<String, Object> result = myInstitutionControllerService.getResultGenerics(this, params)

Profiler prf = new Profiler('subMgmt')
prf.setBenchmark('start loading data')
params.tab = params.tab ?: 'generalProperties'
EhcacheWrapper filterCache = contextService.getUserCache("/subscriptionsManagement/subscriptionFilter/"), paginationCache = cacheService.getTTL1800Cache("/${params.controller}/subscriptionManagement/${params.tab}/${result.user.id}/pagination")
EhcacheWrapper filterCache = contextService.getUserCache("/subscriptionsManagement/subscriptionFilter/")
Set<String> filterFields = ['q', 'identifier', 'referenceYears', 'status', 'filterPropDef', 'filterProp', 'form', 'resource', 'subKinds', 'isPublicForApi', 'hasPerpetualAccess', 'hasPublishComponent', 'holdingSelection', 'subRunTime', 'subRunTimeMultiYear', 'subType', 'consortia']
filterFields.each { String subFilterKey ->
if(params.containsKey('processOption')) {
Expand All @@ -1377,7 +1378,6 @@ class MyInstitutionController {
else filterCache.remove(subFilterKey)
}
}
result.selectionCache = paginationCache.checkedMap ?: [:]

if(!(params.tab in ['notes', 'documents', 'properties'])){
//Important
Expand All @@ -1388,7 +1388,7 @@ class MyInstitutionController {
params.subTypes = [RDStore.SUBSCRIPTION_TYPE_LOCAL.id]
}
}

prf.setBenchmark('get data')
if(params.tab == 'documents' && params.processOption == 'newDoc') {
def input_file = request.getFile("upload_file")
if (input_file.size == 0) {
Expand All @@ -1406,7 +1406,10 @@ class MyInstitutionController {
}else{
result << managementService.subscriptionsManagement(this, params)
}

//at end because cache may get cleared after a process
EhcacheWrapper paginationCache = cacheService.getTTL1800Cache("/${params.controller}/subscriptionManagement/${params.tab}/${result.user.id}/pagination")
result.selectionCache = paginationCache.checkedMap ?: [:]
result.benchMark = prf.stopBenchmark()
result

}
Expand Down
10 changes: 6 additions & 4 deletions grails-app/controllers/de/laser/YodaController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,13 @@ class YodaController {
redirect(url: request.getHeader('referer'))
}

@Deprecated
@Secured(['ROLE_YODA'])
def getTIPPsWithoutGOKBId() {
log.debug("delete TIPPs without GOKb-ID")
yodaService.getTIPPsWithoutGOKBId()
def cleanupIssueEntitlements() {
log.debug("purge unnecessary titles ...")
executorService.execute ({
yodaService.cleanupIssueEntitlements()
})
redirect action: "systemThreads"
}

/**
Expand Down
50 changes: 27 additions & 23 deletions grails-app/controllers/de/laser/ajax/AjaxController.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.laser.ajax

import de.laser.addressbook.Person
import de.laser.addressbook.PersonRole

import de.laser.auth.Role
import de.laser.auth.User
import de.laser.auth.UserRole
Expand Down Expand Up @@ -49,6 +48,7 @@ import javax.servlet.ServletOutputStream
import java.text.NumberFormat
import java.text.SimpleDateFormat
import java.time.Year
import java.util.concurrent.ExecutorService

/**
* This controller manages AJAX calls which result in object manipulation and / or do not deliver clearly either HTML or JSON.
Expand All @@ -61,10 +61,12 @@ class AjaxController {
ContextService contextService
DashboardDueDatesService dashboardDueDatesService
EscapeService escapeService
ExecutorService executorService
FilterService filterService
FormService formService
GenericOIDService genericOIDService
IdentifierService identifierService
PackageService packageService
PropertyService propertyService
SubscriptionControllerService subscriptionControllerService
SubscriptionService subscriptionService
Expand Down Expand Up @@ -238,6 +240,27 @@ class AjaxController {
}
}

if (target instanceof Subscription) {
if(params.name == 'holdingSelection') {
Org ctx = contextService.getOrg()
Subscription sub = (Subscription) target
Map<String, Object> configMap = [sub: sub, value: value]
subscriptionService.switchPackageHoldingInheritance(configMap)
List<Long> subChildIDs = sub.getDerivedSubscriptions().id
if(value == RDStore.SUBSCRIPTION_HOLDING_ENTIRE) {
executorService.execute({
String threadName = 'PackageUnlink_'+sub.id
Thread.currentThread().setName(threadName)
sub.packages.each { SubscriptionPackage sp ->
if(!packageService.unlinkFromSubscription(sp.pkg, subChildIDs, ctx, false)){
log.error('error on clearing issue entitlements when changing package holding selection')
}
}
})
}
}
}

if (params.resultProp) {
result = value[params.resultProp]
} else {
Expand Down Expand Up @@ -1179,31 +1202,12 @@ class AjaxController {
}

@Secured(['ROLE_USER'])
@Transactional
def switchPackageHoldingInheritance() {
if(formService.validateToken(params)) {
String prop = 'holdingSelection'
Subscription sub = Subscription.get(params.id)
RefdataValue value = RefdataValue.get(params.value)
sub.holdingSelection = value
sub.save()
if(value == RDStore.SUBSCRIPTION_HOLDING_ENTIRE) {
if(! AuditConfig.getConfig(sub, prop)) {
AuditConfig.addConfig(sub, prop)

Subscription.findAllByInstanceOf(sub).each { Subscription m ->
m.setProperty(prop, sub.getProperty(prop))
m.save()
}
}
}
else if(!value) {
AuditConfig.removeConfig(sub, prop)
Subscription.findAllByInstanceOf(sub).each { Subscription m ->
m.setProperty(prop, null)
m.save()
}
}
Map<String, Object> configMap = [sub: sub, value: value]
subscriptionService.switchPackageHoldingInheritance(configMap)
}
render([success: true] as JSON)
}
Expand Down
15 changes: 15 additions & 0 deletions grails-app/controllers/de/laser/ajax/AjaxJsonController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,21 @@ class AjaxJsonController {
render controlledListService.getVendors(params) as JSON
}

/**
* Retrieves a list of packages for dropdown display
* @return the result of {@link de.laser.ControlledListService#getPackages(grails.web.servlet.mvc.GrailsParameterMap)}
*/
@Secured(['ROLE_USER'])
def lookupPackages() {
if (params.ctx != "undefined") {
render controlledListService.getPackages(params) as JSON
}
else {
Map empty = [results: []]
render empty as JSON
}
}

/**
* Retrieves a list of subscription packages for dropdown display
* @return the result of {@link de.laser.ControlledListService#getSubscriptionPackages(grails.web.servlet.mvc.GrailsParameterMap)}
Expand Down
2 changes: 1 addition & 1 deletion grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ subscriptionsManagement.unlinkInfo.costsExisting = "Costs were still existent fo
subscriptionsManagement.unlinkInfo.blocked = There are still cost items linked to this package. Please delete them first.
subscriptionsManagement.unlinkInfo.blockingSubscribersConsortia = Cost items concerning this package are linked to subscribers. Please delete those cost items first or unlink them from the package.
subscriptionsManagement.unlinkInfo.blockingInheritanceSetting = Holding selection is being inherited
subscriptionsManagement.unlinkInfo.unlinkingInProgress = The package {0} is currently being unlinked
subscriptionsManagement.unlinkInfo.unlinkingInProgress = A bulk process is currently performed with {0}.

subscriptionsManagement.properties = Properties
subscriptionsManagement.propertySelected = Selected property
Expand Down
2 changes: 1 addition & 1 deletion grails-app/i18n/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ subscriptionsManagement.unlinkInfo.costsExisting = "Für das Paket {0} von {1} w
subscriptionsManagement.unlinkInfo.blocked = Es sind noch Kosten für das Paket anhängig. Bitte löschen Sie die Kosten zuerst.
subscriptionsManagement.unlinkInfo.blockingSubscribersConsortia = Es sind noch Kosten für Pakete der Einrichtungslizenzen anhängig, die das Entknüpfen des Paketes unterbinden. Bitte löschen Sie diese Kosten zuerst oder heben Sie die Verknüpfung zum Paket auf.
subscriptionsManagement.unlinkInfo.blockingInheritanceSetting = Paketzuschnitt wird geerbt
subscriptionsManagement.unlinkInfo.unlinkingInProgress = Das Paket {0} wird aktuell entknüpft
subscriptionsManagement.unlinkInfo.unlinkingInProgress = Mit dem Paket {0} findet aktuell ein Massenprozess statt.

subscriptionsManagement.properties = Merkmale
subscriptionsManagement.propertySelected = Ausgewähltes Merkmal
Expand Down
21 changes: 21 additions & 0 deletions grails-app/services/de/laser/ControlledListService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,27 @@ class ControlledListService {
result
}

/**
* Retrieves a list of issue entitlements owned by the context institution matching given parameters
* @param params eventual request params
* @return a map containing a sorted list of issue entitlements, an empty one if no issue entitlements match the filter
*/
Map getPackages(GrailsParameterMap params) {
LinkedHashMap result = [results:[]]
String queryString = 'select p.id, p.name, (select count(*) from TitleInstancePackagePlatform tipp where tipp.pkg = p and tipp.status = :current) from Package p where p.packageStatus not in (:removed)'
LinkedHashMap filter = [current: RDStore.TIPP_STATUS_CURRENT, removed: [RDStore.PACKAGE_STATUS_DELETED, RDStore.PACKAGE_STATUS_REMOVED]]
//may be generalised later - here it is where to expand the query filter
if(params.query && params.query.length() > 0) {
filter.put('query', params.query)
queryString += " and genfunc_filter_matcher(p.name,:query) = true "
}
List rows = Package.executeQuery(queryString+" order by p.name asc",filter)
rows.each { row ->
result.results.add([name:"${row[1]} (${row[2]})",value:row[0]])
}
result
}

/**
* Retrieves a list of budget codes owned by the context institution matching given parameters
* @param params eventual request params
Expand Down
17 changes: 17 additions & 0 deletions grails-app/services/de/laser/ExportClickMeService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,11 @@ class ExportClickMeService {
'subscription.uuid' : [field: 'subscription.globalUID', label: 'Laser-UUID', message: null],
]
],
subscriptionIdentifiers: [
label : 'Subscription Identifiers',
message: 'subscription.identifiers.label',
fields : [:]
]
]
}

Expand Down Expand Up @@ -3747,6 +3752,9 @@ class ExportClickMeService {
IdentifierNamespace.findAllByNsType(TitleInstancePackagePlatform.class.name, [sort: 'ns']).each {
fields.issueEntitlementIdentifiers.fields << ["issueEntitlementIdentifiers.${it.id}":[field: null, label: it."${localizedName}" ?: it.ns]]
}
IdentifierNamespace.findAllByNsType(Subscription.class.name, [sort: 'ns']).each {
fields.subscriptionIdentifiers.fields << ["subscriptionIdentifiers.${it.id}":[field: null, label: it."${localizedName}" ?: it.ns]]
}

fields
}
Expand Down Expand Up @@ -3777,6 +3785,10 @@ class ExportClickMeService {
exportFields.put("issueEntitlementIdentifiers."+it.id, [field: null, label: it."${localizedName}" ?: it.ns])
}

IdentifierNamespace.findAllByNsType(Subscription.class.name, [sort: 'ns']).each {
exportFields.put("subscriptionIdentifiers."+it.id, [field: null, label: it."${localizedName}" ?: it.ns])
}

exportFields
}

Expand Down Expand Up @@ -6424,6 +6436,11 @@ class ExportClickMeService {
queryCols << "create_cell('${format}', (select string_agg(id_value,';') from identifier where id_tipp_fk = tipp_id and id_ns_fk = :${argKey}), null) as ${argKey}"
queryArgs.put(argKey, Long.parseLong(fieldKey.split("\\.")[1]))
}
else if(fieldKey.startsWith('subscriptionIdentifiers.')) {
String argKey = "ns${i}"
queryCols << "create_cell('${format}', (select string_agg(id_value,';') from identifier where id_sub_fk = ie_subscription_fk and id_ns_fk = :${argKey}), null) as ${argKey}"
queryArgs.put(argKey, Long.parseLong(fieldKey.split("\\.")[1]))
}
else if (fieldKey.contains('subscription.consortium')) {
queryCols << "create_cell('${format}', (select org_name from org join org_role on org_id = or_org_fk where or_sub_fk = ie_subscription_fk and or_roletype_rv_fk = :consortium), null) as consName"
queryArgs.consortium = RDStore.OR_SUBSCRIPTION_CONSORTIUM.id
Expand Down
9 changes: 6 additions & 3 deletions grails-app/services/de/laser/ManagementService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,16 @@ class ManagementService {
}
}
else {
EhcacheWrapper paginationCache = cacheService.getTTL1800Cache("/${params.controller}/subscriptionManagement/linkPackage/${result.user.id}/pagination")
EhcacheWrapper paginationCache = cacheService.getTTL1800Cache("/${params.controller}/subscriptionManagement/linkPackages/${result.user.id}/pagination")
List selectionCache = []
if(paginationCache.checkedMap) {
selectionCache.addAll(paginationCache.checkedMap.values())
paginationCache.remove('checkedMap')
}
else selectionCache.addAll(params.list('selectedSubs'))
if(selectionCache) {
subscriptions = Subscription.findAllByIdInList(selectionCache)
}
paginationCache.remove('checkedMap')
}
List selectedPackageKeys = params.list("selectedPackages")
Set<Package> pkgsToProcess = []
Expand Down Expand Up @@ -399,7 +399,10 @@ class ManagementService {
subscriptionService.addToSubscriptionCurrentStock(selectedSub, result.subscription, pkg, params.processOption == 'linkwithIE')
}
else {
subscriptionService.addToSubscription(selectedSub, pkg, params.processOption == 'linkwithIE')
if(selectedSub.holdingSelection == RDStore.SUBSCRIPTION_HOLDING_ENTIRE)
subscriptionService.addToSubscription(selectedSub, pkg, true)
else
subscriptionService.addToSubscription(selectedSub, pkg, params.processOption == 'linkwithIE')
}
}
}
Expand Down
Loading