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

chore: load petstore via profile #4586

Merged
merged 26 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
149d78c
chore: create schema with petstore via profile loader
connoratrug Dec 30, 2024
4294365
link settings
connoratrug Dec 30, 2024
9927ed9
remove petStoreLoader
connoratrug Jan 8, 2025
05bb614
use other enum
connoratrug Jan 8, 2025
9ce7e1d
Merge branch 'master' of github.com:molgenis/molgenis-emx2 into chore…
connoratrug Jan 9, 2025
3093ae2
update data and test to use profile
connoratrug Jan 9, 2025
c7e6480
add missing setup from petstore loader
connoratrug Jan 9, 2025
b76d7c9
always set pw
connoratrug Jan 9, 2025
c6c8213
fix test
connoratrug Jan 9, 2025
46d11bd
wip debug failing test
connoratrug Jan 10, 2025
6486fe6
Merge branch 'master' of github.com:molgenis/molgenis-emx2 into chore…
mswertz Jan 11, 2025
8912928
Merge branch 'master' into chore/load-pet-store-via-profile
mswertz Jan 11, 2025
e2106c6
Merge branch 'chore/load-pet-store-via-profile' of github.com:molgeni…
mswertz Jan 11, 2025
0197269
fixes to make csv and json based import/export equivalent
mswertz Jan 11, 2025
4d1499c
add missing fix
mswertz Jan 11, 2025
3ff79c9
remove unnecessary schemaid/name filter
mswertz Jan 11, 2025
bb7f896
remove unnecessary schemaid/name filter
mswertz Jan 11, 2025
758e839
remove table.schemaName and table.schemaId from interfaces
mswertz Jan 11, 2025
c4fd0a1
remove table.schemaId from types
mswertz Jan 11, 2025
4499c58
also here
mswertz Jan 11, 2025
9c3b2b1
heading should not be in data map
mswertz Jan 11, 2025
d14cc1f
heading shouldn't be in form errorMap
mswertz Jan 11, 2025
d598915
fix test spec
mswertz Jan 11, 2025
6d11dbd
remove unneeded table.schemaId = schemaId filters
mswertz Jan 12, 2025
5bfe460
remove unneeded table.schemaId statements
mswertz Jan 12, 2025
86432bf
Merge branch 'master' into chore/load-pet-store-via-profile
connoratrug Jan 13, 2025
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
1 change: 0 additions & 1 deletion apps/metadata-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export interface ITableMetaData {
description?: string;
tableType: string;
columns: IColumn[];
schemaId: string;
semantics?: string[];
settings?: ISetting[];
}
Expand Down
8 changes: 2 additions & 6 deletions apps/molgenis-components/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ const client: IClient = {
) => {
const schemaMetaData = await fetchSchemaMetaData(schemaId);
const tableMetaData = schemaMetaData.tables.find(
(table: ITableMetaData) =>
table.id === tableId && table.schemaId === schemaMetaData.id
(table: ITableMetaData) => table.id === tableId
);
const filter = tableMetaData?.columns
?.filter((column: IColumn) => column.key === 1)
Expand Down Expand Up @@ -167,12 +166,10 @@ const metadataQuery = `{
_schema {
id,
tables {
schemaId,
id,
label,
description,
tableType,
schemaId,
semantics,
columns {
id,
Expand Down Expand Up @@ -395,8 +392,7 @@ async function convertRowToPrimaryKey(
): Promise<Record<string, any>> {
const schema = await fetchSchemaMetaData(schemaId);
const tableMetadata = schema.tables.find(
(table: ITableMetaData) =>
table.id === tableId && table.schemaId === schema.id
(table: ITableMetaData) => table.id === tableId
);
if (!tableMetadata?.columns) {
throw new Error("Empty columns in metadata");
Expand Down
4 changes: 1 addition & 3 deletions apps/molgenis-components/src/client/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const getColumns = (
tableId: string,
tableStore: ITableMetaData[]
) => {
const result = tableStore.find(
(table) => table.id === tableId && table.schemaId === schemaId
);
const result = tableStore.find((table) => table.id === tableId);
return result?.columns || [];
};
2 changes: 1 addition & 1 deletion apps/molgenis-components/src/components/forms/RowEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default {
equals: await convertRowToPrimaryKey(
this.internalValues[changedColumn.id],
overlappingKey.refTableId,
overlappingKey.refSchemaId
overlappingKey.refSchemaId || this.schemaMetaData.schemaId
),
},
};
Expand Down
1 change: 0 additions & 1 deletion apps/nuxt3-ssr/gql/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default gql`
label
tableType
description
schemaId
semantics
columns {
id
Expand Down
1 change: 0 additions & 1 deletion apps/schema/src/components/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export default {
}
});
tables.forEach((table) => {
delete table.schemaId;
table.columns = table.columns
? table.columns.filter((column) => column.table === table.name)
: [];
Expand Down
12 changes: 2 additions & 10 deletions apps/schema/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const schemaQuery = gql`
name
tables {
name
schemaName
tableType
inheritName
labels {
Expand Down Expand Up @@ -63,10 +62,7 @@ export function addOldNamesAndRemoveMeta(rawSchema: any) {
//normal tables
let tables = !schema.tables
? []
: schema.tables.filter(
(table) =>
table.tableType !== "ONTOLOGIES" && table.schemaName === schema.name
);
: schema.tables.filter((table) => table.tableType !== "ONTOLOGIES");
tables.forEach((t) => {
t.oldName = t.name;
if (t.columns) {
Expand All @@ -83,10 +79,7 @@ export function addOldNamesAndRemoveMeta(rawSchema: any) {
});
schema.ontologies = !schema.tables
? []
: schema.tables.filter(
(table) =>
table.tableType === "ONTOLOGIES" && table.schemaName === schema.name
);
: schema.tables.filter((table) => table.tableType === "ONTOLOGIES");
//set old name so we can delete them properly
schema.ontologies.forEach((o) => {
o.oldName = o.name;
Expand Down Expand Up @@ -205,7 +198,6 @@ export function addTableIdsLabelsDescription(originalTable: ITableMetaData) {
table.id = convertToPascalCase(table.name);
table.label = getLocalizedLabel(table);
table.description = getLocalizedDescription(table, "en");
table.schemaId = table.schemaName;
table.inheritId = convertToPascalCase(table.inheritName);
table.columns = table.columns.map((column) => {
column.id = convertToCamelCase(column.name);
Expand Down
2 changes: 1 addition & 1 deletion apps/tables/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
this.error = null;
request(
"graphql",
"{_schema{id,label,tables{id,label,tableType,schemaId,description,columns{id,label,columnType,key,refTableId,required,description}}}}"
"{_schema{id,label,tables{id,label,tableType,description,columns{id,label,columnType,key,refTableId,required,description}}}}"
)
.then((data) => {
this.schema = data._schema;
Expand Down
22 changes: 9 additions & 13 deletions apps/tables/src/components/ListTables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,16 @@ export default {
}
if (this.search && this.search.trim().length > 0) {
let terms = this.search.toLowerCase().split(" ");
return this.schema.tables
.filter((table) => table.schemaId === this.schema.id)
.filter((table) =>
terms.every(
(term) =>
table.label.toLowerCase().includes(term) ||
(table.description &&
table.description.toLowerCase().includes(term))
)
);
} else {
return this.schema.tables.filter(
(table) => table.schemaId === this.schema.id
return this.schema.tables.filter((table) =>
terms.every(
(term) =>
table.label.toLowerCase().includes(term) ||
(table.description &&
table.description.toLowerCase().includes(term))
)
);
} else {
return this.schema.tables;
}
},
tables() {
Expand Down
12 changes: 10 additions & 2 deletions apps/tailwind-components/components/form/Fields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ const chapters = computed(() => {
});

const dataMap = reactive(
Object.fromEntries(props.metadata.columns.map((column) => [column.id, ""]))
Object.fromEntries(
props.metadata.columns
.filter((column) => column.columnType !== "HEADING")
.map((column) => [column.id, ""])
)
);

const errorMap = reactive(
Object.fromEntries(props.metadata.columns.map((column) => [column.id, []]))
Object.fromEntries(
props.metadata.columns
.filter((column) => column.columnType !== "HEADING")
.map((column) => [column.id, []])
)
);

const numberOffFieldsWithErrors = computed(() =>
Expand Down
2 changes: 1 addition & 1 deletion apps/tailwind-components/composables/fetchTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const getColumnIds = async (
const metaData = await fetchMetadata(schemaId);

const columns = metaData.tables.find(
(table) => table.id === tableId && table.schemaId === schemaId
(table) => table.id === tableId
)?.columns || [];

let gqlFields = "";
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/pages/[schema]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const { data } = await useFetch<Resp<Schema>>(`/${schema}/graphql`, {
key: "databases",
method: "POST",
body: {
query: `{_schema{id,label,tables{id,label,tableType,schemaId,description}}}`,
query: `{_schema{id,label,tables{id,label,tableType,description}}}`,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public enum Profile {
BEACON_V2("_profiles/BeaconV2.yaml"),
GDI("_profiles/GDI.yaml"),
SHARED_STAGING("_profiles/SharedStaging.yaml"),
IMAGE_TEST("_profiles/ImageTest.yaml");
IMAGE_TEST("_profiles/ImageTest.yaml"),
PET_STORE("_profiles/PetStore.yaml");

public static boolean hasProfile(String nameOther) {
return Arrays.stream(values()).anyMatch(profile -> profile.name().equals(nameOther));
Expand All @@ -48,7 +49,6 @@ public Task getImportTask(Schema schema, boolean includeDemoData) {

public enum Regular {
DIRECTORY(DirectoryLoader::new),
PET_STORE(PetStoreLoader::new),
ERN_DASHBOARD(DashboardLoader::new),
PROJECTMANAGER(ProjectManagerLoader::new),
BIOBANK_DIRECTORY(BiobankDirectoryLoader::new),
Expand Down
Loading
Loading