Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prod/2024-09-09 #264

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/production-ci-cd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
deploy_and_build:
name: Build and deploy
runs-on: ubuntu-latest
environment: prod
environment: staging

steps:
- name: Install ssh keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from mapping_workbench.backend.conceptual_mapping_rule.models.entity import ConceptualMappingRule, \
ConceptualMappingRuleCreateIn, ConceptualMappingRuleUpdateIn, ConceptualMappingRuleOut, \
ConceptualMappingRuleTermsValidity
from mapping_workbench.backend.core.models.base_entity import BaseEntityFiltersSchema
from mapping_workbench.backend.core.models.base_entity import BaseEntityFiltersSchema, BaseEntity
from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException
from mapping_workbench.backend.core.services.request import request_update_data, request_create_data, \
api_entity_is_found, pagination_params, prepare_search_param
from mapping_workbench.backend.fields_registry.models.field_registry import StructuralElement
from mapping_workbench.backend.ontology.services.terms import check_content_terms_validity
from mapping_workbench.backend.user.models.user import User

Expand Down Expand Up @@ -40,8 +41,9 @@ async def list_conceptual_mapping_rules(filters: dict = None, page: int = None,
for item in items:
if item.source_structural_element:
item.source_structural_element = await item.source_structural_element.fetch()
item.source_structural_element_sdk_element_id = item.source_structural_element.sdk_element_id
item.source_structural_element_absolute_xpath = item.source_structural_element.absolute_xpath
if isinstance(item.source_structural_element, StructuralElement):
item.source_structural_element_sdk_element_id = item.source_structural_element.sdk_element_id
item.source_structural_element_absolute_xpath = item.source_structural_element.absolute_xpath

total_count: int = await ConceptualMappingRule.find(query_filters).count()
return items, total_count
Expand All @@ -51,6 +53,10 @@ async def create_conceptual_mapping_rule(data: ConceptualMappingRuleCreateIn,
user: User) -> ConceptualMappingRuleOut:
create_data = await rule_validated_data(request_create_data(data, user=user))
create_data[ConceptualMappingRule.source_structural_element] = data.source_structural_element.to_ref().id
if ConceptualMappingRule.refers_to_mapping_package_ids in create_data:
create_data[ConceptualMappingRule.refers_to_mapping_package_ids] = [
PydanticObjectId(package_id) for package_id in create_data[ConceptualMappingRule.refers_to_mapping_package_ids]
]
conceptual_mapping_rule: ConceptualMappingRule = \
ConceptualMappingRule(
**create_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from beanie import Link
from pymongo import IndexModel

from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \
BaseMappingPackagesResourceSchemaTrait
from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity
from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection, \
FileResourceIn
Expand All @@ -31,7 +33,7 @@ class ResourceCollectionState(ObjectState):
file_resources: Optional[List[ResourceFileState]] = []


class ResourceCollection(FileResourceCollection, StatefulObjectABC):
class ResourceCollection(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC):
file_resources: Optional[List[Link["ResourceFile"]]] = []

async def get_resource_files_states(self) -> List[ResourceFileState]:
Expand Down
15 changes: 14 additions & 1 deletion mapping_workbench/backend/resource_collection/services/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException
from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \
request_create_data, prepare_search_param, pagination_params
from mapping_workbench.backend.mapping_package.models.entity import MappingPackage
from mapping_workbench.backend.resource_collection.models.entity import ResourceCollection, ResourceFile, \
ResourceFileUpdateIn, ResourceFileCreateIn
from mapping_workbench.backend.user.models.user import User
Expand All @@ -32,7 +33,19 @@ async def list_resource_collections(filters: dict = None, page: int = None, limi

async def create_resource_collection(resource_collection: ResourceCollection, user: User) -> ResourceCollection:
resource_collection.on_create(user=user)
return await resource_collection.create()
pkg_ids = resource_collection.refers_to_mapping_package_ids or []
resource_collection.refers_to_mapping_package_ids = None
suite = await resource_collection.create()

for pkg_id in pkg_ids:
mapping_package = await MappingPackage.get(pkg_id)
if mapping_package:
if not mapping_package.resource_collections:
mapping_package.resource_collections = []
mapping_package.resource_collections.append(ResourceCollection.link_from_id(suite.id))
await mapping_package.save()

return suite


async def update_resource_collection(
Expand Down
4 changes: 3 additions & 1 deletion mapping_workbench/backend/shacl_test_suite/models/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from beanie import Link, PydanticObjectId
from pymongo import IndexModel

from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \
BaseMappingPackagesResourceSchemaTrait
from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity
from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection
from mapping_workbench.backend.state_manager.models.state_object import ObjectState, StatefulObjectABC
Expand Down Expand Up @@ -34,7 +36,7 @@ class SHACLTestSuiteState(ObjectState):
shacl_test_states: Optional[List[SHACLTestState]] = []


class SHACLTestSuite(FileResourceCollection, StatefulObjectABC):
class SHACLTestSuite(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC):
file_resources: Optional[List[Link["SHACLTestFileResource"]]] = []

async def get_shacl_test_states(self) -> List[SHACLTestState]:
Expand Down
15 changes: 14 additions & 1 deletion mapping_workbench/backend/shacl_test_suite/services/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException
from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \
request_create_data, prepare_search_param, pagination_params
from mapping_workbench.backend.mapping_package.models.entity import MappingPackage
from mapping_workbench.backend.shacl_test_suite.models.entity import SHACLTestSuite, SHACLTestFileResource
from mapping_workbench.backend.shacl_test_suite.models.entity_api_response import SHACLTestFileResourceCreateIn, \
SHACLTestFileResourceUpdateIn
Expand All @@ -32,7 +33,19 @@ async def list_shacl_test_suites(filters: dict = None, page: int = None, limit:

async def create_shacl_test_suite(shacl_test_suite: SHACLTestSuite, user: User) -> SHACLTestSuite:
shacl_test_suite.on_create(user=user)
return await shacl_test_suite.create()
pkg_ids = shacl_test_suite.refers_to_mapping_package_ids or []
shacl_test_suite.refers_to_mapping_package_ids = None
suite = await shacl_test_suite.create()

for pkg_id in pkg_ids:
mapping_package = await MappingPackage.get(pkg_id)
if mapping_package:
if not mapping_package.shacl_test_suites:
mapping_package.shacl_test_suites = []
mapping_package.shacl_test_suites.append(SHACLTestSuite.link_from_id(suite.id))
await mapping_package.save()

return suite


async def update_shacl_test_suite(
Expand Down
4 changes: 3 additions & 1 deletion mapping_workbench/backend/sparql_test_suite/models/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from pydantic import ConfigDict
from pymongo import IndexModel

from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \
BaseMappingPackagesResourceSchemaTrait
from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity
from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection, \
FileResourceIn
Expand Down Expand Up @@ -52,7 +54,7 @@ class SPARQLTestSuiteState(ObjectState):
sparql_test_states: Optional[List[SPARQLTestState]] = []


class SPARQLTestSuite(FileResourceCollection, StatefulObjectABC):
class SPARQLTestSuite(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC):
type: Optional[SPARQLQueryValidationType] = None
file_resources: Optional[List[Link["SPARQLTestFileResource"]]] = []

Expand Down
15 changes: 14 additions & 1 deletion mapping_workbench/backend/sparql_test_suite/services/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException
from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \
request_create_data, prepare_search_param, pagination_params
from mapping_workbench.backend.mapping_package.models.entity import MappingPackage
from mapping_workbench.backend.project.models.entity import Project
from mapping_workbench.backend.sparql_test_suite.models.entity import SPARQLTestSuite, SPARQLTestFileResource, \
SPARQLTestFileResourceUpdateIn, SPARQLTestFileResourceCreateIn
Expand All @@ -32,7 +33,19 @@ async def list_sparql_test_suites(filters: dict = None, page: int = None, limit:

async def create_sparql_test_suite(sparql_test_suite: SPARQLTestSuite, user: User) -> SPARQLTestSuite:
sparql_test_suite.on_create(user=user)
return await sparql_test_suite.create()
pkg_ids = sparql_test_suite.refers_to_mapping_package_ids or []
sparql_test_suite.refers_to_mapping_package_ids = None
suite = await sparql_test_suite.create()

for pkg_id in pkg_ids:
mapping_package = await MappingPackage.get(pkg_id)
if mapping_package:
if not mapping_package.sparql_test_suites:
mapping_package.sparql_test_suites = []
mapping_package.sparql_test_suites.append(SPARQLTestSuite.link_from_id(suite.id))
await mapping_package.save()

return suite


async def update_sparql_test_suite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ResourceCollectionsApi extends FileCollectionsApi {
constructor() {
super("value_mapping_resources");
this.isProjectResource = true;
this.refersToMappingPackages = true;
}

async getValuesForSelector(request = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SHACLTestSuitesApi extends FileCollectionsApi {
constructor() {
super("shacl_test_suites");
this.isProjectResource = true;
this.refersToMappingPackages = true;
}

async getValuesForSelector(request = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SPARQLTestSuitesApi extends FileCollectionsApi {
super("sparql_test_suites");
this.isProjectResource = true;
this.hasFileCollectionType = true;
this.refersToMappingPackages = true;
}

async getValuesForSelector(request = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q}))
setState(prevState => ({...prevState, search: filters.q, page: 0}))
}

const handleFiltersChange = (filters) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q}))
setState(prevState => ({...prevState, search: filters.q, page: 0}))
}

const handleFiltersChange = (filters) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q }))
setState(prevState => ({...prevState, search: filters.q, page: 0 }))
}

