Skip to content

Commit 6b38dbb

Browse files
committed
[bugfix] first set of updates and fixes post-transfer
1 parent a069fc7 commit 6b38dbb

File tree

10 files changed

+260
-38
lines changed

10 files changed

+260
-38
lines changed

main/java/dc_metadata/Contributor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private Contributor(String qualifier, String value){
6767
/**
6868
* Return a contributor object whose qualifier has been selected with care.
6969
* @param qualifierText the raw text from the metadata file
70-
* @param fullName TODO switch to pass a 'Person' object
70+
* @param fullName TODO switch to pass a 'main.Person' object
7171
*/
7272
public static Contributor createContributor(String qualifierText, String fullName) {
7373
String qualifier = determineContributorQualifier(qualifierText);
@@ -161,7 +161,7 @@ else if( matchManaging(line)){
161161
}
162162

163163
//OTHER
164-
else{ q = AUTHOR
164+
else{ q = AUTHOR; }
165165

166166
return q;
167167
}

main/java/export/CSVExporter.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package export;
2+
3+
import main.Collection;
4+
import main.Item;
5+
import java.io.File;
6+
7+
/**
8+
* Export to CSV file for use with `DSpace/SAFBuildier`
9+
*/
10+
public class CSVExporter extends main.Exporter{
11+
12+
@Override
13+
protected String processItem(Item i) {
14+
return null;
15+
}
16+
17+
@Override
18+
public File publish(File directory, String filename) {
19+
return null;
20+
}
21+
}

main/java/Collection.java renamed to main/java/main/Collection.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
package main;
2+
13
import org.pmw.tinylog.Logger;
24

35
import java.io.*;
4-
import java.lang.reflect.Array;
56
import java.util.ArrayList;
67

78
/**
@@ -59,10 +60,6 @@ public int processDirectory(String directoryPath) {
5960
return 0; //TODO
6061
}
6162

62-
public int processFile(File f){
63-
return 0; //TODO
64-
}
65-
6663
// -- CONFIG -- //
6764

6865

main/java/main/Exporter.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main;
2+
3+
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
4+
5+
import java.io.File;
6+
7+
/**
8+
* Abstract class for exporting to various formats
9+
*/
10+
public abstract class Exporter {
11+
12+
protected String fileText;
13+
14+
// parts of the exported document, possibly reused
15+
protected static String header;
16+
protected static String footer;
17+
18+
//
19+
public String processCollection(Collection c){
20+
throw new NotImplementedException();
21+
}
22+
23+
// process
24+
protected abstract String processItem(Item i);
25+
26+
public abstract File publish(File directory, String filename);
27+
}

main/java/Item.java renamed to main/java/main/Item.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package main;
2+
13
import dc_metadata.*;
24
import org.pmw.tinylog.Logger;
35
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

main/java/Main.java renamed to main/java/main/Main.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package main;
2+
13
import java.io.*;
24
import java.text.ParseException;
35
import java.util.ArrayList;
@@ -8,16 +10,17 @@
810
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
911

1012
/**
11-
* Main user-facing class. Directs all actions.
13+
* main.Main user-facing class. Directs all actions.
1214
*/
1315
public class Main {
1416

15-
//delimitors
17+
//delimiters
1618
public static String DELIM_SHARED = "|";
1719
public static String DIRECTORY_PATH_IN = "./main/sample_data/"; //TODO allow custom path
1820
public static String DIRECTORY_PATH_CONF = "./main/config/"; //TODO allow custom path
19-
public String DIRECTORY_PATH_OUT = "./main/output/"; //TODO allow custom path
21+
public static String DIRECTORY_PATH_OUT = "./main/output/"; //TODO allow custom patt
2022
public String DIRECTORY_PATH_LOG = "./main/logs/";
23+
private String EXPORT_FILENAME = "export"; //name of each exported file in 'output/' (collection name)
2124

2225

2326
// - public facing back end
@@ -122,11 +125,9 @@ public static void main(String[] args) throws IOException, ParseException {
122125
int id = 1;
123126
//foreach file in the directory...
124127

125-
String report= "1993-v74n03.txt";
126-
String focus = "NTIDFocus-1976-11.txt";
127128
String waldo = "sample-metadata-file.txt";
128129
String sample= "1990-v123n04.txt";
129-
String[] lsFiles = {report, focus, waldo, sample };
130+
String[] lsFiles = { waldo, sample };
130131

131132
for(String filename : lsFiles) {
132133
String path = DIRECTORY_PATH_IN + filename;
@@ -138,12 +139,26 @@ public static void main(String[] args) throws IOException, ParseException {
138139

139140
// - export in desired formats - //
140141

142+
String exportFilename = "export";
143+
144+
// get desired format/s from command line
141145
boolean exp_csv = commandLine.hasOption('C');
142146
boolean exp_XML = commandLine.hasOption('X'); boolean exp_xml = commandLine.hasOption('x');
143-
boolean exp_MRK = commandLine.hasOption('M'); boolean exp_mrk = commandLine.hasOption('m');
147+
//boolean exp_MRK = commandLine.hasOption('M'); boolean exp_mrk = commandLine.hasOption('m');
144148
boolean exp_JSN = commandLine.hasOption('J'); boolean exp_jsn = commandLine.hasOption('j');
145149

146-
//...
150+
//
151+
List<Exporter> lsExporters = new ArrayList<Exporter>();
152+
153+
if(exp_csv){ lsExporters.add( new export.CSVExporter() ); }
154+
//if(exp_XML){ lsExporters.add( new XMLExporter() ); }
155+
//if(exp_JSN){ lsExporters.add( new JSNExporter() ); }
156+
//if(exp_bib){ lsExporters.add( new BibExporter() ); }
157+
158+
for(Exporter e : lsExporters){
159+
//e.processCollection(p);
160+
e.publish(new File(DIRECTORY_PATH_OUT), exportFilename);
161+
}
147162

148163
for(Item i : p.getLsItems()){ System.out.println(i); } //TODO change out.
149164
}

main/java/Parser.java renamed to main/java/main/Parser.java

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
package main;
2+
13
import org.pmw.tinylog.Logger;
24

35
import java.util.ArrayList;
46
import java.util.Arrays;
57
import java.util.List;
68

79
/**
8-
* Parser object which interprets a given text file and creates an interpreted 'Item' object
10+
* main.Parser object which interprets a given text file and creates an interpreted 'main.Item' object
911
*/
1012
public class Parser {
1113

@@ -32,13 +34,13 @@ public class Parser {
3234
public static String SUBJECT = "SUBJECT";
3335
public static String TITLE = "TITLE";
3436
public static String TYPE = "TYPE";
35-
public static String[] ALL_OPTIONS =
37+
public static String[] ALL_OPTIONS =
3638
{ AUDIENCE, COVERAGE, DATE, DESCRIPTION, FILENAME, FORMAT, IDENTIFIER, LANGUAGE,
3739
NOTE, PUBLISHER, RELATION, RIGHTS, RIGHTSHOLDER, SUBJECT, TITLE, TYPE };
3840

3941
//modes
40-
protected enum mode { CONTRIBUTORS, ARTICLES, SUBJECT, NULL }
41-
private mode current_mode = mode.NULL;
42+
public enum mode { CONTRIBUTORS, ARTICLES, SUBJECT, NULL }
43+
protected mode current_mode = mode.NULL;
4244

4345
//critical elements
4446
private ArrayList<String> lsHeaderOptions;
@@ -47,28 +49,16 @@ protected enum mode { CONTRIBUTORS, ARTICLES, SUBJECT, NULL }
4749
private String current_qualifier;
4850

4951

52+
5053
// - constructors - //
5154

5255
/**
5356
* base constructor which initializes object state and sets defaults
5457
*/
5558
public Parser(){
5659

57-
//initialize header options
58-
lsHeaderOptions = new ArrayList<String>();
59-
60-
/* set to default header:
61-
* 0: title | 'Title of the Issue'
62-
* 1: relation.isPartOfSeries | 'Volume ##, Number ##, "
63-
* 2: date.issued | '1993-03-26'
64-
* 3: title.alternative | ''
65-
* 4: filename | 'filename.pdf'
66-
*/
67-
lsHeaderOptions.add(TITLE);
68-
lsHeaderOptions.add(RELATION + SPLIT_OPTION + "ISPARTOFSERIES");
69-
lsHeaderOptions.add(DATE + SPLIT_OPTION + "ISSUED");
70-
lsHeaderOptions.add(TITLE + SPLIT_OPTION + "ALTERNATIVE");
71-
lsHeaderOptions.add(FILENAME);
60+
//initialize header
61+
initHeader();
7262

7363
//initialize list of shared values
7464
lsShared = new ArrayList<String[]>();
@@ -212,6 +202,24 @@ else if (current_mode == mode.CONTRIBUTORS) {
212202

213203
// - helpers - //
214204

205+
private void initHeader(){
206+
//initialize header options
207+
lsHeaderOptions = new ArrayList<String>();
208+
209+
/* set to default header:
210+
* 0: title | 'Title of the Issue'
211+
* 1: relation.isPartOfSeries | 'Volume ##, Number ##, "
212+
* 2: date.issued | '1993-03-26'
213+
* 3: title.alternative | ''
214+
* 4: filename | 'filename.pdf'
215+
*/
216+
lsHeaderOptions.add(TITLE);
217+
lsHeaderOptions.add(RELATION + SPLIT_OPTION + "ISPARTOFSERIES");
218+
lsHeaderOptions.add(DATE + SPLIT_OPTION + "ISSUED");
219+
lsHeaderOptions.add(TITLE + SPLIT_OPTION + "ALTERNATIVE");
220+
lsHeaderOptions.add(FILENAME);
221+
}
222+
215223
/**
216224
* check list of header options sent in to see if they are valid
217225
* @param lsOptions the set of custom options the user established for the header
@@ -250,7 +258,7 @@ private static boolean containsAny(String[] target, String given){
250258

251259
/* - Mode Entry - */
252260

253-
protected static mode determineMode(String str){
261+
public static mode determineMode(String str){
254262

255263
if(matchTableOfContents(str) ){ return mode.ARTICLES; }
256264
else if(matchContributor(str)){ return mode.CONTRIBUTORS; }

main/java/main/Person.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package main;
2+
3+
/**
4+
*
5+
*/
6+
public class Person {
7+
8+
//Name Pre-fixes and titles
9+
static {
10+
11+
//traditional
12+
String MR = "Mr."; //mister
13+
String MRS = "Mrs."; //missus
14+
String MS = "Ms."; //miss
15+
String MISS = "Miss"; //miss
16+
String DR = "Dr."; //doctor
17+
18+
//professional
19+
String COACH= "Coach"; //coach
20+
String SUPT = "Supt."; //superintendent
21+
String ADM = "Adm."; //administrator
22+
23+
//governmental
24+
String ATTY = "Atty."; //attorney
25+
String HON = "Hon."; //honorable
26+
String PRES = "Pres."; //president
27+
String GOV = "Gov."; //governor
28+
String OFC = "Ofc."; //officer
29+
String AMB = "Amb."; //ambassador
30+
String REP = "Rep."; //representative
31+
32+
//familial/religious
33+
String MSGR = "Msgr."; //Monsignor
34+
String REV = "Rev."; //reverend
35+
String FR = "Fr."; //father
36+
String SR = "Sr."; //sister
37+
String BR = "Br."; //brother
38+
39+
//military
40+
String MAJ = "Maj."; //major
41+
String CAPT = "Capt."; //captain
42+
String CMDR = "Cmdr."; //commander
43+
String LT = "Lt."; //lieutenant
44+
String LTOCL= "Lt Col.";//lieutenant colonel
45+
String COL = "Col."; //colonel
46+
String GEN = "Gen."; //general
47+
48+
}
49+
50+
private String uid;
51+
private String title;
52+
private String first;
53+
private String middle;
54+
private String last;
55+
private String suffix;
56+
private String buffer;
57+
58+
public Person(String oneName){ }
59+
60+
61+
62+
}

0 commit comments

Comments
 (0)