Add device name and owner to response

Add device name and owner to getAllComplianceDevices response which gives compliance status of all devices
feature/appm-store/pbac
Shamalka Navod 5 years ago committed by Dharmakeerthi Lasantha
parent ec0c5fde39
commit 300d9b9002

@ -37,9 +37,11 @@ class DeviceStatusReport extends React.Component {
this.state = { this.state = {
paramsObject: { paramsObject: {
from: moment() from: moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
to: moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
to: moment().format('YYYY-MM-DD'),
}, },
data: [], data: [],
fields: [], fields: [],
@ -62,17 +64,21 @@ class DeviceStatusReport extends React.Component {
case 'weekly': case 'weekly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
case 'monthly': case 'monthly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(30, 'days') .subtract(29, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
} }

@ -37,9 +37,11 @@ class EnrollmentTypeReport extends React.Component {
this.state = { this.state = {
paramsObject: { paramsObject: {
from: moment() from: moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
to: moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
to: moment().format('YYYY-MM-DD'),
}, },
data: [], data: [],
fields: [], fields: [],
@ -66,17 +68,21 @@ class EnrollmentTypeReport extends React.Component {
case 'weekly': case 'weekly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
case 'monthly': case 'monthly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(30, 'days') .subtract(29, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
} }

@ -37,9 +37,11 @@ class EnrollmentsVsUnenrollmentsReport extends React.Component {
this.state = { this.state = {
paramsObject: { paramsObject: {
from: moment() from: moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
to: moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
to: moment().format('YYYY-MM-DD'),
}, },
data: [], data: [],
fields: [], fields: [],
@ -66,17 +68,21 @@ class EnrollmentsVsUnenrollmentsReport extends React.Component {
case 'weekly': case 'weekly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
case 'monthly': case 'monthly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(30, 'days') .subtract(29, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
} }

@ -42,9 +42,11 @@ class PolicyReport extends React.Component {
// This object contains parameters which pass into API endpoint // This object contains parameters which pass into API endpoint
policyReportData: { policyReportData: {
from: moment() from: moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
to: moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
to: moment().format('YYYY-MM-DD'),
}, },
visible: false, visible: false,
}; };
@ -60,26 +62,30 @@ class PolicyReport extends React.Component {
switch (durationMode) { switch (durationMode) {
case 'daily': case 'daily':
this.updateDurationValue( this.updateDurationValue(
moment().format('YYYY-MM-DD'),
moment() moment()
.subtract(1, 'days') .add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
case 'weekly': case 'weekly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(7, 'days') .subtract(6, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
case 'monthly': case 'monthly':
this.updateDurationValue( this.updateDurationValue(
moment() moment()
.subtract(30, 'days') .subtract(29, 'days')
.format('YYYY-MM-DD'),
moment()
.add(1, 'days')
.format('YYYY-MM-DD'), .format('YYYY-MM-DD'),
moment().format('YYYY-MM-DD'),
); );
break; break;
} }

@ -60,7 +60,7 @@ class SelectPolicyDropDown extends React.Component {
if (res.status === 200) { if (res.status === 200) {
this.setState({ this.setState({
loading: false, loading: false,
data: JSON.parse(res.data.data), data: res.data.data.policies,
}); });
} }
}) })

@ -170,12 +170,12 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP(); PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
policies = policyAdministratorPoint.getPolicies(); policies = policyAdministratorPoint.getPolicies();
if(offset == 0 && limit == 0){ if(offset == 0 && limit == 0){
return Response.status(Response.Status.OK).entity(policies).build(); targetPolicies.setCount(policies.size());
targetPolicies.setList(policies);
}else{ }else{
targetPolicies.setCount(policies.size()); targetPolicies.setCount(policies.size());
filteredPolicies = FilteringUtil.getFilteredList(policies, offset, limit); filteredPolicies = FilteringUtil.getFilteredList(policies, offset, limit);
targetPolicies.setList(filteredPolicies); targetPolicies.setList(filteredPolicies);
return Response.status(Response.Status.OK).entity(targetPolicies).build();
} }
} catch (PolicyManagementException e) { } catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving all available policies"; String msg = "Error occurred while retrieving all available policies";
@ -183,8 +183,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
return Response.status(Response.Status.OK).entity(targetPolicies).build();
} }
@GET @GET

@ -35,8 +35,12 @@
package org.wso2.carbon.device.mgt.core.dao; package org.wso2.carbon.device.mgt.core.dao;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo.Status; import org.wso2.carbon.device.mgt.common.EnrolmentInfo.Status;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.Count;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory;
import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo; import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceData; import org.wso2.carbon.device.mgt.common.device.details.DeviceData;

@ -605,10 +605,11 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
sql = sql + " AND e.OWNERSHIP = ?"; sql = sql + " AND e.OWNERSHIP = ?";
} }
sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ?,?"; sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ? OFFSET ?";
try (Connection conn = this.getConnection(); try {
PreparedStatement stmt = conn.prepareStatement(sql)) { Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
stmt.setString(paramIdx++, fromDate); stmt.setString(paramIdx++, fromDate);
@ -621,8 +622,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
if (ownership != null) { if (ownership != null) {
stmt.setString(paramIdx++, ownership); stmt.setString(paramIdx++, ownership);
} }
stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getRowCount());
stmt.setInt(paramIdx, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex());
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) { while (rs.next()) {
Count count = new Count( Count count = new Count(
@ -632,12 +633,14 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
countList.add(count); countList.add(count);
} }
} }
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving information of all " + String msg = "Error occurred while retrieving information of all " +
"registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate; "registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate;
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementDAOException(msg, e); throw new DeviceManagementDAOException(msg, e);
} }
return countList; return countList;
} }

@ -557,8 +557,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (Connection conn = this.getConnection(); try {
PreparedStatement stmt = conn.prepareStatement(sql)) { Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
stmt.setString(paramIdx++, fromDate); stmt.setString(paramIdx++, fromDate);
@ -582,6 +583,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
countList.add(count); countList.add(count);
} }
} }
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving information of all " + String msg = "Error occurred while retrieving information of all " +
"registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate; "registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate;

@ -536,8 +536,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ? OFFSET ?"; sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ? OFFSET ?";
try (Connection conn = this.getConnection(); try {
PreparedStatement stmt = conn.prepareStatement(sql)) { Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
stmt.setString(paramIdx++, fromDate); stmt.setString(paramIdx++, fromDate);
@ -561,6 +562,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
countList.add(count); countList.add(count);
} }
} }
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving information of all " + String msg = "Error occurred while retrieving information of all " +
"registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate; "registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate;

@ -701,8 +701,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (Connection conn = this.getConnection(); try {
PreparedStatement stmt = conn.prepareStatement(sql)) { Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
stmt.setString(paramIdx++, fromDate); stmt.setString(paramIdx++, fromDate);
@ -726,6 +727,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
countList.add(count); countList.add(count);
} }
} }
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving information of all " + String msg = "Error occurred while retrieving information of all " +
"registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate; "registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate;

@ -203,7 +203,7 @@ public class ReportManagementServiceImpl implements ReportManagementService {
} }
} else { } else {
for (Count count : countList) { for (Count count : countList) {
resultObject.addProperty(count.getDate(), count.getCount()); resultObject.addProperty(count.getDate() + " - " + count.getDate(), count.getCount());
} }
} }
return resultObject; return resultObject;

Loading…
Cancel
Save