From 402b62d399133e635f79369aebc1746349bc74fd Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 28 May 2023 10:48:57 +0200 Subject: Fix reverse property handling in flattening --- src/Data/JLD/Flattening/NodeMap.hs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/Data/JLD/Flattening') diff --git a/src/Data/JLD/Flattening/NodeMap.hs b/src/Data/JLD/Flattening/NodeMap.hs index 6c35302..2e6b8e3 100644 --- a/src/Data/JLD/Flattening/NodeMap.hs +++ b/src/Data/JLD/Flattening/NodeMap.hs @@ -185,9 +185,9 @@ buildNodeMap' element = case element of if -- 6.5. | Just referenceNode <- bnmEnvReferenceNode -> bnmModifyNodeMap \nodeMap -> - if N.memberArray bnmEnvActiveGraph bnmEnvActiveSubject bnmEnvActiveProperty (Object referenceNode) nodeMap + if N.memberArray bnmEnvActiveGraph (Just id') bnmEnvActiveProperty (Object referenceNode) nodeMap then nodeMap - else N.modifyArray bnmEnvActiveGraph bnmEnvActiveSubject bnmEnvActiveProperty (`V.snoc` Object referenceNode) nodeMap + else N.modifyArray bnmEnvActiveGraph (Just id') bnmEnvActiveProperty (`V.snoc` Object referenceNode) nodeMap -- 6.6. | isJust bnmEnvActiveProperty -> do -- 6.6.1. @@ -223,25 +223,19 @@ buildNodeMap' element = case element of case KM.lookup (show KeywordIndex) elementObject' of Just indexValue | N.hasKey3 bnmEnvActiveGraph (Just id') (Just <| show KeywordIndex) nodeMap' -> throwError <| Left ConflictingIndexes - | otherwise -> bnmModifyNodeMap <| N.insert bnmEnvActiveGraph (Just id') (Just <| show KeywordType) indexValue + | otherwise -> bnmModifyNodeMap <| N.insert bnmEnvActiveGraph (Just id') (Just <| show KeywordIndex) indexValue -- Nothing -> pure () -- 6.9. case KM.lookup (show KeywordReverse) elementObject' of - Just (Object reverseMap) -> do - -- 6.9.1. - let referenced = KM.singleton (show KeywordId) (String id') - - -- 6.9.3. - iforM_ reverseMap \key -> - valueToArray .> mapM_ \value -> do - void <| bnmBuildNodeMap value \params -> - params - { bnmParamsReferenceNode = Just referenced - , bnmParamsActiveProperty = Just <| K.toText key - } - pure () + Just (Object reverseMap) -> iforM_ reverseMap \key -> + valueToArray .> mapM_ \value -> + void <| bnmBuildNodeMap value \params -> + params + { bnmParamsReferenceNode = Just <| KM.singleton (show KeywordId) (String id') + , bnmParamsActiveProperty = Just <| K.toText key + } -- _ -> pure () -- cgit v1.2.3-70-g09d2