how to insert rdf into virtuoso via jena? - jena

After i generate my rdf triple.I want to insert them into Virtuoso triple Store via Jena.
....
model.write(System.out,"RDF/XML");
....
url = "jdbc:virtuoso://localhost:1111";
VirtGraph set = new VirtGraph (url, "dba", "dba");
Query sparql = QueryFactory.create("?????");
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, set);
vqe.exec();
How can i do ?

The documentation for the Virtuoso Jena Provider includes a sample program VirtuosoSPARQLExample8 demonstrating how to insert triples into a graph.

Related

Denodo Json Source and Base View: how to make VQL more traditional SQL syntax

I have a web service api
In Denodo, I have virtualized the following api:
https://delphi.cmu.edu/epidata/fluview/?regions=nat&epiweeks=201501,201601,201701
as
https://delphi.cmu.edu/epidata/fluview/?regions=#{regions}&epiweeks=#{epiweeks}
This allows us, in Denodo, to write the following:
Select * from bv_fluview where epiweeks = '201501,201601,201701' and regions = 'nat'
Is there any way where the query could be written in a more traditional way such as:
Select * from bv_fluview where epiweeks in ('201501','201601','201701') and regions = 'nat'
I am relatively new to Denodo.
Thanks,
Dan
In Denodo, you can use the IN clause to check if a value is present in a list
SELECT *
FROM bv_fluview
WHERE epiweeks IN ('201501','201601','201701')
AND regions = 'nat'
This would return the same result as your original query but with a more conventional syntax for the IN operator.

How to retrieve an XMLTYPE data that contains special characters?

I want to retrieve XMLTYPE data from an Oracle table using cx_oracle.
the data looks like this:
<infos>
<Comment/>
<Observation>àéèç</Observation>
<Level>L3</Level>
<Duration/>
<Cause/>
<Depot> Haren </Depot>
<Resolution/>
</infos>
Here's my code:
#!/usr/bin/python
from __future__ import print_function
import cx_Oracle
# Connection to RTDIAG
try:
dsn_test = cx_Oracle.makedsn(host='xxxxx',port='1521',service_name='xxxxx')
con_test = cx_Oracle.connect(user='xxxx', password='xxxxx',dsn=xxxx)
except cx_Oracle.InterfaceError:
print ("Impossible to connect to the DB!")
print ("***exit script***")
quit()
ID_record = 1729
cursor = con_test.cursor()
query = """select a.content.getClobVal() from emb_log a where ID = :id and uncompleted_record=1
"""
cursor.execute(query,id=1729)
xml_retrieved = cursor.fetchone()[0].read() #string
print (xml_retrieved)
Here's what I get
<infos>
<Comment/>
<Observation>aeec</Observation>
<Level>L3</Level>
<Duration/>
<Cause/>
<Depot> Haren </Depot>
<Resolution/>
</infos>
The special characters contained within the XML child is not being retrieved proprely. They are converted in 'ascii like' characters.
Why and how to fetch the XML exactly the way it appears in the DB ?
Thank you.
Set your NLS environment. You will probably find it easiest to use
the
encoding
option when you connect.
for performance, you will want to fetch the CLOB via an OutputTypeHandler

Using an existing spreadsheet as a template PHPspreadsheet

Objective
I want to use an existing Excel sheet, as a template to create an invoice.
Cell styling, such as coloring have to be included
An image (logo) has to be included
Standard data such as company address has to be included
I've read something about cfspreadsheet, but I'm not entirely sure how to use it.
Question A:
Is there a way to use a template file? Or do you know any alternatives?
Question B
Is it possible to use $_POST data with this library?
Example
$data = $_POST['example'];
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', '$data');
I am not 100% sure, but according to PhpSpreadsheet's doc, you can read a local file (your pre-made template) with :
$inputFileName = './sampleData/example1.xls';
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
Or in case you already know the file type (.xlsx or .xsl) :
$inputFileType = 'Xls'; // Xlsx - Xml - Ods - Slk - Gnumeric - Csv
$inputFileName = './sampleData/example1.xls';
/** Create a new Reader of the type defined in $inputFileType **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($inputFileName);
You can also wrap all of that in a try catch if you want.
Then you just have to make changes the same way you would populate a Spreadsheet you created, populating cells with data you get from pretty much where you want with php, examples :
Classic variable $foo = 'bar';
$_GET / $_POST / $_REQUEST
From a Database

No results returns while using 'where' clause in zend framework 2

I am using a simple select object to list all the parent categories as follows.
$select = $this->sql->select();
$select -> where(array('cat_parent_id'=>2));
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
When I run the above code, I donot have an error message but I always have a null result. If I use the where clause without the array params then I have the good results.
$select -> where('cat_parent_id=2');
To learn more, I tried to get the sql string using the code below,
$select = $this->sql->select();
$select -> where(array('cat_parent_id'=>2));
$sqlstring = $this->sql->getSqlStringForSqlObject($select);
I have a warning.
Notice: Attempting to quote a value in Zend\Db\Adapter\Platform\Mysql without extension/driver support can introduce security vulnerabilities in a production environment. in D:\wamp\www\shops\vendor\ZF2\library\Zend\Db\Adapter\Platform\Mysql.php on line 128
I really would like to use the array method inside the where clause. Any help would be very appreciated. :)

ESPER using csv adapter with POJO

I need some help with esper using csv files as input with csv adapter. I need to use POJO classes and more than 1 csv file.
If there is an example that includes the above with listener as well I will appreciate.
Thanks
To use Java objects as events ,simply register the event type name for the Java class and provide the same name to the CSV adapter.
Configuration configuration = new Configuration();
configuration.addEventType("Event1", Event1.class);
configuration.addEventType("Event2", Event2.class);
configuration.addEventType("Event3", Event3.class);
epService = EPServiceProviderManager.getDefaultProvider(configuration);
EPStatement stmt = epService.getEPAdministrator().createEPL(
"select * from Event1, Event2,Event3");
(new CSVInputAdapter(epService, new AdapterInputSource(filename1), "Event1")).start();
(new CSVInputAdapter(epService, new AdapterInputSource(filename2), "Event2")).start();
(new CSVInputAdapter(epService, new AdapterInputSource(filename3), "Event3")).start();

Resources