use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean in project identity-api-server by wso2.
the class ServerApplicationManagementService method getSearchCondition.
/**
* Retrieve search condition from @{SearchContext}.
*
* @param templateType Template type.
* @param tenantDomain Tenant domain.
* @param searchContext Search context.
* @return Condition.
*/
private Condition getSearchCondition(String templateType, String tenantDomain, SearchContext searchContext) {
if (searchContext != null) {
SearchCondition<ResourceSearchBean> searchCondition = searchContext.getCondition(ResourceSearchBean.class);
if (searchCondition != null) {
Condition result = buildSearchCondition(searchCondition);
List<Condition> list = new ArrayList<>();
Condition typeCondition = new PrimitiveCondition(ApplicationManagementConstants.TemplateProperties.TEMPLATE_TYPE_KEY, EQUALS, templateType);
Condition tenantCondition = new PrimitiveCondition(ApplicationManagementConstants.TemplateProperties.TENANT_DOMAIN_KEY, EQUALS, tenantDomain);
if (result instanceof ComplexCondition) {
list = ((ComplexCondition) result).getConditions();
list.add(typeCondition);
list.add(tenantCondition);
} else if (result instanceof PrimitiveCondition) {
list.add(result);
list.add(typeCondition);
list.add(tenantCondition);
}
return new ComplexCondition(getComplexOperatorFromOdata(ConditionType.AND), list);
} else {
if (log.isDebugEnabled()) {
log.debug("Search condition parsed from the search expression is invalid.");
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Cannot find a valid search context.");
}
}
return null;
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method buildPlaceholderSQL.
private PlaceholderSQL buildPlaceholderSQL(Condition condition, boolean useCreatedTime) throws ConfigurationManagementException {
String queryWithCreatedTime = GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL;
String queryWithOutCreatedTime = GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME;
try {
if (isOracleDB() || isMSSqlDB()) {
queryWithCreatedTime = GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE;
}
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_CHECK_DB_METADATA, e.getMessage(), e);
}
StringBuilder sb = new StringBuilder();
sb.append(useCreatedTime ? queryWithCreatedTime : queryWithOutCreatedTime);
sb.append("WHERE\n");
try {
PlaceholderSQL placeholderSQL = condition.buildQuery(new PrimitiveConditionValidator(new ResourceSearchBean()));
placeholderSQL.setQuery(sb.append(placeholderSQL.getQuery()).toString());
return placeholderSQL;
} catch (PrimitiveConditionValidationException e) {
throw handleClientException(ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR, e.getMessage(), e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean in project identity-api-server by wso2.
the class ServerIdpManagementService method getSearchCondition.
/**
* Retrieve search condition from @{SearchContext}.
*
* @param templateType Template type.
* @param tenantDomain Tenant domain.
* @param searchContext Search context.
* @return Condition.
*/
private Condition getSearchCondition(String templateType, String tenantDomain, SearchContext searchContext) {
if (searchContext != null) {
SearchCondition<ResourceSearchBean> searchCondition = searchContext.getCondition(ResourceSearchBean.class);
if (searchCondition != null) {
Condition result = buildSearchCondition(searchCondition);
Condition typeCondition = new PrimitiveCondition(Constants.TEMPLATE_TYPE_KEY, EQUALS, templateType);
Condition tenantCondition = new PrimitiveCondition(Constants.TENANT_DOMAIN_KEY, EQUALS, tenantDomain);
List<Condition> list = new ArrayList<>();
list.add(result);
list.add(typeCondition);
list.add(tenantCondition);
return new ComplexCondition(getComplexOperatorFromOdata(ConditionType.AND), list);
} else {
if (log.isDebugEnabled()) {
log.debug("Search condition parsed from the search expression is invalid.");
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Cannot find a valid search context.");
}
}
return null;
}
Aggregations