const handleFiltersChange = (filters) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q}))
setState(prevState => ({...prevState, search: filters.q, page: 0}))
}

const handleFiltersChange = filters => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters}))
setState(prevState => ({...prevState, search: filters, page: 0 }))
}


Expand Down
2 changes: 1 addition & 1 deletion mapping_workbench/frontend/src/pages/app/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q }))
setState(prevState => ({...prevState, search: filters.q, page: 0 }))
}

const handleFiltersChange = (filters) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters }))
setState(prevState => ({...prevState, search: filters, page: 0 }))
}


Expand Down
2 changes: 1 addition & 1 deletion mapping_workbench/frontend/src/pages/app/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q }))
setState(prevState => ({...prevState, search: filters.q, page: 0 }))
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const useItemsSearch = (items) => {
})

const handleSearchItems = (filters) => {
setState(prevState => ({...prevState, search: filters.q}))
setState(prevState => ({...prevState, search: filters.q, page: 0}))
}

const handleFiltersChange = filters => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useEffect} from "react";
import {useEffect, useState} from "react";

import Card from "@mui/material/Card";
import Stack from "@mui/material/Stack";
Expand All @@ -18,10 +18,19 @@ import AutocompleteCM from "./ontology_fragment_editor";
import {sessionApi} from "src/api/session";
import {FormTextField} from "src/components/app/form/text-field";
import {toastError, toastLoad, toastSuccess} from "src/components/app-toast";
import Grid from "@mui/material/Unstable_Grid2";
import {MappingPackageCheckboxList} from "../../mapping-package/components/mapping-package-checkbox-list";
import Typography from "@mui/material/Typography";
import Divider from "@mui/material/Divider";


