carnival-data / carnival

JVM property graph data unification framework
https://carnival-data.github.io/carnival/
GNU General Public License v3.0
7 stars 2 forks source link

Graph model harmonization #4

Closed augustearth closed 3 years ago

augustearth commented 4 years ago

Harmonize VertexDefTrait and EdgeDefTrait.

// having to call instance() is potentially non-intuitive

Pmbb.VX.PATIENT.instance().withProperties(Core.PX.NAME, 'Hayden').vertex(graph, g)

// doesn't matter
Pmbb.VX.PATIENT.withProperties(Core.PX.NAME, 'Hayden').create(graph, g)

// existing 0 or 1
Pmbb.VX.PATIENT.withProperties(Core.PX.NAME, 'Hayden').getOrCreate(graph, g)

// existing 1
Pmbb.VX.PATIENT.withProperties(Core.PX.NAME, 'Hayden').get(graph, g)

// maybe add find() that will return all pre-existing
// exists() returns true/false
// just have get() return the GraphTraversal tryNext() thing???
// get returns vertex or null?
// get returns an optional like thing?

Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.relate(pV, encV, g)
Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.instance().withProperties(Core.PX.THING, 'ada').from(pV).to(encV).create(graph, g)

Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.withProperties(Core.PX.THING, 'ada').from(pV).to(encV).create(graph, g)
Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.withProperties(Core.PX.THING, 'ada').from(pV).to(encV).getOrCreate(graph, g)
Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.withProperties(Core.PX.THING, 'ada').from(pV).to(encV).get(graph, g)

Pmbb.EX.PARTICIPATED_IN_ENCOUNTER.withProperties(Core.PX.THING, 'ada').create(pV, encV, graph, g)

Core.PX.NAME.of(pV).isPresent()
Core.PX.NAME.valueOf(pV)
augustearth commented 4 years ago

Propose the following:

// to create a vertex
Clinical.VX.PATIENT
    .withProperty(Core.PX.NAME, 'david')
    .create(graph, g)

// to get or create the existing singleton
Clinical.VX.PATIENT
    .withProperty(Core.PX.NAME, 'david'))
    .singleton()
    .get(graph, g)

// to get the existing singleton
// if it has not been created, return null
Clinical.VX.PATIENT
    .withProperty(Core.PX.NAME, 'david'))
    .singleton()
    .getExisting(graph, g)

// check if the singleton exists
Clinical.VX.PATIENT
    .withProperty(Core.PX.NAME, 'david'))
    .singleton()
    .exists(graph, g)
augustearth commented 3 years ago

This is done. Pretty sure.