Ejemplo n.º 1
0
Further information about Construct can be obtained from
http://www.construct-infrastructure.org
"""
 
from construct.proxy import proxy
from construct.constructservice import ServiceError
from rdflib.Graph import ConjunctiveGraph
	
# Create a new proxy object.
proxy = proxy()
print "Executing Script"
try:
    # Generate a piece of FOAF RDF
    store = ConjunctiveGraph()
    store.load("joebloggs_foaf.rdf")
    data = store.serialize(format="nt")
    # Send the FOAF RDF to the data store
    if(proxy.insert(data)):
        # Now query for joebloggs web address
        query = """SELECT ?nickname WHERE{
        ?subject <http://xmlns.com/foaf/0.1/name> "Joe Bloggs".
        ?subject <http://xmlns.com/foaf/0.1/nick> ?nickname.}
        """
        results = proxy.query(query)
        print "Here is the N3 form of the QueryResults Object:"		
        print results
except ServiceError, e:
    print e
# Close the proxy.
proxy.close()
Ejemplo n.º 2
0
Construct is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with Construct; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA

Further information about Construct can be obtained from
http://www.construct-infrastructure.org
""" 
from construct.proxy import proxy
from construct.constructservice import ServiceError
# Create a new Proxy object. 
proxy = proxy()
print "Executing Script"
try:
	# Send a VALID piece of RDF to the data store
    insertGoodResponse = proxy.insert("<http://hello><http://construct>\"world\".")
    print "Response to good RDF: " + str(insertGoodResponse) 
    # response should be "1"
	#Send an INVALID piece of RDF to the data store
    insertBadResponse = proxy.insert("<http://badly><http://formed>\"rd\"f\".")
    print "Response to bad RDF: " + str(insertBadResponse) 
    # response should be "None"
except ServiceError, e:
    print e.value
#Close the proxy.
proxy.close()
Ejemplo n.º 3
0
from construct.constructservice import ServiceError

from rdflib import RDF, Namespace, Literal
from rdflib.Graph import ConjunctiveGraph
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
exampleNS = Namespace("http://www.example.com/")
	
#Create a new Proxy object.
proxy = proxy()
print "Executing Script"
try:
    # Generate a piece of FOAF RDF
    store = ConjunctiveGraph()
    store.bind("foaf", "http://xmlns.com/foaf/0.1/")
    store.add((exampleNS["~joebloggs"], RDF.type, FOAF["Person"]))
    store.add((exampleNS["~joebloggs"], FOAF["name"], Literal("Joe Bloggs")))
    store.add((exampleNS["~joebloggs"], FOAF["nick"], Literal("joe")))
    store.add((exampleNS["~joebloggs"], FOAF["givenname"], Literal("Joe")))
    store.add((exampleNS["~joebloggs"], FOAF["family_name"], Literal("Bloggs")))
    data = store.serialize(format="nt")
    #Send the FOAF RDF to the data store
    if proxy.insert(data):
        print "The following data were added correctly:"
        print data
    else:
        print "Problem encountered when adding the following data:"
        print data
except ServiceError, e:
    print e
# Close the proxy.
proxy.close()