forked from community/device-mgt-core
parent
a888cf39c0
commit
274aa0ecd3
@ -1,15 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.analytics.dashboard;
|
package org.wso2.carbon.device.mgt.analytics.dashboard;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To be updated...
|
* To be updated...
|
||||||
*/
|
*/
|
||||||
public interface GadgetDataService {
|
public interface GadgetDataService {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int getTotalDeviceCount(Map<String, Object> filters);
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int getActiveDeviceCount();
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int getInactiveDeviceCount();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int getTotalFilteredDeviceCount(String[] filters);
|
int getRemovedDeviceCount();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int getNonCompliantDeviceCount(String[] filters);
|
int getNonCompliantDeviceCount();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int getUnmonitoredDeviceCount(String[] filters);
|
int getUnmonitoredDeviceCount();
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.analytics.dashboard.internal;
|
package org.wso2.carbon.device.mgt.analytics.dashboard.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
|
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
|
||||||
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOException;
|
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOException;
|
||||||
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
|
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To be updated...
|
* To be updated...
|
||||||
*/
|
*/
|
||||||
class GadgetDataServiceImpl implements GadgetDataService {
|
class GadgetDataServiceImpl implements GadgetDataService {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private static final Log log = LogFactory.getLog(GadgetDataServiceImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalFilteredDeviceCount(String[] filters) {
|
public int getTotalDeviceCount(Map<String, Object> filters) {
|
||||||
// default
|
int totalDeviceCount;
|
||||||
int totalFilteredDeviceCount = -1;
|
|
||||||
try {
|
try {
|
||||||
totalFilteredDeviceCount = GadgetDataServiceDAOFactory.
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
getGadgetDataServiceDAO().getTotalFilteredDeviceCount(filters);
|
totalDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
} catch (GadgetDataServiceDAOException e) {
|
getGadgetDataServiceDAO().getTotalDeviceCount(filters);
|
||||||
return totalFilteredDeviceCount;
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
totalDeviceCount = -1;
|
||||||
|
return totalDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
}
|
}
|
||||||
return totalFilteredDeviceCount;
|
return totalDeviceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNonCompliantDeviceCount(String[] filters) {
|
public int getActiveDeviceCount() {
|
||||||
return GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getNonCompliantDeviceCount(filters);
|
int activeDeviceCount;
|
||||||
|
try {
|
||||||
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
|
activeDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
|
getGadgetDataServiceDAO().getActiveDeviceCount();
|
||||||
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
activeDeviceCount = -1;
|
||||||
|
return activeDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return activeDeviceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUnmonitoredDeviceCount(String[] filters) {
|
public int getInactiveDeviceCount() {
|
||||||
return GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getUnmonitoredDeviceCount(filters);
|
int inactiveDeviceCount;
|
||||||
|
try {
|
||||||
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
|
inactiveDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
|
getGadgetDataServiceDAO().getInactiveDeviceCount();
|
||||||
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
inactiveDeviceCount = -1;
|
||||||
|
return inactiveDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return inactiveDeviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRemovedDeviceCount() {
|
||||||
|
int removedDeviceCount;
|
||||||
|
try {
|
||||||
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
|
removedDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
|
getGadgetDataServiceDAO().getRemovedDeviceCount();
|
||||||
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
removedDeviceCount = -1;
|
||||||
|
return removedDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
}
|
}
|
||||||
|
return removedDeviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNonCompliantDeviceCount() {
|
||||||
|
int nonCompliantDeviceCount;
|
||||||
|
try {
|
||||||
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
|
nonCompliantDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
|
getGadgetDataServiceDAO().getNonCompliantDeviceCount();
|
||||||
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
nonCompliantDeviceCount = -1;
|
||||||
|
return nonCompliantDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return nonCompliantDeviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getUnmonitoredDeviceCount() {
|
||||||
|
int unmonitoredDeviceCount;
|
||||||
|
try {
|
||||||
|
GadgetDataServiceDAOFactory.openConnection();
|
||||||
|
unmonitoredDeviceCount = GadgetDataServiceDAOFactory.
|
||||||
|
getGadgetDataServiceDAO().getUnmonitoredDeviceCount();
|
||||||
|
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||||
|
unmonitoredDeviceCount = -1;
|
||||||
|
return unmonitoredDeviceCount;
|
||||||
|
} finally {
|
||||||
|
GadgetDataServiceDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return unmonitoredDeviceCount;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue