Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5286

Show
Ignore:
Timestamp:
08/14/08 23:50:49 (5 months ago)
Author:
kevjay
Message:

birtoda: added Javadocs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-contrib/birt_oda_plugin/org.eclipse.datatools.connectivity.oda.openmrs/src/org/eclipse/datatools/connectivity/oda/openmrs/impl/Token.java

    r5221 r5286  
    1616import java.util.logging.Logger; 
    1717 
     18// TODO: Auto-generated Javadoc 
    1819/** 
    1920 * This is a wrapper class for a token, which is comprised of a String name and 
     
    281282    } 
    282283 
     284    /** 
     285     * Gets the aggregate value. 
     286     *  
     287     * @return the aggregate value 
     288     */ 
    283289    public String getAggregateValue() { 
    284290        return aggregateValue; 
    285291    } 
    286292 
     293    /** 
     294     * Sets the aggregate value. 
     295     *  
     296     * @param aggregateValue the new aggregate value 
     297     */ 
    287298    public void setAggregateValue(String aggregateValue) { 
    288299        this.aggregateValue = aggregateValue; 
  • openmrs-contrib/birt_oda_plugin/org.eclipse.datatools.connectivity.oda.openmrs/src/org/eclipse/datatools/connectivity/oda/openmrs/impl/Utils.java

    r5221 r5286  
    2626    private static Logger log = Logger.getLogger(Utils.class.getName()); 
    2727 
    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)) { 
    4449                String aggregate = breakup[i].split(" ")[0]; 
    45                  
     50 
    4651                log.info("Aggregate: " + aggregate); 
    47                  
     52 
    4853                return aggregate; 
    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)) { 
    7282                String value = breakup[i].split(" ")[1]; 
    73                  
     83 
    7484                log.info("Aggregate value: " + value); 
    75                  
     85 
    7686                return value; 
    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 + "}")) { 
    96113                token = aggregate + token.substring(token.indexOf(" ")); 
    97114            } 
    98115            query += "|" + token; 
    99116        } 
    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    } 
    129151 
    130152    /** 
     
    181203 
    182204        String query = ""; 
    183          
     205 
    184206        // rebuild the query 
    185207        for (String token : tokens) { 
     
    252274                    // grab the rest of the string that is after the token 
    253275                    if (breakup[i].contains(":")) 
    254                         return breakup[i].substring(breakup[i].indexOf("}") + 1, 
    255                                 breakup[i].indexOf(":")); 
     276                        return breakup[i].substring( 
     277                                breakup[i].indexOf("}") + 1, breakup[i] 
     278                                        .indexOf(":")); 
    256279                    else 
    257                         return breakup[i].substring(breakup[i].indexOf("}") + 1); 
     280                        return breakup[i] 
     281                                .substring(breakup[i].indexOf("}") + 1); 
    258282                } else { 
    259283                    return null;