I'm trying to query a GraphDB repository on a server from java code where I'm using Jena. According to the GraphDB documentation (http://graphdb.ontotext.com/free/using-graphdb-with-jena.html#installing-graphdb-with-jena), it's possible to instatiate a model using Jena SesameDataset as follow :
import com.ontotext.jena.SesameDataset;
// Some code goes here...
SesameDataset dataset = new SesameDataset(repositoryConnection);
Model model =
ModelFactory.createModelForGraph(dataset.getDefaultGraph());
I'm looking for the "Jena SesameDataSet" library from a couple of days without success.
Do you know where I can find it (maven or jar file) ? Or do you know any mean of instantiating a jena Model that is backed by a GraphDB repository on a server (whose URL can be something like http://localhost:7200/repositories/TestRepo) ?
Related
I'm currently trying to figure out how to "connect" an Xtext Language Server with an EMFCloud.ModelServer instance so each time a client (VS Code extension in my case) saves a custom DSL text file, the Language Server saves the AST as XMI (or JSON). So then later the model can be included in the Model Server workspace and other editors can react to changes on my model (XMI, JSON)
So far I've seen that the current Xtext LS version does nothing with the "textDocument/didSave" notifications:
#Override
public void didSave(DidSaveTextDocumentParams params) {
// nothing to do
}
I'd like to enhance my LS instance to provide logic to that method and persist the current AST to XMI/JSON.
So far I was able to see that there is a generator class which the doGenerate method is called when the save is triggered on client side. However, taking a look to the call hierarchy of that method, it seems that is called within a "code generation" process. The documentation found for this is always related to other language generation (i.e. Java or c++) and I'm not sure if this would be the right place also because it seems that the file URI is not accessible (as it is in the didSave method of the LS part)
As summary, is there a way to access the semantic model (AST) from the Language Server "didSave" operation?
Following the hints provided by Christian Dietrich, the Language Server uses a ProjectManager which is able to retrieve the XtextResource holding the semantic model for a specific model URI (i.e. the URI passed to the server from the editor). Basically:
XtextResource resource = (XtextResource) getWorkspaceManager().getProjectManager(uri).getResource(uri);
In order to get our model from the resource the following method is provided:
EList<EObject> modelObjects = resource.getContents();
At this point we can persist the semantic model via the EMF Model Server (i.e. by creating or modifying an existing model in the Model Server).
There is some Odata lib which I can use that from edmx file it generate an
odata service?
By providing only edmx file it create the service that can answer the metadata calls...
I've found this library
https://github.com/htammen/n-odata-server
But it requires json not edmx/metadata.xml file...
I see the Olingo lib but I didn't find any functionality that can do it ...
https://olingo.apache.org
Any direction if it possible?
I prefer to use some nodejs lib if there is some combination that could work, but its not mandatory
I've also find this lib
https://github.com/jaystack/jaysvcutil
If you are happy to use .Net, you could try RESTier. Follow the instructions here: http://odata.github.io/RESTier/, except don't generate a new EF data model class. Instead add your edmx model into the project.
Then go to the section 'Configure the OData Endpoint', and rather than entering:
await config.MapRestierRoute<EntityFrameworkApi<AdventureWorksLT>>(
"AdventureWorksLT",
"api/AdventureWorksLT",
new RestierBatchHandler(GlobalConfiguration.DefaultServer));
use your data model class (the class that inherits DbContext) rather than AdventureWorksLT in
EntityFrameworkApi<AdventureWorksLT>
, and change the route name and prefix to something more suitable.
There is a maven plugin from SAP:
<plugin>
<groupId>com.sap.cloud.sdk.datamodel</groupId>
<artifactId>odata-generator-maven-plugin</artifactId>
<version>3.52.0</version>
...
See documentation here https://sap.github.io/cloud-sdk/docs/java/features/odata/generate-typed-odata-v2-and-v4-client-for-java
My use case is:
I have an existing JTA TransactionManager and a Transaction in-flight. I'd like to enlist Neo4j as an XAResource in this Transaction such that it may prepare/commit in proper 2PC.
I'm not seeing a public XAResource implementation in Neo4j; everything seems to be routed through the NioNeoDbPersistenceSource > NeoStoreXaDataSource > NeoStoreXaConnection.NeoStoreXaResource.
Is there a preferred way to enlist Neo4j in JTA Transactions outside those provided by its own TransactionManager? All the test cases I'm finding enlist mock "FakeXAResource"[1]
Appreciated!
S,
ALR
[1] e.g. UseJOTMAsTxManagerIT
OK, I have a solution which I believe is the best that Neo4j can handle, though I'm not thrilled with it. :)
https://gist.github.com/ALRubinger/b584065d0e7da251469a
The idea is this:
1) Implement Neo4j's AbstractTransactionManager
This clunky class is a composite of JTA TransactionManager, Neo4j Lifecycle, and some other methods; it's not completely clear to me what some of these (e.g. "getEventIdentifier()" or "doRecovery()") are supposed to, and the contract feels over-specified. I'm not certain why we'd want lifecycle methods in here for the case where Neo4j is not the authoritative owner of the TransactionManager.
2) Implement Neo4j's TransactionManagerProvider
This will let you create a new instance of your AbstractTransactionManager implementation, but it's bound by the JDK Service SPI, so you must supply a no-arg constructor and find some other intelligent/hacky way of passing contextual information in.
3) Create a META-INF/services/org.neo4j.kernel.impl.transaction.TransactionManagerProvider file, with contents of the FQN of your TransactionManagerProvider impl from step 2)
4) When you create a new GraphDatabaseService, pass in config like:
final GraphDatabaseService graphDatabaseService = new GraphDatabaseFactory().
newEmbeddedDatabaseBuilder(FILE_NAME_STORAGE).setConfig(
GraphDatabaseSettings.tx_manager_impl.name(),
"NAME_OF_YOUR_TXM_PROVIDER")
.newGraphDatabase();
Then you access the TransactionManager using a deprecated API (GraphDatabaseAPI):
// Get at Neo4j's view of the TransactionManager
final TransactionManager tm = ((GraphDatabaseAPI) graphDatabaseService).getDependencyResolver().resolveDependency(TransactionManager.class);
tm.begin();
final Transaction tx = tm.getTransaction();
The real problem I have with this approach is that we have to use the TransactionManager implementation from Neo4j, which is wrapping our real TM. What I want to do is use my TM and enlist Neo4j as an XAResource.
So I still haven't found a way to do that, and judging from the Neo4j test suites I don't think it's possible at the moment with any of their supplied XAResource support.
Absolutely willing and hoping to be corrected! :)
But failing the points I mention above, the attached gist works and shows Neo4j using an external TransactionManager (Narayana, from us at JBoss) as the backing implementation.
S,
ALR
I'm trying to write a Rexster extension in Java that among other things queries nodes using Neo4j 2.0 Lucene indices.
From the few threads I was able to find (mostly old Google Group threads), it doesn't seem to be possible using Blueprint's Graph.
I thought about a possible solution where I access the underlying Neo4jGraph class from the extension's:
#RexsterContext Graph graph
parameter, but I'm not sure how to do this.
The end-goal ideally, would be to use an automatic get-or-create-index method which could be called with a piece of text on a Lucene index.
Any ideas ?
Thank you in advance!
I think you said the answer here:
I thought about a possible solution where I access the underlying
Neo4jGraph class from the extension's:
#RexsterContext Graph graph
If you need methods from Blueprints Neo4jGraph then just cast Graph to that:
Neo4jGraph neo4j = (Neo4jGraph) neo4j;
Furthermore, if you need to work with specific, native Neo4j classes/methods then just do:
GraphDatabaseService graphdb = neo4j.getRawGraph()
Obviously both of these approaches makes your Rexster Extension Neo4j specific but it sounds like that is ok for your case.
I'm working with a (.net4 / mvc3 ) solution file downloaded (from a reputable source) where a connection string exists in web.config but I don't see explicit instructions to create the database and there's no included '.mdf'. The first time I build I got a runtime error regarding lack of permissions to CREATE database. So I created a blank db and made sure the string referenced a SQL user that had .dbo/owner rights to the db just created.
But subsequent builds don't seem to execute that same initialize db script - where ever that's stored.
Where is this 'first use' convention for creating databases documented?
thx
That is a feature of Entity Framework Code First. I am not sure what you are looking for exactly, but searching for "EF Code First Initialization Strategy" might help.
For instance read this article: EF Code First DB Initialization Using Web.Config
I assume you are talking about Entity Framework, which allows you to create the database from an instance of an ObjectContext object, which is used in any of the three approaches in EF (database-, model- and code-first).
Look for a line that actually calls ObjectContext.CreateDatabase(). If one of the supported ADO.NET provides is used (SQL Server or SQL Server CE 4.0) this will generate the required SQL Statements. Assuming the classic Northwind example, you might find something like that:
NorthwindContext context = new NorthwindContext();
if (!context.DatabaseExists())
{
context.CreateDatabase();
}
If this is in fact a code-first application, "lalibi" is right about the initialization strategy which by default doesn't require you to explicitly create the database. (But my guess is, that it actually uses a statement internally very similar to mine).