├── .gitignore ├── README.md ├── eswc2016 ├── README.md ├── documentation.rdf ├── eswc2016-owlapi.owl ├── ic-eswc2016.owl ├── mapping ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── cz │ │ │ └── cvut │ │ │ └── kbss │ │ │ └── jopa │ │ │ └── eswc2016 │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ ├── ConfigurationService.java │ │ │ ├── DispatcherServletInitializer.java │ │ │ ├── PersistenceConfig.java │ │ │ ├── RestConfig.java │ │ │ ├── ServiceConfig.java │ │ │ └── WebAppConfig.java │ │ │ ├── model │ │ │ ├── Vocabulary.java │ │ │ ├── dto │ │ │ │ ├── RawJson.java │ │ │ │ └── ReportDto.java │ │ │ └── model │ │ │ │ ├── Answer.java │ │ │ │ ├── Event.java │ │ │ │ ├── Person.java │ │ │ │ ├── Question.java │ │ │ │ ├── Record.java │ │ │ │ ├── Report.java │ │ │ │ └── Thing.java │ │ │ ├── persistence │ │ │ ├── BasePersistenceFactory.java │ │ │ ├── PersistenceException.java │ │ │ ├── dao │ │ │ │ ├── BaseDao.java │ │ │ │ ├── DataDao.java │ │ │ │ ├── EventDao.java │ │ │ │ ├── PersonDao.java │ │ │ │ ├── QuestionDao.java │ │ │ │ └── ReportDao.java │ │ │ ├── owlapi │ │ │ │ ├── OwlapiDataProvider.java │ │ │ │ └── OwlapiPersistenceFactory.java │ │ │ └── rdf4j │ │ │ │ ├── Rdf4jDataProvider.java │ │ │ │ └── Rdf4jPersistenceFactory.java │ │ │ ├── rest │ │ │ ├── BaseController.java │ │ │ ├── ConfigurationController.java │ │ │ ├── DataController.java │ │ │ ├── EventController.java │ │ │ ├── OptionsController.java │ │ │ ├── QuestionController.java │ │ │ ├── ReportController.java │ │ │ ├── RestUtils.java │ │ │ ├── exception │ │ │ │ ├── NotFoundException.java │ │ │ │ ├── ValidationException.java │ │ │ │ └── WebServiceIntegrationException.java │ │ │ └── handler │ │ │ │ ├── ErrorInfo.java │ │ │ │ └── RestExceptionHandler.java │ │ │ ├── service │ │ │ ├── BaseRepositoryService.java │ │ │ ├── DataFormat.java │ │ │ ├── DataRepositoryService.java │ │ │ ├── EventService.java │ │ │ ├── FileDataLoader.java │ │ │ ├── PropertiesValidationService.java │ │ │ ├── PropertyLoader.java │ │ │ ├── QuestionService.java │ │ │ └── ReportService.java │ │ │ └── util │ │ │ ├── ConfigParam.java │ │ │ ├── Constants.java │ │ │ ├── KeyGenerator.java │ │ │ └── RepositoryType.java │ │ ├── resources │ │ ├── config.properties │ │ ├── logback.xml │ │ ├── owlapi.properties │ │ └── rdf4j.properties │ │ └── webapp │ │ ├── .babelrc │ │ ├── .env │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ │ ├── resources │ │ └── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── src │ │ ├── App.tsx │ │ ├── action │ │ │ ├── ActionType.ts │ │ │ ├── AsyncActionStatus.ts │ │ │ ├── AsyncActions.ts │ │ │ └── SyncActions.ts │ │ ├── component │ │ │ ├── Data.tsx │ │ │ ├── DeleteDialog.tsx │ │ │ ├── Input.tsx │ │ │ ├── MainView.tsx │ │ │ ├── Mask.scss │ │ │ ├── Mask.tsx │ │ │ ├── PromiseTrackingMask.tsx │ │ │ ├── Settings.tsx │ │ │ ├── audit │ │ │ │ ├── AuditController.tsx │ │ │ │ ├── AuditDetail.tsx │ │ │ │ ├── AuditReports.tsx │ │ │ │ ├── AuditRow.tsx │ │ │ │ ├── Audits.tsx │ │ │ │ ├── AuditsRoute.tsx │ │ │ │ └── BasicAuditInfo.tsx │ │ │ ├── message │ │ │ │ ├── Message.tsx │ │ │ │ ├── Messages.scss │ │ │ │ └── Messages.tsx │ │ │ ├── property │ │ │ │ ├── Properties.tsx │ │ │ │ ├── PropertyEditRow.tsx │ │ │ │ └── PropertyRow.tsx │ │ │ ├── record │ │ │ │ ├── Answer.tsx │ │ │ │ ├── CreateQuestion.tsx │ │ │ │ ├── QuestionSelector.tsx │ │ │ │ ├── RecordClassification.tsx │ │ │ │ ├── RecordDetail.tsx │ │ │ │ ├── RecordRow.tsx │ │ │ │ ├── ReportRecords.scss │ │ │ │ └── ReportRecords.tsx │ │ │ └── report │ │ │ │ ├── CreateReportDialog.tsx │ │ │ │ ├── ReportDetail.tsx │ │ │ │ ├── ReportRow.tsx │ │ │ │ ├── Reports.tsx │ │ │ │ ├── ReportsController.tsx │ │ │ │ └── ReportsRoute.tsx │ │ ├── index.scss │ │ ├── index.tsx │ │ ├── model │ │ │ ├── AppModel.ts │ │ │ ├── Event.ts │ │ │ ├── Person.ts │ │ │ ├── Record.ts │ │ │ ├── Report.ts │ │ │ └── Types.ts │ │ ├── react-app-env.d.ts │ │ ├── reducer │ │ │ └── AppReducers.ts │ │ ├── reportWebVitals.js │ │ ├── store │ │ │ └── AppStore.ts │ │ └── util │ │ │ ├── Constants.ts │ │ │ ├── InstanceFactory.ts │ │ │ ├── Routing.ts │ │ │ └── Util.ts │ │ └── tsconfig.json ├── ufo-a.rdf ├── ufo-b.rdf ├── ufo-c.rdf ├── ufo-powertypes.rdf └── ufo.rdf ├── example01-jopa-rdf4j-owl2java ├── README.md ├── ic-example01.owl ├── mapping ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example01 │ │ ├── Example.java │ │ ├── GeneratedRunner.java │ │ ├── ManualRunner.java │ │ ├── PersistenceFactory.java │ │ ├── Runner.java │ │ └── model │ │ ├── ConferencePaper.java │ │ ├── Course.java │ │ └── UndergraduateStudent.java │ └── resources │ └── logback.xml ├── example02-jopa-owlapi ├── README.md ├── ontology.owl ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example02 │ │ ├── Example.java │ │ ├── PersistenceFactory.java │ │ └── model │ │ ├── Jedi.java │ │ └── Vocabulary.java │ └── resources │ └── logback.xml ├── example03-jopa-rdf4j-contexts ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example03 │ │ ├── Environment.java │ │ ├── Example.java │ │ ├── PersistenceFactory.java │ │ └── model │ │ ├── Accident.java │ │ ├── Aircraft.java │ │ ├── Flight.java │ │ ├── Operator.java │ │ └── Vocabulary.java │ └── resources │ └── logback.xml ├── example04-jopa-spring ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cz │ │ │ └── cvut │ │ │ └── kbss │ │ │ └── jopa │ │ │ └── example04 │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ ├── DispatcherServletInitializer.java │ │ │ ├── PersistenceConfig.java │ │ │ ├── RestConfig.java │ │ │ ├── ServiceConfig.java │ │ │ └── WebAppConfig.java │ │ │ ├── model │ │ │ ├── Student.java │ │ │ └── Vocabulary.java │ │ │ ├── persistence │ │ │ ├── PersistenceFactory.java │ │ │ ├── dao │ │ │ │ ├── DataDao.java │ │ │ │ └── StudentDao.java │ │ │ └── rdf4j │ │ │ │ └── RDf4jPersistenceProvider.java │ │ │ ├── rest │ │ │ ├── DataController.java │ │ │ ├── NotFoundException.java │ │ │ ├── RestUtils.java │ │ │ └── StudentController.java │ │ │ └── service │ │ │ ├── DataFormat.java │ │ │ ├── DataRepositoryService.java │ │ │ └── StudentRepositoryService.java │ ├── resources │ │ ├── config.properties │ │ └── logback.xml │ └── webapp │ │ ├── .babelrc │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ │ └── src │ │ ├── App.js │ │ ├── App.test.js │ │ ├── action │ │ ├── ActionType.js │ │ ├── Actions.js │ │ └── AsyncStatus.js │ │ ├── component │ │ ├── CreateStudent.jsx │ │ ├── Data.jsx │ │ ├── MainView.jsx │ │ ├── StudentRow.jsx │ │ └── Students.jsx │ │ ├── index.css │ │ ├── index.js │ │ ├── reducer │ │ └── reducers.js │ │ ├── reportWebVitals.js │ │ ├── setupTests.js │ │ └── store │ │ └── ReduxStore.js │ └── test │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example04 │ │ ├── environment │ │ ├── TestPersistenceConfig.java │ │ ├── TestPersistenceFactory.java │ │ ├── TestRdf4jPersistenceProvider.java │ │ ├── Transaction.java │ │ └── TransactionalTestRunner.java │ │ ├── persistence │ │ └── dao │ │ │ └── StudentDaoTest.java │ │ └── service │ │ └── StudentRepositoryServiceTest.java │ └── resources │ └── config.properties ├── example05-jopa-owl2query ├── README.md ├── ontology.owl ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example05 │ │ ├── DataGenerator.java │ │ ├── Example.java │ │ ├── PersistenceFactory.java │ │ ├── dao │ │ └── SuperheroDao.java │ │ └── model │ │ ├── Superhero.java │ │ └── Vocabulary.java │ └── resources │ └── logback.xml ├── example06-jopa-mapped-superclass ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example06 │ │ ├── DataGenerator.java │ │ ├── DataOutput.java │ │ ├── Example.java │ │ ├── PersistenceFactory.java │ │ ├── ReportDao.java │ │ └── model │ │ ├── AbstractEntity.java │ │ ├── AuditReport.java │ │ ├── OccurrenceReport.java │ │ ├── Person.java │ │ ├── Report.java │ │ └── Vocabulary.java │ └── resources │ └── logback.xml ├── example07-jopa-plural-dp-inheritance ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example07 │ │ ├── Example07.java │ │ ├── config │ │ └── RestConfig.java │ │ ├── model │ │ ├── AbstractEntity.java │ │ ├── AuditReport.java │ │ ├── OccurrenceReport.java │ │ ├── Report.java │ │ ├── SafetyIssueReport.java │ │ └── Vocabulary.java │ │ ├── persistence │ │ ├── PersistenceFactory.java │ │ └── dao │ │ │ └── ReportDao.java │ │ ├── rest │ │ ├── ReportController.java │ │ └── exception │ │ │ ├── ErrorInfo.java │ │ │ ├── NotFoundException.java │ │ │ └── RestExceptionHandler.java │ │ └── service │ │ ├── DataInitializer.java │ │ └── ReportService.java │ └── resources │ ├── application.properties │ ├── config.properties │ └── logback-spring.xml ├── example08-jena-polymorphism ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example08 │ │ ├── Example08.java │ │ ├── config │ │ ├── PersistenceConfig.java │ │ └── RestConfig.java │ │ ├── model │ │ ├── AbstractEntity.java │ │ ├── AbstractReport.java │ │ ├── Audit.java │ │ ├── AuditFinding.java │ │ ├── AuditReport.java │ │ ├── Event.java │ │ ├── Occurrence.java │ │ ├── OccurrenceReport.java │ │ └── Vocabulary.java │ │ ├── persistence │ │ ├── PersistenceFactory.java │ │ ├── SchemaExporter.java │ │ └── dao │ │ │ └── ReportDao.java │ │ ├── rest │ │ ├── NotFoundException.java │ │ └── ReportController.java │ │ └── service │ │ ├── DataGenerator.java │ │ └── ReportService.java │ └── resources │ ├── application.properties │ └── logback-spring.xml ├── example09-soql ├── README.md ├── data.ttl ├── pom.xml └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example09 │ │ ├── Example09.java │ │ ├── config │ │ ├── PersistenceConfig.java │ │ └── RestConfig.java │ │ ├── model │ │ ├── Developer.java │ │ ├── Game.java │ │ └── package-info.java │ │ ├── persistence │ │ ├── DeveloperRepository.java │ │ ├── GameRepository.java │ │ └── PersistenceFactory.java │ │ └── rest │ │ ├── DeveloperController.java │ │ ├── GameController.java │ │ └── NotFoundException.java │ └── resources │ ├── application.properties │ └── logback-spring.xml ├── example10-strings-languages ├── README.md ├── build.gradle ├── pom.xml ├── settings.gradle └── src │ └── main │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── example10 │ │ ├── Example.java │ │ ├── PersistenceFactory.java │ │ └── model │ │ ├── Person.java │ │ ├── SimpleLiteralPerson.java │ │ ├── Term.java │ │ └── package-info.java │ └── resources │ └── logback.xml ├── header.txt ├── jsonld ├── README.md ├── mapping ├── model.ttl ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cz │ │ │ └── cvut │ │ │ └── kbss │ │ │ └── jopa │ │ │ └── jsonld │ │ │ ├── JsonLdDemo.java │ │ │ ├── config │ │ │ ├── PersistenceConfig.java │ │ │ └── WebAppConfig.java │ │ │ ├── dto │ │ │ ├── OrganizationDto.java │ │ │ ├── StudyDto.java │ │ │ ├── UserDto.java │ │ │ └── mapper │ │ │ │ └── DtoMapper.java │ │ │ ├── model │ │ │ ├── AbstractEntity.java │ │ │ ├── Organization.java │ │ │ ├── Study.java │ │ │ ├── User.java │ │ │ └── util │ │ │ │ ├── EntityToOwlClassMapper.java │ │ │ │ └── HasDerivableUri.java │ │ │ ├── persistence │ │ │ ├── PersistenceException.java │ │ │ ├── PersistenceFactory.java │ │ │ └── dao │ │ │ │ ├── BaseDao.java │ │ │ │ ├── DerivableUriDao.java │ │ │ │ ├── OrganizationDao.java │ │ │ │ ├── StudyDao.java │ │ │ │ └── UserDao.java │ │ │ ├── rest │ │ │ ├── OrganizationController.java │ │ │ ├── RestUtils.java │ │ │ ├── StudyController.java │ │ │ ├── UserController.java │ │ │ └── exception │ │ │ │ ├── ErrorInfo.java │ │ │ │ ├── NotFoundException.java │ │ │ │ └── RestExceptionHandler.java │ │ │ └── service │ │ │ ├── BaseService.java │ │ │ ├── OrganizationService.java │ │ │ ├── StudyService.java │ │ │ ├── UserService.java │ │ │ ├── data │ │ │ └── DataGenerator.java │ │ │ └── repository │ │ │ ├── BaseRepositoryService.java │ │ │ ├── OrganizationRepositoryService.java │ │ │ ├── StudyRepositoryService.java │ │ │ └── UserRepositoryService.java │ └── resources │ │ ├── application.properties │ │ ├── config.properties │ │ └── logback-spring.xml │ └── test │ ├── java │ └── cz │ │ └── cvut │ │ └── kbss │ │ └── jopa │ │ └── jsonld │ │ ├── environment │ │ ├── Generator.java │ │ ├── TestPersistenceConfig.java │ │ ├── TestPersistenceFactory.java │ │ ├── TestServiceConfig.java │ │ └── TestUtils.java │ │ ├── persistence │ │ └── dao │ │ │ ├── BaseDaoTestRunner.java │ │ │ ├── OrganizationDaoTest.java │ │ │ ├── StudyDaoTest.java │ │ │ └── UserDaoTest.java │ │ └── service │ │ ├── BaseServiceTestRunner.java │ │ └── repository │ │ ├── OrganizationRepositoryServiceTest.java │ │ ├── StudyRepositoryServiceTest.java │ │ └── UserRepositoryServiceTest.java │ └── resources │ ├── config.properties │ └── logback-test.xml ├── license └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.iml 3 | **/.idea 4 | **/.gradle 5 | **/results 6 | **/testResults 7 | **/example02-jopa-owlapi/repository.owl 8 | **/example03-jopa-rdf4j-contexts/repositories 9 | **/example05-jopa-owl2query/repository.owl 10 | **/node_modules 11 | **/generated-sources 12 | **/generated/model 13 | **/build 14 | **/.vscode 15 | **/withoutPersistenceUnitLanguage.ttl 16 | **/withPersistenceUnitLanguage.ttl 17 | -------------------------------------------------------------------------------- /eswc2016/eswc2016-owlapi.owl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | ]> 10 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /eswc2016/mapping: -------------------------------------------------------------------------------- 1 | http://onto.felk.cvut.cz/ontologies/2016/jopa-eswc2016.owl > ./ic-eswc2016.owl 2 | http://onto.fel.cvut.cz/ontologies/aviation/documentation > ./documentation.rdf 3 | http://onto.fel.cvut.cz/ontologies/ufo > ./ufo.rdf 4 | http://onto.fel.cvut.cz/ontologies/ufo/ufo-a > ./ufo-a.rdf 5 | http://onto.fel.cvut.cz/ontologies/ufo/ufo-b > ./ufo-b.rdf 6 | http://onto.fel.cvut.cz/ontologies/ufo/powertypes > ./ufo-powertypes.rdf 7 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.config; 19 | 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.context.annotation.Import; 23 | 24 | @Configuration 25 | @Import({WebAppConfig.class, PersistenceConfig.class, ServiceConfig.class}) 26 | public class AppConfig { 27 | 28 | @Bean 29 | public ConfigurationService configurationService() { 30 | return new ConfigurationService(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/config/ConfigurationService.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.eswc2016.config; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.util.ConfigParam; 21 | import cz.cvut.kbss.jopa.eswc2016.util.RepositoryType; 22 | 23 | import javax.annotation.PostConstruct; 24 | import java.util.Map; 25 | import java.util.concurrent.ConcurrentHashMap; 26 | 27 | public class ConfigurationService { 28 | 29 | private final Map configuration = new ConcurrentHashMap<>(); 30 | 31 | public void set(ConfigParam param, String value) { 32 | configuration.put(param, value); 33 | } 34 | 35 | public String get(ConfigParam param) { 36 | return configuration.get(param); 37 | } 38 | 39 | @PostConstruct 40 | private void init() { 41 | configuration.put(ConfigParam.REPOSITORY_TYPE, RepositoryType.RDF4J.toString()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.config; 19 | 20 | import org.springframework.context.annotation.ComponentScan; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | @Configuration 24 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.eswc2016.persistence") 25 | public class PersistenceConfig { 26 | } 27 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.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.eswc2016.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 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.config; 19 | 20 | import org.springframework.context.annotation.ComponentScan; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | @Configuration 24 | @ComponentScan(basePackages = "cz.cvut.kbss.jopa.eswc2016.service") 25 | public class ServiceConfig { 26 | } 27 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.persistence; 19 | 20 | public class PersistenceException extends RuntimeException { 21 | 22 | public PersistenceException() { 23 | } 24 | 25 | public PersistenceException(String message) { 26 | super(message); 27 | } 28 | 29 | public PersistenceException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public PersistenceException(Throwable cause) { 34 | super(cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/persistence/dao/EventDao.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.eswc2016.persistence.dao; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.model.model.Event; 21 | import cz.cvut.kbss.jopa.eswc2016.util.KeyGenerator; 22 | import cz.cvut.kbss.jopa.model.EntityManager; 23 | import org.springframework.stereotype.Repository; 24 | 25 | @Repository 26 | public class EventDao extends BaseDao { 27 | 28 | public EventDao() { 29 | super(Event.class); 30 | } 31 | 32 | @Override 33 | protected void persist(Event entity, EntityManager em) { 34 | entity.setIdentifier(KeyGenerator.generateKey()); 35 | super.persist(entity, em); 36 | } 37 | 38 | @Override 39 | protected Event findByKey(Long key, EntityManager em) { 40 | final Event e = super.findByKey(key, em); 41 | if (e != null) { 42 | // Trigger the lazy field 43 | e.getIsDocumentedBy(); 44 | } 45 | return e; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/persistence/dao/QuestionDao.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.eswc2016.persistence.dao; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.model.model.Question; 21 | import cz.cvut.kbss.jopa.eswc2016.util.KeyGenerator; 22 | import cz.cvut.kbss.jopa.model.EntityManager; 23 | import org.springframework.stereotype.Repository; 24 | 25 | @Repository 26 | public class QuestionDao extends BaseDao { 27 | 28 | public QuestionDao() { 29 | super(Question.class); 30 | } 31 | 32 | @Override 33 | protected void persist(Question entity, EntityManager em) { 34 | entity.setIdentifier(KeyGenerator.generateKey()); 35 | super.persist(entity, em); 36 | } 37 | 38 | @Override 39 | protected void remove(Question entity, EntityManager em) { 40 | throw new UnsupportedOperationException("Cannot remove an existing question."); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/rest/BaseController.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.eswc2016.rest; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | public abstract class BaseController { 24 | 25 | protected static final Logger LOG = LoggerFactory.getLogger(BaseController.class); 26 | } 27 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.rest; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.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 | @Autowired 32 | private DataRepositoryService dataService; 33 | 34 | @RequestMapping(method = RequestMethod.GET) 35 | public String getData(@RequestParam(value = "format", required = false, defaultValue = "rdfxml") String format) { 36 | return dataService.getRepositoryData(format); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/rest/OptionsController.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.eswc2016.rest; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.model.dto.RawJson; 21 | import cz.cvut.kbss.jopa.eswc2016.service.PropertyLoader; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.http.MediaType; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.RequestMethod; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | @RestController 29 | @RequestMapping("/options") 30 | public class OptionsController extends BaseController { 31 | 32 | @Autowired 33 | private PropertyLoader propertyLoader; 34 | 35 | /** 36 | * Loads properties present in the documentation ontology. 37 | * 38 | * @return List of properties in JSON-LD 39 | */ 40 | @RequestMapping(method = RequestMethod.GET, value = "/properties", produces = MediaType.APPLICATION_JSON_VALUE) 41 | public RawJson getProperties() { 42 | return new RawJson(propertyLoader.loadProperties()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.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 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/rest/exception/ValidationException.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.eswc2016.rest.exception; 19 | 20 | public class ValidationException extends RuntimeException { 21 | 22 | public ValidationException() { 23 | } 24 | 25 | public ValidationException(String message) { 26 | super(message); 27 | } 28 | 29 | public ValidationException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/rest/exception/WebServiceIntegrationException.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.eswc2016.rest.exception; 19 | 20 | public class WebServiceIntegrationException extends RuntimeException { 21 | 22 | public WebServiceIntegrationException() { 23 | } 24 | 25 | public WebServiceIntegrationException(String message) { 26 | super(message); 27 | } 28 | 29 | public WebServiceIntegrationException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/rest/handler/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.eswc2016.rest.handler; 19 | 20 | /** 21 | * Class which contains information about an error and can be send to client as JSON to let him know what is wrong. 22 | */ 23 | public class ErrorInfo { 24 | 25 | private String message; 26 | 27 | private String requestUri; 28 | 29 | public ErrorInfo(String message, String requestUri) { 30 | this.message = message; 31 | this.requestUri = requestUri; 32 | } 33 | 34 | public String getMessage() { 35 | return message; 36 | } 37 | 38 | public void setMessage(String message) { 39 | this.message = message; 40 | } 41 | 42 | public String getRequestUri() { 43 | return requestUri; 44 | } 45 | 46 | public void setRequestUri(String requestUri) { 47 | this.requestUri = requestUri; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ErrorInfo{" + requestUri + ", message = " + message + "}"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/service/BaseRepositoryService.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.eswc2016.service; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.persistence.dao.BaseDao; 21 | 22 | import java.util.List; 23 | 24 | public abstract class BaseRepositoryService { 25 | 26 | protected abstract BaseDao getPrimaryDao(); 27 | 28 | public List findAll() { 29 | return getPrimaryDao().findAll(); 30 | } 31 | 32 | public T find(String uri) { 33 | return getPrimaryDao().find(uri); 34 | } 35 | 36 | public void persist(T instance) { 37 | getPrimaryDao().persist(instance); 38 | } 39 | 40 | public void update(T instance) { 41 | getPrimaryDao().update(instance); 42 | } 43 | 44 | public void remove(T instance) { 45 | getPrimaryDao().remove(instance); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.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 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/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.eswc2016.service; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.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 | @Autowired 30 | private DataDao dataDao; 31 | 32 | public String getRepositoryData(String format) { 33 | Objects.requireNonNull(format); 34 | final DataFormat df = DataFormat.fromString(format); 35 | return dataDao.getRepositoryData(df); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/service/PropertiesValidationService.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.eswc2016.service; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.rest.exception.ValidationException; 21 | import org.springframework.stereotype.Service; 22 | 23 | import java.net.URI; 24 | import java.net.URISyntaxException; 25 | import java.util.Map; 26 | import java.util.Set; 27 | 28 | @Service 29 | public class PropertiesValidationService { 30 | 31 | public void validate(Map> properties) { 32 | if (properties == null || properties.isEmpty()) { 33 | return; 34 | } 35 | for (String property : properties.keySet()) { 36 | try { 37 | new URI(property); 38 | } catch (URISyntaxException e) { 39 | throw new ValidationException("Property " + property + " is not a valid URI."); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/service/QuestionService.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.eswc2016.service; 19 | 20 | import cz.cvut.kbss.jopa.eswc2016.model.model.Question; 21 | import cz.cvut.kbss.jopa.eswc2016.persistence.dao.BaseDao; 22 | import cz.cvut.kbss.jopa.eswc2016.persistence.dao.QuestionDao; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Service; 25 | 26 | import java.util.Objects; 27 | 28 | @Service 29 | public class QuestionService extends BaseRepositoryService { 30 | 31 | @Autowired 32 | private QuestionDao questionDao; 33 | 34 | @Override 35 | protected BaseDao getPrimaryDao() { 36 | return questionDao; 37 | } 38 | 39 | public Question findByKey(Long key) { 40 | Objects.requireNonNull(key); 41 | return questionDao.findByKey(key); 42 | } 43 | 44 | @Override 45 | public void remove(Question instance) { 46 | throw new UnsupportedOperationException("Cannot remove a question."); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/util/ConfigParam.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.eswc2016.util; 19 | 20 | import java.util.Objects; 21 | 22 | public enum ConfigParam { 23 | 24 | REPOSITORY_TYPE("repositoryType"); 25 | 26 | private final String name; 27 | 28 | ConfigParam(String name) { 29 | this.name = name; 30 | } 31 | 32 | public static ConfigParam fromString(String str) { 33 | Objects.requireNonNull(str); 34 | for (ConfigParam param : values()) { 35 | if (str.equalsIgnoreCase(param.name)) { 36 | return param; 37 | } 38 | } 39 | throw new IllegalArgumentException("Unsupported configuration parameter " + str); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/util/Constants.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.eswc2016.util; 19 | 20 | import java.net.URI; 21 | 22 | public abstract class Constants { 23 | 24 | private Constants() { 25 | throw new AssertionError(); 26 | } 27 | 28 | /** 29 | * URI of context in which persons are stored. 30 | */ 31 | public static final URI PERSONS_CONTEXT = URI.create("http://krizik.felk.cvut.cz/ontologies/eswc2016/persons"); 32 | 33 | /** 34 | * Default user's username. 35 | */ 36 | public static final String USERNAME = "master-chief"; 37 | 38 | /** 39 | * Default ontology language. 40 | */ 41 | public static final String LANGUAGE = "en"; 42 | 43 | public static final String APPLICATION_JSON_LD_TYPE = "application/ld+json"; 44 | 45 | public static final String UTF_8_ENCODING = "UTF-8"; 46 | } 47 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/util/KeyGenerator.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.eswc2016.util; 19 | 20 | public class KeyGenerator { 21 | 22 | private KeyGenerator() { 23 | throw new AssertionError(); 24 | } 25 | 26 | public static Long generateKey() { 27 | return System.currentTimeMillis(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /eswc2016/src/main/java/cz/cvut/kbss/jopa/eswc2016/util/RepositoryType.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.eswc2016.util; 19 | 20 | import java.util.Objects; 21 | 22 | public enum RepositoryType { 23 | 24 | RDF4J("rdf4j"), OWLAPI("owlapi"); 25 | 26 | private final String name; 27 | 28 | RepositoryType(String name) { 29 | this.name = name; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return name; 35 | } 36 | 37 | public static RepositoryType fromString(String str) { 38 | Objects.requireNonNull(str); 39 | for (RepositoryType type : values()) { 40 | if (str.equalsIgnoreCase(type.name)) { 41 | return type; 42 | } 43 | } 44 | throw new IllegalArgumentException("Unsupported repository type " + str); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /eswc2016/src/main/resources/config.properties: -------------------------------------------------------------------------------- 1 | # This would contain reference to a SPARQL endpoint capable of providing properties for typeahead in Additional (unmapped) properties 2 | propertyRepositoryUrl= -------------------------------------------------------------------------------- /eswc2016/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | %date{dd-MM-yyyy HH:mm:ss.SSS} [eswc2016-jopa-demo] [%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 | -------------------------------------------------------------------------------- /eswc2016/src/main/resources/owlapi.properties: -------------------------------------------------------------------------------- 1 | owlapi.repositoryUrl=file:/tmp/jopa/eswc2016-owlapi.owl 2 | owlapi.mappingFile=file:/tmp/jopa/mapping 3 | owlapi.ontologyUri=http://onto.felk.cvut.cz/ontologies/2016/jopa-eswc2016.owl 4 | owlapi.driver=cz.cvut.kbss.ontodriver.owlapi.OwlapiDataSource -------------------------------------------------------------------------------- /eswc2016/src/main/resources/rdf4j.properties: -------------------------------------------------------------------------------- 1 | rdf4j.repositoryUrl=file:/tmp/jopa/repositories/eswc2016-rdf4j 2 | rdf4j.driver=cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"] 3 | } -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_SERVER_URL=http://localhost:8080/eswc2016 2 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jopa-eswc2016", 3 | "version": "0.16.3", 4 | "private": true, 5 | "homepage": ".", 6 | "dependencies": { 7 | "@fortawesome/fontawesome-free": "^6.1.1", 8 | "axios": "^1.8.2", 9 | "bootstrap": "^5.1.3", 10 | "moment": "^2.29.4", 11 | "prop-types": "^15.8.1", 12 | "react": "^17.0.2", 13 | "react-bootstrap": "^2.4.0", 14 | "react-datetime": "^3.1.1", 15 | "react-dom": "^17.0.2", 16 | "react-icons": "^4.4.0", 17 | "react-promise-tracker": "^2.1.0", 18 | "react-redux": "^8.0.2", 19 | "react-router": "^5.3.3", 20 | "react-router-dom": "^5.3.3", 21 | "react-select": "^5.3.2", 22 | "react-spinners": "^0.13.2", 23 | "redux-thunk": "^2.4.1", 24 | "web-vitals": "^2.1.4" 25 | }, 26 | "devDependencies": { 27 | "@testing-library/jest-dom": "^5.16.3", 28 | "@testing-library/react": "^11.1.0", 29 | "@testing-library/user-event": "^12.1.10", 30 | "@types/node": "^17.0.23", 31 | "@types/react": "^17.0.43", 32 | "@types/react-dom": "^17.0.14", 33 | "@types/react-redux": "^7.1.23", 34 | "@types/react-router-dom": "^5.3.3", 35 | "@types/react-select": "^4.0.18", 36 | "react-scripts": "5.0.0", 37 | "sass": "^1.49.9", 38 | "typescript": "^4.6.3" 39 | }, 40 | "scripts": { 41 | "start": "react-scripts start", 42 | "build": "react-scripts build", 43 | "test": "react-scripts test", 44 | "eject": "react-scripts eject", 45 | "prebuild": "npm install" 46 | }, 47 | "eslintConfig": { 48 | "extends": [ 49 | "react-app", 50 | "react-app/jest" 51 | ] 52 | }, 53 | "browserslist": { 54 | "production": [ 55 | ">0.2%", 56 | "not dead", 57 | "not op_mini all" 58 | ], 59 | "development": [ 60 | "last 1 chrome version", 61 | "last 1 firefox version", 62 | "last 1 safari version" 63 | ] 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/public/favicon.ico -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/public/logo192.png -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/public/logo512.png -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "ESWC 2016", 3 | "name": "JOPA ESWC 2016 Demo", 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 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbss-cvut/jopa-examples/00d31b482673f36b499c1191e036114446a719c5/eswc2016/src/main/webapp/resources/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/App.tsx: -------------------------------------------------------------------------------- 1 | import {Router} from 'react-router'; 2 | 3 | import MainView from './component/MainView'; 4 | import Routing from './util/Routing'; 5 | import {Provider} from "react-redux"; 6 | import AppStore from "./store/AppStore"; 7 | 8 | const App = () => { 9 | return 10 | 11 | 12 | 13 | 14 | }; 15 | 16 | export default App; 17 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/action/AsyncActionStatus.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 | enum AsyncActionStatus { 20 | REQUEST, 21 | SUCCESS, 22 | FAILURE, 23 | } 24 | 25 | export default AsyncActionStatus; 26 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/Data.tsx: -------------------------------------------------------------------------------- 1 | import {useEffect, useState} from "react"; 2 | import {Card, Form} from "react-bootstrap"; 3 | import {useDispatch} from "react-redux"; 4 | import {loadData} from "../action/AsyncActions"; 5 | import {ThunkDispatch} from "../util/Util"; 6 | 7 | const Data = () => { 8 | const [data, setData] = useState(""); 9 | const [format, setFormat] = useState("rdfxml"); 10 | const dispatch: ThunkDispatch = useDispatch(); 11 | useEffect(() => { 12 | dispatch(loadData(format)).then((content: string) => setData(content)); 13 | }, [dispatch, format, setData]); 14 | 15 | 16 | return 17 | Repository Content 18 | 19 |
20 | 21 | setFormat(e.currentTarget.value)} value={format}> 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 |
33 |
34 |
; 35 | }; 36 | 37 | export default Data; 38 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/DeleteDialog.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Button, Modal} from "react-bootstrap"; 3 | 4 | interface DeleteDialogProps { 5 | show: boolean; 6 | onSubmit: () => void; 7 | onClose: () => void; 8 | } 9 | 10 | const DeleteDialog: React.FC = props => { 11 | const {show, onSubmit, onClose} = props; 12 | 13 | return 14 | 15 | 16 | Delete item? 17 | 18 | 19 | 20 | Are you sure you want to remove this item? 21 | 22 | 23 | 24 | 25 | 26 | ; 27 | }; 28 | 29 | export default DeleteDialog; 30 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/Input.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Form, FormControlProps} from "react-bootstrap"; 3 | 4 | interface InputProps extends FormControlProps{ 5 | label?: string; 6 | } 7 | 8 | const Input: React.FC = props => { 9 | const {label, ...inputProps} = props; 10 | return 11 | {label && {label}} 12 | 13 | 14 | }; 15 | 16 | export default Input; 17 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/Mask.scss: -------------------------------------------------------------------------------- 1 | .mask { 2 | position: fixed !important; 3 | padding: 0; 4 | margin: 0; 5 | top: 0; 6 | left: 0; 7 | width: 100%; 8 | height: 100%; 9 | background: rgba(245, 245, 245, 0.6); 10 | z-index: 1051; 11 | } 12 | 13 | /* This mask covers a container instead of the whole viewport */ 14 | .mask-container { 15 | position: absolute; 16 | padding: 0; 17 | margin: 0; 18 | top: 0; 19 | left: 0; 20 | width: 100%; 21 | height: 100%; 22 | background: rgba(245, 245, 245, 0.6); 23 | z-index: 101; 24 | } 25 | 26 | .spinner-container { 27 | position: absolute; 28 | top: 0; 29 | bottom: 0; 30 | left: 0; 31 | right: 0; 32 | margin: auto; 33 | height: 50px; 34 | text-align: center; 35 | vertical-align: middle; 36 | 37 | .spinner-message { 38 | color: #007bff; 39 | font-size: 11px; 40 | } 41 | } 42 | 43 | .without-text { 44 | @extend .spinner-container; 45 | height: 32px; 46 | } 47 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/Mask.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import classNames from "classnames"; 3 | import { ClipLoader } from "react-spinners"; 4 | import "./Mask.scss"; 5 | 6 | export interface MaskProps { 7 | text?: string; 8 | withoutText?: boolean; 9 | classes?: string; 10 | } 11 | 12 | const Mask: React.FC = (props) => { 13 | const containerClasses = classNames("spinner-container", { 14 | "without-text": props.withoutText, 15 | }); 16 | const text = props.text ? props.text : "Please wait..."; 17 | return ( 18 |
19 |
20 |
21 | 22 |
23 | {!props.withoutText &&
{text}
} 24 |
25 |
26 | ); 27 | }; 28 | 29 | Mask.defaultProps = { 30 | classes: "mask", 31 | withoutText: false, 32 | }; 33 | 34 | export default Mask; 35 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/PromiseTrackingMask.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {usePromiseTracker} from "react-promise-tracker"; 3 | import Mask from "./Mask"; 4 | 5 | interface PromiseTrackingMaskProps { 6 | area: string; 7 | text: string; 8 | coverViewport?: boolean; 9 | } 10 | 11 | const PromiseTrackingMask: React.FC = props => { 12 | const {promiseInProgress} = usePromiseTracker({area: props.area}); 13 | 14 | return promiseInProgress ? 15 | : null; 16 | }; 17 | 18 | export default PromiseTrackingMask; 19 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/audit/AuditRow.tsx: -------------------------------------------------------------------------------- 1 | import Event from "../../model/Event"; 2 | import React from "react"; 3 | import {Button} from "react-bootstrap"; 4 | import Util from "../../util/Util"; 5 | import {Link} from "react-router-dom"; 6 | import {Routing} from "../../util/Routing"; 7 | 8 | interface AuditRowProps { 9 | audit: Event; 10 | onRemove: (audit: Event) => void; 11 | } 12 | 13 | const AuditRow: React.FC = props => { 14 | const {audit, onRemove} = props; 15 | 16 | return 17 | {audit.title} 18 | {Util.formatDate(new Date(audit.date))} 19 | 20 | ([["auditKey", audit.identifier!.toString()]])})}> 22 | 23 | 24 | 25 | 26 | ; 27 | }; 28 | 29 | export default AuditRow; 30 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/audit/AuditsRoute.tsx: -------------------------------------------------------------------------------- 1 | import {Route, Switch} from "react-router"; 2 | import AuditController from "./AuditController"; 3 | import Audits from "./Audits"; 4 | 5 | const AuditsRoute = () => { 6 | return 7 | 8 | 9 | 10 | ; 11 | }; 12 | 13 | export default AuditsRoute; 14 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/audit/BasicAuditInfo.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Col, Form, Row} from "react-bootstrap"; 3 | import Datetime from "react-datetime"; 4 | import "react-datetime/css/react-datetime.css"; 5 | import Event from "../../model/Event"; 6 | import {Moment} from "moment"; 7 | 8 | interface BasicAuditInfoProps { 9 | audit: Event; 10 | onChange: (change: Partial) => void; 11 | disabled?: boolean; 12 | } 13 | 14 | const BasicAuditInfo: React.FC = props => { 15 | const {audit, disabled, onChange} = props; 16 | const onDateChange = (v: string | Moment) => { 17 | if ((v as any).date) { 18 | onChange({date: (v as Moment).valueOf()}); 19 | } 20 | }; 21 | 22 | return <> 23 | 24 | 25 | 26 | Title 27 | onChange({title: e.currentTarget.value})}/> 29 | 30 | 31 | 32 | 33 | 34 | 35 | Audit date 36 | 38 | 39 | 40 | 41 | ; 42 | }; 43 | 44 | export default BasicAuditInfo; 45 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/message/Message.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import {useCallback, useEffect} from "react"; 3 | import {Message as MessageModel} from "../../model/Types"; 4 | import {Alert} from "react-bootstrap"; 5 | import {useDispatch} from "react-redux"; 6 | import {dismissMessage} from "../../action/SyncActions"; 7 | import Constants from "../../util/Constants"; 8 | 9 | interface MessageProps { 10 | message: MessageModel; 11 | } 12 | 13 | export const Message: React.FC = (props: MessageProps) => { 14 | const {message} = props; 15 | const dispatch = useDispatch(); 16 | const dismiss = useCallback( 17 | () => dispatch(dismissMessage(message)), 18 | [message, dispatch] 19 | ); 20 | useEffect(() => { 21 | const timer = setTimeout(() => { 22 | dismiss(); 23 | }, Constants.MESSAGE_DURATION); 24 | return () => clearTimeout(timer); 25 | }, [dismiss, message]); 26 | 27 | return ( 28 | 29 | {message.message} 30 | 31 | ); 32 | }; 33 | 34 | export default Message; 35 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/message/Messages.scss: -------------------------------------------------------------------------------- 1 | .message-container { 2 | width: 25%; 3 | min-width: 220px; 4 | height: 25%; 5 | position: fixed; 6 | top: 60px; 7 | right: 7.5px / 2; 8 | margin: auto; 9 | z-index: 1030; 10 | @media (min-width: 1024px) { 11 | top: 50px; 12 | right: 7.5px; 13 | } 14 | } 15 | 16 | .messages-0 { 17 | height: 0; 18 | } 19 | 20 | .messages-1 { 21 | height: 4.125rem; 22 | } 23 | 24 | .messages-2 { 25 | height: 8.25rem; 26 | } 27 | 28 | .messages-3 { 29 | height: 12.375rem; 30 | } 31 | 32 | .messages-4 { 33 | height: 16.5rem; 34 | } 35 | 36 | .messages-5 { 37 | height: 20.625rem; 38 | } 39 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/message/Messages.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useSelector } from "react-redux"; 3 | import AppModel from "../../model/AppModel"; 4 | import Constants from "../../util/Constants"; 5 | import Message from "./Message"; 6 | import "./Messages.scss"; 7 | 8 | export const Messages: React.FC = () => { 9 | const messages = useSelector((state: AppModel) => state.messages); 10 | const count = 11 | messages.length < Constants.MESSAGE_DISPLAY_COUNT 12 | ? messages.length 13 | : Constants.MESSAGE_DISPLAY_COUNT; 14 | const toRender = messages.slice(0, count); 15 | return ( 16 |
17 | {toRender.map((m) => ( 18 | 19 | ))} 20 |
21 | ); 22 | }; 23 | 24 | export default Messages; 25 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/property/PropertyRow.tsx: -------------------------------------------------------------------------------- 1 | import {PropertyRecord} from "./Properties"; 2 | import {Button, ButtonToolbar} from "react-bootstrap"; 3 | import React from "react"; 4 | 5 | interface PropertyRowProps { 6 | record: PropertyRecord; 7 | onEdit: (record: PropertyRecord) => void; 8 | onRemove: (record: PropertyRecord) => void; 9 | } 10 | 11 | const PropertyRow: React.FC = props => { 12 | const {record, onEdit, onRemove} = props; 13 | 14 | return 15 | {record.property} 16 | {record.value} 17 | 18 | 19 | 20 | 21 | 22 | 23 | ; 24 | }; 25 | 26 | export default PropertyRow; 27 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/record/Answer.tsx: -------------------------------------------------------------------------------- 1 | import React, {ChangeEvent} from "react"; 2 | import {Answer as AnswerModel} from "../../model/Record"; 3 | import {Col, Form, Row} from "react-bootstrap"; 4 | 5 | interface AnswerProps { 6 | show: boolean; 7 | answer: AnswerModel; 8 | onChange: (a: AnswerModel) => void; 9 | } 10 | 11 | const Answer: React.FC = props => { 12 | const {answer, show, onChange} = props; 13 | const onAnswerChange = (e: ChangeEvent) => { 14 | const newAnswer = Object.assign({}, answer, {has_data_value: e.currentTarget.value}); 15 | onChange(newAnswer); 16 | }; 17 | 18 | if (!show) { 19 | return null; 20 | } 21 | 22 | return 23 | 24 | 25 | Answer 26 | 27 | 28 | 29 | ; 30 | }; 31 | 32 | export default Answer; 33 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/record/CreateQuestion.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Button, ButtonToolbar, Form, Modal} from "react-bootstrap"; 3 | import {Question} from "../../model/Record"; 4 | 5 | interface CreateQuestionProps { 6 | show: boolean; 7 | onClose: () => void; 8 | onCreate: (q: Question) => void; 9 | } 10 | 11 | const CreateQuestion: React.FC = props => { 12 | const {show, onClose, onCreate} = props; 13 | const [content, setContent] = React.useState(""); 14 | React.useEffect(() => { 15 | setContent(""); 16 | }, [show, setContent]); 17 | const onSaveClick = () => { 18 | onCreate({has_data_value: content}); 19 | }; 20 | 21 | return 22 | 23 | Create question 24 | 25 | 26 | 27 | Question 28 | setContent(e.currentTarget.value)}/> 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | ; 38 | }; 39 | 40 | export default CreateQuestion; 41 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/record/QuestionSelector.tsx: -------------------------------------------------------------------------------- 1 | import React, {useEffect} from "react"; 2 | import {Question} from "../../model/Record"; 3 | import Util, {ThunkDispatch} from "../../util/Util"; 4 | import {useDispatch, useSelector} from "react-redux"; 5 | import {loadQuestions} from "../../action/AsyncActions"; 6 | import AppModel from "../../model/AppModel"; 7 | import Select from "react-select"; 8 | import {SelectOption} from "../../model/Types"; 9 | 10 | interface QuestionSelectorProps { 11 | question: Question | null; 12 | onSelect: (q: Question | null) => void; 13 | } 14 | 15 | const QuestionSelector: React.FC = props => { 16 | const {question, onSelect} = props; 17 | const dispatch: ThunkDispatch = useDispatch(); 18 | useEffect(() => { 19 | dispatch(loadQuestions()); 20 | }, [dispatch]); 21 | const questions = useSelector((state: AppModel) => state.questions); 22 | const options = React.useMemo(() => Util.sanitizeArray(questions).map(q => ({ 23 | label: q.has_data_value, 24 | value: q.id 25 | })), [questions]); 26 | const onOptionSelect = (o: SelectOption | null) => { 27 | const q = o != null ? Util.sanitizeArray(questions).find(q => q.id === o.value) : null; 28 | onSelect(q !== undefined ? q : null); 29 | }; 30 | const value = question ? options.find(q => q.value === question.id) : undefined; 31 | 32 | return 33 | 34 | ; 35 | }; 36 | 37 | export default RecordClassification; 38 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/record/RecordRow.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Record from "../../model/Record"; 3 | import Util from "../../util/Util"; 4 | import {Button} from "react-bootstrap"; 5 | import classNames from "classnames"; 6 | 7 | interface RecordRowProps { 8 | record: Record; 9 | onEdit: (r: Record) => void; 10 | onRemove: (r: Record) => void; 11 | } 12 | 13 | const RecordRow: React.FC = props => { 14 | const {record, onEdit, onRemove} = props; 15 | 16 | const classification = record.types ? record.types[0] : ''; 17 | const className = 'record-classification ' + Util.getClassificationClassName(classification); 18 | return 19 | {record!.has_question!.has_data_value} 20 | {record!.has_answer!.has_data_value} 21 | 22 | 23 | 24 | 25 | ; 26 | }; 27 | 28 | export default RecordRow; 29 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/record/ReportRecords.scss: -------------------------------------------------------------------------------- 1 | .record-classification.valid, select.record-classification option.valid { 2 | background: rgba(92, 184, 82, 0.2); 3 | } 4 | 5 | .record-classification.part-valid, select.record-classification option.part-valid { 6 | background: rgba(240, 173, 78, 0.2); 7 | } 8 | 9 | .record-classification.invalid, select.record-classification option.invalid { 10 | background: rgba(217, 83, 79, 0.2); 11 | } 12 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/report/ReportRow.tsx: -------------------------------------------------------------------------------- 1 | import {Button} from "react-bootstrap"; 2 | import React from "react"; 3 | import Util from "../../util/Util"; 4 | import {ReportItem} from "../../model/Report"; 5 | import Routing from "../../util/Routing"; 6 | 7 | interface ReportRowProps { 8 | report: ReportItem; 9 | onRemove: (r: ReportItem) => void; 10 | } 11 | 12 | const ReportRow: React.FC = props => { 13 | const {report, onRemove} = props; 14 | 15 | return 16 | {report.auditTitle} 17 | {Util.formatDate(new Date(report.auditDate!))} 18 | {report.recordCount ? report.recordCount : '?'} 19 | 20 | 21 | 22 | 23 | ; 24 | }; 25 | 26 | export default ReportRow; 27 | -------------------------------------------------------------------------------- /eswc2016/src/main/webapp/src/component/report/Reports.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {ReportItem} from "../../model/Report"; 3 | import Util from "../../util/Util"; 4 | import {Button, Card, Col, Row, Table} from "react-bootstrap"; 5 | import ReportRow from "./ReportRow"; 6 | 7 | interface ReportsProps { 8 | reports: ReportItem[]; 9 | createReport: () => void; 10 | removeReport: (report: ReportItem) => void; 11 | } 12 | 13 | const Reports: React.FC = 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 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {reports.map(r => removeReport(r)}/>)} 31 | 32 |
Audit titleAudit dateRecordsActions
; 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 | 30 | 31 | 32 | 33 | 34 | 35 | {students.map(s => )} 36 | 37 |
NameEmailActions
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 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 | --------------------------------------------------------------------------------