Skip to content

Commit

Permalink
Merge branch 'release/4.11.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Nov 3, 2021
2 parents 18e0a40 + 8dd6299 commit a99c1da
Show file tree
Hide file tree
Showing 275 changed files with 9,275 additions and 1,238 deletions.
22 changes: 11 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pipeline {
'mdm-plugin-datamodel',
'mdm-plugin-email-proxy',
'mdm-plugin-federation',
// 'mdm-plugin-profile',
'mdm-plugin-profile',
'mdm-plugin-referencedata',
'mdm-plugin-terminology',
'mdm-security',
Expand Down Expand Up @@ -393,16 +393,16 @@ pipeline {
}
}
}
// stage('E2E Profile Functional Test') {
// steps {
// sh "./gradlew -Dgradle.test.package=profile :mdm-testing-functional:integrationTest"
// }
// post {
// always {
// junit allowEmptyResults: true, testResults: 'mdm-testing-functional/build/test-results/profile/*.xml'
// }
// }
// }
stage('E2E Profile Functional Test') {
steps {
sh "./gradlew -Dgradle.test.package=profile :mdm-testing-functional:integrationTest"
}
post {
always {
junit allowEmptyResults: true, testResults: 'mdm-testing-functional/build/test-results/profile/*.xml'
}
}
}

