Skip to content

Commit

Permalink
0.01
Browse files Browse the repository at this point in the history
  • Loading branch information
meskine wassif committed Jan 5, 2020
0 parents commit 7ea7ef0
Show file tree
Hide file tree
Showing 23 changed files with 333 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/arq.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/commons-logging.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/jena.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/axis.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/icu4j_3_4.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/iri.jar"/>
<classpathentry kind="lib" path="/Users/Zazif/Desktop/3anneeTI/benhlima/demo/VOSDownload-jenajars/xercesImpl.jar"/>
<classpathentry kind="lib" path="/Applications/Virtuoso 7.2.app/Contents/virtuoso/lib/virt_jena.jar"/>
<classpathentry kind="lib" path="/Applications/Virtuoso 7.2.app/Contents/virtuoso/lib/virtjdbc3.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>virtuosoJenaProvider</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
encoding/src=UTF-8
16 changes: 16 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Binary file added bin/ma/meskine/Main.class
Binary file not shown.
Binary file added bin/ma/meskine/dao/DBManager.class
Binary file not shown.
Binary file added bin/ma/meskine/dao/DBManagerImp.class
Binary file not shown.
Binary file added bin/ma/meskine/model/Company.class
Binary file not shown.
37 changes: 37 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>virtuosoJenaProvider</groupId>
<artifactId>virtuosoJenaProvider</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<properties>
<java.version>1.8</java.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions src/ma/meskine/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ma.meskine;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
29 changes: 29 additions & 0 deletions src/ma/meskine/controller/CompanyCotroller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ma.meskine.controller;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import ma.meskine.dao.DBManager;
import ma.meskine.model.Company;

@RestController
public class CompanyCotroller {

@Autowired
private DBManager dbm;

@GetMapping("/companies/{id}")
public Company findCompany(@PathVariable long id) {
Company c = dbm.findCompanyById(id);
return c;
}

@GetMapping("/companies/")
public ArrayList<Company> findCompany() {
return dbm.findAll();
}
}
12 changes: 12 additions & 0 deletions src/ma/meskine/dao/DBManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ma.meskine.dao;

import java.util.ArrayList;

import ma.meskine.model.Company;

public interface DBManager {

public Company findCompanyById(long id);
public ArrayList<String> allCompaniesName();
public ArrayList<Company> findAll();
}
76 changes: 76 additions & 0 deletions src/ma/meskine/dao/DBManagerImp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package ma.meskine.dao;

import java.util.ArrayList;

import org.springframework.stereotype.Component;

import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;

import ma.meskine.model.Company;
import virtuoso.jena.driver.VirtModel;

@Component
public class DBManagerImp implements DBManager {

@Override
public Company findCompanyById(long id) {
String url = "jdbc:virtuoso://localhost:1111";

Model m = VirtModel.openDatabaseModel("http://localhost:8890/mydb#", url, "dba", "admin");
String prolog = "PREFIX mdb: <http://localhost:8890/schemas/mydb/>\n";
String queryString = prolog + "select ?compId ?compN ?compCity where { \n" + "?company mdb:company_id '" + id
+ "'.\n" + "?company mdb:company_id ?compId.\n" + "?company mdb:company_name ?compN.\n"
+ "?company mdb:company_city ?compCity\n" + "}";
QueryExecution qexec = QueryExecutionFactory.create(queryString, m);
ResultSet rs = qexec.execSelect();
QuerySolution result = rs.nextSolution();
Company c = new Company(id, result.get("compN").toString(), result.get("compCity").toString());
return c;
}

@Override
public ArrayList<String> allCompaniesName() {
ArrayList<String> names = new ArrayList<>();
String url = "jdbc:virtuoso://localhost:1111";
Model m = VirtModel.openDatabaseModel("http://localhost:8890/mydb#", url, "dba", "admin");
String prolog = "PREFIX mdb: <http://localhost:8890/schemas/mydb/>\n";
String queryString = prolog + "select ?companyName where {?s mdb:company_name ?companyName . }";
QueryExecution qexec = QueryExecutionFactory.create(queryString, m);
ResultSet rs = qexec.execSelect();
while (rs.hasNext()) {
QuerySolution result = rs.nextSolution();
RDFNode companyName = result.get("companyName");
names.add(companyName.toString());
}
m.close();
return names;
}

@Override
public ArrayList<Company> findAll() {
ArrayList<Company> companies = new ArrayList<>();
String url = "jdbc:virtuoso://localhost:1111";
Model m = VirtModel.openDatabaseModel("http://localhost:8890/mydb#", url, "dba", "admin");
String prolog = "PREFIX mdb: <http://localhost:8890/schemas/mydb/>\n";
String queryString = prolog + "select ?compId ?compN ?compCity where {\n" + "?company mdb:company_id ?compId.\n"
+ "?company mdb:company_name ?compN.\n" + "?company mdb:company_city ?compCity\n" + " }";
QueryExecution qexec = QueryExecutionFactory.create(queryString, m);
ResultSet rs = qexec.execSelect();
while (rs.hasNext()) {
QuerySolution result = rs.nextSolution();
RDFNode companyId = result.get("compId");
RDFNode companyName = result.get("compN");
RDFNode companyCity = result.get("compCity");
Company c = new Company(Long.valueOf(companyId.toString()), companyName.toString(), companyCity.toString());
companies.add(c);
}
m.close();
return companies;
}

}
43 changes: 43 additions & 0 deletions src/ma/meskine/model/Company.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ma.meskine.model;

public class Company {

private long companyId;
private String companyName;
private String companyCity;

public Company() {
}

public Company(long companyId, String companyName, String companyCity) {
super();
this.companyId = companyId;
this.companyName = companyName;
this.companyCity = companyCity;
}

public long getCompanyId() {
return companyId;
}

public void setCompanyId(long companyId) {
this.companyId = companyId;
}

public String getCompanyName() {
return companyName;
}

public void setCompanyName(String companyName) {
this.companyName = companyName;
}

public String getCompanyCity() {
return companyCity;
}

public void setCompanyCity(String companyCity) {
this.companyCity = companyCity;
}

}
6 changes: 6 additions & 0 deletions target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Implementation-Title: virtuosoJenaProvider
Implementation-Version: 0.0.1-SNAPSHOT
Build-Jdk-Spec: 1.8
Created-By: Maven Integration for Eclipse

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Sun Jan 05 12:01:51 WET 2020
version=0.0.1-SNAPSHOT
groupId=virtuosoJenaProvider
m2e.projectName=virtuosoJenaProvider
m2e.projectLocation=/Users/Zazif/eclipse-workspace-09-2019/virtuosoJenaProvider
artifactId=virtuosoJenaProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>virtuosoJenaProvider</groupId>
<artifactId>virtuosoJenaProvider</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<properties>
<java.version>1.8</java.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Binary file added target/classes/ma/meskine/Main.class
Binary file not shown.
Binary file not shown.
Binary file added target/classes/ma/meskine/dao/DBManager.class
Binary file not shown.
Binary file added target/classes/ma/meskine/dao/DBManagerImp.class
Binary file not shown.
Binary file added target/classes/ma/meskine/model/Company.class
Binary file not shown.

0 comments on commit 7ea7ef0

Please sign in to comment.