| 28 | | public static String getAggregateNameForTokenFromTokenProperty(String token, String tokenProperty) |
|---|
| 29 | | { |
|---|
| 30 | | log.info(token); |
|---|
| 31 | | log.info(tokenProperty); |
|---|
| 32 | | |
|---|
| 33 | | if(!tokenProperty.contains(token)) |
|---|
| 34 | | return null; |
|---|
| 35 | | |
|---|
| 36 | | |
|---|
| 37 | | //iterate through the different tokens and their modifiers |
|---|
| 38 | | String[] breakup = tokenProperty.split("\\|"); |
|---|
| 39 | | for(int i = 0; i < breakup.length; i++) |
|---|
| 40 | | { |
|---|
| 41 | | //check if we're at the part that has the token we are looking for |
|---|
| 42 | | if(breakup[i].contains("{" + token)) |
|---|
| 43 | | { |
|---|
| | 28 | /** |
|---|
| | 29 | * Gets the aggregate name for a given token from the token storage. |
|---|
| | 30 | * |
|---|
| | 31 | * @param token the token to get the aggregate for |
|---|
| | 32 | * @param tokenProperty the token storage |
|---|
| | 33 | * |
|---|
| | 34 | * @return the aggregate name for the desired token |
|---|
| | 35 | */ |
|---|
| | 36 | public static String getAggregateNameForTokenFromTokenProperty( |
|---|
| | 37 | String token, String tokenProperty) { |
|---|
| | 38 | log.info(token); |
|---|
| | 39 | log.info(tokenProperty); |
|---|
| | 40 | |
|---|
| | 41 | if (!tokenProperty.contains(token)) |
|---|
| | 42 | return null; |
|---|
| | 43 | |
|---|
| | 44 | // iterate through the different tokens and their modifiers |
|---|
| | 45 | String[] breakup = tokenProperty.split("\\|"); |
|---|
| | 46 | for (int i = 0; i < breakup.length; i++) { |
|---|
| | 47 | // check if we're at the part that has the token we are looking for |
|---|
| | 48 | if (breakup[i].contains("{" + token)) { |
|---|
| 49 | | |
|---|
| 50 | | } |
|---|
| 51 | | } |
|---|
| 52 | | |
|---|
| 53 | | return null; |
|---|
| 54 | | } |
|---|
| 55 | | |
|---|
| 56 | | public static String getAggregateValueForTokenFromTokenProperty(String token, String tokenProperty) |
|---|
| 57 | | { |
|---|
| 58 | | log.info(token); |
|---|
| 59 | | log.info(tokenProperty); |
|---|
| 60 | | |
|---|
| 61 | | if(!tokenProperty.contains(token)) |
|---|
| 62 | | return null; |
|---|
| 63 | | |
|---|
| 64 | | |
|---|
| 65 | | //iterate through the different tokens and their modifiers |
|---|
| 66 | | String[] breakup = tokenProperty.split("\\|"); |
|---|
| 67 | | for(int i = 0; i < breakup.length; i++) |
|---|
| 68 | | { |
|---|
| 69 | | //check if we're at the part that has the token we are looking for |
|---|
| 70 | | if(breakup[i].contains("{" + token)) |
|---|
| 71 | | { |
|---|
| | 54 | |
|---|
| | 55 | } |
|---|
| | 56 | } |
|---|
| | 57 | |
|---|
| | 58 | return null; |
|---|
| | 59 | } |
|---|
| | 60 | |
|---|
| | 61 | /** |
|---|
| | 62 | * Gets the aggregate value for a given token from token storage. |
|---|
| | 63 | * |
|---|
| | 64 | * @param token the token to get the aggregate value for |
|---|
| | 65 | * @param tokenProperty the token storage |
|---|
| | 66 | * |
|---|
| | 67 | * @return the aggregate value for the desired token |
|---|
| | 68 | */ |
|---|
| | 69 | public static String getAggregateValueForTokenFromTokenProperty( |
|---|
| | 70 | String token, String tokenProperty) { |
|---|
| | 71 | log.info(token); |
|---|
| | 72 | log.info(tokenProperty); |
|---|
| | 73 | |
|---|
| | 74 | if (!tokenProperty.contains(token)) |
|---|
| | 75 | return null; |
|---|
| | 76 | |
|---|
| | 77 | // iterate through the different tokens and their modifiers |
|---|
| | 78 | String[] breakup = tokenProperty.split("\\|"); |
|---|
| | 79 | for (int i = 0; i < breakup.length; i++) { |
|---|
| | 80 | // check if we're at the part that has the token we are looking for |
|---|
| | 81 | if (breakup[i].contains("{" + token)) { |
|---|
| 77 | | |
|---|
| 78 | | } |
|---|
| 79 | | } |
|---|
| 80 | | |
|---|
| 81 | | return null; |
|---|
| 82 | | } |
|---|
| 83 | | |
|---|
| 84 | | public static String replaceAggregateNameForToken(String aggregateToken, String aggregate, String tokenProperties) |
|---|
| 85 | | { |
|---|
| 86 | | //split up the tokens |
|---|
| 87 | | String[] tokens = tokenProperties.split("\\|"); |
|---|
| 88 | | |
|---|
| 89 | | String query = ""; |
|---|
| 90 | | |
|---|
| 91 | | //rebuild the query |
|---|
| 92 | | for(String token: tokens) |
|---|
| 93 | | { |
|---|
| 94 | | if(token.contains("{" + aggregateToken + "}")) |
|---|
| 95 | | { |
|---|
| | 87 | |
|---|
| | 88 | } |
|---|
| | 89 | } |
|---|
| | 90 | |
|---|
| | 91 | return null; |
|---|
| | 92 | } |
|---|
| | 93 | |
|---|
| | 94 | /** |
|---|
| | 95 | * Replace the aggregate name in the query for a give token. |
|---|
| | 96 | * |
|---|
| | 97 | * @param aggregateToken the token to replace the aggregate name for |
|---|
| | 98 | * @param aggregate the new aggregate name |
|---|
| | 99 | * @param tokenProperties the token query |
|---|
| | 100 | * |
|---|
| | 101 | * @return the new token query |
|---|
| | 102 | */ |
|---|
| | 103 | public static String replaceAggregateNameForToken(String aggregateToken, |
|---|
| | 104 | String aggregate, String tokenProperties) { |
|---|
| | 105 | // split up the tokens |
|---|
| | 106 | String[] tokens = tokenProperties.split("\\|"); |
|---|
| | 107 | |
|---|
| | 108 | String query = ""; |
|---|
| | 109 | |
|---|
| | 110 | // rebuild the query |
|---|
| | 111 | for (String token : tokens) { |
|---|
| | 112 | if (token.contains("{" + aggregateToken + "}")) { |
|---|
| 100 | | |
|---|
| 101 | | return query.substring(1); |
|---|
| 102 | | } |
|---|
| 103 | | |
|---|
| 104 | | public static String replaceAggregateValueForToken(String aggregateToken, String value, String tokenProperties) |
|---|
| 105 | | { |
|---|
| 106 | | //split up the tokens |
|---|
| 107 | | String[] tokens = tokenProperties.split("\\|"); |
|---|
| 108 | | |
|---|
| 109 | | String query = ""; |
|---|
| 110 | | |
|---|
| 111 | | String aggregate = getAggregateNameForTokenFromTokenProperty(aggregateToken, tokenProperties); |
|---|
| 112 | | |
|---|
| 113 | | //rebuild the query |
|---|
| 114 | | for(String token: tokens) |
|---|
| 115 | | { |
|---|
| 116 | | if(token.contains("{" + aggregateToken + "}")) |
|---|
| 117 | | { |
|---|
| 118 | | token = aggregate + " " + value + " " + token.substring(token.indexOf("{")); |
|---|
| 119 | | } |
|---|
| 120 | | query += "|" + token; |
|---|
| 121 | | } |
|---|
| 122 | | |
|---|
| 123 | | return query.substring(1); |
|---|
| 124 | | } |
|---|
| 125 | | |
|---|
| 126 | | |
|---|
| 127 | | |
|---|
| 128 | | |
|---|
| | 117 | |
|---|
| | 118 | return query.substring(1); |
|---|
| | 119 | } |
|---|
| | 120 | |
|---|
| | 121 | /** |
|---|
| | 122 | * Replace the aggregate value in the query for a given token. |
|---|
| | 123 | * |
|---|
| | 124 | * @param aggregateToken the token to replace the aggregate value for |
|---|
| | 125 | * @param value the new aggregate value |
|---|
| | 126 | * @param tokenProperties the token query |
|---|
| | 127 | * |
|---|
| | 128 | * @return the new token query |
|---|
| | 129 | */ |
|---|
| | 130 | public static String replaceAggregateValueForToken(String aggregateToken, |
|---|
| | 131 | String value, String tokenProperties) { |
|---|
| | 132 | // split up the tokens |
|---|
| | 133 | String[] tokens = tokenProperties.split("\\|"); |
|---|
| | 134 | |
|---|
| | 135 | String query = ""; |
|---|
| | 136 | |
|---|
| | 137 | String aggregate = getAggregateNameForTokenFromTokenProperty( |
|---|
| | 138 | aggregateToken, tokenProperties); |
|---|
| | 139 | |
|---|
| | 140 | // rebuild the query |
|---|
| | 141 | for (String token : tokens) { |
|---|
| | 142 | if (token.contains("{" + aggregateToken + "}")) { |
|---|
| | 143 | token = aggregate + " " + value + " " |
|---|
| | 144 | + token.substring(token.indexOf("{")); |
|---|
| | 145 | } |
|---|
| | 146 | query += "|" + token; |
|---|
| | 147 | } |
|---|
| | 148 | |
|---|
| | 149 | return query.substring(1); |
|---|
| | 150 | } |
|---|