Révision 3883

TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/TypedValue.java (revision 3883)
46 46
	}
47 47
	
48 48
	public String toString() {
49
		return PK.toString() + "(" + name + ")";
49
		return PK.toString() + "(" + name + ")"; //$NON-NLS-1$ //$NON-NLS-2$
50 50
	}
51 51
	
52 52
	public String toHumanString() {
53
		return name + "(" + PK.getId() + ")";
53
		return name + "(" + PK.getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
54 54
	}
55 55
}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/AnnotationEffect.java (revision 3883)
17 17
	 * @return Effet suffix used to display the annotation type in messages
18 18
	 */
19 19
	public String toSuffix() {
20
		if (this.equals(TOKEN)) return " (T)";
21
		else if (this.equals(ANNOTATION)) return " (A)";
22
		else return "";
20
		if (this.equals(TOKEN)) return " (T)"; //$NON-NLS-1$
21
		else if (this.equals(ANNOTATION)) return " (A)"; //$NON-NLS-1$
22
		else return ""; //$NON-NLS-1$
23 23
	}
24 24
}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/TypedValuePK.java (revision 3883)
44 44
	}
45 45
	
46 46
	public String toString() {
47
		return typeId + "=" + id;
47
		return typeId + "=" + id; //$NON-NLS-1$
48 48
	}
