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 729ee868bda..c35674da0a3 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 792d5400044..8d548bbde57 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 2236d5cd902..f28c5d02f4c 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 5233b373877..dd13540c9bd 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 ce6c34bd651..01da583b623 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 6f9b1613e00..59827e1061a 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 f20f34d50b4..ce83acc4499 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 842a4253703..78d23cda742 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 84fa0a811df..fee6ecece7e 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 7252d9d5d3d..7d398a7412d 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 2c8eb1e4a46..d574a545364 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 e5a39b31811..be5a2dee669 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 ccfb341abb4..aec19e09667 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 3a2af14e240..fef316de625 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 b7c18519333..529fe205196 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 80068d7a9bc..9f605521aa1 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 a8ac6b305fb..df69679b902 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 2c9938229c3..7dbb7fb3898 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 f4840f9a626..03720e9b59a 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 8d63d98c893..bcf450059ac 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 cb581770478..a944a3e888f 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 12f4fb4d22e..5d2345e77f2 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 82b38aacded..0c5a8fb090e 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 023fa7e9422..1a0ddb30649 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 1ff92fc028c..7df9dcc0656 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-- + +