SDN Controller Blueprints Data Adaptor 73/64473/1
authorSingal, Kapil (ks220y) <ks220y@att.com>
Tue, 4 Sep 2018 16:53:15 +0000 (12:53 -0400)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Tue, 4 Sep 2018 16:53:15 +0000 (12:53 -0400)
Creating SDN Controller Blueprints Data Adaptor Component

Change-Id: I2f2db69a085eb696c5d1833d652a56e9f7b2e159
Issue-ID: CCSDK-495
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
22 files changed:
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml [new file with mode: 0644]
blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql [new file with mode: 0644]

diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java
new file mode 100644 (file)
index 0000000..c794b5d
--- /dev/null
@@ -0,0 +1,47 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor;\r
+\r
+/**\r
+ * ConfigDataAdaptorException.java Purpose: Provide Configuration Data Adaptor Exception\r
+ *\r
+ * @version 1.0\r
+ */\r
+public class ConfigDataAdaptorException extends Exception {\r
+    \r
+    /**\r
+     *\r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+    \r
+    /**\r
+     * This is a ConfigDataAdaptorException constructor\r
+     *\r
+     * @param message\r
+     */\r
+    public ConfigDataAdaptorException(String message) {\r
+        super(message);\r
+    }\r
+    \r
+    /**\r
+     * This is a ConfigDataAdaptorException constructor\r
+     *\r
+     * @param message\r
+     */\r
+    public ConfigDataAdaptorException(String message, Throwable cause) {\r
+        super(message, cause);\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java
new file mode 100644 (file)
index 0000000..c942ed6
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor;\r
+\r
+@SuppressWarnings("squid:S1118")\r
+public class DataAdaptorConstants {\r
+    \r
+    public static final String OUTPUT_STATUS_SUCCESS = "success";\r
+    public static final String OUTPUT_STATUS_FAILURE = "failure";\r
+    \r
+    public static final String PROPERTY_ENV_TYPE = "org.onap.ccsdk.config.rest.adaptors.envtype";\r
+    public static final String PROPERTY_ENV_PROD = "field";\r
+    public static final String PROPERTY_ENV_SOLO = "solo";\r
+    \r
+    public static final String INPUT_PARAM_TAGS = "tags";\r
+    public static final String INPUT_PARAM_CAPABILITY_NAME = "capabilityName";\r
+    public static final String INPUT_PARAM_MESSAGE = "message";\r
+    public static final String INPUT_PARAM_MESSAGE_TYPE = "messageType";\r
+    public static final String OUTPUT_PARAM_STATUS = "status";\r
+    public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";\r
+    public static final String INPUT_PARAM_FILE_CATEGORY = "fileCategory";\r
+    public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance";\r
+    public static final String INPUT_PARAM_ASDC_ARTIFACT_IND = "asdcArtifactInd";\r
+    public static final Object INPUT_PARAM_VNF_ID = "vnfId";\r
+    public static final Object INPUT_PARAM_VM_NAME = "vmName";\r
+    \r
+    public static final Object INPUT_PARAM_CONFIG_CONTENT_TYPE = "configContentType";\r
+    \r
+    public static final Object INPUT_PARAM_CONFIG_CONTENT = "configContent";\r
+    public static final Object INPUT_PARAM_CONFIG_INDICATOR = "configIndicator";\r
+    \r
+    public static final Object CONFIG_CONTENT_TYPE_CONFIGURATION = "Configuration";\r
+    public static final Object CONFIG_CONTENT_TYPE_PARAMETERS = "Parameters";\r
+    public static final Object CONFIG_INDICATOR_PREPARE = "Prepare";\r
+    public static final Object CONFIG_INDICATOR_ACTIVE = "Active";\r
+    \r
+    public static final String INPUT_PARAM_RESPONSE_PRIFIX = "response-prefix";\r
+    public static final String INPUT_PARAM_VNF_TYPE = "vnfType";\r
+    public static final String INPUT_PARAM_VNFC_TYPE = "vnfcType";\r
+    public static final String INPUT_PARAM_ACTION = "action";\r
+    public static final String INPUT_PARAM_API_VERSION = "apiVersion";\r
+    \r
+    public static final String INPUT_PARAM_FILE_ID = "fileId";\r
+    public static final String INPUT_PARAM_UPLOAD_CONFIG_ID = "uploadConfigId";\r
+    public static final String FILE_CATEGORY_SERVICE_TEMPLATE = "service_template";\r
+    \r
+    public static final String ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";\r
+    \r
+    public static final String LOG_MESSAGE_TYPE_LOG = "Log";\r
+    public static final String LOG_MESSAGE_TYPE_COMPONENT = "Component";\r
+    public static final String LOG_MESSAGE_TYPE_REQUEST = "Request";\r
+    public static final String LOG_MESSAGE_TYPE_MODEL = "Model";\r
+    public static final String LOG_MESSAGE_TYPE_DATA = "Data";\r
+    public static final String LOG_MESSAGE_TYPE_CONFIG = "Config";\r
+    \r
+    public static final String SELF_SERVICE_STATUS_RECEIVED = "Received";\r
+    public static final String SELF_SERVICE_STATUS_ACKNOWLEDGED = "Acknowledged";\r
+    public static final String SELF_SERVICE_STATUS_REPLIED = "Replied";\r
+    public static final String SELF_SERVICE_STATUS_FAILED = "Failed";\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java
new file mode 100644 (file)
index 0000000..e1b25be
--- /dev/null
@@ -0,0 +1,30 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+\r
+public interface ConfigPropertyMapDao {\r
+    \r
+    /**\r
+     * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
+     *\r
+     * @param key key mapped to a value\r
+     * @return the result string, containing mapped string value\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
+     */\r
+    public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java
new file mode 100644 (file)
index 0000000..84c96a8
--- /dev/null
@@ -0,0 +1,68 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.Map;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+import java.util.concurrent.Executors;\r
+import java.util.concurrent.ScheduledExecutorService;\r
+import java.util.concurrent.TimeUnit;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.data.adaptor.DataAdaptorConstants;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.JdbcTemplate;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.google.common.base.Preconditions;\r
+\r
+public class ConfigPropertyMapDaoImpl implements ConfigPropertyMapDao {\r
+    \r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPropertyMapDaoImpl.class);\r
+    \r
+    private JdbcTemplate jdbcTemplate;\r
+    private Map<String, String> configPropertyMap = new ConcurrentHashMap<>();\r
+    \r
+    public ConfigPropertyMapDaoImpl(JdbcTemplate jdbcTemplate) {\r
+        this.jdbcTemplate = jdbcTemplate;\r
+        initializeMap();\r
+        \r
+        String envType = configPropertyMap.get(DataAdaptorConstants.PROPERTY_ENV_TYPE);\r
+        if (!(DataAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)\r
+                || DataAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {\r
+            ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);\r
+            Runnable task = () -> {\r
+                initializeMap();\r
+            };\r
+            executor.scheduleWithFixedDelay(task, 60, 15, TimeUnit.MINUTES);\r
+        }\r
+    }\r
+    \r
+    private void initializeMap() {\r
+        String getPropQuery = "SELECT * FROM CONFIG_PROPERTY_MAP";\r
+        jdbcTemplate.queryForList(getPropQuery).forEach(rows -> {\r
+            String key = StringUtils.trimToEmpty((String) rows.get("reference_key"));\r
+            String value = StringUtils.trimToEmpty((String) rows.get("reference_value"));\r
+            configPropertyMap.put(key, value);\r
+        });\r
+        logger.trace("loaded configPropertyMap : ({})", configPropertyMap);\r
+    }\r
+    \r
+    @Override\r
+    public String getConfigPropertyByKey(String key) throws SvcLogicException {\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing property key");\r
+        return configPropertyMap.get(key);\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java
new file mode 100644 (file)
index 0000000..98f2647
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+\r
+public interface ConfigResourceDao {\r
+    \r
+    /**\r
+     * Issue a single SQL Insert operation for CONFIG_RESOURCE table via a prepared statement, binding\r
+     * the given arguments.\r
+     *\r
+     * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
+     */\r
+    public ConfigResource save(ConfigResource configResourceInput) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue a single SQL Delete operation for CONFIG_RESOURCE table via a prepared statement, binding\r
+     * the given arguments.\r
+     *\r
+     * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
+     */\r
+    public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
+     * query, mapping each row to a Java object via a ConfigResource RowMapper.\r
+     *\r
+     * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;\r
+    \r
+    public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java
new file mode 100644 (file)
index 0000000..88cb78c
--- /dev/null
@@ -0,0 +1,412 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ResourceAssignmentData;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.JdbcTemplate;\r
+import org.springframework.jdbc.core.RowMapper;\r
+import org.springframework.jdbc.core.RowMapperResultSetExtractor;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ConfigResourceDaoImpl implements ConfigResourceDao {\r
+    \r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoImpl.class);\r
+    \r
+    private JdbcTemplate jdbcTemplate;\r
+    \r
+    public ConfigResourceDaoImpl(JdbcTemplate jdbcTemplate) {\r
+        this.jdbcTemplate = jdbcTemplate;\r
+    }\r
+    \r
+    @Override\r
+    public ConfigResource save(ConfigResource configResource) throws SvcLogicException {\r
+        \r
+        ConfigResource dbConfigResource = checkConfigResource(configResource);\r
+        \r
+        if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {\r
+            configResource.setConfigResourceId(dbConfigResource.getConfigResourceId());\r
+            \r
+            validateConfigResource(configResource);\r
+            \r
+            update(configResource);\r
+            \r
+            saveConfigResourceAssignmentData(configResource);\r
+        } else {\r
+            String addQuery = "INSERT INTO CONFIG_RESOURCE "\r
+                    + "( config_resource_id, resource_id, resource_type, service_template_name, service_template_version,"\r
+                    + "template_name, recipe_name, request_id, resource_data, mask_data, status, created_date, updated_by ) "\r
+                    + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
+            \r
+            configResource.setConfigResourceId(configResource.getUniqueId());\r
+            \r
+            validateConfigResource(configResource);\r
+            \r
+            logger.info("saving config resource ({}) ...", configResource);\r
+            jdbcTemplate.update(addQuery, configResource.getConfigResourceId(), configResource.getResourceId(),\r
+                    configResource.getResourceType(), configResource.getServiceTemplateName(),\r
+                    configResource.getServiceTemplateVersion(), configResource.getTemplateName(),\r
+                    configResource.getRecipeName(), configResource.getRequestId(), configResource.getResourceData(),\r
+                    configResource.getMaskData(), configResource.getStatus(), configResource.getCreatedDate(),\r
+                    configResource.getUpdatedBy());\r
+            \r
+            saveConfigResourceAssignmentData(configResource);\r
+        }\r
+        dbConfigResource = getConfigResource(configResource);\r
+        return dbConfigResource;\r
+    }\r
+    \r
+    private void update(ConfigResource configResource) throws SvcLogicException {\r
+        if (StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
+            logger.info("updating config resource ({}) ...", configResource);\r
+            // Added service_template_name and version in update query to update with 1802 data.\r
+            String updateQuery = "UPDATE CONFIG_RESOURCE SET "\r
+                    + "resource_data = ?, mask_data = ?, created_date = ?, updated_by = ? ,service_template_name = ?, service_template_version = ? "\r
+                    + "where config_resource_id = ?";\r
+            \r
+            jdbcTemplate.update(updateQuery, configResource.getResourceData(), configResource.getMaskData(),\r
+                    configResource.getCreatedDate(), configResource.getUpdatedBy(),\r
+                    configResource.getServiceTemplateName(), configResource.getServiceTemplateVersion(),\r
+                    configResource.getConfigResourceId());\r
+        } else {\r
+            throw new SvcLogicException("missing config resource id to update.");\r
+        }\r
+    }\r
+    \r
+    private void saveConfigResourceAssignmentData(ConfigResource configResource) {\r
+        if (configResource != null && StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
+            List<Object> listOfArguments = new ArrayList<>();\r
+            String deleteQuery = "DELETE FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? ";\r
+            listOfArguments.add(configResource.getConfigResourceId());\r
+            this.jdbcTemplate.update(deleteQuery, listOfArguments.toArray());\r
+            logger.info("config resource assignment data deleted successfully for the  config_resource_id ({})",\r
+                    configResource.getConfigResourceId());\r
+            \r
+            if (configResource.getResourceAssignments() != null) {\r
+                List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
+                for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
+                    if (resourceAssignmentData != null) {\r
+                        resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId());\r
+                        saveResourceAssignmentData(resourceAssignmentData);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+    \r
+    private ResourceAssignmentData saveResourceAssignmentData(ResourceAssignmentData resourceAssignmentData) {\r
+        String addQuery = "INSERT INTO CONFIG_RESOURCE_ASSIGNMENT_DATA "\r
+                + "( config_resource_assignment_data_id, config_resource_id, version, updated_by, template_key_name, "\r
+                + "resource_name, data_type, entry_schema, resource_value, source, status, message ) "\r
+                + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
+        \r
+        logger.debug("saving config resource assignment data ({}) ... ", resourceAssignmentData);\r
+        jdbcTemplate.update(addQuery, resourceAssignmentData.getId(), resourceAssignmentData.getConfigResourceId(),\r
+                resourceAssignmentData.getVersion(), resourceAssignmentData.getUpdatedBy(),\r
+                resourceAssignmentData.getTemplateKeyName(), resourceAssignmentData.getResourceName(),\r
+                resourceAssignmentData.getDataType(), resourceAssignmentData.getEntrySchema(),\r
+                resourceAssignmentData.getResourceValue(), resourceAssignmentData.getSource(),\r
+                resourceAssignmentData.getStatus(), resourceAssignmentData.getMessage());\r
+        \r
+        return resourceAssignmentData;\r
+    }\r
+    \r
+    @Override\r
+    public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {\r
+        StringBuilder selectArtifactBuffer = new StringBuilder();\r
+        List<Object> listOfArguments = new ArrayList<>();\r
+        \r
+        selectArtifactBuffer.append("DELETE FROM CONFIG_RESOURCE WHERE config_resource_id = ? ");\r
+        listOfArguments.add(configResourceInput.getConfigResourceId());\r
+        \r
+        String queryString = selectArtifactBuffer.toString();\r
+        this.jdbcTemplate.update(queryString, listOfArguments.toArray());\r
+        logger.info("config resource ({}) deleted successfully ", configResourceInput);\r
+    }\r
+    \r
+    @SuppressWarnings("squid:S3776")\r
+    @Override\r
+    public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {\r
+        StringBuilder selectArtifactBuffer = new StringBuilder();\r
+        List<Object> listOfArguments = new ArrayList<>();\r
+        \r
+        selectArtifactBuffer.append("SELECT * FROM CONFIG_RESOURCE WHERE ");\r
+        \r
+        StringBuilder whereClauseRemaining = new StringBuilder();\r
+        \r
+        if (configResourceInput.getServiceTemplateName() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("service_template_name = ? ");\r
+            listOfArguments.add(configResourceInput.getServiceTemplateName());\r
+        }\r
+        \r
+        if (configResourceInput.getServiceTemplateVersion() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("service_template_version = ? ");\r
+            listOfArguments.add(configResourceInput.getServiceTemplateVersion());\r
+        }\r
+        \r
+        if (configResourceInput.getResourceId() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("resource_id = ? ");\r
+            listOfArguments.add(configResourceInput.getResourceId());\r
+        }\r
+        \r
+        if (configResourceInput.getResourceType() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("resource_type = ? ");\r
+            listOfArguments.add(configResourceInput.getResourceType());\r
+        }\r
+        \r
+        if (configResourceInput.getRequestId() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("request_id = ? ");\r
+            listOfArguments.add(configResourceInput.getRequestId());\r
+        }\r
+        \r
+        if (configResourceInput.getTemplateName() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("template_name = ? ");\r
+            listOfArguments.add(configResourceInput.getTemplateName());\r
+        }\r
+        \r
+        if (configResourceInput.getRecipeName() != null) {\r
+            if (whereClauseRemaining.length() != 0) {\r
+                whereClauseRemaining.append("AND ");\r
+            }\r
+            whereClauseRemaining.append("recipe_name = ? ");\r
+            listOfArguments.add(configResourceInput.getRecipeName());\r
+        }\r
+        \r
+        String queryString = selectArtifactBuffer.toString() + whereClauseRemaining.toString();\r
+        logger.info("config resource queryString ({})", queryString);\r
+        List<ConfigResource> configResources =\r
+                this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ConfigResourceMapper());\r
+        \r
+        List<ConfigResource> returnConfigResources = new ArrayList<>();\r
+        \r
+        if (configResources != null) {\r
+            for (ConfigResource configResource : configResources) {\r
+                if (configResource != null) {\r
+                    returnConfigResources.add(getConfigResource(configResource));\r
+                }\r
+            }\r
+        }\r
+        return returnConfigResources;\r
+    }\r
+    \r
+    public ConfigResource checkConfigResource(ConfigResource configResource) {\r
+        StringBuilder selectBuffer = new StringBuilder();\r
+        List<Object> listOfArguments = new ArrayList<>();\r
+        \r
+        selectBuffer.append(\r
+                "SELECT * FROM CONFIG_RESOURCE WHERE resource_id = ? AND resource_type = ? AND template_name = ? ");\r
+        listOfArguments.add(configResource.getResourceId());\r
+        listOfArguments.add(configResource.getResourceType());\r
+        listOfArguments.add(configResource.getTemplateName());\r
+        return queryOneForObject(selectBuffer.toString(), listOfArguments.toArray(), new ConfigResourceMapper());\r
+    }\r
+    \r
+    @Override\r
+    public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
+        ConfigResource dbConfigResource = checkConfigResource(configResource);\r
+        if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {\r
+            List<ResourceAssignmentData> resourceAssignments =\r
+                    getResourceAssignmentdata(dbConfigResource.getConfigResourceId());\r
+            configResource.setResourceAssignments(resourceAssignments);\r
+        }\r
+        return configResource;\r
+    }\r
+    \r
+    private List<ResourceAssignmentData> getResourceAssignmentdata(String configResourceId) {\r
+        List<Object> listOfArguments = new ArrayList<>();\r
+        String queryString = "SELECT * FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? ";\r
+        logger.info("getResourceAssignmentdata queryString ({}), query inputs ({})", queryString, configResourceId);\r
+        listOfArguments.add(configResourceId);\r
+        return this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ResourceAssignmentDataMapper());\r
+    }\r
+    \r
+    @SuppressWarnings("squid:S3776")\r
+    private boolean validateConfigResource(ConfigResource configResource) throws SvcLogicException {\r
+        if (configResource == null) {\r
+            throw new SvcLogicException("config resource information is missing.");\r
+        }\r
+        \r
+        if (StringUtils.isBlank(configResource.getConfigResourceId())) {\r
+            throw new SvcLogicException("config resource id is missing.");\r
+        }\r
+        \r
+        if (StringUtils.isBlank(configResource.getResourceType())) {\r
+            throw new SvcLogicException("config resource type is missing.");\r
+        }\r
+        if (StringUtils.isBlank(configResource.getResourceId())) {\r
+            throw new SvcLogicException("config resource  resource id is missing.");\r
+        }\r
+        \r
+        if (StringUtils.isBlank(configResource.getRecipeName())) {\r
+            throw new SvcLogicException("config resource action name is missing.");\r
+        }\r
+        \r
+        if (StringUtils.isBlank(configResource.getTemplateName())) {\r
+            throw new SvcLogicException("config resource template name is missing.");\r
+        }\r
+        \r
+        if (configResource.getResourceAssignments() != null) {\r
+            List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
+            for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
+                if (resourceAssignmentData != null) {\r
+                    resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId());\r
+                    if (StringUtils.isBlank(resourceAssignmentData.getId())) {\r
+                        resourceAssignmentData.setId(resourceAssignmentData.getUniqueId());\r
+                    }\r
+                    if (resourceAssignmentData.getVersion() == null || resourceAssignmentData.getVersion() == 0) {\r
+                        resourceAssignmentData.setVersion(1);\r
+                    }\r
+                    if (StringUtils.isBlank(resourceAssignmentData.getUpdatedBy())) {\r
+                        resourceAssignmentData.setUpdatedBy("System");\r
+                    }\r
+                    if (resourceAssignmentData.getStatus() == null) {\r
+                        logger.warn("{} status is missing and setting to undefined", resourceAssignmentData);\r
+                        resourceAssignmentData.setStatus("undefined");\r
+                    }\r
+                    if (resourceAssignmentData.getMessage() == null) {\r
+                        resourceAssignmentData.setMessage("");\r
+                    }\r
+                    if (resourceAssignmentData.getResourceValue() == null) {\r
+                        resourceAssignmentData.setResourceValue("");\r
+                    }\r
+                    \r
+                    validateResourceAssignmentData(resourceAssignmentData);\r
+                }\r
+            }\r
+        }\r
+        \r
+        return true;\r
+    }\r
+    \r
+    private boolean validateResourceAssignmentData(ResourceAssignmentData resourceAssignmentData)\r
+            throws SvcLogicException {\r
+        if (resourceAssignmentData == null) {\r
+            throw new SvcLogicException("resource assignment data information is missing.");\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getConfigResourceId())) {\r
+            throw new SvcLogicException("resource assignment data config resource id is missing.");\r
+        }\r
+        if (resourceAssignmentData.getVersion() == null) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) version is missing", resourceAssignmentData));\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getTemplateKeyName())) {\r
+            throw new SvcLogicException(String.format("resource assignment data (%s) template key name is missing",\r
+                    resourceAssignmentData));\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getResourceName())) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) resource name is missing", resourceAssignmentData));\r
+        }\r
+        if (resourceAssignmentData.getResourceValue() == null) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) resource value is missing", resourceAssignmentData));\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getSource())) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) source is missing", resourceAssignmentData));\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getDataType())) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) data type is missing", resourceAssignmentData));\r
+        }\r
+        if (StringUtils.isBlank(resourceAssignmentData.getStatus())) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) status is missing", resourceAssignmentData));\r
+        }\r
+        if (resourceAssignmentData.getMessage() == null) {\r
+            throw new SvcLogicException(\r
+                    String.format("resource assignment data (%s) message is missing", resourceAssignmentData));\r
+        }\r
+        return true;\r
+    }\r
+    \r
+    private <T> T queryOneForObject(String sql, Object[] args, RowMapper<T> rowMapper) {\r
+        List<T> results = this.jdbcTemplate.query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper, 1));\r
+        if (results != null && !results.isEmpty()) {\r
+            return results.get(0);\r
+        } else {\r
+            return null;\r
+        }\r
+    }\r
+    \r
+    class ConfigResourceMapper implements RowMapper<ConfigResource> {\r
+        @Override\r
+        public ConfigResource mapRow(ResultSet rs, int rowNum) throws SQLException {\r
+            ConfigResource configResource = new ConfigResource();\r
+            configResource.setConfigResourceId(rs.getString("config_resource_id"));\r
+            configResource.setResourceId(rs.getString("resource_id"));\r
+            configResource.setResourceType(rs.getString("resource_type"));\r
+            configResource.setServiceTemplateName(rs.getString("service_template_name"));\r
+            configResource.setServiceTemplateVersion(rs.getString("service_template_version"));\r
+            configResource.setTemplateName(rs.getString("template_name"));\r
+            configResource.setRecipeName(rs.getString("recipe_name"));\r
+            configResource.setRequestId(rs.getString("request_id"));\r
+            configResource.setResourceData(rs.getString("resource_data"));\r
+            configResource.setMaskData(rs.getString("mask_data"));\r
+            configResource.setStatus(rs.getString("status"));\r
+            configResource.setCreatedDate(rs.getDate("created_date"));\r
+            configResource.setUpdatedBy(rs.getString("updated_by"));\r
+            return configResource;\r
+        }\r
+    }\r
+    \r
+    class ResourceAssignmentDataMapper implements RowMapper<ResourceAssignmentData> {\r
+        @Override\r
+        public ResourceAssignmentData mapRow(ResultSet rs, int rowNum) throws SQLException {\r
+            ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
+            resourceAssignmentData.setConfigResourceId(rs.getString("config_resource_id"));\r
+            resourceAssignmentData.setDataType(rs.getString("data_type"));\r
+            resourceAssignmentData.setEntrySchema(rs.getString("entry_schema"));\r
+            resourceAssignmentData.setId(rs.getString("config_resource_assignment_data_id"));\r
+            resourceAssignmentData.setMessage(rs.getString("message"));\r
+            resourceAssignmentData.setResourceName(rs.getString("resource_name"));\r
+            resourceAssignmentData.setResourceValue(rs.getString("resource_value"));\r
+            resourceAssignmentData.setSource(rs.getString("source"));\r
+            resourceAssignmentData.setStatus(rs.getString("status"));\r
+            resourceAssignmentData.setTemplateKeyName(rs.getString("template_key_name"));\r
+            resourceAssignmentData.setUpdatedBy(rs.getString("updated_by"));\r
+            resourceAssignmentData.setUpdatedDate(rs.getTimestamp("updated_date"));\r
+            resourceAssignmentData.setVersion(rs.getInt("version"));\r
+            return resourceAssignmentData;\r
+        }\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java
new file mode 100644 (file)
index 0000000..d8d5090
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
+\r
+public interface NamedQueryExecutorDao {\r
+    /**\r
+     * Return NamedParameterJdbcTemplate object.\r
+     */\r
+    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
+     * query, expecting a result list.\r
+     * <p>\r
+     * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
+     * using the column name as the key).\r
+     *\r
+     * @param sql SQL query to execute\r
+     * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return a List that contains a Map per row\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue an update via a prepared statement, binding the given arguments.\r
+     *\r
+     * @param sql SQL containing named parameters\r
+     * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return the number of rows affected\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
+     */\r
+    public int update(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java
new file mode 100644 (file)
index 0000000..bbb12cf
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class NamedQueryExecutorDaoImpl implements NamedQueryExecutorDao {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);\r
+    private static final String CLASS_NAME = "NamedQueryExecutorDaoImpl";\r
+    \r
+    @Autowired(required = true)\r
+    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;\r
+    \r
+    public NamedQueryExecutorDaoImpl(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {\r
+        this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;\r
+        logger.info("{} Constructor initialised..", CLASS_NAME);\r
+    }\r
+    \r
+    @Override\r
+    public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
+        logger.debug("Query  ({}) with parameters ({})", sql, parameters);\r
+        return namedParameterJdbcTemplate.queryForList(sql, parameters);\r
+    }\r
+    \r
+    @Override\r
+    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {\r
+        return namedParameterJdbcTemplate;\r
+    }\r
+    \r
+    @Override\r
+    public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
+        logger.debug("update ({}) with parameters ({})", sql, parameters);\r
+        return namedParameterJdbcTemplate.update(sql, parameters);\r
+    }\r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java
new file mode 100644 (file)
index 0000000..f66cd4a
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+\r
+public interface QueryExecutorDao {\r
+    \r
+    /**\r
+     * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
+     * query, expecting a result list.\r
+     * <p>\r
+     * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
+     * using the column name as the key). Each element in the list will be of the form returned by this\r
+     * interface's queryForMap() methods.\r
+     *\r
+     * @param sql SQL query to execute\r
+     * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return a List that contains a Map per row\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
+     * prepared statement, binding the given arguments.\r
+     *\r
+     * @param sql SQL containing bind parameters\r
+     * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return the number of rows affected\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
+     */\r
+    public int update(String sql, Object[] data) throws SvcLogicException;\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java
new file mode 100644 (file)
index 0000000..bc3901a
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.jdbc.core.JdbcTemplate;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class QueryExecutorDaoImpl implements QueryExecutorDao {\r
+    \r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);\r
+    private static final String CLASS_NAME = "QueryExecutorDaoImpl";\r
+    \r
+    @Autowired(required = true)\r
+    private JdbcTemplate jdbcTemplate;\r
+    \r
+    public QueryExecutorDaoImpl(JdbcTemplate jdbcTemplate) {\r
+        this.jdbcTemplate = jdbcTemplate;\r
+        logger.info("{} Constructor initialised..", CLASS_NAME);\r
+    }\r
+    \r
+    @Override\r
+    public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {\r
+        logger.debug("Query  ({}) with data ({})", sql, data);\r
+        return jdbcTemplate.queryForList(sql, data);\r
+    }\r
+    \r
+    @Override\r
+    public int update(String sql, Object[] data) throws SvcLogicException {\r
+        logger.debug("Query  ({}) with data ({})", sql, data);\r
+        return jdbcTemplate.update(sql, data);\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java
new file mode 100644 (file)
index 0000000..f87dbb7
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.util.List;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+\r
+public interface TransactionLogDao {\r
+    \r
+    /**\r
+     * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
+     * binding the given arguments.\r
+     *\r
+     * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
+     */\r
+    public void save(TransactionLog transactionLog) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
+     * TransactionLog RowMapper.\r
+     *\r
+     * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
+     * TransactionLog RowMapper.\r
+     *\r
+     * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
+            throws SvcLogicException;\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java
new file mode 100644 (file)
index 0000000..88d9c84
--- /dev/null
@@ -0,0 +1,87 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.dao;\r
+\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.util.List;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.JdbcTemplate;\r
+import org.springframework.jdbc.core.RowMapper;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class TransactionLogDaoImpl implements TransactionLogDao {\r
+    \r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(TransactionLogDaoImpl.class);\r
+    \r
+    private JdbcTemplate jdbcTemplate;\r
+    \r
+    public TransactionLogDaoImpl(JdbcTemplate jdbcTemplate) {\r
+        this.jdbcTemplate = jdbcTemplate;\r
+    }\r
+    \r
+    @Override\r
+    public void save(TransactionLog transactionLog) throws SvcLogicException {\r
+        if (transactionLog != null && StringUtils.isNotBlank(transactionLog.getRequestId())) {\r
+            String addSql =\r
+                    "INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (?, ?, ?, ?) ";\r
+            jdbcTemplate.update(addSql, transactionLog.getUniqueId(), transactionLog.getRequestId(),\r
+                    transactionLog.getMessageType(), transactionLog.getMessage());\r
+            logger.trace("TransactionLog Updated Successfully for message_type {}", transactionLog.getMessageType());\r
+        }\r
+        \r
+    }\r
+    \r
+    @Override\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
+        if (StringUtils.isNotBlank(requestId)) {\r
+            String selectByRequestIdSql =\r
+                    "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? ORDER BY creation_date DESC";\r
+            return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId}, new TransactionLogMapper());\r
+        } else {\r
+            throw new SvcLogicException("TransactionLog Request id  (" + requestId + ")is missing ");\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
+            throws SvcLogicException {\r
+        if (StringUtils.isNotBlank(requestId)) {\r
+            String selectByRequestIdSql =\r
+                    "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? and message_type = ? ORDER BY creation_date DESC";\r
+            return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId, messageType},\r
+                    new TransactionLogMapper());\r
+        } else {\r
+            throw new SvcLogicException("TransactionLog Request id  (" + requestId + ")is missing ");\r
+        }\r
+    }\r
+    \r
+    private static final class TransactionLogMapper implements RowMapper<TransactionLog> {\r
+        @Override\r
+        public TransactionLog mapRow(ResultSet rs, int rowNum) throws SQLException {\r
+            TransactionLog transactionLog = new TransactionLog();\r
+            transactionLog.setCreationDate(rs.getDate("creation_date"));\r
+            transactionLog.setMessage(rs.getString("message"));\r
+            transactionLog.setMessageType(rs.getString("message_type"));\r
+            transactionLog.setRequestId(rs.getString("request_id"));\r
+            transactionLog.setTransactionLogId(rs.getString("config_transaction_log_id"));\r
+            return transactionLog;\r
+        }\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java
new file mode 100644 (file)
index 0000000..888bdcb
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.db;\r
+\r
+import java.io.PrintWriter;\r
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+import java.sql.SQLFeatureNotSupportedException;\r
+import javax.sql.DataSource;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class DataSourceWrap implements DataSource {\r
+    \r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);\r
+    \r
+    private DataSource dataSource;\r
+    \r
+    public DataSourceWrap(DataSource dataSource) {\r
+        logger.info("Setting Data Source {} ", dataSource);\r
+        this.dataSource = dataSource;\r
+    }\r
+    \r
+    @Override\r
+    public PrintWriter getLogWriter() throws SQLException {\r
+        return dataSource.getLogWriter();\r
+    }\r
+    \r
+    @Override\r
+    public void setLogWriter(PrintWriter out) throws SQLException {\r
+        dataSource.setLogWriter(out);\r
+    }\r
+    \r
+    @Override\r
+    public void setLoginTimeout(int seconds) throws SQLException {\r
+        dataSource.setLoginTimeout(seconds);\r
+    }\r
+    \r
+    @Override\r
+    public int getLoginTimeout() throws SQLException {\r
+        return dataSource.getLoginTimeout();\r
+    }\r
+    \r
+    @Override\r
+    public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {\r
+        return dataSource.getParentLogger();\r
+    }\r
+    \r
+    @Override\r
+    public <T> T unwrap(Class<T> iface) throws SQLException {\r
+        return dataSource.unwrap(iface);\r
+    }\r
+    \r
+    @Override\r
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+        return dataSource.isWrapperFor(iface);\r
+    }\r
+    \r
+    @SuppressWarnings("squid:S2095")\r
+    @Override\r
+    public Connection getConnection() throws SQLException {\r
+        Connection c = dataSource.getConnection();\r
+        logger.trace("getConnection: ({})", c.getClass().getName());\r
+        c.setAutoCommit(true);\r
+        return c;\r
+    }\r
+    \r
+    @SuppressWarnings("squid:S2095")\r
+    @Override\r
+    public Connection getConnection(String username, String pass) throws SQLException {\r
+        Connection c = dataSource.getConnection(username, pass);\r
+        c.setAutoCommit(true);\r
+        return c;\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java
new file mode 100644 (file)
index 0000000..6cc796e
--- /dev/null
@@ -0,0 +1,46 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.domain;\r
+\r
+import java.io.Serializable;\r
+\r
+public class ConfigPropertyMapData implements Serializable {\r
+    private static final long serialVersionUID = 1L;\r
+    \r
+    private String referenceKey;\r
+    private String referenceValue;\r
+    \r
+    public String getReferenceKey() {\r
+        return referenceKey;\r
+    }\r
+    \r
+    public void setReferenceKey(String referenceKey) {\r
+        this.referenceKey = referenceKey;\r
+    }\r
+    \r
+    public String getReferenceValue() {\r
+        return referenceValue;\r
+    }\r
+    \r
+    public void setReferenceValue(String referenceValue) {\r
+        this.referenceValue = referenceValue;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+        return "ConfigPropertyMapData [referenceKey=" + referenceKey + ", referenceValue=" + referenceValue + "]";\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java
new file mode 100644 (file)
index 0000000..2e46198
--- /dev/null
@@ -0,0 +1,168 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.domain;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.UUID;\r
+\r
+public class ConfigResource implements Serializable {\r
+    /**\r
+     *\r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+    \r
+    private String configResourceId;\r
+    private String resourceId;\r
+    private String resourceType;\r
+    private String serviceTemplateName;\r
+    private String serviceTemplateVersion;\r
+    private String templateName;\r
+    private String recipeName;\r
+    private String requestId;\r
+    private String resourceData;\r
+    private String maskData;\r
+    private Date createdDate = new Date();\r
+    private String status;\r
+    private String updatedBy;\r
+    private List<ResourceAssignmentData> resourceAssignments;\r
+    \r
+    public String getConfigResourceId() {\r
+        return configResourceId;\r
+    }\r
+    \r
+    public void setConfigResourceId(String configResourceId) {\r
+        this.configResourceId = configResourceId;\r
+    }\r
+    \r
+    public String getResourceId() {\r
+        return resourceId;\r
+    }\r
+    \r
+    public void setResourceId(String resourceId) {\r
+        this.resourceId = resourceId;\r
+    }\r
+    \r
+    public String getResourceType() {\r
+        return resourceType;\r
+    }\r
+    \r
+    public void setResourceType(String resourceType) {\r
+        this.resourceType = resourceType;\r
+    }\r
+    \r
+    public String getServiceTemplateName() {\r
+        return serviceTemplateName;\r
+    }\r
+    \r
+    public void setServiceTemplateName(String serviceTemplateName) {\r
+        this.serviceTemplateName = serviceTemplateName;\r
+    }\r
+    \r
+    public String getServiceTemplateVersion() {\r
+        return serviceTemplateVersion;\r
+    }\r
+    \r
+    public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
+        this.serviceTemplateVersion = serviceTemplateVersion;\r
+    }\r
+    \r
+    public String getTemplateName() {\r
+        return templateName;\r
+    }\r
+    \r
+    public void setTemplateName(String templateName) {\r
+        this.templateName = templateName;\r
+    }\r
+    \r
+    public String getRecipeName() {\r
+        return recipeName;\r
+    }\r
+    \r
+    public void setRecipeName(String recipeName) {\r
+        this.recipeName = recipeName;\r
+    }\r
+    \r
+    public String getRequestId() {\r
+        return requestId;\r
+    }\r
+    \r
+    public void setRequestId(String requestId) {\r
+        this.requestId = requestId;\r
+    }\r
+    \r
+    public String getResourceData() {\r
+        return resourceData;\r
+    }\r
+    \r
+    public void setResourceData(String resourceData) {\r
+        this.resourceData = resourceData;\r
+    }\r
+    \r
+    public String getMaskData() {\r
+        return maskData;\r
+    }\r
+    \r
+    public void setMaskData(String maskData) {\r
+        this.maskData = maskData;\r
+    }\r
+    \r
+    public Date getCreatedDate() {\r
+        return createdDate;\r
+    }\r
+    \r
+    public void setCreatedDate(Date createdDate) {\r
+        this.createdDate = createdDate;\r
+    }\r
+    \r
+    public String getStatus() {\r
+        return status;\r
+    }\r
+    \r
+    public void setStatus(String status) {\r
+        this.status = status;\r
+    }\r
+    \r
+    public String getUpdatedBy() {\r
+        return updatedBy;\r
+    }\r
+    \r
+    public void setUpdatedBy(String updatedBy) {\r
+        this.updatedBy = updatedBy;\r
+    }\r
+    \r
+    public List<ResourceAssignmentData> getResourceAssignments() {\r
+        return resourceAssignments;\r
+    }\r
+    \r
+    public void setResourceAssignments(List<ResourceAssignmentData> resourceAssignments) {\r
+        this.resourceAssignments = resourceAssignments;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+        return "ConfigResource [configResourceId=" + configResourceId + ", resourceId=" + resourceId\r
+                + ", serviceTemplateName=" + serviceTemplateName + ", serviceTemplateVersion=" + serviceTemplateVersion\r
+                + ", resourceType=" + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName\r
+                + ", requestId=" + requestId + ", resourceData= ******** , maskData=" + maskData + ", createdDate="\r
+                + createdDate + ", updatedBy=" + updatedBy + "]";\r
+    }\r
+    \r
+    public String getUniqueId() {\r
+        return UUID.randomUUID().toString();\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java
new file mode 100644 (file)
index 0000000..c213326
--- /dev/null
@@ -0,0 +1,154 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.domain;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+import java.util.UUID;\r
+\r
+public class ResourceAssignmentData implements Serializable {\r
+    \r
+    private static final long serialVersionUID = 1L;\r
+    private String id;\r
+    private String configResourceId;\r
+    private Integer version;\r
+    private Date updatedDate = new Date();\r
+    private String updatedBy;\r
+    private String templateKeyName;\r
+    private String resourceName;\r
+    private String dataType;\r
+    private String entrySchema;\r
+    private String resourceValue;\r
+    private String source;\r
+    private String status;\r
+    private String message;\r
+    \r
+    public String getUniqueId() {\r
+        return UUID.randomUUID().toString();\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+        return "ResourceAssignmentData [id=" + id + ", configResourceId=" + configResourceId + ", version=" + version\r
+                + ", updatedDate=" + updatedDate + ", updatedBy=" + updatedBy + ", templateKeyName=" + templateKeyName\r
+                + ", resourceName=" + resourceName + ", dataType=" + dataType + ", source=" + source + ", status="\r
+                + status + "]";\r
+    }\r
+    \r
+    public String getId() {\r
+        return id;\r
+    }\r
+    \r
+    public void setId(String id) {\r
+        this.id = id;\r
+    }\r
+    \r
+    public String getConfigResourceId() {\r
+        return configResourceId;\r
+    }\r
+    \r
+    public void setConfigResourceId(String configResourceId) {\r
+        this.configResourceId = configResourceId;\r
+    }\r
+    \r
+    public Integer getVersion() {\r
+        return version;\r
+    }\r
+    \r
+    public void setVersion(Integer version) {\r
+        this.version = version;\r
+    }\r
+    \r
+    public Date getUpdatedDate() {\r
+        return updatedDate;\r
+    }\r
+    \r
+    public void setUpdatedDate(Date updatedDate) {\r
+        this.updatedDate = updatedDate;\r
+    }\r
+    \r
+    public String getUpdatedBy() {\r
+        return updatedBy;\r
+    }\r
+    \r
+    public void setUpdatedBy(String updatedBy) {\r
+        this.updatedBy = updatedBy;\r
+    }\r
+    \r
+    public String getTemplateKeyName() {\r
+        return templateKeyName;\r
+    }\r
+    \r
+    public void setTemplateKeyName(String templateKeyName) {\r
+        this.templateKeyName = templateKeyName;\r
+    }\r
+    \r
+    public String getResourceName() {\r
+        return resourceName;\r
+    }\r
+    \r
+    public void setResourceName(String resourceName) {\r
+        this.resourceName = resourceName;\r
+    }\r
+    \r
+    public String getDataType() {\r
+        return dataType;\r
+    }\r
+    \r
+    public void setDataType(String dataType) {\r
+        this.dataType = dataType;\r
+    }\r
+    \r
+    public String getEntrySchema() {\r
+        return entrySchema;\r
+    }\r
+    \r
+    public void setEntrySchema(String entrySchema) {\r
+        this.entrySchema = entrySchema;\r
+    }\r
+    \r
+    public String getResourceValue() {\r
+        return resourceValue;\r
+    }\r
+    \r
+    public void setResourceValue(String resourceValue) {\r
+        this.resourceValue = resourceValue;\r
+    }\r
+    \r
+    public String getSource() {\r
+        return source;\r
+    }\r
+    \r
+    public void setSource(String source) {\r
+        this.source = source;\r
+    }\r
+    \r
+    public String getStatus() {\r
+        return status;\r
+    }\r
+    \r
+    public void setStatus(String status) {\r
+        this.status = status;\r
+    }\r
+    \r
+    public String getMessage() {\r
+        return message;\r
+    }\r
+    \r
+    public void setMessage(String message) {\r
+        this.message = message;\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java
new file mode 100644 (file)
index 0000000..3ae6ad3
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.domain;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+import java.util.UUID;\r
+\r
+public class TransactionLog implements Serializable {\r
+    private static final long serialVersionUID = 1L;\r
+    \r
+    private String transactionLogId;\r
+    private String requestId;\r
+    private String messageType;\r
+    private Date creationDate;\r
+    private String message;\r
+    \r
+    public TransactionLog() {\r
+        \r
+    }\r
+    \r
+    public TransactionLog(String requestId, String messageType, String message) {\r
+        this.requestId = requestId;\r
+        this.messageType = messageType;\r
+        this.message = message;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+        StringBuilder buffer = new StringBuilder("[");\r
+        buffer.append("transactionLogId =" + transactionLogId);\r
+        buffer.append(", requestId =" + requestId);\r
+        buffer.append(", messageType =" + messageType);\r
+        buffer.append(", creationDate =" + creationDate);\r
+        buffer.append("]");\r
+        return buffer.toString();\r
+    }\r
+    \r
+    public String getTransactionLogId() {\r
+        return transactionLogId;\r
+    }\r
+    \r
+    public void setTransactionLogId(String transactionLogId) {\r
+        this.transactionLogId = transactionLogId;\r
+    }\r
+    \r
+    public String getRequestId() {\r
+        return requestId;\r
+    }\r
+    \r
+    public void setRequestId(String requestId) {\r
+        this.requestId = requestId;\r
+    }\r
+    \r
+    public String getMessageType() {\r
+        return messageType;\r
+    }\r
+    \r
+    public void setMessageType(String messageType) {\r
+        this.messageType = messageType;\r
+    }\r
+    \r
+    public Date getCreationDate() {\r
+        return creationDate;\r
+    }\r
+    \r
+    public void setCreationDate(Date creationDate) {\r
+        this.creationDate = creationDate;\r
+    }\r
+    \r
+    public String getMessage() {\r
+        return message;\r
+    }\r
+    \r
+    public void setMessage(String message) {\r
+        this.message = message;\r
+    }\r
+    \r
+    public String getUniqueId() {\r
+        return UUID.randomUUID().toString();\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java
new file mode 100644 (file)
index 0000000..e8f5817
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.service;\r
+\r
+import java.util.Map;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.data.adaptor.DataAdaptorConstants;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
+\r
+public class ConfigResourceNode implements SvcLogicJavaPlugin {\r
+    \r
+    private ConfigResourceService configResourceService;\r
+    \r
+    public ConfigResourceNode(ConfigResourceService configResourceService) {\r
+        this.configResourceService = configResourceService;\r
+    }\r
+    \r
+    public void saveConfigTransactionLog(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
+        String responsePrefix = inParams.get(DataAdaptorConstants.INPUT_PARAM_RESPONSE_PRIFIX);\r
+        try {\r
+            responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";\r
+            \r
+            String messageType = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE);\r
+            String message = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE);\r
+            String requestId = ctx.getAttribute("request-id");\r
+            \r
+            TransactionLog transactionLog = new TransactionLog();\r
+            \r
+            transactionLog.setMessage(message);\r
+            transactionLog.setMessageType(messageType);\r
+            transactionLog.setRequestId(requestId);\r
+            \r
+            configResourceService.save(transactionLog);\r
+            \r
+        } catch (Exception e) {\r
+            ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS,\r
+                    DataAdaptorConstants.OUTPUT_STATUS_FAILURE);\r
+            ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
+            throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage());\r
+        }\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java
new file mode 100644 (file)
index 0000000..f2b3fa7
--- /dev/null
@@ -0,0 +1,149 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.service;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
+\r
+public interface ConfigResourceService {\r
+    \r
+    /**\r
+     * Return NamedParameterJdbcTemplate object.\r
+     */\r
+    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
+     * query, expecting a result list.\r
+     * <p>\r
+     * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
+     * using the column name as the key).\r
+     *\r
+     * @param sql SQL query to execute\r
+     * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return a List that contains a Map per row\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue an update via a prepared statement, binding the given arguments.\r
+     *\r
+     * @param sql SQL containing named parameters\r
+     * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return the number of rows affected\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
+     */\r
+    public int update(String sql, Map<String, Object> param) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
+     * query, expecting a result list.\r
+     * <p>\r
+     * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
+     * using the column name as the key).\r
+     *\r
+     * @param sql SQL query to execute\r
+     * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return a List that contains a Map per row\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
+     * prepared statement, binding the given arguments.\r
+     *\r
+     * @param sql SQL containing bind parameters\r
+     * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return the number of rows affected\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
+     */\r
+    public int update(String sql, Object[] data) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
+     * binding the given arguments.\r
+     *\r
+     * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
+     */\r
+    public void save(TransactionLog transactionLog) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
+     * TransactionLog RowMapper.\r
+     *\r
+     * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
+     * query, mapping each row to a Java object via a ConfigResource RowMapper.\r
+     *\r
+     * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a\r
+     * prepared statement, binding the given arguments.\r
+     *\r
+     * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
+     *        corresponding SQL type)\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
+     */\r
+    public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
+     *\r
+     * @param key key mapped to a value\r
+     * @return the result string, containing mapped string value\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
+     */\r
+    public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
+    \r
+    /**\r
+     * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
+     * TransactionLog RowMapper.\r
+     *\r
+     * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
+     *        corresponding SQL type)\r
+     * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
+     *        the corresponding SQL type)\r
+     * @return the result List, containing mapped objects\r
+     * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
+     */\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
+            throws SvcLogicException;\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java
new file mode 100644 (file)
index 0000000..77fbbe1
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.data.adaptor.service;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.onap.ccsdk.config.data.adaptor.dao.ConfigPropertyMapDao;\r
+import org.onap.ccsdk.config.data.adaptor.dao.ConfigResourceDao;\r
+import org.onap.ccsdk.config.data.adaptor.dao.NamedQueryExecutorDao;\r
+import org.onap.ccsdk.config.data.adaptor.dao.QueryExecutorDao;\r
+import org.onap.ccsdk.config.data.adaptor.dao.TransactionLogDao;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ConfigResourceServiceImpl implements ConfigResourceService {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceServiceImpl.class);\r
+    private static final String CLASS_NAME = "ConfigResourceServiceImpl";\r
+    \r
+    private TransactionLogDao transactionLogDao;\r
+    private ConfigResourceDao configResourceDao;\r
+    private QueryExecutorDao queryExecutorDao;\r
+    private NamedQueryExecutorDao namedQueryExecutorDao;\r
+    private ConfigPropertyMapDao configPropertyMapDao;\r
+    \r
+    @SuppressWarnings("squid:S00107")\r
+    public ConfigResourceServiceImpl(TransactionLogDao transactionLogDao, ConfigResourceDao configResourceDao,\r
+            QueryExecutorDao queryExecutorDao, NamedQueryExecutorDao namedQueryExecutorDao,\r
+            ConfigPropertyMapDao configPropertyMapDao) {\r
+        \r
+        logger.info("{} Constuctor Initated...", CLASS_NAME);\r
+        this.transactionLogDao = transactionLogDao;\r
+        this.configResourceDao = configResourceDao;\r
+        this.queryExecutorDao = queryExecutorDao;\r
+        this.namedQueryExecutorDao = namedQueryExecutorDao;\r
+        this.configPropertyMapDao = configPropertyMapDao;\r
+    }\r
+    \r
+    @Override\r
+    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException {\r
+        return namedQueryExecutorDao.getNamedParameterJdbcTemplate();\r
+    }\r
+    \r
+    @Override\r
+    public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
+        return namedQueryExecutorDao.query(sql, parameters);\r
+    }\r
+    \r
+    @Override\r
+    public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
+        return namedQueryExecutorDao.update(sql, parameters);\r
+    }\r
+    \r
+    @Override\r
+    public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {\r
+        return queryExecutorDao.query(sql, data);\r
+    }\r
+    \r
+    @Override\r
+    public int update(String sql, Object[] data) throws SvcLogicException {\r
+        return queryExecutorDao.update(sql, data);\r
+    }\r
+    \r
+    @Override\r
+    public void save(TransactionLog transactionLog) throws SvcLogicException {\r
+        transactionLogDao.save(transactionLog);\r
+    }\r
+    \r
+    @Override\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
+        return transactionLogDao.getTransactionsByRequestId(requestId);\r
+    }\r
+    \r
+    @Override\r
+    public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
+            throws SvcLogicException {\r
+        return transactionLogDao.getTransactionsByRequestId(requestId, messageType);\r
+    }\r
+    \r
+    @Override\r
+    public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
+        return configResourceDao.findByConfigResource(configResource);\r
+    }\r
+    \r
+    @Override\r
+    public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException {\r
+        return configResourceDao.save(configResource);\r
+    }\r
+    \r
+    @Override\r
+    public String getConfigPropertyByKey(String key) throws SvcLogicException {\r
+        return configPropertyMapDao.getConfigPropertyByKey(key);\r
+    }\r
+    \r
+}\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
new file mode 100644 (file)
index 0000000..445f623
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  Copyright © 2017-2018 AT&T Intellectual Property.\r
+  \r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+  \r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+-->\r
+\r
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
+       xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
+       odl:use-default-for-reference-types="true">\r
+\r
+       <!-- Dependencies -->\r
+\r
+       <reference id="dataSource" interface="javax.sql.DataSource" />\r
+\r
+       <!-- Expose the Common Component Bean -->\r
+\r
+       <bean id="configResourceService"\r
+               class="org.onap.ccsdk.config.data.adaptor.service.ConfigResourceServiceImpl">\r
+               <argument ref="transactionLogDao" />\r
+               <argument ref="configResourceDao" />\r
+               <argument ref="queryExecutorDao" />\r
+               <argument ref="namedQueryExecutorDao" />\r
+               <argument ref="configPropertyMapDao" />\r
+       </bean>\r
+\r
+       <service ref="configResourceService"\r
+               interface="org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService" />\r
+\r
+       <!-- Data SourceInitialisation -->\r
+\r
+       <bean id="config.dataSource"\r
+               class="org.onap.ccsdk.config.data.adaptor.db.DataSourceWrap">\r
+               <argument ref="dataSource" />\r
+       </bean>\r
+\r
+       <bean id="jdbcTemplate"\r
+               class="org.springframework.jdbc.core.JdbcTemplate">\r
+               <property name="dataSource" ref="config.dataSource" />\r
+       </bean>\r
+\r
+       <bean id="namedParameterJdbcTemplate"\r
+               class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">\r
+               <argument ref="config.dataSource" />\r
+       </bean>\r
+\r
+       <!-- DAO Initialisation -->\r
+       <bean id="transactionLogDao"\r
+               class="org.onap.ccsdk.config.data.adaptor.dao.TransactionLogDaoImpl">\r
+               <argument ref="jdbcTemplate" />\r
+       </bean>\r
+\r
+       <bean id="configResourceDao"\r
+               class="org.onap.ccsdk.config.data.adaptor.dao.ConfigResourceDaoImpl">\r
+               <argument ref="jdbcTemplate" />\r
+       </bean>\r
+\r
+       <bean id="queryExecutorDao"\r
+               class="org.onap.ccsdk.config.data.adaptor.dao.QueryExecutorDaoImpl">\r
+               <argument ref="jdbcTemplate" />\r
+       </bean>\r
+\r
+       <bean id="namedQueryExecutorDao"\r
+               class="org.onap.ccsdk.config.data.adaptor.dao.NamedQueryExecutorDaoImpl">\r
+               <argument ref="namedParameterJdbcTemplate" />\r
+       </bean>\r
+\r
+       <bean id="configPropertyMapDao"\r
+               class="org.onap.ccsdk.config.data.adaptor.dao.ConfigPropertyMapDaoImpl">\r
+               <argument ref="jdbcTemplate" />\r
+       </bean>\r
+\r
+</blueprint>\r
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql
new file mode 100644 (file)
index 0000000..593f347
--- /dev/null
@@ -0,0 +1,106 @@
+-- -----------------------------------------------------\r
+-- Dropping tables ( One time )\r
+-- -----------------------------------------------------\r
+\r
+DROP TABLE sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA;\r
+DROP TABLE sdnctl.CONFIG_RESOURCE;\r
+DROP TABLE sdnctl.CONFIG_RESOURCE_RELATION;\r
+DROP TABLE sdnctl.CONFIG_TRANSACTION_LOG\r
+DROP TABLE sdnctl.CONFIG_PROPERTY_MAP\r
+\r
+\r
+-- -----------------------------------------------------\r
+-- table sdnctl.CONFIG_TRANSACTION_LOG\r
+-- -----------------------------------------------------\r
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_TRANSACTION_LOG (\r
+   config_transaction_log_id  VARCHAR(50) NOT NULL,\r
+   request_id                 VARCHAR(50)   NULL          DEFAULT NULL,\r
+   message_type               VARCHAR(100)  NULL          DEFAULT NULL,\r
+   creation_date              DATETIME      NOT NULL      DEFAULT CURRENT_TIMESTAMP,\r
+   message                           LONGTEXT      NULL          DEFAULT NULL,\r
+   PRIMARY KEY PK_CONFIG_TRANSACTION_LOG (config_transaction_log_id)\r
+   ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
+\r
+\r
+-- -----------------------------------------------------\r
+-- table sdnctl.CONFIG_RESOURCE\r
+-- -----------------------------------------------------\r
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE (\r
+   config_resource_id   VARCHAR(50)         NOT NULL,\r
+   resource_id          VARCHAR(50)   NOT NULL,\r
+   resource_type        VARCHAR(50)   NOT NULL,\r
+   service_template_name   VARCHAR(50)      NULL          DEFAULT NULL,\r
+   service_template_version   VARCHAR(50)      NULL          DEFAULT NULL,\r
+   template_name        VARCHAR(50)   NOT NULL,\r
+   recipe_name          VARCHAR(50)   NOT NULL,\r
+   request_id           VARCHAR(50)   NOT NULL,\r
+   resource_data        LONGTEXT      NULL          DEFAULT NULL,\r
+   mask_data            LONGTEXT      NULL          DEFAULT NULL,\r
+   created_date         DATETIME      NOT NULL      DEFAULT CURRENT_TIMESTAMP,\r
+   status               VARCHAR(20)   NOT NULL,\r
+   updated_by           VARCHAR(50)   NOT NULL,\r
+   PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_id),\r
+   INDEX IX_CONFIG_RESOURCE (created_date desc)\r
+   ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
+\r
+\r
+-- -----------------------------------------------------\r
+-- table sdnctl.CONFIG_RESOURCE_RELATION\r
+-- -----------------------------------------------------\r
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_RELATION (\r
+   config_resource_relation_id VARCHAR(50) NOT NULL,\r
+   resource_id VARCHAR(50) NOT NULL,\r
+   related_resource_id VARCHAR(50) NOT NULL,\r
+   relation_type VARCHAR(50) NOT NULL DEFAULT 'children',\r
+   created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
+   updated_by VARCHAR(50) NOT NULL,\r
+   PRIMARY KEY PK_CONFIG_RESOURCE_RELATION (config_resource_relation_id),\r
+   INDEX IX_CONFIG_RESOURCE_RELATION (created_date desc),\r
+   CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE1\r
+   FOREIGN KEY (resource_id)\r
+   REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
+   ON DELETE NO ACTION\r
+   ON UPDATE NO ACTION,\r
+   CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE2\r
+   FOREIGN KEY (related_resource_id)\r
+   REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
+   ON DELETE NO ACTION\r
+   ON UPDATE NO ACTION\r
+   ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
+\r
+\r
+-- -----------------------------------------------------\r
+-- table sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA\r
+-- -----------------------------------------------------\r
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA (\r
+   config_resource_assignment_data_id VARCHAR(50) NOT NULL,\r
+   config_resource_id    VARCHAR(50) NOT NULL,\r
+   version INT(11) NOT NULL,\r
+   updated_date    DATETIME         NOT NULL          DEFAULT CURRENT_TIMESTAMP,\r
+   updated_by      VARCHAR(50)    NOT NULL,   \r
+   template_key_name     VARCHAR(50)    NOT NULL,\r
+   resource_name   VARCHAR(50)    NOT NULL,\r
+   data_type       VARCHAR(100)    NOT NULL,\r
+   entry_schema    VARCHAR(100)    NULL DEFAULT NULL,\r
+   resource_value  LONGTEXT         NOT NULL,\r
+   source   VARCHAR(50)    NOT NULL,\r
+   status   VARCHAR(50)    NOT NULL,\r
+   message  LONGTEXT         NOT NULL,\r
+   PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_assignment_data_id),\r
+   INDEX IX_CONFIG_RESOURCE (updated_date desc),\r
+   CONSTRAINT FK_CONFIG_RESOURCE_ASSIGNMENT_DATA\r
+   FOREIGN KEY (config_resource_id)\r
+   REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
+   ON DELETE NO ACTION\r
+   ON UPDATE NO ACTION\r
+   ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
+\r
+\r
+-- -----------------------------------------------------\r
+-- table sdnctl.CONFIG_PROPERTY_MAP\r
+-- -----------------------------------------------------\r
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_PROPERTY_MAP (\r
+   reference_key  VARCHAR(100) NOT NULL,\r
+   reference_value  VARCHAR(250) NOT NULL,\r
+   CONSTRAINT PK_CONFIG_PROPERTY_MAP PRIMARY KEY (reference_key)\r
+   ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r