stage('Compile complete Test Report') {
steps {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Core Info
version=4.10.0
version=4.11.0
group=uk.ac.ox.softeng.maurodatamapper
# Gradle
gradleVersion=6.7.1
Expand All @@ -23,6 +23,7 @@ hibernateSearchVersion=2.3.0
luceneVersion=5.5.5
## Core
commonsTextVersion=1.9
commonsCsvVersion=1.8
springBootVersion=2.1.17.RELEASE
jaxbApiVersion=2.3.1
assetPipelineVersion=3.3.2
Expand Down
1 change: 1 addition & 0 deletions mdm-common/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {

implementation group: 'org.grails', name: 'grails-core', version: grailsVersion
implementation group: 'org.grails', name: 'grails-datastore-gorm'
implementation group: 'org.grails', name: 'grails-datastore-gorm-hibernate5'
implementation group: 'org.grails', name: 'grails-plugin-validation'
implementation "org.grails.plugins:views-json:$grailsViewsVersion"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import uk.ac.ox.softeng.maurodatamapper.traits.domain.CreatorAware

import groovy.transform.stc.ClosureParams
import groovy.transform.stc.SimpleType
import uk.ac.ox.softeng.maurodatamapper.traits.domain.PathAware
import uk.ac.ox.softeng.maurodatamapper.util.Utils

/**
* @since 28/08/2020
Expand Down Expand Up @@ -248,4 +250,16 @@ class Path {
static boolean isValidPath(String possiblePath) {
from(possiblePath).toString() == possiblePath
}

static Path toPathPrefix(CreatorAware domain, String prefix)
{
List<CreatorAware> objectsInPath = []
objectsInPath.push(domain)

while (objectsInPath.first().getPathPrefix() != prefix && Utils.parentClassIsAssignableFromChild(PathAware, objectsInPath.first().class)) {
objectsInPath.push(objectsInPath.first().getPathParent())
}

Path.from(objectsInPath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OffsetDateTimeBridge implements StringBridge {
@Override
String objectToString(Object object) {
if (object instanceof OffsetDateTime) {
return ((OffsetDateTime) object).format(dtf)
return ((OffsetDateTime) object).toLocalDate().format(dtf)
}
logger.error('Bridge set up to convert object of type {} but it is not an OffsetDateTime', object.getClass())
return null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2020 University of Oxford and Health and Social Care Information Centre, also known as NHS Digital
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package uk.ac.ox.softeng.maurodatamapper.search.bridge.spi


import uk.ac.ox.softeng.maurodatamapper.search.bridge.OffsetDateTimeBridge
import uk.ac.ox.softeng.maurodatamapper.util.Utils

import org.hibernate.search.bridge.FieldBridge
import org.hibernate.search.bridge.spi.BridgeProvider
import org.hibernate.search.bridge.util.impl.String2FieldBridgeAdaptor

import java.time.OffsetDateTime

/**
* @since 13/09/2021
*/
class OffsetDateTimeBridgeProvider implements BridgeProvider {
@Override
FieldBridge provideFieldBridge(BridgeProviderContext bridgeProviderContext) {
if (
bridgeProviderContext.returnType.simpleName == OffsetDateTime.simpleName && Utils.parentClassIsAssignableFromChild(OffsetDateTime, bridgeProviderContext.returnType)) {
return new String2FieldBridgeAdaptor(new OffsetDateTimeBridge())
}
null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ trait User extends SecurableResource {
Boolean getReadableByAuthenticatedUsers() {
false
}

String getFullName() {
"${firstName} ${lastName}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2020 University of Oxford and Health and Social Care Information Centre, also known as NHS Digital
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package uk.ac.ox.softeng.maurodatamapper.security.basic

import uk.ac.ox.softeng.maurodatamapper.security.User

/**
* @since 21/10/2019
*/
@Singleton
class AnonymousUser implements User {

public static final String ANONYMOUS_EMAIL_ADDRESS = 'anonymous@maurodatamapper.com'

String emailAddress = ANONYMOUS_EMAIL_ADDRESS
String firstName = 'Anonymous'
String lastName = 'User'
String tempPassword

@Override
UUID getId() {
UUID.randomUUID()
}

UUID ident() {
id
}

@Override
String getDomainType() {
AnonymousUser
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package uk.ac.ox.softeng.maurodatamapper.core.traits.domain
package uk.ac.ox.softeng.maurodatamapper.traits.domain

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import grails.compiler.GrailsCompileStatic
import groovy.transform.SelfType
import org.grails.datastore.gorm.GormEntity
import org.grails.datastore.mapping.proxy.EntityProxy
import org.grails.orm.hibernate.proxy.HibernateProxyHandler

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uk.ac.ox.softeng.maurodatamapper.search.bridge.spi.OffsetDateTimeBridgeProvider
1 change: 1 addition & 0 deletions mdm-core/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependencies {
compile project(':mdm-common')

compile group: 'org.apache.commons', name: 'commons-text', version: commonsTextVersion
compile group: 'org.apache.commons', name: 'commons-csv', version: commonsCsvVersion
compile group: 'org.simplejavamail', name: 'simple-java-mail', version: javaMailVersion
compile group: 'com.google.guava', name: 'guava', version: guavaVersion
compile group: 'commons-beanutils', name: 'commons-beanutils', version: commonsBeanutilsVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE core.email
ALTER COLUMN email_service_used DROP NOT NULL;

ALTER TABLE core.email
ALTER COLUMN date_time_sent DROP NOT NULL;
23 changes: 17 additions & 6 deletions mdm-core/grails-app/conf/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ maurodatamapper:
public: false
bootstrap:
authority: true
email:
from:
address: ''
---
simplejavamail:
smtp:
username: username@gmail.com
password: password
host: smtp.gmail.com
port: 587
username: ''
password: ''
host: ''
port: ''
transportstrategy: SMTP_TLS
javaxmail.debug: false
---
Expand Down Expand Up @@ -98,10 +101,18 @@ hibernate:
batch_size: 30
order_inserts: true
order_updates: true

grails:
plugins:
hibernatesearch:
rebuildIndexOnStart: true
environments:
development:
grails:
views:
markup:
cacheTemplates: false
cacheTemplates: false
production:
grails:
plugins:
hibernatesearch:
rebuildIndexOnStart: false
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UrlMappings {
'/emails'(resources: 'email', includes: INCLUDES_INDEX_ONLY)

'/properties'(resources: 'apiProperty', excludes: DEFAULT_EXCLUDES)
post '/properties/apply'(controller: 'apiProperty', action: 'apply')

group "/tree/$containerDomainType/$modelDomainType", {
get '/documentationSuperseded'(controller: 'treeItem', action: 'documentationSupersededModels') // New URL
Expand Down Expand Up @@ -247,6 +248,7 @@ class UrlMappings {
get '/'(controller: 'treeItem', action: 'index')
get "/${containerId}"(controller: 'treeItem', action: 'show')
get "/${catalogueItemDomainType}/$catalogueItemId"(controller: 'treeItem', action: 'show')
get "/${catalogueItemDomainType}/$catalogueItemId/ancestors"(controller: 'treeItem', action: 'ancestors')
get "/search/$searchTerm"(controller: 'treeItem', action: 'search')
}
"/full/$modelDomainType/$modelId"(controller: 'treeItem', action: 'fullModelTree')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@
*/
package uk.ac.ox.softeng.maurodatamapper.core.admin

import grails.gorm.transactions.Transactional
import uk.ac.ox.softeng.maurodatamapper.api.exception.ApiInternalException
import uk.ac.ox.softeng.maurodatamapper.core.controller.EditLoggingController

import grails.web.servlet.mvc.GrailsParameterMap
import groovy.util.logging.Slf4j
import uk.ac.ox.softeng.maurodatamapper.security.User

@Slf4j
class ApiPropertyController extends EditLoggingController<ApiProperty> {

ApiPropertyService apiPropertyService

static responseFormats = ['json', 'xml']
static responseFormats = ['json', 'xml', 'csv']

static includesExcludes = ["include": ["key", "value", "publiclyVisible", "category"]]

ApiPropertyController() {
super(ApiProperty)
Expand All @@ -43,6 +47,26 @@ class ApiPropertyController extends EditLoggingController<ApiProperty> {
respond res, [model: [userSecurityPolicyManager: currentUserSecurityPolicyManager], view: 'index']
}

/**
* Override so that we can specify includesExcludes when creating the resource
* @return
*/
@Transactional
@Override
def save() {
if (handleReadOnly()) return

def instance = createResource(includesExcludes)

if (response.isCommitted()) return

if (!validateResource(instance, 'create')) return

saveResource instance

saveResponse instance
}

@Override
protected ApiProperty saveResource(ApiProperty resource) {
ApiProperty apiProperty = super.saveResource(resource)
Expand All @@ -65,4 +89,53 @@ class ApiPropertyController extends EditLoggingController<ApiProperty> {
currentUserSecurityPolicyManager.isApplicationAdministrator() ? apiPropertyService.list(params) : []

}

/**
* Save a collection of ApiProperty resources and respond with the index listing
* @return
*/
@Transactional
def apply() {
if (handleReadOnly()) return

Collection instances = createResources()

instances.each {instance ->
saveResource instance
}

// Respond with the index listing
index()
}

/**
* Create a collection of resources from the request body
* @return
*/
protected Collection<ApiProperty> createResources() {

// First, bind what was exported to an ApiPropertyCollection (which has properties count and items)
// There isn't a way here to specify an includesExcludes list
ApiPropertyCollection apiPropertyCollection = new ApiPropertyCollection()
bindData apiPropertyCollection, getObjectToBind()

// Second, iterate the items we just created, and use each instance
// to create another cleaned instance. This time, we specify includesExcludes.
// At the same time, set the createdBy property of the cleaned instance.
Collection<ApiProperty> cleanedInstances = []
User creator = getCurrentUser()
apiPropertyCollection.items.each {instance ->
ApiProperty cleanedInstance = new ApiProperty()

// Copy the included properties to a cleaned instance
includesExcludes["include"].each {
cleanedInstance[it] = instance[it]
}

cleanedInstance.createdBy = creator.emailAddress
cleanedInstances.add(cleanedInstance)
}

cleanedInstances
}
}

0 comments on commit a99c1da

Please sign in to comment.