use of org.eclipse.rdf4j.repository.sparql.config.SPARQLRepositoryConfig in project inception by inception-project.
the class KnowledgeBaseServiceImpl method getConnection.
@Override
public RepositoryConnection getConnection(KnowledgeBase kb) {
assertRegistration(kb);
Repository repo = repoManager.getRepository(kb.getRepositoryId());
if (repo instanceof SPARQLRepository) {
SPARQLRepositoryConfig sparqlRepoConfig = (SPARQLRepositoryConfig) getKnowledgeBaseConfig(kb);
URI uri = URI.create(sparqlRepoConfig.getQueryEndpointUrl());
String userInfo = uri.getUserInfo();
if (StringUtils.isNotBlank(userInfo)) {
userInfo = userInfo.trim();
String username;
String password;
if (userInfo.contains(":")) {
username = substringBefore(userInfo, ":");
password = substringAfter(userInfo, ":");
} else {
username = userInfo;
password = "";
}
SPARQLRepository sparqlRepo = (SPARQLRepository) repo;
sparqlRepo.setUsernameAndPassword(username, password);
}
}
return new RepositoryConnectionWrapper(repo, repo.getConnection()) {
{
skipCertificateChecks(kb.isSkipSslValidation());
}
@Override
public void close() throws RepositoryException {
try {
super.close();
} finally {
restoreSslVerification();
}
}
};
}
use of org.eclipse.rdf4j.repository.sparql.config.SPARQLRepositoryConfig in project inception by inception-project.
the class KnowledgeBaseExporterTest method setUp.
@BeforeEach
public void setUp() throws Exception {
initMocks(this);
sourceProject = new Project();
sourceProject.setId(1l);
sourceProject.setName("Test Project");
targetProject = new Project();
sourceProject.setId(2l);
targetProject.setName("Test Project");
when(kbService.getKnowledgeBases(sourceProject)).thenReturn(knowledgeBases());
when(kbService.getKnowledgeBaseConfig(any())).thenReturn(new SPARQLRepositoryConfig(TestURLEndpoint));
when(schemaService.listAnnotationFeature(sourceProject)).thenReturn(features(sourceProject));
sut = new KnowledgeBaseExporter(kbService, new KnowledgeBasePropertiesImpl(), schemaService);
}
use of org.eclipse.rdf4j.repository.sparql.config.SPARQLRepositoryConfig in project inception by inception-project.
the class KnowledgeBaseExporter method exportData.
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aFile) throws Exception {
Project project = aRequest.getProject();
List<ExportedKnowledgeBase> exportedKnowledgeBases = new ArrayList<>();
for (KnowledgeBase kb : kbService.getKnowledgeBases(project)) {
// check if the export has been cancelled
if (Thread.interrupted()) {
throw new InterruptedException();
}
ExportedKnowledgeBase exportedKB = new ExportedKnowledgeBase();
exportedKB.setId(kb.getRepositoryId());
exportedKB.setName(kb.getName());
exportedKB.setType(kb.getType().toString());
exportedKB.setClassIri(kb.getClassIri());
exportedKB.setSubclassIri(kb.getSubclassIri());
exportedKB.setTypeIri(kb.getTypeIri());
exportedKB.setDescriptionIri(kb.getDescriptionIri());
exportedKB.setLabelIri(kb.getLabelIri());
exportedKB.setPropertyTypeIri(kb.getPropertyTypeIri());
exportedKB.setPropertyLabelIri(kb.getPropertyLabelIri());
exportedKB.setPropertyDescriptionIri(kb.getPropertyDescriptionIri());
exportedKB.setFullTextSearchIri(kb.getFullTextSearchIri());
exportedKB.setReadOnly(kb.isReadOnly());
exportedKB.setEnabled(kb.isEnabled());
exportedKB.setReification(kb.getReification().toString());
exportedKB.setSupportConceptLinking(kb.isSupportConceptLinking());
exportedKB.setBasePrefix(kb.getBasePrefix());
exportedKB.setRootConcepts(new ArrayList<>(kb.getRootConcepts()));
exportedKB.setAdditionalMatchingProperties(new ArrayList<>(kb.getAdditionalMatchingProperties()));
exportedKB.setDefaultLanguage(kb.getDefaultLanguage());
exportedKB.setDefaultDatasetIri(kb.getDefaultDatasetIri() != null ? kb.getDefaultDatasetIri() : null);
exportedKB.setMaxResults(kb.getMaxResults());
exportedKB.setSubPropertyIri(kb.getSubPropertyIri());
exportedKnowledgeBases.add(exportedKB);
if (kb.getType() == RepositoryType.REMOTE) {
// set url for remote KB
RepositoryImplConfig cfg = kbService.getKnowledgeBaseConfig(kb);
String url = ((SPARQLRepositoryConfig) cfg).getQueryEndpointUrl();
exportedKB.setRemoteURL(url);
} else {
// export local kb files
exportKnowledgeBaseFiles(aFile, kb);
}
}
aExProject.setProperty(KEY, exportedKnowledgeBases);
int n = exportedKnowledgeBases.size();
LOG.info("Exported [{}] knowledge bases for project [{}]", n, project.getName());
}
Aggregations