6 package de.uni_hamburg.corpora.publication;
13 import java.io.FileInputStream;
14 import java.io.FileOutputStream;
15 import java.io.IOException;
16 import java.util.ArrayList;
17 import java.util.Collection;
18 import java.util.List;
19 import java.util.zip.ZipEntry;
20 import java.util.zip.ZipOutputStream;
34 List<String> fileList;
36 String SOURCE_FOLDER =
"";
38 String OUTPUT_ZIP_FILE =
"";
39 Boolean AUDIO =
false;
44 fileList =
new ArrayList<String>();
63 if (zipFile.equals(
"")) {
66 zipFile = SOURCE_FOLDER +
"resources" + File.separator + SOURCE_FOLDER_NAME +
"WithAudio.zip";
68 zipFile = SOURCE_FOLDER +
"resources" + File.separator + SOURCE_FOLDER_NAME +
"NoAudio.zip";
71 byte[] buffer =
new byte[1024];
75 FileOutputStream fos =
new FileOutputStream(zipFile);
76 ZipOutputStream zos =
new ZipOutputStream(fos);
78 System.out.println(
"Output to Zip : " + zipFile);
80 for (String file : this.fileList) {
82 System.out.println(
"File Added : " + file);
83 ZipEntry ze =
new ZipEntry(file);
87 =
new FileInputStream(file);
90 while ((len = in.read(buffer)) > 0) {
91 zos.write(buffer, 0, len);
100 System.out.println(
"Done");
101 stats.
addCorrect(
function, comadata,
"Successfully created zip file at " + zipFile);
102 }
catch (IOException ex) {
103 stats.
addException(ex,
function, comadata,
"Unknown IO exception");
118 if (node.getName().endsWith(
".exb") || node.getName().endsWith(
".exs") || node.getName().endsWith(
".coma") || node.getName().endsWith(
".pdf") || node.getName().endsWith(
".mp3")) {
119 System.out.println(node.getName());
120 fileList.add(generateZipEntry(node.getAbsoluteFile().toString()));
121 stats.
addCorrect(
function, comadata, node.getAbsoluteFile().toString() +
" added to filelist");
123 }
else if (node.getName().endsWith(
".exb") || node.getName().endsWith(
".exs") || node.getName().endsWith(
".coma") || node.getName().endsWith(
".pdf")) {
124 System.out.println(node.getName());
125 fileList.add(generateZipEntry(node.getAbsoluteFile().toString()));
126 stats.
addCorrect(
function, comadata, node.getAbsoluteFile().toString() +
" added to filelist");
129 if (node.isDirectory()) {
130 String[] subNote = node.list();
131 for (String filename : subNote) {
132 System.out.println(node.getName());
145 private String generateZipEntry(String file) {
154 if (SOURCE_FOLDER.equals(
"")){
158 stats.
merge(
zipIt(cd, OUTPUT_ZIP_FILE, AUDIO));
165 comadata = c.getComaData();
168 stats.
merge(
zipIt(cd, OUTPUT_ZIP_FILE, AUDIO));
175 Class cl = Class.forName(
"de.uni_hamburg.corpora.ComaData");
177 }
catch (ClassNotFoundException ex) {
193 if (s.equalsIgnoreCase(
"true") || s.equalsIgnoreCase(
"wahr") || s.equalsIgnoreCase(
"ja")) {
195 }
else if (s.equalsIgnoreCase(
"false") || s.equalsIgnoreCase(
"falsch") || s.equalsIgnoreCase(
"nein")) {
198 report.
addCritical(
function, cd,
"Parameter audio not recognized: " + s);
204 String description =
"This class takes a coma file and creates a zip file containing all important " 205 +
"corpus file in the resources folder. It only takes exb, exs, coma, pdf and optionally mp3, " 206 +
"and the folder structure. ";
String getFilenameWithoutFileEnding()
void setWithAudio(String s)
void setOutputFile(String s)
Report zipIt(CorpusData comadata, String zipFile, Boolean AUDIO)
void addCritical(String description)
Report generateFileList(File node)
void setSourceFolder(String s)
void addCorrect(String statId, String description)
Collection< Class<?extends CorpusData > > getIsUsableFor()
void addException(Throwable e, String description)