Add original app icons into single device app list and application restriction policy app list

Co-authored-by: Sanjana Rajapakshe <sanjana@entgra.io>
Co-committed-by: Sanjana Rajapakshe <sanjana@entgra.io>
pull/133/head
Sanjana Rajapakshe 2 years ago committed by Lasantha Dharmakeerthi
parent 2cf7cf8705
commit c06fd22ecd

@ -525,4 +525,12 @@ public interface ApplicationManager {
String getPlistArtifact(String uuid) throws ApplicationManagementException;
List<ApplicationReleaseDTO> getReleaseByPackageNames(List<String> packageIds) throws ApplicationManagementException;
/**
* @param applicationRelease {@link ApplicationRelease}
* @param oldPackageName Old package name of the application
* @throws ApplicationManagementException Application management exception
*/
void updateAppIconInfo(ApplicationRelease applicationRelease, String oldPackageName)
throws ApplicationManagementException;
}

@ -1287,6 +1287,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
applicationDTO.setId(appId);
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) {
persistAppIconInfo(applicationReleaseDTO);
}
return APIUtil.appDtoToAppResponse(applicationDTO);
}
} catch (LifeCycleManagementDAOException e) {
@ -1313,6 +1316,30 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
}
/**
* Persist application icon information when creating an application
*
* @param applicationReleaseDTO {@link ApplicationReleaseDTO}
* @throws ApplicationManagementException if error occurred while persisting application icon information
*/
private void persistAppIconInfo(ApplicationReleaseDTO applicationReleaseDTO)
throws ApplicationManagementException {
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String iconPath = APIUtil.createAppIconPath(applicationReleaseDTO, tenantId);
DataHolder.getInstance().getDeviceManagementService().saveApplicationIcon(iconPath,
String.valueOf(applicationReleaseDTO.getPackageName()), applicationReleaseDTO.getVersion(), tenantId);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while creating iconPath. Application package name : " + applicationReleaseDTO.getPackageName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DeviceManagementException e) {
String msg = "Error occurred while saving application icon info. Application package name : " + applicationReleaseDTO.getPackageName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
@Override
public <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
ApplicationType type, boolean isPublished)
@ -1918,6 +1945,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
break;
}
}
try {
deleteAppIconInfo(applicationDTO);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while deleting application icon info. Application package name: " + applicationDTO.getPackageName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
@Override
@ -4022,4 +4056,32 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.closeDBConnection();
}
}
@Override
public void updateAppIconInfo(ApplicationRelease applicationRelease, String oldPackageName) throws ApplicationManagementException {
try {
DataHolder.getInstance().getDeviceManagementService().updateApplicationIcon(applicationRelease.getIconPath(),
oldPackageName, applicationRelease.getPackageName(), applicationRelease.getVersion());
} catch (DeviceManagementException e) {
String msg = "Error occurred while updating application icon info. Application package name: " + oldPackageName;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
/**
* Delete application icon information when deleting an application
*
* @param applicationDTO {@link ApplicationDTO}
* @throws ApplicationManagementException if error occurred while deleting application icon information
*/
private void deleteAppIconInfo(ApplicationDTO applicationDTO) throws ApplicationManagementException {
try {
DataHolder.getInstance().getDeviceManagementService().deleteApplicationIcon(applicationDTO.getPackageName());
} catch (DeviceManagementException e) {
String msg = "Error occurred while deleting application icon info. Application package name: " + applicationDTO.getPackageName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
}

@ -510,4 +510,18 @@ public class APIUtil {
return mdmConfig.getArtifactDownloadProtocol() + "://" + host + ":" + port
+ artifactDownloadEndpoint + Constants.FORWARD_SLASH;
}
/**
* To create the application icon path.
*
* @param applicationReleaseDTO {@link ApplicationReleaseDTO}
* @param tenantId tenant ID
* @return iconPath constructed icon path.
*/
public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException {
String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO
.getAppHashValue() + Constants.FORWARD_SLASH;
String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName();
return iconPath;
}
}

@ -532,6 +532,8 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
String oldPackageName = applicationManager.getApplicationByUuid(applicationUUID).getPackageName();
applicationManager.updateAppIconInfo(applicationRelease, oldPackageName);
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
@ -572,6 +574,8 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
String oldPackageName = applicationManager.getApplicationByUuid(applicationUUID).getPackageName();
applicationManager.updateAppIconInfo(applicationRelease, oldPackageName);
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = e.getMessage();

@ -362,6 +362,18 @@
<groupId>io.entgra.device.mgt.core</groupId>
<artifactId>io.entgra.device.mgt.core.notification.logger</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1.wso2v1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.wso2.orbit.javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1.wso2v1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

@ -63,4 +63,55 @@ public interface ApplicationDAO {
* @throws DeviceManagementDAOException If any database error occured
*/
List<String> getAppVersions(int tenantId, String packageName) throws DeviceManagementDAOException;
/**
* This method is used to save application icon information.
* @param iconPath Icon path of the application
* @param packageName Package name of the application
* @param version version of the application
* @throws DeviceManagementDAOException If any database error occurred
*/
void saveApplicationIcon(String iconPath, String packageName, String version, int tenantId) throws DeviceManagementDAOException;
/**
* This method is used to check the package existence.
* @param packageName Package name of the application
* @throws DeviceManagementDAOException If any database error occurred
*/
int getApplicationPackageCount(String packageName) throws DeviceManagementDAOException;
/**
* This method is used to update application icon information.
* @param iconPath Icon path of the application
* @param oldPackageName Old package name of the application
* @param newPackageName New package name of the application
* @param version Version of the application
* @throws DeviceManagementDAOException If any database error occurred
*/
void updateApplicationIcon(String iconPath, String oldPackageName, String newPackageName, String version) throws DeviceManagementDAOException;
/**
* This method is used to delete application icon information.
* @param packageName Package name of the application
* @throws DeviceManagementDAOException If any database error occurred
*/
void deleteApplicationIcon(String packageName) throws DeviceManagementDAOException;
/**
* This method is used to get the installed application list of a specific device
* @param deviceId ID of the device
* @param enrolmentId Enrolment ID of the device
* @param tenantId tenant ID
* @throws DeviceManagementDAOException If any database error occurred
*/
List<Application> getInstalledApplicationListOnDevice(int deviceId, int enrolmentId, int offset, int limit, int tenantId)
throws DeviceManagementDAOException;
/**
* This method is used to retrieve the icon info of an installed app in device.
* @param applicationIdentifier application identifier.
* @return returns the application icon path.
* @throws DeviceManagementDAOException
*/
String getIconPath(String applicationIdentifier) throws DeviceManagementDAOException;
}

@ -34,7 +34,9 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
@ -394,4 +396,178 @@ public class ApplicationDAOImpl implements ApplicationDAO {
return application;
}
@Override
public void saveApplicationIcon(String iconPath, String packageName, String version, int tenantId)
throws DeviceManagementDAOException{
Connection conn;
String sql = "INSERT INTO DM_APP_ICONS " +
"(ICON_PATH, " +
"PACKAGE_NAME, " +
"VERSION, " +
"CREATED_TIMESTAMP, " +
"TENANT_ID) " +
"VALUES (?, ?, ?, ?, ?)";
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1,iconPath);
stmt.setString(2,packageName);
stmt.setString(3,version);
stmt.setTimestamp(4, new Timestamp(new Date().getTime()));
stmt.setInt(5, tenantId);
stmt.executeUpdate();
}
} catch (SQLException e) {
String msg = "Error occurred while saving application icon details";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
@Override
public int getApplicationPackageCount(String packageName) throws DeviceManagementDAOException{
Connection conn;
String sql = "SELECT " +
"COUNT(*) AS APP_PACKAGE_COUNT " +
"FROM DM_APP_ICONS " +
"WHERE PACKAGE_NAME = ?";
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, packageName);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("APP_PACKAGE_COUNT");
}
return 0;
}
}
} catch (SQLException e) {
String msg = "Error occurred while getting application icon details";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
@Override
public void updateApplicationIcon(String iconPath, String oldPackageName, String newPackageName, String version)
throws DeviceManagementDAOException{
Connection conn;
String sql = "UPDATE DM_APP_ICONS " +
"SET " +
"ICON_PATH= ?, " +
"PACKAGE_NAME = ?, " +
"VERSION = ? " +
"WHERE PACKAGE_NAME = ?";
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1,iconPath);
stmt.setString(2,newPackageName);
stmt.setString(3,version);
stmt.setString(4,oldPackageName);
stmt.executeUpdate();
}
} catch (SQLException e) {
String msg = "Error occurred while updating application icon details";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
@Override
public void deleteApplicationIcon(String packageName) throws DeviceManagementDAOException {
Connection conn;
String sql = "DELETE " +
"FROM DM_APP_ICONS " +
"WHERE PACKAGE_NAME = ?";
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, packageName);
stmt.executeUpdate();
}
} catch (SQLException e) {
String msg = "Error occurred while deleting application icon details";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
@Override
public String getIconPath(String applicationIdentifier) throws DeviceManagementDAOException{
Connection conn;
String sql = "SELECT " +
"ICON_PATH " +
"FROM DM_APP_ICONS " +
"WHERE PACKAGE_NAME = ?";
String iconPath = null;
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1,applicationIdentifier);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
iconPath = rs.getString("ICON_PATH");
}
return iconPath;
}
}
} catch (SQLException e) {
String msg = "Error occurred while retrieving app icon path of the application";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
@Override
public List<Application> getInstalledApplicationListOnDevice(int deviceId, int enrolmentId, int offset, int limit, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
List<Application> applicationList = new ArrayList<>();
Application application;
String sql = "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 DEVICE_ID = ? AND " +
"ENROLMENT_ID = ? AND " +
"TENANT_ID = ? " +
"LIMIT ? " +
"OFFSET ?";
try {
conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.setInt(3, tenantId);
stmt.setInt(4, limit);
stmt.setInt(5, offset);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
application = loadApplication(rs);
applicationList.add(application);
}
}
}
} catch (SQLException e) {
String msg = "SQL Error occurred while retrieving the list of Applications " +
"installed in device id '" + deviceId;
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
return applicationList;
}
}