49 49
}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/KnowledgeRepository.java (revision 3883)
19 19

  
20 20
public abstract class KnowledgeRepository { // extends Vector<AnnotationType>
21 21
	
22
	protected String values_base_url = "";
22
	protected String values_base_url = ""; //$NON-NLS-1$
23 23
	
24
	protected String types_base_url = "";
24
	protected String types_base_url = ""; //$NON-NLS-1$
25 25
	
26
	protected String url = "";
26
	protected String url = ""; //$NON-NLS-1$
27 27
	
28
	protected String dbPath = ""; // the KR database path
28
	protected String dbPath = ""; // the KR database path //$NON-NLS-1$
29 29
	
30 30
	protected String name;
31 31
	
......
45 45

  
46 46
	private EntityManagerFactory emf;
47 47
	
48
	public final static String NAME = "name";
48
	public final static String NAME = "name"; //$NON-NLS-1$
49 49
	
50
	public final static String TYPE_URL = "url";
50
	public final static String TYPE_URL = "url"; //$NON-NLS-1$
51 51
	
52
	public final static String TYPE_RESURL = "resurl";
52
	public final static String TYPE_RESURL = "resurl"; //$NON-NLS-1$
53 53
	
54
	public final static String TYPE_TYPEURL = "typeurl";
54
	public final static String TYPE_TYPEURL = "typeurl"; //$NON-NLS-1$
55 55
	
56
	public final static String TYPE_ID = "id";
56
	public final static String TYPE_ID = "id"; //$NON-NLS-1$
57 57
	
58
	public final static String TYPE_SIZE = "size";
58
	public final static String TYPE_SIZE = "size"; //$NON-NLS-1$
59 59
	
60
	public final static String TYPE_EFFECT = "effect";
60
	public final static String TYPE_EFFECT = "effect"; //$NON-NLS-1$
61 61
	
62
	public final static String TYPE_SQLFIELD_NAME = "sql_name";
62
	public final static String TYPE_SQLFIELD_NAME = "sql_name"; //$NON-NLS-1$
63 63
	
64
	public final static String TYPE_SQLFIELD_ID = "sql_id";
64
	public final static String TYPE_SQLFIELD_ID = "sql_id"; //$NON-NLS-1$
65 65
	
66
	public final static String TYPE_SQLFIELD_QUERY = "sql_query";
66
	public final static String TYPE_SQLFIELD_QUERY = "sql_query"; //$NON-NLS-1$
67 67
	
68
	public final static String LOGIN_KEY = "org.txm.repository.credencies.login.";
68
	public final static String LOGIN_KEY = "org.txm.repository.credencies.login."; //$NON-NLS-1$
69 69
	
70
	public final static String PASSWORD_KEY = "org.txm.repository.credencies.password.";
70
	public final static String PASSWORD_KEY = "org.txm.repository.credencies.password."; //$NON-NLS-1$
71 71
	
72 72
	public static final boolean[] FALSES = { false, false };
73 73
	
......
85 85
	 * @return
86 86
	 */
87 87
	public EntityManager initializeEntityManager() {
88
		this.dbPath = new File(Toolbox.getTxmHomePath(), "repositories/" + name).getAbsolutePath();
88
		this.dbPath = new File(Toolbox.getTxmHomePath(), "repositories/" + name).getAbsolutePath(); //$NON-NLS-1$
89 89
		// System.out.println("KnowledgeRepository.initializeEntityManager [DB @ "+dbPath+"]");
90 90
		
91 91
		HashMap<String, Object> properties = new HashMap<String, Object>();
......
95 95
		//
96 96
		// properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "/home/mdecorde/workspace079/org.txm.annotation.core/META-INF");
97 97
		// //properties.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
98
		String urlProperty = "jdbc:hsqldb:file:" + dbPath + "/db;shutdown=true;hsqldb.lock_file=false;";
98
		String urlProperty = "jdbc:hsqldb:file:" + dbPath + "/db;shutdown=true;hsqldb.lock_file=false;"; //$NON-NLS-1$ //$NON-NLS-2$
99 99
		if (Log.getLevel().intValue() < Level.INFO.intValue()) {
100
			urlProperty += "";
100
			urlProperty += ""; //$NON-NLS-1$
101 101
		}
102 102
		else {
103
			urlProperty += "hsqldb.applog=0;hsqldb.sqllog=0";
103
			urlProperty += "hsqldb.applog=0;hsqldb.sqllog=0"; //$NON-NLS-1$
104 104
		}
105
		properties.put("javax.persistence.jdbc.url", urlProperty);
105
		properties.put("javax.persistence.jdbc.url", urlProperty); //$NON-NLS-1$
106 106
		// properties.put("javax.persistence.jdbc.username", "SA");
107 107
		// properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, "database");
108
		properties.put(PersistenceUnitProperties.DDL_GENERATION, "create-or-extend-tables"); // create&update table if needed
108
		properties.put(PersistenceUnitProperties.DDL_GENERATION, "create-or-extend-tables"); // create&update table if needed //$NON-NLS-1$
109 109
		// properties.put(PersistenceUnitProperties.DDL_GENERATION, "drop-and-create-tables"); // drop all and recreate
110 110
		// if (Log.getLevel().intValue() < Level.WARNING.intValue()) {
111 111
		// properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "WARNING");
......
119 119
		PersistenceProvider pp = new PersistenceProvider();
120 120
		emf = pp.createEntityManagerFactory(DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, properties);
121 121
		if (emf == null) {
122
			Log.warning(NLS.bind("Error: could not create the ''{0}'' EntityManagerFactory and PersistenceProvider={1}.", DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, pp));
122
			Log.warning(NLS.bind("Error: could not create the ''{0}'' EntityManagerFactory and PersistenceProvider={1}.", DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, pp)); //$NON-NLS-1$
123 123
			return null;
124 124
		}
125 125
		EntityManager entityManager = (EntityManager) emf.createEntityManager();
......
132 132
	public void setAccessProperties(HashMap<String, String> accessProperties) {
133 133
		this.accessProperties = accessProperties;
134 134
		
135
		String sVersion = accessProperties.get("version");
135
		String sVersion = accessProperties.get("version"); //$NON-NLS-1$
136 136
		if (sVersion.length() > 0) {
137 137
			this.version = Integer.parseInt(sVersion);
138 138
		}
......
218 218
	
219 219
	public String toHumanString() {
220 220
		StringBuffer buffer = new StringBuffer();
221
		buffer.append(this.getName() + " version=" + version + " (" + this.getURL() + "): " + this.getAccessType() + "\n");
221
		buffer.append(this.getName() + " version=" + version + " (" + this.getURL() + "): " + this.getAccessType() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
222 222
		for (AnnotationType type : getAllAnnotationTypes()) {
223
			buffer.append("\t" + type.toHumanString() + "\n");
223
			buffer.append("\t" + type.toHumanString() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
224 224
		}
225 225
		return buffer.toString();
226 226
	}
227 227
	
228 228
	public void reload() {
229
		Log.fine("Reloading KR " + name);
229
		Log.fine("Reloading KR " + name); //$NON-NLS-1$
230 230
		
231 231
		clearTypes();
232 232
		buildTypesAndValues();
......
240 240
	 */
241 241
	public List<TypedValue> getValues(AnnotationType type, int limit) throws Exception {
242 242
		
243
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t "
244
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'", TypedValue.class);
243
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t " //$NON-NLS-1$
244
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'", TypedValue.class); //$NON-NLS-1$ //$NON-NLS-2$
245 245
		if (limit != -1) {
246 246
			query.setMaxResults(limit);
247 247
		}
......
256 256
	 * @throws Exception
257 257
	 */
258 258
	public boolean hasValues(AnnotationType type) throws Exception {
259
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t.name FROM TypedValue AS t "
260
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'", TypedValue.class);
259
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t.name FROM TypedValue AS t " //$NON-NLS-1$
260
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'", TypedValue.class); //$NON-NLS-1$ //$NON-NLS-2$
261 261
		query.setMaxResults(1);
262 262
		
263 263
		return query.getResultList().size() > 0;
......
280 280
		// clear all persisted values
281 281
		if (jpaem != null) {
282 282
			jpaem.getTransaction().begin();
283
			Query query = jpaem.createQuery("DELETE FROM TypedValue");
283
			Query query = jpaem.createQuery("DELETE FROM TypedValue"); //$NON-NLS-1$
284 284
			query.executeUpdate();
285 285
			jpaem.getTransaction().commit();
286 286
		}
......
329 329
				String url = typeFieldsContent.get(KnowledgeRepository.TYPE_URL);
330 330
				String size = typeFieldsContent.get(KnowledgeRepository.TYPE_SIZE);
331 331
				String s_effect = typeFieldsContent.get(KnowledgeRepository.TYPE_EFFECT);
332
				if (s_effect == null) s_effect = "SEGMENT";
332
				if (s_effect == null) s_effect = "SEGMENT"; //$NON-NLS-1$
333 333
				
334 334
				for (String typeField : typeFieldsContent.keySet()) {
335 335
					// System.out.println("Type field : "+typeField+" value : "+typeFieldsContent.get(typeField));
......
360 360
	 * @return
361 361
	 */
362 362
	public AnnotationType addType(String name, String id) {
363
		return addType(name, id, this.url + "/" + id);
363
		return addType(name, id, this.url + "/" + id); //$NON-NLS-1$
364 364
	}
365 365
	
366 366
	/**
......
403 403
	}
404 404
	
405 405
	public List<AnnotationType> getAllAnnotationTypes() {
406
		TypedQuery<AnnotationType> query = jpaem.createQuery("SELECT t FROM AnnotationType AS t ", AnnotationType.class);
406
		TypedQuery<AnnotationType> query = jpaem.createQuery("SELECT t FROM AnnotationType AS t ", AnnotationType.class); //$NON-NLS-1$
407 407
		return query.getResultList();
408 408
	}
409 409
	
410 410
	public List<TypedValue> getAllTypedValuesForType(String idType) {
411
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t WHERE t.PK.typeId LIKE '" + idType + "'", TypedValue.class);
411
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t WHERE t.PK.typeId LIKE '" + idType + "'", TypedValue.class); //$NON-NLS-1$ //$NON-NLS-2$
412 412
		return query.getResultList();
413 413
	}
414 414
	
......
419 419
	 * @throws Exception
420 420
	 */
421 421
	public List<TypedValue> findTypedValuesWithPrefix(AnnotationType type, String prefix) throws Exception {
422
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t "
423
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'"
424
				+ " AND t.name LIKE '" + prefix + "%'", TypedValue.class);
422
		TypedQuery<TypedValue> query = jpaem.createQuery("SELECT t FROM TypedValue AS t " //$NON-NLS-1$
423
				+ "WHERE t.PK.typeId LIKE '" + type.getId() + "'" //$NON-NLS-1$ //$NON-NLS-2$
424
				+ " AND t.name LIKE '" + prefix + "%'", TypedValue.class); //$NON-NLS-1$ //$NON-NLS-2$
425 425
		// System.out.println("Query for "+prefix+" has nb results = "+query.getResultList().size());
426 426
		return query.getResultList();
427 427
	}
......
478 478
			values = strings.get(lang);
479 479
		}
480 480
		if (values == null) { // get default lang = "en"
481
			values = strings.get("en");
481
			values = strings.get("en"); //$NON-NLS-1$
482 482
		}
483 483
		if (values == null) { // fail
484 484
			return null;
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/temporary/DeleteAnnotation.java (revision 3883)
8 8
	
9 9
	@Test
10 10
	public void test() {
11
		fail("Not yet implemented");
11
		fail("Not yet implemented"); //$NON-NLS-1$
12 12
	}
13 13
	
14 14
}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/temporary/UpdateAnnotation.java (revision 3883)
8 8
	
9 9
	@Test
10 10
	public void test() {
11
		fail("Not yet implemented");
11
		fail("Not yet implemented"); //$NON-NLS-1$
12 12
	}
13 13
	
14 14
}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/temporary/CreateAnnotation.java (revision 3883)
16 16
	
17 17
	@Test
18 18
	public void test() throws CqiClientException, InvalidCqpIdException {
19
		if (!Toolbox.isInitialized()) fail("Toolbox not initialized.");
20
		MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus("VOEUX");
21
		if (corpus == null) fail("Corpus Voeux not loaded.");
19
		if (!Toolbox.isInitialized()) fail("Toolbox not initialized."); //$NON-NLS-1$
20
		MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus("VOEUX"); //$NON-NLS-1$
21
		if (corpus == null) fail("Corpus Voeux not loaded."); //$NON-NLS-1$
22 22
		
23 23
		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(this.getClass(), corpus);
24
		properties.put("eclipselink.persistencexml", System.getProperty("user.home") + "/workspace442/org.txm.core/META-INF/persistence.xml");
24
		properties.put("eclipselink.persistencexml", System.getProperty("user.home") + "/workspace442/org.txm.core/META-INF/persistence.xml"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
25 25
		
26 26
		TemporaryAnnotationManager tam = new TemporaryAnnotationManager(corpus, properties);
27 27
		System.out.println(tam);
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/conversion/XMLTXMFileRuledConversion.java (revision 3883)
26 26
	
27 27
	protected String newType;
28 28
	
29
	public static final String DELETE = "supprimer";
29
	public static final String DELETE = "supprimer"; //$NON-NLS-1$
30 30
	
31
	public static final String COPY = "copier";
31
	public static final String COPY = "copier"; //$NON-NLS-1$
32 32
	
33
	public static final String ABANDON = "abandon";
33
	public static final String ABANDON = "abandon"; //$NON-NLS-1$
34 34
	
35 35
	HashSet<String> noMatchValues = new HashSet<>();
36 36
	
......
58 58
		}
59 59
		
60 60
		if (elementPath == null) { // where fixing txm:words
61
			if (!this.newType.startsWith("#")) this.newType = "#" + this.newType;
62
			if (!this.oldType.startsWith("#")) this.oldType = "#" + this.oldType;
61
			if (!this.newType.startsWith("#")) this.newType = "#" + this.newType; //$NON-NLS-1$ //$NON-NLS-2$
62
			if (!this.oldType.startsWith("#")) this.oldType = "#" + this.oldType; //$NON-NLS-1$ //$NON-NLS-2$
63 63
		}
64 64
	}
65 65
	
......
99 99
				String value = parser.getAttributeValue(i);
100 100
				if (oldType != null && oldType.equals(att)) {
101 101
					if (converter != null) {
102
						if (debug) Log.finer("CALL CONVERTER with attribute "+att);
102
						if (debug) Log.finer("CALL CONVERTER with attribute "+att); //$NON-NLS-1$
103 103
						newValue = converter.getValue(parser, localname, att, value);
104 104
					}
105 105
					else {
......
112 112
			}
113 113
			
114 114
			if (oldType == null && converter != null) {
115
				if (debug) Log.finer("CALL CONVERTER with no attribute set");
115
				if (debug) Log.finer("CALL CONVERTER with no attribute set"); //$NON-NLS-1$
116 116
				newValue = converter.getValue(parser, localname, null, null);
117 117
			}
118 118
			
119 119
			if (newValue != null) {
120
				if (debug) Log.finer("WRITE NEWTYPE: " + newType + "=" + newValue);
120
				if (debug) Log.finer("WRITE NEWTYPE: " + newType + "=" + newValue); //$NON-NLS-1$ //$NON-NLS-2$
121 121
				writeAttribute(null, newType, newValue);
122 122
			}
123 123
		}
......
142 142
			
143 143
			if (!inW) super.processStartElement(); // don't write W content
144 144
			
145
			if (localname.equals("w")) {
145
			if (localname.equals("w")) { //$NON-NLS-1$
146 146
				inW = true;
147 147
				anaValues.clear();
148 148
				anaResps.clear();
149 149
				
150 150
				// initialize the new type to a empty value in case there is transformation rule
151
				anaValues.put(newType, "");
152
				anaResps.put(newType, "#txm_recode");
151
				anaValues.put(newType, ""); //$NON-NLS-1$
152
				anaResps.put(newType, "#txm_recode"); //$NON-NLS-1$
153 153
			}
154
			else if (localname.equals("ana")) {
154
			else if (localname.equals("ana")) { //$NON-NLS-1$
155 155
				inAna = true;
156
				typeName = parser.getAttributeValue(null, "type");
157
				respName = parser.getAttributeValue(null, "resp");
156
				typeName = parser.getAttributeValue(null, "type"); //$NON-NLS-1$
157
				respName = parser.getAttributeValue(null, "resp"); //$NON-NLS-1$
158 158
				anaResps.put(typeName, respName);
159 159
				// if (typeName != null) typeName = typeName.substring(1); // remove #
160
				typeValue = "";
160
				typeValue = ""; //$NON-NLS-1$
161 161
			}
162
			else if (localname.equals("form")) {
162
			else if (localname.equals("form")) { //$NON-NLS-1$
163 163
				inForm = true;
164
				formValue = "";
164
				formValue = ""; //$NON-NLS-1$
165 165
			}
166 166
		}
167 167
	}
......
186 186
		}
187 187
		else {
188 188
			
189
			if (localname.equals("w")) {
189
			if (localname.equals("w")) { //$NON-NLS-1$
190 190
				inW = false;
191 191
				
192 192
				// write W content
193 193
				try {
194 194
					// get the value to test
195 195
					String value = null;
196
					if (oldType.equals("word")) {
196
					if (oldType.equals("word")) { //$NON-NLS-1$
197 197
						value = formValue;
198 198
					}
199 199
					else {
200 200
						value = anaValues.get(oldType);
201 201
					}
202 202
					
203
					if (newType.equals("word")) { // update form property
203
					if (newType.equals("word")) { // update form property //$NON-NLS-1$
204 204
						updateFormValueIfMatch(value);
205 205
					}
206 206
					else { // update a ana property
......
210 210
					}
211 211
					
212 212
					// write the word element
213
					writer.writeStartElement("txm:form");
213
					writer.writeStartElement("txm:form"); //$NON-NLS-1$
214 214
					writer.writeCharacters(formValue);
215 215
					writer.writeEndElement();
216 216
					
217 217
					for (String k : anaValues.keySet()) {
218 218
						String resp = anaResps.get(k);
219
						if (resp == null) resp = "#txm_recode";
219
						if (resp == null) resp = "#txm_recode"; //$NON-NLS-1$
220 220
						
221
						writer.writeStartElement("txm:ana");
222
						writer.writeAttribute("resp", resp);
223
						writer.writeAttribute("type", k);
221
						writer.writeStartElement("txm:ana"); //$NON-NLS-1$
222
						writer.writeAttribute("resp", resp); //$NON-NLS-1$
223
						writer.writeAttribute("type", k); //$NON-NLS-1$
224 224
						writer.writeCharacters(anaValues.get(k));
225 225
						writer.writeEndElement();
226 226
					}
......
229 229
					e.printStackTrace();
230 230
				}
231 231
			}
232
			else if (localname.equals("ana")) {
232
			else if (localname.equals("ana")) { //$NON-NLS-1$
233 233
				anaValues.put(typeName, typeValue);
234 234
				inAna = false;
235 235
			}
236
			else if (localname.equals("form")) {
236
			else if (localname.equals("form")) { //$NON-NLS-1$
237 237
				inForm = false;
238 238
			}
239 239
			
......
279 279
			String v = converter.getValue(parser, localname, null, value);
280 280
			if (v != null) {
281 281
				anaValues.put(newType, v); // do a replace if newType == oldType :-)
282
				anaResps.put(newType, "#txm_recode");
282
				anaResps.put(newType, "#txm_recode"); //$NON-NLS-1$
283 283
				return; // ok stop
284 284
			}
285 285
		}
......
289 289
				if (rule.matcher(value).matches()) {
290 290
					value = rules.get(rule);
291 291
					anaValues.put(newType, value); // do a replace if newType == oldType :-)
292
					anaResps.put(newType, "#txm_recode");
292
					anaResps.put(newType, "#txm_recode"); //$NON-NLS-1$
293 293
					return;
294 294
				}
295 295
			}
296 296
		}
297
		if (DELETE.equals(mode)) anaValues.put(newType, ""); // do a replace if newType == oldType :-)
298
		else if (ABANDON.equals(mode)) anaValues.put(newType, "ERROR(" + value + ")"); // do a replace if newType == oldType :-)
297
		if (DELETE.equals(mode)) anaValues.put(newType, ""); // do a replace if newType == oldType :-) //$NON-NLS-1$
298
		else if (ABANDON.equals(mode)) anaValues.put(newType, "ERROR(" + value + ")"); // do a replace if newType == oldType :-) //$NON-NLS-1$ //$NON-NLS-2$
299 299
		
300 300
		noMatchValues.add(value);
301 301
	}
......
306 306
	
307 307
	public static void main(String args[]) {
308 308
		try {
309
			File xmlFile = new File("/home/mdecorde/xml/recode/test.xml");
310
			File tmpFile = new File("/home/mdecorde/xml/recode/test-o.xml");
311
			String oldType = "myattr";
312
			String newType = "myattr";
309
			File xmlFile = new File("/home/mdecorde/xml/recode/test.xml"); //$NON-NLS-1$
310
			File tmpFile = new File("/home/mdecorde/xml/recode/test-o.xml"); //$NON-NLS-1$
311
			String oldType = "myattr"; //$NON-NLS-1$
312
			String newType = "myattr"; //$NON-NLS-1$
313 313
			LinkedHashMap<Pattern, String> rules = new LinkedHashMap<>();
314
			rules.put(Pattern.compile(".+"), "NEWW");
315
			rules.put(Pattern.compile("x.+"), "XWORD");
316
			rules.put(Pattern.compile("y"), "YWORD");
317
			rules.put(Pattern.compile("y.*"), "YMULTIWORD");
318
			XMLTXMFileRuledConversion converter = new XMLTXMFileRuledConversion(xmlFile, rules, "w", oldType, newType, ABANDON);
314
			rules.put(Pattern.compile(".+"), "NEWW"); //$NON-NLS-1$ //$NON-NLS-2$
315
			rules.put(Pattern.compile("x.+"), "XWORD"); //$NON-NLS-1$ //$NON-NLS-2$
316
			rules.put(Pattern.compile("y"), "YWORD"); //$NON-NLS-1$ //$NON-NLS-2$
317
			rules.put(Pattern.compile("y.*"), "YMULTIWORD"); //$NON-NLS-1$ //$NON-NLS-2$
318
			XMLTXMFileRuledConversion converter = new XMLTXMFileRuledConversion(xmlFile, rules, "w", oldType, newType, ABANDON); //$NON-NLS-1$
319 319
			converter.converter = new Converter() {
320 320
				
321 321
				@Override
322 322
				public String getValue(XMLStreamReader parser, String localname, String attribute, String value) {
323
					return "NEW" + value;
323
					return "NEW" + value; //$NON-NLS-1$
324 324
				}
325 325
			};
326 326
			System.out.println(converter.process(tmpFile));
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java (revision 3883)
68 68
		
69 69
		List<Annotation> annots = tempManager.getAnnotations();
70 70
		if (annots.isEmpty()) {
71
			Log.info("No annotation to save. Aborting.");
71
			Log.info(Messages.noAnnotationToSaveAborting);
72 72
			dirty = false;
73 73
			return true;
74 74
		}
75 75
		
76 76
		if (monitor != null) {
77 77
			monitor.beginTask(Messages.savingAnnotations, annots.size());
78
			monitor.setTaskName("Writing annotations in XML-TXM files");
78
			monitor.setTaskName(Messages.writingAnnotationsInXMLTXMFiles);
79 79
		}
80 80
		
81 81
		AnnotationWriter writer = new AnnotationWriter(corpus);
......
116 116
			tempManager.getEntityManager().getTransaction().begin();
117 117
			for (Annotation a : temporaryAnnotations) {
118 118
				if (job != null && job.isCanceled()) {
119
					Log.info("Delete annotation canceled.");
119
					Log.info(Messages.deleteAnnotationCanceled);
120 120
					return false;
121 121
				}
122 122
				tempManager.deleteAnnotation(type, a.getStart(), a.getEnd());
......
127 127
			tempManager.getEntityManager().getTransaction().begin();
128 128
			for (Annotation a : cqpAnnotations) {
129 129
				if (job != null && job.isCanceled()) {
130
					Log.info("Delete annotation canceled.");
130
					Log.info(Messages.deleteAnnotationCanceled);
131 131
					return false;
132 132
				}
133 133
				String value = cqpManager.getCQPAnnotationValue(a.getStart(), a.getEnd(), type);
134 134
				if (value != null) {
135
					tempManager.createAnnotationNoCommit(type, new TypedValue("#del", "#del", type.getId()), a.getStart(), a.getEnd());
135
					tempManager.createAnnotationNoCommit(type, new TypedValue("#del", "#del", type.getId()), a.getStart(), a.getEnd()); //$NON-NLS-1$ //$NON-NLS-2$
136 136
				}
137 137
				else {
138 138
					tempManager.deleteAnnotationNoCommit(type, a.getStart(), a.getEnd());
......
166 166
				}
167 167
				
168 168
				if (job != null && job.isCanceled()) {
169
					Log.info("Delete annotation canceled.");
169
					Log.info(Messages.deleteAnnotationCanceled);
170 170
					return false;
171 171
				}
172 172
				
173 173
				String value = cqpManager.getCQPAnnotationValue(start, end, type);
174 174
				
175 175
				if (value != null) {
176
					tempManager.createAnnotationNoCommit(type, new TypedValue("#del", "#del", type.getId()), start, end);
176
					tempManager.createAnnotationNoCommit(type, new TypedValue("#del", "#del", type.getId()), start, end); //$NON-NLS-1$ //$NON-NLS-2$
177 177
				}
178 178
				else {
179 179
					tempManager.deleteAnnotationNoCommit(type, start, end);
......
206 206
			// System.out.println("Temporary annotations: "+temporaryAnnotations);
207 207
			// System.out.println("CQP annotations: "+cqpAnnotations);
208 208
			if (cqpAnnotations.size() != matches.size() || temporaryAnnotations.size() != matches.size()) {
209
				Log.info("ERROR in getAnnotationsForMatches methods! ");
209
				Log.info("ERROR in getAnnotationsForMatches methods! "); //$NON-NLS-1$
210 210
				return new ArrayList<>(matches.size());
211 211
			}
212 212
			// merge the 2 results
......
237 237
			tempManager.close();
238 238
		}
239 239
		catch (Exception e) {
240
			Log.warning(NLS.bind("Fail to clear AnnotationManager instance with error: {0}", e));
240
			Log.warning(NLS.bind(Messages.failToClearTheAnnotationManagerInstanceP0, e));
241 241
			Log.printStackTrace(e);
242 242
		}
243 243
	}
......
286 286
			}
287 287
			
288 288
			if (job != null && job.isCanceled()) { // check if user canceled the job
289
				Log.info("Affect annotation canceled.");
289
				Log.info(Messages.affectAnnotationCanceled);
290 290
				return null;
291 291
			}
292 292
			
......
345 345
				
346 346
			}
347 347
			catch (Throwable e) {
348
				Log.info(NLS.bind("Error during annotation creation: {0}.", e));
348
				Log.info(NLS.bind(Messages.errorDuringAnnotationCreationP0, e));
349 349
				Log.printStackTrace(e);
350 350
				
351 351
				if (tempManager.getEntityManager().getTransaction().isActive()) {
......
390 390
	}
391 391
	
392 392
	public void closeAll() {
393
		Log.fine("Closing annotation manager of " + corpus);
393
		Log.fine("Closing annotation manager of " + corpus); //$NON-NLS-1$
394 394
		tempManager.close();
395 395
		cqpManager.close();
396 396
	}
......
423 423
		
424 424
		List<String> krnames = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
425 425
		if (krnames.size() == 0) {
426
			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
427
			throw new IllegalArgumentException("No kr in " + corpus);
426
			Log.severe(NLS.bind(Messages.errorNoKRFoundInP0Corpus, corpus));
427
			throw new IllegalArgumentException("No kr in " + corpus); //$NON-NLS-1$
428 428
		}
429 429
		String firtsKRName = krnames.get(0);
430 430
		KnowledgeRepository defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, firtsKRName);
431 431
		if (defaultKR == null) {
432
			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
433
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus);
432
			Log.severe(NLS.bind(Messages.errorNoKRP0FoundInP1Corpus, defaultKR, corpus));
433
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus); //$NON-NLS-1$ //$NON-NLS-2$
434 434
		}
435 435
		
436 436
		PrintWriter writer = IOUtils.getWriter(resultFile, encoding, false);
437
		String cols [] = {"text_id", "id", "end_id", "start", "end", "type", "value", "mode", "date", "annotator"};
437
		String cols [] = {"text_id", "id", "end_id", "start", "end", "type", "value", "mode", "date", "annotator"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
438 438
		writer.println(StringUtils.join(cols, colseparator));
439 439
		
440 440
		if (this.getTemporaryManager().getAnnotations().size() == 0) {
441
			Log.warning("Warning: no annotations to export. Aborting.");
441
			Log.warning(Messages.warningNoAnnotationsToExportAborting);
442 442
			return false;
443 443
		}
444 444
		
......
456 456
		for (int p : positions2Ids.keySet()) {
457 457
			positions[i++] = p;
458 458
		}
459
		String values[] = corpus.getProperty("id").cpos2Str(positions);
459
		String values[] = corpus.getProperty("id").cpos2Str(positions); //$NON-NLS-1$
460 460
		for (i = 0 ; i < positions.length ; i++) {
461 461
			positions2Ids.put(positions[i], values[i]);
462 462
		}
......
469 469
			}
470 470
		});
471 471
		
472
		Log.info(NLS.bind("Exporting {0} annotations.", annotations.size()));
472
		Log.info(NLS.bind(Messages.exportingP0Annotations, annotations.size()));
473 473
		ConsoleProgressBar cpb = new ConsoleProgressBar(annotations.size());
474 474
		
475 475
		int currentText = 0;
......
515 515
		
516 516
		List<String> krnames = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
517 517
		if (krnames.size() == 0) {
518
			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
519
			throw new IllegalArgumentException("No kr in " + corpus);
518
			Log.severe(NLS.bind(Messages.errorNoKRFoundInP0Corpus, corpus));
519
			throw new IllegalArgumentException("No kr in " + corpus); //$NON-NLS-1$
520 520
		}
521 521
		String firtsKRName = krnames.get(0);
522 522
		KnowledgeRepository defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, firtsKRName);
523 523
		if (defaultKR == null) {
524
			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
525
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus);
524
			Log.severe(NLS.bind(Messages.errorNoKRP0FoundInP1Corpus, defaultKR, corpus));
525
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus); //$NON-NLS-1$ //$NON-NLS-2$
526 526
		}
527 527
		
528 528
		CsvReader reader = new CsvReader(annotationsFile.getAbsolutePath(), colseparator.charAt(0), Charset.forName(encoding));
529 529
		if (txtseparator.length() > 0) reader.setTextQualifier(txtseparator.charAt(0));
530 530
		reader.readHeaders();
531 531
		String headers [] = reader.getHeaders();
532
		String cols [] = {"text_id", "id", "end_id", "start", "end", "type", "value", "mode", "date", "annotator"};
532
		String cols [] = {"text_id", "id", "end_id", "start", "end", "type", "value", "mode", "date", "annotator"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
533 533
		if (headers.length != cols.length) {
534
			Log.warning("Error: annotation file header format is not well-formatted: "+StringUtils.join(headers, ", ")+". Should be: "+StringUtils.join(cols, ", "));
534
			Log.warning(Messages.errorAnnotationFileHeaderFormatIsNotWekkfomattedP0ItShouldBeP1+StringUtils.join(headers, ", ")+". Should be: "+StringUtils.join(cols, ", ")); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
535 535
			return false;
536 536
		}
537 537
		for (int i = 0 ; i < cols.length ; i++) {
538 538
			if (!(headers[i].equals(cols[i]))) {
539
				Log.warning("Error: annotation file header format is not well-formatted: "+StringUtils.join(headers, ", ")+". Should be: "+StringUtils.join(cols, ", "));
539
				Log.warning(Messages.errorAnnotationFileHeaderFormatIsNotWekkfomattedP0ItShouldBeP1+StringUtils.join(headers, ", ")+". Should be: "+StringUtils.join(cols, ", ")); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
540 540
				return false;
541 541
			}
542 542
		}
......
548 548
		reader.close();
549 549
		
550 550
		if (nLines == 0) {
551
			Log.warning("Error: no annotation line found");
551
			Log.warning(Messages.errorNoAnnotationLineFound);
552 552
			return false;
553 553
		}
554 554
		
555
		Log.info(NLS.bind("Importing {0} annotations...", nLines));
555
		Log.info(NLS.bind(Messages.importingP0Annotations, nLines));
556 556
		reader = new CsvReader(annotationsFile.getAbsolutePath(), colseparator.charAt(0), Charset.forName(encoding));
557 557
		if (txtseparator.length() > 0) reader.setTextQualifier(txtseparator.charAt(0));
558 558
		reader.readHeaders();
......
574 574
			if (startId.length() > 0 && endId.length() > 0) { // use the word id if present
575 575
				String textId = record[0].trim();
576 576
				if (startId.equals(endId)) {
577
					CQLQuery cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", startId, textId));
578
					QueryResult qr = corpus.query(cql , "TMP", false);
577
					CQLQuery cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", startId, textId)); //$NON-NLS-1$
578
					QueryResult qr = corpus.query(cql , "TMP", false); //$NON-NLS-1$
579 579
					if (qr.getNMatch() == 0) {
580
						Log.warning("No match found with CQL="+cql);
580
						Log.warning(Messages.noMatchFoundWithCQLEqualP0+cql);
581 581
						continue;
582 582
					}
583 583
					startPos = qr.getMatch(0).getStart();
584 584
					endPos = startPos;
585 585
				} else {
586
					CQLQuery cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", startId, textId));
587
					QueryResult qr = corpus.query(cql , "TMP", false);
586
					CQLQuery cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", startId, textId)); //$NON-NLS-1$
587
					QueryResult qr = corpus.query(cql , "TMP", false); //$NON-NLS-1$
588 588
					if (qr.getNMatch() == 0) {
589
						Log.warning("No match found with CQL="+cql);
589
						Log.warning(Messages.noMatchFoundWithCQLEqualP0+cql);
590 590
						continue;
591 591
					}
592 592
					startPos = qr.getMatch(0).getStart();
593 593
					qr.drop();
594
					cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", endId, textId));
595
					qr = corpus.query(cql , "TMP", false);
594
					cql = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", endId, textId)); //$NON-NLS-1$
595
					qr = corpus.query(cql , "TMP", false); //$NON-NLS-1$
596 596
					if (qr.getNMatch() == 0) {
597
						Log.warning("No match found with CQL="+cql);
597
						Log.warning(Messages.noMatchFoundWithCQLEqualP0+cql);
598 598
						continue;
599 599
					}
600 600
					endPos = qr.getMatch(0).getStart();
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 3883)
45 45
		this.corpus = corpus;
46 46
		List<String> krnames = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
47 47
		if (krnames.size() == 0) {
48
			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
49
			throw new IllegalArgumentException("No kr in " + corpus);
48
			Log.severe(NLS.bind(Messages.ErrorNoKnowledgeRepositoryFoundInP0Corpus, corpus));
49
			throw new IllegalArgumentException("No kr in " + corpus); //$NON-NLS-1$
50 50
		}
51 51
		String firtsKRName = krnames.get(0);
52 52
		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, firtsKRName);
53 53
		if (defaultKR == null) {
54
			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
55
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus);
54
			Log.severe(NLS.bind(Messages.ErrorNoKnowledgeRepositoryP0FoundInP1Corpus, defaultKR, corpus));
55
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus); //$NON-NLS-1$ //$NON-NLS-2$
56 56
		}
57 57
		
58 58
		types = new ArrayList<AnnotationType>();
......
78 78
	 * @throws XMLStreamException
79 79
	 */
80 80
	protected boolean writeTextAnnotationToSyMoGIH(String textid, File currentXMLFile, File currentXMLStandoffFile, File xmlStandOffDirectory) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException {
81
		Log.info("  text=" + textid);
81
		Log.info(Messages.TestP0 + textid);
82 82
		boolean show_debug = Log.getLevel().intValue() < Level.INFO.intValue();
83 83
		
84 84
		AnnotationSyMoGIHWriter annotationstdoff = new AnnotationSyMoGIHWriter(textid, currentXMLFile, xmlStandOffDirectory, types, show_debug);
......
89 89
				return true;
90 90
			}
91 91
			else {
92
				Log.warning(NLS.bind("Error: the {0} result file is malformed.", currentXMLStandoffFile));
92
				Log.warning(NLS.bind(Messages.ErrorTheP0ResultFileIsMalformed, currentXMLStandoffFile));
93 93
			}
94 94
		}
