diff --git a/registry-public/package.yaml b/registry-public/package.yaml index d8def6332..d252afa7e 100644 --- a/registry-public/package.yaml +++ b/registry-public/package.yaml @@ -1,5 +1,5 @@ name: registry-public -version: '4.33.4' +version: '4.34.0' synopsis: Registry Public description: Registry Public category: Web diff --git a/registry-server/package.yaml b/registry-server/package.yaml index 5b09011a4..68fa570d5 100644 --- a/registry-server/package.yaml +++ b/registry-server/package.yaml @@ -1,5 +1,5 @@ name: registry-server -version: '4.33.4' +version: '4.34.0' synopsis: Engine Registry description: Engine Registry category: Web diff --git a/registry-server/src/Registry/Api/Handler/Swagger/Api.hs b/registry-server/src/Registry/Api/Handler/Swagger/Api.hs index 819dca47c..07e45d7a5 100644 --- a/registry-server/src/Registry/Api/Handler/Swagger/Api.hs +++ b/registry-server/src/Registry/Api/Handler/Swagger/Api.hs @@ -41,7 +41,7 @@ swagger = s._swaggerInfo { _infoTitle = "Registry API" , _infoDescription = Just "API specification for Registry" - , _infoVersion = "4.33.4" + , _infoVersion = "4.34.0" , _infoLicense = Just $ License diff --git a/shared-common/package.yaml b/shared-common/package.yaml index e1a4b552a..e2eb69e79 100644 --- a/shared-common/package.yaml +++ b/shared-common/package.yaml @@ -1,5 +1,5 @@ name: shared-common -version: '4.33.4' +version: '4.34.0' synopsis: Engine Shared description: Engine Shared category: Web diff --git a/shared-common/src/Shared/Common/Integration/Http/Common/ResponseMapper.hs b/shared-common/src/Shared/Common/Integration/Http/Common/ResponseMapper.hs index b9d91b058..218c87fb3 100644 --- a/shared-common/src/Shared/Common/Integration/Http/Common/ResponseMapper.hs +++ b/shared-common/src/Shared/Common/Integration/Http/Common/ResponseMapper.hs @@ -76,4 +76,5 @@ extractIntField fieldName _ = Left . GeneralServerError $ _ERROR_INTEGRATION_COM convertToArray :: Value -> Either AppError [Value] convertToArray (Array array) = Right . Vector.toList $ array +convertToArray Null = Right [] convertToArray _ = Left . GeneralServerError $ _ERROR_INTEGRATION_COMMON__FIELD_IS_NOT_ARRAY diff --git a/shared-common/src/Shared/DocumentTemplate/Api/Resource/DocumentTemplate/DocumentTemplateDTO.hs b/shared-common/src/Shared/DocumentTemplate/Api/Resource/DocumentTemplate/DocumentTemplateDTO.hs index 687e17205..c6cd2ead9 100644 --- a/shared-common/src/Shared/DocumentTemplate/Api/Resource/DocumentTemplate/DocumentTemplateDTO.hs +++ b/shared-common/src/Shared/DocumentTemplate/Api/Resource/DocumentTemplate/DocumentTemplateDTO.hs @@ -10,6 +10,8 @@ import Shared.DocumentTemplate.Model.DocumentTemplate.DocumentTemplateFormatSimp data DocumentTemplateDTO = DocumentTemplateDTO { uuid :: U.UUID , name :: String + , organizationId :: String + , templateId :: String , version :: String , phase :: DocumentTemplatePhase , description :: String diff --git a/shared-common/src/Shared/DocumentTemplate/Database/DAO/DocumentTemplate/DocumentTemplateDAO.hs b/shared-common/src/Shared/DocumentTemplate/Database/DAO/DocumentTemplate/DocumentTemplateDAO.hs index a00cf496f..788e2061b 100644 --- a/shared-common/src/Shared/DocumentTemplate/Database/DAO/DocumentTemplate/DocumentTemplateDAO.hs +++ b/shared-common/src/Shared/DocumentTemplate/Database/DAO/DocumentTemplate/DocumentTemplateDAO.hs @@ -77,8 +77,8 @@ findLatestDocumentTemplateByOrganizationIdAndTemplateId orgId templateId = do \ AND template_id = ? \ \ORDER BY split_part(version, '.', 1)::int DESC, \ \ split_part(version, '.', 2)::int DESC, \ - \ split_part(version, '.', 3)::int DESC; \ - \LIMIT 1:" + \ split_part(version, '.', 3)::int DESC \ + \LIMIT 1" let params = [U.toString tenantUuid, orgId, templateId] logQuery sql params let action conn = query conn sql params diff --git a/shared-common/src/Shared/DocumentTemplate/Service/DocumentTemplate/DocumentTemplateMapper.hs b/shared-common/src/Shared/DocumentTemplate/Service/DocumentTemplate/DocumentTemplateMapper.hs index 73df0d25d..10743966d 100644 --- a/shared-common/src/Shared/DocumentTemplate/Service/DocumentTemplate/DocumentTemplateMapper.hs +++ b/shared-common/src/Shared/DocumentTemplate/Service/DocumentTemplate/DocumentTemplateMapper.hs @@ -15,6 +15,8 @@ toDTO dt formats = DocumentTemplateDTO { uuid = dt.uuid , name = dt.name + , organizationId = dt.organizationId + , templateId = dt.templateId , version = dt.version , phase = dt.phase , description = dt.description diff --git a/shared-common/src/Shared/OpenId/Service/OpenId/Client/Flow/OpenIdClientFlowService.hs b/shared-common/src/Shared/OpenId/Service/OpenId/Client/Flow/OpenIdClientFlowService.hs index fec72e142..9b8de0a57 100644 --- a/shared-common/src/Shared/OpenId/Service/OpenId/Client/Flow/OpenIdClientFlowService.hs +++ b/shared-common/src/Shared/OpenId/Service/OpenId/Client/Flow/OpenIdClientFlowService.hs @@ -32,7 +32,7 @@ requestTokensWithCode openIDClient mCode mNonce = case mCode of Just code -> do context <- ask - eTokens <- liftIO . E.try $ O.requestTokens openIDClient (fmap BS.pack mNonce) (BS.pack code) context.httpClientManager' :: AppContextC s sc m => m (Either IOError (OT.Tokens A.Value)) + eTokens <- liftIO . E.try $ O.requestTokens openIDClient (fmap BS.pack mNonce) (BS.pack code) context.httpClientManager' :: AppContextC s sc m => m (Either E.SomeException (OT.Tokens A.Value)) case eTokens of Right tokens -> return tokens Left error -> do diff --git a/shared-common/test/Shared/Specs/Common/Integration/Http/Common/ResponseMapperSpec.hs b/shared-common/test/Shared/Specs/Common/Integration/Http/Common/ResponseMapperSpec.hs index 4fd1d7729..339c60259 100644 --- a/shared-common/test/Shared/Specs/Common/Integration/Http/Common/ResponseMapperSpec.hs +++ b/shared-common/test/Shared/Specs/Common/Integration/Http/Common/ResponseMapperSpec.hs @@ -122,6 +122,16 @@ commonResponseMapperSpec = let result = convertToArray response -- THEN: result `shouldBe` expectation + it "null as empty array" $ + -- GIVEN: Response + do + let response = Null + -- AND: Expectations + let expectation = Right [] + -- WHEN: + let result = convertToArray response + -- THEN: + result `shouldBe` expectation it "bad type" $ -- GIVEN: Response do diff --git a/wizard-public/package.yaml b/wizard-public/package.yaml index 6d0a5f565..cba7bc1c0 100644 --- a/wizard-public/package.yaml +++ b/wizard-public/package.yaml @@ -1,5 +1,5 @@ name: wizard-public -version: '4.33.4' +version: '4.34.0' synopsis: Wizard Public description: Wizard Public category: Web diff --git a/wizard-public/src/WizardLib/Public/Api/Resource/User/UserWithMembershipDTO.hs b/wizard-public/src/WizardLib/Public/Api/Resource/User/UserWithMembershipDTO.hs index b406345aa..736fb3646 100644 --- a/wizard-public/src/WizardLib/Public/Api/Resource/User/UserWithMembershipDTO.hs +++ b/wizard-public/src/WizardLib/Public/Api/Resource/User/UserWithMembershipDTO.hs @@ -11,6 +11,7 @@ data UserWithMembershipDTO = UserWithMembershipDTO , lastName :: String , gravatarHash :: String , imageUrl :: Maybe String + , affiliation :: Maybe String , membershipType :: UserGroupMembershipType } deriving (Show, Eq, Generic) diff --git a/wizard-public/src/WizardLib/Public/Database/Mapping/PersistentCommand/PersistentCommandList.hs b/wizard-public/src/WizardLib/Public/Database/Mapping/PersistentCommand/PersistentCommandList.hs index f10c02366..af557a643 100644 --- a/wizard-public/src/WizardLib/Public/Database/Mapping/PersistentCommand/PersistentCommandList.hs +++ b/wizard-public/src/WizardLib/Public/Database/Mapping/PersistentCommand/PersistentCommandList.hs @@ -56,4 +56,8 @@ instance FromRow PersistentCommandList where case parts !! 4 of "" -> Nothing imageUrl -> Just imageUrl + , affiliation = + case parts !! 5 of + "" -> Nothing + affiliation -> Just affiliation } diff --git a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSimple.hs b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSimple.hs index d399026f6..0ebce1647 100644 --- a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSimple.hs +++ b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSimple.hs @@ -12,6 +12,7 @@ instance FromRow UserSimple where lastName <- field email <- field imageUrl <- field + affiliation <- field return $ UserSimple {..} fieldUserSimple :: RowParser UserSimple @@ -21,6 +22,7 @@ fieldUserSimple = do lastName <- field email <- field imageUrl <- field + affiliation <- field return UserSimple {..} fieldUserSimple' :: RowParser (Maybe UserSimple) @@ -30,6 +32,7 @@ fieldUserSimple' = do mCreatedByLastName <- field mCreatedByEmail <- field mCreatedByImageUrl <- field - case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByEmail, mCreatedByImageUrl) of - (Just uuid, Just firstName, Just lastName, Just email, imageUrl) -> return $ Just UserSimple {..} + mCreatedByAffiliation <- field + case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByEmail, mCreatedByImageUrl, mCreatedByAffiliation) of + (Just uuid, Just firstName, Just lastName, Just email, imageUrl, affiliation) -> return $ Just UserSimple {..} _ -> return Nothing diff --git a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSuggestion.hs b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSuggestion.hs index f4fc72110..e785fe53d 100644 --- a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSuggestion.hs +++ b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserSuggestion.hs @@ -12,6 +12,7 @@ instance FromRow UserSuggestion where lastName <- field gravatarHash <- field imageUrl <- field + affiliation <- field return $ UserSuggestion {..} fieldUserSuggestion :: RowParser UserSuggestion @@ -21,6 +22,7 @@ fieldUserSuggestion = do lastName <- field gravatarHash <- field imageUrl <- field + affiliation <- field return UserSuggestion {..} fieldUserSuggestion' :: RowParser (Maybe UserSuggestion) @@ -30,6 +32,7 @@ fieldUserSuggestion' = do mCreatedByLastName <- field mCreatedByGravatarHash <- field mCreatedByImageUrl <- field - case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByGravatarHash, mCreatedByImageUrl) of - (Just uuid, Just firstName, Just lastName, Just gravatarHash, imageUrl) -> return $ Just UserSuggestion {..} + mCreatedByAffiliation <- field + case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByGravatarHash, mCreatedByImageUrl, mCreatedByAffiliation) of + (Just uuid, Just firstName, Just lastName, Just gravatarHash, imageUrl, affiliation) -> return $ Just UserSuggestion {..} _ -> return Nothing diff --git a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserWithMembership.hs b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserWithMembership.hs index 95ee8ac48..e452c387f 100644 --- a/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserWithMembership.hs +++ b/wizard-public/src/WizardLib/Public/Database/Mapping/User/UserWithMembership.hs @@ -13,5 +13,6 @@ instance FromRow UserWithMembership where lastName <- field email <- field imageUrl <- field + affiliation <- field membershipType <- field return $ UserWithMembership {..} diff --git a/wizard-public/src/WizardLib/Public/Database/Migration/Development/User/Data/Users.hs b/wizard-public/src/WizardLib/Public/Database/Migration/Development/User/Data/Users.hs index 1a33888ac..2d63f7c28 100644 --- a/wizard-public/src/WizardLib/Public/Database/Migration/Development/User/Data/Users.hs +++ b/wizard-public/src/WizardLib/Public/Database/Migration/Development/User/Data/Users.hs @@ -16,6 +16,7 @@ userAlbertWithMembership = , lastName = "Einstein" , gravatarHash = ".." , imageUrl = Nothing + , affiliation = Nothing , membershipType = OwnerUserGroupMembershipType } @@ -27,6 +28,7 @@ userAlbertSuggestion = , lastName = "Einstein" , gravatarHash = ".." , imageUrl = Nothing + , affiliation = Nothing } userLocaleEmpty :: UserLocaleDTO diff --git a/wizard-public/src/WizardLib/Public/Model/User/UserSimple.hs b/wizard-public/src/WizardLib/Public/Model/User/UserSimple.hs index cfbb4f6b0..13c097521 100644 --- a/wizard-public/src/WizardLib/Public/Model/User/UserSimple.hs +++ b/wizard-public/src/WizardLib/Public/Model/User/UserSimple.hs @@ -9,5 +9,6 @@ data UserSimple = UserSimple , lastName :: String , email :: String , imageUrl :: Maybe String + , affiliation :: Maybe String } deriving (Generic, Eq, Show) diff --git a/wizard-public/src/WizardLib/Public/Model/User/UserSuggestion.hs b/wizard-public/src/WizardLib/Public/Model/User/UserSuggestion.hs index 6f5909a13..e5721aeb6 100644 --- a/wizard-public/src/WizardLib/Public/Model/User/UserSuggestion.hs +++ b/wizard-public/src/WizardLib/Public/Model/User/UserSuggestion.hs @@ -10,6 +10,7 @@ data UserSuggestion = UserSuggestion , lastName :: String , gravatarHash :: String , imageUrl :: Maybe String + , affiliation :: Maybe String } deriving (Show, Eq, Generic) diff --git a/wizard-public/src/WizardLib/Public/Model/User/UserWithMembership.hs b/wizard-public/src/WizardLib/Public/Model/User/UserWithMembership.hs index 51d289db8..872eb1ae0 100644 --- a/wizard-public/src/WizardLib/Public/Model/User/UserWithMembership.hs +++ b/wizard-public/src/WizardLib/Public/Model/User/UserWithMembership.hs @@ -11,6 +11,7 @@ data UserWithMembership = UserWithMembership , lastName :: String , email :: String , imageUrl :: Maybe String + , affiliation :: Maybe String , membershipType :: UserGroupMembershipType } deriving (Generic, Eq, Show) diff --git a/wizard-public/src/WizardLib/Public/Service/User/UserMapper.hs b/wizard-public/src/WizardLib/Public/Service/User/UserMapper.hs index ee272154f..c1fd619c2 100644 --- a/wizard-public/src/WizardLib/Public/Service/User/UserMapper.hs +++ b/wizard-public/src/WizardLib/Public/Service/User/UserMapper.hs @@ -12,5 +12,6 @@ toWithMembershipDTO user = , lastName = user.lastName , gravatarHash = createGravatarHash user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation , membershipType = user.membershipType } diff --git a/wizard-server/package.yaml b/wizard-server/package.yaml index 15e46e5eb..65b57bc1b 100644 --- a/wizard-server/package.yaml +++ b/wizard-server/package.yaml @@ -1,5 +1,5 @@ name: wizard-server -version: '4.33.4' +version: '4.34.0' synopsis: Engine Wizard description: Engine Wizard category: Web diff --git a/wizard-server/src/Wizard/Api/Handler/Project/List_GET.hs b/wizard-server/src/Wizard/Api/Handler/Project/List_GET.hs index 80d69d164..3f66f9c78 100644 --- a/wizard-server/src/Wizard/Api/Handler/Project/List_GET.hs +++ b/wizard-server/src/Wizard/Api/Handler/Project/List_GET.hs @@ -1,8 +1,10 @@ module Wizard.Api.Handler.Project.List_GET where +import qualified Data.UUID as U import Servant import Shared.Common.Api.Handler.Common +import Shared.Common.Api.Resource.Common.FromHttpApiData () import Shared.Common.Model.Common.Page import Shared.Common.Model.Common.Pageable import Shared.Common.Model.Context.TransactionState @@ -21,11 +23,12 @@ type List_GET = :> "projects" :> QueryParam "q" String :> QueryParam "isTemplate" Bool - :> QueryParam "isMigrating" Bool :> QueryParam "projectTags" String :> QueryParam "projectTagsOp" String - :> QueryParam "userUuids" String + :> QueryParam "userUuids" [U.UUID] :> QueryParam "userUuidsOp" String + :> QueryParam "userGroupUuids" [U.UUID] + :> QueryParam "userGroupUuidsOp" String :> QueryParam "knowledgeModelPackageIds" [Coordinate] :> QueryParam "knowledgeModelPackageIdsOp" String :> QueryParam "page" Int @@ -38,10 +41,11 @@ list_GET -> Maybe String -> Maybe String -> Maybe Bool - -> Maybe Bool -> Maybe String -> Maybe String + -> Maybe [U.UUID] -> Maybe String + -> Maybe [U.UUID] -> Maybe String -> Maybe [Coordinate] -> Maybe String @@ -49,20 +53,20 @@ list_GET -> Maybe Int -> Maybe String -> BaseContextM (Headers '[Header "x-trace-uuid" String] (Page ProjectDTO)) -list_GET mTokenHeader mServerUrl mQuery mIsTemplate mIsMigrating mProjectTagsL mProjectTagsOp mUserUuidsL mUserUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp mPage mSize mSort = +list_GET mTokenHeader mServerUrl mQuery mIsTemplate mProjectTagsL mProjectTagsOp mUserUuids mUserUuidsOp mUserGroupUuids mUserGroupUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp mPage mSize mSort = getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> runInAuthService NoTransaction $ addTraceUuidHeader =<< do - let mUserUuids = fmap (splitOn ",") mUserUuidsL let mProjectTags = fmap (splitOn ",") mProjectTagsL getProjectsForCurrentUserPageDto mQuery mIsTemplate - mIsMigrating mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp + mUserGroupUuids + mUserGroupUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp (Pageable mPage mSize) diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/Api.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/Api.hs index 465a7b7c5..e07444680 100644 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/Api.hs +++ b/wizard-server/src/Wizard/Api/Handler/Project/Migration/Api.hs @@ -3,29 +3,15 @@ module Wizard.Api.Handler.Project.Migration.Api where import Servant import Servant.Swagger.Tags -import Wizard.Api.Handler.Project.Migration.List_Current_Completion_POST -import Wizard.Api.Handler.Project.Migration.List_Current_DELETE -import Wizard.Api.Handler.Project.Migration.List_Current_GET -import Wizard.Api.Handler.Project.Migration.List_Current_PUT import Wizard.Api.Handler.Project.Migration.List_POST import Wizard.Model.Context.BaseContext type MigrationAPI = Tags "Project Migration" - :> ( List_POST - :<|> List_Current_GET - :<|> List_Current_PUT - :<|> List_Current_DELETE - :<|> List_Current_Completion_POST - ) + :> List_POST migrationApi :: Proxy MigrationAPI migrationApi = Proxy migrationServer :: ServerT MigrationAPI BaseContextM -migrationServer = - list_POST - :<|> list_current_GET - :<|> list_current_PUT - :<|> list_current_DELETE - :<|> list_current_completion_POST +migrationServer = list_POST diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_Completion_POST.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_Completion_POST.hs deleted file mode 100644 index 57a87d2db..000000000 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_Completion_POST.hs +++ /dev/null @@ -1,29 +0,0 @@ -module Wizard.Api.Handler.Project.Migration.List_Current_Completion_POST where - -import qualified Data.UUID as U -import Servant - -import Shared.Common.Api.Handler.Common -import Shared.Common.Model.Context.TransactionState -import Wizard.Api.Handler.Common -import Wizard.Model.Context.BaseContext -import Wizard.Service.Project.Migration.ProjectMigrationService - -type List_Current_Completion_POST = - Header "Authorization" String - :> Header "Host" String - :> "projects" - :> Capture "uuid" U.UUID - :> "migrations" - :> "current" - :> "completion" - :> Verb POST 204 '[SafeJSON] (Headers '[Header "x-trace-uuid" String] NoContent) - -list_current_completion_POST - :: Maybe String -> Maybe String -> U.UUID -> BaseContextM (Headers '[Header "x-trace-uuid" String] NoContent) -list_current_completion_POST mTokenHeader mServerUrl uuid = - getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> - runInAuthService Transactional $ - addTraceUuidHeader =<< do - finishProjectMigration uuid - return NoContent diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_DELETE.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_DELETE.hs deleted file mode 100644 index 3878cebf1..000000000 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_DELETE.hs +++ /dev/null @@ -1,28 +0,0 @@ -module Wizard.Api.Handler.Project.Migration.List_Current_DELETE where - -import qualified Data.UUID as U -import Servant - -import Shared.Common.Api.Handler.Common -import Shared.Common.Model.Context.TransactionState -import Wizard.Api.Handler.Common -import Wizard.Model.Context.BaseContext -import Wizard.Service.Project.Migration.ProjectMigrationService - -type List_Current_DELETE = - Header "Authorization" String - :> Header "Host" String - :> "projects" - :> Capture "uuid" U.UUID - :> "migrations" - :> "current" - :> Verb DELETE 204 '[SafeJSON] (Headers '[Header "x-trace-uuid" String] NoContent) - -list_current_DELETE - :: Maybe String -> Maybe String -> U.UUID -> BaseContextM (Headers '[Header "x-trace-uuid" String] NoContent) -list_current_DELETE mTokenHeader mServerUrl uuid = - getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> - runInAuthService Transactional $ - addTraceUuidHeader =<< do - cancelProjectMigration uuid - return NoContent diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_GET.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_GET.hs deleted file mode 100644 index 373ef134b..000000000 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_GET.hs +++ /dev/null @@ -1,27 +0,0 @@ -module Wizard.Api.Handler.Project.Migration.List_Current_GET where - -import qualified Data.UUID as U -import Servant - -import Shared.Common.Api.Handler.Common -import Shared.Common.Model.Context.TransactionState -import Wizard.Api.Handler.Common -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationJM () -import Wizard.Model.Context.BaseContext -import Wizard.Service.Project.Migration.ProjectMigrationService - -type List_Current_GET = - Header "Authorization" String - :> Header "Host" String - :> "projects" - :> Capture "uuid" U.UUID - :> "migrations" - :> "current" - :> Get '[SafeJSON] (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) - -list_current_GET - :: Maybe String -> Maybe String -> U.UUID -> BaseContextM (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) -list_current_GET mTokenHeader mServerUrl uuid = - getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> - runInAuthService NoTransaction $ addTraceUuidHeader =<< getProjectMigration uuid diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_PUT.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_PUT.hs deleted file mode 100644 index 60e5c70f0..000000000 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_Current_PUT.hs +++ /dev/null @@ -1,34 +0,0 @@ -module Wizard.Api.Handler.Project.Migration.List_Current_PUT where - -import qualified Data.UUID as U -import Servant - -import Shared.Common.Api.Handler.Common -import Shared.Common.Model.Context.TransactionState -import Wizard.Api.Handler.Common -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeJM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationJM () -import Wizard.Model.Context.BaseContext -import Wizard.Service.Project.Migration.ProjectMigrationService - -type List_Current_PUT = - Header "Authorization" String - :> Header "Host" String - :> ReqBody '[SafeJSON] ProjectMigrationChangeDTO - :> "projects" - :> Capture "uuid" U.UUID - :> "migrations" - :> "current" - :> Put '[SafeJSON] (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) - -list_current_PUT - :: Maybe String - -> Maybe String - -> ProjectMigrationChangeDTO - -> U.UUID - -> BaseContextM (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) -list_current_PUT mTokenHeader mServerUrl reqDto uuid = - getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> - runInAuthService Transactional $ addTraceUuidHeader =<< modifyProjectMigration uuid reqDto diff --git a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_POST.hs b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_POST.hs index 0b699b332..2c3292299 100644 --- a/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_POST.hs +++ b/wizard-server/src/Wizard/Api/Handler/Project/Migration/List_POST.hs @@ -6,10 +6,10 @@ import Servant import Shared.Common.Api.Handler.Common import Shared.Common.Model.Context.TransactionState import Wizard.Api.Handler.Common +import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO +import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireJM () import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateJM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationJM () import Wizard.Model.Context.BaseContext import Wizard.Service.Project.Migration.ProjectMigrationService @@ -20,14 +20,14 @@ type List_POST = :> "projects" :> Capture "uuid" U.UUID :> "migrations" - :> Verb 'POST 201 '[SafeJSON] (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) + :> Verb 'POST 200 '[SafeJSON] (Headers '[Header "x-trace-uuid" String] ProjectDetailQuestionnaireDTO) list_POST :: Maybe String -> Maybe String -> ProjectMigrationCreateDTO -> U.UUID - -> BaseContextM (Headers '[Header "x-trace-uuid" String] ProjectMigrationDTO) + -> BaseContextM (Headers '[Header "x-trace-uuid" String] ProjectDetailQuestionnaireDTO) list_POST mTokenHeader mServerUrl reqDto uuid = getAuthServiceExecutor mTokenHeader mServerUrl $ \runInAuthService -> - runInAuthService Transactional $ addTraceUuidHeader =<< createProjectMigration uuid reqDto + runInAuthService Transactional $ addTraceUuidHeader =<< migrateProject uuid reqDto diff --git a/wizard-server/src/Wizard/Api/Handler/Swagger/Api.hs b/wizard-server/src/Wizard/Api/Handler/Swagger/Api.hs index 9351d3d53..f872aadec 100644 --- a/wizard-server/src/Wizard/Api/Handler/Swagger/Api.hs +++ b/wizard-server/src/Wizard/Api/Handler/Swagger/Api.hs @@ -86,9 +86,7 @@ import Wizard.Api.Resource.Project.Detail.ProjectDetailSM () import Wizard.Api.Resource.Project.Detail.ProjectDetailSettingsSM () import Wizard.Api.Resource.Project.Detail.ProjectDetailWsSM () import Wizard.Api.Resource.Project.Event.ProjectEventListSM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeSM () import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateSM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationSM () import Wizard.Api.Resource.Project.ProjectContentChangeSM () import Wizard.Api.Resource.Project.ProjectContentSM () import Wizard.Api.Resource.Project.ProjectCreateFromTemplateSM () @@ -158,7 +156,7 @@ swagger = s._swaggerInfo { _infoTitle = "Wizard API" , _infoDescription = Just "API specification for Wizard" - , _infoVersion = "4.33.4" + , _infoVersion = "4.34.0" , _infoLicense = Just $ License diff --git a/wizard-server/src/Wizard/Api/Resource/Acl/MemberDTO.hs b/wizard-server/src/Wizard/Api/Resource/Acl/MemberDTO.hs index 8f9207b4d..d5559a383 100644 --- a/wizard-server/src/Wizard/Api/Resource/Acl/MemberDTO.hs +++ b/wizard-server/src/Wizard/Api/Resource/Acl/MemberDTO.hs @@ -10,6 +10,7 @@ data MemberDTO , lastName :: String , gravatarHash :: String , imageUrl :: Maybe String + , affiliation :: Maybe String } | UserGroupMemberDTO { uuid :: U.UUID diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailDTO.hs index b2d84f2f9..e99a6d38b 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailDTO.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailDTO.hs @@ -14,7 +14,6 @@ data ProjectDetailDTO = ProjectDetailDTO , visibility :: ProjectVisibility , knowledgeModelPackage :: KnowledgeModelPackageSuggestion , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , fileCount :: Int } diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailPreviewSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailPreviewSM.hs index ded612c94..f94b6eb6b 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailPreviewSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailPreviewSM.hs @@ -30,7 +30,6 @@ instance ToSchema ProjectDetailPreview where , knowledgeModelPackage = germanyPackageSuggestion , isTemplate = project1.isTemplate , documentTemplateUuid = Just wizardDocumentTemplate.uuid - , migrationUuid = Nothing , permissions = [project1AlbertEditProjectPermDto] , format = Just . DocumentTemplateMapper.toFormatSimple $ formatJson , fileCount = 0 diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireDTO.hs index 9c6997aa7..775f65f86 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireDTO.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireDTO.hs @@ -26,7 +26,6 @@ data ProjectDetailQuestionnaireDTO = ProjectDetailQuestionnaireDTO , replies :: M.Map String Reply , labels :: M.Map String [U.UUID] , phaseUuid :: Maybe U.UUID - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , files :: [ProjectFileSimple] , unresolvedCommentCounts :: M.Map String (M.Map U.UUID Int) diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireSM.hs index 717ebd6a2..090743ce5 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailQuestionnaireSM.hs @@ -39,7 +39,6 @@ instance ToSchema ProjectDetailQuestionnaireDTO where , replies = fReplies , labels = fLabels , phaseUuid = Just . u' $ "4b376e49-1589-429b-9590-c654378f0bd5" - , migrationUuid = Nothing , permissions = [project1AlbertEditProjectPermDto] , files = [] , unresolvedCommentCounts = diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportDTO.hs index 223f50a64..615ec2362 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportDTO.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportDTO.hs @@ -18,7 +18,6 @@ data ProjectDetailReportDTO = ProjectDetailReportDTO , knowledgeModelPackage :: KnowledgeModelPackageSuggestion , locale :: Maybe Value , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , fileCount :: Int , totalReport :: TotalReport diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportSM.hs index ecf06398c..ac0894c96 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailReportSM.hs @@ -28,7 +28,6 @@ instance ToSchema ProjectDetailReportDTO where , knowledgeModelPackage = germanyPackageSuggestion , locale = Nothing , isTemplate = project1.isTemplate - , migrationUuid = Nothing , permissions = [project1AlbertEditProjectPermDto] , fileCount = 0 , totalReport = report1.totalReport diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSM.hs index f73232b80..b4ce9e1ac 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSM.hs @@ -23,7 +23,6 @@ instance ToSchema ProjectDetailDTO where , sharing = project1.sharing , knowledgeModelPackage = germanyPackageSuggestion , isTemplate = project1.isTemplate - , migrationUuid = Nothing , permissions = [project1AlbertEditProjectPermDto] , fileCount = 0 } diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSettingsSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSettingsSM.hs index 8d3dc0a02..06b101c8b 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSettingsSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Detail/ProjectDetailSettingsSM.hs @@ -28,6 +28,7 @@ import Wizard.Database.Migration.Development.Project.Data.Projects import Wizard.Model.DocumentTemplate.DocumentTemplateState import Wizard.Model.Project.Detail.ProjectDetailSettings import Wizard.Model.Project.Project +import Wizard.Model.Project.ProjectState import qualified Wizard.Service.KnowledgeModel.Package.KnowledgeModelPackageMapper as PackageMapper instance ToSchema ProjectDetailSettings where @@ -41,16 +42,17 @@ instance ToSchema ProjectDetailSettings where , sharing = project1.sharing , selectedQuestionTagUuids = project1.selectedQuestionTagUuids , isTemplate = project1.isTemplate - , migrationUuid = Nothing , permissions = [project1AlbertEditProjectPermDto] , projectTags = project1.projectTags , knowledgeModelPackageUuid = netherlandsKmPackageV2.uuid , knowledgeModelPackage = PackageMapper.toSimpleDTO netherlandsKmPackageV2 , knowledgeModelTags = [tagDataScience] + , knowledgeModelState = UpToDateKnowledgeModelProjectState , language = Nothing , availableLocales = [] , documentTemplate = Just $ DocumentTemplateMapper.toDTO wizardDocumentTemplate wizardDocumentTemplateFormats - , documentTemplateState = Just DefaultDocumentTemplateState + , documentTemplateState = Just UpToDateDocumentTemplateProjectState + , documentTemplateSupportState = Just DefaultDocumentTemplateState , documentTemplatePhase = Just DraftDocumentTemplatePhase , formatUuid = Just . u' $ "ae3b9e68-e09e-4ad7-b476-67ab5626e873" , fileCount = 0 diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeDTO.hs deleted file mode 100644 index a3c1a4ba0..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeDTO.hs +++ /dev/null @@ -1,9 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO where - -import qualified Data.UUID as U -import GHC.Generics - -data ProjectMigrationChangeDTO = ProjectMigrationChangeDTO - { resolvedQuestionUuids :: [U.UUID] - } - deriving (Show, Eq, Generic) diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeJM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeJM.hs deleted file mode 100644 index 425568528..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeJM.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeJM where - -import Data.Aeson - -import Shared.Common.Util.Aeson -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO - -instance FromJSON ProjectMigrationChangeDTO where - parseJSON = genericParseJSON jsonOptions - -instance ToJSON ProjectMigrationChangeDTO where - toJSON = genericToJSON jsonOptions diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeSM.hs deleted file mode 100644 index 0aba1f1bb..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationChangeSM.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeSM where - -import Data.Swagger - -import Shared.Common.Util.Swagger -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeJM () -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations - -instance ToSchema ProjectMigrationChangeDTO where - declareNamedSchema = toSwagger projectMigrationChangeDto diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationCreateSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationCreateSM.hs index 7d27c3611..9fed65b60 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationCreateSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationCreateSM.hs @@ -5,7 +5,7 @@ import Data.Swagger import Shared.Common.Util.Swagger import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateJM () -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations +import Wizard.Database.Migration.Development.Project.Data.Projects instance ToSchema ProjectMigrationCreateDTO where declareNamedSchema = toSwagger projectMigrationCreateDto diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationDTO.hs deleted file mode 100644 index 299d3c572..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationDTO.hs +++ /dev/null @@ -1,14 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO where - -import qualified Data.UUID as U -import GHC.Generics - -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO - -data ProjectMigrationDTO = ProjectMigrationDTO - { oldProject :: ProjectDetailQuestionnaireDTO - , newProject :: ProjectDetailQuestionnaireDTO - , resolvedQuestionUuids :: [U.UUID] - , tenantUuid :: U.UUID - } - deriving (Show, Eq, Generic) diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationJM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationJM.hs deleted file mode 100644 index 226c643e6..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationJM.hs +++ /dev/null @@ -1,13 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationJM where - -import Data.Aeson - -import Shared.Common.Util.Aeson -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireJM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO - -instance FromJSON ProjectMigrationDTO where - parseJSON = genericParseJSON jsonOptions - -instance ToJSON ProjectMigrationDTO where - toJSON = genericToJSON jsonOptions diff --git a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationSM.hs deleted file mode 100644 index 30740a771..000000000 --- a/wizard-server/src/Wizard/Api/Resource/Project/Migration/ProjectMigrationSM.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Wizard.Api.Resource.Project.Migration.ProjectMigrationSM where - -import Data.Swagger - -import Shared.Common.Util.Swagger -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireSM () -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationJM () -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations - -instance ToSchema ProjectMigrationDTO where - declareNamedSchema = toSwagger projectMigrationDto diff --git a/wizard-server/src/Wizard/Api/Resource/Project/ProjectDTO.hs b/wizard-server/src/Wizard/Api/Resource/Project/ProjectDTO.hs index 89c48a30c..82082882e 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/ProjectDTO.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/ProjectDTO.hs @@ -15,7 +15,8 @@ data ProjectDTO = ProjectDTO , description :: Maybe String , visibility :: ProjectVisibility , sharing :: ProjectSharing - , state :: ProjectState + , knowledgeModelState :: KnowledgeModelProjectState + , documentTemplateState :: Maybe DocumentTemplateProjectState , knowledgeModelPackage :: KnowledgeModelPackageSimple , permissions :: [ProjectPermDTO] , isTemplate :: Bool @@ -31,7 +32,8 @@ instance Eq ProjectDTO where && a.description == b.description && a.visibility == b.visibility && a.sharing == b.sharing - && a.state == b.state + && a.knowledgeModelState == b.knowledgeModelState + && a.documentTemplateState == b.documentTemplateState && a.knowledgeModelPackage == b.knowledgeModelPackage && a.permissions == b.permissions && a.isTemplate == b.isTemplate diff --git a/wizard-server/src/Wizard/Api/Resource/Project/ProjectSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/ProjectSM.hs index 9c6086cfd..6c2d613d7 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/ProjectSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/ProjectSM.hs @@ -19,4 +19,4 @@ import Wizard.Service.Project.ProjectMapper instance ToSchema ProjectDTO where declareNamedSchema = - toSwagger (toDTO project1 germanyKmPackage DefaultProjectState [project1AlbertEditProjectPermDto]) + toSwagger (toDTO project1 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project1AlbertEditProjectPermDto]) diff --git a/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateJM.hs b/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateJM.hs index f962cff34..a197c83b2 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateJM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateJM.hs @@ -4,6 +4,10 @@ import Data.Aeson import Wizard.Model.Project.ProjectState -instance FromJSON ProjectState +instance FromJSON KnowledgeModelProjectState -instance ToJSON ProjectState +instance ToJSON KnowledgeModelProjectState + +instance FromJSON DocumentTemplateProjectState + +instance ToJSON DocumentTemplateProjectState diff --git a/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateSM.hs b/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateSM.hs index 640d7158f..3c655f61d 100644 --- a/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateSM.hs +++ b/wizard-server/src/Wizard/Api/Resource/Project/ProjectStateSM.hs @@ -4,4 +4,6 @@ import Data.Swagger import Wizard.Model.Project.ProjectState -instance ToSchema ProjectState +instance ToSchema KnowledgeModelProjectState + +instance ToSchema DocumentTemplateProjectState diff --git a/wizard-server/src/Wizard/Database/DAO/KnowledgeModel/KnowledgeModelEditorDAO.hs b/wizard-server/src/Wizard/Database/DAO/KnowledgeModel/KnowledgeModelEditorDAO.hs index 16c909663..b85f9e923 100644 --- a/wizard-server/src/Wizard/Database/DAO/KnowledgeModel/KnowledgeModelEditorDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/KnowledgeModel/KnowledgeModelEditorDAO.hs @@ -66,7 +66,7 @@ findKnowledgeModelEditorsPage mQuery pageable sort = \ fork_of_package.description, \ \ knowledge_model_editor.created_by, \ \ knowledge_model_editor.created_at, \ - \ knowledge_model_editor.updated_at \ + \ GREATEST(knowledge_model_editor.updated_at, (SELECT MAX(created_at) FROM knowledge_model_editor_event WHERE knowledge_model_editor_event.editor_uuid = knowledge_model_editor.uuid AND knowledge_model_editor_event.tenant_uuid = knowledge_model_editor.tenant_uuid)) AS updated_at \ \FROM knowledge_model_editor \ \JOIN config_organization ON knowledge_model_editor.tenant_uuid = config_organization.tenant_uuid \ \LEFT JOIN knowledge_model_migration ON knowledge_model_editor.uuid = knowledge_model_migration.editor_uuid \ diff --git a/wizard-server/src/Wizard/Database/DAO/PersistentCommand/PersistentCommandDAO.hs b/wizard-server/src/Wizard/Database/DAO/PersistentCommand/PersistentCommandDAO.hs index 6d2f141d0..5470818c1 100644 --- a/wizard-server/src/Wizard/Database/DAO/PersistentCommand/PersistentCommandDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/PersistentCommand/PersistentCommandDAO.hs @@ -53,7 +53,8 @@ findPersistentCommandsPage states pageable sort = do \ user_entity.first_name, '::', \ \ user_entity.last_name, '::', \ \ user_entity.email, '::', \ - \ user_entity.image_url) \ + \ user_entity.image_url, '::', \ + \ user_entity.affiliation) \ \ END AS created_by \ \FROM persistent_command \ \ LEFT JOIN tenant ON tenant.uuid = persistent_command.tenant_uuid \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectCommentThreadDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectCommentThreadDAO.hs index 2cc371fd6..7592bb41d 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectCommentThreadDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectCommentThreadDAO.hs @@ -104,7 +104,8 @@ findAssignedProjectCommentThreadsPage mQuery mProjectUuid mResolved pageable sor \ u.first_name AS created_by_first_name, \ \ u.last_name AS created_by_last_name, \ \ u.email AS created_by_email, \ - \ u.image_url AS created_by_image_url \ + \ u.image_url AS created_by_image_url, \ + \ u.affiliation AS created_by_affiliation \ \FROM project_comment_thread thread \ \JOIN project ON project.uuid = thread.project_uuid AND project.tenant_uuid = thread.tenant_uuid \ \LEFT JOIN user_entity u ON u.uuid = thread.created_by AND u.tenant_uuid = thread.tenant_uuid \ @@ -189,11 +190,13 @@ findProjectCommentThreadsForProject projectUuid mPath mResolved editor = do \ assigned_to_user.last_name, \ \ assigned_to_user.email, \ \ assigned_to_user.image_url, \ + \ assigned_to_user.affiliation, \ \ created_by_user.uuid, \ \ created_by_user.first_name, \ \ created_by_user.last_name, \ \ created_by_user.email, \ \ created_by_user.image_url, \ + \ created_by_user.affiliation, \ \ (SELECT array_agg(concat(comment.uuid, '<:::::>', \ \ comment.text, '<:::::>', \ \ comment.created_at, '<:::::>', \ @@ -202,7 +205,8 @@ findProjectCommentThreadsForProject projectUuid mPath mResolved editor = do \ user_entity.first_name, '<:::::>', \ \ user_entity.last_name, '<:::::>', \ \ user_entity.email, '<:::::>', \ - \ user_entity.image_url \ + \ user_entity.image_url, '<:::::>', \ + \ user_entity.affiliation \ \ )) AS comments \ \ FROM project_comment comment \ \ LEFT JOIN user_entity ON user_entity.uuid = comment.created_by \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectDAO.hs index 3ec56cc08..77fac9a0e 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectDAO.hs @@ -65,8 +65,8 @@ findProjects = do entities <- runDB action traverse enhance entities -findProjectsForCurrentUserPage :: Maybe String -> Maybe Bool -> Maybe Bool -> Maybe [String] -> Maybe String -> Maybe [String] -> Maybe String -> Maybe [Coordinate] -> Maybe String -> Pageable -> [Sort] -> AppContextM (Page ProjectList) -findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp pageable sort = +findProjectsForCurrentUserPage :: Maybe String -> Maybe Bool -> Maybe [String] -> Maybe String -> Maybe [U.UUID] -> Maybe String -> Maybe [U.UUID] -> Maybe String -> Maybe [Coordinate] -> Maybe String -> Pageable -> [Sort] -> AppContextM (Page ProjectList) +findProjectsForCurrentUserPage mQuery mIsTemplate mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp mUserGroupUuids mUserGroupUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp pageable sort = -- 1. Prepare variables do tenantUuid <- asks currentTenantUuid @@ -80,15 +80,6 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro Nothing -> "" Just True -> " AND project.is_template = true" Just False -> " AND project.is_template = false" - let isMigratingCondition useWhere = - case mIsMigrating of - Nothing -> "" - Just True -> f' " %s project_mig.new_project_uuid IS NOT NULL" [if useWhere then "WHERE" else "AND"] - Just False -> f' " %s project_mig.new_project_uuid IS NULL" [if useWhere then "WHERE" else "AND"] - let projectMigrationJoin = - case mIsMigrating of - Nothing -> "" - Just _ -> "LEFT JOIN project_migration project_mig ON project.uuid = project_mig.new_project_uuid " let (projectTagsCondition, projectTagsParam) = case mProjectTags of Nothing -> ("", []) @@ -116,11 +107,34 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro \FROM project_perm_user \ \WHERE project_uuid = project.uuid AND user_uuid in (%s)) " [show . length $ userUuids, generateQuestionMarks userUuids] - , userUuids + , fmap U.toString userUuids ) else let mapFn _ = " project_perm_user.user_uuid = ? " - in (" AND (" ++ L.intercalate " OR " (fmap mapFn userUuids) ++ ")", userUuids) + in (" AND (" ++ L.intercalate " OR " (fmap mapFn userUuids) ++ ")", fmap U.toString userUuids) + let userGroupUuidsJoin = + case mUserGroupUuids of + Nothing -> "" + Just [] -> "" + Just _ -> "LEFT JOIN project_perm_group ON project.uuid = project_perm_group.project_uuid " + let (userGroupUuidsCondition, userGroupUuidsParam) = + case mUserGroupUuids of + Nothing -> ("", []) + Just [] -> ("", []) + Just userGroupUuids -> + if isAndOperator mUserGroupUuidsOp + then + ( f' + " AND %s = ( \ + \SELECT COUNT(DISTINCT user_group_uuid) \ + \FROM project_perm_group \ + \WHERE project_uuid = project.uuid AND user_group_uuid in (%s)) " + [show . length $ userGroupUuids, generateQuestionMarks userGroupUuids] + , fmap U.toString userGroupUuids + ) + else + let mapFn _ = " project_perm_group.user_group_uuid = ? " + in (" AND (" ++ L.intercalate " OR " (fmap mapFn userGroupUuids) ++ ")", fmap U.toString userGroupUuids) let (knowledgeModelPackageJoin, knowledgeModelPackageCondition, knowledgeModelPackageIdsParam) = case mKnowledgeModelPackageCoordinates of Nothing -> ("", "", []) @@ -134,7 +148,7 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro hasPermission <- hasPermission _PROJECTS_VIEW_ROLE_PERMISSION let (aclJoins, aclCondition) = if hasPermission - then (userUuidsJoin, "") + then (userUuidsJoin ++ userGroupUuidsJoin, "") else ( f'' "LEFT JOIN project_perm_user ON project.uuid = project_perm_user.project_uuid AND project_perm_user.tenant_uuid = '${tenantUuid}' \ @@ -159,23 +173,21 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro f'' "SELECT COUNT(DISTINCT project.uuid) \ \FROM project \ - \${projectMigrationJoin} \ \${knowledgeModelPackageJoin} \ \${aclJoins} \ - \WHERE project.tenant_uuid = '${tenantUuid}' ${aclCondition} ${nameCondition} ${isTemplateCondition} ${isMigratingCondition} ${projectTagsCondition} ${userUuidsCondition} ${knowledgeModelPackageCondition}" - [ ("projectMigrationJoin", projectMigrationJoin) - , ("knowledgeModelPackageJoin", knowledgeModelPackageJoin) + \WHERE project.tenant_uuid = '${tenantUuid}' ${aclCondition} ${nameCondition} ${isTemplateCondition} ${projectTagsCondition} ${userUuidsCondition} ${userGroupUuidsCondition} ${knowledgeModelPackageCondition}" + [ ("knowledgeModelPackageJoin", knowledgeModelPackageJoin) , ("aclJoins", aclJoins) , ("tenantUuid", U.toString tenantUuid) , ("aclCondition", aclCondition) , ("nameCondition", nameCondition) , ("isTemplateCondition", isTemplateCondition) - , ("isMigratingCondition", isMigratingCondition False) , ("projectTagsCondition", projectTagsCondition) , ("userUuidsCondition", userUuidsCondition) + , ("userGroupUuidsCondition", userGroupUuidsCondition) , ("knowledgeModelPackageCondition", knowledgeModelPackageCondition) ] - let params = nameRegex ++ projectTagsParam ++ userUuidsParam ++ knowledgeModelPackageIdsParam + let params = nameRegex ++ projectTagsParam ++ userUuidsParam ++ userGroupUuidsParam ++ knowledgeModelPackageIdsParam logQuery countSql params let action conn = query conn countSql params result <- runDB action @@ -195,21 +207,19 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro \ project.is_template, \ \ project.created_at, \ \ project.updated_at, \ - \ project.knowledge_model_package_uuid \ + \ project.knowledge_model_package_uuid, \ + \ project.document_template_uuid \ \ FROM project \ \ ${knowledgeModelPackageJoin} \ \ ${aclJoins} \ - \ WHERE project.tenant_uuid = '${tenantUuid}' ${aclCondition} ${nameCondition} ${isTemplateCondition} ${projectTagsCondition} ${userUuidsCondition} ${knowledgeModelPackageCondition}), \ + \ WHERE project.tenant_uuid = '${tenantUuid}' ${aclCondition} ${nameCondition} ${isTemplateCondition} ${projectTagsCondition} ${userUuidsCondition} ${userGroupUuidsCondition} ${knowledgeModelPackageCondition}), \ \ pkg AS (SELECT knowledge_model_package.uuid, \ \ knowledge_model_package.name, \ \ knowledge_model_package.version, \ \ knowledge_model_package.organization_id, \ \ knowledge_model_package.km_id \ \ FROM knowledge_model_package \ - \ WHERE knowledge_model_package.tenant_uuid = '${tenantUuid}'), \ - \ project_mig AS (SELECT new_project_uuid \ - \ FROM project_migration \ - \ WHERE project_migration.tenant_uuid = '${tenantUuid}') \ + \ WHERE knowledge_model_package.tenant_uuid = '${tenantUuid}') \ \SELECT filtered_project.uuid, \ \ filtered_project.name, \ \ filtered_project.description, \ @@ -219,13 +229,25 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro \ filtered_project.created_at, \ \ filtered_project.updated_at, \ \ CASE \ - \ WHEN project_mig.new_project_uuid IS NOT NULL THEN 'MigratingProjectState' \ - \ WHEN filtered_project.knowledge_model_package_uuid != get_newest_knowledge_model_package(pkg.organization_id, pkg.km_id, '${tenantUuid}', ARRAY['ReleasedKnowledgeModelPackagePhase']) THEN 'OutdatedProjectState' \ - \ WHEN project_mig.new_project_uuid IS NULL THEN 'DefaultProjectState' END, \ + \ WHEN filtered_project.knowledge_model_package_uuid != get_newest_knowledge_model_package(pkg.organization_id, pkg.km_id, '${tenantUuid}', ARRAY['ReleasedKnowledgeModelPackagePhase']) THEN 'OutdatedKnowledgeModelProjectState' \ + \ ELSE 'UpToDateKnowledgeModelProjectState' END, \ + \ CASE \ + \ WHEN dt.uuid IS NULL THEN NULL \ + \ WHEN dt.uuid != (SELECT newest_dt.uuid \ + \ FROM document_template newest_dt \ + \ WHERE newest_dt.tenant_uuid = '${tenantUuid}' \ + \ AND newest_dt.organization_id = dt.organization_id \ + \ AND newest_dt.template_id = dt.template_id \ + \ AND newest_dt.phase = 'ReleasedDocumentTemplatePhase' \ + \ ORDER BY split_part(newest_dt.version, '.', 1)::int DESC, \ + \ split_part(newest_dt.version, '.', 2)::int DESC, \ + \ split_part(newest_dt.version, '.', 3)::int DESC \ + \ LIMIT 1) THEN 'OutdatedDocumentTemplateProjectState' \ + \ ELSE 'UpToDateDocumentTemplateProjectState' END, \ \ pkg.uuid, \ \ pkg.name, \ \ pkg.version, \ - \ (SELECT array_agg(CONCAT(project_perm_user.user_uuid, '::', project_perm_user.perms, '::', u.uuid, '::', u.first_name, '::', u.last_name, '::', u.email, '::', u.image_url)) \ + \ (SELECT array_agg(CONCAT(project_perm_user.user_uuid, '::', project_perm_user.perms, '::', u.uuid, '::', u.first_name, '::', u.last_name, '::', u.email, '::', u.image_url, '::', u.affiliation)) \ \ FROM project_perm_user \ \ JOIN user_entity u on u.uuid = project_perm_user.user_uuid \ \ WHERE project_uuid = filtered_project.uuid \ @@ -237,8 +259,7 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro \ GROUP BY project_uuid) as group_permissions \ \FROM filtered_project \ \JOIN pkg ON filtered_project.knowledge_model_package_uuid = pkg.uuid \ - \LEFT JOIN project_mig ON filtered_project.uuid = project_mig.new_project_uuid \ - \${isMigratingCondition} \ + \LEFT JOIN document_template dt ON filtered_project.document_template_uuid = dt.uuid AND dt.tenant_uuid = '${tenantUuid}' \ \${sort} \ \OFFSET ${offset} LIMIT ${limit}" [ ("knowledgeModelPackageJoin", knowledgeModelPackageJoin) @@ -247,9 +268,9 @@ findProjectsForCurrentUserPage mQuery mIsTemplate mIsMigrating mProjectTags mPro , ("aclCondition", aclCondition) , ("nameCondition", nameCondition) , ("isTemplateCondition", isTemplateCondition) - , ("isMigratingCondition", isMigratingCondition True) , ("projectTagsCondition", projectTagsCondition) , ("userUuidsCondition", userUuidsCondition) + , ("userGroupUuidsCondition", userGroupUuidsCondition) , ("knowledgeModelPackageCondition", knowledgeModelPackageCondition) , ("sort", mapSortWithPrefix "filtered_project" sort) , ("offset", show skip) @@ -393,7 +414,6 @@ findProjectDetail uuid = do \ knowledge_model_package.description AS knowledge_model_package_description, \ \ project.selected_question_tag_uuids, \ \ project.is_template, \ - \ project_mig.new_project_uuid AS migration_uuid, \ \ ${projectDetailPermSql}, \ \ ( \ \ SELECT count(*) \ @@ -401,7 +421,6 @@ findProjectDetail uuid = do \ WHERE tenant_uuid = '${tenantUuid}' AND project_uuid = '${projectUuid}' \ \ ) as file_count \ \FROM project \ - \LEFT JOIN project_migration project_mig ON project.uuid = project_mig.old_project_uuid AND project.tenant_uuid = project_mig.tenant_uuid \ \LEFT JOIN knowledge_model_package ON project.knowledge_model_package_uuid = knowledge_model_package.uuid AND project.tenant_uuid = knowledge_model_package.tenant_uuid \ \WHERE project.tenant_uuid = ? AND project.uuid = ?" [ ("projectUuid", U.toString uuid) @@ -433,7 +452,6 @@ findProjectDetailQuestionnaire uuid = do \ project.selected_question_tag_uuids, \ \ project.language, \ \ project.is_template, \ - \ project_mig.new_project_uuid AS migration_uuid, \ \ ${projectDetailPermSql}, \ \ ( \ \ SELECT array_agg(concat(uuid, '<:::::>', \ @@ -445,7 +463,6 @@ findProjectDetailQuestionnaire uuid = do \ WHERE tenant_uuid = '${tenantUuid}' AND project_uuid = '${projectUuid}' \ \ ) as files \ \FROM project \ - \LEFT JOIN project_migration project_mig ON project.uuid = project_mig.old_project_uuid AND project.tenant_uuid = project_mig.tenant_uuid \ \LEFT JOIN knowledge_model_package ON project.knowledge_model_package_uuid = knowledge_model_package.uuid AND project.tenant_uuid = knowledge_model_package.tenant_uuid \ \WHERE project.tenant_uuid = ? AND project.uuid = ?" [ ("projectUuid", U.toString uuid) @@ -476,7 +493,6 @@ findProjectDetailPreview uuid = do \ knowledge_model_package.description AS knowledge_model_package_description, \ \ project.is_template, \ \ project.document_template_uuid, \ - \ project_mig.new_project_uuid AS migration_uuid, \ \ ${projectDetailPermSql}, \ \ dt_format.uuid, \ \ dt_format.name, \ @@ -487,7 +503,6 @@ findProjectDetailPreview uuid = do \ WHERE tenant_uuid = '${tenantUuid}' AND project_uuid = '${projectUuid}' \ \ ) as file_count \ \FROM project \ - \LEFT JOIN project_migration project_mig ON project.uuid = project_mig.old_project_uuid AND project.tenant_uuid = project_mig.tenant_uuid \ \LEFT JOIN knowledge_model_package ON project.knowledge_model_package_uuid = knowledge_model_package.uuid AND project.tenant_uuid = knowledge_model_package.tenant_uuid \ \LEFT JOIN document_template dt ON project.document_template_uuid = dt.uuid AND project.tenant_uuid = dt.tenant_uuid \ \LEFT JOIN document_template_format dt_format ON project.document_template_uuid = dt_format.document_template_uuid AND project.format_uuid = dt_format.uuid AND project.tenant_uuid = dt_format.tenant_uuid \ @@ -518,7 +533,6 @@ findProjectDetailSettings uuid = do \ project.selected_question_tag_uuids, \ \ project.language, \ \ project.format_uuid, \ - \ project_mig.new_project_uuid AS migration_uuid, \ \ ${projectDetailPermSql}, \ \ pkg.uuid as knowledge_model_package_uuid, \ \ pkg.name as knowledge_model_package_name, \ @@ -533,6 +547,8 @@ findProjectDetailSettings uuid = do \ pkg.created_at as knowledge_model_package_created_at, \ \ dt.uuid as document_template_uuid, \ \ dt.name as document_template_name, \ + \ dt.organization_id as document_template_organization_id, \ + \ dt.template_id as document_template_template_id, \ \ dt.version as document_template_version, \ \ dt.phase as document_template_phase, \ \ dt.description as document_template_description, \ @@ -544,13 +560,28 @@ findProjectDetailSettings uuid = do \ ORDER BY dt_format.name) nested \ \ ) AS document_template_formats, \ \ dt.metamodel_version as document_template_metamodel_version, \ + \ CASE \ + \ WHEN project.knowledge_model_package_uuid != get_newest_knowledge_model_package(pkg.organization_id, pkg.km_id, '${tenantUuid}', ARRAY['ReleasedKnowledgeModelPackagePhase']) THEN 'OutdatedKnowledgeModelProjectState' \ + \ ELSE 'UpToDateKnowledgeModelProjectState' END as knowledge_model_state, \ + \ CASE \ + \ WHEN dt.uuid IS NULL THEN NULL \ + \ WHEN dt.uuid != (SELECT newest_dt.uuid \ + \ FROM document_template newest_dt \ + \ WHERE newest_dt.tenant_uuid = '${tenantUuid}' \ + \ AND newest_dt.organization_id = dt.organization_id \ + \ AND newest_dt.template_id = dt.template_id \ + \ AND newest_dt.phase = 'ReleasedDocumentTemplatePhase' \ + \ ORDER BY split_part(newest_dt.version, '.', 1)::int DESC, \ + \ split_part(newest_dt.version, '.', 2)::int DESC, \ + \ split_part(newest_dt.version, '.', 3)::int DESC \ + \ LIMIT 1) THEN 'OutdatedDocumentTemplateProjectState' \ + \ ELSE 'UpToDateDocumentTemplateProjectState' END as document_template_state, \ \ ( \ \ SELECT count(*) \ \ FROM project_file \ \ WHERE tenant_uuid = '${tenantUuid}' AND project_uuid = '${projectUuid}' \ \ ) as file_count \ \FROM project \ - \LEFT JOIN project_migration project_mig ON project.uuid = project_mig.old_project_uuid AND project.tenant_uuid = project_mig.tenant_uuid \ \LEFT JOIN knowledge_model_package pkg ON project.knowledge_model_package_uuid = pkg.uuid AND project.tenant_uuid = pkg.tenant_uuid \ \LEFT JOIN document_template dt ON project.document_template_uuid = dt.uuid AND project.tenant_uuid = dt.tenant_uuid \ \WHERE project.tenant_uuid = ? AND project.uuid = ?" @@ -567,7 +598,7 @@ findProjectDetailSettings uuid = do projectDetailPermSql :: String projectDetailPermSql = "(SELECT array_agg(CONCAT(project_perm_user.user_uuid, '::', project_perm_user.perms, '::', u.uuid, '::', u.first_name, \ - \ '::', u.last_name, '::', u.email, '::', u.image_url)) \ + \ '::', u.last_name, '::', u.email, '::', u.image_url, '::', u.affiliation)) \ \ FROM project_perm_user \ \ JOIN user_entity u on u.uuid = project_perm_user.user_uuid \ \ WHERE project_uuid = project.uuid \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectEventDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectEventDAO.hs index 6a59ec885..6d6e021e2 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectEventDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectEventDAO.hs @@ -66,7 +66,8 @@ findProjectEventsPage projectUuid pageable sort = do \ user_entity.first_name AS created_by_first_name, \ \ user_entity.last_name AS created_by_last_name, \ \ gravatar_hash(user_entity.email) AS created_by_gravatar_hash, \ - \ user_entity.image_url AS created_by_email \ + \ user_entity.image_url AS created_by_image_url, \ + \ user_entity.affiliation AS created_by_affiliation \ \FROM project_event \ \ LEFT JOIN user_entity ON user_entity.uuid = project_event.created_by \ \WHERE project_event.tenant_uuid = ? \ @@ -121,7 +122,8 @@ findProjectEventListsByProjectUuid projectUuid = do \ user_entity.first_name AS created_by_first_name, \ \ user_entity.last_name AS created_by_last_name, \ \ gravatar_hash(user_entity.email) AS created_by_gravatar_hash, \ - \ user_entity.image_url AS created_by_email \ + \ user_entity.image_url AS created_by_image_url, \ + \ user_entity.affiliation AS created_by_affiliation \ \FROM project_event \ \ LEFT JOIN user_entity ON user_entity.uuid = project_event.created_by \ \WHERE project_event.tenant_uuid = ? \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectFileDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectFileDAO.hs index 928b4f82f..532bfad3f 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectFileDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectFileDAO.hs @@ -67,7 +67,8 @@ findProjectFilesPage mQuery mProjectUuid pageable sort = do \ created_by.first_name, \ \ created_by.last_name, \ \ created_by.email, \ - \ created_by.image_url \ + \ created_by.image_url, \ + \ created_by.affiliation \ \FROM project_file file \ \LEFT JOIN user_entity created_by ON created_by.uuid = file.created_by AND created_by.tenant_uuid = file.tenant_uuid \ \LEFT JOIN project ON project.uuid = file.project_uuid AND project.tenant_uuid = file.tenant_uuid \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectMigrationDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectMigrationDAO.hs deleted file mode 100644 index e5aa87f8b..000000000 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectMigrationDAO.hs +++ /dev/null @@ -1,68 +0,0 @@ -module Wizard.Database.DAO.Project.ProjectMigrationDAO where - -import Control.Monad.Reader (asks) -import Data.String -import qualified Data.UUID as U -import Database.PostgreSQL.Simple -import Database.PostgreSQL.Simple.ToField -import Database.PostgreSQL.Simple.ToRow -import GHC.Int - -import Wizard.Database.DAO.Common -import Wizard.Database.Mapping.Project.Migration.ProjectMigration () -import Wizard.Model.Context.AppContext -import Wizard.Model.Context.ContextLenses () -import Wizard.Model.Project.Migration.ProjectMigration - -entityName = "project_migration" - -pageLabel = "migrations" - -findProjectMigrations :: AppContextM [ProjectMigration] -findProjectMigrations = do - tenantUuid <- asks currentTenantUuid - createFindEntitiesByFn entityName [tenantQueryUuid tenantUuid] - -findProjectMigrationsByOldProjectUuid :: U.UUID -> AppContextM [ProjectMigration] -findProjectMigrationsByOldProjectUuid oldProjectUuid = do - tenantUuid <- asks currentTenantUuid - createFindEntitiesByFn entityName [tenantQueryUuid tenantUuid, ("old_project_uuid", U.toString oldProjectUuid)] - -findProjectMigrationByNewProjectUuid :: U.UUID -> AppContextM ProjectMigration -findProjectMigrationByNewProjectUuid newProjectUuid = do - tenantUuid <- asks currentTenantUuid - createFindEntityByFn entityName [tenantQueryUuid tenantUuid, ("new_project_uuid", U.toString newProjectUuid)] - -findProjectMigrationByNewProjectUuid' :: U.UUID -> AppContextM (Maybe ProjectMigration) -findProjectMigrationByNewProjectUuid' newProjectUuid = do - tenantUuid <- asks currentTenantUuid - createFindEntityByFn' entityName [tenantQueryUuid tenantUuid, ("new_project_uuid", U.toString newProjectUuid)] - -insertProjectMigration :: ProjectMigration -> AppContextM Int64 -insertProjectMigration ms = do - let sql = - fromString - "INSERT INTO project_migration VALUES (?, ?, ?::uuid[], ?)" - let params = toRow ms - logQuery sql params - let action conn = execute conn sql params - runDB action - -updateProjectMigrationByNewProjectUuid :: ProjectMigration -> AppContextM Int64 -updateProjectMigrationByNewProjectUuid ms = do - tenantUuid <- asks currentTenantUuid - let sql = - fromString - "UPDATE project_migration SET old_project_uuid = ?, new_project_uuid = ?, resolved_question_uuids = ?::uuid[], tenant_uuid = ? WHERE tenant_uuid = ? AND new_project_uuid = ?" - let params = toRow ms ++ [toField tenantUuid, toField ms.newProjectUuid] - logQuery sql params - let action conn = execute conn sql params - runDB action - -deleteProjectMigrations :: AppContextM Int64 -deleteProjectMigrations = createDeleteEntitiesFn entityName - -deleteProjectMigrationByNewProjectUuid :: U.UUID -> AppContextM Int64 -deleteProjectMigrationByNewProjectUuid newProjectUuid = do - tenantUuid <- asks currentTenantUuid - createDeleteEntityByFn entityName [tenantQueryUuid tenantUuid, ("new_project_uuid", U.toString newProjectUuid)] diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectUserDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectUserDAO.hs index 57d11a996..21d5f8d39 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectUserDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectUserDAO.hs @@ -76,7 +76,8 @@ findProjectUserSuggestionsPage projectUuid perm mQuery pageable sort = \ u.first_name, \ \ u.last_name, \ \ u.email, \ - \ u.image_url \ + \ u.image_url, \ + \ u.affiliation \ \ FROM project_perm_user \ \ JOIN user_entity u ON project_perm_user.user_uuid = u.uuid AND project_perm_user.tenant_uuid = u.tenant_uuid \ \ WHERE project_perm_user.project_uuid = ? \ @@ -89,7 +90,8 @@ findProjectUserSuggestionsPage projectUuid perm mQuery pageable sort = \ u.first_name, \ \ u.last_name, \ \ u.email, \ - \ u.image_url \ + \ u.image_url, \ + \ u.affiliation \ \ FROM project_perm_group \ \ LEFT JOIN user_group_membership ug_membership ON ug_membership.user_group_uuid = project_perm_group.user_group_uuid AND ug_membership.tenant_uuid = project_perm_group.tenant_uuid \ \ LEFT JOIN user_entity u ON u.uuid = ug_membership.user_uuid AND u.tenant_uuid = project_perm_group.tenant_uuid \ diff --git a/wizard-server/src/Wizard/Database/DAO/Project/ProjectVersionDAO.hs b/wizard-server/src/Wizard/Database/DAO/Project/ProjectVersionDAO.hs index 5c63f53e4..efaaab2f8 100644 --- a/wizard-server/src/Wizard/Database/DAO/Project/ProjectVersionDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Project/ProjectVersionDAO.hs @@ -49,7 +49,8 @@ findProjectVersionListByProjectUuidAndCreatedAt projectUuid mCreatedAt = do \ u.first_name, \ \ u.last_name, \ \ u.email, \ - \ u.image_url \ + \ u.image_url, \ + \ u.affiliation \ \FROM project_version v \ \JOIN user_entity u ON u.uuid = v.created_by AND u.tenant_uuid = v.tenant_uuid ${createdAtCondition} \ \WHERE v.tenant_uuid = ? AND v.project_uuid = ? \ diff --git a/wizard-server/src/Wizard/Database/DAO/Submission/SubmissionDAO.hs b/wizard-server/src/Wizard/Database/DAO/Submission/SubmissionDAO.hs index 612270d0a..ba1d93cf1 100644 --- a/wizard-server/src/Wizard/Database/DAO/Submission/SubmissionDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/Submission/SubmissionDAO.hs @@ -49,7 +49,8 @@ findSubmissionsByDocumentUuid documentUuid = do \ user_entity.first_name, \ \ user_entity.last_name, \ \ gravatar_hash(user_entity.email), \ - \ user_entity.image_url \ + \ user_entity.image_url, \ + \ user_entity.affiliation \ \FROM submission \ \LEFT JOIN config_submission_service service ON service.tenant_uuid = submission.tenant_uuid AND service.id = submission.service_id \ \LEFT JOIN user_entity ON user_entity.tenant_uuid = submission.tenant_uuid AND user_entity.uuid = submission.created_by \ diff --git a/wizard-server/src/Wizard/Database/DAO/User/UserDAO.hs b/wizard-server/src/Wizard/Database/DAO/User/UserDAO.hs index 58407c46d..3b21ad13a 100644 --- a/wizard-server/src/Wizard/Database/DAO/User/UserDAO.hs +++ b/wizard-server/src/Wizard/Database/DAO/User/UserDAO.hs @@ -77,7 +77,7 @@ findUserSuggestionsPage mQuery mSelectUuids mExcludeUuids pageable sort = do pageLabel pageable sort - "uuid, first_name, last_name, gravatar_hash(email), image_url" + "uuid, first_name, last_name, gravatar_hash(email), image_url, affiliation" condition ([regexM mQuery, regexM mQuery, U.toString tenantUuid] ++ fromMaybe [] mSelectUuids ++ fromMaybe [] mExcludeUuids) @@ -91,7 +91,7 @@ findUsersByUserGroupUuid userGroupUuid = do tenantUuid <- asks currentTenantUuid let sql = fromString - "SELECT u.uuid, u.first_name, u.last_name, u.email, u.image_url, ugm.type \ + "SELECT u.uuid, u.first_name, u.last_name, u.email, u.image_url, u.affiliation, ugm.type \ \FROM user_group_membership ugm \ \JOIN user_entity u ON u.uuid = ugm.user_uuid AND u.tenant_uuid = ugm.tenant_uuid \ \WHERE ugm.user_group_uuid = ? AND ugm.tenant_uuid = ? \ diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadAssigned.hs b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadAssigned.hs index 370f50480..20a78015c 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadAssigned.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadAssigned.hs @@ -23,6 +23,7 @@ instance FromRow ProjectCommentThreadAssigned where mCreatedByLastName <- fieldWith (optionalField fromField) mCreatedByEmail <- fieldWith (optionalField fromField) mCreatedByImageUrl <- fieldWith (optionalField fromField) + mCreatedByAffiliation <- fieldWith (optionalField fromField) let createdBy = case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByEmail) of (Just createdByUuid, Just createdByFirstName, Just createdByLastName, Just createdByEmail) -> @@ -33,6 +34,7 @@ instance FromRow ProjectCommentThreadAssigned where , lastName = createdByLastName , imageUrl = mCreatedByImageUrl , gravatarHash = createGravatarHash createdByEmail + , affiliation = mCreatedByAffiliation } _ -> Nothing return ProjectCommentThreadAssigned {..} diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadList.hs b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadList.hs index bd345503a..dab380eae 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadList.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadList.hs @@ -26,6 +26,7 @@ instance FromRow ProjectCommentThreadList where mAssignedToLastName <- fieldWith (optionalField fromField) mAssignedToEmail <- fieldWith (optionalField fromField) mAssignedToImageUrl <- fieldWith (optionalField fromField) + mAssignedToAffiliation <- fieldWith (optionalField fromField) let assignedTo = case (mAssignedToUuid, mAssignedToFirstName, mAssignedToLastName, mAssignedToEmail) of (Just assignedToUuid, Just assignedToFirstName, Just assignedToLastName, Just assignedToEmail) -> @@ -36,6 +37,7 @@ instance FromRow ProjectCommentThreadList where , lastName = assignedToLastName , imageUrl = mAssignedToImageUrl , gravatarHash = createGravatarHash assignedToEmail + , affiliation = mAssignedToAffiliation } _ -> Nothing mCreatedByUuid <- fieldWith (optionalField fromField) @@ -43,6 +45,7 @@ instance FromRow ProjectCommentThreadList where mCreatedByLastName <- fieldWith (optionalField fromField) mCreatedByEmail <- fieldWith (optionalField fromField) mCreatedByImageUrl <- fieldWith (optionalField fromField) + mCreatedByAffiliation <- fieldWith (optionalField fromField) let createdBy = case (mCreatedByUuid, mCreatedByFirstName, mCreatedByLastName, mCreatedByEmail) of (Just createdByUuid, Just createdByFirstName, Just createdByLastName, Just createdByEmail) -> @@ -53,6 +56,7 @@ instance FromRow ProjectCommentThreadList where , lastName = createdByLastName , imageUrl = mCreatedByImageUrl , gravatarHash = createGravatarHash createdByEmail + , affiliation = mCreatedByAffiliation } _ -> Nothing commentsArray <- fromPGArray <$> field @@ -81,5 +85,9 @@ parseComment commentS = "" -> Nothing value -> Just value , gravatarHash = createGravatarHash $ parts !! 7 + , affiliation = + case parts !! 9 of + "" -> Nothing + value -> Just value } } diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadNotification.hs b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadNotification.hs index 396238f72..7c11f2207 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadNotification.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/Comment/ProjectCommentThreadNotification.hs @@ -30,6 +30,7 @@ instance FromRow ProjectCommentThreadNotification where , lastName = assignedToLastName , imageUrl = Nothing , email = assignedToEmail + , affiliation = Nothing } mAssignedByUuid <- fieldWith (optionalField fromField) mAssignedByFirstName <- fieldWith (optionalField fromField) @@ -45,6 +46,7 @@ instance FromRow ProjectCommentThreadNotification where , lastName = assignedByLastName , imageUrl = Nothing , email = assignedByEmail + , affiliation = Nothing } _ -> Nothing text <- field diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/File/ProjectFileList.hs b/wizard-server/src/Wizard/Database/Mapping/Project/File/ProjectFileList.hs index d186dd56c..56575aeb1 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/File/ProjectFileList.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/File/ProjectFileList.hs @@ -21,9 +21,10 @@ instance FromRow ProjectFileList where createdByLastName <- field createdByEmail <- field createdByImageUrl <- field + createdByAffiliation <- field let createdBy = - case (createdByUuid, createdByFirstName, createdByLastName, createdByEmail, createdByImageUrl) of - (Just uuid, Just firstName, Just lastName, Just email, imageUrl) -> + case (createdByUuid, createdByFirstName, createdByLastName, createdByEmail, createdByImageUrl, createdByAffiliation) of + (Just uuid, Just firstName, Just lastName, Just email, imageUrl, affiliation) -> let gravatarHash = createGravatarHash email in Just UserSuggestion {..} _ -> Nothing diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/Migration/ProjectMigration.hs b/wizard-server/src/Wizard/Database/Mapping/Project/Migration/ProjectMigration.hs deleted file mode 100644 index 150c7990b..000000000 --- a/wizard-server/src/Wizard/Database/Mapping/Project/Migration/ProjectMigration.hs +++ /dev/null @@ -1,25 +0,0 @@ -module Wizard.Database.Mapping.Project.Migration.ProjectMigration where - -import Database.PostgreSQL.Simple -import Database.PostgreSQL.Simple.FromRow -import Database.PostgreSQL.Simple.ToField -import Database.PostgreSQL.Simple.ToRow -import Database.PostgreSQL.Simple.Types - -import Wizard.Model.Project.Migration.ProjectMigration - -instance ToRow ProjectMigration where - toRow ProjectMigration {..} = - [ toField oldProjectUuid - , toField newProjectUuid - , toField . PGArray $ resolvedQuestionUuids - , toField tenantUuid - ] - -instance FromRow ProjectMigration where - fromRow = do - oldProjectUuid <- field - newProjectUuid <- field - resolvedQuestionUuids <- fromPGArray <$> field - tenantUuid <- field - return $ ProjectMigration {..} diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectAcl.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectAcl.hs index 291f22c56..68f41b473 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectAcl.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectAcl.hs @@ -43,6 +43,10 @@ parseUserPermission projectUuid permission = case parts !! 6 of "" -> Nothing imageUrl -> Just imageUrl + , affiliation = + case parts !! 7 of + "" -> Nothing + affiliation -> Just affiliation } } parseGroupPermission :: U.UUID -> String -> ProjectPermDTO diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetail.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetail.hs index 4d2b5e7d0..880026e3e 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetail.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetail.hs @@ -21,7 +21,6 @@ instance FromRow ProjectDetail where knowledgeModelPackage <- fieldKnowledgeModelPackageSuggestion selectedQuestionTagUuids <- fromPGArray <$> field isTemplate <- field - migrationUuid <- field permissions <- loadPermissions uuid fileCount <- field return $ ProjectDetail {..} diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailPreview.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailPreview.hs index 4b1a18904..6ded686d4 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailPreview.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailPreview.hs @@ -21,7 +21,6 @@ instance FromRow ProjectDetailPreview where knowledgeModelPackage <- fieldKnowledgeModelPackageSuggestion isTemplate <- field documentTemplateUuid <- field - migrationUuid <- field permissions <- loadPermissions uuid mFormatUuid <- field mFormatName <- field diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailQuestionnaire.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailQuestionnaire.hs index 88cbbd7d7..27470367d 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailQuestionnaire.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailQuestionnaire.hs @@ -27,7 +27,6 @@ instance FromRow ProjectDetailQuestionnaire where selectedQuestionTagUuids <- fromPGArray <$> field language <- field isTemplate <- field - migrationUuid <- field permissions <- loadPermissions uuid mFiles <- fieldWith (optionalField fromField) let files = diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailSettings.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailSettings.hs index f6ce2f2b8..9e6dbd903 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailSettings.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectDetailSettings.hs @@ -33,7 +33,6 @@ instance FromRow ProjectDetailSettings where selectedQuestionTagUuids <- fromPGArray <$> field language <- field formatUuid <- field - migrationUuid <- field permissions <- loadPermissions uuid knowledgeModelPackageUuid <- field knowledgeModelPackageName <- field @@ -66,17 +65,21 @@ instance FromRow ProjectDetailSettings where let availableLocales = [] mDocumentTemplateId <- field mDocumentTemplateName <- field + mDocumentTemplateOrganizationId <- field + mDocumentTemplateTemplateId <- field mDocumentTemplateVersion <- field mDocumentTemplatePhase <- field mDocumentTemplateDescription <- field mDocumentTemplateFormats <- fieldWith (optionalField fromJSONField) let documentTemplate = - case (mDocumentTemplateId, mDocumentTemplateName, mDocumentTemplateVersion, mDocumentTemplatePhase, mDocumentTemplateDescription, mDocumentTemplateFormats) of - (Just documentTemplateUuid, Just documentTemplateName, Just documentTemplateVersion, Just documentTemplatePhase, Just documentTemplateDescription, Just documentTemplateFormats) -> + case (mDocumentTemplateId, mDocumentTemplateName, mDocumentTemplateOrganizationId, mDocumentTemplateTemplateId, mDocumentTemplateVersion, mDocumentTemplatePhase, mDocumentTemplateDescription, mDocumentTemplateFormats) of + (Just documentTemplateUuid, Just documentTemplateName, Just documentTemplateOrganizationId, Just documentTemplateTemplateId, Just documentTemplateVersion, Just documentTemplatePhase, Just documentTemplateDescription, Just documentTemplateFormats) -> Just $ DocumentTemplateDTO { uuid = documentTemplateUuid , name = documentTemplateName + , organizationId = documentTemplateOrganizationId + , templateId = documentTemplateTemplateId , version = documentTemplateVersion , phase = documentTemplatePhase , description = documentTemplateDescription @@ -85,12 +88,14 @@ instance FromRow ProjectDetailSettings where _ -> Nothing let documentTemplatePhase = mDocumentTemplatePhase mDocumentTemplateMetamodelVersion <- field - let documentTemplateState = + let documentTemplateSupportState = case mDocumentTemplateMetamodelVersion of Just metamodelVersion -> if isDocumentTemplateUnsupported metamodelVersion then Just UnsupportedMetamodelVersionDocumentTemplateState else Just DefaultDocumentTemplateState _ -> Nothing + knowledgeModelState <- field + documentTemplateState <- field fileCount <- field return $ ProjectDetailSettings {..} diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectList.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectList.hs index 8f24e4979..707e2fbce 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectList.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectList.hs @@ -29,7 +29,8 @@ instance FromRow ProjectList where isTemplate <- field createdAt <- field updatedAt <- field - state <- field + knowledgeModelState <- field + documentTemplateState <- field packageUuid <- field packageName <- field packageVersion <- field @@ -63,6 +64,10 @@ instance FromRow ProjectList where case parts !! 6 of "" -> Nothing imageUrl -> Just imageUrl + , affiliation = + case parts !! 7 of + "" -> Nothing + affiliation -> Just affiliation } } parseGroupPermission :: U.UUID -> String -> ProjectPermDTO diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectState.hs b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectState.hs index afa63b603..9f02891b3 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/ProjectState.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/ProjectState.hs @@ -5,5 +5,8 @@ import Database.PostgreSQL.Simple.FromField import Shared.Common.Database.Mapping.Common import Wizard.Model.Project.ProjectState -instance FromField ProjectState where +instance FromField KnowledgeModelProjectState where + fromField = fromFieldGenericEnum + +instance FromField DocumentTemplateProjectState where fromField = fromFieldGenericEnum diff --git a/wizard-server/src/Wizard/Database/Mapping/Project/Version/ProjectVersionList.hs b/wizard-server/src/Wizard/Database/Mapping/Project/Version/ProjectVersionList.hs index 07ea55b74..52a371c6f 100644 --- a/wizard-server/src/Wizard/Database/Mapping/Project/Version/ProjectVersionList.hs +++ b/wizard-server/src/Wizard/Database/Mapping/Project/Version/ProjectVersionList.hs @@ -20,9 +20,10 @@ instance FromRow ProjectVersionList where createdByLastName <- field createdByEmail <- field createdByImageUrl <- field + createdByAffiliation <- field let createdBy = - case (createdByUuid, createdByFirstName, createdByLastName, createdByEmail, createdByImageUrl) of - (Just uuid, Just firstName, Just lastName, Just email, imageUrl) -> + case (createdByUuid, createdByFirstName, createdByLastName, createdByEmail, createdByImageUrl, createdByAffiliation) of + (Just uuid, Just firstName, Just lastName, Just email, imageUrl, affiliation) -> let gravatarHash = createGravatarHash email in Just UserSuggestion {..} _ -> Nothing diff --git a/wizard-server/src/Wizard/Database/Migration/Development/Migration.hs b/wizard-server/src/Wizard/Database/Migration/Development/Migration.hs index edaf24ead..8653fac53 100644 --- a/wizard-server/src/Wizard/Database/Migration/Development/Migration.hs +++ b/wizard-server/src/Wizard/Database/Migration/Development/Migration.hs @@ -36,8 +36,6 @@ import qualified Wizard.Database.Migration.Development.PersistentCommand.Persist import qualified Wizard.Database.Migration.Development.Plugin.PluginMigration as Plugin import qualified Wizard.Database.Migration.Development.Plugin.PluginSchemaMigration as Plugin import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as Project -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as ProjectMigration -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationSchemaMigration as ProjectMigration import qualified Wizard.Database.Migration.Development.Project.ProjectSchemaMigration as Project import qualified Wizard.Database.Migration.Development.Registry.RegistryMigration as Registry import qualified Wizard.Database.Migration.Development.Registry.RegistrySchemaMigration as Registry @@ -86,7 +84,6 @@ runMigration = runAppContextWithBaseContext $ do KnowledgeModelEditor.dropTables KnowledgeModelCache.dropTables Document.dropTables - ProjectMigration.dropTables Project.dropTables KnowledgeModelSecret.dropTables KnowledgeModelLocale.dropTables @@ -132,7 +129,6 @@ runMigration = runAppContextWithBaseContext $ do Project.createTables DocumentTemplate.createDraftDataTable Document.createTables - ProjectMigration.createTables KnowledgeModelMigration.createTables Submission.createTables PersistentCommand.createTables @@ -171,7 +167,6 @@ runMigration = runAppContextWithBaseContext $ do Project.runMigration Feedback.runMigration Document.runMigration - ProjectMigration.runMigration KnowledgeModelMigration.runMigration PersistentCommand.runMigration Prefab.runMigration diff --git a/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/ProjectMigrations.hs b/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/ProjectMigrations.hs deleted file mode 100644 index 2cf82f0c1..000000000 --- a/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/ProjectMigrations.hs +++ /dev/null @@ -1,142 +0,0 @@ -module Wizard.Database.Migration.Development.Project.Data.ProjectMigrations where - -import qualified Data.Map.Strict as M - -import Shared.KnowledgeModel.Database.Migration.Development.KnowledgeModel.Data.KnowledgeModels -import Shared.KnowledgeModel.Database.Migration.Development.KnowledgeModel.Data.Package.KnowledgeModelPackages -import Shared.KnowledgeModel.Database.Migration.Development.KnowledgeModel.Data.Questions -import Shared.KnowledgeModel.Model.KnowledgeModel.KnowledgeModel -import Shared.KnowledgeModel.Model.KnowledgeModel.Package.KnowledgeModelPackage -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Database.Migration.Development.Project.Data.Projects -import Wizard.Database.Migration.Development.Tenant.Data.Tenants -import Wizard.Model.Project.Migration.ProjectMigration -import Wizard.Model.Project.Project -import Wizard.Model.Project.ProjectContent -import Wizard.Model.Tenant.Tenant -import qualified Wizard.Service.KnowledgeModel.Package.KnowledgeModelPackageMapper as KMP -import Wizard.Service.Project.ProjectMapper - -projectMigration :: ProjectMigration -projectMigration = - ProjectMigration - { oldProjectUuid = projectMigrationDto.oldProject.uuid - , newProjectUuid = projectMigrationDto.newProject.uuid - , resolvedQuestionUuids = [question2.uuid] - , tenantUuid = defaultTenant.uuid - } - -projectMigrationDto :: ProjectMigrationDTO -projectMigrationDto = - ProjectMigrationDTO - { oldProject = - toDetailProjectDTO - (toDetailQuestionnaire project4 (KMP.toSuggestion netherlandsKmPackage) (Just project4Upgraded.uuid) []) - M.empty - M.empty - km1Netherlands - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , newProject = - toDetailProjectDTO - (toDetailQuestionnaire project4Upgraded (KMP.toSuggestion netherlandsKmPackageV2) Nothing []) - M.empty - M.empty - km1NetherlandsV2 - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , resolvedQuestionUuids = [question2.uuid] - , tenantUuid = defaultTenant.uuid - } - -projectMigrationVisibleViewDto :: ProjectMigrationDTO -projectMigrationVisibleViewDto = - ProjectMigrationDTO - { oldProject = - toDetailProjectDTO - (toDetailQuestionnaire project4VisibleView (KMP.toSuggestion netherlandsKmPackage) (Just project4Upgraded.uuid) []) - M.empty - M.empty - km1Netherlands - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , newProject = - toDetailProjectDTO - (toDetailQuestionnaire project4VisibleViewUpgraded (KMP.toSuggestion netherlandsKmPackageV2) Nothing []) - M.empty - M.empty - km1NetherlandsV2 - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , resolvedQuestionUuids = projectMigrationDto.resolvedQuestionUuids - , tenantUuid = defaultTenant.uuid - } - -projectMigrationVisibleEditDto :: ProjectMigrationDTO -projectMigrationVisibleEditDto = - ProjectMigrationDTO - { oldProject = - toDetailProjectDTO - (toDetailQuestionnaire project4VisibleEdit (KMP.toSuggestion netherlandsKmPackage) (Just project4Upgraded.uuid) []) - M.empty - M.empty - km1Netherlands - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , newProject = - toDetailProjectDTO - (toDetailQuestionnaire project4VisibleEditUpgraded (KMP.toSuggestion netherlandsKmPackageV2) Nothing []) - M.empty - M.empty - km1NetherlandsV2 - project4Ctn.phaseUuid - project4Ctn.replies - project4Ctn.labels - Nothing - , resolvedQuestionUuids = projectMigrationDto.resolvedQuestionUuids - , tenantUuid = defaultTenant.uuid - } - -projectMigrationDtoEdited :: ProjectMigrationDTO -projectMigrationDtoEdited = - ProjectMigrationDTO - { oldProject = projectMigrationDto.oldProject - , newProject = projectMigrationDto.newProject - , resolvedQuestionUuids = [question2.uuid, question3.uuid] - , tenantUuid = projectMigrationDto.tenantUuid - } - -projectMigrationCreateDto :: ProjectMigrationCreateDTO -projectMigrationCreateDto = - ProjectMigrationCreateDTO - { targetKnowledgeModelPackageUuid = netherlandsKmPackageV2.uuid - , targetTagUuids = project4Upgraded.selectedQuestionTagUuids - } - -projectMigrationChangeDto :: ProjectMigrationChangeDTO -projectMigrationChangeDto = - ProjectMigrationChangeDTO - { resolvedQuestionUuids = projectMigrationDtoEdited.resolvedQuestionUuids - } - -differentProjectMigration :: ProjectMigration -differentProjectMigration = - ProjectMigration - { oldProjectUuid = differentProject.uuid - , newProjectUuid = differentProject.uuid - , resolvedQuestionUuids = [question2.uuid] - , tenantUuid = differentTenant.uuid - } diff --git a/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/Projects.hs b/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/Projects.hs index d61b8a9cc..6215c8fbe 100644 --- a/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/Projects.hs +++ b/wizard-server/src/Wizard/Database/Migration/Development/Project/Data/Projects.hs @@ -15,6 +15,7 @@ import Shared.KnowledgeModel.Model.KnowledgeModel.KnowledgeModel import Shared.KnowledgeModel.Model.KnowledgeModel.Package.KnowledgeModelPackage import Wizard.Api.Resource.Project.Acl.ProjectPermDTO import Wizard.Api.Resource.Project.Detail.ProjectDetailWsDTO +import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO import Wizard.Api.Resource.Project.ProjectContentChangeDTO import Wizard.Api.Resource.Project.ProjectContentDTO import Wizard.Api.Resource.Project.ProjectCreateDTO @@ -127,7 +128,7 @@ project1CtnRevertedDto = } project1Dto :: ProjectDTO -project1Dto = toSimpleDTO project1 germanyKmPackage DefaultProjectState [project1AlbertEditProjectPermDto] +project1Dto = toSimpleDTO project1 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project1AlbertEditProjectPermDto] project1Create :: ProjectCreateDTO project1Create = @@ -263,7 +264,7 @@ project2EventsEdited :: [ProjectEvent] project2EventsEdited = fEventsEdited project2Uuid project2Dto :: ProjectDTO -project2Dto = toSimpleDTO project2 germanyKmPackage DefaultProjectState [project2AlbertEditProjectPermDto] +project2Dto = toSimpleDTO project2 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project2AlbertEditProjectPermDto] project2AlbertEditProjectPerm :: ProjectPerm project2AlbertEditProjectPerm = @@ -324,7 +325,7 @@ project3EventsEdited :: [ProjectEvent] project3EventsEdited = fEventsEdited project3Uuid project3Dto :: ProjectDTO -project3Dto = toSimpleDTO project3 germanyKmPackage DefaultProjectState [] +project3Dto = toSimpleDTO project3 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [] -- ------------------------------------------------------------------------ -- ------------------------------------------------------------------------ @@ -380,28 +381,13 @@ project4VisibleEdit = project4 {visibility = VisibleEditProjectVisibility} project4VisibleEditEvents :: [ProjectEvent] project4VisibleEditEvents = [sphse_2' project4VisibleEdit.uuid] -project4Upgraded :: Project -project4Upgraded = - project4 - { uuid = u' "5deabef8-f526-421c-90e2-dd7aed1a25c5" - , knowledgeModelPackageUuid = netherlandsKmPackageV2.uuid +projectMigrationCreateDto :: ProjectMigrationCreateDTO +projectMigrationCreateDto = + ProjectMigrationCreateDTO + { targetKnowledgeModelPackageUuid = netherlandsKmPackageV2.uuid + , targetTagUuids = [] } -project4UpgradedEvents :: [ProjectEvent] -project4UpgradedEvents = [sphse_2' project4Upgraded.uuid] - -project4VisibleViewUpgraded :: Project -project4VisibleViewUpgraded = project4Upgraded {visibility = VisibleViewProjectVisibility} - -project4VisibleViewUpgradedEvents :: [ProjectEvent] -project4VisibleViewUpgradedEvents = [sphse_2' project4VisibleViewUpgraded.uuid] - -project4VisibleEditUpgraded :: Project -project4VisibleEditUpgraded = project4Upgraded {visibility = VisibleEditProjectVisibility} - -project4VisibleEditUpgradedEvents :: [ProjectEvent] -project4VisibleEditUpgradedEvents = [sphse_2' project4VisibleEditUpgraded.uuid] - -- ------------------------------------------------------------------------ -- ------------------------------------------------------------------------ project5Uuid :: U.UUID @@ -469,7 +455,7 @@ project6EventsEdited :: [ProjectEvent] project6EventsEdited = fEventsEdited project6Uuid project6Dto :: ProjectDTO -project6Dto = toSimpleDTO project6 germanyKmPackage DefaultProjectState [project6AlbertEditProjectPermDto] +project6Dto = toSimpleDTO project6 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project6AlbertEditProjectPermDto] project6AlbertEditProjectPerm :: ProjectPerm project6AlbertEditProjectPerm = @@ -701,7 +687,7 @@ project11Ctn :: ProjectContent project11Ctn = project1Ctn project11Dto :: ProjectDTO -project11Dto = toSimpleDTO project11 germanyKmPackage DefaultProjectState [project11AlbertEditProjectPermDto] +project11Dto = toSimpleDTO project11 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project11AlbertEditProjectPermDto] project11AlbertEditProjectPerm :: ProjectPerm project11AlbertEditProjectPerm = @@ -743,7 +729,7 @@ project12Ctn = project1Ctn project12Dto :: ProjectDTO project12Dto = - toSimpleDTO project12 germanyKmPackage DefaultProjectState [project12NikolaEditProjectPermDto, project12AlbertEditProjectPermDto] + toSimpleDTO project12 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project12NikolaEditProjectPermDto, project12AlbertEditProjectPermDto] project12AlbertEditProjectPerm :: ProjectPerm project12AlbertEditProjectPerm = @@ -795,7 +781,7 @@ project13Ctn :: ProjectContent project13Ctn = project1Ctn project13Dto :: ProjectDTO -project13Dto = toSimpleDTO project13 germanyKmPackage DefaultProjectState [project13NikolaCommentProjectPermDto] +project13Dto = toSimpleDTO project13 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project13NikolaCommentProjectPermDto] project13NikolaCommentProjectPerm :: ProjectPerm project13NikolaCommentProjectPerm = @@ -829,7 +815,7 @@ project14Ctn :: ProjectContent project14Ctn = project1Ctn project14Dto :: ProjectDTO -project14Dto = toSimpleDTO project14 amsterdamKmPackage DefaultProjectState [project14NikolaEditProjectPermDto] +project14Dto = toSimpleDTO project14 amsterdamKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project14NikolaEditProjectPermDto] project14NikolaEditProjectPerm :: ProjectPerm project14NikolaEditProjectPerm = @@ -897,7 +883,7 @@ project15Versions :: [ProjectVersion] project15Versions = qVersions project15Uuid project15Dto :: ProjectDTO -project15Dto = toSimpleDTO project15 germanyKmPackage DefaultProjectState [project15GroupEditProjectPermDto] +project15Dto = toSimpleDTO project15 germanyKmPackage UpToDateKnowledgeModelProjectState (Just UpToDateDocumentTemplateProjectState) [project15GroupEditProjectPermDto] project15GroupEditProjectPerm :: ProjectPerm project15GroupEditProjectPerm = diff --git a/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationMigration.hs b/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationMigration.hs deleted file mode 100644 index 0c3dcee6d..000000000 --- a/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationMigration.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Wizard.Database.Migration.Development.Project.ProjectMigrationMigration where - -import Shared.Common.Constant.Component -import Shared.Common.Util.Logger -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations - -runMigration = do - logInfo _CMP_MIGRATION "(Migration/Project) started" - deleteProjectMigrations - insertProjectMigration differentProjectMigration - logInfo _CMP_MIGRATION "(Migration/Project) ended" diff --git a/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationSchemaMigration.hs b/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationSchemaMigration.hs deleted file mode 100644 index 07cbb522e..000000000 --- a/wizard-server/src/Wizard/Database/Migration/Development/Project/ProjectMigrationSchemaMigration.hs +++ /dev/null @@ -1,34 +0,0 @@ -module Wizard.Database.Migration.Development.Project.ProjectMigrationSchemaMigration where - -import Database.PostgreSQL.Simple -import GHC.Int - -import Shared.Common.Util.Logger -import Wizard.Database.DAO.Common -import Wizard.Model.Context.AppContext -import Wizard.Model.Context.ContextLenses () - -dropTables :: AppContextM Int64 -dropTables = do - logInfo _CMP_MIGRATION "(Table/Migration/Project) drop tables" - let sql = "DROP TABLE IF EXISTS project_migration;" - let action conn = execute_ conn sql - runDB action - -createTables :: AppContextM Int64 -createTables = do - logInfo _CMP_MIGRATION "(Table/Migration/Project) create table" - let sql = - "CREATE TABLE project_migration \ - \( \ - \ old_project_uuid uuid NOT NULL, \ - \ new_project_uuid uuid NOT NULL, \ - \ resolved_question_uuids uuid[] NOT NULL, \ - \ tenant_uuid uuid NOT NULL, \ - \ CONSTRAINT project_migration_pk PRIMARY KEY (old_project_uuid, new_project_uuid), \ - \ CONSTRAINT project_migration_old_project_uuid_fk FOREIGN KEY (old_project_uuid) REFERENCES project (uuid) ON DELETE CASCADE, \ - \ CONSTRAINT project_migration_new_project_uuid_fk FOREIGN KEY (new_project_uuid) REFERENCES project (uuid) ON DELETE CASCADE, \ - \ CONSTRAINT project_migration_tenant_uuid_fk FOREIGN KEY (tenant_uuid) REFERENCES tenant (uuid) ON DELETE CASCADE \ - \);" - let action conn = execute_ conn sql - runDB action diff --git a/wizard-server/src/Wizard/Database/Migration/Production/Migration.hs b/wizard-server/src/Wizard/Database/Migration/Production/Migration.hs index a35754125..a303acc9c 100644 --- a/wizard-server/src/Wizard/Database/Migration/Production/Migration.hs +++ b/wizard-server/src/Wizard/Database/Migration/Production/Migration.hs @@ -70,6 +70,7 @@ import qualified Wizard.Database.Migration.Production.Migration_0065_idToUuid.Mi import qualified Wizard.Database.Migration.Production.Migration_0066_tcKnowledgeModel.Migration as M_0066 import qualified Wizard.Database.Migration.Production.Migration_0067_openIdClient.Migration as M_0067 import qualified Wizard.Database.Migration.Production.Migration_0068_roles.Migration as M_0068 +import qualified Wizard.Database.Migration.Production.Migration_0069_setPhaseEventFix.Migration as M_0069 migrationDefinitions :: [MigrationDefinition] migrationDefinitions = @@ -141,4 +142,5 @@ migrationDefinitions = , M_0066.definition , M_0067.definition , M_0068.definition + , M_0069.definition ] diff --git a/wizard-server/src/Wizard/Database/Migration/Production/Migration_0069_setPhaseEventFix/Migration.hs b/wizard-server/src/Wizard/Database/Migration/Production/Migration_0069_setPhaseEventFix/Migration.hs new file mode 100644 index 000000000..93fa78319 --- /dev/null +++ b/wizard-server/src/Wizard/Database/Migration/Production/Migration_0069_setPhaseEventFix/Migration.hs @@ -0,0 +1,32 @@ +module Wizard.Database.Migration.Production.Migration_0069_setPhaseEventFix.Migration ( + definition, +) where + +import Control.Monad.Logger +import Control.Monad.Reader (liftIO) +import Data.Pool (Pool, withResource) +import Database.PostgreSQL.Migration.Entity +import Database.PostgreSQL.Simple + +definition = (meta, migrate) + +meta = MigrationMeta {mmNumber = 69, mmName = "Fix set phase event", mmDescription = "Repair SetPhaseEvent project events with a NULL array element in value and remove the project migration walkthrough"} + +migrate :: Pool Connection -> LoggingT IO (Maybe Error) +migrate dbPool = do + fixSetPhaseEvents dbPool + dropProjectMigrations dbPool + +fixSetPhaseEvents dbPool = do + let sql = "UPDATE project_event SET value = '{}' WHERE event_type = 'SetPhaseEvent' AND array_position(value, NULL) IS NOT NULL;" + let action conn = execute_ conn sql + liftIO $ withResource dbPool action + return Nothing + +dropProjectMigrations dbPool = do + let sql = + "DELETE FROM project WHERE uuid IN (SELECT new_project_uuid FROM project_migration); \ + \DROP TABLE project_migration;" + let action conn = execute_ conn sql + liftIO $ withResource dbPool action + return Nothing diff --git a/wizard-server/src/Wizard/Localization/Messages/Public.hs b/wizard-server/src/Wizard/Localization/Messages/Public.hs index e4314c78a..02900d763 100644 --- a/wizard-server/src/Wizard/Localization/Messages/Public.hs +++ b/wizard-server/src/Wizard/Localization/Messages/Public.hs @@ -20,9 +20,6 @@ _ERROR_VALIDATION__DOC_TML_FILE_OR_ASSET_UNIQUENESS = _ERROR_VALIDATION__KM_MIGRATION_UNIQUENESS = LocaleRecord "error.validation.km_migration_uniqueness" "Migration of Knowledge Model already exists" [] -_ERROR_VALIDATION__PROJECT_MIGRATION_UNIQUENESS = - LocaleRecord "error.validation.project_migration_uniqueness" "Project Migration already exists" [] - _ERROR_VALIDATION__USER_EMAIL_UNIQUENESS email = LocaleRecord "error.validation.user_email_uniqueness" "User (email: '%s') already exists" [email] @@ -150,12 +147,6 @@ _ERROR_SERVICE_PB__PULL_NON_EXISTING_PKG pkgId = [pkgId] -- Project -_ERROR_SERVICE_PROJECT__PROJECT_CANT_BE_DELETED_BECAUSE_IT_IS_USED_IN_MIGRATION = - LocaleRecord - "error.service.project.project_cant_be_deleted_because_it_is_used_in_migration" - "Project can't be deleted because it's used in some project migration" - [] - _ERROR_SERVICE_PROJECT_COLLABORATION__FORCE_DISCONNECT projectUuid = LocaleRecord "error.service.project.collaboration.force_disconnect" diff --git a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetail.hs b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetail.hs index 47308b8ff..826bc8b8b 100644 --- a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetail.hs +++ b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetail.hs @@ -15,7 +15,6 @@ data ProjectDetail = ProjectDetail , knowledgeModelPackage :: KnowledgeModelPackageSuggestion , selectedQuestionTagUuids :: [U.UUID] , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , fileCount :: Int } diff --git a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailPreview.hs b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailPreview.hs index 7f639487b..bbf7ab7e4 100644 --- a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailPreview.hs +++ b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailPreview.hs @@ -15,7 +15,6 @@ data ProjectDetailPreview = ProjectDetailPreview , sharing :: ProjectSharing , knowledgeModelPackage :: KnowledgeModelPackageSuggestion , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , documentTemplateUuid :: Maybe U.UUID , format :: Maybe DocumentTemplateFormatSimple diff --git a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailQuestionnaire.hs b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailQuestionnaire.hs index 1500f256b..b7e286050 100644 --- a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailQuestionnaire.hs +++ b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailQuestionnaire.hs @@ -17,7 +17,6 @@ data ProjectDetailQuestionnaire = ProjectDetailQuestionnaire , selectedQuestionTagUuids :: [U.UUID] , language :: Maybe String , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , files :: [ProjectFileSimple] } diff --git a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailSettings.hs b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailSettings.hs index 34717f37e..34b2b93c9 100644 --- a/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailSettings.hs +++ b/wizard-server/src/Wizard/Model/Project/Detail/ProjectDetailSettings.hs @@ -11,6 +11,7 @@ import Wizard.Api.Resource.Project.Acl.ProjectPermDTO import Wizard.Model.DocumentTemplate.DocumentTemplateState import Wizard.Model.KnowledgeModel.Locale.KnowledgeModelLocaleList import Wizard.Model.Project.Project +import Wizard.Model.Project.ProjectState data ProjectDetailSettings = ProjectDetailSettings { uuid :: U.UUID @@ -19,16 +20,17 @@ data ProjectDetailSettings = ProjectDetailSettings , visibility :: ProjectVisibility , sharing :: ProjectSharing , isTemplate :: Bool - , migrationUuid :: Maybe U.UUID , permissions :: [ProjectPermDTO] , projectTags :: [String] , knowledgeModelPackageUuid :: U.UUID , knowledgeModelPackage :: KnowledgeModelPackageSimpleDTO , knowledgeModelTags :: [Tag] + , knowledgeModelState :: KnowledgeModelProjectState , language :: Maybe String , availableLocales :: [KnowledgeModelLocaleList] , documentTemplate :: Maybe DocumentTemplateDTO - , documentTemplateState :: Maybe DocumentTemplateState + , documentTemplateState :: Maybe DocumentTemplateProjectState + , documentTemplateSupportState :: Maybe DocumentTemplateState , documentTemplatePhase :: Maybe DocumentTemplatePhase , formatUuid :: Maybe U.UUID , selectedQuestionTagUuids :: [U.UUID] diff --git a/wizard-server/src/Wizard/Model/Project/Migration/ProjectMigration.hs b/wizard-server/src/Wizard/Model/Project/Migration/ProjectMigration.hs deleted file mode 100644 index 4213c2363..000000000 --- a/wizard-server/src/Wizard/Model/Project/Migration/ProjectMigration.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Wizard.Model.Project.Migration.ProjectMigration where - -import qualified Data.UUID as U -import GHC.Generics - -data ProjectMigration = ProjectMigration - { oldProjectUuid :: U.UUID - , newProjectUuid :: U.UUID - , resolvedQuestionUuids :: [U.UUID] - , tenantUuid :: U.UUID - } - deriving (Show, Eq, Generic) diff --git a/wizard-server/src/Wizard/Model/Project/ProjectList.hs b/wizard-server/src/Wizard/Model/Project/ProjectList.hs index ac851228a..25f3ef49b 100644 --- a/wizard-server/src/Wizard/Model/Project/ProjectList.hs +++ b/wizard-server/src/Wizard/Model/Project/ProjectList.hs @@ -15,7 +15,8 @@ data ProjectList = ProjectList , description :: Maybe String , visibility :: ProjectVisibility , sharing :: ProjectSharing - , state :: ProjectState + , knowledgeModelState :: KnowledgeModelProjectState + , documentTemplateState :: Maybe DocumentTemplateProjectState , knowledgeModelPackage :: KnowledgeModelPackageSimple , permissions :: [ProjectPermDTO] , isTemplate :: Bool @@ -31,7 +32,8 @@ instance Eq ProjectList where && a.description == b.description && a.visibility == b.visibility && a.sharing == b.sharing - && a.state == b.state + && a.knowledgeModelState == b.knowledgeModelState + && a.documentTemplateState == b.documentTemplateState && a.knowledgeModelPackage == b.knowledgeModelPackage && a.permissions == b.permissions && a.isTemplate == b.isTemplate diff --git a/wizard-server/src/Wizard/Model/Project/ProjectState.hs b/wizard-server/src/Wizard/Model/Project/ProjectState.hs index fc8bd36d5..d3927fb06 100644 --- a/wizard-server/src/Wizard/Model/Project/ProjectState.hs +++ b/wizard-server/src/Wizard/Model/Project/ProjectState.hs @@ -2,8 +2,12 @@ module Wizard.Model.Project.ProjectState where import GHC.Generics -data ProjectState - = DefaultProjectState - | MigratingProjectState - | OutdatedProjectState +data KnowledgeModelProjectState + = UpToDateKnowledgeModelProjectState + | OutdatedKnowledgeModelProjectState + deriving (Show, Eq, Generic, Read) + +data DocumentTemplateProjectState + = UpToDateDocumentTemplateProjectState + | OutdatedDocumentTemplateProjectState deriving (Show, Eq, Generic, Read) diff --git a/wizard-server/src/Wizard/Model/User/OnlineUserInfo.hs b/wizard-server/src/Wizard/Model/User/OnlineUserInfo.hs index 4dbb4c555..5a937ece9 100644 --- a/wizard-server/src/Wizard/Model/User/OnlineUserInfo.hs +++ b/wizard-server/src/Wizard/Model/User/OnlineUserInfo.hs @@ -15,6 +15,7 @@ data OnlineUserInfo , lastName :: String , gravatarHash :: String , imageUrl :: Maybe String + , affiliation :: Maybe String , colorNumber :: Int , role :: RoleSimple , groupUuids :: [U.UUID] diff --git a/wizard-server/src/Wizard/Model/User/UserProfile.hs b/wizard-server/src/Wizard/Model/User/UserProfile.hs index 3afe98eee..e63ffa6b1 100644 --- a/wizard-server/src/Wizard/Model/User/UserProfile.hs +++ b/wizard-server/src/Wizard/Model/User/UserProfile.hs @@ -16,6 +16,7 @@ data UserProfile = UserProfile , firstName :: String , lastName :: String , email :: String + , affiliation :: Maybe String , imageUrl :: Maybe String , role :: RoleSimple , lastSeenNewsId :: Maybe String diff --git a/wizard-server/src/Wizard/Service/Acl/AclMapper.hs b/wizard-server/src/Wizard/Service/Acl/AclMapper.hs index 26ed4afac..036626809 100644 --- a/wizard-server/src/Wizard/Service/Acl/AclMapper.hs +++ b/wizard-server/src/Wizard/Service/Acl/AclMapper.hs @@ -13,6 +13,7 @@ toUserMemberDTO user = , lastName = user.lastName , gravatarHash = createGravatarHash user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation } toUserGroupMemberDTO :: UserGroup -> MemberDTO diff --git a/wizard-server/src/Wizard/Service/DocumentTemplate/Bundle/DocumentTemplateBundleService.hs b/wizard-server/src/Wizard/Service/DocumentTemplate/Bundle/DocumentTemplateBundleService.hs index 68e19e439..20a382c4a 100644 --- a/wizard-server/src/Wizard/Service/DocumentTemplate/Bundle/DocumentTemplateBundleService.hs +++ b/wizard-server/src/Wizard/Service/DocumentTemplate/Bundle/DocumentTemplateBundleService.hs @@ -64,7 +64,7 @@ pullBundleFromRegistry :: Coordinate -> AppContextM DocumentTemplateSimple pullBundleFromRegistry coordinate = runInTransaction $ do checkPermission _DOCUMENT_TEMPLATES_MANAGE_ROLE_PERMISSION - checkDocumentTemplateLimit + checkDocumentTemplateLimit coordinate.organizationId coordinate.entityId tb <- catchError (retrieveDocumentTemplateBundleByCoordinate coordinate) handleError importAndConvertBundle tb True where @@ -78,7 +78,7 @@ importAndConvertBundle contentS fromRegistry = case fromDocumentTemplateArchive contentS of Right (bundle, assetContents) -> do checkPermission _DOCUMENT_TEMPLATES_MANAGE_ROLE_PERMISSION - checkDocumentTemplateLimit + checkDocumentTemplateLimit bundle.organizationId bundle.templateId let assetSize = foldl (\acc (_, content) -> acc + (fromIntegral . BS.length $ content)) 0 assetContents checkStorageSize assetSize uuid <- liftIO generateUuid diff --git a/wizard-server/src/Wizard/Service/KnowledgeModel/Bundle/KnowledgeModelBundleService.hs b/wizard-server/src/Wizard/Service/KnowledgeModel/Bundle/KnowledgeModelBundleService.hs index 73818b6b0..b7a2f021f 100644 --- a/wizard-server/src/Wizard/Service/KnowledgeModel/Bundle/KnowledgeModelBundleService.hs +++ b/wizard-server/src/Wizard/Service/KnowledgeModel/Bundle/KnowledgeModelBundleService.hs @@ -20,6 +20,7 @@ import Shared.Common.Constant.Component import Shared.Common.Localization.Messages.Internal import Shared.Common.Localization.Messages.Public import Shared.Common.Model.Error.Error +import Shared.Common.Model.Localization.LocaleRecord import Shared.Common.Util.List import Shared.Common.Util.Logger import Shared.Common.Util.Uuid @@ -50,7 +51,6 @@ import Wizard.Service.KnowledgeModel.Package.KnowledgeModelPackageValidation ( validateMaybePreviousPackageIdExistence, validatePackageIdUniqueness, ) -import Wizard.Service.Tenant.Limit.LimitService import WizardLib.Public.Api.Resource.TemporaryFile.TemporaryFileDTO import qualified WizardLib.Public.Service.TemporaryFile.TemporaryFileMapper as TemporaryFileMapper import WizardLib.Public.Service.TemporaryFile.TemporaryFileService @@ -91,7 +91,6 @@ pullBundleFromRegistry :: String -> AppContextM KnowledgeModelPackageSimpleDTO pullBundleFromRegistry pkgId = runInTransaction $ do checkPermission _KNOWLEDGE_MODELS_MANAGE_ROLE_PERMISSION - checkPackageLimit pb <- catchError (retrieveKnowledgeModelBundleById pkgId) handleError importAndConvertBundle pb True where @@ -104,7 +103,6 @@ importAndConvertBundle :: BSL.ByteString -> Bool -> AppContextM KnowledgeModelPa importAndConvertBundle contentS fromRegistry = runInTransaction $ do checkPermission _KNOWLEDGE_MODELS_MANAGE_ROLE_PERMISSION - checkPackageLimit case eitherDecode contentS of Right content -> do encodedPb <- migrateKnowledgeModelBundle content @@ -127,7 +125,9 @@ importBundle pb = pkg <- extractMainPackage pb validatePackageIdUniqueness (createCoordinate pkg) pkgs <- forM pb.packages importPackage - return . last $ catMaybes pkgs + case lastSafe . catMaybes $ pkgs of + Just createdPkg -> return createdPkg + Nothing -> throwError . UserError $ _ERROR_VALIDATION__PKG_ID_UNIQUENESS (show . createCoordinate $ pkg) where extractMainPackage pb = case find (\p -> p.pId == pb.bundleId) pb.packages of @@ -149,7 +149,7 @@ importPackage dto = let events = fmap KnowledgeModelPackageMapper.toEvent kmEvents validateKmValidity events pkg.previousPackageUuid let fixedKmEvents = fixTimestampsIfNeeded kmEvents - createdPkg <- createPackage (pkg, fixedKmEvents) + createdPkg <- catchError (createPackage (pkg, fixedKmEvents)) (handleCreatePackageError pkg) return . Just $ createdPkg where skipIfPackageIsAlreadyImported pkg callback = do @@ -157,6 +157,9 @@ importPackage dto = case eitherPackage of Nothing -> callback Just _ -> return Nothing + handleCreatePackageError pkg (UserError (LocaleRecord "error.database.unique_constraint_violation" _ _)) = + throwError . UserError $ _ERROR_VALIDATION__PKG_ID_UNIQUENESS (show . createCoordinate $ pkg) + handleCreatePackageError _ error = throwError error fixTimestampsIfNeeded :: [KnowledgeModelPackageEvent] -> [KnowledgeModelPackageEvent] fixTimestampsIfNeeded [] = [] diff --git a/wizard-server/src/Wizard/Service/KnowledgeModel/Editor/EditorMapper.hs b/wizard-server/src/Wizard/Service/KnowledgeModel/Editor/EditorMapper.hs index 5122cebf5..4bdf20c5a 100644 --- a/wizard-server/src/Wizard/Service/KnowledgeModel/Editor/EditorMapper.hs +++ b/wizard-server/src/Wizard/Service/KnowledgeModel/Editor/EditorMapper.hs @@ -59,7 +59,7 @@ toDetailDTO editor kmEditorEvents kmEditorReplies mPreviousPackage knowledgeMode , knowledgeModel = knowledgeModel , createdBy = editor.createdBy , createdAt = editor.createdAt - , updatedAt = editor.updatedAt + , updatedAt = maximum (editor.updatedAt : fmap (.createdAt) kmEditorEvents) } fromCreateDTO :: KnowledgeModelEditorCreateDTO -> U.UUID -> Maybe KnowledgeModelPackage -> U.UUID -> U.UUID -> UTCTime -> KnowledgeModelEditor diff --git a/wizard-server/src/Wizard/Service/KnowledgeModel/Package/KnowledgeModelPackageService.hs b/wizard-server/src/Wizard/Service/KnowledgeModel/Package/KnowledgeModelPackageService.hs index 57eea41ca..a24c5d2be 100644 --- a/wizard-server/src/Wizard/Service/KnowledgeModel/Package/KnowledgeModelPackageService.hs +++ b/wizard-server/src/Wizard/Service/KnowledgeModel/Package/KnowledgeModelPackageService.hs @@ -71,7 +71,7 @@ getDependentPackageResources uuid mAllVersions = do createPackage :: (KnowledgeModelPackage, [KnowledgeModelPackageEvent]) -> AppContextM KnowledgeModelPackageSimpleDTO createPackage (pkg, pkgEvents) = runInTransaction $ do - checkPackageLimit + checkPackageLimit pkg.organizationId pkg.kmId insertPackage pkg traverse_ insertPackageEvent pkgEvents return . toSimpleDTO $ pkg diff --git a/wizard-server/src/Wizard/Service/Locale/Bundle/LocaleBundleService.hs b/wizard-server/src/Wizard/Service/Locale/Bundle/LocaleBundleService.hs index 8344e12c4..d060a08e3 100644 --- a/wizard-server/src/Wizard/Service/Locale/Bundle/LocaleBundleService.hs +++ b/wizard-server/src/Wizard/Service/Locale/Bundle/LocaleBundleService.hs @@ -10,6 +10,7 @@ import Shared.Common.Model.Error.Error import Shared.Common.Util.String import Shared.Common.Util.Uuid import Shared.Coordinate.Model.Coordinate.Coordinate +import Shared.Locale.Api.Resource.LocaleBundle.LocaleBundleDTO import Shared.Locale.Database.DAO.Locale.LocaleDAO import Shared.Locale.Model.Locale.Locale import Shared.Locale.Model.Locale.LocaleSimple @@ -24,6 +25,7 @@ import Wizard.Model.Context.AppContextHelpers import Wizard.S3.Locale.LocaleS3 import Wizard.Service.Locale.Bundle.LocaleBundleAudit import Wizard.Service.Locale.LocaleValidation +import Wizard.Service.Tenant.Limit.LimitService import WizardLib.Public.Api.Resource.TemporaryFile.TemporaryFileDTO import qualified WizardLib.Public.Service.TemporaryFile.TemporaryFileMapper as TemporaryFileMapper import WizardLib.Public.Service.TemporaryFile.TemporaryFileService @@ -61,6 +63,7 @@ importBundle :: BSL.ByteString -> Bool -> AppContextM LocaleSimple importBundle contentS fromRegistry = case fromLocaleArchive contentS of Right (bundle, wizardTranslation, mailTranslation) -> do + checkLocaleLimit bundle.organizationId bundle.localeId validateLocaleIdUniqueness (createCoordinate bundle) uuid <- liftIO generateUuid tenantUuid <- asks currentTenantUuid diff --git a/wizard-server/src/Wizard/Service/Locale/LocaleService.hs b/wizard-server/src/Wizard/Service/Locale/LocaleService.hs index e0e9dee75..580fd19c3 100644 --- a/wizard-server/src/Wizard/Service/Locale/LocaleService.hs +++ b/wizard-server/src/Wizard/Service/Locale/LocaleService.hs @@ -59,11 +59,11 @@ createLocale reqDto = runInTransaction $ do checkPermission _SETTINGS_MANAGE_ROLE_PERMISSION checkIfAdminIsDisabled - checkLocaleLimit now <- liftIO getCurrentTime uuid <- liftIO generateUuid tcOrganization <- findTenantConfigOrganization let organizationId = tcOrganization.organizationId + checkLocaleLimit organizationId reqDto.localeId validateLocaleCreate reqDto organizationId let defaultLocale = False let locale = fromCreateDTO reqDto uuid organizationId defaultLocale tcOrganization.tenantUuid now diff --git a/wizard-server/src/Wizard/Service/Project/Collaboration/ProjectCollaborationService.hs b/wizard-server/src/Wizard/Service/Project/Collaboration/ProjectCollaborationService.hs index 2abbc357e..2e7f8f9a8 100644 --- a/wizard-server/src/Wizard/Service/Project/Collaboration/ProjectCollaborationService.hs +++ b/wizard-server/src/Wizard/Service/Project/Collaboration/ProjectCollaborationService.hs @@ -424,6 +424,7 @@ getMaybeCreatedBy myself = , lastName = lastName , gravatarHash = gravatarHash , imageUrl = imageUrl + , affiliation = affiliation } -> Just $ UserSuggestion @@ -432,5 +433,6 @@ getMaybeCreatedBy myself = , lastName = lastName , gravatarHash = gravatarHash , imageUrl = imageUrl + , affiliation = affiliation } u@AnonymousOnlineUserInfo {..} -> Nothing diff --git a/wizard-server/src/Wizard/Service/Project/Migration/Migrator/Sanitizer.hs b/wizard-server/src/Wizard/Service/Project/Migration/Migrator/Sanitizer.hs index 0d14dcf25..3b0f8cdf5 100644 --- a/wizard-server/src/Wizard/Service/Project/Migration/Migrator/Sanitizer.hs +++ b/wizard-server/src/Wizard/Service/Project/Migration/Migrator/Sanitizer.hs @@ -5,7 +5,6 @@ module Wizard.Service.Project.Migration.Migrator.Sanitizer ( import Control.Monad.Reader (liftIO) import qualified Data.Map.Strict as M import Data.Time -import qualified Data.UUID as U import Shared.Common.Util.Uuid import Shared.KnowledgeModel.Model.KnowledgeModel.KnowledgeModel @@ -19,15 +18,15 @@ import qualified Wizard.Service.Project.Migration.Migrator.ChangeQTypeSanitizer import qualified Wizard.Service.Project.Migration.Migrator.MoveSanitizer as MS import Wizard.Service.User.UserMapper -sanitizeProjectEvents :: U.UUID -> KnowledgeModel -> KnowledgeModel -> [ProjectEventList] -> AppContextM [ProjectEventList] -sanitizeProjectEvents projectUuid oldKm newKm events = do +sanitizeProjectEvents :: KnowledgeModel -> KnowledgeModel -> [ProjectEventList] -> AppContextM [ProjectEventList] +sanitizeProjectEvents oldKm newKm events = do let oldProjectContent = compileProjectEvents events let oldReplies = oldProjectContent.replies now <- liftIO getCurrentTime let sanitizedReplies = M.fromList . sanitizeReplies now oldKm newKm . M.toList $ oldReplies - clearReplyEvents <- generateClearReplyEvents projectUuid oldReplies sanitizedReplies - setReplyEvents <- generateSetReplyEvents projectUuid oldReplies sanitizedReplies - return $ events ++ clearReplyEvents ++ setReplyEvents + clearReplyEvents <- generateClearReplyEvents oldReplies sanitizedReplies + setReplyEvents <- generateSetReplyEvents oldReplies sanitizedReplies + return $ clearReplyEvents ++ setReplyEvents -- -------------------------------- -- PRIVATE @@ -35,8 +34,8 @@ sanitizeProjectEvents projectUuid oldKm newKm events = do sanitizeReplies :: UTCTime -> KnowledgeModel -> KnowledgeModel -> [ReplyTuple] -> [ReplyTuple] sanitizeReplies now oldKm newKm = MS.sanitizeReplies now oldKm newKm . CTS.sanitizeReplies newKm -generateClearReplyEvents :: U.UUID -> M.Map String Reply -> M.Map String Reply -> AppContextM [ProjectEventList] -generateClearReplyEvents projectUuid oldReplies sanitizedReplies = traverse generateEvent repliesToBeDeleted +generateClearReplyEvents :: M.Map String Reply -> M.Map String Reply -> AppContextM [ProjectEventList] +generateClearReplyEvents oldReplies sanitizedReplies = traverse generateEvent repliesToBeDeleted where repliesToBeDeleted :: [ReplyTuple] repliesToBeDeleted = M.toList . M.filterWithKey (\k _ -> k `M.notMember` sanitizedReplies) $ oldReplies @@ -47,8 +46,8 @@ generateClearReplyEvents projectUuid oldReplies sanitizedReplies = traverse gene user <- getCurrentUser return . ClearReplyEventList' $ ClearReplyEventList eUuid k (Just (toSuggestion' user)) now -generateSetReplyEvents :: U.UUID -> M.Map String Reply -> M.Map String Reply -> AppContextM [ProjectEventList] -generateSetReplyEvents projectUuid oldReplies sanitizedReplies = foldl generateEvent (return []) (M.toList sanitizedReplies) +generateSetReplyEvents :: M.Map String Reply -> M.Map String Reply -> AppContextM [ProjectEventList] +generateSetReplyEvents oldReplies sanitizedReplies = foldl generateEvent (return []) (M.toList sanitizedReplies) where generateEvent :: AppContextM [ProjectEventList] -> ReplyTuple -> AppContextM [ProjectEventList] generateEvent accM (keyFromSanitizedReply, valueFromSanitizedReply) = do diff --git a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationAudit.hs b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationAudit.hs index 3df18f45c..ff4a2d75c 100644 --- a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationAudit.hs +++ b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationAudit.hs @@ -4,46 +4,19 @@ import qualified Data.Map.Strict as M import qualified Data.UUID as U import Shared.Audit.Service.Audit.AuditService -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO import Wizard.Model.Context.AppContext import Wizard.Model.Context.ContextLenses () import Wizard.Model.Project.Project -auditProjectMigrationCreate :: ProjectMigrationCreateDTO -> Project -> Project -> AppContextM () -auditProjectMigrationCreate reqDto oldProject newProject = +auditProjectMigration :: ProjectMigrationCreateDTO -> Project -> AppContextM () +auditProjectMigration reqDto project = logAuditWithBody "project_migration" - "create" - (U.toString oldProject.uuid) + "migrate" + (U.toString project.uuid) ( M.fromList - [ ("sourceKnowledgeModelPackageUuid", U.toString oldProject.knowledgeModelPackageUuid) + [ ("sourceKnowledgeModelPackageUuid", U.toString project.knowledgeModelPackageUuid) , ("targetKnowledgeModelPackageUuid", U.toString reqDto.targetKnowledgeModelPackageUuid) - , ("oldProjectUuid", U.toString oldProject.uuid) - , ("newProjectUuid", U.toString newProject.uuid) ] ) - -auditProjectMigrationModify :: ProjectMigrationDTO -> ProjectMigrationChangeDTO -> AppContextM () -auditProjectMigrationModify projectMigration resolvedQuestionUuids = - logAuditWithBody - "project_migration" - "modify" - (U.toString projectMigration.newProject.uuid) - (M.fromList [("resolvedQuestionUuids", show resolvedQuestionUuids)]) - -auditProjectMigrationFinish :: Project -> Project -> AppContextM () -auditProjectMigrationFinish oldProject newProject = - logAuditWithBody - "project_migration" - "finish" - (U.toString oldProject.uuid) - ( M.fromList - [("oldProjectUuid", U.toString oldProject.uuid), ("newProjectUuid", U.toString newProject.uuid)] - ) - -auditProjectMigrationCancel :: ProjectMigrationDTO -> AppContextM () -auditProjectMigrationCancel projectMigration = - logAudit "project_migration" "cancel" (U.toString projectMigration.oldProject.uuid) diff --git a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationMapper.hs b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationMapper.hs index 9efa8ae08..7452a57ee 100644 --- a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationMapper.hs +++ b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationMapper.hs @@ -3,39 +3,8 @@ module Wizard.Service.Project.Migration.ProjectMigrationMapper where import Data.Time import qualified Data.UUID as U -import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO import Wizard.Api.Resource.User.UserDTO import Wizard.Model.Project.Event.ProjectEvent -import Wizard.Model.Project.Migration.ProjectMigration - -toDTO :: ProjectDetailQuestionnaireDTO -> ProjectDetailQuestionnaireDTO -> [U.UUID] -> U.UUID -> ProjectMigrationDTO -toDTO oldProject newProject projectUuids tenantUuid = - ProjectMigrationDTO - { oldProject = oldProject - , newProject = newProject - , resolvedQuestionUuids = projectUuids - , tenantUuid = tenantUuid - } - -fromCreateDTO :: U.UUID -> U.UUID -> U.UUID -> ProjectMigration -fromCreateDTO oldProjectUuid newProjectUuid tenantUuid = - ProjectMigration - { oldProjectUuid = oldProjectUuid - , newProjectUuid = newProjectUuid - , resolvedQuestionUuids = [] - , tenantUuid = tenantUuid - } - -fromChangeDTO :: ProjectMigrationChangeDTO -> ProjectMigrationDTO -> ProjectMigration -fromChangeDTO changeDto ms = - ProjectMigration - { oldProjectUuid = ms.oldProject.uuid - , newProjectUuid = ms.newProject.uuid - , resolvedQuestionUuids = changeDto.resolvedQuestionUuids - , tenantUuid = ms.tenantUuid - } toProjectPhaseEvent :: U.UUID -> Maybe U.UUID -> U.UUID -> U.UUID -> Maybe UserDTO -> UTCTime -> ProjectEvent toProjectPhaseEvent phaseEventUuid kmPhaseUuid projectUuid tenantUuid mCurrentUserUuid now = diff --git a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationService.hs b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationService.hs index 801aa339c..135e8a142 100644 --- a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationService.hs +++ b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationService.hs @@ -1,13 +1,9 @@ module Wizard.Service.Project.Migration.ProjectMigrationService where import Control.Monad.Reader (asks, liftIO) -import Data.Foldable (traverse_) -import qualified Data.List as L -import Data.Maybe (catMaybes) import Data.Time import qualified Data.UUID as U -import Shared.Common.Model.Common.Lens import Shared.Common.Util.List import Shared.Common.Util.Uuid import Shared.Coordinate.Model.Coordinate.Coordinate @@ -18,180 +14,71 @@ import Shared.KnowledgeModel.Model.KnowledgeModel.KnowledgeModel import Shared.KnowledgeModel.Model.KnowledgeModel.Package.KnowledgeModelPackage import Shared.KnowledgeModel.Service.KnowledgeModel.Package.KnowledgeModelPackageUtil import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationChangeDTO import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO import Wizard.Database.DAO.Common import Wizard.Database.DAO.Project.ProjectDAO import Wizard.Database.DAO.Project.ProjectEventDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import Wizard.Database.DAO.Project.ProjectVersionDAO -import Wizard.Model.Common.Lens import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Acl.ProjectPerm import Wizard.Model.Project.Event.ProjectEvent -import Wizard.Model.Project.Migration.ProjectMigration +import Wizard.Model.Project.Event.ProjectEventList import Wizard.Model.Project.Project import Wizard.Model.Project.ProjectContent -import Wizard.Model.Project.Version.ProjectVersion import Wizard.Service.KnowledgeModel.KnowledgeModelService +import Wizard.Service.Project.Collaboration.ProjectCollaborationService import Wizard.Service.Project.Compiler.ProjectCompilerService import Wizard.Service.Project.Event.ProjectEventMapper import Wizard.Service.Project.Migration.Migrator.Sanitizer import Wizard.Service.Project.Migration.ProjectMigrationAudit import Wizard.Service.Project.Migration.ProjectMigrationMapper -import Wizard.Service.Project.Migration.ProjectMigrationValidation import Wizard.Service.Project.ProjectAcl import Wizard.Service.Project.ProjectService -createProjectMigration :: U.UUID -> ProjectMigrationCreateDTO -> AppContextM ProjectMigrationDTO -createProjectMigration oldProjectUuid reqDto = +migrateProject :: U.UUID -> ProjectMigrationCreateDTO -> AppContextM ProjectDetailQuestionnaireDTO +migrateProject projectUuid reqDto = runInTransaction $ do - validateMigrationExistence oldProjectUuid - oldProject <- findProjectByUuid oldProjectUuid - checkMigrationPermissionToProject oldProject.visibility oldProject.permissions - (newProject, newProjectEvents, newProjectVersions) <- upgradeProject reqDto oldProject - insertProject newProject - insertProjectEvents newProjectEvents - traverse_ insertProjectVersion newProjectVersions - tenantUuid <- asks currentTenantUuid - let projectMigration = fromCreateDTO oldProject.uuid newProject.uuid tenantUuid - insertProjectMigration projectMigration - auditProjectMigrationCreate reqDto oldProject newProject - getProjectMigration newProject.uuid - -getProjectMigration :: U.UUID -> AppContextM ProjectMigrationDTO -getProjectMigration projectUuid = do - projectMigration <- findProjectMigrationByNewProjectUuid projectUuid - oldProjectDto <- getProjectDetailQuestionnaireByUuid projectMigration.oldProjectUuid - newProjectDto <- getProjectDetailQuestionnaireByUuid projectMigration.newProjectUuid - oldProject <- findProjectByUuid projectMigration.oldProjectUuid - newProject <- findProjectByUuid projectMigration.newProjectUuid - checkMigrationPermissionToProject oldProject.visibility oldProject.permissions - checkMigrationPermissionToProject newProject.visibility newProject.permissions - return $ toDTO oldProjectDto newProjectDto projectMigration.resolvedQuestionUuids projectMigration.tenantUuid - -modifyProjectMigration :: U.UUID -> ProjectMigrationChangeDTO -> AppContextM ProjectMigrationDTO -modifyProjectMigration projectUuid reqDto = - runInTransaction $ do - projectMigration <- getProjectMigration projectUuid - let updatedState = fromChangeDTO reqDto projectMigration - updateProjectMigrationByNewProjectUuid updatedState - auditProjectMigrationModify projectMigration reqDto - return $ toDTO projectMigration.oldProject projectMigration.newProject updatedState.resolvedQuestionUuids updatedState.tenantUuid - -finishProjectMigration :: U.UUID -> AppContextM () -finishProjectMigration projectUuid = - runInTransaction $ do - _ <- getProjectMigration projectUuid - projectMigration <- findProjectMigrationByNewProjectUuid projectUuid - deleteProjectMigrationByNewProjectUuid projectUuid - oldProject <- findProjectByUuid projectMigration.oldProjectUuid - newProject <- findProjectByUuid projectMigration.newProjectUuid - newProjectEvents <- ensurePhaseIsSetIfNecessary newProject - newProjectVersions <- findProjectVersionsByProjectUuid projectMigration.newProjectUuid + project <- findProjectByUuid projectUuid + checkMigrationPermissionToProject project.visibility project.permissions + newPkg <- findPackageByUuid reqDto.targetKnowledgeModelPackageUuid + oldKm <- compileKnowledgeModel [] (Just project.knowledgeModelPackageUuid) reqDto.targetTagUuids + newKm <- compileKnowledgeModel [] (Just reqDto.targetKnowledgeModelPackageUuid) reqDto.targetTagUuids + projectEvents <- findProjectEventListsByProjectUuid project.uuid + deltaEvents <- sanitizeProjectEvents oldKm newKm projectEvents + phaseEvents <- ensurePhaseIsSetIfNecessary project newKm projectEvents + (newDocumentTemplateUuid, newFormatUuid) <- getNewDocumentTemplateIdAndFormatUuid project newPkg now <- liftIO getCurrentTime - let newProjectUpdated = - oldProject - { formatUuid = newProject.formatUuid - , documentTemplateUuid = newProject.documentTemplateUuid - , selectedQuestionTagUuids = newProject.selectedQuestionTagUuids - , knowledgeModelPackageUuid = newProject.knowledgeModelPackageUuid + let updatedProject = + project + { knowledgeModelPackageUuid = reqDto.targetKnowledgeModelPackageUuid + , selectedQuestionTagUuids = reqDto.targetTagUuids + , documentTemplateUuid = newDocumentTemplateUuid + , formatUuid = newFormatUuid + , squashed = False , updatedAt = now } :: Project - let newProjectEventsWithOldProjectUuid = fmap (\event -> setProjectUuid event oldProject.uuid) newProjectEvents - newVersionsWithNewUuid <- traverse generateNewVersionUuid newProjectVersions - let newVersionsWithOldProjectUuid = fmap (\v -> v {projectUuid = oldProject.uuid} :: ProjectVersion) newVersionsWithNewUuid - -- Delete the new project - deleteProjectEventsByProjectUuid newProject.uuid - deleteProject newProject.uuid False - -- Update the old project with values from new project - updateProjectByUuid newProjectUpdated - deleteProjectEventsByProjectUuid oldProject.uuid - insertProjectEvents newProjectEventsWithOldProjectUuid - traverse_ insertProjectVersion newVersionsWithOldProjectUuid - auditProjectMigrationFinish oldProject newProject - -cancelProjectMigration :: U.UUID -> AppContextM () -cancelProjectMigration projectUuid = - runInTransaction $ do - projectMigration <- getProjectMigration projectUuid - deleteProject projectMigration.newProject.uuid True - deleteProjectMigrationByNewProjectUuid projectUuid - auditProjectMigrationCancel projectMigration - return () + updateProjectByUuid updatedProject + insertProjectEvents (fmap (toEvent project.uuid project.tenantUuid) deltaEvents ++ phaseEvents) + auditProjectMigration reqDto project + logOutOnlineUsersWhenProjectDramaticallyChanged project.uuid + getProjectDetailQuestionnaireByUuid project.uuid -- -------------------------------- -- PRIVATE -- -------------------------------- -upgradeProject :: ProjectMigrationCreateDTO -> Project -> AppContextM (Project, [ProjectEvent], [ProjectVersion]) -upgradeProject reqDto oldProject = do - let newPkgUuid = reqDto.targetKnowledgeModelPackageUuid - newPkg <- findPackageByUuid newPkgUuid - let newTagUuids = reqDto.targetTagUuids - oldKm <- compileKnowledgeModel [] (Just oldProject.knowledgeModelPackageUuid) newTagUuids - newKm <- compileKnowledgeModel [] (Just newPkgUuid) newTagUuids - newUuid <- liftIO generateUuid - oldProjectEvents <- findProjectEventListsByProjectUuid oldProject.uuid - clonedProjectEventsWithOldEventUuid <- cloneProjectEventsWithOldEventUuid oldProjectEvents - let clonedProjectEvents = fmap snd clonedProjectEventsWithOldEventUuid - newProjectEvents <- sanitizeProjectEvents newUuid oldKm newKm clonedProjectEvents - (newDocumentTemplateId, newFormatUuid) <- getNewDocumentTemplateIdAndFormatUuid oldProject newPkg - let newProjectEventUuids = fmap getUuid newProjectEvents - let clonedProjectEventsFiltered = filter (\e -> getUuid (snd e) `elem` newProjectEventUuids) clonedProjectEventsWithOldEventUuid - let newPermissions = fmap (\perm -> perm {projectUuid = newUuid} :: ProjectPerm) oldProject.permissions - let upgradedProject = - oldProject - { uuid = newUuid - , knowledgeModelPackageUuid = newPkgUuid - , selectedQuestionTagUuids = newTagUuids - , documentTemplateUuid = newDocumentTemplateId - , formatUuid = newFormatUuid - , permissions = newPermissions - } - :: Project - versionsWithOldProjectUuid <- findProjectVersionsByProjectUuid oldProject.uuid - newVersionsWithNewUuid <- traverse generateNewVersionUuid versionsWithOldProjectUuid - let newVersionsWithNewEventUuid = - fmap - ( \v -> - case L.find (\(oldEventUuid, _) -> v.eventUuid == oldEventUuid) clonedProjectEventsWithOldEventUuid of - Just (_, newEvent) -> - Just $ - v - { projectUuid = newUuid - , eventUuid = getUuid newEvent - } - Nothing -> Nothing - ) - newVersionsWithNewUuid - let newVersions = catMaybes newVersionsWithNewEventUuid - return (upgradedProject, fmap (toEvent upgradedProject.uuid upgradedProject.tenantUuid) newProjectEvents, newVersions) - -ensurePhaseIsSetIfNecessary :: Project -> AppContextM [ProjectEvent] -ensurePhaseIsSetIfNecessary newProject = do +ensurePhaseIsSetIfNecessary :: Project -> KnowledgeModel -> [ProjectEventList] -> AppContextM [ProjectEvent] +ensurePhaseIsSetIfNecessary project newKm projectEvents = do uuid <- liftIO generateUuid mCurrentUser <- asks currentUser now <- liftIO getCurrentTime - newProjectListEvents <- findProjectEventListsByProjectUuid newProject.uuid - let projectContent = compileProjectEvents newProjectListEvents - knowledgeModel <- compileKnowledgeModel [] (Just newProject.knowledgeModelPackageUuid) newProject.selectedQuestionTagUuids - let newProjectEvents = fmap (toEvent newProject.uuid newProject.tenantUuid) newProjectListEvents + let projectContent = compileProjectEvents projectEvents return $ - case (headSafe knowledgeModel.phaseUuids, projectContent.phaseUuid) of - (Nothing, Nothing) -> newProjectEvents - (Nothing, Just projectPhaseUuid) -> newProjectEvents ++ [toProjectPhaseEvent uuid Nothing newProject.uuid newProject.tenantUuid mCurrentUser now] - (Just kmPhaseUuid, Nothing) -> newProjectEvents ++ [toProjectPhaseEvent uuid (Just kmPhaseUuid) newProject.uuid newProject.tenantUuid mCurrentUser now] - (Just kmPhaseUuid, Just projectPhaseUuid) -> - if projectPhaseUuid `notElem` knowledgeModel.phaseUuids - then newProjectEvents ++ [toProjectPhaseEvent uuid (Just kmPhaseUuid) newProject.uuid newProject.tenantUuid mCurrentUser now] - else newProjectEvents - -generateNewVersionUuid :: ProjectVersion -> AppContextM ProjectVersion -generateNewVersionUuid version = do - newVersionUuid <- liftIO generateUuid - return $ version {uuid = newVersionUuid} + case (headSafe newKm.phaseUuids, projectContent.phaseUuid) of + (Nothing, Nothing) -> [] + (Nothing, Just projectPhaseUuid) -> [toProjectPhaseEvent uuid Nothing project.uuid project.tenantUuid mCurrentUser now] + (Just kmPhaseUuid, Nothing) -> [toProjectPhaseEvent uuid (Just kmPhaseUuid) project.uuid project.tenantUuid mCurrentUser now] + (Just kmPhaseUuid, Just projectPhaseUuid) + | projectPhaseUuid `notElem` newKm.phaseUuids -> [toProjectPhaseEvent uuid (Just kmPhaseUuid) project.uuid project.tenantUuid mCurrentUser now] + | otherwise -> [] getNewDocumentTemplateIdAndFormatUuid :: Project -> KnowledgeModelPackage -> AppContextM (Maybe U.UUID, Maybe U.UUID) getNewDocumentTemplateIdAndFormatUuid oldProject newPkg = do diff --git a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationValidation.hs b/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationValidation.hs deleted file mode 100644 index 63cc39cc7..000000000 --- a/wizard-server/src/Wizard/Service/Project/Migration/ProjectMigrationValidation.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Wizard.Service.Project.Migration.ProjectMigrationValidation where - -import Control.Monad (unless) -import Control.Monad.Except (throwError) - -import Shared.Common.Model.Error.Error -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import Wizard.Localization.Messages.Public - -validateMigrationExistence oldProjectUuid = do - states <- findProjectMigrationsByOldProjectUuid oldProjectUuid - unless (null states) (throwError . UserError $ _ERROR_VALIDATION__PROJECT_MIGRATION_UNIQUENESS) diff --git a/wizard-server/src/Wizard/Service/Project/ProjectMapper.hs b/wizard-server/src/Wizard/Service/Project/ProjectMapper.hs index 3b777d6dd..d26ad65ff 100644 --- a/wizard-server/src/Wizard/Service/Project/ProjectMapper.hs +++ b/wizard-server/src/Wizard/Service/Project/ProjectMapper.hs @@ -27,7 +27,6 @@ import Wizard.Api.Resource.Project.ProjectSettingsChangeDTO import Wizard.Api.Resource.Project.ProjectShareChangeDTO import Wizard.Api.Resource.User.UserDTO import Wizard.Model.DocumentTemplate.DocumentTemplateState -import Wizard.Model.KnowledgeModel.Package.KnowledgeModelPackageSuggestion import Wizard.Model.Project.Acl.ProjectPerm import Wizard.Model.Project.Comment.ProjectCommentList import Wizard.Model.Project.Detail.ProjectDetail @@ -50,15 +49,16 @@ import Wizard.Service.Project.Event.ProjectEventMapper import WizardLib.Public.Model.PersistentCommand.Project.CreateProjectCommand import WizardLib.Public.Model.User.UserGroup -toDTO :: Project -> KnowledgeModelPackage -> ProjectState -> [ProjectPermDTO] -> ProjectDTO -toDTO project kmPackage state permissions = +toDTO :: Project -> KnowledgeModelPackage -> KnowledgeModelProjectState -> Maybe DocumentTemplateProjectState -> [ProjectPermDTO] -> ProjectDTO +toDTO project kmPackage knowledgeModelState documentTemplateState permissions = ProjectDTO { uuid = project.uuid , name = project.name , description = project.description , visibility = project.visibility , sharing = project.sharing - , state = state + , knowledgeModelState = knowledgeModelState + , documentTemplateState = documentTemplateState , knowledgeModelPackage = SPM.toSimple kmPackage , permissions = permissions , isTemplate = project.isTemplate @@ -74,7 +74,8 @@ toDTO' project = , description = project.description , visibility = project.visibility , sharing = project.sharing - , state = project.state + , knowledgeModelState = project.knowledgeModelState + , documentTemplateState = project.documentTemplateState , knowledgeModelPackage = project.knowledgeModelPackage , permissions = project.permissions , isTemplate = project.isTemplate @@ -82,15 +83,16 @@ toDTO' project = , updatedAt = project.updatedAt } -toSimpleDTO :: Project -> KnowledgeModelPackage -> ProjectState -> [ProjectPermDTO] -> ProjectDTO -toSimpleDTO project kmPackage state permissions = +toSimpleDTO :: Project -> KnowledgeModelPackage -> KnowledgeModelProjectState -> Maybe DocumentTemplateProjectState -> [ProjectPermDTO] -> ProjectDTO +toSimpleDTO project kmPackage knowledgeModelState documentTemplateState permissions = ProjectDTO { uuid = project.uuid , name = project.name , description = project.description , visibility = project.visibility , sharing = project.sharing - , state = state + , knowledgeModelState = knowledgeModelState + , documentTemplateState = documentTemplateState , knowledgeModelPackage = SPM.toSimple kmPackage , permissions = permissions , isTemplate = project.isTemplate @@ -98,22 +100,6 @@ toSimpleDTO project kmPackage state permissions = , updatedAt = project.updatedAt } -toDetailQuestionnaire :: Project -> KnowledgeModelPackageSuggestion -> Maybe U.UUID -> [ProjectPermDTO] -> ProjectDetailQuestionnaire -toDetailQuestionnaire project kmPackage migrationUuid permissions = - ProjectDetailQuestionnaire - { uuid = project.uuid - , name = project.name - , visibility = project.visibility - , sharing = project.sharing - , knowledgeModelPackage = kmPackage - , selectedQuestionTagUuids = project.selectedQuestionTagUuids - , language = project.language - , isTemplate = project.isTemplate - , migrationUuid = migrationUuid - , permissions = permissions - , files = [] - } - toDetailDTO :: ProjectDetail -> ProjectDetailDTO toDetailDTO ProjectDetail {..} = ProjectDetailDTO {..} @@ -226,8 +212,8 @@ toCreateFromTemplateDTO project = , projectUuid = project.uuid } -toProjectDetailTemplateState :: Maybe DocumentTemplate -> Maybe DocumentTemplateState -toProjectDetailTemplateState = +toProjectDetailTemplateSupportState :: Maybe DocumentTemplate -> Maybe DocumentTemplateState +toProjectDetailTemplateSupportState = fmap ( \tml -> if isDocumentTemplateUnsupported tml.metamodelVersion diff --git a/wizard-server/src/Wizard/Service/Project/ProjectService.hs b/wizard-server/src/Wizard/Service/Project/ProjectService.hs index e12274876..fab629a62 100644 --- a/wizard-server/src/Wizard/Service/Project/ProjectService.hs +++ b/wizard-server/src/Wizard/Service/Project/ProjectService.hs @@ -82,27 +82,29 @@ import WizardLib.Public.Model.PersistentCommand.Project.CreateProjectCommand getProjectsForCurrentUserPageDto :: Maybe String -> Maybe Bool - -> Maybe Bool -> Maybe [String] -> Maybe String - -> Maybe [String] + -> Maybe [U.UUID] + -> Maybe String + -> Maybe [U.UUID] -> Maybe String -> Maybe [Coordinate] -> Maybe String -> Pageable -> [Sort] -> AppContextM (Page ProjectDTO) -getProjectsForCurrentUserPageDto mQuery mIsTemplate mIsMigrating mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp pageable sort = do +getProjectsForCurrentUserPageDto mQuery mIsTemplate mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp mUserGroupUuids mUserGroupUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp pageable sort = do currentUser <- getCurrentUser projectPage <- findProjectsForCurrentUserPage mQuery mIsTemplate - mIsMigrating mProjectTags mProjectTagsOp mUserUuids mUserUuidsOp + mUserGroupUuids + mUserGroupUuidsOp mKnowledgeModelPackageCoordinates mKnowledgeModelPackageCoordinatesOp pageable @@ -119,7 +121,8 @@ createProjectWithGivenUuid reqDto projectUuid = checkProjectLimit checkCreatePermissionToProject pkg <- findPackageByUuid reqDto.knowledgeModelPackageUuid - projectState <- getProjectState projectUuid pkg + knowledgeModelState <- getKnowledgeModelProjectState pkg + documentTemplateState <- getDocumentTemplateProjectState reqDto.documentTemplateUuid now <- liftIO getCurrentTime tenantUuid <- asks currentTenantUuid visibility <- extractVisibility reqDto @@ -142,7 +145,7 @@ createProjectWithGivenUuid reqDto projectUuid = insertProject project insertProjectEvents projectEvents permissionDtos <- traverse enhanceProjectPerm project.permissions - return $ toSimpleDTO project pkg projectState permissionDtos + return $ toSimpleDTO project pkg knowledgeModelState documentTemplateState permissionDtos createProjectFromTemplate :: ProjectCreateFromTemplateDTO -> AppContextM ProjectDTO createProjectFromTemplate reqDto = @@ -181,9 +184,10 @@ createProjectFromTemplate reqDto = insertProjectEvents (fmap (toEvent newProjectUuid newProject.tenantUuid) newProjectEventsWithReplacedFiles) duplicateCommentThreads reqDto.projectUuid newProjectUuid cloneProjectVersions originProject.uuid newProject.uuid newProjectEventsWithOldEventUuid - state <- getProjectState newProjectUuid pkg + knowledgeModelState <- getKnowledgeModelProjectState pkg + documentTemplateState <- getDocumentTemplateProjectState newProject.documentTemplateUuid permissionDtos <- traverse enhanceProjectPerm newProject.permissions - return $ toSimpleDTO newProject pkg state permissionDtos + return $ toSimpleDTO newProject pkg knowledgeModelState documentTemplateState permissionDtos cloneProject :: U.UUID -> AppContextM ProjectDTO cloneProject cloneUuid = @@ -215,9 +219,10 @@ cloneProject cloneUuid = insertProjectEvents (fmap (toEvent newProjectUuid newProject.tenantUuid) newProjectEventsWithReplacedFiles) cloneProjectVersions originProject.uuid newProject.uuid newProjectEventsWithOldEventUuid duplicateCommentThreads cloneUuid newProjectUuid - state <- getProjectState newProjectUuid pkg + knowledgeModelState <- getKnowledgeModelProjectState pkg + documentTemplateState <- getDocumentTemplateProjectState newProject.documentTemplateUuid permissionDtos <- traverse enhanceProjectPerm newProject.permissions - return $ toSimpleDTO newProject pkg state permissionDtos + return $ toSimpleDTO newProject pkg knowledgeModelState documentTemplateState permissionDtos createProjectsFromCommands :: [CreateProjectCommand] -> AppContextM () createProjectsFromCommands = runInTransaction . traverse_ create @@ -376,7 +381,6 @@ deleteProject :: U.UUID -> Bool -> AppContextM () deleteProject projectUuid shouldValidatePermission = runInTransaction $ do project <- findProjectByUuid projectUuid - validateProjectDeletion projectUuid when shouldValidatePermission (checkOwnerPermissionToProject project.visibility project.permissions) deleteProjectByUuid projectUuid void $ logOutOnlineUsersWhenProjectDramaticallyChanged projectUuid diff --git a/wizard-server/src/Wizard/Service/Project/ProjectUtil.hs b/wizard-server/src/Wizard/Service/Project/ProjectUtil.hs index db0173079..727ce5ec3 100644 --- a/wizard-server/src/Wizard/Service/Project/ProjectUtil.hs +++ b/wizard-server/src/Wizard/Service/Project/ProjectUtil.hs @@ -1,12 +1,15 @@ module Wizard.Service.Project.ProjectUtil where import Control.Monad (when) +import qualified Data.List as L import qualified Data.UUID as U +import Shared.Coordinate.Util.Coordinate +import Shared.DocumentTemplate.Database.DAO.DocumentTemplate.DocumentTemplateDAO +import Shared.DocumentTemplate.Model.DocumentTemplate.DocumentTemplate import Shared.KnowledgeModel.Database.DAO.Package.KnowledgeModelPackageDAO import Shared.KnowledgeModel.Model.KnowledgeModel.Package.KnowledgeModelPackage import Wizard.Api.Resource.Project.Acl.ProjectPermDTO -import Wizard.Database.DAO.Project.ProjectMigrationDAO import Wizard.Database.DAO.User.UserDAO import Wizard.Model.Context.AppContext import Wizard.Model.Project.Acl.ProjectPerm @@ -40,19 +43,31 @@ enhanceProjectPerm projectPerm = userGroup <- findUserGroupByUuid projectPerm.memberUuid return $ toUserGroupProjectPermDTO projectPerm userGroup -getProjectState :: U.UUID -> KnowledgeModelPackage -> AppContextM ProjectState -getProjectState projectUuid pkg = do - mMs <- findProjectMigrationByNewProjectUuid' projectUuid - case mMs of - Just _ -> return MigratingProjectState - Nothing -> do - mLatestPkg <- findLatestPackageByOrganizationIdAndKmId' pkg.organizationId pkg.kmId (Just ReleasedKnowledgeModelPackagePhase) - case mLatestPkg of - Just latestPkg -> - if latestPkg.uuid == pkg.uuid - then return DefaultProjectState - else return OutdatedProjectState - Nothing -> return DefaultProjectState +getKnowledgeModelProjectState :: KnowledgeModelPackage -> AppContextM KnowledgeModelProjectState +getKnowledgeModelProjectState pkg = do + mLatestPkg <- findLatestPackageByOrganizationIdAndKmId' pkg.organizationId pkg.kmId (Just ReleasedKnowledgeModelPackagePhase) + case mLatestPkg of + Just latestPkg -> + if latestPkg.uuid == pkg.uuid + then return UpToDateKnowledgeModelProjectState + else return OutdatedKnowledgeModelProjectState + Nothing -> return UpToDateKnowledgeModelProjectState + +getDocumentTemplateProjectState :: Maybe U.UUID -> AppContextM (Maybe DocumentTemplateProjectState) +getDocumentTemplateProjectState mDocumentTemplateUuid = + case mDocumentTemplateUuid of + Nothing -> return Nothing + Just documentTemplateUuid -> do + documentTemplate <- findDocumentTemplateByUuid documentTemplateUuid + templates <- findDocumentTemplatesByOrganizationIdAndKmId documentTemplate.organizationId documentTemplate.templateId + let releasedTemplates = filter (\t -> t.phase == ReleasedDocumentTemplatePhase) templates + case releasedTemplates of + [] -> return (Just UpToDateDocumentTemplateProjectState) + _ -> + let latestTemplate = L.maximumBy (\t1 t2 -> compareVersion t1.version t2.version) releasedTemplates + in if latestTemplate.uuid == documentTemplate.uuid + then return (Just UpToDateDocumentTemplateProjectState) + else return (Just OutdatedDocumentTemplateProjectState) skipIfAssigningProject :: Project -> AppContextM () -> AppContextM () skipIfAssigningProject project action = do diff --git a/wizard-server/src/Wizard/Service/Project/ProjectValidation.hs b/wizard-server/src/Wizard/Service/Project/ProjectValidation.hs index a68564851..30df49076 100644 --- a/wizard-server/src/Wizard/Service/Project/ProjectValidation.hs +++ b/wizard-server/src/Wizard/Service/Project/ProjectValidation.hs @@ -3,29 +3,16 @@ module Wizard.Service.Project.ProjectValidation where import Control.Monad.Except (throwError) import Data.Foldable (forM_, traverse_) import qualified Data.Map.Strict as M -import qualified Data.UUID as U import Text.Regex.TDFA import Shared.Common.Localization.Messages.Public import Shared.Common.Model.Error.Error import Wizard.Api.Resource.Project.ProjectSettingsChangeDTO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import Wizard.Localization.Messages.Public import Wizard.Model.Context.AppContext validateProjectSettingsChangeDTO :: ProjectSettingsChangeDTO -> AppContextM () validateProjectSettingsChangeDTO reqDto = validateProjectTags reqDto.projectTags -validateProjectDeletion :: U.UUID -> AppContextM () -validateProjectDeletion = validateUsageByProjectMigration - -validateUsageByProjectMigration :: U.UUID -> AppContextM () -validateUsageByProjectMigration projectUuid = do - result <- findProjectMigrationsByOldProjectUuid projectUuid - case result of - [] -> return () - _ -> throwError . UserError $ _ERROR_SERVICE_PROJECT__PROJECT_CANT_BE_DELETED_BECAUSE_IT_IS_USED_IN_MIGRATION - validateProjectTags :: [String] -> AppContextM () validateProjectTags = traverse_ validateProjectTag diff --git a/wizard-server/src/Wizard/Service/Report/ReportMapper.hs b/wizard-server/src/Wizard/Service/Report/ReportMapper.hs index adaf96811..f7e52de2b 100644 --- a/wizard-server/src/Wizard/Service/Report/ReportMapper.hs +++ b/wizard-server/src/Wizard/Service/Report/ReportMapper.hs @@ -17,7 +17,6 @@ toDTO project report locale = , locale = locale , isTemplate = project.isTemplate , permissions = project.permissions - , migrationUuid = project.migrationUuid , fileCount = project.fileCount , totalReport = report.totalReport , chapters = report.chapters diff --git a/wizard-server/src/Wizard/Service/Tenant/Limit/LimitService.hs b/wizard-server/src/Wizard/Service/Tenant/Limit/LimitService.hs index 3288379bf..7f2a81539 100644 --- a/wizard-server/src/Wizard/Service/Tenant/Limit/LimitService.hs +++ b/wizard-server/src/Wizard/Service/Tenant/Limit/LimitService.hs @@ -1,5 +1,6 @@ module Wizard.Service.Tenant.Limit.LimitService where +import Control.Monad (when) import Control.Monad.Reader (liftIO) import Data.Time import qualified Data.UUID as U @@ -8,6 +9,7 @@ import GHC.Int import Shared.Common.Service.Tenant.Limit.LimitService import Shared.DocumentTemplate.Database.DAO.DocumentTemplate.DocumentTemplateAssetDAO import Shared.DocumentTemplate.Database.DAO.DocumentTemplate.DocumentTemplateDAO +import Shared.DocumentTemplate.Model.DocumentTemplate.DocumentTemplate import Shared.KnowledgeModel.Database.DAO.Package.KnowledgeModelPackageDAO import Shared.Locale.Database.DAO.Locale.LocaleDAO import Wizard.Database.DAO.Common @@ -48,23 +50,37 @@ checkUserLimit = do count <- countUsers checkLimit "users" count limit.users +checkUserLimitForTenant :: U.UUID -> AppContextM () +checkUserLimitForTenant tenantUuid = do + limit <- findLimitBundleByUuid tenantUuid + count <- countUsersWithTenant tenantUuid + checkLimit "users" count limit.users + checkActiveUserLimit :: AppContextM () checkActiveUserLimit = do limit <- findLimitBundleForCurrentTenant count <- countActiveUsers checkLimit "active users" count limit.activeUsers +checkActiveUserLimitForTenant :: U.UUID -> AppContextM () +checkActiveUserLimitForTenant tenantUuid = do + limit <- findLimitBundleByUuid tenantUuid + count <- countActiveUsersWithTenant tenantUuid + checkLimit "active users" count limit.activeUsers + checkKnowledgeModelEditorLimit :: AppContextM () checkKnowledgeModelEditorLimit = do limit <- findLimitBundleForCurrentTenant count <- countKnowledgeModelEditors checkLimit "knowledgeModelEditors" count limit.knowledgeModelEditors -checkPackageLimit :: AppContextM () -checkPackageLimit = do - limit <- findLimitBundleForCurrentTenant - count <- countPackagesGroupedByOrganizationIdAndKmId - checkLimit "knowledge models" count limit.knowledgeModels +checkPackageLimit :: String -> String -> AppContextM () +checkPackageLimit organizationId kmId = do + existingPackages <- findPackagesByOrganizationIdAndKmId organizationId kmId + when (null existingPackages) $ do + limit <- findLimitBundleForCurrentTenant + count <- countPackagesGroupedByOrganizationIdAndKmId + checkLimit "knowledge models" count limit.knowledgeModels checkProjectLimit :: AppContextM () checkProjectLimit = do @@ -72,11 +88,13 @@ checkProjectLimit = do count <- countProjects checkLimit "projects" count limit.projects -checkDocumentTemplateLimit :: AppContextM () -checkDocumentTemplateLimit = do - limit <- findLimitBundleForCurrentTenant - count <- countDocumentTemplatesGroupedByOrganizationIdAndKmId - checkLimit "document templates" count limit.documentTemplates +checkDocumentTemplateLimit :: String -> String -> AppContextM () +checkDocumentTemplateLimit organizationId templateId = do + existingTemplates <- findDocumentTemplatesByOrganizationIdAndKmId organizationId templateId + when (all (\dt -> dt.phase == DraftDocumentTemplatePhase) existingTemplates) $ do + limit <- findLimitBundleForCurrentTenant + count <- countDocumentTemplatesGroupedByOrganizationIdAndKmId + checkLimit "document templates" count limit.documentTemplates checkDocumentTemplateDraftLimit :: AppContextM () checkDocumentTemplateDraftLimit = do @@ -90,11 +108,13 @@ checkDocumentLimit = do count <- countDocuments checkLimit "documents" count limit.documents -checkLocaleLimit :: AppContextM () -checkLocaleLimit = do - limit <- findLimitBundleForCurrentTenant - count <- countLocalesGroupedByOrganizationIdAndLocaleId - checkLimit "locales" count limit.locales +checkLocaleLimit :: String -> String -> AppContextM () +checkLocaleLimit organizationId localeId = do + existingLocales <- findLocalesByOrganizationIdAndLocaleId organizationId localeId + when (null existingLocales) $ do + limit <- findLimitBundleForCurrentTenant + count <- countLocalesGroupedByOrganizationIdAndLocaleId + checkLimit "locales" count limit.locales checkStorageSize :: Int64 -> AppContextM () checkStorageSize newFileSize = do diff --git a/wizard-server/src/Wizard/Service/Tenant/TenantService.hs b/wizard-server/src/Wizard/Service/Tenant/TenantService.hs index 1128125dc..1bc1129b5 100644 --- a/wizard-server/src/Wizard/Service/Tenant/TenantService.hs +++ b/wizard-server/src/Wizard/Service/Tenant/TenantService.hs @@ -80,11 +80,11 @@ registerTenant reqDto = do let tenant = fromRegisterCreateDTO reqDto uuid serverConfig now insertTenant tenant adminRole <- createAdminRole uuid now + createLimitBundle uuid now userUuid <- liftIO generateUuid let userCreate = U_Mapper.fromTenantCreateToUserCreateDTO reqDto adminRole.uuid user <- createUserByAdminWithUuid userCreate userUuid tenant.uuid tenant.clientUrl True createConfig uuid adminRole.uuid now - createLimitBundle uuid now createLocale uuid now return $ toDTO tenant Nothing Nothing @@ -99,12 +99,12 @@ createTenantByAdmin reqDto = do let tenant = fromAdminCreateDTO reqDto uuid serverConfig now insertTenant tenant adminRole <- createAdminRole uuid now + createLimitBundle uuid now userUuid <- liftIO generateUuid userPassword <- liftIO $ generateRandomString 25 let userCreate = U_Mapper.fromTenantCreateToUserCreateDTO (reqDto {password = userPassword}) adminRole.uuid user <- createUserByAdminWithUuid userCreate userUuid tenant.uuid tenant.clientUrl False createConfig uuid adminRole.uuid now - createLimitBundle uuid now createLocale uuid now return $ toDTO tenant Nothing Nothing diff --git a/wizard-server/src/Wizard/Service/User/UserMapper.hs b/wizard-server/src/Wizard/Service/User/UserMapper.hs index 2c6db6798..51d26c828 100644 --- a/wizard-server/src/Wizard/Service/User/UserMapper.hs +++ b/wizard-server/src/Wizard/Service/User/UserMapper.hs @@ -46,6 +46,7 @@ toUserProfile user userGroupUuids pluginSettings = , firstName = user.firstName , lastName = user.lastName , email = user.email + , affiliation = user.affiliation , imageUrl = user.imageUrl , role = user.role , lastSeenNewsId = user.lastSeenNewsId @@ -63,6 +64,7 @@ toSimple user = , lastName = user.lastName , email = user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation } toWithMembership :: User -> UserGroupMembershipType -> UserWithMembership @@ -73,6 +75,7 @@ toWithMembership user membershipType = , lastName = user.lastName , email = user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation , membershipType = membershipType } @@ -84,6 +87,7 @@ toSuggestion user = , lastName = user.lastName , gravatarHash = createGravatarHash user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation } toSuggestion' :: UserDTO -> UserSuggestion @@ -94,6 +98,7 @@ toSuggestion' user = , lastName = user.lastName , gravatarHash = createGravatarHash user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation } toOnlineUserInfo :: Maybe UserDTO -> Int -> Int -> [U.UUID] -> OnlineUserInfo @@ -110,6 +115,7 @@ toLoggedOnlineUserInfo user colorNumber groupUuids = , lastName = user.lastName , gravatarHash = createGravatarHash user.email , imageUrl = user.imageUrl + , affiliation = user.affiliation , colorNumber = colorNumber , role = user.role , groupUuids = groupUuids diff --git a/wizard-server/src/Wizard/Service/User/UserService.hs b/wizard-server/src/Wizard/Service/User/UserService.hs index 93db9ecd0..6ab17452e 100644 --- a/wizard-server/src/Wizard/Service/User/UserService.hs +++ b/wizard-server/src/Wizard/Service/User/UserService.hs @@ -117,8 +117,8 @@ registerUser reqDto = createUser :: UserCreateDTO -> U.UUID -> String -> U.UUID -> [String] -> String -> U.UUID -> String -> Bool -> AppContextM UserDTO createUser reqDto uUuid uPasswordHash role uPermissions uRoleName tenantUuid clientUrl shouldSendRegistrationEmail = runInTransaction $ do - checkUserLimit - checkActiveUserLimit + checkUserLimitForTenant tenantUuid + checkActiveUserLimitForTenant tenantUuid validateUserEmailUniqueness reqDto.email tenantUuid now <- liftIO getCurrentTime let user = fromUserCreateDTO reqDto uUuid uPasswordHash role uPermissions uRoleName tenantUuid now shouldSendRegistrationEmail diff --git a/wizard-server/test/Wizard/Specs/API/Project/Common.hs b/wizard-server/test/Wizard/Specs/API/Project/Common.hs index af1b11ca2..78dc4a798 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Common.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Common.hs @@ -63,7 +63,8 @@ compareProjectCreateFromTemplateDtos resDto expDto = do liftIO $ resDto.name `shouldBe` expDto.name liftIO $ resDto.visibility `shouldBe` expDto.visibility liftIO $ resDto.sharing `shouldBe` expDto.sharing - liftIO $ resDto.state `shouldBe` expDto.state + liftIO $ resDto.knowledgeModelState `shouldBe` expDto.knowledgeModelState + liftIO $ resDto.documentTemplateState `shouldBe` expDto.documentTemplateState liftIO $ resDto.knowledgeModelPackage `shouldBe` expDto.knowledgeModelPackage compareProjectCloneDtos resDto expDto = do @@ -71,7 +72,8 @@ compareProjectCloneDtos resDto expDto = do liftIO $ resDto.name `shouldBe` ("Copy of " ++ expDto.name) liftIO $ resDto.visibility `shouldBe` expDto.visibility liftIO $ resDto.sharing `shouldBe` expDto.sharing - liftIO $ resDto.state `shouldBe` expDto.state + liftIO $ resDto.knowledgeModelState `shouldBe` expDto.knowledgeModelState + liftIO $ resDto.documentTemplateState `shouldBe` expDto.documentTemplateState liftIO $ resDto.knowledgeModelPackage `shouldBe` expDto.knowledgeModelPackage compareProjectCreateDtos' resDto expDto = do @@ -79,7 +81,8 @@ compareProjectCreateDtos' resDto expDto = do liftIO $ resDto.phaseUuid `shouldBe` expDto.phaseUuid liftIO $ resDto.visibility `shouldBe` expDto.visibility liftIO $ resDto.sharing `shouldBe` expDto.sharing - liftIO $ resDto.state `shouldBe` expDto.state + liftIO $ resDto.knowledgeModelState `shouldBe` expDto.knowledgeModelState + liftIO $ resDto.documentTemplateState `shouldBe` expDto.documentTemplateState liftIO $ resDto.knowledgeModelPackage `shouldBe` expDto.knowledgeModelPackage liftIO $ resDto.selectedQuestionTagUuids `shouldBe` expDto.selectedQuestionTagUuids liftIO $ resDto.knowledgeModel `shouldBe` expDto.knowledgeModel diff --git a/wizard-server/test/Wizard/Specs/API/Project/Detail_DELETE.hs b/wizard-server/test/Wizard/Specs/API/Project/Detail_DELETE.hs index 71e6e36c6..fac14868e 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Detail_DELETE.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Detail_DELETE.hs @@ -16,14 +16,11 @@ import Shared.Common.Localization.Messages.Public import Shared.Common.Model.Error.Error import Wizard.Database.DAO.Document.DocumentDAO import Wizard.Database.DAO.Project.ProjectDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO import qualified Wizard.Database.Migration.Development.Document.DocumentMigration as DOC import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations import Wizard.Database.Migration.Development.Project.Data.Projects import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ import qualified Wizard.Database.Migration.Development.User.UserMigration as U -import Wizard.Localization.Messages.Public import Wizard.Model.Context.AppContext import Wizard.Model.Project.Project @@ -38,7 +35,6 @@ detail_DELETE :: AppContext -> SpecWith ((), Application) detail_DELETE appContext = describe "DELETE /wizard-api/projects/{projectUuid}" $ do test_204 appContext - test_400 appContext test_401 appContext test_403 appContext test_404 appContext @@ -86,38 +82,6 @@ create_test_204 title appContext project authHeader docCount = assertCountInDB findProjects appContext 2 assertCountInDB findDocuments appContext docCount --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_400 appContext = - it "HTTP 400 BAD REQUEST when package can't be deleted" $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project4.uuid - let reqHeaders = reqHeadersT reqAuthHeader - -- AND: Prepare expectation - let expStatus = 400 - let expHeaders = resCorsHeaders - let expDto = UserError _ERROR_SERVICE_PROJECT__PROJECT_CANT_BE_DELETED_BECAUSE_IT_IS_USED_IN_MIGRATION - let expBody = encode expDto - -- AND: Prepare DB - runInContextIO U.runMigration appContext - runInContextIO TML.runMigration appContext - runInContextIO PRJ.runMigration appContext - runInContextIO (insertProject project4) appContext - runInContextIO (insertProject project4Upgraded) appContext - runInContextIO (insertProjectMigration projectMigration) appContext - runInContextIO DOC.runMigration appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjects appContext 5 - assertCountInDB findDocuments appContext 3 - -- ---------------------------------------------------- -- ---------------------------------------------------- -- ---------------------------------------------------- diff --git a/wizard-server/test/Wizard/Specs/API/Project/Detail_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/Detail_GET.hs index 7c3120213..8f104ad62 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Detail_GET.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Detail_GET.hs @@ -148,7 +148,6 @@ create_test_200 title appContext project projectEvents kmPackage authHeader perm , visibility = project.visibility , knowledgeModelPackage = kmPackage , isTemplate = project.isTemplate - , migrationUuid = Nothing , permissions = permissions , fileCount = 0 } diff --git a/wizard-server/test/Wizard/Specs/API/Project/Detail_Preview_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/Detail_Preview_GET.hs index 89406b115..fb44ea43a 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Detail_Preview_GET.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Detail_Preview_GET.hs @@ -139,7 +139,6 @@ create_test_200 title appContext project kmPackage authHeader permissions = , sharing = project.sharing , knowledgeModelPackage = kmPackage , isTemplate = project.isTemplate - , migrationUuid = Nothing , permissions = permissions , documentTemplateUuid = project.documentTemplateUuid , format = Just formatJsonSimple diff --git a/wizard-server/test/Wizard/Specs/API/Project/Detail_Questionnaire_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/Detail_Questionnaire_GET.hs index c3ff49089..1baf0404d 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Detail_Questionnaire_GET.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Detail_Questionnaire_GET.hs @@ -195,7 +195,6 @@ create_test_200 title appContext project projectEvents projectContent kmPackage , replies = fReplies , labels = projectContent.labels , phaseUuid = projectContent.phaseUuid - , migrationUuid = Nothing , permissions = permissions , files = [] , unresolvedCommentCounts = unresolvedCommentCounts diff --git a/wizard-server/test/Wizard/Specs/API/Project/Detail_Settings_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/Detail_Settings_GET.hs index 6b6f2b726..60f803a69 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Detail_Settings_GET.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Detail_Settings_GET.hs @@ -33,6 +33,7 @@ import qualified Wizard.Database.Migration.Development.User.UserMigration as U import Wizard.Model.Context.AppContext import Wizard.Model.Project.Detail.ProjectDetailSettings import Wizard.Model.Project.Project +import Wizard.Model.Project.ProjectState import qualified Wizard.Service.KnowledgeModel.Package.KnowledgeModelPackageMapper as PM import Wizard.Service.Project.ProjectMapper import WizardLib.Public.Localization.Messages.Public @@ -138,16 +139,17 @@ create_test_200 title appContext project authHeader permissions = , visibility = project.visibility , sharing = project.sharing , isTemplate = project.isTemplate - , migrationUuid = Nothing , permissions = permissions , projectTags = project.projectTags , knowledgeModelPackageUuid = project.knowledgeModelPackageUuid , knowledgeModelPackage = PM.toSimpleDTO' [] [] germanyKmPackage , knowledgeModelTags = M.elems km1WithQ4.entities.tags + , knowledgeModelState = UpToDateKnowledgeModelProjectState , language = project.language , availableLocales = [] , documentTemplate = Just $ STM.toDTO wizardDocumentTemplate wizardDocumentTemplateFormats - , documentTemplateState = toProjectDetailTemplateState (Just wizardDocumentTemplate) + , documentTemplateState = Just UpToDateDocumentTemplateProjectState + , documentTemplateSupportState = toProjectDetailTemplateSupportState (Just wizardDocumentTemplate) , documentTemplatePhase = Just wizardDocumentTemplate.phase , formatUuid = Just formatJson.uuid , selectedQuestionTagUuids = project.selectedQuestionTagUuids diff --git a/wizard-server/test/Wizard/Specs/API/Project/List_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/List_GET.hs index 470479c38..86b3d5102 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/List_GET.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/List_GET.hs @@ -25,6 +25,8 @@ import Wizard.Database.Migration.Development.User.Data.Users import qualified Wizard.Database.Migration.Development.User.UserMigration as U import Wizard.Model.Context.AppContext import Wizard.Model.User.User +import WizardLib.Public.Database.Migration.Development.User.Data.UserGroups +import WizardLib.Public.Model.User.UserGroup import SharedTest.Specs.API.Common import Wizard.Specs.API.Common @@ -95,33 +97,45 @@ test_200 appContext = do reqAuthHeader (Page "projects" (PageMetadata 20 0 0 0) ([] :: [ProjectDTO])) create_test_200 - "HTTP 200 OK (Admin - isTemplate - true)" + "HTTP 200 OK (Admin - userGroupUuids)" appContext - "/wizard-api/projects?sort=uuid,asc&isTemplate=true" + (BS.pack $ "/wizard-api/projects?sort=uuid,asc&userGroupUuids=" ++ U.toString bioGroup.uuid) reqAuthHeader - (Page "projects" (PageMetadata 20 3 1 0) [project14Dto, project1Dto, project12Dto]) + (Page "projects" (PageMetadata 20 1 1 0) [project15Dto]) create_test_200 - "HTTP 200 OK (Admin - isTemplate - false)" + "HTTP 200 OK (Admin - userGroupUuids, or)" appContext - "/wizard-api/projects?sort=uuid,asc&isTemplate=false" + ( BS.pack $ + "/wizard-api/projects?sort=uuid,asc&userGroupUuidsOp=or&userGroupUuids=" + ++ U.toString bioGroup.uuid + ++ "," + ++ U.toString plantGroup.uuid + ) reqAuthHeader - (Page "projects" (PageMetadata 20 3 1 0) [project3Dto, project15Dto, project2Dto]) + (Page "projects" (PageMetadata 20 1 1 0) [project15Dto]) create_test_200 - "HTTP 200 OK (Admin - isMigrating - true)" + "HTTP 200 OK (Admin - userGroupUuids, and)" appContext - "/wizard-api/projects?sort=uuid,asc&isMigrating=true" + ( BS.pack $ + "/wizard-api/projects?sort=uuid,asc&userGroupUuidsOp=and&userGroupUuids=" + ++ U.toString bioGroup.uuid + ++ "," + ++ U.toString plantGroup.uuid + ) reqAuthHeader (Page "projects" (PageMetadata 20 0 0 0) ([] :: [ProjectDTO])) create_test_200 - "HTTP 200 OK (Admin - isMigrating - false)" + "HTTP 200 OK (Admin - isTemplate - true)" appContext - "/wizard-api/projects?sort=uuid,asc&isMigrating=false" + "/wizard-api/projects?sort=uuid,asc&isTemplate=true" reqAuthHeader - ( Page - "projects" - (PageMetadata 20 6 1 0) - [project3Dto, project14Dto, project1Dto, project15Dto, project2Dto, project12Dto] - ) + (Page "projects" (PageMetadata 20 3 1 0) [project14Dto, project1Dto, project12Dto]) + create_test_200 + "HTTP 200 OK (Admin - isTemplate - false)" + appContext + "/wizard-api/projects?sort=uuid,asc&isTemplate=false" + reqAuthHeader + (Page "projects" (PageMetadata 20 3 1 0) [project3Dto, project15Dto, project2Dto]) create_test_200 "HTTP 200 OK (Admin - projectTags)" appContext @@ -196,6 +210,12 @@ test_200 appContext = do (BS.pack $ "/wizard-api/projects?sort=uuid,asc&userUuids=" ++ U.toString userAlbert.uuid) reqNonAdminAuthHeader (Page "projects" (PageMetadata 20 2 1 0) [project2Dto, project12Dto]) + create_test_200 + "HTTP 200 OK (Non-Admin - query user groups)" + appContext + (BS.pack $ "/wizard-api/projects?sort=uuid,asc&userGroupUuids=" ++ U.toString bioGroup.uuid) + reqNonAdminAuthHeader + (Page "projects" (PageMetadata 20 1 1 0) [project15Dto]) create_test_200 "HTTP 200 OK (Non-Admin - projectTags)" appContext @@ -220,22 +240,6 @@ test_200 appContext = do "/wizard-api/projects?sort=uuid,asc&isTemplate=false" reqNonAdminAuthHeader (Page "projects" (PageMetadata 20 3 1 0) [project3Dto, project15Dto, project2Dto]) - create_test_200 - "HTTP 200 OK (Non-Admin - isMigrating - true)" - appContext - "/wizard-api/projects?sort=uuid,asc&isMigrating=true" - reqNonAdminAuthHeader - (Page "projects" (PageMetadata 20 0 0 0) ([] :: [ProjectDTO])) - create_test_200 - "HTTP 200 OK (Non-Admin - isMigrating - false)" - appContext - "/wizard-api/projects?sort=uuid,asc&isMigrating=false" - reqNonAdminAuthHeader - ( Page - "projects" - (PageMetadata 20 5 1 0) - [project3Dto, project14Dto, project15Dto, project2Dto, project12Dto] - ) create_test_200 title appContext reqUrl reqAuthHeader expDto = it title $ diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/APISpec.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/APISpec.hs index e738969cd..76a122f70 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/APISpec.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Migration/APISpec.hs @@ -2,16 +2,8 @@ module Wizard.Specs.API.Project.Migration.APISpec where import Test.Hspec -import Wizard.Specs.API.Project.Migration.List_Current_Completion_POST -import Wizard.Specs.API.Project.Migration.List_Current_DELETE -import Wizard.Specs.API.Project.Migration.List_Current_GET -import Wizard.Specs.API.Project.Migration.List_Current_PUT import Wizard.Specs.API.Project.Migration.List_POST projectMigrationAPI appContext = - describe "PROJECT MIGRATION API Spec" $ do + describe "PROJECT MIGRATION API Spec" $ list_POST appContext - list_current_GET appContext - list_current_PUT appContext - list_current_DELETE appContext - list_current_completion_POST appContext diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/Common.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/Common.hs deleted file mode 100644 index 8dad388b7..000000000 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/Common.hs +++ /dev/null @@ -1,37 +0,0 @@ -module Wizard.Specs.API.Project.Migration.Common where - -import Data.Either (isRight) -import Test.Hspec -import Test.Hspec.Wai hiding (shouldRespondWith) - -import Shared.Common.Api.Resource.Error.ErrorJM () -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import Wizard.Model.Project.Migration.ProjectMigration - -import Wizard.Specs.API.Project.Common -import Wizard.Specs.Common - --- -------------------------------- --- ASSERTS --- -------------------------------- -assertExistenceOfMigrationStateInDB appContext entity = do - eEntitiesFromDb <- - runInContextIO (findProjectMigrationsByOldProjectUuid entity.oldProjectUuid) appContext - liftIO $ isRight eEntitiesFromDb `shouldBe` True - let (Right entitiesFromDb) = eEntitiesFromDb - liftIO $ length entitiesFromDb `shouldBe` 1 - let entityFromDb = head entitiesFromDb - compareProjectMigrators entityFromDb entity - --- -------------------------------- --- COMPARATORS --- -------------------------------- -compareProjectMigrators resDto expDto = do - liftIO $ resDto.oldProjectUuid `shouldBe` expDto.oldProjectUuid - liftIO $ resDto.newProjectUuid `shouldBe` expDto.newProjectUuid - liftIO $ resDto.resolvedQuestionUuids `shouldBe` expDto.resolvedQuestionUuids - -compareProjectMigratorDtos resDto expDto = do - compareProjectCreateDtos'' resDto.oldProject expDto.oldProject - compareProjectCreateDtos'' resDto.newProject expDto.newProject - liftIO $ resDto.resolvedQuestionUuids `shouldBe` expDto.resolvedQuestionUuids diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_Completion_POST.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_Completion_POST.hs deleted file mode 100644 index 9eef8c48d..000000000 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_Completion_POST.hs +++ /dev/null @@ -1,134 +0,0 @@ -module Wizard.Specs.API.Project.Migration.List_Current_Completion_POST ( - list_current_completion_POST, -) where - -import Data.Aeson (encode) -import qualified Data.ByteString.Char8 as BS -import qualified Data.UUID as U -import Network.HTTP.Types -import Network.Wai (Application) -import Test.Hspec -import Test.Hspec.Wai hiding (shouldRespondWith) -import Test.Hspec.Wai.Matcher - -import Shared.Common.Api.Resource.Error.ErrorJM () -import Shared.Common.Localization.Messages.Public -import Shared.Common.Model.Error.Error -import Wizard.Database.DAO.Project.ProjectDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations -import Wizard.Database.Migration.Development.Project.Data.Projects -import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as PRJ_MIG -import qualified Wizard.Database.Migration.Development.User.UserMigration as U -import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Migration.ProjectMigration -import Wizard.Model.Project.Project - -import SharedTest.Specs.API.Common -import Wizard.Specs.API.Common -import Wizard.Specs.Common - --- ------------------------------------------------------------------------ --- POST /wizard-api/projects/{projectUuid}/migrations/current/completion --- ------------------------------------------------------------------------ -list_current_completion_POST :: AppContext -> SpecWith ((), Application) -list_current_completion_POST appContext = - describe "POST /wizard-api/projects/{projectUuid}/migrations/current/completion" $ do - test_204 appContext - test_401 appContext - test_403 appContext - test_404 appContext - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -reqMethod = methodPost - -reqUrlT projectUuid = BS.pack $ "/wizard-api/projects/" ++ U.toString projectUuid ++ "/migrations/current/completion" - -reqHeadersT authHeader = [authHeader] - -reqBody = "" - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_204 appContext = - it "HTTP 204 NO CONTENT" $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project4Upgraded.uuid - let reqHeaders = reqHeadersT reqAuthHeader - -- AND: Prepare expectation - let expStatus = 204 - let expBody = "" - let expHeaders = resCorsHeaders - -- AND: Prepare database - runInContextIO TML.runMigration appContext - runInContextIO (insertProject project4) appContext - runInContextIO (insertProject project4Upgraded) appContext - runInContextIO (insertProject differentProject) appContext - runInContextIO PRJ_MIG.runMigration appContext - runInContextIO (insertProjectMigration projectMigration) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjects appContext 1 - assertCountInDB findProjectMigrations appContext 0 - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_401 appContext = createAuthTest reqMethod (reqUrlT project3.uuid) [] reqBody - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_403 appContext = do - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, Private)" appContext project1 "View Project" - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, VisibleView)" appContext project2 "Migrate Project" - -create_test_403 title appContext project reason = - it title $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project.uuid - let reqHeaders = reqHeadersT reqNonAdminAuthHeader - -- AND: Prepare expectation - let expStatus = 403 - let expHeaders = resCtHeader : resCorsHeaders - let expDto = ForbiddenError $ _ERROR_VALIDATION__FORBIDDEN reason - let expBody = encode expDto - -- AND: Run migrations - runInContextIO U.runMigration appContext - runInContextIO TML.runMigration appContext - runInContextIO PRJ.runMigration appContext - let ms = projectMigration {oldProjectUuid = project.uuid, newProjectUuid = project.uuid} - runInContextIO (insertProjectMigration ms) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjects appContext 3 - assertCountInDB findProjectMigrations appContext 1 - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_404 appContext = - createNotFoundTest' - reqMethod - (reqUrlT project4.uuid) - (reqHeadersT reqAuthHeader) - reqBody - "project_migration" - [("new_project_uuid", "57250a07-a663-4ff3-ac1f-16530f2c1bfe")] diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_DELETE.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_DELETE.hs deleted file mode 100644 index 625b55294..000000000 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_DELETE.hs +++ /dev/null @@ -1,134 +0,0 @@ -module Wizard.Specs.API.Project.Migration.List_Current_DELETE ( - list_current_DELETE, -) where - -import Data.Aeson (encode) -import qualified Data.ByteString.Char8 as BS -import qualified Data.UUID as U -import Network.HTTP.Types -import Network.Wai (Application) -import Test.Hspec -import Test.Hspec.Wai hiding (shouldRespondWith) -import Test.Hspec.Wai.Matcher - -import Shared.Common.Api.Resource.Error.ErrorJM () -import Shared.Common.Localization.Messages.Public -import Shared.Common.Model.Error.Error -import Wizard.Database.DAO.Project.ProjectDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations -import Wizard.Database.Migration.Development.Project.Data.Projects -import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as PRJ_MIG -import qualified Wizard.Database.Migration.Development.User.UserMigration as U -import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Migration.ProjectMigration -import Wizard.Model.Project.Project - -import SharedTest.Specs.API.Common -import Wizard.Specs.API.Common -import Wizard.Specs.Common - --- ------------------------------------------------------------------------ --- DELETE /wizard-api/projects/{projectUuid}/migrations/current --- ------------------------------------------------------------------------ -list_current_DELETE :: AppContext -> SpecWith ((), Application) -list_current_DELETE appContext = - describe "DELETE /wizard-api/projects/{projectUuid}/migrations/current" $ do - test_204 appContext - test_401 appContext - test_403 appContext - test_404 appContext - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -reqMethod = methodDelete - -reqUrlT projectUuid = BS.pack $ "/wizard-api/projects/" ++ U.toString projectUuid ++ "/migrations/current" - -reqHeadersT authHeader = [authHeader] - -reqBody = "" - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_204 appContext = - it "HTTP 204 NO CONTENT" $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project4Upgraded.uuid - let reqHeaders = reqHeadersT reqAuthHeader - -- AND: Prepare expectation - let expStatus = 204 - let expBody = "" - let expHeaders = resCorsHeaders - -- AND: Prepare database - runInContextIO TML.runMigration appContext - runInContextIO (insertProject project4) appContext - runInContextIO (insertProject project4Upgraded) appContext - runInContextIO (insertProject differentProject) appContext - runInContextIO PRJ_MIG.runMigration appContext - runInContextIO (insertProjectMigration projectMigration) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjects appContext 1 - assertCountInDB findProjectMigrations appContext 0 - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_401 appContext = createAuthTest reqMethod (reqUrlT project3.uuid) [] reqBody - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_403 appContext = do - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, Private)" appContext project1 "View Project" - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, VisibleView)" appContext project2 "Migrate Project" - -create_test_403 title appContext project reason = - it title $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project.uuid - let reqHeaders = reqHeadersT reqNonAdminAuthHeader - -- AND: Prepare expectation - let expStatus = 403 - let expHeaders = resCtHeader : resCorsHeaders - let expDto = ForbiddenError $ _ERROR_VALIDATION__FORBIDDEN reason - let expBody = encode expDto - -- AND: Run migrations - runInContextIO U.runMigration appContext - runInContextIO TML.runMigration appContext - runInContextIO PRJ.runMigration appContext - let ms = projectMigration {oldProjectUuid = project.uuid, newProjectUuid = project.uuid} - runInContextIO (insertProjectMigration ms) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjects appContext 3 - assertCountInDB findProjectMigrations appContext 1 - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_404 appContext = - createNotFoundTest' - reqMethod - (reqUrlT project4.uuid) - (reqHeadersT reqAuthHeader) - reqBody - "project_migration" - [("new_project_uuid", "57250a07-a663-4ff3-ac1f-16530f2c1bfe")] diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_GET.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_GET.hs deleted file mode 100644 index fa21336dd..000000000 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_GET.hs +++ /dev/null @@ -1,164 +0,0 @@ -module Wizard.Specs.API.Project.Migration.List_Current_GET ( - list_current_GET, -) where - -import Data.Aeson (encode) -import qualified Data.ByteString.Char8 as BS -import qualified Data.UUID as U -import Network.HTTP.Types -import Network.Wai (Application) -import Test.Hspec -import Test.Hspec.Wai hiding (shouldRespondWith) -import Test.Hspec.Wai.Matcher - -import Shared.Common.Localization.Messages.Public -import Shared.Common.Model.Error.Error -import Wizard.Database.DAO.Project.ProjectDAO -import Wizard.Database.DAO.Project.ProjectEventDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations -import Wizard.Database.Migration.Development.Project.Data.Projects -import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as PRJ_MIG -import qualified Wizard.Database.Migration.Development.User.UserMigration as U -import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Migration.ProjectMigration -import Wizard.Model.Project.Project - -import SharedTest.Specs.API.Common -import Wizard.Specs.API.Common -import Wizard.Specs.Common - --- ------------------------------------------------------------------------ --- GET /wizard-api/projects/{projectUuid}/migrations/current --- ------------------------------------------------------------------------ -list_current_GET :: AppContext -> SpecWith ((), Application) -list_current_GET appContext = - describe "GET /wizard-api/projects/{projectUuid}/migrations/current" $ do - test_200 appContext - test_401 appContext - test_403 appContext - test_404 appContext - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -reqMethod = methodGet - -reqUrlT projectUuid = BS.pack $ "/wizard-api/projects/" ++ U.toString projectUuid ++ "/migrations/current" - -reqHeadersT authHeader = [authHeader, reqCtHeader] - -reqBody = "" - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_200 appContext = do - create_test_200 - "HTTP 200 OK (Owner, Private)" - appContext - project4 - project4Events - project4Upgraded - project4UpgradedEvents - projectMigration - projectMigrationDto - reqNonAdminAuthHeader - create_test_200 - "HTTP 200 OK (Non-Owner, VisibleView)" - appContext - project4VisibleView - project4VisibleViewEvents - project4VisibleViewUpgraded - project4VisibleViewUpgradedEvents - projectMigration - projectMigrationVisibleViewDto - reqNonAdminAuthHeader - create_test_200 - "HTTP 200 OK (Non-Owner, Public)" - appContext - project4VisibleEdit - project4VisibleEditEvents - project4VisibleEditUpgraded - project4VisibleEditUpgradedEvents - projectMigration - projectMigrationVisibleEditDto - reqNonAdminAuthHeader - -create_test_200 title appContext oldProject oldProjectEvents newProject newProjectEvents state stateDto authHeader = - it title $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project4Upgraded.uuid - let reqHeaders = reqHeadersT reqAuthHeader - -- AND: Prepare expectation - let expStatus = 200 - let expDto = stateDto - let expBody = encode expDto - let expHeaders = resCtHeader : resCorsHeaders - -- AND: Prepare database - runInContextIO TML.runMigration appContext - runInContextIO (insertProject oldProject) appContext - runInContextIO (insertProjectEvents oldProjectEvents) appContext - runInContextIO (insertProject newProject) appContext - runInContextIO (insertProjectEvents newProjectEvents) appContext - runInContextIO (insertProject differentProject) appContext - runInContextIO (insertProjectEvents differentProjectEvents) appContext - runInContextIO PRJ_MIG.runMigration appContext - runInContextIO (insertProjectMigration state) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_401 appContext = createAuthTest reqMethod (reqUrlT project4.uuid) [] reqBody - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_403 appContext = do - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, Private)" appContext project1 "View Project" - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, VisibleView)" appContext project2 "Migrate Project" - -create_test_403 title appContext project reason = - it title $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project.uuid - let reqHeaders = reqHeadersT reqNonAdminAuthHeader - -- AND: Prepare expectation - let expStatus = 403 - let expHeaders = resCtHeader : resCorsHeaders - let expDto = ForbiddenError $ _ERROR_VALIDATION__FORBIDDEN reason - let expBody = encode expDto - -- AND: Run migrations - runInContextIO U.runMigration appContext - runInContextIO TML.runMigration appContext - runInContextIO PRJ.runMigration appContext - let ms = projectMigration {oldProjectUuid = project.uuid, newProjectUuid = project.uuid} - runInContextIO (insertProjectMigration ms) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_404 appContext = - createNotFoundTest' - reqMethod - (reqUrlT project4.uuid) - (reqHeadersT reqAuthHeader) - reqBody - "project_migration" - [("new_project_uuid", "57250a07-a663-4ff3-ac1f-16530f2c1bfe")] diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_PUT.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_PUT.hs deleted file mode 100644 index e09ac1cdc..000000000 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_Current_PUT.hs +++ /dev/null @@ -1,140 +0,0 @@ -module Wizard.Specs.API.Project.Migration.List_Current_PUT ( - list_current_PUT, -) where - -import Data.Aeson (encode) -import qualified Data.ByteString.Char8 as BS -import qualified Data.UUID as U -import Network.HTTP.Types -import Network.Wai (Application) -import Test.Hspec -import Test.Hspec.Wai hiding (shouldRespondWith) -import Test.Hspec.Wai.Matcher - -import Shared.Common.Localization.Messages.Public -import Shared.Common.Model.Error.Error -import Wizard.Database.DAO.Project.ProjectDAO -import Wizard.Database.DAO.Project.ProjectEventDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO -import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations -import Wizard.Database.Migration.Development.Project.Data.Projects -import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as PRJ_MIG -import qualified Wizard.Database.Migration.Development.User.UserMigration as U -import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Migration.ProjectMigration -import Wizard.Model.Project.Project - -import SharedTest.Specs.API.Common -import Wizard.Specs.API.Common -import Wizard.Specs.Common - --- ------------------------------------------------------------------------ --- PUT /wizard-api/projects/{projectUuid}/migrations/current --- ------------------------------------------------------------------------ -list_current_PUT :: AppContext -> SpecWith ((), Application) -list_current_PUT appContext = - describe "PUT /wizard-api/projects/{projectUuid}/migrations/current" $ do - test_204 appContext - test_400 appContext - test_401 appContext - test_403 appContext - test_404 appContext - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -reqMethod = methodPut - -reqUrlT projectUuid = BS.pack $ "/wizard-api/projects/" ++ U.toString projectUuid ++ "/migrations/current" - -reqHeadersT authHeader = [authHeader, reqCtHeader] - -reqDto = projectMigrationChangeDto - -reqBody = encode reqDto - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_204 appContext = - it "HTTP 204 NO CONTENT" $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project4Upgraded.uuid - let reqHeaders = reqHeadersT reqAuthHeader - -- AND: Prepare expectation - let expStatus = 200 - let expDto = projectMigrationDtoEdited - let expBody = encode expDto - let expHeaders = resCtHeader : resCorsHeaders - -- AND: Prepare database - runInContextIO TML.runMigration appContext - runInContextIO (insertProject project4) appContext - runInContextIO (insertProjectEvents project4Events) appContext - runInContextIO (insertProject project4Upgraded) appContext - runInContextIO (insertProjectEvents project4UpgradedEvents) appContext - runInContextIO (insertProject differentProject) appContext - runInContextIO (insertProjectEvents differentProjectEvents) appContext - runInContextIO PRJ_MIG.runMigration appContext - runInContextIO (insertProjectMigration projectMigration) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_400 appContext = createInvalidJsonTest reqMethod (reqUrlT project4.uuid) "resolvedQuestionUuids" - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_401 appContext = createAuthTest reqMethod (reqUrlT project4.uuid) [reqCtHeader] reqBody - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_403 appContext = do - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, Private)" appContext project1 "View Project" - create_test_403 "HTTP 403 FORBIDDEN (Non-Owner, VisibleView)" appContext project2 "Migrate Project" - -create_test_403 title appContext project reason = - it title $ - -- GIVEN: Prepare request - do - let reqUrl = reqUrlT project.uuid - let reqHeaders = reqHeadersT reqNonAdminAuthHeader - -- AND: Prepare expectation - let expStatus = 403 - let expHeaders = resCtHeader : resCorsHeaders - let expDto = ForbiddenError $ _ERROR_VALIDATION__FORBIDDEN reason - let expBody = encode expDto - -- AND: Run migrations - runInContextIO U.runMigration appContext - runInContextIO TML.runMigration appContext - runInContextIO PRJ.runMigration appContext - let ms = projectMigration {oldProjectUuid = project.uuid, newProjectUuid = project.uuid} - runInContextIO (insertProjectMigration ms) appContext - -- WHEN: Call API - response <- request reqMethod reqUrl reqHeaders reqBody - -- THEN: Compare response with expectation - let responseMatcher = - ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} - response `shouldRespondWith` responseMatcher - --- ---------------------------------------------------- --- ---------------------------------------------------- --- ---------------------------------------------------- -test_404 appContext = - createNotFoundTest' - reqMethod - (reqUrlT project4.uuid) - (reqHeadersT reqAuthHeader) - reqBody - "project_migration" - [("new_project_uuid", "57250a07-a663-4ff3-ac1f-16530f2c1bfe")] diff --git a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_POST.hs b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_POST.hs index bf17607ec..18ee8c825 100644 --- a/wizard-server/test/Wizard/Specs/API/Project/Migration/List_POST.hs +++ b/wizard-server/test/Wizard/Specs/API/Project/Migration/List_POST.hs @@ -4,6 +4,8 @@ module Wizard.Specs.API.Project.Migration.List_POST ( import Data.Aeson (encode) import qualified Data.ByteString.Char8 as BS +import Data.Either (isRight) +import qualified Data.Map.Strict as M import qualified Data.UUID as U import Network.HTTP.Types import Network.Wai (Application) @@ -13,25 +15,25 @@ import Test.Hspec.Wai.Matcher import Shared.Common.Localization.Messages.Public import Shared.Common.Model.Error.Error +import Shared.KnowledgeModel.Database.Migration.Development.KnowledgeModel.Data.KnowledgeModels +import Shared.KnowledgeModel.Database.Migration.Development.KnowledgeModel.Data.Package.KnowledgeModelPackages +import Shared.KnowledgeModel.Model.KnowledgeModel.Package.KnowledgeModelPackage import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationDTO -import Wizard.Api.Resource.Project.Migration.ProjectMigrationJM () +import Wizard.Api.Resource.Project.Detail.ProjectDetailQuestionnaireJM () +import Wizard.Api.Resource.Project.Migration.ProjectMigrationCreateJM () import Wizard.Database.DAO.Project.ProjectDAO import Wizard.Database.DAO.Project.ProjectEventDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO import qualified Wizard.Database.Migration.Development.DocumentTemplate.DocumentTemplateMigration as TML -import Wizard.Database.Migration.Development.Project.Data.ProjectMigrations import Wizard.Database.Migration.Development.Project.Data.Projects import qualified Wizard.Database.Migration.Development.Project.ProjectMigration as PRJ -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationMigration as PRJ_MIG import qualified Wizard.Database.Migration.Development.User.UserMigration as U import Wizard.Model.Context.AppContext -import Wizard.Model.Project.Migration.ProjectMigration +import Wizard.Model.KnowledgeModel.Package.KnowledgeModelPackageSuggestion import Wizard.Model.Project.Project +import Wizard.Model.Project.ProjectContent import SharedTest.Specs.API.Common import Wizard.Specs.API.Common -import Wizard.Specs.API.Project.Migration.Common import Wizard.Specs.Common -- ------------------------------------------------------------------------ @@ -40,7 +42,7 @@ import Wizard.Specs.Common list_POST :: AppContext -> SpecWith ((), Application) list_POST appContext = describe "POST /wizard-api/projects/{projectUuid}/migrations" $ do - test_201 appContext + test_200 appContext test_400 appContext test_401 appContext test_403 appContext @@ -62,71 +64,47 @@ reqBody = encode reqDto -- ---------------------------------------------------- -- ---------------------------------------------------- -- ---------------------------------------------------- -test_201 appContext = do - create_test_201 - "HTTP 201 CREATED (Owner, Private)" - appContext - project4 - project4Events - project4Upgraded - project4UpgradedEvents - projectMigration - projectMigrationDto - reqNonAdminAuthHeader - create_test_201 - "HTTP 201 CREATED (Non-Owner, VisibleView)" - appContext - project4VisibleView - project4VisibleViewEvents - project4VisibleViewUpgraded - project4VisibleViewUpgradedEvents - projectMigration - projectMigrationVisibleViewDto - reqNonAdminAuthHeader - create_test_201 - "HTTP 201 CREATED (Non-Owner, Public)" - appContext - project4VisibleEdit - project4VisibleEditEvents - project4VisibleEditUpgraded - project4VisibleEditUpgradedEvents - projectMigration - projectMigrationVisibleEditDto - reqNonAdminAuthHeader - -create_test_201 title appContext oldProject oldProjectEvents newProject newProjectEvents state stateDto authHeader = +test_200 appContext = do + create_test_200 "HTTP 200 OK (Owner, Private)" appContext project4 project4Events + create_test_200 "HTTP 200 OK (Non-Owner, VisibleView)" appContext project4VisibleView project4VisibleViewEvents + create_test_200 "HTTP 200 OK (Non-Owner, VisibleEdit)" appContext project4VisibleEdit project4VisibleEditEvents + +create_test_200 title appContext project projectEvents = it title $ -- GIVEN: Prepare request do - let reqUrl = reqUrlT oldProject.uuid + let reqUrl = reqUrlT project.uuid let reqHeaders = reqHeadersT reqAuthHeader -- AND: Prepare expectation - let expStatus = 201 + let expStatus = 200 let expHeaders = resCorsHeadersPlain - let expDto = stateDto {resolvedQuestionUuids = []} :: ProjectMigrationDTO - let expBody = encode expDto -- AND: Prepare database runInContextIO TML.runMigration appContext - runInContextIO (insertProject oldProject) appContext - runInContextIO (insertProjectEvents oldProjectEvents) appContext - runInContextIO (insertProject newProject) appContext - runInContextIO (insertProjectEvents newProjectEvents) appContext - runInContextIO (insertProject differentProject) appContext - runInContextIO (insertProjectEvents differentProjectEvents) appContext - runInContextIO PRJ_MIG.runMigration appContext + runInContextIO (insertProject project) appContext + runInContextIO (insertProjectEvents projectEvents) appContext + -- WHEN: Call API response <- request reqMethod reqUrl reqHeaders reqBody -- THEN: Compare response with expectation - let (status, headers, resBody) = destructResponse response :: (Int, ResponseHeaders, ProjectMigrationDTO) + let (status, headers, resBody) = destructResponse response :: (Int, ResponseHeaders, ProjectDetailQuestionnaireDTO) assertResStatus status expStatus assertResHeaders headers expHeaders - compareProjectMigratorDtos resBody expDto + liftIO $ resBody.uuid `shouldBe` project.uuid + liftIO $ resBody.knowledgeModelPackage.uuid `shouldBe` netherlandsKmPackageV2.uuid + liftIO $ resBody.knowledgeModel `shouldBe` km1NetherlandsV2 + liftIO $ resBody.phaseUuid `shouldBe` project4Ctn.phaseUuid + liftIO $ resBody.replies `shouldBe` M.empty -- AND: Find a result in DB - let entityInDB = - state - { newProjectUuid = resBody.newProject.uuid - , resolvedQuestionUuids = [] - } - assertExistenceOfMigrationStateInDB appContext entityInDB + assertCountInDB findProjects appContext 1 + eProjectFromDb <- runInContextIO (findProjectByUuid project.uuid) appContext + liftIO $ isRight eProjectFromDb `shouldBe` True + let (Right projectFromDb) = eProjectFromDb + liftIO $ projectFromDb.knowledgeModelPackageUuid `shouldBe` netherlandsKmPackageV2.uuid + liftIO $ projectFromDb.selectedQuestionTagUuids `shouldBe` [] + liftIO $ projectFromDb.squashed `shouldBe` False + eProjectEventsFromDb <- runInContextIO (findProjectEventsByProjectUuid project.uuid) appContext + liftIO $ isRight eProjectEventsFromDb `shouldBe` True + let (Right projectEventsFromDb) = eProjectEventsFromDb + liftIO $ projectEventsFromDb `shouldBe` projectEvents -- ---------------------------------------------------- -- ---------------------------------------------------- @@ -166,8 +144,6 @@ create_test_403 title appContext project reason = let responseMatcher = ResponseMatcher {matchHeaders = expHeaders, matchStatus = expStatus, matchBody = bodyEquals expBody} response `shouldRespondWith` responseMatcher - -- AND: Find result in DB and compare with expectation state - assertCountInDB findProjectMigrations appContext 0 -- ---------------------------------------------------- -- ---------------------------------------------------- diff --git a/wizard-server/test/Wizard/Specs/Service/Project/Migration/Migrator/SanitizerSpec.hs b/wizard-server/test/Wizard/Specs/Service/Project/Migration/Migrator/SanitizerSpec.hs index 32ba52ba7..db03a56bb 100644 --- a/wizard-server/test/Wizard/Specs/Service/Project/Migration/Migrator/SanitizerSpec.hs +++ b/wizard-server/test/Wizard/Specs/Service/Project/Migration/Migrator/SanitizerSpec.hs @@ -29,11 +29,11 @@ sanitizerIntegrationSpec appContext = $ km1WithQ4 let projectEvents = fEventsList project1Uuid -- WHEN: - (Right result) <- runInContext (sanitizeProjectEvents project1Uuid oldKm newKm projectEvents) appContext + (Right result) <- runInContext (sanitizeProjectEvents oldKm newKm projectEvents) appContext -- THEN: - extractEventPath (result !! 15) `shouldBe` fst rQ1 - extractEventPath (result !! 16) `shouldBe` fst rQ9 - extractSetEventValue (result !! 16) `shouldBe` (snd rQ9WithNewType).value + extractEventPath (head result) `shouldBe` fst rQ1 + extractEventPath (result !! 1) `shouldBe` fst rQ9 + extractSetEventValue (result !! 1) `shouldBe` (snd rQ9WithNewType).value extractEventPath :: ProjectEventList -> String extractEventPath (ClearReplyEventList' event) = event.path diff --git a/wizard-server/test/Wizard/TestMigration.hs b/wizard-server/test/Wizard/TestMigration.hs index f6b743272..77aec0922 100644 --- a/wizard-server/test/Wizard/TestMigration.hs +++ b/wizard-server/test/Wizard/TestMigration.hs @@ -29,7 +29,6 @@ import Wizard.Database.DAO.Project.ProjectCommentThreadDAO import Wizard.Database.DAO.Project.ProjectDAO import Wizard.Database.DAO.Project.ProjectEventDAO import Wizard.Database.DAO.Project.ProjectFileDAO -import Wizard.Database.DAO.Project.ProjectMigrationDAO import Wizard.Database.DAO.Project.ProjectPermDAO import Wizard.Database.DAO.Project.ProjectVersionDAO import Wizard.Database.DAO.Registry.RegistryKnowledgeModelPackageDAO @@ -65,7 +64,6 @@ import qualified Wizard.Database.Migration.Development.Locale.LocaleSchemaMigrat import qualified Wizard.Database.Migration.Development.PersistentCommand.PersistentCommandSchemaMigration as PersistentCommand import Wizard.Database.Migration.Development.Plugin.Data.Plugins import qualified Wizard.Database.Migration.Development.Plugin.PluginSchemaMigration as Plugin -import qualified Wizard.Database.Migration.Development.Project.ProjectMigrationSchemaMigration as ProjectMigration import qualified Wizard.Database.Migration.Development.Project.ProjectSchemaMigration as Project import qualified Wizard.Database.Migration.Development.Registry.RegistrySchemaMigration as Registry import qualified Wizard.Database.Migration.Development.Submission.SubmissionSchemaMigration as Submission @@ -127,7 +125,6 @@ buildSchema appContext = do runInContext KnowledgeModelCache.dropTables appContext runInContext KnowledgeModelEditor.dropTables appContext runInContext Document.dropTables appContext - runInContext ProjectMigration.dropTables appContext runInContext Project.dropTables appContext runInContext KnowledgeModelSecret.dropTables appContext runInContext KnowledgeModelLocale.dropTables appContext @@ -172,7 +169,6 @@ buildSchema appContext = do runInContext Project.createTables appContext runInContext DocumentTemplate.createDraftDataTable appContext runInContext Document.createTables appContext - runInContext ProjectMigration.createTables appContext runInContext KnowledgeModelMigration.createTables appContext runInContext Submission.createTables appContext runInContext PersistentCommand.createTables appContext @@ -219,7 +215,6 @@ resetDB appContext = do runInContext deleteTenantConfigAuthentications appContext runInContext deleteTenantConfigOrganizations appContext runInContext deleteKnowledgeModelMigrations appContext - runInContext deleteProjectMigrations appContext runInContext deleteFeedbacks appContext runInContext deleteUserEmailLinks appContext runInContext deleteKnowledgeModelEditors appContext