mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
commit
6922a8693f
@ -18,18 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||||
|
|
||||||
import io.swagger.annotations.SwaggerDefinition;
|
import io.swagger.annotations.*;
|
||||||
import io.swagger.annotations.Info;
|
import org.apache.axis2.transport.http.HTTPConstants;
|
||||||
import io.swagger.annotations.ExtensionProperty;
|
|
||||||
import io.swagger.annotations.Extension;
|
|
||||||
import io.swagger.annotations.Tag;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
@ -61,6 +54,12 @@ import javax.ws.rs.core.Response;
|
|||||||
description = "View Users",
|
description = "View Users",
|
||||||
key = "perm:admin-users:view",
|
key = "perm:admin-users:view",
|
||||||
permissions = {"/device-mgt/users/manage"}
|
permissions = {"/device-mgt/users/manage"}
|
||||||
|
),
|
||||||
|
@Scope(
|
||||||
|
name = "Delete Users Device Information",
|
||||||
|
description = "Delete users device details",
|
||||||
|
key = "perm:admin-users:remove",
|
||||||
|
permissions = {"/device-mgt/users/manage"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -127,4 +126,131 @@ public interface UserManagementAdminService {
|
|||||||
value = "Credential.",
|
value = "Credential.",
|
||||||
required = true) PasswordResetWrapper credentials);
|
required = true) PasswordResetWrapper credentials);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Path("/{username}/devices")
|
||||||
|
@DELETE
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = HTTPConstants.HEADER_DELETE,
|
||||||
|
value = "Delete a users associated devices.",
|
||||||
|
notes = "If you wish to remove an device details to comply with the privacy requirements, can be done with " +
|
||||||
|
"this resource.",
|
||||||
|
tags = "Device details remove",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "OK. \n Users devices and details has been deleted successfully.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. \n Empty body because the client has already the latest version of " +
|
||||||
|
"the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Group not found.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while removing the group.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response deleteDeviceOfUser(@ApiParam(
|
||||||
|
name = "username",
|
||||||
|
value = "Username of the users devices to be deleted.",
|
||||||
|
required = true)
|
||||||
|
@PathParam("username") String username);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//device remove request would looks like follows
|
||||||
|
//DELETE devices/type/virtual_firealarm/id/us06ww93auzp
|
||||||
|
@DELETE
|
||||||
|
@Path("/type/{device-type}/id/{device-id}")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "DELETE",
|
||||||
|
value = "Remove the information of device specified by device id",
|
||||||
|
notes = "Returns the status of the deleted device information.",
|
||||||
|
tags = "Device details remove privacy compliance",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deleted the device information.",
|
||||||
|
response = Device.class,
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified the last time.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 304,
|
||||||
|
message = "Not Modified. Empty body because the client already has the latest " +
|
||||||
|
"version of the requested resource."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 404,
|
||||||
|
message = "Not Found. \n No device is found under the provided type and id.",
|
||||||
|
response = ErrorResponse.class),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n " +
|
||||||
|
"Server error occurred while retrieving information requested device.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response deleteDevice(
|
||||||
|
@ApiParam(
|
||||||
|
name = "device-type",
|
||||||
|
value = "The device type, such as ios, android or windows.",
|
||||||
|
required = true)
|
||||||
|
@PathParam("device-type")
|
||||||
|
@Size(max = 45)
|
||||||
|
String deviceType,
|
||||||
|
@ApiParam(
|
||||||
|
name = "device-id",
|
||||||
|
value = "The device identifier of the device.",
|
||||||
|
required = true)
|
||||||
|
@PathParam("device-id")
|
||||||
|
@Size(max = 45)
|
||||||
|
String deviceId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,9 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
|
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.netbeans.lib.cvsclient.commandLine.command.log;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -32,16 +40,45 @@ import javax.ws.rs.core.Response;
|
|||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public class UserManagementAdminServiceImpl implements UserManagementAdminService {
|
public class UserManagementAdminServiceImpl implements UserManagementAdminService {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(UserManagementAdminServiceImpl.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/{username}/credentials")
|
@Path("/{username}/credentials")
|
||||||
@Override
|
@Override
|
||||||
public Response resetUserPassword(@PathParam("username")
|
public Response resetUserPassword(@PathParam("username")
|
||||||
@Size(max = 45)
|
@Size(max = 45)
|
||||||
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
|
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
|
||||||
if (domain != null && !domain.isEmpty()) {
|
if (domain != null && !domain.isEmpty()) {
|
||||||
user = domain + '/' + user;
|
user = domain + '/' + user;
|
||||||
}
|
}
|
||||||
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
|
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response deleteDeviceOfUser(@PathParam("username") String username) {
|
||||||
|
try {
|
||||||
|
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDevicesOfUser(username);
|
||||||
|
return Response.status(Response.Status.OK).build();
|
||||||
|
} catch (PrivacyComplianceException e) {
|
||||||
|
String msg = "Error occurred while deleting the devices belongs to the user.";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response deleteDevice(@PathParam("device-type") @Size(max = 45) String deviceType,
|
||||||
|
@PathParam("device-id") @Size(max = 45) String deviceId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
|
||||||
|
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDeviceDetails(deviceIdentifier);
|
||||||
|
return Response.status(Response.Status.OK).build();
|
||||||
|
} catch (PrivacyComplianceException e) {
|
||||||
|
String msg = "Error occurred while deleting the devices information.";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
|
|||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
|
||||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
|
||||||
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
|
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||||
@ -297,6 +298,19 @@ public class DeviceMgtAPIUtils {
|
|||||||
return realmService;
|
return realmService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PrivacyComplianceProvider getPrivacyComplianceProvider() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
PrivacyComplianceProvider privacyComplianceProvider =
|
||||||
|
(PrivacyComplianceProvider) ctx.getOSGiService(PrivacyComplianceProvider.class, null);
|
||||||
|
if (privacyComplianceProvider == null) {
|
||||||
|
String msg = "PrivacyComplianceProvider service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return privacyComplianceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IntegrationClientService getIntegrationClientService() {
|
public static IntegrationClientService getIntegrationClientService() {
|
||||||
if (integrationClientService == null) {
|
if (integrationClientService == null) {
|
||||||
synchronized (DeviceMgtAPIUtils.class) {
|
synchronized (DeviceMgtAPIUtils.class) {
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.common;
|
||||||
|
|
||||||
|
public class PrivacyComplianceException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3127931192903344297L;
|
||||||
|
|
||||||
|
public PrivacyComplianceException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -222,7 +222,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
|
applicationMappingDAO.removeApplicationMapping(device.getId(), device.getEnrolmentInfo().getId(),
|
||||||
|
appIdsToRemove, tenantId);
|
||||||
Application installedApp;
|
Application installedApp;
|
||||||
List<Integer> applicationIds = new ArrayList<>();
|
List<Integer> applicationIds = new ArrayList<>();
|
||||||
List<Application> applicationsToMap = new ArrayList<>();
|
List<Application> applicationsToMap = new ArrayList<>();
|
||||||
@ -263,7 +264,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("num of app Ids:" + applicationIds.size());
|
log.debug("num of app Ids:" + applicationIds.size());
|
||||||
}
|
}
|
||||||
applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), applicationsToMap, tenantId);
|
applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), device.getEnrolmentInfo().getId(),
|
||||||
|
applicationsToMap, tenantId);
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("num of remove app Ids:" + appIdsToRemove.size());
|
log.debug("num of remove app Ids:" + appIdsToRemove.size());
|
||||||
@ -312,7 +314,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
return applicationDAO.getInstalledApplications(device.getId());
|
return applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
String msg = "Error occurred while fetching the Application List of device " + deviceId.toString();
|
String msg = "Error occurred while fetching the Application List of device " + deviceId.toString();
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|||||||
@ -34,7 +34,8 @@ public interface ApplicationDAO {
|
|||||||
|
|
||||||
Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException;
|
Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException;
|
Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
|
||||||
|
throws DeviceManagementDAOException;
|
||||||
|
|
||||||
List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException;
|
List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,9 @@ public interface ApplicationMappingDAO {
|
|||||||
void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId)
|
void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId)
|
||||||
throws DeviceManagementDAOException;
|
throws DeviceManagementDAOException;
|
||||||
|
|
||||||
void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId)
|
void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
|
||||||
throws DeviceManagementDAOException;
|
throws DeviceManagementDAOException;
|
||||||
|
|
||||||
void removeApplicationMapping(int deviceId, List<Integer> appIdList, int tenantId)
|
void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList, int tenantId)
|
||||||
throws DeviceManagementDAOException;
|
throws DeviceManagementDAOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,8 @@ import org.wso2.carbon.device.mgt.core.dao.impl.device.SQLServerDeviceDAOImpl;
|
|||||||
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.device.details.mgt.dao.DeviceDetailsDAO;
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl;
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.impl.PrivacyComplianceDAOImpl;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -151,6 +153,10 @@ public class DeviceManagementDAOFactory {
|
|||||||
return new DeviceDetailsDAOImpl();
|
return new DeviceDetailsDAOImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PrivacyComplianceDAO getPrivacyComplianceDAO() {
|
||||||
|
return new PrivacyComplianceDAOImpl();
|
||||||
|
}
|
||||||
|
|
||||||
public static void init(DataSourceConfig config) {
|
public static void init(DataSourceConfig config) {
|
||||||
dataSource = resolveDataSource(config);
|
dataSource = resolveDataSource(config);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -152,8 +152,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
||||||
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
|
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
|
||||||
"AND TENANT_ID = ?");
|
"DM_APPLICATION WHERE APP_IDENTIFIER = ? AND TENANT_ID = ?");
|
||||||
stmt.setString(1, identifier);
|
stmt.setString(1, identifier);
|
||||||
stmt.setInt(2, tenantId);
|
stmt.setInt(2, tenantId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
@ -171,7 +171,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application getApplication(String identifier, String version, int tenantId) throws DeviceManagementDAOException {
|
public Application getApplication(String identifier, String version, int tenantId)
|
||||||
|
throws DeviceManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -179,8 +180,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
||||||
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
|
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
|
||||||
"AND VERSION = ? AND TENANT_ID = ?");
|
"DM_APPLICATION WHERE APP_IDENTIFIER = ? AND VERSION = ? AND TENANT_ID = ?");
|
||||||
stmt.setString(1, identifier);
|
stmt.setString(1, identifier);
|
||||||
stmt.setString(2, version);
|
stmt.setString(2, version);
|
||||||
stmt.setInt(3, tenantId);
|
stmt.setInt(3, tenantId);
|
||||||
@ -199,7 +200,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException {
|
public Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
|
||||||
|
throws DeviceManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -208,14 +210,15 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
||||||
"LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " +
|
"LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " +
|
||||||
"FROM DM_APPLICATION app INNER JOIN " +
|
"FROM DM_APPLICATION app INNER JOIN (SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, " +
|
||||||
"(SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING W" +
|
"IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?) appmap " +
|
||||||
"HERE DEVICE_ID = ?) appmap WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
|
"WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
|
||||||
"appmap.APPLICATION_ID = app.id AND TENANT_ID = ?");
|
"appmap.APPLICATION_ID = app.id AND TENANT_ID = ?");
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setString(2, identifier);
|
stmt.setInt(2, enrolmentId);
|
||||||
stmt.setString(3, version);
|
stmt.setString(3, identifier);
|
||||||
stmt.setInt(4, tenantId);
|
stmt.setString(4, version);
|
||||||
|
stmt.setInt(5, tenantId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
@ -235,7 +238,7 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException {
|
public List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
List<Application> applications = new ArrayList<>();
|
List<Application> applications = new ArrayList<>();
|
||||||
@ -247,11 +250,12 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
|
|||||||
"LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " +
|
"LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " +
|
||||||
"TENANT_ID From DM_APPLICATION app INNER JOIN " +
|
"TENANT_ID From DM_APPLICATION app INNER JOIN " +
|
||||||
"(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" +
|
"(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" +
|
||||||
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
|
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=? AND ENROLMENT_ID = ?) APPMAP " +
|
||||||
"ON " +
|
"ON " +
|
||||||
"app.ID = APPMAP.APPLICATION_ID ");
|
"app.ID = APPMAP.APPLICATION_ID ");
|
||||||
|
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId)
|
public void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
@ -108,25 +108,26 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, APP_PROPERTIES, " +
|
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, ENROLMENT_ID, APPLICATION_ID, " +
|
||||||
"MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?)";
|
"APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
|
|
||||||
for (Application application : applications) {
|
for (Application application : applications) {
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setInt(2, application.getId());
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.setInt(3, application.getId());
|
||||||
|
|
||||||
bao = new ByteArrayOutputStream();
|
bao = new ByteArrayOutputStream();
|
||||||
oos = new ObjectOutputStream(bao);
|
oos = new ObjectOutputStream(bao);
|
||||||
oos.writeObject(application.getAppProperties());
|
oos.writeObject(application.getAppProperties());
|
||||||
stmt.setBytes(3, bao.toByteArray());
|
stmt.setBytes(4, bao.toByteArray());
|
||||||
|
|
||||||
stmt.setInt(4, application.getMemoryUsage());
|
stmt.setInt(5, application.getMemoryUsage());
|
||||||
stmt.setBoolean(5, application.isActive());
|
stmt.setBoolean(6, application.isActive());
|
||||||
|
|
||||||
stmt.setInt(6, tenantId);
|
stmt.setInt(7, tenantId);
|
||||||
stmt.addBatch();
|
stmt.addBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
stmt.executeBatch();
|
||||||
@ -155,13 +156,13 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeApplicationMapping(int deviceId, List<Integer> appIdList,
|
public void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList,
|
||||||
int tenantId) throws DeviceManagementDAOException {
|
int tenantId) throws DeviceManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " +
|
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " +
|
||||||
"APPLICATION_ID = ? AND TENANT_ID = ?";
|
"APPLICATION_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
|
||||||
|
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
for (int appId : appIdList) {
|
for (int appId : appIdList) {
|
||||||
@ -169,6 +170,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
|
|||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setInt(2, appId);
|
stmt.setInt(2, appId);
|
||||||
stmt.setInt(3, tenantId);
|
stmt.setInt(3, tenantId);
|
||||||
|
stmt.setInt(4, enrolmentId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -38,14 +38,15 @@ public interface DeviceDetailsDAO {
|
|||||||
* @param deviceInfo - Device information object.
|
* @param deviceInfo - Device information object.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException;
|
void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will add the device properties to the database.
|
* This method will add the device properties to the database.
|
||||||
* @param propertyMap - device properties.
|
* @param propertyMap - device properties.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException;
|
void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
|
||||||
|
throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return the device information when device id is provided.
|
* This method will return the device information when device id is provided.
|
||||||
@ -53,7 +54,7 @@ public interface DeviceDetailsDAO {
|
|||||||
* @return DeviceInfo
|
* @return DeviceInfo
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException;
|
DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return the device properties from database.
|
* This method will return the device properties from database.
|
||||||
@ -61,28 +62,28 @@ public interface DeviceDetailsDAO {
|
|||||||
* @return - device properties map.
|
* @return - device properties map.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException;
|
Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will delete the device information from the database.
|
* This method will delete the device information from the database.
|
||||||
* @param deviceId - Integer.
|
* @param deviceId - Integer.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException;
|
void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will delete the device properties from database.
|
* This method will delete the device properties from database.
|
||||||
* @param deviceId - Integer.
|
* @param deviceId - Integer.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException;
|
void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will add device location to database.
|
* This method will add device location to database.
|
||||||
* @param deviceLocation - Device location with latitude and longitude.
|
* @param deviceLocation - Device location with latitude and longitude.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException;
|
void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return the device location object when the device id is provided.
|
* This method will return the device location object when the device id is provided.
|
||||||
@ -90,14 +91,14 @@ public interface DeviceDetailsDAO {
|
|||||||
* @return - Device location object.
|
* @return - Device location object.
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException;
|
DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will delete the device location from the database.
|
* This method will delete the device location from the database.
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
* @throws DeviceDetailsMgtDAOException
|
* @throws DeviceDetailsMgtDAOException
|
||||||
*/
|
*/
|
||||||
void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException;
|
void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * This method will add device application to database.
|
// * This method will add device application to database.
|
||||||
|
|||||||
@ -41,7 +41,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
private static Log log = LogFactory.getLog(DeviceDetailsDAOImpl.class);
|
private static Log log = LogFactory.getLog(DeviceDetailsDAOImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException {
|
public void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo)
|
||||||
|
throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -51,8 +52,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
|
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
|
||||||
"VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
|
"VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
|
||||||
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
|
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
|
||||||
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP) " +
|
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setString(2, deviceInfo.getDeviceModel());
|
stmt.setString(2, deviceInfo.getDeviceModel());
|
||||||
@ -71,6 +72,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
|
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
|
||||||
stmt.setBoolean(16, deviceInfo.isPluggedIn());
|
stmt.setBoolean(16, deviceInfo.isPluggedIn());
|
||||||
stmt.setLong(17, System.currentTimeMillis());
|
stmt.setLong(17, System.currentTimeMillis());
|
||||||
|
stmt.setInt(18, enrolmentId);
|
||||||
|
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
|
||||||
@ -83,7 +85,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException {
|
public void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
|
||||||
|
throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
if (propertyMap.isEmpty()) {
|
if (propertyMap.isEmpty()) {
|
||||||
if(log.isDebugEnabled()) {
|
if(log.isDebugEnabled()) {
|
||||||
@ -95,12 +98,14 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD) VALUES (?, ?, ?)");
|
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD, ENROLMENT_ID) " +
|
||||||
|
"VALUES (?, ?, ?, ?)");
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
|
for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setString(2, entry.getKey());
|
stmt.setString(2, entry.getKey());
|
||||||
stmt.setString(3, entry.getValue());
|
stmt.setString(3, entry.getValue());
|
||||||
|
stmt.setInt(4, enrolmentId);
|
||||||
stmt.addBatch();
|
stmt.addBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
stmt.executeBatch();
|
||||||
@ -113,7 +118,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException {
|
public DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -121,9 +126,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
|
|
||||||
String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
|
String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
@ -159,7 +165,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException {
|
public Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -167,9 +173,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
|
String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -184,15 +191,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException {
|
public void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
|
String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(query);
|
stmt = conn.prepareStatement(query);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrollmentId);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -203,15 +211,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException {
|
public void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
|
String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(query);
|
stmt = conn.prepareStatement(query);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrollmentId);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -222,14 +231,15 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException {
|
public void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_LOCATION (DEVICE_ID, LATITUDE, LONGITUDE, STREET1, " +
|
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_LOCATION (DEVICE_ID, LATITUDE, LONGITUDE, STREET1, " +
|
||||||
"STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)");
|
"STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
stmt.setInt(1, deviceLocation.getDeviceId());
|
stmt.setInt(1, deviceLocation.getDeviceId());
|
||||||
stmt.setDouble(2, deviceLocation.getLatitude());
|
stmt.setDouble(2, deviceLocation.getLatitude());
|
||||||
stmt.setDouble(3, deviceLocation.getLongitude());
|
stmt.setDouble(3, deviceLocation.getLongitude());
|
||||||
@ -241,6 +251,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
stmt.setString(9, deviceLocation.getCountry());
|
stmt.setString(9, deviceLocation.getCountry());
|
||||||
stmt.setString(10, GeoHashGenerator.encodeGeohash(deviceLocation));
|
stmt.setString(10, GeoHashGenerator.encodeGeohash(deviceLocation));
|
||||||
stmt.setLong(11, System.currentTimeMillis());
|
stmt.setLong(11, System.currentTimeMillis());
|
||||||
|
stmt.setInt(12, enrollmentId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceDetailsMgtDAOException("Error occurred while adding the device location to database.", e);
|
throw new DeviceDetailsMgtDAOException("Error occurred while adding the device location to database.", e);
|
||||||
@ -250,7 +261,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException {
|
public DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -258,9 +269,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
DeviceLocation location = new DeviceLocation();
|
DeviceLocation location = new DeviceLocation();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
|
String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrollmentId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -286,15 +298,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException {
|
public void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
|
String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(query);
|
stmt = conn.prepareStatement(query);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrollmentId);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -68,12 +68,14 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
|
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||||
deviceDetailsDAO.deleteDeviceInformation(device.getId());
|
deviceDetailsDAO.deleteDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
deviceDetailsDAO.deleteDeviceProperties(device.getId());
|
deviceDetailsDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
deviceDetailsDAO.addDeviceInformation(device.getId(), deviceInfo);
|
deviceDetailsDAO.addDeviceInformation(device.getId(), device.getEnrolmentInfo().getId(), deviceInfo);
|
||||||
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId());
|
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId());
|
||||||
DeviceManagementDAOFactory.commitTransaction();
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
|
|
||||||
|
//TODO :: This has to be fixed by adding the enrollment ID.
|
||||||
if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {
|
if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {
|
||||||
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
|
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
|
||||||
Object[] payload = new Object[]{
|
Object[] payload = new Object[]{
|
||||||
@ -131,8 +133,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId());
|
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
|
||||||
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId()));
|
device.getEnrolmentInfo().getId());
|
||||||
|
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId()));
|
||||||
return deviceInfo;
|
return deviceInfo;
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -154,19 +158,21 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
identifierMap.put(identifier.getId(), identifier);
|
identifierMap.put(identifier.getId(), identifier);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<Integer> deviceIds = new ArrayList<>();
|
List<Device> deviceIds = new ArrayList<>();
|
||||||
List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
||||||
getAllDevices(false);
|
getAllDevices(false);
|
||||||
for (Device device : devices) {
|
for (Device device : devices) {
|
||||||
if (identifierMap.containsKey(device.getDeviceIdentifier()) &&
|
if (identifierMap.containsKey(device.getDeviceIdentifier()) &&
|
||||||
device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) {
|
device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) {
|
||||||
deviceIds.add(device.getId());
|
deviceIds.add(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
for (Integer id : deviceIds) {
|
for (Device device : deviceIds) {
|
||||||
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(id);
|
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
|
||||||
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(id));
|
device.getEnrolmentInfo().getId());
|
||||||
|
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId()));
|
||||||
deviceInfos.add(deviceInfo);
|
deviceInfos.add(deviceInfo);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -190,8 +196,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
deviceLocation.setDeviceId(device.getId());
|
deviceLocation.setDeviceId(device.getId());
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||||
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId());
|
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId(), device.getEnrolmentInfo().getId());
|
||||||
deviceDetailsDAO.addDeviceLocation(deviceLocation);
|
deviceDetailsDAO.addDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
|
||||||
|
//TODO: This has to be fixed with enrollment id or username should include in the stream def.
|
||||||
if (DeviceManagerUtil.isPublishLocationResponseEnabled()) {
|
if (DeviceManagerUtil.isPublishLocationResponseEnabled()) {
|
||||||
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
|
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
|
||||||
Object[] payload = new Object[]{
|
Object[] payload = new Object[]{
|
||||||
@ -233,7 +240,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
return deviceDetailsDAO.getDeviceLocation(device.getId());
|
return deviceDetailsDAO.getDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceDetailsMgtException("SQL error occurred while retrieving device from database.", e);
|
throw new DeviceDetailsMgtException("SQL error occurred while retrieving device from database.", e);
|
||||||
} catch (DeviceDetailsMgtDAOException e) {
|
} catch (DeviceDetailsMgtDAOException e) {
|
||||||
@ -270,7 +277,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|||||||
List<DeviceLocation> deviceLocations = new ArrayList<>();
|
List<DeviceLocation> deviceLocations = new ArrayList<>();
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
for (Device device : devices) {
|
for (Device device : devices) {
|
||||||
deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId()));
|
deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId()));
|
||||||
}
|
}
|
||||||
return deviceLocations;
|
return deviceLocations;
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
|||||||
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
|
||||||
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||||
@ -67,6 +68,7 @@ public class DeviceManagementDataHolder {
|
|||||||
private DeviceTaskManagerService deviceTaskManagerService;
|
private DeviceTaskManagerService deviceTaskManagerService;
|
||||||
private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
|
private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
|
||||||
private DeviceTypeGeneratorService deviceTypeGeneratorService;
|
private DeviceTypeGeneratorService deviceTypeGeneratorService;
|
||||||
|
private PrivacyComplianceProvider privacyComplianceProvider;
|
||||||
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
|
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
|
||||||
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
|
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
|
||||||
|
|
||||||
@ -266,4 +268,12 @@ public class DeviceManagementDataHolder {
|
|||||||
DeviceTypeGeneratorService deviceTypeGeneratorService) {
|
DeviceTypeGeneratorService deviceTypeGeneratorService) {
|
||||||
this.deviceTypeGeneratorService = deviceTypeGeneratorService;
|
this.deviceTypeGeneratorService = deviceTypeGeneratorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceProvider getPrivacyComplianceProvider() {
|
||||||
|
return privacyComplianceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrivacyComplianceProvider(PrivacyComplianceProvider privacyComplianceProvider) {
|
||||||
|
this.privacyComplianceProvider = privacyComplianceProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -51,6 +51,8 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManageme
|
|||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.impl.PrivacyComplianceProviderImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.push.notification.mgt.task.PushNotificationSchedulerTask;
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.task.PushNotificationSchedulerTask;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
@ -225,6 +227,12 @@ public class DeviceManagementServiceComponent {
|
|||||||
.getPushNotificationConfiguration().getSchedulerTaskInitialDelay(), config
|
.getPushNotificationConfiguration().getSchedulerTaskInitialDelay(), config
|
||||||
.getPushNotificationConfiguration().getSchedulerBatchDelayMills(), TimeUnit.MILLISECONDS);
|
.getPushNotificationConfiguration().getSchedulerBatchDelayMills(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrivacyComplianceProvider privacyComplianceProvider = new PrivacyComplianceProviderImpl();
|
||||||
|
DeviceManagementDataHolder.getInstance().setPrivacyComplianceProvider(privacyComplianceProvider);
|
||||||
|
componentContext.getBundleContext().registerService(PrivacyComplianceProvider.class.getName(),
|
||||||
|
privacyComplianceProvider, null);
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Device management core bundle has been successfully initialized");
|
log.debug("Device management core bundle has been successfully initialized");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
|
||||||
|
|
||||||
|
public interface PrivacyComplianceProvider {
|
||||||
|
|
||||||
|
void deleteDevicesOfUser(String username) throws PrivacyComplianceException;
|
||||||
|
|
||||||
|
void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy.dao;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PrivacyComplianceDAO {
|
||||||
|
|
||||||
|
List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy.dao;
|
||||||
|
|
||||||
|
public class PrivacyComplianceDAOException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3127931192903344297L;
|
||||||
|
|
||||||
|
public PrivacyComplianceDAOException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceDAOException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceDAOException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceDAOException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrivacyComplianceDAOException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,280 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy.dao.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PrivacyComplianceDAOImpl implements PrivacyComplianceDAO {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
List<DeviceEnrollmentMapping> deviceIds = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "SELECT * FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ? ORDER BY DEVICE_ID";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setString(1, username);
|
||||||
|
stmt.setInt(2, tenantId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
DeviceEnrollmentMapping mapping = new DeviceEnrollmentMapping();
|
||||||
|
mapping.setDeviceId(rs.getInt("DEVICE_ID"));
|
||||||
|
mapping.setEnrolmentId(rs.getInt("ENROLMENT_ID"));
|
||||||
|
deviceIds.add(mapping);
|
||||||
|
}
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return deviceIds;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while retrieving device ids " +
|
||||||
|
"related to the given user.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE WHERE ID = ? AND TENANT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, tenantId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the devices", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, tenantId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId)
|
||||||
|
throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, tenantId);
|
||||||
|
stmt.setInt(3, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device details.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId)
|
||||||
|
throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? " +
|
||||||
|
"AND ENROLMENT_ID = ? AND TENANT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.setInt(3, tenantId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device applications.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId)
|
||||||
|
throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, deviceId);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device location.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "UPDATE DM_DEVICE_OPERATION_RESPONSE SET OPERATION_RESPONSE = ? WHERE ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setNull(1, java.sql.Types.BLOB);
|
||||||
|
stmt.setInt(2, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException {
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, enrolmentId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getConnection() throws SQLException {
|
||||||
|
return DeviceManagementDAOFactory.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
|
||||||
|
public class DeviceEnrollmentMapping {
|
||||||
|
|
||||||
|
private int deviceId;
|
||||||
|
private int enrolmentId;
|
||||||
|
private DeviceIdentifier deviceIdentifier;
|
||||||
|
private int tenantId;
|
||||||
|
|
||||||
|
public int getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(int deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnrolmentId() {
|
||||||
|
return enrolmentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnrolmentId(int enrolmentId) {
|
||||||
|
this.enrolmentId = enrolmentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceIdentifier getDeviceIdentifier() {
|
||||||
|
return deviceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) {
|
||||||
|
this.deviceIdentifier = deviceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTenantId(int tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.privacy.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PrivacyComplianceProviderImpl implements PrivacyComplianceProvider {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(PrivacyComplianceProviderImpl.class);
|
||||||
|
|
||||||
|
PrivacyComplianceDAO complianceDAO;
|
||||||
|
|
||||||
|
public PrivacyComplianceProviderImpl() {
|
||||||
|
complianceDAO = DeviceManagementDAOFactory.getPrivacyComplianceDAO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDevicesOfUser(String username) throws PrivacyComplianceException {
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Deleting the requested users.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
List<DeviceEnrollmentMapping> enrollmentMappings = complianceDAO.getDevicesOfUser(username, tenantId);
|
||||||
|
Map<Integer, List<Integer>> deviceMap = new HashMap<>();
|
||||||
|
int x = -1;
|
||||||
|
for (DeviceEnrollmentMapping m : enrollmentMappings) {
|
||||||
|
if (m.getDeviceId() != x) {
|
||||||
|
x = m.getDeviceId();
|
||||||
|
List<Integer> enrolments = new ArrayList<>();
|
||||||
|
enrolments.add(m.getEnrolmentId());
|
||||||
|
deviceMap.put(m.getDeviceId(), enrolments);
|
||||||
|
} else {
|
||||||
|
deviceMap.get(m.getDeviceId()).add(m.getEnrolmentId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int deviceId : deviceMap.keySet()) {
|
||||||
|
List<Integer> enrollmentIds = deviceMap.get(deviceId);
|
||||||
|
for (Integer enrolmentId : enrollmentIds) {
|
||||||
|
complianceDAO.deleteDeviceOperationDetails(enrolmentId);
|
||||||
|
complianceDAO.deleteOperationEnrolmentMappings(enrolmentId);
|
||||||
|
complianceDAO.deleteDeviceApplications(deviceId, enrolmentId, tenantId);
|
||||||
|
complianceDAO.deleteDeviceDetails(deviceId, enrolmentId);
|
||||||
|
complianceDAO.deleteDeviceProperties(deviceId, enrolmentId, tenantId);
|
||||||
|
complianceDAO.deleteDeviceLocation(deviceId, enrolmentId);
|
||||||
|
complianceDAO.deleteDeviceEnrollments(deviceId, enrolmentId);
|
||||||
|
}
|
||||||
|
complianceDAO.deleteDevice(deviceId, tenantId);
|
||||||
|
}
|
||||||
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
|
} catch (PrivacyComplianceDAOException e) {
|
||||||
|
DeviceManagementDAOFactory.rollbackTransaction();
|
||||||
|
String msg = "Error occurred while deleting the devices and details of the given user";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PrivacyComplianceException(msg, e);
|
||||||
|
} catch (TransactionManagementException e) {
|
||||||
|
DeviceManagementDAOFactory.rollbackTransaction();
|
||||||
|
String msg = "Database error occurred while deleting the devices and details of the given user";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PrivacyComplianceException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
log.info("Requested users device has been successfully removed..!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException {
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Deleting the requested device details.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Device device = this.getDevice(deviceIdentifier);
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
|
complianceDAO.deleteDeviceOperationDetails(device.getEnrolmentInfo().getId());
|
||||||
|
complianceDAO.deleteOperationEnrolmentMappings(device.getEnrolmentInfo().getId());
|
||||||
|
complianceDAO.deleteDeviceApplications(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
|
||||||
|
complianceDAO.deleteDeviceDetails(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
|
complianceDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
|
||||||
|
complianceDAO.deleteDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
|
} catch (TransactionManagementException e) {
|
||||||
|
DeviceManagementDAOFactory.rollbackTransaction();
|
||||||
|
String msg = "Database error occurred while deleting the device details.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PrivacyComplianceException(msg, e);
|
||||||
|
} catch (PrivacyComplianceDAOException e) {
|
||||||
|
DeviceManagementDAOFactory.rollbackTransaction();
|
||||||
|
String msg = "Error occurred while deleting the device details.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PrivacyComplianceException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Device getDevice(DeviceIdentifier deviceId) throws PrivacyComplianceException {
|
||||||
|
try {
|
||||||
|
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new PrivacyComplianceException(
|
||||||
|
"Error occurred while retrieving device info.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -236,7 +236,8 @@ public class ProcessorImpl implements Processor {
|
|||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
for (Device device : devices) {
|
for (Device device : devices) {
|
||||||
device.setApplications(applicationDAO.getInstalledApplications(device.getId()));
|
device.setApplications(applicationDAO.getInstalledApplications(device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId()));
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
throw new SearchMgtException("Error occurred while fetching the Application List of devices ", e);
|
throw new SearchMgtException("Error occurred while fetching the Application List of devices ", e);
|
||||||
|
|||||||
@ -2475,8 +2475,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
DeviceInfo info = null;
|
DeviceInfo info = null;
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
info = deviceInfoDAO.getDeviceInformation(device.getId());
|
info = deviceInfoDAO.getDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId());
|
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId(),
|
||||||
|
device.getEnrolmentInfo().getId());
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
//There are some cases where the device-info is not updated properly. Hence returning a null value.
|
//There are some cases where the device-info is not updated properly. Hence returning a null value.
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
@ -2507,23 +2508,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
/**
|
/**
|
||||||
* Returns all the installed apps of the given device.
|
* Returns all the installed apps of the given device.
|
||||||
*/
|
*/
|
||||||
private List<Application> getInstalledApplications(Device device) {
|
private List<Application> getInstalledApplications(Device device) throws DeviceManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'");
|
log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
}
|
}
|
||||||
List<Application> applications = new ArrayList<>();
|
List<Application> applications = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
applications = applicationDAO.getInstalledApplications(device.getId());
|
applications = applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
device.setApplications(applications);
|
device.setApplications(applications);
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " +
|
String msg = "Error occurred while retrieving the application list of '" + device.getType() + "', " +
|
||||||
"which carries the id '" + device.getId() + "'", e);
|
"which carries the id '" + device.getId() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error occurred while opening a connection to the data source", e);
|
String msg = "Error occurred while opening a connection to the data source";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Error occurred in getInstalledApplications";
|
String msg = "Error occurred in getInstalledApplications";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -506,7 +506,8 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|||||||
|
|
||||||
//Device details table will be reffered when looking for last updated time
|
//Device details table will be reffered when looking for last updated time
|
||||||
//This dao entry is to mimic a device info operation
|
//This dao entry is to mimic a device info operation
|
||||||
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), TestDataHolder
|
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), initialDevice.getEnrolmentInfo().getId(),
|
||||||
|
TestDataHolder
|
||||||
.generateDummyDeviceInfo());
|
.generateDummyDeviceInfo());
|
||||||
|
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
|||||||
@ -301,7 +301,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
|
|||||||
POLICY_CRITERION_ID INT NOT NULL,
|
POLICY_CRITERION_ID INT NOT NULL,
|
||||||
PROP_KEY VARCHAR(45) NULL,
|
PROP_KEY VARCHAR(45) NULL,
|
||||||
PROP_VALUE VARCHAR(100) NULL,
|
PROP_VALUE VARCHAR(100) NULL,
|
||||||
CONTENT BLOB NULL COMMENT 'This is used to ',
|
CONTENT BLOB NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
|
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
|
||||||
FOREIGN KEY (POLICY_CRITERION_ID)
|
FOREIGN KEY (POLICY_CRITERION_ID)
|
||||||
@ -363,19 +363,32 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
FOREIGN KEY (DEVICE_ID)
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
REFERENCES DM_DEVICE (ID)
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT fk_dm_application
|
||||||
|
FOREIGN KEY (APPLICATION_ID)
|
||||||
|
REFERENCES DM_APPLICATION (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- POLICY RELATED TABLES FINISHED --
|
-- POLICY RELATED TABLES FINISHED --
|
||||||
@ -400,6 +413,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
@ -407,12 +421,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
LATITUDE DOUBLE NULL,
|
LATITUDE DOUBLE NULL,
|
||||||
LONGITUDE DOUBLE NULL,
|
LONGITUDE DOUBLE NULL,
|
||||||
STREET1 VARCHAR(255) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
@ -428,14 +448,19 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT NOT NULL AUTO_INCREMENT,
|
||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -457,6 +482,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,13 @@
|
|||||||
class="form-control" placeholder="Confirm Password"/>
|
class="form-control" placeholder="Confirm Password"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-warning" style="border-radius:5px"><p class="doc-link">
|
||||||
|
This site uses cookies. By logging in to the site, you are agreeing on the usage of cookies. For more information, refer <a href="{{@unit.publicUri}}/privacy-policies/cookie-policy" style="color:#ffffff;"
|
||||||
|
target="_blank"><u>cookie policy</u></a> and
|
||||||
|
<a href="{{@unit.publicUri}}/privacy-policies/privacy-policy" style="color:#ffffff;"
|
||||||
|
target="_blank"><u>privacy policy</u></a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="wr-input-control">
|
<div class="wr-input-control">
|
||||||
<button class="wr-btn" id="add-user-btn">Register</button>
|
<button class="wr-btn" id="add-user-btn">Register</button>
|
||||||
<button class="wr-btn" onclick="document.location.href='{{@app.context}}/login';">
|
<button class="wr-btn" onclick="document.location.href='{{@app.context}}/login';">
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-sm-offset-3 col-md-offset-3 col-lg-offset-4">
|
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-sm-offset-3 col-md-offset-3 col-lg-offset-4">
|
||||||
|
|
||||||
<p class="page-sub-title">Login</p>
|
<p class="page-sub-title">Login</p>
|
||||||
<hr />
|
<hr/>
|
||||||
{{#if message}}
|
{{#if message}}
|
||||||
<div class="alert alert-danger" style="padding-right: 15px;">
|
<div class="alert alert-danger" style="padding-right: 15px;">
|
||||||
<i class="icon fw fw-warning"></i> {{message}}!
|
<i class="icon fw fw-warning"></i> {{message}}!
|
||||||
@ -35,19 +35,27 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">Username *</label>
|
<label for="username">Username *</label>
|
||||||
<input type="text" name="username" class="form-control" placeholder="Enter your username"
|
<input type="text" name="username" class="form-control" placeholder="Enter your username"
|
||||||
autofocus="autofocus" required="required" />
|
autofocus="autofocus" required="required"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password *</label>
|
<label for="password">Password *</label>
|
||||||
<input type="password" name="password" class="form-control" autocomplete="off"
|
<input type="password" name="password" class="form-control" autocomplete="off"
|
||||||
placeholder="Enter your password" required="required" />
|
placeholder="Enter your password" required="required"/>
|
||||||
</div>
|
</div>
|
||||||
{{#if sessionDataKey}}
|
{{#if sessionDataKey}}
|
||||||
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}" />
|
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}"/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if referer}}
|
{{#if referer}}
|
||||||
<input type="hidden" name="referer" value="{{referer}}" />
|
<input type="hidden" name="referer" value="{{referer}}"/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
<div class="alert alert-warning" style="border-radius:5px"><p class="doc-link">
|
||||||
|
This site uses cookies. By logging in to the site, you are agreeing on the usage of cookies. For more information, refer <a href="{{@unit.publicUri}}/privacy-policies/cookie-policy" style="color:#ffffff;"
|
||||||
|
target="_blank"><u>cookie policy</u></a> and
|
||||||
|
<a href="{{@unit.publicUri}}/privacy-policies/privacy-policy" style="color:#ffffff;"
|
||||||
|
target="_blank"><u>privacy policy</u></a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="wr-input-control wr-btn-grp">
|
<div class="wr-input-control wr-btn-grp">
|
||||||
<button class="wr-btn btn-download-agent">
|
<button class="wr-btn btn-download-agent">
|
||||||
Log in
|
Log in
|
||||||
|
|||||||
@ -414,19 +414,32 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
);
|
);
|
||||||
|
|
||||||
DROP TABLE IF EXISTS DM_DEVICE_APPLICATION_MAPPING;
|
DROP TABLE IF EXISTS DM_DEVICE_APPLICATION_MAPPING;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
FOREIGN KEY (DEVICE_ID)
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
REFERENCES DM_DEVICE (ID)
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT fk_dm_application
|
||||||
|
FOREIGN KEY (APPLICATION_ID)
|
||||||
|
REFERENCES DM_APPLICATION (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- POLICY RELATED TABLES FINISHED --
|
-- POLICY RELATED TABLES FINISHED --
|
||||||
@ -448,10 +461,10 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|||||||
);
|
);
|
||||||
-- NOTIFICATION TABLE END --
|
-- NOTIFICATION TABLE END --
|
||||||
|
|
||||||
DROP TABLE IF EXISTS DM_DEVICE_INFO;
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
@ -459,35 +472,46 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS DM_DEVICE_LOCATION;
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
LATITUDE DOUBLE NULL,
|
LATITUDE DOUBLE NULL,
|
||||||
LONGITUDE DOUBLE NULL,
|
LONGITUDE DOUBLE NULL,
|
||||||
STREET1 VARCHAR(45) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
STREET2 VARCHAR(45) NULL,
|
STREET2 VARCHAR(45) NULL,
|
||||||
CITY VARCHAR(45) NULL,
|
CITY VARCHAR(45) NULL,
|
||||||
ZIP VARCHAR(10) NULL,
|
ZIP VARCHAR(10) NULL,
|
||||||
STATE VARCHAR(45) NULL,
|
STATE VARCHAR(45) NULL,
|
||||||
COUNTRY VARCHAR(45) NULL,
|
COUNTRY VARCHAR(45) NULL,
|
||||||
|
GEO_HASH VARCHAR(45) NULL,
|
||||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TABLE IF EXISTS DM_DEVICE_DETAIL;
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT NOT NULL AUTO_INCREMENT,
|
||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -497,7 +521,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
EXTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
EXTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL,
|
||||||
EXTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
EXTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL,
|
||||||
CONNECTION_TYPE VARCHAR(10) NULL,
|
CONNECTION_TYPE VARCHAR(50) NULL,
|
||||||
SSID VARCHAR(45) NULL,
|
SSID VARCHAR(45) NULL,
|
||||||
CPU_USAGE DECIMAL(5) NULL,
|
CPU_USAGE DECIMAL(5) NULL,
|
||||||
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
|
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
|
||||||
@ -509,10 +533,16 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- POLICY AND DEVICE GROUP MAPPING --
|
-- POLICY AND DEVICE GROUP MAPPING --
|
||||||
DROP TABLE IF EXISTS DM_DEVICE_GROUP_POLICY;
|
DROP TABLE IF EXISTS DM_DEVICE_GROUP_POLICY;
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
||||||
|
|||||||
@ -366,16 +366,28 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
TENANT_ID INTEGER NOT NULL,
|
TENANT_ID INTEGER NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
FOREIGN KEY (DEVICE_ID)
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
REFERENCES DM_DEVICE (ID)
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT fk_dm_application
|
||||||
|
FOREIGN KEY (APPLICATION_ID)
|
||||||
|
REFERENCES DM_APPLICATION (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- POLICY RELATED TABLES FINISHED --
|
-- POLICY RELATED TABLES FINISHED --
|
||||||
@ -400,6 +412,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
@ -407,12 +420,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
LATITUDE DOUBLE NULL,
|
LATITUDE DOUBLE NULL,
|
||||||
LONGITUDE DOUBLE NULL,
|
LONGITUDE DOUBLE NULL,
|
||||||
STREET1 VARCHAR(255) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
@ -428,6 +447,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
||||||
@ -435,6 +459,7 @@ CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT NOT NULL AUTO_INCREMENT,
|
||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -456,6 +481,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -395,6 +395,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D
|
|||||||
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID INTEGER IDENTITY(1,1) NOT NULL,
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES VARBINARY(MAX) NULL,
|
APP_PROPERTIES VARBINARY(MAX) NULL,
|
||||||
MEMORY_USAGE INTEGER NULL,
|
MEMORY_USAGE INTEGER NULL,
|
||||||
@ -404,7 +405,9 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
|||||||
CONSTRAINT FK_DM_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT FK_DM_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
CONSTRAINT FK_DM_APPLICATION FOREIGN KEY (APPLICATION_ID) REFERENCES
|
CONSTRAINT FK_DM_APPLICATION FOREIGN KEY (APPLICATION_ID) REFERENCES
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
||||||
|
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- POLICY RELATED TABLES FINISHED --
|
-- POLICY RELATED TABLES FINISHED --
|
||||||
@ -453,18 +456,29 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D
|
|||||||
CREATE TABLE DM_DEVICE_INFO (
|
CREATE TABLE DM_DEVICE_INFO (
|
||||||
ID INTEGER IDENTITY(1,1) NOT NULL,
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
||||||
DEVICE_ID INTEGER NULL,
|
DEVICE_ID INTEGER NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION
|
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC)
|
||||||
ON UPDATE NO ACTION
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
REFERENCES DM_DEVICE (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_LOCATION]') AND TYPE IN (N'U'))
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_LOCATION]') AND TYPE IN (N'U'))
|
||||||
CREATE TABLE DM_DEVICE_LOCATION (
|
CREATE TABLE DM_DEVICE_LOCATION (
|
||||||
ID INTEGER IDENTITY(1,1) NOT NULL,
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
||||||
DEVICE_ID INTEGER NULL,
|
DEVICE_ID INTEGER NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
LATITUDE FLOAT NULL,
|
LATITUDE FLOAT NULL,
|
||||||
LONGITUDE FLOAT NULL,
|
LONGITUDE FLOAT NULL,
|
||||||
STREET1 VARCHAR(255) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
@ -478,10 +492,16 @@ CREATE TABLE DM_DEVICE_LOCATION (
|
|||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC),
|
||||||
INDEX DM_DEVICE_LOCATION_GEO_hashx (GEO_HASH ASC),
|
INDEX DM_DEVICE_LOCATION_GEO_hashx (GEO_HASH ASC),
|
||||||
|
INDEX DM_DEVICE_LOCATION_DM_ENROLLMENT_idx (ENROLMENT_ID ASC),
|
||||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -489,6 +509,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D
|
|||||||
CREATE TABLE DM_DEVICE_DETAIL (
|
CREATE TABLE DM_DEVICE_DETAIL (
|
||||||
ID INTEGER IDENTITY(1,1) NOT NULL,
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -507,11 +528,17 @@ CREATE TABLE DM_DEVICE_DETAIL (
|
|||||||
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
UPDATE_TIMESTAMP BIGINT NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC),
|
INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC),
|
||||||
|
INDEX FK_DM_ENROLMENT_DEVICE_DETAILS_idx (ENROLMENT_ID ASC),
|
||||||
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- DASHBOARD RELATED VIEWS --
|
-- DASHBOARD RELATED VIEWS --
|
||||||
|
|||||||
@ -410,6 +410,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE INTEGER(10) NULL,
|
MEMORY_USAGE INTEGER(10) NULL,
|
||||||
@ -419,7 +420,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
|||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
||||||
|
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
)ENGINE = InnoDB;
|
)ENGINE = InnoDB;
|
||||||
|
|
||||||
-- END OF POLICY RELATED TABLES --
|
-- END OF POLICY RELATED TABLES --
|
||||||
@ -468,14 +471,21 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
||||||
|
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
)
|
)
|
||||||
ENGINE = InnoDB;
|
ENGINE = InnoDB;
|
||||||
@ -483,6 +493,7 @@ ENGINE = InnoDB;
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
LATITUDE DOUBLE NULL,
|
LATITUDE DOUBLE NULL,
|
||||||
LONGITUDE DOUBLE NULL,
|
LONGITUDE DOUBLE NULL,
|
||||||
STREET1 VARCHAR(255) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
@ -496,10 +507,16 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC),
|
||||||
INDEX DM_DEVICE_LOCATION_GEO_hashx (GEO_HASH ASC),
|
INDEX DM_DEVICE_LOCATION_GEO_hashx (GEO_HASH ASC),
|
||||||
|
INDEX DM_DEVICE_LOCATION_DM_ENROLLMENT_idx (ENROLMENT_ID ASC),
|
||||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
)
|
)
|
||||||
ENGINE = InnoDB;
|
ENGINE = InnoDB;
|
||||||
@ -507,6 +524,7 @@ ENGINE = InnoDB;
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT NOT NULL AUTO_INCREMENT,
|
||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -525,11 +543,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
UPDATE_TIMESTAMP BIGINT(15) NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC),
|
INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC),
|
||||||
|
INDEX FK_DM_ENROLMENT_DEVICE_DETAILS_idx (ENROLMENT_ID ASC),
|
||||||
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION)
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION
|
||||||
|
)
|
||||||
ENGINE = InnoDB;
|
ENGINE = InnoDB;
|
||||||
|
|
||||||
-- DASHBOARD RELATED VIEWS --
|
-- DASHBOARD RELATED VIEWS --
|
||||||
|
|||||||
@ -714,6 +714,7 @@ WHEN (NEW.ID IS NULL)
|
|||||||
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_ID NUMBER(10) NOT NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
|
ENROLMENT_ID NUMBER(10 NOT NULL,
|
||||||
APPLICATION_ID NUMBER(10) NOT NULL,
|
APPLICATION_ID NUMBER(10) NOT NULL,
|
||||||
APP_PROPERTIES BLOB NULL,
|
APP_PROPERTIES BLOB NULL,
|
||||||
MEMORY_USAGE NUMBER(10) NULL,
|
MEMORY_USAGE NUMBER(10) NULL,
|
||||||
@ -723,7 +724,9 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
|||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||||
DM_DEVICE (ID),
|
DM_DEVICE (ID),
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
||||||
DM_APPLICATION (ID)
|
DM_APPLICATION (ID),
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
||||||
|
DM_ENROLMENT (ID)
|
||||||
)
|
)
|
||||||
/
|
/
|
||||||
-- Generate ID using sequence and trigger
|
-- Generate ID using sequence and trigger
|
||||||
@ -786,14 +789,17 @@ END;
|
|||||||
|
|
||||||
CREATE TABLE DM_DEVICE_INFO (
|
CREATE TABLE DM_DEVICE_INFO (
|
||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_ID NUMBER(10) NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
|
ENROLMENT_ID NUMBER(10) NOT NULL,
|
||||||
KEY_FIELD VARCHAR2(45) NULL,
|
KEY_FIELD VARCHAR2(45) NULL,
|
||||||
VALUE_FIELD VARCHAR2(100) NULL,
|
VALUE_FIELD VARCHAR2(100) NULL,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID),
|
||||||
,
|
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID),
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
)
|
)
|
||||||
/
|
/
|
||||||
|
|
||||||
@ -810,7 +816,8 @@ WHEN (NEW.ID IS NULL)
|
|||||||
|
|
||||||
CREATE TABLE DM_DEVICE_LOCATION (
|
CREATE TABLE DM_DEVICE_LOCATION (
|
||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_ID NUMBER(10) NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
|
ENROLMENT_ID NUMBER(10) NOT NULL,
|
||||||
LATITUDE BINARY_DOUBLE NULL,
|
LATITUDE BINARY_DOUBLE NULL,
|
||||||
LONGITUDE BINARY_DOUBLE NULL,
|
LONGITUDE BINARY_DOUBLE NULL,
|
||||||
STREET1 VARCHAR2(255) NULL,
|
STREET1 VARCHAR2(255) NULL,
|
||||||
@ -824,7 +831,10 @@ CREATE TABLE DM_DEVICE_LOCATION (
|
|||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID),
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
/
|
/
|
||||||
@ -845,6 +855,7 @@ WHEN (NEW.ID IS NULL)
|
|||||||
CREATE TABLE DM_DEVICE_DETAIL (
|
CREATE TABLE DM_DEVICE_DETAIL (
|
||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_ID NUMBER(10) NOT NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
|
ENROLMENT_ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR2(45) NULL,
|
DEVICE_MODEL VARCHAR2(45) NULL,
|
||||||
VENDOR VARCHAR2(45) NULL,
|
VENDOR VARCHAR2(45) NULL,
|
||||||
OS_VERSION VARCHAR2(45) NULL,
|
OS_VERSION VARCHAR2(45) NULL,
|
||||||
@ -864,7 +875,10 @@ CREATE TABLE DM_DEVICE_DETAIL (
|
|||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID),
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
)
|
)
|
||||||
/
|
/
|
||||||
-- Generate ID using sequence and trigger
|
-- Generate ID using sequence and trigger
|
||||||
|
|||||||
@ -356,6 +356,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
APPLICATION_ID INTEGER NOT NULL,
|
APPLICATION_ID INTEGER NOT NULL,
|
||||||
APP_PROPERTIES BYTEA NULL,
|
APP_PROPERTIES BYTEA NULL,
|
||||||
MEMORY_USAGE INTEGER NULL,
|
MEMORY_USAGE INTEGER NULL,
|
||||||
@ -364,7 +365,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
|
|||||||
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES
|
||||||
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
|
||||||
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
||||||
|
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
-- POLICY RELATED TABLES FINISHED --
|
-- POLICY RELATED TABLES FINISHED --
|
||||||
@ -412,20 +415,27 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(100) NULL,
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
LATITUDE DOUBLE PRECISION NULL,
|
LATITUDE DOUBLE PRECISION NULL,
|
||||||
LONGITUDE DOUBLE PRECISION NULL,
|
LONGITUDE DOUBLE PRECISION NULL,
|
||||||
STREET1 VARCHAR(255) NULL,
|
STREET1 VARCHAR(255) NULL,
|
||||||
@ -440,6 +450,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -448,6 +463,7 @@ CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
|
|||||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
|
ENROLMENT_ID INT NOT NULL,
|
||||||
DEVICE_MODEL VARCHAR(45) NULL,
|
DEVICE_MODEL VARCHAR(45) NULL,
|
||||||
VENDOR VARCHAR(45) NULL,
|
VENDOR VARCHAR(45) NULL,
|
||||||
OS_VERSION VARCHAR(45) NULL,
|
OS_VERSION VARCHAR(45) NULL,
|
||||||
@ -468,6 +484,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS
|
||||||
|
FOREIGN KEY (ENROLMENT_ID)
|
||||||
|
REFERENCES DM_ENROLMENT (ID)
|
||||||
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user