@ -18,6 +18,7 @@
package io.entgra.device.mgt.core.device.mgt.core.service;
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application;
import org.apache.commons.collections.map.SingletonMap;
import io.entgra.device.mgt.core.device.mgt.common.*;
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException;
@ -1017,4 +1018,42 @@ public interface DeviceManagementProviderService {
throws DeviceManagementException;
Boolean sendDeviceNameChangedNotification(Device device) throws DeviceManagementException;
/**
* This method is for saving application icon info
* @param iconPath Icon path of the application
* @param packageName Package name of the application
* @param version Version of the application
* @param tenantId Tenant ID of the application created user
* @throws DeviceManagementException if any service level or DAO level error occurs
*/
void saveApplicationIcon(String iconPath, String packageName, String version, int tenantId)
throws DeviceManagementException;
/**
* This method is for updating application icon info
* @param iconPath Icon path of the application
* @param oldPackageName Old package name of the application
* @param newPackageName New package name of the application
* @param version Version of the application
* @throws DeviceManagementException if any service level or DAO level error occurs
*/
void updateApplicationIcon(String iconPath, String oldPackageName, String newPackageName, String version)
throws DeviceManagementException;
/**
* This method is for deleting application icon info
* @param packageName Package name of the application
* @throws DeviceManagementException if any service level or DAO level error occurs
*/
void deleteApplicationIcon(String packageName) throws DeviceManagementException;
/**
* This method is for getting the installed application list of a device
* @param device {@link Device}
* @return list of applications {@link Application}
* @throws DeviceManagementException if any service level or DAO level error occurs
*/
List<Application> getInstalledApplicationsOnDevice(Device device, int offset, int limit)
throws DeviceManagementException;
}

