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

Record Schema aligned with DB Schema #110

Merged
merged 2 commits into from
Oct 21, 2023
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
4 changes: 2 additions & 2 deletions src/api/docs/BIOMD_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Every Request is sent as a JSON-compliant object. The following is the standard
"city": "",
"address_1": "",
"address_2": "",
"area_code": ""
"areaCode": ""
}
}
}
Expand Down Expand Up @@ -100,7 +100,7 @@ Every Request is sent as a JSON-compliant object. The following is the standard
"city": "",
"address_1": "",
"address_2": "",
"area_code": ""
"areaCode": ""
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ export default {
API: "CREATE_RECORD",
collection: "Facility",
record: new FacilityRecord({
facility_name: facilityInfo.value.facilityName,
facilityName: facilityInfo.value.facilityName,
country: Global_Facility_Definition.value.facilityAddress.Country,
area: Global_Facility_Definition.value.facilityAddress.State,
city: Global_Facility_Definition.value.facilityAddress.District,
address_1: facilityInfo.value.streetAddress1,
address_2: facilityInfo.value.streetAddress2,
area_code: facilityInfo.value.zipCode,
departments: facilityInfo.value.departments,
areaCode: facilityInfo.value.zipCode,
}).serialize(),
Institute_Code: Institute_Code.value, //Dynamically changes when another institute logged in
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default {
.District,
address_1: manufacturerInfo.value.streetAddress1,
address_2: manufacturerInfo.value.streetAddress2,
area_code: manufacturerInfo.value.zipCode,
areaCode: manufacturerInfo.value.zipCode,
}).serialize(),
Institute_Code: Institute_Code.value, //Dynamically changes when another institute logged in
},
Expand Down
81 changes: 29 additions & 52 deletions src/client/web/src/store/modules/recordSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,22 @@ class AssetRecord extends Record {
return {
type: BSONType.object,
fields: {
//Schema Version: 0.2
assetCode: { type: BSONType.string },
commonName: { type: BSONType.string },
description: { type: BSONType.string },
serialNumber: { type: BSONType.string },
model_id: { type: BSONType.objectId },
manufacturer_id: { type: BSONType.objectId },
modelID: { type: BSONType.objectId },
manufacturerID: { type: BSONType.objectId },
manufactureDate: { type: BSONType.date },
facility_id: { type: BSONType.objectId },
area: { type: BSONType.string },
city: { type: BSONType.string },
department: { type: BSONType.objectId },
roomTag: { type: BSONType.string },
facilityID: { type: BSONType.objectId },
departmentID: { type: BSONType.objectId },
locationName: { type: BSONType.string },
supportTeam: { type: BSONType.string },
vendor_id: { type: BSONType.objectId },
vendorID: { type: BSONType.objectId },
status: { type: BSONType.string },
user_manual: { type: BSONType.bool },
technical_manual: { type: BSONType.bool },
purchaseOrderNumber: { type: BSONType.string },
project: { type: BSONType.string },
purchaseCost: { type: BSONType.double },
purchaseDate: { type: BSONType.date },
purchaseOrderID: { type: BSONType.objectId},
acceptanceDate: { type: BSONType.date },
warrantyDate: { type: BSONType.date },
generalComment: { type: BSONType.string },
comment: { type: BSONType.string },
},
};
}
Expand All @@ -187,17 +179,14 @@ class FacilityRecord extends Record {
return {
type: BSONType.object,
fields: {
//Schema Version: 0.1
facility_name: { type: BSONType.string },
address_1: { type: BSONType.string },
address_2: { type: BSONType.string },
city: { type: BSONType.string },
area: { type: BSONType.string },
area_code: { type: BSONType.string },
areaCode: { type: BSONType.string },
country: { type: BSONType.string },
departments: {
type: BSONType.array,
items: { type: BSONType.objectId },
},
},
};
}
Expand All @@ -211,13 +200,8 @@ class ManufacturerRecord extends Record {
return {
type: BSONType.object,
fields: {
manufacturer_name: { type: BSONType.string },
country: { type: BSONType.string },
area: { type: BSONType.string },
city: { type: BSONType.string },
address_1: { type: BSONType.string },
address_2: { type: BSONType.string },
area_code: { type: BSONType.string },
//Schema Version: 0.1
manufacturerName: { type: BSONType.string },
},
};
}
Expand All @@ -231,11 +215,12 @@ class ModelRecord extends Record {
return {
type: BSONType.object,
fields: {
manufacturer_id: { type: BSONType.objectId },
model_name: { type: BSONType.string },
model_number: { type: BSONType.string },
vendor_site_ID: { type: BSONType.string }, // TODO: Is this ObjectID?
manufacturer_name: { type: BSONType.string },
//Schema Version: v0.1
manufacturerID: { type: BSONType.objectId },
contactID: { type: BSONType.objectId },
modelName: { type: BSONType.string },
commonName: { type: BSONType.string },
UMDNSCode: { type: BSONType.string },
},
};
}
Expand All @@ -249,44 +234,36 @@ class VendorRecord extends Record {
return {
type: BSONType.object,
fields: {
vendor_name: { type: BSONType.string },
//Schema Version: v0.1
vendorName: { type: BSONType.string },
country: { type: BSONType.string },
area: { type: BSONType.string },
city: { type: BSONType.string },
address_1: { type: BSONType.string },
address_2: { type: BSONType.string },
areaCode: { type: BSONType.string },
contact_info: {
contactInfo: {
type: BSONType.array,
items: {
type: BSONType.object,
fields: {
contact_number: { type: BSONType.string },
representative_name: { type: BSONType.string },
number: { type: BSONType.string },
name: { type: BSONType.string },
email: { type: BSONType.string },
contact_type: { type: BSONType.string },
type: { type: BSONType.string },
},
},
},
manufacturer_list: {
manufacturerList: {
type: BSONType.array,
items: {
type: BSONType.object,
fields: {
manufacturer: { type: BSONType.objectId },
model_list: {
type: BSONType.array,
items: {
type: BSONType.object,
fields: {
model_id: { type: BSONType.objectId },
},
},
},
},
manufacturer: {type : BSONType.objectId },
}
},
},
},
}
};
}
}
Expand Down
80 changes: 21 additions & 59 deletions src/client/web/src/store/modules/recordSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,6 @@ describe("Testing Base Record Functionality", () => {
],
])("Parsing %s", (_, { input, schema, expected }) => {
_RECORD_BASE._validateSchema(schema);
console.log(
input,
schema,
expected,
_RECORD_BASE._fieldToBsonType("", input, schema)
);
expect(_RECORD_BASE._fieldToBsonType("", input, schema)).toStrictEqual(
expected == undefined ? input : expected
);
Expand All @@ -221,29 +215,20 @@ describe("Testing Records", () => {
"Asset",
{
assetCode: "assetCode",
commonName: "commonName",
description: "description",
serialNumber: "serialNumber",
model_id: new ObjectId("650f14d8dc843d63d8639973"),
manufacturer_id: new ObjectId("f088034d002843d6ff639424"),
modelID: new ObjectId("650f14d8dc843d63d8639973"),
manufacturerID: new ObjectId("f088034d002843d6ff639424"),
manufactureDate: new Date(2022, 11, 24, 10, 33, 30, 0),
facility_id: new ObjectId("1d223300b663778899abcedf"),
area: "area",
city: "city",
department: new ObjectId("88de630123371298da201bbc"),
roomTag: "roomTag",
facilityID: new ObjectId("1d223300b663778899abcedf"),
departmentID: new ObjectId("88de630123371298da201bbc"),
locationName: "roomTag",
supportTeam: "supportTeam",
vendor_id: new ObjectId("0238488de63012338da271bd"),
vendorID: new ObjectId("0238488de63012338da271bd"),
status: "status",
user_manual: true,
technical_manual: true,
purchaseOrderNumber: "purchaseOrderNumber",
project: "project",
purchaseCost: 220.31,
purchaseDate: new Date(2020, 7, 14, 10, 33, 30, 0),
purchaseOrderID: new ObjectId("ff38488de63012338da271bd"),
acceptanceDate: new Date(2022, 7, 14, 10, 33, 30, 0),
warrantyDate: new Date(2033, 1, 1, 0, 0, 0, 0),
generalComment: "generalComment",
comment: "generalComment",
},
],
[
Expand All @@ -255,69 +240,46 @@ describe("Testing Records", () => {
city: "city",
address_1: "Address 1",
address_2: "Address 2",
area_code: "34AND82",
departments: [
new ObjectId("ff3e630123371298da201bbc"),
new ObjectId("650f1a8b9aea2dfe2d0d114e"),
new ObjectId("750f1a8b9aea2dfe2d0d1122"),
new ObjectId("850f1a8b9aea2dfe2d0d114d"),
],
areaCode: "34AND82",
},
],
[
"Manufacturer",
{
manufacturer_name: "ManufacturerName",
country: "Canada",
area: "area",
city: "city",
address_1: "Address 1",
address_2: "Address 2",
area_code: "34AND82",
manufacturerName: "ManufacturerName",
},
],
[
"Model",
{
manufacturer_id: new ObjectId("ff0f1a8b9aea2dfe2d0d1142"),
model_name: "ModelName",
model_number: "ModelNumber",
vendor_site_ID: "SiteId5",
manufacturer_name: "ManufacturerName",
manufacturerID: new ObjectId("ff0f1a8b9aea2dfe2d0d1142"),
modelName: "ModelName",
commonName: "common Name",
contactID: new ObjectId("720f1a8b9aea2dfe2d0d11dd"),
UMDNSCode: "UMDNS Code",
},
],
[
"Vendor",
{
vendor_name: "VendorName",
vendorName: "VendorName",
country: "Canada",
area: "area",
city: "city",
address_1: "Address 1",
address_2: "Address 2",
areaCode: "Z4AND87",
contact_info: [
contactInfo: [
{
contact_number: "233-231-1212",
representative_name: "RepName",
number: "233-231-1212",
name: "RepName",
email: "rep.name@example.com",
contact_type: "RepType",
type: "RepType",
},
],
manufacturer_list: [
manufacturerList: [
{
manufacturer: new ObjectId("bf0f1a8b9aea2dfe2d0d1142"),
model_list: [
{
model_id: new ObjectId("ff0f188b9aea2dfe2d0d8b23"),
},
{
model_id: new ObjectId("3f0f188b9aea2dfe2d0d8bff"),
},
{
model_id: new ObjectId("92f0f188b9aea2dfe2dd8b29"),
},
],
},
],
},
Expand Down