Révision 3205

tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/AjouterDesSujetsAuCorpusOkapiMacro.groovy (revision 3205)
50 50
	if (corpusID.length() > 0 && corpusID.startsWith("http") && corpusID.equals(identifiant_corpus_okapi)) {
51 51
		println "Le corpus Okapi $identifiant_corpus_okapi a été mis à jour avec $liste_identifiants_sujets"
52 52
	} else {
53
		println "Erreur : Le corpus Okapi n'a pas été mis à jour  (session=$sessionID, corpus=$identifiant_corpus_okapi et identifiants=$liste_identifiants_sujets)"
53
		monitorShowError("Erreur : Le corpus Okapi n'a pas été mis à jour  (session=$sessionID, corpus=$identifiant_corpus_okapi et identifiants=$liste_identifiants_sujets)")
54 54
	}
55 55
} else {
56
	println "Erreur : la session Okapi n'a pas pu être démarrée."
56
	monitorShowError("Erreur : la session Okapi n'a pas pu être démarrée.")
57 57
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN, "")
58 58
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD, "")
59
}
59
}
60

  
61
def monitorShowError(String message) {
62
	monitor.syncExec(new Runnable() {
63
		public void run() {
64
			org.eclipse.jface.dialogs.MessageDialog.openError(org.eclipse.swt.widgets.Display.getCurrent().getActiveShell(), "Erreur", message)
65
		}
66
	});
67
}
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/InstallAndUpdateToolsMacro.groovy (revision 3205)
13 13
	return;
14 14
}
15 15

  
16
//def macros = [
17
//"AjouterDesSujetsAuCorpusOkapiMacro.groovy",
18
//"BuildAFMetadataMacro.groovy",
19
//"ExporterSousCorpusSujetsDansOkapiMacro.groovy",
20
//"FixINATRSMacro.groovy",
21
//"ImporterCorpusOkapiMacro.groovy",
22
//"InstallAndUpdateToolsMacro.groovy",
23
//"ListerCorpusOkapiMacro.groovy",
24
//"ListerIdentifiantsSujetsMacro.groovy",
25
//"OkapiSaphirAPI.groovy",
26
//"PrepareAFVOIXOFFCorpusMacro.groovy",
27
//"WordProperty2WordMacro.groovy"]
28

  
29 16
String svn = "http://forge.cbp.ens-lyon.fr/svn/txm/tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/"
17
try {
18
	macros = IOUtils.getText(new URL(svn+"tools.txt"), "UTF-8")
19
	macros = macros.split("\n")
20
} catch(Exception e2) {
21
	monitorShowError("La liste des outils ${svn+"tools.txt"} n'a pas pu être récupérée (raison : $e2).\nAbandon.")
22
	return
23
}
30 24

  
31
def macros = IOUtils.getText(new URL(svn+"tools.txt"), "UTF-8")
32
macros = macros.split("\n")
33

  
34
println "Copyping ${macros.size()} files..."
35
ConsoleProgressBar cpb = new ConsoleProgressBar(macros.size())
25
println "Copyping ${macros.size()} files: "
36 26
for (def m : macros) {
27
	def f = new File(groovyUserDirectory.getAbsolutePath()+"/"+m)
37 28
	try {
38
	String remoteUrl = svn+m
39
	def file = new FileOutputStream(groovyUserDirectory.getAbsolutePath()+"/"+m)
40
	def out = new BufferedOutputStream(file)
41
	out << new URL(remoteUrl).openStream()
42
	out.close()
29
		String remoteUrl = svn+m
30
		
31
		if (f.exists()) print "."
32
		else print "*"
33
		
34
		def file = new FileOutputStream(f)
35
		def out = new BufferedOutputStream(file)
36
		out << new URL(remoteUrl).openStream()
37
		out.close()
43 38
	} catch(Exception e ) {
44
		println "Error: $e"
39
		println "\nErreur lors de la récupération de $f: $e"
45 40
	}
46
	
47
	cpb.tick()
48 41
}
49
cpb.done()
50
println "Antract tools updated \\o/"
42
println "\nAntract tools updated \\o/"
51 43

  
52 44
def monitorShowError(String message) {
53 45
	monitor.syncExec(new Runnable() {
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/ImporterCorpusOkapiMacro.groovy (revision 3205)
27 27
//def identifiant_corpus_okapi
28 28

  
29 29
if (!(corpusViewSelection instanceof CQPCorpus)) {
30
	println "Erreur: la sélection n'est pas un corpus."
30
	monitorShowError("Erreur: la sélection n'est pas un corpus.")
31 31
	return false
32 32
} 
33 33

  
......
42 42
} else if (parentCorpusName.startsWith("AFNOTICES") || parentCorpusName.startsWith("AF-NOTICES")) {
43 43
	
44 44
} else {
45
	println "Erreur: le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE"
45
	monitorShowError("Erreur: le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE")
46 46
	return false
47 47
}
48 48

  
......
94 94
String query = "[_.$prop=\"$liste_identifiants_sujets\"] expand to $prop"
95 95
println "CQL=$query"
96 96
if (query.length() > 15500) {
97
	println "Erreur : la requête CQL est trop longue (${query.length()})."
97
	monitorShowError("Erreur : la requête CQL est trop longue (${query.length()}).")
98 98
	return
99 99
}
100 100
Subcorpus sub = parentCorpus.createSubcorpus(new CQLQuery(query), nom_sous_corpus)
......
109 109
					}
110 110
				});
