Statistics
| Revision:

root / tmp / org.txm.analec.rcp / src / org / txm / macro / urs / edit / ResetAllAnnotationsMacro.groovy @ 2144

History | View | Annotate | Download (1.7 kB)

1
// STANDARD DECLARATIONS
2
package org.txm.macro.urs.edit
3

    
4
import org.kohsuke.args4j.*
5
import groovy.transform.Field
6
import org.txm.rcp.swt.widget.parameters.*
7
import org.txm.annotation.urs.*
8
import org.txm.searchengine.cqp.corpus.*
9
import visuAnalec.elements.*
10

    
11
if (!(corpusViewSelection instanceof CQPCorpus)) {
12
        println "Corpora selection is not a Corpus"
13
        return;
14
}
15

    
16
@Field @Option(name="CONFIRMATION", usage="select to confirm the annotations reset", widget="Boolean", required=false, def="false")
17
def CONFIRMATION
18

    
19
// Open the parameters input dialog box
20
if (!ParametersDialog.open(this)) return;
21

    
22
def corpus = corpusViewSelection
23
def analecCorpus = URSCorpora.getCorpus(corpus);
24
def structure = analecCorpus.getStructure()
25

    
26
Class[] classes = [Unite.class, Relation.class, Schema.class]
27
println "Removing unites..."
28
for (String type : structure.getTypes(Unite.class)) {
29
        for (Unite unite : analecCorpus.getUnites(type).toArray(new Unite[0])) {
30
                analecCorpus.supUnite(unite)
31
        }
32
//        fireMessage(new StructureEvent(analecCorpus, TypeModifStructure.SUPPR_TYPE, Unite.class, type));
33
}
34

    
35
println "Removing relations..."
36
for (String type : structure.getTypes(Relation.class)) {
37
        for (Relation relation : analecCorpus.getRelations(type).toArray(new Relation[0])) {
38
                analecCorpus.supRelation(relation)
39
        }
40
//        fireMessage(new StructureEvent(analecCorpus, TypeModifStructure.SUPPR_TYPE, Relation.class, type));
41
}
42

    
43
println "Removing schemas..."
44
for (String type : structure.getTypes(Schema.class)) {
45
        for (Schema schema : analecCorpus.getSchemas(type).toArray(new Schema[0])) {
46
                analecCorpus.supSchema(schema)
47
        }
48
//        fireMessage(new StructureEvent(analecCorpus, TypeModifStructure.SUPPR_TYPE, Schema.class, type));
49
}
50

    
51
println "Done. Save the corpus to finish the annotations reset."
52