revert-70aa11f8
Pasindu 8 years ago
commit 02164b54e1

@ -345,11 +345,11 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
public Response updatePolicyPriorities(List<PriorityUpdatedPolicyWrapper> priorityUpdatedPolicies) { public Response updatePolicyPriorities(List<PriorityUpdatedPolicyWrapper> priorityUpdatedPolicies) {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
List<Policy> policiesToUpdate = new ArrayList<>(priorityUpdatedPolicies.size()); List<Policy> policiesToUpdate = new ArrayList<>(priorityUpdatedPolicies.size());
int i;
for (i = 0; i < priorityUpdatedPolicies.size(); i++) { for (PriorityUpdatedPolicyWrapper priorityUpdatedPolicy : priorityUpdatedPolicies) {
Policy policyObj = new Policy(); Policy policyObj = new Policy();
policyObj.setId(priorityUpdatedPolicies.get(i).getId()); policyObj.setId(priorityUpdatedPolicy.getId());
policyObj.setPriorityId(priorityUpdatedPolicies.get(i).getPriority()); policyObj.setPriorityId(priorityUpdatedPolicy.getPriority());
policiesToUpdate.add(policyObj); policiesToUpdate.add(policyObj);
} }
boolean policiesUpdated; boolean policiesUpdated;

@ -151,7 +151,7 @@ public class OperationManagerImpl implements OperationManager {
// check whether device list is greater than batch size notification strategy has enable to send push // check whether device list is greater than batch size notification strategy has enable to send push
// notification using scheduler task // notification using scheduler task
if (DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). if (DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
getPushNotificationConfiguration().getSchedulerBatchSize() < authorizedDeviceList.size() && getPushNotificationConfiguration().getSchedulerBatchSize() <= authorizedDeviceList.size() &&
notificationStrategy != null) { notificationStrategy != null) {
isScheduled = notificationStrategy.getConfig().isScheduled(); isScheduled = notificationStrategy.getConfig().isScheduled();
} }

@ -27,6 +27,7 @@ public class OperationMapping {
private DeviceIdentifier deviceIdentifier; private DeviceIdentifier deviceIdentifier;
private int operationId; private int operationId;
private int enrollmentId;
private int tenantId; private int tenantId;
private Operation.Status status; private Operation.Status status;
private Operation.PushNotificationStatus pushNotificationStatus; private Operation.PushNotificationStatus pushNotificationStatus;
@ -39,6 +40,14 @@ public class OperationMapping {
this.operationId = operationId; this.operationId = operationId;
} }
public int getEnrollmentId() {
return enrollmentId;
}
public void setEnrollmentId(int enrollmentId) {
this.enrollmentId = enrollmentId;
}
public int getTenantId() { public int getTenantId() {
return tenantId; return tenantId;
} }

@ -1104,10 +1104,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>(); Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>();
try { try {
conn = OperationManagementDAOFactory.getConnection(); conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, dt.NAME ,d.TENANT_ID FROM DM_DEVICE d, " + String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, d.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE, " +
"DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? AND " + "d.TENANT_ID FROM DM_DEVICE d, DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ?" +
"op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID ORDER BY " + " AND op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID ORDER" +
"op.OPERATION_ID LIMIT ?"; " BY op.OPERATION_ID LIMIT ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, opStatus.toString()); stmt.setString(1, opStatus.toString());
stmt.setString(2, pushNotificationStatus.toString()); stmt.setString(2, pushNotificationStatus.toString());
@ -1122,8 +1122,11 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
operationMapping = new OperationMapping(); operationMapping = new OperationMapping();
operationMapping.setOperationId(rs.getInt("OPERATION_ID")); operationMapping.setOperationId(rs.getInt("OPERATION_ID"));
operationMapping.setDeviceIdentifier(new DeviceIdentifier(String.valueOf(rs.getInt("ENROLMENT_ID")), DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
rs.getString("NAME"))); deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
operationMapping.setDeviceIdentifier(deviceIdentifier);
operationMapping.setEnrollmentId(rs.getInt("ENROLMENT_ID"));
operationMapping.setTenantId(tenantID); operationMapping.setTenantId(tenantID);
operationMappings.add(operationMapping); operationMappings.add(operationMapping);
} }

@ -109,7 +109,7 @@ public class OperationMappingDAOImpl implements OperationMappingDAO {
if (conn.getMetaData().supportsBatchUpdates()) { if (conn.getMetaData().supportsBatchUpdates()) {
for (OperationMapping operationMapping : operationMappingList) { for (OperationMapping operationMapping : operationMappingList) {
stmt.setString(1, operationMapping.getPushNotificationStatus().toString()); stmt.setString(1, operationMapping.getPushNotificationStatus().toString());
stmt.setInt(2, Integer.parseInt(operationMapping.getDeviceIdentifier().getId())); stmt.setInt(2, operationMapping.getEnrollmentId());
stmt.setInt(3, operationMapping.getOperationId()); stmt.setInt(3, operationMapping.getOperationId());
stmt.addBatch(); stmt.addBatch();
} }
@ -117,7 +117,7 @@ public class OperationMappingDAOImpl implements OperationMappingDAO {
} else { } else {
for (OperationMapping operationMapping : operationMappingList) { for (OperationMapping operationMapping : operationMappingList) {
stmt.setString(1, operationMapping.getPushNotificationStatus().toString()); stmt.setString(1, operationMapping.getPushNotificationStatus().toString());
stmt.setInt(2, Integer.parseInt(operationMapping.getDeviceIdentifier().getId())); stmt.setInt(2, operationMapping.getEnrollmentId());
stmt.setInt(3, operationMapping.getOperationId()); stmt.setInt(3, operationMapping.getOperationId());
stmt.executeUpdate(); stmt.executeUpdate();
} }

@ -376,10 +376,10 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>(); Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>();
try { try {
Connection conn = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, dt.NAME ,d.TENANT_ID FROM DM_DEVICE d, " + String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, d.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE, d" +
"DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? AND op" + ".TENANT_ID FROM DM_DEVICE d, DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? " +
".PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID AND ROWNUM" + "AND op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID AND d.ID=op.ENROLMENT_ID AND " +
" <= ? ORDER BY op.OPERATION_ID"; "ROWNUM <= ? ORDER BY op.OPERATION_ID";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, opStatus.toString()); stmt.setString(1, opStatus.toString());
@ -395,8 +395,11 @@ public class OracleOperationDAOImpl extends GenericOperationDAOImpl {
} }
operationMapping = new OperationMapping(); operationMapping = new OperationMapping();
operationMapping.setOperationId(rs.getInt("OPERATION_ID")); operationMapping.setOperationId(rs.getInt("OPERATION_ID"));
operationMapping.setDeviceIdentifier(new DeviceIdentifier(String.valueOf(rs.getInt("ENROLMENT_ID")), DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
rs.getString("NAME"))); deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
operationMapping.setDeviceIdentifier(deviceIdentifier);
operationMapping.setEnrollmentId(rs.getInt("ENROLMENT_ID"));
operationMapping.setTenantId(tenantID); operationMapping.setTenantId(tenantID);
operationMappings.add(operationMapping); operationMappings.add(operationMapping);
} }

@ -277,9 +277,9 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>(); Map<Integer, List<OperationMapping>> operationMappingsTenantMap = new HashMap<>();
try { try {
Connection conn = OperationManagementDAOFactory.getConnection(); Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, dt.NAME ,d.TENANT_ID FROM DM_DEVICE d, " + String sql = "SELECT op.ENROLMENT_ID, op.OPERATION_ID, d.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE, d" +
"DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? AND op" + ".TENANT_ID FROM DM_DEVICE d, DM_ENROLMENT_OP_MAPPING op, DM_DEVICE_TYPE dt WHERE op.STATUS = ? " +
".PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID " + "AND op.PUSH_NOTIFICATION_STATUS = ? AND d.DEVICE_TYPE_ID = dt.ID " +
"AND d.ID=op.ENROLMENT_ID ORDER BY op.OPERATION_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; "AND d.ID=op.ENROLMENT_ID ORDER BY op.OPERATION_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, opStatus.toString()); stmt.setString(1, opStatus.toString());
@ -295,8 +295,11 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
} }
operationMapping = new OperationMapping(); operationMapping = new OperationMapping();
operationMapping.setOperationId(rs.getInt("OPERATION_ID")); operationMapping.setOperationId(rs.getInt("OPERATION_ID"));
operationMapping.setDeviceIdentifier(new DeviceIdentifier(String.valueOf(rs.getInt("ENROLMENT_ID")), DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
rs.getString("NAME"))); deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
operationMapping.setDeviceIdentifier(deviceIdentifier);
operationMapping.setEnrollmentId(rs.getInt("ENROLMENT_ID"));
operationMapping.setTenantId(tenantID); operationMapping.setTenantId(tenantID);
operationMappings.add(operationMapping); operationMappings.add(operationMapping);
} }

@ -77,7 +77,7 @@ public class PushNotificationSchedulerTask implements Runnable {
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Sending push notification for operationId :" + operationMapping.getOperationId() + log.debug("Sending push notification for operationId :" + operationMapping.getOperationId() +
"to deviceId : " + operationMapping.getDeviceIdentifier().getId()); " to deviceId : " + operationMapping.getDeviceIdentifier().getId());
} }
// Set tenant id and domain // Set tenant id and domain
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();

