Merge branch 'app_restriction_policy_issue' into 'master'

Add a searchable input for App Restriction Settings policy

See merge request entgra/carbon-device-mgt!916
license
Pahansith Gunathilake 2 years ago
commit 94ac25deab

@ -2623,7 +2623,9 @@ public interface DeviceManagementService {
@GET
@Path("/{deviceType}/applications")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of Applications",
@ -2681,7 +2683,12 @@ public interface DeviceManagementService {
value = "Provide how many device details you require from the starting pagination index/offset.",
defaultValue = "10")
@QueryParam("limit")
int limit);
int limit,
@ApiParam(
name = "appName",
value = "App name to be searched")
@QueryParam("appName")
String appName);
@GET
@Path("/application/{packageName}/versions")

@ -131,6 +131,7 @@ import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.validation.constraints.Size;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
@ -1605,16 +1606,19 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Override
@Consumes("application/json")
@Path("/{deviceType}/applications")
public Response getApplications(
@PathParam("deviceType") String deviceType,
@DefaultValue("0")
@QueryParam("offset") int offset,
@DefaultValue("10")
@QueryParam("limit") int limit) {
@QueryParam("limit") int limit,
@QueryParam("appName") String appName) {
PaginationRequest request = new PaginationRequest(offset, limit);
ApplicationList applicationList = new ApplicationList();
request.setDeviceType(deviceType);
request.setFilter(appName);
try {
PaginationResult paginationResult = DeviceMgtAPIUtils
.getDeviceManagementService()

@ -32,6 +32,7 @@ public class Column {
private Input input;
private Upload upload;
private Checkbox checkbox;
private SearchInput searchInput;
private boolean isRequired;
private String tooltip;
private String docLink;
@ -100,6 +101,15 @@ public class Column {
this.checkbox = checkbox;
}
@XmlElement(name = "SearchInput")
public SearchInput getSearchInput() {
return searchInput;
}
public void setSearchInput(SearchInput searchInput) {
this.searchInput = searchInput;
}
@XmlElement(name = "RequiredItem")
public boolean isRequired() {
return isRequired;

@ -45,6 +45,7 @@ public class Item {
private APITable apiTable;
private Text text;
private InputList inputList;
private SearchInput searchInput;
private String nullableValue;
private String divider;
private boolean isHidden;
@ -212,6 +213,15 @@ public class Item {
this.inputList = inputList;
}
@XmlElement(name = "SearchInput")
public SearchInput getSearchInput() {
return searchInput;
}
public void setSearchInput(SearchInput searchInput) {
this.searchInput = searchInput;
}
@XmlElement(name = "NullableValue")
public String getNullableValue() {
return nullableValue;

@ -0,0 +1,108 @@
/* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.policy.mgt.ui;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "SearchInput")
public class SearchInput {
private String valueType;
private String placeholderValue;
private String apiUrl;
private String defineValueKey;
private String displayValueKey;
private String arrayPath;
private String paramValue;
private String iteratorKeyValue;
@XmlElement(name = "Url")
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
@XmlElement(name = "DefineValueKey")
public String getDefineValueKey() {
return defineValueKey;
}
public void setDefineValueKey(String defineValueKey) {
this.defineValueKey = defineValueKey;
}
@XmlElement(name = "DisplayValueKey")
public String getDisplayValueKey() {
return displayValueKey;
}
public void setDisplayValueKey(String displayValueKey) {
this.displayValueKey = displayValueKey;
}
@XmlElement(name = "ArrayPath")
public String getArrayPath() {
return arrayPath;
}
public void setArrayPath(String arrayPath) {
this.arrayPath = arrayPath;
}
@XmlElement(name = "ValueType", required = true)
public String getValueType() {
return valueType;
}
public void setValueType(String valueType) {
this.valueType = valueType;
}
@XmlElement(name = "Placeholder")
public String getPlaceholderValue() {
return placeholderValue;
}
public void setPlaceholderValue(String placeholderValue) {
this.placeholderValue = placeholderValue;
}
@XmlElement(name = "ParamValue")
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
@XmlElement(name = "IteratorKeyValue")
public String getIteratorKeyValue() {
return iteratorKeyValue;
}
public void setIteratorKeyValue(String iteratorKeyValue) {
this.iteratorKeyValue = iteratorKeyValue;
}
}

@ -292,14 +292,24 @@ public class ApplicationDAOImpl implements ApplicationDAO {
"WHERE A.NAME = DM_APPLICATION.NAME " +
"AND A.ID < DM_APPLICATION.ID) " +
"AND PLATFORM = ? " +
"AND TENANT_ID = ? LIMIT ? OFFSET ?";
"AND TENANT_ID = ?";
try {
String filter = request.getFilter();
if (filter != null) {
sql = sql + "AND NAME LIKE ?";
}
sql = sql + "LIMIT ? OFFSET ?";
Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, request.getDeviceType());
stmt.setInt(2, tenantId);
stmt.setInt(3, request.getRowCount());
stmt.setInt(4, request.getStartIndex());
int paramIdx = 1;
stmt.setString(paramIdx++, request.getDeviceType());
stmt.setInt(paramIdx++, tenantId);
if (filter != null){
stmt.setString(paramIdx++, filter);
}
stmt.setInt(paramIdx++, request.getRowCount());
stmt.setInt(paramIdx, request.getStartIndex());
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
application = loadApplication(rs);

Loading…
Cancel
Save