Skip to content

Commit

Permalink
Merge pull request #150 from shanggeeth/main
Browse files Browse the repository at this point in the history
Add Oracle specific Query for GET_ALL_UM_ORG_ATTRIBUTES
  • Loading branch information
shanggeeth authored Aug 12, 2024
2 parents 0e8f028 + a120ea8 commit 23ba3e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ public class SQLConstants {
"UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_VALUE FROM UM_ORG INNER JOIN UM_ORG_ATTRIBUTE ON UM_ORG.UM_ID " +
"= UM_ORG_ATTRIBUTE.UM_ORG_ID INNER JOIN (%s) AS FILTERED_ORG ON UM_ORG.UM_ID = FILTERED_ORG.UM_ID;";

public static final String GET_ALL_UM_ORG_ATTRIBUTES_ORACLE = "SELECT UM_ORG.UM_ID, UM_ORG.UM_ORG_NAME, " +
"UM_ORG.UM_CREATED_TIME, UM_ORG.UM_STATUS, UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY, " +
"UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_VALUE FROM UM_ORG INNER JOIN UM_ORG_ATTRIBUTE ON UM_ORG.UM_ID " +
"= UM_ORG_ATTRIBUTE.UM_ORG_ID INNER JOIN (%s) FILTERED_ORG ON UM_ORG.UM_ID = FILTERED_ORG.UM_ID " +
"ORDER BY UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY";

public static final String GET_ORGANIZATIONS_META_ATTRIBUTES = "SELECT DISTINCT " +
"UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY FROM UM_ORG_ATTRIBUTE " +
"JOIN UM_ORG ON UM_ORG_ATTRIBUTE.UM_ORG_ID = UM_ORG.UM_ID WHERE ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.DELETE_ORGANIZATION_ATTRIBUTES_BY_ID;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.DELETE_ORGANIZATION_BY_ID;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ALL_UM_ORG_ATTRIBUTES;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ALL_UM_ORG_ATTRIBUTES_ORACLE;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ANCESTORS_OF_GIVEN_ORG_INCLUDING_ITSELF;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ANCESTOR_ORGANIZATION_ID_WITH_DEPTH;
import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_CHILD_ORGANIZATIONS;
Expand Down Expand Up @@ -742,7 +743,11 @@ private List<Organization> getOrganizationsList(boolean authorizedSubOrgsOnly, b
boolean isFilteringMetaAttributes = filterQueryBuilder.getMetaAttributeCount() > 0;

if (isFilteringMetaAttributes) {
sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES, sqlStmt);
if (isOracleDB()) {
sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES_ORACLE, sqlStmt);
} else {
sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES, sqlStmt);
}
}
List<Organization> organizations;
Map<String, Organization> organizationMap = new HashMap<>();
Expand Down

0 comments on commit 23ba3e3

Please sign in to comment.