95 95
		else {
96
			Log.warning(NLS.bind("Error: while processing the {0} file in standoff dir", currentXMLStandoffFile));
96
			Log.warning(NLS.bind(Messages.ErrorWhileProcessingTheP0FileInStandOffDir, currentXMLStandoffFile));
97 97
		}
98 98
		return false;
99 99
		
......
113 113
	public boolean writeAnnotationsInStandoff(File resultZipFile) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException {
114 114
		
115 115
		List<String> textsIds = Arrays.asList(corpus.getCorpusTextIdsList());
116
		Log.info(NLS.bind("Exporting annotations of the {0} text(s).", StringUtils.join(textsIds, ", ")));
116
		Log.info(NLS.bind(Messages.ExportingAnnotationsOfTheP0Texts, StringUtils.join(textsIds, ", "))); //$NON-NLS-2$
117 117
		
118
		File resultDirectory = new File(Toolbox.getTxmHomePath(), "results/" + corpus.getID() + "_annotations");
118
		File resultDirectory = new File(Toolbox.getTxmHomePath(), "results/" + corpus.getID() + "_annotations"); //$NON-NLS-1$ //$NON-NLS-2$
119 119
		DeleteDir.deleteDirectory(resultDirectory);
120 120
		resultDirectory.mkdirs();
121 121
		if (!(resultDirectory.exists() && resultDirectory.canWrite())) {
122
			Log.warning(NLS.bind("ERROR: could not create/write temporary directory: {0}.", resultDirectory));
122
			Log.warning(NLS.bind(Messages.ErrorCouldNotCreateWriteTemporaryDirectoryP0, resultDirectory));
123 123
			return false;
124 124
		}
125 125
		
126 126
		File inputDirectory = corpus.getProjectDirectory();
127
		File corpusTxmDirectory = new File(inputDirectory, "txm/" + corpus.getID());
127
		File corpusTxmDirectory = new File(inputDirectory, "txm/" + corpus.getID()); //$NON-NLS-1$
128 128
		
129
		Log.info(NLS.bind("Writing annotations XML files in {0}.", resultDirectory));
129
		Log.info(NLS.bind(Messages.WritingAnnotationsXMLFilesInP0, resultDirectory));
130 130
		for (String textid : textsIds) {
131
			File currentXMLFile = new File(corpusTxmDirectory, textid + ".xml");
131
			File currentXMLFile = new File(corpusTxmDirectory, textid + ".xml"); //$NON-NLS-1$
132 132
			if (!currentXMLFile.exists()) {
133
				Log.warning(NLS.bind("Error: cannot found ab XML-TXM file for text with the ''{0}'' id.", textid));
133
				Log.warning(NLS.bind(Messages.ErrorCannotFoundAXMLTXMFileForTextWithTheP0Id, textid));
134 134
				return false;
135 135
			}
136
			File currentXMLStandoffFile = new File(resultDirectory, textid + ".xml"); // To Be Changed ?
136
			File currentXMLStandoffFile = new File(resultDirectory, textid + ".xml"); // To Be Changed ? //$NON-NLS-1$
137 137
			if (!writeTextAnnotationToSyMoGIH(textid, currentXMLFile, currentXMLStandoffFile, resultDirectory)) {
138
				Log.warning(NLS.bind("Error while writing annotations of text in {0}.", currentXMLStandoffFile));
138
				Log.warning(NLS.bind(Messages.ErrorWhileWritingAnnotationsOfTextInP0, currentXMLStandoffFile));
139 139
				return false;
140 140
			}
141 141
		}
......
143 143
		Zip.compress(resultDirectory, resultZipFile, new ConsoleProgressBar(1));
144 144
		DeleteDir.deleteDirectory(resultDirectory);
145 145
		
146
		Log.info(NLS.bind("Annotations saved in ''{0}''.", resultZipFile.getAbsolutePath()));
146
		Log.info(NLS.bind(Messages.AnnotationsSavedInP0, resultZipFile.getAbsolutePath()));
147 147
		return resultZipFile.exists();
148 148
	}
