From 8533542035ba8ed105216e4c896b793d046a15f2 Mon Sep 17 00:00:00 2001 From: Thameera Date: Tue, 9 May 2023 22:46:15 +0530 Subject: [PATCH] Update operation template core changes --- .../pom.xml | 14 +++-- .../cache/OperationTemplateCacheLoader.java | 15 +++--- .../template/dao/OperationTemplateDAO.java | 17 +++---- .../dao/OperationTemplateDAOFactory.java | 13 +++-- .../dao/impl/OperationTemplateDAOImpl.java | 25 +++++---- .../impl/OperationTemplateMySQLDAOImpl.java | 13 +++-- .../config/DeviceConfigurationManager.java | 13 +++-- .../impl/config/DeviceManagementConfig.java | 13 +++-- .../config/DeviceManagementRepository.java | 13 +++-- .../config/datasource/DataSourceConfig.java | 13 +++-- .../datasource/JNDILookupDefinition.java | 13 +++-- .../util/OperationTemplateManagementUtil.java | 17 +++---- .../template/dto/OperationTemplate.java | 19 ++++--- .../dto/OperationTemplateCacheKey.java | 19 ++++--- .../BadOperationRequestException.java | 13 +++-- .../exception/DBConnectionException.java | 13 +++-- ...erationTemplateManagementDAOException.java | 13 +++-- .../OperationTemplateMgtPluginException.java | 13 +++-- .../impl/OperationTemplateServiceImpl.java | 22 ++++---- .../OperationTemplateMgtDataHolder.java | 13 +++-- .../OperationTemplateMgtServiceComponent.java | 13 +++-- .../spi/OperationTemplateService.java | 17 +++---- .../operation/template/util/AssertUtils.java | 13 +++-- .../template/util/ConnectionManagerUtils.java | 13 +++-- .../mgt/operation/template/util/DAOUtil.java | 15 +++--- .../operation/template/DAONegativeTest.java | 15 +++--- .../mgt/operation/template/DAOTest.java | 29 +++++------ .../operation/template/DataSourceConfig.java | 13 +++-- .../template/ServiceNegativeTest.java | 15 +++--- .../mgt/operation/template/ServiceTest.java | 16 +++--- .../mgt/operation/template/TestUtils.java | 51 +++++++++++-------- .../mock/BaseOperationTemplatePluginTest.java | 13 +++-- .../template/mock/MockConnection.java | 13 +++-- .../template/mock/MockDataSource.java | 13 +++-- .../template/mock/MockDatabaseMetaData.java | 13 +++-- .../template/mock/MockResultSet.java | 13 +++-- .../template/mock/MockStatement.java | 13 +++-- components/operation-template-mgt/pom.xml | 13 +++-- .../main/resources/dbscripts/cdm/mssql.sql | 16 +++++- .../main/resources/dbscripts/cdm/mysql.sql | 2 +- .../main/resources/dbscripts/cdm/oracle.sql | 25 ++++++++- .../resources/dbscripts/cdm/postgresql.sql | 20 +++++++- 42 files changed, 347 insertions(+), 321 deletions(-) diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/pom.xml index 729ee868bd..c35674da0a 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/pom.xml @@ -1,20 +1,18 @@ - diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/cache/OperationTemplateCacheLoader.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/cache/OperationTemplateCacheLoader.java index 792d540004..8d548bbde5 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/cache/OperationTemplateCacheLoader.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/cache/OperationTemplateCacheLoader.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -55,7 +54,7 @@ public class OperationTemplateCacheLoader extends CacheLoader 0, "Invalid meter device subtype id: " + subTypeId); + AssertUtils.hasText(subTypeId, "Invalid meter device subtype id: " + subTypeId); + AssertUtils.isTrue(Integer.valueOf(subTypeId)>0, "Invalid meter device subtype id: " + subTypeId); AssertUtils.hasText(operationCode, "Validation failed due to invalid operation code: " + operationCode); AssertUtils.hasText(deviceType, "Invalid device type."); AssertUtils.isTrue(deviceType.equals("METER"), "Invalid device type. "); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtDataHolder.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtDataHolder.java index 2236d5cd90..f28c5d02f4 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtDataHolder.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtDataHolder.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtServiceComponent.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtServiceComponent.java index 5233b37387..dd13540c9b 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtServiceComponent.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/internal/OperationTemplateMgtServiceComponent.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/spi/OperationTemplateService.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/spi/OperationTemplateService.java index ce6c34bd65..01da583b62 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/spi/OperationTemplateService.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/spi/OperationTemplateService.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -31,8 +30,8 @@ public interface OperationTemplateService { OperationTemplate updateOperationTemplate(OperationTemplate operationTemplate) throws OperationTemplateMgtPluginException; - OperationTemplate getOperationTemplate(int subTypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException; + OperationTemplate getOperationTemplate(String subTypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException; - void deleteOperationTemplate(int subTypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException; + void deleteOperationTemplate(String subTypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException; } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/AssertUtils.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/AssertUtils.java index 6f9b1613e0..59827e1061 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/AssertUtils.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/AssertUtils.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/ConnectionManagerUtils.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/ConnectionManagerUtils.java index f20f34d50b..ce83acc449 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/ConnectionManagerUtils.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/ConnectionManagerUtils.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/DAOUtil.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/DAOUtil.java index 842a425370..78d23cda74 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/DAOUtil.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/main/java/io/entgra/device/mgt/operation/template/util/DAOUtil.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -45,7 +44,7 @@ public class DAOUtil { throws SQLException, JsonSyntaxException { OperationTemplate operationTemplate = new OperationTemplate(); Gson g = new Gson(); - operationTemplate.setSubTypeId(rs.getInt("SUB_TYPE_ID")); + operationTemplate.setSubTypeId(rs.getString("SUB_TYPE_ID")); operationTemplate.setCode(rs.getString("OPERATION_CODE")); operationTemplate.setDeviceType(rs.getString("DEVICE_TYPE")); operationTemplate.setOperationTemplateId(rs.getInt("SUB_OPERATION_TEMPLATE_ID")); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAONegativeTest.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAONegativeTest.java index 84fa0a811d..fee6ecece7 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAONegativeTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAONegativeTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -50,7 +49,7 @@ public class DAONegativeTest extends BaseOperationTemplatePluginTest { try { ConnectionManagerUtils.beginDBTransaction(); OperationTemplate operationTemplate = new OperationTemplate(); - operationTemplate.setSubTypeId(0); + operationTemplate.setSubTypeId("0"); operationTemplate.setCode(null); operationTemplate.setOperationDefinition(TestUtils.getOperationDefinition(TestUtils.subtypeId, TestUtils.operationCode)); operationTemplateDAO.addOperationTemplate(operationTemplate); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAOTest.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAOTest.java index 7252d9d5d3..7d398a7412 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAOTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DAOTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -50,10 +49,10 @@ public class DAOTest extends BaseOperationTemplatePluginTest { ConnectionManagerUtils.openDBConnection(); OperationTemplate operationTemplateActual = operationTemplateDAO.getOperationTemplate( - 4, TestUtils.deviceType, TestUtils.operationCode); + "4", TestUtils.deviceType, TestUtils.operationCode); ConnectionManagerUtils.closeDBConnection(); Assert.assertNotNull(operationTemplateActual, "Cannot be null"); - Assert.assertEquals(operationTemplateActual.getSubTypeId(), 4); + Assert.assertEquals(operationTemplateActual.getSubTypeId(), "4"); Assert.assertEquals(operationTemplateActual.getCode(), TestUtils.operationCode); Assert.assertEquals(operationTemplateActual.getDeviceType(), TestUtils.deviceType); } @@ -63,21 +62,21 @@ public class DAOTest extends BaseOperationTemplatePluginTest { throws DBConnectionException, OperationTemplateManagementDAOException { OperationTemplate operationTemplate = new OperationTemplate(); - operationTemplate.setSubTypeId(4); + operationTemplate.setSubTypeId("4"); operationTemplate.setCode(TestUtils.operationCode); operationTemplate.setDeviceType(TestUtils.deviceType); operationTemplate.setOperationDefinition( - TestUtils.getOperationDefinition(4, TestUtils.operationCode)); + TestUtils.getOperationDefinition("4", TestUtils.operationCode)); ConnectionManagerUtils.beginDBTransaction(); operationTemplateDAO.addOperationTemplate(operationTemplate); ConnectionManagerUtils.commitDBTransaction(); OperationTemplate operationTemplateActual = operationTemplateDAO.getOperationTemplate( - 4, TestUtils.deviceType, TestUtils.operationCode); + "4", TestUtils.deviceType, TestUtils.operationCode); ConnectionManagerUtils.closeDBConnection(); Assert.assertNotNull(operationTemplateActual, "Cannot be null"); - Assert.assertEquals(operationTemplateActual.getSubTypeId(), 4); + Assert.assertEquals(operationTemplateActual.getSubTypeId(), "4"); Assert.assertEquals(operationTemplateActual.getCode(), TestUtils.operationCode); Assert.assertEquals(operationTemplateActual.getDeviceType(), TestUtils.deviceType); } @@ -88,14 +87,14 @@ public class DAOTest extends BaseOperationTemplatePluginTest { ConnectionManagerUtils.beginDBTransaction(); OperationTemplate operationTemplate = operationTemplateDAO.getOperationTemplate( - 4, TestUtils.deviceType, TestUtils.operationCode); + "4", TestUtils.deviceType, TestUtils.operationCode); OperationTemplate operationTemplateActual = operationTemplateDAO.updateOperationTemplate( operationTemplate); ConnectionManagerUtils.commitDBTransaction(); ConnectionManagerUtils.closeDBConnection(); Assert.assertNotNull(operationTemplateActual, "Cannot be null"); - Assert.assertEquals(operationTemplateActual.getSubTypeId(), 4); + Assert.assertEquals(operationTemplateActual.getSubTypeId(), "4"); Assert.assertEquals(operationTemplateActual.getCode(), TestUtils.operationCode); Assert.assertEquals(operationTemplateActual.getDeviceType(), TestUtils.deviceType); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DataSourceConfig.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DataSourceConfig.java index 2c8eb1e4a4..d574a54536 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DataSourceConfig.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/DataSourceConfig.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceNegativeTest.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceNegativeTest.java index e5a39b3181..be5a2dee66 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceNegativeTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceNegativeTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -56,7 +55,7 @@ public class ServiceNegativeTest extends BaseOperationTemplatePluginTest { OperationTemplate operationTemplate = new OperationTemplate(); operationTemplate.setDeviceType(TestUtils.deviceType); operationTemplate.setCode(TestUtils.operationCode); - operationTemplate.setSubTypeId(0); + operationTemplate.setSubTypeId("0"); operationTemplate.setOperationDefinition(TestUtils.getOperationDefinition(TestUtils.subtypeId, TestUtils.operationCode)); operationTemplateService.addOperationTemplate(operationTemplate); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceTest.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceTest.java index ccfb341abb..aec19e0966 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/ServiceTest.java @@ -1,25 +1,23 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package io.entgra.device.mgt.operation.template; -import com.google.common.cache.CacheLoader; import io.entgra.device.mgt.operation.template.dto.OperationTemplate; import io.entgra.device.mgt.operation.template.exception.OperationTemplateMgtPluginException; import io.entgra.device.mgt.operation.template.impl.OperationTemplateServiceImpl; @@ -89,7 +87,7 @@ public class ServiceTest extends BaseOperationTemplatePluginTest { Assert.assertNull(getOperationTemplateBySubtypeIdAndDeviceTypeAndOperationCode(TestUtils.subtypeId, TestUtils.deviceType, TestUtils.operationCode)); } - public OperationTemplate getOperationTemplateBySubtypeIdAndDeviceTypeAndOperationCode(int subtypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException { + public OperationTemplate getOperationTemplateBySubtypeIdAndDeviceTypeAndOperationCode(String subtypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException { return operationTemplateService.getOperationTemplate(subtypeId, deviceType, operationCode); } } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/TestUtils.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/TestUtils.java index 3a2af14e24..fef316de62 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/TestUtils.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/TestUtils.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -30,23 +29,33 @@ import java.sql.Statement; public class TestUtils { private static final Log log = LogFactory.getLog(TestUtils.class); - public static Integer subtypeId = 3; + public static String subtypeId = "3"; public static String deviceType = "METER"; public static String operationCode = "BILLING_REGISTERS_RETRIEVE"; - public static String getOperationDefinition(int subtypeId, String operationCode) { - String operationDefinition = "{\"" + subtypeId + "\":2,\"deviceType\":\"METER\",\"maxAttempts\":1," - + "\"registerTransaction\":{},\"registers\":[\"0.0.0_0\",\"0.9.0_0\",\"1.8.0_0\"," - + "\"1.8.1_0\",\"1.8.2_0\",\"1.8.3_0\",\"2.8.0_0\",\"2.8.1_0\",\"2.8.2_0\",\"2.8.3_0\"," - + "\"1.8.0*01_0\",\"1.8.1*01_0\",\"1.8.2*01_0\",\"1.8.3*01_0\",\"2.8.0*01_0\"," - + "\"2.8.1*01_0\",\"2.8.2*01_0\",\"2.8.3*01_0\",\"9.6.0*01_0\",\"9.6.0_0\"," - + "\"10.6.0*01_0\",\"10.6.0_0\",\"0.4.2_0\",\"0.4.3_0\",\"0.4.5_0\",\"0.4.6_0\"," - + "\"14.7.0_0\",\"31.7.0_0\",\"32.7.0_0\",\"51.7.0_0\",\"52.7.0_0\",\"71.7.0_0\"," - + "\"72.7.0_0\"],\"attemptCount\":1,\"transportMode\":\"NET_ONLY\"," - + "\"hasPermanentError\":false,\"tryToReachViaSMS\":false,\"waitingTime\":0," - + "\"code\":\"" + operationCode + "\",\"properties\":{\"RequireDateAdjust\":\"30000\"," - + "\"RequireAuthentication\":\"32\",\"RequireSerialValidation\":\"1.0.0.0.0.255\"}," - + "\"type\":\"PROFILE\",\"id\":0,\"control\":\"NO_REPEAT\",\"isEnabled\":true}"; + public static String getOperationDefinition(String subtypeId, String operationCode) { + String operationDefinition = "{ \"subTypeId\": "+subtypeId+", \"deviceType\": \"METER\", " + + " \"maxAttempts\": 1, \"registerTransaction\": { " + + " \"globalRegName\": \"CSRQ_RL\", \"register\": \"0.0.96.3.10.255\", " + + " \"attributeIndex\": 2, \"classId\": 70, " + + " \"status\": \"PENDING\", \"receivedTimeStamp\": 0, " + + " \"isWriteOut\": false, \"isProfileRegister\": false, " + + " \"remoteMethod\": { \"index\": 2, \"data\": 0.0, " + + " \"type\": \"INT8\" \t\t},\t\t\"registers\": [\"0.0.0_0\"," + + " \"0.9.0_0\", \"1.8.0_0\", \"1.8.1_0\", \"1.8.2_0\", \"1.8.3_0\"," + + " \"2.8.0_0\", \"2.8.1_0\", \"2.8.2_0\", \"2.8.3_0\", \"1.8.0*01_0\", \"1.8.1*01_0\"," + + " \"1.8.2*01_0\", \"1.8.3*01_0\", \"2.8.0*01_0\", \"2.8.1*01_0\", " + + "\"2.8.2*01_0\", \"2.8.3*01_0\", \"9.6.0*01_0\", \"9.6.0_0\", " + + "\"10.6.0*01_0\", \"10.6.0_0\", \"0.4.2_0\", \"0.4.3_0\", \"0.4.5_0\"," + + " \"0.4.6_0\", \"14.7.0_0\", \"31.7.0_0\", \"32.7.0_0\", " + + " \"51.7.0_0\", \"52.7.0_0\", \"71.7.0_0\", \"72.7.0_0\"], " + + " \"attemptCount\": 1, \"transportMode\": \"NET_ONLY\", " + + " \"hasPermanentError\": false, \"tryToReachViaSMS\": false, " + + " \"waitingTime\": 0, \"code\": \"BILLING_REGISTERS_RETRIEVE\", " + + " \"properties\": { \"RequireDateAdjust\": \"30000\", " + + " \"RequireAuthentication\": \"32\", \"RequireSerialValidation\": \"1.0.0.0.0.255\" }," + + " \"type\": \"PROFILE\", \"id\": 0, \"control\": \"NO_REPEAT\", " + + "\"isEnabled\": true}"; return operationDefinition; } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/BaseOperationTemplatePluginTest.java index b7c1851933..529fe20519 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockConnection.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockConnection.java index 80068d7a9b..9f605521aa 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockConnection.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockConnection.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDataSource.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDataSource.java index a8ac6b305f..df69679b90 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDataSource.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDataSource.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDatabaseMetaData.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDatabaseMetaData.java index 2c9938229c..7dbb7fb389 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDatabaseMetaData.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockDatabaseMetaData.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockResultSet.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockResultSet.java index f4840f9a62..03720e9b59 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockResultSet.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockResultSet.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockStatement.java b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockStatement.java index 8d63d98c89..bcf450059a 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockStatement.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.operation.template/src/test/java/io/entgra/device/mgt/operation/template/mock/MockStatement.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * https://entgra.io/licenses/entgra-commercial/1.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index cb58177047..a944a3e888 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -1,19 +1,18 @@ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 12f4fb4d22..5d2345e77f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -797,4 +797,18 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -- SUB_OPERATION_TEMPLATE TABLE-- ---TODO: Need to add SUB_OPERATION_TEMPLATE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SUB_OPERATION_TEMPLATE]') AND TYPE IN (N'U')) +CREATE TABLE SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INTEGER IDENTITY(1,1), + OPERATION_DEFINITION VARCHAR(MAX) NOT NULL, + OPERATION_CODE varchar(100) NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP BIGINT NULL DEFAULT NULL, + UPDATE_TIMESTAMP BIGINT NULL DEFAULT NULL, + PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), + UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) +); + +-- END SUB_OPERATION_TEMPLATE TABLE-- \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 82b38aacde..0c5a8fb090 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -879,7 +879,7 @@ CREATE TABLE SUB_OPERATION_TEMPLATE ( SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION json NOT NULL, OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 023fa7e942..1a0ddb3064 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1144,4 +1144,27 @@ CREATE TABLE DM_TRACCAR_UNSYNCED_DEVICES ( -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -- SUB_OPERATION_TEMPLATE TABLE-- ---TODO: Need to add SUB_OPERATION_TEMPLATE +CREATE TABLE SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID NUMBER(10) NOT NULL, + OPERATION_DEFINITION CLOB NOT NULL, + OPERATION_CODE varchar(100) NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP TIMESTAMP (2) NOT NULL, + UPDATE_TIMESTAMP TIMESTAMP (2) NOT NULL, + UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE) +); + +ALTER TABLE SUB_OPERATION_TEMPLATE +ADD CONSTRAINT FK_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE +FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE); + +ALTER TABLE SUB_OPERATION_TEMPLATE + ADD ( + CONSTRAINT SUB_OPERATION_TEMPLATE_PK PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID) + ); + + -- Generate ID using sequence and trigger +CREATE SEQUENCE SUB_OPERATION_TEMPLATE_seq START WITH 1 INCREMENT BY 1; + +-- END OF SUB_OPERATION_TEMPLATE TABLE-- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 1ff92fc028..7df9dcc065 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -798,4 +798,22 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -- SUB_OPERATION_TEMPLATE TABLE-- ---TODO: Need to add SUB_OPERATION_TEMPLATE + +CREATE SEQUENCE SUB_OPERATION_TEMPLATE_seq; + +CREATE TABLE SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INTEGER DEFAULT NEXTVAL ('SUB_OPERATION_TEMPLATE_seq') NOT NULL, + OPERATION_DEFINITION json NOT NULL, + OPERATION_CODE varchar(100) NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, + UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), + CONSTRAINT SUB_TYPE_ID_OPERATION_CODE_DEVICE_TYPE UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) +); + +-- END OF SUB_OPERATION_TEMPLATE TABLE-- + +