Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macro / cqp / SetMatchingStrategyMacro.groovy @ 499

History | View | Annotate | Download (1.3 kB)

1
package org.txm.macro.cqp
2

    
3
// STANDARD DECLARATIONS
4
import org.kohsuke.args4j.*
5
import groovy.transform.Field
6
import org.txm.rcp.swt.widget.parameters.*
7
import org.txm.Toolbox
8
import org.txm.searchengine.cqp.*
9

    
10
def current = System.getProperty("cqp_matching_strategy")
11
if (current != null)
12
        println "Current strategy is: $current"
13

    
14
def CQI = Toolbox.getCqiClient();
15
if ((CQI instanceof NetCqiClient)) {
16
        println "Error: only available in CQP memory mode"
17
        return;
18
}
19

    
20
// BEGINNING OF PARAMETERS
21
@Field @Option(name="matchingStrategy", usage="CQL matching strategy", widget="String", required=false, def="shortest | standard | longest | traditional")
22
def matchingStrategy 
23
// Open the parameters input dialog box
24
if (!ParametersDialog.open(this)) return;
25
// END OF PARAMETERS
26

    
27
matchingStrategy = matchingStrategy.trim().toLowerCase();
28
switch(matchingStrategy ) {
29
        case "shortest":
30
        case "standard":
31
        case "longest":
32
        case "traditional":
33
                println "Setting Greedy to $matchingStrategy "
34
                CQI.query("set MatchingStrategy ${matchingStrategy };")
35
                System.setProperty("cqp_matching_strategy",matchingStrategy ) 
36
        break
37
        case "shortest | standard | longest | traditional":
38
                println "You must choose between shortest, standard, longest or traditional"
39
        break
40
        default:
41
                println "Unknown matching strategy: ${matchingStrategy}. Aborting "
42
}