Revision 966

tmp/org.txm.tigersearch.rcp/groovy/org/txm/importer/tigersearch/TSImporter.groovy (revision 966)
25 25
		File binDir = module.getBinaryDirectory();
26 26
		
27 27
		//prepare metadata if any
28
		File allmetadatafile = new File(inputDirectory, "metadata.csv");
28
		File allmetadatafile = Metadatas.findMetadataFile(inputDirectory);
29 29
		println allmetadatafile
30 30
		if (allmetadatafile.exists()) {
31
			File copy = new File(binDir, "metadata.csv")
31
			File copy = new File(binDir, allmetadatasfile.getName())
32 32
			if (!FileCopy.copy(allmetadatafile, copy)) {
33 33
				println "Error: could not create a copy of the metadata file "+allmetadatafile.getAbsoluteFile();
34 34
				return;
tmp/org.txm.tigersearch.rcp/groovy/org/txm/importer/srcmf/srcmfLoader.groovy (revision 966)
103 103
// copy txm files
104 104
List<File> srcfiles = txmSrcDir.listFiles();
105 105
for (File f : srcfiles) {// check XML format, and copy file into binDir
106
	if (f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties"))
106
	if (f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties"))
107 107
		continue;
108 108
	if (ValidateXml.test(f)) {
109 109
		FileCopy.copy(f, new File(txmDir, f.getName()));
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xmltxmpara/xmltxmparaLoader.groovy (revision 966)
98 98
//copy txm files
99 99
List<File> srcfiles = srcDir.listFiles();
100 100
for (File f : srcfiles) {// check XML format, and copy file into binDir
101
	if (f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties"))
101
	if (f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties"))
102 102
	continue;
103 103
	if (ValidateXml.test(f)) {
104 104
		FileCopy.copy(f, new File(paraDir, f.getName()));
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xml/xmlLoader.groovy (revision 966)
147 147
if (srcfiles != null)
148 148
	for (int i = 0 ; i < srcfiles.size() ; i++) {// check XML format, and copy file into binDir
149 149
		File f = srcfiles.get(i)
150
		if (f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties")) {
150
		if (f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties")) {
151 151
			srcfiles.remove(i);
152 152
			i--;
153 153
			continue;
......
185 185
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
186 186
if (allmetadatasfile.exists()) {
187 187
	println " Metadata file found: "+allmetadatasfile
188
	File copy = new File(binDir, "metadata.csv")
188
	File copy = new File(binDir, allmetadatasfile.getName())
189 189
	if (!FileCopy.copy(allmetadatasfile, copy)) {
190 190
		println "Error: could not create a copy of metadata file "+allmetadatasfile.getAbsoluteFile();
191 191
		return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/bfm/bfmLoader.groovy (revision 966)
124 124
println "-- VALIDATION - checking XML source files well-formedness"
125 125
List<File> srcfiles = srcDir.listFiles();
126 126
for (File f : srcfiles) { // check XML format, and copy file into binDir
127
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties"))
127
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties"))
128 128
		continue;
129 129
	if (ValidateXml.test(f)) {
130 130
		FileCopy.copy(f, new File(txmDir, f.getName()));
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/factiva/factivaLoader.groovy (revision 966)
154 154
List<File> srcfiles = srcDir.listFiles();
155 155
for (int i = 0 ; i < srcfiles.size() ; i++) {// check XML format, and copy file into binDir
156 156
	File f = srcfiles.get(i)
157
	if (f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties")) {
157
	if (f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties")) {
158 158
		srcfiles.remove(i);
159 159
		i--;
160 160
		continue;
......
175 175
Metadatas metadatas; // text metadata
176 176
println "Trying to read metadata from: "+allmetadatasfile
177 177
if (allmetadatasfile.exists()) {
178
	File copy = new File(binDir, "metadata.csv")
178
	File copy = new File(binDir, allmetadatasfile.getName())
179 179
	if (!FileCopy.copy(allmetadatasfile, copy)) {
180 180
		println "Error: could not create a copy of metadata file "+allmetadatasfile.getAbsoluteFile();
181 181
		return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/XMLText2TXTCSV.groovy (revision 966)
5 5
println "1) xml -> txt + write metadata.csv"
6 6
outdir.deleteDir()
7 7
outdir.mkdir()
8
File metadatafile = new File(outdir, "metadata.csv")
8
File metadatafile = Metadatas.findMetadataFile(outdir)
9 9
String csvString = ""
10 10

  
11 11
def files = dir.listFiles()
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/discours/importer.groovy (revision 966)
93 93
		
94 94
		println "Trying to read metadata from: "+csvfile
95 95
		if (csvfile.exists()) {
96
			File copy = new File(binDir, "metadata.csv")
96
			File copy = new File(binDir, csvfile.getName())
97 97
			if (!FileCopy.copy(csvfile, copy)) {
98 98
				println "Error: could not create a copy of metadata file "+csvfile.getAbsoluteFile();
99 99
				return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/doc/docLoader.groovy (revision 966)
207 207
Metadatas metadatas; // text metadata
208 208
//println "Trying to read metadata from: "+allmetadatasfile
209 209
if (allmetadatasfile.exists()) {
210
	File copy = new File(binDir, "metadata.csv")
210
	File copy = new File(binDir, allmetadatasfile.getName())
211 211
	if (!FileCopy.copy(allmetadatasfile, copy)) {
212
		println "Error: could not create a copy of the metadata.csv file "+allmetadatasfile.getAbsoluteFile();
212
		println "Error: could not create a copy of the $allmetadatasfile file "+allmetadatasfile.getAbsoluteFile();
213 213
		return;
214 214
	}
215 215
	metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), 
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/transcriber/transcriberLoader.groovy (revision 966)
117 117
File allmetadatasfile = Metadatas.findMetadataFile(srcDir);
118 118
println "Trying to read metadatas values from: "+allmetadatasfile
119 119
if (allmetadatasfile.exists()) {
120
	File copy = new File(binDir, "metadata.csv")
120
	File copy = new File(binDir, allmetadatasfile.getName())
121 121
	if (!FileCopy.copy(allmetadatasfile, copy)) {
122 122
		println "Error: could not create a copy of metadata file "+allmetadatasfile.getAbsoluteFile();
123 123
		return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xmltxm/xmltxmLoader.groovy (revision 966)
111 111
println "Copying XML-TXM files..."
112 112
List<File> srcfiles = srcDir.listFiles();
113 113
for (File f : srcfiles) {// check XML format, and copy file into binDir
114
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties"))
114
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties"))
115 115
		continue;
116 116
	if (ValidateXml.test(f)) {
117 117
		FileCopy.copy(f, new File(txmDir, f.getName()));
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/txt/txtLoader.groovy (revision 966)
92 92

  
93 93
if (allmetadatasfile.exists()) {
94 94
	println "Trying to read metadata from: "+allmetadatasfile
95
	File copy = new File(binDir, "metadata.csv")
95
	File copy = new File(binDir, allmetadatasfile.getName())
96 96
	if (!FileCopy.copy(allmetadatasfile, copy)) {
97 97
		println "Error: could not create a copy of metadata file "+allmetadatasfile.getAbsoluteFile();
98 98
		return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xtz/XTZImporter.groovy (revision 966)
102 102
		this.skipDoTokenizeStep = module.getParameters().getSkipTokenization()
103 103

  
104 104
		//prepare metadata if any
105
		File allmetadatafile = new File(inputDirectory, "metadata.csv");
105
		File allmetadatafile = Metadatas.findMetadataFile(inputDirectory);
106 106
		if (allmetadatafile.exists()) {
107
			File copy = new File(binDir, "metadata.csv")
107
			File copy = new File(binDir, allmetadatasfile.getName())
108 108
			if (!FileCopy.copy(allmetadatafile, copy)) {
109 109
				println "Error: could not create a copy of the metadata file "+allmetadatafile.getAbsoluteFile();
110 110
				return;
tmp/org.txm.groovy.core/src/groovy/org/txm/importer/frantext/frantextLoader.groovy (revision 966)
126 126
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
127 127
List<File> srcfiles = srcDir.listFiles();
128 128
for (File f : srcfiles) { // check XML format, and copy file into binDir
129
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties"))
129
	if (f.isHidden() || f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties"))
130 130
		continue;
131 131
	if (ValidateXml.test(f)) {
132 132
		FileCopy.copy(f, new File(txmDir, f.getName()));
tmp/org.txm.groovy.core/src/groovy/org/txm/macroproto/importer/XTZImporterMacro.groovy (revision 966)
210 210
if (srcfiles != null)
211 211
for (int i = 0 ; i < srcfiles.size() ; i++) {// check XML format, and copy file into binDir
212 212
	File f = srcfiles.get(i)
213
	if (f.getName().equals("import.xml") || f.getName().equals("metadata.csv") || f.getName().endsWith(".properties")) {
213
	if (f.getName().equals("import.xml") || f.getName().matches("metadata\.....?") || f.getName().endsWith(".properties")) {
214 214
		srcfiles.remove(i);
215 215
		i--;
216 216
		continue;
......
233 233
println "Trying to read metadatas from: "+allmetadatasfile
234 234
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
235 235
if (allmetadatasfile.exists()) {
236
	File copy = new File(binDir, "metadata.csv")
236
	File copy = new File(binDir, allmetadatasfile.getName())
237 237
	if (!FileCopy.copy(allmetadatasfile, copy)) {
238 238
		println "Error: could not create a copy of metadata file "+allmetadatasfile.getAbsoluteFile();
239 239
		return;
tmp/org.txm.groovy.core/src/groovy/org/txm/macroproto/XMLText2MetadataCSVMacro.groovy (revision 966)
7 7
import org.txm.rcp.swt.widget.parameters.*
8 8

  
9 9
import org.txm.importer.*
10
import org.txm.metadatas.Metadatas
10 11

  
11 12
// BEGINNING OF PARAMETERS
12 13

  
......
47 48
println "XPATH queries: $xpaths"
48 49

  
49 50
if (metadataFile == null)
50
	metadataFile = new File(srcDirectory, "metadata.csv")
51
	metadataFile = Metadatas.findMetadataFile(srcDirectory)
51 52

  
52 53
def writer = metadataFile.newWriter("UTF-8")
53 54
println "Creating file: $metadataFile"
tmp/org.txm.groovy.core/src/groovy/org/txm/test/InjectMetadataCSV.groovy (revision 966)
4 4
def txmfilesdir = new File("C:\\Documents and Settings\\alavrent\\xml\\metadata")
5 5
def outdir = new File("C:\\Documents and Settings\\alavrent\\xml\\metadata\\meta")
6 6
outdir.mkdir()
7
def allmetadatasfile = new File("C:\\Documents and Settings\\alavrent\\xml\\metadata\\metadata.csv");
7
def allmetadatasfile = Metadatas.findMetadataFile(new File("C:\\Documents and Settings\\alavrent\\xml\\metadata"));
8 8
println "-- INJECT METADATA - from csv file: "+allmetadatasfile+" in directory: "+txmfilesdir
9 9
def metadatas = new Metadatas(allmetadatasfile, "UTF-8", ",","\"", 1)
10 10
if(metadatas != null)
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/ImportPreferencePage.java (revision 966)
37 37
import org.eclipse.swt.layout.RowLayout;
38 38
import org.eclipse.swt.widgets.Group;
39 39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.ui.IWorkbench;
40 41
import org.txm.core.preferences.TBXPreferences;
41 42
import org.txm.libs.cqp.CQPLibPreferences;
42 43
import org.txm.rcp.messages.TXMUIMessages;
......
44 45
/**
45 46
 * The Class ExportPreferencePage.
46 47
 */
47
public class ImportPreferencePage extends RCPPreferencesPage {
48
public class ImportPreferencePage extends TXMPreferencePage {
48 49

  
49 50
	/** The encoding. */
50 51
	private ComboFieldEditor encoding;
......
138 139
		l.setLayoutData(ldata);
139 140
		addField(defaultlang);
140 141
		
141
		empty_code = new StringFieldEditor(CQPLibPreferences.CQP_EMPTY_VALUE_CODE, "Empty property value code", getFieldEditorParent());
142
		empty_code = new StringFieldEditor(TBXPreferences.EMPTY_PROPERTY_VALUE_CODE, "Empty property value code", getFieldEditorParent());
142 143
		addField(empty_code);
143 144
		
144 145
	}
146

  
147
	@Override
148
	public void init(IWorkbench workbench) {
149
		this.setPreferenceStore(new TXMPreferenceStore(TBXPreferences.PREFERENCES_NODE));
150
	}
145 151
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/CorpusPage.java (revision 966)
59 59
import org.txm.Toolbox;
60 60
import org.txm.core.preferences.TBXPreferences;
61 61
import org.txm.core.preferences.TXMPreferences;
62
import org.txm.metadatas.Metadatas;
62 63
import org.txm.objects.BaseParameters;
63 64
import org.txm.rcp.IImageKeys;
64 65
import org.txm.rcp.editors.imports.sections.EditionSection;
......
832 833
		System.out.println(TXMUIMessages.CorpusPage_48 + paramFile);
833 834
		Log.info("Params: "+params); //$NON-NLS-1$
834 835

  
835
		File metadataFile = new File(params.rootDir, "metadata.csv"); //$NON-NLS-1$
836
		File metadataFile = Metadatas.findMetadataFile(new File(params.rootDir)); //$NON-NLS-1$
836 837
		if (metadataFile.exists())
837 838
			this.editor.getMetaPage().setMetadataFile(metadataFile);
838 839

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/MetadataPage.java (revision 966)
190 190
			@Override
191 191
			public void widgetSelected(SelectionEvent e) {
192 192
				
193
//				File metafile = new File(srcdir, "metadata.csv");
194
//				if (metafile.exists())
195 193
					reloadViewers();
196
//				else {
197
//					System.out.println("no metadata file found: "+metafile.getAbsolutePath());
198
//				}
199 194
			}
200 195

  
201 196
			@Override
......
484 479
		//viewer2.setInput(null);
485 480
		//viewer2.refresh();
486 481
		if (main.getRootDir() == null) return;
487
		metadataFile = new File(main.getRootDir(), "metadata.csv"); //$NON-NLS-1$
482
		metadataFile = Metadatas.findMetadataFile(new File(main.getRootDir())); //$NON-NLS-1$
488 483
		Metadatas temp = null;
489 484
		if (metadataFile.exists()) {//if their is a metadata file OK
490 485
			if (metadataFile.getName().endsWith(".csv")) { //$NON-NLS-1$
tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java (revision 966)
235 235
		 */
236 236

  
237 237
		// Warning !! for WINDOWS ONLY the "" value does not work with the ProcessBuilder we must set the value to "\"\""
238
		String empty_value_code = TXMPreferences.getString(CQPLibPreferences.CQP_EMPTY_VALUE_CODE, CQPLibPreferences.PREFERENCES_NODE);
238
		String empty_value_code = TXMPreferences.getString(TBXPreferences.EMPTY_PROPERTY_VALUE_CODE, TBXPreferences.PREFERENCES_NODE);
239 239
		if (OSDetector.isFamilyWindows()) {
240 240
			if (empty_value_code == null) empty_value_code = "\"\"";
241 241
			empty_value_code = empty_value_code.trim();
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/CQPLibPreferences.java (revision 966)
51 51
	/** The Constant CQI_SERVER_MODE. */
52 52
	public static final String CQI_NETWORK_MODE = "cqi_server_mode"; //$NON-NLS-1$
53 53

  
54
	public static final String CQP_EMPTY_VALUE_CODE = "cqp_empty_value_code";
55
	
54

  
56 55
	@Override
57 56
	public void initializeDefaultPreferences() {
58 57
		
......
66 65
		preferences.put(CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$
67 66
		preferences.put(CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$
68 67
		preferences.putBoolean(CQI_NETWORK_MODE, false); //$NON-NLS-1$
69
		preferences.put(CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$
70 68
		
71 69
		String CQPFRAGMENT = "org.txm.libs.cqp."+System.getProperty("osgi.os");
72 70
		//TODO: fix preferneces logic between org.txm.cqp.lib et org.txm.searchengine.cqp
......
162 160
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$
163 161
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$
164 162
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_NETWORK_MODE, false); //$NON-NLS-1$
165
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$
166
		
167 163
	}
168 164
}
tmp/org.txm.core/src/java/org/txm/importer/XMLText2TXTCSV.groovy (revision 966)
1 1
package org.txm.importer
2 2

  
3
import org.txm.metadatas.Metadatas
4

  
3 5
File dir = new File("/home/mdecorde/xml/voeux/split_xml")
4 6
File outdir = new File("/home/mdecorde/xml/voeux/split_txtcsv")
5 7
println "1) xml -> txt + write metadata.csv"
6 8
outdir.deleteDir()
7 9
outdir.mkdir()
8
File metadatafile = new File(outdir, "metadata.csv")
10
File metadatafile = Metadatas.findMetadataFile(outdir)
9 11
String csvString = ""
10 12

  
11 13
def files = dir.listFiles()
tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java (revision 966)
39 39
	public static final String METADATA_ENCODING = "metadata_encoding"; //$NON-NLS-1$
40 40
	public static final String METADATA_COLSEPARATOR = "metadata_colseparator"; //$NON-NLS-1$
41 41
	public static final String METADATA_TXTSEPARATOR = "metadata_txtseparator"; //$NON-NLS-1$
42

  
42
	
43
	public static final String EMPTY_PROPERTY_VALUE_CODE = "empty_property_value_code";
44
	
43 45
	public static final String IMPORT_DEFAULT_LANG = "import_default_lang";
44 46
	
45 47
	/** The Constant EXPORT_SHOW. */
......
84 86
		
85 87
		preferences.put(TBXPreferences.METADATA_ENCODING, "UTF-8"); //$NON-NLS-1$
86 88
		preferences.put(TBXPreferences.METADATA_TXTSEPARATOR, "\""); //$NON-NLS-1$
89
		preferences.put(TBXPreferences.METADATA_COLSEPARATOR, ","); //$NON-NLS-1$
90
		preferences.put(TBXPreferences.EMPTY_PROPERTY_VALUE_CODE, "__UNDEF__"); //$NON-NLS-1$
87 91
		
88 92
		preferences.put(EXPORT_COLSEPARATOR, "\t"); //$NON-NLS-1$
89 93
		preferences.put(EXPORT_ENCODING, System.getProperty("file.encoding")); //$NON-NLS-1$
tmp/org.txm.core/META-INF/MANIFEST.MF (revision 966)
9 9
 org.eclipse.core.commands;visibility:=reexport,
10 10
 org.eclipse.core.resources;visibility:=reexport,
11 11
 org.txm.libs.office;bundle-version="0.0.0",
12
 org.txm.libs.msoffice;bundle-version="1.0.0"
12
 org.txm.libs.msoffice;bundle-version="0.0.0"
13 13
Export-Package: .,
14 14
 EDU.oswego.cs.dl.util.concurrent,
15 15
 EDU.oswego.cs.dl.util.concurrent.misc,

Also available in: Unified diff