protected String getJoin(String key, Object value) { String join = StringPool.BLANK; if (key.equals("contactTwitterSn")) { join = CustomSQLUtil.get(JOIN_BY_CONTACT_TWITTER_SN); } else if (key.equals("noOrganizations")) { join = CustomSQLUtil.get(JOIN_BY_NO_ORGANIZATIONS); } else if (key.equals("permission")) { join = CustomSQLUtil.get(JOIN_BY_PERMISSION); } else if (key.equals("userGroupRole")) { join = CustomSQLUtil.get(JOIN_BY_USER_GROUP_ROLE); } else if (key.equals("usersGroups")) { join = CustomSQLUtil.get(JOIN_BY_USERS_GROUPS); } else if (key.equals("usersOrgs")) { join = CustomSQLUtil.get(JOIN_BY_USERS_ORGS); } else if (key.equals("usersOrgsTree")) { join = CustomSQLUtil.get(JOIN_BY_USERS_ORGS_TREE); } else if (key.equals("usersPasswordPolicies")) { join = CustomSQLUtil.get(JOIN_BY_USERS_PASSWORD_POLICIES); } else if (key.equals("usersRoles")) { join = CustomSQLUtil.get(JOIN_BY_USERS_ROLES); } else if (key.equals("usersTeams")) { join = CustomSQLUtil.get(JOIN_BY_USERS_TEAMS); } else if (key.equals("usersUserGroups")) { join = CustomSQLUtil.get(JOIN_BY_USERS_USER_GROUPS); } else if (key.equals("announcementsDeliveryEmailOrSms")) { join = CustomSQLUtil.get(JOIN_BY_ANNOUNCEMENTS_DELIVERY_EMAIL_OR_SMS); } else if (key.equals("socialMutualRelation")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_MUTUAL_RELATION); } else if (key.equals("socialMutualRelationType")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_MUTUAL_RELATION_TYPE); } else if (key.equals("socialRelation")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_RELATION); } else if (key.equals("socialRelationType")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_RELATION_TYPE); } else if (value instanceof CustomSQLParam) { CustomSQLParam customSQLParam = (CustomSQLParam) value; join = customSQLParam.getSQL(); } if (Validator.isNotNull(join)) { int pos = join.indexOf("WHERE"); if (pos != -1) { join = join.substring(0, pos); } } return join; }
protected String getWhere(String key, Object value) { String join = StringPool.BLANK; if (key.equals("contactTwitterSn")) { join = CustomSQLUtil.get(JOIN_BY_CONTACT_TWITTER_SN); } else if (key.equals("noOrganizations")) { join = CustomSQLUtil.get(JOIN_BY_NO_ORGANIZATIONS); } else if (key.equals("permission")) { join = CustomSQLUtil.get(JOIN_BY_PERMISSION); } else if (key.equals("userGroupRole")) { join = CustomSQLUtil.get(JOIN_BY_USER_GROUP_ROLE); } else if (key.equals("usersGroups")) { join = CustomSQLUtil.get(JOIN_BY_USERS_GROUPS); } else if (key.equals("usersOrgs")) { if (value instanceof Long) { join = CustomSQLUtil.get(JOIN_BY_USERS_ORGS); } else if (value instanceof Long[]) { Long[] organizationIds = (Long[]) value; if (organizationIds.length == 0) { join = "WHERE ((Users_Orgs.organizationId = -1) ))"; } else { StringBundler sb = new StringBundler(organizationIds.length * 2 + 1); sb.append("WHERE ("); for (int i = 0; i < organizationIds.length; i++) { sb.append("(Users_Orgs.organizationId = ?) "); if ((i + 1) < organizationIds.length) { sb.append("OR "); } } sb.append(")"); join = sb.toString(); } } } else if (key.equals("usersOrgsTree")) { List<Organization> organizationsTree = (List<Organization>) value; int size = organizationsTree.size(); if (size > 0) { StringBundler sb = new StringBundler(size * 2 + 1); sb.append("WHERE ("); for (int i = 0; i < size; i++) { sb.append("(Organization_.treePath LIKE ?) "); if ((i + 1) < size) { sb.append("OR "); } } sb.append(")"); join = sb.toString(); } } else if (key.equals("usersPasswordPolicies")) { join = CustomSQLUtil.get(JOIN_BY_USERS_PASSWORD_POLICIES); } else if (key.equals("usersRoles")) { join = CustomSQLUtil.get(JOIN_BY_USERS_ROLES); } else if (key.equals("usersTeams")) { join = CustomSQLUtil.get(JOIN_BY_USERS_TEAMS); } else if (key.equals("usersUserGroups")) { join = CustomSQLUtil.get(JOIN_BY_USERS_USER_GROUPS); } else if (key.equals("announcementsDeliveryEmailOrSms")) { join = CustomSQLUtil.get(JOIN_BY_ANNOUNCEMENTS_DELIVERY_EMAIL_OR_SMS); } else if (key.equals("socialMutualRelation")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_MUTUAL_RELATION); } else if (key.equals("socialMutualRelationType")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_MUTUAL_RELATION_TYPE); } else if (key.equals("socialRelation")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_RELATION); } else if (key.equals("socialRelationType")) { join = CustomSQLUtil.get(JOIN_BY_SOCIAL_RELATION_TYPE); } else if (value instanceof CustomSQLParam) { CustomSQLParam customSQLParam = (CustomSQLParam) value; join = customSQLParam.getSQL(); } if (Validator.isNotNull(join)) { int pos = join.indexOf("WHERE"); if (pos != -1) { join = join.substring(pos + 5, join.length()).concat(" AND "); } else { join = StringPool.BLANK; } } return join; }