Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Spring Social Neo4j

  1. #11
    Join Date
    Jul 2012
    Posts
    10

    Default

    The authentication works and I am back on the track for SSN. Was not as hard as i expected.

    I basically do the same stuff, as you did with the JDBC conncetor:
    Code:
    ExecutionResult results = engine.execute("start user=node:User(uuid={" + userId + "}) match user-[:HAS_SOCIAL_CONNECTION]->connection return connection");
    I need to map the results to List<Connection<?>> resultList. But I dunno what exactly I have to do, because you use a RowMapper helper class.

    How does the List look like?

    Code:
    results.columns() // returns List<String>
    I think it should not be hard to convert that list into List<Connection<?>>, is it?

  2. #12
    Join Date
    Aug 2004
    Posts
    1,099

    Default

    Are you implementing the findAllConnections() method here? That's what it looks like based on the Cypher query you're using.

    I'll admit that I'm less familiar with the Java-native Neo4j API, but it appears that ExecutionResult.columns() returns a list of String where each value is the *name* of the so-called column (column seems like a poor choice of words here, but that's what they call it) in the result set. That's probably not what you want. Instead, you probably want to call iterator() to get a Map<String,Object> of result objects for each match in the Cypher query. From that Map<String,Object> you pull values and use them to create a Connection object that you add to a List<Connection<?>>.
    Craig Walls
    Spring Social Project Lead

  3. #13
    Join Date
    Jul 2012
    Posts
    10

    Default

    Quote Originally Posted by habuma View Post
    Are you implementing the findAllConnections() method here? That's what it looks like based on the Cypher query you're using.

    I'll admit that I'm less familiar with the Java-native Neo4j API, but it appears that ExecutionResult.columns() returns a list of String where each value is the *name* of the so-called column (column seems like a poor choice of words here, but that's what they call it) in the result set. That's probably not what you want. Instead, you probably want to call iterator() to get a Map<String,Object> of result objects for each match in the Cypher query. From that Map<String,Object> you pull values and use them to create a Connection object that you add to a List<Connection<?>>.
    Yep, it is the findAllConnections() method. Thanks for the guidance, I will try it out

  4. #14
    Join Date
    Jul 2012
    Posts
    10

    Question

    The findAllConnections method is working, but I think by resultList's structure differs from the JDBC query list's structure. I do not really know what to do about that. My resultList is a type of LinkedList. I do not really know how to create something like a JDBCqueryList so that I do not get the following error message:

    javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'facebook.displayName' for locale 'de_DE'.

    I think my result list should be something like a associative array, but I did not find a solution in the web yet. Maybe it is just a simple type of some list, that I do not know yet...?

    Code:
    	private Connection<?> mapEntry(ConnectionData connectionData) {
    		ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId());
    		return connectionFactory.createConnection(connectionData);
    	}
    	
    	private ConnectionData mapConnectionData(Node node) {
    		return new ConnectionData((String) node.getProperty("providerId"),
    				(String) node.getProperty("providerUserId"),
    				(String) node.getProperty("displayName"), 
    				(String) node.getProperty("profileUrl"),
    				(String) node.getProperty("imageUrl"),
    				decrypt((String) node.getProperty("accessToken")),
    				decrypt((String) node.getProperty("secret")),
    				decrypt((String) node.getProperty("refreshToken")),
    				expireTime((Long) node.getProperty("expireTime")));
    	}
    	
    	private List<Connection<?>> createResultList(ExecutionResult er) {
    		List<Connection<?>> resultList = new LinkedList<Connection<?>>();
    		Iterator<Node> userConnections = er.columnAs("connection");
    		while (userConnections.hasNext()) {
    			Node userConnectionNode = userConnections.next();
    			resultList.add(mapEntry(mapConnectionData(userConnectionNode)));
    		}
    		return resultList;
    	}

  5. #15
    Join Date
    Oct 2011
    Location
    London, UK
    Posts
    27

    Default

    Hi

    I saw this thread and thought that a test harness I wrote for UsersConnectionRepository implementations may be useful to you in testing your implementation.

    I reworked the existing JdbcUsersConnectionRepositoryTest from spring-social-core into an abstract test class which can be subclassed for specific implementations of UsersConnectionRepository. The abstract test is available here:

    https://github.com/michaellavelle/sp...itoryTest.java

    A subclass which tests the JdbcUsersConnectionRepository (essentially a refactor of the original JdbcUsersConnectionRepositoryTest which uses this superclass ) is available here:

    https://github.com/michaellavelle/sp...itoryTest.java

    and a version for my RooUsersConnectionRepository implementation:

    https://github.com/michaellavelle/sp...itoryTest.java

    I thought that if you had the time to create your own subclass for Neo4JUsersConnectionRepository this may help you in testing your project.

    Hope this helps,

    Michael
    Michael

  6. #16
    Join Date
    Aug 2004
    Posts
    1,099

    Default

    Thanks for sharing that. Yes, I can see how that might be useful for testing other implementations of UsersConnectionRepository.
    Craig Walls
    Spring Social Project Lead

  7. #17
    Join Date
    Jul 2012
    Posts
    10

    Default

    Thanks Michael, it does look nice, but I think I might have not enough time to focus on that. I should get this thing running, but I am still struggling with basics.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •