Skip to content

Commit f555219

Browse files
Merge pull request #30 from gchq/develop
Release 2.0.0
2 parents 68ca8f6 + e9c357b commit f555219

File tree

550 files changed

+22847
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

550 files changed

+22847
-1003
lines changed

Diff for: .gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
target/
77
bin/
88
tdb/
9+
out
910
*.code-workspace
1011
*.iml
1112
*.ttl
1213
.DS_Store
1314
.factorypath
15+
.devcontainer
1416

1517

1618
# Compiled class file
@@ -36,3 +38,8 @@ tdb/
3638

3739
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
3840
hs_err_pid*
41+
42+
# Vim files
43+
*.swp
44+
tags
45+
.vim/

Diff for: .gitmodules

-3
This file was deleted.

Diff for: CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Where possible a pull request should correlate to a single GitHub issue. An issu
4343

4444
Please ensure your coding style is consistent with rest of the project and follows our coding standards and best practices.
4545

46+
> A `java-formatter.xml` configuration file is provided in the root of the project. Please include this in for editor settings when developing Magma Core.
47+
4648
Checkstyle is run as part of `mvn install` so you should ensure your code is compliant with these rules. The project will not build if there are checkstyle errors.
4749

4850
In particular please ensure you have adhered to the following:

Diff for: HQDM

-1
This file was deleted.

Diff for: README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,35 @@ This code release is a contribution to support the adoption of data models that
1010

1111
\* Dr. West was not involved in the creation of this project. GCHQ are grateful for his open contributions to the field of ontology and data quality management.
1212

