Skip to content

Commit 958de67

Browse files
committed
Add deepOrder field to Character that presents orders through root Character as a string
1 parent 087d64e commit 958de67

File tree

1 file changed

+79
-69
lines changed

1 file changed

+79
-69
lines changed

schema.graphql

Lines changed: 79 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ type Character {
9999
name: String
100100
definition: String
101101
order: String
102+
deepOrder: String @cypher(
103+
statement: """
104+
MATCH path = (this)-[:CHARACTER_OF*0..]->(root:Character)
105+
WITH nodes(path) AS ns
106+
ORDER BY length(path) DESC
107+
LIMIT 1
108+
WITH [n IN reverse(ns) | n.order] AS orders
109+
RETURN apoc.text.join(orders, ".")
110+
"""
111+
)
102112
characterOf: Characterable! @cypher(
103113
statement: "match (this)-[:CHARACTER_OF]->(n) return n limit 1"
104114
)
@@ -148,7 +158,7 @@ type PreservationMode {
148158
"""Note: schema should be non null, but isn't right now due to missing data"""
149159
type Description {
150160
pbotID: ID!
151-
name: String
161+
name: String
152162
writtenDescription: String
153163
notes: String
154164
characterInstances: [CharacterInstance!]! @relation(name: "DEFINED_BY", direction: OUT)
@@ -188,17 +198,17 @@ type PseudoDescription {
188198

189199
type OTU {
190200
pbotID: ID!
191-
name: String
201+
name: String
192202
authority: String
193203
diagnosis: String
194204
qualityIndex: String
195205
majorTaxonGroup: String
196206
pbdbParentTaxon: String
197-
family: String
198-
genus: String
199-
pfnGenusLink: String
200-
species: String
201-
pfnSpeciesLink: String
207+
family: String
208+
genus: String
209+
pfnGenusLink: String
210+
species: String
211+
pfnSpeciesLink: String
202212
additionalClades: String
203213
identifiedSpecimens: [IdentifiedSpecimenOf!]!
204214
typeSpecimens: [TypeSpecimenOf!]!
@@ -239,7 +249,7 @@ type OTU {
239249

240250
type Synonym {
241251
pbotID: ID!
242-
explanation: String
252+
explanation: String
243253
comments: [Comment!] @relation(name: "REFERS_TO", direction: IN)
244254
references: [SynonymCitedBy]
245255
otus: [OTU!]! @relation(name: "SAME_AS", direction: IN)
@@ -635,20 +645,20 @@ input GroupInput {
635645
purpose: String
636646
members: [String]
637647
elements: [String]
638-
groups: [String]
648+
groups: [String]
639649
enteredByPersonID: String
640650
}
641651

642652
input PersonInput {
643653
pbotID: String
644654
given: String
645655
middle: String
646-
surname: String
647-
email: String
648-
orcid: String
656+
surname: String
657+
email: String
658+
orcid: String
649659
reason: String
650660
bio: String
651-
enteredByPersonID: String
661+
enteredByPersonID: String
652662
}
653663

654664
input AuthoredBy {
@@ -659,7 +669,7 @@ input AuthoredBy {
659669
input ReferenceInput {
660670
pbotID: String
661671
title: String
662-
year: String
672+
year: String
663673
publicationType: String
664674
firstPage: String
665675
lastPage: String
@@ -672,11 +682,11 @@ input ReferenceInput {
672682
bookType: String
673683
editors: String
674684
notes: String
675-
doi: String
685+
doi: String
676686
pbdbid: String
677-
authors: [AuthoredBy!]!
678-
groups: [String]
679-
enteredByPersonID: String
687+
authors: [AuthoredBy!]!
688+
groups: [String]
689+
enteredByPersonID: String
680690
}
681691

682692
input CitedByInput {
@@ -687,16 +697,16 @@ input CitedByInput {
687697
input SchemaInput {
688698
pbotID: String
689699
title: String!
690-
year: String
700+
year: String
691701
acknowledgments: String
692702
purpose: String!
693703
partsPreservedIDs: [String!]!
694704
notableFeaturesIDs: [String]
695-
references: [CitedByInput!]!
696-
authors: [AuthoredBy]
697-
groups: [String]
698-
enteredByPersonID: String
699-
cascade: Boolean
705+
references: [CitedByInput!]!
706+
authors: [AuthoredBy]
707+
groups: [String]
708+
enteredByPersonID: String
709+
cascade: Boolean
700710
}
701711

702712
input CharacterInput {
@@ -706,8 +716,8 @@ input CharacterInput {
706716
order: String
707717
parentID: String
708718
schemaID: String
709-
enteredByPersonID: String
710-
cascade: Boolean
719+
enteredByPersonID: String
720+
cascade: Boolean
711721
}
712722

713723
input StateInput {
@@ -717,21 +727,21 @@ input StateInput {
717727
order: String
718728
parentID: String
719729
schemaID: String
720-
enteredByPersonID: String
721-
cascade: Boolean
730+
enteredByPersonID: String
731+
cascade: Boolean
722732
}
723733

724734
input DescriptionInput {
725735
pbotID: String
726736
specimenIDs: [String]
727-
name: String!
737+
name: String!
728738
writtenDescription: String
729739
notes: String
730-
schemaID: String!
740+
schemaID: String!
731741
references: [CitedByInput]
732-
groups: [String]
733-
enteredByPersonID: String
734-
cascade: Boolean
742+
groups: [String]
743+
enteredByPersonID: String
744+
cascade: Boolean
735745
}
736746

737747
input CharacterInstanceInput {
@@ -741,40 +751,40 @@ input CharacterInstanceInput {
741751
stateID: String!
742752
quantity: String
743753
order: String
744-
enteredByPersonID: String
754+
enteredByPersonID: String
745755
}
746756

747757
input OTUInput {
748758
pbotID: String
749-
name: String!
759+
name: String!
750760
authority: String!
751761
diagnosis: String!
752762
qualityIndex: String!
753763
majorTaxonGroup: String!
754764
pbdbParentTaxon: String!
755-
family: String
756-
genus: String
757-
pfnGenusLink: String
758-
species: String
759-
pfnSpeciesLink: String
765+
family: String
766+
genus: String
767+
pfnGenusLink: String
768+
species: String
769+
pfnSpeciesLink: String
760770
additionalClades: String
761771
identifiedSpecimens: [String]
762772
typeSpecimens: [String]
763773
holotypeSpecimen: String
764774
synonyms: [String]
765-
references: [CitedByInput!]!
775+
references: [CitedByInput!]!
766776
partsPreservedIDs: [String!]!
767777
notableFeaturesIDs: [String]
768778
notes: String
769-
groups: [String!]!
779+
groups: [String!]!
770780
}
771781

772782
input SynonymInput {
773783
pbotID: String
774-
explanation: String
784+
explanation: String
775785
references: [CitedByInput]
776786
otus: [String!]!
777-
groups: [String]
787+
groups: [String]
778788
}
779789

780790
input CommentInput {
@@ -816,9 +826,9 @@ input SpecimenInput {
816826
references: [CitedByInput]
817827
collection: String!
818828
uploadImages: [ImageUpload]
819-
groups: [String]
820-
enteredByPersonID: String
821-
cascade: Boolean
829+
groups: [String]
830+
enteredByPersonID: String
831+
cascade: Boolean
822832
}
823833

824834
input ImageInput {
@@ -829,26 +839,26 @@ input ImageInput {
829839
citation: String
830840
caption: String
831841
type: String
832-
groups: [String]
842+
groups: [String]
833843
imageOf: String
834844
}
835845

836846
input OrganInput {
837847
pbotID: String
838848
type: String!
839-
enteredByPersonID: String
849+
enteredByPersonID: String
840850
}
841851

842852
input FeatureInput {
843853
pbotID: String
844854
name: String!
845-
enteredByPersonID: String
855+
enteredByPersonID: String
846856
}
847857

848858
input PreservationModeInput {
849859
pbotID: String
850860
name: String!
851-
enteredByPersonID: String
861+
enteredByPersonID: String
852862
}
853863

854864
"""Note: location is required, but it shown optional here for api consistency. This is caught in resolver."""
@@ -893,10 +903,10 @@ input CollectionInput {
893903
country: String!
894904
state: String
895905
pbdbid: String
896-
references: [CitedByInput]
897-
groups: [String]
906+
references: [CitedByInput]
907+
groups: [String]
898908
enteredByPersonID: String
899-
cascade: Boolean
909+
cascade: Boolean
900910
}
901911

902912
type File {
@@ -960,21 +970,21 @@ type Mutation {
960970
statement: """
961971
MATCH
962972
(description:Description {pbotID: $data.descriptionID}),
963-
(description)-[:ELEMENT_OF]->(group:Group),
973+
(description)-[:ELEMENT_OF]->(group:Group),
964974
(character:Character {pbotID: $data.characterID})<-[:CHARACTER_OF*0..]-()<-[:STATE_OF*1..]-(state:State {pbotID: $data.stateID}),
965975
(person:Person {pbotID: $data.enteredByPersonID})
966-
WITH
967-
collect(group) AS groups, description, character, state, person
976+
WITH
977+
collect(group) AS groups, description, character, state, person
968978
CREATE
969979
(description)-[:DEFINED_BY]->(characterInstance:CharacterInstance {
970980
pbotID: apoc.create.uuid()
971981
})-[:ENTERED_BY {timestamp: datetime(), type:"CREATE"}]->(person),
972982
(character)<-[:INSTANCE_OF]-(characterInstance),
973983
(state)<-[:HAS_STATE {value: $data.quantity, order: $data.order}]-(characterInstance)
974-
WITH groups, characterInstance
975-
FOREACH (group IN groups |
976-
CREATE
977-
(characterInstance)-[:ELEMENT_OF]->(group)
984+
WITH groups, characterInstance
985+
FOREACH (group IN groups |
986+
CREATE
987+
(characterInstance)-[:ELEMENT_OF]->(group)
978988
)
979989
RETURN characterInstance
980990
"""
@@ -986,12 +996,12 @@ type Mutation {
986996
(characterInstance:CharacterInstance {pbotID: $data.pbotID}),
987997
(ePerson:Person {pbotID: $data.enteredByPersonID})
988998
WITH characterInstance, ePerson
989-
CREATE
990-
(characterInstance)-[eb:ENTERED_BY {timestamp: datetime(), type:"EDIT"}]->(ePerson)
991-
WITH characterInstance, eb
999+
CREATE
1000+
(characterInstance)-[eb:ENTERED_BY {timestamp: datetime(), type:"EDIT"}]->(ePerson)
1001+
WITH characterInstance, eb
9921002
OPTIONAL MATCH
993-
(oldCharacter:Character)<-[oldCharacterRelationship:INSTANCE_OF]-(characterInstance)
994-
DELETE oldCharacterRelationship
1003+
(oldCharacter:Character)<-[oldCharacterRelationship:INSTANCE_OF]-(characterInstance)
1004+
DELETE oldCharacterRelationship
9951005
WITH characterInstance, eb, oldCharacter
9961006
CALL apoc.do.case([
9971007
oldCharacter IS NULL AND $data.characterID IS NOT NULL,
@@ -1003,7 +1013,7 @@ type Mutation {
10031013
) YIELD value
10041014
WITH characterInstance, eb
10051015
OPTIONAL MATCH
1006-
(oldState:State)<-[oldStateRelationship:HAS_STATE]-(characterInstance)
1016+
(oldState:State)<-[oldStateRelationship:HAS_STATE]-(characterInstance)
10071017
WITH characterInstance, eb, oldState, oldStateRelationship
10081018
CALL apoc.do.case([
10091019
oldState IS NULL AND $data.stateID IS NOT NULL,
@@ -1014,8 +1024,8 @@ type Mutation {
10141024
{oldState: oldState, oldStateRelationship: oldStateRelationship, eb: eb}
10151025
) YIELD value
10161026
DELETE oldStateRelationship
1017-
WITH characterInstance
1018-
MATCH
1027+
WITH characterInstance
1028+
MATCH
10191029
(character:Character {pbotID: $data.characterID})<-[:CHARACTER_OF*0..]-()<-[:STATE_OF*1..]-(state:State {pbotID: $data.stateID})
10201030
CREATE
10211031
(character)<-[:INSTANCE_OF]-(characterInstance),

0 commit comments

Comments
 (0)