@ -4899,4 +4899,130 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
throw new DeviceManagementException(msg, e);
}
}
@Override
public void saveApplicationIcon(String iconPath, String packageName, String version, int tenantId) throws DeviceManagementException{
try{
DeviceManagementDAOFactory.beginTransaction();
if(applicationDAO.getApplicationPackageCount(packageName) == 0){
applicationDAO.saveApplicationIcon(iconPath, packageName, version, tenantId);
}
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
String msg = "Error occurred while initiating transaction";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while saving app icon. Icon Path: " + iconPath +
" Package Name: " + packageName +
" Version: " + version +
" Tenant Id: " + tenantId;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
}
@Override
public void updateApplicationIcon(String iconPath, String oldPackageName, String newPackageName, String version)
throws DeviceManagementException{
try {
DeviceManagementDAOFactory.beginTransaction();
applicationDAO.updateApplicationIcon(iconPath, oldPackageName, newPackageName, version);
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
String msg = "Error occurred while initiating transaction";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while updating app icon info." +
" Package Name: " + oldPackageName;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
}
@Override
public void deleteApplicationIcon(String packageName)
throws DeviceManagementException {
try {
DeviceManagementDAOFactory.beginTransaction();
applicationDAO.deleteApplicationIcon(packageName);
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
String msg = "Error occurred while initiating transaction";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting app icon info." +
" Package Name: " + packageName ;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
}
private List<Application> getInstalledAppIconInfo(List<Application> applications) throws DeviceManagementException {
String iconPath;
try {
DeviceManagementDAOFactory.openConnection();
for (Application app : applications) {
iconPath = applicationDAO.getIconPath(app.getApplicationIdentifier());
app.setImageUrl(iconPath);
}
} catch (DeviceManagementDAOException e) {
String msg = "Error occurred while retrieving installed app icon info";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while opening a connection to the data source";
log.error(msg);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return applications;
}
@Override
public List<Application> getInstalledApplicationsOnDevice(Device device, int offset, int limit) throws DeviceManagementException {
List<Application> applications;
try {
DeviceManagementDAOFactory.openConnection();
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
applications = applicationDAO.getInstalledApplicationListOnDevice(device.getId(),
device.getEnrolmentInfo().getId(), offset, limit, tenantId);
if (applications == null) {
String msg = "Couldn't found applications for device identifier '" + device.getId() + "'";
log.error(msg);
throw new DeviceManagementException(msg);
}
} catch (DeviceManagementDAOException e) {
String msg = "Error occurred while retrieving the application list of android device, " +
"which carries the id '" + device.getId() + "'";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while opening a connection to the data source";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
List<Application> newApplicationList;
newApplicationList = this.getInstalledAppIconInfo(applications);
if (newApplicationList == null) {
String msg = "Error occurred while getting app icon info for device identifier '" + device.getId() + "'";
log.error(msg);
throw new DeviceManagementException(msg);
}
return newApplicationList;
}
}

@ -417,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
-- POLICY RELATED TABLES FINISHED --
CREATE TABLE IF NOT EXISTS DM_APP_ICONS (
ID INTEGER AUTO_INCREMENT NOT NULL,
ICON_PATH VARCHAR(150) DEFAULT NULL,
PACKAGE_NAME VARCHAR(150) NOT NULL,
VERSION VARCHAR(50) DEFAULT '1.1.0',
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
);
-- NOTIFICATION TABLE --
CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL,

@ -462,6 +462,17 @@ CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENAN
-- POLICY RELATED TABLES FINISHED --
IF NOT EXISTS (SELECT * SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_APP_ICONS]') AND TYPE IN (N'U'))
CREATE TABLE DM_APP_ICONS (
ID INTEGER IDENTITY(1,1) NOT NULL,
ICON_PATH VARCHAR(150) DEFAULT NULL,
PACKAGE_NAME VARCHAR(150) NOT NULL,
VERSION VARCHAR(50) DEFAULT '1.1.0',
CREATED_TIMESTAMP DATETIME2 NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
);
-- POLICY AND DEVICE GROUP MAPPING --
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_POLICY]') AND TYPE IN (N'U'))
CREATE TABLE DM_DEVICE_GROUP_POLICY (

@ -458,6 +458,16 @@ CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENAN
-- END OF POLICY RELATED TABLES --
CREATE TABLE IF NOT EXISTS DM_APP_ICONS (
ID INTEGER AUTO_INCREMENT NOT NULL,
ICON_PATH VARCHAR(150) DEFAULT NULL,
PACKAGE_NAME VARCHAR(150) NOT NULL,
VERSION VARCHAR(50) DEFAULT '1.1.0',
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
)ENGINE = InnoDB;
-- POLICY AND DEVICE GROUP MAPPING --
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (

@ -748,6 +748,28 @@ WHEN (NEW.ID IS NULL)
-- POLICY RELATED TABLES FINISHED --
CREATE TABLE DM_APP_ICONS (
ID NUMBER(10) NOT NULL,
ICON_PATH VARCHAR2(150) DEFAULT NULL,
PACKAGE_NAME VARCHAR2(150) NOT NULL,
VERSION VARCHAR2(50) DEFAULT '1.1.0',
CREATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
TENANT_ID NUMBER(10) NOT NULL,
PRIMARY KEY (ID)
)
/
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_APP_ICONS_seq START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER DM_APP_ICONS_seq_tr
BEFORE INSERT ON DM_APP_ICONS FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_APP_ICONS_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
-- NOTIFICATION TABLE --
CREATE TABLE DM_NOTIFICATION (
NOTIFICATION_ID NUMBER(10) NOT NULL,

@ -490,6 +490,19 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
-- END OF POLICY RELATED TABLES --
CREATE SEQUENCE DM_APP_ICONS_seq;
CREATE TABLE IF NOT EXISTS DM_APP_ICONS (
ID INTEGER DEFAULT NEXTVAL ('DM_APP_ICONS_seq') NOT NULL,
ICON_PATH VARCHAR(150) DEFAULT NULL,
PACKAGE_NAME VARCHAR(150) NOT NULL,
VERSION VARCHAR(50) DEFAULT '1.1.0',
CREATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
)
;
-- POLICY AND DEVICE GROUP MAPPING --
CREATE SEQUENCE DM_DEVICE_GROUP_POLICY_seq;

Loading…
Cancel
Save