{"action":"created","issue":{"url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/44","repository_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher","labels_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/44/comments","events_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/44/events","html_url":"https://github.com/Wolfgang-Schuetzelhofer/jcypher/issues/44","id":356613355,"node_id":"MDU6SXNzdWUzNTY2MTMzNTU=","number":44,"title":"Is it possible to retrieve relationship types from collection?","user":{"login":"DonCziken","id":36049985,"node_id":"MDQ6VXNlcjM2MDQ5OTg1","avatar_url":"https://avatars2.githubusercontent.com/u/36049985?v=4","gravatar_id":"","url":"https://api.github.com/users/DonCziken","html_url":"https://github.com/DonCziken","followers_url":"https://api.github.com/users/DonCziken/followers","following_url":"https://api.github.com/users/DonCziken/following{/other_user}","gists_url":"https://api.github.com/users/DonCziken/gists{/gist_id}","starred_url":"https://api.github.com/users/DonCziken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DonCziken/subscriptions","organizations_url":"https://api.github.com/users/DonCziken/orgs","repos_url":"https://api.github.com/users/DonCziken/repos","events_url":"https://api.github.com/users/DonCziken/events{/privacy}","received_events_url":"https://api.github.com/users/DonCziken/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-03T23:34:33Z","updated_at":"2018-09-05T13:36:09Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi Wolfgang,\r\n\r\nsay I'd like to do following:\r\n\r\n```\r\n        JcPath p;\r\n        [..]\r\n        WHERE.valueOf(p.relations().head().type()).EQUALS(\"someType\")\r\n```\r\n\r\nbut the problem is that `p.relations().head()` returns `ValueElement `which I can't find a way to convert to `Relation` using available API. Another example of such a case maybe following:\r\n\r\n```\r\nMATCH.node(n0).label(\"JcTestPerson\")\r\n                .relation(r0).out().minHops(0)\r\n                .node(n1),\r\n            RETURN.value(n0.name)\r\n            RETURN.value((r[i - 1].asCollection().head().type()).as(new JcString(\"type\"))\r\n            RETURN.value(n1.name)\r\n```\r\n\r\nso Question to you Wolfgang - is it possible to retrieve type from relation picked from JcCollection? If so how can I do that?  Just FYI in mean time I had prepared a workaround for above doing following, but its very dirty :)\r\n\r\n```\r\npublic class JcStringExtension {\r\n\r\n    public static JcString create(Object val, ValueElement predecessor, IOperatorOrFunction opf) {\r\n        try {\r\n            Constructor<?> constructor  = JcString.class.getDeclaredConstructor(Object.class,\r\n                ValueElement.class, IOperatorOrFunction.class);\r\n            constructor.setAccessible(true);\r\n            return (JcString) constructor.newInstance(val, predecessor, opf);\r\n        } catch (NoSuchMethodException | InstantiationException\r\n            | IllegalAccessException | InvocationTargetException e) {\r\n            EigenLog.errorLog(e.getMessage());\r\n            throw new DomainApiException(\"Internal error - please check logs\");\r\n        }\r\n    }\r\n\r\n}\r\n\r\npublic class FunctionInstanceExtension {\r\n\r\n    public static FunctionInstance create(Function function, int numArgs) {\r\n\r\n        try {\r\n            Constructor<?> constructor = FunctionInstance.class\r\n                .getDeclaredConstructor(Function.class,\r\n                    int.class);\r\n            constructor.setAccessible(true);\r\n            return (FunctionInstance) constructor.newInstance(function, numArgs);\r\n        } catch (NoSuchMethodException | InstantiationException\r\n            | IllegalAccessException | InvocationTargetException e) {\r\n            EigenLog.errorLog(e.getMessage());\r\n            throw new DomainApiException(\"Internal error - please check logs\");\r\n        }\r\n    }\r\n\r\n}\r\n\r\n\r\n//usage:\r\n    @SuppressWarnings(\"unchecked\")\r\n    private JcString typeOfValueElement(ValueElement v) {\r\n        return JcStringExtension.create(null, v,\r\n            FunctionInstanceExtension.create(FUNCTION.Relation.TYPE, 1));\r\n    }\r\n\r\nRETURN.value(typeOfValueElement((r[i - 1].asCollection().head())))\r\n                .AS(r[i - 1])\r\n\r\n```\r\n\r\ncheers,\r\nKrzysztof"},"comment":{"url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/comments/418733026","html_url":"https://github.com/Wolfgang-Schuetzelhofer/jcypher/issues/44#issuecomment-418733026","issue_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/44","id":418733026,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODczMzAyNg==","user":{"login":"DonCziken","id":36049985,"node_id":"MDQ6VXNlcjM2MDQ5OTg1","avatar_url":"https://avatars2.githubusercontent.com/u/36049985?v=4","gravatar_id":"","url":"https://api.github.com/users/DonCziken","html_url":"https://github.com/DonCziken","followers_url":"https://api.github.com/users/DonCziken/followers","following_url":"https://api.github.com/users/DonCziken/following{/other_user}","gists_url":"https://api.github.com/users/DonCziken/gists{/gist_id}","starred_url":"https://api.github.com/users/DonCziken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DonCziken/subscriptions","organizations_url":"https://api.github.com/users/DonCziken/orgs","repos_url":"https://api.github.com/users/DonCziken/repos","events_url":"https://api.github.com/users/DonCziken/events{/privacy}","received_events_url":"https://api.github.com/users/DonCziken/received_events","type":"User","site_admin":false},"created_at":"2018-09-05T13:36:09Z","updated_at":"2018-09-05T13:36:09Z","author_association":"CONTRIBUTOR","body":"Hi Wolfgang,\r\n\r\nthanks for reply, its good to know that it is possible to combine Query DSL with NATIVE.cypher this would help in such cases :).\r\n\r\nLet me know when you got a fix for that within DSL, and for the moment I i will stick with my dirty hack using JcStringExtension and FunctionInstanceExtension.\r\n\r\ncheers,\r\nKrzysztof"}}
{"actor":{"display_login":"DonCziken"}}