Skip to content

Commit

Permalink
Merge branch 'release/4.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
olliefreeman committed Aug 7, 2021
2 parents d9dff3a + cdbb2a1 commit 01f6a0f
Show file tree
Hide file tree
Showing 399 changed files with 12,251 additions and 5,887 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Core Info
version=4.7.0
version=4.8.0
group=uk.ac.ox.softeng.maurodatamapper
# Gradle
gradleVersion=6.7.1
Expand Down
1 change: 1 addition & 0 deletions mdm-common/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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-plugin-validation'
implementation "org.grails.plugins:views-json:$grailsViewsVersion"

api group: 'com.bertramlabs.plugins', name: 'asset-pipeline-core', version: assetPipelineVersion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class PaginatedResultList<E> extends PagedResultList<E> {
totalCount = results.size()
this.pagination = pagination

Integer max = pagination.max?.toInteger ?: 10
Integer offset = pagination.offset?.toInteger ?: 0
Integer max = pagination.max?: 10
Integer offset = pagination.offset?: 0
resultList = results.subList(Math.min(totalCount, offset), Math.min(totalCount, offset + max))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package uk.ac.ox.softeng.maurodatamapper.hibernate

import uk.ac.ox.softeng.maurodatamapper.util.Version
import uk.ac.ox.softeng.maurodatamapper.version.Version

import org.hibernate.dialect.Dialect
import org.hibernate.type.AbstractSingleColumnStandardBasicType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package uk.ac.ox.softeng.maurodatamapper.hibernate

import uk.ac.ox.softeng.maurodatamapper.util.Version
import uk.ac.ox.softeng.maurodatamapper.version.Version

import org.hibernate.type.descriptor.WrapperOptions
import org.hibernate.type.descriptor.java.AbstractTypeDescriptor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
/*
* 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.path

import uk.ac.ox.softeng.maurodatamapper.traits.domain.CreatorAware

import groovy.transform.stc.ClosureParams
import groovy.transform.stc.SimpleType

/**
* @since 28/08/2020
*/
class Path {

//Need to escape the vertical bar which we are using as the split delimiter
static String PATH_DELIMITER = '\\|'

//Arbitrary maximum number of nodes, to avoid unexpectedly long iteration
static int MAX_NODES = 10

List<PathNode> pathNodes

private Path() {
pathNodes = []
}

/*
* Make a list of PathNode from the provided path string. The path string is like dc:class-label|de:element-label
* which means 'The DataElement labelled element-label which belongs to the DataClass labelled class-label which
* belongs to the current DataModel'
* @param path The path
*/

private Path(String path) {
this()

if (path) {
String[] splits = path.split(PATH_DELIMITER, MAX_NODES)
int lastIndex = splits.size() - 1

splits.eachWithIndex {String node, int i ->
pathNodes << new PathNode(node, i == lastIndex)
}
}
}

int size() {
pathNodes.size()
}

PathNode getAt(int i) {
pathNodes[i]
}

PathNode last() {
pathNodes.last()
}

PathNode first() {
pathNodes.first()
}

Path addToPathNodes(PathNode pathNode) {
pathNodes.add(pathNode)
this
}

Path addToPathNodes(String prefix, String pathIdentifier, boolean isLast) {
addToPathNodes(new PathNode(prefix, pathIdentifier, isLast))
}

Path getParent() {
clone().tap {
pathNodes.removeLast()
}
}

boolean isAbsoluteTo(CreatorAware creatorAware, String modelIdentifierOverride = null) {
// If the first node in this path matches the supplied object then this path is absolute against the supplied object,
// otherwise it may be relative or may not be inside this object
Path rootPath = from(creatorAware)
isAbsoluteTo(rootPath, modelIdentifierOverride)
}

boolean isAbsoluteTo(Path rootPath, String modelIdentifierOverride = null) {
// If the first node in this path matches the supplied object then this path is absolute against the supplied object,
// otherwise it may be relative or may not be inside this object
rootPath.first().matches(this.first(), modelIdentifierOverride)
}

boolean isEmpty() {
pathNodes.isEmpty()
}

void each(@DelegatesTo(List) @ClosureParams(value = SimpleType, options = 'uk.ac.ox.softeng.maurodatamapper.path.PathNode') Closure closure) {
pathNodes.each closure
}

PathNode find(@DelegatesTo(List) @ClosureParams(value = SimpleType, options = 'uk.ac.ox.softeng.maurodatamapper.path.PathNode') Closure closure) {
pathNodes.find closure
}

Path getChildPath() {
clone().tap {
pathNodes.removeAt(0)
}
}

String toString() {
pathNodes.join('|')
}

Path clone() {
Path local = this
new Path().tap {
pathNodes = local.pathNodes.collect {it.clone()}
}
}

boolean matches(Path otherPath) {
if (size() != otherPath.size()) return false
for (i in 0..<size()) {
if (!this[i].matches(otherPath[i])) return false
}
true
}

static Path from(String path) {
new Path(path)
}

static Path from(PathNode pathNode) {
new Path().tap {
pathNodes << pathNode
}
}

static Path from(String prefix, String pathIdentifier) {
new Path().tap {
pathNodes << new PathNode(prefix, pathIdentifier, true)
}
}

static Path from(Path parentPath, String prefix, String pathIdentifier) {
parentPath ? parentPath.clone().addToPathNodes(prefix, pathIdentifier, false) : from(prefix, pathIdentifier)
}

static Path from(String parentPath, String prefix, String pathIdentifier) {
from(from(parentPath), prefix, pathIdentifier)
}

static Path from(CreatorAware... domains) {
new Path().tap {
domains.eachWithIndex {CreatorAware domain, int i ->
pathNodes << new PathNode(domain.pathPrefix, domain.pathIdentifier, false)
}
}
}

static Path from(List<CreatorAware> domains) {
new Path().tap {
domains.eachWithIndex {CreatorAware domain, int i ->
pathNodes << new PathNode(domain.pathPrefix, domain.pathIdentifier, false)
}
}
}

static Path forAttributeOnPath(Path path, String attribute) {
Path attributePath = path.clone()
attributePath.last().attribute = attribute
attributePath
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.path

import grails.plugin.json.builder.JsonGenerator

/**
* @since 15/07/2021
*/
class PathJsonConverter implements JsonGenerator.Converter {
@Override
boolean handles(Class<?> type) {
Path.isAssignableFrom(type)
}

@Override
Object convert(Object value, String key) {
((Path) value).toString()
}
}
Loading

0 comments on commit 01f6a0f

Please sign in to comment.