[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [External] [xdi] One change to multiplicity proposal
Some thoughts for our query language are below. These are taken from a comparison of two Neo4j graph query languages, Cypher and Gremlin, posted at
http://romikoderbynew.com/2012/02/22/gremlin-vs-cypher-initial-thoughts-neo4j/.
An example of Cypher var resultSet = graphClient.RootNode .StartCypher("root") .Match(@"root-[:HOSTS]->(agency) <-[:USER_BELONGS_TO]-(user)-[:USER_LINKED_TO_PROGRAM] ->(program) <-[:HAS_PROGRAM]-(centre), (program)<-[:HAS_SUGGESTED_PROGRAM]-(referralDecisionsSection) <-[:REFERRAL_HAS_DECISIONS_SECTION]-(referral)-[:CREATED_BY] ->(createdByUser), (referral)-[:REFERRAL_HAS_WHO_SECTION] ->(whoSection)-[:HAS_PARTICIPANT]->(participant)") .Where<Agency>(agency => agency.Key == userIdentifier.AgencyKey) .And() .Where<User>(user => user.Username == userIdentifier.Username) .And() .Where<Referral>(referral => referral.Completed == false) .Return((user, program, centre, createdByUser, referral, whoSection, participant) =>
new ReferralByGroup { UserFamilyName = createdByUser.As<User>().FamilyName, UserGivenName = createdByUser.As<User>().GivenName, Program = program.As<Program>().Name, Centre = centre.As<Centre>().Name, ReferralId = referral.As<Referral>().UniqueId, ReferralDate = whoSection.As<ReferralWhoSection>().ReferralDate, ParticipantName = participant.As<ReferralParticipant>().Name, ParticipantDisplayOrder = participant.As<ReferralParticipant>().DisplayOrder, }) .Results .ToArray(); An equivalent in Gremlin: var resultSet = graphClient .RootNode .Out<Agency>(Hosts.TypeKey, a => a.Key == userIdentifier.AgencyKey) .In<User>(UserBelongsTo.TypeKey, u => u.Username == userIdentifier.Username) .Out<Program>(UserLinkedToProgram.TypeKey) .As("Program") .In<Centre>(HasProgram.TypeKey) .As("Centre") .BackV<Program>("Program") .In<ReferralDecisionsSection>(HasSuggestedProgram.TypeKey) .In<Referral>(ReferralHasDecisionsSection.TypeKey, r => r.Completed == false) .As("ReferralId") .Out<User>(CreatedBy.TypeKey) .As("UserGivenName") .As("UserFamilyName") .BackV<Referral>("ReferralId") .Out<ReferralWhoSection>(ReferralHasWhoSection.TypeKey) .As("ReferralDate") .Out<ReferralParticipant>(HasParticipant.TypeKey) .As("ParticipantDisplayOrder") .As("ParticipantName") .Table <ReferralByGroup, Program, Centre, Referral, User, User, ReferralWhoSection, ReferralParticipant, ReferralParticipant>( program => program.Name, centre => centre.Name, referral => referral.UniqueId, user => user.FamilyName, user => user.GivenName, who => who.ReferralDate, participant => participant.Name, participant => participant.DisplayOrder ) .ToArray(); And I will try to post a follow-up email with an equivalent in XGP, XDI Graph Patterns, the query language I’ve been trying to put together as an underpinning
for applying DLP style reasoning to an XDI dataset, similar to what Euler# allows for semantic web queries. Kind regards, Bill Barnhill Booz Allen Hamilton - Belcamp,MD Cell: 1-443-924-0824
Desk: 1-443-861-9102 |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]