const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, afterItemSave, ontologyFragments}) => {

const [mappingPackages, setMappingPackages] = useState([]);

useEffect(() => {
setMappingPackages(item?.refers_to_mapping_package_ids || [])
}, [item])

const addItem = (requestValues, resetForm) => {
const toastId = toastLoad('Adding item...')
Expand Down Expand Up @@ -58,7 +67,7 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
'target_class_path': item?.target_class_path || '',
'target_property_path': item?.target_property_path || '',
'autocomplete_cm': [],
'autocomplete_cm_checked': true,
'autocomplete_cm_checked': !item,
},
validationSchema: Yup.object({
source_structural_element: Yup
Expand All @@ -75,6 +84,7 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
const {autocomplete_cm, autocomplete_cm_checked, ...values} = initialValues
values['project'] = sessionApi.getSessionProject();
values['source_structural_element'] = values['source_structural_element'] || null;
values['refers_to_mapping_package_ids'] = mappingPackages || null;

if (item) {
updateItem(values, resetForm)
Expand Down Expand Up @@ -120,7 +130,6 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
return;
}


return (
<Drawer
anchor='right'
Expand Down Expand Up @@ -154,7 +163,7 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
control={
<Checkbox
checked={formik.values.autocomplete_cm_checked}
onChange={() => formik.setFieldValue('autocomplete_cm_checked', event.target.checked)}
onChange={(event) => formik.setFieldValue('autocomplete_cm_checked', event.target.checked)}
/>
}
label="Use Ontology Fragment Editor"
Expand All @@ -164,7 +173,6 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
disabled={!formik.values.autocomplete_cm_checked}
data={ontologyFragments}
onSelect={handleAutocompleteChange}
required={formik.values.autocomplete_cm_checked}
name='autocomplete_cm'/>
</Stack>
<FormTextField formik={formik}
Expand Down Expand Up @@ -192,7 +200,23 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft
name="max_sdk_version"
label="Max XSD Version"/>
</Stack>
<Divider sx={{my: 3}}/>
<Typography variant="subtitle2">
Mapping Packages
</Typography>
<Grid container
spacing={3}>
<Grid xs={12}
md={12}>
<MappingPackageCheckboxList
mappingPackages={mappingPackages}
withDefaultPackage={!item}
/>
</Grid>
</Grid>
<Divider/>
</CardContent>

<Button type='submit'
sx={{width: '100%'}}
disabled={false}>Save</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ export const EditForm = (props) => {
spacing={3}>
<Grid xs={12}
md={12}>
<MappingPackageCheckboxList mappingPackages={formik.values.refers_to_mapping_package_ids}/>
<MappingPackageCheckboxList
mappingPackages={formik.values.refers_to_mapping_package_ids}
withDefaultPackage={itemctx.isNew}
/>
</Grid>
</Grid>
</CardContent>
Expand Down
Loading
Loading