[Mulgara-svn] r1427 - in branches/xa11: . KOWARI-MODIFICATIONS src/jar/ant-task/java/org/mulgara/ant/task/rdf src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql src/jar/client-jrdf/java/org/mulgara/client/jrdf/test src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer src/jar/content-mbox/java/org/mulgara/content/mbox/parser/model src/jar/content-mp3/java/org/mulgara/content/mp3/parser src/jar/content-n3/java/org/mulgara/content/n3 src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer src/jar/demo-mp3/java/org/mulgara/demo/mp3 src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3 src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets src/jar/descriptor/src/java/org/mulgara/descriptor src/jar/jrdf/java/org/mulgara/jrdf src/jar/krule/java/org/mulgara/krule src/jar/query/java/org/jrdf/graph src/jar/query/java/org/mulgara/connection src/jar/query/java/org/mulgara/query src/jar/query/java/org/mulgara/query/operation src/jar/query/java/org/mulgara/server src/jar/querylang/java/org/mulgara/itql src/jar/querylang/java/org/mulgara/protocol/http src/jar/querylang/java/org/mulgara/sparql src/jar/querylang/java/org/mulgara/store/jxunit src/jar/querylang/sablecc src/jar/resolver/java/org/mulgara/resolver src/jar/resolver/java/org/mulgara/store/exporter src/jar/resolver-distributed/java/org/mulgara/resolver/distributed src/jar/resolver-file/java/org/mulgara/resolver/file src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem src/jar/resolver-gis/java/org/mulgara/resolver/gis src/jar/resolver-http/java/org/mulgara/resolver/http src/jar/resolver-jar/java/org/mulgara/resolver/jar src/jar/resolver-lucene/java/org/mulgara/resolver/lucene src/jar/resolver-memory/java/org/mulgara/resolver/memory src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype src/jar/resolver-null/java/org/mulgara/resolver/nullres src/jar/resolver-prefix/java/org/mulgara/resolver/prefix src/jar/resolver-relational/java/org/mulgara/resolver/relational src/jar/resolver-spi/java/org/mulgara/content src/jar/resolver-spi/java/org/mulgara/resolver/spi src/jar/resolver-spi/java/org/mulgara/store/statement src/jar/resolver-test/java/org/mulgara/resolver/test src/jar/resolver-url/java/org/mulgara/resolver/url src/jar/resolver-view/java/org/mulgara/resolver/view src/jar/resolver-xsd/java/org/mulgara/resolver/xsd src/jar/server/java/org/mulgara/server src/jar/server-local/java/org/mulgara/server/local src/jar/server-rmi/java/org/mulgara/server/rmi src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11 src/jar/store-xa/java/org/mulgara/store/xa src/jar/tag/java/org/mulgara/extractor/tag src/jar/tuples/java/org/mulgara/store/tuples src/jar/util/java/org/mulgara/util src/jar/util/java/org/mulgara/util/functional src/jar/web/java/org/mulgara/webquery src/jar/web/resources
pag at mulgara.org
pag at mulgara.org
Sat Jan 10 08:23:31 UTC 2009
Author: pag
Date: 2009-01-10 00:23:29 -0800 (Sat, 10 Jan 2009)
New Revision: 1427
Added:
branches/xa11/KOWARI-MODIFICATIONS/mods-mulgara-2.0.7.txt
branches/xa11/src/jar/query/java/org/mulgara/query/Graph.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphExpression.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphIntersection.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphLiteral.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphOperation.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphPartition.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphResource.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphUnion.java
branches/xa11/src/jar/query/java/org/mulgara/query/GraphVariable.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java
branches/xa11/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java
branches/xa11/src/jar/web/resources/tutorial.html
branches/xa11/src/jar/web/resources/tutorial_head.html
Removed:
branches/xa11/src/jar/query/java/org/mulgara/query/Model.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelExpression.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelIntersection.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelLiteral.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelOperation.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelPartition.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelResource.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelUnion.java
branches/xa11/src/jar/query/java/org/mulgara/query/ModelVariable.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java
branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java
Modified:
branches/xa11/common.properties
branches/xa11/src/jar/ant-task/java/org/mulgara/ant/task/rdf/RDFLoadUnitTest.java
branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/ItqlGraphProxy.java
branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/SessionGraphProxy.java
branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/RemoteAnswerCloneUnitTest.java
branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer/MemoryXMLWriter.java
branches/xa11/src/jar/content-mbox/java/org/mulgara/content/mbox/parser/model/ModelFactory.java
branches/xa11/src/jar/content-mp3/java/org/mulgara/content/mp3/parser/ID3ParsersUnitTest.java
branches/xa11/src/jar/content-n3/java/org/mulgara/content/n3/Parser.java
branches/xa11/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/AbstractModel.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/FileSystemModelImpl.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ControllerImpl.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3FileImpl.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3Model.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ModelImpl.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModel.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModelImpl.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3/AbstractId3Tag.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions/ClearMp3ModelAction.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results/Mp3List.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search/BrowserPanel.java
branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets/PropertiesTable.java
branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DeployServlet.java
branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/Descriptor.java
branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DescriptorElement.java
branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraph.java
branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraphUnitTest.java
branches/xa11/src/jar/krule/java/org/mulgara/krule/KruleLoader.java
branches/xa11/src/jar/krule/java/org/mulgara/krule/QueryStruct.java
branches/xa11/src/jar/query/java/org/jrdf/graph/AbstractURIReference.java
branches/xa11/src/jar/query/java/org/mulgara/connection/Connection.java
branches/xa11/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
branches/xa11/src/jar/query/java/org/mulgara/connection/DummyConnection.java
branches/xa11/src/jar/query/java/org/mulgara/connection/SessionConnection.java
branches/xa11/src/jar/query/java/org/mulgara/query/AskQuery.java
branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
branches/xa11/src/jar/query/java/org/mulgara/query/ConstructQuery.java
branches/xa11/src/jar/query/java/org/mulgara/query/Query.java
branches/xa11/src/jar/query/java/org/mulgara/query/QueryUnitTest.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/Backup.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/Export.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/Load.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/Restore.java
branches/xa11/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
branches/xa11/src/jar/query/java/org/mulgara/server/Session.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/Collaborator.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/CollaboratorUnitTest.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/ConstraintExpressionBuilder.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
branches/xa11/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
branches/xa11/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java
branches/xa11/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
branches/xa11/src/jar/querylang/sablecc/itql.grammar
branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
branches/xa11/src/jar/resolver-file/java/org/mulgara/resolver/file/FileResolver.java
branches/xa11/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemResolver.java
branches/xa11/src/jar/resolver-gis/java/org/mulgara/resolver/gis/ReadOnlyGISResolver.java
branches/xa11/src/jar/resolver-http/java/org/mulgara/resolver/http/HttpResolver.java
branches/xa11/src/jar/resolver-jar/java/org/mulgara/resolver/jar/JarResolver.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java
branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java
branches/xa11/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java
branches/xa11/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java
branches/xa11/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
branches/xa11/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/TuplesWrapperResolution.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraint.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraintDescriptor.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverFactory.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverUnitTest.java
branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalTransformer.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConjunctiveTransformer.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintDescriptor.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintExpansion.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintResolutionHandler.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/QueryEvaluationContext.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolver.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolverFactory.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java
branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStoreAbstractUnitTest.java
branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestConstraintDescriptor.java
branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolver.java
branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolverUnitTest.java
branches/xa11/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java
branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolver.java
branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolverUnitTest.java
branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraintDescriptor.java
branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/XSDResolver.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BasicDatabaseSessionUnitTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BootstrapOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/Database.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionUnitTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DirectTransitiveFunction.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExhaustiveTransitiveFunction.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/InternalResolver.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/JotmTransactionStandaloneTest.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/PrimitiveConstraintDescriptor.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RestoreOperation.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/TestDef.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/WalkFunction.java
branches/xa11/src/jar/resolver/java/org/mulgara/resolver/XADatabaseSessionUnitTest.java
branches/xa11/src/jar/server-local/java/org/mulgara/server/local/LocalSessionFactory.java
branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteJRDFSession.java
branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionFactoryImpl.java
branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
branches/xa11/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
branches/xa11/src/jar/server/java/org/mulgara/server/HttpServices.java
branches/xa11/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
branches/xa11/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
branches/xa11/src/jar/store-xa/java/org/mulgara/store/xa/XAStatementStore.java
branches/xa11/src/jar/tag/java/org/mulgara/extractor/tag/InitTag.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/AbstractTuples.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/DefinablePrefixAnnotation.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/LeftJoin.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedAppend.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/Tuples.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/WrappedTuples.java
branches/xa11/src/jar/util/java/org/mulgara/util/StackTrace.java
branches/xa11/src/jar/util/java/org/mulgara/util/functional/C.java
branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
branches/xa11/src/jar/web/java/org/mulgara/webquery/Template.java
branches/xa11/src/jar/web/resources/template.html
branches/xa11/src/jar/web/resources/template_head.html
Log:
Merge of trunk into this branch
Copied: branches/xa11/KOWARI-MODIFICATIONS/mods-mulgara-2.0.7.txt (from rev 1423, trunk/KOWARI-MODIFICATIONS/mods-mulgara-2.0.7.txt)
===================================================================
--- branches/xa11/KOWARI-MODIFICATIONS/mods-mulgara-2.0.7.txt (rev 0)
+++ branches/xa11/KOWARI-MODIFICATIONS/mods-mulgara-2.0.7.txt 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,824 @@
+------------------------------------------------------------------------
+r1411 | pag | 2008-12-06 09:05:09 -0600 (Sat, 06 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/LEGAL.txt
+
+Added license descriptions for new jars
+------------------------------------------------------------------------
+r1409 | pag | 2008-12-06 08:24:59 -0600 (Sat, 06 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/common.properties
+
+Updated version
+------------------------------------------------------------------------
+r1408 | pag | 2008-12-06 08:23:16 -0600 (Sat, 06 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Load.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/Template.java
+ M /trunk/src/jar/web/resources/template.html
+ M /trunk/src/jar/web/resources/template_head.html
+ M /trunk/src/jar/web/resources/tutorial.html
+ M /trunk/src/jar/web/resources/tutorial_head.html
+
+Added upload capability. Also testing for invalid LOCAL operations
+------------------------------------------------------------------------
+r1407 | pag | 2008-12-06 08:22:21 -0600 (Sat, 06 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
+
+removed warnings
+------------------------------------------------------------------------
+r1406 | pag | 2008-12-05 17:53:44 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/query/java/org/mulgara/connection/Connection.java
+ M /trunk/src/jar/query/java/org/mulgara/connection/DummyConnection.java
+ M /trunk/src/jar/query/java/org/mulgara/connection/SessionConnection.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Backup.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Export.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Load.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Restore.java
+ M /trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionFactoryImpl.java
+
+Detecting when remote data streaming is requested on local connections, and reporting an error
+------------------------------------------------------------------------
+r1405 | pag | 2008-12-05 17:53:03 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java
+
+Handling creation of parameterized graph names. Needed for remote sessions.
+------------------------------------------------------------------------
+r1404 | pag | 2008-12-05 17:51:58 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/util/java/org/mulgara/util/StackTrace.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
+
+Better error reporting for users
+------------------------------------------------------------------------
+r1403 | pag | 2008-12-05 17:50:30 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
+
+Removed a warning, and replaced tabs with spaces
+------------------------------------------------------------------------
+r1402 | ronald | 2008-12-05 05:56:21 -0600 (Fri, 05 Dec 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
+
+Fixed a bug where a statement with an empty literal could be inserted but
+not deleted.
+------------------------------------------------------------------------
+r1401 | ronald | 2008-12-05 05:56:15 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+
+Corrected exception message a bit.
+------------------------------------------------------------------------
+r1400 | ronald | 2008-12-05 05:56:09 -0600 (Fri, 05 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java
+
+Log the transaction timeouts (at level debug).
+------------------------------------------------------------------------
+r1399 | pag | 2008-12-04 23:42:29 -0600 (Thu, 04 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/ant-task/java/org/mulgara/ant/task/rdf/RDFLoadUnitTest.java
+ M /trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/ItqlGraphProxy.java
+ M /trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/SessionGraphProxy.java
+ M /trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/RemoteAnswerCloneUnitTest.java
+ M /trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer/MemoryXMLWriter.java
+ R /trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/parser/model/ModelFactory.java (from /trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/parser/model/ModelFactory.java:1397)
+ M /trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/parser/ID3ParsersUnitTest.java
+ M /trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/AbstractModel.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/FileSystemModelImpl.java
+ R /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java (from /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java:1397)
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ControllerImpl.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3FileImpl.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3Model.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ModelImpl.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModel.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModelImpl.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3/AbstractId3Tag.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions/ClearMp3ModelAction.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results/Mp3List.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search/BrowserPanel.java
+ M /trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets/PropertiesTable.java
+ M /trunk/src/jar/descriptor/src/java/org/mulgara/descriptor/DeployServlet.java
+ M /trunk/src/jar/descriptor/src/java/org/mulgara/descriptor/Descriptor.java
+ M /trunk/src/jar/descriptor/src/java/org/mulgara/descriptor/DescriptorElement.java
+ M /trunk/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraph.java
+ M /trunk/src/jar/krule/java/org/mulgara/krule/QueryStruct.java
+ M /trunk/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
+ M /trunk/src/jar/query/java/org/mulgara/query/AskQuery.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ConstructQuery.java
+ A /trunk/src/jar/query/java/org/mulgara/query/Graph.java (from /trunk/src/jar/query/java/org/mulgara/query/Model.java:1397)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphExpression.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java:1398)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphIntersection.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java:1397)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphLiteral.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java:1398)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphOperation.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java:1398)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphPartition.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java:1398)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphResource.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelResource.java:1398)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java:1397)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphUnion.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java:1397)
+ A /trunk/src/jar/query/java/org/mulgara/query/GraphVariable.java (from /trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java:1398)
+ D /trunk/src/jar/query/java/org/mulgara/query/Model.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java
+ D /trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java
+ M /trunk/src/jar/query/java/org/mulgara/query/Query.java
+ M /trunk/src/jar/query/java/org/mulgara/query/QueryUnitTest.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/Load.java
+ M /trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
+ M /trunk/src/jar/query/java/org/mulgara/server/Session.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/Collaborator.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/CollaboratorUnitTest.java
+ A /trunk/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java (from /trunk/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java:1397)
+ A /trunk/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java (from /trunk/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java:1397)
+ D /trunk/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java
+ D /trunk/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/BasicDatabaseSessionUnitTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/Database.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionUnitTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DirectTransitiveFunction.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/ExhaustiveTransitiveFunction.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java:1397)
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/InternalResolver.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/JotmTransactionStandaloneTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/PrimitiveConstraintDescriptor.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/RestoreOperation.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
+ A /trunk/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java (from /trunk/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/TestDef.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/WalkFunction.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/XADatabaseSessionUnitTest.java
+ A /trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java (from /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java:1397)
+ A /trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java (from /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java:1397)
+ A /trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java (from /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java:1397)
+ D /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java
+ D /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java
+ D /trunk/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ M /trunk/src/jar/resolver-file/java/org/mulgara/resolver/file/FileResolver.java
+ M /trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemResolver.java
+ M /trunk/src/jar/resolver-gis/java/org/mulgara/resolver/gis/ReadOnlyGISResolver.java
+ M /trunk/src/jar/resolver-http/java/org/mulgara/resolver/http/HttpResolver.java
+ M /trunk/src/jar/resolver-jar/java/org/mulgara/resolver/jar/JarResolver.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java
+ M /trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraintDescriptor.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverFactory.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverUnitTest.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintDescriptor.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintExpansion.java
+ A /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java (from /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java:1397)
+ D /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintResolutionHandler.java
+ A /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java (from /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java:1397)
+ A /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java (from /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java:1397)
+ D /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java
+ D /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/QueryEvaluationContext.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolver.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolverFactory.java
+ M /trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java
+ M /trunk/src/jar/resolver-test/java/org/mulgara/resolver/test/TestConstraintDescriptor.java
+ M /trunk/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolver.java
+ M /trunk/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolverUnitTest.java
+ M /trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java
+ M /trunk/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolver.java
+ M /trunk/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolverUnitTest.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraintDescriptor.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/XSDResolver.java
+ M /trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
+ M /trunk/src/jar/server-local/java/org/mulgara/server/local/LocalSessionFactory.java
+ M /trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteJRDFSession.java
+ M /trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
+ M /trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
+ M /trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
+ M /trunk/src/jar/tag/java/org/mulgara/extractor/tag/InitTag.java
+
+Renaming classes from "Model" to "Graph"
+------------------------------------------------------------------------
+r1398 | pag | 2008-12-04 17:38:27 -0600 (Thu, 04 Dec 2008) | 7 lines
+Changed paths:
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
+ M /trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java
+ M /trunk/src/jar/server/java/org/mulgara/server/HttpServices.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/C.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
+ A /trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java
+ M /trunk/src/jar/web/resources/template.html
+ M /trunk/src/jar/web/resources/template_head.html
+ A /trunk/src/jar/web/resources/tutorial.html
+ A /trunk/src/jar/web/resources/tutorial_head.html
+
+Updated WebUI with a couple of cosmetic enhancements.
+ * No longer require a ; at the end of a TQL query. This addresses #157
+ * If the default graph is blank, then update it with the last queried graph
+ * A separate servlet for the tutorial. This gets the tutorial out of the way
+ for this majority of users as they're not using it.
+
+
+------------------------------------------------------------------------
+r1397 | ronald | 2008-12-03 03:26:08 -0600 (Wed, 03 Dec 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
+
+Fix exception when both subject and object of an xsd constraint are literals.
+
+------------------------------------------------------------------------
+r1396 | ronald | 2008-12-03 03:26:04 -0600 (Wed, 03 Dec 2008) | 4 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraint.java
+ M /trunk/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalTransformer.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConjunctiveTransformer.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
+
+Refactored symbolic tranformers to extend new AbstractSymbolicTranformer in
+order to handle things like the minus and optional-join constraints properly
+and to reduce duplicated code.
+
+------------------------------------------------------------------------
+r1395 | ronald | 2008-12-03 03:26:00 -0600 (Wed, 03 Dec 2008) | 3 lines
+Changed paths:
+ A /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java
+
+Factored out generic constraint walking code into a common superclass for
+symbolic transformers.
+
+------------------------------------------------------------------------
+r1394 | ronald | 2008-12-03 03:25:57 -0600 (Wed, 03 Dec 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
+ M /trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
+
+Code formatting fixes.
+
+------------------------------------------------------------------------
+r1390 | pag | 2008-12-02 17:48:40 -0600 (Tue, 02 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
+
+Added in generics
+------------------------------------------------------------------------
+r1386 | pag | 2008-12-01 19:13:13 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
+
+Fixed a bug where wrapped graph URIs were being ignored because they don't contain a fragment
+------------------------------------------------------------------------
+r1385 | pag | 2008-12-01 19:12:12 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
+
+Removed weird superfluous "unchecked" parameters to the SuppressWarnings annotation
+------------------------------------------------------------------------
+r1384 | pag | 2008-12-01 19:11:05 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
+
+changed an info log to a more appropriate debug
+------------------------------------------------------------------------
+r1383 | pag | 2008-12-01 19:10:12 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/OrderByRowComparator.java
+
+Correctly dealing with numbers that end in d or f
+------------------------------------------------------------------------
+r1382 | pag | 2008-12-01 14:30:09 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/.classpath
+
+updated sesame jar reference
+------------------------------------------------------------------------
+r1381 | pag | 2008-12-01 13:53:56 -0600 (Mon, 01 Dec 2008) | 1 line
+Changed paths:
+ M /trunk/.project
+ M /trunk/build.properties
+ D /trunk/lib/sesame-model-2.1.jar
+ A /trunk/lib/sesame-model-2.2.1.jar
+ M /trunk/src/jar/query/java/org/jrdf/graph/AbstractURIReference.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
+ D /trunk/src/jar/querylang/java/org/mulgara/itql/URIUtil.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
+ A /trunk/src/jar/util/java/org/mulgara/util/QueryParams.java (from /trunk/src/jar/web/java/org/mulgara/webquery/QueryParams.java:1380)
+ A /trunk/src/jar/util/java/org/mulgara/util/URIUtil.java
+ D /trunk/src/jar/web/java/org/mulgara/webquery/QueryParams.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
+
+Added in support for relative URIs in queries. This changes the URIReference implementation, so the sesame-model jar was updated so we could confirm it against the sesame sources.
+------------------------------------------------------------------------
+r1379 | pag | 2008-11-19 14:29:31 -0600 (Wed, 19 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/krule/java/org/mulgara/krule/KruleLoader.java
+ M /trunk/src/jar/krule/java/org/mulgara/krule/KruleStructureException.java
+ M /trunk/src/jar/krule/java/org/mulgara/krule/QueryStruct.java
+ M /trunk/src/jar/krule/java/org/mulgara/krule/Rule.java
+ M /trunk/src/jar/krule/java/org/mulgara/krule/RuleStructure.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/Aliasing.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/CommandSplitter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlAutoInterpreter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlCommandSplitter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/URIUtil.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedJSONAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswerUnitTest.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONObject.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLObject.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedTqlXMLAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedTqlXMLAnswerUnitTest.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedXMLAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/XMLAnswer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/BadRequestException.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/InternalErrorException.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/MimeMultiNamedPart.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/ServiceUnavailableException.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/ServletDataSource.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/ServletException.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/SparqlServlet.java
+ M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/TqlServlet.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/ConstantVarFactory.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/IdentityTransformer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/PatternMapper.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/PatternTransformer.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/SymbolicTransformationException.java
+ M /trunk/src/jar/querylang/java/org/mulgara/sparql/VariableRenameTransformer.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/AnswerResolution.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/Delegator.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/ForeignBlankNode.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/Config.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/RemotePager.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/RemotePagerImpl.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/SetProxy.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/ShortGlobalStatementSet.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/StatementSetFactory.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/TripleSetAdaptor.java
+ M /trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
+ M /trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolver.java
+ M /trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolverFactory.java
+ M /trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java
+ M /trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolverFactory.java
+ M /trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/TuplesWrapperResolution.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/DummyRuleLoader.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/InitializerException.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/RuleLoader.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/RuleLoaderFactory.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/Rules.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/RulesException.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/RulesRef.java
+ M /trunk/src/jar/rules/java/org/mulgara/rules/RulesRefImpl.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeAllocator.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/BlankNodeMapper.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataAVLComparator.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataCategoryAVLComparator.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataCategoryTypeAVLComparator.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/DataStruct.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolFactory.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImplTest.java
+ M /trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolLoadTest.java
+ M /trunk/src/jar/util/java/org/mulgara/util/ClasspathDesc.java
+ M /trunk/src/jar/util/java/org/mulgara/util/LexicalDateTime.java
+ M /trunk/src/jar/util/java/org/mulgara/util/LexicalDateTimeUnitTest.java
+ M /trunk/src/jar/util/java/org/mulgara/util/LongMapper.java
+ M /trunk/src/jar/util/java/org/mulgara/util/MemLongMapper.java
+ M /trunk/src/jar/util/java/org/mulgara/util/MortbayLogger.java
+ M /trunk/src/jar/util/java/org/mulgara/util/Rmi.java
+ M /trunk/src/jar/util/java/org/mulgara/util/SparqlUtil.java
+ M /trunk/src/jar/util/java/org/mulgara/util/SparqlUtilUnitTest.java
+ M /trunk/src/jar/util/java/org/mulgara/util/StackTrace.java
+ M /trunk/src/jar/util/java/org/mulgara/util/Timezone.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/C.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/F.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Fn.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Fn1.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Fn1E.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Fn2.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Fn2E.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/FnE.java
+ M /trunk/src/jar/util/java/org/mulgara/util/functional/Pair.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryParams.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/RequestException.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/ResourceBinaryFile.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/ResourceFile.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/ResourceTextFile.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/Template.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Anchor.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Break.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Div.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Emphasis.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/HtmlElement.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Paragraph.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Span.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Strong.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Table.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableAbstr.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableBody.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableData.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableHeader.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableRow.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/TableStructure.java
+ M /trunk/src/jar/web/java/org/mulgara/webquery/html/Text.java
+
+Updated licenses to Apache 2.0 on code that I am permitted to update the license on.
+------------------------------------------------------------------------
+r1378 | alexhall | 2008-11-12 12:39:26 -0600 (Wed, 12 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/util/java/org/mulgara/util/MappedIntFile.java
+ M /trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFile.java
+
+Address a Windows performance issue. Eliminate call to super.force() in the mapped block and int files. For mapped files, this call is unnecessary because the only operation on a file channel to force is a possible truncation, so no data can be lost on abnormal termination. The force method on the FileChannel class is causes significant performance problems on Windows.
+------------------------------------------------------------------------
+r1377 | alexhall | 2008-11-11 09:33:50 -0600 (Tue, 11 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/tuples/java/org/mulgara/store/tuples/LeftJoin.java
+
+Check for overflow when computing row count upper bound.
+------------------------------------------------------------------------
+r1376 | ronald | 2008-11-11 07:37:26 -0600 (Tue, 11 Nov 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
+
+Discard the lucene indexers after a rollback, as a rollback implicitly closes
+them. Also added tests for rollback.
+------------------------------------------------------------------------
+r1375 | ronald | 2008-11-11 07:37:20 -0600 (Tue, 11 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
+
+Fixed typo in test-method name.
+------------------------------------------------------------------------
+r1374 | ronald | 2008-11-11 07:37:13 -0600 (Tue, 11 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
+
+Flush the lexer on lexer errors too, not just on parser errors.
+------------------------------------------------------------------------
+r1373 | alexhall | 2008-11-03 09:57:36 -0600 (Mon, 03 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/jxdata/iTQL/backup_restore/loadFromExportResult.txt
+ M /trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java
+
+Don't throw an exception for recoverable parser errors encountered by ARP.
+------------------------------------------------------------------------
+r1372 | ronald | 2008-11-02 01:34:33 -0600 (Sun, 02 Nov 2008) | 2 lines
+Changed paths:
+ M /trunk/build.xml
+
+Fix up-to-date check for javadocs.
+
+------------------------------------------------------------------------
+r1371 | pag | 2008-11-01 23:44:03 -0500 (Sat, 01 Nov 2008) | 1 line
+Changed paths:
+ M /trunk/.classpath
+
+Added the new jline lib
+------------------------------------------------------------------------
+r1370 | eddie | 2008-10-30 21:28:30 -0500 (Thu, 30 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/build.xml
+
+added client-jrdf back to core-dist (the dependency was still there, but the actual jar inclusion was dropped in r1232)
+------------------------------------------------------------------------
+r1369 | bsletten | 2008-10-30 09:46:17 -0500 (Thu, 30 Oct 2008) | 3 lines
+Changed paths:
+ M /trunk/build.properties
+ M /trunk/common.xml
+ A /trunk/lib/jline-0.9.94.jar
+ M /trunk/src/jar/querylang/build.xml
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/ItqlOptionParser.java
+ A /trunk/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java
+ M /trunk/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
+
+Jline support for Swing-less shell, tabbed completion and command line history.
+
+
+------------------------------------------------------------------------
+r1368 | alexhall | 2008-10-28 14:19:40 -0500 (Tue, 28 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/Parser.java
+
+Get rid of deprecation warnings with ARP parser.
+------------------------------------------------------------------------
+r1367 | ronald | 2008-10-27 07:38:55 -0500 (Mon, 27 Oct 2008) | 6 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
+ A /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverFactory.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java
+
+Added caching of the lucene indexers. In one case this took the query time
+from 330ms down to 130ms.
+
+As part of this, the directory operations (creating and deleting directory)
+have been moved into the LuceneIndexerCache. Also, the ResolverFactory.delete
+has been implemented.
+------------------------------------------------------------------------
+r1366 | ronald | 2008-10-27 07:38:48 -0500 (Mon, 27 Oct 2008) | 17 lines
+Changed paths:
+ M /trunk/common.xml
+ A /trunk/jxdata/iTQL/fulltext_queries/queryResult17.txt
+ A /trunk/jxdata/iTQL/fulltext_queries/queryResult18.txt
+ A /trunk/jxdata/iTQL/fulltext_queries/queryResult19.txt
+ M /trunk/jxdata/iTQL/fulltext_queries/test.jxu
+ A /trunk/lib/jakarta-regexp-1.5.jar
+ M /trunk/src/jar/resolver-lucene/build.xml
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java
+ A /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java
+ A /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverFactory.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
+ A /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java
+
+Added support for returning the score in fulltext (lucene) queries.
+
+For this a new query graph is introduced with two new predicates, mulgara:search
+and mulgara:score . As an example, the query
+
+ select $foo from ... where $foo <title> 'sequencing' in <lucene-graph>;
+
+now becomes
+
+ select $foo $score from ... where
+ $foo <mulgara:search> $search in <lucene-graph> and
+ $search <title> 'sequencing' in <lucene-graph> and
+ $search <mulgara:score> $score in <lucene-graph>;
+
+The score is optional; also, the previous simple form is still recognized. This
+query graph is extensible, e.g. to add query parameters such as the analyzer to
+use.
+------------------------------------------------------------------------
+r1365 | ronald | 2008-10-27 07:38:39 -0500 (Mon, 27 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverFactory.java
+
+Made the modelTypeURI a static final.
+------------------------------------------------------------------------
+r1364 | ronald | 2008-10-27 07:38:34 -0500 (Mon, 27 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java
+
+Generified List usages, thereby removing a warning.
+------------------------------------------------------------------------
+r1363 | ronald | 2008-10-27 07:38:27 -0500 (Mon, 27 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverFactory.java
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java
+
+Replaced wildcard imports with explicit ones, made some code formatting fixes,
+and made loggers final.
+------------------------------------------------------------------------
+r1362 | ronald | 2008-10-23 08:42:39 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java
+
+Handle RMFAIL and NOTA correctly in forget().
+------------------------------------------------------------------------
+r1361 | ronald | 2008-10-23 08:13:06 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ A /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/SessionCache.java
+
+Added caching of Session's and their factories across transactions.
+------------------------------------------------------------------------
+r1360 | ronald | 2008-10-23 08:13:00 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+
+Handle null server-uri (such as whenever mulgara is not started using the
+EmbeddedMulgaraServer).
+------------------------------------------------------------------------
+r1359 | ronald | 2008-10-23 08:12:54 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/ShortGlobalStatementSet.java
+
+Fixed array population (List.set() cannot be used to insert new values, only
+to replace existing ones).
+------------------------------------------------------------------------
+r1358 | ronald | 2008-10-23 08:12:48 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/ShortGlobalStatementSet.java
+
+Removed trailing spaces.
+------------------------------------------------------------------------
+r1357 | ronald | 2008-10-23 08:12:41 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+ A /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java
+ A /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResourceUnitTest.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ A /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/TransactionCoordinator.java
+
+Added transaction suport to the distributed resolver. The main chunk of this is
+an XAResource capable of forwarding to a list of other XAResource's.
+------------------------------------------------------------------------
+r1356 | ronald | 2008-10-23 08:12:35 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Made the XidWrapper implement Xid.
+------------------------------------------------------------------------
+r1355 | ronald | 2008-10-23 08:12:28 -0500 (Thu, 23 Oct 2008) | 3 lines
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+ M /trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryXAResource.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+ M /trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreXAResource.java
+
+Changed TxInfo creation for AbstractXAResource to be a bit cleaner: subclasses
+must now implement an appropriate factory method rather than passing in a
+pre-constructed instance. This allows reuse of the XAResource instance.
+------------------------------------------------------------------------
+r1354 | ronald | 2008-10-23 08:12:18 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
+ M /trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransaction.java
+
+According to Table 1 in the JTA spec we can end(TMFAIL/TMSUCCESS) a suspended
+resource, so no need to resume it first.
+------------------------------------------------------------------------
+r1353 | ronald | 2008-10-23 08:12:11 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Always chain underlying exception to new exceptions.
+------------------------------------------------------------------------
+r1352 | ronald | 2008-10-23 08:12:05 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Minor restructuring of if and try blocks.
+------------------------------------------------------------------------
+r1351 | ronald | 2008-10-23 08:11:59 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Factored out transaction cleanup; this also now provides a nice hook for
+subclasses to do their cleanup in.
+------------------------------------------------------------------------
+r1350 | ronald | 2008-10-23 08:11:53 -0500 (Thu, 23 Oct 2008) | 4 lines
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Let the transaction-manager handle rolling back:
+ * cleaned out rollback flag and associated rollback calls
+ * don't explicitly roll back on a failed prepare(); this also fixes the
+ problem of rollback being invoked even when prepare threw a XA_RB
+------------------------------------------------------------------------
+r1349 | ronald | 2008-10-23 08:11:47 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Factored out exception handling for start() and end(), and fixed handling to
+only remove transaction if the exception warrants it.
+------------------------------------------------------------------------
+r1348 | ronald | 2008-10-23 08:11:42 -0500 (Thu, 23 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java
+
+Moved the isHeuristic() helper into DummyXAResource, added isRollback(), and
+made them public and a bit more generic.
+------------------------------------------------------------------------
+r1347 | ronald | 2008-10-23 08:11:35 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Minor formatting fix: removed extra whitespace.
+------------------------------------------------------------------------
+r1346 | ronald | 2008-10-23 08:11:28 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+
+Factored out common transaction-lookup code.
+------------------------------------------------------------------------
+r1345 | ronald | 2008-10-23 08:11:22 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
+ M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java
+
+Format the xid consistently in the logs.
+------------------------------------------------------------------------
+r1344 | ronald | 2008-10-23 08:11:16 -0500 (Thu, 23 Oct 2008) | 4 lines
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/Delegator.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
+
+Fix closing of sessions and plug memory leak. The remote sessions and their
+factories are now closed at the end of every transaction, instead of at the
+time the resolver-factory is closed (which usually isn't until mulgara is
+shut down).
+------------------------------------------------------------------------
+r1343 | ronald | 2008-10-23 08:11:09 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+
+Simplify building of set of supported protocols.
+------------------------------------------------------------------------
+r1342 | ronald | 2008-10-23 08:11:01 -0500 (Thu, 23 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolverFactory.java
+
+Minor cleanups: explicit imports, correct bracing, remove trailing whitespace.
+------------------------------------------------------------------------
+r1341 | ronald | 2008-10-21 19:28:00 -0500 (Tue, 21 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/descriptor/src/java/org/mulgara/descriptor/PIErrorHandler.java
+
+Get rid of warning message (varargs related).
+------------------------------------------------------------------------
+r1340 | ronald | 2008-10-21 19:27:54 -0500 (Tue, 21 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk/src/jar/util/java/org/mulgara/util/conversion/html/HTMLParser.jj
+
+Removed obsolete option which was causing a warning. Should've been part of
+r1215.
+------------------------------------------------------------------------
+r1339 | ronald | 2008-10-21 19:27:48 -0500 (Tue, 21 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
+
+Fixed copy-paste error in test.
+------------------------------------------------------------------------
Modified: branches/xa11/common.properties
===================================================================
--- branches/xa11/common.properties 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/common.properties 2009-01-10 08:23:29 UTC (rev 1427)
@@ -5,7 +5,7 @@
# Product properties
project =mulgara
description =Mulgara Semantic Store
-mulgara-version=2.0.6
+mulgara-version=2.0.7-xa11
year =2001-2008
default.build.label=${description} Version ${mulgara-version} (Build @@build@@)
Modified: branches/xa11/src/jar/ant-task/java/org/mulgara/ant/task/rdf/RDFLoadUnitTest.java
===================================================================
--- branches/xa11/src/jar/ant-task/java/org/mulgara/ant/task/rdf/RDFLoadUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/ant-task/java/org/mulgara/ant/task/rdf/RDFLoadUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -278,7 +278,7 @@
answer.beforeFirst();
if (answer.isUnconstrained() || !answer.next()) {
- fail("Model was not created!");
+ fail("Graph was not created!");
}
assertEquals("Query should not return multiple answers", list.size(), 1);
answer.close();
@@ -297,7 +297,7 @@
answer.beforeFirst();
if (answer.next()) {
- fail("Model was not dropped!");
+ fail("Graph was not dropped!");
}
assertEquals("Query should not return multiple answers", list.size(), 1);
answer.close();
@@ -307,7 +307,7 @@
try {
load.createModel();
- fail("Model creation should have failed");
+ fail("Graph creation should have failed");
} catch (BuildException be) {
}
@@ -317,7 +317,7 @@
try {
load.interpreter = null;
load.execute();
- fail("Model creation should have failed");
+ fail("Graph creation should have failed");
} catch (BuildException be) {
}
}
Modified: branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/ItqlGraphProxy.java
===================================================================
--- branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/ItqlGraphProxy.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/ItqlGraphProxy.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -112,7 +112,7 @@
if (modelURI == null) {
- throw new GraphException("Model URI cannot be null.");
+ throw new GraphException("Graph URI cannot be null.");
}
//initialize members
Modified: branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/SessionGraphProxy.java
===================================================================
--- branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/SessionGraphProxy.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/itql/SessionGraphProxy.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -111,7 +111,7 @@
if (modelURI == null) {
- throw new GraphException("Model URI cannot be null.");
+ throw new GraphException("Graph URI cannot be null.");
}
//initialize members
Modified: branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/RemoteAnswerCloneUnitTest.java
===================================================================
--- branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/RemoteAnswerCloneUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/RemoteAnswerCloneUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -27,18 +27,15 @@
package org.mulgara.client.jrdf.test;
-import java.io.*;
import org.jrdf.graph.*;
-import org.jrdf.vocabulary.*;
+import org.jrdf.graph.Graph;
// Third party packages
import junit.framework.*;
import java.net.*;
import java.util.*;
-import org.jrdf.graph.mem.*;
import org.mulgara.client.jrdf.*;
-import org.mulgara.jrdf.*;
import org.mulgara.query.*;
import org.mulgara.query.rdf.LiteralImpl;
import org.mulgara.query.rdf.TripleImpl;
@@ -109,11 +106,11 @@
public Graph newGraph() throws Exception {
//reset graph
- this.dropModel(this.modelURI);
- this.createModel(this.modelURI);
+ dropModel(modelURI);
+ createModel(modelURI);
//create and return graph
- return AbstractGraphFactory.createGraph(this.serverURI, this.modelURI);
+ return AbstractGraphFactory.createGraph(serverURI, modelURI);
}
/**
@@ -151,40 +148,40 @@
try {
//test answer with entire graph
- Answer answer = this.session.find(this.modelURI, null, null, null);
- this.testClone(answer);
+ Answer answer = session.find(modelURI, null, null, null);
+ testClone(answer);
//test constrained answers
- Answer constrainedS = this.session.find(this.modelURI, this.reference1,
+ Answer constrainedS = session.find(modelURI, reference1,
null, null);
- this.testClone(constrainedS);
+ testClone(constrainedS);
- Answer constrainedP = this.session.find(this.modelURI, null,
- this.reference1, null);
- this.testClone(constrainedP);
+ Answer constrainedP = session.find(modelURI, null,
+ reference1, null);
+ testClone(constrainedP);
- Triple constrainedTripleO = new TripleImpl(null, null, this.reference1);
- Answer constrainedO = this.session.find(this.modelURI,
+ Triple constrainedTripleO = new TripleImpl(null, null, reference1);
+ Answer constrainedO = session.find(modelURI,
constrainedTripleO.getSubject(), constrainedTripleO.getPredicate(),
constrainedTripleO.getObject());
- this.testClone(constrainedO);
+ testClone(constrainedO);
- Answer constrainedSP = this.session.find(this.modelURI, this.reference1,
- this.reference1, null);
- this.testClone(constrainedSP);
+ Answer constrainedSP = session.find(modelURI, reference1,
+ reference1, null);
+ testClone(constrainedSP);
- Answer constrainedPO = this.session.find(this.modelURI, null,
- this.reference1, this.reference1);
- this.testClone(constrainedPO);
+ Answer constrainedPO = session.find(modelURI, null,
+ reference1, reference1);
+ testClone(constrainedPO);
- Answer constrainedOS = this.session.find(this.modelURI, this.reference1,
- null, this.reference1);
- this.testClone(constrainedOS);
+ Answer constrainedOS = session.find(modelURI, reference1,
+ null, reference1);
+ testClone(constrainedOS);
//test unconstrained answer
- Answer unconstrained = this.session.find(this.modelURI, this.reference1,
- this.reference1, this.reference1);
- this.testClone(unconstrained);
+ Answer unconstrained = session.find(modelURI, reference1,
+ reference1, reference1);
+ testClone(unconstrained);
} catch (Exception exception) {
exception.printStackTrace();
@@ -244,38 +241,38 @@
try {
//test answer with entire graph
- Answer answer = this.session.find(this.modelURI, null, null, null);
- this.testCloneOfClones(answer);
+ Answer answer = session.find(modelURI, null, null, null);
+ testCloneOfClones(answer);
//test constrained answers
- Answer constrainedS = this.session.find(this.modelURI, this.reference1,
+ Answer constrainedS = session.find(modelURI, reference1,
null, null);
- this.testCloneOfClones(constrainedS);
+ testCloneOfClones(constrainedS);
- Answer constrainedP = this.session.find(this.modelURI, null,
- this.reference1, null);
- this.testCloneOfClones(constrainedP);
+ Answer constrainedP = session.find(modelURI, null,
+ reference1, null);
+ testCloneOfClones(constrainedP);
- Answer constrainedO = this.session.find(this.modelURI, null, null,
- this.reference1);
- this.testCloneOfClones(constrainedO);
+ Answer constrainedO = session.find(modelURI, null, null,
+ reference1);
+ testCloneOfClones(constrainedO);
- Answer constrainedSP = this.session.find(this.modelURI, this.reference1,
- this.reference1, null);
- this.testCloneOfClones(constrainedSP);
+ Answer constrainedSP = session.find(modelURI, reference1,
+ reference1, null);
+ testCloneOfClones(constrainedSP);
- Answer constrainedPO = this.session.find(this.modelURI, null,
- this.reference1, this.reference1);
- this.testCloneOfClones(constrainedPO);
+ Answer constrainedPO = session.find(modelURI, null,
+ reference1, reference1);
+ testCloneOfClones(constrainedPO);
- Answer constrainedOS = this.session.find(this.modelURI, this.reference1,
- null, this.reference1);
- this.testCloneOfClones(constrainedOS);
+ Answer constrainedOS = session.find(modelURI, reference1,
+ null, reference1);
+ testCloneOfClones(constrainedOS);
//test unconstrained answer
- Answer unconstrained = this.session.find(this.modelURI, this.reference1,
- this.reference1, this.reference1);
- this.testCloneOfClones(unconstrained);
+ Answer unconstrained = session.find(modelURI, reference1,
+ reference1, reference1);
+ testCloneOfClones(unconstrained);
} catch (Exception exception) {
exception.printStackTrace();
@@ -297,10 +294,10 @@
Answer answerCloneCloneClone = (Answer) answerCloneClone.clone();
//test each level (also closes)
- this.testClone(original);
- this.testClone(answerClone);
- this.testClone(answerCloneClone);
- this.testClone(answerCloneCloneClone);
+ testClone(original);
+ testClone(answerClone);
+ testClone(answerCloneClone);
+ testClone(answerCloneCloneClone);
}
/**
@@ -310,7 +307,7 @@
*/
private void populate() throws Exception {
- Set triples = new HashSet();
+ Set<Triple> triples = new HashSet<Triple>();
//create triples that can be searched for
triples.add(new TripleImpl(reference1, reference1, literal));
@@ -342,7 +339,7 @@
}
//insert
- this.session.insert(this.modelURI, triples);
+ session.insert(modelURI, triples);
}
@@ -359,35 +356,31 @@
try {
String hostname = InetAddress.getLocalHost().getCanonicalHostName();
- this.serverURI = new URI("rmi", hostname, "/" + SERVER_NAME, null);
- this.modelURI = new URI("rmi", hostname, "/" + SERVER_NAME, MODEL_NAME);
+ serverURI = new URI("rmi", hostname, "/" + SERVER_NAME, null);
+ modelURI = new URI("rmi", hostname, "/" + SERVER_NAME, MODEL_NAME);
//get session
SessionFactory sessionFactory = SessionFactoryFinder.newSessionFactory(
- this.serverURI, true);
- this.session = (JRDFSession) sessionFactory.newJRDFSession();
+ serverURI, true);
+ session = (JRDFSession) sessionFactory.newJRDFSession();
//create test triples
- this.reference1 = new URIReferenceImpl(new URI("http://mulgara.org/mulgara#testReference"));
- this.reference2 = new URIReferenceImpl(new URI("http://mulgara.org/mulgara#testReference2"));
- this.literal = new LiteralImpl("test Literal");
+ reference1 = new URIReferenceImpl(new URI("http://mulgara.org/mulgara#testReference"));
+ reference2 = new URIReferenceImpl(new URI("http://mulgara.org/mulgara#testReference2"));
+ literal = new LiteralImpl("test Literal");
//initialize model
- this.createModel(this.modelURI);
- this.populate();
+ createModel(modelURI);
+ populate();
//let superclass set up too
super.setUp();
- }
- catch (Exception exception) {
+ } catch (Exception exception) {
//try to tear down first
try {
-
tearDown();
- }
- finally {
-
+ } catch (Throwable t) {
throw exception;
}
}
@@ -400,7 +393,7 @@
*/
public void tearDown() throws Exception {
- this.dropModel(this.modelURI);
+ dropModel(modelURI);
//allow super to close down too
super.tearDown();
@@ -414,7 +407,7 @@
*/
private void createModel(URI modelURI) throws Exception {
- this.session.createModel(modelURI, new URI("http://mulgara.org/mulgara#Model"));
+ session.createModel(modelURI, new URI("http://mulgara.org/mulgara#Model"));
}
/**
@@ -425,6 +418,6 @@
*/
private void dropModel(URI modelURI) throws Exception {
- this.session.removeModel(modelURI);
+ session.removeModel(modelURI);
}
}
Modified: branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer/MemoryXMLWriter.java
===================================================================
--- branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer/MemoryXMLWriter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/client-jrdf/java/org/mulgara/client/jrdf/writer/MemoryXMLWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -42,7 +42,7 @@
import org.jrdf.graph.GraphException;
import org.jrdf.util.ClosableIterator;
import org.jrdf.graph.*;
-//import org.mulgara.store.exporter.ModelXMLWriter;
+//import org.mulgara.store.exporter.GraphXMLWriter;
import org.mulgara.client.jrdf.util.*;
import org.mulgara.util.StringUtil;
@@ -116,7 +116,7 @@
}
catch (IOException ioException) {
- throw new GraphException("Could not write Model.", ioException);
+ throw new GraphException("Could not write Graph.", ioException);
}
}
@@ -147,7 +147,7 @@
}
catch (IOException ioException) {
- throw new GraphException("Could not write Model.", ioException);
+ throw new GraphException("Could not write Graph.", ioException);
}
}
@@ -313,7 +313,7 @@
}
/**
- * Writes the Model's statements as RDF/XML to the print Writer.
+ * Writes the Graph's statements as RDF/XML to the print Writer.
*
* @param graph Graph
* @param out PrintWriter
@@ -360,7 +360,7 @@
else {
//message for exception to be thrown
- String message = "Could not write Model. Invlaid arguments provided. ";
+ String message = "Could not write Graph. Invlaid arguments provided. ";
if (out == null) {
Property changes on: branches/xa11/src/jar/content-mbox/java/org/mulgara/content/mbox/parser/model/ModelFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: branches/xa11/src/jar/content-mp3/java/org/mulgara/content/mp3/parser/ID3ParsersUnitTest.java
===================================================================
--- branches/xa11/src/jar/content-mp3/java/org/mulgara/content/mp3/parser/ID3ParsersUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/content-mp3/java/org/mulgara/content/mp3/parser/ID3ParsersUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -326,7 +326,7 @@
// Obtain the next triple
Triple triple = (Triple) iterator.next();
- log.debug(">> Model triple [" + triple.getSubject() +
+ log.debug(">> Graph triple [" + triple.getSubject() +
", " + triple.getPredicate() + ", " +
triple.getObject() + "]");
}
@@ -567,7 +567,7 @@
// Get the next triple
Triple triple = (Triple) iterator.next();
- System.err.println(">> Model triple [" + triple.getSubject() + ", " +
+ System.err.println(">> Graph triple [" + triple.getSubject() + ", " +
triple.getPredicate() + ", " + triple.getObject() + "]");
}
} catch (GraphException graphException) {
Modified: branches/xa11/src/jar/content-n3/java/org/mulgara/content/n3/Parser.java
===================================================================
--- branches/xa11/src/jar/content-n3/java/org/mulgara/content/n3/Parser.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/content-n3/java/org/mulgara/content/n3/Parser.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -49,6 +49,7 @@
import org.jrdf.graph.SubjectNode;
import org.jrdf.graph.Triple;
import org.jrdf.graph.URIReference;
+import org.jrdf.vocabulary.RDF;
// Locally written packages
import org.mulgara.content.Content;
@@ -393,6 +394,8 @@
}
case N3Parser.URIREF:
return toURIReference(ast.toString());
+ case N3Parser.KW_A:
+ return toURIReference(RDF.TYPE);
default:
throw new Error("Unsupported N3 parser token type: " + ast.getType());
}
@@ -406,6 +409,10 @@
}
}
+ private URIReference toURIReference(URI u) {
+ return new URIReferenceImpl(u);
+ }
+
/**
* Tests if a node is anonymous.
*
Modified: branches/xa11/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java
===================================================================
--- branches/xa11/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -330,7 +330,7 @@
}
/**
- * Writes the Model's statements as RDF/XML to the print Writer.
+ * Writes the Graph's statements as RDF/XML to the print Writer.
*
* @param statements Statements
* @param session ResolverSession
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/AbstractModel.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/AbstractModel.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/AbstractModel.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -54,7 +54,7 @@
import java.net.URLEncoder;
/**
- * Base class for Model.
+ * Base class for Graph.
*
* @created 2004-12-03
*
@@ -93,13 +93,13 @@
/** Used to perform queries */
private ItqlInterpreterBean bean = null;
- /** The Resource that the Model represents */
+ /** The Resource that the Graph represents */
private URIReference resource = null;
- /** Used to determine if the Model has been initialized */
+ /** Used to determine if the Graph has been initialized */
private boolean initialized = false;
- /** Type of the Model */
+ /** Type of the Graph */
private URIReference type = null;
/**
@@ -140,7 +140,7 @@
}
/**
- * Sets the Model's type.
+ * Sets the Graph's type.
* @param model URIReference
*/
public void setType(URIReference type) {
@@ -148,7 +148,7 @@
}
/**
- * Returns the Resource URI that represents the Model's type.
+ * Returns the Resource URI that represents the Graph's type.
* @return URIReference
*/
public URIReference getType() {
@@ -178,7 +178,7 @@
}
/**
- * Creates the Model with the specified type, or the default Model type if
+ * Creates the Graph with the specified type, or the default Graph type if
* 'type' null.
*
* @param type URIReference
@@ -187,7 +187,7 @@
public void create() throws QueryException {
checkInitialized();
try {
- String typeURI = (type == null) ? Mulgara.NAMESPACE + "Model" :
+ String typeURI = (type == null) ? Mulgara.NAMESPACE + "Graph" :
type.getURI().toString();
getBean().executeUpdate("create <" + getResource().getURI() + "> " +
"<" + typeURI + "> ;");
@@ -214,7 +214,7 @@
}
/**
- * Drops the Model and then re-creates it.
+ * Drops the Graph and then re-creates it.
*
* @throws QueryException
*/
@@ -291,7 +291,7 @@
}
/**
- * Throw an Exception if the Model has not been initialized.
+ * Throw an Exception if the Graph has not been initialized.
* @throws IllegalStateException
*/
protected void checkInitialized() throws IllegalStateException {
@@ -300,7 +300,7 @@
initialized = true;
}
else {
- throw new IllegalStateException("Model has not been Initialized.");
+ throw new IllegalStateException("Graph has not been Initialized.");
}
}
}
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/FileSystemModelImpl.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/FileSystemModelImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/FileSystemModelImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -248,7 +248,7 @@
}
/**
- * Returns a Resource representing the Definition Model Resource
+ * Returns a Resource representing the Definition Graph Resource
*
* @return URIReference
* @throws URISyntaxException
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -39,7 +39,7 @@
import org.jrdf.util.*;
/**
- * Generic methods for Model management.
+ * Generic methods for Graph management.
*
* @created 2004-12-03
*
@@ -61,7 +61,7 @@
public interface Model {
/**
- * Initializes the Model.
+ * Initializes the Graph.
*
* @param context ModelContext
* @throws Exception
@@ -81,13 +81,13 @@
public URIReference getResource();
/**
- * Sets the Model's type.
+ * Sets the Graph's type.
* @param model URIReference
*/
public void setType(URIReference type);
/**
- * Returns the Resource URI that represents the Model's type.
+ * Returns the Resource URI that represents the Graph's type.
* @return URIReference
*/
public URIReference getType();
@@ -116,7 +116,7 @@
public ClosableIterator query(String query) throws Exception;
/**
- * Creates the Model with the type set by setType(), or the default Model
+ * Creates the Graph with the type set by setType(), or the default Graph
* type if 'type' null (or not set).
* @throws QueryException
*/
@@ -130,7 +130,7 @@
public void delete() throws QueryException;
/**
- * Deletes all statements in the Model.
+ * Deletes all statements in the Graph.
*
* @throws QueryException
*/
@@ -142,7 +142,7 @@
public void close();
/**
- * Returns true if the Model has been initialized.
+ * Returns true if the Graph has been initialized.
* @return boolean
*/
public boolean hasInitialized();
Property changes on: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Model.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ControllerImpl.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ControllerImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ControllerImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -86,13 +86,13 @@
/** Where the fsModel stores it's information */
private URIReference fsModelResource = null;
- /** Type of Model to store Mp3s information */
+ /** Type of Graph to store Mp3s information */
private URIReference mp3ModelType = null;
- /** Type of Model to store Schema information */
+ /** Type of Graph to store Schema information */
private URIReference schemaModelType = null;
- /** Type of Model to store FileSystem information */
+ /** Type of Graph to store FileSystem information */
private URIReference fsModelType = null;
/** Returned by getMp3Model */
@@ -213,8 +213,8 @@
}
/**
- * Closes the Model
- * @param model Model
+ * Closes the Graph
+ * @param model Graph
*/
private void close(Model model) {
if (model != null) {
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3FileImpl.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3FileImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3FileImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -77,10 +77,10 @@
/** Used to execute iTQL queries */
private ItqlInterpreterBean bean = null;
- /** Model where the Mp3 metadata is stored */
+ /** Graph where the Mp3 metadata is stored */
private Mp3Model model = null;
- /** Model where schema information is stored */
+ /** Graph where schema information is stored */
private SchemaModel schemaModel = null;
/** Used to determine if this Mp3 is ready first use. */
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3Model.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3Model.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3Model.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -79,7 +79,7 @@
QueryException, IllegalArgumentException;
/**
- * Sets the Model used to store Schema Information.
+ * Sets the Graph used to store Schema Information.
* @param schemaModel SchemaModel
* @throws IllegalArgumentException
*/
@@ -87,7 +87,7 @@
IllegalArgumentException;
/**
- * Returns the Model used to store Schema Information.
+ * Returns the Graph used to store Schema Information.
* @return SchemaModel
*/
public SchemaModel getSchemaModel();
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ModelImpl.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ModelImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/Mp3ModelImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -75,7 +75,7 @@
/** Listener used to notify caller of events */
private Mp3ModelListener listener = null;
- /** Model where Schema information is stored */
+ /** Graph where Schema information is stored */
private SchemaModel schemaModel = null;
/**
@@ -119,7 +119,7 @@
}
/**
- * Sets the Model used to store Schema Information.
+ * Sets the Graph used to store Schema Information.
*
* @param schemaModel
* SchemaModel
@@ -134,7 +134,7 @@
}
/**
- * Returns the Model used to store Schema Information.
+ * Returns the Graph used to store Schema Information.
*
* @return SchemaModel
*/
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModel.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModel.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModel.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -37,7 +37,7 @@
import org.mulgara.query.QueryException;
/**
- * Represents a Model containg RDF schema statements.
+ * Represents a Graph containg RDF schema statements.
*
* @created 2004-12-03
*
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModelImpl.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModelImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/SchemaModelImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,7 +41,7 @@
import org.mulgara.query.QueryException;
/**
- * Represents a Model containg RDF schema statements.
+ * Represents a Graph containg RDF schema statements.
*
* @created 2004-12-03
*
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3/AbstractId3Tag.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3/AbstractId3Tag.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/id3/AbstractId3Tag.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -81,10 +81,10 @@
/** Used to perform queries */
private ItqlInterpreterBean bean = null;
- /** Model containing the Mp3 instance data */
+ /** Graph containing the Mp3 instance data */
private Mp3Model model = null;
- /** Model containing Schema information */
+ /** Graph containing Schema information */
private SchemaModel schemaModel = null;
/** Mp3File that this Tag represents. */
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions/ClearMp3ModelAction.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions/ClearMp3ModelAction.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/actions/ClearMp3ModelAction.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -86,7 +86,7 @@
Mp3Controller controller = getMp3Controller();
Mp3Model mp3Model = controller.getMp3Model();
if (confirmClear(mp3Model.getResource())) {
- getStatusPanel().startProcessing("Clearing Mp3 Model...");
+ getStatusPanel().startProcessing("Clearing Mp3 Graph...");
mp3Model.clear();
//underlying model/data has changed
getSearchPanel().constraintsHaveChanged();
@@ -95,7 +95,7 @@
}
catch (Exception exception) {
getStatusPanel().stopProcessingError("Error(s) occurred while clearing " +
- "Mp3 Model");
+ "Mp3 Graph");
ExceptionHandler.handleException(exception);
}
}
@@ -109,7 +109,7 @@
*/
private boolean confirmClear(URIReference model) {
String message = "Are you sure you want to delete all statements from " +
- NEWLINE + "the following Model: " + NEWLINE + model + "?";
+ NEWLINE + "the following Graph: " + NEWLINE + model + "?";
int decision = JOptionPane.showConfirmDialog(super.getSearchPanel(), message,
"Confirm Clear Mp3 Metadata", JOptionPane.YES_NO_OPTION);
//was 'Yes' chosen
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results/Mp3List.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results/Mp3List.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/results/Mp3List.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -68,7 +68,7 @@
*/
private final static Logger log = Logger.getLogger(Mp3List.class.getName());
- /** Model used to store list items */
+ /** Graph used to store list items */
private DefaultListModel model = null;
/** Renders the Mp3Files */
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search/BrowserPanel.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search/BrowserPanel.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/search/BrowserPanel.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -297,7 +297,7 @@
}
/**
- * Registers the Constraint Listener with the Model.
+ * Registers the Constraint Listener with the Graph.
* @param listener ConstraintListener
* @throws IllegalArgumentException
*/
Modified: branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets/PropertiesTable.java
===================================================================
--- branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets/PropertiesTable.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/widgets/PropertiesTable.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -137,7 +137,7 @@
}
/**
- * Returns the Model to be used to modify Table.
+ * Returns the Graph to be used to modify Table.
* @return DefaultTableModel
*/
private DefaultTableModel getTableModel() {
Modified: branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DeployServlet.java
===================================================================
--- branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DeployServlet.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DeployServlet.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -449,7 +449,7 @@
if (clearLocalDescriptors) {
query.append(
- "# create,drop,create avoids Model not found exceptions" + eol);
+ "# create,drop,create avoids Graph not found exceptions" + eol);
query.append("create <" + modelURIString + ">;" + eol);
query.append("drop <" + modelURIString + ">;" + eol);
query.append("create <" + modelURIString + ">;" + eol);
Modified: branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/Descriptor.java
===================================================================
--- branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/Descriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/Descriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -295,9 +295,9 @@
/**
- * Get the descriptor Model URI
+ * Get the descriptor Graph URI
*
- * @return the Descriptor Model URI as a string;
+ * @return the Descriptor Graph URI as a string;
*/
public static String getModelURIString() {
return ServerInfo.getServerURI() + "#" + DEFAULT_DESCRIPTOR_MODEL;
@@ -935,12 +935,12 @@
if (log.isDebugEnabled()) {
- log.debug("Using descriptor Model URI is : " + descriptorModelURI);
+ log.debug("Using descriptor Graph URI is : " + descriptorModelURI);
}
}
catch (URISyntaxException use) {
- throw new DescriptorException("Descriptor Model URI: " +
+ throw new DescriptorException("Descriptor Graph URI: " +
descriptorModelString +
" is not a valid URI", use);
}
Modified: branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DescriptorElement.java
===================================================================
--- branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DescriptorElement.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/descriptor/src/java/org/mulgara/descriptor/DescriptorElement.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -241,7 +241,7 @@
String errorString = "Could not find parameters for (" +
descURL +
- ") RDF is probably not loaded into the Descriptor Model";
+ ") RDF is probably not loaded into the Descriptor Graph";
log.error(errorString);
throw new DescriptorException(errorString);
}
Modified: branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraph.java
===================================================================
--- branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraph.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraph.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -36,6 +36,7 @@
// JRDF
import org.jrdf.graph.*;
+import org.jrdf.graph.Graph;
import org.jrdf.util.ClosableIterator;
// Locally written packages
@@ -45,7 +46,7 @@
/**
* A {@link org.jrdf.graph.Graph} contained within this database. Represents a
- * Model/Resolver via an URI and a Session.
+ * Graph/Resolver via an URI and a Session.
*
* @created 2004-10-12
*
@@ -78,7 +79,7 @@
private LocalJRDFSession session = null;
/**
- * Model URI.
+ * Graph URI.
*/
private URI graphURI = null;
Modified: branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraphUnitTest.java
===================================================================
--- branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraphUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/jrdf/java/org/mulgara/jrdf/JRDFGraphUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -111,8 +111,8 @@
}
//reset model
- this.dropModel(this.modelURI);
- this.createModel(this.modelURI);
+ this.dropModel(modelURI);
+ this.createModel(modelURI);
//create and return graph
graph = new JRDFGraph(session, modelURI);
@@ -246,19 +246,18 @@
try {
String hostname = InetAddress.getLocalHost().getCanonicalHostName();
- this.serverURI = new URI("rmi", hostname, "/" + SERVER_NAME, null);
- this.modelURI = new URI("rmi", hostname, "/" + SERVER_NAME, MODEL_NAME);
+ serverURI = new URI("rmi", hostname, "/" + SERVER_NAME, null);
+ modelURI = new URI("rmi", hostname, "/" + SERVER_NAME, MODEL_NAME);
SessionFactory sessionFactory = SessionFactoryFinder.newSessionFactory(serverURI, false);
this.session = (LocalJRDFSession) sessionFactory.newJRDFSession();
//initialize model
- this.createModel(this.modelURI);
+ this.createModel(modelURI);
//let superclass set up too
super.setUp();
- }
- catch (Exception exception) {
+ } catch (Exception exception) {
exception.printStackTrace();
@@ -266,11 +265,11 @@
try {
tearDown();
+ } catch (Throwable t) {
+ logger.error("Encountered exception in exception handler. Ignoring.", t);
}
- finally {
- throw exception;
- }
+ throw exception;
}
}
@@ -281,7 +280,7 @@
*/
public void tearDown() throws Exception {
- this.dropModel(this.modelURI);
+ this.dropModel(modelURI);
//close the graph
if (graph != null) {
Modified: branches/xa11/src/jar/krule/java/org/mulgara/krule/KruleLoader.java
===================================================================
--- branches/xa11/src/jar/krule/java/org/mulgara/krule/KruleLoader.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/krule/java/org/mulgara/krule/KruleLoader.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -227,11 +227,11 @@
rules = null;
try {
- logger.debug("Initializing for rule queries.");
+ if (logger.isDebugEnabled()) logger.debug("Initializing for rule queries.");
// load the objects
loadRdfObjects();
- logger.debug("Querying for rules");
+ if (logger.isDebugEnabled()) logger.debug("Querying for rules");
rules = findRules();
// set the target model
rules.setTargetModel(destModel);
@@ -273,21 +273,21 @@
private void loadRdfObjects() throws QueryException, TuplesException, InitializerException, KruleStructureException {
// get all the URIReferences
findUriReferences();
- logger.debug("Got URI References");
+ if (logger.isDebugEnabled()) logger.debug("Got URI References");
findVarReferences();
- logger.debug("Got Variable references");
+ if (logger.isDebugEnabled()) logger.debug("Got Variable references");
findLiteralReferences();
- logger.debug("Got Literal references");
+ if (logger.isDebugEnabled()) logger.debug("Got Literal references");
// pre-load all constraints
loadSimpleConstraints();
- logger.debug("Got simple constraints");
+ if (logger.isDebugEnabled()) logger.debug("Got simple constraints");
loadTransitiveConstraints();
- logger.debug("Got transitive constraints");
+ if (logger.isDebugEnabled()) logger.debug("Got transitive constraints");
loadJoinConstraints();
- logger.debug("Got join constraints");
+ if (logger.isDebugEnabled()) logger.debug("Got join constraints");
loadHavingConstraints();
- logger.debug("Got having constraints");
+ if (logger.isDebugEnabled()) logger.debug("Got having constraints");
}
@@ -304,11 +304,11 @@
// find all of the rules
query = interpreter.parseQuery("select $rule from <" + ruleModel + "> where $rule <rdf:type> <krule:Rule> ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query attempted while finding rules.", e);
}
Answer ruleAnswer = query(query);
- logger.debug("Got response for rule query");
+ if (logger.isDebugEnabled()) logger.debug("Got response for rule query");
// create the rule structure for all the rules
RuleStructure rules = new RuleStructure();
@@ -322,7 +322,7 @@
} finally {
ruleAnswer.close();
}
- logger.debug("Created rules" + rules.toString());
+ if (logger.isDebugEnabled()) logger.debug("Created rules" + rules.toString());
return rules;
}
@@ -339,7 +339,7 @@
try {
query = interpreter.parseQuery("select $src $dest from <" + ruleModel + "> where $src <krule:triggers> $dest ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while finding triggers.", e);
}
Answer answer = query(query);
@@ -349,7 +349,7 @@
while (answer.next()) {
String src = answer.getObject(0).toString();
String dest = answer.getObject(1).toString();
- logger.debug("Linking <" + src + "> -> <" + dest + ">");
+ if (logger.isDebugEnabled()) logger.debug("Linking <" + src + "> -> <" + dest + ">");
rules.setTrigger(src, dest);
}
} finally {
@@ -368,13 +368,13 @@
* @throws InitializerException When there is an intialization error.
*/
private void loadQueries() throws TuplesException, QueryException, KruleStructureException, InitializerException {
- logger.debug("Loading Queries");
+ if (logger.isDebugEnabled()) logger.debug("Loading Queries");
// go through the rules to set their queries
Iterator<Rule> ri = rules.getRuleIterator();
while (ri.hasNext()) {
Rule rule = ri.next();
- logger.debug("Reading query for rule: " + rule.getName());
+ if (logger.isDebugEnabled()) logger.debug("Reading query for rule: " + rule.getName());
Query query;
try {
// get the query data for this rule
@@ -383,7 +383,7 @@
" $vs $pre $v and $pre <mulgara:prefix> <rdf:_> in <"+ PREFIX_GRAPH +
"> and $v <rdf:type> $t ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while getting rule queries.", e);
}
Answer answer = query(query);
@@ -394,17 +394,17 @@
URIReference[] types = new URIReference[3];
try {
while (answer.next()) {
- logger.debug("Getting element from " + answer.getObject(0));
+ if (logger.isDebugEnabled()) logger.debug("Getting element from " + answer.getObject(0));
// work out the position of the element. Subject=0 Predicate=1 Object=2
int seqNr = Integer.parseInt(answer.getObject(0).toString().substring(prefixLength)) - 1;
- logger.debug("parsed: " + seqNr);
+ if (logger.isDebugEnabled()) logger.debug("parsed: " + seqNr);
if (seqNr > elements.length) {
- throw new KruleStructureException("Rule " + rule.getName() + " has too many insertion elements");
+ throw new KruleStructureException("Rule " + rule.getName() + " has too many insertion elements. Found sequence number: " + seqNr);
}
// get the selection element and its type
elements[seqNr] = (URIReference)answer.getObject(1);
types[seqNr] = (URIReference)answer.getObject(2);
- logger.debug("Nr: " + seqNr + ", v: " + elements[seqNr] + ", type: " + types[seqNr]);
+ if (logger.isDebugEnabled()) logger.debug("Nr: " + seqNr + ", v: " + elements[seqNr] + ", type: " + types[seqNr]);
}
} finally {
answer.close();
@@ -431,36 +431,32 @@
query = interpreter.parseQuery("select $w from <" + ruleModel +
"> where <" + rule.getName() + "> <krule:hasQuery> $q and $q <krule:hasWhereClause> $w;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query reading WHERE clause for rule: " + rule.getName(), e);
}
answer = query(query);
try {
// attach the correct constraint tree to the query structure
if (answer.next()) {
- logger.debug("Setting where clause for rule: " + rule.getName() + "");
+ if (logger.isDebugEnabled()) logger.debug("Setting where clause for rule: " + rule.getName() + "");
Node whereClauseNode = (Node)answer.getObject(0);
- logger.debug("Where clause is: " + whereClauseNode);
+ if (logger.isDebugEnabled()) logger.debug("Where clause is: " + whereClauseNode);
ConstraintExpression ce = (ConstraintExpression)constraintMap.get(whereClauseNode);
- logger.debug("where clause expression: " + ce);
- if (ce == null) {
- throw new KruleStructureException("Rule " + rule.getName() + " has no where clause");
- }
+ if (logger.isDebugEnabled()) logger.debug("where clause expression: " + ce);
+ if (ce == null) throw new KruleStructureException("Rule " + rule.getName() + " has no where clause");
queryStruct.setWhereClause(ce);
}
- if (answer.next()) {
- throw new KruleStructureException("Rule " + rule.getName() + " has more than one query");
- }
+ if (answer.next()) throw new KruleStructureException("Rule " + rule.getName() + " has more than one query");
} finally {
answer.close();
}
- logger.debug("Setting models for the query");
+ if (logger.isDebugEnabled()) logger.debug("Setting models for the query");
// set the models
queryStruct.setModelExpression(baseModel, destModel);
- logger.debug("Setting query structure for the rule");
+ if (logger.isDebugEnabled()) logger.debug("Setting query structure for the rule");
// create a new query and set it for the rule
rule.setQueryStruct(queryStruct);
}
@@ -477,7 +473,7 @@
* @throws InitializerException When there is an intialization error.
*/
private Set<org.jrdf.graph.Triple> findAxioms() throws TuplesException, QueryException, KruleStructureException, InitializerException {
- logger.debug("Loading Axioms");
+ if (logger.isDebugEnabled()) logger.debug("Loading Axioms");
Query query;
try {
@@ -486,7 +482,7 @@
"> where $axiom <rdf:type> <krule:Axiom> and $axiom <krule:subject> $s" +
" and $axiom <krule:predicate> $p and $axiom <krule:object> $o;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while finding axioms.", e);
}
Answer answer = query(query);
@@ -537,16 +533,13 @@
*/
private Map<String,URI> newAliases() {
aliases = new HashMap<String,URI>();
- try {
- aliases.put("rdf", new URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
- aliases.put("rdfs", new URI("http://www.w3.org/2000/01/rdf-schema#"));
- aliases.put("owl", new URI("http://www.w3.org/2002/07/owl#"));
- aliases.put("mulgara", new URI("http://mulgara.org/mulgara#"));
- aliases.put("krule", new URI("http://mulgara.org/owl/krule/#"));
- } catch (URISyntaxException e) {
- /* get those aliases which we could */
- logger.error("Error defining internal aliases: ", e);
- }
+ aliases.put("rdf", URI.create("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
+ aliases.put("rdfs", URI.create("http://www.w3.org/2000/01/rdf-schema#"));
+ aliases.put("owl", URI.create("http://www.w3.org/2002/07/owl#"));
+ aliases.put("mulgara", URI.create("http://mulgara.org/mulgara#"));
+ aliases.put("krule", URI.create("http://mulgara.org/owl/krule/#"));
+ aliases.put("foaf", URI.create("http://xmlns.com/foaf/0.1/"));
+ aliases.put("skos", URI.create("http://www.w3.org/2004/02/skos/core#"));
return aliases;
}
@@ -559,7 +552,7 @@
* @throws InitializerException There was an error in the method preconditions.
*/
private void findUriReferences() throws TuplesException, QueryException, InitializerException {
- logger.debug("Querying for URI reference objects.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for URI reference objects.");
Query query;
try {
@@ -567,11 +560,11 @@
query = interpreter.parseQuery("select $ref $uri from <" +
ruleModel + "> where $ref <rdf:type> <krule:URIReference> and $ref <rdf:value> $uri ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while looking for URI references.", e);
}
Answer answer = query(query);
- logger.debug("Found all URI references.");
+ if (logger.isDebugEnabled()) logger.debug("Found all URI references.");
// create the mapping
uriReferences = new HashMap<URIReference,URIReference>();
@@ -580,13 +573,13 @@
while (answer.next()) {
URIReference ref = (URIReference)answer.getObject(0);
URIReference uri = (URIReference)answer.getObject(1);
- logger.debug("Mapping <" + ref + "> to <" + uri + ">");
+ if (logger.isDebugEnabled()) logger.debug("Mapping <" + ref + "> to <" + uri + ">");
uriReferences.put(ref, uri);
}
} finally {
answer.close();
}
- logger.debug("Mapped all URI references.");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all URI references.");
}
@@ -598,7 +591,7 @@
* @throws InitializerException There was an error in the method preconditions.
*/
private void findVarReferences() throws TuplesException, QueryException, InitializerException {
- logger.debug("Querying for variable reference objects.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for variable reference objects.");
Query query;
try {
@@ -606,11 +599,11 @@
query = interpreter.parseQuery("select $ref $name from <" +
ruleModel + "> where $ref <rdf:type> <krule:Variable> and $ref <krule:name> $name ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while finding variable references.", e);
}
Answer answer = query(query);
- logger.debug("Found all variable references.");
+ if (logger.isDebugEnabled()) logger.debug("Found all variable references.");
// create the mapping
varReferences = new HashMap<URIReference,Variable>();
@@ -619,13 +612,13 @@
while (answer.next()) {
URIReference ref = (URIReference)answer.getObject(0);
Literal name = (Literal)answer.getObject(1);
- logger.debug("Mapping <" + ref + "> to <" + name + ">");
+ if (logger.isDebugEnabled()) logger.debug("Mapping <" + ref + "> to <" + name + ">");
varReferences.put(ref, new Variable(name.toString()));
}
} finally {
answer.close();
}
- logger.debug("Mapped all Variable references.");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all Variable references.");
}
@@ -637,7 +630,7 @@
* @throws InitializerException There was an error in the method preconditions.
*/
private void findLiteralReferences() throws TuplesException, QueryException, InitializerException {
- logger.debug("Querying for Literal objects.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for Literal objects.");
Query query;
try {
@@ -645,11 +638,11 @@
query = interpreter.parseQuery("select $lit $str from <" +
ruleModel + "> where $lit <rdf:type> <krule:Literal> and $lit <rdf:value> $str ;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while looking for literal references.", e);
}
Answer answer = query(query);
- logger.debug("Found all Literals.");
+ if (logger.isDebugEnabled()) logger.debug("Found all Literals.");
// create the mapping
literalReferences = new HashMap<Node,Literal>();
@@ -658,13 +651,13 @@
while (answer.next()) {
Node litRef = (Node)answer.getObject(0);
Literal lit = (Literal)answer.getObject(1);
- logger.debug("Mapping <" + litRef + "> to <" + lit + ">");
+ if (logger.isDebugEnabled()) logger.debug("Mapping <" + litRef + "> to <" + lit + ">");
literalReferences.put(litRef, lit);
}
} finally {
answer.close();
}
- logger.debug("Mapped all Literals.");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all Literals.");
}
@@ -676,7 +669,7 @@
* @throws KruleStructureException There was an error in the krule model.
*/
private void loadSimpleConstraints() throws KruleStructureException, TuplesException, QueryException {
- logger.debug("Querying for Simple constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for Simple constraints.");
Query query;
try {
@@ -686,11 +679,11 @@
"($p <mulgara:is> <krule:hasSubject> or $p <mulgara:is> <krule:hasPredicate> or " +
"$p <mulgara:is> <krule:hasObject> or $p <mulgara:is> <krule:hasModel>);");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while looking for simple constraints.", e);
}
Answer answer = query(query);
- logger.debug("Found all simple constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Found all simple constraints.");
// create a mapping of URIs to simple constraint structures
Map<Node,Map<Node,Node>> simpleConstraints = new HashMap<Node,Map<Node,Node>>();
@@ -700,14 +693,14 @@
Node constraintNode = (Node)answer.getObject(0);
URIReference predicate = (URIReference)answer.getObject(1);
Node object = (Node)answer.getObject(2);
- logger.debug("setting <" + constraintNode + ">.<" + predicate + "> = " + object);
+ if (logger.isDebugEnabled()) logger.debug("setting <" + constraintNode + ">.<" + predicate + "> = " + object);
addProperty(simpleConstraints, constraintNode, predicate, object);
}
} finally {
answer.close();
}
- logger.debug("Mapped all constraints to their property/values");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all constraints to their property/values");
// collect all property/values together into constraints
for (Map.Entry<Node,Map<Node,Node>> entry: simpleConstraints.entrySet()) {
@@ -724,10 +717,10 @@
// build the appropriate constraint
// add it to the map
if (from == null) {
- logger.debug("Creating <" + constraintNode + "> as (<" + s + "> <" + p + "> <" + o +">)");
+ if (logger.isDebugEnabled()) logger.debug("Creating <" + constraintNode + "> as (<" + s + "> <" + p + "> <" + o +">)");
constraintMap.put(constraintNode, ConstraintFactory.newConstraint(s, p, o));
} else {
- logger.debug("Creating <" + constraintNode + "> as (<" + s + "> <" + p + "> <" + o +">) in <" + from + ">");
+ if (logger.isDebugEnabled()) logger.debug("Creating <" + constraintNode + "> as (<" + s + "> <" + p + "> <" + o +">) in <" + from + ">");
constraintMap.put(constraintNode, ConstraintFactory.newConstraint(s, p, o, convertToElement(from)));
}
}
@@ -743,7 +736,7 @@
*/
private void loadJoinConstraints() throws KruleStructureException, TuplesException, QueryException {
// build constraints in place, recursively constructing child constraints until all are found
- logger.debug("Querying for Join constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for Join constraints.");
Query query;
try {
@@ -752,11 +745,11 @@
"> where $constraint <krule:argument> $constraint2 and $constraint <rdf:type> $type and " +
"($type <mulgara:is> <krule:ConstraintConjunction> or $type <mulgara:is> <krule:ConstraintDisjunction>);");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while looking for join constraints.", e);
}
Answer answer = query(query);
- logger.debug("Found all join constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Found all join constraints.");
// accumulate all the constraint links and types
@@ -772,7 +765,7 @@
Node constraintNode = (Node)answer.getObject(0);
Node constraintNode2 = (Node)answer.getObject(1);
URIReference type = (URIReference)answer.getObject(2);
- logger.debug("constraint (" + type + ")<" + constraintNode + "> -> <" + constraintNode2 + ">");
+ if (logger.isDebugEnabled()) logger.debug("constraint (" + type + ")<" + constraintNode + "> -> <" + constraintNode2 + ">");
// map the constraint to its argument
addLink(constraintLinks, constraintNode, constraintNode2);
// map the type
@@ -782,7 +775,7 @@
answer.close();
}
- logger.debug("mapping join constraint RDF nodes to join constraint objects");
+ if (logger.isDebugEnabled()) logger.debug("mapping join constraint RDF nodes to join constraint objects");
// collect all arguments together into constraints and map the node to the constraint
for (Map.Entry<Node,Set<Node>> entry: constraintLinks.entrySet()) {
// get the constraint node in question
@@ -794,33 +787,31 @@
Set<Node> args = entry.getValue();
// get the constraint's type
Node type = joinTypes.get(constraintNode);
- if (type == null) {
- throw new KruleStructureException("No type available on join constraint");
- }
+ if (type == null) throw new KruleStructureException("No type (AND/OR) available on join constraint: " + constraintNode);
// convert the RDF nodes to constraints
List<ConstraintExpression> constraintArgs = getConstraints(args, constraintLinks, joinTypes);
ConstraintExpression joinConstraint = newJoinConstraint(type, constraintArgs);
- logger.debug("mapped " + constraintNode + " -> " + joinConstraint);
+ if (logger.isDebugEnabled()) logger.debug("mapped " + constraintNode + " -> " + joinConstraint);
// build the join constraint, and map the node to it
constraintMap.put(constraintNode, joinConstraint);
} else {
- logger.debug("constraint <" + constraintNode + "> already exists");
+ if (logger.isDebugEnabled()) logger.debug("constraint <" + constraintNode + "> already exists");
}
}
// every key should now be mapped to a constraint object
- logger.debug("mapped all constraint nodes to constraints");
+ if (logger.isDebugEnabled()) logger.debug("mapped all constraint nodes to constraints");
}
/**
- * Finds all having constraints.
+ * Finds all having constraints. This is included for completeness, but we don't do it yet.
*
* @throws TuplesException There was an error retrieving data from the model.
* @throws QueryException There was an error querying the model.
* @throws KruleStructureException There was an error querying the model.
*/
private void loadHavingConstraints() throws KruleStructureException, TuplesException, QueryException {
- logger.debug("Querying for Having constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for Having constraints.");
Query query;
try {
@@ -828,16 +819,14 @@
query = interpreter.parseQuery("select $constraint from <" + ruleModel +
"> where $rule <krule:hasHavingClause> $constraint;");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while searching on having clauses.", e);
}
Answer answer = query(query);
- logger.debug("Found all having constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Found all having constraints.");
try {
- if (answer.next()) {
- throw new KruleStructureException("Having structures not implemented");
- }
+ if (answer.next()) throw new KruleStructureException("Having structures not yet implemented");
} finally {
answer.close();
}
@@ -852,7 +841,7 @@
* @throws KruleStructureException There was an error in the krule model.
*/
private void loadTransitiveConstraints() throws KruleStructureException, TuplesException, QueryException {
- logger.debug("Querying for Transitive constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Querying for Transitive constraints.");
Query query;
try {
@@ -861,11 +850,11 @@
"> where $c <rdf:type> <krule:TransitiveConstraint> and $c $p $arg and " +
"($p <mulgara:is> <krule:transitiveArgument> or $p <mulgara:is> <krule:anchorArgument>);");
} catch (Exception e) {
- throw new QueryException("Invalid query.", e);
+ throw new QueryException("Invalid query while querying for transitive constraints.", e);
}
Answer answer = query(query);
- logger.debug("Retrieved all transitive constraints.");
+ if (logger.isDebugEnabled()) logger.debug("Retrieved all transitive constraints.");
// set up a mapping of constraints to predicate/SimpleConstraint pairs
Map<Node,Map<Node,Node>> transMap = new HashMap<Node,Map<Node,Node>>();
@@ -877,12 +866,12 @@
URIReference predicate = (URIReference)answer.getObject(1);
Node argument = (Node)answer.getObject(2);
addProperty(transMap, transConstraint, predicate, argument);
- logger.debug("mapping <" + transConstraint + "> to <" + predicate + ">.<" + argument +">");
+ if (logger.isDebugEnabled()) logger.debug("mapping <" + transConstraint + "> to <" + predicate + ">.<" + argument +">");
}
} finally {
answer.close();
}
- logger.debug("Mapped all transitive properties");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all transitive properties");
// build a new transconstraint for each transitive constraint node
for (Map.Entry<Node,Map<Node,Node>> tEntry: transMap.entrySet()) {
@@ -892,28 +881,26 @@
// build the constraint based on the arguments
if (arguments.size() == 1) {
Node sc = arguments.get(TRANSITIVE_ARGUMENT);
- if (sc == null) {
- throw new KruleStructureException("Transitive argument not correct");
- }
- logger.debug("Mapping transitive constraint <" + constraintNode +"> to <" + sc +">");
+ if (sc == null) throw new KruleStructureException("Transitive argument not correct in: " + constraintNode + " " + arguments);
+ if (logger.isDebugEnabled()) logger.debug("Mapping transitive constraint <" + constraintNode +"> to <" + sc +">");
// get the simple constraint and build the transitive constraint around it
constraint = new SingleTransitiveConstraint((Constraint)constraintMap.get(sc));
} else if (arguments.size() == 2) {
Node sc = arguments.get(TRANSITIVE_ARGUMENT);
Node anchor = arguments.get(ANCHOR_ARGUMENT);
if (sc == null || anchor == null) {
- throw new KruleStructureException("Transitive arguments not correct");
+ throw new KruleStructureException("Transitive arguments not correct for: " + constraintNode + " " + arguments);
}
- logger.debug("Mapping transitive constraint <" + constraintNode +"> to <" + sc +">,<" + anchor + ">");
+ if (logger.isDebugEnabled()) logger.debug("Mapping transitive constraint <" + constraintNode +"> to <" + sc +">,<" + anchor + ">");
// get the simple constraint and build the transitive constraint around it
constraint = new TransitiveConstraint((Constraint)constraintMap.get(anchor), (Constraint)constraintMap.get(sc));
} else {
- throw new KruleStructureException("Expected 1 or 2 arguments for Transitive constraint, got: " + arguments.size());
+ throw new KruleStructureException("Expected 1 or 2 arguments for Transitive constraint (" + constraintNode + "), got: " + arguments.size());
}
// map the transitive constraint node to the transitive constraint
constraintMap.put(constraintNode, constraint);
}
- logger.debug("Mapped all transitive constraints");
+ if (logger.isDebugEnabled()) logger.debug("Mapped all transitive constraints");
}
@@ -931,7 +918,7 @@
* @throws KruleStructureException There was an error in the RDF data structure.
*/
private List<ConstraintExpression> getConstraints(Set<Node> constraints, Map<Node,Set<Node>> constraintLinks, Map<Node,URIReference> typeMap) throws KruleStructureException {
- logger.debug("converting nodes to constraint list: " + constraints);
+ if (logger.isDebugEnabled()) logger.debug("converting nodes to constraint list: " + constraints);
// build the return list
List<ConstraintExpression> cList = new ArrayList<ConstraintExpression>();
@@ -942,11 +929,11 @@
}
// go through the arguments
for (Node cNode: constraints) {
- logger.debug("converting: " + cNode);
+ if (logger.isDebugEnabled()) logger.debug("converting: " + cNode);
// get the constraint expression object
ConstraintExpression constraintExpr = (ConstraintExpression)constraintMap.get(cNode);
if (constraintExpr == null) {
- logger.debug(cNode.toString() + " not yet mapped to constraint");
+ if (logger.isDebugEnabled()) logger.debug(cNode.toString() + " not yet mapped to constraint");
// constraint expression object does not yet exist, get its arguments
Set<Node> constraintArgNodes = constraintLinks.get(cNode);
// build the constraint expression - get the arguments as a list of constraints
@@ -978,7 +965,7 @@
} else if (type.equals(CONSTRAINT_DISJUNCTION)) {
return new ConstraintDisjunction(args);
}
- throw new KruleStructureException("Unknown constraint type: " + type);
+ throw new KruleStructureException("Unknown join constraint type (not AND/OR): " + type);
}
@@ -989,27 +976,22 @@
* @throws KruleStructureException If node cannot be converted.
*/
private ConstraintElement convertToElement(Node node) throws KruleStructureException {
- logger.debug("converting " + node + " to ConstraintElement");
+ if (logger.isDebugEnabled()) logger.debug("converting " + node + " to ConstraintElement");
// check that this is a named node
if (node instanceof URIReference) {
// get the referred node
URIReferenceImpl ref = (URIReferenceImpl)uriReferences.get(node);
- if (ref != null) {
- return ref;
- }
+ if (ref != null) return ref;
// not referred, so look in the variables
- Variable var = (Variable)varReferences.get(node);
- if (var != null) {
- return var;
- }
+ Variable var = varReferences.get(node);
+ if (var != null) return var;
+ throw new KruleStructureException("Unrecognized URI (" + node + ") in constraint. Was not declared to reference a URI nor a variable.");
} else {
// This could be an anonymous Literal
LiteralImpl lit = (LiteralImpl)literalReferences.get(node);
- if (lit != null) {
- return lit;
- }
+ if (lit != null) return lit;
+ throw new KruleStructureException("Unrecognized literal (" + lit + ") in constraint. Was not declared to reference a literal.");
}
- throw new KruleStructureException("Invalid constraint element: " + node);
}
Modified: branches/xa11/src/jar/krule/java/org/mulgara/krule/QueryStruct.java
===================================================================
--- branches/xa11/src/jar/krule/java/org/mulgara/krule/QueryStruct.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/krule/java/org/mulgara/krule/QueryStruct.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -32,9 +32,9 @@
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintHaving;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.ModelResource;
-import org.mulgara.query.ModelUnion;
+import org.mulgara.query.GraphExpression;
+import org.mulgara.query.GraphResource;
+import org.mulgara.query.GraphUnion;
import org.mulgara.query.Order;
import org.mulgara.query.Query;
import org.mulgara.query.SelectElement;
@@ -68,7 +68,7 @@
private List<SelectElement> variables;
/** The model expresison for the query. */
- private ModelExpression models;
+ private GraphExpression models;
/** The where clause of the query. */
private ConstraintExpression where;
@@ -181,7 +181,7 @@
* @param modelUri The URI of the model for the query.
*/
public void setModelExpression(URI modelUri) {
- this.models = new ModelResource(modelUri);
+ this.models = new GraphResource(modelUri);
}
@@ -195,7 +195,7 @@
if (firstModelUri.equals(secondModelUri)) {
setModelExpression(firstModelUri);
} else {
- this.models = new ModelUnion(new ModelResource(firstModelUri), new ModelResource(secondModelUri));
+ this.models = new GraphUnion(new GraphResource(firstModelUri), new GraphResource(secondModelUri));
}
}
Modified: branches/xa11/src/jar/query/java/org/jrdf/graph/AbstractURIReference.java
===================================================================
--- branches/xa11/src/jar/query/java/org/jrdf/graph/AbstractURIReference.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/jrdf/graph/AbstractURIReference.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -194,6 +194,6 @@
* @return A hash code for the URI.
*/
public int hashCode() {
- return uri.hashCode();
+ return toString().hashCode();
}
}
Modified: branches/xa11/src/jar/query/java/org/mulgara/connection/Connection.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/connection/Connection.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/connection/Connection.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -116,6 +116,13 @@
/**
+ * Tests if this connection is over a network protocol.
+ * @return <code>true</code> if this connection is being executed over a network protocol.
+ */
+ public boolean isRemote();
+
+
+ /**
* Starts and commits transactions on this connection, by turning the autocommit
* flag on and off.
* @param autocommit <code>true</code> if the flag is to be on.
Modified: branches/xa11/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -25,7 +25,7 @@
import org.mulgara.query.Answer;
import org.mulgara.query.ConstraintImpl;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.Order;
import org.mulgara.query.Query;
import org.mulgara.query.SelectElement;
@@ -83,7 +83,7 @@
query = new Query(
selectList, // SELECT
- new ModelResource(URI.create("rmi://localhost/server1#")), // FROM
+ new GraphResource(URI.create("rmi://localhost/server1#")), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
Modified: branches/xa11/src/jar/query/java/org/mulgara/connection/DummyConnection.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/connection/DummyConnection.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/connection/DummyConnection.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -101,5 +101,13 @@
*/
public void dispose() throws QueryException {
}
+
+
+ /**
+ * Always returns <code>false</code>.
+ */
+ public boolean isRemote() {
+ return false;
+ }
}
Modified: branches/xa11/src/jar/query/java/org/mulgara/connection/SessionConnection.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/connection/SessionConnection.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/connection/SessionConnection.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -289,5 +289,14 @@
}
assert session != null;
}
+
+
+ /**
+ * Tests if the Connection is being conducted over a network.
+ * @return <code>true</code> if the underlying session is not local.
+ */
+ public boolean isRemote() {
+ return session != null && !session.isLocal();
+ }
}
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/AskQuery.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/AskQuery.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/AskQuery.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -34,13 +34,13 @@
/**
* Creates an ASK query.
* @param variableList The variables in the result to check for.
- * @param modelExpression The source of the data to query.
+ * @param graphExpression The source of the data to query.
* @param constraintExpression The WHERE clause to test.
*/
@SuppressWarnings("unchecked")
- public AskQuery(List<? extends SelectElement> variableList, ModelExpression modelExpression,
+ public AskQuery(List<? extends SelectElement> variableList, GraphExpression graphExpression,
ConstraintExpression constraintExpression) {
- super(variableList, modelExpression, constraintExpression,
+ super(variableList, graphExpression, constraintExpression,
null, // no having
(List<Order>)Collections.EMPTY_LIST, // no ordering
null, // no limit
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintFalse.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintFalse.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -112,14 +112,14 @@
/**
* METHOD TO DO
*
- * @param modelExpression PARAMETER TO DO
+ * @param graphExpression PARAMETER TO DO
* @param transformation PARAMETER TO DO
* @param modelProperty PARAMETER TO DO
* @param systemModel PARAMETER TO DO
* @param variableFactory PARAMETER TO DO
* @return RETURNED VALUE TO DO
*/
- public ConstraintExpression from(ModelExpression modelExpression,
+ public ConstraintExpression from(GraphExpression graphExpression,
Transformation transformation, Value modelProperty, Value systemModel,
VariableFactory variableFactory) {
return this;
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintTrue.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ConstraintTrue.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -110,14 +110,14 @@
/**
* Converts an expression to be made against a new source. In this case, nothing need change.
*
- * @param modelExpression ignored
+ * @param graphExpression ignored
* @param transformation ignored
* @param modelProperty ignored
* @param systemModel ignored
* @param variableFactory ignored
* @return The current constraint.
*/
- public ConstraintExpression from(ModelExpression modelExpression,
+ public ConstraintExpression from(GraphExpression graphExpression,
Transformation transformation, Value modelProperty, Value systemModel,
VariableFactory variableFactory) {
return this;
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/ConstructQuery.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ConstructQuery.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ConstructQuery.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -34,10 +34,10 @@
private static final long serialVersionUID = -6024259961466362580L;
@SuppressWarnings("unchecked")
- public ConstructQuery(List<? extends SelectElement> variableList, ModelExpression modelExpression,
+ public ConstructQuery(List<? extends SelectElement> variableList, GraphExpression graphExpression,
ConstraintExpression constraintExpression,
List<Order> orderList, Integer limit, int offset) {
- super(variableList, modelExpression, constraintExpression,
+ super(variableList, graphExpression, constraintExpression,
null, // no having
orderList,
limit,
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/Graph.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/Graph.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/Graph.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/Graph.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,59 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+/**
+ * A simple model expression involving a set of RDF statements.
+ *
+ * @created 2001-10-02
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2003
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public interface Graph extends GraphExpression {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = -4054403807442867450L;
+
+ // no additional specification
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphExpression.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphExpression.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphExpression.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphExpression.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,83 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+import java.net.*;
+import java.util.*;
+import java.io.Serializable;
+
+/**
+ * An expression whose leaves are the {@link URL}s of RDF models.
+ *
+ * Currently this doesn't handle compound expressions, only simple models.
+ *
+ * @created 12/Aug/2001
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public interface GraphExpression extends Cloneable, Serializable {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = -7760184436366431348L;
+
+ /**
+ * Calculate the databases involved in this expression. Bear in mind that
+ * different models may reside on the same database. The idea of this function
+ * is to test for when only one database is involved, and we're able to
+ * transmit a query to that database for remove processing.
+ *
+ * @return a set containing the {@link URI}s of the databases
+ */
+ public Set<URI> getDatabaseURIs();
+
+ /**
+ * Calculate the graphs involved in this expression.
+ *
+ * @return a set containing the {@link URI}s of the graphs
+ */
+ public Set<URI> getGraphURIs();
+
+ /**
+ * Clones sets of models in the rhs and lhs objects.
+ */
+ public Object clone();
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphIntersection.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphIntersection.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphIntersection.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphIntersection.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,80 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+/**
+ * A model expression composed of the intersection of two subexpressions.
+ *
+ * @created 2001-09-04
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2003
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphIntersection extends GraphOperation {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = -5897664547668612754L;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Construct a model intersection.
+ *
+ * @param lhs a non-<code>null</code> model expression
+ * @param rhs another non-<code>null</code> model expression
+ */
+ public GraphIntersection(GraphExpression lhs, GraphExpression rhs) {
+ super(lhs, rhs);
+ }
+
+ /**
+ * Legible representation
+ *
+ * @return RETURNED VALUE TO DO
+ */
+ public String toString() {
+ return "(" + getLHS() + " intersect " + getRHS() + ")";
+ }
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphLiteral.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphLiteral.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphLiteral.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphLiteral.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,208 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+// Java 2 standard packages
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamResult;
+
+// Third party packages
+import org.apache.log4j.Logger;
+import org.xml.sax.InputSource;
+
+/**
+ * A leaf expression containing the statements comprising an RDF model.
+ *
+ * @created 2001-10-02
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2003
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphLiteral implements Graph {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = 5132086338306266830L;
+
+ /**
+ * Logger. This is named after the class.
+ */
+ @SuppressWarnings("unused")
+ private final static Logger logger = Logger.getLogger(GraphLiteral.class);
+
+ /**
+ * The content of the model, an RDF syntax byte sequence.
+ */
+ private byte[] buffer;
+
+ /**
+ * The system ID of the model.
+ */
+ private String systemId;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * Construct a model from RDF syntax.
+ *
+ * @param source the RDF syntax source
+ * @throws IllegalArgumentException if the <var>inputSource</var> is <code>null</code>
+ * @throws TransformerConfigurationException EXCEPTION TO DO
+ * @throws TransformerException EXCEPTION TO DO
+ */
+ public GraphLiteral(Source source) throws TransformerConfigurationException,
+ TransformerException {
+
+ // Validate "source" parameter
+ if (source == null) {
+
+ throw new IllegalArgumentException("Null \"source\" parameter");
+ }
+
+ // Copy from the RDF syntax source into a byte array
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ TransformerFactory.newInstance().newTransformer().transform(source,
+ // RDF syntax source
+ new StreamResult(baos));
+
+ // Initialize fields
+ buffer = baos.toByteArray();
+ systemId = source.getSystemId();
+ }
+
+ //
+ // Methods implementing GraphExpression
+ //
+
+ /**
+ * @return an empty {@link Set}
+ */
+ public Set<URI> getDatabaseURIs() {
+ return Collections.emptySet();
+ }
+
+ /**
+ * @return an empty {@link Set}
+ */
+ public Set<URI> getGraphURIs() {
+ return Collections.emptySet();
+ }
+
+ //
+ // API methods
+ //
+
+ /**
+ * Gets the InputSource attribute of the GraphLiteral object
+ *
+ * @return The InputSource value
+ */
+ public InputSource getInputSource() {
+
+ InputSource in = new InputSource(new ByteArrayInputStream(buffer));
+
+ if (systemId != null) {
+
+ in.setSystemId(systemId);
+ }
+
+ return in;
+ }
+
+ //
+ // Methods of Object
+ //
+
+ /**
+ * Equality is by value. The value of a literal requires that the RDF model be
+ * parsed out of it and compared. We don't actually do this, so the method
+ * will throw an {@link Error} if it's asked to do any serious work.
+ *
+ * @param object the object to test against
+ * @return <code>false</code> if inequality can be proved
+ * @throws Error if inequality can't be proved
+ */
+ public boolean equals(Object object) {
+
+ // Check trivial cases
+ if (object == null) {
+
+ return false;
+ }
+
+ if (object == this) {
+
+ return true;
+ }
+
+ if (! (object instanceof GraphLiteral)) {
+
+ return false;
+ }
+
+ // Give up
+ throw new Error("RDF literal equality not implemented");
+ }
+
+ /**
+ * Returns just the default Object clone.
+ */
+ public Object clone() {
+
+ try {
+
+ GraphLiteral cloned = (GraphLiteral) super.clone();
+ return cloned;
+ }
+ catch (CloneNotSupportedException e) {
+ throw new RuntimeException(
+ "GraphLiteral not cloneable"
+ );
+ }
+ }
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphOperation.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphOperation.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphOperation.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,243 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+// Java 2 standard packages
+import java.net.URI;
+import java.util.*;
+
+/**
+ * A model expression composed of two subexpressions and a dyadic operator.
+ *
+ * @created 2001-07-12
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
+ *
+ * @copyright © 2001-2003 <A href="http://www.PIsoftware.com/">Plugged In
+ * Software Pty Ltd</A>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public abstract class GraphOperation implements GraphExpression {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = 7647456202844495785L;
+
+ /**
+ * The two operands.
+ */
+ private GraphExpression lhs;
+
+ /**
+ * The two operands.
+ */
+ private GraphExpression rhs;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Construct a model operation. Subclasses are compelled to use this
+ * constructor, guaranteeing that the operands are always
+ * non-<code>null</code>.
+ *
+ * @param lhs a non-<code>null</code> model expression
+ * @param rhs another non-<code>null</code> model expression
+ */
+ protected GraphOperation(GraphExpression lhs, GraphExpression rhs) {
+
+ // Validate "lhs" parameter
+ if (lhs == null) {
+
+ throw new IllegalArgumentException("Null \"lhs\" parameter");
+ }
+
+ // Validate "rhs" parameter
+ if (rhs == null) {
+
+ throw new IllegalArgumentException("Null \"rhs\" parameter");
+ }
+
+ // Initialize fields
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ //
+ // Methods implementing the GraphExpression abstract class
+ //
+
+ /**
+ * Gets the DatabaseURIs attribute of the GraphOperation object
+ *
+ * @return The DatabaseURIs value
+ */
+ public Set<URI> getDatabaseURIs() {
+
+ Set<URI> databaseURIs = new HashSet<URI>();
+ databaseURIs.addAll(lhs.getDatabaseURIs());
+ databaseURIs.addAll(rhs.getDatabaseURIs());
+
+ return databaseURIs;
+ }
+
+ /**
+ * Calculate the graphs involved in this expression.
+ *
+ * @return a set containing the {@link URI}s of the graphs
+ */
+ public Set<URI> getGraphURIs() {
+
+ Set<URI> graphURIs = new HashSet<URI>();
+ graphURIs.addAll(lhs.getGraphURIs());
+ graphURIs.addAll(rhs.getGraphURIs());
+
+ return graphURIs;
+ }
+
+ //
+ // Additional API
+ //
+
+ /**
+ * Accessor for the <var>lhs</var> property.
+ *
+ * @return The LHS value
+ */
+ public GraphExpression getLHS() {
+
+ return lhs;
+ }
+
+ /**
+ * Accessor for the <var>rhs</var> property.
+ *
+ * @return The RHS value
+ */
+ public GraphExpression getRHS() {
+
+ return rhs;
+ }
+
+ /**
+ * Transform to an equivalent WHERE clause expression.
+ *
+ * @param m The object to compare against.
+ * @return <code>true</code> if the objects are the same type,
+ * and applied to the same operands
+ */
+ public boolean equals(Object m) {
+
+ if (!(m instanceof GraphOperation)) return false;
+ if ((m == null) || !m.getClass().equals(getClass())) return false;
+ if (m == this) return true;
+
+ Class<?> type = m.getClass();
+
+ Set<GraphExpression> otherExpressions = new HashSet<GraphExpression>();
+ ((GraphOperation)m).flattenExpression(otherExpressions, type);
+
+ Set<GraphExpression> myExpressions = new HashSet<GraphExpression>();
+ flattenExpression(myExpressions, type);
+
+ return myExpressions.equals(otherExpressions);
+ }
+
+ /**
+ * Creates a hash code, based on the child expressions and the current operation type.
+ *
+ * @return The hash code for this object.
+ */
+ public int hashCode() {
+
+ Set<GraphExpression> myExpressions = new HashSet<GraphExpression>();
+ flattenExpression(myExpressions, getClass());
+
+ return (getClass().hashCode() * 7) + myExpressions.hashCode();
+ }
+
+ /**
+ * Traverse down the binary tree of the current object, and merge any nodes
+ * of the current type into a flattened set.
+ *
+ * @param expressions The set to be built up containing all nodes being
+ * operated on in the same way.
+ * @param type The class representing the operation type.
+ */
+ private void flattenExpression(Set<GraphExpression> expressions, Class<?> type) {
+
+ if (lhs.getClass().equals(type)) {
+ ((GraphOperation)lhs).flattenExpression(expressions, type);
+ } else {
+ expressions.add(lhs);
+ }
+
+ if (rhs.getClass().equals(type)) {
+ ((GraphOperation)rhs).flattenExpression(expressions, type);
+ } else {
+ expressions.add(rhs);
+ }
+ }
+
+ /**
+ * Clones sets of models in the rhs and lhs objects.
+ */
+ public Object clone() {
+
+ try {
+ GraphOperation cloned = (GraphOperation)super.clone();
+
+ // Copy database URIs.
+ cloned.lhs = (GraphExpression)lhs.clone();
+ cloned.rhs = (GraphExpression)rhs.clone();
+
+ return cloned;
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException("GraphOperation subclass " + getClass() + " not cloneable");
+ }
+ }
+
+
+ public String toString() {
+ return getClass().toString() + ":[(" + lhs.toString() + ") . (" + rhs.toString() +")]";
+ }
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphPartition.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphPartition.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphPartition.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphPartition.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,92 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+/**
+ * A model expression composed of the union of two subexpressions.
+ *
+ *
+ * @created 2002-05-20
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
+ *
+ * @copyright © 2002-2004 <A href="http://www.PIsoftware.com/">Plugged In
+ * Software Pty Ltd</A>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphPartition extends GraphOperation {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = 8660358035003409731L;
+
+ /** Logger. */
+ @SuppressWarnings("unused")
+ private final static Logger logger = Logger.getLogger(GraphPartition.class);
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Construct a model union.
+ *
+ * @param lhs a non-<code>null</code> model expression
+ * @param rhs another non-<code>null</code> model expression
+ */
+ public GraphPartition(GraphExpression lhs, GraphExpression rhs) {
+ super(lhs, rhs);
+ }
+
+ /**
+ * Legible representation
+ *
+ * @return RETURNED VALUE TO DO
+ */
+ public String toString() {
+
+ return "(" + getLHS() + " par " + getRHS() + ")";
+ }
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphResource.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphResource.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphResource.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphResource.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,219 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+// Java 2 standard packages
+import java.net.*;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+
+/**
+ * A leaf expression containing the {@link URL} of an RDF model.
+ *
+ * @created 2001-07-12
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2003
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphResource implements Graph {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = -5673467065206144337L;
+
+ /** Logger. This is named after the class. */
+ @SuppressWarnings("unused")
+ private final static Logger logger = Logger.getLogger(GraphResource.class.getName());
+
+ /** The {@link URI} of the RDF model. */
+ private URI uri;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * Construct a model from a {@link URL}.
+ *
+ * @param uri the {@link URI} of the model to query
+ * @throws IllegalArgumentException if <var>url</var> is <code>null</code>
+ */
+ public GraphResource(URI uri) {
+
+ // Validate "uri" parameter
+ if (uri == null) {
+
+ throw new IllegalArgumentException("Null \"uri\" parameter");
+ }
+
+ // Initialize fields
+ this.uri = uri;
+ }
+
+ //
+ // Methods implementing GraphExpression
+ //
+
+ /**
+ * @return an immutable singleton {@link Set} containing the {@link URL} of
+ * the server if this is a Java RMI, BEEP, or local model, or the empty
+ * {@link Set} otherwise
+ */
+ @SuppressWarnings("unchecked")
+ public Set<URI> getDatabaseURIs() {
+
+ try {
+
+ if ("beep".equals(uri.getScheme()) || "rmi".equals(uri.getScheme()) ||
+ "local".equals(uri.getScheme())) {
+
+ // In Java RMI models, the database is the URI without
+ // the fragment identifier
+ // TODO: Call RmiQueryHandler.serverURI instead
+ return Collections.singleton(new URI(uri.getScheme(),
+ uri.getAuthority(),
+ uri.getPath(),
+ null,
+ null));
+ } else {
+ return (Set<URI>)Collections.EMPTY_SET;
+ }
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Couldn't truncate model URI " + uri + " to obtain a database URI");
+ }
+
+ }
+
+ /** @see org.mulgara.query.GraphExpression#getGraphURIs() */
+ public Set<URI> getGraphURIs() {
+ return Collections.singleton(uri);
+ }
+
+ //
+ // API methods
+ //
+
+ /**
+ * Accessor for the <var>uri</var> property.
+ *
+ * @return a {@link URI} instance (never <code>null</code>)
+ */
+ public URI getURI() {
+
+ return uri;
+ }
+
+ //
+ // Methods extending Object
+ //
+
+ /**
+ * The text representation of the URI.
+ *
+ * @return the text representation of the URI.
+ */
+ public String toString() {
+
+ return uri.toString();
+ }
+
+ //
+ // Methods overriding Object
+ //
+
+ /**
+ * Return true if the URIs of a GraphResource are equal.
+ *
+ * @param object GraphResource to test equality.
+ * @return true if the URIs of a GraphResource are equal.
+ */
+ public boolean equals(Object object) {
+
+ if (object == null) {
+
+ return false;
+ }
+
+ try {
+
+ GraphResource tmpModelResource = (GraphResource) object;
+ return getURI().equals(tmpModelResource.getURI());
+ }
+ catch (ClassCastException cce) {
+
+ return false;
+ }
+ }
+
+ /**
+ * Returns the hashCode of a URI.
+ *
+ * @return the hashCode of a URI.
+ */
+ public int hashCode() {
+
+ return uri.hashCode();
+ }
+
+ /**
+ * Returns just the default Object clone.
+ *
+ * @return just the default Object clone.
+ */
+ public Object clone() {
+
+ try {
+
+ GraphResource cloned = (GraphResource) super.clone();
+ cloned.uri = getURI();
+ return cloned;
+ }
+ catch (CloneNotSupportedException e) {
+
+ throw new RuntimeException("GraphResource not cloneable");
+ }
+ }
+
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphResourceUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,146 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+// Java packages
+import java.net.URI;
+
+// JUnit
+import junit.framework.*;
+
+// Log4J
+import org.apache.log4j.Logger;
+
+/**
+ * Tests the functionality of GraphResource.
+ *
+ * @created 2004-04-15
+ *
+ * @author Andrew Newman
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2003
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphResourceUnitTest extends TestCase {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = Logger.getLogger(GraphResourceUnitTest.class);
+
+ /**
+ * Construct a new unit test.
+ *
+ * @param name the name of the test
+ */
+ public GraphResourceUnitTest(String name) {
+
+ super(name);
+ }
+
+ /**
+ * Hook for test runner to obtain a test suite from.
+ *
+ * @return The test suite
+ */
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite();
+ suite.addTest(new GraphResourceUnitTest("testEquals"));
+ suite.addTest(new GraphResourceUnitTest("testClone"));
+ return suite;
+ }
+
+ /**
+ * Default text runner.
+ *
+ * @param args The command line arguments
+ */
+ public static void main(String[] args) {
+
+ junit.textui.TestRunner.run(suite());
+ }
+
+ //
+ // Test cases
+ //
+
+ /**
+ * Test equality of two model resource.
+ */
+ public void testEquals() {
+
+ try {
+
+ GraphResource res1 = new GraphResource(new URI("rmi://foo/server1#_"));
+ GraphResource res2 = new GraphResource(new URI("rmi://foo/server1#"));
+ GraphResource res3 = new GraphResource(new URI("rmi://foo/server1#"));
+
+ assertEquals("Two GraphResource with the same RMI protcol should " +
+ "resolve to the same server", res1.getDatabaseURIs(),
+ res2.getDatabaseURIs());
+
+ assertFalse("Resource should be unequal", res1.equals(res2));
+
+ assertNotSame("Resources should be different instances", res2, res3);
+ assertTrue("Resource should be equal", res2.equals(res3));
+ }
+ catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Test clone of two resources.
+ */
+ public void testClone() {
+
+ try {
+
+ GraphResource res1 = new GraphResource(new URI("rmi://foo/server1#_"));
+ GraphResource res2 = (GraphResource) res1.clone();
+
+ assertNotSame("Resources should be different instances", res1, res2);
+ assertTrue("Resources should be equal", res1.equals(res2));
+ }
+ catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ }
+}
+
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphUnion.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphUnion.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphUnion.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphUnion.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,81 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+/**
+ * A model expression composed of the union of two subexpressions.
+ *
+ * @created 2001-08-12
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2001-2004
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphUnion extends GraphOperation {
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ static final long serialVersionUID = -2658255434397870185L;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Construct a model union.
+ *
+ * @param lhs a non-<code>null</code> model expression
+ * @param rhs another non-<code>null</code> model expression
+ */
+ public GraphUnion(GraphExpression lhs, GraphExpression rhs) {
+ super(lhs, rhs);
+ }
+
+ /**
+ * Legible representation
+ *
+ * @return RETURNED VALUE TO DO
+ */
+ public String toString() {
+
+ return "(" + getLHS() + " union " + getRHS() + ")";
+ }
+}
Copied: branches/xa11/src/jar/query/java/org/mulgara/query/GraphVariable.java (from rev 1423, trunk/src/jar/query/java/org/mulgara/query/GraphVariable.java)
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/GraphVariable.java (rev 0)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/GraphVariable.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,141 @@
+/**
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query;
+
+// Java 2 standard packages
+import java.net.*;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+/**
+ * A leaf expression containing a variable that is used for the model expression.
+ *
+ * @created Apr 22, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class GraphVariable implements Graph {
+
+ /** Used for serializing. */
+ static final long serialVersionUID = 5132086338306266830L;
+
+ /** Logger. */
+ @SuppressWarnings("unused")
+ private final static Logger logger = Logger.getLogger(GraphVariable.class);
+
+ /** The variable for the graph */
+ private Variable variable;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * Construct a model from a {@link URL}.
+ *
+ * @param uri the {@link URI} of the model to query
+ * @throws IllegalArgumentException if <var>url</var> is <code>null</code>
+ */
+ public GraphVariable(Variable variable) {
+ if (variable == null) throw new IllegalArgumentException("Null variable parameter");
+ this.variable = variable;
+ }
+
+ //
+ // Methods implementing GraphExpression
+ //
+
+ /**
+ * Gets a set of database URIs to operate against.
+ * @return We don't know what is in the variable, so return the empty {@link Set}
+ */
+ public Set<URI> getDatabaseURIs() {
+ return Collections.emptySet();
+ }
+
+ /**
+ * Gets a set of graph URIs this represents.
+ * @return We don't know what is in the variable, so return the empty {@link Set}
+ */
+ public Set<URI> getGraphURIs() {
+ return Collections.emptySet();
+ }
+
+ //
+ // API methods
+ //
+
+ /**
+ * Accessor for the <var>variable</var> property.
+ * @return a {@link Variable} instance
+ */
+ public Variable getVariable() {
+ return variable;
+ }
+
+ //
+ // Methods extending Object
+ //
+
+ /**
+ * The text representation of the URI.
+ * @return the text representation of the URI.
+ */
+ public String toString() {
+ return variable.toString();
+ }
+
+ //
+ // Methods overriding Object
+ //
+
+ /**
+ * Return true if the variables of a GraphVariable are equal.
+ * @param object GraphVariable to test equality.
+ * @return true if the variables of a GraphVariable are equal.
+ */
+ public boolean equals(Object object) {
+ if (object == null) return false;
+ if (object == this) return true;
+
+ if (!(object instanceof GraphVariable)) return false;
+ GraphVariable modelVar = (GraphVariable)object;
+ return variable.equals(modelVar.variable);
+ }
+
+ /**
+ * Returns the hashCode of a Variable.
+ * @return the hashCode of a Variable.
+ */
+ public int hashCode() {
+ return variable.hashCode();
+ }
+
+ /**
+ * Returns just the default Object clone.
+ * @return just the default Object clone.
+ */
+ public Object clone() {
+ try {
+ GraphVariable cloned = (GraphVariable)super.clone();
+ cloned.variable = variable;
+ return cloned;
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException("GraphVariable not cloneable");
+ }
+ }
+
+}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/Model.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/Model.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/Model.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,59 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-/**
- * A simple model expression involving a set of RDF statements.
- *
- * @created 2001-10-02
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2003
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface Model extends ModelExpression {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = -4054403807442867450L;
-
- // no additional specification
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelExpression.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelExpression.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelExpression.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,76 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-import java.net.*;
-import java.util.*;
-import java.io.Serializable;
-
-/**
- * An expression whose leaves are the {@link URL}s of RDF models.
- *
- * Currently this doesn't handle compound expressions, only simple models.
- *
- * @created 12/Aug/2001
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface ModelExpression extends Cloneable, Serializable {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = -7760184436366431348L;
-
- /**
- * Calculate the databases involved in this expression. Bear in mind that
- * different models may reside on the same database. The idea of this function
- * is to test for when only one database is involved, and we're able to
- * transmit a query to that database for remove processing.
- *
- * @return a set containing the {@link URI}s of the databases
- */
- public Set<URI> getDatabaseURIs();
-
- /**
- * Clones sets of models in the rhs and lhs objects.
- */
- public Object clone();
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelIntersection.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelIntersection.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelIntersection.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,80 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-/**
- * A model expression composed of the intersection of two subexpressions.
- *
- * @created 2001-09-04
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2003
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelIntersection extends ModelOperation {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = -5897664547668612754L;
-
- //
- // Constructor
- //
-
- /**
- * Construct a model intersection.
- *
- * @param lhs a non-<code>null</code> model expression
- * @param rhs another non-<code>null</code> model expression
- */
- public ModelIntersection(ModelExpression lhs, ModelExpression rhs) {
- super(lhs, rhs);
- }
-
- /**
- * Legible representation
- *
- * @return RETURNED VALUE TO DO
- */
- public String toString() {
- return "(" + getLHS() + " intersect " + getRHS() + ")";
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelLiteral.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelLiteral.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelLiteral.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,202 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-// Java 2 standard packages
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import javax.xml.transform.*;
-import javax.xml.transform.stream.StreamResult;
-
-// Third party packages
-import org.apache.log4j.Logger;
-import org.xml.sax.InputSource;
-
-/**
- * A leaf expression containing the statements comprising an RDF model.
- *
- * @created 2001-10-02
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2003
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelLiteral implements Model {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = 5132086338306266830L;
-
- /**
- * Logger. This is named after the class.
- */
- private final static Logger logger = Logger.getLogger(ModelLiteral.class);
-
- /**
- * The content of the model, an RDF syntax byte sequence.
- */
- private byte[] buffer;
-
- /**
- * The system ID of the model.
- */
- private String systemId;
-
- //
- // Constructors
- //
-
- /**
- * Construct a model from RDF syntax.
- *
- * @param source the RDF syntax source
- * @throws IllegalArgumentException if the <var>inputSource</var> is <code>null</code>
- * @throws TransformerConfigurationException EXCEPTION TO DO
- * @throws TransformerException EXCEPTION TO DO
- */
- public ModelLiteral(Source source) throws TransformerConfigurationException,
- TransformerException {
-
- // Validate "source" parameter
- if (source == null) {
-
- throw new IllegalArgumentException("Null \"source\" parameter");
- }
-
- // Copy from the RDF syntax source into a byte array
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- TransformerFactory.newInstance().newTransformer().transform(source,
- // RDF syntax source
- new StreamResult(baos));
-
- // Initialize fields
- buffer = baos.toByteArray();
- systemId = source.getSystemId();
- }
-
- //
- // Methods implementing ModelExpression
- //
-
- /**
- * @return an empty {@link Set}
- */
- @SuppressWarnings("unchecked")
- public Set<URI> getDatabaseURIs() {
-
- return (Set<URI>)Collections.EMPTY_SET;
- }
-
- //
- // API methods
- //
-
- /**
- * Gets the InputSource attribute of the ModelLiteral object
- *
- * @return The InputSource value
- */
- public InputSource getInputSource() {
-
- InputSource in = new InputSource(new ByteArrayInputStream(buffer));
-
- if (systemId != null) {
-
- in.setSystemId(systemId);
- }
-
- return in;
- }
-
- //
- // Methods of Object
- //
-
- /**
- * Equality is by value. The value of a literal requires that the RDF model be
- * parsed out of it and compared. We don't actually do this, so the method
- * will throw an {@link Error} if it's asked to do any serious work.
- *
- * @param object the object to test against
- * @return <code>false</code> if inequality can be proved
- * @throws Error if inequality can't be proved
- */
- public boolean equals(Object object) {
-
- // Check trivial cases
- if (object == null) {
-
- return false;
- }
-
- if (object == this) {
-
- return true;
- }
-
- if (! (object instanceof ModelLiteral)) {
-
- return false;
- }
-
- // Give up
- throw new Error("RDF literal equality not implemented");
- }
-
- /**
- * Returns just the default Object clone.
- */
- public Object clone() {
-
- try {
-
- ModelLiteral cloned = (ModelLiteral) super.clone();
- return cloned;
- }
- catch (CloneNotSupportedException e) {
- throw new RuntimeException(
- "ModelLiteral not cloneable"
- );
- }
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelOperation.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,229 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-// Java 2 standard packages
-import java.net.URI;
-import java.util.*;
-
-/**
- * A model expression composed of two subexpressions and a dyadic operator.
- *
- * @created 2001-07-12
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright © 2001-2003 <A href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</A>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public abstract class ModelOperation implements ModelExpression {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = 7647456202844495785L;
-
- /**
- * The two operands.
- */
- private ModelExpression lhs;
-
- /**
- * The two operands.
- */
- private ModelExpression rhs;
-
- //
- // Constructor
- //
-
- /**
- * Construct a model operation. Subclasses are compelled to use this
- * constructor, guaranteeing that the operands are always
- * non-<code>null</code>.
- *
- * @param lhs a non-<code>null</code> model expression
- * @param rhs another non-<code>null</code> model expression
- */
- protected ModelOperation(ModelExpression lhs, ModelExpression rhs) {
-
- // Validate "lhs" parameter
- if (lhs == null) {
-
- throw new IllegalArgumentException("Null \"lhs\" parameter");
- }
-
- // Validate "rhs" parameter
- if (rhs == null) {
-
- throw new IllegalArgumentException("Null \"rhs\" parameter");
- }
-
- // Initialize fields
- this.lhs = lhs;
- this.rhs = rhs;
- }
-
- //
- // Methods implementing the ModelExpression abstract class
- //
-
- /**
- * Gets the DatabaseURIs attribute of the ModelOperation object
- *
- * @return The DatabaseURIs value
- */
- public Set<URI> getDatabaseURIs() {
-
- Set<URI> databaseURIs = new HashSet<URI>();
- databaseURIs.addAll(lhs.getDatabaseURIs());
- databaseURIs.addAll(rhs.getDatabaseURIs());
-
- return databaseURIs;
- }
-
- //
- // Additional API
- //
-
- /**
- * Accessor for the <var>lhs</var> property.
- *
- * @return The LHS value
- */
- public ModelExpression getLHS() {
-
- return lhs;
- }
-
- /**
- * Accessor for the <var>rhs</var> property.
- *
- * @return The RHS value
- */
- public ModelExpression getRHS() {
-
- return rhs;
- }
-
- /**
- * Transform to an equivalent WHERE clause expression.
- *
- * @param m The object to compare against.
- * @return <code>true</code> if the objects are the same type,
- * and applied to the same operands
- */
- public boolean equals(Object m) {
-
- if (!(m instanceof ModelOperation)) return false;
- if ((m == null) || !m.getClass().equals(getClass())) return false;
- if (m == this) return true;
-
- Class<?> type = m.getClass();
-
- Set<ModelExpression> otherExpressions = new HashSet<ModelExpression>();
- ((ModelOperation)m).flattenExpression(otherExpressions, type);
-
- Set<ModelExpression> myExpressions = new HashSet<ModelExpression>();
- flattenExpression(myExpressions, type);
-
- return myExpressions.equals(otherExpressions);
- }
-
- /**
- * Creates a hash code, based on the child expressions and the current operation type.
- *
- * @return The hash code for this object.
- */
- public int hashCode() {
-
- Set<ModelExpression> myExpressions = new HashSet<ModelExpression>();
- flattenExpression(myExpressions, getClass());
-
- return (getClass().hashCode() * 7) + myExpressions.hashCode();
- }
-
- /**
- * Traverse down the binary tree of the current object, and merge any nodes
- * of the current type into a flattened set.
- *
- * @param expressions The set to be built up containing all nodes being
- * operated on in the same way.
- * @param type The class representing the operation type.
- */
- private void flattenExpression(Set<ModelExpression> expressions, Class<?> type) {
-
- if (lhs.getClass().equals(type)) {
- ((ModelOperation)lhs).flattenExpression(expressions, type);
- } else {
- expressions.add(lhs);
- }
-
- if (rhs.getClass().equals(type)) {
- ((ModelOperation)rhs).flattenExpression(expressions, type);
- } else {
- expressions.add(rhs);
- }
- }
-
- /**
- * Clones sets of models in the rhs and lhs objects.
- */
- public Object clone() {
-
- try {
- ModelOperation cloned = (ModelOperation)super.clone();
-
- // Copy database URIs.
- cloned.lhs = (ModelExpression)lhs.clone();
- cloned.rhs = (ModelExpression)rhs.clone();
-
- return cloned;
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException("ModelOperation subclass " + getClass() + " not cloneable");
- }
- }
-
-
- public String toString() {
- return getClass().toString() + ":[(" + lhs.toString() + ") . (" + rhs.toString() +")]";
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelPartition.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelPartition.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelPartition.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,93 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-/**
- * A model expression composed of the union of two subexpressions.
- *
- *
- * @created 2002-05-20
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright © 2002-2004 <A href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</A>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelPartition extends ModelOperation {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = 8660358035003409731L;
-
- /**
- * Logger.
- */
- private final static Logger logger = Logger.getLogger(ModelPartition.class);
-
- //
- // Constructor
- //
-
- /**
- * Construct a model union.
- *
- * @param lhs a non-<code>null</code> model expression
- * @param rhs another non-<code>null</code> model expression
- */
- public ModelPartition(ModelExpression lhs, ModelExpression rhs) {
- super(lhs, rhs);
- }
-
- /**
- * Legible representation
- *
- * @return RETURNED VALUE TO DO
- */
- public String toString() {
-
- return "(" + getLHS() + " par " + getRHS() + ")";
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelResource.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelResource.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelResource.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,219 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-// Java 2 standard packages
-import java.net.*;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-// Local packages
-import org.mulgara.query.rdf.URIReferenceImpl;
-
-/**
- * A leaf expression containing the {@link URL} of an RDF model.
- *
- * @created 2001-07-12
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2003
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelResource implements Model {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = -5673467065206144337L;
-
- /**
- * Logger. This is named after the class.
- */
- private final static Logger logger =
- Logger.getLogger(ModelResource.class.getName());
-
- /**
- * The {@link URI} of the RDF model.
- */
- private URI uri;
-
- //
- // Constructors
- //
-
- /**
- * Construct a model from a {@link URL}.
- *
- * @param uri the {@link URI} of the model to query
- * @throws IllegalArgumentException if <var>url</var> is <code>null</code>
- */
- public ModelResource(URI uri) {
-
- // Validate "uri" parameter
- if (uri == null) {
-
- throw new IllegalArgumentException("Null \"uri\" parameter");
- }
-
- // Initialize fields
- this.uri = uri;
- }
-
- //
- // Methods implementing ModelExpression
- //
-
- /**
- * @return an immutable singleton {@link Set} containing the {@link URL} of
- * the server if this is a Java RMI, BEEP, or local model, or the empty
- * {@link Set} otherwise
- */
- @SuppressWarnings("unchecked")
- public Set<URI> getDatabaseURIs() {
-
- try {
-
- if ("beep".equals(uri.getScheme()) || "rmi".equals(uri.getScheme()) ||
- "local".equals(uri.getScheme())) {
-
- // In Java RMI models, the database is the URI without
- // the fragment identifier
- // TODO: Call RmiQueryHandler.serverURI instead
- return Collections.singleton(new URI(uri.getScheme(),
- uri.getAuthority(),
- uri.getPath(),
- null,
- null));
- } else {
- return (Set<URI>)Collections.EMPTY_SET;
- }
- } catch (URISyntaxException e) {
- throw new RuntimeException("Couldn't truncate model URI " + uri + " to obtain a database URI");
- }
-
- }
-
- //
- // API methods
- //
-
- /**
- * Accessor for the <var>uri</var> property.
- *
- * @return a {@link URI} instance (never <code>null</code>)
- */
- public URI getURI() {
-
- return uri;
- }
-
- //
- // Methods extending Object
- //
-
- /**
- * The text representation of the URI.
- *
- * @return the text representation of the URI.
- */
- public String toString() {
-
- return uri.toString();
- }
-
- //
- // Methods overriding Object
- //
-
- /**
- * Return true if the URIs of a ModelResource are equal.
- *
- * @param object ModelResource to test equality.
- * @return true if the URIs of a ModelResource are equal.
- */
- public boolean equals(Object object) {
-
- if (object == null) {
-
- return false;
- }
-
- try {
-
- ModelResource tmpModelResource = (ModelResource) object;
- return getURI().equals(tmpModelResource.getURI());
- }
- catch (ClassCastException cce) {
-
- return false;
- }
- }
-
- /**
- * Returns the hashCode of a URI.
- *
- * @return the hashCode of a URI.
- */
- public int hashCode() {
-
- return uri.hashCode();
- }
-
- /**
- * Returns just the default Object clone.
- *
- * @return just the default Object clone.
- */
- public Object clone() {
-
- try {
-
- ModelResource cloned = (ModelResource) super.clone();
- cloned.uri = getURI();
- return cloned;
- }
- catch (CloneNotSupportedException e) {
-
- throw new RuntimeException("ModelResource not cloneable");
- }
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelResourceUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,146 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-// Java packages
-import java.net.URI;
-
-// JUnit
-import junit.framework.*;
-
-// Log4J
-import org.apache.log4j.Logger;
-
-/**
- * Tests the functionality of ModelResource.
- *
- * @created 2004-04-15
- *
- * @author Andrew Newman
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2003
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelResourceUnitTest extends TestCase {
-
- /**
- * Logger.
- */
- private static final Logger logger = Logger.getLogger(ModelResourceUnitTest.class);
-
- /**
- * Construct a new unit test.
- *
- * @param name the name of the test
- */
- public ModelResourceUnitTest(String name) {
-
- super(name);
- }
-
- /**
- * Hook for test runner to obtain a test suite from.
- *
- * @return The test suite
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite();
- suite.addTest(new ModelResourceUnitTest("testEquals"));
- suite.addTest(new ModelResourceUnitTest("testClone"));
- return suite;
- }
-
- /**
- * Default text runner.
- *
- * @param args The command line arguments
- */
- public static void main(String[] args) {
-
- junit.textui.TestRunner.run(suite());
- }
-
- //
- // Test cases
- //
-
- /**
- * Test equality of two model resource.
- */
- public void testEquals() {
-
- try {
-
- ModelResource res1 = new ModelResource(new URI("rmi://foo/server1#_"));
- ModelResource res2 = new ModelResource(new URI("rmi://foo/server1#"));
- ModelResource res3 = new ModelResource(new URI("rmi://foo/server1#"));
-
- assertEquals("Two ModelResource with the same RMI protcol should " +
- "resolve to the same server", res1.getDatabaseURIs(),
- res2.getDatabaseURIs());
-
- assertFalse("Resource should be unequal", res1.equals(res2));
-
- assertNotSame("Resources should be different instances", res2, res3);
- assertTrue("Resource should be equal", res2.equals(res3));
- }
- catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- /**
- * Test clone of two resources.
- */
- public void testClone() {
-
- try {
-
- ModelResource res1 = new ModelResource(new URI("rmi://foo/server1#_"));
- ModelResource res2 = (ModelResource) res1.clone();
-
- assertNotSame("Resources should be different instances", res1, res2);
- assertTrue("Resources should be equal", res1.equals(res2));
- }
- catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-}
-
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelUnion.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelUnion.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelUnion.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,81 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-/**
- * A model expression composed of the union of two subexpressions.
- *
- * @created 2001-08-12
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2001-2004
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelUnion extends ModelOperation {
-
- /**
- * Allow newer compiled version of the stub to operate when changes
- * have not occurred with the class.
- * NOTE : update this serialVersionUID when a method or a public member is
- * deleted.
- */
- static final long serialVersionUID = -2658255434397870185L;
-
- //
- // Constructor
- //
-
- /**
- * Construct a model union.
- *
- * @param lhs a non-<code>null</code> model expression
- * @param rhs another non-<code>null</code> model expression
- */
- public ModelUnion(ModelExpression lhs, ModelExpression rhs) {
- super(lhs, rhs);
- }
-
- /**
- * Legible representation
- *
- * @return RETURNED VALUE TO DO
- */
- public String toString() {
-
- return "(" + getLHS() + " union " + getRHS() + ")";
- }
-}
Deleted: branches/xa11/src/jar/query/java/org/mulgara/query/ModelVariable.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/ModelVariable.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/ModelVariable.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,134 +0,0 @@
-/**
- * The contents of this file are subject to the Open Software License
- * Version 3.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.opensource.org/licenses/osl-3.0.txt
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- */
-
-package org.mulgara.query;
-
-// Java 2 standard packages
-import java.net.*;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-/**
- * A leaf expression containing a variable that is used for the model expression.
- *
- * @created Apr 22, 2008
- * @author Paul Gearon
- * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public class ModelVariable implements Model {
-
- /** Used for serializing. */
- static final long serialVersionUID = 5132086338306266830L;
-
- /** Logger. */
- @SuppressWarnings("unused")
- private final static Logger logger = Logger.getLogger(ModelVariable.class);
-
- /** The variable for the graph */
- private Variable variable;
-
- //
- // Constructors
- //
-
- /**
- * Construct a model from a {@link URL}.
- *
- * @param uri the {@link URI} of the model to query
- * @throws IllegalArgumentException if <var>url</var> is <code>null</code>
- */
- public ModelVariable(Variable variable) {
- if (variable == null) throw new IllegalArgumentException("Null variable parameter");
- this.variable = variable;
- }
-
- //
- // Methods implementing ModelExpression
- //
-
- /**
- * Gets a set of database URIs to operate against.
- * @return We don't know what is in the variable, so return the empty {@link Set}
- */
- @SuppressWarnings("unchecked")
- public Set<URI> getDatabaseURIs() {
- return (Set<URI>)Collections.EMPTY_SET;
- }
-
- //
- // API methods
- //
-
- /**
- * Accessor for the <var>variable</var> property.
- * @return a {@link Variable} instance
- */
- public Variable getVariable() {
- return variable;
- }
-
- //
- // Methods extending Object
- //
-
- /**
- * The text representation of the URI.
- * @return the text representation of the URI.
- */
- public String toString() {
- return variable.toString();
- }
-
- //
- // Methods overriding Object
- //
-
- /**
- * Return true if the variables of a ModelVariable are equal.
- * @param object ModelVariable to test equality.
- * @return true if the variables of a ModelVariable are equal.
- */
- public boolean equals(Object object) {
- if (object == null) return false;
- if (object == this) return true;
-
- if (!(object instanceof ModelVariable)) return false;
- ModelVariable modelVar = (ModelVariable)object;
- return variable.equals(modelVar.variable);
- }
-
- /**
- * Returns the hashCode of a Variable.
- * @return the hashCode of a Variable.
- */
- public int hashCode() {
- return variable.hashCode();
- }
-
- /**
- * Returns just the default Object clone.
- * @return just the default Object clone.
- */
- public Object clone() {
- try {
- ModelVariable cloned = (ModelVariable)super.clone();
- cloned.variable = variable;
- return cloned;
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException("ModelVariable not cloneable");
- }
- }
-
-}
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/Query.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/Query.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/Query.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -82,7 +82,7 @@
private List<SelectElement> mutableVariableList;
/** The model expression. It corresponds to the <code>from</code> clause. */
- private ModelExpression modelExpression;
+ private GraphExpression graphExpression;
/** The constraint expression. It corresponds to the <code>where</code> clause. */
private ConstraintExpression constraintExpression;
@@ -126,7 +126,7 @@
* in the solution (i.e. columns of the result {@link Answer});
* <code>null</code> indicates that all columns are to be retained.
* This is a list of: Variable; ConstantValue; Count; Subquery.
- * @param modelExpression an expression defining the model to query, never
+ * @param graphExpression an expression defining the model to query, never
* <code>null</code>
* @param constraintExpression an expression defining the constraints to
* satisfy, never <code>null</code>
@@ -142,18 +142,18 @@
* {@link UnconstrainedAnswer} for no constraints; never
* <code>null</code> is
* @throws IllegalArgumentException if <var>limit</var> or <var>offset</var>
- * are negative, or if <var>modelExpression</var>,
+ * are negative, or if <var>graphExpression</var>,
* <var>constraintExpression</var>, <var>orderList<var> or
* <var>answer</var> are <code>null</code>
*/
- public Query(List<? extends SelectElement> variableList, ModelExpression modelExpression,
+ public Query(List<? extends SelectElement> variableList, GraphExpression graphExpression,
ConstraintExpression constraintExpression,
ConstraintHaving havingExpression, List<Order> orderList, Integer limit,
int offset, Answer answer) {
// Validate parameters
- if (modelExpression == null) {
- throw new IllegalArgumentException("Null \"modelExpression\" parameter");
+ if (graphExpression == null) {
+ throw new IllegalArgumentException("Null \"graphExpression\" parameter");
} else if (constraintExpression == null) {
throw new IllegalArgumentException("Null \"constraintExpression\" parameter");
} else if ((limit != null) && (limit.intValue() < 0)) {
@@ -183,7 +183,7 @@
// Initialize fields
this.mutableVariableList = (variableList == null) ? null : new ArrayList<SelectElement>(variableList);
this.variableList = (variableList == null) ? null : Collections.unmodifiableList(mutableVariableList);
- this.modelExpression = modelExpression;
+ this.graphExpression = graphExpression;
this.constraintExpression = constraintExpression;
this.havingConstraint = havingExpression;
this.orderList = Collections.unmodifiableList(new ArrayList<Order>(orderList));
@@ -200,7 +200,7 @@
public Query(Query query, ConstraintExpression where) {
this.mutableVariableList = query.mutableVariableList;
this.variableList = query.variableList;
- this.modelExpression = query.modelExpression;
+ this.graphExpression = query.graphExpression;
this.constraintExpression = where;
this.havingConstraint = query.havingConstraint;
this.orderList = query.orderList;
@@ -251,7 +251,7 @@
}
cloned.mutableVariableList = Collections.unmodifiableList(cloned.variableList);
}
- cloned.modelExpression = modelExpression; // FIXME: should be cloned
+ cloned.graphExpression = graphExpression; // FIXME: should be cloned
cloned.answer = (Answer)answer.clone();
// Copy immutable fields by reference
@@ -297,11 +297,11 @@
/**
- * Accessor for the <code>modelExpression</code> property.
- * @return a {@link ModelExpression}, or <code>null</code> to indicate the empty model
+ * Accessor for the <code>graphExpression</code> property.
+ * @return a {@link GraphExpression}, or <code>null</code> to indicate the empty model
*/
- public ModelExpression getModelExpression() {
- return modelExpression;
+ public GraphExpression getModelExpression() {
+ return graphExpression;
}
@@ -364,10 +364,10 @@
// Check the variableList field
if (!variableList.equals(query.variableList)) return false;
- // Check the modelExpression field
- if ((modelExpression == null) ?
- (query.modelExpression != null) :
- (!modelExpression.equals(query.modelExpression))) {
+ // Check the graphExpression field
+ if ((graphExpression == null) ?
+ (query.graphExpression != null) :
+ (!graphExpression.equals(query.graphExpression))) {
return false;
}
@@ -450,7 +450,7 @@
}
// FROM
- buffer.append("FROM ").append(modelExpression);
+ buffer.append("FROM ").append(graphExpression);
// WHERE
buffer.append(" WHERE ").append(constraintExpression);
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/QueryUnitTest.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/QueryUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/QueryUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -101,7 +101,7 @@
public void setUp() throws Exception {
query = new Query(
Arrays.asList(new SelectElement[] { new Variable("x") }), // variable list
- new ModelResource(new URI("x:m")), // model expression
+ new GraphResource(new URI("x:m")), // model expression
new ConstraintImpl(new Variable("x"), // constraint expression
new URIReferenceImpl(new URI("x:p")),
new LiteralImpl("o")),
@@ -147,7 +147,7 @@
// Compose test instances
Query query2 = new Query(
Arrays.asList(new SelectElement[] { new Variable("x") }), // variable list
- new ModelResource(new URI("x:m")), // model expression
+ new GraphResource(new URI("x:m")), // model expression
new ConstraintImpl(new Variable("x"), // constraint expression
new URIReferenceImpl(new URI("x:p")),
new LiteralImpl("o")),
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/Backup.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/Backup.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/Backup.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -96,7 +96,12 @@
URI src = getSource();
URI dest = getDestination();
if (serverTest(src)) throw new QueryException("Cannot back up a graph. Must be a server URI.");
-
+
+ if (isLocal() && !conn.isRemote()) {
+ logger.error("Used a LOCAL modifier when backing up <" + src + "> to <" + dest + "> on a non-remote server.");
+ throw new QueryException("LOCAL modifier is not valid for BACKUP command when not using a client-server connection.");
+ }
+
try {
if (isLocal()) {
getMarshalledData(conn);
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -43,7 +43,7 @@
private static final String ZIP_EXTENSION = ".zip";
/** A stream to enable an API to load or restore data directly. */
- private InputStream overrideInputStream = null;
+ protected InputStream overrideInputStream = null;
/**
* Create a new data transfer command for moving data into a graph or server.
@@ -96,12 +96,14 @@
protected long sendMarshalledData(Connection conn, boolean compressable) throws QueryException, IOException {
if (logger.isInfoEnabled()) logger.info("Sending local resource : " + getSource());
+ InputStream inputStream = getLocalInputStream(compressable);
+
+ // If the connection is local, then no need to wrap
+ if (!conn.isRemote()) return doTx(conn, inputStream);
+
RemoteInputStreamSrvImpl srv = null;
RemoteInputStream remoteInputStream = null;
try {
-
- InputStream inputStream = getLocalInputStream(compressable);
-
// open and wrap the inputstream
srv = new RemoteInputStreamSrvImpl(inputStream);
Rmi.export(srv);
@@ -134,7 +136,7 @@
* @throws QueryException If no valid data source was set.
* @throws IOException If an error occurred opening the local source.
*/
- private InputStream getLocalInputStream(boolean compressable) throws QueryException, IOException {
+ protected InputStream getLocalInputStream(boolean compressable) throws QueryException, IOException {
// Use provided input stream if there is one.
InputStream stream = overrideInputStream;
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/Export.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/Export.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/Export.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -73,7 +73,12 @@
public Object execute(Connection conn) throws QueryException {
URI src = getSource();
URI dest = getDestination();
-
+
+ if (isLocal() && !conn.isRemote()) {
+ logger.error("Used a LOCAL modifier when exporting <" + src + "> to <" + dest + "> on a non-remote server.");
+ throw new QueryException("LOCAL modifier is not valid for EXPORT command when not using a client-server connection.");
+ }
+
try {
if (isLocal()) {
getMarshalledData(conn);
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/Load.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/Load.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/Load.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -17,7 +17,7 @@
import org.apache.log4j.Logger;
import org.mulgara.connection.Connection;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.QueryException;
import org.mulgara.query.rdf.Mulgara;
@@ -37,8 +37,8 @@
/** Dummy source model URI to pass to the server when overriding with local stream. */
protected static final URI DUMMY_RDF_SOURCE = URI.create(Mulgara.NAMESPACE+"locally-sourced-inputStream.rdf");
- /** Model resource form of the source URI */
- private final ModelResource srcRsc;
+ /** Graph resource form of the source URI */
+ private final GraphResource srcRsc;
/**
* Build a load operation, loading data from one URI into a graph specified by another URI.
@@ -52,7 +52,7 @@
// Validate arguments.
if (graphURI == null) throw new IllegalArgumentException("Need a valid destination graph URI");
- srcRsc = new ModelResource(source == null ? DUMMY_RDF_SOURCE : source);
+ srcRsc = new GraphResource(source == null ? DUMMY_RDF_SOURCE : source);
}
@@ -75,6 +75,12 @@
public Object execute(Connection conn) throws QueryException {
URI src = getSource();
URI dest = getDestination();
+
+ if (isLocal() && !conn.isRemote() && overrideInputStream == null) {
+ logger.error("Used a LOCAL modifier when loading <" + src + "> to <" + dest + "> on a non-remote server.");
+ throw new QueryException("LOCAL modifier is not valid for LOAD command when not using a client-server connection.");
+ }
+
try {
long stmtCount = isLocal() ? sendMarshalledData(conn, true) : conn.getSession().setModel(dest, srcRsc);
if (logger.isDebugEnabled()) logger.debug("Loaded " + stmtCount + " statements from " + src + " into " + dest);
@@ -101,4 +107,15 @@
return conn.getSession().setModel(inputStream, getDestination(), srcRsc);
}
+
+ /**
+ * Get the text of the command, or generate a virtual command if no text was parsed.
+ * @return The query that created this command, or a generated query if no query exists.
+ */
+ public String getText() {
+ String text = super.getText();
+ if (text == null || text.length() == 0) text = "load <" + getSource() + "> into <" + getDestination() + ">";
+ return text;
+ }
+
}
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/Restore.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/Restore.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/Restore.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -89,6 +89,12 @@
URI src = getSource();
URI dest = getDestination();
if (serverTest(dest)) throw new QueryException("Cannot restore to a graph. Must be a server URI.");
+
+ if (isLocal() && !conn.isRemote()) {
+ logger.error("Used a LOCAL modifier when restoring <" + src + "> to <" + dest + "> on a non-remote server.");
+ throw new QueryException("LOCAL modifier is not valid for RESTORE command when not using a client-server connection.");
+ }
+
try {
if (isLocal()) sendMarshalledData(conn, false);
else conn.getSession().restore(src);
Modified: branches/xa11/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -15,7 +15,7 @@
import java.util.Iterator;
import java.util.Set;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
/**
* An AST element for server-based commands.
@@ -28,10 +28,10 @@
public abstract class ServerCommand implements Command {
/** The text used to create this command. */
- private String textualForm;
+ private String textualForm = "";
/** The graph being referred to on the server. */
- private final ModelResource serverGraph;
+ private final GraphResource serverGraph;
/** The message set by the result of this command. */
private String resultMessage;
@@ -41,7 +41,7 @@
* @param serverGraphUri The URI of the graph.
*/
public ServerCommand(URI serverGraphUri) {
- serverGraph = (serverGraphUri != null) ? new ModelResource(serverGraphUri) : null;
+ serverGraph = (serverGraphUri != null) ? new GraphResource(serverGraphUri) : null;
resultMessage = "";
}
Modified: branches/xa11/src/jar/query/java/org/mulgara/server/Session.java
===================================================================
--- branches/xa11/src/jar/query/java/org/mulgara/server/Session.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/query/java/org/mulgara/server/Session.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,7 +41,7 @@
import org.mulgara.query.AskQuery;
import org.mulgara.query.ConstructQuery;
import org.mulgara.query.GraphAnswer;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.query.rdf.Mulgara;
@@ -278,14 +278,14 @@
public boolean modelExists(URI uri) throws QueryException;
/**
- * Define the contents of a model via a {@link ModelExpression}
+ * Define the contents of a model via a {@link GraphExpression}
*
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
*/
- public long setModel(URI uri, ModelExpression modelExpression)
+ public long setModel(URI uri, GraphExpression graphExpression)
throws QueryException;
/**
@@ -293,12 +293,12 @@
*
* @param inputStream a remote inputstream
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
*/
public long setModel(InputStream inputStream, URI uri,
- ModelExpression modelExpression) throws QueryException;
+ GraphExpression graphExpression) throws QueryException;
/**
* Extract {@link Rules} from the data found in a model.
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/Collaborator.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/Collaborator.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/Collaborator.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -785,7 +785,7 @@
}
if (initialized == false) {
- // Model has not been initialized
+ // Graph has not been initialized
initialized = createModel();
} else {
log.debug("Collaborator model already initialized at " + SERVER + MODEL);
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/CollaboratorUnitTest.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/CollaboratorUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/CollaboratorUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -161,7 +161,7 @@
assertTrue("Failed to create collaborator model", collaborator.createModel());
} catch (SOAPException ex) {
ex.printStackTrace();
- fail("Model tests failed " + ex.getMessage());
+ fail("Graph tests failed " + ex.getMessage());
}
}
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/ConstraintExpressionBuilder.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/ConstraintExpressionBuilder.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/ConstraintExpressionBuilder.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -133,7 +133,87 @@
}
+ public void caseAConstraintConstraintFactor(AConstraintConstraintFactor rawConstraintFactor) {
+
+ if (logger.isDebugEnabled()) logger.debug("Found constraint constraint factor " + rawConstraintFactor);
+
+ // get the constraint
+ PConstraint constraint = ((AConstraintConstraintFactor)rawConstraintFactor).getConstraint();
+
+ if (logger.isDebugEnabled()) logger.debug("Found constraint " + constraint + ", resolving components");
+
+ // get the constraint's components
+ try {
+ Constraint tmpConstraint;
+
+ ConstraintElement subject = toConstraintElement(((AConstraint)constraint).getSubject());
+ ConstraintElement predicate = toConstraintElement(((AConstraint)constraint).getPredicate());
+ ConstraintElement object = toConstraintElement(((AConstraint)constraint).getObject());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found subject " + subject);
+ logger.debug("Found predicate " + predicate);
+ logger.debug("Found object " + object);
+ }
+
+ // check for an IN clause
+ AInClause inClause = (AInClause)((AConstraint)constraint).getInClause();
+
+ // bundle them into a constraint (order is probably important here...?)
+ if (inClause != null) {
+ if (logger.isDebugEnabled()) logger.debug("Found model " + inClause.getElement());
+
+ ConstraintElement model = toConstraintElement(inClause.getElement());
+ tmpConstraint = ConstraintFactory.newConstraint(subject, predicate, object, model);
+ } else {
+ tmpConstraint = ConstraintFactory.newConstraint(subject, predicate, object);
+ }
+
+ // Set new value.
+ if (logger.isDebugEnabled()) logger.debug("Setting constraint: " + tmpConstraint);
+
+ setConstraintExpression(tmpConstraint);
+ } catch (URISyntaxException use) {
+ uriException = use;
+ } catch (QueryException qe) {
+ queryException = qe;
+ }
+ }
+
+
/**
+ * Handle a constraint expression. Will set URIException or QueryException if
+ * an exception occurs.
+ *
+ * @param rawConstraintFactor the expression to create a constraint expression from.
+ */
+ public void caseAExpressionConstraintFactor(AExpressionConstraintFactor rawConstraintFactor) {
+
+ try {
+ ConstraintExpression tmpConstraintExpression;
+
+ if (logger.isDebugEnabled()) logger.debug("Found factor expression constraint factor " + rawConstraintFactor);
+
+ // get the constraint expression
+ PConstraintExpression embeddedConstraintExpression =
+ ((AExpressionConstraintFactor)rawConstraintFactor).getConstraintExpression();
+
+ if (logger.isDebugEnabled()) logger.debug("Recursing with constraint factor " + embeddedConstraintExpression);
+
+ // build the constraint expression
+ ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
+ embeddedConstraintExpression.apply((Switch) builder);
+
+ setConstraintExpression(builder.getConstraintExpression());
+ } catch (URISyntaxException use) {
+ uriException = use;
+ } catch (QueryException qe) {
+ queryException = qe;
+ }
+ }
+
+
+ /**
* Handle a transitive constraint. Will set URIException or QueryException if
* an exception occurs.
*
Copied: branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java (from rev 1423, trunk/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java)
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java (rev 0)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphExpressionBuilder.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,551 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.itql;
+
+// Java 2 standard packages
+import java.net.*;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+// Automatically generated packages (SableCC)
+import org.mulgara.itql.node.AAndModelTerm;
+import org.mulgara.itql.node.AExpressionModelFactor;
+import org.mulgara.itql.node.AFactorModelPart;
+import org.mulgara.itql.node.AOrModelExpression;
+import org.mulgara.itql.node.APartModelTerm;
+import org.mulgara.itql.node.AResourceModelFactor;
+import org.mulgara.itql.node.ATermModelExpression;
+import org.mulgara.itql.node.AXorModelPart;
+import org.mulgara.itql.node.PModelExpression;
+import org.mulgara.itql.node.PModelFactor;
+import org.mulgara.itql.node.PModelPart;
+import org.mulgara.itql.node.PModelTerm;
+import org.mulgara.query.GraphExpression;
+import org.mulgara.query.GraphIntersection;
+import org.mulgara.query.GraphPartition;
+import org.mulgara.query.GraphResource;
+import org.mulgara.query.GraphUnion;
+import org.mulgara.query.QueryException;
+import org.mulgara.util.ServerURIHandler;
+import org.mulgara.util.URIUtil;
+
+/**
+ * Builds model expressions using input from the iTQL command interpreter.
+ *
+ * @created 2001-09-11
+ *
+ * @author Tom Adams
+ *
+ * @version $Revision: 1.9 $
+ *
+ * @modified $Date: 2005/04/04 11:30:11 $ by $Author: tomadams $
+ *
+ * @maintenanceAuthor $Author: tomadams $
+ *
+ * @copyright ©2001-2004
+ * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphExpressionBuilder {
+
+ //
+ // Constants
+ //
+
+ /**
+ * the category to log to
+ */
+ private final static Logger logger =
+ Logger.getLogger(GraphExpressionBuilder.class.getName());
+
+ //
+ // Public API (methods overridden from ExpressionBuilder)
+ //
+
+ /**
+ * Builds a {@link org.mulgara.query.GraphExpression} object from a {@link
+ * org.mulgara.itql.node.PModelExpression}, using an <code>aliasMap</code>
+ * to resolve aliases.
+ *
+ * TODO: aliasMap is currently ignored!
+ *
+ * @param aliasMap the map from targets to aliases
+ * @param expression a model expression from the parser
+ * @return RETURNED VALUE TO DO
+ * @throws QueryException if <code>rawModelExpression</code> does not
+ * represent a valid query
+ * @throws URISyntaxException if the <code>rawModelExpression</code> contains
+ * a resource whose text violates <a
+ * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
+ */
+ public static GraphExpression build(Map<String,URI> aliasMap,
+ PModelExpression expression) throws QueryException, URISyntaxException {
+
+ // validate aliasMap parameter
+ if (aliasMap == null) {
+
+ throw new IllegalArgumentException("Null \"aliasMap\" parameter");
+ }
+
+ // end if
+ // validate expression parameter
+ if (expression == null) {
+
+ throw new IllegalArgumentException("Null \"expression\" parameter");
+ }
+
+ // end if
+ // logger that we're building a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Building model expression from " + expression);
+ }
+
+ // build the model expression from the parser input
+ GraphExpression graphExpression = buildModelExpression(expression, aliasMap);
+
+ // logger that we've building successfully built a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Successfully built model expression from " + expression);
+ }
+
+ // return the model expression
+ return graphExpression;
+ }
+
+ // build()
+ //
+ // Internal methods
+ //
+
+ /**
+ * Recursively builds a {@link org.mulgara.query.GraphExpression} from a
+ * {@link org.mulgara.itql.node.PModelExpression}.
+ *
+ * @param rawModelExpression a raw model expression from the parser
+ * @return a {@link org.mulgara.query.GraphExpression} suitable for use in
+ * creating a {@link org.mulgara.query.Query}
+ * @throws QueryException if <code>rawModelExpression</code> does not
+ * represent a valid query
+ * @throws URISyntaxException if the <code>rawModelExpression</code> contains
+ * a resource whose text violates <a
+ * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
+ */
+ private static GraphExpression buildModelExpression(
+ PModelExpression rawModelExpression, Map<String,URI> aliasMap)
+ throws QueryException, URISyntaxException {
+
+ // validate the rawModelExpression parameter
+ if (rawModelExpression == null) {
+
+ throw new IllegalArgumentException("Null \"rawModelExpression\" " +
+ "parameter");
+ }
+
+ // end if
+ // logger that we're building a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Building model expression from " + rawModelExpression);
+ }
+
+ // create a new model expression that we can return
+ GraphExpression graphExpression = null;
+
+ // drill down to find its constituents
+ if (rawModelExpression instanceof AOrModelExpression) {
+
+ // logger that we've found a OR model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found OR model expression " + rawModelExpression);
+ }
+
+ // get the OR model expression
+ PModelExpression orModelExpression =
+ ((AOrModelExpression) rawModelExpression).getModelExpression();
+
+ // get the model term
+ PModelTerm modelTerm =
+ ((AOrModelExpression) rawModelExpression).getModelTerm();
+
+ // logger that we've found the operands of the union
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model expression " + orModelExpression +
+ " & model term " + modelTerm);
+ }
+
+ // get the LHS and RHS operands of the union
+ GraphExpression lhs = buildModelExpression(orModelExpression, aliasMap);
+ GraphExpression rhs = buildModelExpression(modelTerm, aliasMap);
+
+ // logger that we've resolved the operands
+ if (logger.isDebugEnabled()) {
+ logger.debug("Resolved LHS union operand " + lhs);
+ logger.debug("Resolved RHS union operand " + rhs);
+ }
+
+ // apply the union
+ graphExpression = new GraphUnion(lhs, rhs);
+ } else if (rawModelExpression instanceof ATermModelExpression) {
+
+ // logger that we've got a term model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found term model expression " + rawModelExpression);
+ }
+
+ // get the model term
+ PModelTerm modelTerm = ((ATermModelExpression)rawModelExpression).getModelTerm();
+
+ // logger that we're about to resolve the term into an expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model term " + modelTerm);
+ }
+
+ // drill down into the model term
+ graphExpression = buildModelExpression(modelTerm, aliasMap);
+ }
+
+ // end if
+ // we should not be returning null
+ if (graphExpression == null) {
+
+ throw new QueryException("Unable to parse ITQL model expression " +
+ "into a valid model expression");
+ }
+
+ // end if
+ // logger that we've created a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created model expression " + graphExpression);
+ }
+
+ // return the built up expression
+ return graphExpression;
+ }
+
+ // buildModelExpression()
+
+ /**
+ * Recursively builds a {@link org.mulgara.query.GraphExpression} from a
+ * {@link org.mulgara.itql.node.PModelTerm}.
+ *
+ * @param rawModelTerm a raw model term from the parser
+ * @return a {@link org.mulgara.query.GraphExpression} suitable for use in
+ * creating a {@link org.mulgara.query.Query}
+ * @throws QueryException if <code>rawModelExpression</code> does not
+ * represent a valid query
+ * @throws URISyntaxException if the <code>rawModelExpression</code> contains
+ * a resource whose text violates <a
+ * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
+ */
+ private static GraphExpression buildModelExpression(
+ PModelTerm rawModelTerm, Map<String,URI> aliasMap
+ ) throws QueryException, URISyntaxException {
+
+ // validate the rawModelTerm parameter
+ if (rawModelTerm == null) {
+
+ throw new IllegalArgumentException("Null \"rawModelTerm\" " +
+ "parameter");
+ }
+
+ // end if
+ // logger that we're building a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Building model expression from " + rawModelTerm);
+ }
+
+ // create a new model expression that we can return
+ GraphExpression graphExpression = null;
+
+ // drill down into the model term
+ if (rawModelTerm instanceof APartModelTerm) {
+
+ // logger that we've got a factor model term
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found factor contraint term " + rawModelTerm);
+ }
+
+ // get the model factor
+ PModelPart modelPart = ((APartModelTerm) rawModelTerm).getModelPart();
+
+ // logger that we're recursing with a model part
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model part " + modelPart);
+ }
+
+ // drill down into the model part
+ graphExpression = buildModelExpression(modelPart, aliasMap);
+
+ } else if (rawModelTerm instanceof AAndModelTerm) {
+
+ // logger that we've got a AND model term
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found AND contraint term " + rawModelTerm);
+ }
+
+ // get the model term
+ PModelTerm modelTerm = ((AAndModelTerm)rawModelTerm).getModelTerm();
+
+ // get the model part
+ PModelPart modelPart = ((AAndModelTerm)rawModelTerm).getModelPart();
+
+ // logger that we've found the operands of the union
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model term " + modelTerm +
+ " & model part " + modelPart);
+ }
+
+ // get the LHS and RHS operands of the intersection
+ GraphExpression lhs = buildModelExpression(modelTerm, aliasMap);
+ GraphExpression rhs = buildModelExpression(modelPart, aliasMap);
+
+ // logger that we've resolved the operands
+ if (logger.isDebugEnabled()) {
+ logger.debug("Resolved LHS intersection operand " + lhs);
+ logger.debug("Resolved RHS intersection operand " + rhs);
+ }
+
+ // apply the intersection
+ graphExpression = new GraphIntersection(lhs, rhs);
+ }
+
+ // end if
+ // we should not be returning null
+ if (graphExpression == null) {
+
+ throw new QueryException("Unable to parse ITQL model term into a valid model expression");
+ }
+
+ // end if
+ // logger that we've created a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created model expression " + graphExpression);
+ }
+
+ // return the built up expression
+ return graphExpression;
+ }
+
+ // buildModelExpression()
+
+ /**
+ * Recursively builds a {@link org.mulgara.query.GraphExpression} from a
+ * {@link org.mulgara.itql.node.PModelPart}.
+ *
+ * @param rawModelPart a raw model part from the parser
+ * @return a {@link org.mulgara.query.GraphExpression} suitable for use in
+ * creating a {@link org.mulgara.query.Query}
+ * @throws QueryException if <code>rawModelExpression</code> does not
+ * represent a valid query
+ * @throws URISyntaxException if the <code>rawModelExpression</code> contains
+ * a resource whose text violates <a
+ * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
+ */
+ private static GraphExpression buildModelExpression(
+ PModelPart rawModelPart, Map<String,URI> aliasMap
+ ) throws QueryException, URISyntaxException {
+
+ // validate the rawModelPart parameter
+ if (rawModelPart == null) {
+ throw new IllegalArgumentException("Null \"rawModelPart\" " +
+ "parameter");
+ }
+
+ // end if
+ // logger that we're building a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Building model expression from " + rawModelPart);
+ }
+
+ // create a new model expression that we can return
+ GraphExpression graphExpression = null;
+
+ // drill down into the model term
+ if (rawModelPart instanceof AFactorModelPart) {
+
+ // logger that we've got a factor model term
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found factor contraint term " + rawModelPart);
+ }
+
+ // get the model factor
+ PModelFactor modelFactor = ((AFactorModelPart)rawModelPart).getModelFactor();
+
+ // logger that we're recursing with a model factor
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model factor " + modelFactor);
+ }
+
+ // drill down into the model part
+ graphExpression = buildModelExpression(modelFactor, aliasMap);
+ } else if (rawModelPart instanceof AXorModelPart) {
+
+ // logger that we've got a AND model term
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found AND contraint term " + rawModelPart);
+ }
+
+ // get the model term
+ PModelPart modelPart = ((AXorModelPart)rawModelPart).getModelPart();
+
+ // get the model factor
+ PModelFactor modelFactor = ((AXorModelPart)rawModelPart).getModelFactor();
+
+ // logger that we've found the operands of the union
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model part " + modelPart + " & model factor " + modelFactor);
+ }
+
+ // get the LHS and RHS operands of the intersection
+ GraphExpression lhs = buildModelExpression(modelPart, aliasMap);
+ GraphExpression rhs = buildModelExpression(modelFactor, aliasMap);
+
+ // logger that we've resolved the operands
+ if (logger.isDebugEnabled()) {
+ logger.debug("Resolved LHS intersection operand " + lhs);
+ logger.debug("Resolved RHS intersection operand " + rhs);
+ }
+
+ // apply the intersection
+ graphExpression = new GraphPartition(lhs, rhs);
+ }
+
+ // end if
+ // we should not be returning null
+ if (graphExpression == null) {
+
+ throw new QueryException("Unable to parse ITQL model term into a valid model expression");
+ }
+
+ // end if
+ // logger that we've created a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created model expression " + graphExpression);
+ }
+
+ // return the built up expression
+ return graphExpression;
+ }
+
+ // buildModelExpression()
+
+ /**
+ * Recursively builds a {@link org.mulgara.query.GraphExpression} from a
+ * {@link org.mulgara.itql.node.PModelFactor}.
+ *
+ * @param rawModelFactor a raw model factor from the parser
+ * @return a {@link org.mulgara.query.GraphExpression} suitable for use in
+ * creating a {@link org.mulgara.query.Query}
+ * @throws QueryException if <code>rawModelExpression</code> does not
+ * represent a valid query
+ * @throws URISyntaxException if the <code>rawModelExpression</code> contains
+ * a resource whose text violates <a
+ * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
+ */
+ private static GraphExpression buildModelExpression(
+ PModelFactor rawModelFactor, Map<String,URI> aliasMap
+ ) throws QueryException, URISyntaxException {
+
+ // validate the rawModelFactor parameter
+ if (rawModelFactor == null) {
+
+ throw new IllegalArgumentException("Null \"rawModelFactor\" parameter");
+ }
+
+ // end if
+ // logger that we're building a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Building model expression from " + rawModelFactor);
+ }
+
+ // create a new model expression that we can return
+ GraphExpression graphExpression = null;
+
+ // drill down into the model term
+ if (rawModelFactor instanceof AResourceModelFactor) {
+
+ // logger that we've got a model model factor
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found resource model factor " + rawModelFactor);
+ }
+
+ // get the resource
+ String resource = ((AResourceModelFactor)rawModelFactor).getResource().getText();
+
+ // logger that we've found a resource
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found resource " + resource);
+ }
+
+ // this resource is what we're looking for
+ URI modelURI = URIUtil.convertToURI(resource, aliasMap);
+ graphExpression = new GraphResource(ServerURIHandler.removePort(modelURI));
+ } else if (rawModelFactor instanceof AExpressionModelFactor) {
+
+ // logger that we've got an expression model factor
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found factor expression model factor " + rawModelFactor);
+ }
+
+ // get the model expression
+ PModelExpression embeddedModelExpression = ((AExpressionModelFactor)rawModelFactor).getModelExpression();
+
+ // logger that we're recursing with a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recursing with model factor " + graphExpression);
+ }
+
+ // build the model expression
+ graphExpression = buildModelExpression(embeddedModelExpression, aliasMap);
+ }
+
+ // end if
+ // we should not be returning null
+ if (graphExpression == null) {
+
+ throw new QueryException("Unable to parse ITQL model factor " +
+ "into a valid model expression");
+ }
+
+ // end if
+ // logger that we've created a model expression
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created model expression " + graphExpression);
+ }
+
+ // return the built up expression
+ return graphExpression;
+ }
+
+ // buildModelExpression()
+}
+
+
+// GraphExpressionBuilder
Copied: branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java (from rev 1423, trunk/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java)
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java (rev 0)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/GraphNameCompletor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,56 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.itql;
+
+import java.util.List;
+
+import jline.Completor;
+
+public class GraphNameCompletor implements Completor {
+
+ private List<String> modelNames;
+
+ public GraphNameCompletor(List<String> modelNames) {
+ this.modelNames = modelNames;
+ }
+
+ @SuppressWarnings("unchecked")
+ public int complete(String s, int idx, List completionList) {
+ int retValue = idx;
+
+ if(s.endsWith("<")) {
+ completionList.addAll(modelNames);
+ } else {
+ int gtIdx = s.lastIndexOf("<");
+ boolean addedSomething = false;
+
+ if(gtIdx >= 0) {
+ String partial = s.substring(gtIdx+1);
+ for(String s2 : modelNames) {
+ if(s2.startsWith(partial)) {
+ completionList.add(s2);
+ addedSomething = true;
+ }
+ }
+ }
+
+ if(addedSomething) {
+ retValue = gtIdx + 1;
+ }
+ }
+
+ // TODO Auto-generated method stub
+ return retValue ;
+ }
+
+}
Deleted: branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelExpressionBuilder.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,551 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.itql;
-
-// Java 2 standard packages
-import java.net.*;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-// Automatically generated packages (SableCC)
-import org.mulgara.itql.node.AAndModelTerm;
-import org.mulgara.itql.node.AExpressionModelFactor;
-import org.mulgara.itql.node.AFactorModelPart;
-import org.mulgara.itql.node.AOrModelExpression;
-import org.mulgara.itql.node.APartModelTerm;
-import org.mulgara.itql.node.AResourceModelFactor;
-import org.mulgara.itql.node.ATermModelExpression;
-import org.mulgara.itql.node.AXorModelPart;
-import org.mulgara.itql.node.PModelExpression;
-import org.mulgara.itql.node.PModelFactor;
-import org.mulgara.itql.node.PModelPart;
-import org.mulgara.itql.node.PModelTerm;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.ModelIntersection;
-import org.mulgara.query.ModelPartition;
-import org.mulgara.query.ModelResource;
-import org.mulgara.query.ModelUnion;
-import org.mulgara.query.QueryException;
-import org.mulgara.util.ServerURIHandler;
-import org.mulgara.util.URIUtil;
-
-/**
- * Builds model expressions using input from the iTQL command interpreter.
- *
- * @created 2001-09-11
- *
- * @author Tom Adams
- *
- * @version $Revision: 1.9 $
- *
- * @modified $Date: 2005/04/04 11:30:11 $ by $Author: tomadams $
- *
- * @maintenanceAuthor $Author: tomadams $
- *
- * @copyright ©2001-2004
- * <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelExpressionBuilder {
-
- //
- // Constants
- //
-
- /**
- * the category to log to
- */
- private final static Logger logger =
- Logger.getLogger(ModelExpressionBuilder.class.getName());
-
- //
- // Public API (methods overridden from ExpressionBuilder)
- //
-
- /**
- * Builds a {@link org.mulgara.query.ModelExpression} object from a {@link
- * org.mulgara.itql.node.PModelExpression}, using an <code>aliasMap</code>
- * to resolve aliases.
- *
- * TODO: aliasMap is currently ignored!
- *
- * @param aliasMap the map from targets to aliases
- * @param expression a model expression from the parser
- * @return RETURNED VALUE TO DO
- * @throws QueryException if <code>rawModelExpression</code> does not
- * represent a valid query
- * @throws URISyntaxException if the <code>rawModelExpression</code> contains
- * a resource whose text violates <a
- * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
- */
- public static ModelExpression build(Map<String,URI> aliasMap,
- PModelExpression expression) throws QueryException, URISyntaxException {
-
- // validate aliasMap parameter
- if (aliasMap == null) {
-
- throw new IllegalArgumentException("Null \"aliasMap\" parameter");
- }
-
- // end if
- // validate expression parameter
- if (expression == null) {
-
- throw new IllegalArgumentException("Null \"expression\" parameter");
- }
-
- // end if
- // logger that we're building a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Building model expression from " + expression);
- }
-
- // build the model expression from the parser input
- ModelExpression modelExpression = buildModelExpression(expression, aliasMap);
-
- // logger that we've building successfully built a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Successfully built model expression from " + expression);
- }
-
- // return the model expression
- return modelExpression;
- }
-
- // build()
- //
- // Internal methods
- //
-
- /**
- * Recursively builds a {@link org.mulgara.query.ModelExpression} from a
- * {@link org.mulgara.itql.node.PModelExpression}.
- *
- * @param rawModelExpression a raw model expression from the parser
- * @return a {@link org.mulgara.query.ModelExpression} suitable for use in
- * creating a {@link org.mulgara.query.Query}
- * @throws QueryException if <code>rawModelExpression</code> does not
- * represent a valid query
- * @throws URISyntaxException if the <code>rawModelExpression</code> contains
- * a resource whose text violates <a
- * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
- */
- private static ModelExpression buildModelExpression(
- PModelExpression rawModelExpression, Map<String,URI> aliasMap)
- throws QueryException, URISyntaxException {
-
- // validate the rawModelExpression parameter
- if (rawModelExpression == null) {
-
- throw new IllegalArgumentException("Null \"rawModelExpression\" " +
- "parameter");
- }
-
- // end if
- // logger that we're building a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Building model expression from " + rawModelExpression);
- }
-
- // create a new model expression that we can return
- ModelExpression modelExpression = null;
-
- // drill down to find its constituents
- if (rawModelExpression instanceof AOrModelExpression) {
-
- // logger that we've found a OR model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Found OR model expression " + rawModelExpression);
- }
-
- // get the OR model expression
- PModelExpression orModelExpression =
- ((AOrModelExpression) rawModelExpression).getModelExpression();
-
- // get the model term
- PModelTerm modelTerm =
- ((AOrModelExpression) rawModelExpression).getModelTerm();
-
- // logger that we've found the operands of the union
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model expression " + orModelExpression +
- " & model term " + modelTerm);
- }
-
- // get the LHS and RHS operands of the union
- ModelExpression lhs = buildModelExpression(orModelExpression, aliasMap);
- ModelExpression rhs = buildModelExpression(modelTerm, aliasMap);
-
- // logger that we've resolved the operands
- if (logger.isDebugEnabled()) {
- logger.debug("Resolved LHS union operand " + lhs);
- logger.debug("Resolved RHS union operand " + rhs);
- }
-
- // apply the union
- modelExpression = new ModelUnion(lhs, rhs);
- } else if (rawModelExpression instanceof ATermModelExpression) {
-
- // logger that we've got a term model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Found term model expression " + rawModelExpression);
- }
-
- // get the model term
- PModelTerm modelTerm = ((ATermModelExpression)rawModelExpression).getModelTerm();
-
- // logger that we're about to resolve the term into an expression
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model term " + modelTerm);
- }
-
- // drill down into the model term
- modelExpression = buildModelExpression(modelTerm, aliasMap);
- }
-
- // end if
- // we should not be returning null
- if (modelExpression == null) {
-
- throw new QueryException("Unable to parse ITQL model expression " +
- "into a valid model expression");
- }
-
- // end if
- // logger that we've created a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Created model expression " + modelExpression);
- }
-
- // return the built up expression
- return modelExpression;
- }
-
- // buildModelExpression()
-
- /**
- * Recursively builds a {@link org.mulgara.query.ModelExpression} from a
- * {@link org.mulgara.itql.node.PModelTerm}.
- *
- * @param rawModelTerm a raw model term from the parser
- * @return a {@link org.mulgara.query.ModelExpression} suitable for use in
- * creating a {@link org.mulgara.query.Query}
- * @throws QueryException if <code>rawModelExpression</code> does not
- * represent a valid query
- * @throws URISyntaxException if the <code>rawModelExpression</code> contains
- * a resource whose text violates <a
- * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
- */
- private static ModelExpression buildModelExpression(
- PModelTerm rawModelTerm, Map<String,URI> aliasMap
- ) throws QueryException, URISyntaxException {
-
- // validate the rawModelTerm parameter
- if (rawModelTerm == null) {
-
- throw new IllegalArgumentException("Null \"rawModelTerm\" " +
- "parameter");
- }
-
- // end if
- // logger that we're building a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Building model expression from " + rawModelTerm);
- }
-
- // create a new model expression that we can return
- ModelExpression modelExpression = null;
-
- // drill down into the model term
- if (rawModelTerm instanceof APartModelTerm) {
-
- // logger that we've got a factor model term
- if (logger.isDebugEnabled()) {
- logger.debug("Found factor contraint term " + rawModelTerm);
- }
-
- // get the model factor
- PModelPart modelPart = ((APartModelTerm) rawModelTerm).getModelPart();
-
- // logger that we're recursing with a model part
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model part " + modelPart);
- }
-
- // drill down into the model part
- modelExpression = buildModelExpression(modelPart, aliasMap);
-
- } else if (rawModelTerm instanceof AAndModelTerm) {
-
- // logger that we've got a AND model term
- if (logger.isDebugEnabled()) {
- logger.debug("Found AND contraint term " + rawModelTerm);
- }
-
- // get the model term
- PModelTerm modelTerm = ((AAndModelTerm)rawModelTerm).getModelTerm();
-
- // get the model part
- PModelPart modelPart = ((AAndModelTerm)rawModelTerm).getModelPart();
-
- // logger that we've found the operands of the union
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model term " + modelTerm +
- " & model part " + modelPart);
- }
-
- // get the LHS and RHS operands of the intersection
- ModelExpression lhs = buildModelExpression(modelTerm, aliasMap);
- ModelExpression rhs = buildModelExpression(modelPart, aliasMap);
-
- // logger that we've resolved the operands
- if (logger.isDebugEnabled()) {
- logger.debug("Resolved LHS intersection operand " + lhs);
- logger.debug("Resolved RHS intersection operand " + rhs);
- }
-
- // apply the intersection
- modelExpression = new ModelIntersection(lhs, rhs);
- }
-
- // end if
- // we should not be returning null
- if (modelExpression == null) {
-
- throw new QueryException("Unable to parse ITQL model term into a valid model expression");
- }
-
- // end if
- // logger that we've created a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Created model expression " + modelExpression);
- }
-
- // return the built up expression
- return modelExpression;
- }
-
- // buildModelExpression()
-
- /**
- * Recursively builds a {@link org.mulgara.query.ModelExpression} from a
- * {@link org.mulgara.itql.node.PModelPart}.
- *
- * @param rawModelPart a raw model part from the parser
- * @return a {@link org.mulgara.query.ModelExpression} suitable for use in
- * creating a {@link org.mulgara.query.Query}
- * @throws QueryException if <code>rawModelExpression</code> does not
- * represent a valid query
- * @throws URISyntaxException if the <code>rawModelExpression</code> contains
- * a resource whose text violates <a
- * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
- */
- private static ModelExpression buildModelExpression(
- PModelPart rawModelPart, Map<String,URI> aliasMap
- ) throws QueryException, URISyntaxException {
-
- // validate the rawModelPart parameter
- if (rawModelPart == null) {
- throw new IllegalArgumentException("Null \"rawModelPart\" " +
- "parameter");
- }
-
- // end if
- // logger that we're building a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Building model expression from " + rawModelPart);
- }
-
- // create a new model expression that we can return
- ModelExpression modelExpression = null;
-
- // drill down into the model term
- if (rawModelPart instanceof AFactorModelPart) {
-
- // logger that we've got a factor model term
- if (logger.isDebugEnabled()) {
- logger.debug("Found factor contraint term " + rawModelPart);
- }
-
- // get the model factor
- PModelFactor modelFactor = ((AFactorModelPart)rawModelPart).getModelFactor();
-
- // logger that we're recursing with a model factor
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model factor " + modelFactor);
- }
-
- // drill down into the model part
- modelExpression = buildModelExpression(modelFactor, aliasMap);
- } else if (rawModelPart instanceof AXorModelPart) {
-
- // logger that we've got a AND model term
- if (logger.isDebugEnabled()) {
- logger.debug("Found AND contraint term " + rawModelPart);
- }
-
- // get the model term
- PModelPart modelPart = ((AXorModelPart)rawModelPart).getModelPart();
-
- // get the model factor
- PModelFactor modelFactor = ((AXorModelPart)rawModelPart).getModelFactor();
-
- // logger that we've found the operands of the union
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model part " + modelPart + " & model factor " + modelFactor);
- }
-
- // get the LHS and RHS operands of the intersection
- ModelExpression lhs = buildModelExpression(modelPart, aliasMap);
- ModelExpression rhs = buildModelExpression(modelFactor, aliasMap);
-
- // logger that we've resolved the operands
- if (logger.isDebugEnabled()) {
- logger.debug("Resolved LHS intersection operand " + lhs);
- logger.debug("Resolved RHS intersection operand " + rhs);
- }
-
- // apply the intersection
- modelExpression = new ModelPartition(lhs, rhs);
- }
-
- // end if
- // we should not be returning null
- if (modelExpression == null) {
-
- throw new QueryException("Unable to parse ITQL model term into a valid model expression");
- }
-
- // end if
- // logger that we've created a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Created model expression " + modelExpression);
- }
-
- // return the built up expression
- return modelExpression;
- }
-
- // buildModelExpression()
-
- /**
- * Recursively builds a {@link org.mulgara.query.ModelExpression} from a
- * {@link org.mulgara.itql.node.PModelFactor}.
- *
- * @param rawModelFactor a raw model factor from the parser
- * @return a {@link org.mulgara.query.ModelExpression} suitable for use in
- * creating a {@link org.mulgara.query.Query}
- * @throws QueryException if <code>rawModelExpression</code> does not
- * represent a valid query
- * @throws URISyntaxException if the <code>rawModelExpression</code> contains
- * a resource whose text violates <a
- * href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
- */
- private static ModelExpression buildModelExpression(
- PModelFactor rawModelFactor, Map<String,URI> aliasMap
- ) throws QueryException, URISyntaxException {
-
- // validate the rawModelFactor parameter
- if (rawModelFactor == null) {
-
- throw new IllegalArgumentException("Null \"rawModelFactor\" parameter");
- }
-
- // end if
- // logger that we're building a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Building model expression from " + rawModelFactor);
- }
-
- // create a new model expression that we can return
- ModelExpression modelExpression = null;
-
- // drill down into the model term
- if (rawModelFactor instanceof AResourceModelFactor) {
-
- // logger that we've got a model model factor
- if (logger.isDebugEnabled()) {
- logger.debug("Found resource model factor " + rawModelFactor);
- }
-
- // get the resource
- String resource = ((AResourceModelFactor)rawModelFactor).getResource().getText();
-
- // logger that we've found a resource
- if (logger.isDebugEnabled()) {
- logger.debug("Found resource " + resource);
- }
-
- // this resource is what we're looking for
- URI modelURI = URIUtil.convertToURI(resource, aliasMap);
- modelExpression = new ModelResource(ServerURIHandler.removePort(modelURI));
- } else if (rawModelFactor instanceof AExpressionModelFactor) {
-
- // logger that we've got an expression model factor
- if (logger.isDebugEnabled()) {
- logger.debug("Found factor expression model factor " + rawModelFactor);
- }
-
- // get the model expression
- PModelExpression embeddedModelExpression = ((AExpressionModelFactor)rawModelFactor).getModelExpression();
-
- // logger that we're recursing with a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Recursing with model factor " + modelExpression);
- }
-
- // build the model expression
- modelExpression = buildModelExpression(embeddedModelExpression, aliasMap);
- }
-
- // end if
- // we should not be returning null
- if (modelExpression == null) {
-
- throw new QueryException("Unable to parse ITQL model factor " +
- "into a valid model expression");
- }
-
- // end if
- // logger that we've created a model expression
- if (logger.isDebugEnabled()) {
- logger.debug("Created model expression " + modelExpression);
- }
-
- // return the built up expression
- return modelExpression;
- }
-
- // buildModelExpression()
-}
-
-
-// ModelExpressionBuilder
Deleted: branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/ModelNameCompletor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,56 +0,0 @@
-/*
- * The contents of this file are subject to the Open Software License
- * Version 3.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.opensource.org/licenses/osl-3.0.txt
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- */
-
-package org.mulgara.itql;
-
-import java.util.List;
-
-import jline.Completor;
-
-public class ModelNameCompletor implements Completor {
-
- private List<String> modelNames;
-
- public ModelNameCompletor(List<String> modelNames) {
- this.modelNames = modelNames;
- }
-
- @SuppressWarnings("unchecked")
- public int complete(String s, int idx, List completionList) {
- int retValue = idx;
-
- if(s.endsWith("<")) {
- completionList.addAll(modelNames);
- } else {
- int gtIdx = s.lastIndexOf("<");
- boolean addedSomething = false;
-
- if(gtIdx >= 0) {
- String partial = s.substring(gtIdx+1);
- for(String s2 : modelNames) {
- if(s2.startsWith(partial)) {
- completionList.add(s2);
- addedSomething = true;
- }
- }
- }
-
- if(addedSomething) {
- retValue = gtIdx + 1;
- }
- }
-
- // TODO Auto-generated method stub
- return retValue ;
- }
-
-}
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -553,7 +553,7 @@
// get the name of the model to create
URI graphURI = toURI(node.getModel());
- // get the type of model to create; default to mulgara:Model is unspecified
+ // get the type of model to create; default to mulgara:Graph is unspecified
URI graphTypeURI = (node.getModelType() == null)
? Session.MULGARA_GRAPH_URI
: toURI(node.getModelType());
@@ -563,7 +563,7 @@
graphURI = getCanonicalUriAlias(graphURI);
- if (logger.isDebugEnabled()) logger.debug("Model is alias for " + graphURI);
+ if (logger.isDebugEnabled()) logger.debug("Graph is alias for " + graphURI);
lastCommand = new CreateGraph(graphURI, graphTypeURI);
}
@@ -891,8 +891,8 @@
PModelExpression rawModelExpression = fromClause.getModelExpression();
if (logger.isDebugEnabled()) logger.debug("Building model expression from " + rawModelExpression);
// parse the text into a model expression
- ModelExpression modelExpression = ModelExpressionBuilder.build(this.getAliasMap(), rawModelExpression);
- if (logger.isDebugEnabled()) logger.debug("Built model expression " + modelExpression);
+ GraphExpression graphExpression = GraphExpressionBuilder.build(this.getAliasMap(), rawModelExpression);
+ if (logger.isDebugEnabled()) logger.debug("Built model expression " + graphExpression);
// get the constraint expression from the parser
PConstraintExpression rawConstraintExpression = whereClause.getConstraintExpression();
@@ -920,7 +920,7 @@
}
// build a query using the information we've obtained from the parser
- return new Query(variableList, modelExpression, constraintExpression,
+ return new Query(variableList, graphExpression, constraintExpression,
havingExpression, orderList, limit, offset, new UnconstrainedAnswer());
}
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlSession.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/TqlSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -230,14 +230,14 @@
* Indicates if we should use the Swing shell or not
*/
boolean useSwingShell() {
- return useSwing;
+ return useSwing;
}
/**
* Returns the host to query for model names
*/
String getModelHost() {
- return host;
+ return host;
}
/**
@@ -358,119 +358,113 @@
}
- /**
- * Create a UI and start it up. Returns when the GUI has been exited.
- */
- private void runInterface() {
- runInterface(false);
- }
-
private void runInterface(boolean useSwing) {
-
- if(useSwing) {
- // Create the UI.
- JFrame mainWindow = new JFrame(SHELL_NAME);
- mainWindow.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
- mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ if(useSwing) {
+ // Create the UI.
+ JFrame mainWindow = new JFrame(SHELL_NAME);
+ mainWindow.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- gui = new TqlSessionUI(this, System.in, System.out);
- mainWindow.getContentPane().add(gui);
+ gui = new TqlSessionUI(this, System.in, System.out);
+ mainWindow.getContentPane().add(gui);
- if (log.isInfoEnabled()) log.info("Starting TQL interpreter");
+ if (log.isInfoEnabled()) log.info("Starting TQL interpreter");
- motdInitialization();
+ motdInitialization();
- // Start the application, by making the UI visible
- mainWindow.setVisible(true);
- } else {
- try {
- ConsoleReader reader = new ConsoleReader();
- File historyFile = getHistoryFile();
- History history = reader.getHistory();
- history.setHistoryFile(historyFile);
- history.setMaxSize(50);
- reader.setBellEnabled(false);
- reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));
- reader.addCompletor(new ModelNameCompletor(prefetchModels(getModelHost())));
+ // Start the application, by making the UI visible
+ mainWindow.setVisible(true);
+ } else {
+ try {
+ ConsoleReader reader = new ConsoleReader();
+ File historyFile = getHistoryFile();
+ History history = reader.getHistory();
+ history.setHistoryFile(historyFile);
+ history.setMaxSize(50);
+ reader.setBellEnabled(false);
+ reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));
+ reader.addCompletor(new GraphNameCompletor(prefetchModels(getModelHost())));
- String line;
- PrintWriter out = new PrintWriter(System.out);
+ String line;
+ PrintWriter out = new PrintWriter(System.out);
- while ((line = reader.readLine(PS1)) != null) {
- executeCommand(line);
+ while ((line = reader.readLine(PS1)) != null) {
+ executeCommand(line);
- List<Answer> answers = getLastAnswers();
- List<String> messages = getLastMessages();
+ List<Answer> answers = getLastAnswers();
+ List<String> messages = getLastMessages();
- if (answers.isEmpty()) {
- for (String message: messages) out.println(message);
- } else {
- int answerIndex = 0;
+ if (answers.isEmpty()) {
+ for (String message: messages) out.println(message);
+ } else {
+ int answerIndex = 0;
- while (answerIndex < answers.size()) {
- String lastMessage = (String)messages.get(answerIndex);
-
- try {
- // Assume the same number of answers and messages
- Answer answer = answers.get(answerIndex);
+ while (answerIndex < answers.size()) {
+ @SuppressWarnings("unused")
+ String lastMessage = (String)messages.get(answerIndex);
+
+ try {
+ // Assume the same number of answers and messages
+ Answer answer = answers.get(answerIndex);
- // If there's more than one answer print a heading.
- if (answers.size() > 1) {
- out.println();
- // If there's more than one answer add an extra line before the heading.
- out.println("Executing Query " + (answerIndex+1));
- }
-
- // print the results
- if (answer != null) {
- boolean hasAnswers = true;
+ // If there's more than one answer print a heading.
+ if (answers.size() > 1) {
+ out.println();
+ // If there's more than one answer add an extra line before the heading.
+ out.println("Executing Query " + (answerIndex+1));
+ }
+
+ // print the results
+ if (answer != null) {
+ boolean hasAnswers = true;
- long rowCount = 0;
- answer.beforeFirst();
- if (answer.isUnconstrained()) {
- out.println("[ true ]");
- rowCount = 1;
- } else {
- if (!answer.next()) {
- out.print("No results returned.");
- hasAnswers = false;
- } else {
- do {
- rowCount++;
- out.print("[ ");
- for (int index = 0; index < answer.getNumberOfVariables(); index++) {
- Object object = answer.getObject(index);
- assert(object instanceof Answer) ||
- (object instanceof Node ) ||
- (object == null);
- out.print(String.valueOf(object));
- if (index < (answer.getNumberOfVariables() - 1)) out.print(", ");
- }
- out.println(" ]");
- } while (answer.next());
- }
- }
- if (hasAnswers) out.println(rowCount + " rows returned.");
- answerIndex++;
- answer.close();
- out.flush();
+ long rowCount = 0;
+ answer.beforeFirst();
+ if (answer.isUnconstrained()) {
+ out.println("[ true ]");
+ rowCount = 1;
+ } else {
+ if (!answer.next()) {
+ out.print("No results returned.");
+ hasAnswers = false;
+ } else {
+ do {
+ rowCount++;
+ out.print("[ ");
+ for (int index = 0; index < answer.getNumberOfVariables(); index++) {
+ Object object = answer.getObject(index);
+ assert(object instanceof Answer) ||
+ (object instanceof Node ) ||
+ (object == null);
+ out.print(String.valueOf(object));
+ if (index < (answer.getNumberOfVariables() - 1)) out.print(", ");
+ }
+ out.println(" ]");
+ } while (answer.next());
+ }
+ }
+ if (hasAnswers) out.println(rowCount + " rows returned.");
+ answerIndex++;
+ answer.close();
+ out.flush();
- if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) {
- break;
- }
- }
- } catch(TuplesException te ) {
- te.printStackTrace();
- }
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
+ if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) {
+ break;
+ }
+ }
+ } catch(TuplesException te ) {
+ te.printStackTrace();
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
-
- }
+
+ }
if (log.isInfoEnabled()) log.info("Stopping TQL interpreter");
if (log.isDebugEnabled()) log.debug("Executed post-loading script");
@@ -481,9 +475,9 @@
*
*/
private File getHistoryFile() {
- // TODO: Generalize this process
- File retValue = new File(System.getProperty("user.home") + File.separator + ".itqllog");
- return retValue;
+ // TODO: Generalize this process
+ File retValue = new File(System.getProperty("user.home") + File.separator + ".itqllog");
+ return retValue;
}
@@ -528,26 +522,26 @@
*/
private List<String> prefetchModels(String hostname) {
- List<String> retValue = new ArrayList<String>();
- StringBuffer sb = new StringBuffer();
- sb.append("select $model from <rmi://");
- sb.append(hostname);
- sb.append("/server1#> where $model $p $o;");
-
- try {
- executeCommand(sb.toString());
- List<Answer> models = getLastAnswers();
+ List<String> retValue = new ArrayList<String>();
+ StringBuffer sb = new StringBuffer();
+ sb.append("select $model from <rmi://");
+ sb.append(hostname);
+ sb.append("/server1#> where $model $p $o;");
+
+ try {
+ executeCommand(sb.toString());
+ List<Answer> models = getLastAnswers();
- for(Answer a : models) {
- while(a.next()) {
- retValue.add(a.getObject(0).toString());
- }
- }
- } catch(Throwable t) {
- t.printStackTrace();
- }
-
- return retValue;
+ for(Answer a : models) {
+ while(a.next()) {
+ retValue.add(a.getObject(0).toString());
+ }
+ }
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+
+ return retValue;
}
@@ -658,7 +652,7 @@
String modelHost = (String) parser.getOptionValue(ItqlOptionParser.REMOTE);
if(modelHost != null) {
- host = modelHost;
+ host = modelHost;
}
// load an external interpreter configuration file
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -59,6 +59,9 @@
*/
public abstract class ProtocolServlet extends HttpServlet {
+ /** Generated serialization ID. */
+ private static final long serialVersionUID = -6510062000251611536L;
+
/**
* Internal type definition of a function that takes "something" and an output stream,
* and returns a {@link StreamedAnswer}
@@ -96,7 +99,6 @@
protected static final String DEFAULT_GRAPH_ARG = "default-graph-uri";
/** The parameter identifying the graph. We don't set these in SPARQL yet. */
- @SuppressWarnings("unused")
protected static final String NAMED_GRAPH_ARG = "named-graph-uri";
/** The name of the default graph. This is a null graph. */
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/sparql/SparqlInterpreter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -45,9 +45,9 @@
import org.mulgara.query.ConstraintIs;
import org.mulgara.query.ConstructQuery;
import org.mulgara.query.GraphAnswer;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.ModelResource;
-import org.mulgara.query.ModelUnion;
+import org.mulgara.query.GraphExpression;
+import org.mulgara.query.GraphResource;
+import org.mulgara.query.GraphUnion;
import org.mulgara.query.Order;
import org.mulgara.query.Query;
import org.mulgara.query.SelectElement;
@@ -225,7 +225,7 @@
*/
Query buildSelectQuery(QueryStructure queryStruct) throws MulgaraParserException {
List<? extends SelectElement> selection = getSelection(queryStruct);
- ModelExpression defaultGraphs = getFrom(queryStruct);
+ GraphExpression defaultGraphs = getFrom(queryStruct);
ConstraintExpression whereClause = getWhere(queryStruct);
if (whereClause == null) throw new MulgaraParserException("SELECT query must have a WHERE clause");
List<Order> orderBy = getOrdering(queryStruct);
@@ -245,7 +245,7 @@
List<Variable> selection = new ArrayList<Variable>();
Collection<org.mulgara.sparql.parser.cst.Variable> allVars = queryStruct.getAllVariables();
for (org.mulgara.sparql.parser.cst.Variable v: allVars) selection.add(new Variable(v.getName()));
- ModelExpression defaultGraphs = getFrom(queryStruct);
+ GraphExpression defaultGraphs = getFrom(queryStruct);
ConstraintExpression whereClause = getWhere(queryStruct);
if (whereClause == null) throw new MulgaraParserException("ASK query must have a WHERE clause");
return new AskQuery(selection, defaultGraphs, whereClause);
@@ -262,7 +262,7 @@
if (selection.size() % 3 != 0) {
throw new MulgaraParserException("CONSTRUCT queries require a multiple of 3 nodes in the template.");
}
- ModelExpression defaultGraphs = getFrom(queryStruct);
+ GraphExpression defaultGraphs = getFrom(queryStruct);
ConstraintExpression whereClause = getWhere(queryStruct);
if (whereClause == null) throw new MulgaraParserException("CONSTRUCT query must have a WHERE clause");
List<Order> orderBy = getOrdering(queryStruct);
@@ -283,7 +283,7 @@
List<? extends SelectElement> described = getSelection(queryStruct);
ConstraintExpression whereClause = distributeIntoWhereClause(described, getWhere(queryStruct));
whereClause = constraintToNonBlank(whereClause);
- ModelExpression defaultGraphs = getFrom(queryStruct);
+ GraphExpression defaultGraphs = getFrom(queryStruct);
// Ignore the order since its behavior is unspecified for DESCRIBE.
//List<Order> orderBy = getOrdering(queryStruct);
List<Order> orderBy = new ArrayList<Order>(0);
@@ -376,12 +376,12 @@
}
/**
- * Gets the graph expression ({@link ModelExpression}) the represents the FROM clause, or the default
+ * Gets the graph expression ({@link GraphExpression}) the represents the FROM clause, or the default
* graph if none was provided.
* @param queryStruct The structure to query for the FROM clause.
- * @return A ModelExpression containing all the required graphs as a union. TODO: this should be a merge.
+ * @return A GraphExpression containing all the required graphs as a union. TODO: this should be a merge.
*/
- ModelExpression getFrom(QueryStructure queryStruct) {
+ GraphExpression getFrom(QueryStructure queryStruct) {
List<IRIReference> iris = queryStruct.getDefaultFroms();
// accumulate the graphs as a union, using the default if no graphs supplied
return graphUnion(iris.isEmpty() ? getDefaultGraphIris() : iris);
@@ -391,17 +391,17 @@
* Convert a list of IRIs into a model resource union of minimal depth. This recurses through construction
* of a tree of binary unions, rather than creating a linear linked list of unions.
* @param iris The list to convert.
- * @return A ModelExpression which is a union of all the elements in the list,
- * or a {@link ModelResource} if the list contains only one element.
+ * @return A GraphExpression which is a union of all the elements in the list,
+ * or a {@link GraphResource} if the list contains only one element.
*/
- private ModelExpression graphUnion(List<IRIReference> iris) {
+ private GraphExpression graphUnion(List<IRIReference> iris) {
int listSize = iris.size();
// terminate on singleton lists
- if (listSize == 1) return new ModelResource(iris.get(0).getUri());
+ if (listSize == 1) return new GraphResource(iris.get(0).getUri());
// short circuit for 2 element lists - optimization
- if (listSize == 2) return new ModelUnion(new ModelResource(iris.get(0).getUri()), new ModelResource(iris.get(1).getUri()));
+ if (listSize == 2) return new GraphUnion(new GraphResource(iris.get(0).getUri()), new GraphResource(iris.get(1).getUri()));
// general case
- return new ModelUnion(graphUnion(iris.subList(0, listSize / 2)), graphUnion(iris.subList(listSize / 2, listSize)));
+ return new GraphUnion(graphUnion(iris.subList(0, listSize / 2)), graphUnion(iris.subList(listSize / 2, listSize)));
}
/**
Modified: branches/xa11/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -65,7 +65,7 @@
/** Parameter name of the results of the load operation */
public final static String LOAD_RESULT = "loadResult";
- /** Parameter name of the "Clear Model" command */
+ /** Parameter name of the "Clear Graph" command */
public final static String CLEAR = "clearModel";
/**
Modified: branches/xa11/src/jar/querylang/sablecc/itql.grammar
===================================================================
--- branches/xa11/src/jar/querylang/sablecc/itql.grammar 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/querylang/sablecc/itql.grammar 2009-01-10 08:23:29 UTC (rev 1427)
@@ -252,8 +252,10 @@
{minus} [minuend]:constraint_dterm minus [subtrahend]:constraint_factor ;
constraint_factor =
+ {constraint} constraint |
{compound} lbrace [subject]:element exists_expression in_clause? rbrace |
{existential} lbracket exists_expression in_clause? rbracket |
+ {expression} lpar constraint_expression rpar |
{transitive} transitive_clause |
{walk} walk_clause ;
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -59,7 +59,7 @@
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintImpl;
import org.mulgara.query.ConstraintIs;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.Order;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
@@ -231,7 +231,7 @@
Session session = database.newSession();
try {
session.createModel(modelURI, null);
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
} finally {
session.close();
}
@@ -301,7 +301,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -318,7 +318,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -376,7 +376,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -393,7 +393,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -552,7 +552,7 @@
try {
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
// Evaluate the query
Answer answer = session2.query(createQuery(model3URI));
@@ -590,7 +590,7 @@
try {
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
// Evaluate the query
Answer answer = session2.query(createQuery(model3URI));
@@ -630,7 +630,7 @@
try {
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
// Evaluate the query
Answer answer = session2.query(createQuery(model3URI));
@@ -684,7 +684,7 @@
Session session2 = database.newSession();
try {
session1.createModel(model4URI, null);
- session1.setModel(model4URI, new ModelResource(fileURI));
+ session1.setModel(model4URI, new GraphResource(fileURI));
// Check data loaded
Answer answer = session1.query(createQuery(model4URI));
@@ -771,7 +771,7 @@
try {
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -864,7 +864,7 @@
try {
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
Thread t2 = new Thread("tx2Test") {
public void run() {
@@ -984,7 +984,7 @@
};
t2.start();
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
logger.debug("Sleeping for 1sec");
Thread.sleep(1000);
logger.debug("Slept for 1sec");
@@ -1042,7 +1042,7 @@
};
t2.start();
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
logger.debug("Sleeping for 1sec");
Thread.sleep(1000);
logger.debug("Slept for 1sec");
@@ -1218,7 +1218,7 @@
Session session = database.newSession();
try {
session.createModel(model5URI, null);
- session.setModel(model5URI, new ModelResource(fileURI));
+ session.setModel(model5URI, new GraphResource(fileURI));
Variable varA = new Variable("a");
Variable varB = new Variable("b");
@@ -1231,7 +1231,7 @@
// Check data loaded
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(model5URI), // FROM
+ new GraphResource(model5URI), // FROM
new ConstraintConjunction(Arrays.asList(
new ConstraintExpression[] {
new ConstraintImpl(varB,
@@ -1327,7 +1327,7 @@
// verify second setAutoCommit(false) is a no-op
session.createModel(model3URI, null);
session.setAutoCommit(false);
- session.setModel(model3URI, new ModelResource(new File("data/xatest-model1.rdf").toURI()));
+ session.setModel(model3URI, new GraphResource(new File("data/xatest-model1.rdf").toURI()));
session.setAutoCommit(false);
session.commit();
@@ -1673,7 +1673,7 @@
return new Query(
selectList, // SELECT
- new ModelResource(model), // FROM
+ new GraphResource(model), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BasicDatabaseSessionUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BasicDatabaseSessionUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BasicDatabaseSessionUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -195,7 +195,7 @@
// Evaluate the query
Answer answer = new ArrayAnswer(session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -245,7 +245,7 @@
Session session = database.newSession();
try {
session.createModel(modelURI, null);
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
session.removeModel(modelURI);
} finally {
session.close();
@@ -284,8 +284,8 @@
// Evaluate the query
new ArrayAnswer(session.query(new Query(
selectList, // SELECT
- new ModelUnion(new ModelResource(dcFileURI), // FROM
- new ModelResource(rdfsFileURI)),
+ new GraphUnion(new GraphResource(dcFileURI), // FROM
+ new GraphResource(rdfsFileURI)),
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BootstrapOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BootstrapOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/BootstrapOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -38,18 +38,22 @@
public void execute(OperationContext operationContext,
SystemResolver systemResolver,
DatabaseMetadata metadata) throws Exception {
+ if (logger.isDebugEnabled()) logger.debug("Creating bootstrap nodes");
// Find the local node identifying the model
- long model = systemResolver.localizePersistent(
+ long graph = systemResolver.localizePersistent(
new URIReferenceImpl(databaseMetadata.getSystemModelURI()));
long rdfType = systemResolver.localizePersistent(
new URIReferenceImpl(databaseMetadata.getRdfTypeURI()));
- long modelType = systemResolver.localizePersistent(
+ long graphType = systemResolver.localizePersistent(
new URIReferenceImpl(databaseMetadata.getSystemModelTypeURI()));
+ // set up the system resolver to understand the system graph
+ systemResolver.initializeSystemNodes(graph, rdfType, graphType);
+
+ if (logger.isDebugEnabled()) logger.debug("Creating bootstrap statements");
// Use the session to create the model
- systemResolver.modifyModel(model, new SingletonStatements(model, rdfType,
- modelType), true);
- databaseMetadata.initializeSystemNodes(model, rdfType, modelType);
+ systemResolver.modifyModel(graph, new SingletonStatements(graph, rdfType, graphType), true);
+ databaseMetadata.initializeSystemNodes(graph, rdfType, graphType);
long preSubject = systemResolver.localizePersistent(
new URIReferenceImpl(databaseMetadata.getPreallocationSubjectURI()));
@@ -60,13 +64,13 @@
// Every node cached by DatabaseMetadata must be preallocated
systemResolver.modifyModel(preModel,
- new SingletonStatements(preSubject, prePredicate, model),
+ new SingletonStatements(preSubject, prePredicate, graph),
true);
systemResolver.modifyModel(preModel,
new SingletonStatements(preSubject, prePredicate, rdfType),
true);
systemResolver.modifyModel(preModel,
- new SingletonStatements(preSubject, prePredicate, modelType),
+ new SingletonStatements(preSubject, prePredicate, graphType),
true);
systemResolver.modifyModel(preModel,
new SingletonStatements(preSubject, prePredicate, preSubject),
@@ -80,7 +84,7 @@
databaseMetadata.initializePreallocationNodes(preSubject, prePredicate, preModel);
- result = model;
+ result = graph;
}
public boolean isWriteOperation()
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,10 +41,10 @@
import org.mulgara.query.*;
import org.mulgara.resolver.spi.ConstraintBindingHandler;
import org.mulgara.resolver.spi.ConstraintLocalization;
-import org.mulgara.resolver.spi.ConstraintModelRewrite;
+import org.mulgara.resolver.spi.ConstraintGraphRewrite;
import org.mulgara.resolver.spi.ConstraintResolutionHandler;
import org.mulgara.resolver.spi.ConstraintVariableRewrite;
-import org.mulgara.resolver.spi.ModelResolutionHandler;
+import org.mulgara.resolver.spi.GraphResolutionHandler;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
import org.mulgara.util.NVPair;
@@ -102,12 +102,12 @@
static void addModelResolutionHandlers(NVPair<Class<? extends ConstraintExpression>,Object>[] resolutionHandlers) throws RuntimeException {
addToMap(resolutionHandlers, modelResolutionHandlers,
- ModelExpression.class, ModelResolutionHandler.class);
+ GraphExpression.class, GraphResolutionHandler.class);
}
static void addConstraintModelRewrites(NVPair<Class<? extends ConstraintExpression>,Object>[] resolutionHandlers) throws RuntimeException {
addToMap(resolutionHandlers, constraintModelRewrites,
- ConstraintExpression.class, ConstraintModelRewrite.class);
+ ConstraintExpression.class, ConstraintGraphRewrite.class);
}
static void addConstraintVariableRewrites(NVPair<Class<? extends ConstraintExpression>,Object>[] resolutionHandlers) throws RuntimeException {
@@ -146,21 +146,21 @@
}
- public static Tuples resolveModelExpression(QueryEvaluationContext context, ModelExpression modelExpr,
+ public static Tuples resolveModelExpression(QueryEvaluationContext context, GraphExpression modelExpr,
Constraint constraint) throws QueryException {
try {
if (logger.isDebugEnabled()) {
- logger.debug("Resolving " + constraint + " against ModelExpression[" + modelExpr.getClass() + "]");
+ logger.debug("Resolving " + constraint + " against GraphExpression[" + modelExpr.getClass() + "]");
}
- ModelResolutionHandler op = (ModelResolutionHandler)modelResolutionHandlers.get(modelExpr.getClass());
+ GraphResolutionHandler op = (GraphResolutionHandler)modelResolutionHandlers.get(modelExpr.getClass());
if (op == null) {
- throw new QueryException("Unknown ModelExpression type: " + modelExpr.getClass() + " known types: " + modelResolutionHandlers.keySet());
+ throw new QueryException("Unknown GraphExpression type: " + modelExpr.getClass() + " known types: " + modelResolutionHandlers.keySet());
}
Tuples result = op.resolve(context, modelExpr, constraint);
if (logger.isDebugEnabled()) {
- logger.debug("Resolved " + constraint + " against ModelExpression[" + modelExpr.getClass() + "] to: " + result);
+ logger.debug("Resolved " + constraint + " against GraphExpression[" + modelExpr.getClass() + "] to: " + result);
}
return result;
@@ -173,7 +173,7 @@
public static Tuples resolveConstraintExpression(QueryEvaluationContext context,
- ModelExpression modelExpr, ConstraintExpression constraintExpr) throws QueryException {
+ GraphExpression modelExpr, ConstraintExpression constraintExpr) throws QueryException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Resolving ConstraintExpression[" + constraintExpr.getClass() + "]");
@@ -251,17 +251,17 @@
Constraint constraint) throws QueryException {
try {
if (logger.isDebugEnabled()) {
- logger.debug("Rewriting Model" + newModel + " in " + constraint);
+ logger.debug("Rewriting Graph" + newModel + " in " + constraint);
}
- ConstraintModelRewrite op = (ConstraintModelRewrite)constraintModelRewrites.get(constraint.getClass());
+ ConstraintGraphRewrite op = (ConstraintGraphRewrite)constraintModelRewrites.get(constraint.getClass());
if (op == null) {
throw new QueryException("Unknown Constraint type: " + constraint.getClass() + " known types: " + constraintModelRewrites.keySet());
}
Constraint result = op.rewrite(newModel, constraint);
if (logger.isDebugEnabled()) {
- logger.debug("Rewrote Model" + newModel + " in " + constraint + " to " + result);
+ logger.debug("Rewrote Graph " + newModel + " in " + constraint + " to " + result);
}
return result;
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateGraphOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,264 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Java 2 standard packages
+import java.net.URI;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+import org.jrdf.graph.*;
+
+// Local packages
+import org.mulgara.query.*;
+import org.mulgara.query.rdf.*;
+import org.mulgara.resolver.spi.*;
+import org.mulgara.store.nodepool.NodePool;
+import org.mulgara.util.QueryParams;
+
+/**
+ * An {@link Operation} that implements the {@link Session#createModel} method.
+ * TODO: Rename to CreateGraphOperation.
+ *
+ * @created 2004-11-24
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ * @version $Revision: 1.9 $
+ * @modified $Date: 2005/02/22 08:16:08 $ by $Author: newmana $
+ * @maintenanceAuthor $Author: newmana $
+ * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana Technology, Inc</a>
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+class CreateGraphOperation implements Operation {
+ /** Logger. This is named after the class. */
+ @SuppressWarnings("unused")
+ private static final Logger logger = Logger.getLogger(CreateGraphOperation.class.getName());
+
+ /** The parameter used for describing subgraphs within a URI. */
+ static final String GRAPH = "graph";
+
+ /** The URI of the model to be created. */
+ private final URI graphURI;
+
+ /** The URI of the type of the model to be created. */
+ private URI graphTypeURI;
+
+
+ /**
+ * Sole constructor.
+ *
+ * @param graphURI the {@link URI} of the graph to be created, never <code>null</code>
+ * @param graphTypeURI thie {@link URI} of the type of graph to create, or
+ * <code>null</code> for the same type as the system graph (<code>#</code>)
+ * @throws IllegalArgumentException if <var>graphURI</var> is <code>null</code>
+ */
+ CreateGraphOperation(URI graphURI, URI graphTypeURI) throws QueryException {
+ // Validate "graphURI" parameter
+ if (graphURI == null) throw new IllegalArgumentException("Null \"graphURI\" parameter");
+ if (!graphURI.isOpaque() && fragmentScheme(graphURI) && graphURI.getFragment() == null) {
+ throw new QueryException("Graph URI does not have a fragment (graphURI:\"" + graphURI + "\")");
+ }
+
+ // Initialize fields
+ this.graphURI = graphURI;
+ this.graphTypeURI = graphTypeURI;
+ }
+
+ //
+ // Methods implementing Operation
+ //
+
+ public void execute(OperationContext operationContext,
+ SystemResolver systemResolver,
+ DatabaseMetadata metadata) throws Exception {
+ // Default to the system graph type
+ if (graphTypeURI == null) graphTypeURI = metadata.getSystemModelTypeURI();
+
+ verifyGraphUri(graphURI, metadata);
+
+ // Look up the resolver factory for the model type
+ ResolverFactory resolverFactory = operationContext.findModelTypeResolverFactory(graphTypeURI);
+ if (resolverFactory == null) {
+ throw new QueryException("Couldn't find resolver factory in internal resolver map " + graphTypeURI);
+ }
+
+ // PREVIOUSLY WITHIN TRANSACTION
+
+ // Obtain an appropriate resolver bound to this session
+ Resolver resolver = operationContext.obtainResolver(resolverFactory);
+ assert resolver != null;
+
+ // Find the local node identifying the model
+ long graph = systemResolver.localizePersistent(new URIReferenceImpl(graphURI));
+ assert graph != NodePool.NONE;
+
+ // Check model does not already exist with a different model type.
+ // TODO: there's a node leak here, if the model has already been created.
+ Resolution resolution = systemResolver.resolve(new ConstraintImpl(
+ new LocalNode(graph),
+ new LocalNode(metadata.getRdfTypeNode()),
+ new Variable("x"),
+ new LocalNode(metadata.getSystemModelNode())));
+
+ try {
+ resolution.beforeFirst();
+ if (resolution.next()) {
+ Node eNode = systemResolver.globalize(resolution.getColumnValue(0));
+ try {
+ URIReferenceImpl existing = (URIReferenceImpl)eNode;
+ if (!new URIReferenceImpl(graphTypeURI).equals(existing)) {
+ throw new QueryException(graphURI + " already exists with model type " + existing +
+ " in attempt to create it with type " + graphTypeURI);
+ }
+ } catch (ClassCastException ec) {
+ throw new QueryException("Invalid model type entry in system model: " + graphURI + " <rdf:type> " + eNode);
+ }
+ }
+ } finally {
+ resolution.close();
+ }
+
+
+ // TODO: there's a node leak here, because the model node was created
+ // persistently, but may never end up linked into the graph if the
+ // following security check doesn't succeed
+
+ // Make sure security adapters are satisfied
+ for (Iterator<SecurityAdapter> i = operationContext.getSecurityAdapterList().iterator(); i.hasNext();) {
+ SecurityAdapter securityAdapter = i.next();
+
+ // Tell the truth to the user
+ if (!securityAdapter.canCreateModel(graph, systemResolver) || !securityAdapter.canSeeModel(graph, systemResolver)) {
+ throw new QueryException("You aren't allowed to create " + graphURI);
+ }
+ }
+
+ // Use the session to create the model
+ resolver.createModel(graph, graphTypeURI);
+ }
+
+ /**
+ * @return <code>true</code>
+ */
+ public boolean isWriteOperation() {
+ return true;
+ }
+
+ /**
+ * Verify that the graph URI is relative to the database URI. The graph
+ * URI can use one of the hostname aliases instead of the canonical
+ * hostname of the database URI. No checking of the scheme specific part
+ * of the graph URI is performed if the database URI is opaque.
+ * @param graphURI
+ * @param metadata
+ * @throws QueryException
+ */
+ private void verifyGraphUri(URI graphURI, DatabaseMetadata metadata) throws QueryException {
+ // only check if this is a scheme which can use fragments - for the moment only RMI
+ if (!fragmentSchemes.contains(graphURI)) return;
+
+ boolean badModelURI = true;
+ URI databaseURI = metadata.getURI();
+ String scheme = graphURI.getScheme();
+ String fragment = graphURI.getFragment();
+
+ if (scheme != null && scheme.equals(databaseURI.getScheme())) {
+ if (databaseURI.isOpaque()) {
+ // databaseURI is opaque.
+ if (graphURI.isOpaque() && fragment != null) {
+ // Strip out the query string.
+ String ssp = graphURI.getSchemeSpecificPart();
+ int qIndex = ssp.indexOf('?');
+ if (qIndex >= 0) ssp = ssp.substring(0, qIndex);
+
+ if (ssp.equals(databaseURI.getSchemeSpecificPart())) {
+ // graphURI is relative to databaseURI.
+ badModelURI = false;
+ }
+ }
+ } else {
+ // databaseURI is hierarchial.
+ String path;
+ String host;
+
+ if (
+ !graphURI.isOpaque() && (
+ graphURI.getSchemeSpecificPart().equals(
+ databaseURI.getSchemeSpecificPart()
+ ) || (
+ (host = graphURI.getHost()) != null &&
+ graphURI.getPort() == databaseURI.getPort() &&
+ (path = graphURI.getPath()) != null &&
+ path.equals(databaseURI.getPath()) &&
+ metadata.getHostnameAliases().contains(host.toLowerCase())
+ )
+ )
+ ) {
+ // graphURI is relative to databaseURI.
+ // only good if we have a fragment OR we have a graph parameter
+ if (fragment != null || hasSubgraph(graphURI)) badModelURI = false;
+ }
+ }
+ } else {
+ badModelURI = !graphURI.isOpaque();
+ }
+
+ if (badModelURI) {
+ throw new QueryException(
+ "Graph URI is not relative to the database URI (graphURI:\"" +
+ graphURI + "\", databaseURI:\"" + databaseURI + "\")"
+ );
+ }
+ }
+
+ /** Schemes with fragments are handled for backward compatibility */
+ private static final Set<String> fragmentSchemes = new HashSet<String>();
+ static {
+ fragmentSchemes.add("rmi");
+ fragmentSchemes.add("beep");
+ }
+
+ /**
+ * Test if the given URI is in a scheme which differentiates graphs based on fragments
+ * and there is no sub-graph name encoded in the URI.
+ * @param graphUri The URI to test for the graph.
+ * @return <code>true</code> only of the URI is in the known graph schemes.
+ */
+ private static boolean fragmentScheme(URI u) {
+ return fragmentSchemes.contains(u.getScheme()) && !hasSubgraph(u);
+ }
+
+ /**
+ * Check if a graph URI contains another graph name.
+ * @param graphURI The URI to test.
+ * @return <code>true</code> if the URI contains the name of another graph.
+ */
+ private static boolean hasSubgraph(URI graphURI) {
+ return QueryParams.decode(graphURI).getNames().contains(GRAPH);
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/CreateModelOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,249 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Java 2 standard packages
-import java.net.URI;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-import org.jrdf.graph.*;
-
-// Local packages
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
-import org.mulgara.resolver.spi.*;
-import org.mulgara.store.nodepool.NodePool;
-
-/**
- * An {@link Operation} that implements the {@link Session#createModel} method.
- * TODO: Rename to CreateGraphOperation.
- *
- * @created 2004-11-24
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- * @version $Revision: 1.9 $
- * @modified $Date: 2005/02/22 08:16:08 $ by $Author: newmana $
- * @maintenanceAuthor $Author: newmana $
- * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana Technology, Inc</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-class CreateModelOperation implements Operation {
- /** Logger. This is named after the class. */
- @SuppressWarnings("unused")
- private static final Logger logger = Logger.getLogger(CreateModelOperation.class.getName());
-
- /** The URI of the model to be created. */
- private final URI graphURI;
-
- /** The URI of the type of the model to be created. */
- private URI graphTypeURI;
-
-
- /**
- * Sole constructor.
- *
- * @param graphURI the {@link URI} of the graph to be created, never <code>null</code>
- * @param graphTypeURI thie {@link URI} of the type of graph to create, or
- * <code>null</code> for the same type as the system graph (<code>#</code>)
- * @throws IllegalArgumentException if <var>graphURI</var> is <code>null</code>
- */
- CreateModelOperation(URI graphURI, URI graphTypeURI) throws QueryException {
- // Validate "graphURI" parameter
- if (graphURI == null) throw new IllegalArgumentException("Null \"graphURI\" parameter");
- if (!graphURI.isOpaque() && fragmentScheme(graphURI) && graphURI.getFragment() == null) {
- throw new QueryException("Graph URI does not have a fragment (graphURI:\"" + graphURI + "\")");
- }
-
- // Initialize fields
- this.graphURI = graphURI;
- this.graphTypeURI = graphTypeURI;
- }
-
- //
- // Methods implementing Operation
- //
-
- public void execute(OperationContext operationContext,
- SystemResolver systemResolver,
- DatabaseMetadata metadata) throws Exception {
- // Default to the system graph type
- if (graphTypeURI == null) graphTypeURI = metadata.getSystemModelTypeURI();
-
- verifyGraphUri(graphURI, metadata);
-
- // Look up the resolver factory for the model type
- ResolverFactory resolverFactory = operationContext.findModelTypeResolverFactory(graphTypeURI);
- if (resolverFactory == null) {
- throw new QueryException("Couldn't find resolver factory in internal resolver map " + graphTypeURI);
- }
-
- // PREVIOUSLY WITHIN TRANSACTION
-
- // Obtain an appropriate resolver bound to this session
- Resolver resolver = operationContext.obtainResolver(resolverFactory);
- assert resolver != null;
-
- // Find the local node identifying the model
- long graph = systemResolver.localizePersistent(new URIReferenceImpl(graphURI));
- assert graph != NodePool.NONE;
-
- // Check model does not already exist with a different model type.
- // TODO: there's a node leak here, if the model has already been created.
- Resolution resolution = systemResolver.resolve(new ConstraintImpl(
- new LocalNode(graph),
- new LocalNode(metadata.getRdfTypeNode()),
- new Variable("x"),
- new LocalNode(metadata.getSystemModelNode())));
-
- try {
- resolution.beforeFirst();
- if (resolution.next()) {
- Node eNode = systemResolver.globalize(resolution.getColumnValue(0));
- try {
- URIReferenceImpl existing = (URIReferenceImpl)eNode;
- if (!new URIReferenceImpl(graphTypeURI).equals(existing)) {
- throw new QueryException(graphURI + " already exists with model type " + existing +
- " in attempt to create it with type " + graphTypeURI);
- }
- } catch (ClassCastException ec) {
- throw new QueryException("Invalid model type entry in system model: " + graphURI + " <rdf:type> " + eNode);
- }
- }
- } finally {
- resolution.close();
- }
-
-
- // TODO: there's a node leak here, because the model node was created
- // persistently, but may never end up linked into the graph if the
- // following security check doesn't succeed
-
- // Make sure security adapters are satisfied
- for (Iterator<SecurityAdapter> i = operationContext.getSecurityAdapterList().iterator(); i.hasNext();) {
- SecurityAdapter securityAdapter = i.next();
-
- // Tell the truth to the user
- if (!securityAdapter.canCreateModel(graph, systemResolver) || !securityAdapter.canSeeModel(graph, systemResolver)) {
- throw new QueryException("You aren't allowed to create " + graphURI);
- }
- }
-
- // Use the session to create the model
- resolver.createModel(graph, graphTypeURI);
- }
-
- /**
- * @return <code>true</code>
- */
- public boolean isWriteOperation() {
- return true;
- }
-
- /**
- * Verify that the graph URI is relative to the database URI. The graph
- * URI can use one of the hostname aliases instead of the canonical
- * hostname of the database URI. No checking of the scheme specific part
- * of the graph URI is performed if the database URI is opaque.
- * @param graphURI
- * @param metadata
- * @throws QueryException
- */
- private void verifyGraphUri(URI graphURI, DatabaseMetadata metadata) throws QueryException {
- // only both if this is a scheme which uses fragments - for the moment only RMI
- if (!fragmentScheme(graphURI)) return;
-
- boolean badModelURI = true;
- URI databaseURI = metadata.getURI();
- String scheme = graphURI.getScheme();
- String fragment = graphURI.getFragment();
-
- if (scheme != null && scheme.equals(databaseURI.getScheme()) && fragment != null) {
- if (databaseURI.isOpaque()) {
- // databaseURI is opaque.
- if (graphURI.isOpaque()) {
- // Strip out the query string.
- String ssp = graphURI.getSchemeSpecificPart();
- int qIndex = ssp.indexOf('?');
- if (qIndex >= 0) ssp = ssp.substring(0, qIndex);
-
- if (ssp.equals(databaseURI.getSchemeSpecificPart())) {
- // graphURI is relative to databaseURI.
- badModelURI = false;
- }
- }
- } else {
- // databaseURI is hierarchial.
- String path;
- String host;
-
- if (
- !graphURI.isOpaque() && (
- graphURI.getSchemeSpecificPart().equals(
- databaseURI.getSchemeSpecificPart()
- ) || (
- (host = graphURI.getHost()) != null &&
- graphURI.getPort() == databaseURI.getPort() &&
- (path = graphURI.getPath()) != null &&
- path.equals(databaseURI.getPath()) &&
- metadata.getHostnameAliases().contains(host.toLowerCase())
- )
- )
- ) {
- // graphURI is relative to databaseURI.
- badModelURI = false;
- }
- }
- } else {
- badModelURI = !graphURI.isOpaque();
- }
-
- if (badModelURI) {
- throw new QueryException(
- "Model URI is not relative to the database URI (graphURI:\"" +
- graphURI + "\", databaseURI:\"" + databaseURI + "\")"
- );
- }
- }
-
- /** Schemes with fragments are handled for backward compatibility */
- private static final Set<String> fragmentSchemes = new HashSet<String>();
- static {
- fragmentSchemes.add("rmi");
- fragmentSchemes.add("beep");
- }
-
- /**
- * Test if the given URI is in a scheme which differentiates graphs based on fragments.
- * @param graphUri The URI to test for the graph.
- * @return <code>true</code> only of the URI is in the known graph schemes.
- */
- private static boolean fragmentScheme(URI graphUri) {
- return fragmentSchemes.contains(graphUri.getScheme());
- }
-}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/Database.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/Database.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/Database.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -203,7 +203,7 @@
/**
* The set of {@link SecurityAdapter} instances.
*
- * This will always contain the {@link SystemModelSecurityAdapter} which
+ * This will always contain the {@link SystemGraphSecurityAdapter} which
* safeguards the system model (<code>#</code>). It will additionally
* contain any additional adapters registered via the
* {@link #addSecurityAdapter} method.
@@ -233,7 +233,7 @@
Collections.unmodifiableList(symbolicTransformationList);
/**
- * Model type to use to cache of external models.
+ * Graph type to use to cache of external models.
*/
private final URI temporaryModelTypeURI;
@@ -811,7 +811,7 @@
// Add the mandatory security adapter that protects the system model
securityAdapterList.add(
- new SystemModelSecurityAdapter(metadata.getSystemModelNode())
+ new SystemGraphSecurityAdapter(metadata.getSystemModelNode())
);
addSymbolicTransformation(new DuplicateVariableTransformer());
@@ -1062,7 +1062,7 @@
// check if the other resolver factory is actually the current one
InternalResolverFactory rf = internalResolverFactoryMap.get(modelTypeURI);
if (!rf.resolverFactory.getClass().equals(resolverFactory.getClass())) {
- throw new InitializerException("Model type " + modelTypeURI + " is already registered to " + rf.resolverFactory);
+ throw new InitializerException("Graph type " + modelTypeURI + " is already registered to " + rf.resolverFactory);
} else {
// already registered
return;
@@ -1250,7 +1250,7 @@
transactionManager,
transactionManagerFactory,
Collections.singletonList(
- (SecurityAdapter)new SystemModelSecurityAdapter(metadata.getSystemModelNode())
+ (SecurityAdapter)new SystemGraphSecurityAdapter(metadata.getSystemModelNode())
),
unmodifiableSymbolicTransformationList,
spSessionFactory,
@@ -1281,7 +1281,7 @@
transactionManager,
transactionManagerFactory,
Collections.singletonList(
- new SystemModelSecurityAdapter(metadata.getSystemModelNode())
+ new SystemGraphSecurityAdapter(metadata.getSystemModelNode())
),
unmodifiableSymbolicTransformationList,
jrdfSessionFactory,
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -573,7 +573,8 @@
String newHost = metadata.getSystemModelURI().getHost();
// update the URI
try {
- URI newGraphURI = new URI(uri.getScheme(), newHost, uri.getPath(), uri.getFragment());
+ URI newGraphURI = new URI(uri.getScheme(), uri.getUserInfo(), newHost, uri.getPort(),
+ uri.getPath(), uri.getQuery(), uri.getFragment());
logger.debug("Changing graph URI from " + uri + " to " + newGraphURI);
return new URIReferenceImpl(newGraphURI);
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -304,7 +304,7 @@
* Used by Database *only* to bootstrap the system model on DB startup.
*/
long bootstrapSystemModel(DatabaseMetadataImpl metadata) throws QueryException {
- logger.debug("Bootstrapping System Model");
+ logger.debug("Bootstrapping System Graph");
BootstrapOperation operation = new BootstrapOperation(metadata);
execute(operation, "Failed to bootstrap system-model");
systemResolverFactory.setDatabaseMetadata(metadata);
@@ -507,9 +507,9 @@
public void createModel(URI modelURI, URI modelTypeURI) throws QueryException {
- if (logger.isDebugEnabled()) logger.debug("Creating Model " + modelURI + " with type " + modelTypeURI);
+ if (logger.isDebugEnabled()) logger.debug("Creating Graph " + modelURI + " with type " + modelTypeURI);
- execute(new CreateModelOperation(modelURI, modelTypeURI),
+ execute(new CreateGraphOperation(modelURI, modelTypeURI),
"Could not commit creation of model " + modelURI + " of type " + modelTypeURI);
}
@@ -527,12 +527,12 @@
if (logger.isDebugEnabled()) logger.debug("REMOVE MODEL: " + modelURI);
if (modelURI == null) throw new IllegalArgumentException("Null 'modelURI' parameter");
- execute(new RemoveModelOperation(modelURI), "Unable to remove " + modelURI);
+ execute(new RemoveGraphOperation(modelURI), "Unable to remove " + modelURI);
}
public boolean modelExists(URI modelURI) throws QueryException {
- ModelExistsOperation operation = new ModelExistsOperation(modelURI);
+ GraphExistsOperation operation = new GraphExistsOperation(modelURI);
execute(operation, "Failed to determine model existence");
return operation.getResult();
}
@@ -541,12 +541,12 @@
/**
* Define the contents of a model.
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return RETURNED VALUE TO DO
* @throws QueryException if the model can't be modified
*/
- public synchronized long setModel(URI uri, ModelExpression modelExpression) throws QueryException {
- return this.setModel(null, uri, modelExpression);
+ public synchronized long setModel(URI uri, GraphExpression graphExpression) throws QueryException {
+ return this.setModel(null, uri, graphExpression);
}
@@ -554,34 +554,34 @@
* Define the contents of a model via an inputstream
* @param inputStream a remote inputstream
* @param destinationModelURI the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return RETURNED VALUE TO DO
* @throws QueryException if the model can't be modified
*/
public synchronized long setModel(InputStream inputStream,
- URI destinationModelURI, ModelExpression modelExpression) throws QueryException {
+ URI destinationModelURI, GraphExpression graphExpression) throws QueryException {
if (logger.isDebugEnabled()) {
- logger.debug("SET-MODEL " + destinationModelURI + " to " + modelExpression + " from " + inputStream);
+ logger.debug("SET-MODEL " + destinationModelURI + " to " + graphExpression + " from " + inputStream);
}
// Validate parameters
if (destinationModelURI == null) {
throw new IllegalArgumentException("Null 'destinationModelURI' parameter");
- } else if (modelExpression == null) {
+ } else if (graphExpression == null) {
throw new IllegalArgumentException("Null 'modelExpression' parameter");
}
// Convert the model expression into the source model URI
- if (!(modelExpression instanceof ModelResource)) {
- throw new QueryException("Unsupported model expression " + modelExpression + " (" + modelExpression.getClass() + ")");
+ if (!(graphExpression instanceof GraphResource)) {
+ throw new QueryException("Unsupported model expression " + graphExpression + " (" + graphExpression.getClass() + ")");
}
- assert modelExpression instanceof ModelResource;
+ assert graphExpression instanceof GraphResource;
- URI sourceModelURI = ((ModelResource)modelExpression).getURI();
+ URI sourceModelURI = ((GraphResource)graphExpression).getURI();
assert sourceModelURI != null;
// Perform the operation
- SetModelOperation op = new SetModelOperation(sourceModelURI, destinationModelURI,
+ SetGraphOperation op = new SetGraphOperation(sourceModelURI, destinationModelURI,
inputStream, contentHandlers, this);
// preExcecute is a rather ugly hack, get rid of it once we support re-entrant transactions.
if (op.preExecute()) {
@@ -725,7 +725,7 @@
if (logger.isDebugEnabled()) logger.debug("Modifying (ins:" + insert + ") : " + modelURI);
if (logger.isTraceEnabled()) logger.trace("Modifying statements: " + statements);
- execute(new ModifyModelOperation(modelURI, statements, insert), "Could not commit modify");
+ execute(new ModifyGraphOperation(modelURI, statements, insert), "Could not commit modify");
}
@@ -734,7 +734,7 @@
logger.debug((insert ? "INSERT" : "DELETE") + " QUERY: " + query + " into " + modelURI);
}
- execute(new ModifyModelOperation(modelURI, query, insert, this), "Unable to modify " + modelURI);
+ execute(new ModifyGraphOperation(modelURI, query, insert, this), "Unable to modify " + modelURI);
}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -290,7 +290,7 @@
};
//from <modelURI>
- ModelResource model = new ModelResource(modelURI);
+ GraphResource model = new GraphResource(modelURI);
//where $s $p $o
ConstraintImpl varConstraint = new ConstraintImpl(vars[0], vars[1], vars[2]);
@@ -332,19 +332,19 @@
}
/**
- * Creates the Model.
+ * Creates the Graph.
*
* @param modelURI URI
* @param session Session
* @throws Exception
*/
private void createModel(URI modelURI, Session session) throws Exception {
-// session.createModel(modelURI, new URI(Mulgara.NAMESPACE + "Model"));
+// session.createModel(modelURI, new URI(Mulgara.NAMESPACE + "Graph"));
session.createModel(modelURI, memoryModelURI);
}
/**
- * Drops the Model.
+ * Drops the Graph.
*
* @param modelURI URI
* @param session Session
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -87,22 +87,22 @@
private TestDef test;
- protected static final ModelResource[] models;
+ protected static final GraphResource[] models;
static {
try {
- models = new ModelResource[] {
- new ModelResource(new URI("local:database#")),
- new ModelResource(new File("data/test-model1.rdf").toURI()),
- new ModelResource(new File("data/test-model2.rdf").toURI()),
- new ModelResource(new File("data/test-model3.rdf").toURI()),
- new ModelResource(new File("data/test-model4.rdf").toURI()),
- new ModelResource(new File("data/test-model5.rdf").toURI()),
- new ModelResource(new File("data/test-model6.rdf").toURI()),
- new ModelResource(new File("data/test-model7.rdf").toURI()),
- new ModelResource(new File("data/test-model8.rdf").toURI()),
- new ModelResource(new File("data/test-model9.rdf").toURI()),
- new ModelResource(new File("data/test-model10.rdf").toURI()),
- new ModelResource(new File("data/test-model11.rdf").toURI()),
+ models = new GraphResource[] {
+ new GraphResource(new URI("local:database#")),
+ new GraphResource(new File("data/test-model1.rdf").toURI()),
+ new GraphResource(new File("data/test-model2.rdf").toURI()),
+ new GraphResource(new File("data/test-model3.rdf").toURI()),
+ new GraphResource(new File("data/test-model4.rdf").toURI()),
+ new GraphResource(new File("data/test-model5.rdf").toURI()),
+ new GraphResource(new File("data/test-model6.rdf").toURI()),
+ new GraphResource(new File("data/test-model7.rdf").toURI()),
+ new GraphResource(new File("data/test-model8.rdf").toURI()),
+ new GraphResource(new File("data/test-model9.rdf").toURI()),
+ new GraphResource(new File("data/test-model10.rdf").toURI()),
+ new GraphResource(new File("data/test-model11.rdf").toURI()),
};
} catch (URISyntaxException eu) {
throw new IllegalArgumentException("Initialising ModelResources");
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DefaultConstraintHandlers.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -59,10 +59,10 @@
import org.mulgara.query.rdf.URIReferenceImpl;
import org.mulgara.resolver.spi.ConstraintBindingHandler;
import org.mulgara.resolver.spi.ConstraintLocalization;
-import org.mulgara.resolver.spi.ConstraintModelRewrite;
+import org.mulgara.resolver.spi.ConstraintGraphRewrite;
import org.mulgara.resolver.spi.ConstraintResolutionHandler;
import org.mulgara.resolver.spi.ConstraintVariableRewrite;
-import org.mulgara.resolver.spi.ModelResolutionHandler;
+import org.mulgara.resolver.spi.GraphResolutionHandler;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
import org.mulgara.store.tuples.TuplesOperations;
@@ -95,13 +95,13 @@
static void initializeModelResolutionHandlers() {
ConstraintOperations.addModelResolutionHandlers(new NVPair[]
{
- new NVPair(ModelUnion.class, new ModelResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr,
+ new NVPair(GraphUnion.class, new GraphResolutionHandler() {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr,
Constraint constraint) throws Exception {
Tuples lhs = ConstraintOperations.
- resolveModelExpression(context, ((ModelOperation)modelExpr).getLHS(), constraint);
+ resolveModelExpression(context, ((GraphOperation)modelExpr).getLHS(), constraint);
Tuples rhs = ConstraintOperations.
- resolveModelExpression(context, ((ModelOperation)modelExpr).getRHS(), constraint);
+ resolveModelExpression(context, ((GraphOperation)modelExpr).getRHS(), constraint);
try {
return TuplesOperations.append(lhs, rhs);
} finally {
@@ -110,13 +110,13 @@
}
}
}),
- new NVPair(ModelIntersection.class, new ModelResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr,
+ new NVPair(GraphIntersection.class, new GraphResolutionHandler() {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr,
Constraint constraint) throws Exception {
Tuples lhs = ConstraintOperations.
- resolveModelExpression(context, ((ModelOperation)modelExpr).getLHS(), constraint);
+ resolveModelExpression(context, ((GraphOperation)modelExpr).getLHS(), constraint);
Tuples rhs = ConstraintOperations.
- resolveModelExpression(context, ((ModelOperation)modelExpr).getRHS(), constraint);
+ resolveModelExpression(context, ((GraphOperation)modelExpr).getRHS(), constraint);
try {
return TuplesOperations.join(lhs, rhs);
} finally {
@@ -125,16 +125,16 @@
}
}
}),
- new NVPair(ModelResource.class, new ModelResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr,
+ new NVPair(GraphResource.class, new GraphResolutionHandler() {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr,
Constraint constraint) throws Exception {
- return context.resolve((ModelResource)modelExpr, (Constraint)constraint);
+ return context.resolve((GraphResource)modelExpr, (Constraint)constraint);
}
}),
- new NVPair(ModelVariable.class, new ModelResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr,
+ new NVPair(GraphVariable.class, new GraphResolutionHandler() {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr,
Constraint constraint) throws Exception {
- Variable modelVar = ((ModelVariable)modelExpr).getVariable();
+ Variable modelVar = ((GraphVariable)modelExpr).getVariable();
if (constraint.getVariables().contains(modelVar)) {
// need to change the re-write and wrap the result in a filter
Variable newVar = new Variable("*" + modelVar.getName() + "0");
@@ -158,7 +158,7 @@
ConstraintOperations.addConstraintResolutionHandlers(new NVPair[]
{
new NVPair(ConstraintConjunction.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
List l =
context.resolveConstraintOperation(modelExpr, (ConstraintOperation)constraintExpr);
try {
@@ -172,7 +172,7 @@
}
}),
new NVPair(ConstraintDisjunction.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
List l =
context.resolveConstraintOperation(modelExpr, (ConstraintOperation)constraintExpr);
try {
@@ -186,7 +186,7 @@
}
}),
new NVPair(ConstraintDifference.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
List args = context.resolveConstraintOperation(modelExpr, (ConstraintOperation)constraintExpr);
assert args.size() == 2;
try {
@@ -198,7 +198,7 @@
}
}),
new NVPair(ConstraintOptionalJoin.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
List<Tuples> args = context.resolveConstraintOperation(modelExpr, (ConstraintOperation)constraintExpr);
assert args.size() == 2;
try {
@@ -210,27 +210,27 @@
}
}),
new NVPair(ConstraintIs.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
ConstraintIs constraint = (ConstraintIs)constraintExpr;
return TuplesOperations.assign((Variable)context.localize(constraint.getVariable()),
((LocalNode)context.localize(constraint.getValueNode())).getValue());
}
}),
new NVPair(ConstraintImpl.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
ConstraintImpl constraint = (ConstraintImpl)constraintExpr;
ConstraintElement constraintElem = constraint.getModel();
assert constraintElem != null;
if (constraintElem.equals(Variable.FROM)) {
return ConstraintOperations.resolveModelExpression(context, modelExpr, constraint);
} else if (constraintElem instanceof URIReference) {
- return ConstraintOperations.resolveModelExpression(context, new ModelResource(((URIReference)constraintElem).getURI()), constraint);
+ return ConstraintOperations.resolveModelExpression(context, new GraphResource(((URIReference)constraintElem).getURI()), constraint);
} else if (constraintElem instanceof LocalNode) {
return context.resolve(null, constraint);
} else if (constraintElem instanceof Variable) {
for (int i = 0; i < 3; i++) {
if (constraintElem.equals(constraint.getElement(i))) {
- ModelVariable modelVar = new ModelVariable((Variable)constraintElem);
+ GraphVariable modelVar = new GraphVariable((Variable)constraintElem);
return ConstraintOperations.resolveModelExpression(context, modelVar, constraint);
}
}
@@ -242,12 +242,12 @@
}
}),
new NVPair(WalkConstraint.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
return WalkFunction.walk(context, (WalkConstraint)constraintExpr, modelExpr, context.getResolverSession());
}
}),
new NVPair(SingleTransitiveConstraint.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
SingleTransitiveConstraint constraint = (SingleTransitiveConstraint)constraintExpr;
if (constraint.isAnchored()) {
return DirectTransitiveFunction.infer(context, constraint, modelExpr, context.getResolverSession());
@@ -257,12 +257,12 @@
}
}),
new NVPair(TransitiveConstraint.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
return ExhaustiveTransitiveFunction.infer(context, (TransitiveConstraint)constraintExpr, modelExpr, context.getResolverSession());
}
}),
new NVPair(ConstraintFilter.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
Tuples unfiltered = ConstraintOperations.resolveConstraintExpression(context, modelExpr, ((ConstraintFilter)constraintExpr).getUnfilteredConstraint());
try {
return TuplesOperations.filter(unfiltered, ((ConstraintFilter)constraintExpr).getFilter(), context);
@@ -272,14 +272,14 @@
}
}),
new NVPair(ConstraintIn.class, new ConstraintResolutionHandler() {
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
ConstraintIn constraint = (ConstraintIn)constraintExpr;
- ModelExpression graph;
+ GraphExpression graph;
if (constraint.getGraph() instanceof URIReferenceImpl) {
- graph = new ModelResource(((URIReferenceImpl)constraint.getGraph()).getURI());
+ graph = new GraphResource(((URIReferenceImpl)constraint.getGraph()).getURI());
} else {
assert constraint.getGraph() instanceof Variable;
- graph = new ModelVariable((Variable)constraint.getGraph());
+ graph = new GraphVariable((Variable)constraint.getGraph());
}
return ConstraintOperations.resolveConstraintExpression(context, graph, constraint.getConstraintParam());
}
@@ -358,7 +358,7 @@
static void initializeConstraintModelRewrites() {
ConstraintOperations.addConstraintModelRewrites(new NVPair[]
{
- new NVPair(ConstraintImpl.class, new ConstraintModelRewrite() {
+ new NVPair(ConstraintImpl.class, new ConstraintGraphRewrite() {
public Constraint rewrite(ConstraintElement newModel, Constraint constraint) throws Exception {
return new ConstraintImpl(constraint.getElement(0), constraint.getElement(1), constraint.getElement(2), newModel);
}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DirectTransitiveFunction.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DirectTransitiveFunction.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/DirectTransitiveFunction.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -92,7 +92,7 @@
* @param constraint a constraint describing a transitive predicate with a
* supported model type fourth element of the constraint is not a Variable
* or is a Variable with the name _from.
- * @param modelExpression the ModelExpression to resolve the constraint against.
+ * @param graphExpression the GraphExpression to resolve the constraint against.
* @param session the resolverSession against which to localize nodes.
* @return the answer satisfying the <var>constraint</var>
* @throws QueryException if the <var>constraint</var> has a model of an
@@ -101,7 +101,7 @@
* from various query resolutions.
*/
public static Tuples infer(QueryEvaluationContext query, SingleTransitiveConstraint constraint,
- ModelExpression modelExpression, ResolverSession session)
+ GraphExpression graphExpression, ResolverSession session)
throws QueryException, TuplesException {
if (logger.isDebugEnabled()) {
logger.debug("Transitive Constraint is anchored");
@@ -129,7 +129,7 @@
Constraint predConstraint = constraint.getTransConstraint();
// ask for all statements for this predicate
- Tuples initialTuples = query.resolve(modelExpression, predConstraint);
+ Tuples initialTuples = query.resolve(graphExpression, predConstraint);
// prepare to iterate through anchor
initialTuples.beforeFirst();
@@ -188,7 +188,7 @@
}
// find *all* statements with the given predicate
- Tuples predTuples = query.resolve(modelExpression, openConstraint);
+ Tuples predTuples = query.resolve(graphExpression, openConstraint);
// set up the final result [$x] built from [$x predicate anchor] or [anchor predicate $x]
LiteralTuples inferredResult = new LiteralTuples(new Variable[] {variable});
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExhaustiveTransitiveFunction.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExhaustiveTransitiveFunction.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExhaustiveTransitiveFunction.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -100,7 +100,7 @@
* from various query resolutions.
*/
public static Tuples infer(QueryEvaluationContext query, SingleTransitiveConstraint constraint,
- ModelExpression modelExpression, ResolverSession session)
+ GraphExpression graphExpression, ResolverSession session)
throws QueryException, TuplesException {
if (logger.isDebugEnabled()) {
@@ -130,7 +130,7 @@
Constraint predConstraint = constraint.getTransConstraint();
// ask for all statements for this predicate
- initialTuples = query.resolve(modelExpression, predConstraint);
+ initialTuples = query.resolve(graphExpression, predConstraint);
// prepare to iterate through anchor, or set of all predicate statements
initialTuples.beforeFirst();
@@ -248,7 +248,7 @@
* from various query resolutions.
*/
public static Tuples infer(QueryEvaluationContext query, TransitiveConstraint constraint,
- ModelExpression modelExpression, ResolverSession session)
+ GraphExpression graphExpression, ResolverSession session)
throws QueryException, TuplesException {
if (logger.isDebugEnabled()) {
@@ -304,7 +304,7 @@
// Walk down the graph getting all the statements for the given predicate
initialTuples = WalkFunction.walk(query, walkConstraint,
- modelExpression, session);
+ graphExpression, session);
// prepare to iterate through anchor, or set of all predicate statements
initialTuples.beforeFirst();
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -276,7 +276,7 @@
Xid xid = new TestXid(1);
resource.start(xid, XAResource.TMNOFLAGS);
try {
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
resource.end(xid, XAResource.TMSUCCESS);
resource.prepare(xid);
resource.commit(xid, false);
@@ -600,7 +600,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -617,7 +617,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -681,7 +681,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -698,7 +698,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -782,7 +782,7 @@
// Perform update
rwResource.start(xid3, XAResource.TMNOFLAGS);
- session.setModel(model3URI, new ModelResource(fileURI));
+ session.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(xid3, XAResource.TMSUSPEND);
// Check uncommitted change not visible
@@ -887,7 +887,7 @@
// Perform update
rwResource.start(xid2, XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(xid2, XAResource.TMSUSPEND);
// Check uncommitted change not visible
@@ -946,7 +946,7 @@
// Perform update with autocommit off
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
// Check uncommitted change not visible
roResource.start(xid2, XAResource.TMNOFLAGS);
@@ -1034,7 +1034,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1134,7 +1134,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1229,7 +1229,7 @@
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1339,7 +1339,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1435,7 +1435,7 @@
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1544,7 +1544,7 @@
rwResource.commit(new TestXid(1), true);
rwResource.start(new TestXid(2), XAResource.TMNOFLAGS);
- session.setModel(model3URI, new ModelResource(fileURI));
+ session.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(new TestXid(2), XAResource.TMSUSPEND);
roResource.start(new TestXid(3), XAResource.TMNOFLAGS);
@@ -1596,7 +1596,7 @@
session1.createModel(model4URI, null);
session1.setAutoCommit(false);
- session1.setModel(model4URI, new ModelResource(fileURI));
+ session1.setModel(model4URI, new GraphResource(fileURI));
session1.commit();
session1.close();
@@ -1665,7 +1665,7 @@
};
t2.start();
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
logger.debug("Sleeping for 1sec");
Thread.sleep(1000);
logger.debug("Slept for 1sec");
@@ -1732,7 +1732,7 @@
};
t2.start();
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
logger.debug("Sleeping for 1sec");
Thread.sleep(1000);
logger.debug("Slept for 1sec");
@@ -2576,7 +2576,7 @@
return new Query(
selectList, // SELECT
- new ModelResource(model), // FROM
+ new GraphResource(model), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/GraphExistsOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,83 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): This file, excluding the two lines of the execute method
+ * is an original work developed by Netymon Pty Ltd. Excluding these to
+ * lines this file is:
+ * Copyright (c) 2006 Netymon Pty Ltd.
+ * All Rights Reserved.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Java 2 standard packages
+import java.net.URI;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+// Local packages
+import org.mulgara.query.*;
+import org.mulgara.query.rdf.URIReferenceImpl;
+import org.mulgara.resolver.spi.*;
+
+class GraphExistsOperation implements Operation
+{
+ /** Logger. */
+ private static final Logger logger = Logger.getLogger(GraphExistsOperation.class.getName());
+
+ private URI modelURI = null;
+
+ private boolean result;
+
+
+ GraphExistsOperation(URI modelURI) {
+ this.modelURI = modelURI;
+ }
+
+ //
+ // Methods implementing Operation
+ //
+
+ public void execute(OperationContext operationContext,
+ SystemResolver systemResolver,
+ DatabaseMetadata metadata) throws Exception
+ {
+ try {
+ long model = systemResolver.lookupPersistent(new URIReferenceImpl(modelURI));
+ result = systemResolver.modelExists(model);
+ } catch (LocalizeException le) {
+ result = false;
+ }
+ }
+
+ public boolean isWriteOperation() {
+ return false;
+ }
+
+
+ boolean getResult() {
+ return result;
+ }
+}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/InternalResolver.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/InternalResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/InternalResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -234,7 +234,7 @@
if (resolution.next()) {
long modelType = resolution.getColumnValue(
resolution.getColumnIndex(modelTypeVariable));
- if (resolution.next()) { throw new ResolverException("Model " + model + " has more than one type!");
+ if (resolution.next()) { throw new ResolverException("Graph " + model + " has more than one type!");
}
return modelType;
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/JotmTransactionStandaloneTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/JotmTransactionStandaloneTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/JotmTransactionStandaloneTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -194,7 +194,7 @@
try {
try {
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
} finally {
session.close();
}
@@ -224,7 +224,7 @@
txManager.getTransaction().enlistResource(session.getXAResource());
try {
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
txManager.commit();
} finally {
session.close();
@@ -500,7 +500,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -517,7 +517,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -583,7 +583,7 @@
selectList.add(subjectVariable);
selectList.add(new Subquery(new Variable("k0"), new Query(
Collections.singletonList(objectVariable),
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
@@ -600,7 +600,7 @@
// Evaluate the query
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(modelURI), // FROM
+ new GraphResource(modelURI), // FROM
new ConstraintImpl(subjectVariable, // WHERE
new URIReferenceImpl(new URI("test:p03")),
objectVariable),
@@ -684,7 +684,7 @@
// Perform update
rwResource.start(xid3, XAResource.TMNOFLAGS);
- session.setModel(model3URI, new ModelResource(fileURI));
+ session.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(xid3, XAResource.TMSUSPEND);
// Check uncommitted change not visible
@@ -789,7 +789,7 @@
// Perform update
rwResource.start(xid2, XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(xid2, XAResource.TMSUSPEND);
// Check uncommitted change not visible
@@ -848,7 +848,7 @@
// Perform update with autocommit off
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
// Check uncommitted change not visible
roResource.start(xid2, XAResource.TMNOFLAGS);
@@ -936,7 +936,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1036,7 +1036,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1131,7 +1131,7 @@
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1241,7 +1241,7 @@
resource1.commit(new TestXid(1), true);
resource1.start(new TestXid(2), XAResource.TMNOFLAGS);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1337,7 +1337,7 @@
session1.createModel(model3URI, null);
session1.setAutoCommit(false);
- session1.setModel(model3URI, new ModelResource(fileURI));
+ session1.setModel(model3URI, new GraphResource(fileURI));
final boolean[] tx2Started = new boolean[] { false };
@@ -1446,7 +1446,7 @@
rwResource.commit(new TestXid(1), true);
rwResource.start(new TestXid(2), XAResource.TMNOFLAGS);
- session.setModel(model3URI, new ModelResource(fileURI));
+ session.setModel(model3URI, new GraphResource(fileURI));
rwResource.end(new TestXid(2), XAResource.TMSUSPEND);
roResource.start(new TestXid(3), XAResource.TMNOFLAGS);
@@ -1518,7 +1518,7 @@
return new Query(
selectList, // SELECT
- new ModelResource(model), // FROM
+ new GraphResource(model), // FROM
new ConstraintImpl(subjectVariable, // WHERE
predicateVariable,
objectVariable),
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -145,7 +145,7 @@
}
catch (TuplesException tuplesException) {
- throw new GraphException("Failed to determine if Model contains Triple.",
+ throw new GraphException("Failed to determine if Graph contains Triple.",
tuplesException);
}
finally {
@@ -186,7 +186,7 @@
Query query = new Query(
Arrays.asList(vars), // variable list
- new ModelResource(modelURI), // model expression
+ new GraphResource(modelURI), // model expression
constraint, // constraint expr
null, // no having
(List<Order>)Collections.EMPTY_LIST, // no ordering
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -103,7 +103,7 @@
this.resolverSession = resolverSession;
}
- public List<Tuples> resolveConstraintOperation(ModelExpression modelExpr,
+ public List<Tuples> resolveConstraintOperation(GraphExpression modelExpr,
ConstraintOperation constraintOper)
throws QueryException {
@@ -162,16 +162,16 @@
* Localize and resolve the leaf node of the <code>FROM</code> and
* <code>WHERE</code> clause product.
*
- * @param modelResource the <code>FROM<code> clause to resolve, never
+ * @param graphResource the <code>FROM<code> clause to resolve, never
* <code>null</codE>
* @param constraint the <code>WHERE</code> clause to resolve, which must
* have {@link Variable#FROM} as its fourth element, and never be
* <code>null</code>
* @throws QueryException if resolution can't be obtained
*/
- public Tuples resolve(ModelResource modelResource, Constraint constraint) throws QueryException
+ public Tuples resolve(GraphResource graphResource, Constraint constraint) throws QueryException
{
- assert modelResource != null || !constraint.getModel().equals(Variable.FROM);
+ assert graphResource != null || !constraint.getModel().equals(Variable.FROM);
assert constraint != null;
// Delegate constraint resolution back to the database session
@@ -181,25 +181,25 @@
if (localized.getModel().equals(Variable.FROM)) {
// create the URIReferenceImpl without checking if it is absolute
localized = ConstraintOperations.rewriteConstraintModel(
- localize(new URIReferenceImpl(modelResource.getURI(), false)), localized);
+ localize(new URIReferenceImpl(graphResource.getURI(), false)), localized);
}
Tuples result = operationContext.resolve(localized);
return result;
} catch (LocalizeException e) {
- throw new QueryException("Unable to resolve FROM " + modelResource +
+ throw new QueryException("Unable to resolve FROM " + graphResource +
" WHERE " + constraint, e);
} catch (QueryException eq) {
- throw new QueryException("Error resolving " + constraint + " from " + modelResource, eq);
+ throw new QueryException("Error resolving " + constraint + " from " + graphResource, eq);
} catch (Exception e) {
- throw new QueryException("Unexpected error resolving " + constraint + " from " + modelResource, e);
+ throw new QueryException("Unexpected error resolving " + constraint + " from " + graphResource, e);
}
}
- public Tuples resolve(ModelExpression modelExpression, ConstraintExpression constraintExpression) throws QueryException {
- return ConstraintOperations.resolveConstraintExpression(this, modelExpression, constraintExpression);
+ public Tuples resolve(GraphExpression graphExpression, ConstraintExpression constraintExpression) throws QueryException {
+ return ConstraintOperations.resolveConstraintExpression(this, graphExpression, constraintExpression);
}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModelExistsOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,83 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): This file, excluding the two lines of the execute method
- * is an original work developed by Netymon Pty Ltd. Excluding these to
- * lines this file is:
- * Copyright (c) 2006 Netymon Pty Ltd.
- * All Rights Reserved.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Java 2 standard packages
-import java.net.URI;
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-// Local packages
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.URIReferenceImpl;
-import org.mulgara.resolver.spi.*;
-
-class ModelExistsOperation implements Operation
-{
- /** Logger. */
- private static final Logger logger = Logger.getLogger(ModelExistsOperation.class.getName());
-
- private URI modelURI = null;
-
- private boolean result;
-
-
- ModelExistsOperation(URI modelURI) {
- this.modelURI = modelURI;
- }
-
- //
- // Methods implementing Operation
- //
-
- public void execute(OperationContext operationContext,
- SystemResolver systemResolver,
- DatabaseMetadata metadata) throws Exception
- {
- try {
- long model = systemResolver.lookupPersistent(new URIReferenceImpl(modelURI));
- result = systemResolver.modelExists(model);
- } catch (LocalizeException le) {
- result = false;
- }
- }
-
- public boolean isWriteOperation() {
- return false;
- }
-
-
- boolean getResult() {
- return result;
- }
-}
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,261 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Java 2 standard packages
+import java.net.URI;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+import org.jrdf.graph.Triple;
+
+// Local packages
+import org.mulgara.query.*;
+import org.mulgara.query.rdf.URIReferenceImpl;
+import org.mulgara.resolver.spi.*;
+
+/**
+ * An {@link Operation} that implements the {@link Session#insert} and
+ * {@link Session#delete} methods.
+ *
+ * The operation is really two closely-related operations combined into one
+ * class: modification by a specified set of {@link Triple}s, and modification
+ * by the result of a specified {@link Query}.
+ *
+ * @created 2004-11-24
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:24 $ by $Author: newmana $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
+ * Technology, Inc</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+class ModifyGraphOperation implements Operation
+{
+ /**
+ * Logger.
+ *
+ * This is named after the class.
+ */
+ private static final Logger logger =
+ Logger.getLogger(ModifyGraphOperation.class.getName());
+
+ /**
+ * The URI of the model to be removed.
+ */
+ private final URI modelURI;
+
+ /**
+ * The statements whose occurence is to be modified.
+ *
+ * If this field is not <code>null</code>, {@link #query} will be
+ * <code>null</code>
+ */
+ private final Set<? extends Triple> tripleSet;
+
+ /**
+ * The query generating the statements whose occurence is to be modified.
+ */
+ private final Query query;
+
+ /**
+ * Whether to insert or delete statements from the model.
+ */
+ private final boolean insert;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Construct a modification of a literal set of statements.
+ *
+ * @param modelURI the {@link URI} of the model to be removed, never
+ * <code>null</code>
+ * @param tripleSet the statements to be modified, never <code>null</code>
+ * @param insert whether to insert or delete the <var>tripleSet</var> from
+ * the model
+ * @throws IllegalArgumentException if <var>modelURI</var> or
+ * <var>tripleSet</var> are <code>null</code>
+ */
+ ModifyGraphOperation(URI modelURI, Set<? extends Triple> tripleSet, boolean insert)
+ {
+ // Validate "modelURI" parameter
+ if (modelURI == null) {
+ throw new IllegalArgumentException("Null \"modelURI\" parameter");
+ }
+
+ // Validate "statements" parameter
+ if (tripleSet == null) {
+ throw new IllegalArgumentException("Null \"tripleSet\" parameter");
+ }
+
+ // Initialize fields
+ this.modelURI = modelURI;
+ this.tripleSet = tripleSet;
+ this.query = null;
+ this.insert = insert;
+ }
+
+ /**
+ * Construct a modification of a query-generated set of statements.
+ *
+ * @param modelURI the {@link URI} of the model to be removed, never
+ * <code>null</code>
+ * @param query the query used to generate the statements to be modified,
+ * never <code>null</code>
+ * @param insert whether to insert or delete statements from the model
+ * @throws IllegalArgumentException if <var>modelURI</var> or
+ * <var>query</var> are <code>null</code>
+ * @throws QueryException if <var>query</var> doesn't have exactly three
+ * variables in its <code>SELECT</code> clause
+ */
+ ModifyGraphOperation(URI modelURI, Query query, boolean insert,
+ DatabaseSession databaseSession)
+ throws QueryException
+ {
+ // Validate "modelURI" parameter
+ if (modelURI == null) {
+ throw new IllegalArgumentException("Null \"modelURI\" parameter");
+ }
+
+ // Validate "query" parameter
+ if (query == null) {
+ throw new IllegalArgumentException("Null \"query\" parameter");
+ }
+ if (query.getVariableList().size() != 3) {
+ throw new QueryException(
+ "Invalid select clause in insert/select. Exactly 3 terms required");
+ }
+
+ // Validate "databaseSession" parameter
+ if (databaseSession == null) {
+ throw new IllegalArgumentException("Null \"databaseSession\" parameter");
+ }
+
+ // Initialize fields
+ this.modelURI = modelURI;
+ this.tripleSet = null;
+ this.query = query;
+ this.insert = insert;
+ }
+
+ //
+ // Methods implementing Operation
+ //
+
+ public void execute(OperationContext operationContext,
+ SystemResolver systemResolver,
+ DatabaseMetadata metadata) throws Exception
+ {
+ Statements statements;
+ if (tripleSet != null) {
+ assert query == null;
+
+ statements = new TripleSetWrapperStatements(
+ tripleSet, systemResolver, TripleSetWrapperStatements.PERSIST
+ );
+ } else {
+ assert query != null;
+
+ Answer answer = operationContext.doQuery(query);
+ try {
+ Variable[] vars = answer.getVariables();
+ assert vars.length == 3;
+ statements = new TuplesWrapperStatements(
+ new LocalizedTuples(systemResolver, answer, insert),
+ vars[0], vars[1], vars[2]);
+ } finally {
+ answer.close();
+ }
+ }
+ assert statements != null;
+
+ try {
+ doModify(operationContext, systemResolver, modelURI, statements, insert);
+ } finally {
+ statements.close();
+ }
+ }
+
+
+ protected void doModify(OperationContext operationContext,
+ SystemResolver systemResolver,
+ URI modelURI,
+ Statements statements,
+ boolean insert) throws Exception
+ {
+ long model = systemResolver.localize(new URIReferenceImpl(modelURI));
+ model = operationContext.getCanonicalModel(model);
+
+ // Make sure security adapters are satisfied
+ for (SecurityAdapter securityAdapter: (List<SecurityAdapter>)operationContext.getSecurityAdapterList()) {
+
+ // Lie to the user
+ if (!securityAdapter.canSeeModel(model, systemResolver)) {
+ throw new QueryException("No such model " + modelURI);
+ }
+
+ // Tell the truth to the user
+ if (!securityAdapter.canModifyModel(model, systemResolver)) {
+ throw new QueryException("You aren't allowed to modify " + modelURI);
+ }
+ }
+
+ // Obtain a resolver for the destination model type
+ Resolver resolver = operationContext.obtainResolver(
+ operationContext.findModelResolverFactory(model));
+ assert resolver != null;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Modifying " + modelURI + " using " + resolver);
+ }
+
+ resolver.modifyModel(model, statements, insert);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Modified " + modelURI);
+ }
+ }
+
+ /**
+ * @return <code>true</code>
+ */
+ public boolean isWriteOperation()
+ {
+ return true;
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,261 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Java 2 standard packages
-import java.net.URI;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-import org.jrdf.graph.Triple;
-
-// Local packages
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.URIReferenceImpl;
-import org.mulgara.resolver.spi.*;
-
-/**
- * An {@link Operation} that implements the {@link Session#insert} and
- * {@link Session#delete} methods.
- *
- * The operation is really two closely-related operations combined into one
- * class: modification by a specified set of {@link Triple}s, and modification
- * by the result of a specified {@link Query}.
- *
- * @created 2004-11-24
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:24 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
- * Technology, Inc</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-class ModifyModelOperation implements Operation
-{
- /**
- * Logger.
- *
- * This is named after the class.
- */
- private static final Logger logger =
- Logger.getLogger(ModifyModelOperation.class.getName());
-
- /**
- * The URI of the model to be removed.
- */
- private final URI modelURI;
-
- /**
- * The statements whose occurence is to be modified.
- *
- * If this field is not <code>null</code>, {@link #query} will be
- * <code>null</code>
- */
- private final Set<? extends Triple> tripleSet;
-
- /**
- * The query generating the statements whose occurence is to be modified.
- */
- private final Query query;
-
- /**
- * Whether to insert or delete statements from the model.
- */
- private final boolean insert;
-
- //
- // Constructor
- //
-
- /**
- * Construct a modification of a literal set of statements.
- *
- * @param modelURI the {@link URI} of the model to be removed, never
- * <code>null</code>
- * @param tripleSet the statements to be modified, never <code>null</code>
- * @param insert whether to insert or delete the <var>tripleSet</var> from
- * the model
- * @throws IllegalArgumentException if <var>modelURI</var> or
- * <var>tripleSet</var> are <code>null</code>
- */
- ModifyModelOperation(URI modelURI, Set<? extends Triple> tripleSet, boolean insert)
- {
- // Validate "modelURI" parameter
- if (modelURI == null) {
- throw new IllegalArgumentException("Null \"modelURI\" parameter");
- }
-
- // Validate "statements" parameter
- if (tripleSet == null) {
- throw new IllegalArgumentException("Null \"tripleSet\" parameter");
- }
-
- // Initialize fields
- this.modelURI = modelURI;
- this.tripleSet = tripleSet;
- this.query = null;
- this.insert = insert;
- }
-
- /**
- * Construct a modification of a query-generated set of statements.
- *
- * @param modelURI the {@link URI} of the model to be removed, never
- * <code>null</code>
- * @param query the query used to generate the statements to be modified,
- * never <code>null</code>
- * @param insert whether to insert or delete statements from the model
- * @throws IllegalArgumentException if <var>modelURI</var> or
- * <var>query</var> are <code>null</code>
- * @throws QueryException if <var>query</var> doesn't have exactly three
- * variables in its <code>SELECT</code> clause
- */
- ModifyModelOperation(URI modelURI, Query query, boolean insert,
- DatabaseSession databaseSession)
- throws QueryException
- {
- // Validate "modelURI" parameter
- if (modelURI == null) {
- throw new IllegalArgumentException("Null \"modelURI\" parameter");
- }
-
- // Validate "query" parameter
- if (query == null) {
- throw new IllegalArgumentException("Null \"query\" parameter");
- }
- if (query.getVariableList().size() != 3) {
- throw new QueryException(
- "Invalid select clause in insert/select. Exactly 3 terms required");
- }
-
- // Validate "databaseSession" parameter
- if (databaseSession == null) {
- throw new IllegalArgumentException("Null \"databaseSession\" parameter");
- }
-
- // Initialize fields
- this.modelURI = modelURI;
- this.tripleSet = null;
- this.query = query;
- this.insert = insert;
- }
-
- //
- // Methods implementing Operation
- //
-
- public void execute(OperationContext operationContext,
- SystemResolver systemResolver,
- DatabaseMetadata metadata) throws Exception
- {
- Statements statements;
- if (tripleSet != null) {
- assert query == null;
-
- statements = new TripleSetWrapperStatements(
- tripleSet, systemResolver, TripleSetWrapperStatements.PERSIST
- );
- } else {
- assert query != null;
-
- Answer answer = operationContext.doQuery(query);
- try {
- Variable[] vars = answer.getVariables();
- assert vars.length == 3;
- statements = new TuplesWrapperStatements(
- new LocalizedTuples(systemResolver, answer, insert),
- vars[0], vars[1], vars[2]);
- } finally {
- answer.close();
- }
- }
- assert statements != null;
-
- try {
- doModify(operationContext, systemResolver, modelURI, statements, insert);
- } finally {
- statements.close();
- }
- }
-
-
- protected void doModify(OperationContext operationContext,
- SystemResolver systemResolver,
- URI modelURI,
- Statements statements,
- boolean insert) throws Exception
- {
- long model = systemResolver.localize(new URIReferenceImpl(modelURI));
- model = operationContext.getCanonicalModel(model);
-
- // Make sure security adapters are satisfied
- for (SecurityAdapter securityAdapter: (List<SecurityAdapter>)operationContext.getSecurityAdapterList()) {
-
- // Lie to the user
- if (!securityAdapter.canSeeModel(model, systemResolver)) {
- throw new QueryException("No such model " + modelURI);
- }
-
- // Tell the truth to the user
- if (!securityAdapter.canModifyModel(model, systemResolver)) {
- throw new QueryException("You aren't allowed to modify " + modelURI);
- }
- }
-
- // Obtain a resolver for the destination model type
- Resolver resolver = operationContext.obtainResolver(
- operationContext.findModelResolverFactory(model));
- assert resolver != null;
-
- if (logger.isDebugEnabled()) {
- logger.debug("Modifying " + modelURI + " using " + resolver);
- }
-
- resolver.modifyModel(model, statements, insert);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Modified " + modelURI);
- }
- }
-
- /**
- * @return <code>true</code>
- */
- public boolean isWriteOperation()
- {
- return true;
- }
-}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionFactory.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -96,6 +96,11 @@
synchronized (getMutexLock()) {
timeoutTasks.put(transaction, new XAReaper(transaction, now + txnTimeout, idleTimeout, now));
}
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Timeouts set for transaction " + System.identityHashCode(transaction) +
+ ": idleTimeout=" + idleTimeout + ", txnTimeout=" + txnTimeout);
+ }
}
protected void transactionComplete(MulgaraTransaction transaction) throws MulgaraTransactionException {
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/PrimitiveConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/PrimitiveConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/PrimitiveConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -44,9 +44,9 @@
import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.resolver.spi.ConstraintDescriptor;
-import org.mulgara.resolver.spi.ConstraintModelRewrite;
+import org.mulgara.resolver.spi.ConstraintGraphRewrite;
import org.mulgara.resolver.spi.ConstraintResolutionHandler;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
@@ -70,7 +70,7 @@
private Class<? extends Constraint> constraintClass;
private ConstraintResolutionHandler resolutionHandler;
- private ConstraintModelRewrite rewriteHandler;
+ private ConstraintGraphRewrite rewriteHandler;
/**
* @param constraintClass the class of the constraint described
@@ -81,7 +81,7 @@
* @throws IllegalArgumentException if <var>constraintClass</var> is <code>null</code>
*/
PrimitiveConstraintDescriptor(Class<? extends Constraint> constraintClass,
- ConstraintResolutionHandler resolutionHandler, ConstraintModelRewrite rewriteHandler) {
+ ConstraintResolutionHandler resolutionHandler, ConstraintGraphRewrite rewriteHandler) {
// Validate parameters
if (!ConstraintExpression.class.isAssignableFrom(constraintClass)) {
@@ -107,7 +107,7 @@
}
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
if (rewriteHandler == null) {
throw new IllegalStateException("Attempt to resolve model for " + constraintClass + " no handler registered");
}
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveGraphOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,154 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Java 2 standard packages
+import java.io.*;
+import java.net.URI;
+import java.util.*;
+
+// Third party packages
+import org.apache.log4j.Logger;
+import org.jrdf.graph.*;
+
+// Local packages
+import org.mulgara.query.*;
+import org.mulgara.query.rdf.*;
+import org.mulgara.resolver.spi.*;
+import org.mulgara.store.nodepool.NodePool;
+
+/**
+ * An {@link Operation} that implements the {@link Session#removeModel} method.
+ *
+ * @created 2004-11-24
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.10 $
+ *
+ * @modified $Date: 2005/05/02 20:07:56 $ by $Author: raboczi $
+ *
+ * @maintenanceAuthor $Author: raboczi $
+ *
+ * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
+ * Technology, Inc</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+class RemoveGraphOperation implements Operation
+{
+ /**
+ * Logger.
+ *
+ * This is named after the class.
+ */
+ private static final Logger logger =
+ Logger.getLogger(RemoveGraphOperation.class.getName());
+
+ /**
+ * The URI of the model to be removed.
+ */
+ private final URI modelURI;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Sole constructor.
+ *
+ * @param modelURI the {@link URI} of the model to be removed, never
+ * <code>null</code>
+ * @throws IllegalArgumentException if <var>modelURI</var> is
+ * <code>null</code>
+ */
+ RemoveGraphOperation(URI modelURI)
+ {
+ // Validate "modelURI" parameter
+ if (modelURI == null) {
+ throw new IllegalArgumentException("Null \"modelURI\" parameter");
+ }
+
+ // Initialize fields
+ this.modelURI = modelURI;
+ }
+
+ //
+ // Methods implementing Operation
+ //
+
+ public void execute(OperationContext operationContext,
+ SystemResolver systemResolver,
+ DatabaseMetadata metadata) throws Exception
+ {
+ long model = systemResolver.localize(new URIReferenceImpl(modelURI));
+ model = operationContext.getCanonicalModel(model);
+
+ // Make sure security adapters are satisfied
+ for (Iterator i = operationContext.getSecurityAdapterList().iterator();
+ i.hasNext(); )
+ {
+ SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
+
+ // Lie to the user
+ if (model == NodePool.NONE || !securityAdapter.canSeeModel(model, systemResolver)) {
+ throw new QueryException("No such model " + modelURI);
+ }
+
+ // Tell the truth to the user
+ if (!securityAdapter.canRemoveModel(model, systemResolver)) {
+ throw new QueryException("You aren't allowed to remove " + modelURI);
+ }
+ }
+
+ // Look up the resolver factory for the model
+ ResolverFactory resolverFactory =
+ operationContext.findModelResolverFactory(model);
+
+ if (resolverFactory == null) {
+ throw new QueryException(
+ "Could not obtain a resolver factory for " + modelURI
+ );
+ }
+
+ // Obtain an appropriate resolver bound to this session
+ Resolver resolver = operationContext.obtainResolver(resolverFactory);
+ assert resolver != null;
+
+ // Use the resolver to remove the model
+ resolver.removeModel(model);
+ }
+
+ /**
+ * @return <code>true</code>
+ */
+ public boolean isWriteOperation()
+ {
+ return true;
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RemoveModelOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,154 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Java 2 standard packages
-import java.io.*;
-import java.net.URI;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-import org.jrdf.graph.*;
-
-// Local packages
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
-import org.mulgara.resolver.spi.*;
-import org.mulgara.store.nodepool.NodePool;
-
-/**
- * An {@link Operation} that implements the {@link Session#removeModel} method.
- *
- * @created 2004-11-24
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.10 $
- *
- * @modified $Date: 2005/05/02 20:07:56 $ by $Author: raboczi $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
- * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
- * Technology, Inc</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-class RemoveModelOperation implements Operation
-{
- /**
- * Logger.
- *
- * This is named after the class.
- */
- private static final Logger logger =
- Logger.getLogger(RemoveModelOperation.class.getName());
-
- /**
- * The URI of the model to be removed.
- */
- private final URI modelURI;
-
- //
- // Constructor
- //
-
- /**
- * Sole constructor.
- *
- * @param modelURI the {@link URI} of the model to be removed, never
- * <code>null</code>
- * @throws IllegalArgumentException if <var>modelURI</var> is
- * <code>null</code>
- */
- RemoveModelOperation(URI modelURI)
- {
- // Validate "modelURI" parameter
- if (modelURI == null) {
- throw new IllegalArgumentException("Null \"modelURI\" parameter");
- }
-
- // Initialize fields
- this.modelURI = modelURI;
- }
-
- //
- // Methods implementing Operation
- //
-
- public void execute(OperationContext operationContext,
- SystemResolver systemResolver,
- DatabaseMetadata metadata) throws Exception
- {
- long model = systemResolver.localize(new URIReferenceImpl(modelURI));
- model = operationContext.getCanonicalModel(model);
-
- // Make sure security adapters are satisfied
- for (Iterator i = operationContext.getSecurityAdapterList().iterator();
- i.hasNext(); )
- {
- SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
-
- // Lie to the user
- if (model == NodePool.NONE || !securityAdapter.canSeeModel(model, systemResolver)) {
- throw new QueryException("No such model " + modelURI);
- }
-
- // Tell the truth to the user
- if (!securityAdapter.canRemoveModel(model, systemResolver)) {
- throw new QueryException("You aren't allowed to remove " + modelURI);
- }
- }
-
- // Look up the resolver factory for the model
- ResolverFactory resolverFactory =
- operationContext.findModelResolverFactory(model);
-
- if (resolverFactory == null) {
- throw new QueryException(
- "Could not obtain a resolver factory for " + modelURI
- );
- }
-
- // Obtain an appropriate resolver bound to this session
- Resolver resolver = operationContext.obtainResolver(resolverFactory);
- assert resolver != null;
-
- // Use the resolver to remove the model
- resolver.removeModel(model);
- }
-
- /**
- * @return <code>true</code>
- */
- public boolean isWriteOperation()
- {
- return true;
- }
-}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RestoreOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RestoreOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/RestoreOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -380,7 +380,7 @@
if (meta == emptyGroupNode) {
// Statements in the EMPTY_GROUP.
if (node1 == tksIntModelNode) {
- // Set up a mapping from each V4 Group node to (multiple) Model
+ // Set up a mapping from each V4 Group node to (multiple) Graph
// nodes.
Long groupL = new Long(node0);
Set modelSet = (Set)g2mMap.get(groupL);
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetGraphOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,231 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Java 2 standard packages
+import java.io.*;
+import java.net.URI;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+// Local packages
+import org.mulgara.content.Content;
+import org.mulgara.content.ContentHandler;
+import org.mulgara.content.ContentHandlerException;
+import org.mulgara.content.ContentHandlerManager;
+import org.mulgara.content.ContentLoader;
+import org.mulgara.content.NotModifiedException;
+import org.mulgara.query.*;
+import org.mulgara.query.rdf.*;
+import org.mulgara.resolver.spi.*;
+
+/**
+ * An {@link Operation} that implements the {@link Session#setModel} method.
+ *
+ * @created 2004-11-04
+ *
+ * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
+ *
+ * @version $Revision: 1.10 $
+ *
+ * @modified $Date: 2005/05/02 20:07:56 $ by $Author: raboczi $
+ *
+ * @maintenanceAuthor $Author: raboczi $
+ *
+ * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
+ * Technology, Inc</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+class SetGraphOperation implements Operation
+{
+ /**
+ * Logger.
+ *
+ * This is named after the class.
+ */
+ private static final Logger logger =
+ Logger.getLogger(SetGraphOperation.class.getName());
+
+ private final URI srcModelURI;
+ private final URI destModelURI;
+ private final InputStream inputStream;
+
+ private Content content;
+ private final ContentHandlerManager contentHandlers;
+ private final DatabaseSession databaseSession;
+
+ /**
+ * Number of statements loaded, or -1 if the {@link #execute} method hasn't yet been
+ * invoked.
+ */
+ private long statementCount = -1;
+
+ //
+ // Constructor
+ //
+
+ /**
+ * Sole constructor.
+ *
+ * @param srcModelURI the {@link URI} of the model to be redefined
+ * @param destModelURI the {@link URI} of the model to be redefined
+ * @param inputStream a stream containing the content at the <var>srcModelURI</var>
+ * or <code>null</code> if the content must be fetched
+ */
+ SetGraphOperation(URI srcModelURI,
+ URI destModelURI,
+ InputStream inputStream,
+ ContentHandlerManager contentHandlers,
+ DatabaseSession databaseSession)
+ {
+ this.srcModelURI = srcModelURI;
+ this.destModelURI = destModelURI;
+ this.inputStream = inputStream;
+ this.contentHandlers = contentHandlers;
+ this.databaseSession = databaseSession;
+ }
+
+ //
+ // Methods implementing Operation
+ //
+
+ public void execute(OperationContext operationContext,
+ SystemResolver systemResolver,
+ DatabaseMetadata metadata) throws Exception
+ {
+ // A prior call to execute will have set statementCount >= 0.
+ if (statementCount != -1) {
+ throw new IllegalStateException("SetGraphOperation already executed. Cannot reexecute.");
+ }
+
+ long destinationModel = systemResolver.localize(new URIReferenceImpl(destModelURI));
+ try {
+ long sourceModel = systemResolver.localize(new URIReferenceImpl(srcModelURI, false));
+ if (destinationModel == sourceModel) throw new QueryException("Identical source and destination: " + destModelURI);
+ } catch (Exception e) {
+ // source and destinations cannot be equal, so ignore
+ }
+
+ // update the destination to the canonical form
+ destinationModel = operationContext.getCanonicalModel(destinationModel);
+
+ // Obtain a resolver for the destination model type
+ Resolver destinationResolver = operationContext.obtainResolver(
+ operationContext.findModelResolverFactory(destinationModel));
+ assert destinationResolver != null;
+
+ ContentHandler contentHandler = contentHandlers.getContentHandler(content);
+
+ Statements statements = contentHandler.parse(content,
+ new PersistentResolverSession(systemResolver));
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Modifying " + destModelURI + " using " + destinationResolver);
+ }
+
+ destinationResolver.modifyModel(destinationModel, statements, true);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Modified " + destModelURI);
+ }
+
+ statementCount = statements.getRowCount();
+ }
+
+ /**
+ * @return <code>true</code>
+ */
+ public boolean isWriteOperation() {
+ return true;
+ }
+
+
+ //
+ // Operation result accessor
+ //
+
+ /**
+ * @return the number of statements loaded
+ * @throws IllegalStateException if {@link #execute} hasn't yet been called
+ */
+ long getStatementCount()
+ {
+ if (statementCount == -1) {
+ throw new IllegalStateException("Statement count not available before execution.");
+ }
+
+ return statementCount;
+ }
+
+
+ /**
+ * This method is a refactoring hack, purely to get all the code which
+ * depends on content handler and resolver components out of the core
+ * <code>resolver</code> component.
+ *
+ * @return whether {@link #execute} should be called next
+ */
+ boolean preExecute() throws QueryException
+ {
+ // create a StreamContent if an inputStream has been supplied
+ if (inputStream != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Detected inputstream associated with " + srcModelURI );
+ }
+ content = new StreamContent(inputStream, srcModelURI);
+ } else {
+ try {
+ content = ContentFactory.getContent(srcModelURI);
+ } catch (ContentHandlerException ec) {
+ throw new QueryException("Failed to find Content for uri", ec);
+ }
+ }
+
+ ContentLoader loader;
+ try {
+ loader = contentHandlers.getContentLoader(content);
+ } catch (NotModifiedException e) {
+ throw new QueryException("Content is already cached", e);
+ } catch (ContentHandlerException ec) {
+ throw new QueryException("Failure finding contentLoader");
+ }
+
+ if (loader != null) {
+ try {
+ statementCount = loader.load(content, new GraphResource(destModelURI), databaseSession);
+
+ return false; // notifies caller that a call to execute will fail.
+ } catch (ContentHandlerException handlerException) {
+ throw new QueryException("Failed to setModel.", handlerException);
+ }
+ }
+
+ return true;
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SetModelOperation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,233 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Java 2 standard packages
-import java.io.*;
-import java.net.URI;
-import java.util.*;
-
-// Third party packages
-import org.apache.log4j.Logger;
-import org.jrdf.graph.*;
-
-// Local packages
-import org.mulgara.content.Content;
-import org.mulgara.content.ContentHandler;
-import org.mulgara.content.ContentHandlerException;
-import org.mulgara.content.ContentHandlerManager;
-import org.mulgara.content.ContentLoader;
-import org.mulgara.content.NotModifiedException;
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
-import org.mulgara.resolver.spi.*;
-
-/**
- * An {@link Operation} that implements the {@link Session#setModel} method.
- *
- * @created 2004-11-04
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.10 $
- *
- * @modified $Date: 2005/05/02 20:07:56 $ by $Author: raboczi $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
- * @copyright ©2004 <a href="http://www.tucanatech.com/">Tucana
- * Technology, Inc</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-class SetModelOperation implements Operation
-{
- /**
- * Logger.
- *
- * This is named after the class.
- */
- private static final Logger logger =
- Logger.getLogger(SetModelOperation.class.getName());
-
- private final URI srcModelURI;
- private final URI destModelURI;
- private final InputStream inputStream;
-
- private Content content;
- private final ContentHandlerManager contentHandlers;
- private final DatabaseSession databaseSession;
-
- /**
- * Number of statements loaded, or -1 if the {@link #execute} method hasn't yet been
- * invoked.
- */
- private long statementCount = -1;
-
- //
- // Constructor
- //
-
- /**
- * Sole constructor.
- *
- * @param srcModelURI the {@link URI} of the model to be redefined
- * @param destModelURI the {@link URI} of the model to be redefined
- * @param inputStream a stream containing the content at the <var>srcModelURI</var>
- * or <code>null</code> if the content must be fetched
- */
- SetModelOperation(URI srcModelURI,
- URI destModelURI,
- InputStream inputStream,
- ContentHandlerManager contentHandlers,
- DatabaseSession databaseSession)
- {
- this.srcModelURI = srcModelURI;
- this.destModelURI = destModelURI;
- this.inputStream = inputStream;
- this.contentHandlers = contentHandlers;
- this.databaseSession = databaseSession;
- }
-
- //
- // Methods implementing Operation
- //
-
- public void execute(OperationContext operationContext,
- SystemResolver systemResolver,
- DatabaseMetadata metadata) throws Exception
- {
- // A prior call to execute will have set statementCount >= 0.
- if (statementCount != -1) {
- throw new IllegalStateException("SetModelOperation already executed. Cannot reexecute.");
- }
-
- long destinationModel = systemResolver.localize(new URIReferenceImpl(destModelURI));
- try {
- long sourceModel = systemResolver.localize(new URIReferenceImpl(srcModelURI, false));
- if (destinationModel == sourceModel) throw new QueryException("Identical source and destination: " + destModelURI);
- } catch (Exception e) {
- // source and destinations cannot be equal, so ignore
- }
-
- // update the destination to the canonical form
- destinationModel = operationContext.getCanonicalModel(destinationModel);
-
- // Obtain a resolver for the destination model type
- Resolver destinationResolver = operationContext.obtainResolver(
- operationContext.findModelResolverFactory(destinationModel));
- assert destinationResolver != null;
-
- ContentHandler contentHandler = contentHandlers.getContentHandler(content);
-
- Statements statements = contentHandler.parse(content,
- new PersistentResolverSession(systemResolver));
-
- if (logger.isDebugEnabled()) {
- logger.debug("Modifying " + destModelURI + " using " + destinationResolver);
- }
-
- destinationResolver.modifyModel(destinationModel, statements, true);
- if (logger.isDebugEnabled()) {
- logger.debug("Modified " + destModelURI);
- }
-
- statementCount = statements.getRowCount();
- }
-
- /**
- * @return <code>true</code>
- */
- public boolean isWriteOperation() {
- return true;
- }
-
-
- //
- // Operation result accessor
- //
-
- /**
- * @return the number of statements loaded
- * @throws IllegalStateException if {@link #execute} hasn't yet been called
- */
- long getStatementCount()
- {
- if (statementCount == -1) {
- throw new IllegalStateException("Statement count not available before execution.");
- }
-
- return statementCount;
- }
-
-
- /**
- * This method is a refactoring hack, purely to get all the code which
- * depends on content handler and resolver components out of the core
- * <code>resolver</code> component.
- *
- * @return whether {@link #execute} should be called next
- */
- boolean preExecute() throws QueryException
- {
- // create a StreamContent if an inputStream has been supplied
- if (inputStream != null) {
- if (logger.isDebugEnabled()) {
- logger.debug("Detected inputstream associated with " + srcModelURI );
- }
- content = new StreamContent(inputStream, srcModelURI);
- } else {
- try {
- content = ContentFactory.getContent(srcModelURI);
- } catch (ContentHandlerException ec) {
- throw new QueryException("Failed to find Content for uri", ec);
- }
- }
-
- ContentLoader loader;
- try {
- loader = contentHandlers.getContentLoader(content);
- } catch (NotModifiedException e) {
- throw new QueryException("Content is already cached", e);
- } catch (ContentHandlerException ec) {
- throw new QueryException("Failure finding contentLoader");
- }
-
- if (loader != null) {
- try {
- statementCount = loader.load(content, new ModelResource(destModelURI), databaseSession);
-
- return false; // notifies caller that a call to execute will fail.
- } catch (ContentHandlerException handlerException) {
- throw new QueryException("Failed to setModel.", handlerException);
- }
- }
-
- return true;
- }
-}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -610,7 +610,7 @@
) {
URI uri = ((SPURI)spObject).getURI();
if (!uri.isAbsolute()) {
- // Model URIs are stored as a relative URI containing only a fragment.
+ // Graph URIs are stored as a relative URI containing only a fragment.
// Relative URIs with both a query string and a fragment are also used
// for views.
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemGraphSecurityAdapter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,86 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver;
+
+// Local packages
+import org.mulgara.resolver.spi.NullSecurityAdapter;
+import org.mulgara.resolver.spi.ResolverSession;
+import org.mulgara.store.nodepool.NodePool;
+
+/**
+ * This {@link SecurityAdapter} enforces the sanctity of the system model
+ * (<code>#</code>).
+ *
+ * A {@link Session} may only modify the contents of the system model
+ * indirectly, via the <code>backup</code>, <code>create</code>,
+ * <code>drop</code> and <code>restore</code> methods.
+ *
+ * @created 2004-10-15
+ * @author <a href="http://www.pisoftware.com/raboczi">Simon Raboczi</a>
+ * @version $Revision: 1.8 $
+ * @modified $Date: 2005/01/05 04:58:24 $
+ * @maintenanceAuthor $Author: newmana $
+ * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
+ * @copyright ©2004 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+
+class SystemGraphSecurityAdapter extends NullSecurityAdapter
+{
+ /**
+ * The preallocated node representing the system model.
+ */
+ private final long systemModel;
+
+ /**
+ * Sole constructor.
+ *
+ * @param systemModel the preallocated node representing the system model
+ */
+ SystemGraphSecurityAdapter(long systemModel)
+ {
+ assert systemModel != NodePool.NONE;
+
+ // Initialize fields
+ this.systemModel = systemModel;
+ }
+
+ //
+ // Methods overriding NullSecurityAdapter
+ //
+
+ /**
+ * @return <code>true</code> unless <var>model</var> represents the system
+ * model
+ */
+ public boolean canModifyModel(long model, ResolverSession resolverSession)
+ {
+ return model != systemModel;
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/SystemModelSecurityAdapter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,86 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver;
-
-// Local packages
-import org.mulgara.resolver.spi.NullSecurityAdapter;
-import org.mulgara.resolver.spi.ResolverSession;
-import org.mulgara.store.nodepool.NodePool;
-
-/**
- * This {@link SecurityAdapter} enforces the sanctity of the system model
- * (<code>#</code>).
- *
- * A {@link Session} may only modify the contents of the system model
- * indirectly, via the <code>backup</code>, <code>create</code>,
- * <code>drop</code> and <code>restore</code> methods.
- *
- * @created 2004-10-15
- * @author <a href="http://www.pisoftware.com/raboczi">Simon Raboczi</a>
- * @version $Revision: 1.8 $
- * @modified $Date: 2005/01/05 04:58:24 $
- * @maintenanceAuthor $Author: newmana $
- * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
- * @copyright ©2004 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-
-class SystemModelSecurityAdapter extends NullSecurityAdapter
-{
- /**
- * The preallocated node representing the system model.
- */
- private final long systemModel;
-
- /**
- * Sole constructor.
- *
- * @param systemModel the preallocated node representing the system model
- */
- SystemModelSecurityAdapter(long systemModel)
- {
- assert systemModel != NodePool.NONE;
-
- // Initialize fields
- this.systemModel = systemModel;
- }
-
- //
- // Methods overriding NullSecurityAdapter
- //
-
- /**
- * @return <code>true</code> unless <var>model</var> represents the system
- * model
- */
- public boolean canModifyModel(long model, ResolverSession resolverSession)
- {
- return model != systemModel;
- }
-}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/TestDef.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/TestDef.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/TestDef.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -55,14 +55,14 @@
public String name;
public String[] resolvers;
public List<Variable> selectList;
- public ModelExpression model;
+ public GraphExpression model;
public ConstraintExpression query;
public List<List<Object>> results;
public String errorString;
@SuppressWarnings("unchecked")
public TestDef(String name, String[] resolvers, TestQuery query,
- ModelExpression model, List results, String errorString) {
+ GraphExpression model, List results, String errorString) {
this.name = name;
this.resolvers = resolvers;
this.model = model;
@@ -85,9 +85,9 @@
static public class Parser {
private ConstraintElement[] elements;
- private ModelResource[] models;
+ private GraphResource[] models;
- public Parser(ConstraintElement[] elements, ModelResource[] models) {
+ public Parser(ConstraintElement[] elements, GraphResource[] models) {
this.elements = elements;
this.models = models;
}
@@ -113,7 +113,7 @@
}
- private ModelExpression parseModel(StringTokenizer tokenizer) {
+ private GraphExpression parseModel(StringTokenizer tokenizer) {
String token = getToken(tokenizer);
if ("(".equals(token)) {
@@ -126,34 +126,34 @@
}
- private ModelOperation parseModelOperation(StringTokenizer tokenizer) {
+ private GraphOperation parseModelOperation(StringTokenizer tokenizer) {
String token = getToken(tokenizer);
- ModelExpression lhs = parseModel(tokenizer);
- ModelExpression rhs = parseModel(tokenizer);
+ GraphExpression lhs = parseModel(tokenizer);
+ GraphExpression rhs = parseModel(tokenizer);
String terminator = getToken(tokenizer);
if (!")".equals(terminator)) {
- throw new IllegalArgumentException("Unterminated ModelOperation " + terminator);
+ throw new IllegalArgumentException("Unterminated GraphOperation " + terminator);
}
if ("union".equals(token)) {
- return new ModelUnion(lhs, rhs);
+ return new GraphUnion(lhs, rhs);
}
if ("intersect".equals(token)) {
- return new ModelIntersection(lhs, rhs);
+ return new GraphIntersection(lhs, rhs);
}
- throw new IllegalArgumentException("Unknown ModelOperation " + token);
+ throw new IllegalArgumentException("Unknown GraphOperation " + token);
}
- private ModelResource parseModelResource(String token) {
+ private GraphResource parseModelResource(String token) {
try {
int index = Integer.parseInt(token.substring(1));
if (index > models.length) {
- throw new IllegalArgumentException("Invalid ModelResource index " + index);
+ throw new IllegalArgumentException("Invalid GraphResource index " + index);
}
return models[index];
} catch (NumberFormatException en) {
- throw new IllegalArgumentException("Invalid ModelResource descriptor" + token);
+ throw new IllegalArgumentException("Invalid GraphResource descriptor" + token);
}
}
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/WalkFunction.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/WalkFunction.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/WalkFunction.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -93,7 +93,7 @@
* @param predConstraint a constraint describing a predicate to traverse with
* a supported model type fourth element of the constraint is not a Variable
* or is a Variable with the name _from.
- * @param modelExpression the Graph to resolve the constraint against if the
+ * @param graphExpression the Graph to resolve the constraint against if the
* fourth element of the constraint is a Variable with the name _from.
* @return the answer satisfying the <var>constraint</var>
* @throws QueryException if the <var>constraint</var> has a model of an
@@ -102,7 +102,7 @@
* from various query resolutions.
*/
public static Tuples walk(QueryEvaluationContext query, WalkConstraint predConstraint,
- ModelExpression modelExpression, ResolverSession session)
+ GraphExpression graphExpression, ResolverSession session)
throws QueryException, TuplesException {
if (logger.isDebugEnabled()) {
@@ -149,7 +149,7 @@
try {
// ask for all statements for this predicate
- initialTuples = query.resolve(modelExpression, predConstraint.getAnchoredConstraint());
+ initialTuples = query.resolve(graphExpression, predConstraint.getAnchoredConstraint());
// prepare to iterate through anchor
initialTuples.beforeFirst();
@@ -232,7 +232,7 @@
}
// find *all* statements with the given predicate
- predTuples = query.resolve(modelExpression, openConstraint);
+ predTuples = query.resolve(graphExpression, openConstraint);
// remember that the current value has been visited
Set visited = new HashSet();
Modified: branches/xa11/src/jar/resolver/java/org/mulgara/resolver/XADatabaseSessionUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/resolver/XADatabaseSessionUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/resolver/XADatabaseSessionUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -133,11 +133,11 @@
};
- protected static final ModelResource[] models;
+ protected static final GraphResource[] models;
static {
- models = new ModelResource[modelURIs.length];
+ models = new GraphResource[modelURIs.length];
for (int i = 0; i < modelURIs.length; i++) {
- models[i] = new ModelResource(modelURIs[i]);
+ models[i] = new GraphResource(modelURIs[i]);
}
};
@@ -582,7 +582,7 @@
Session session = database.newSession();
for (int i = 1; i < modelURIs.length; i++) {
session.createModel(modelURIs[i], modelTypeURI);
- session.setModel(modelURIs[i], new ModelResource(modelDataURIs[i]));
+ session.setModel(modelURIs[i], new GraphResource(modelDataURIs[i]));
}
} catch (URISyntaxException e) {
throw new Error("Bad hardcoded XA store model URI", e);
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphN3Writer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,204 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+package org.mulgara.store.exporter;
+
+// Java 2 standard packages
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+// Apache packages
+import org.apache.log4j.Logger;
+
+// JRDF
+import org.jrdf.vocabulary.*;
+
+// Local packages
+import org.jrdf.graph.GraphException;
+import org.jrdf.util.ClosableIterator;
+import org.jrdf.graph.*;
+import org.mulgara.store.*;
+
+/**
+ * A Writer used to write N3 for a Mulgara model.
+ *
+ * @created 2004-07-26
+ *
+ * @author <a href="mailto:pag at pisoftware.com">Paul Gearon</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:25 $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
+ *
+ * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphN3Writer implements GraphWriter {
+
+ /**
+ * Logger. This is named after the class.
+ */
+ private final static Logger log = Logger.getLogger(GraphN3Writer.class.
+ getName());
+
+
+ /**
+ * Default Constructor
+ */
+ public GraphN3Writer() {
+ }
+
+
+ /**
+ * Writes the contents of the JRDFGraph to a PrintWriter in N3 format.
+ *
+ * @param graph Graph Graph containing the Statements to be written.
+ * @param writer PrintWriter Where to write the statements.
+ * @throws GraphException
+ */
+ synchronized public void write(Graph graph, PrintWriter writer) throws
+ GraphException {
+
+ //write Header, Body and Footer
+ try {
+
+ //write document
+ writeHeader(writer);
+ writeBody(graph, writer);
+ }
+ catch (IOException ioException) {
+
+ throw new GraphException("Could not write Graph.", ioException);
+ }
+ }
+
+
+ /**
+ * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format
+ * with the encoding specified in the opening XML tag.
+ *
+ * @param graph Graph Graph containing the Statements to be written.
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ synchronized public void write(Graph graph, OutputStreamWriter writer)
+ throws GraphException {
+
+ //wrap writer and enable auto flushing
+ PrintWriter out = new PrintWriter(writer, true);
+
+ write(graph, out);
+ }
+
+
+ /**
+ * Writes any desired comments as a header.
+ *
+ * @param out the writer to use to output.
+ * @throws IOException if there was an IO exception.
+ * @throws IllegalArgumentException if the given writer is null.
+ */
+ private void writeHeader(PrintWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+ out.println("# Mulgara graph in N3");
+ } else {
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+
+ /**
+ * Writes the Graph's statements as N3 to the print Writer.
+ *
+ * @param graph Graph Graph containing the Statements to be written.
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ private void writeBody(Graph graph, PrintWriter out) throws IOException,
+ GraphException {
+
+ //validate
+ if ( (out != null)
+ && (graph != null)) {
+
+ // iterator to access entire graph
+ ClosableIterator graphIter = graph.find(null, null, null);
+
+ while (graphIter.hasNext()) {
+ // extract the triple
+ Triple triple = (Triple)graphIter.next();
+ SubjectNode s = triple.getSubject();
+ PredicateNode p = triple.getPredicate();
+ ObjectNode o = triple.getObject();
+
+ out.println("<" + s.toString() + "> <" + ((URIReference)p).getURI().toString() + "> "+ getLabel(o));
+ }
+
+ } else {
+
+ //message for exception to be thrown
+ String message = "Could not write Graph. Invlaid arguments provided. ";
+
+ if (out == null) {
+ message += "Writer is null. ";
+ }
+
+ if (graph == null) {
+ message += "Graph is null. ";
+ }
+
+ throw new IllegalArgumentException(message);
+ }
+ }
+
+
+ /**
+ * Formats an object node appropriately at either a literal or a resource.
+ * For efficiency, a line termination character is appended.
+ *
+ * @param node The object node to format
+ * @throws GraphException
+ */
+ private String getLabel(ObjectNode node) {
+ if (node instanceof Literal) {
+ return "\"" + ((Literal)node).getLexicalForm() + "\" .";
+ } else if (node instanceof URIReference) {
+ return "<" + ((URIReference)node).getURI().toString() + "> .";
+ }
+ // node is a blank node
+ return "<" + node.toString() + "> .";
+ }
+
+}
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,77 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+package org.mulgara.store.exporter;
+
+// Java 2 standard packages
+import java.io.*;
+
+// Local packages
+import org.jrdf.graph.GraphException;
+import org.jrdf.graph.Graph;
+
+/**
+ * A Writer used to write a serialization for a Mulgara model.
+ *
+ * @created 2004-02-23
+ *
+ * @author <a href="mailto:pag at tucanatech.com">Paul Gearon</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:25 $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
+ *
+ * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public interface GraphWriter {
+
+ /**
+ * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format.
+ *
+ * @param graph JRDF Graph containing the Statements to be written.
+ * @param writer PrintWriter Where to write the statements.
+ * @throws GraphException
+ */
+ public void write(Graph graph, PrintWriter writer) throws GraphException;
+
+ /**
+ * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format
+ * with the encoding specified in the opening XML tag.
+ *
+ * @param graph JRDF Graph
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ public void write(Graph graph, OutputStreamWriter writer) throws GraphException;
+
+}
Copied: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java (from rev 1423, trunk/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java)
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java (rev 0)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/GraphXMLWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,1143 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+package org.mulgara.store.exporter;
+
+// Java 2 standard packages
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+// Apache packages
+import org.apache.log4j.Logger;
+import org.apache.xerces.util.EncodingMap;
+
+// JRDF
+import org.jrdf.graph.GraphException;
+import org.jrdf.util.ClosableIterator;
+import org.jrdf.vocabulary.*;
+
+// Local packages
+/*
+import org.mulgara.resolver.jrdf.ClosableIteratorImpl;
+import org.mulgara.resolver.jrdf.JRDFGraph;
+*/
+import org.jrdf.graph.*;
+import org.mulgara.query.Order;
+import org.mulgara.query.Value;
+import org.mulgara.store.*;
+import org.mulgara.store.statement.StatementStore;
+import org.mulgara.store.tuples.RowComparator;
+import org.mulgara.util.*;
+
+/**
+ * A Writer used to write RDF/XML for a Mulgara model.
+ *
+ * @created 2004-02-20
+ *
+ * @author <a href="mailto:robert.turner at tucanatech.com">Robert Turner</a>
+ *
+ * @version $Revision: 1.8 $
+ *
+ * @modified $Date: 2005/01/05 04:58:25 $
+ *
+ * @maintenanceAuthor $Author: newmana $
+ *
+ * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
+ *
+ * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ *
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+public class GraphXMLWriter
+ implements GraphWriter {
+
+ /**
+ * Logger. This is named after the class.
+ */
+ private final static Logger log = Logger.getLogger(GraphXMLWriter.class.
+ getName());
+
+ /** Prefix used to abbreviate RDF Namespace */
+ private static final String RDF_PREFIX = "rdf";
+
+ /** Prefix used to abbreviate RDFS Namespace */
+ private static final String RDFS_PREFIX = "rdfs";
+
+ /** Convenience reference to the new line character */
+ private static final String NEWLINE = System.getProperty("line.separator");
+
+ /** Map used to replace commonly used namespaces with prefixes */
+ protected Map namespaces = null;
+
+ /**
+ * Default Constructor
+ */
+ public GraphXMLWriter() {
+ }
+
+ /**
+ * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format.
+ *
+ * @param graph JRDFGraph Graph containing the Statements to be written.
+ * @param writer PrintWriter Where to write the statements.
+ * @throws GraphException
+ */
+ synchronized public void write(Graph graph, PrintWriter writer) throws
+ GraphException {
+
+ /*
+ if (! (graph instanceof JRDFGraph)) {
+ throw new IllegalArgumentException("Graph must be of type JRDFGraph");
+ }
+ */
+
+ //write Header, Body and Footer
+ try {
+
+ //initialize the namespaces first
+ this.populateNamespaces(graph);
+
+ //write document
+ this.writeHeader(writer);
+ this.writeBody(graph, writer);
+ this.writeFooter(writer);
+ }
+ catch (IOException ioException) {
+
+ throw new GraphException("Could not write Graph.", ioException);
+ }
+ }
+
+ /**
+ * Writes the contents of the JRDF Graph to a PrintWriter in RDF/XML format
+ * with the encoding specified in the opening XML tag.
+ *
+ * @param graph JRDFGraph
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ synchronized public void write(Graph graph, OutputStreamWriter writer) throws
+ GraphException {
+
+ /*
+ if (! (graph instanceof JRDFGraph)) {
+ throw new IllegalArgumentException("Graph must be of type JRDFGraph");
+ }
+ */
+
+ //write Header, Body and Footer
+ try {
+
+ //wrap writer and enable auto flushing
+ PrintWriter out = new PrintWriter(writer, true);
+
+ //initialize the namespaces first
+ this.populateNamespaces(graph);
+
+ //write document
+ this.writeHeader(writer);
+ this.writeBody(graph, out);
+ this.writeFooter(out);
+ }
+ catch (IOException ioException) {
+
+ throw new GraphException("Could not write Graph.", ioException);
+ }
+ }
+
+ /**
+ * Writes the XML Declaration and the opening RDF tag to the print Writer.
+ * Encoding not specified.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeHeader(PrintWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+
+ //print opening tags
+ out.println("<?xml version=\"1.0\"?>");
+
+ //print the opening RDF tag (including namespaces)
+ this.writeRDFHeader(out);
+ }
+ else {
+
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+ /**
+ * Writes the XML Declaration and the opening RDF tag to the print Writer.
+ * Encoding attribute is specified as the encoding argument.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeHeader(OutputStreamWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+
+ //wrapper for output stream writer (enable autoflushing)
+ PrintWriter writer = new PrintWriter(out, true);
+
+ //get encoding from the Encoding map
+ String encoding = EncodingMap.getJava2IANAMapping(out.getEncoding());
+
+ //only insert encoding if there is a value
+ if (encoding != null) {
+
+ //print opening tags <?xml version="1.0" encoding=*encoding*?>
+ writer.println("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>");
+ }
+ else {
+
+ //print opening tags <?xml version="1.0"?>
+ writer.println("<?xml version=\"1.0\"?>");
+ }
+
+ //print the Entities
+ this.writeXMLEntities(writer);
+
+ //print the opening RDF tag (including namespaces)
+ this.writeRDFHeader(writer);
+ }
+ else {
+
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+ /**
+ * Writes the XML Entities (used for namespaces) to the print Writer.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeXMLEntities(PrintWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+
+ //print opening DOCTYPE DECLARATION tag
+ out.print(NEWLINE + "<!DOCTYPE rdf:RDF [");
+
+ //print namespaces
+ Set keys = this.namespaces.keySet();
+
+ if (keys != null) {
+
+ Iterator keyIter = keys.iterator();
+ Object currentKey = null;
+ Object currentValue = null;
+
+ while (keyIter.hasNext()) {
+
+ currentKey = keyIter.next();
+ currentValue = this.namespaces.get(currentKey);
+
+ if ( (currentKey != null)
+ && (currentValue != null)) {
+
+ //write as: <!ENTITY ns 'http://example.org/abc#'>
+ out.print(NEWLINE + " <!ENTITY " + currentKey + " '" +
+ currentValue + "'>");
+ }
+ }
+ }
+
+ //close the opening tag (add a space for readability)
+ out.print("]>" + NEWLINE + NEWLINE);
+ }
+ else {
+
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+ /**
+ * Writes the opening RDF tag (with namespaces) to the print Writer.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeRDFHeader(PrintWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+
+ //print opening RDF tag (including namespaces)
+ out.print("<rdf:RDF ");
+
+ //print namespaces
+ Set keys = this.namespaces.keySet();
+
+ if (keys != null) {
+
+ Iterator keyIter = keys.iterator();
+ Object currentKey = null;
+ Object currentValue = null;
+
+ while (keyIter.hasNext()) {
+
+ currentKey = keyIter.next();
+ currentValue = this.namespaces.get(currentKey);
+
+ if ( (currentKey != null)
+ && (currentValue != null)) {
+
+ //use entities: xmlns:ns="&ns;"
+ out.print(NEWLINE + " xmlns:" + currentKey + "=\"&" + currentKey +
+ ";\"");
+ }
+ }
+ }
+
+ //close the opening tag (add a space for readability)
+ out.print(">" + NEWLINE + NEWLINE);
+ }
+ else {
+
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+ /**
+ * Writes the Graph's statements as RDF/XML to the print Writer.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeBody(Graph graph, PrintWriter out) throws IOException,
+ GraphException {
+
+ //validate
+ if ( (out != null)
+ && (graph != null)) {
+
+ //iterator used to access subjects
+ ClosableIterator subjectIter = graph.find(null, null, null);
+
+ //write every (unique) subject
+ if (subjectIter != null) {
+
+ //current Triple
+ Object triple = null;
+
+ //current Subject
+ SubjectNode subject = null;
+
+ Set writtenSubjectSet = new HashSet();
+
+ while (subjectIter.hasNext()) {
+
+ //get the next triple
+ triple = subjectIter.next();
+
+ if ( (triple != null)
+ && (triple instanceof Triple)) {
+
+ subject = ( (Triple) triple).getSubject();
+
+ if (!writtenSubjectSet.contains(subject)) {
+ this.writeSubject(graph, subject, out);
+ writtenSubjectSet.add(subject);
+ }
+ }
+ }
+
+ //close the Iterator
+ subjectIter.close();
+ }
+ }
+ else {
+
+ //message for exception to be thrown
+ String message = "Could not write Graph. Invlaid arguments provided. ";
+
+ if (out == null) {
+
+ message += "Writer is null. ";
+ }
+ if (graph == null) {
+
+ message += "Graph is null. ";
+ }
+
+ throw new IllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Writes the closing RDF tag to the writer.
+ *
+ * @param out PrintWriter
+ * @throws IOException
+ */
+ protected void writeFooter(PrintWriter out) throws IOException {
+
+ //validate
+ if (out != null) {
+
+ //print closing RDF tag
+ out.println("</" + RDF_PREFIX + ":RDF>");
+ }
+ else {
+
+ throw new IllegalArgumentException("Cannot write to null Writer.");
+ }
+ }
+
+ /**
+ * Writes a Subject to the writer
+ *
+ * @param graph JRDFGraph
+ * @param subject SubjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeSubject(Graph graph, SubjectNode subject,
+ PrintWriter writer) throws GraphException {
+
+ //opening subject tag (includes literals)
+ this.writeOpeningTag(graph, subject, writer);
+
+ //subject contents
+ this.writeSubjectBody(graph, subject, writer);
+
+ //closing subject tag
+ this.writeClosingTag(graph, subject, writer);
+
+ //put a space between Subjects
+ writer.println("");
+ }
+
+ /**
+ * Writes the opening tag for the subject
+ *
+ * @param graph JRDFGraph
+ * @param subject SubjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeOpeningTag(Graph graph, SubjectNode subject,
+ PrintWriter writer) throws
+ GraphException {
+
+ if (writer != null) {
+
+ //write the subject type and rdf:about
+ if (subject != null) {
+
+ //open tag - BlankNodes are a special case
+ if (subject instanceof BlankNode) {
+
+ this.writeOpeningTag(graph, (BlankNode) subject, writer);
+ }
+ else {
+
+ writer.print(" <" + RDF_PREFIX + ":Description " + RDF_PREFIX +
+ ":about=\"" + this.getNodeString(subject) + "\">" +
+ NEWLINE);
+ }
+ }
+ else {
+
+ throw new IllegalArgumentException("Could not write opening tag for " +
+ "subject. Subject Node is null.");
+ }
+ }
+ }
+
+ /**
+ * Writes the opening tag for a blank node.
+ *
+ * @param graph JRDFGraph
+ * @param subject BlankNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeOpeningTag(Graph graph, BlankNode subject,
+ PrintWriter writer) throws GraphException {
+
+ ObjectNode subjectType = this.getSubjectType(graph, subject);
+
+ //only display as a subject if it can be found
+ if (subjectType != null) {
+
+ //opening tag
+ writer.print(" <" + this.getURI(subjectType) + ">" + NEWLINE);
+ }
+ else {
+
+ //opening tag
+ writer.print(" <" + RDF_PREFIX + ":Description>" + NEWLINE);
+ }
+ }
+
+ /**
+ * Writes the opening tag for the subject
+ *
+ * @param graph JRDFGraph
+ * @param subject SubjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeClosingTag(Graph graph, SubjectNode subject,
+ PrintWriter writer) throws
+ GraphException {
+
+ //Blank Nodes are written differently
+ if (subject instanceof BlankNode) {
+
+ this.writeClosingTag(graph, (BlankNode) subject, writer);
+ }
+ else {
+
+ //closing tag
+ writer.print(" </" + RDF_PREFIX + ":Description>" + NEWLINE);
+ }
+ }
+
+ /**
+ * Writes the opening tag for the subject
+ *
+ * @param graph JRDFGraph
+ * @param subject SubjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeClosingTag(Graph graph, BlankNode subject,
+ PrintWriter writer) throws
+ GraphException {
+
+ ObjectNode subjectType = this.getSubjectType(graph, subject);
+
+ //only display as a subject if it can be found
+ if (subjectType != null) {
+
+ //closing tag
+ writer.print(" </" + this.getURI(subjectType) + ">" + NEWLINE);
+ }
+ else {
+
+ //closing tag
+ writer.print(" </" + RDF_PREFIX + ":Description>" + NEWLINE);
+ }
+ }
+
+ /**
+ * Writes the Resources for a subject (one per line).
+ *
+ * eg. <predicateURI rdf:resource="resourceURI"/>
+ * (<predicateURI rdf:nodeID="resourceURI"/> for Blank Nodes)
+ *
+ * @param graph Graph
+ * @param subject SubjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeSubjectBody(Graph graph, SubjectNode subject,
+ PrintWriter writer) throws GraphException {
+
+ //validate graph
+ /*
+ if (! (graph instanceof JRDFGraph)) {
+
+ throw new IllegalArgumentException("Graph must be of type JRDFGraph");
+ }
+ */
+
+ //get all statements for the Subject
+ //statements are sorted by predicate (for sequences).
+ List orderList = new ArrayList();
+ ClosableIterator tripleIter = graph.find(subject, null, null);
+
+ if (tripleIter != null) {
+
+ //current Triple
+ Object triple = null;
+
+ //current predicate
+ PredicateNode predicate = null;
+
+ //current object (URIReference)
+ ObjectNode object = null;
+
+ //evaluate all triples
+ while (tripleIter.hasNext()) {
+
+ triple = tripleIter.next();
+
+ //validate triple
+ if ( (triple != null)
+ && (triple instanceof Triple)) {
+
+ //retrieve Predicate and Object
+ predicate = ( (Triple) triple).getPredicate();
+ object = ( (Triple) triple).getObject();
+
+ //Literals and Resources are written differently
+ if (object != null) {
+
+ this.writeStatement(graph, subject, predicate, object, writer);
+ }
+ }
+ }
+
+ //close the Iterator
+ tripleIter.close();
+ }
+ }
+
+ /**
+ * Used to write Resources for a Subject. Literals will by-pass this method
+ * and use "Literal" method.
+ *
+ * @param predicate PredicateNode
+ * @param object ObjectNode
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeStatement(Graph graph, SubjectNode subject,
+ PredicateNode predicate, ObjectNode object,
+ PrintWriter writer) throws GraphException {
+
+ //Literals are written differently
+ if (object instanceof Literal) {
+
+ this.writeStatement(graph, subject, predicate, (Literal) object, writer);
+ }
+ else if (object instanceof BlankNode) {
+
+ //write as: <predicateURI> *blank node as subject* </predicateURI>
+ writer.println(" <" + this.getURI(predicate) + ">");
+
+ //write blank node as a "subject"
+ this.writeSubject(graph, (BlankNode) object, writer);
+
+ writer.println(" </" + this.getURI(predicate) + ">");
+ }
+ else if (subject instanceof BlankNode) {
+
+ //predicatNode representing RDF Type
+ PredicateNode rdfTypeNode = null;
+
+ try {
+
+ rdfTypeNode = graph.getElementFactory().createResource(RDF.TYPE);
+ }
+ catch (GraphElementFactoryException factoryException) {
+
+ throw new GraphException("Could not create RDF Type node.",
+ factoryException);
+ }
+
+ //do not write the RDF Type element
+ if (!rdfTypeNode.equals(predicate)) {
+
+ //write as: <predicateURI rdf:resource="resourceURI"/>
+ writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
+ ":resource=\"" + this.getNodeString(object) + "\"" +
+ "/>");
+ }
+ }
+ else {
+
+ //write as: <predicateURI rdf:resource="resourceURI"/>
+ writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
+ ":resource=\"" + this.getNodeString(object) + "\"" +
+ "/>");
+ }
+ }
+
+ /**
+ * Used to write Resources for a Subject. Resources will use "ObjectNode"
+ * method.
+ *
+ * @param predicate PredicateNode
+ * @param object Literal
+ * @param writer PrintWriter
+ * @throws GraphException
+ */
+ protected void writeStatement(Graph graph, SubjectNode subject,
+ PredicateNode predicate, Literal object,
+ PrintWriter writer) throws GraphException {
+
+ //determine if the Literal has a datatype
+ URI datatype = object.getDatatypeURI();
+
+ // Get the lexical form of the literal
+ String literalObject = object.getLexicalForm();
+
+ // Create the StringBuffer to hold the resultant string
+ StringBuffer buffer = new StringBuffer();
+
+ // Escape the XML string
+ StringUtil.quoteAV(literalObject, buffer);
+
+ if (datatype != null) {
+
+ //write as: <predicateURI rdf:datatype="datatype">"Literal value"
+ // </predicateURI>
+ writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
+ ":datatype=\"" + datatype + "\">" +
+ buffer.toString() +
+ "</" + this.getURI(predicate) + ">");
+ }
+ else {
+
+ //write as: <predicateURI>"Literal value"</predicateURI>
+ writer.println(" <" + this.getURI(predicate) + ">" +
+ buffer.toString() + "</" +
+ this.getURI(predicate) + ">");
+ }
+ }
+
+ /**
+ * Finds the RDF Type for a given subject.
+ *
+ * @param graph Graph
+ * @param subject SubjectNode
+ * @throws GraphException
+ * @return ObjectNode
+ */
+ protected ObjectNode getSubjectType(Graph graph, SubjectNode subject) throws
+ GraphException {
+
+ //value to be returned
+ ObjectNode type = null;
+
+ //validate graph
+ if ( (graph == null)) {
+
+ throw new IllegalArgumentException("Graph argument must not be null.");
+ }
+
+ //predicatNode representing RDF Type
+ PredicateNode rdfType = null;
+
+ try {
+
+ rdfType = graph.getElementFactory().createResource(RDF.TYPE);
+ }
+ catch (GraphElementFactoryException factoryException) {
+
+ throw new GraphException("Could not create RDF Type node.",
+ factoryException);
+ }
+
+ //get the Subject's RDF type
+ ClosableIterator typeIter = graph.find(subject, rdfType, null);
+
+ if (typeIter != null) {
+
+ Object typeTriple = null;
+
+ //validate "first" triple and extract it's object (rdf type)
+ if (typeIter.hasNext()) {
+
+ typeTriple = typeIter.next();
+
+ if ( (typeTriple != null)
+ && (typeTriple instanceof Triple)) {
+
+ type = ( (Triple) typeTriple).getObject();
+ }
+ else {
+
+ throw new GraphException("Could not find RDF type for Subject: " +
+ subject + " . Invalid Triple returned.");
+ }
+ }
+
+ //close the Iterator
+ typeIter.close();
+ }
+
+ return type;
+ }
+
+ /**
+ * Returns a URI that represents the Node.
+ *
+ * @param node the node representing the URI.
+ * @throws GraphException
+ * @return URI
+ */
+ protected String getURI(Node node) throws GraphException {
+
+ //value to be returned
+ String uri = null;
+
+ //determine type of subject node and create uri from it
+ if (node != null) {
+
+ try {
+
+ if (node instanceof URIReference) {
+
+ uri = ( (URIReference) node).getURI().toString();
+ }
+ else if (node instanceof BlankNode) {
+
+ uri = new URI("#" + ( (BlankNode) node).toString()).toString();
+ }
+ else {
+
+ uri = node.toString();
+ }
+ }
+ catch (URISyntaxException uriException) {
+
+ throw new GraphException("Could not get URI for Node: " + node +
+ ".", uriException);
+ }
+ }
+ else {
+
+ throw new GraphException("Could not get URI for Node: " + node +
+ ". Node is null.");
+ }
+
+ //return the URI with any namespaces replaced with prefixes
+ return this.replaceNamespace(uri);
+ }
+
+ /**
+ * Returns a String representation of an ObjectNode. Object values do not have
+ * to be escaped.
+ *
+ * @param node Node
+ * @throws GraphException
+ * @return String
+ */
+ protected String getNodeString(Node node) throws GraphException {
+
+ //value to be returned
+ String object = null;
+
+ //determine type of subject node and create uri from it
+ if (node != null) {
+
+ try {
+
+ if (node instanceof URIReference) {
+
+ object = ( (URIReference) node).getURI().toString();
+ }
+ else if (node instanceof BlankNode) {
+
+ object = new URI("#" + ( (BlankNode) node).toString()).toString();
+ }
+ else if (node instanceof Literal) {
+
+ object = ((Literal) node).getLexicalForm();
+ } else {
+
+ object = node.toString();
+ }
+ }
+ catch (URISyntaxException uriException) {
+
+ throw new GraphException("Could not get String for ObjectNode: " + node +
+ ".", uriException);
+ }
+ }
+ else {
+
+ throw new GraphException("Could not get String for ObjectNode: " + node +
+ ". ObjectNode is null.");
+ }
+
+ return object;
+ }
+
+ /**
+ * If the URI contains the URI of a known namespace, it is replaced.
+ *
+ * @param original original URI.
+ * @return new URI with namespace references.
+ */
+ protected String replaceNamespace(String original) throws GraphException {
+
+ //value to be returned
+ String uri = original;
+
+ //validate URI (only replace uri's with fragments)
+ if (original != null) {
+
+ //replace any URI occurances with namespace prefixes
+ Set keys = this.namespaces.keySet();
+
+ Iterator keyIter = keys.iterator();
+ Object currentKey = null;
+ Object currentValue = null;
+
+ if (keyIter != null) {
+
+ while (keyIter.hasNext()) {
+
+ currentKey = keyIter.next();
+ currentValue = this.namespaces.get(currentKey);
+
+ //validate the Objects
+ if ( (currentKey != null)
+ && (currentValue != null)) {
+
+// int index = uriAsString.indexOf(currentValue.toString());
+ //if the entire namespace is used, replace it with an entity
+ if (original.equals(currentValue.toString())) {
+
+ uri = "&" + currentKey + ";";
+ }
+ else if (original.startsWith(currentValue.toString())) {
+
+ //replace with namespace
+ uri = original.replaceAll(currentValue.toString(),
+ currentKey + ":");
+ }
+ }
+ }
+ }
+ }
+
+ //return the URI with any collection/container items renamed
+ return replaceCollection(uri);
+ }
+
+ /**
+ * If the URI has a fragment representing a collection (eg. Bag) item, it is
+ * replaced with li.
+ *
+ * @param original original URI.
+ * @return new URI with any necessary li.
+ */
+ protected String replaceCollection(String original) throws GraphException {
+
+ //value to be returned
+ String uri = original;
+
+ //validate URI
+ if (original != null) {
+
+ uri = original.replaceAll("_[0-9]+", "li");
+
+ }
+
+ return uri;
+ }
+
+ /**
+ * Populates the namespaces map with default namespaces and namespaces used
+ * by the graph.
+ *
+ * @param graph Graph
+ * @throws GraphException
+ */
+ protected void populateNamespaces(Graph graph) throws GraphException {
+
+ //default namespaces
+ this.namespaces = new HashMap();
+ this.namespaces.put(RDF_PREFIX, RDF.BASE_URI);
+ this.namespaces.put(RDFS_PREFIX, RDFS.BASE_URI);
+ this.namespaces.put("owl", "http://www.w3.org/2002/07/owl#");
+ this.namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
+
+ //validate graph before reading
+ if (graph == null) {
+
+ throw new IllegalArgumentException("Graph argument is null.");
+ }
+
+ //get all statements
+ ClosableIterator tripleIter = graph.find(null, null, null);
+
+ if (tripleIter != null) {
+
+ //current Triple/Predicate
+ Triple triple = null;
+ SubjectNode subject = null;
+ PredicateNode predicate = null;
+ ObjectNode object = null;
+
+ while (tripleIter.hasNext()) {
+
+ //get the next triple
+ triple = (Triple) tripleIter.next();
+
+ if (triple != null) {
+
+ //evaluate subject
+ subject = triple.getSubject();
+ if (subject instanceof URIReference) {
+
+ this.addNamespaceURI(((URIReference) subject).getURI());
+ }
+
+ //evaluate predicate (must be URIReference)
+ predicate = triple.getPredicate();
+ this.addNamespaceURI(((URIReference) predicate).getURI());
+
+ //evaluate object
+ object = triple.getObject();
+ if (object instanceof URIReference) {
+
+ this.addNamespaceURI(((URIReference) object).getURI());
+ }
+ }
+ }
+
+ //close the Iterator
+ tripleIter.close();
+ }
+ }
+
+ /**
+ * Populates the namespaces map with default namespaces and namespaces used
+ * by the graph.
+ *
+ * @param graph Graph
+ * @throws GraphException
+ */
+/* protected void populateNamespaces(Graph graph) throws GraphException {
+
+ //validate graph
+ if (! (graph instanceof JRDFGraph)) {
+
+ throw new IllegalArgumentException("Graph must be of type JRDFGraph");
+ }
+
+ //default namespaces
+ this.namespaces = new HashMap();
+ this.namespaces.put(RDF_PREFIX, RDF.baseURI);
+ this.namespaces.put(RDFS_PREFIX, RDFS.baseURI);
+ this.namespaces.put("owl", "http://www.w3.org/2002/07/owl#");
+ this.namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
+
+ //validate graph before reading
+ if (graph == null) {
+
+ throw new IllegalArgumentException("Graph argument is null.");
+ }
+
+ //iterator used to access predicates
+ ClosableIterator predicateIter = ( (JRDFGraph) graph).getUniquePredicates();
+
+ if (predicateIter != null) {
+
+ //current Triple/Predicate
+ Object triple = null;
+ PredicateNode predicate = null;
+ String predicateURI = null;
+
+ while (predicateIter.hasNext()) {
+
+ //get the next triple
+ triple = predicateIter.next();
+
+ if ( (triple != null)
+ && (triple instanceof Triple)) {
+
+ //get the predicate and evaluate
+ predicate = ( (Triple) triple).getPredicate();
+ predicateURI = this.getURI(predicate);
+
+ //add the namespace
+ try {
+
+ this.addNamespaceURI(new URI(predicateURI));
+ }
+ catch (URISyntaxException uriException) {
+
+ throw new GraphException("Could not add Namespace: " + predicateURI,
+ uriException);
+ }
+ }
+ }
+
+ //close the Iterator
+ predicateIter.close();
+ }
+ } */
+
+ /**
+ * Evaluates a URI and adds it to the namespace map as a namespace.
+ *
+ * @param uri URI
+ */
+ protected void addNamespaceURI(URI uri) {
+
+ if (uri == null) {
+
+ throw new IllegalArgumentException("URI argument is null.");
+ }
+
+ //extract URI without fragment
+ String uriString = uri.toString();
+ String newURI = null;
+
+ if (uriString != null) {
+
+ //determine what comes last a '#' or '/'
+ int hashindex = uriString.lastIndexOf('#');
+ int slashindex = uriString.lastIndexOf('/');
+
+ //validate (URI must contain a forward slash)
+ if (slashindex == -1) {
+
+ //namespace may have been evaluated already
+ return;
+ }
+
+ //is there a '/' after the '#'?
+ if (slashindex > hashindex) {
+
+ //remove everything after the last '/'
+ int index = uriString.lastIndexOf('/');
+ newURI = uriString.substring(0, index) + "/";
+ }
+ else {
+
+ //'#' comes after last '/' (remove entire fragment)
+ newURI = uriString.replaceAll(uri.getFragment(), "");
+ }
+
+ //only add namespace if it is new
+ if ( (newURI != null)
+ && (!this.namespaces.containsValue(newURI))) {
+
+ //add to namespaces
+ this.namespaces.put("ns" + this.namespaces.size(), newURI);
+ }
+ }
+ }
+}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelN3Writer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,204 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-package org.mulgara.store.exporter;
-
-// Java 2 standard packages
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-// Apache packages
-import org.apache.log4j.Logger;
-
-// JRDF
-import org.jrdf.vocabulary.*;
-
-// Local packages
-import org.jrdf.graph.GraphException;
-import org.jrdf.util.ClosableIterator;
-import org.jrdf.graph.*;
-import org.mulgara.store.*;
-
-/**
- * A Writer used to write N3 for a Mulgara model.
- *
- * @created 2004-07-26
- *
- * @author <a href="mailto:pag at pisoftware.com">Paul Gearon</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:25 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelN3Writer implements ModelWriter {
-
- /**
- * Logger. This is named after the class.
- */
- private final static Logger log = Logger.getLogger(ModelN3Writer.class.
- getName());
-
-
- /**
- * Default Constructor
- */
- public ModelN3Writer() {
- }
-
-
- /**
- * Writes the contents of the JRDFGraph to a PrintWriter in N3 format.
- *
- * @param graph Graph Graph containing the Statements to be written.
- * @param writer PrintWriter Where to write the statements.
- * @throws GraphException
- */
- synchronized public void write(Graph graph, PrintWriter writer) throws
- GraphException {
-
- //write Header, Body and Footer
- try {
-
- //write document
- writeHeader(writer);
- writeBody(graph, writer);
- }
- catch (IOException ioException) {
-
- throw new GraphException("Could not write Model.", ioException);
- }
- }
-
-
- /**
- * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format
- * with the encoding specified in the opening XML tag.
- *
- * @param graph Graph Graph containing the Statements to be written.
- * @param writer PrintWriter
- * @throws GraphException
- */
- synchronized public void write(Graph graph, OutputStreamWriter writer)
- throws GraphException {
-
- //wrap writer and enable auto flushing
- PrintWriter out = new PrintWriter(writer, true);
-
- write(graph, out);
- }
-
-
- /**
- * Writes any desired comments as a header.
- *
- * @param out the writer to use to output.
- * @throws IOException if there was an IO exception.
- * @throws IllegalArgumentException if the given writer is null.
- */
- private void writeHeader(PrintWriter out) throws IOException {
-
- //validate
- if (out != null) {
- out.println("# Mulgara graph in N3");
- } else {
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
-
- /**
- * Writes the Model's statements as N3 to the print Writer.
- *
- * @param graph Graph Graph containing the Statements to be written.
- * @param out PrintWriter
- * @throws IOException
- */
- private void writeBody(Graph graph, PrintWriter out) throws IOException,
- GraphException {
-
- //validate
- if ( (out != null)
- && (graph != null)) {
-
- // iterator to access entire graph
- ClosableIterator graphIter = graph.find(null, null, null);
-
- while (graphIter.hasNext()) {
- // extract the triple
- Triple triple = (Triple)graphIter.next();
- SubjectNode s = triple.getSubject();
- PredicateNode p = triple.getPredicate();
- ObjectNode o = triple.getObject();
-
- out.println("<" + s.toString() + "> <" + ((URIReference)p).getURI().toString() + "> "+ getLabel(o));
- }
-
- } else {
-
- //message for exception to be thrown
- String message = "Could not write Model. Invlaid arguments provided. ";
-
- if (out == null) {
- message += "Writer is null. ";
- }
-
- if (graph == null) {
- message += "Graph is null. ";
- }
-
- throw new IllegalArgumentException(message);
- }
- }
-
-
- /**
- * Formats an object node appropriately at either a literal or a resource.
- * For efficiency, a line termination character is appended.
- *
- * @param node The object node to format
- * @throws GraphException
- */
- private String getLabel(ObjectNode node) {
- if (node instanceof Literal) {
- return "\"" + ((Literal)node).getLexicalForm() + "\" .";
- } else if (node instanceof URIReference) {
- return "<" + ((URIReference)node).getURI().toString() + "> .";
- }
- // node is a blank node
- return "<" + node.toString() + "> .";
- }
-
-}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,77 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-package org.mulgara.store.exporter;
-
-// Java 2 standard packages
-import java.io.*;
-
-// Local packages
-import org.jrdf.graph.GraphException;
-import org.jrdf.graph.Graph;
-
-/**
- * A Writer used to write a serialization for a Mulgara model.
- *
- * @created 2004-02-23
- *
- * @author <a href="mailto:pag at tucanatech.com">Paul Gearon</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:25 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface ModelWriter {
-
- /**
- * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format.
- *
- * @param graph JRDF Graph containing the Statements to be written.
- * @param writer PrintWriter Where to write the statements.
- * @throws GraphException
- */
- public void write(Graph graph, PrintWriter writer) throws GraphException;
-
- /**
- * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format
- * with the encoding specified in the opening XML tag.
- *
- * @param graph JRDF Graph
- * @param writer PrintWriter
- * @throws GraphException
- */
- public void write(Graph graph, OutputStreamWriter writer) throws GraphException;
-
-}
Deleted: branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java
===================================================================
--- branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver/java/org/mulgara/store/exporter/ModelXMLWriter.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,1143 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-package org.mulgara.store.exporter;
-
-// Java 2 standard packages
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-// Apache packages
-import org.apache.log4j.Logger;
-import org.apache.xerces.util.EncodingMap;
-
-// JRDF
-import org.jrdf.graph.GraphException;
-import org.jrdf.util.ClosableIterator;
-import org.jrdf.vocabulary.*;
-
-// Local packages
-/*
-import org.mulgara.resolver.jrdf.ClosableIteratorImpl;
-import org.mulgara.resolver.jrdf.JRDFGraph;
-*/
-import org.jrdf.graph.*;
-import org.mulgara.query.Order;
-import org.mulgara.query.Value;
-import org.mulgara.store.*;
-import org.mulgara.store.statement.StatementStore;
-import org.mulgara.store.tuples.RowComparator;
-import org.mulgara.util.*;
-
-/**
- * A Writer used to write RDF/XML for a Mulgara model.
- *
- * @created 2004-02-20
- *
- * @author <a href="mailto:robert.turner at tucanatech.com">Robert Turner</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:25 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright ©2001 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ModelXMLWriter
- implements ModelWriter {
-
- /**
- * Logger. This is named after the class.
- */
- private final static Logger log = Logger.getLogger(ModelXMLWriter.class.
- getName());
-
- /** Prefix used to abbreviate RDF Namespace */
- private static final String RDF_PREFIX = "rdf";
-
- /** Prefix used to abbreviate RDFS Namespace */
- private static final String RDFS_PREFIX = "rdfs";
-
- /** Convenience reference to the new line character */
- private static final String NEWLINE = System.getProperty("line.separator");
-
- /** Map used to replace commonly used namespaces with prefixes */
- protected Map namespaces = null;
-
- /**
- * Default Constructor
- */
- public ModelXMLWriter() {
- }
-
- /**
- * Writes the contents of the JRDFGraph to a PrintWriter in RDF/XML format.
- *
- * @param graph JRDFGraph Graph containing the Statements to be written.
- * @param writer PrintWriter Where to write the statements.
- * @throws GraphException
- */
- synchronized public void write(Graph graph, PrintWriter writer) throws
- GraphException {
-
- /*
- if (! (graph instanceof JRDFGraph)) {
- throw new IllegalArgumentException("Graph must be of type JRDFGraph");
- }
- */
-
- //write Header, Body and Footer
- try {
-
- //initialize the namespaces first
- this.populateNamespaces(graph);
-
- //write document
- this.writeHeader(writer);
- this.writeBody(graph, writer);
- this.writeFooter(writer);
- }
- catch (IOException ioException) {
-
- throw new GraphException("Could not write Model.", ioException);
- }
- }
-
- /**
- * Writes the contents of the JRDF Graph to a PrintWriter in RDF/XML format
- * with the encoding specified in the opening XML tag.
- *
- * @param graph JRDFGraph
- * @param writer PrintWriter
- * @throws GraphException
- */
- synchronized public void write(Graph graph, OutputStreamWriter writer) throws
- GraphException {
-
- /*
- if (! (graph instanceof JRDFGraph)) {
- throw new IllegalArgumentException("Graph must be of type JRDFGraph");
- }
- */
-
- //write Header, Body and Footer
- try {
-
- //wrap writer and enable auto flushing
- PrintWriter out = new PrintWriter(writer, true);
-
- //initialize the namespaces first
- this.populateNamespaces(graph);
-
- //write document
- this.writeHeader(writer);
- this.writeBody(graph, out);
- this.writeFooter(out);
- }
- catch (IOException ioException) {
-
- throw new GraphException("Could not write Model.", ioException);
- }
- }
-
- /**
- * Writes the XML Declaration and the opening RDF tag to the print Writer.
- * Encoding not specified.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeHeader(PrintWriter out) throws IOException {
-
- //validate
- if (out != null) {
-
- //print opening tags
- out.println("<?xml version=\"1.0\"?>");
-
- //print the opening RDF tag (including namespaces)
- this.writeRDFHeader(out);
- }
- else {
-
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
- /**
- * Writes the XML Declaration and the opening RDF tag to the print Writer.
- * Encoding attribute is specified as the encoding argument.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeHeader(OutputStreamWriter out) throws IOException {
-
- //validate
- if (out != null) {
-
- //wrapper for output stream writer (enable autoflushing)
- PrintWriter writer = new PrintWriter(out, true);
-
- //get encoding from the Encoding map
- String encoding = EncodingMap.getJava2IANAMapping(out.getEncoding());
-
- //only insert encoding if there is a value
- if (encoding != null) {
-
- //print opening tags <?xml version="1.0" encoding=*encoding*?>
- writer.println("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>");
- }
- else {
-
- //print opening tags <?xml version="1.0"?>
- writer.println("<?xml version=\"1.0\"?>");
- }
-
- //print the Entities
- this.writeXMLEntities(writer);
-
- //print the opening RDF tag (including namespaces)
- this.writeRDFHeader(writer);
- }
- else {
-
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
- /**
- * Writes the XML Entities (used for namespaces) to the print Writer.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeXMLEntities(PrintWriter out) throws IOException {
-
- //validate
- if (out != null) {
-
- //print opening DOCTYPE DECLARATION tag
- out.print(NEWLINE + "<!DOCTYPE rdf:RDF [");
-
- //print namespaces
- Set keys = this.namespaces.keySet();
-
- if (keys != null) {
-
- Iterator keyIter = keys.iterator();
- Object currentKey = null;
- Object currentValue = null;
-
- while (keyIter.hasNext()) {
-
- currentKey = keyIter.next();
- currentValue = this.namespaces.get(currentKey);
-
- if ( (currentKey != null)
- && (currentValue != null)) {
-
- //write as: <!ENTITY ns 'http://example.org/abc#'>
- out.print(NEWLINE + " <!ENTITY " + currentKey + " '" +
- currentValue + "'>");
- }
- }
- }
-
- //close the opening tag (add a space for readability)
- out.print("]>" + NEWLINE + NEWLINE);
- }
- else {
-
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
- /**
- * Writes the opening RDF tag (with namespaces) to the print Writer.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeRDFHeader(PrintWriter out) throws IOException {
-
- //validate
- if (out != null) {
-
- //print opening RDF tag (including namespaces)
- out.print("<rdf:RDF ");
-
- //print namespaces
- Set keys = this.namespaces.keySet();
-
- if (keys != null) {
-
- Iterator keyIter = keys.iterator();
- Object currentKey = null;
- Object currentValue = null;
-
- while (keyIter.hasNext()) {
-
- currentKey = keyIter.next();
- currentValue = this.namespaces.get(currentKey);
-
- if ( (currentKey != null)
- && (currentValue != null)) {
-
- //use entities: xmlns:ns="&ns;"
- out.print(NEWLINE + " xmlns:" + currentKey + "=\"&" + currentKey +
- ";\"");
- }
- }
- }
-
- //close the opening tag (add a space for readability)
- out.print(">" + NEWLINE + NEWLINE);
- }
- else {
-
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
- /**
- * Writes the Model's statements as RDF/XML to the print Writer.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeBody(Graph graph, PrintWriter out) throws IOException,
- GraphException {
-
- //validate
- if ( (out != null)
- && (graph != null)) {
-
- //iterator used to access subjects
- ClosableIterator subjectIter = graph.find(null, null, null);
-
- //write every (unique) subject
- if (subjectIter != null) {
-
- //current Triple
- Object triple = null;
-
- //current Subject
- SubjectNode subject = null;
-
- Set writtenSubjectSet = new HashSet();
-
- while (subjectIter.hasNext()) {
-
- //get the next triple
- triple = subjectIter.next();
-
- if ( (triple != null)
- && (triple instanceof Triple)) {
-
- subject = ( (Triple) triple).getSubject();
-
- if (!writtenSubjectSet.contains(subject)) {
- this.writeSubject(graph, subject, out);
- writtenSubjectSet.add(subject);
- }
- }
- }
-
- //close the Iterator
- subjectIter.close();
- }
- }
- else {
-
- //message for exception to be thrown
- String message = "Could not write Model. Invlaid arguments provided. ";
-
- if (out == null) {
-
- message += "Writer is null. ";
- }
- if (graph == null) {
-
- message += "Graph is null. ";
- }
-
- throw new IllegalArgumentException(message);
- }
- }
-
- /**
- * Writes the closing RDF tag to the writer.
- *
- * @param out PrintWriter
- * @throws IOException
- */
- protected void writeFooter(PrintWriter out) throws IOException {
-
- //validate
- if (out != null) {
-
- //print closing RDF tag
- out.println("</" + RDF_PREFIX + ":RDF>");
- }
- else {
-
- throw new IllegalArgumentException("Cannot write to null Writer.");
- }
- }
-
- /**
- * Writes a Subject to the writer
- *
- * @param graph JRDFGraph
- * @param subject SubjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeSubject(Graph graph, SubjectNode subject,
- PrintWriter writer) throws GraphException {
-
- //opening subject tag (includes literals)
- this.writeOpeningTag(graph, subject, writer);
-
- //subject contents
- this.writeSubjectBody(graph, subject, writer);
-
- //closing subject tag
- this.writeClosingTag(graph, subject, writer);
-
- //put a space between Subjects
- writer.println("");
- }
-
- /**
- * Writes the opening tag for the subject
- *
- * @param graph JRDFGraph
- * @param subject SubjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeOpeningTag(Graph graph, SubjectNode subject,
- PrintWriter writer) throws
- GraphException {
-
- if (writer != null) {
-
- //write the subject type and rdf:about
- if (subject != null) {
-
- //open tag - BlankNodes are a special case
- if (subject instanceof BlankNode) {
-
- this.writeOpeningTag(graph, (BlankNode) subject, writer);
- }
- else {
-
- writer.print(" <" + RDF_PREFIX + ":Description " + RDF_PREFIX +
- ":about=\"" + this.getNodeString(subject) + "\">" +
- NEWLINE);
- }
- }
- else {
-
- throw new IllegalArgumentException("Could not write opening tag for " +
- "subject. Subject Node is null.");
- }
- }
- }
-
- /**
- * Writes the opening tag for a blank node.
- *
- * @param graph JRDFGraph
- * @param subject BlankNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeOpeningTag(Graph graph, BlankNode subject,
- PrintWriter writer) throws GraphException {
-
- ObjectNode subjectType = this.getSubjectType(graph, subject);
-
- //only display as a subject if it can be found
- if (subjectType != null) {
-
- //opening tag
- writer.print(" <" + this.getURI(subjectType) + ">" + NEWLINE);
- }
- else {
-
- //opening tag
- writer.print(" <" + RDF_PREFIX + ":Description>" + NEWLINE);
- }
- }
-
- /**
- * Writes the opening tag for the subject
- *
- * @param graph JRDFGraph
- * @param subject SubjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeClosingTag(Graph graph, SubjectNode subject,
- PrintWriter writer) throws
- GraphException {
-
- //Blank Nodes are written differently
- if (subject instanceof BlankNode) {
-
- this.writeClosingTag(graph, (BlankNode) subject, writer);
- }
- else {
-
- //closing tag
- writer.print(" </" + RDF_PREFIX + ":Description>" + NEWLINE);
- }
- }
-
- /**
- * Writes the opening tag for the subject
- *
- * @param graph JRDFGraph
- * @param subject SubjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeClosingTag(Graph graph, BlankNode subject,
- PrintWriter writer) throws
- GraphException {
-
- ObjectNode subjectType = this.getSubjectType(graph, subject);
-
- //only display as a subject if it can be found
- if (subjectType != null) {
-
- //closing tag
- writer.print(" </" + this.getURI(subjectType) + ">" + NEWLINE);
- }
- else {
-
- //closing tag
- writer.print(" </" + RDF_PREFIX + ":Description>" + NEWLINE);
- }
- }
-
- /**
- * Writes the Resources for a subject (one per line).
- *
- * eg. <predicateURI rdf:resource="resourceURI"/>
- * (<predicateURI rdf:nodeID="resourceURI"/> for Blank Nodes)
- *
- * @param graph Graph
- * @param subject SubjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeSubjectBody(Graph graph, SubjectNode subject,
- PrintWriter writer) throws GraphException {
-
- //validate graph
- /*
- if (! (graph instanceof JRDFGraph)) {
-
- throw new IllegalArgumentException("Graph must be of type JRDFGraph");
- }
- */
-
- //get all statements for the Subject
- //statements are sorted by predicate (for sequences).
- List orderList = new ArrayList();
- ClosableIterator tripleIter = graph.find(subject, null, null);
-
- if (tripleIter != null) {
-
- //current Triple
- Object triple = null;
-
- //current predicate
- PredicateNode predicate = null;
-
- //current object (URIReference)
- ObjectNode object = null;
-
- //evaluate all triples
- while (tripleIter.hasNext()) {
-
- triple = tripleIter.next();
-
- //validate triple
- if ( (triple != null)
- && (triple instanceof Triple)) {
-
- //retrieve Predicate and Object
- predicate = ( (Triple) triple).getPredicate();
- object = ( (Triple) triple).getObject();
-
- //Literals and Resources are written differently
- if (object != null) {
-
- this.writeStatement(graph, subject, predicate, object, writer);
- }
- }
- }
-
- //close the Iterator
- tripleIter.close();
- }
- }
-
- /**
- * Used to write Resources for a Subject. Literals will by-pass this method
- * and use "Literal" method.
- *
- * @param predicate PredicateNode
- * @param object ObjectNode
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeStatement(Graph graph, SubjectNode subject,
- PredicateNode predicate, ObjectNode object,
- PrintWriter writer) throws GraphException {
-
- //Literals are written differently
- if (object instanceof Literal) {
-
- this.writeStatement(graph, subject, predicate, (Literal) object, writer);
- }
- else if (object instanceof BlankNode) {
-
- //write as: <predicateURI> *blank node as subject* </predicateURI>
- writer.println(" <" + this.getURI(predicate) + ">");
-
- //write blank node as a "subject"
- this.writeSubject(graph, (BlankNode) object, writer);
-
- writer.println(" </" + this.getURI(predicate) + ">");
- }
- else if (subject instanceof BlankNode) {
-
- //predicatNode representing RDF Type
- PredicateNode rdfTypeNode = null;
-
- try {
-
- rdfTypeNode = graph.getElementFactory().createResource(RDF.TYPE);
- }
- catch (GraphElementFactoryException factoryException) {
-
- throw new GraphException("Could not create RDF Type node.",
- factoryException);
- }
-
- //do not write the RDF Type element
- if (!rdfTypeNode.equals(predicate)) {
-
- //write as: <predicateURI rdf:resource="resourceURI"/>
- writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
- ":resource=\"" + this.getNodeString(object) + "\"" +
- "/>");
- }
- }
- else {
-
- //write as: <predicateURI rdf:resource="resourceURI"/>
- writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
- ":resource=\"" + this.getNodeString(object) + "\"" +
- "/>");
- }
- }
-
- /**
- * Used to write Resources for a Subject. Resources will use "ObjectNode"
- * method.
- *
- * @param predicate PredicateNode
- * @param object Literal
- * @param writer PrintWriter
- * @throws GraphException
- */
- protected void writeStatement(Graph graph, SubjectNode subject,
- PredicateNode predicate, Literal object,
- PrintWriter writer) throws GraphException {
-
- //determine if the Literal has a datatype
- URI datatype = object.getDatatypeURI();
-
- // Get the lexical form of the literal
- String literalObject = object.getLexicalForm();
-
- // Create the StringBuffer to hold the resultant string
- StringBuffer buffer = new StringBuffer();
-
- // Escape the XML string
- StringUtil.quoteAV(literalObject, buffer);
-
- if (datatype != null) {
-
- //write as: <predicateURI rdf:datatype="datatype">"Literal value"
- // </predicateURI>
- writer.println(" <" + this.getURI(predicate) + " " + RDF_PREFIX +
- ":datatype=\"" + datatype + "\">" +
- buffer.toString() +
- "</" + this.getURI(predicate) + ">");
- }
- else {
-
- //write as: <predicateURI>"Literal value"</predicateURI>
- writer.println(" <" + this.getURI(predicate) + ">" +
- buffer.toString() + "</" +
- this.getURI(predicate) + ">");
- }
- }
-
- /**
- * Finds the RDF Type for a given subject.
- *
- * @param graph Graph
- * @param subject SubjectNode
- * @throws GraphException
- * @return ObjectNode
- */
- protected ObjectNode getSubjectType(Graph graph, SubjectNode subject) throws
- GraphException {
-
- //value to be returned
- ObjectNode type = null;
-
- //validate graph
- if ( (graph == null)) {
-
- throw new IllegalArgumentException("Graph argument must not be null.");
- }
-
- //predicatNode representing RDF Type
- PredicateNode rdfType = null;
-
- try {
-
- rdfType = graph.getElementFactory().createResource(RDF.TYPE);
- }
- catch (GraphElementFactoryException factoryException) {
-
- throw new GraphException("Could not create RDF Type node.",
- factoryException);
- }
-
- //get the Subject's RDF type
- ClosableIterator typeIter = graph.find(subject, rdfType, null);
-
- if (typeIter != null) {
-
- Object typeTriple = null;
-
- //validate "first" triple and extract it's object (rdf type)
- if (typeIter.hasNext()) {
-
- typeTriple = typeIter.next();
-
- if ( (typeTriple != null)
- && (typeTriple instanceof Triple)) {
-
- type = ( (Triple) typeTriple).getObject();
- }
- else {
-
- throw new GraphException("Could not find RDF type for Subject: " +
- subject + " . Invalid Triple returned.");
- }
- }
-
- //close the Iterator
- typeIter.close();
- }
-
- return type;
- }
-
- /**
- * Returns a URI that represents the Node.
- *
- * @param node the node representing the URI.
- * @throws GraphException
- * @return URI
- */
- protected String getURI(Node node) throws GraphException {
-
- //value to be returned
- String uri = null;
-
- //determine type of subject node and create uri from it
- if (node != null) {
-
- try {
-
- if (node instanceof URIReference) {
-
- uri = ( (URIReference) node).getURI().toString();
- }
- else if (node instanceof BlankNode) {
-
- uri = new URI("#" + ( (BlankNode) node).toString()).toString();
- }
- else {
-
- uri = node.toString();
- }
- }
- catch (URISyntaxException uriException) {
-
- throw new GraphException("Could not get URI for Node: " + node +
- ".", uriException);
- }
- }
- else {
-
- throw new GraphException("Could not get URI for Node: " + node +
- ". Node is null.");
- }
-
- //return the URI with any namespaces replaced with prefixes
- return this.replaceNamespace(uri);
- }
-
- /**
- * Returns a String representation of an ObjectNode. Object values do not have
- * to be escaped.
- *
- * @param node Node
- * @throws GraphException
- * @return String
- */
- protected String getNodeString(Node node) throws GraphException {
-
- //value to be returned
- String object = null;
-
- //determine type of subject node and create uri from it
- if (node != null) {
-
- try {
-
- if (node instanceof URIReference) {
-
- object = ( (URIReference) node).getURI().toString();
- }
- else if (node instanceof BlankNode) {
-
- object = new URI("#" + ( (BlankNode) node).toString()).toString();
- }
- else if (node instanceof Literal) {
-
- object = ((Literal) node).getLexicalForm();
- } else {
-
- object = node.toString();
- }
- }
- catch (URISyntaxException uriException) {
-
- throw new GraphException("Could not get String for ObjectNode: " + node +
- ".", uriException);
- }
- }
- else {
-
- throw new GraphException("Could not get String for ObjectNode: " + node +
- ". ObjectNode is null.");
- }
-
- return object;
- }
-
- /**
- * If the URI contains the URI of a known namespace, it is replaced.
- *
- * @param original original URI.
- * @return new URI with namespace references.
- */
- protected String replaceNamespace(String original) throws GraphException {
-
- //value to be returned
- String uri = original;
-
- //validate URI (only replace uri's with fragments)
- if (original != null) {
-
- //replace any URI occurances with namespace prefixes
- Set keys = this.namespaces.keySet();
-
- Iterator keyIter = keys.iterator();
- Object currentKey = null;
- Object currentValue = null;
-
- if (keyIter != null) {
-
- while (keyIter.hasNext()) {
-
- currentKey = keyIter.next();
- currentValue = this.namespaces.get(currentKey);
-
- //validate the Objects
- if ( (currentKey != null)
- && (currentValue != null)) {
-
-// int index = uriAsString.indexOf(currentValue.toString());
- //if the entire namespace is used, replace it with an entity
- if (original.equals(currentValue.toString())) {
-
- uri = "&" + currentKey + ";";
- }
- else if (original.startsWith(currentValue.toString())) {
-
- //replace with namespace
- uri = original.replaceAll(currentValue.toString(),
- currentKey + ":");
- }
- }
- }
- }
- }
-
- //return the URI with any collection/container items renamed
- return replaceCollection(uri);
- }
-
- /**
- * If the URI has a fragment representing a collection (eg. Bag) item, it is
- * replaced with li.
- *
- * @param original original URI.
- * @return new URI with any necessary li.
- */
- protected String replaceCollection(String original) throws GraphException {
-
- //value to be returned
- String uri = original;
-
- //validate URI
- if (original != null) {
-
- uri = original.replaceAll("_[0-9]+", "li");
-
- }
-
- return uri;
- }
-
- /**
- * Populates the namespaces map with default namespaces and namespaces used
- * by the graph.
- *
- * @param graph Graph
- * @throws GraphException
- */
- protected void populateNamespaces(Graph graph) throws GraphException {
-
- //default namespaces
- this.namespaces = new HashMap();
- this.namespaces.put(RDF_PREFIX, RDF.BASE_URI);
- this.namespaces.put(RDFS_PREFIX, RDFS.BASE_URI);
- this.namespaces.put("owl", "http://www.w3.org/2002/07/owl#");
- this.namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
-
- //validate graph before reading
- if (graph == null) {
-
- throw new IllegalArgumentException("Graph argument is null.");
- }
-
- //get all statements
- ClosableIterator tripleIter = graph.find(null, null, null);
-
- if (tripleIter != null) {
-
- //current Triple/Predicate
- Triple triple = null;
- SubjectNode subject = null;
- PredicateNode predicate = null;
- ObjectNode object = null;
-
- while (tripleIter.hasNext()) {
-
- //get the next triple
- triple = (Triple) tripleIter.next();
-
- if (triple != null) {
-
- //evaluate subject
- subject = triple.getSubject();
- if (subject instanceof URIReference) {
-
- this.addNamespaceURI(((URIReference) subject).getURI());
- }
-
- //evaluate predicate (must be URIReference)
- predicate = triple.getPredicate();
- this.addNamespaceURI(((URIReference) predicate).getURI());
-
- //evaluate object
- object = triple.getObject();
- if (object instanceof URIReference) {
-
- this.addNamespaceURI(((URIReference) object).getURI());
- }
- }
- }
-
- //close the Iterator
- tripleIter.close();
- }
- }
-
- /**
- * Populates the namespaces map with default namespaces and namespaces used
- * by the graph.
- *
- * @param graph Graph
- * @throws GraphException
- */
-/* protected void populateNamespaces(Graph graph) throws GraphException {
-
- //validate graph
- if (! (graph instanceof JRDFGraph)) {
-
- throw new IllegalArgumentException("Graph must be of type JRDFGraph");
- }
-
- //default namespaces
- this.namespaces = new HashMap();
- this.namespaces.put(RDF_PREFIX, RDF.baseURI);
- this.namespaces.put(RDFS_PREFIX, RDFS.baseURI);
- this.namespaces.put("owl", "http://www.w3.org/2002/07/owl#");
- this.namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
-
- //validate graph before reading
- if (graph == null) {
-
- throw new IllegalArgumentException("Graph argument is null.");
- }
-
- //iterator used to access predicates
- ClosableIterator predicateIter = ( (JRDFGraph) graph).getUniquePredicates();
-
- if (predicateIter != null) {
-
- //current Triple/Predicate
- Object triple = null;
- PredicateNode predicate = null;
- String predicateURI = null;
-
- while (predicateIter.hasNext()) {
-
- //get the next triple
- triple = predicateIter.next();
-
- if ( (triple != null)
- && (triple instanceof Triple)) {
-
- //get the predicate and evaluate
- predicate = ( (Triple) triple).getPredicate();
- predicateURI = this.getURI(predicate);
-
- //add the namespace
- try {
-
- this.addNamespaceURI(new URI(predicateURI));
- }
- catch (URISyntaxException uriException) {
-
- throw new GraphException("Could not add Namespace: " + predicateURI,
- uriException);
- }
- }
- }
-
- //close the Iterator
- predicateIter.close();
- }
- } */
-
- /**
- * Evaluates a URI and adds it to the namespace map as a namespace.
- *
- * @param uri URI
- */
- protected void addNamespaceURI(URI uri) {
-
- if (uri == null) {
-
- throw new IllegalArgumentException("URI argument is null.");
- }
-
- //extract URI without fragment
- String uriString = uri.toString();
- String newURI = null;
-
- if (uriString != null) {
-
- //determine what comes last a '#' or '/'
- int hashindex = uriString.lastIndexOf('#');
- int slashindex = uriString.lastIndexOf('/');
-
- //validate (URI must contain a forward slash)
- if (slashindex == -1) {
-
- //namespace may have been evaluated already
- return;
- }
-
- //is there a '/' after the '#'?
- if (slashindex > hashindex) {
-
- //remove everything after the last '/'
- int index = uriString.lastIndexOf('/');
- newURI = uriString.substring(0, index) + "/";
- }
- else {
-
- //'#' comes after last '/' (remove entire fragment)
- newURI = uriString.replaceAll(uri.getFragment(), "");
- }
-
- //only add namespace if it is new
- if ( (newURI != null)
- && (!this.namespaces.containsValue(newURI))) {
-
- //add to namespaces
- this.namespaces.put("ns" + this.namespaces.size(), newURI);
- }
- }
- }
-}
Modified: branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/DistributedResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -78,7 +78,7 @@
/**
- * Model creation method. Not supported in this resolver.
+ * Graph creation method. Not supported in this resolver.
* @throws ResolverException The server should not ask this resolver to create a model.
*/
public void createModel(long model, URI modelType) throws ResolverException {
Modified: branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
===================================================================
--- branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -21,7 +21,7 @@
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintImpl;
import org.mulgara.query.LocalNode;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.query.TuplesException;
@@ -216,7 +216,7 @@
// convert the variable set to a variable list - add types via unchecked casts
List<Variable> variables = new ArrayList<Variable>((Set<Variable>)globalConstraint.getVariables());
// build the new query
- return new Query(variables, new ModelResource(model.getURI()), globalConstraint, null, Collections.EMPTY_LIST, null, 0, new UnconstrainedAnswer());
+ return new Query(variables, new GraphResource(model.getURI()), globalConstraint, null, Collections.EMPTY_LIST, null, 0, new UnconstrainedAnswer());
}
Modified: branches/xa11/src/jar/resolver-file/java/org/mulgara/resolver/file/FileResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-file/java/org/mulgara/resolver/file/FileResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-file/java/org/mulgara/resolver/file/FileResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -102,7 +102,7 @@
Node globalModel = resolverSession.globalize(model);
if (!(globalModel instanceof URIReference)) {
throw new ResolverException(
- "Model parameter " + globalModel + " isn't a URI reference");
+ "Graph parameter " + globalModel + " isn't a URI reference");
}
modelURI = ((URIReference) globalModel).getURI();
} catch (GlobalizeException e) {
Modified: branches/xa11/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -127,7 +127,7 @@
// Validate "modelType" parameter
if (modelTypeURI == null) {
- throw new IllegalArgumentException("Model type can't be null");
+ throw new IllegalArgumentException("Graph type can't be null");
}
// Store the global variable values
@@ -359,7 +359,7 @@
definitionURI(model)));
} catch (LocalizeException localiseException) {
- throw new QueryException("Model " + model +
+ throw new QueryException("Graph " + model +
" did not exist in FileSystem" +
" expansion", localiseException);
} catch (ResolverException resolverException) {
Modified: branches/xa11/src/jar/resolver-gis/java/org/mulgara/resolver/gis/ReadOnlyGISResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-gis/java/org/mulgara/resolver/gis/ReadOnlyGISResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-gis/java/org/mulgara/resolver/gis/ReadOnlyGISResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -87,7 +87,7 @@
/** Used to handle content/manage content handlers */
protected ContentHandlerManager contentManager;
- /** Model type supported by this resolver */
+ /** Graph type supported by this resolver */
public static final URI MODEL_TYPE = URI.create(Mulgara.NAMESPACE + "GISModel");
/** Node ID for rdf:type */
Modified: branches/xa11/src/jar/resolver-http/java/org/mulgara/resolver/http/HttpResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-http/java/org/mulgara/resolver/http/HttpResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-http/java/org/mulgara/resolver/http/HttpResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -111,7 +111,7 @@
if (!(globalModel instanceof URIReference)) {
// Check that our node is a URIReference
- throw new ResolverException("Model parameter " + globalModel + " isn't a URI reference");
+ throw new ResolverException("Graph parameter " + globalModel + " isn't a URI reference");
}
// Get the URI from the globalised node
Modified: branches/xa11/src/jar/resolver-jar/java/org/mulgara/resolver/jar/JarResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-jar/java/org/mulgara/resolver/jar/JarResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-jar/java/org/mulgara/resolver/jar/JarResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -120,7 +120,7 @@
// Check that our node is a URIReference
throw new ResolverException(
- "Model parameter " + globalModel + " isn't a URI reference");
+ "Graph parameter " + globalModel + " isn't a URI reference");
}
// Get the URI from the globalised node
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -438,7 +438,6 @@
throws FullTextStringIndexException {
boolean removed = false;
if ((literal == null) ||
- (literal.length() == 0) ||
(subject == null) ||
(subject.length() == 0) ||
(predicate == null) ||
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -103,6 +103,7 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new FullTextStringIndexUnitTest("testFullTextStringPool"));
+ suite.addTest(new FullTextStringIndexUnitTest("testFullTextStringPoolCornerCases"));
suite.addTest(new FullTextStringIndexUnitTest("testFullTextStringPoolwithFiles"));
suite.addTest(new FullTextStringIndexUnitTest("testFullTextStringPoolTransactions"));
@@ -325,7 +326,104 @@
}
}
+
/**
+ * Test corner cases (null subject, object, predicate, etc).
+ *
+ * @throws Exception Test fails
+ */
+ public void testFullTextStringPoolCornerCases() throws Exception {
+ LuceneIndexerCache cache = new LuceneIndexerCache(indexDirectory);
+ FullTextStringIndex index = null;
+
+ try {
+ String document = "http://mulgara.org/mulgara/document#";
+ String has = "http://mulgara.org/mulgara/document#has";
+
+ //Clean any existing indexes.
+ cache.close();
+ cache.removeAllIndexes();
+ cache = new LuceneIndexerCache(indexDirectory);
+
+ //create the index
+ index = new FullTextStringIndex(cache, true, true);
+
+ // Add strings to the index
+ try {
+ index.add(null, has, "foo");
+ fail("exception expected for adding null subject");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.add(document, null, "foo");
+ fail("exception expected for adding null predicate");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.add(document, has, null);
+ fail("exception expected for adding null literal");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.add("", has, "foo");
+ fail("exception expected for adding empty subject");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.add(document, "", "foo");
+ fail("exception expected for adding empty predicate");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ index.add(document, has, "");
+
+ // remove strings from the index
+ try {
+ index.remove(null, has, "foo");
+ fail("exception expected for removing null subject");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.remove(document, null, "foo");
+ fail("exception expected for removing null predicate");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.remove(document, has, null);
+ fail("exception expected for removing null literal");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.remove("", has, "foo");
+ fail("exception expected for removing empty subject");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ try {
+ index.remove(document, "", "foo");
+ fail("exception expected for removing empty predicate");
+ } catch (FullTextStringIndexException ftsie) {
+ }
+
+ index.remove(document, has, "");
+
+ } finally {
+ if (index != null) {
+ index.close();
+ cache.close();
+ assertTrue("Unable to remove all index files", cache.removeAllIndexes());
+ }
+ }
+ }
+
+ /**
* 1. Test the loading of text files into the fulltext string pool 2. Checking
* for existance 3. Test removal of files
*
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -26,7 +26,7 @@
import org.mulgara.resolver.spi.ConstraintDescriptor;
import org.mulgara.resolver.spi.ConstraintLocalization;
import org.mulgara.resolver.spi.QueryEvaluationContext;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.Constraint;
@@ -50,7 +50,7 @@
}
- public Tuples resolve(QueryEvaluationContext queryContext, ModelExpression modelExpr,
+ public Tuples resolve(QueryEvaluationContext queryContext, GraphExpression modelExpr,
ConstraintExpression constraintExpr) throws Exception {
return ConstraintOperations.resolveModelExpression(queryContext, modelExpr, (Constraint)constraintExpr);
}
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -305,8 +305,8 @@
}
}
} catch (FullTextStringIndexException e) {
- throw new ResolverException("Unable to add '" + literal +
- "' to full text string index", e);
+ throw new ResolverException("Unable to " + (occurs ? "add" : "delete") + "'" +
+ literal + "' to full text string index", e);
}
} else {
if (logger.isInfoEnabled()) {
@@ -358,7 +358,7 @@
if (logger.isDebugEnabled()) logger.debug("Ignoring solutions for " + constraint);
return new EmptyResolution(constraint, false);
} else if (!(modelElement instanceof LocalNode)) {
- throw new QueryException("Failed to localize Lucene Model before resolution " + constraint);
+ throw new QueryException("Failed to localize Lucene Graph before resolution " + constraint);
}
/* temporary hack because $_from is not resolved before transformation occurs, and hence
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -40,7 +40,7 @@
import org.mulgara.query.Answer;
import org.mulgara.query.ConstraintConjunction;
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.Query;
import org.mulgara.query.Variable;
import org.mulgara.query.operation.Modification;
@@ -175,7 +175,7 @@
session.removeModel(modelURI);
}
session.createModel(modelURI, luceneModelType);
- session.setModel(modelURI, new ModelResource(fileURI));
+ session.setModel(modelURI, new GraphResource(fileURI));
// Run the queries
try {
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneTransformer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -28,15 +28,14 @@
import org.jrdf.graph.URIReference;
+import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintElement;
-import org.mulgara.query.ConstraintImpl;
import org.mulgara.query.ConstraintConjunction;
-import org.mulgara.query.ConstraintDisjunction;
+import org.mulgara.query.ConstraintOperation;
import org.mulgara.query.QueryException;
import org.mulgara.query.rdf.URIReferenceImpl;
-import org.mulgara.resolver.spi.MutableLocalQuery;
-import org.mulgara.resolver.spi.SymbolicTransformation;
+import org.mulgara.resolver.spi.AbstractSymbolicTransformer;
import org.mulgara.resolver.spi.SymbolicTransformationContext;
import org.mulgara.resolver.spi.SymbolicTransformationException;
@@ -53,7 +52,7 @@
* @author Ronald Tschalär
* @licence Apache License v2.0
*/
-public class LuceneTransformer implements SymbolicTransformation {
+public class LuceneTransformer extends AbstractSymbolicTransformer {
private static final Logger logger = Logger.getLogger(LuceneTransformer.class);
private final URI modelTypeURI;
@@ -73,36 +72,27 @@
scorePred = new URIReferenceImpl(scorePredUri);
}
- public void transform(SymbolicTransformationContext context, MutableLocalQuery query)
- throws SymbolicTransformationException {
- ConstraintExpression expr = query.getConstraintExpression();
- ConstraintExpression trans = transformExpr(context, expr);
-
- if (expr != trans) {
- query.setConstraintExpression(trans);
- }
- }
-
- private ConstraintExpression transformExpr(SymbolicTransformationContext context, ConstraintExpression expr) throws SymbolicTransformationException {
- if (expr instanceof ConstraintImpl) {
- return transformConstr(context, (ConstraintImpl)expr);
- }
- if (expr instanceof ConstraintConjunction) {
+ @Override
+ protected ConstraintExpression transformOperation(SymbolicTransformationContext context,
+ ConstraintOperation expr)
+ throws SymbolicTransformationException {
+ if (expr instanceof ConstraintConjunction)
return transformConj(context, (ConstraintConjunction)expr);
- }
- if (expr instanceof ConstraintDisjunction) {
- return transformDisj(context, (ConstraintDisjunction)expr);
- }
-
- return expr;
+ return super.transformOperation(context, expr);
}
- private ConstraintExpression transformConstr(SymbolicTransformationContext context, ConstraintImpl c) throws SymbolicTransformationException {
+ @Override
+ protected ConstraintExpression transformConstraint(SymbolicTransformationContext context,
+ Constraint c)
+ throws SymbolicTransformationException {
+ if (c instanceof LuceneConstraint) return c;
+
try {
ConstraintElement ce = c.getModel();
if (ce instanceof URIReference) {
URI constraintModelType = context.mapToModelTypeURI(((URIReference)ce).getURI());
if (constraintModelType != null && constraintModelType.equals(modelTypeURI)) {
+ if (logger.isTraceEnabled()) logger.trace("Creating LC for: " + c);
return new LuceneConstraint(c, searchPred, scorePred);
}
}
@@ -112,7 +102,7 @@
}
}
- public ConstraintExpression transformConj(SymbolicTransformationContext context, ConstraintConjunction cc) throws SymbolicTransformationException {
+ private ConstraintConjunction transformConj(SymbolicTransformationContext context, ConstraintConjunction cc) throws SymbolicTransformationException {
List<ConstraintExpression> retainedArgs = new ArrayList<ConstraintExpression>();
Map<ConstraintElement, List<LuceneConstraint>> luceneArgs =
new HashMap<ConstraintElement, List<LuceneConstraint>>();
@@ -120,7 +110,7 @@
boolean transformed = false;
for (ConstraintExpression arg : cc.getElements()) {
- ConstraintExpression trans = transformExpr(context, arg);
+ ConstraintExpression trans = transformExpression(context, arg);
if (trans != arg) {
transformed = true;
}
@@ -140,6 +130,7 @@
cumulative.add(lc);
} else {
cumulative.iterator().next().conjoinWith(lc);
+ if (logger.isTraceEnabled()) logger.trace("Updated LC with: " + cumulative.iterator().next() + "; result: " + lc);
transformed = true;
}
} else {
@@ -160,18 +151,4 @@
return cc;
}
}
-
- private ConstraintExpression transformDisj(SymbolicTransformationContext context, ConstraintDisjunction cd) throws SymbolicTransformationException {
- List<ConstraintExpression> transArgs = new ArrayList<ConstraintExpression>();
- boolean transformed = false;
- for (ConstraintExpression ce : cd.getElements()) {
- ConstraintExpression trans = transformExpr(context, ce);
- if (trans != ce) {
- transformed = true;
- }
- transArgs.add(trans);
- }
-
- return transformed ? new ConstraintDisjunction(transArgs) : cd;
- }
}
Modified: branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/ReadOnlyLuceneResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -88,7 +88,7 @@
//
/**
- * Model creation is not allowed the via this read-only view.
+ * Graph creation is not allowed the via this read-only view.
*
* @throws ResolverException always
*/
@@ -98,7 +98,7 @@
}
/**
- * Model modification is not supported via this read-only view.
+ * Graph modification is not supported via this read-only view.
*
* @throws ResolverException always
*/
@@ -108,7 +108,7 @@
}
/**
- * Model deletion is not supported via this read-only view.
+ * Graph deletion is not supported via this read-only view.
*
* @throws ResolverException always
*/
Modified: branches/xa11/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -136,7 +136,7 @@
throws ResolverFactoryException {
// Validate "modelType" parameter
if (modelTypeURI == null) {
- throw new IllegalArgumentException("Model type can't be null");
+ throw new IllegalArgumentException("Graph type can't be null");
}
// Initialize fields
@@ -385,4 +385,11 @@
public LongMapper getRestoreMapper() throws Exception {
return new MemLongMapper();
}
+
+ /**
+ * Ignored in this implementation
+ */
+ public void initializeSystemNodes(long systemGraphNode, long rdfTypeNode, long systemGraphTypeNode) {
+ // do nothing
+ }
}
Modified: branches/xa11/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java
===================================================================
--- branches/xa11/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -368,7 +368,7 @@
/**
* Copied from AbstractTuples
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: branches/xa11/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
===================================================================
--- branches/xa11/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -75,7 +75,7 @@
* @see org.mulgara.store.tuples.Tuples#getAnnotation(java.lang.Class)
* @return Always <code>null</code>.
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
Modified: branches/xa11/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/TuplesWrapperResolution.java
===================================================================
--- branches/xa11/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/TuplesWrapperResolution.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/TuplesWrapperResolution.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -352,7 +352,7 @@
/**
* Copied from AbstractTuples
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraint.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraint.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraint.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -58,7 +58,6 @@
import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ConstraintImpl;
import org.mulgara.query.Value;
import org.mulgara.query.Variable;
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -123,7 +122,7 @@
this.predConstraints = new HashMap<ConstraintElement,List<Constraint>>();
}
- public RelationalConstraint(ConstraintImpl constraint) {
+ public RelationalConstraint(Constraint constraint) {
this();
conjoinWith(constraint);
@@ -145,7 +144,7 @@
}
}
- public void conjoinWith(ConstraintImpl constraint) {
+ public void conjoinWith(Constraint constraint) {
preliminaries(constraint);
if (constraint.getElement(1).equals(rdftype)) {
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -50,7 +50,7 @@
import org.mulgara.resolver.spi.ConstraintDescriptor;
import org.mulgara.resolver.spi.ConstraintLocalization;
import org.mulgara.resolver.spi.QueryEvaluationContext;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.Constraint;
@@ -72,7 +72,7 @@
public Tuples resolve(QueryEvaluationContext queryContext,
- ModelExpression modelExpr,
+ GraphExpression modelExpr,
ConstraintExpression constraintExpr) throws Exception {
assert constraintExpr instanceof Constraint;
return ConstraintOperations.resolveModelExpression(queryContext, modelExpr, (Constraint)constraintExpr);
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -134,7 +134,7 @@
throws ResolverFactoryException {
if (modelTypeURI == null) {
- throw new IllegalArgumentException("Model type can't be null");
+ throw new IllegalArgumentException("Graph type can't be null");
}
// Store the global variable values
@@ -266,7 +266,7 @@
defModel = resolverSession.lookupPersistent(new URIReferenceImpl(
definitionURI(model)));
} catch (LocalizeException localiseException) {
- throw new QueryException("Model " + model +
+ throw new QueryException("Graph " + model +
" did not exist in Relational" +
" expansion", localiseException);
} catch (ResolverException resolverException) {
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverFactory.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverFactory.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverFactory.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -81,7 +81,7 @@
/** Node id for the relational model type */
private long relationalModelTypeNode;
- /** The URL associated with the Relational Model type. */
+ /** The URL associated with the Relational Graph type. */
private static final URI modelTypeURI = URI.create(Mulgara.NAMESPACE + "RelationalModel");
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalResolverUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -370,7 +370,7 @@
public void testLoadRelationalDef() throws Exception {
Session session = database.newSession();
try {
- session.setModel(testModelDefURI, new ModelResource(new File("data/ISWC-d2rq.rdf").toURI()));
+ session.setModel(testModelDefURI, new GraphResource(new File("data/ISWC-d2rq.rdf").toURI()));
} finally {
session.close();
}
@@ -385,7 +385,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
new URIReferenceImpl(new URI("http://annotation.semanticweb.org/iswc/iswc.daml#Person")),
@@ -422,7 +422,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -465,7 +465,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -506,7 +506,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new URIReferenceImpl(new URI("http://www.smith.id/albert")),
@@ -548,7 +548,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -595,7 +595,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
new URIReferenceImpl(new URI("http://annotation.semanticweb.org/iswc/iswc.daml#Conference")),
@@ -632,7 +632,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -676,7 +676,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -718,7 +718,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -797,7 +797,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -842,7 +842,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -891,7 +891,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -955,7 +955,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -1001,7 +1001,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new Variable("s"),
@@ -1042,7 +1042,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[]
{
new ConstraintImpl(new URIReferenceImpl(new URI("http://www.conference.org/conf02004/paper#Paper3")),
@@ -1085,7 +1085,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -1150,7 +1150,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -1220,7 +1220,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("p"),
new URIReferenceImpl(RDF.TYPE),
@@ -1272,7 +1272,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("per"),
new URIReferenceImpl(RDF.TYPE),
@@ -1335,7 +1335,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("per"),
new URIReferenceImpl(RDF.TYPE),
@@ -1390,7 +1390,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
@@ -1441,7 +1441,7 @@
public void testLoadRelationalDef2() throws Exception {
Session session = database.newSession();
try {
- session.setModel(testModel2DefURI, new ModelResource(new File("data/ISWC-d2rq.rdf").toURI()));
+ session.setModel(testModel2DefURI, new GraphResource(new File("data/ISWC-d2rq.rdf").toURI()));
} finally {
session.close();
}
@@ -1459,7 +1459,7 @@
Answer answer = session.query(new Query(
selectList, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
new ConstraintImpl(new Variable("s"),
new URIReferenceImpl(RDF.TYPE),
Modified: branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalTransformer.java
===================================================================
--- branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalTransformer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-relational/java/org/mulgara/resolver/relational/RelationalTransformer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -52,18 +52,17 @@
import org.jrdf.graph.URIReference;
-import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ConstraintElement;
-import org.mulgara.query.ConstraintImpl;
+import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintConjunction;
-import org.mulgara.query.ConstraintDisjunction;
+import org.mulgara.query.ConstraintElement;
+import org.mulgara.query.ConstraintExpression;
+import org.mulgara.query.ConstraintOperation;
import org.mulgara.query.QueryException;
-import org.mulgara.resolver.spi.MutableLocalQuery;
-import org.mulgara.resolver.spi.SymbolicTransformation;
+import org.mulgara.resolver.spi.AbstractSymbolicTransformer;
import org.mulgara.resolver.spi.SymbolicTransformationContext;
import org.mulgara.resolver.spi.SymbolicTransformationException;
-public class RelationalTransformer implements SymbolicTransformation {
+public class RelationalTransformer extends AbstractSymbolicTransformer {
/** Logger */
private static Logger logger = Logger.getLogger(RelationalTransformer.class);
@@ -73,32 +72,19 @@
this.modelTypeURI = modelTypeURI;
}
- public void transform(SymbolicTransformationContext context, MutableLocalQuery query)
- throws SymbolicTransformationException {
-
- ConstraintExpression expr = query.getConstraintExpression();
- ConstraintExpression trans = transformExpr(context, expr);
-
- if (expr != trans) {
- query.setConstraintExpression(trans);
- }
- }
-
- public ConstraintExpression transformExpr(SymbolicTransformationContext context, ConstraintExpression expr) throws SymbolicTransformationException {
- if (expr instanceof ConstraintImpl) {
- return transformMatch(context, (ConstraintImpl)expr);
- }
- if (expr instanceof ConstraintConjunction) {
+ @Override
+ protected ConstraintExpression transformOperation(SymbolicTransformationContext context,
+ ConstraintOperation expr)
+ throws SymbolicTransformationException {
+ if (expr instanceof ConstraintConjunction)
return transformConj(context, (ConstraintConjunction)expr);
- }
- if (expr instanceof ConstraintDisjunction) {
- return transformDisj(context, (ConstraintDisjunction)expr);
- }
-
- return expr;
+ return super.transformOperation(context, expr);
}
- public ConstraintExpression transformMatch(SymbolicTransformationContext context, ConstraintImpl c) throws SymbolicTransformationException {
+ @Override
+ protected ConstraintExpression transformConstraint(SymbolicTransformationContext context, Constraint c) throws SymbolicTransformationException {
+ if (c instanceof RelationalConstraint) return c;
+
try {
ConstraintElement ce = c.getModel();
if (ce instanceof URIReference) {
@@ -132,7 +118,7 @@
}
rcArgs.add(rc);
} else {
- ConstraintExpression trans = (ConstraintExpression)transformExpr(context, arg);
+ ConstraintExpression trans = transformExpression(context, arg);
retainedArgs.add(trans);
if (arg != trans) {
transformed = true;
@@ -164,20 +150,4 @@
return cc;
}
}
-
- public ConstraintExpression transformDisj(SymbolicTransformationContext context, ConstraintDisjunction cd) throws SymbolicTransformationException {
- List transArgs = new ArrayList();
- boolean transformed = false;
- Iterator i = cd.getElements().iterator();
- while (i.hasNext()) {
- ConstraintExpression ce = (ConstraintExpression)i.next();
- ConstraintExpression trans = transformExpr(context, ce);
- if (trans != ce) {
- transformed = true;
- }
- transArgs.add(trans);
- }
-
- return transformed ? new ConstraintDisjunction(transArgs) : cd;
- }
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/content/ContentLoader.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -31,11 +31,11 @@
import org.mulgara.content.Content;
import org.mulgara.content.ContentHandler;
import org.mulgara.content.ContentHandlerException;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.server.Session;
/**
- * Interface for loading Content into a Model (ModelExpression). Similar to a
+ * Interface for loading Content into a Graph (GraphExpression). Similar to a
* {@link ContentHandler} but is reponsible for inserting global statements
* directly into the destination.
*
@@ -61,15 +61,15 @@
public interface ContentLoader extends ContentHandler {
/**
* Processes and Loads the content and inserts the statements into the
- * ModelResource.
+ * GraphResource.
*
* @param content Content
- * @param destination ModelResource
+ * @param destination GraphResource
* @param session Session
* @throws ContentHandlerException
* @return long The number of statements loaded
*/
- public long load(Content content, ModelResource destination,
+ public long load(Content content, GraphResource destination,
Session session) throws ContentHandlerException;
}
Copied: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java (from rev 1423, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java)
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java (rev 0)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractSymbolicTransformer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,187 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.resolver.spi;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.mulgara.query.Constraint;
+import org.mulgara.query.ConstraintConjunction;
+import org.mulgara.query.ConstraintDifference;
+import org.mulgara.query.ConstraintDisjunction;
+import org.mulgara.query.ConstraintExpression;
+import org.mulgara.query.ConstraintFilter;
+import org.mulgara.query.ConstraintIn;
+import org.mulgara.query.ConstraintOperation;
+import org.mulgara.query.ConstraintOptionalJoin;
+
+/**
+ * This provides some common processing for symbolic-transformers.
+ *
+ * @created Dec 2, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class AbstractSymbolicTransformer implements SymbolicTransformation {
+ private static final Logger logger = Logger.getLogger(AbstractSymbolicTransformer.class);
+
+ public void transform(SymbolicTransformationContext context, MutableLocalQuery mutableLocalQuery)
+ throws SymbolicTransformationException {
+ if (logger.isTraceEnabled()) logger.trace("Transforming query: " + mutableLocalQuery.getConstraintExpression());
+
+ ConstraintExpression expr = mutableLocalQuery.getConstraintExpression();
+ ConstraintExpression trans = transformExpression(context, expr);
+
+ if (logger.isTraceEnabled()) logger.trace("Transform result: " + (expr != trans ? trans : "-no-change-"));
+
+ if (expr != trans) {
+ mutableLocalQuery.setConstraintExpression(trans);
+ }
+ }
+
+ /**
+ * Transform the given constraint-expression. This is a dispatcher, invoking one of the other
+ * transformXYZ methods as applicable or returning the given expr if none are.
+ *
+ * @param context the current transformation context
+ * @param expr the constraint expression to transform
+ * @return a new expression is something was changed, or <var>expr</var> if nothing was changed.
+ * @throws SymbolicTransformationException If there is an error applying the transform
+ */
+ public ConstraintExpression transformExpression(SymbolicTransformationContext context,
+ ConstraintExpression expr)
+ throws SymbolicTransformationException {
+ // explicitly handle all the recursive types
+ if (expr instanceof ConstraintFilter) return transformFilter(context, (ConstraintFilter)expr);
+ if (expr instanceof ConstraintIn) return transformIn(context, (ConstraintIn)expr);
+ if (expr instanceof ConstraintOperation) return transformOperation(context, (ConstraintOperation)expr);
+ // do the actual work of this transformer
+ if (expr instanceof Constraint) return transformConstraint(context, (Constraint)expr);
+ // By default we do not recognise the constraint type, so pass it unchanged.
+ return expr;
+ }
+
+ /**
+ * Transform the filtered constraint. This invokes {@link #transformExpression} on the inner constraint.
+ *
+ * @param context the current transformation context
+ * @param filter the constraint filter to transform
+ * @return a new expression is something was changed, or <var>filter</var> if nothing was changed.
+ * @throws SymbolicTransformationException If there is an error applying the transform
+ */
+ protected ConstraintExpression transformFilter(SymbolicTransformationContext context,
+ ConstraintFilter filter)
+ throws SymbolicTransformationException {
+ ConstraintExpression inner = filter.getUnfilteredConstraint();
+ ConstraintExpression tx = transformExpression(context, inner);
+ return (tx == inner) ? filter : new ConstraintFilter(tx, filter.getFilter());
+ }
+
+ /**
+ * Transform the in constraint. This invokes {@link #transformExpression} on the inner constraint.
+ *
+ * @param context the current transformation context
+ * @param in the in-constraint to transform
+ * @return a new expression is something was changed, or <var>in</var> if nothing was changed.
+ * @throws SymbolicTransformationException If there is an error applying the transform
+ */
+ protected ConstraintExpression transformIn(SymbolicTransformationContext context, ConstraintIn in)
+ throws SymbolicTransformationException {
+ ConstraintExpression inner = in.getConstraintParam();
+ ConstraintExpression tx = transformExpression(context, inner);
+ return (tx == inner) ? in : new ConstraintIn(tx, in.getGraph());
+ }
+
+ /**
+ * Transform the constraint-operation. This invokes {@link #transformExpression} on all the inner
+ * constraints.
+ *
+ * @param context the current transformation context
+ * @param oper the constraint-operation to transform
+ * @return a new expression is something was changed, or <var>oper</var> if nothing was changed.
+ * @throws SymbolicTransformationException If there is an error applying the transform
+ */
+ protected ConstraintExpression transformOperation(SymbolicTransformationContext context,
+ ConstraintOperation oper)
+ throws SymbolicTransformationException {
+ List<ConstraintExpression> ops = oper.getElements();
+ List<ConstraintExpression> newOps = new ArrayList<ConstraintExpression>(ops.size());
+ boolean changed = false;
+
+ for (ConstraintExpression op: ops) {
+ ConstraintExpression tx = transformExpression(context, op);
+ newOps.add(tx);
+ if (tx != op) changed = true;
+ }
+
+ if (changed) {
+ OpType operationType = OpType.getType(oper);
+ if (operationType == null) throw new SymbolicTransformationException("Encountered an unknown operation type: " + oper.getClass());
+ return operationType.newOp(newOps);
+ }
+
+ return oper;
+ }
+
+ /**
+ * Transform the given expression. The main work of this class is usually performed in this
+ * method.
+ *
+ * @param context the current transformation context
+ * @param c the constraint to transform.
+ * @return the original constraint, or a new constraint if something was changed.
+ * @throws SymbolicTransformationException If there is an error applying the transform
+ */
+ protected abstract ConstraintExpression transformConstraint(SymbolicTransformationContext context,
+ Constraint c)
+ throws SymbolicTransformationException;
+
+ /**
+ * This enum enumerates the ConstraintOperation types. It has been built to deal with
+ * the fact that constructors for the various types cannot be passed as a lambda.
+ * It also provides a map for the enumerated types to their enumerations, making it
+ * easy for an operation to get to an appropriate constructor.
+ */
+ protected static enum OpType {
+ difference {
+ public ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDifference(ops.get(0), ops.get(1)); }
+ },
+ optional {
+ public ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintOptionalJoin(ops.get(0), ops.get(1)); }
+ },
+ conjunction {
+ public ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintConjunction(ops); }
+ },
+ disjunction {
+ public ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDisjunction(ops); }
+ };
+
+ public abstract ConstraintOperation newOp(List<ConstraintExpression> ops);
+
+ private static Map<Class<? extends ConstraintOperation>, OpType> opMap = new HashMap<Class<? extends ConstraintOperation>, OpType>();
+
+ public static OpType getType(ConstraintOperation op) { return opMap.get(op.getClass()); }
+
+ static {
+ opMap.put(ConstraintDifference.class, difference);
+ opMap.put(ConstraintOptionalJoin.class, optional);
+ opMap.put(ConstraintConjunction.class, conjunction);
+ opMap.put(ConstraintDisjunction.class, disjunction);
+ }
+ }
+}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConjunctiveTransformer.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConjunctiveTransformer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConjunctiveTransformer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -55,7 +55,6 @@
import org.jrdf.graph.URIReference;
-import org.mulgara.query.ConstraintImpl;
import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.Variable;
@@ -63,9 +62,6 @@
import org.mulgara.query.ConstraintConjunction;
import org.mulgara.query.ConstraintDisjunction;
import org.mulgara.query.QueryException;
-import org.mulgara.resolver.spi.SymbolicTransformation;
-import org.mulgara.resolver.spi.SymbolicTransformationContext;
-import org.mulgara.resolver.spi.SymbolicTransformationException;
/**
* A transformer that works on the basis of combining multiple conjoined constraints
@@ -77,8 +73,7 @@
* Australian Commonwealth Government, Department of Defence</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public abstract class ConjunctiveTransformer implements SymbolicTransformation
-{
+public abstract class ConjunctiveTransformer extends AbstractSymbolicTransformer {
/** Logger */
private static final Logger logger = Logger.getLogger(ConjunctiveTransformer.class.getName());
@@ -90,34 +85,17 @@
public abstract ConstraintExpression constructConstraintExpression(ConstraintElement model, Map byVarSubject, Map byConstSubject) throws SymbolicTransformationException;
- public void transform(SymbolicTransformationContext context, MutableLocalQuery query)
- throws SymbolicTransformationException {
- ConstraintExpression expr = query.getConstraintExpression();
- ConstraintExpression trans = transformExpr(context, expr);
-
- if (expr != trans) {
- query.setConstraintExpression(trans);
- }
- }
-
-
- public ConstraintExpression transformExpr(SymbolicTransformationContext context, ConstraintExpression expr) throws SymbolicTransformationException {
-
+ @Override
+ public ConstraintExpression transformExpression(SymbolicTransformationContext context, ConstraintExpression expr) throws SymbolicTransformationException {
// This is the main case.
if (expr instanceof ConstraintConjunction) {
return transformConj(context, (ConstraintConjunction)expr);
}
- // In the case of a Disjunction we need to attempt to transform it's arguments
- // should the query be in sum of product form.
- if (expr instanceof ConstraintDisjunction) {
- return transformDisj(context, (ConstraintDisjunction)expr);
- }
-
// A single constraint could still be transformed as a singleton conjunction.
// Therefore pack in conjunction, attempt transform, and check to see if it was.
- if (expr instanceof ConstraintImpl) {
+ if (expr instanceof Constraint) {
ConstraintConjunction conj = new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] { expr }));
ConstraintConjunction trans = transformConj(context, conj);
if (conj == trans) {
@@ -127,11 +105,18 @@
}
}
- // By default we do not recognise the constraint type, so pass it unchanged.
- return expr;
+ // all else go through the default handling
+ return super.transformExpression(context, expr);
}
+ @Override
+ protected ConstraintExpression transformConstraint(SymbolicTransformationContext context,
+ Constraint c)
+ throws SymbolicTransformationException {
+ return c;
+ }
+
public ConstraintConjunction transformConj(SymbolicTransformationContext context, ConstraintConjunction cc) throws SymbolicTransformationException {
ConjAccumulator acc = transformConj(context, cc, new ConjAccumulator(context));
@@ -168,7 +153,7 @@
if (arg instanceof ConstraintConjunction) {
acc = transformConj(context, (ConstraintConjunction)arg, acc);
} else if (arg instanceof ConstraintDisjunction) {
- ConstraintExpression expr = transformDisj(context, (ConstraintDisjunction)arg);
+ ConstraintExpression expr = transformOperation(context, (ConstraintDisjunction)arg);
acc.accumulate(expr);
} else {
acc.accumulate(arg);
@@ -179,24 +164,6 @@
}
- public ConstraintExpression transformDisj(SymbolicTransformationContext context, ConstraintDisjunction cd) throws SymbolicTransformationException {
-
- List transArgs = new ArrayList();
- boolean transformed = false;
- Iterator i = cd.getElements().iterator();
- while (i.hasNext()) {
- ConstraintExpression ce = (ConstraintExpression)i.next();
- ConstraintExpression trans = transformExpr(context, ce);
- if (trans != ce) {
- transformed = true;
- }
- transArgs.add(trans);
- }
-
- return transformed ? new ConstraintDisjunction(transArgs) : cd;
- }
-
-
private class ConjAccumulator {
private SymbolicTransformationContext context;
@@ -214,8 +181,8 @@
public void accumulate(ConstraintExpression arg) throws SymbolicTransformationException {
- if (arg instanceof ConstraintImpl) {
- accumulateConstraint((ConstraintImpl)arg);
+ if (arg instanceof Constraint) {
+ accumulateConstraint((Constraint)arg);
} else if (arg instanceof ConstraintConjunction) {
throw new IllegalStateException("ConstraintConjunction should have been handled by caller");
} else {
@@ -223,7 +190,7 @@
}
}
- private void accumulateConstraint(ConstraintImpl arg) throws SymbolicTransformationException {
+ private void accumulateConstraint(Constraint arg) throws SymbolicTransformationException {
try {
ConstraintElement model = arg.getModel();
if (model instanceof URIReference) {
@@ -248,7 +215,7 @@
}
- private void insertByModel(ConstraintElement model, Map target, ConstraintImpl arg) {
+ private void insertByModel(ConstraintElement model, Map target, Constraint arg) {
Map bySubject = (Map)target.get(model);
if (bySubject == null) {
bySubject = new HashMap();
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -54,7 +54,7 @@
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public interface ConstraintDescriptor extends ConstraintResolutionHandler, ConstraintModelRewrite {
+public interface ConstraintDescriptor extends ConstraintResolutionHandler, ConstraintGraphRewrite {
public Class<? extends Constraint> getConstraintClass();
@@ -62,6 +62,6 @@
// methods imported from the super-interfaces.
/*
public Constraint rewrite(ConstraintElement newModel, Constraint constraint) throws Exception;
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception;
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception;
*/
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintExpansion.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintExpansion.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintExpansion.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -33,7 +33,7 @@
// Local packages
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.QueryException;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
@@ -53,6 +53,6 @@
public interface ConstraintExpansion
{
public Tuples expand(QueryEvaluationContext queryContext,
- ModelExpression modelExpr,
+ GraphExpression modelExpr,
ConstraintExpression constraintExpr) throws Exception;
}
Copied: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java (from rev 1423, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java)
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java (rev 0)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintGraphRewrite.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,63 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver.spi;
+
+// Java 2 standard packages
+import javax.transaction.xa.XAResource;
+import java.net.URI;
+
+// Local packages
+import org.mulgara.query.Constraint;
+import org.mulgara.query.ConstraintElement;
+import org.mulgara.query.QueryException;
+
+/**
+ * Used to constrain a given constraint to a specified model
+ *
+ * @created 2003-12-01
+ * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
+ * @version $Revision: 1.9 $
+ * @modified $Date: 2005/05/03 08:11:44 $
+ * @maintenanceAuthor $Author: amuys $
+ * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
+ * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+
+public interface ConstraintGraphRewrite
+{
+ /**
+ * Rewrite this constraintExpression to access the specified model
+ *
+ * @param newModel the model with which to constrain the constraint
+ * @param constraint the constraint to constrain
+ */
+ public Constraint rewrite(ConstraintElement newModel,
+ Constraint constraint) throws Exception;
+}
Deleted: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintModelRewrite.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,63 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver.spi;
-
-// Java 2 standard packages
-import javax.transaction.xa.XAResource;
-import java.net.URI;
-
-// Local packages
-import org.mulgara.query.Constraint;
-import org.mulgara.query.ConstraintElement;
-import org.mulgara.query.QueryException;
-
-/**
- * Used to constrain a given constraint to a specified model
- *
- * @created 2003-12-01
- * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
- * @version $Revision: 1.9 $
- * @modified $Date: 2005/05/03 08:11:44 $
- * @maintenanceAuthor $Author: amuys $
- * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
- * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-
-public interface ConstraintModelRewrite
-{
- /**
- * Rewrite this constraintExpression to access the specified model
- *
- * @param newModel the model with which to constrain the constraint
- * @param constraint the constraint to constrain
- */
- public Constraint rewrite(ConstraintElement newModel,
- Constraint constraint) throws Exception;
-}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintResolutionHandler.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintResolutionHandler.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ConstraintResolutionHandler.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,7 +41,7 @@
// Local packages
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.QueryException;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
@@ -71,6 +71,6 @@
* @param constraintExpr the constraintExpression to resolve
*/
public Tuples resolve(QueryEvaluationContext queryContext,
- ModelExpression modelExpr,
+ GraphExpression modelExpr,
ConstraintExpression constraintExpr) throws Exception;
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DuplicateVariableTransformer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -13,21 +13,13 @@
package org.mulgara.resolver.spi;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.mulgara.query.Constraint;
-import org.mulgara.query.ConstraintConjunction;
-import org.mulgara.query.ConstraintDifference;
-import org.mulgara.query.ConstraintDisjunction;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintExpression;
import org.mulgara.query.ConstraintFilter;
import org.mulgara.query.ConstraintImpl;
-import org.mulgara.query.ConstraintIn;
-import org.mulgara.query.ConstraintOperation;
-import org.mulgara.query.ConstraintOptionalJoin;
import org.mulgara.query.Variable;
import org.mulgara.query.filter.And;
import org.mulgara.query.filter.Filter;
@@ -43,90 +35,35 @@
* @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
* @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
*/
-public class DuplicateVariableTransformer implements SymbolicTransformation {
-
+public class DuplicateVariableTransformer extends AbstractSymbolicTransformer {
/**
- * @see org.mulgara.resolver.spi.SymbolicTransformation#transform(org.mulgara.resolver.spi.SymbolicTransformationContext, org.mulgara.resolver.spi.MutableLocalQuery)
- */
- public void transform(SymbolicTransformationContext context, MutableLocalQuery mutableLocalQuery)
- throws SymbolicTransformationException {
- ConstraintExpression expr = mutableLocalQuery.getConstraintExpression();
- ConstraintExpression trans = transformExpr(expr);
-
- if (expr != trans) {
- mutableLocalQuery.setConstraintExpression(trans);
- }
- }
-
- public ConstraintExpression transformExpr(ConstraintExpression expr) throws SymbolicTransformationException {
- // explicitly handle all the recursive types
- if (expr instanceof ConstraintFilter) return transformFilter(expr);
- if (expr instanceof ConstraintIn) return transformIn(expr);
- if (expr instanceof ConstraintOperation) return transformOperation(expr);
- // do the actual work of this transformer
- if (expr instanceof Constraint) return transformConstraint(expr);
- // By default we do not recognise the constraint type, so pass it unchanged.
- return expr;
- }
-
- ConstraintFilter transformFilter(ConstraintExpression expr) throws SymbolicTransformationException {
- ConstraintFilter filter = (ConstraintFilter)expr;
- ConstraintExpression inner = filter.getUnfilteredConstraint();
- ConstraintExpression tx = transformExpr(inner);
- return (tx == inner) ? filter : new ConstraintFilter(tx, filter.getFilter());
- }
-
- ConstraintIn transformIn(ConstraintExpression expr) throws SymbolicTransformationException {
- ConstraintIn in = (ConstraintIn)expr;
- ConstraintExpression inner = in.getConstraintParam();
- ConstraintExpression tx = transformExpr(inner);
- return (tx == inner) ? in : new ConstraintIn(tx, in.getGraph());
- }
-
- ConstraintOperation transformOperation(ConstraintExpression expr) throws SymbolicTransformationException {
- ConstraintOperation operation = (ConstraintOperation)expr;
- List<ConstraintExpression> ops = operation.getElements();
- List<ConstraintExpression> newOps = new ArrayList<ConstraintExpression>(ops.size());
- boolean changed = false;
- for (ConstraintExpression op: ops) {
- ConstraintExpression tx = transformExpr(op);
- newOps.add(tx);
- if (tx != op) changed = true;
- }
- if (changed) {
- OpType operationType = OpType.getType(operation);
- if (operationType == null) throw new SymbolicTransformationException("Encountered an unknown operation type: " + operation.getClass());
- return operationType.newOp(newOps);
- }
- return operation;
- }
-
- /**
* All the work of this class is performed in this method. It ignores general constraints,
* and converts a ConstraintImpls with repeated variables into a conjunction of terms
* which have non-repeating variables, joined in an equivalent way to the original constraint.
- * @param expr The expression to transform.
+ * @param c The constraint to transform.
* @return The original constraint, or else a new equivalent conjunction if expr contains
* a repeated variable.
* @throws SymbolicTransformationException If there is an error in the constraint structure.
*/
- ConstraintExpression transformConstraint(ConstraintExpression expr) throws SymbolicTransformationException {
- if (!((Constraint)expr).isRepeating()) return (Constraint)expr;
- ConstraintImpl cnstr = (ConstraintImpl)expr;
+ @Override
+ protected ConstraintExpression transformConstraint(SymbolicTransformationContext context, Constraint c)
+ throws SymbolicTransformationException {
+ if (!c.isRepeating()) return c;
+ ConstraintImpl cnstr = (ConstraintImpl)c;
VarFreq vf = new VarFreq(cnstr);
// build the equivalent term
ConstraintElement[] elements = buildElements(cnstr, vf);
- expr = new ConstraintImpl(elements[0], elements[1], elements[2], elements[3]);
+ c = new ConstraintImpl(elements[0], elements[1], elements[2], elements[3]);
// if there was only a pair then return it as a simple filter
- if (vf.frequency == 2) return new ConstraintFilter(expr, createSameTermPair(vf.repeatedVar, 1));
+ if (vf.frequency == 2) return new ConstraintFilter(c, createSameTermPair(vf.repeatedVar, 1));
// build a conjunction of filters
int matches = vf.frequency - 1;
Filter[] sameTerms = new Filter[matches];
for (int f = 0; f < matches; f++) sameTerms[f] = createSameTermPair(vf.repeatedVar, f + 1);
- return new ConstraintFilter(expr, new And(sameTerms));
+ return new ConstraintFilter(c, new And(sameTerms));
}
/**
@@ -223,34 +160,4 @@
this.repeatedVar = repeatedVar;
}
}
-
- /**
- * This enum enumerates the ConstraintOperation types. It has been built to deal with
- * the fact that constructors for the various types cannot be passed as a lambda.
- * It also provides a map for the enumerated types to their enumerations, making it
- * easy for an operation to get to an appropriate constructor.
- */
- private static enum OpType {
- difference {
- ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDifference(ops.get(0), ops.get(1)); }
- },
- optional {
- ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintOptionalJoin(ops.get(0), ops.get(1)); }
- },
- conjunction {
- ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintConjunction(ops); }
- },
- disjunction {
- ConstraintOperation newOp(List<ConstraintExpression> ops) { return new ConstraintDisjunction(ops); }
- };
- abstract ConstraintOperation newOp(List<ConstraintExpression> ops);
- private static Map<Class<? extends ConstraintOperation>, OpType> opMap = new HashMap<Class<? extends ConstraintOperation>, OpType>();
- public static OpType getType(ConstraintOperation op) { return opMap.get(op.getClass()); }
- static {
- opMap.put(ConstraintDifference.class, difference);
- opMap.put(ConstraintOptionalJoin.class, optional);
- opMap.put(ConstraintConjunction.class, conjunction);
- opMap.put(ConstraintDisjunction.class, disjunction);
- }
- }
}
Copied: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java (from rev 1423, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java)
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java (rev 0)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphExpansion.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,58 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver.spi;
+
+// Java 2 standard packages
+import javax.transaction.xa.XAResource;
+import java.net.URI;
+
+// Local packages
+import org.mulgara.query.Constraint;
+import org.mulgara.query.GraphExpression;
+import org.mulgara.query.QueryException;
+import org.mulgara.resolver.spi.QueryEvaluationContext;
+import org.mulgara.store.tuples.Tuples;
+
+/**
+ * @created 2003-12-01
+ * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
+ * @version $Revision: 1.8 $
+ * @modified $Date: 2005/01/05 04:58:50 $
+ * @maintenanceAuthor $Author: newmana $
+ * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
+ * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+
+public interface GraphExpansion
+{
+ public Tuples expand(QueryEvaluationContext queryContext,
+ GraphExpression modelExpr,
+ Constraint constraint) throws Exception;
+}
Copied: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java (from rev 1423, trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java)
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java (rev 0)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/GraphResolutionHandler.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,58 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s): N/A.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.resolver.spi;
+
+// Java 2 standard packages
+import javax.transaction.xa.XAResource;
+import java.net.URI;
+
+// Local packages
+import org.mulgara.query.Constraint;
+import org.mulgara.query.GraphExpression;
+import org.mulgara.query.QueryException;
+import org.mulgara.resolver.spi.QueryEvaluationContext;
+import org.mulgara.store.tuples.Tuples;
+
+/**
+ * @created 2003-12-01
+ * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
+ * @version $Revision: 1.1 $
+ * @modified $Date: 2005/04/17 03:00:40 $
+ * @maintenanceAuthor $Author: pgearon $
+ * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
+ * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
+ * Software Pty Ltd</a>
+ * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
+ */
+
+public interface GraphResolutionHandler
+{
+ public Tuples resolve(QueryEvaluationContext queryContext,
+ GraphExpression modelExpr,
+ Constraint constraint) throws Exception;
+}
Deleted: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelExpansion.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,58 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver.spi;
-
-// Java 2 standard packages
-import javax.transaction.xa.XAResource;
-import java.net.URI;
-
-// Local packages
-import org.mulgara.query.Constraint;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.QueryException;
-import org.mulgara.resolver.spi.QueryEvaluationContext;
-import org.mulgara.store.tuples.Tuples;
-
-/**
- * @created 2003-12-01
- * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
- * @version $Revision: 1.8 $
- * @modified $Date: 2005/01/05 04:58:50 $
- * @maintenanceAuthor $Author: newmana $
- * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
- * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-
-public interface ModelExpansion
-{
- public Tuples expand(QueryEvaluationContext queryContext,
- ModelExpression modelExpr,
- Constraint constraint) throws Exception;
-}
Deleted: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ModelResolutionHandler.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -1,58 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver.spi;
-
-// Java 2 standard packages
-import javax.transaction.xa.XAResource;
-import java.net.URI;
-
-// Local packages
-import org.mulgara.query.Constraint;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.QueryException;
-import org.mulgara.resolver.spi.QueryEvaluationContext;
-import org.mulgara.store.tuples.Tuples;
-
-/**
- * @created 2003-12-01
- * @author <a href="http://www.pisoftware.com/andrae">Andrae Muys</a>
- * @version $Revision: 1.1 $
- * @modified $Date: 2005/04/17 03:00:40 $
- * @maintenanceAuthor $Author: pgearon $
- * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
- * @copyright ©2003-2004 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-
-public interface ModelResolutionHandler
-{
- public Tuples resolve(QueryEvaluationContext queryContext,
- ModelExpression modelExpr,
- Constraint constraint) throws Exception;
-}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/QueryEvaluationContext.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/QueryEvaluationContext.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/QueryEvaluationContext.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -72,19 +72,19 @@
* Localize and resolve the leaf node of the <code>FROM</code> and
* <code>WHERE</code> clause product.
*
- * @param modelResource the <code>FROM</code> clause to resolve, never
+ * @param graphResource the <code>FROM</code> clause to resolve, never
* <code>null</code>
* @param constraint the <code>WHERE</code> clause to resolve, which must
* have {@link Variable#FROM} as its fourth element, and never be
* <code>null</code>
* @throws QueryException if resolution can't be obtained
*/
- public Tuples resolve(ModelResource modelResource, Constraint constraint) throws QueryException;
+ public Tuples resolve(GraphResource graphResource, Constraint constraint) throws QueryException;
- public Tuples resolve(ModelExpression modelExpression, ConstraintExpression constraintExpression) throws QueryException;
+ public Tuples resolve(GraphExpression graphExpression, ConstraintExpression constraintExpression) throws QueryException;
public ResolverSession getResolverSession();
- public List<Tuples> resolveConstraintOperation(ModelExpression modelExpr,
+ public List<Tuples> resolveConstraintOperation(GraphExpression modelExpr,
ConstraintOperation constraintOper) throws QueryException;
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -29,6 +29,7 @@
import java.util.Map;
+import org.mulgara.query.ConstraintElement;
import org.mulgara.query.TuplesException;
/**
@@ -60,5 +61,5 @@
* @return null if resolution was not able to be simplified using bindings otherwise a new
* ReresolvableResolution with any variables bound in the reresolution removed.
*/
- public ReresolvableResolution reresolve(Map bindings) throws TuplesException;
+ public ReresolvableResolution reresolve(Map<? extends ConstraintElement,Long> bindings) throws TuplesException;
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -27,10 +27,9 @@
package org.mulgara.resolver.spi;
-import java.net.URI;
/**
- * A {@link Resolver} that is currently hosting the System Model.
+ * A {@link Resolver} that is currently hosting the System Graph.
*
* @created 2004-03-28
* @author <a href="http://staff.pisoftware.com/andrae">Andrae Muys</a>
@@ -50,4 +49,12 @@
public void createSystemModel(long model, long modelTypeURI) throws ResolverException, LocalizeException;
public boolean modelExists(long model) throws ResolverException, LocalizeException;
+
+ /**
+ * Informs the system resolver of the metadata it uses for managing data.
+ * @param systemGraphNode The node for the system graph.
+ * @param rdfTypeNode The node representing <rdf:type>.
+ * @param systemGraphTypeNode The node used for the SystemResolver graph type.
+ */
+ public void initializeSystemNodes(long systemGraphNode, long rdfTypeNode, long systemGraphTypeNode);
}
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolverFactory.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolverFactory.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SystemResolverFactory.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -35,7 +35,7 @@
// Local packages
import org.mulgara.query.Constraint;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.QueryException;
import org.mulgara.store.tuples.Tuples;
import org.mulgara.store.xa.SimpleXARecoveryHandler;
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -27,9 +27,6 @@
package org.mulgara.store.statement;
-// Java 2 standard packages
-import java.util.*;
-
// Locally written packages
import org.mulgara.query.Variable;
import org.mulgara.store.tuples.StoreTuples;
Modified: branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStoreAbstractUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStoreAbstractUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStoreAbstractUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -69,6 +69,10 @@
private static Logger log =
Logger.getLogger(StatementStoreAbstractUnitTest.class.getName());
+ static final protected long SYSTEM_GRAPH = 100;
+ static final protected long RDF_TYPE = 101;
+ static final protected long GRAPH_TYPE = 102;
+
/**
* Subclasses must initialize this field.
*/
@@ -111,6 +115,9 @@
store.removeTriples(1, 2, 3, 1);
store.removeTriples(1, 2, 4, 2);
store.removeTriples(2, 5, 6, 2);
+ store.removeTriples(SYSTEM_GRAPH, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
+ store.removeTriples(1, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
+ store.removeTriples(2, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
assertTrue(!store.isEmpty());
@@ -175,10 +182,7 @@
*/
public void testDump() throws Exception {
- TestTuples expected = new TestTuples();
- add(expected, StatementStore.VARIABLES, new long[] {1, 2, 3, 1});
- add(expected, StatementStore.VARIABLES, new long[] {1, 2, 4, 2});
- add(expected, StatementStore.VARIABLES, new long[] {2, 5, 6, 2});
+ TestTuples expected = getDump();
Tuples t = store.findTuples(NodePool.NONE, NodePool.NONE, NodePool.NONE, NodePool.NONE);
Tuples r = TuplesOperations.project(t, Arrays.asList(StatementStore.VARIABLES));
@@ -223,6 +227,7 @@
new Variable[] {StatementStore.VARIABLES[1], StatementStore.VARIABLES[2], StatementStore.VARIABLES[3]};
add(expected, vars, new long[] {2, 3, 1});
add(expected, vars, new long[] {2, 4, 2});
+ add(expected, vars, new long[] {RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH});
try {
Tuples t = store.findTuples(1, NodePool.NONE, NodePool.NONE, NodePool.NONE);
@@ -239,6 +244,7 @@
add(expected, vars, new long[] {5, 6, 2});
Tuples t = store.findTuples(2, NodePool.NONE, NodePool.NONE, NodePool.NONE);
+ add(expected, vars, new long[] {RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH});
assertEquals(expected, t);
t.close();
expected.close();
@@ -482,13 +488,25 @@
* Populate the test store.
*/
protected void setUp() throws Exception {
+ store.initializeSystemNodes(SYSTEM_GRAPH, RDF_TYPE, GRAPH_TYPE);
+ // set up the graph instances
+ store.addTriple(SYSTEM_GRAPH, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
+ store.addTriple(1, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
+ store.addTriple(2, RDF_TYPE, GRAPH_TYPE, SYSTEM_GRAPH);
+
store.addTriple(1, 2, 3, 1);
store.addTriple(1, 2, 4, 2);
store.addTriple(2, 5, 6, 2);
}
/**
+ * Return a dump of all tuples, sorted by the primary index.
+ * @return a new TestTuples containing all the {@link #setUp()} triples, according to the natural ordering of the store.
+ */
+ protected abstract TestTuples getDump();
+
+ /**
* Close the test store.
*/
protected void tearDown() throws Exception {
Modified: branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -42,7 +42,7 @@
import org.mulgara.query.Constraint;
import org.mulgara.query.ConstraintElement;
import org.mulgara.query.ConstraintExpression;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.resolver.spi.ConstraintDescriptor;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.store.tuples.Tuples;
@@ -77,7 +77,7 @@
}
- public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
+ public Tuples resolve(QueryEvaluationContext context, GraphExpression modelExpr, ConstraintExpression constraintExpr) throws Exception {
if (constraintExpr instanceof TestConstraint) {
// FIXME: Need to find a clean way of enlisting the resolver in the transaction.
// This will involve changes to LocalQueryResolver (the QEC/context passed to this method).
Modified: branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -115,7 +115,7 @@
* Remove the file containing the model.
*/
public void removeModel(long model) throws ResolverException {
- throw new ResolverException("Model removal not supported in TestResolver");
+ throw new ResolverException("Graph removal not supported in TestResolver");
}
/**
Modified: branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolverUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolverUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-test/java/org/mulgara/resolver/test/TestResolverUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -49,7 +49,7 @@
// locally written packages
import org.mulgara.query.Answer;
import org.mulgara.query.ConstraintConjunction;
-import org.mulgara.query.ModelResource;
+import org.mulgara.query.GraphResource;
import org.mulgara.query.Order;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
@@ -135,7 +135,7 @@
Answer answer = session.query(new Query(
variables, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new TestConstraint(new Variable("a"), new Variable("b"), "test:a", ""), // WHERE
null, // HAVING
Arrays.asList(new Order[]
@@ -182,7 +182,7 @@
Answer answer = session.query(new Query(
variables, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new TestConstraint(new Variable("a"), new Variable("c"), "test:b", ""), // WHERE
null, // HAVING
Arrays.asList(new Order[]
@@ -227,7 +227,7 @@
Answer answer = session.query(new Query(
variables, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction( // WHERE
new TestConstraint(new Variable("a"), new Variable("c"), "test:b", ""),
new TestConstraint(new Variable("a"), new Variable("b"), "test:a", "")),
@@ -278,7 +278,7 @@
Answer answer = session.query(new Query(
variables, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction( // WHERE
new TestConstraint(new Variable("a"), new Variable("c"), "test:b", "a"),
new TestConstraint(new Variable("a"), new Variable("b"), "test:a", "")),
@@ -330,7 +330,7 @@
try {
session.query(new Query(
variables, // SELECT
- new ModelResource(systemModelURI), // FROM
+ new GraphResource(systemModelURI), // FROM
new ConstraintConjunction( // WHERE
new TestConstraint(new Variable("a"), new Variable("c"), "test:b", "b"), // non-prefix variable causes failure
new TestConstraint(new Variable("a"), new Variable("b"), "test:a", "")),
Modified: branches/xa11/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-url/java/org/mulgara/resolver/url/URLResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -138,7 +138,7 @@
Node globalModel = resolverSession.globalize(model);
if (!(globalModel instanceof URIReference)) {
throw new ResolverException(
- "Model parameter " + globalModel + " isn't a URI reference");
+ "Graph parameter " + globalModel + " isn't a URI reference");
}
modelURIReference = (URIReference) globalModel;
}
@@ -241,7 +241,7 @@
Node globalModel = resolverSession.globalize(model);
if (!(globalModel instanceof URIReference)) {
throw new ResolverException(
- "Model parameter " + globalModel + " isn't a URI reference");
+ "Graph parameter " + globalModel + " isn't a URI reference");
}
modelURIReference = (URIReference) globalModel;
}
Modified: branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -111,7 +111,7 @@
// Validate "modelType" parameter
if (modelTypeURI == null) {
- throw new IllegalArgumentException("Model type can't be null");
+ throw new IllegalArgumentException("Graph type can't be null");
}
this.resolverSession = resolverSession;
this.systemResolver = systemResolver;
@@ -257,7 +257,7 @@
return definition.resolve(constraint, session);
} catch (LocalizeException el) {
- throw new QueryException("Model " + model + " did not exist in view expansion", el);
+ throw new QueryException("Graph " + model + " did not exist in view expansion", el);
} catch (ResolverException er) {
throw new QueryException("Failed to build view definition uri", er.getCause());
}
Modified: branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolverUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolverUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-view/java/org/mulgara/resolver/view/ViewResolverUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -133,11 +133,11 @@
};
- protected static final ModelResource[] models;
+ protected static final GraphResource[] models;
static {
- models = new ModelResource[modelURIs.length];
+ models = new GraphResource[modelURIs.length];
for (int i = 0; i < modelURIs.length; i++) {
- models[i] = new ModelResource(modelURIs[i]);
+ models[i] = new GraphResource(modelURIs[i]);
}
};
@@ -579,7 +579,7 @@
Session session = database.newSession();
for (int i = 1; i < modelURIs.length; i++) {
session.createModel(modelURIs[i], modelTypeURI);
- session.setModel(modelURIs[i], new ModelResource(modelDataURIs[i]));
+ session.setModel(modelURIs[i], new GraphResource(modelDataURIs[i]));
}
}
Modified: branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraintDescriptor.java
===================================================================
--- branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraintDescriptor.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraintDescriptor.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -83,7 +83,7 @@
* an {@link IntervalConstraint}
*/
public Tuples resolve(QueryEvaluationContext queryEvaluationContext,
- ModelExpression modelExpression,
+ GraphExpression graphExpression,
ConstraintExpression constraintExpression)
throws Exception {
Modified: branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
===================================================================
--- branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -51,7 +51,7 @@
import org.mulgara.query.*;
import org.mulgara.query.rdf.URIReferenceImpl;
import org.mulgara.resolver.spi.MutableLocalQuery;
-import org.mulgara.resolver.spi.SymbolicTransformation;
+import org.mulgara.resolver.spi.AbstractSymbolicTransformer;
import org.mulgara.resolver.spi.SymbolicTransformationContext;
import org.mulgara.resolver.spi.SymbolicTransformationException;
import org.mulgara.store.stringpool.StringPoolException;
@@ -69,11 +69,9 @@
* Australian Commonwealth Government, Department of Defence</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-class IntervalTransformation implements SymbolicTransformation
-{
+class IntervalTransformation extends AbstractSymbolicTransformer {
/** Logger. */
- private static final Logger logger =
- Logger.getLogger(IntervalTransformation.class.getName());
+ private static final Logger logger = Logger.getLogger(IntervalTransformation.class);
/**
* The node representing the < relation between <tt>xsd:double</tt>s.
@@ -102,8 +100,7 @@
* @param greaterThan property representing > for <tt>xsd:double</tt>s,
* never <code>null</code>
*/
- IntervalTransformation(URI modelTypeURI, URIReferenceImpl lessThan, URIReferenceImpl greaterThan)
- {
+ IntervalTransformation(URI modelTypeURI, URIReferenceImpl lessThan, URIReferenceImpl greaterThan) {
assert lessThan != null;
assert greaterThan != null;
@@ -113,62 +110,17 @@
this.lessThan = lessThan;
}
- //
- // Methods implementing Symbolic Transformation
- //
-
- public void transform(SymbolicTransformationContext context, MutableLocalQuery mutableLocalQuery)
- throws SymbolicTransformationException
- {
- ConstraintExpression constraintExpression =
- transformExpression(context, mutableLocalQuery.getConstraintExpression());
-
- if (constraintExpression != null) {
- mutableLocalQuery.setConstraintExpression(constraintExpression);
- }
+ @Override
+ protected ConstraintExpression transformOperation(SymbolicTransformationContext context,
+ ConstraintOperation expr)
+ throws SymbolicTransformationException {
+ if (expr instanceof ConstraintConjunction)
+ return transformConjunction(context, (ConstraintConjunction)expr);
+ return super.transformOperation(context, expr);
}
- //
- // Internal methods
- //
-
- /**
- * @param constraintExpression the <code>WHERE</code> clause to transform,
- * never <code>null</code>
- * @return the transformed version of the <var>constraintExpression</var>, or
- * <code>null</code> to indicate no transformation
- * @throws IllegalArgumentException if <var>constraintExpression</var> is
- * <code>null</code>
- * @throws SymbolicTransformationException if the transformation can't be
- * returned
- */
- ConstraintExpression transformExpression(SymbolicTransformationContext context, ConstraintExpression constraintExpression)
- throws SymbolicTransformationException
- {
- // Validate "constraintExpression" parameter
- if (constraintExpression == null) {
- throw new IllegalArgumentException("Null \"constraintExpression\" parameter"
- );
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Transforming ConstraintExpression: " + constraintExpression);
- }
-
- if (constraintExpression instanceof ConstraintConjunction) {
- return transformConjunction(context, (ConstraintConjunction) constraintExpression);
- }
- else if (constraintExpression instanceof ConstraintImpl) {
- return transformConstraint(context, (ConstraintImpl) constraintExpression);
- }
- else {
- return null; // don't modify constraints we don't understand
- }
- }
-
private ConstraintExpression transformConjunction(SymbolicTransformationContext context, ConstraintConjunction constraintConjunction)
- throws SymbolicTransformationException
- {
+ throws SymbolicTransformationException {
if (logger.isDebugEnabled()) {
logger.debug("Transforming conjunction " + constraintConjunction);
}
@@ -188,7 +140,7 @@
// Recursively transform the element
ConstraintExpression transformedElement = transformExpression(context, element);
- if (transformedElement != null) {
+ if (transformedElement != element) {
if (logger.isDebugEnabled()) {
logger.debug("Recursively transformed " + element +
" to " + transformedElement);
@@ -232,16 +184,16 @@
logger.debug("Conjunction not modified");
}
- return null;
+ return constraintConjunction;
} else {
newElements.addAll(map.values());
// Convert the list of conjoined terms into a ConstraintExpression
ConstraintExpression result;
switch (newElements.size()) {
- case 0: result = ConstraintFalse.INSTANCE; break;
- case 1: result = (ConstraintExpression) newElements.get(0); break;
- default: result = new ConstraintConjunction(newElements);
+ case 0: result = ConstraintFalse.INSTANCE; break;
+ case 1: result = (ConstraintExpression) newElements.get(0); break;
+ default: result = new ConstraintConjunction(newElements);
}
assert result != null;
@@ -253,73 +205,71 @@
}
}
- private ConstraintExpression transformConstraint(SymbolicTransformationContext context, ConstraintImpl constraintImpl)
- throws SymbolicTransformationException
- {
- assert constraintImpl != null;
+ @Override
+ protected ConstraintExpression transformConstraint(SymbolicTransformationContext context,
+ Constraint constraint)
+ throws SymbolicTransformationException {
+ assert constraint != null;
+ if (constraint instanceof IntervalConstraint) return constraint;
Variable variable;
boolean boundedBelow;
Bound bound;
if (logger.isDebugEnabled()) {
- logger.debug("Transforming ConstraintImpl: " + constraintImpl);
+ logger.debug("Transforming Constraint: " + constraint);
}
// Confirm model is of type XSDModel.
try {
- ConstraintElement modelElement = constraintImpl.getModel();
+ ConstraintElement modelElement = constraint.getModel();
if (!(modelElement instanceof URIReference)) {
- logger.debug("model not URIReference; cannot participate in transform returning null");
- return null;
+ logger.debug("model not URIReference; cannot participate in transform, returning original");
+ return constraint;
}
URI modelURI = ((URIReference)modelElement).getURI();
URI modelTypeURI = context.mapToModelTypeURI(modelURI);
if (!this.modelTypeURI.equals(modelTypeURI)) {
- logger.debug("model: " + modelURI + " is of type " + modelTypeURI + " not " + this.modelTypeURI + " ignoring constraint, returning null");
+ logger.debug("model: " + modelURI + " is of type " + modelTypeURI + " not " + this.modelTypeURI + " ignoring constraint, returning original");
- return null;
+ return constraint;
}
} catch (QueryException eq) {
throw new SymbolicTransformationException("Unable to check model on constraint", eq);
}
- logger.debug("Model suitable for IntervalTransformation");
+ logger.debug("Graph suitable for IntervalTransformation");
// Figure out the direction of bounding, assuming [$var op value] order
- if (constraintImpl.getElement(1).equals(lessThan)) {
+ if (constraint.getElement(1).equals(lessThan)) {
boundedBelow = false;
- }
- else if (constraintImpl.getElement(1).equals(greaterThan)) {
+ } else if (constraint.getElement(1).equals(greaterThan)) {
boundedBelow = true;
- }
- else {
+ } else {
logger.debug("Predicate not recognised by IntervalTransformation");
- return null;
+ return constraint;
}
// Determine whether we have a [$var op value] or [value op $var] form
- if (constraintImpl.getElement(0) instanceof Variable) {
- if (constraintImpl.getElement(2) instanceof Variable) {
- logger.debug("Both Subject and Object are Variables, returning null");
- return null;
- }
- else {
- variable = (Variable) constraintImpl.getElement(0);
+ if (constraint.getElement(0) instanceof Variable) {
+ if (constraint.getElement(2) instanceof Variable) {
+ logger.debug("Both Subject and Object are Variables, returning original");
+ return constraint;
+ } else {
+ variable = (Variable) constraint.getElement(0);
double value = Double.parseDouble(
- ((Literal) constraintImpl.getElement(2)).getLexicalForm()
+ ((Literal) constraint.getElement(2)).getLexicalForm()
);
bound = new Bound(value, false);
}
} else {
- if (constraintImpl.getElement(2) instanceof Variable) {
- logger.debug("Object is a variable returning null?");
- // Is this right, surely the above should be not-instanceof !?
- return null;
+ if (!(constraint.getElement(2) instanceof Variable)) {
+ logger.debug("Neither Subject nor Object are Variables, returning original");
+ return constraint;
} else {
- variable = (Variable) constraintImpl.getElement(2);
+ variable = (Variable) constraint.getElement(2);
double value = Double.parseDouble(
- ((Literal) constraintImpl.getElement(0)).getLexicalForm()
+ ((Literal) constraint.getElement(0)).getLexicalForm()
);
bound = new Bound(value, false);
boundedBelow = !boundedBelow; // reverse the comparison
@@ -331,7 +281,7 @@
variable,
boundedBelow ? bound : null,
boundedBelow ? null : bound,
- (URIReference)constraintImpl.getModel()
+ (URIReference)constraint.getModel()
);
}
}
Modified: branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
===================================================================
--- branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -70,11 +70,9 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class IntervalTransformationUnitTest extends TestCase
-{
+public class IntervalTransformationUnitTest extends TestCase {
/** Logger */
- private static Logger logger =
- Logger.getLogger(IntervalTransformationUnitTest.class.getName());
+ private static Logger logger = Logger.getLogger(IntervalTransformationUnitTest.class);
private URIReferenceImpl greaterThan;
@@ -115,8 +113,7 @@
*
* @param name the name of the test
*/
- public IntervalTransformationUnitTest(String name)
- {
+ public IntervalTransformationUnitTest(String name) {
super(name);
}
@@ -125,8 +122,7 @@
*
* @return the test suite
*/
- public static Test suite()
- {
+ public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new IntervalTransformationUnitTest("test1Transform"));
@@ -136,6 +132,8 @@
suite.addTest(new IntervalTransformationUnitTest("test5Transform"));
suite.addTest(new IntervalTransformationUnitTest("test6IgnoreNonXSD"));
suite.addTest(new IntervalTransformationUnitTest("test7PreserveNonXSD"));
+ suite.addTest(new IntervalTransformationUnitTest("test8IgnoreNoVars"));
+ suite.addTest(new IntervalTransformationUnitTest("test9IgnoreAllVars"));
return suite;
}
@@ -143,8 +141,7 @@
/**
* Create test instance.
*/
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
greaterThan = new URIReferenceImpl(new URI(Mulgara.NAMESPACE + "lt"));
lessThan = new URIReferenceImpl(new URI(Mulgara.NAMESPACE + "gt"));
@@ -174,8 +171,7 @@
*
* @param args the command line arguments
*/
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
@@ -186,11 +182,9 @@
/**
* Test #1 for the {@link IntervalTransformation#transform} method.
*/
- public void test1Transform() throws Exception
- {
+ public void test1Transform() throws Exception {
try {
- intervalTransformation.transformExpression(context, (ConstraintExpression) null);
- fail("Expected an IllegalArgumentException");
+ assertNull(intervalTransformation.transformExpression(context, (ConstraintExpression) null));
}
catch (IllegalArgumentException e) {
// expected
@@ -200,9 +194,8 @@
/**
* Test #2 for the {@link IntervalTransformation#transform} method.
*/
- public void test2Transform() throws Exception
- {
- assertNull(intervalTransformation.transformExpression(context, ConstraintTrue.INSTANCE));
+ public void test2Transform() throws Exception {
+ assertSame(ConstraintTrue.INSTANCE, intervalTransformation.transformExpression(context, ConstraintTrue.INSTANCE));
}
/**
@@ -210,8 +203,7 @@
*
* This transforms a single {@link ConstraintImpl}.
*/
- public void test3Transform() throws Exception
- {
+ public void test3Transform() throws Exception {
Variable x = new Variable("x");
assertEquals(
@@ -231,8 +223,7 @@
*
* This transforms a single {@link ConstraintConjunction}.
*/
- public void test4Transform() throws Exception
- {
+ public void test4Transform() throws Exception {
Variable x = new Variable("x");
assertEquals(new IntervalConstraint(
@@ -255,8 +246,7 @@
* This transforms a {@link ConstraintConjunction} containing
* {@link IntervalConstraint}s over different variables.
*/
- public void test5Transform() throws Exception
- {
+ public void test5Transform() throws Exception {
Variable x = new Variable("x");
Variable y = new Variable("y");
@@ -281,13 +271,11 @@
Variable x = new Variable("x");
Variable y = new Variable("y");
- assertEquals(
- intervalTransformation.transformExpression(context, new ConstraintConjunction(
+ ConstraintConjunction cc = new ConstraintConjunction(
new ConstraintImpl(x, greaterThan, new LiteralImpl(2), nonXSDModel),
new ConstraintImpl(y, lessThan, new LiteralImpl(3), nonXSDModel)
- )
- ),
- null);
+ );
+ assertSame(cc, intervalTransformation.transformExpression(context, cc));
}
/**
@@ -296,8 +284,7 @@
* This checks that xsd models will be transformed in the presence of
* non-xsd models which will be preserved.
*/
- public void test7PreserveNonXSD() throws Exception
- {
+ public void test7PreserveNonXSD() throws Exception {
Variable x = new Variable("x");
assertEquals(
@@ -320,4 +307,24 @@
)
);
}
+
+ /**
+ * Test #8 for the {@link IntervalTransformation#transform} method.
+ *
+ * This checks that constraints with no variables will not be transformed.
+ */
+ public void test8IgnoreNoVars() throws Exception {
+ ConstraintImpl ci = new ConstraintImpl(new LiteralImpl(2), lessThan, new LiteralImpl(3), xsdModel);
+ assertSame(ci, intervalTransformation.transformExpression(context, ci));
+ }
+
+ /**
+ * Test #9 for the {@link IntervalTransformation#transform} method.
+ *
+ * This checks that constraints with variables in both subj and obj will not be transformed.
+ */
+ public void test9IgnoreAllVars() throws Exception {
+ ConstraintImpl ci = new ConstraintImpl(new Variable("x"), lessThan, new Variable("y"), xsdModel);
+ assertSame(ci, intervalTransformation.transformExpression(context, ci));
+ }
}
Modified: branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/XSDResolver.java
===================================================================
--- branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/XSDResolver.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/XSDResolver.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -129,13 +129,13 @@
}
/**
- * @param modelResource a model identified in the <code>FROM</code> clause
+ * @param graphResource a model identified in the <code>FROM</code> clause
* @return <code>true</code> only if this resource is the unique XML Schema
* model
* @throws QueryException always, because it's not implemented
* @deprecated XSDResolver.canResolve is not implemented
*/
- public boolean canResolve(ModelResource modelResource) throws QueryException {
+ public boolean canResolve(GraphResource graphResource) throws QueryException {
throw new QueryException(getClass() + ".canResolve not implemented");
}
Modified: branches/xa11/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
===================================================================
--- branches/xa11/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -146,7 +146,6 @@
* where this class was run.</p>
* @param args command line arguments
*/
- @SuppressWarnings("unchecked")
public static void main(String[] args) {
// report the version and build number
System.out.println("@@build.label@@");
Modified: branches/xa11/src/jar/server/java/org/mulgara/server/HttpServices.java
===================================================================
--- branches/xa11/src/jar/server/java/org/mulgara/server/HttpServices.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server/java/org/mulgara/server/HttpServices.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -79,6 +79,9 @@
/** The Web Query path. */
private final static String WEBQUERY_PATH = "webui";
+ /** The Web Tutorial path. */
+ private final static String WEBTUTORIAL_PATH = "tutorial";
+
/** The sparql path. */
private final static String SPARQL_PATH = "sparql";
@@ -220,8 +223,11 @@
return addWebServicesWebAppContext(s);
} });
starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
- return addWebQueryContext(s);
+ return addWebQueryContext(s, "User Interface", "org.mulgara.webquery.QueryServlet", WEBQUERY_PATH);
} });
+ starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
+ return addWebQueryContext(s, "User Tutorial", "org.mulgara.webquery.TutorialServlet", WEBTUTORIAL_PATH);
+ } });
// expect to get the following from a config file
// TODO: create a decent configuration object, instead of just handing out a Server
starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
@@ -305,22 +311,22 @@
/**
- * Creates the Mulgara Semantic Store Query Tool (webui).
+ * Creates and registers a web servlet.
* @throws IOException if the servlet cannot talk to the network.
*/
- private Service addWebQueryContext(Server server) throws IOException {
- if (logger.isDebugEnabled()) logger.debug("Adding WebQuery servlet context");
+ private Service addWebQueryContext(Server server, String name, String servletClass, String servletPath) throws IOException {
+ if (logger.isDebugEnabled()) logger.debug("Adding Web servlet context: " + name);
- // create the web query context
+ // create the web context
try {
AbstractServer serverMBean = (AbstractServer)hostServer.getServerMBean();
String rmiName = hostServer.getServerName();
- Servlet servlet = (Servlet)Reflect.newInstance(Class.forName("org.mulgara.webquery.QueryServlet"), hostName, rmiName, serverMBean);
- String webPath = "/" + WEBQUERY_PATH;
+ Servlet servlet = (Servlet)Reflect.newInstance(Class.forName(servletClass), hostName, rmiName, serverMBean);
+ String webPath = "/" + servletPath;
new org.mortbay.jetty.servlet.Context(server, webPath, SESSIONS).addServlet(new ServletHolder(servlet), "/*");
- return new Service("User Interface", webPath);
+ return new Service(name, webPath);
} catch (ClassNotFoundException e) {
- throw new IllegalStateException("Not configured to use the requested Query servlet");
+ throw new IllegalStateException("Not configured to use the requested servlet: " + name + "(" + servletClass + ")");
}
}
Modified: branches/xa11/src/jar/server-local/java/org/mulgara/server/local/LocalSessionFactory.java
===================================================================
--- branches/xa11/src/jar/server-local/java/org/mulgara/server/local/LocalSessionFactory.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-local/java/org/mulgara/server/local/LocalSessionFactory.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,7 +41,7 @@
// Locally written packages
import java.lang.reflect.*;
-import org.mulgara.query.ModelLiteral;
+import org.mulgara.query.GraphLiteral;
import org.mulgara.query.QueryException;
import org.mulgara.server.Session;
import org.mulgara.server.SessionFactory;
Modified: branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteJRDFSession.java
===================================================================
--- branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteJRDFSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteJRDFSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -41,7 +41,7 @@
// Locally written packages
import org.mulgara.query.Answer;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
Modified: branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
===================================================================
--- branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -38,7 +38,7 @@
import org.jrdf.graph.Triple;
import org.mulgara.query.AskQuery;
import org.mulgara.query.ConstructQuery;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.rules.InitializerException;
@@ -235,25 +235,25 @@
* Define the contents of a model.
*
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
* @throws RemoteException EXCEPTION TO DO
*/
public long setModel(URI uri,
- ModelExpression modelExpression) throws QueryException, RemoteException;
+ GraphExpression graphExpression) throws QueryException, RemoteException;
/**
* Define the contents of a model via an inputstream.
*
* @param inputStream a remote inputstream
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
*/
public long setModel(InputStream inputStream, URI uri,
- ModelExpression modelExpression) throws QueryException,
+ GraphExpression graphExpression) throws QueryException,
RemoteException;
/**
Modified: branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionFactoryImpl.java
===================================================================
--- branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionFactoryImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionFactoryImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -54,7 +54,6 @@
class RemoteSessionFactoryImpl implements RemoteSessionFactory {
/** Logger. This is named after the classname. */
- @SuppressWarnings("unused")
private final static Logger logger = Logger.getLogger(RemoteSessionFactoryImpl.class);
/** The local database. */
Modified: branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
===================================================================
--- branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -46,7 +46,7 @@
import org.mulgara.query.AskQuery;
import org.mulgara.query.ConstructQuery;
import org.mulgara.query.GraphAnswer;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.rules.RulesRef;
@@ -133,19 +133,19 @@
* Sets the contents of a model, via a model expression.
*
* @param uri The name of the model to set.
- * @param modelExpression The expression describing the data to put in the model.
+ * @param graphExpression The expression describing the data to put in the model.
* @return The number of statements inserted into the model.
* @throws QueryException An error getting data for the model, or inserting into the new model.
*/
- public long setModel(URI uri, ModelExpression modelExpression) throws QueryException {
+ public long setModel(URI uri, GraphExpression graphExpression) throws QueryException {
try {
- long r = remoteSession.setModel(uri, modelExpression);
+ long r = remoteSession.setModel(uri, graphExpression);
resetRetries();
return r;
} catch (RemoteException e) {
testRetry(e);
- return setModel(uri, modelExpression);
+ return setModel(uri, graphExpression);
}
}
@@ -155,20 +155,20 @@
*
* @param inputStream a remote inputstream
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
*/
- public long setModel(InputStream inputStream, URI uri, ModelExpression modelExpression) throws QueryException {
+ public long setModel(InputStream inputStream, URI uri, GraphExpression graphExpression) throws QueryException {
try {
- long r = remoteSession.setModel(inputStream, uri, modelExpression);
+ long r = remoteSession.setModel(inputStream, uri, graphExpression);
resetRetries();
return r;
} catch (RemoteException e) {
testRetry(e);
- return setModel(inputStream, uri, modelExpression);
+ return setModel(inputStream, uri, graphExpression);
}
}
@@ -507,7 +507,6 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
public List<Answer> query(List<Query> queries) throws QueryException {
try {
@@ -699,10 +698,12 @@
public RulesRef buildRules(URI ruleModel, URI baseModel, URI destModel) throws QueryException, org.mulgara.rules.InitializerException {
try {
RulesRef ref = remoteSession.buildRules(ruleModel, baseModel, destModel);
- logger.info("got rules from RMI");
+ if (logger.isDebugEnabled()) logger.debug("got rules from RMI");
return ref;
} catch (RemoteException re) {
- throw new org.mulgara.rules.InitializerException("Java RMI reconnection failure", re);
+ Throwable cause = re.getCause();
+ if (cause != null) throw new org.mulgara.rules.InitializerException("Unable to load rules: " + cause.getMessage(), cause);
+ throw new org.mulgara.rules.InitializerException("Unable to load rules", re);
}
}
@@ -714,7 +715,9 @@
try {
remoteSession.applyRules(rules);
} catch (RemoteException re) {
- throw new QueryException("Java RMI reconnection failure", re);
+ Throwable cause = re.getCause();
+ if (cause != null) throw new QueryException("Error applying rules: " + cause.getMessage(), cause);
+ throw new QueryException("Error applying rules", re);
}
}
Modified: branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
===================================================================
--- branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -44,7 +44,7 @@
import org.mulgara.query.ArrayAnswer;
import org.mulgara.query.AskQuery;
import org.mulgara.query.ConstructQuery;
-import org.mulgara.query.ModelExpression;
+import org.mulgara.query.GraphExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.query.TuplesException;
@@ -93,17 +93,17 @@
}
/**
- * Sets the Model attribute of the SessionWrapperRemoteSession object
+ * Sets the Graph attribute of the SessionWrapperRemoteSession object
*
- * @param uri The new Model value
- * @param modelExpression The new Model value
+ * @param uri The new Graph value
+ * @param graphExpression The new Graph value
* @return RETURNED VALUE TO DO
* @throws QueryException EXCEPTION TO DO
* @throws RemoteException EXCEPTION TO DO
*/
- public long setModel(URI uri, ModelExpression modelExpression) throws QueryException, RemoteException {
+ public long setModel(URI uri, GraphExpression graphExpression) throws QueryException, RemoteException {
try {
- return session.setModel(uri, modelExpression);
+ return session.setModel(uri, graphExpression);
} catch (Throwable t) {
throw convertToQueryException(t);
}
@@ -114,13 +114,13 @@
*
* @param inputStream a remote inputstream
* @param uri the {@link URI} of the model to be redefined
- * @param modelExpression the new content for the model
+ * @param graphExpression the new content for the model
* @return The number of statements inserted into the model
* @throws QueryException if the model can't be modified
*/
- public long setModel(InputStream inputStream, URI uri, ModelExpression modelExpression) throws QueryException {
+ public long setModel(InputStream inputStream, URI uri, GraphExpression graphExpression) throws QueryException {
try {
- return session.setModel(inputStream, uri, modelExpression);
+ return session.setModel(inputStream, uri, graphExpression);
} catch (Throwable t) {
throw convertToQueryException(t);
}
Modified: branches/xa11/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
===================================================================
--- branches/xa11/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -694,7 +694,7 @@
/**
* Copied from AbstractTuples
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: branches/xa11/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
===================================================================
--- branches/xa11/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -2085,7 +2085,7 @@
/**
* Copied from AbstractTuples
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
Modified: branches/xa11/src/jar/store-xa/java/org/mulgara/store/xa/XAStatementStore.java
===================================================================
--- branches/xa11/src/jar/store-xa/java/org/mulgara/store/xa/XAStatementStore.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/store-xa/java/org/mulgara/store/xa/XAStatementStore.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -84,4 +84,12 @@
*/
public void delete() throws StatementStoreException;
+ /**
+ * Informs the statement store of the metadata it uses for managing data.
+ * @param systemGraphNode The node for the system graph.
+ * @param rdfTypeNode The node representing <rdf:type>.
+ * @param systemGraphTypeNode The node used for the SystemResolver graph type.
+ */
+ public void initializeSystemNodes(long systemGraphNode, long rdfTypeNode, long systemGraphTypeNode);
+
}
Modified: branches/xa11/src/jar/tag/java/org/mulgara/extractor/tag/InitTag.java
===================================================================
--- branches/xa11/src/jar/tag/java/org/mulgara/extractor/tag/InitTag.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tag/java/org/mulgara/extractor/tag/InitTag.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -295,7 +295,7 @@
if (model == null) {
- throw new JspTagException("init: Model URI cannot be null");
+ throw new JspTagException("init: Graph URI cannot be null");
}
// end if
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/AbstractTuples.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/AbstractTuples.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/AbstractTuples.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -69,6 +69,7 @@
private final static Variable[] emptyVariables = new Variable[] {};
/** Description of the Field */
+ @SuppressWarnings("unused")
private final static long[] NO_PREFIX = new long[] {};
/** Description of the Field */
@@ -577,7 +578,7 @@
variables = variableArray;
}
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/DefinablePrefixAnnotation.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/DefinablePrefixAnnotation.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/DefinablePrefixAnnotation.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -42,10 +42,6 @@
package org.mulgara.store.tuples;
// JDK packages
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
// Third party packages
@@ -73,5 +69,5 @@
*
* @param boundVars variables available to be bound in beforeFirst.
*/
- public void definePrefix(Set boundVars) throws TuplesException;
+ public void definePrefix(Set<Variable> boundVars) throws TuplesException;
}
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/LeftJoin.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/LeftJoin.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/LeftJoin.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -51,7 +51,6 @@
*/
public class LeftJoin extends AbstractTuples implements ContextOwner {
- @SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(LeftJoin.class.getName());
/** The set of tuples to return all row from. */
@@ -576,7 +575,7 @@
}
/** @see org.mulgara.store.tuples.Tuples#getAnnotation(java.lang.Class) */
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return wrapped.getAnnotation(annotationClass);
}
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedAppend.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedAppend.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedAppend.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -75,7 +75,7 @@
/**
* The propositions to conjoin.
*/
- private final Tuples[] operands;
+ protected final Tuples[] operands;
/**
* The return value of the {@link #beforeFirst} method.
@@ -233,7 +233,7 @@
}
- public List getOperands() {
+ public List<Tuples> getOperands() {
return Arrays.asList(operands);
}
@@ -351,13 +351,13 @@
public Variable[] getVariables() {
// Container for our variables
- ArrayList variablesList = new ArrayList();
+ ArrayList<Variable> variablesList = new ArrayList<Variable>();
// Iterate through the tuples objects and get the variables for each
for (int index = 0; index < operands.length; index++) {
// Get the array of variables for the current tuples object
- Variable [] variableArray = operands[index].getVariables();
+ Variable[] variableArray = operands[index].getVariables();
// We need to prevent duplicate variables so iterate through the new array
// and remove duplicates
@@ -372,17 +372,17 @@
}
// Convert the list to an array
- Variable [] newVariables = new Variable [variablesList.size()];
- newVariables = (Variable []) variablesList.toArray(newVariables);
+ Variable[] newVariables = new Variable[variablesList.size()];
+ newVariables = variablesList.toArray(newVariables);
return newVariables;
}
- public Annotation getAnnotation(Class annotation) {
+ public Annotation getAnnotation(Class<? extends Annotation> annotation) {
if (annotation.equals(DefinablePrefixAnnotation.class) && prefixDefinable) {
return new DefinablePrefixAnnotation() {
- public void definePrefix(Set boundVars) throws TuplesException {
+ public void definePrefix(Set<Variable> boundVars) throws TuplesException {
for (int i = 0; i < operands.length; i++) {
DefinablePrefixAnnotation annotation =
(DefinablePrefixAnnotation)operands[i].getAnnotation(DefinablePrefixAnnotation.class);
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/Tuples.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/Tuples.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/Tuples.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -274,5 +274,5 @@
*
* @return An annotation of the class requested, or null if none exists.
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException;
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException;
}
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -193,6 +193,58 @@
/**
+ * Creates a new Tuples which contains all of the bindings of the Tuples in the argument list.
+ * All tuples must have an identical pattern, and come directly from the store.
+ * @param args A list of the Tuples directly backed by the store to be used in the result.
+ * @return A StoreTuples containing all of the bindings from the args list.
+ * @throws TuplesException If the data could not be appended.
+ */
+ public static StoreTuples appendCompatible(List<StoreTuples> args) throws TuplesException {
+ if (logger.isDebugEnabled()) logger.debug("Compatible append of " + args);
+
+ Variable[] vars = null;
+ List<StoreTuples> operands = new ArrayList<StoreTuples>();
+ for (StoreTuples arg: args) {
+
+ // test for empty or unconstrained data
+ if (arg.isUnconstrained()) {
+ closeOperands(operands);
+ if (logger.isDebugEnabled()) logger.debug("Returning unconstrained from append.");
+ return unconstrained();
+ } else if (arg.getRowCardinality() == Cursor.ZERO) {
+ if (logger.isDebugEnabled()) logger.debug("Ignoring append operand " + arg + " with rowcount = " + arg.getRowCount());
+ continue;
+ }
+
+ operands.add((StoreTuples)arg.clone());
+
+ // test for tuples compatibility
+ if (vars == null) vars = arg.getVariables();
+ else if (!Arrays.equals(vars, arg.getVariables())) {
+ throw new IllegalArgumentException("Incompatible arguments to appendCompatible");
+ }
+
+ }
+
+ if (logger.isDebugEnabled()) logger.debug("Operands after compatible-append-unification: " + operands);
+
+ if (operands.isEmpty()) {
+ if (logger.isDebugEnabled()) logger.debug("Returning empty from append.");
+ return empty();
+ }
+
+ if (operands.size() == 1) {
+ if (logger.isDebugEnabled()) logger.debug("Returning singleton from append.");
+ return operands.get(0);
+ }
+
+ StoreTuples result = new OrderedStoreAppend(operands.toArray(new StoreTuples[operands.size()]));
+ closeOperands(operands);
+ return result;
+ }
+
+
+ /**
* Convenience method for doing a binary {@link #join(List)}.
* @param lhs The first argument to be joined.
* @param rhs The second argument to be joined.
Modified: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/WrappedTuples.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/WrappedTuples.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/WrappedTuples.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -328,7 +328,7 @@
/**
* Copied from AbstractTuples.
*/
- public Annotation getAnnotation(Class<?> annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: branches/xa11/src/jar/util/java/org/mulgara/util/StackTrace.java
===================================================================
--- branches/xa11/src/jar/util/java/org/mulgara/util/StackTrace.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/util/java/org/mulgara/util/StackTrace.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -108,4 +108,24 @@
t.printStackTrace(new PrintWriter(strWriter));
return strWriter.toString();
}
+
+ /**
+ * Gets the base of the cause chain.
+ * @param t The Throwable to get the cause from.
+ * @return The base of the cause chain for the throwable.
+ */
+ public static Throwable getReason(Throwable t) {
+ while (t.getCause() != null) t = t.getCause();
+ return t;
+ }
+
+ /**
+ * Gets the message from the base cause for a Throwable.
+ * @param t The throwable to get the base of the cause chain for.
+ * @return The message from the base case.
+ */
+ public static String getReasonMessage(Throwable t) {
+ return getReason(t).getMessage();
+ }
+
}
Modified: branches/xa11/src/jar/util/java/org/mulgara/util/functional/C.java
===================================================================
--- branches/xa11/src/jar/util/java/org/mulgara/util/functional/C.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/util/java/org/mulgara/util/functional/C.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -181,4 +181,28 @@
return arg.isEmpty() ? null : arg.get(arg.size() - 1);
}
+ /**
+ * Returns the first item from a Collection. This is a simple wrapper for {@link LinkedList#getFirst()}
+ * @param <T1> The element type.
+ * @param arg The list.
+ * @return The first element in the list.
+ * @throws NoSuchElementException If the list is empty.
+ */
+ public static <T1> T1 first(LinkedList<T1> arg) throws NoSuchElementException {
+ return arg.getFirst();
+ }
+
+ /**
+ * Returns the first item from an Iterable.
+ * @param <T1> The element type.
+ * @param arg The iterable collection.
+ * @return The first element in the collection.
+ * @throws NoSuchElementException If the collection is empty.
+ */
+ public static <T1> T1 first(Collection<T1> arg) throws NoSuchElementException {
+ if (arg instanceof LinkedList) return ((LinkedList<T1>)arg).getFirst();
+ if (arg.isEmpty()) throw new NoSuchElementException("Empty Collection");
+ return arg.iterator().next();
+ }
+
}
Modified: branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
===================================================================
--- branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -79,6 +79,12 @@
/** The structure for sending the page back to the client. */
HttpServletResponse response;
+ /** The absolute file path of the template header, with the root set to the resource directory. */
+ final String templateHeadFile;
+
+ /** The absolute file path of the template footer, with the root set to the resource directory. */
+ final String templateTailFile;
+
/** A map of tags to the values that should replace them. */
Map<String,String> tagMap;
@@ -105,10 +111,12 @@
* @param tagMap A map of tags to the values that should replace them
*/
@SuppressWarnings("unchecked")
- public QueryResponsePage(HttpServletRequest req, HttpServletResponse resp, Map<String,String> tagMap) {
+ public QueryResponsePage(HttpServletRequest req, HttpServletResponse resp, Map<String,String> tagMap, String headFile, String tailFile) {
this.request = req;
this.response = resp;
this.tagMap = tagMap;
+ this.templateHeadFile = headFile;
+ this.templateTailFile = tailFile;
this.unfinishedResults = (Map<Answer,Pair<Long,Command>>)req.getSession().getAttribute(UNFINISHED_RESULTS);
}
@@ -140,7 +148,7 @@
response.setHeader("pragma", "no-cache");
PrintWriter output = getOutput();
// write the head of the page
- new ResourceTextFile(TEMPLATE_HEAD, tagMap).sendTo(output);
+ new ResourceTextFile(templateHeadFile, tagMap).sendTo(output);
// summarise the results first
writeResultSummary(time, results.size());
@@ -154,7 +162,7 @@
if (r.hasNext()) response.sendError(SC_INTERNAL_SERVER_ERROR, "Internal error: results do not match queries.");
// write the tail of the page
- new ResourceTextFile(TEMPLATE_TAIL).sendTo(output);
+ new ResourceTextFile(templateTailFile).sendTo(output);
output.close();
}
Modified: branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
===================================================================
--- branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryServlet.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/web/java/org/mulgara/webquery/QueryServlet.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -19,14 +19,18 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.mail.BodyPart;
+import javax.mail.MessagingException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -36,11 +40,17 @@
import org.mulgara.connection.SessionConnection;
import org.mulgara.itql.TqlInterpreter;
import org.mulgara.parser.Interpreter;
+import org.mulgara.parser.MulgaraLexerException;
import org.mulgara.parser.MulgaraParserException;
+import org.mulgara.protocol.http.MimeMultiNamedPart;
+import org.mulgara.protocol.http.ServletDataSource;
import org.mulgara.query.Answer;
+import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.query.TuplesException;
import org.mulgara.query.operation.Command;
+import org.mulgara.query.operation.CreateGraph;
+import org.mulgara.query.operation.Load;
import org.mulgara.server.AbstractServer;
import org.mulgara.server.SessionFactory;
import org.mulgara.sparql.SparqlInterpreter;
@@ -80,6 +90,12 @@
/** Session value for the SPARQL interpreter. */
private static final String SPARQL_INTERPRETER = "session.sparql.interpreter";
+ /** Posted RDF data content type. */
+ protected static final String POSTED_DATA_TYPE = "multipart/form-data;";
+
+ /** A made-up scheme for data uploaded through http-put, since http means "downloaded". */
+ protected static final String HTTP_PUT_NS = "http-put://upload/";
+
/** The name of the host for the application. */
private final String hostname;
@@ -90,12 +106,12 @@
private final AbstractServer server;
/** The default graph URI to use. */
- private final String defaultGraphUri;
+ private String defaultGraphUri;
/** Session factory for accessing the database. */
private SessionFactory cachedSessionFactory;
- /** The path down to the TEMPLATE resource. */
+ /** The path down to the template resource. */
private String templatePath;
/** The path prefix for resources. */
@@ -114,8 +130,8 @@
this.servername = servername;
this.cachedSessionFactory = null;
this.server = server;
- URL path = getClass().getClassLoader().getResource(ResourceFile.RESOURCES + TEMPLATE);
- if (path == null) throw new IOException("Resource not found: " + ResourceFile.RESOURCES + TEMPLATE);
+ URL path = getClass().getClassLoader().getResource(ResourceFile.RESOURCES + getTemplateFile());
+ if (path == null) throw new IOException("Resource not found: " + ResourceFile.RESOURCES + getTemplateFile());
templatePath = path.toString();
resourcePath = templatePath.split("!")[0];
defaultGraphUri = "rmi://" + hostname + "/" + servername + "#sampledata";
@@ -168,7 +184,9 @@
resp.sendError(SC_BAD_REQUEST, "Sent a command to the wrong page.");
return;
}
-
+
+ String type = req.getContentType();
+ if (type != null && type.startsWith(POSTED_DATA_TYPE)) handleDataUpload(req, resp);
doQuery(req, resp, req.getParameter(GRAPH_ARG));
}
@@ -189,7 +207,7 @@
*/
private void outputStandardTemplate(HttpServletResponse resp) throws IOException {
PrintWriter out = resp.getWriter();
- new ResourceTextFile(TEMPLATE, getTemplateTags()).sendTo(out);
+ new ResourceTextFile(getTemplateFile(), getTemplateTags()).sendTo(out);
out.close();
}
@@ -227,19 +245,30 @@
} catch (MulgaraParserException mpe) {
resp.sendError(SC_BAD_REQUEST, "Error parsing command: " + mpe.getMessage());
return;
+ } catch (RequestException re) {
+ resp.sendError(SC_BAD_REQUEST, "Error processing request: " + re.getMessage());
+ return;
} catch (IllegalStateException ise) {
resp.sendError(SC_SERVICE_UNAVAILABLE, ise.getMessage());
return;
} catch (Exception e) {
- resp.sendError(SC_BAD_REQUEST, "Error executing command: " + StackTrace.throwableToString(e));
+ resp.sendError(SC_BAD_REQUEST, "Error executing command. Reason: " + StackTrace.getReasonMessage(e));
return;
}
+ // Use the first graph mentioned as the future default
+ for (Command c: cmds) {
+ if (c instanceof Query) {
+ updateDefaultGraph(c);
+ break;
+ }
+ }
+
// Get the tags to use in the page template
Map<String,String> templateTags = getTemplateTagMap();
templateTags.put(GRAPH_TAG, defaultGraph(graphUri));
// Generate the page
- QueryResponsePage page = new QueryResponsePage(req, resp, templateTags);
+ QueryResponsePage page = new QueryResponsePage(req, resp, templateTags, getTemplateHeaderFile(), getTemplateTailFile());
page.writeResults(time, cmds, results);
}
@@ -276,12 +305,131 @@
templateTags.put(GRAPH_TAG, defaultGraph(req.getParameter(GRAPH_ARG)));
// Generate the page
- QueryResponsePage page = new QueryResponsePage(req, resp, templateTags);
+ QueryResponsePage page = new QueryResponsePage(req, resp, templateTags, getTemplateHeaderFile(), getTemplateTailFile());
page.writeResult(unfinishedResults.get(remaining).second(), remaining);
}
/**
+ * Do the work of extracting data to be uploaded, and put it in the requested graph. Create the graph if needed.
+ * @param req The HTTP request containing the file.
+ * @param resp The response back to the submitting client.
+ * @throws IOException Due to an error reading the input stream, or writing to the response stream.
+ */
+ private void handleDataUpload(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ try {
+ // parse in the data to be uploaded
+ MimeMultiNamedPart mime = new MimeMultiNamedPart(new ServletDataSource(req, UPLOAD_GRAPH_ARG));
+
+ // validate the request
+ if (mime.getCount() == 0) throw new RequestException("Request claims to have posted data, but none was supplied.");
+
+ long time = System.currentTimeMillis();
+
+ // Get the destination graph, and ensure it exists
+ URI destGraph = getRequestedGraph(req, mime);
+ Connection conn = getConnection(req);
+ try {
+ new CreateGraph(destGraph).execute(conn);
+ } catch (QueryException e) {
+ throw new RequestException("Unable to create graph: " + e.getMessage());
+ }
+
+ // upload the data
+ Command loadCommand = null;
+ for (int partNr = 0; partNr < mime.getCount(); partNr++) {
+ BodyPart part = mime.getBodyPart(partNr);
+ String partName = mime.getPartName(partNr);
+ try {
+ if (UPLOAD_FILE_ARG.equalsIgnoreCase(partName)) {
+ loadCommand = loadData(destGraph, part, conn);
+ break;
+ }
+ } catch (QueryException e) {
+ throw new RequestException("Unable to load data: " + partName);
+ }
+ }
+
+ time = System.currentTimeMillis() - time;
+
+ // Get the tags to use in the page template
+ Map<String,String> templateTags = getTemplateTagMap();
+ templateTags.put(GRAPH_TAG, defaultGraph(destGraph.toString()));
+
+ // Generate the page
+ QueryResponsePage page = new QueryResponsePage(req, resp, templateTags, getTemplateHeaderFile(), getTemplateTailFile());
+ page.writeResults(time, Collections.singletonList(loadCommand), Collections.singletonList((Object)""));
+
+ } catch (MessagingException e) {
+ resp.sendError(SC_BAD_REQUEST, "Unable to process received MIME data: " + e.getMessage());
+ } catch (RequestException re) {
+ resp.sendError(SC_BAD_REQUEST, re.getMessage());
+ }
+ }
+
+
+ /**
+ * Gets the graph parameter from the MIME data.
+ * @param req The request object from the user.
+ * @return The URI for the requested graph.
+ * @throws RequestException If a graph name was an invalid URI or was not present in the request.
+ */
+ protected URI getRequestedGraph(HttpServletRequest req, MimeMultiNamedPart mime) throws RequestException {
+ // look in the parameters
+ String[] graphArgs = req.getParameterValues(UPLOAD_GRAPH_ARG);
+ if (graphArgs != null) {
+ if (graphArgs.length != 1) throw new RequestException("Multiple graphs requested.");
+ try {
+ return new URI(graphArgs[0]);
+ } catch (URISyntaxException e) {
+ throw new RequestException("Invalid URI for upload graph. " + e.getInput());
+ }
+ }
+ // look in the mime data
+ if (mime != null) {
+ try {
+ String result = mime.getParameterString(UPLOAD_GRAPH_ARG);
+ if (result != null) {
+ try {
+ return new URI(result);
+ } catch (URISyntaxException e) {
+ throw new RequestException("Invalid URI for upload graph <" + e.getInput() + ">: " + result);
+ }
+ }
+ } catch (Exception e) {
+ throw new RequestException("Bad MIME data in upload request: " + e.getMessage());
+ }
+ }
+ throw new RequestException("No graph argument provided.");
+ }
+
+
+ /**
+ * Load MIME data into a graph.
+ * @param graph The graph to load into.
+ * @param data The data to be loaded, with associated meta-data.
+ * @param cxt The connection to the database.
+ * @return The Command that did the loading.
+ * @throws IOException error reading from the client.
+ * @throws RequestException Bad data passed to the load request.
+ * @throws QueryException A query exception occurred during the load operation.
+ */
+ protected Load loadData(URI graph, BodyPart data, Connection cxt) throws RequestException, IOException, QueryException {
+ try {
+ URI absoluteUri = new URI(HTTP_PUT_NS + data.getFileName());
+ Load loadCmd = new Load(absoluteUri, graph, true);
+ loadCmd.setOverrideInputStream(data.getInputStream());
+ loadCmd.execute(cxt);
+ return loadCmd;
+ } catch (MessagingException e) {
+ throw new RequestException("Unable to process data for loading: " + e.getMessage());
+ } catch (URISyntaxException e) {
+ throw new RequestException("Illegal filename: " + e.getInput());
+ }
+ }
+
+
+ /**
* Close all but one answer.
* @param answers The answers to close.
* @param ordinal The ordinal (1-based) of the answer to NOT close.
@@ -417,6 +565,16 @@
/**
+ * Updates the default graph URI to one found in a Query.
+ * @param cmd A Command that contains a query.
+ */
+ private void updateDefaultGraph(Command cmd) {
+ assert cmd instanceof Query;
+ Set<URI> graphs = ((Query)cmd).getModelExpression().getGraphURIs();
+ if (!graphs.isEmpty()) defaultGraphUri = C.first(graphs).toString();
+ }
+
+ /**
* Creates the default graph name for the sample data.
* @param The graph name that the user has already set.
* @return The default graph name to use when no graph has been set.
@@ -480,7 +638,7 @@
factory = new Fn<Interpreter>(){ public Interpreter fn(){ return new SparqlInterpreter(); }};
attr = SPARQL_INTERPRETER;
} else {
- factory = new Fn<Interpreter>(){ public Interpreter fn() { return new TqlInterpreter(); }};
+ factory = new Fn<Interpreter>(){ public Interpreter fn() { return new TerminatingTqlInterpreter(); }};
attr = TQL_INTERPRETER;
}
return new RegInterpreter(factory, attr);
@@ -523,16 +681,57 @@
/**
+ * Get the name of the file to be used for the template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateFile() {
+ return TEMPLATE;
+ }
+
+
+ /**
+ * Get the name of the file to be used for the header template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateHeaderFile() {
+ return TEMPLATE_HEAD;
+ }
+
+
+ /**
+ * Get the name of the file to be used for the footer template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateTailFile() {
+ return TEMPLATE_TAIL;
+ }
+
+
+ /**
+ * Compare a parameter name to a set of known parameter names used for uploading.
+ * @param name The name to check.
+ * @return <code>true</code> if the name is known. <code>false</code> if not known or <code>null</code>.
+ */
+ @SuppressWarnings("unused")
+ private boolean knownUploadParam(String name) {
+ final String[] knownParams = new String[] { UPLOAD_GRAPH_ARG };
+ for (String p: knownParams) if (p.equalsIgnoreCase(name)) return true;
+ return false;
+ }
+
+
+ /**
* Returns the filename extension for a given path.
* @param path The path to get the extension for.
* @return The extension, including the . character. If there is no extension, then an empty string.
*/
- private String getExtension(String path) {
+ private static String getExtension(String path) {
int dot = path.lastIndexOf('.');
if (dot < 0) return "";
return path.substring(dot);
}
+
/**
* Registerable Interpreter. This contains a factory for an interpreter, plus the name it should
* be registered under.
@@ -560,4 +759,26 @@
return regString;
}
}
+
+
+ /**
+ * Extension of TQL interpreter that will automatically terminate any
+ * commands that are not already terminated.
+ */
+ private static class TerminatingTqlInterpreter extends TqlInterpreter {
+
+ /** The terminating character. */
+ private static final String TERMINATOR = ";";
+
+ /**
+ * Calls TqlInterpreter#parseCommands(String) with a guaranteed termination of ";".
+ * @see TqlInterpreter#parseCommands(String)
+ */
+ public List<Command> parseCommands(String command) throws MulgaraParserException, MulgaraLexerException, IOException {
+ command = command.trim();
+ if (!command.endsWith(TERMINATOR)) command += TERMINATOR;
+ return super.parseCommands(command);
+ }
+ }
+
}
Modified: branches/xa11/src/jar/web/java/org/mulgara/webquery/Template.java
===================================================================
--- branches/xa11/src/jar/web/java/org/mulgara/webquery/Template.java 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/web/java/org/mulgara/webquery/Template.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -76,6 +76,12 @@
/** The ResultOrdinal argument for URL parameters. */
public static final String RESULT_ORD_ARG = "ResultOrdinal";
+ /** The URI of a graph to be uploaded into. */
+ public static final String UPLOAD_GRAPH_ARG = "UploadGraph";
+
+ /** The path of a file to be uploaded. */
+ public static final String UPLOAD_FILE_ARG = "UploadFile";
+
/** A label out of the CSS file. That file could be structurally generated, but for no good reason. */
public static final String CSS_LARGE = "styleLarge";
Copied: branches/xa11/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java (from rev 1423, trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java)
===================================================================
--- branches/xa11/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java (rev 0)
+++ branches/xa11/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2008 Fedora Commons, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.mulgara.webquery;
+
+import java.io.IOException;
+
+import org.mulgara.server.AbstractServer;
+
+/**
+ * A tutorial Web UI for the server. This is almost the same as the standard
+ * WebUI, but includes a series of selectable commands.
+ *
+ * @created Dec 4, 2008
+ * @author Paul Gearon
+ */
+public class TutorialServlet extends QueryServlet {
+
+ /** Generated serialization ID. */
+ private static final long serialVersionUID = 1959974464706199835L;
+
+ /** The name of the template HTML file. */
+ public static final String TUTORIAL = "/tutorial.html";
+
+ /** The name of the HTML file containing the head of a result. */
+ public static final String TUTORIAL_HEAD = "/tutorial_head.html";
+
+ /** The name of the HTML file containing the tail of a result. Same as the standard template. */
+ public static final String TUTORIAL_TAIL = "/template_tail.html";
+
+ /**
+ * Creates the tutorial servlet.
+ * @param hostname
+ * @param servername
+ * @param server
+ * @throws IOException
+ */
+ public TutorialServlet(String hostname, String servername, AbstractServer server) throws IOException {
+ super(hostname, servername, server);
+ }
+
+
+ /**
+ * Provide a description for the servlet.
+ * @see javax.servlet.GenericServlet#getServletInfo()
+ */
+ public String getServletInfo() {
+ return "Mulgara Query Tutorial";
+ }
+
+
+ /**
+ * Get the name of the file to be used for the tutorial template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateFile() {
+ return TUTORIAL;
+ }
+
+
+ /**
+ * Get the name of the file to be used for the tutorial header template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateHeaderFile() {
+ return TUTORIAL_HEAD;
+ }
+
+
+ /**
+ * Get the name of the file to be used for the tutorial footer template.
+ * @return The absolute file path, with a root set at the resource directory.
+ */
+ protected String getTemplateTailFile() {
+ return TUTORIAL_TAIL;
+ }
+
+}
Modified: branches/xa11/src/jar/web/resources/template.html
===================================================================
--- branches/xa11/src/jar/web/resources/template.html 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/web/resources/template.html 2009-01-10 08:23:29 UTC (rev 1427)
@@ -9,23 +9,6 @@
<link href="styles/ui.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--
- // Put the selected example query into the query text area. The graph
- // name is also inserted in to the query.
- function setQuery() {
- // Must have a Graph URI
- if (document.QueryForm.GraphURI.value == '') {
- alert('Please enter a Graph URI and then select the query again');
- document.QueryForm.GraphURI.focus;
- return;
- }
- var index = document.QueryForm.ExampleQuery.selectedIndex;
- var exampleText = document.QueryForm.ExampleQuery[index].value;
- var graphURI= document.QueryForm.GraphURI.value;
- // Add the graph name
- var queryString = exampleText.replace(/-graph-/gi, graphURI);
- document.QueryForm.QueryText.value = queryString;
- }
-
// Validate the form and submit it if all is OK
function validateAndSubmit() {
// Is there a query?
@@ -40,6 +23,23 @@
return true;
}
}
+ function uploadFile() {
+ if (document.QueryForm.GraphURI.value == null ||
+ document.QueryForm.GraphURI.value == "") {
+ alert('Please enter a Graph URI to upload into.');
+ document.QueryForm.GraphURI.focus();
+ return false;
+ }
+ if (document.UploadForm.UploadFile.value == null ||
+ document.UploadForm.UploadFile.value == "") {
+ alert('Please select a file to upload to the Graph.');
+ document.UploadForm.UploadFile.focus();
+ return false;
+ }
+ document.UploadForm.UploadGraph.value = document.QueryForm.GraphURI.value;
+ document.UploadForm.submit();
+ return true;
+ }
//-->
</script>
</head>
@@ -54,41 +54,38 @@
<table class="formatTable" summary="">
<tr>
<td>
- <form action="@@execute@@" method="post" name="QueryForm">
- <table class="queryTable" summary="Enter a query">
+ <table class="queryTable" summary="Enter a query">
+ <form action="@@execute@@" method="post" name="QueryForm">
<tr>
<td><strong>Graph URI:</strong> </td>
- <td><input name="GraphURI" size="60" type="text" value="rmi://@@hostname@@/@@servername@@#sampledata"> </td>
+ <td><input name="GraphURI" size="60" type="text" value=""/> </td>
</tr>
<tr>
- <td><strong>Example Queries:</strong> </td>
- <td>
- <select name="ExampleQuery" onchange="javascript:setQuery()">
- <option selected value="">Select a query..</option>
- <option value="create <-graph->;">Step 1. Create a graph</option>
- <option value="load <@@jarurl@@!/data/w3c-news.rss> into <-graph->;">Step 2. Load RSS data into the graph</option>
- <option value="select $subject $predicate $object from <-graph-> where $subject $predicate $object;">Step 3. List everything in the graph</option>
- <option value="select $title $link $description from <-graph-> where $article <http://purl.org/rss/1.0/title> $title and $article <http://purl.org/rss/1.0/link> $link and $article <http://purl.org/rss/1.0/description> $description;">Step 4. List the news articles</option>
- <option value="create <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 5. Create a standalone RDF schema graph</option>
- <option value="load <@@jarurl@@!/data/rss-1.0.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/dc.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/rdfs.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 6. Load in the referenced schemas</option>
- <option value="select $rdfSubject $rdfProperty $value from <-graph-> or <rmi://@@hostname@@/@@servername@@#rdfs> where $rdfSubject $rdfProperty $value and $rdfProperty <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> and $rdfProperty <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://purl.org/rss/1.0/>;">Step 7. List the RSS properties using both graphs</option>
- <option value="drop <-graph->; drop <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 8. Drop the graphs</option>
- </select>
- </td>
- </tr>
- <tr>
<td><strong>Query Text:</strong> </td>
<td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
</tr>
<tr>
<td> </td>
<td align="left">
- <input type="button" value="Submit Query" onclick="validateAndSubmit()">
- <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';">
+ <input type="button" value="Submit Query" onclick="validateAndSubmit()"/>
+ <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';"/>
</td>
</tr>
- </table>
- </form>
+ <tr>
+ <td colspan="2"> </td>
+ </tr>
+ </form>
+ <form enctype='multipart/form-data' action="@@execute@@" method="post" name="UploadForm">
+ <tr>
+ <td><strong>File:</strong> </td>
+ <td>
+ <input type="hidden" name="UploadGraph" value=""/>
+ <input type="file" name="UploadFile" size="60" value=""/>
+ <input type="button" value="Upload" onclick="uploadFile()"/>
+ </td>
+ </tr>
+ </form>
+ </table>
</td>
</tr>
</table>
Modified: branches/xa11/src/jar/web/resources/template_head.html
===================================================================
--- branches/xa11/src/jar/web/resources/template_head.html 2009-01-10 08:10:37 UTC (rev 1426)
+++ branches/xa11/src/jar/web/resources/template_head.html 2009-01-10 08:23:29 UTC (rev 1427)
@@ -9,23 +9,6 @@
<link href="styles/ui.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--
- // Put the selected example query into the query text area. The graph
- // name is also inserted in to the query.
- function setQuery() {
- // Must have a Graph URI
- if (document.QueryForm.GraphURI.value == '') {
- alert('Please enter a Graph URI and then select the query again');
- document.QueryForm.GraphURI.focus;
- return;
- }
- var index = document.QueryForm.ExampleQuery.selectedIndex;
- var exampleText = document.QueryForm.ExampleQuery[index].value;
- var graphURI= document.QueryForm.GraphURI.value;
- // Add the graph name
- var queryString = exampleText.replace(/-graph-/gi, graphURI);
- document.QueryForm.QueryText.value = queryString;
- }
-
// Validate the form and submit it if all is OK
function validateAndSubmit() {
// Is there a query?
@@ -40,6 +23,23 @@
return true;
}
}
+ function uploadFile() {
+ if (document.QueryForm.GraphURI.value == null ||
+ document.QueryForm.GraphURI.value == "") {
+ alert('Please enter a Graph URI to upload into.');
+ document.QueryForm.GraphURI.focus();
+ return false;
+ }
+ if (document.UploadForm.UploadFile.value == null ||
+ document.UploadForm.UploadFile.value == "") {
+ alert('Please select a file to upload to the Graph.');
+ document.UploadForm.UploadFile.focus();
+ return false;
+ }
+ document.UploadForm.UploadGraph.value = document.QueryForm.GraphURI.value;
+ document.UploadForm.submit();
+ return true;
+ }
//-->
</script>
</head>
@@ -54,41 +54,35 @@
<table class="formatTable" summary="">
<tr>
<td>
- <form action="@@execute@@.html" method="post" name="QueryForm">
- <table class="queryTable" summary="Enter a query">
+ <table class="queryTable" summary="Enter a query">
+ <form action="@@execute@@.html" method="post" name="QueryForm">
<tr>
<td><strong>Graph URI:</strong> </td>
- <td><input name="GraphURI" size="60" type="text" value="@@graph@@"> </td>
+ <td><input name="GraphURI" size="60" type="text" value="@@graph@@"/> </td>
</tr>
<tr>
- <td><strong>Example Queries:</strong> </td>
- <td>
- <select name="ExampleQuery" onchange="javascript:setQuery()">
- <option selected value="">Select a query..</option>
- <option value="create <-graph->;">Step 1. Create a graph</option>
- <option value="load <@@jarurl@@!/data/w3c-news.rss> into <-graph->;">Step 2. Load RSS data into the graph</option>
- <option value="select $subject $predicate $object from <-graph-> where $subject $predicate $object;">Step 3. List everything in the graph</option>
- <option value="select $title $link $description from <-graph-> where $article <http://purl.org/rss/1.0/title> $title and $article <http://purl.org/rss/1.0/link> $link and $article <http://purl.org/rss/1.0/description> $description;">Step 4. List the news articles</option>
- <option value="create <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 5. Create a standalone RDF schema graph</option>
- <option value="load <@@jarurl@@!/data/rss-1.0.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/dc.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/rdfs.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 6. Load in the referenced schemas</option>
- <option value="select $rdfSubject $rdfProperty $value from <-graph-> or <rmi://@@hostname@@/@@servername@@#rdfs> where $rdfSubject $rdfProperty $value and $rdfProperty <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> and $rdfProperty <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://purl.org/rss/1.0/>;">Step 7. List the RSS properties using both graphs</option>
- <option value="drop <-graph->; drop <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 8. Drop the graphs</option>
- </select>
- </td>
- </tr>
- <tr>
<td><strong>Query Text:</strong> </td>
<td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
</tr>
<tr>
<td> </td>
<td align="left">
- <input type="button" value="Submit Query" onclick="validateAndSubmit()">
- <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';">
+ <input type="button" value="Submit Query" onclick="validateAndSubmit()"/>
+ <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';"/>
</td>
</tr>
- </table>
- </form>
+ </form>
+ <form enctype='multipart/form-data' action="@@execute@@" method="post" name="UploadForm">
+ <tr>
+ <td><strong>File:</strong> </td>
+ <td>
+ <input type="hidden" name="UploadGraph" value=""/>
+ <input type="file" name="UploadFile" size="60" value=""/>
+ <input type="button" value="Upload" onclick="uploadFile()"/>
+ </td>
+ </tr>
+ </form>
+ </table>
</td>
</tr>
<tr>
Copied: branches/xa11/src/jar/web/resources/tutorial.html (from rev 1423, trunk/src/jar/web/resources/tutorial.html)
===================================================================
--- branches/xa11/src/jar/web/resources/tutorial.html (rev 0)
+++ branches/xa11/src/jar/web/resources/tutorial.html 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+@@debug@@
+-->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Mulgara Tutorial</title>
+ <link href="styles/ui.css" rel="stylesheet" type="text/css" />
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ // Put the selected example query into the query text area. The graph
+ // name is also inserted in to the query.
+ function setQuery() {
+ // Must have a Graph URI
+ if (document.QueryForm.GraphURI.value == '') {
+ alert('Please enter a Graph URI and then select the query again');
+ document.QueryForm.GraphURI.focus;
+ return;
+ }
+ var index = document.QueryForm.ExampleQuery.selectedIndex;
+ var exampleText = document.QueryForm.ExampleQuery[index].value;
+ var graphURI= document.QueryForm.GraphURI.value;
+ // Add the graph name
+ var queryString = exampleText.replace(/-graph-/gi, graphURI);
+ document.QueryForm.QueryText.value = queryString;
+ }
+
+ // Validate the form and submit it if all is OK
+ function validateAndSubmit() {
+ // Is there a query?
+ if (document.QueryForm.QueryText.value == null ||
+ document.QueryForm.QueryText.value == "") {
+ alert('Please enter a query');
+ document.QueryForm.QueryText.focus();
+ return false;
+ } else {
+ // Submit the form
+ document.QueryForm.submit();
+ return true;
+ }
+ }
+ //-->
+ </script>
+</head>
+<body>
+ <div id="wrapper">
+ <div id="header">
+ <div id="logo">
+ <a href="http://mulgara.org/"><img src="images/logo.jpg" alt="Mulgara - Semantic Store" border="0" /></a>
+ </div>
+ </div>
+ <div id="content">
+ <table class="formatTable" summary="">
+ <tr>
+ <td>
+ <form action="@@execute@@" method="post" name="QueryForm">
+ <table class="queryTable" summary="Enter a query">
+ <tr>
+ <td><strong>Graph URI:</strong> </td>
+ <td><input name="GraphURI" size="60" type="text" value="rmi://@@hostname@@/@@servername@@#sampledata"/> </td>
+ </tr>
+ <tr>
+ <td><strong>Example Queries:</strong> </td>
+ <td>
+ <select name="ExampleQuery" onchange="javascript:setQuery()">
+ <option selected value="">Select a query..</option>
+ <option value="create <-graph->;">Step 1. Create a graph</option>
+ <option value="load <@@jarurl@@!/data/w3c-news.rss> into <-graph->;">Step 2. Load RSS data into the graph</option>
+ <option value="select $subject $predicate $object from <-graph-> where $subject $predicate $object;">Step 3. List everything in the graph</option>
+ <option value="select $title $link $description from <-graph-> where $article <http://purl.org/rss/1.0/title> $title and $article <http://purl.org/rss/1.0/link> $link and $article <http://purl.org/rss/1.0/description> $description;">Step 4. List the news articles</option>
+ <option value="create <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 5. Create a standalone RDF schema graph</option>
+ <option value="load <@@jarurl@@!/data/rss-1.0.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/dc.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/rdfs.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 6. Load in the referenced schemas</option>
+ <option value="select $rdfSubject $rdfProperty $value from <-graph-> or <rmi://@@hostname@@/@@servername@@#rdfs> where $rdfSubject $rdfProperty $value and $rdfProperty <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> and $rdfProperty <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://purl.org/rss/1.0/>;">Step 7. List the RSS properties using both graphs</option>
+ <option value="drop <-graph->; drop <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 8. Drop the graphs</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><strong>Query Text:</strong> </td>
+ <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td align="left">
+ <input type="button" value="Submit Query" onclick="validateAndSubmit()"/>
+ <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+</body>
+</html>
Copied: branches/xa11/src/jar/web/resources/tutorial_head.html (from rev 1423, trunk/src/jar/web/resources/tutorial_head.html)
===================================================================
--- branches/xa11/src/jar/web/resources/tutorial_head.html (rev 0)
+++ branches/xa11/src/jar/web/resources/tutorial_head.html 2009-01-10 08:23:29 UTC (rev 1427)
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+@@debug@@
+-->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Mulgara Tutorial</title>
+ <link href="styles/ui.css" rel="stylesheet" type="text/css" />
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ // Put the selected example query into the query text area. The graph
+ // name is also inserted in to the query.
+ function setQuery() {
+ // Must have a Graph URI
+ if (document.QueryForm.GraphURI.value == '') {
+ alert('Please enter a Graph URI and then select the query again');
+ document.QueryForm.GraphURI.focus;
+ return;
+ }
+ var index = document.QueryForm.ExampleQuery.selectedIndex;
+ var exampleText = document.QueryForm.ExampleQuery[index].value;
+ var graphURI= document.QueryForm.GraphURI.value;
+ // Add the graph name
+ var queryString = exampleText.replace(/-graph-/gi, graphURI);
+ document.QueryForm.QueryText.value = queryString;
+ }
+
+ // Validate the form and submit it if all is OK
+ function validateAndSubmit() {
+ // Is there a query?
+ if (document.QueryForm.QueryText.value == null ||
+ document.QueryForm.QueryText.value == "") {
+ alert('Please enter a query');
+ document.QueryForm.QueryText.focus();
+ return false;
+ } else {
+ // Submit the form
+ document.QueryForm.submit();
+ return true;
+ }
+ }
+ //-->
+ </script>
+</head>
+<body>
+ <div id="wrapper">
+ <div id="header">
+ <div id="logo">
+ <a href="http://mulgara.org/"><img src="images/logo.jpg" alt="Mulgara - Semantic Store" border="0" /></a>
+ </div>
+ </div>
+ <div id="content">
+ <table class="formatTable" summary="">
+ <tr>
+ <td>
+ <form action="@@execute@@.html" method="post" name="QueryForm">
+ <table class="queryTable" summary="Enter a query">
+ <tr>
+ <td><strong>Graph URI:</strong> </td>
+ <td><input name="GraphURI" size="60" type="text" value="@@graph@@"/> </td>
+ </tr>
+ <tr>
+ <td><strong>Example Queries:</strong> </td>
+ <td>
+ <select name="ExampleQuery" onchange="javascript:setQuery()">
+ <option selected value="">Select a query..</option>
+ <option value="create <-graph->;">Step 1. Create a graph</option>
+ <option value="load <@@jarurl@@!/data/w3c-news.rss> into <-graph->;">Step 2. Load RSS data into the graph</option>
+ <option value="select $subject $predicate $object from <-graph-> where $subject $predicate $object;">Step 3. List everything in the graph</option>
+ <option value="select $title $link $description from <-graph-> where $article <http://purl.org/rss/1.0/title> $title and $article <http://purl.org/rss/1.0/link> $link and $article <http://purl.org/rss/1.0/description> $description;">Step 4. List the news articles</option>
+ <option value="create <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 5. Create a standalone RDF schema graph</option>
+ <option value="load <@@jarurl@@!/data/rss-1.0.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/dc.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>; load <@@jarurl@@!/data/rdfs.rdfs> into <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 6. Load in the referenced schemas</option>
+ <option value="select $rdfSubject $rdfProperty $value from <-graph-> or <rmi://@@hostname@@/@@servername@@#rdfs> where $rdfSubject $rdfProperty $value and $rdfProperty <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> and $rdfProperty <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://purl.org/rss/1.0/>;">Step 7. List the RSS properties using both graphs</option>
+ <option value="drop <-graph->; drop <rmi://@@hostname@@/@@servername@@#rdfs>;">Step 8. Drop the graphs</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><strong>Query Text:</strong> </td>
+ <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td align="left">
+ <input type="button" value="Submit Query" onclick="validateAndSubmit()"/>
+ <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="allResultsTable" border="0" cellpadding="5" width="100%">
More information about the Mulgara-svn
mailing list