= props => {
14 | const {reports, createReport, removeReport} = props;
15 |
16 | let content: JSX.Element;
17 | if (Util.sanitizeArray(reports).length === 0) {
18 | content = There are no reports, yet.
;
19 | } else {
20 | content =
21 |
22 |
23 | Audit title |
24 | Audit date |
25 | Records |
26 | Actions |
27 |
28 |
29 |
30 | {reports.map(r => removeReport(r)}/>)}
31 |
32 |
;
33 | }
34 |
35 | return
36 | Reports
37 |
38 |
39 |
40 | {content}
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | };
51 |
52 | export default Reports;
53 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/component/report/ReportsRoute.tsx:
--------------------------------------------------------------------------------
1 | import {Route, Switch} from "react-router";
2 | import ReportDetail from "./ReportDetail";
3 | import ReportsController from "./ReportsController";
4 |
5 | const ReportsRoute = () => {
6 | return
7 |
8 |
9 |
10 |
11 | };
12 |
13 | export default ReportsRoute;
14 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/index.scss:
--------------------------------------------------------------------------------
1 | html {
2 | height: 100% !important;
3 | }
4 |
5 | body {
6 | height: 100% !important;
7 | flex-direction: column !important;
8 | display: flex !important;
9 | position: relative;
10 | }
11 |
12 | #root {
13 | height: 100% !important;
14 | flex-direction: column !important;
15 | display: flex !important;
16 | position: relative;
17 | }
18 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as ReactDOM from "react-dom";
2 | import App from "./App";
3 | import 'bootstrap/dist/css/bootstrap.min.css';
4 | import "./index.scss";
5 |
6 | ReactDOM.render(, document.getElementById("root") as HTMLElement);
7 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/AppModel.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import {ReportItem} from "./Report";
20 | import Event from "./Event";
21 | import {Question} from "./Record";
22 | import {Message} from "./Types";
23 |
24 | export default class AppModel {
25 | public settings: { [key: string]: string };
26 | public reports: ReportItem[];
27 | public audits: Event[];
28 | public properties: string[];
29 | public questions: Question[];
30 | public messages: Message[];
31 |
32 | constructor() {
33 | this.settings = {};
34 | this.reports = [];
35 | this.audits = [];
36 | this.properties = [];
37 | this.questions = [];
38 | this.messages = [];
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/Event.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import {BaseEntity, Properties} from "./Types";
20 | import {ReportItem} from "./Report";
21 |
22 | export default interface Event extends BaseEntity {
23 | identifier?: number;
24 | title?: string;
25 | date: number;
26 | types?: string[];
27 | properties?: Properties;
28 | isDocumentedBy?: ReportItem[];
29 |
30 | isNew?: boolean;
31 | }
32 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/Person.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import {BaseEntity} from "./Types";
20 |
21 | export default interface Person extends BaseEntity {
22 | accountName: string;
23 | firstName: string;
24 | lastName: string;
25 | }
26 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/Record.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | export default interface Record {
20 | id?: string;
21 | name?: string;
22 | types?: string[];
23 |
24 | has_question?: Question;
25 | has_answer?: Answer;
26 |
27 | isNew?: boolean;
28 | }
29 |
30 | export interface Question {
31 | id?: string;
32 | identifier?: number;
33 | has_data_value: string;
34 | }
35 |
36 | export interface Answer {
37 | id?: string;
38 | has_data_value?: string;
39 | }
40 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/Report.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import {BaseEntity, Properties} from "./Types";
20 | import Person from "./Person";
21 | import Record from "./Record";
22 | import Event from "./Event";
23 |
24 | export interface ReportItem extends BaseEntity {
25 | identifier?: number;
26 | auditTitle?: string;
27 | auditDate?: number;
28 | recordCount?: number;
29 | hasAuthor?: Person;
30 | created?: number;
31 | }
32 |
33 | export default interface Report extends BaseEntity {
34 | identifier?: number;
35 | documents: Event;
36 | hasAuthor?: Person;
37 | created?: number;
38 | has_documentation_part?: Record[];
39 | properties?: Properties;
40 |
41 | isNew?: boolean;
42 | }
43 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/model/Types.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | export interface BaseEntity {
20 | id?: string;
21 | }
22 |
23 | export type Properties = { [key: string]: string | string[] };
24 |
25 | export type SelectOption = {
26 | label?: string;
27 | value?: string;
28 | }
29 |
30 | export type Message = {
31 | message: string,
32 | type: MessageType,
33 | timestamp?: number
34 | };
35 |
36 | export type MessageType = "success" | "danger" | "warning" | "info";
37 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | ///
20 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/store/AppStore.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import {applyMiddleware, compose, createStore, Middleware} from "redux";
20 | import thunk, {ThunkMiddleware} from "redux-thunk";
21 | import AppReducers from "../reducer/AppReducers";
22 |
23 | const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
24 |
25 | const middlewares: Middleware[] = [thunk as ThunkMiddleware];
26 |
27 | const AppStore = createStore(
28 | AppReducers,
29 | composeEnhancers(applyMiddleware(...middlewares))
30 | );
31 |
32 | export default AppStore;
33 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/src/util/InstanceFactory.ts:
--------------------------------------------------------------------------------
1 | ///
2 | /// JOPA Examples
3 | /// Copyright (C) 2024 Czech Technical University in Prague
4 | ///
5 | /// This library is free software; you can redistribute it and/or
6 | /// modify it under the terms of the GNU Lesser General Public
7 | /// License as published by the Free Software Foundation; either
8 | /// version 3.0 of the License, or (at your option) any later version.
9 | ///
10 | /// This library is distributed in the hope that it will be useful,
11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | /// Lesser General Public License for more details.
14 | ///
15 | /// You should have received a copy of the GNU Lesser General Public
16 | /// License along with this library.
17 | ///
18 |
19 | import Event from "../model/Event";
20 | import Report from "../model/Report";
21 |
22 | export function createAudit(): Event {
23 | return {
24 | title: "",
25 | isNew: true,
26 | date: (Date.now() / 1000) * 1000
27 | };
28 | }
29 |
30 | export function createReport(audit?: object): Report {
31 | const report: any = {isNew: true, has_documentation_part: []};
32 | if (audit) {
33 | report.documents = audit;
34 | } else {
35 | report.documents = createAudit();
36 | }
37 | return report;
38 | }
39 |
--------------------------------------------------------------------------------
/eswc2016/src/main/webapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "outDir": "build/dist",
5 | "module": "esnext",
6 | "target": "es5",
7 | "lib": [
8 | "esnext",
9 | "dom",
10 | "dom.iterable"
11 | ],
12 | "sourceMap": true,
13 | "allowJs": true,
14 | "jsx": "react-jsx",
15 | "moduleResolution": "node",
16 | "downlevelIteration": true,
17 | "forceConsistentCasingInFileNames": true,
18 | "noImplicitReturns": true,
19 | "noImplicitThis": true,
20 | "noImplicitAny": true,
21 | "resolveJsonModule": true,
22 | "isolatedModules": true,
23 | "noEmit": true,
24 | "strictNullChecks": true,
25 | "suppressImplicitAnyIndexErrors": true,
26 | "noUnusedLocals": true,
27 | "esModuleInterop": true,
28 | "allowSyntheticDefaultImports": true,
29 | "skipLibCheck": true,
30 | "strict": true,
31 | "types": [
32 | "node",
33 | "jest"
34 | ],
35 | "noFallthroughCasesInSwitch": true
36 | },
37 | "include": [
38 | "src"
39 | ],
40 | "exclude": [
41 | "node_modules",
42 | "build",
43 | "scripts",
44 | "acceptance-tests",
45 | "webpack",
46 | "jest",
47 | "**/__tests__",
48 | "**/__mocks__"
49 | ]
50 | }
51 |
--------------------------------------------------------------------------------
/example01-jopa-rdf4j-owl2java/mapping:
--------------------------------------------------------------------------------
1 | http://krizik.felk.cvut.cz/ontologies/2015/jopa-example01.owl > ./ic-example01.owl
--------------------------------------------------------------------------------
/example01-jopa-rdf4j-owl2java/src/main/java/cz/cvut/kbss/jopa/example01/Runner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example01;
19 |
20 | interface Runner {
21 |
22 | /**
23 | * Runs the example.
24 | */
25 | void run();
26 | }
27 |
--------------------------------------------------------------------------------
/example01-jopa-rdf4j-owl2java/src/main/java/cz/cvut/kbss/jopa/example01/model/ConferencePaper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example01.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
22 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
23 |
24 | import java.net.URI;
25 |
26 | @OWLClass(iri = "http://uob.iodt.ibm.com/univ-bench-dl.owl#ConferencePaper")
27 | public class ConferencePaper {
28 |
29 | @Id(generated = true)
30 | private URI uri;
31 |
32 | @OWLDataProperty(iri = "http://uob.iodt.ibm.com/univ-bench-dl.owl#name")
33 | private String name;
34 |
35 | public URI getUri() {
36 | return uri;
37 | }
38 |
39 | public void setUri(URI uri) {
40 | this.uri = uri;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public String toString() {
52 | return "[ConferencePaper " + name + ", uri = " + uri + "]";
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/example01-jopa-rdf4j-owl2java/src/main/java/cz/cvut/kbss/jopa/example01/model/Course.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example01.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
22 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
23 |
24 | import java.net.URI;
25 |
26 | @OWLClass(iri = "http://uob.iodt.ibm.com/univ-bench-dl.owl#Course")
27 | public class Course {
28 |
29 | @Id(generated = true)
30 | private URI uri;
31 |
32 | @OWLDataProperty(iri = "http://uob.iodt.ibm.com/univ-bench-dl.owl#name")
33 | private String name;
34 |
35 | public Course() {
36 | }
37 |
38 | public Course(URI uri) {
39 | this.uri = uri;
40 | }
41 |
42 | public Course(URI uri, String name) {
43 | this.uri = uri;
44 | this.name = name;
45 | }
46 |
47 | public URI getUri() {
48 | return uri;
49 | }
50 |
51 | public void setUri(URI uri) {
52 | this.uri = uri;
53 | }
54 |
55 | public String getName() {
56 | return name;
57 | }
58 |
59 | public void setName(String name) {
60 | this.name = name;
61 | }
62 |
63 | public String toString() {
64 | return "[Course " + name + ", uri = " + uri + "]";
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/example01-jopa-rdf4j-owl2java/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example02-jopa-owlapi/src/main/java/cz/cvut/kbss/jopa/example02/model/Vocabulary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example02.model;
19 |
20 | public class Vocabulary {
21 |
22 | private Vocabulary() {
23 | throw new AssertionError();
24 | }
25 |
26 | public static final String BASE_URI = "http://krizik.felk.cvut.cz/ontologies/jopa/example02#";
27 |
28 | public static final String JEDI = BASE_URI + "Jedi";
29 | public static final String HAS_CHILD = BASE_URI + "hasChild";
30 | public static final String HAS_FATHER = BASE_URI + "hasFather";
31 |
32 | public static final String FIRST_NAME = "http://xmlns.com/foaf/0.1/firstName";
33 | public static final String LAST_NAME = "http://xmlns.com/foaf/0.1/lastName";
34 | public static final String NICKNAME = "http://xmlns.com/foaf/0.1/nick";
35 | }
36 |
--------------------------------------------------------------------------------
/example02-jopa-owlapi/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/example03-jopa-rdf4j-contexts/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/config/AppConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.config;
19 |
20 | import org.springframework.context.annotation.Configuration;
21 | import org.springframework.context.annotation.Import;
22 |
23 | @Configuration
24 | @Import({WebAppConfig.class, PersistenceConfig.class, ServiceConfig.class})
25 | public class AppConfig {
26 | }
27 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/config/PersistenceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.config;
19 |
20 | import com.github.ledsoft.jopa.spring.transaction.DelegatingEntityManager;
21 | import com.github.ledsoft.jopa.spring.transaction.JopaTransactionManager;
22 | import cz.cvut.kbss.jopa.model.EntityManagerFactory;
23 | import org.springframework.context.annotation.Bean;
24 | import org.springframework.context.annotation.ComponentScan;
25 | import org.springframework.context.annotation.Configuration;
26 | import org.springframework.transaction.PlatformTransactionManager;
27 |
28 | @Configuration
29 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.example04.persistence")
30 | public class PersistenceConfig {
31 |
32 | @Bean
33 | public DelegatingEntityManager entityManager() {
34 | return new DelegatingEntityManager();
35 | }
36 |
37 | @Bean(name = "txManager")
38 | public PlatformTransactionManager transactionManager(EntityManagerFactory emf, DelegatingEntityManager emProxy) {
39 | return new JopaTransactionManager(emf, emProxy);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/config/RestConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.config;
19 |
20 | import com.fasterxml.jackson.databind.DeserializationFeature;
21 | import com.fasterxml.jackson.databind.ObjectMapper;
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.ComponentScan;
24 | import org.springframework.context.annotation.Configuration;
25 |
26 | /**
27 | * @author ledvima1
28 | */
29 | @Configuration
30 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.example04.rest")
31 | public class RestConfig {
32 |
33 | @Bean
34 | public ObjectMapper objectMapper() {
35 | final ObjectMapper objectMapper = new ObjectMapper();
36 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
37 | return objectMapper;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/config/ServiceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.config;
19 |
20 | import org.springframework.context.annotation.ComponentScan;
21 | import org.springframework.context.annotation.Configuration;
22 | import org.springframework.transaction.annotation.EnableTransactionManagement;
23 |
24 | @Configuration
25 | @EnableTransactionManagement
26 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.example04.service")
27 | public class ServiceConfig {
28 | }
29 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/model/Vocabulary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.model;
19 |
20 | public class Vocabulary {
21 |
22 | public static final String URI_BASE = "http://onto.fel.cvut.cz/ontologies/example04/";
23 |
24 | public static final String Student = URI_BASE + "Student";
25 | public static final String p_firstName = URI_BASE + "firstName";
26 | public static final String p_lastName = URI_BASE + "lastName";
27 | public static final String p_emailAddress = URI_BASE + "emailAddress";
28 | public static final String p_key = URI_BASE + "key";
29 | }
30 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/rest/DataController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.rest;
19 |
20 | import cz.cvut.kbss.jopa.example04.service.DataRepositoryService;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.web.bind.annotation.RequestMapping;
23 | import org.springframework.web.bind.annotation.RequestMethod;
24 | import org.springframework.web.bind.annotation.RequestParam;
25 | import org.springframework.web.bind.annotation.RestController;
26 |
27 | @RestController
28 | @RequestMapping("/data")
29 | public class DataController {
30 |
31 | private final DataRepositoryService dataService;
32 |
33 | @Autowired
34 | public DataController(DataRepositoryService dataService) {
35 | this.dataService = dataService;
36 | }
37 |
38 | @RequestMapping(method = RequestMethod.GET)
39 | public String getData(@RequestParam(value = "format", required = false, defaultValue = "rdfxml") String format) {
40 | return dataService.getRepositoryData(format);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/rest/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.rest;
19 |
20 | import org.springframework.http.HttpStatus;
21 | import org.springframework.web.bind.annotation.ResponseStatus;
22 |
23 | @ResponseStatus(HttpStatus.NOT_FOUND)
24 | public class NotFoundException extends RuntimeException {
25 |
26 | public NotFoundException(String message) {
27 | super(message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/service/DataFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.service;
19 |
20 | public enum DataFormat {
21 |
22 | JSON, RDFXML, TURTLE;
23 |
24 | public static DataFormat fromString(String str) {
25 | for (DataFormat df : values()) {
26 | if (str.equalsIgnoreCase(df.toString())) {
27 | return df;
28 | }
29 | }
30 | throw new IllegalArgumentException("No matching data format found for string " + str);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/java/cz/cvut/kbss/jopa/example04/service/DataRepositoryService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.service;
19 |
20 | import cz.cvut.kbss.jopa.example04.persistence.dao.DataDao;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Service;
23 |
24 | import java.util.Objects;
25 |
26 | @Service
27 | public class DataRepositoryService {
28 |
29 | private final DataDao dataDao;
30 |
31 | @Autowired
32 | public DataRepositoryService(DataDao dataDao) {
33 | this.dataDao = dataDao;
34 | }
35 |
36 | public String getRepositoryData(String format) {
37 | Objects.requireNonNull(format);
38 | final DataFormat df = DataFormat.fromString(format);
39 | return dataDao.getRepositoryData(df);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | repositoryUrl=file:/tmp/jopa/repositories/example04
2 | driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env", "@babel/preset-react"]
3 | }
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jopa-example04",
3 | "description": "Example web application demonstrating JOPA in cooperation with Spring.",
4 | "version": "0.16.3",
5 | "private": true,
6 | "homepage": ".",
7 | "dependencies": {
8 | "axios": "^1.8.2",
9 | "bootstrap": "^5.1.3",
10 | "prop-types": "^15.8.1",
11 | "react": "^17.0.2",
12 | "react-bootstrap": "^2.4.0",
13 | "react-dom": "^17.0.2",
14 | "react-redux": "^8.0.2",
15 | "redux": "^4.2.0",
16 | "redux-thunk": "^2.4.1",
17 | "web-vitals": "^2.1.4"
18 | },
19 | "devDependencies": {
20 | "@babel/preset-env": "^7.16.11",
21 | "@testing-library/jest-dom": "^5.16.3",
22 | "@testing-library/react": "^12.1.4",
23 | "@testing-library/user-event": "^14.0.0",
24 | "react-scripts": "5.0.0"
25 | },
26 | "scripts": {
27 | "start": "react-scripts start",
28 | "build": "react-scripts build",
29 | "test": "react-scripts test",
30 | "eject": "react-scripts eject",
31 | "prebuild": "npm install"
32 | },
33 | "eslintConfig": {
34 | "extends": [
35 | "react-app",
36 | "react-app/jest"
37 | ]
38 | },
39 | "browserslist": {
40 | "production": [
41 | ">0.2%",
42 | "not dead",
43 | "not op_mini all"
44 | ],
45 | "development": [
46 | "last 1 chrome version",
47 | "last 1 firefox version",
48 | "last 1 safari version"
49 | ]
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/example04-jopa-spring/src/main/webapp/public/favicon.ico
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/example04-jopa-spring/src/main/webapp/public/logo192.png
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/example04-jopa-spring/src/main/webapp/public/logo512.png
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/App.js:
--------------------------------------------------------------------------------
1 | import MainView from "./component/MainView";
2 | import {Container} from "react-bootstrap";
3 |
4 | function App() {
5 | return <>
6 |
7 | Example04 - JOPA + Spring
8 |
9 |
10 |
11 |
12 | >;
13 | }
14 |
15 | export default App;
16 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/action/ActionType.js:
--------------------------------------------------------------------------------
1 | const ActionType = {
2 | SELECT_DATA_FORMAT: "SELECT_DATA_FORMAT",
3 | LOAD_DATA: "LOAD_DATA",
4 |
5 | LOAD_STUDENTS: "LOAD_STUDENTS",
6 | CREATE_STUDENT: "CREATE_STUDENT",
7 | DELETE_STUDENT: "DELETE_STUDENT",
8 | };
9 |
10 | export default ActionType;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/action/AsyncStatus.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Async action status declarations.
3 | */
4 |
5 | const AsyncStatus = {
6 | REQUEST: "REQUEST",
7 | SUCCESS: "SUCCESS",
8 | FAILURE: "FAILURE"
9 | };
10 |
11 | export default AsyncStatus;
12 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/component/Data.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {useDispatch, useSelector} from "react-redux";
3 | import {loadData, selectDataFormat} from "../action/Actions";
4 | import {Card, Form} from "react-bootstrap";
5 |
6 | export const formats = [
7 | {value: "rdfxml", label: "RDF/XML (Pretty)"},
8 | {value: "json", label: "JSON"},
9 | {value: "turtle", label: "Turtle"}
10 | ];
11 |
12 | const Data = () => {
13 | const dispatch = useDispatch();
14 | const format = useSelector(state => state.dataFormat);
15 | const data = useSelector(state => state.data);
16 | React.useEffect(() => {
17 | dispatch(loadData());
18 | }, [dispatch]);
19 | const onSelectFormat = e => {
20 | dispatch(selectDataFormat(e.currentTarget.value));
21 | dispatch(loadData());
22 | }
23 |
24 | return
25 | Repository Content
26 |
27 |
28 |
29 | {formats.map(f => )}
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | };
38 |
39 | export default Data;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/component/MainView.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {Col, Row} from "react-bootstrap";
3 | import Data from "./Data";
4 | import Students from "./Students";
5 |
6 | const MainView = () => {
7 | return
8 |
9 |
10 |
11 |
12 |
13 |
14 |
;
15 | };
16 |
17 | export default MainView;
18 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/component/StudentRow.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {Button} from "react-bootstrap";
3 | import PropTypes from "prop-types";
4 |
5 | const StudentRow = ({student, onDelete}) => {
6 | const name = student.firstName + " " + student.lastName;
7 | return
8 | {name} |
9 | {student.email} |
10 |
11 | |
12 |
;
13 | };
14 |
15 | StudentRow.propTypes = {
16 | student: PropTypes.object.isRequired,
17 | onDelete: PropTypes.func.isRequired
18 | };
19 |
20 | export default StudentRow;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/component/Students.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {useDispatch, useSelector} from "react-redux";
3 | import {createStudent, deleteStudent, loadStudents} from "../action/Actions";
4 | import {Card, Col, Row, Table} from "react-bootstrap";
5 | import StudentRow from "./StudentRow";
6 | import CreateStudent from "./CreateStudent";
7 |
8 | const Students = () => {
9 | const students = useSelector(state => state.students);
10 | const dispatch = useDispatch();
11 | React.useEffect(() => {
12 | dispatch(loadStudents());
13 | }, [dispatch]);
14 | const onCreate = student => {
15 | dispatch(createStudent(student));
16 | };
17 | const onDelete = student => {
18 | dispatch(deleteStudent(student));
19 | }
20 |
21 | return
22 | Students
23 |
24 |
25 |
26 |
27 |
28 |
29 | Name |
30 | Email |
31 | Actions |
32 |
33 |
34 |
35 | {students.map(s => )}
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | ;
47 | };
48 |
49 | export default Students;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/index.css:
--------------------------------------------------------------------------------
1 | /**
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | body {
19 | margin: 0;
20 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
21 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
22 | sans-serif;
23 | -webkit-font-smoothing: antialiased;
24 | -moz-osx-font-smoothing: grayscale;
25 | }
26 |
27 | code {
28 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
29 | monospace;
30 | }
31 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 | import {Provider} from "react-redux";
7 | import store from "./store/ReduxStore";
8 | import "bootstrap/dist/css/bootstrap.min.css";
9 |
10 | ReactDOM.render(
11 |
12 |
13 |
14 |
15 | ,
16 | document.getElementById('root')
17 | );
18 |
19 | // If you want to start measuring performance in your app, pass a function
20 | // to log results (for example: reportWebVitals(console.log))
21 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
22 | reportWebVitals();
23 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/reducer/reducers.js:
--------------------------------------------------------------------------------
1 | import {combineReducers} from "redux";
2 | import ActionType from "../action/ActionType";
3 | import AsyncStatus from "../action/AsyncStatus";
4 | import {formats} from "../component/Data";
5 |
6 | function dataFormat(state = formats[0].value, action) {
7 | if (action.type === ActionType.SELECT_DATA_FORMAT) {
8 | return action.format;
9 | }
10 | return state;
11 | }
12 |
13 | function data(state = "", action) {
14 | if (action.type === ActionType.LOAD_DATA && action.status === AsyncStatus.SUCCESS) {
15 | return action.payload;
16 | }
17 | return state;
18 | }
19 |
20 | function students(state = [], action) {
21 | if (action.type === ActionType.LOAD_STUDENTS && action.status === AsyncStatus.SUCCESS) {
22 | return action.payload;
23 | }
24 | return state;
25 | }
26 |
27 | const rootReducer = combineReducers({
28 | dataFormat,
29 | data,
30 | students
31 | });
32 |
33 | export default rootReducer;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/main/webapp/src/store/ReduxStore.js:
--------------------------------------------------------------------------------
1 | import {applyMiddleware, compose, createStore} from "redux";
2 | import rootReducer from "../reducer/reducers";
3 | import thunk from "redux-thunk";
4 |
5 | const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
6 |
7 | const ReduxStore = createStore(rootReducer, composeEnhancers(applyMiddleware(thunk)));
8 |
9 | export default ReduxStore;
--------------------------------------------------------------------------------
/example04-jopa-spring/src/test/java/cz/cvut/kbss/jopa/example04/environment/TestRdf4jPersistenceProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.environment;
19 |
20 | import org.eclipse.rdf4j.repository.Repository;
21 | import org.springframework.context.annotation.Bean;
22 | import org.springframework.context.annotation.Configuration;
23 | import org.springframework.context.annotation.Primary;
24 |
25 | import static org.mockito.Mockito.mock;
26 |
27 | @Configuration
28 | public class TestRdf4jPersistenceProvider {
29 |
30 | @Bean
31 | @Primary
32 | public Repository repository() {
33 | return mock(Repository.class);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/test/java/cz/cvut/kbss/jopa/example04/environment/TransactionalTestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example04.environment;
19 |
20 | import org.springframework.beans.factory.annotation.Autowired;
21 | import org.springframework.transaction.PlatformTransactionManager;
22 |
23 | public abstract class TransactionalTestRunner {
24 |
25 | @Autowired
26 | protected PlatformTransactionManager txManager;
27 |
28 | protected void transactional(Runnable procedure) {
29 | Transaction.execute(txManager, procedure);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/example04-jopa-spring/src/test/resources/config.properties:
--------------------------------------------------------------------------------
1 | repositoryUrl=mem:test
2 | driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource
3 |
--------------------------------------------------------------------------------
/example05-jopa-owl2query/README.md:
--------------------------------------------------------------------------------
1 | # JOPA Example 05 - JOPA + OWL2Query
2 |
3 | This example shows how JOPA works with OWL2Query, which provides SPARQL-DL query support for OWLAPI-based ontologies.
4 |
5 | ### Features
6 |
7 | This example shows query support when accessing OWL ontologies with JOPA. In addition, unmapped properties are used.
8 |
9 | ### OWL2Query
10 |
11 | [OWL2Query](https://kbss.felk.cvut.cz/web/portal/owl2query) is a query engine with OWL 2 and SPARQL-DL with negation as failure support.
12 | It is used by default by the OWLAPI OntoDriver. In this example, [Openllet](https://github.com/Galigator/openllet) is used to evaluate
13 | the queries.
14 |
15 | ### Unmapped Properties
16 |
17 | It is not always possible (and/or desirable) to capture the whole ontology schema with the object model. If it were, there would be
18 | little reason to use ontologies over relational databases (apart from inference, of course). JOPA provides (limited) access
19 | to property values of an individual, which are not mapped by the object model.
20 |
21 | These values are stored in a field annotated with @Properties. Currently, it is a map with string keys (representing the property IRI)
22 | and sets of strings as values. This somewhat limits the expressiveness of the values, which are always stored as string literals
23 | in the ontology. If a corresponding property is not found in the TBox, it is assumed to be an object property.
24 |
25 | ## Persistence Setup
26 |
27 | The persistence is set up in `cz.cvut.kbss.jopa.example05.persistence.PersistenceFactory`. We are using an existing OWL ontology,
28 | which defines the object properties we want to use for inference. To be sure that the ontology is not interfered with and
29 | thus stays reusable, the application copies the ontology into a separate file, which is then used as a storage for the application.
30 |
31 | ## Running the Demo
32 |
33 | To run the demo, `mvn exec:java` can be used.
34 |
--------------------------------------------------------------------------------
/example05-jopa-owl2query/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/README.md:
--------------------------------------------------------------------------------
1 | # JOPA Example 06 - JOPA + Mapped Superclass Support
2 |
3 | This example showcases JOPA's support for mapped superclasses.
4 |
5 | ### Features
6 |
7 | * `@MappedSuperclass` support
8 | * Plain URI object property values
9 |
10 | ### Mapped Superclass
11 |
12 | Mapped superclasses allow entities to inherit common attributes and behaviour. However, the classes themselves are not mapped
13 | to any ontological classes. Their attributes are added to the attributes of entity classes which extend them.
14 |
15 | In this case, the `AbstractEntity` represents a common persistence idiom, in which there is a single abstract mapped superclass,
16 | which declares an identifier, and is extended by all entities in the model. In our model, there is another mapped superclass -
17 | `Report`, which declares attributes common to both `AuditReport` and `OccurrenceReport`.
18 |
19 | ### Plain URI Object Property Values
20 |
21 | JOPA now supports use of identifiers instead of full entities as object property values. This enables the model to be connected
22 | to parts of the ontology which are not mapped by it. The identifier-valued properties are always eagerly fetched and no
23 | range check is performed, as there is no knowledge about the target of the relationship in the model.
24 |
25 | ## Persistence Setup
26 |
27 | The persistence is set up in `cz.cvut.kbss.jopa.example06.persistence.PersistenceFactory`. We are using an in-memory RDF4J repository,
28 | which is thrown away after the application exits.
29 |
30 | ## Running the Demo
31 |
32 | To run the demo, `mvn exec:java` can be used.
33 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | cz.cvut.kbss.jopa
7 | jopa-examples-parent
8 | 2.0.0
9 | ../pom.xml
10 |
11 | 4.0.0
12 |
13 | example-06
14 | Example06-JOPA-RDF4J-MappedSuperclass
15 |
16 | Demo showcasing mapped superclass support in JOPA.
17 |
18 |
19 |
20 |
21 | cz.cvut.kbss.jopa
22 | ontodriver-rdf4j
23 | ${cz.cvut.kbss.jopa.version}
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.codehaus.mojo
32 | exec-maven-plugin
33 | 1.4.0
34 |
35 | cz.cvut.kbss.jopa.example06.Example
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/src/main/java/cz/cvut/kbss/jopa/example06/DataOutput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example06;
19 |
20 | import cz.cvut.kbss.jopa.example06.model.Report;
21 |
22 | import java.util.Collection;
23 |
24 | class DataOutput {
25 |
26 | void printReports(String tableHeadline, Collection extends Report> reports) {
27 | System.out.println(String.format("%1$-53s", "").replace(' ', '-'));
28 | System.out.println("|" + String.format("%1$-51s", tableHeadline) + "|");
29 | if (!reports.isEmpty()) {
30 | reports.iterator().next().printTableHeader();
31 | reports.forEach(Report::printTableRow);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/src/main/java/cz/cvut/kbss/jopa/example06/model/AbstractEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example06.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.MappedSuperclass;
22 |
23 | import java.io.Serializable;
24 | import java.net.URI;
25 |
26 | /**
27 | * Base class for all entities.
28 | *
29 | * Declares just the identifier and getter/setter for it.
30 | */
31 | @MappedSuperclass
32 | abstract class AbstractEntity implements Serializable {
33 |
34 | @Id(generated = true)
35 | private URI uri;
36 |
37 | public URI getUri() {
38 | return uri;
39 | }
40 |
41 | public void setUri(URI uri) {
42 | this.uri = uri;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/src/main/java/cz/cvut/kbss/jopa/example06/model/Vocabulary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example06.model;
19 |
20 | public class Vocabulary {
21 |
22 | private Vocabulary() {
23 | throw new AssertionError();
24 | }
25 |
26 | static final String URI_BASE = "http://krizik.felk.cvut.cz/ontologies/example06/";
27 |
28 | public static final String Person = URI_BASE + "Person";
29 | public static final String OccurrenceReport = URI_BASE + "OccurrenceReport";
30 | public static final String AuditReport = URI_BASE + "AuditReport";
31 |
32 | static final String firstName = URI_BASE + "firstName";
33 | static final String lastName = URI_BASE + "lastName";
34 | static final String username = URI_BASE + "username";
35 | public static final String hasAuthor = URI_BASE + "hasAuthor";
36 | static final String startTime = URI_BASE + "startTime";
37 | static final String endTime = URI_BASE + "endTime";
38 | static final String date = "http://purl.org/dc/terms/date";
39 | static final String hasSeverity = URI_BASE + "hasSeverity";
40 | static final String hasOutcome = URI_BASE + "hasOutcome";
41 | }
42 |
--------------------------------------------------------------------------------
/example06-jopa-mapped-superclass/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/Example07.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07;
19 |
20 | import org.springframework.boot.SpringApplication;
21 | import org.springframework.boot.autoconfigure.SpringBootApplication;
22 |
23 | @SpringBootApplication
24 | public class Example07 {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(Example07.class, args);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/config/RestConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.config;
19 |
20 | import com.fasterxml.jackson.annotation.JsonInclude;
21 | import com.fasterxml.jackson.databind.DeserializationFeature;
22 | import com.fasterxml.jackson.databind.ObjectMapper;
23 | import cz.cvut.kbss.jsonld.jackson.JsonLdModule;
24 | import org.springframework.context.annotation.Bean;
25 | import org.springframework.context.annotation.Configuration;
26 |
27 | @Configuration
28 | public class RestConfig {
29 |
30 | @Bean
31 | public ObjectMapper objectMapper() {
32 | final ObjectMapper objectMapper = new ObjectMapper();
33 | objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
34 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
35 | // Here we register the JSON-LD serialization/deserialization module
36 | objectMapper.registerModule(new JsonLdModule());
37 | return objectMapper;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/model/AbstractEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.MappedSuperclass;
22 |
23 | import java.net.URI;
24 |
25 | @MappedSuperclass
26 | public class AbstractEntity {
27 |
28 | @Id(generated = true)
29 | private URI uri;
30 |
31 | public URI getUri() {
32 | return uri;
33 | }
34 |
35 | public void setUri(URI uri) {
36 | this.uri = uri;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/model/AuditReport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
21 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
22 | import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
23 |
24 | import java.util.Date;
25 | import java.util.Set;
26 |
27 | @OWLClass(iri = Vocabulary.c_AuditReport)
28 | public class AuditReport extends Report {
29 |
30 | @ParticipationConstraints(nonEmpty = true)
31 | @OWLDataProperty(iri = Vocabulary.p_date)
32 | private Date date;
33 |
34 | @OWLDataProperty(iri = Vocabulary.p_hasFinding)
35 | private Set findings;
36 |
37 | public Date getDate() {
38 | return date;
39 | }
40 |
41 | public void setDate(Date date) {
42 | this.date = date;
43 | }
44 |
45 | public Set getFindings() {
46 | return findings;
47 | }
48 |
49 | public void setFindings(Set findings) {
50 | this.findings = findings;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/model/OccurrenceReport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
21 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
22 | import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
23 |
24 | import java.util.Date;
25 |
26 | @OWLClass(iri = Vocabulary.c_OccurrenceReport)
27 | public class OccurrenceReport extends Report {
28 |
29 | @ParticipationConstraints(nonEmpty = true)
30 | @OWLDataProperty(iri = Vocabulary.p_date)
31 | private Date date;
32 |
33 | @OWLDataProperty(iri = Vocabulary.p_severity)
34 | private Integer severity;
35 |
36 | public Date getDate() {
37 | return date;
38 | }
39 |
40 | public void setDate(Date date) {
41 | this.date = date;
42 | }
43 |
44 | public Integer getSeverity() {
45 | return severity;
46 | }
47 |
48 | public void setSeverity(Integer severity) {
49 | this.severity = severity;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/model/SafetyIssueReport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
21 | import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty;
22 |
23 | import java.util.Set;
24 |
25 | @OWLClass(iri = Vocabulary.c_SafetyIssueReport)
26 | public class SafetyIssueReport extends Report {
27 |
28 | @OWLObjectProperty(iri = Vocabulary.p_basedOn)
29 | private Set bases;
30 |
31 | public Set getBases() {
32 | return bases;
33 | }
34 |
35 | public void setBases(Set bases) {
36 | this.bases = bases;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/rest/exception/ErrorInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.rest.exception;
19 |
20 | /**
21 | * Contains information about an error and can be send to client as JSON to let him know what was wrong.
22 | */
23 | public class ErrorInfo {
24 |
25 | private String message;
26 |
27 | private String requestUri;
28 |
29 | public ErrorInfo() {
30 | }
31 |
32 | public ErrorInfo(String message, String requestUri) {
33 | this.message = message;
34 | this.requestUri = requestUri;
35 | }
36 |
37 | public String getMessage() {
38 | return message;
39 | }
40 |
41 | public void setMessage(String message) {
42 | this.message = message;
43 | }
44 |
45 | public String getRequestUri() {
46 | return requestUri;
47 | }
48 |
49 | public void setRequestUri(String requestUri) {
50 | this.requestUri = requestUri;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return "ErrorInfo{" + requestUri + ", message = " + message + "}";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/java/cz/cvut/kbss/jopa/example07/rest/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example07.rest.exception;
19 |
20 | public class NotFoundException extends RuntimeException {
21 |
22 | public NotFoundException(String message) {
23 | super(message);
24 | }
25 |
26 | public static NotFoundException create(String resourceName, Object identifier) {
27 | return new NotFoundException(resourceName + " identified by " + identifier + " not found.");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.servlet.context-path=/example07
2 | spring.mvc.servlet.path=/rest/
3 | server.port=18117
4 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | repositoryUrl=file:/tmp/jopa/repositories/example07
2 | driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource
3 |
--------------------------------------------------------------------------------
/example07-jopa-plural-dp-inheritance/src/main/resources/logback-spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/java/cz/cvut/kbss/jopa/example08/Example08.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example08;
19 |
20 | import org.springframework.boot.SpringApplication;
21 | import org.springframework.boot.autoconfigure.SpringBootApplication;
22 |
23 | @SpringBootApplication
24 | public class Example08 {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(Example08.class, args);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/java/cz/cvut/kbss/jopa/example08/model/AbstractEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example08.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.MappedSuperclass;
22 |
23 | import java.net.URI;
24 |
25 | @MappedSuperclass
26 | abstract class AbstractEntity {
27 |
28 | @Id(generated = true)
29 | private URI uri;
30 |
31 | public URI getUri() {
32 | return uri;
33 | }
34 |
35 | public void setUri(URI uri) {
36 | this.uri = uri;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/java/cz/cvut/kbss/jopa/example08/model/AuditReport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example08.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.CascadeType;
21 | import cz.cvut.kbss.jopa.model.annotations.FetchType;
22 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
23 | import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty;
24 |
25 | @OWLClass(iri = Vocabulary.C_AUDIT_REPORT)
26 | public class AuditReport extends AbstractReport {
27 |
28 | @OWLObjectProperty(iri = Vocabulary.P_DOCUMENTS, cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
29 | private Audit audit;
30 |
31 | public Audit getAudit() {
32 | return audit;
33 | }
34 |
35 | public void setAudit(Audit audit) {
36 | this.audit = audit;
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return "AuditReport{" +
42 | "audit=" + audit +
43 | '}';
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/java/cz/cvut/kbss/jopa/example08/model/OccurrenceReport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example08.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.*;
21 |
22 | @OWLClass(iri = Vocabulary.C_OCCURRENCE_REPORT)
23 | public class OccurrenceReport extends AbstractReport {
24 |
25 | @OWLObjectProperty(iri = Vocabulary.P_DOCUMENTS, cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
26 | @ParticipationConstraints(nonEmpty = true)
27 | private Occurrence occurrence;
28 |
29 | public Occurrence getOccurrence() {
30 | return occurrence;
31 | }
32 |
33 | public void setOccurrence(Occurrence occurrence) {
34 | this.occurrence = occurrence;
35 | }
36 |
37 | @Override
38 | public String toString() {
39 | return "OccurrenceReport{" +
40 | "occurrence=" + occurrence +
41 | '}';
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/java/cz/cvut/kbss/jopa/example08/rest/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example08.rest;
19 |
20 | import org.springframework.http.HttpStatus;
21 | import org.springframework.web.bind.annotation.ResponseStatus;
22 |
23 | @ResponseStatus(HttpStatus.NOT_FOUND)
24 | public class NotFoundException extends RuntimeException {
25 |
26 | public NotFoundException(String message) {
27 | super(message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.servlet.context-path=/example08
2 | spring.mvc.servlet.path=/rest/
3 | server.port=18115
4 | # Application-specific configuration
5 | #repositoryUrl=http://localhost:18080/fuseki/test-one
6 | #repository.type=fuseki
7 | repository.type=tdb
8 | repositoryUrl=/tmp/jopa-example08
9 |
--------------------------------------------------------------------------------
/example08-jena-polymorphism/src/main/resources/logback-spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/example09-soql/src/main/java/cz/cvut/kbss/jopa/example09/Example09.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example09;
19 |
20 | import org.springframework.boot.SpringApplication;
21 | import org.springframework.boot.autoconfigure.SpringBootApplication;
22 |
23 | @SpringBootApplication
24 | public class Example09 {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(Example09.class, args);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example09-soql/src/main/java/cz/cvut/kbss/jopa/example09/model/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | @Namespaces({@Namespace(prefix = "foaf", namespace = "http://xmlns.com/foaf/0.1/"),
19 | @Namespace(prefix = "dbo", namespace = "http://dbpedia.org/ontology/")})
20 | package cz.cvut.kbss.jopa.example09.model;
21 |
22 | import cz.cvut.kbss.jopa.model.annotations.Namespace;
23 | import cz.cvut.kbss.jopa.model.annotations.Namespaces;
24 |
--------------------------------------------------------------------------------
/example09-soql/src/main/java/cz/cvut/kbss/jopa/example09/rest/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.example09.rest;
19 |
20 | import org.springframework.http.HttpStatus;
21 | import org.springframework.web.bind.annotation.ResponseStatus;
22 |
23 | @ResponseStatus(HttpStatus.NOT_FOUND)
24 | public class NotFoundException extends RuntimeException {
25 |
26 | public NotFoundException(String message) {
27 | super(message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/example09-soql/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.servlet.context-path=/example09
2 | spring.mvc.servlet.path=/rest/
3 | server.port=18119
4 | # Application-specific configuration
5 | repositoryUrl=data.ttl
6 |
--------------------------------------------------------------------------------
/example09-soql/src/main/resources/logback-spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/example10-strings-languages/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "java"
3 | id "io.freefair.aspectj" version "8.6"
4 | }
5 |
6 | group "cz.cvut.kbss.jopa"
7 | version "1.2.2"
8 |
9 | repositories {
10 | mavenCentral()
11 | }
12 |
13 | dependencies {
14 | implementation "cz.cvut.kbss.jopa:jopa-impl:1.2.2"
15 | implementation "cz.cvut.kbss.jopa:ontodriver-rdf4j:1.2.2"
16 | implementation "org.slf4j:slf4j-api:1.7.36"
17 | implementation "ch.qos.logback:logback-classic:1.2.13"
18 |
19 | aspect "cz.cvut.kbss.jopa:jopa-impl:1.2.2"
20 | }
21 |
22 | task runApp(type: JavaExec) {
23 | classpath = sourceSets.main.runtimeClasspath
24 |
25 | mainClass = 'cz.cvut.kbss.jopa.example10.Example'
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/example10-strings-languages/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | cz.cvut.kbss.jopa
8 | jopa-examples-parent
9 | 2.0.0
10 |
11 |
12 | example10-strings-languages
13 | Example10 - Strings and Languages
14 |
15 |
16 |
17 | cz.cvut.kbss.jopa
18 | ontodriver-rdf4j
19 | ${cz.cvut.kbss.jopa.version}
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.codehaus.mojo
28 | exec-maven-plugin
29 | 1.4.0
30 |
31 |
32 | default-cli
33 |
34 | cz.cvut.kbss.jopa.example10.Example
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/example10-strings-languages/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "example10-strings-languages"
--------------------------------------------------------------------------------
/example10-strings-languages/src/main/java/cz/cvut/kbss/jopa/example10/model/Person.java:
--------------------------------------------------------------------------------
1 | package cz.cvut.kbss.jopa.example10.model;
2 |
3 | import cz.cvut.kbss.jopa.model.annotations.Id;
4 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
5 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
6 | import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
7 |
8 | import java.net.URI;
9 |
10 | @OWLClass(iri = "foaf:Person")
11 | public class Person {
12 |
13 | @Id
14 | private URI uri;
15 |
16 | @ParticipationConstraints(nonEmpty = true)
17 | @OWLDataProperty(iri = "foaf:givenName")
18 | private String firstName;
19 |
20 | @ParticipationConstraints(nonEmpty = true)
21 | @OWLDataProperty(iri = "foaf:familyName")
22 | private String lastName;
23 |
24 | @OWLDataProperty(iri = "foaf:mbox")
25 | private String email;
26 |
27 | public URI getUri() {
28 | return uri;
29 | }
30 |
31 | public void setUri(URI uri) {
32 | this.uri = uri;
33 | }
34 |
35 | public String getFirstName() {
36 | return firstName;
37 | }
38 |
39 | public void setFirstName(String firstName) {
40 | this.firstName = firstName;
41 | }
42 |
43 | public String getLastName() {
44 | return lastName;
45 | }
46 |
47 | public void setLastName(String lastName) {
48 | this.lastName = lastName;
49 | }
50 |
51 | public String getEmail() {
52 | return email;
53 | }
54 |
55 | public void setEmail(String email) {
56 | this.email = email;
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return getClass().getSimpleName() + "{<" + uri + "> " + firstName + " " + lastName + " (" + email + ")}";
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example10-strings-languages/src/main/java/cz/cvut/kbss/jopa/example10/model/SimpleLiteralPerson.java:
--------------------------------------------------------------------------------
1 | package cz.cvut.kbss.jopa.example10.model;
2 |
3 | import cz.cvut.kbss.jopa.model.annotations.Id;
4 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
5 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
6 | import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
7 |
8 | import java.net.URI;
9 |
10 | @OWLClass(iri = "foaf:Person")
11 | public class SimpleLiteralPerson {
12 |
13 | @Id
14 | private URI uri;
15 |
16 | @ParticipationConstraints(nonEmpty = true)
17 | @OWLDataProperty(iri = "foaf:givenName", simpleLiteral = true)
18 | private String firstName;
19 |
20 | @ParticipationConstraints(nonEmpty = true)
21 | @OWLDataProperty(iri = "foaf:familyName", simpleLiteral = true)
22 | private String lastName;
23 |
24 | @OWLDataProperty(iri = "foaf:mbox", simpleLiteral = true)
25 | private String email;
26 |
27 | public URI getUri() {
28 | return uri;
29 | }
30 |
31 | public void setUri(URI uri) {
32 | this.uri = uri;
33 | }
34 |
35 | public String getFirstName() {
36 | return firstName;
37 | }
38 |
39 | public void setFirstName(String firstName) {
40 | this.firstName = firstName;
41 | }
42 |
43 | public String getLastName() {
44 | return lastName;
45 | }
46 |
47 | public void setLastName(String lastName) {
48 | this.lastName = lastName;
49 | }
50 |
51 | public String getEmail() {
52 | return email;
53 | }
54 |
55 | public void setEmail(String email) {
56 | this.email = email;
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return getClass().getSimpleName() + "{<" + uri + "> " + firstName + " " + lastName + " (" + email + ")}";
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example10-strings-languages/src/main/java/cz/cvut/kbss/jopa/example10/model/Term.java:
--------------------------------------------------------------------------------
1 | package cz.cvut.kbss.jopa.example10.model;
2 |
3 | import cz.cvut.kbss.jopa.model.MultilingualString;
4 | import cz.cvut.kbss.jopa.model.annotations.Id;
5 | import cz.cvut.kbss.jopa.model.annotations.OWLAnnotationProperty;
6 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
7 | import cz.cvut.kbss.jopa.vocabulary.SKOS;
8 |
9 | import java.net.URI;
10 |
11 | @OWLClass(iri = SKOS.CONCEPT)
12 | public class Term {
13 |
14 | @Id
15 | private URI uri;
16 |
17 | @OWLAnnotationProperty(iri = SKOS.PREF_LABEL)
18 | private MultilingualString label;
19 |
20 | public URI getUri() {
21 | return uri;
22 | }
23 |
24 | public void setUri(URI uri) {
25 | this.uri = uri;
26 | }
27 |
28 | public MultilingualString getLabel() {
29 | return label;
30 | }
31 |
32 | public void setLabel(MultilingualString label) {
33 | this.label = label;
34 | }
35 |
36 | @Override
37 | public String toString() {
38 | return getClass().getSimpleName() + "{<" + uri + "> " + label + '}';
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/example10-strings-languages/src/main/java/cz/cvut/kbss/jopa/example10/model/package-info.java:
--------------------------------------------------------------------------------
1 | @Namespace(prefix = "foaf", namespace = "http://xmlns.com/foaf/0.1/")
2 | package cz.cvut.kbss.jopa.example10.model;
3 |
4 | import cz.cvut.kbss.jopa.model.annotations.Namespace;
--------------------------------------------------------------------------------
/example10-strings-languages/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/header.txt:
--------------------------------------------------------------------------------
1 | JOPA Examples
2 | Copyright (C) 2024 Czech Technical University in Prague
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 3.0 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library.
16 |
--------------------------------------------------------------------------------
/jsonld/mapping:
--------------------------------------------------------------------------------
1 | http://krizik.felk.cvut.cz/ontologies/study-manager > ./model.ttl
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/JsonLdDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld;
19 |
20 | import org.springframework.boot.SpringApplication;
21 | import org.springframework.boot.autoconfigure.SpringBootApplication;
22 |
23 | @SpringBootApplication
24 | public class JsonLdDemo {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(JsonLdDemo.class, args);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/config/PersistenceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.config;
19 |
20 | import com.github.ledsoft.jopa.spring.transaction.DelegatingEntityManager;
21 | import com.github.ledsoft.jopa.spring.transaction.JopaTransactionManager;
22 | import cz.cvut.kbss.jopa.model.EntityManagerFactory;
23 | import org.springframework.context.annotation.Bean;
24 | import org.springframework.context.annotation.Configuration;
25 | import org.springframework.context.annotation.EnableAspectJAutoProxy;
26 | import org.springframework.transaction.PlatformTransactionManager;
27 | import org.springframework.transaction.annotation.EnableTransactionManagement;
28 |
29 | @EnableTransactionManagement
30 | @EnableAspectJAutoProxy(proxyTargetClass = true)
31 | @Configuration
32 | public class PersistenceConfig {
33 |
34 | @Bean
35 | public DelegatingEntityManager entityManager() {
36 | return new DelegatingEntityManager();
37 | }
38 |
39 | @Bean(name = "txManager")
40 | public PlatformTransactionManager transactionManager(EntityManagerFactory emf, DelegatingEntityManager emProxy) {
41 | return new JopaTransactionManager(emf, emProxy);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/dto/mapper/DtoMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.dto.mapper;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.dto.OrganizationDto;
21 | import cz.cvut.kbss.jopa.jsonld.dto.StudyDto;
22 | import cz.cvut.kbss.jopa.jsonld.dto.UserDto;
23 | import cz.cvut.kbss.jopa.jsonld.model.Organization;
24 | import cz.cvut.kbss.jopa.jsonld.model.Study;
25 | import cz.cvut.kbss.jopa.jsonld.model.User;
26 | import org.mapstruct.Mapper;
27 |
28 | @Mapper(componentModel = "spring")
29 | public interface DtoMapper {
30 |
31 | OrganizationDto organizationToDto(Organization entity);
32 |
33 | Organization dtoToOrganization(OrganizationDto dto);
34 |
35 | StudyDto studyToDto(Study entity);
36 |
37 | Study dtoToStudy(StudyDto dto);
38 |
39 | UserDto userToDto(User entity);
40 |
41 | User dtoToUser(UserDto dto);
42 | }
43 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/model/AbstractEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.model;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.Id;
21 | import cz.cvut.kbss.jopa.model.annotations.MappedSuperclass;
22 | import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
23 | import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
24 |
25 | import java.io.Serializable;
26 | import java.net.URI;
27 |
28 | @MappedSuperclass
29 | public class AbstractEntity implements Serializable {
30 |
31 | @Id(generated = true)
32 | private URI uri;
33 |
34 | @ParticipationConstraints(nonEmpty = true)
35 | @OWLDataProperty(iri = Vocabulary.s_p_key)
36 | private String key;
37 |
38 | public URI getUri() {
39 | return uri;
40 | }
41 |
42 | public void setUri(URI uri) {
43 | this.uri = uri;
44 | }
45 |
46 | public String getKey() {
47 | return key;
48 | }
49 |
50 | public void setKey(String key) {
51 | this.key = key;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/model/util/EntityToOwlClassMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.model.util;
19 |
20 | import cz.cvut.kbss.jopa.model.annotations.OWLClass;
21 |
22 | /**
23 | * Utility class for getting information about the entity - OWL class mapping.
24 | */
25 | public class EntityToOwlClassMapper {
26 |
27 | private EntityToOwlClassMapper() {
28 | throw new AssertionError();
29 | }
30 |
31 | /**
32 | * Gets IRI of the OWL class mapped by the specified entity.
33 | *
34 | * @param entityClass Entity class
35 | * @return IRI of mapped OWL class (as String)
36 | */
37 | public static String getOwlClassForEntity(Class> entityClass) {
38 | final OWLClass owlClass = entityClass.getDeclaredAnnotation(OWLClass.class);
39 | if (owlClass == null) {
40 | throw new IllegalArgumentException("Class " + entityClass + " is not an entity.");
41 | }
42 | return owlClass.iri();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/model/util/HasDerivableUri.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.model.util;
19 |
20 | public interface HasDerivableUri {
21 |
22 | void generateUri();
23 | }
24 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/persistence/PersistenceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.persistence;
19 |
20 | /**
21 | * General exception marking an error in the persistence layer.
22 | */
23 | public class PersistenceException extends RuntimeException {
24 |
25 | public PersistenceException() {
26 | }
27 |
28 | public PersistenceException(String message) {
29 | super(message);
30 | }
31 |
32 | public PersistenceException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | public PersistenceException(Throwable cause) {
37 | super(cause);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/persistence/dao/DerivableUriDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.persistence.dao;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.AbstractEntity;
21 | import cz.cvut.kbss.jopa.jsonld.model.util.HasDerivableUri;
22 |
23 | public class DerivableUriDao extends BaseDao {
24 |
25 | DerivableUriDao(Class type) {
26 | super(type);
27 | }
28 |
29 | @Override
30 | public void persist(T entity) {
31 | entity.generateUri();
32 | super.persist(entity);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/persistence/dao/OrganizationDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.persistence.dao;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.Organization;
21 | import org.springframework.stereotype.Component;
22 |
23 | @Component
24 | public class OrganizationDao extends DerivableUriDao {
25 |
26 | public OrganizationDao() {
27 | super(Organization.class);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/persistence/dao/UserDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.persistence.dao;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.User;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Component;
23 |
24 | @Component
25 | public class UserDao extends DerivableUriDao {
26 |
27 | private final OrganizationDao organizationDao;
28 |
29 | @Autowired
30 | public UserDao(OrganizationDao organizationDao) {
31 | super(User.class);
32 | this.organizationDao = organizationDao;
33 | }
34 |
35 | @Override
36 | public void persist(User entity) {
37 | if (entity.getClinic() != null && !organizationDao.exists(entity.getClinic().getUri())) {
38 | organizationDao.persist(entity.getClinic());
39 | }
40 | super.persist(entity);
41 | }
42 |
43 | @Override
44 | public void update(User entity) {
45 | if (entity.getClinic() != null && !organizationDao.exists(entity.getClinic().getUri())) {
46 | organizationDao.persist(entity.getClinic());
47 | }
48 | super.update(entity);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/rest/exception/ErrorInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.rest.exception;
19 |
20 | /**
21 | * Contains information about an error and can be send to client as JSON to let him know what was wrong.
22 | */
23 | public class ErrorInfo {
24 |
25 | private String message;
26 |
27 | private String requestUri;
28 |
29 | public ErrorInfo() {
30 | }
31 |
32 | public ErrorInfo(String message, String requestUri) {
33 | this.message = message;
34 | this.requestUri = requestUri;
35 | }
36 |
37 | public String getMessage() {
38 | return message;
39 | }
40 |
41 | public void setMessage(String message) {
42 | this.message = message;
43 | }
44 |
45 | public String getRequestUri() {
46 | return requestUri;
47 | }
48 |
49 | public void setRequestUri(String requestUri) {
50 | this.requestUri = requestUri;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return "ErrorInfo{" + requestUri + ", message = " + message + "}";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/rest/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.rest.exception;
19 |
20 | public class NotFoundException extends RuntimeException {
21 |
22 | public NotFoundException(String message) {
23 | super(message);
24 | }
25 |
26 | public static NotFoundException create(String resourceName, Object identifier) {
27 | return new NotFoundException(resourceName + " identified by " + identifier + " not found.");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/rest/exception/RestExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.rest.exception;
19 |
20 | import jakarta.servlet.http.HttpServletRequest;
21 | import org.springframework.http.HttpStatus;
22 | import org.springframework.http.ResponseEntity;
23 | import org.springframework.web.bind.annotation.ControllerAdvice;
24 | import org.springframework.web.bind.annotation.ExceptionHandler;
25 |
26 | /**
27 | * Exception handlers for REST controllers.
28 | */
29 | @ControllerAdvice
30 | public class RestExceptionHandler {
31 |
32 | @ExceptionHandler(NotFoundException.class)
33 | public ResponseEntity resourceNotFound(HttpServletRequest request, NotFoundException e) {
34 | return new ResponseEntity<>(errorInfo(request, e), HttpStatus.NOT_FOUND);
35 | }
36 |
37 | private ErrorInfo errorInfo(HttpServletRequest request, Throwable e) {
38 | return new ErrorInfo(e.getMessage(), request.getRequestURI());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/service/BaseService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.service;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.AbstractEntity;
21 |
22 | import java.net.URI;
23 | import java.util.Collection;
24 | import java.util.List;
25 |
26 | /**
27 | * Provides basic CRUD operations.
28 | *
29 | * @param
30 | */
31 | public interface BaseService {
32 |
33 | List findAll();
34 |
35 | T find(URI uri);
36 |
37 | T findByKey(String key);
38 |
39 | void persist(T instance);
40 |
41 | void persist(Collection instances);
42 |
43 | void update(T instance);
44 |
45 | void remove(T instance);
46 |
47 | /**
48 | * Checks whether instance with the specified URI exists.
49 | *
50 | * @param uri Instance URI
51 | * @return Whether a matching instance exists
52 | */
53 | boolean exists(URI uri);
54 | }
55 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/service/OrganizationService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.service;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.Organization;
21 |
22 | public interface OrganizationService extends BaseService {
23 | }
24 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/service/StudyService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.service;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.Study;
21 |
22 | public interface StudyService extends BaseService {
23 | }
24 |
--------------------------------------------------------------------------------
/jsonld/src/main/java/cz/cvut/kbss/jopa/jsonld/service/UserService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.service;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.model.User;
21 |
22 | public interface UserService extends BaseService {
23 |
24 | /**
25 | * Gets default system user.
26 | *
27 | * This would normally return the currently logged in user. But for demo purposes, we create a default user.
28 | *
29 | * @return Default user
30 | */
31 | User getDefaultUser();
32 | }
33 |
--------------------------------------------------------------------------------
/jsonld/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.servlet.context-path=/jsonld
2 | server.port=18117
3 |
4 | apiPrefix=/rest
5 |
--------------------------------------------------------------------------------
/jsonld/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | repositoryUrl=file:/tmp/jopa/repositories/json-ld-demo
2 | driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource
3 |
--------------------------------------------------------------------------------
/jsonld/src/main/resources/logback-spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/jsonld/src/test/java/cz/cvut/kbss/jopa/jsonld/environment/TestPersistenceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.environment;
19 |
20 | import com.github.ledsoft.jopa.spring.transaction.DelegatingEntityManager;
21 | import com.github.ledsoft.jopa.spring.transaction.JopaTransactionManager;
22 | import cz.cvut.kbss.jopa.model.EntityManagerFactory;
23 | import org.springframework.context.annotation.*;
24 | import org.springframework.transaction.PlatformTransactionManager;
25 | import org.springframework.transaction.annotation.EnableTransactionManagement;
26 |
27 | @Configuration
28 | @EnableAspectJAutoProxy(proxyTargetClass = true)
29 | @ComponentScan(basePackages = {"cz.cvut.kbss.jopa.jsonld.persistence"})
30 | @Import({TestPersistenceFactory.class})
31 | @EnableTransactionManagement
32 | public class TestPersistenceConfig {
33 |
34 | @Bean
35 | public DelegatingEntityManager entityManager() {
36 | return new DelegatingEntityManager();
37 | }
38 |
39 | @Bean(name = "txManager")
40 | public PlatformTransactionManager transactionManager(EntityManagerFactory emf, DelegatingEntityManager emProxy) {
41 | return new JopaTransactionManager(emf, emProxy);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/jsonld/src/test/java/cz/cvut/kbss/jopa/jsonld/environment/TestServiceConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.environment;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.service.data.DataGenerator;
21 | import org.springframework.context.annotation.ComponentScan;
22 | import org.springframework.context.annotation.Configuration;
23 | import org.springframework.context.annotation.FilterType;
24 |
25 | @Configuration
26 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.jsonld.service", excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DataGenerator.class))
27 | public class TestServiceConfig {
28 | }
29 |
--------------------------------------------------------------------------------
/jsonld/src/test/java/cz/cvut/kbss/jopa/jsonld/environment/TestUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.environment;
19 |
20 | import org.springframework.transaction.PlatformTransactionManager;
21 | import org.springframework.transaction.TransactionStatus;
22 | import org.springframework.transaction.support.TransactionCallbackWithoutResult;
23 | import org.springframework.transaction.support.TransactionTemplate;
24 |
25 | public class TestUtils {
26 |
27 | /**
28 | * Executes the specified procedure in a transaction managed by the specified transaction manager.
29 | *
30 | * @param txManager Transaction manager
31 | * @param procedure Code to execute
32 | */
33 | public static void executeInTransaction(PlatformTransactionManager txManager, Runnable procedure) {
34 | new TransactionTemplate(txManager).execute(new TransactionCallbackWithoutResult() {
35 |
36 | @Override
37 | protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) {
38 | procedure.run();
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jsonld/src/test/java/cz/cvut/kbss/jopa/jsonld/service/repository/UserRepositoryServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JOPA Examples
3 | * Copyright (C) 2024 Czech Technical University in Prague
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 3.0 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library.
17 | */
18 | package cz.cvut.kbss.jopa.jsonld.service.repository;
19 |
20 | import cz.cvut.kbss.jopa.jsonld.environment.Generator;
21 | import cz.cvut.kbss.jopa.jsonld.model.User;
22 | import cz.cvut.kbss.jopa.jsonld.service.BaseServiceTestRunner;
23 | import org.junit.jupiter.api.Test;
24 | import org.springframework.beans.factory.annotation.Autowired;
25 |
26 | import static org.junit.jupiter.api.Assertions.assertEquals;
27 | import static org.junit.jupiter.api.Assertions.assertNotNull;
28 |
29 | public class UserRepositoryServiceTest extends BaseServiceTestRunner {
30 |
31 | @Autowired
32 | private UserRepositoryService userService;
33 |
34 | @Test
35 | public void persistSetsDateCreated() {
36 | final User user = Generator.generateUser();
37 | user.setDateCreated(null);
38 | userService.persist(user);
39 | assertNotNull(user.getDateCreated());
40 |
41 | final User result = userService.findByKey(user.getKey());
42 | assertEquals(user.getDateCreated(), result.getDateCreated());
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/jsonld/src/test/resources/config.properties:
--------------------------------------------------------------------------------
1 | repositoryUrl=jsonld-test-repository
2 | driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource
3 |
--------------------------------------------------------------------------------
/jsonld/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------