I am updating to the latest version of neo4j 3.0.1. However, the Traversal pathExpanderForAllTypes method is deprecated and I got errors. I couldn't find the equivalent method which can be used with 3.0.1.
import org.neo4j.kernel.Traversal;
PathExpander<Object> expander = Traversal.pathExpanderForAllTypes(Reldir);
If you look to a previous version Javadoc about neo4j, you will see that this method, along with most of the class has been deprecated.
But you can also see that there are some hints in the code in order to overcome this issue:
Returns a org.neo4j.graphdb.PathExpander which expands relationships
of all types in the given direction.
Deprecated: See
org.neo4j.graphdb.PathExpanders.forDirection(org.neo4j.graphdb.Direction)
Returns: a path expander which expands all relationships in the given
direction.
360
361 #Deprecated
362 #SuppressWarnings( "unchecked" )
363 public static <STATE> PathExpander<STATE> More ...pathExpanderForAllTypes( Direction direction )
364 {
365 return StandardExpander.create( direction );
366 }
So I reccommend you to check the method: org.neo4j.graphdb.PathExpanders.forDirection(Direction) , or one of the others provided by the PathExpanders class.
Related
The Cypher generated by spring data neo4j uses "$" to pass value, which will cause a error of Invalid Syntax by neo4j.
For example:
The Cypher generated by spring data neo4j for:
Optional<linkType> findById(Long id);
is
"MATCH ()-[r0:`linkType`]->() WHERE ID(r0)=$id WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)"
This gets a error of Invalid Syntax.
I fixed this by use #Query:
#Query("MATCH ()-[r0:`linkType`]->() WHERE ID(r0)={id} WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)")
Optional<linkType> findById(Long id);
However, when I want to use the PagingAndSortingRepository, I cannot use the #Query to fix this problem. Because it will add SKIP $sdnSkip LIMIT $sdnLimit at the edn automaticaly.
How can I fix this problem? Thanks.
You are using a really old version of neo4j (older than 3.0).
In neo4j 3.0, the {foo} syntax was deprecated in favor of the $foo syntax. In neo4j 4.0, the {foo} syntax was totally removed.
Instead of trying to support the obsolete {foo} syntax, you should upgrade your neo4j installation to a more recent (ideally, the latest) version of neo4j. If you have data to upgrade, you will have to upgrade in 2 steps:
From your current version to 3.5.
From 3.5 to 4.x.
I've been trying to get Jung 2.1.1 to work successfully but whatever breaking changes were made are just not making sense.
After importing the 2.1.1 jars, I get the error:
The constructor VisualizationViewer(Network, LayoutAlgorithm, Dimension) is undefined
for the line:
VisualizationViewer vv = new
VisualizationViewer(g, layoutAlgorithm, new Dimension(900, 900));
where
Network g = NetworkBuilder.undirected().build(); // and other load steps
There are other imports that aren't working, like
import edu.uci.ics.jung.visualization.decorators.PickableNodePaintFunction;
import edu.uci.ics.jung.visualization.layout.LayoutAlgorithmTransition;
Edit: It appears the classes in the Jung 2.1.1 JAR still use the old definitions, for example
VisualizationViewer(Layout<V,E>,Dimension)
and not
VisualizationViewer(Network<N,E>,Dimension,Dimension)
This question was answered in https://github.com/jrtom/jung/issues/201
The short version is that you should not be cloning the HEAD version on the JUNG website; that's the 3.0 version in development, which is not yet ready for release, and is incompatible with 2.1.1. Use the 2.1.1 version explicitly for both the jars and the samples.
I decided to return to Dropwizard after a very long affair with Spring. I quickly got the absolute barebones REST service built, and it runs without any problems.
Using Dropwizard 0.7.1 and Java 1.8, only POM entries are the dropwizard-core dependency and the maven compiler plugin to enforce Java 1.8, as recommended by the Dropwizard user manual
However, as soon as I try to add an Optional QueryParam to the basic controller, the application fails to start with the following error (cut for brevity):
INFO [2015-01-03 17:44:58,059] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET / (edge.dw.sample.controllers.IndexController)
ERROR [2015-01-03 17:44:58,158] com.sun.jersey.spi.inject.Errors: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public java.lang.String edge.dw.sample.controllers.IndexController.index(java.util.Optional) at parameter at index 0
Exception in thread "main" javax.servlet.ServletException: com.sun.jersey.spi.container.servlet.ServletContainer-6c2ed0cd#330103b7==com.sun.jersey.spi.container.servlet.ServletContainer,1,false
The code for the controller is as follows:
#Path("/")
public class IndexController {
#GET
#Timed
public String index(#QueryParam("name") Optional<String> name) {
String saying = "Hi";
if(name != null && name.isPresent()) {
saying += " " + name.get();
}
return saying;
}
}
If I remove Optional from the mix, the application runs just fine. I replace the Optional-specific code with null checks and it works perfectly.
Am I missing something fundamental here? Both Google Guava Optional and java.util.Optional fail with the same error. (And yes, I did narrow it down to the Optional object)
A quick Google/SO search yielded nothing useful, but feel free to point me to a resource I may have missed
Thanks in advance!
Moments after posting this, I found that the issue was my use of Java 1.8. If using Java 1.8, I have to add the Java8Bundle to my app:
POM Entry:
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-java8</artifactId>
<version>0.7.0-1</version>
</dependency>
And code in the Application class:
#Override
public void initialize(Bootstrap<SampleConfiguration> bootstrap) {
bootstrap.addBundle(new Java8Bundle());
}
See: https://github.com/dropwizard/dropwizard-java8
This enables both Google Guava Optional and java.util.Optional to work just fine.
If I revert to Java 1.7 and use the Google Guava Optional, it works just fine as well and I don't have to include the Java8Bundle. I'll opt for the Java8Bundle for now, though, as using Java8 features is lucrative for me :)
Cheers!
i'm running into a compilation issue, using grails 2.4.0.M1 and spring-security-core:2.0-RC2
this is the error:
..../target/work/plugins/spring-security-core-2.0-RC2/src/groovy/grails/plugin/springsecurity/ReflectionUtils.groovy:
205: Apparent variable 'org' was found in a static scope but doesn't
refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance
variable from a static context. You misspelled a classname or
statically imported field. Please check the spelling. You attempted
to use a method 'org' but left out brackets in a place not allowed by
the grammar. # line 205, column 18.
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
^
the problem seems to be around this method
private static GrailsApplication getApplication() {
if (!application) {
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
}
application
}
on the class ReflectionUtils.groovy,
does anyone else as ran into something like this? if so how do you fixed it?
I fixed this today - https://github.com/grails-plugins/grails-spring-security-core/commit/ef3aab05bfb0eb2f2cbb2c5945f4fc9ca2f0697d
You can make the change that #Bubuntux showed as a temporary workaround, and I'll be releasing 2.0 final in a couple of weeks with this fixed. Hopefully you're not planning on using a Grails M1 release in production, so the delay shouldn't be too much of an issue.
Seems like the ApplicationHolder class was deprecated a long time ago, and now removed on grals 2.4
so i just change the line
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
to
application = Holders.grailsApplication
Can I use Xpath node set function position() in Delphi's function selectNodes() to select only a certain number of element from a node list? If I do like this:
selectNodes('Item[1]')
its all fine and I get the element with index 1, but when I try
selectNodes('Item[position()<10]')
I get exception 'unknown method', when I try
selectNodes('Item[<10]')
I get 'unexpected token <'.
Im using delphi7 and I also imported new type library into my project with newer versions of msxml.
This is not really a Delphi question I think, but an MSXML one. Check the MSXML docs or rather the MS XPath docs.
Hmm, according to the XPath examples posted on MSDN "Item[position() < 10]" should have worked, at least if "Item" is the name of the element you're after...
selectNodes requires a string, so you should try:
selectNodes('Item[position()<10]')
Or whatever xpath query.
Could it be a version-issue? I have imported typelibrary from MS XML 6, and gets no error.