@ -41,7 +41,7 @@
"id": "device_cloud", "id": "device_cloud",
"url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation", "url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation",
"icon": "fw fw-mobile", "icon": "fw fw-mobile",
"target": "_self" "target": "_blank"
} }
} }
} }

@ -86,6 +86,14 @@ var operationModule = function () {
var iconIdentifier = operations[op].operation; var iconIdentifier = operations[op].operation;
if (features && features[iconIdentifier]) { if (features && features[iconIdentifier]) {
var icon = features[iconIdentifier].icon; var icon = features[iconIdentifier].icon;
var isCloud = devicemgtProps["isCloud"];
//TODO: remove isCloud check once able to verify features from the device agent
var isDisabled = features[iconIdentifier].isDisabled;
if (isDisabled && isCloud) {
operations[op]["isDisabled"] = isDisabled;
} else {
operations[op]["isDisabled"] = false;
}
if (icon) { if (icon) {
operations[op]["iconFont"] = icon; operations[op]["iconFont"] = icon;
} else if (iconPath) { } else if (iconPath) {

@ -266,3 +266,8 @@ header .username {
.add-padding-top-3x { .add-padding-top-3x {
padding-top: 15px !important; padding-top: 15px !important;
} }
.op-disabled, .op-disabled i, .op-disabled span {
cursor: not-allowed;
+ color: #d2d2d2;
}

Loading…
Cancel
Save