149 149
	
......
169 169
		List<String> textsIds = Arrays.asList(corpus.getCorpusTextIdsList());
170 170
		
171 171
		File inputDirectory = corpus.getProjectDirectory();
172
		File txmDirectory = new File(inputDirectory, "txm/" + corpus.getID());
172
		File txmDirectory = new File(inputDirectory, "txm/" + corpus.getID()); //$NON-NLS-1$
173 173
		
174 174
		ArrayList<Annotation> textAnnotations = new ArrayList<Annotation>();
175 175
		HashMap<String, ArrayList<Annotation>> annotationsPerTexts = new HashMap<String, ArrayList<Annotation>>();
176 176
		
177 177
		int currentText = 0;
178
		File currentXMLFile = new File(txmDirectory, textsIds.get(currentText) + ".xml");
178
		File currentXMLFile = new File(txmDirectory, textsIds.get(currentText) + ".xml"); //$NON-NLS-1$
179 179
		
180 180
		textAnnotations = new ArrayList<Annotation>();
181 181
		annotationsPerTexts.put(textsIds.get(currentText), textAnnotations);
......
206 206
			textAnnotations.add(currentAnnot);
207 207
		}
208 208
		
209
		File tmpXMLTXMDirectory = new File(txmDirectory.getAbsolutePath() + "_tmp");