13+
14+
## The High Quality Data Model for Data Integration in Java
15+
16+
HQDM contains the replication of an openly available data model based on key ontological foundations to enable the consistent integration of data. The HQDM Java package comprises a set of Java classes and respective interfaces, 230 in total, to replicate the entity-relationship model published by Dr Matthew West as the [High Quality Data Model Framework](http://www.informationjunction.co.uk/hqdm_framework/). This class model can be used to create extensions of the entity types, based on the founding ontological commitments and logical restrictions (such as cardinalities), and instances of those types all in Java application code. This, in theory at least, provides a framework for the consistent representation of almost anything that is, or could be, real\*. All the data model patterns published in the HQDM framework are supported by the HQDM package. The object properties are constructed around a top-level Java HQDM Object class with some root attributes to enable class-instances to be managed in a database. The choice of database can be left to the user but the structure of the attributes is optimised for the use of [Linked Data IRIs](https://www.w3.org/TR/rdf11-concepts/#section-IRIs) and [RDF triples](https://www.w3.org/TR/rdf11-concepts/#section-triples) to represent HQDM object relationships and other object properties as predicates. All of the HQDM objects can be created and searched using the HQDMObject methods and collections can be handled using the Object Factory. To complement this there is an OWL version of the HQDM data model that is a close match for the original EXPRESS model and the HQDM Java package.
17+
18+
\* This is a gross simplification, but it characterises the goal of the model and in use it has proved to be very capable. The UK's National Digital Twin programme is developing a model that aims to address this goal with even more rigour, called the Foundation Data Model (FDM). Data created using HQDM is likely to be mappable to the FDM with low mapping (due to similar ontological commitments).
19+
1320
## Getting Started
1421

15-
An introduction to Magma Core and the [HQDM Java object library](https://github.com/gchq/HQDM) is provided in the [Magma Core Wiki](https://github.com/gchq/MagmaCore/wiki).
22+
An introduction to Magma Core is provided in the [Magma Core Wiki](https://github.com/gchq/MagmaCore/wiki).
1623

1724
### Prerequisites
1825

19-
- [Java 15](https://openjdk.java.net/projects/jdk/15/) - Core language
26+
- [Java 17](https://openjdk.java.net/projects/jdk/17/) - Core language
2027
- [Maven](https://maven.apache.org/) - Dependency management
2128

22-
## Setup
29+
### Inclusion in other projects
30+
31+
Magma Core can be incorporated into other maven projects using the following dependency:
32+
33+
```xml
34+
<dependency>
35+
<groupId>uk.gov.gchq.magmacore</groupId>
36+
<artifactId>core</artifactId>
37+
<version>1.0</version>
38+
</dependency>
39+
```
2340

24-
- To run Magma Core, run `mvn compile exec:java -Dexec.mainClass="uk.gov.gchq.magmacore.MagmaCore"`. This will execute the selected example method from the demo package. Alternatively, if you are using an IDE, you should be able to run the main method in MagmaCore.java from the editor.
25-
- To select which example to run, change the FusekiService.run() call in MagmaCore.java to the desired demo class in magmacore/demo. Each of these demos have slightly different behaviours, which are described in the code.
26-
- By default, this is set to the Fuseki server example, which will build and populate a Jena dataset hosted on a Fuseki server accessible at `localhost:3330/tdb`
27-
- The dataset can then be queried via a web browser by going to `http://localhost:3330/tdb/sparql?query=SELECT ?s ?p ?o WHERE {?s ?p ?o.}`
28-
- This can also be done via curl on the command line using: `curl -X POST -d "query=select ?s ?p ?o where { ?s ?p ?o . }" localhost:3330/tdb/query`
41+
_Magma Core is not currently hosted on Maven Central, so a local install of this repository will be required._
2942

3043
## Contributing
3144

Diff for: checkstyle-suppressions.xml

+18-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD Suppressions 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
33

44
<suppressions>
5-
<suppress checks="Indentation|HiddenField" files="\.java" />
6-
<suppress checks="MethodLength|LineLength" files="ExampleDataObjects.java" />
7-
</suppressions>
5+
<!-- global suppressions -->
6+
<suppress checks="AvoidStarImport" files="\.java" />
7+
8+
<!-- core suppressions -->
9+
<suppress checks="AbbreviationAsWordInName" files="UID\.java" />
10+
11+
<!-- examples suppressions -->
12+
<suppress checks="LineLength" files="ExampleDataObjects.java|ExampleRdl.java|ExampleAssociations.java" />
13+
<suppress checks="MethodLength" files="ExampleDataObjects.java" />
14+
15+
<!-- hqdm-core suppressions -->
16+
<suppress checks="MethodName" files="impl/*" />
17+
<suppress checks="TypeName" files="Function_.java" />
18+
19+
<!-- hqdm-rdf suppressions -->
20+
<suppress checks="ConstantName" files="HQDM.java" />
21+
<suppress checks="AbbreviationAsWordInName" files="IRI.java|HQDM.java|RDFS.java|UID.java" />
22+
</suppressions>

Diff for: core/pom.xml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>uk.gov.gchq.magma-core</groupId>
6+
<artifactId>magma-core</artifactId>
7+
<version>2.0.0</version>
8+
</parent>
9+
10+
<groupId>uk.gov.gchq.magma-core</groupId>
11+
<artifactId>core</artifactId>
12+
<version>2.0.0</version>
13+
14+
<name>core</name>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.release>17</maven.compiler.release>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>uk.gov.gchq.magma-core</groupId>
24+
<artifactId>hqdm</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>uk.gov.gchq.magma-core</groupId>
28+
<artifactId>hqdm-rdf</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>junit</groupId>
32+
<artifactId>junit</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.apache.jena</groupId>
36+
<artifactId>apache-jena-libs</artifactId>
37+
<type>pom</type>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.slf4j</groupId>
41+
<artifactId>slf4j-jdk14</artifactId>
42+
</dependency>
43+
</dependencies>
44+
</project>

Diff for: core/src/main/java/module-info.java

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2021 Crown Copyright
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
/**
16+
* Magma Core is a lightweight set of Java classes to enable HQDM data objects to be created and
17+
* used as RDF Linked Data through Apache Jena.
18+
*/
19+
module uk.gov.gchq.magmacore {
20+
requires org.apache.jena.arq;
21+
requires org.apache.jena.base;
22+
requires org.apache.jena.core;
23+
requires org.apache.jena.dboe.base;
24+
requires org.apache.jena.rdfconnection;
25+
requires org.apache.jena.tdb2;
26+
requires com.fasterxml.jackson.annotation;
27+
28+
requires uk.gov.gchq.magmacore.hqdm;
29+
requires transitive uk.gov.gchq.magmacore.hqdm.rdf;
30+
31+
exports uk.gov.gchq.magmacore.service;
32+
exports uk.gov.gchq.magmacore.service.transformation;
33+
exports uk.gov.gchq.magmacore.exception;
34+
exports uk.gov.gchq.magmacore.util;
35+
}

Diff for: src/main/java/uk/gov/gchq/magmacore/database/MagmaCoreDatabase.java renamed to core/src/main/java/uk/gov/gchq/magmacore/database/MagmaCoreDatabase.java

+33-12
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,37 @@
1717
import java.io.PrintStream;
1818
import java.util.List;
1919

20-
import uk.gov.gchq.hqdm.iri.HqdmIri;
21-
import uk.gov.gchq.hqdm.iri.IRI;
22-
import uk.gov.gchq.hqdm.model.Thing;
20+
import uk.gov.gchq.magmacore.hqdm.model.Thing;
21+
import uk.gov.gchq.magmacore.hqdm.rdf.iri.HqdmIri;
22+
import uk.gov.gchq.magmacore.hqdm.rdf.iri.IRI;
2323

2424
/**
2525
* Interface defining CRUD operations and generic queries for Magma Core data collections.
2626
*/
2727
public interface MagmaCoreDatabase {
2828

29+
/**
30+
* Start a transaction in READ mode and which will switch to WRITE if an update is attempted but
31+
* only if no intermediate transaction has performed an update.
32+
*/
33+
void begin();
34+
35+
/**
36+
* Commit a transaction - Finish the current transaction and make any changes permanent (if a
37+
* "write" transaction).
38+
*/
39+
void commit();
40+
41+
/**
42+
* Abort a transaction - Finish the transaction and undo any changes (if a "write" transaction).
43+
*/
44+
void abort();
45+
46+
/**
47+
* Drop all data from the dataset.
48+
*/
49+
void drop();
50+
2951
/**
3052
* Get an object from the collection.
3153
*
@@ -59,35 +81,34 @@ public interface MagmaCoreDatabase {
5981
* Find object(s) that have a specific object associated with them.
6082
*
6183
* @param predicateIri IRI of the predicate being queried.
62-
* @param objectIri IRI of the object to match.
63-
* @return The object(s).
84+
* @param objectIri IRI of the object to match.
85+
* @return The {@link Thing}(s) found.
6486
*/
6587
List<Thing> findByPredicateIri(IRI predicateIri, IRI objectIri);
6688

6789
/**
6890
* Find object(s) that have a specific HQDM-defined predication.
6991
*
7092
* @param predicateIri IRI of the HQDM relationship type being queried.
71-
* @return The object(s).
93+
* @return The {@link Thing}(s) found.
7294
*/
7395
List<Thing> findByPredicateIriOnly(HqdmIri predicateIri);
7496

7597
/**
76-
* Find object(s) that have a specific case-sensitive string-value attribute associated with
77-
* them.
98+
* Find object(s) that have a specific case-sensitive string-value attribute associated with them.
7899
*
79100
* @param predicateIri IRI of the predicate being queried.
80-
* @param value Case-sensitive string to match.
81-
* @return The object(s).
101+
* @param value Case-sensitive string to match.
102+
* @return The {@link Thing}(s) found.
82103
*/
83104
List<Thing> findByPredicateIriAndStringValue(IRI predicateIri, String value);
84105

85106
/**
86107
* Find object(s) that have a specific string-value attribute associated with them.
87108
*
88109
* @param predicateIri IRI of the predicate being queried.
89-
* @param value Case-insensitive string to match.
90-
* @return The object(s).
110+
* @param value Case-insensitive string to match.
111+
* @return The {@link Thing}(s).
91112
*/
92113
List<Thing> findByPredicateIriAndStringCaseInsensitive(IRI predicateIri, String value);
93114

0 commit comments

Comments
 (0)