private static void AddTaxonTrait(G g, Vertex taxonVertex, int traitVertexLabel, int edgeLabel, string traitCode, string traitName) { if (!g.TryGetV(traitCode, out var traitVertex)) { traitVertex = g.AddV(traitVertexLabel, traitCode).AddP(P.Name, traitName); } taxonVertex.AddE(edgeLabel, traitVertex); }
private static void LinkNatureAreaIds(G g, Vertex vertex, List <int> natureAreaIds) { if (natureAreaIds == null || natureAreaIds.Count == 0) { return; } foreach (var natureAreaId in natureAreaIds) { string code = CodePrefixes.GetNatureAreaCode(natureAreaId); var naVertex = g.V(code); vertex.AddE(EL.In, naVertex); } }
private static void HandleTaxonTraits(G g, Vertex taxonVertex, TaxonTraits taxonTraits) { if (taxonTraits.FeedsOn != null) { foreach (var feedsOn in taxonTraits.FeedsOn) { taxonVertex.AddE(TEL.Spiser, g.V(CodePrefixes.GetTaxonCode(feedsOn))); } } if (taxonTraits.PreysUpon != null) { foreach (var preysUpon in taxonTraits.PreysUpon) { taxonVertex.AddE(TEL.Jakter, g.V(CodePrefixes.GetTaxonCode(preysUpon))); } } if (taxonTraits.Habitat != null) { foreach (var code in taxonTraits.Habitat) { taxonVertex.AddE(TEL.Bor, g.V(code.ToLower())); } } if (!string.IsNullOrWhiteSpace(taxonTraits.MatingSystem)) { AddTaxonTrait(g, taxonVertex, VL.AEMS, TEL.Har, CodePrefixes.GetMatingsSystemCode(taxonTraits.MatingSystem), taxonTraits.MatingSystem); } if (taxonTraits.PrimaryDiet != null) { foreach (var diet in taxonTraits.PrimaryDiet) { AddTaxonTrait(g, taxonVertex, VL.AEPD, TEL.Spiser, CodePrefixes.GetPrimaryDietCode(diet), diet); } } if (taxonTraits.SexualDimorphism != null) { foreach (var sexualDimorphism in taxonTraits.SexualDimorphism) { AddTaxonTrait(g, taxonVertex, VL.AESD, TEL.Har, CodePrefixes.GetSexualDimorphismCode(sexualDimorphism), sexualDimorphism); } } if (taxonTraits.SocialSystem != null) { foreach (var socialSystem in taxonTraits.SocialSystem) { AddTaxonTrait(g, taxonVertex, VL.AESS, TEL.Har, CodePrefixes.GetSocialSystemCode(socialSystem), socialSystem); } } if (!string.IsNullOrWhiteSpace(taxonTraits.Terrestriality)) { AddTaxonTrait(g, taxonVertex, VL.AET, TEL.Bor, CodePrefixes.GetTerrestrialityCode(taxonTraits.Terrestriality), taxonTraits.Terrestriality); } if (taxonTraits.TotalLifeSpan.HasValue) { taxonVertex.AddP(TP.TotalLifeSpan, taxonTraits.TotalLifeSpan.Value); } if (taxonTraits.TrophicLevel != null) { foreach (var trophicLevel in taxonTraits.TrophicLevel) { AddTaxonTrait(g, taxonVertex, VL.AETL, TEL.Er, CodePrefixes.GetTrophicLevelCode(trophicLevel), trophicLevel); } } }