Correction to the dbscripts location path of IoTDevices, which is searched for when -Dsetup property is set

Shabirmean 9 years ago
parent 3b08c2d11f
commit cd4d90563a

@ -16,23 +16,7 @@
* under the License.
*/
package org.wso2.carbon.device.mgt.iot.analytics.statistics;/*
*Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*WSO2 Inc. licenses this file to you under the Apache License,
*Version 2.0 (the "License"); you may not use this file except
*in compliance with the License.
*You may obtain a copy of the License at
*
*http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
*KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
package org.wso2.carbon.device.mgt.iot.analytics.statistics;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@ -104,7 +104,7 @@ public class IotDeviceManagementServiceComponent {
IotDeviceManagementDAOUtil
.setupIotDeviceManagementSchema(
IotDeviceManagementDAOFactory.getDataSourceMap
().get(pluginType));
().get(pluginType), pluginType);
}
} catch (IotDeviceMgtPluginException e) {
log.error(

@ -70,10 +70,10 @@ public class IotDeviceManagementDAOUtil {
*
* @param dataSource Iot data source
*/
public static void setupIotDeviceManagementSchema(DataSource dataSource) throws
public static void setupIotDeviceManagementSchema(DataSource dataSource, String pluginType) throws
IotDeviceMgtPluginException {
IotDeviceManagementSchemaInitializer initializer =
new IotDeviceManagementSchemaInitializer(dataSource);
new IotDeviceManagementSchemaInitializer(dataSource, pluginType);
log.info("Initializing iot device management repository database schema");
try {
initializer.createRegistryDatabase();

@ -40,18 +40,26 @@ public final class IotDeviceManagementSchemaInitializer extends DatabaseCreator
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator
+ IotPluginConstants.IOT_DB_SCRIPTS_FOLDER +
File.separator + "plugins" + File.separator;
private String pluginType;
public IotDeviceManagementSchemaInitializer(DataSource dataSource) {
public String getPluginType() {
return pluginType;
}
public IotDeviceManagementSchemaInitializer(DataSource dataSource, String pType) {
super(dataSource);
this.pluginType = pType;
}
protected String getDbScriptLocation(String databaseType) {
String scriptName = databaseType + ".sql";
String scriptLocation = setupSQLScriptBaseLocation + this.getPluginType() + File.separator + scriptName;
if (log.isDebugEnabled()) {
log.debug("Loading database script from :" + scriptName);
log.debug("Loading database script from :" + scriptLocation);
}
//TODO:test
return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
// return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
return scriptLocation;
}
}

Loading…
Cancel
Save