111 111
} else {
112
	println "Error: the created corpus is empty!"
112
	monitorShowError("Erreur: the created corpus is empty!")
113 113
}
114 114

  
115 115
// UTILS UTILS UTILS UTILS UTILS UTILS UTILS
......
183 183
	return s
184 184
}
185 185

  
186
def monitorShowError(String message) {
187
	monitor.syncExec(new Runnable() {
188
		public void run() {
189
			org.eclipse.jface.dialogs.MessageDialog.openError(org.eclipse.swt.widgets.Display.getCurrent().getActiveShell(), "Erreur", message)
190
		}
191
	});
192
}
193

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/ListerCorpusOkapiMacro.groovy (revision 3205)
35 35

  
36 36
String sessionID = OkapiSaphirAPI.login(user, password)
37 37
if (sessionID.length() == 0) {
38
	println "Erreur : La session Okapi n'a pu être démarrée."
38
	monitorShowError("Erreur : La session Okapi n'a pu être démarrée.")
39 39
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN, "")
40 40
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD, "")
41 41
}
......
45 45
	println "CORPORA"
46 46
	println corpora
47 47
} else {
48
	println "Erreur : la liste des corpus n'a pas pu être récupérée."
48
	monitorShowError("Erreur : la liste des corpus n'a pas pu être récupérée.")
49 49
}
50 50

  
51

  
52
def monitorShowError(String message) {
53
	monitor.syncExec(new Runnable() {
54
		public void run() {
55
			org.eclipse.jface.dialogs.MessageDialog.openError(org.eclipse.swt.widgets.Display.getCurrent().getActiveShell(), "Erreur", message)
56
		}
57
	});
58
}
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/ListerIdentifiantsSujetsMacro.groovy (revision 3205)
10 10
import org.txm.searchengine.cqp.CQPSearchEngine
11 11

  
12 12
if (!(corpusViewSelection instanceof CQPCorpus)) {
13
	println "Erreur: la sélection de la vue Corpus n'est pas un corpus ($corpusViewSelection)."
13
	monitorShowError("Erreur: la sélection de la vue Corpus n'est pas un corpus ($corpusViewSelection).")
14 14
	return false
15 15
} 
16 16

  
......
52 52
	}
53 53

  
54 54
} else {
55
	println "Erreur: le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE"
55
	monitorShowError("Erreur: le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE")
56 56
	return false
57 57
}
58 58

  
......
67 67
})
68 68

  
69 69
return ids
70

  
71

  
72
def monitorShowError(String message) {
73
	monitor.syncExec(new Runnable() {
74
		public void run() {
75
			org.eclipse.jface.dialogs.MessageDialog.openError(org.eclipse.swt.widgets.Display.getCurrent().getActiveShell(), "Erreur", message)
76
		}
77
	});
78
}
79

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/ExporterSousCorpusSujetsDansOkapiMacro.groovy (revision 3205)
13 13
import org.txm.backtomedia.preferences.BackToMediaPreferences
14 14

  
15 15
if (!(corpusViewSelection instanceof CQPCorpus)) {
16
	println "Erreur : la sélection de la vue Corpus n'est pas un corpus ($corpusViewSelection)."
16
	monitorShowError("Erreur : la sélection de la vue Corpus n'est pas un corpus ($corpusViewSelection).")
17 17
	return false
18 18
} 
19 19

  
......
37 37
} else if (parentCorpusName.startsWith("AFNOTICES") || parentCorpusName.startsWith("AF-NOTICES")) {
38 38
	ids = gse.run(ListerIdentifiantsSujetsMacro, ["args":[:], "corpusViewSelection":corpusViewSelection, "monitor":monitor])
39 39
} else {
40
	println "Erreur : le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE"
40
	monitorShowError("Erreur : le corpus n'est pas un corpus d'AF-VOIX-OFF ni AFNOTICE")
41 41
	return false
42 42
}
43 43

  
......
62 62
		println "Le corpus 'titre_corpus_okapi' son identifiant est $corpusID"
63 63
		println "Lien d'accès direct : "+OkapiSaphirAPI.getDirectAccessURL(corpusID)
64 64
	} else {
65
		println "Erreur : Le corpus Okapi n'a pas été créé (code d'erreur=$corpusID)"
65
		monitorShowError("Erreur : Le corpus Okapi n'a pas été créé (code d'erreur=$corpusID)")
66 66
	}
67 67
} else {
68
	println "Erreur : La session Okapi n'a pu être démarrée."
68
	monitorShowError("Erreur : La session Okapi n'a pu être démarrée.")
69 69
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN, "")
70 70
	System.setProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD, "")
71
}
71
}
72

  
73
def monitorShowError(String message) {
74
	monitor.syncExec(new Runnable() {
75
		public void run() {
76
			org.eclipse.jface.dialogs.MessageDialog.openError(org.eclipse.swt.widgets.Display.getCurrent().getActiveShell(), "Erreur", message)
77
		}
78
	});
79
}

Formats disponibles : Unified diff