209
		File tmpXMLTXMDirectory = new File(txmDirectory.getAbsolutePath() + "_tmp"); //$NON-NLS-1$
210 210
		DeleteDir.deleteDirectory(tmpXMLTXMDirectory);
211 211
		tmpXMLTXMDirectory.mkdirs();
212 212
		if (!(tmpXMLTXMDirectory.exists() && tmpXMLTXMDirectory.canWrite())) {
213
			Log.warning(NLS.bind("ERROR: could not create directory: {0}.", tmpXMLTXMDirectory));
213
			Log.warning(NLS.bind(Messages.ErrorCouldNotCreateDirectoryP0, tmpXMLTXMDirectory));
214 214
			return false;
215 215
		}
216 216
		
217
		File previousXMLTXMDirectory = new File(txmDirectory.getAbsolutePath() + "_previous");
217
		File previousXMLTXMDirectory = new File(txmDirectory.getAbsolutePath() + "_previous"); //$NON-NLS-1$
218 218
		// DeleteDir.deleteDirectory(tmpXMLTXMDirectory);
219 219
		previousXMLTXMDirectory.mkdirs();
220 220
		if (!(previousXMLTXMDirectory.exists() && previousXMLTXMDirectory.canWrite())) {
221
			Log.warning(NLS.bind("ERROR: could not create directory: {0}.", previousXMLTXMDirectory));
221
			Log.warning(NLS.bind(Messages.ErrorCouldNotCreateDirectoryP0, previousXMLTXMDirectory));
222 222
			return false;
223 223
		}
224 224
		
225
		Log.fine("Annotations grouped per text for " + annotationsPerTexts.size() + " text" + (annotationsPerTexts.size() > 0 ? "s" : ""));
226
		Log.fine(" - Writing temporary XML files in: " + tmpXMLTXMDirectory);
227
		Log.fine(" - Copying previous version of XML files in: " + previousXMLTXMDirectory);
225
		Log.fine("Annotations grouped per text for " + annotationsPerTexts.size() + " text" + (annotationsPerTexts.size() > 0 ? "s" : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
226
		Log.fine(" - Writing temporary XML files in: " + tmpXMLTXMDirectory); //$NON-NLS-1$
227
		Log.fine(" - Copying previous version of XML files in: " + previousXMLTXMDirectory); //$NON-NLS-1$
228 228
		// for all annotation PER TEXT, update the XML-TXM files
229 229
		currentText = 0;
230 230
		ConsoleProgressBar cpb = new ConsoleProgressBar(annotationsPerTexts.size());
231 231
		while (currentText < end_limits.length) { // end limits : 10, 30, 45, 55, 103
232
			currentXMLFile = new File(txmDirectory, textsIds.get(currentText) + ".xml");
232
			currentXMLFile = new File(txmDirectory, textsIds.get(currentText) + ".xml"); //$NON-NLS-1$
233 233
			ArrayList<Annotation> allAnnotations = annotationsPerTexts.get(textsIds.get(currentText));
234 234
			if (allAnnotations != null && allAnnotations.size() > 0) {
235 235
				ArrayList<Annotation> allSegmentAnnotations = new ArrayList<Annotation>();
......
246 246
							allTokenAnnotations.add(a);
247 247
						}
248 248
						else {
249
							Log.fine("Annotation " + a + " with type=" + a.getType() + " not found in default KR=" + defaultKR);
249
							Log.fine("Annotation " + a + " with type=" + a.getType() + " not found in default KR=" + defaultKR); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
250 250
						}
251 251
					}
252 252
					else {
253
						Log.warning("Warning: unknowed type: " + a.getType());
253
						Log.warning(Messages.WarningUnknownTypeP0 + a.getType());
254 254
					}
255 255
				}
256 256
				
257 257
				if (!writeAnnotationsInFile(currentXMLFile, start_limits[currentText],
258 258
						allSegmentAnnotations, allTokenAnnotations,
259 259
						tmpXMLTXMDirectory, previousXMLTXMDirectory)) {
260
					Log.severe("Error while writing annotations of text " + currentXMLFile);
260
					Log.severe(Messages.ErrorWhileWritingAnnotationsOfTextP0 + currentXMLFile);
261 261
					return false;
262 262
				}
263 263
				else {
......
279 279
	protected boolean writeAnnotationsInFile(File xmlFile, int text_start_position,
280 280
			ArrayList<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, File tmpXMLTXMDirectory, File previousXMLTXMDirectory) throws CqiClientException, IOException,
281 281
			CqiServerError, InvalidCqpIdException, XMLStreamException {
282
		Log.fine("Writing annotations for text " + xmlFile + " segment annotations=" + segmentAnnotations.size() + " token annotations=" + tokenAnnotations.size());
282
		Log.fine("Writing annotations for text " + xmlFile + " segment annotations=" + segmentAnnotations.size() + " token annotations=" + tokenAnnotations.size()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
283 283
		// System.out.println(segmentAnnotations);
284 284
		// System.out.println(tokenAnnotations);
285 285
		
......
297 297
					return true;
298 298
				}
299 299
				else {
300
					Log.severe("Error: could not replace XML-TXM file: " + xmlFile + " with " + tmpfile);
300
					Log.severe(Messages.ErrorCouldNotReplaceXMLTXMFileP0WithP1 + xmlFile + " with " + tmpfile); //$NON-NLS-2$
301 301
				}
302 302
			}
303 303
			else {
304
				Log.severe("Error: result file " + tmpfile + " is malformed.");
304
				Log.severe(Messages.ErrorResultFileP0IsMalformed + tmpfile + " is malformed."); //$NON-NLS-2$
305 305
			}
306 306
		}
307 307
		else {
308
			Log.severe("Error: while processing " + xmlFile + " in temp dir");
308
			Log.severe(Messages.ErrorWhileProcessingP0InTempDir + xmlFile + " in temp dir"); //$NON-NLS-2$
309 309
		}
310 310
		return false;
311 311
	}
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationSyMoGIHWriter.java (revision 3883)
15 15
import javax.xml.stream.XMLStreamWriter;
16 16

  
17 17
import org.eclipse.osgi.util.NLS;
18
import org.txm.annotation.kr.core.messages.Messages;
18 19
import org.txm.annotation.kr.core.repository.AnnotationType;
19 20
import org.txm.importer.StaxIdentityParser;
20 21
import org.txm.utils.logger.Log;
......
142 143
		 */
