Click here to Skip to main content
15,898,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a Registration form, after giving the input it will generate a RDF File. My, professor have given me the RDF generation code, but I am unable to understand that how will I link it with my Registration page.

What I have tried:

Here is my RDF generation code


* To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.at.ju.rdfgraphgeneration;

import ac.at.ju.rdfUtility.UploadRDFFile;
import ac.at.ju.rdfUtility.DBURIFileDirectoryInformation;
import ac.at.ju.rdfUtility.RDFFileWrite;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
//import javax.management.Query;

import org.apache.jena.iri.impl.Main;
import org.apache.jena.query.QueryExecution;
//import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFList;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.util.FileManager;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;

/**
 *
 * @author anindita
 * 
 * This function will be called when a person creates new account
 * 
 */

public class RDFAccountInformation {
    private String fileName;
    private LinkedList<String> userAccountList;
    private String dbURI;
    private String userAccountEntry;

    public void setDbURI(String dbURI) {
        this.dbURI = dbURI;
    }
    public void setUserAccountEntry(String userAccountEntry) {
        this.userAccountEntry = userAccountEntry;
    }
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
    public String getFileDirectory()
    {
        return DBURIFileDirectoryInformation.getInstance().getFileDirectory();
    }
    public void setUserAccountList(LinkedList<String> userAccountList) {
        this.userAccountList = userAccountList;
    }
    
    public int getNumberOfUser() {
        return this.userAccountList.size();
    }
     //RDF file generation
    
    public Model getAccountRDF() throws IOException
    {
         Model m = ModelFactory.createDefaultModel();
       
       Resource account = m.createResource( this.dbURI + "user" );
       Property P = m.createProperty( this.dbURI + "account" );
 
       RDFNode accountNodeArray[]=new RDFNode[getNumberOfUser()];
       for(int i=0;i<getNumberOfUser();i++)
        {
        accountNodeArray[i]=m.createResource(this.dbURI+this.userAccountList.get(i));
        }
      RDFList list=m.createList(accountNodeArray);
      m.add(account, P, list);  
      m.setNsPrefix( "db", this.dbURI );
       return m;
  }
     public void accountInformationGeneration()throws IOException
    {
        LinkedList<String> userList=new LinkedList<String> ();
        if(new File(fileName).exists())
        {
            userList=UploadRDFFile.getInstance().
                       mainExistUserInformation(this.fileName);
        }
         userList.add(this.userAccountEntry);
         setUserAccountList(userList);
         RDFFileWrite.getInstance().fileWriteOperation(getAccountRDF(), this.fileName);
    }
    //responsible to call all the functions and outside class communicate with this method
    public void mainAccountInformationGeneration(String userAccountEntry)throws IOException
    {
         //this information can be changed
        {
        setFileName(getFileDirectory()+"AccountInfo.rdf");
        setDbURI(DBURIFileDirectoryInformation.getInstance().getDBURI());
       }
        setUserAccountEntry(userAccountEntry);
        accountInformationGeneration();
    }
    public static void main(String []p) throws IOException
    {
        String accountId="account6";  //input
        
        new RDFAccountInformation().mainAccountInformationGeneration(accountId);
    }
   
    
}
Posted
Comments
Richard MacCutchan 7-Mar-18 8:27am    
Talk to your professor.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900