mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
* Created a utility js to hold the utility functions
* Created the UI APIs for mobile * Fixed a bug and changed the implementation to work with the properties Map instead of the List * Changed method signature and implementation to accept DeviceType for the conversion * UI level changes and license headers
This commit is contained in:
parent
a195844042
commit
93a82676e3
@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -113,13 +114,15 @@ public class DeviceManagerImpl implements DeviceManager {
|
|||||||
this.getDeviceDAO().getDevices(deviceTypeId);
|
this.getDeviceDAO().getDevices(deviceTypeId);
|
||||||
|
|
||||||
for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
|
for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
|
||||||
Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device);
|
DeviceType deviceType = this.deviceTypeDAO.getDeviceType(device.getDeviceTypeId());
|
||||||
DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil
|
Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, deviceType);
|
||||||
.createDeviceIdentifier(device, this.deviceTypeDAO
|
DeviceIdentifier deviceIdentifier =
|
||||||
.getDeviceType(device.getDeviceTypeId()));
|
DeviceManagementDAOUtil.createDeviceIdentifier(device, deviceType);
|
||||||
Device dmsDevice = dms.getDevice(deviceIdentifier);
|
Device dmsDevice = dms.getDevice(deviceIdentifier);
|
||||||
|
if (dmsDevice != null) {
|
||||||
convertedDevice.setProperties(dmsDevice.getProperties());
|
convertedDevice.setProperties(dmsDevice.getProperties());
|
||||||
convertedDevice.setFeatures(dmsDevice.getFeatures());
|
convertedDevice.setFeatures(dmsDevice.getFeatures());
|
||||||
|
}
|
||||||
devicesList.add(convertedDevice);
|
devicesList.add(convertedDevice);
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
|||||||
@ -34,9 +34,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public final class DeviceManagementDAOUtil {
|
public final class DeviceManagementDAOUtil {
|
||||||
|
|
||||||
@ -107,9 +105,10 @@ public final class DeviceManagementDAOUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param device - The DTO device object.
|
* @param device - The DTO device object.
|
||||||
|
* @param deviceType - The DeviceType object associated with the device
|
||||||
* @return A Business Object.
|
* @return A Business Object.
|
||||||
*/
|
*/
|
||||||
public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device){
|
public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device, DeviceType deviceType){
|
||||||
org.wso2.carbon.device.mgt.common.Device deviceBO =
|
org.wso2.carbon.device.mgt.common.Device deviceBO =
|
||||||
new org.wso2.carbon.device.mgt.common.Device();
|
new org.wso2.carbon.device.mgt.common.Device();
|
||||||
deviceBO.setDateOfEnrolment(device.getDateOfEnrollment());
|
deviceBO.setDateOfEnrolment(device.getDateOfEnrollment());
|
||||||
@ -117,6 +116,7 @@ public final class DeviceManagementDAOUtil {
|
|||||||
deviceBO.setDescription(device.getDescription());
|
deviceBO.setDescription(device.getDescription());
|
||||||
deviceBO.setDeviceIdentifier(device.getDeviceIdentificationId());
|
deviceBO.setDeviceIdentifier(device.getDeviceIdentificationId());
|
||||||
deviceBO.setDeviceTypeId(device.getDeviceTypeId());
|
deviceBO.setDeviceTypeId(device.getDeviceTypeId());
|
||||||
|
deviceBO.setType(deviceType.getName());
|
||||||
deviceBO.setName(device.getName());
|
deviceBO.setName(device.getName());
|
||||||
deviceBO.setId(device.getId());
|
deviceBO.setId(device.getId());
|
||||||
deviceBO.setOwner(device.getOwnerId());
|
deviceBO.setOwner(device.getOwnerId());
|
||||||
@ -126,21 +126,7 @@ public final class DeviceManagementDAOUtil {
|
|||||||
} else if (device.getStatus() == Status.INACTIVE) {
|
} else if (device.getStatus() == Status.INACTIVE) {
|
||||||
deviceBO.setStatus(false);
|
deviceBO.setStatus(false);
|
||||||
}
|
}
|
||||||
return null;
|
return deviceBO;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param devices - DTO Device Object list.
|
|
||||||
* @return converted Business Object list.
|
|
||||||
*/
|
|
||||||
public static List<org.wso2.carbon.device.mgt.common.Device> convertDevices(
|
|
||||||
List<Device> devices) {
|
|
||||||
List<org.wso2.carbon.device.mgt.common.Device> deviceBOList =
|
|
||||||
new ArrayList<org.wso2.carbon.device.mgt.common.Device>();
|
|
||||||
for (Device device : devices) {
|
|
||||||
deviceBOList.add(convertDevice(device));
|
|
||||||
}
|
|
||||||
return deviceBOList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
|
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*/
|
||||||
|
var utility = require("/modules/utility.js");
|
||||||
|
var deviceManagementService = utility.getDeviceManagementService();
|
||||||
|
var devices = deviceManagementService.getAllDevices("android");
|
||||||
|
var logger = new Log();
|
||||||
|
var deviceList = [];
|
||||||
|
for (i = 0; i < devices.size(); i++) {
|
||||||
|
var device = devices.get(i);
|
||||||
|
deviceList.push({
|
||||||
|
"identifier": device.getDeviceIdentifier(),
|
||||||
|
"name": device.getName(),
|
||||||
|
"ownership": device.getOwnership(),
|
||||||
|
"owner": device.getOwner(),
|
||||||
|
"deviceType": device.getType(),
|
||||||
|
"vendor": device.getProperties().get("vendor"),
|
||||||
|
"model": device.getProperties().get("model"),
|
||||||
|
"osVersion": device.getProperties().get("osVersion")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
print(deviceList);
|
||||||
|
%>
|
||||||
@ -1 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*/
|
||||||
//Init js to execute
|
//Init js to execute
|
||||||
|
var logger = new Log();
|
||||||
|
logger.debug("running debug");
|
||||||
|
var app_TENANT_CONFIGS = 'tenant.configs';
|
||||||
|
var app_carbon = require('carbon');
|
||||||
|
var app_configs = {
|
||||||
|
"HTTPS_URL": "https://localhost:9443"
|
||||||
|
};
|
||||||
|
|
||||||
|
var app_server = new app_carbon.server.Server({
|
||||||
|
tenanted: app_configs.tenanted,
|
||||||
|
url: app_configs.HTTPS_URL + '/admin'
|
||||||
|
});
|
||||||
|
application.put("SERVER", app_server);
|
||||||
|
application.put(app_TENANT_CONFIGS, {});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"welcomeFiles": ["pages/dashboard.jag"],
|
"welcomeFiles": ["pages/dashboard.jag"],
|
||||||
"initScripts": ["init.js"],
|
"initScripts": ["/init.js"],
|
||||||
"urlMappings": [
|
"urlMappings": [
|
||||||
{
|
{
|
||||||
"url": "/devices/*",
|
"url": "/devices/*",
|
||||||
@ -9,12 +9,16 @@
|
|||||||
{
|
{
|
||||||
"url": "/dashboard",
|
"url": "/dashboard",
|
||||||
"path": "/pages/dashboard.jag"
|
"path": "/pages/dashboard.jag"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/api/devices/mobile/*",
|
||||||
|
"path": "/api/mobile/device-api.jag"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"errorPages": {
|
"errorPages": {
|
||||||
"500": "/error500.jag",
|
"500": "/error500.jag",
|
||||||
"404": "/error404.jag",
|
"404": "/error404.jag",
|
||||||
"403": "/error403.jag"
|
"403": "/error403.jag "
|
||||||
},
|
},
|
||||||
"logLevel": "info"
|
"logLevel": "debug"
|
||||||
}
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//temporary
|
||||||
|
|
||||||
|
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext,
|
||||||
|
Class = java.lang.Class;
|
||||||
|
|
||||||
|
osgiService = function (clazz) {
|
||||||
|
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz));
|
||||||
|
};
|
||||||
|
var getDeviceManagementService= function(){
|
||||||
|
//server.authenticate("admin", "admin");
|
||||||
|
var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService');
|
||||||
|
//var realmService = null;
|
||||||
|
return realmService;
|
||||||
|
}
|
||||||
@ -1,5 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<%
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*/
|
||||||
var title="WSO2 CDM";
|
var title="WSO2 CDM";
|
||||||
%>
|
%>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -31,7 +48,7 @@ var title="WSO2 CDM";
|
|||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="devicepanel" class="tab-pane active" id="mobile">
|
<div role="devicepanel" class="tab-pane active" id="mobile">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="table-pagination" data-toggle="table" data-url="data2.json" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
<table id="table-pagination" data-toggle="table" data-url="/cdm/api/devices/mobile" data-query-params="queryParams" data-height="400" data-pagination="true" data-search="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-field="state" data-checkbox="true"></th>
|
<th data-field="state" data-checkbox="true"></th>
|
||||||
@ -39,7 +56,7 @@ var title="WSO2 CDM";
|
|||||||
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
<th data-field="name" data-align="center" data-sortable="true">Name</th>
|
||||||
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
<th data-field="owner" data-align="center" data-sortable="true">Owner</th>
|
||||||
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
<th data-field="ownership" data-align="center" data-sortable="true">Ownership</th>
|
||||||
<th data-field="deviceTypeId" data-align="center" data-sortable="true">Device Type</th>
|
<th data-field="deviceType" data-align="center" data-sortable="true">Device Type</th>
|
||||||
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
<th data-field="vendor" data-align="center" data-sortable="true">Vendor</th>
|
||||||
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
<th data-field="model" data-align="center" data-sortable="true">Model</th>
|
||||||
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
<th data-field="osVersion" data-align="center" data-sortable="true">OS Version</th>
|
||||||
|
|||||||
@ -1,5 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<%
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*/
|
||||||
var title="WSO2 CDM";
|
var title="WSO2 CDM";
|
||||||
%>
|
%>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user