143 144
		boolean foundAnnot = false;
144 145
		
145
		if (types.contains(localname) && parser.getPrefix().equals("txm")) { // don't write txm annotation elements
146
		if (types.contains(localname) && parser.getPrefix().equals("txm")) { // don't write txm annotation elements //$NON-NLS-1$
146 147
			// System.out.println(" START "+ localname);
147 148
			foundAnnot = true;
148 149
			currentType = localname;
149 150
			// <txm:actr author="gazelledess" ref="PhileasFogg" date="2016-09-05" start="56" end="57">
150
			currentAuthor = parser.getAttributeValue(null, "author");
151
			currentRef = parser.getAttributeValue(null, "ref");
152
			currentStartPos = parser.getAttributeValue(null, "start");
153
			currentEndPos = parser.getAttributeValue(null, "end");
154
			currentDate = parser.getAttributeValue(null, "date");
151
			currentAuthor = parser.getAttributeValue(null, "author"); //$NON-NLS-1$
152
			currentRef = parser.getAttributeValue(null, "ref"); //$NON-NLS-1$
153
			currentStartPos = parser.getAttributeValue(null, "start"); //$NON-NLS-1$
154
			currentEndPos = parser.getAttributeValue(null, "end"); //$NON-NLS-1$
155
			currentDate = parser.getAttributeValue(null, "date"); //$NON-NLS-1$
155 156
			// annotation is here
156 157
			startAnnotation = true;
157 158
			positions = new ArrayList<String>();
......
176 177
			super.processStartElement(); /// continue writing in file all elements, except the tags that are now in stand-off files
177 178
			
178 179
			// get words ids of the current annotations
179
			if (localname.equals("w") && startAnnotation) {
180
				String id = parser.getAttributeValue(null, "id");
180
			if (localname.equals("w") && startAnnotation) { //$NON-NLS-1$
181
				String id = parser.getAttributeValue(null, "id"); //$NON-NLS-1$
181 182
				for (String typeIn : annotationsPositions.keySet()) {
182 183
					positions = annotationsPositions.get(typeIn);
183 184
					positions.add(id);
......
217 218
	private XMLStreamWriter writeStartStandOffFile(File file) {
218 219
		// System.out.println("writeStartStandOffFile ...");
219 220
		
220
		String ns = "http://www.tei-c.org/ns/1.0";
221
		String ns = "http://www.tei-c.org/ns/1.0"; //$NON-NLS-1$
221 222
		XMLOutputFactory output = XMLOutputFactory.newInstance();
222 223
		XMLStreamWriter writer = null;
223 224
		try {
224 225
			writer = output.createXMLStreamWriter(new FileWriter(file));
225 226
			writer.writeStartDocument();
226
			writer.setPrefix("tei", ns);
227
			writer.setPrefix("tei", ns); //$NON-NLS-1$
227 228
			writer.setDefaultNamespace(ns);
228 229
			
229
			writer.writeStartElement("TEI");
230
			writer.writeStartElement("TEI"); //$NON-NLS-1$
230 231
			
231
			writer.writeStartElement("teiHeader");
232
			writer.writeStartElement("fileDesc");
232
			writer.writeStartElement("teiHeader"); //$NON-NLS-1$
233
			writer.writeStartElement("fileDesc"); //$NON-NLS-1$
233 234
			
234
			writer.writeStartElement("titleStmt");
235
			writer.writeStartElement("title");
235
			writer.writeStartElement("titleStmt"); //$NON-NLS-1$
236
			writer.writeStartElement("title"); //$NON-NLS-1$
236 237
			writer.writeCharacters(textid);
237 238
			writer.writeEndElement(); // title
238 239
			writer.writeEndElement(); // titleStmt
239 240
			
240
			writer.writeStartElement("publicationStmt");
241
			writer.writeStartElement("p");
242
			writer.writeCharacters("PUBLICATION INFO à renseigner");
241
			writer.writeStartElement("publicationStmt"); //$NON-NLS-1$
242
			writer.writeStartElement("p"); //$NON-NLS-1$
243
			writer.writeCharacters("PUBLICATION INFO à renseigner"); //$NON-NLS-1$
243 244
			writer.writeEndElement(); // p
244 245
			writer.writeEndElement(); // publicationStmt
245 246
			
246
			writer.writeStartElement("sourceDesc");
247
			writer.writeStartElement("p");
248
			writer.writeCharacters("Ce document permet l'annotation sémantique de tous les textes, par auteur");
247
			writer.writeStartElement("sourceDesc"); //$NON-NLS-1$
248
			writer.writeStartElement("p"); //$NON-NLS-1$
249
			writer.writeCharacters("Ce document permet l'annotation sémantique de tous les textes, par auteur"); //$NON-NLS-1$
249 250
			writer.writeEndElement(); // p
250 251
			writer.writeEndElement(); // sourceDesc
251 252
			
252 253
			writer.writeEndElement(); // </fileDesc>
253
			writer.writeStartElement("encodingDesc");
254
			writer.writeStartElement("projectDesc");
255
			writer.writeStartElement("p");
256
			writer.writeCharacters("Annotations created by " + currentAuthor + ", for the use in Symogih XML platform");
254
			writer.writeStartElement("encodingDesc"); //$NON-NLS-1$
255
			writer.writeStartElement("projectDesc"); //$NON-NLS-1$
256
			writer.writeStartElement("p"); //$NON-NLS-1$
257
			writer.writeCharacters("Annotations created by " + currentAuthor + ", for the use in Symogih XML platform"); //$NON-NLS-1$ //$NON-NLS-2$
257 258
			writer.writeEndElement(); // p
258 259
			writer.writeEndElement(); // </projectDesc>
259 260
			writer.writeEndElement(); // </encodingDesc>
260 261
			writer.writeEndElement(); // </teiHeader>
261 262
			
262 263
			
263
			writer.writeStartElement("text");
264
			writer.writeStartElement("body");
265
			writer.writeCharacters("\n");
266
			writer.writeStartElement("div");
267
			writer.writeCharacters("\n");
264
			writer.writeStartElement("text"); //$NON-NLS-1$
265
			writer.writeStartElement("body"); //$NON-NLS-1$
266
			writer.writeCharacters("\n"); //$NON-NLS-1$
267
			writer.writeStartElement("div"); //$NON-NLS-1$
268
			writer.writeCharacters("\n"); //$NON-NLS-1$
268 269
		}
269 270
		catch (XMLStreamException e) {
270 271
			// TODO Auto-generated catch block
......
291 292
	private void writeStartAnnotationToStandoffFile(String[] data, ArrayList<String> positions) {
292 293
		// System.out.println("writeStartAnnotationToStandoffFile ...");
293 294
		try {
294
			currentWriter.writeStartElement("span");
295
			currentWriter.writeAttribute("type", data[2]);
296
			currentWriter.writeAttribute("ana", data[1]);
295
			currentWriter.writeStartElement("span"); //$NON-NLS-1$
296
			currentWriter.writeAttribute("type", data[2]); //$NON-NLS-1$
297
			currentWriter.writeAttribute("ana", data[1]); //$NON-NLS-1$
297 298
			StringBuffer listWids = new StringBuffer();
298 299
			for (String posW : positions) {
299
				listWids.append("#" + posW + " ");
300
				listWids.append("#" + posW + " "); //$NON-NLS-1$ //$NON-NLS-2$
300 301
			}
301
			currentWriter.writeAttribute("target", listWids.toString().trim());
302
			currentWriter.writeAttribute("target", listWids.toString().trim()); //$NON-NLS-1$
302 303
			currentWriter.writeEndElement(); // span
303
			currentWriter.writeCharacters("\n");
304
			currentWriter.writeCharacters("\n"); //$NON-NLS-1$
304 305
		}
305 306
		catch (XMLStreamException e) {
306 307
			// TODO Auto-generated catch block
......
310 311
	
311 312
	protected void processEndElement() throws XMLStreamException {
312 313
		boolean foundAnnot = false;
313
		if (types.contains(localname) && parser.getPrefix().equals("txm")) { // skip annotation end element
314
		if (types.contains(localname) && parser.getPrefix().equals("txm")) { // skip annotation end element //$NON-NLS-1$
314 315
			// System.out.println(" END "+ localname);
315 316
			foundAnnot = true;
316 317
			// annotation ends here
......
324 325
		}
325 326
		
326 327
		if (!foundAnnot) {
327
			if (localname.equals("TEI")) {
328
			if (localname.equals("TEI")) { //$NON-NLS-1$
328 329
				try {
329 330
					for (String author : allannotations.keySet()) {
330
						Log.info("    author=" + author);
331
						File currentXmlFile = new File(xmlStandOffDirectory, filename.substring(0, filename.length() - 4) + "_" + currentAuthor + "_annotations.xml");
331
						Log.info("    author=" + author); //$NON-NLS-1$
332
						File currentXmlFile = new File(xmlStandOffDirectory, filename.substring(0, filename.length() - 4) + "_" + currentAuthor + "_annotations.xml"); //$NON-NLS-1$ //$NON-NLS-2$
332 333
						
333 334
						// write start of the stand-off file
334 335
						currentWriter = writeStartStandOffFile(currentXmlFile);
......
340 341
							ArrayList<String[]> datas = dates.get(date);
341 342
							ArrayList<ArrayList<String>> positions = datesPositions.get(date);
342 343
							
343
							currentWriter.writeStartElement("div");
344
							currentWriter.writeCharacters("\n");
345
							currentWriter.writeStartElement("head");
346
							currentWriter.writeStartElement("date");
347
							currentWriter.writeAttribute("type", "annotation_date");
348
							currentWriter.writeAttribute("when", date);
344
							currentWriter.writeStartElement("div"); //$NON-NLS-1$
345
							currentWriter.writeCharacters("\n"); //$NON-NLS-1$
346
							currentWriter.writeStartElement("head"); //$NON-NLS-1$
347
							currentWriter.writeStartElement("date"); //$NON-NLS-1$
348
							currentWriter.writeAttribute("type", "annotation_date"); //$NON-NLS-1$ //$NON-NLS-2$
349
							currentWriter.writeAttribute("when", date); //$NON-NLS-1$
349 350
							currentWriter.writeEndElement(); // date
350 351
							currentWriter.writeEndElement(); // head
351
							currentWriter.writeCharacters("\n");
352
							currentWriter.writeCharacters("\n"); //$NON-NLS-1$
352 353
							
353 354
							for (int i = 0; i < datas.size(); i++) {
354 355
								writeStartAnnotationToStandoffFile(datas.get(i), positions.get(i));
355 356
							}
356 357
							
357 358
							currentWriter.writeEndElement(); // div
358
							currentWriter.writeCharacters("\n");
359
							currentWriter.writeCharacters("\n"); //$NON-NLS-1$
359 360
						}
360 361
						
361 362
						// write the end of the stand-off file
......
363 364
					}
364 365
				}
365 366
				catch (Exception e) {
366
					Log.warning(NLS.bind("Error with current writer: {0}.", currentWriter));
367
					Log.warning(NLS.bind(Messages.ErrorWithCurrentWriterP0, currentWriter));
367 368
					Log.printStackTrace(e);
368 369
				}
369 370
			}
......
373 374
	
374 375
	public static void main(String strs[]) {
375 376
		try {
376
			File xmlFile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J", "tdm80j.xml");
377
			File outfile = new File(xmlFile.getParentFile(), "tdm80j-tei.xml");
377
			File xmlFile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J", "tdm80j.xml"); //$NON-NLS-1$ //$NON-NLS-2$
378
			File outfile = new File(xmlFile.getParentFile(), "tdm80j-tei.xml"); //$NON-NLS-1$
378 379
			
379 380
			File xmlStandOffDirectory = xmlFile.getParentFile();
380 381
			List<AnnotationType> types = new ArrayList<AnnotationType>();
381
			types.add(new AnnotationType("local", "actr_id", "actr"));
382
			types.add(new AnnotationType("local", "actr_id", "actr")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
382 383
			AnnotationSyMoGIHWriter annotStdff;
383 384
			try {
384
				annotStdff = new AnnotationSyMoGIHWriter("TDBM80J", xmlFile, xmlStandOffDirectory, types, true);
385
				annotStdff = new AnnotationSyMoGIHWriter("TDBM80J", xmlFile, xmlStandOffDirectory, types, true); //$NON-NLS-1$
385 386
				annotStdff.process(outfile);
386 387
			}
387 388
			catch (MalformedURLException e) {
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationInjector.java (revision 3883)
15 15

  
16 16
import org.eclipse.osgi.util.NLS;
17 17
import org.txm.Toolbox;
18
import org.txm.annotation.kr.core.messages.Messages;
18 19
import org.txm.importer.StaxIdentityParser;
19 20
import org.txm.importer.ValidateXml;
20 21
import org.txm.utils.logger.Log;
......
86 87
			XMLStreamException {
87 88
		super(xmlFile.toURI().toURL()); // init reader and writer
88 89
		
89
		this.user = System.getProperty("user.name");
90
		this.user = System.getProperty("user.name"); //$NON-NLS-1$
90 91
		
91 92
		this.debug = debug;
92 93
		this.xmlFile = xmlFile;
......
149 150
		});
150 151
		
151 152
		if (debug) {
152
			Log.finer("annotations for " + xmlFile);
153
			Log.finer(" segment grouped and ordered by start position: " + annotationsToAddByStartPos);
154
			Log.finer(" segment grouped and ordered by end position: " + annotationsToAddByEndPos);
155
			Log.finer(" token ordered by start position: " + tokenAnnotations);
153
			Log.finer("annotations for " + xmlFile); //$NON-NLS-1$
154
			Log.finer(" segment grouped and ordered by start position: " + annotationsToAddByStartPos); //$NON-NLS-1$
155
			Log.finer(" segment grouped and ordered by end position: " + annotationsToAddByEndPos); //$NON-NLS-1$
156
			Log.finer(" token ordered by start position: " + tokenAnnotations); //$NON-NLS-1$
156 157
		}
157 158
	}
158 159
	
......
172 173
		// System.out.println("A Starts: "+currentStartAnnotations+" "+currentEndAnnotations);
173 174
		// if (debug)
174 175
		// System.out.println("----- "+localname+"@"+position_counter+" START ANNOT = "+currentStartAnnotations);
175
		if ("teiHeader".equals(localname)) {
176
		if ("teiHeader".equals(localname)) { //$NON-NLS-1$
176 177
			super.processStartElement();
177
			goToEnd("teiHeader"); // skip teiHeader // will be closed in
178
			goToEnd("teiHeader"); // skip teiHeader // will be closed in //$NON-NLS-1$
178 179
			// processEndElement()
179 180
		}
180
		else if ("w".equals(localname)) {
181
		else if ("w".equals(localname)) { //$NON-NLS-1$
181 182
			// System.out.println("W START pos="+position_counter+" annots="+currentStartAnnotations);
182 183
			if (currentStartAnnotations != null) {// there are still annotations
183 184
				// to write, possible
......
185 186
				// if (debug)
186 187
				// System.out.println("WRITING START at "+position_counter+": "+currentStartAnnotations);
187 188
				for (Annotation a : currentStartAnnotations) {
188
					if (!"#del".equals(a.getValue())) {
189
					if (!"#del".equals(a.getValue())) { //$NON-NLS-1$
189 190
						if (debug) {
190
							Log.finer(" force write start annotation " + a);
191
							Log.finer(" force write start annotation " + a); //$NON-NLS-1$
191 192
						}
192 193
						writeStartAnnotation(a);
193 194
					}
194 195
					else {
195 196
						if (debug)
196
							Log.finer(" no need to write start annotation " + a);
197
							Log.finer(" no need to write start annotation " + a); //$NON-NLS-1$
197 198
						currentEndAnnotations = annotationsToAddByEndPos.get(a.getEnd());
198 199
						// System.out.println(" shall we need to change annotation attribute : "+a.getValue()+
199 200
						// " | currentEndAnnotations : "+currentEndAnnotations);
200 201
						if (currentEndAnnotations == null) {
201
							Log.finer("WARNING ERROR null pointer for end position of annotation " + a);
202
							Log.finer("WARNING ERROR null pointer for end position of annotation " + a); //$NON-NLS-1$
202 203
						}
203 204
						else {
204 205
							currentEndAnnotations.remove(a);
......
230 231
			super.processStartElement(); // write the tag
231 232
			
232 233
		}
233
		else if ("form".equals(localname) && inW) {
234
			if (currentTokenAnnotations.containsKey("word")) {
235
				Annotation a = currentTokenAnnotations.get("word");
234
		else if ("form".equals(localname) && inW) { //$NON-NLS-1$
235
			if (currentTokenAnnotations.containsKey("word")) { //$NON-NLS-1$
236
				Annotation a = currentTokenAnnotations.get("word"); //$NON-NLS-1$
236 237
				// System.out.println("Updating token annotation with: " + a);
237 238
				
238 239
				String value = a.getValue();
239
				if ("#del".equals(value)) {
240
					value = "";
240
				if ("#del".equals(value)) { //$NON-NLS-1$
241
					value = ""; //$NON-NLS-1$
241 242
				}
242 243
				if (value == null) {
243
					value = "ERROR";
244
					value = "ERROR"; //$NON-NLS-1$
244 245
				}
245 246
				try {
246
					writer.writeStartElement(TXMNS, "form");
247
					writer.writeStartElement(TXMNS, "form"); //$NON-NLS-1$
247 248
					writer.writeCharacters(value);
248 249
					mustChangeWordValue = true;
249 250
				}
......
252 253
					e.printStackTrace();
253 254
				}
254 255
				
255
				currentTokenAnnotations.remove("word"); // annotation updated
256
				currentTokenAnnotations.remove("word"); // annotation updated //$NON-NLS-1$
256 257
			}
257 258
			else {
258 259
				super.processStartElement();
259 260
			}
260 261
		}
261
		else if ("ana".equals(localname) && inW) {
262
		else if ("ana".equals(localname) && inW) { //$NON-NLS-1$
262 263
			inAna = true;
263
			String type = parser.getAttributeValue(null, "type").substring(1);
264
			String type = parser.getAttributeValue(null, "type").substring(1); //$NON-NLS-1$
264 265
			if (currentTokenAnnotations.containsKey(type)) {
265 266
				Annotation a = currentTokenAnnotations.get(type);
266 267
				// System.out.println("Updating token annotation with: " + a);
267 268
				
268 269
				String value = a.getValue();
269
				if ("#del".equals(value)) {
270
					value = "";
270
				if ("#del".equals(value)) { //$NON-NLS-1$
271
					value = ""; //$NON-NLS-1$
271 272
				}
272 273
				if (value == null) {
273
					value = "ERROR";
274
					value = "ERROR"; //$NON-NLS-1$
274 275
				}
275 276
				
276 277
				try {
277
					writer.writeStartElement("ana");
278
					writer.writeAttribute("type", "#" + type);
279
					writer.writeAttribute("resp", "#" + a.getAnnotator()); // change
278
					writer.writeStartElement("ana"); //$NON-NLS-1$
279
					writer.writeAttribute("type", "#" + type); //$NON-NLS-1$ //$NON-NLS-2$
280
					writer.writeAttribute("resp", "#" + a.getAnnotator()); // change //$NON-NLS-1$ //$NON-NLS-2$
280 281
					// resp
281 282
					writer.writeCharacters(value);
282 283
					mustChangeAnaValue = true;
......
295 296
		else if (currentStartAnnotations != null) { // is it an annotations ?
296 297
			// System.out.println("A START="+localname);
297 298
			
298
			String s_end = parser.getAttributeValue(null, "end");
299
			String s_start = parser.getAttributeValue(null, "start");
300
			String s_author = parser.getAttributeValue(null, "author");
301
			String s_ref = parser.getAttributeValue(null, "ref");
299
			String s_end = parser.getAttributeValue(null, "end"); //$NON-NLS-1$
300
			String s_start = parser.getAttributeValue(null, "start"); //$NON-NLS-1$
301
			String s_author = parser.getAttributeValue(null, "author"); //$NON-NLS-1$
302
			String s_ref = parser.getAttributeValue(null, "ref"); //$NON-NLS-1$
302 303
			
303 304
			boolean toDelete = false;
304 305
			
......
328 329
							// updated = true;
329 330
							// if (debug)
330 331
							// System.out.println(" found existing annotation "+a);
331
							if ("#del".equals(a.getValue())) {
332
							if ("#del".equals(a.getValue())) { //$NON-NLS-1$
332 333
								toDelete = true;
333 334
								// currentEndAnnotations.remove(a); // MAYBE NOT TO
334 335
								// DO THIS HERE ?
335 336
								if (debug) {
336
									Log.finer(" force delete start annotation " + a);
337
									Log.finer(" force delete start annotation " + a); //$NON-NLS-1$
337 338
								}
338 339
							}
339 340
							else { // update existing annotation, no need to store
......
341 342
								writeStartAnnotation(a);
342 343
								toDelete = true;
343 344
								if (debug) {
344
									Log.finer(" update annotation " + a);
345
									Log.finer(" update annotation " + a); //$NON-NLS-1$
345 346
								}
346 347
								currentEndAnnotations = annotationsToAddByEndPos.get(a.getEnd());// EL
347 348
								// NO
......
351 352
								// System.out.println(" shall we need to change annotation attribute : "+a.getValue()+
352 353
								// " | currentEndAnnotations : "+currentEndAnnotations);
353 354
								if (currentEndAnnotations == null) {
354
									Log.warning(NLS.bind("Error: null pointer for end position of annotation {0}.", a));
355
									Log.warning(NLS.bind(Messages.ErrorNPEForEndPositionOfAnnotationP0, a));
355 356
								}
356 357
								else {
357 358
									currentEndAnnotations.remove(a);
......
369 370
						
370 371
						if (s_start != null && s_end != null && s_author != null && s_ref != null) {
371 372
							if (a.getEnd() >= end) { // must write a
372
								if (!"#del".equals(a.getValue())) {
373
								if (!"#del".equals(a.getValue())) { //$NON-NLS-1$
373 374
									if (debug) {
374
										Log.finer(NLS.bind(" writing of start annotation {0}.", a));
375
										Log.finer(NLS.bind(" writing of start annotation {0}.", a)); //$NON-NLS-1$
375 376
									}
376 377
									writeStartAnnotation(a);
377 378
									
......
379 380
								else {
380 381
									toDelete = true;
381 382
									if (debug) {
382
										Log.finer(NLS.bind(" no writing of start annotation {0}.", a));
383
										Log.finer(NLS.bind(" no writing of start annotation {0}.", a)); //$NON-NLS-1$
383 384
									}
384 385
									currentEndAnnotations = annotationsToAddByEndPos.get(a.getEnd());
385 386
									// System.out.println(" shall we need to change annotation attribute : "+a.getValue()+
386 387
									// " | currentEndAnnotations : "+currentEndAnnotations);
387 388
									if (currentEndAnnotations == null) {
388
										Log.warning(NLS.bind("Error: null pointer for end position of annotation {0}.", a));
389
										Log.warning(NLS.bind(Messages.ErrorNPEForEndPositionOfAnnotationP0, a));
389 390
									}
390 391
									else {
391 392
										currentEndAnnotations.remove(a);
......
441 442
		// if (debug)
442 443
		// System.out.println("----- "+localname+"@"+position_counter+" END ANNOT = "+currentEndAnnotations);
443 444
		
444
		if ("w".equals(localname)) {
445
		if ("w".equals(localname)) { //$NON-NLS-1$
445 446
			// System.out.println("W END");
446 447
			
447 448
			for (String type : currentTokenAnnotations.keySet()) {
448 449
				try {
449
					writer.writeStartElement("ana");
450
					writer.writeAttribute("type", "#" + type);
451
					writer.writeAttribute("resp", "#" + currentTokenAnnotations.get(type).getAnnotator()); // change
450
					writer.writeStartElement("ana"); //$NON-NLS-1$
451
					writer.writeAttribute("type", "#" + type); //$NON-NLS-1$ //$NON-NLS-2$
452
					writer.writeAttribute("resp", "#" + currentTokenAnnotations.get(type).getAnnotator()); // change //$NON-NLS-1$ //$NON-NLS-2$
452 453
					// resp
453 454
					writer.writeCharacters(currentTokenAnnotations.get(type).getValue());
454 455
					writer.writeEndElement();
......
469 470
				for (Annotation a : currentEndAnnotations) {
470 471
					// if (debug)
471 472
					// System.out.println("=============== End annot : "+a);
472
					if (!"#del".equals(a.getValue())) {
473
					if (!"#del".equals(a.getValue())) { //$NON-NLS-1$
473 474
						if (debug) {
474
							Log.finer(" force write end annotation " + a);
475
							Log.finer(" force write end annotation " + a); //$NON-NLS-1$
475 476
						}
476 477
						writeEndAnnotation(a);
477 478
					} /*
......
485 486
			
486 487
			position_counter++;
487 488
		}
488
		else if ("form".equals(localname) && inW) {
489
		else if ("form".equals(localname) && inW) { //$NON-NLS-1$
489 490
			// if (!mustChangeAnaValue)
490 491
			super.processEndElement();
491 492
			mustChangeWordValue = false;
492 493
			inForm = false;
493 494
		}
494
		else if ("ana".equals(localname) && inW) {
495
		else if ("ana".equals(localname) && inW) { //$NON-NLS-1$
495 496
			// if (!mustChangeAnaValue)
496 497
			super.processEndElement();
497 498
			inAna = false;
......
508 509
					// if (debug)
509 510
					// System.out.println(" found existing end annotation "+a);
510 511
					
511
					if ("#del".equals(a.getValue())) { // if
512
					if ("#del".equals(a.getValue())) { // if //$NON-NLS-1$
512 513
						// (!"#del".equals(a.getValue()))
513 514
						// {
514 515
						toDelete = true;
515 516
						if (debug) {
516
							Log.finer(" force delete end annotation " + a);
517
							Log.finer(" force delete end annotation " + a); //$NON-NLS-1$
517 518
						}
518 519
					}
519 520
					
......
538 539
	
539 540
	private void writeStartAnnotation(Annotation a) {
540 541
		try {
541
			writer.writeStartElement("txm:" + a.getType());
542
			writer.writeAttribute("author", "" + a.getAnnotator());
543
			writer.writeAttribute("ref", a.getValue());
544
			writer.writeAttribute("date", Toolbox.dateformat.format(new Date()));
545
			writer.writeAttribute("start", Integer.toString(a.getStart()));
546
			writer.writeAttribute("end", Integer.toString(a.getEnd()));
542
			writer.writeStartElement("txm:" + a.getType()); //$NON-NLS-1$
543
			writer.writeAttribute("author", "" + a.getAnnotator()); //$NON-NLS-1$ //$NON-NLS-2$
544
			writer.writeAttribute("ref", a.getValue()); //$NON-NLS-1$
545
			writer.writeAttribute("date", Toolbox.dateformat.format(new Date())); //$NON-NLS-1$
546
			writer.writeAttribute("start", Integer.toString(a.getStart())); //$NON-NLS-1$
547
			writer.writeAttribute("end", Integer.toString(a.getEnd())); //$NON-NLS-1$
547 548
		}
548 549
		catch (XMLStreamException e) {
549 550
			// TODO Auto-generated catch block
......
565 566
	
566 567
	public static ArrayList<Annotation> testAdding() {
567 568
		
568
		Annotation a1 = new Annotation("Actr", "Actr100", 15, 16);
569
		Annotation a1 = new Annotation("Actr", "Actr100", 15, 16); //$NON-NLS-1$ //$NON-NLS-2$
569 570
		ArrayList<Annotation> annotations = new ArrayList<>();
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff