Skip to content

Commit

Permalink
rename PlantUml config data type
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellussiegburg committed May 8, 2024
1 parent 4bea401 commit 1cca139
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 43 deletions.
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/EnterAS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import Modelling.ActivityDiagram.Datatype (
)
import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.ActivityDiagram.Shuffle (shuffleAdNames)
Expand Down Expand Up @@ -75,7 +75,7 @@ import System.Random.Shuffle (shuffleM)

data EnterASInstance = EnterASInstance {
activityDiagram :: UMLActivityDiagram,
drawSettings :: PlantUMLConvConf,
drawSettings :: PlantUmlConfig,
sampleSequence :: [String],
showSolution :: Bool
} deriving (Generic, Show, Eq)
Expand Down Expand Up @@ -275,7 +275,7 @@ getEnterASTask config = do
$ filter (isNothing . (`checkEnterASInstanceForConfig` config))
$ map (\x -> EnterASInstance {
activityDiagram=x,
drawSettings = defaultPlantUMLConvConf {
drawSettings = defaultPlantUmlConfig {
suppressBranchConditions = hideBranchConditions config
},
sampleSequence = sampleSolution $ enterActionSequence x,
Expand Down Expand Up @@ -324,7 +324,7 @@ defaultEnterASInstance = EnterASInstance {
AdConnection {from = 16, to = 7, guard = ""}
]
},
drawSettings = defaultPlantUMLConvConf,
drawSettings = defaultPlantUmlConfig,
sampleSequence = ["D","E","G","B","F"],
showSolution = False
}
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/FindSupportST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import Modelling.ActivityDiagram.Config (
import Modelling.ActivityDiagram.Alloy (modulePetriNet)
import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.Auxiliary.Common (getFirstInstance)
Expand Down Expand Up @@ -93,7 +93,7 @@ import System.Random.Shuffle (shuffleM)

data FindSupportSTInstance = FindSupportSTInstance {
activityDiagram :: UMLActivityDiagram,
plantUMLConf :: PlantUMLConvConf,
plantUMLConf :: PlantUmlConfig,
showSolution :: Bool
} deriving (Generic, Show)

Expand Down Expand Up @@ -284,7 +284,7 @@ getFindSupportSTTask config = do
return $ FindSupportSTInstance {
activityDiagram = ad,
plantUMLConf =
PlantUMLConvConf {
PlantUmlConfig {
suppressNodeNames = hideNodeNames config,
suppressBranchConditions = hideBranchConditions config
},
Expand Down Expand Up @@ -335,6 +335,6 @@ defaultFindSupportSTInstance = FindSupportSTInstance {
AdConnection {from = 17, to = 13, guard = ""}
]
},
plantUMLConf = defaultPlantUMLConvConf,
plantUMLConf = defaultPlantUmlConfig,
showSolution = False
}
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/MatchAd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import Modelling.ActivityDiagram.Datatype (
isActionNode, isObjectNode, isDecisionNode, isMergeNode, isForkNode, isJoinNode, isInitialNode, isActivityFinalNode, isFlowFinalNode)
import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.ActivityDiagram.Shuffle (shuffleAdNames)
Expand Down Expand Up @@ -75,7 +75,7 @@ import System.Random.Shuffle (shuffleM)

data MatchAdInstance = MatchAdInstance {
activityDiagram :: UMLActivityDiagram,
plantUMLConf :: PlantUMLConvConf,
plantUMLConf :: PlantUmlConfig,
showSolution :: Bool
} deriving (Generic, Show)

Expand Down Expand Up @@ -269,7 +269,7 @@ getMatchAdTask config = do
ad <- mapM (fmap snd . shuffleAdNames) randomInstances >>= getFirstInstance
return $ MatchAdInstance {
activityDiagram = ad,
plantUMLConf = defaultPlantUMLConvConf {
plantUMLConf = defaultPlantUmlConfig {
suppressBranchConditions = hideBranchConditions config
},
showSolution = printSolution config
Expand Down Expand Up @@ -319,6 +319,6 @@ defaultMatchAdInstance = MatchAdInstance {
AdConnection {from = 17, to = 4, guard = ""}
]
},
plantUMLConf = defaultPlantUMLConvConf,
plantUMLConf = defaultPlantUmlConfig,
showSolution = False
}
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/MatchPetri.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ import Modelling.ActivityDiagram.Config (
import Modelling.ActivityDiagram.Alloy (modulePetriNet)
import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.Auxiliary.Common (getFirstInstance, oneOf)
Expand Down Expand Up @@ -106,7 +106,7 @@ import System.Random.Shuffle (shuffleM)
data MatchPetriInstance = MatchPetriInstance {
activityDiagram :: UMLActivityDiagram,
petriNet :: SimplePetriLike PetriKey,
plantUMLConf :: PlantUMLConvConf,
plantUMLConf :: PlantUmlConfig,
petriDrawConf :: DrawSettings,
showSolution :: Bool
} deriving (Generic, Read, Show)
Expand Down Expand Up @@ -415,7 +415,7 @@ getMatchPetriTask config = do
activityDiagram=ad,
petriNet = shuffledPetri,
plantUMLConf =
PlantUMLConvConf {
PlantUmlConfig {
suppressNodeNames = False,
suppressBranchConditions = hideBranchConditions config
},
Expand Down Expand Up @@ -878,7 +878,7 @@ defaultMatchPetriInstance = MatchPetriInstance
( SupportST
{ label = 8 }
, 1 ) ] } ) ] }
, plantUMLConf = defaultPlantUMLConvConf
, plantUMLConf = defaultPlantUmlConfig
, petriDrawConf =
DrawSettings {
withPlaceNames = True,
Expand Down
31 changes: 18 additions & 13 deletions src/Modelling/ActivityDiagram/PlantUMLConverter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{-# LANGUAGE NamedFieldPuns #-}

module Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf(..),
defaultPlantUMLConvConf,
PlantUmlConfig(..),
defaultPlantUmlConfig,
convertToPlantUML,
convertToPlantUML',
drawAdToFile
Expand All @@ -23,21 +23,21 @@ import Modelling.ActivityDiagram.Datatype (
adjNodes,
)

data PlantUMLConvConf = PlantUMLConvConf {
data PlantUmlConfig = PlantUmlConfig {
suppressNodeNames :: Bool,
suppressBranchConditions :: Bool
} deriving (Generic, Read, Show, Eq)

defaultPlantUMLConvConf :: PlantUMLConvConf
defaultPlantUMLConvConf = PlantUMLConvConf {
defaultPlantUmlConfig :: PlantUmlConfig
defaultPlantUmlConfig = PlantUmlConfig {
suppressNodeNames = False,
suppressBranchConditions = True
}

drawAdToFile
:: MonadPlantUml m
=> FilePath
-> PlantUMLConvConf
-> PlantUmlConfig
-> UMLActivityDiagram
-> m FilePath
drawAdToFile path conf ad = do
Expand All @@ -48,22 +48,27 @@ drawAdToFile path conf ad = do
adFilename = [i|#{path}Diagram.svg|]

convertToPlantUML :: UMLActivityDiagram -> ByteString
convertToPlantUML = convertToPlantUML' defaultPlantUMLConvConf
convertToPlantUML = convertToPlantUML' defaultPlantUmlConfig

convertToPlantUML' :: PlantUMLConvConf -> UMLActivityDiagram -> ByteString
convertToPlantUML' :: PlantUmlConfig -> UMLActivityDiagram -> ByteString
convertToPlantUML' conf diag =
let start = getInitialNodes diag
body = convertNode start conf diag
document = "@startuml\n" ++ body ++ "@enduml"
in [__i|#{document}|]

convertNode :: [AdNode] -> PlantUMLConvConf -> UMLActivityDiagram -> String
convertNode :: [AdNode] -> PlantUmlConfig -> UMLActivityDiagram -> String
convertNode queue conf diag = convertNode' queue conf diag []

--Traverse the graph and serialize the nodes along the way to a PlantUML-String
convertNode' :: [AdNode] -> PlantUMLConvConf -> UMLActivityDiagram -> [AdNode] -> String
convertNode'
:: [AdNode]
-> PlantUmlConfig
-> UMLActivityDiagram
-> [AdNode]
-> String
convertNode' [] _ _ _ = [__i||]
convertNode' (current:queue) conf@(PlantUMLConvConf sn sb) diag seen =
convertNode' (current:queue) conf@(PlantUmlConfig sn sb) diag seen =
let newQueue = filter (`notElem` seen) (queue ++ adjNodes current diag)
newSeen = seen ++ [current]
in case current of
Expand Down Expand Up @@ -109,7 +114,7 @@ and handle them via 'convertNode''
-}
handleDecisionOrFork
:: AdNode
-> PlantUMLConvConf
-> PlantUmlConfig
-> UMLActivityDiagram
-> [AdNode]
-> String
Expand Down Expand Up @@ -154,7 +159,7 @@ Strategy:
-}
handleRepeat
:: AdNode
-> PlantUMLConvConf
-> PlantUmlConfig
-> UMLActivityDiagram
-> [AdNode]
-> String
Expand Down
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/SelectAS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import Modelling.ActivityDiagram.Datatype (
)
import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.ActivityDiagram.Shuffle (shuffleAdNames)
Expand Down Expand Up @@ -85,7 +85,7 @@ import System.Random.Shuffle (shuffleM)
data SelectASInstance = SelectASInstance {
activityDiagram :: UMLActivityDiagram,
actionSequences :: Map Int (Bool, [String]),
drawSettings :: PlantUMLConvConf,
drawSettings :: PlantUmlConfig,
showSolution :: Bool
} deriving (Generic, Show, Eq)

Expand Down Expand Up @@ -321,7 +321,7 @@ getSelectASTask config = do
let selectASInst = SelectASInstance {
activityDiagram=x,
actionSequences = actionSequences,
drawSettings = defaultPlantUMLConvConf {
drawSettings = defaultPlantUmlConfig {
suppressBranchConditions = hideBranchConditions config
},
showSolution = printSolution config
Expand Down Expand Up @@ -379,6 +379,6 @@ defaultSelectASInstance = SelectASInstance {
(2, (True,["F","A","B","C","D"])),
(3, (False,["A","F","B","C","D"]))
],
drawSettings = defaultPlantUMLConvConf,
drawSettings = defaultPlantUmlConfig,
showSolution = False
}
10 changes: 5 additions & 5 deletions src/Modelling/ActivityDiagram/SelectPetri.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import Modelling.ActivityDiagram.Instance (parseInstance)
import Modelling.ActivityDiagram.Isomorphism (isPetriIsomorphic)
import Modelling.ActivityDiagram.PetriNet (PetriKey (..), convertToPetriNet)
import Modelling.ActivityDiagram.PlantUMLConverter (
PlantUMLConvConf (..),
defaultPlantUMLConvConf,
PlantUmlConfig (..),
defaultPlantUmlConfig,
drawAdToFile,
)
import Modelling.ActivityDiagram.Shuffle (shuffleAdNames, shufflePetri)
Expand Down Expand Up @@ -106,7 +106,7 @@ import System.Random.Shuffle (shuffleM)

data SelectPetriInstance = SelectPetriInstance {
activityDiagram :: UMLActivityDiagram,
plantUMLConf :: PlantUMLConvConf,
plantUMLConf :: PlantUmlConfig,
petriDrawConf :: DrawSettings,
petriNets :: Map Int (Bool, SimplePetriLike PetriKey),
showSolution :: Bool
Expand Down Expand Up @@ -411,7 +411,7 @@ getSelectPetriTask config = do
$ selectPetriAlloy config
randomInstances <- shuffleM instances >>= mapM parseInstance
layout <- pickRandomLayout config
let plantUMLConf = PlantUMLConvConf {
let plantUMLConf = PlantUmlConfig {
suppressNodeNames = hideNodeNames config,
suppressBranchConditions = hideBranchConditions config
}
Expand Down Expand Up @@ -486,7 +486,7 @@ defaultSelectPetriInstance = SelectPetriInstance {
AdConnection {from = 17, to = 7, guard = ""}
]
},
plantUMLConf = defaultPlantUMLConvConf,
plantUMLConf = defaultPlantUmlConfig,
petriDrawConf = DrawSettings {
withPlaceNames = True,
withTransitionNames = True,
Expand Down

0 comments on commit 1cca139

Please sign in to comment.