mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Refactoring DAOs
This commit is contained in:
parent
6a18d7ab4c
commit
52b2739bee
@ -26,10 +26,8 @@ import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
|||||||
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.H2ApplicationDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.H2ApplicationDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.MySQLApplicationDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.MySQLApplicationDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.H2LifecycleStateDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.MySQLLifecycleStateDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.GenericPlatformDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.H2PlatformDAOImpl;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.MySQLPlatformDAOImpl;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
||||||
|
|
||||||
@ -68,9 +66,8 @@ public class DAOFactory {
|
|||||||
if (databaseEngine != null) {
|
if (databaseEngine != null) {
|
||||||
switch (databaseEngine) {
|
switch (databaseEngine) {
|
||||||
case Constants.DataBaseTypes.DB_TYPE_H2:
|
case Constants.DataBaseTypes.DB_TYPE_H2:
|
||||||
return new H2PlatformDAOImpl();
|
|
||||||
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
||||||
return new MySQLPlatformDAOImpl();
|
return new GenericPlatformDAOImpl();
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
||||||
}
|
}
|
||||||
@ -82,9 +79,8 @@ public class DAOFactory {
|
|||||||
if (databaseEngine != null) {
|
if (databaseEngine != null) {
|
||||||
switch (databaseEngine) {
|
switch (databaseEngine) {
|
||||||
case Constants.DataBaseTypes.DB_TYPE_H2:
|
case Constants.DataBaseTypes.DB_TYPE_H2:
|
||||||
return new H2LifecycleStateDAOImpl();
|
|
||||||
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
||||||
return new MySQLLifecycleStateDAOImpl();
|
return new GenericLifecycleStateImpl();
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, 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.application.mgt.core.dao.impl.lifecyclestate;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
|
||||||
|
|
||||||
public abstract class AbstractLifecycleStateDAOImpl extends AbstractDAOImpl implements LifecycleStateDAO {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -19,10 +19,10 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate;
|
package org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate;
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Platform;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.AbstractPlatformDAOImpl;
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -30,7 +30,7 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class MySQLLifecycleStateDAOImpl extends AbstractLifecycleStateDAOImpl {
|
public class GenericLifecycleStateImpl extends AbstractDAOImpl implements LifecycleStateDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LifecycleState getLifeCycleStateByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
public LifecycleState getLifeCycleStateByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
||||||
@ -72,5 +72,4 @@ public class MySQLLifecycleStateDAOImpl extends AbstractLifecycleStateDAOImpl {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, 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.application.mgt.core.dao.impl.lifecyclestate;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.Platform;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.AbstractPlatformDAOImpl;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
||||||
|
|
||||||
public class H2LifecycleStateDAOImpl extends AbstractLifecycleStateDAOImpl {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LifecycleState getLifeCycleStateByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, 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.application.mgt.core.dao.impl.platform;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.Platform;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public abstract class AbstractPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -21,7 +21,9 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.platform;
|
|||||||
import org.wso2.carbon.device.application.mgt.common.Platform;
|
import org.wso2.carbon.device.application.mgt.common.Platform;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.PlatformManagementDAOException;
|
import org.wso2.carbon.device.application.mgt.core.exception.PlatformManagementDAOException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
||||||
@ -33,7 +35,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MySQLPlatformDAOImpl extends AbstractPlatformDAOImpl {
|
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Platform getPlatformByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
public Platform getPlatformByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
||||||
@ -347,4 +349,4 @@ public class MySQLPlatformDAOImpl extends AbstractPlatformDAOImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, 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.application.mgt.core.dao.impl.platform;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.Platform;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.PlatformManagementDAOException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class H2PlatformDAOImpl extends AbstractPlatformDAOImpl {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Platform getPlatformByIdentifier(String identifier) throws ApplicationManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(String tenantDomain, Platform platform) throws PlatformManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregister(String tenantDomain, String platformCode) throws PlatformManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addMapping(String tenantDomain, List<String> platformCode) throws PlatformManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeMapping(String tenantDomain, String platformCode) throws PlatformManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Platform> getPlatforms(String tenantDomain) throws PlatformManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Platform getPlatform(String tenantDomain, String platformCode) throws PlatformManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user