@@ -27,7 +27,6 @@ const dbEnum = require('../../src-shared/db-enum.js')
2727const queryZcl = require ( './query-zcl.js' )
2828const queryUpgrade = require ( '../sdk/matter.js' )
2929const queryDeviceType = require ( './query-device-type' )
30- const querySession = require ( './query-session' )
3130const queryCommand = require ( './query-command.js' )
3231const restApi = require ( '../../src-shared/rest-api.js' )
3332const _ = require ( 'lodash' )
@@ -577,18 +576,16 @@ async function selectCountOfEndpointsWithGivenEndpointIdentifier(
577576/**
578577 * Promises to add an endpoint type.
579578 *
579+ * @export
580580 * @param {* } db
581- * @param {* } sessionPartitionInfo
581+ * @param {* } sessionId
582582 * @param {* } name
583583 * @param {* } deviceTypeRef
584- * @param {* } deviceTypeIdentifier
585- * @param {* } deviceTypeVersion
586- * @param {* } doTransaction
587584 * @returns Promise to update endpoints.
588585 */
589586async function insertEndpointType (
590587 db ,
591- sessionPartitionInfo ,
588+ sessionId ,
592589 name ,
593590 deviceTypeRef ,
594591 deviceTypeIdentifier ,
@@ -607,8 +604,8 @@ async function insertEndpointType(
607604 // Insert endpoint type
608605 let newEndpointTypeId = await dbApi . dbInsert (
609606 db ,
610- 'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_PARTITION_REF , NAME ) VALUES ( ?, ?)' ,
611- [ sessionPartitionInfo . sessionPartitionId , name ]
607+ 'INSERT OR REPLACE INTO ENDPOINT_TYPE ( SESSION_REF , NAME ) VALUES ( ?, ?)' ,
608+ [ sessionId , name ]
612609 )
613610
614611 // Creating endpoint type and device type ref combinations along with order of insertion
@@ -638,7 +635,7 @@ async function insertEndpointType(
638635 db ,
639636 'ERROR' ,
640637 isErrorStringPresent ? err . split ( 'Error:' ) [ 1 ] : err ,
641- sessionPartitionInfo . sessionRef ,
638+ sessionId ,
642639 1 ,
643640 1
644641 )
@@ -659,7 +656,7 @@ async function insertEndpointType(
659656 for ( const dtRef of deviceTypeRefs ) {
660657 await setEndpointDefaults (
661658 db ,
662- sessionPartitionInfo . sessionRef ,
659+ sessionId ,
663660 newEndpointTypeId ,
664661 dtRef ,
665662 doTransaction
@@ -682,8 +679,7 @@ async function duplicateEndpointType(db, endpointTypeId) {
682679 db ,
683680 `
684681 SELECT
685- SESSION_PARTITION.SESSION_REF,
686- SESSION_PARTITION.SESSION_PARTITION_ID,
682+ ENDPOINT_TYPE.SESSION_REF,
687683 ENDPOINT_TYPE.NAME,
688684 ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_REF,
689685 ENDPOINT_TYPE_DEVICE.DEVICE_IDENTIFIER,
@@ -694,10 +690,6 @@ async function duplicateEndpointType(db, endpointTypeId) {
694690 ENDPOINT_TYPE_DEVICE
695691 ON
696692 ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
697- INNER JOIN
698- SESSION_PARTITION
699- ON
700- ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
701693 WHERE
702694 ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF = ?` ,
703695 [ endpointTypeId ]
@@ -707,12 +699,9 @@ async function duplicateEndpointType(db, endpointTypeId) {
707699 // Enter into the endpoint_type table
708700 newEndpointTypeId = await dbApi . dbInsert (
709701 db ,
710- `INSERT INTO ENDPOINT_TYPE (SESSION_PARTITION_REF , NAME)
702+ `INSERT INTO ENDPOINT_TYPE (SESSION_REF , NAME)
711703 VALUES (?, ?)` ,
712- [
713- endpointTypeDeviceInfo [ 0 ] . SESSION_PARTITION_ID ,
714- endpointTypeDeviceInfo [ 0 ] . NAME ,
715- ]
704+ [ endpointTypeDeviceInfo [ 0 ] . SESSION_REF , endpointTypeDeviceInfo [ 0 ] . NAME ]
716705 )
717706
718707 // Enter into the endpoint_type_device table to establish the endpoint_type
@@ -769,12 +758,8 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
769758 INNER JOIN
770759 ENDPOINT_TYPE_DEVICE
771760 ON ENDPOINT_TYPE.ENDPOINT_TYPE_ID = ENDPOINT_TYPE_DEVICE.ENDPOINT_TYPE_REF
772- INNER JOIN
773- SESSION_PARTITION
774- ON
775- ENDPOINT_TYPE.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
776761 WHERE
777- ENDPOINT_TYPE. ENDPOINT_TYPE_ID = ? AND SESSION_PARTITION. SESSION_REF = ?
762+ ENDPOINT_TYPE_ID = ? AND SESSION_REF = ?
778763 ORDER BY
779764 ENDPOINT_TYPE_DEVICE.DEVICE_TYPE_ORDER` ,
780765 [ endpointTypeId , sessionId ]
@@ -888,10 +873,7 @@ async function updateEndpointType(db, sessionId, endpointTypeId, changesArray) {
888873/**
889874 * Promise to set the default attributes and clusters for a endpoint type.
890875 * @param {* } db
891- * @param {* } sessionId
892876 * @param {* } endpointTypeId
893- * @param {* } deviceTypeRef
894- * @param {* } doTransaction
895877 */
896878async function setEndpointDefaults (
897879 db ,
@@ -911,20 +893,7 @@ async function setEndpointDefaults(
911893 if ( pkgs == null || pkgs . length < 1 )
912894 throw new Error ( 'Could not locate package id for a given session.' )
913895
914- let deviceTypeInfo =
915- await querySession . selectDeviceTypePackageInfoFromDeviceTypeId (
916- db ,
917- deviceTypeRef
918- )
919- let endpointTypeCategory =
920- deviceTypeInfo . length > 0 ? deviceTypeInfo [ 0 ] . category : null
921896 let packageId = pkgs [ 0 ] . id
922- for ( let i = 0 ; i < pkgs . length ; i ++ ) {
923- if ( pkgs [ i ] . category == endpointTypeCategory ) {
924- packageId = pkgs [ i ] . id
925- break
926- }
927- }
928897 let clusters = await queryDeviceType . selectDeviceTypeClustersByDeviceTypeRef (
929898 db ,
930899 deviceTypeRef
@@ -1247,16 +1216,7 @@ async function resolveNonOptionalAndReportableAttributes(
12471216async function selectEndpointTypeCount ( db , sessionId ) {
12481217 let x = await dbApi . dbGet (
12491218 db ,
1250- `SELECT
1251- COUNT(ENDPOINT_TYPE_ID) AS CNT
1252- FROM
1253- ENDPOINT_TYPE
1254- INNER JOIN
1255- SESSION_PARTITION
1256- ON
1257- SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
1258- WHERE
1259- SESSION_PARTITION.SESSION_REF = ?` ,
1219+ 'SELECT COUNT(ENDPOINT_TYPE_ID) AS CNT FROM ENDPOINT_TYPE WHERE SESSION_REF = ?' ,
12601220 [ sessionId ]
12611221 )
12621222 return x [ 'CNT' ]
@@ -1283,11 +1243,7 @@ SELECT
12831243 COUNT(ENDPOINT_TYPE_ID)
12841244FROM
12851245 ENDPOINT_TYPE
1286- INNER JOIN
1287- SESSION_PARTITION
1288- ON
1289- SESSION_PARTITION.SESSION_PARTITION_ID = ENDPOINT_TYPE.SESSION_PARTITION_REF
1290- WHERE SESSION_PARTITION.SESSION_REF = ?
1246+ WHERE SESSION_REF = ?
12911247 AND ENDPOINT_TYPE_ID IN
12921248 (SELECT ENDPOINT_TYPE_REF
12931249 FROM ENDPOINT_TYPE_CLUSTER
@@ -1448,12 +1404,8 @@ JOIN
14481404 ATTRIBUTE AS A ON ETA.ATTRIBUTE_REF = A.ATTRIBUTE_ID
14491405JOIN
14501406 ENDPOINT_TYPE AS ET ON ETA.ENDPOINT_TYPE_REF = ET.ENDPOINT_TYPE_ID
1451- INNER JOIN
1452- SESSION_PARTITION
1453- ON
1454- ET.SESSION_PARTITION_REF = SESSION_PARTITION.SESSION_PARTITION_ID
14551407WHERE
1456- SESSION_PARTITION .SESSION_REF = ? AND ETA.INCLUDED = 1
1408+ ET .SESSION_REF = ? AND ETA.INCLUDED = 1
14571409ORDER BY
14581410 CLUSTER_CODE, ATTRIBUTE_CODE
14591411 ` ,
0 commit comments