forked from community/device-mgt-core
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into merge-master
# Conflicts: # components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java # components/apimgt-extensions/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java # components/certificate-mgt/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml # components/device-mgt-extensions/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/Profile.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ProfileFeature.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Policy.java # components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Profile.java # components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/ProcessorImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml # components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationProcessor.java # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/ExtendedFileProtocolIteratorFactory.java # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/ExtendedIteratorFactory.java # components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error400.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error401.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error403.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error404.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error405.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error500.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js # components/device-mgt/pom.xml # components/email-sender/org.wso2.carbon.email.sender.core/pom.xml # components/email-sender/pom.xml # components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml # components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml # components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml # components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml # components/identity-extensions/dynamic-client-registration/pom.xml # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java # components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml # components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml # components/identity-extensions/pom.xml # components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml # components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml # components/policy-mgt/pom.xml # components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml # components/webapp-authenticator-framework/pom.xml # features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml # features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml # features/apimgt-extensions/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml # features/certificate-mgt/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml # features/device-mgt-extensions/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml # features/device-mgt/pom.xml # features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml # features/dynamic-client-registration/pom.xml # features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml # features/email-sender/pom.xml # features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml # features/jwt-client/pom.xml # features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml # features/oauth-extensions/pom.xml # features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml # features/policy-mgt/pom.xml # features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml # features/webapp-authenticator-framework/pom.xml # pom.xml4.x.x
parent
dde094ecf8
commit
83aea1fd01
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.core.search.mgt.dao;
|
|
||||||
|
|
||||||
|
|
||||||
public interface SearchDAO {
|
|
||||||
|
|
||||||
// List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException;
|
|
||||||
//
|
|
||||||
// List<Device> searchDevicePropertyTable(String query) throws SearchDAOException;
|
|
||||||
|
|
||||||
}
|
|
@ -1,238 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.core.search.mgt.dao.impl;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO;
|
|
||||||
|
|
||||||
|
|
||||||
public class SearchDAOImpl implements SearchDAO {
|
|
||||||
//
|
|
||||||
// private static final Log log = LogFactory.getLog(SearchDAOImpl.class);
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<Device> searchDeviceDetailsTable(String query) throws SearchDAOException {
|
|
||||||
// if (log.isDebugEnabled()) {
|
|
||||||
// log.debug("Query : " + query);
|
|
||||||
// }
|
|
||||||
// Connection conn;
|
|
||||||
// PreparedStatement stmt = null;
|
|
||||||
// ResultSet rs;
|
|
||||||
// List<Device> devices = new ArrayList<>();
|
|
||||||
// Map<Integer, Integer> devs = new HashMap<>();
|
|
||||||
// try {
|
|
||||||
// conn = this.getConnection();
|
|
||||||
// stmt = conn.prepareStatement(query);
|
|
||||||
// rs = stmt.executeQuery();
|
|
||||||
// while (rs.next()) {
|
|
||||||
// if (!devs.containsKey(rs.getInt("ID"))) {
|
|
||||||
// Device device = new Device();
|
|
||||||
// device.setId(rs.getInt("ID"));
|
|
||||||
// device.setDescription(rs.getString("DESCRIPTION"));
|
|
||||||
// device.setName("NAME");
|
|
||||||
// device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
//
|
|
||||||
// DeviceIdentifier identifier = new DeviceIdentifier();
|
|
||||||
// identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
// identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
//
|
|
||||||
// DeviceInfo deviceInfo = new DeviceInfo();
|
|
||||||
// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
||||||
// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
||||||
// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
||||||
// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
||||||
// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
||||||
// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
||||||
// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
||||||
// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
||||||
// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
||||||
// deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
||||||
// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
|
||||||
// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
||||||
// deviceInfo.setSsid(rs.getString("SSID"));
|
|
||||||
// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
||||||
// deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
||||||
// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
||||||
//
|
|
||||||
// DeviceLocation deviceLocation = new DeviceLocation();
|
|
||||||
// deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
||||||
// deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
||||||
// deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
||||||
// deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
||||||
// deviceLocation.setCity(rs.getString("CITY"));
|
|
||||||
// deviceLocation.setState(rs.getString("STATE"));
|
|
||||||
// deviceLocation.setZip(rs.getString("ZIP"));
|
|
||||||
// deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
||||||
// deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
||||||
// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
||||||
//
|
|
||||||
// deviceInfo.setLocation(deviceLocation);
|
|
||||||
// device.setDeviceInfo(deviceInfo);
|
|
||||||
// devices.add(device);
|
|
||||||
// devs.put(device.getId(), device.getId());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new SearchDAOException("Error occurred while acquiring the device details.", e);
|
|
||||||
// } finally {
|
|
||||||
// DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.fillPropertiesOfDevices(devices);
|
|
||||||
//
|
|
||||||
// if (log.isDebugEnabled()) {
|
|
||||||
// log.debug("Number of the device returned from the query : " + devices.size());
|
|
||||||
// }
|
|
||||||
// return devices;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<Device> searchDevicePropertyTable(String query) throws SearchDAOException {
|
|
||||||
// if (log.isDebugEnabled()) {
|
|
||||||
// log.debug("Query : " + query);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Connection conn;
|
|
||||||
// PreparedStatement stmt = null;
|
|
||||||
// ResultSet rs;
|
|
||||||
// List<Device> devices = new ArrayList<>();
|
|
||||||
// Map<Integer, Integer> devs = new HashMap<>();
|
|
||||||
// try {
|
|
||||||
// conn = this.getConnection();
|
|
||||||
// stmt = conn.prepareStatement(query);
|
|
||||||
// rs = stmt.executeQuery();
|
|
||||||
// while (rs.next()) {
|
|
||||||
// if (!devs.containsKey(rs.getInt("ID"))) {
|
|
||||||
// Device device = new Device();
|
|
||||||
// device.setId(rs.getInt("ID"));
|
|
||||||
// device.setDescription(rs.getString("DESCRIPTION"));
|
|
||||||
// device.setName(rs.getString("NAME"));
|
|
||||||
// device.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
//
|
|
||||||
// DeviceIdentifier identifier = new DeviceIdentifier();
|
|
||||||
// identifier.setType(rs.getString("DEVICE_TYPE_NAME"));
|
|
||||||
// identifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
|
||||||
//
|
|
||||||
// DeviceInfo deviceInfo = new DeviceInfo();
|
|
||||||
// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY"));
|
|
||||||
// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL"));
|
|
||||||
// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE"));
|
|
||||||
// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE"));
|
|
||||||
// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL"));
|
|
||||||
// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY"));
|
|
||||||
// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
||||||
// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY"));
|
|
||||||
// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY"));
|
|
||||||
// deviceInfo.setOsVersion(rs.getString("OS_VERSION"));
|
|
||||||
// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE"));
|
|
||||||
// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN"));
|
|
||||||
// deviceInfo.setSsid(rs.getString("SSID"));
|
|
||||||
// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY"));
|
|
||||||
// deviceInfo.setVendor(rs.getString("VENDOR"));
|
|
||||||
// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP")));
|
|
||||||
//
|
|
||||||
// DeviceLocation deviceLocation = new DeviceLocation();
|
|
||||||
// deviceLocation.setLatitude(rs.getDouble("LATITUDE"));
|
|
||||||
// deviceLocation.setLongitude(rs.getDouble("LONGITUDE"));
|
|
||||||
// deviceLocation.setStreet1(rs.getString("STREET1"));
|
|
||||||
// deviceLocation.setStreet2(rs.getString("STREET2"));
|
|
||||||
// deviceLocation.setCity(rs.getString("CITY"));
|
|
||||||
// deviceLocation.setState(rs.getString("STATE"));
|
|
||||||
// deviceLocation.setZip(rs.getString("ZIP"));
|
|
||||||
// deviceLocation.setCountry(rs.getString("COUNTRY"));
|
|
||||||
// deviceLocation.setDeviceId(rs.getInt("ID"));
|
|
||||||
// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP")));
|
|
||||||
//
|
|
||||||
// deviceInfo.setLocation(deviceLocation);
|
|
||||||
// device.setDeviceInfo(deviceInfo);
|
|
||||||
// devices.add(device);
|
|
||||||
// devs.put(device.getId(), device.getId());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new SearchDAOException("Error occurred while aquiring the device details.", e);
|
|
||||||
// } finally {
|
|
||||||
// DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.fillPropertiesOfDevices(devices);
|
|
||||||
//
|
|
||||||
// if (log.isDebugEnabled()) {
|
|
||||||
// log.debug("Number of the device returned from the query : " + devices.size());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return devices;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private Connection getConnection() throws SQLException {
|
|
||||||
// return DeviceManagementDAOFactory.getConnection();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private List<Device> fillPropertiesOfDevices(List<Device> devices) throws SearchDAOException {
|
|
||||||
// if (devices.isEmpty()) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Connection conn;
|
|
||||||
// PreparedStatement stmt;
|
|
||||||
// ResultSet rs;
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// conn = this.getConnection();
|
|
||||||
// String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (?) ORDER BY DEVICE_ID ;";
|
|
||||||
// stmt = conn.prepareStatement(query);
|
|
||||||
// if (conn.getMetaData().getDatabaseProductName().contains("H2") ||
|
|
||||||
// conn.getMetaData().getDatabaseProductName().contains("MySQL")) {
|
|
||||||
// String inData = Utils.getDeviceIdsAsString(devices);
|
|
||||||
// stmt.setString(1, inData);
|
|
||||||
// } else {
|
|
||||||
// Array array = conn.createArrayOf("INT", Utils.getArrayOfDeviceIds(devices));
|
|
||||||
// stmt.setArray(1, array);
|
|
||||||
// }
|
|
||||||
// rs = stmt.executeQuery();
|
|
||||||
//
|
|
||||||
// DeviceInfo dInfo;
|
|
||||||
// while (rs.next()) {
|
|
||||||
// dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID"));
|
|
||||||
// dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD"));
|
|
||||||
// }
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new SearchDAOException("Error occurred while retrieving the device properties.", e);
|
|
||||||
// }
|
|
||||||
// return devices;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private DeviceInfo getDeviceInfo(List<Device> devices, int deviceId) {
|
|
||||||
// for (Device device : devices) {
|
|
||||||
// if (device.getId() == deviceId) {
|
|
||||||
// if (device.getDeviceInfo() == null) {
|
|
||||||
// device.setDeviceInfo(new DeviceInfo());
|
|
||||||
// }
|
|
||||||
// return device.getDeviceInfo();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,183 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.core.search;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.search.Condition;
|
|
||||||
import org.wso2.carbon.device.mgt.common.search.SearchContext;
|
|
||||||
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
|
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
|
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
|
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SearchDevice extends BaseDeviceManagementTest {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DeviceDetails.class);
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Override
|
|
||||||
public void init() throws Exception {
|
|
||||||
DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl();
|
|
||||||
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void searchDeviceDetails() throws Exception {
|
|
||||||
|
|
||||||
SearchContext context = new SearchContext();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
Condition cond = new Condition();
|
|
||||||
cond.setKey("BATTERY_VOLTAGE");
|
|
||||||
cond.setOperator("=");
|
|
||||||
cond.setValue("40");
|
|
||||||
cond.setState(Condition.State.AND);
|
|
||||||
conditions.add(cond);
|
|
||||||
|
|
||||||
// Condition cond2 = new Condition();
|
|
||||||
// cond2.setKey("CPU_USAGE");
|
|
||||||
// cond2.setOperator(">");
|
|
||||||
// cond2.setValue("40");
|
|
||||||
// cond2.setState(Condition.State.OR);
|
|
||||||
// conditions.add(cond2);
|
|
||||||
//
|
|
||||||
// Condition cond3 = new Condition();
|
|
||||||
// cond3.setKey("LOCATION");
|
|
||||||
// cond3.setOperator("=");
|
|
||||||
// cond3.setValue("Colombo");
|
|
||||||
// cond3.setState(Condition.State.AND);
|
|
||||||
// conditions.add(cond3);
|
|
||||||
|
|
||||||
context.setConditions(conditions);
|
|
||||||
|
|
||||||
SearchManagerService service = new SearchManagerServiceImpl();
|
|
||||||
List<Device> devices = service.search(context);
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String bbbb = gson.toJson(devices);
|
|
||||||
log.info(bbbb);
|
|
||||||
|
|
||||||
|
|
||||||
for (Device device : devices) {
|
|
||||||
log.debug(device.getDescription());
|
|
||||||
log.debug(device.getDeviceIdentifier());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void doValidLocationSearch() throws Exception {
|
|
||||||
|
|
||||||
SearchContext context = new SearchContext();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
|
|
||||||
Condition cond = new Condition();
|
|
||||||
cond.setKey("LOCATION");
|
|
||||||
cond.setOperator("=");
|
|
||||||
cond.setValue("Karan");
|
|
||||||
cond.setState(Condition.State.AND);
|
|
||||||
conditions.add(cond);
|
|
||||||
|
|
||||||
context.setConditions(conditions);
|
|
||||||
|
|
||||||
SearchManagerService service = new SearchManagerServiceImpl();
|
|
||||||
List<Device> devices = service.search(context);
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String bbbb = gson.toJson(devices);
|
|
||||||
log.info("Valid Search " + bbbb);
|
|
||||||
|
|
||||||
|
|
||||||
for (Device device : devices) {
|
|
||||||
log.debug(device.getDescription());
|
|
||||||
log.debug(device.getDeviceIdentifier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void doInvalidLocationSearch() throws Exception {
|
|
||||||
|
|
||||||
SearchContext context = new SearchContext();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
|
|
||||||
Condition cond = new Condition();
|
|
||||||
cond.setKey("LOCATION");
|
|
||||||
cond.setOperator("=");
|
|
||||||
cond.setValue("Colombo");
|
|
||||||
cond.setState(Condition.State.AND);
|
|
||||||
conditions.add(cond);
|
|
||||||
|
|
||||||
context.setConditions(conditions);
|
|
||||||
|
|
||||||
SearchManagerService service = new SearchManagerServiceImpl();
|
|
||||||
List<Device> devices = service.search(context);
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String bbbb = gson.toJson(devices);
|
|
||||||
log.info("Invalid Search " + bbbb);
|
|
||||||
|
|
||||||
|
|
||||||
for (Device device : devices) {
|
|
||||||
log.debug(device.getDescription());
|
|
||||||
log.debug(device.getDeviceIdentifier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void doStringSearch() throws Exception {
|
|
||||||
|
|
||||||
SearchContext context = new SearchContext();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
|
|
||||||
Condition cond = new Condition();
|
|
||||||
cond.setKey("deviceModel");
|
|
||||||
cond.setOperator("=");
|
|
||||||
cond.setValue("SM-T520");
|
|
||||||
cond.setState(Condition.State.AND);
|
|
||||||
conditions.add(cond);
|
|
||||||
|
|
||||||
context.setConditions(conditions);
|
|
||||||
|
|
||||||
SearchManagerService service = new SearchManagerServiceImpl();
|
|
||||||
List<Device> devices = service.search(context);
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String bbbb = gson.toJson(devices);
|
|
||||||
log.info("Invalid Search " + bbbb);
|
|
||||||
|
|
||||||
|
|
||||||
for (Device device : devices) {
|
|
||||||
log.debug(device.getDescription());
|
|
||||||
log.debug(device.getDeviceIdentifier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.core.search.util;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
||||||
import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Utils {
|
|
||||||
|
|
||||||
public static DeviceInfo getDeviceInfo() {
|
|
||||||
|
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
|
||||||
|
|
||||||
deviceInfo.setIMSI("e6f236ac82537a8e");
|
|
||||||
deviceInfo.setSsid("FAFDA");
|
|
||||||
|
|
||||||
|
|
||||||
deviceInfo.setAvailableRAMMemory(1.24);
|
|
||||||
deviceInfo.setBatteryLevel(27.3);
|
|
||||||
deviceInfo.setConnectionType("GSM");
|
|
||||||
deviceInfo.setCpuUsage(82.34);
|
|
||||||
deviceInfo.setDeviceModel("SM-T520");
|
|
||||||
deviceInfo.setExternalAvailableMemory(2.45);
|
|
||||||
deviceInfo.setExternalTotalMemory(16.23);
|
|
||||||
deviceInfo.setIMEI("e6f236ac82537a8e");
|
|
||||||
deviceInfo.setIMSI("GT-0WDA");
|
|
||||||
deviceInfo.setInternalAvailableMemory(3.56);
|
|
||||||
deviceInfo.setInternalTotalMemory(7.89);
|
|
||||||
deviceInfo.setMobileSignalStrength(0.67);
|
|
||||||
deviceInfo.setOperator("Dialog");
|
|
||||||
deviceInfo.setOsVersion("Lolipop");
|
|
||||||
deviceInfo.setOsBuildDate("1467366458");
|
|
||||||
deviceInfo.setPluggedIn(true);
|
|
||||||
deviceInfo.setSsid("SSSSSS");
|
|
||||||
deviceInfo.setTotalRAMMemory(4.00);
|
|
||||||
deviceInfo.setVendor("SAMSUNG");
|
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> propertyMap = new HashMap<>();
|
|
||||||
|
|
||||||
propertyMap.put("BATTERY_VOLTAGE", "40");
|
|
||||||
propertyMap.put("BATTERY_HEALTH", "Good");
|
|
||||||
propertyMap.put("BATTERY_STATUS", "SWElLED");
|
|
||||||
propertyMap.put("LOW_MEMORY", "false");
|
|
||||||
propertyMap.put("MEMORY_THRESHOLD", "100663296");
|
|
||||||
propertyMap.put("CPU_IOW", "12");
|
|
||||||
propertyMap.put("CPU_IRQ", "1");
|
|
||||||
|
|
||||||
deviceInfo.setDeviceDetailsMap(propertyMap);
|
|
||||||
|
|
||||||
return deviceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static DeviceLocation getSampleDeviceLocation(){
|
|
||||||
|
|
||||||
|
|
||||||
DeviceLocation deviceLocation = new DeviceLocation();
|
|
||||||
deviceLocation.setDeviceIdentifier(Utils.getDeviceIdentifier());
|
|
||||||
deviceLocation.setLatitude(76.2422);
|
|
||||||
deviceLocation.setLongitude(81.43);
|
|
||||||
deviceLocation.setStreet1("4");
|
|
||||||
deviceLocation.setStreet2("Isuru Uyana");
|
|
||||||
deviceLocation.setCity("Karanadeniya");
|
|
||||||
deviceLocation.setState("Karandeniya");
|
|
||||||
deviceLocation.setZip("80360");
|
|
||||||
deviceLocation.setCountry("Sri Lanka");
|
|
||||||
deviceLocation.setDeviceId(1);
|
|
||||||
|
|
||||||
return deviceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DeviceIdentifier getDeviceIdentifier(){
|
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setType(TestDataHolder.TEST_DEVICE_TYPE);
|
|
||||||
deviceIdentifier.setId("12345");
|
|
||||||
|
|
||||||
return deviceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue