The DaBIn importer now supports seperated content sections for the main items (organization, departments), persons, projects and publications.

git-svn-id: https://svn.libreccm.org/ccm/trunk@737 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-02-07 08:22:01 +00:00
parent 14ab384925
commit 96c1719677
1 changed files with 89 additions and 64 deletions

View File

@ -99,9 +99,18 @@ public class DaBInImporter extends Program {
private static final Logger logger = Logger.getLogger(DaBInImporter.class); private static final Logger logger = Logger.getLogger(DaBInImporter.class);
private Properties config; private Properties config;
private ContentSection section; private ContentSection section;
private ContentSection personsSection;
private ContentSection projectsSection;
private ContentSection publicationsSection;
private LifecycleDefinition lifecycle; private LifecycleDefinition lifecycle;
private LifecycleDefinition personsLifecycle;
private LifecycleDefinition projectsLifecycle;
private LifecycleDefinition publicationsLifecycle;
private Connection connection = null; private Connection connection = null;
private Folder root; private Folder root;
private Folder personsRootFolder;
private Folder projectsRootFolder;
private Folder publicationsRootFolder;
private Folder authors; private Folder authors;
private Map<Character, Folder> authorsAlpha; private Map<Character, Folder> authorsAlpha;
private Folder contacts; private Folder contacts;
@ -208,11 +217,26 @@ public class DaBInImporter extends Program {
mySqlDb = config.getProperty("mysql.db"); mySqlDb = config.getProperty("mysql.db");
section = getContentSection(config.getProperty("ccm.contentsection")); section = getContentSection(config.getProperty("ccm.contentsection"));
personsSection = getContentSection(config.getProperty("ccm.personsContentSection"));
projectsSection = getContentSection(config.getProperty("ccm.projectsContentSection"));
publicationsSection = getContentSection(config.getProperty("ccm.publicationsContentSection"));
LifecycleDefinitionCollection lifecycles = LifecycleDefinitionCollection lifecycles =
section.getLifecycleDefinitions(); section.getLifecycleDefinitions();
while (lifecycles.next()) { while (lifecycles.next()) {
lifecycle = lifecycles.getLifecycleDefinition(); lifecycle = lifecycles.getLifecycleDefinition();
} }
lifecycles = personsSection.getLifecycleDefinitions();
while(lifecycles.next()) {
personsLifecycle = lifecycles.getLifecycleDefinition();
}
lifecycles = projectsSection.getLifecycleDefinitions();
while(lifecycles.next()) {
projectsLifecycle = lifecycles.getLifecycleDefinition();
}
lifecycles = publicationsSection.getLifecycleDefinitions();
while(lifecycles.next()) {
publicationsLifecycle = lifecycles.getLifecycleDefinition();
}
//Create connection to the DaBIn MySQL database //Create connection to the DaBIn MySQL database
System.out.println("Trying to connect to DaBIn MySQL database with these " System.out.println("Trying to connect to DaBIn MySQL database with these "
@ -245,8 +269,11 @@ public class DaBInImporter extends Program {
System.out.println( System.out.println(
"\nCreating CCM folders (if they do not exist already)..."); "\nCreating CCM folders (if they do not exist already)...");
root = section.getRootFolder(); root = section.getRootFolder();
personsRootFolder = personsSection.getRootFolder();
projectsRootFolder = projectsSection.getRootFolder();
publicationsRootFolder = publicationsSection.getRootFolder();
authors = createFolder(root, "autoren", "Autoren"); authors = createFolder(personsRootFolder, "autoren", "Autoren");
folder = createFolder(authors, "09", "0-9"); folder = createFolder(authors, "09", "0-9");
authorsAlpha.put('0', folder); authorsAlpha.put('0', folder);
folder = createFolder(authors, "ab", "A-B"); folder = createFolder(authors, "ab", "A-B");
@ -288,7 +315,7 @@ public class DaBInImporter extends Program {
authorsAlpha.put('y', folder); authorsAlpha.put('y', folder);
authorsAlpha.put('z', folder); authorsAlpha.put('z', folder);
contacts = createFolder(root, "kontaktdaten", "Kontaktdaten"); contacts = createFolder(personsRootFolder, "kontaktdaten", "Kontaktdaten");
folder = createFolder(contacts, "09", "0-9"); folder = createFolder(contacts, "09", "0-9");
contactsAlpha.put('0', folder); contactsAlpha.put('0', folder);
folder = createFolder(contacts, "ab", "A-B"); folder = createFolder(contacts, "ab", "A-B");
@ -332,7 +359,7 @@ public class DaBInImporter extends Program {
departments = createFolder(root, "abteilungen", "Abteilungen"); departments = createFolder(root, "abteilungen", "Abteilungen");
members = createFolder(root, "mitglieder", "Mitglieder"); members = createFolder(personsRootFolder, "mitglieder", "Mitglieder");
folder = createFolder(members, "09", "0-9"); folder = createFolder(members, "09", "0-9");
membersAlpha.put('0', folder); membersAlpha.put('0', folder);
folder = createFolder(members, "ab", "A-B"); folder = createFolder(members, "ab", "A-B");
@ -376,7 +403,7 @@ public class DaBInImporter extends Program {
organization = createFolder(root, "organisationen", "Organisation(en)"); organization = createFolder(root, "organisationen", "Organisation(en)");
persons = createFolder(root, "personen", "Personen"); persons = createFolder(personsRootFolder, "personen", "Personen");
folder = createFolder(persons, "09", "0-9"); folder = createFolder(persons, "09", "0-9");
personsAlpha.put('0', folder); personsAlpha.put('0', folder);
folder = createFolder(persons, "ab", "A-B"); folder = createFolder(persons, "ab", "A-B");
@ -418,7 +445,7 @@ public class DaBInImporter extends Program {
personsAlpha.put('y', folder); personsAlpha.put('y', folder);
personsAlpha.put('z', folder); personsAlpha.put('z', folder);
projects = createFolder(root, "projekte", "Projekte"); projects = createFolder(projectsRootFolder, "projekte", "Projekte");
folder = createFolder(projects, "09", "0-9"); folder = createFolder(projects, "09", "0-9");
projectsAlpha.put('0', folder); projectsAlpha.put('0', folder);
folder = createFolder(projects, "a", "A"); folder = createFolder(projects, "a", "A");
@ -474,7 +501,7 @@ public class DaBInImporter extends Program {
folder = createFolder(projects, "z", "Z"); folder = createFolder(projects, "z", "Z");
projectsAlpha.put('z', folder); projectsAlpha.put('z', folder);
publishers = createFolder(root, "verlage", "Verlage"); publishers = createFolder(publicationsRootFolder, "verlage", "Verlage");
folder = createFolder(publishers, "09", "0-9"); folder = createFolder(publishers, "09", "0-9");
publishersAlpha.put('0', folder); publishersAlpha.put('0', folder);
folder = createFolder(publishers, "a", "A"); folder = createFolder(publishers, "a", "A");
@ -530,7 +557,7 @@ public class DaBInImporter extends Program {
folder = createFolder(publishers, "z", "Z"); folder = createFolder(publishers, "z", "Z");
publishersAlpha.put('z', folder); publishersAlpha.put('z', folder);
publications = createFolder(root, "publikationen", "Publikationen"); publications = createFolder(publicationsRootFolder, "publikationen", "Publikationen");
folder = createFolder(publications, "09", "0-9"); folder = createFolder(publications, "09", "0-9");
publicationsAlpha.put('0', folder); publicationsAlpha.put('0', folder);
folder = createFolder(publications, "a", "A"); folder = createFolder(publications, "a", "A");
@ -586,7 +613,7 @@ public class DaBInImporter extends Program {
folder = createFolder(publications, "z", "Z"); folder = createFolder(publications, "z", "Z");
publicationsAlpha.put('z', folder); publicationsAlpha.put('z', folder);
files = createFolder(root, "dateien", "Dateien"); files = createFolder(publicationsRootFolder, "dateien", "Dateien");
folder = createFolder(files, "09", "0-9"); folder = createFolder(files, "09", "0-9");
filesAlpha.put('0', folder); filesAlpha.put('0', folder);
folder = createFolder(files, "a", "A"); folder = createFolder(files, "a", "A");
@ -1738,7 +1765,7 @@ public class DaBInImporter extends Program {
personDe.setGivenName(personData.getGivenname()); personDe.setGivenName(personData.getGivenname());
personDe.setTitlePre(personData.getTitlePre()); personDe.setTitlePre(personData.getTitlePre());
personDe.setContentSection(section); personDe.setContentSection(section);
personDe.setLifecycle(createLifecycle()); personDe.setLifecycle(createLifecycle(personsLifecycle));
personDe.save(); personDe.save();
personDe.setLanguage("de"); personDe.setLanguage("de");
@ -1746,7 +1773,7 @@ public class DaBInImporter extends Program {
personEn.setTitlePre(personData.getTitlePre()); personEn.setTitlePre(personData.getTitlePre());
personEn.setGivenName(personData.getGivenname()); personEn.setGivenName(personData.getGivenname());
personEn.setContentSection(section); personEn.setContentSection(section);
personEn.setLifecycle(createLifecycle()); personEn.setLifecycle(createLifecycle(personsLifecycle));
personEn.save(); personEn.save();
personEn.setLanguage("en"); personEn.setLanguage("en");
@ -1755,13 +1782,12 @@ public class DaBInImporter extends Program {
person.addInstance(personEn); person.addInstance(personEn);
person.setDefaultLanguage("de"); person.setDefaultLanguage("de");
person.setContentSection(section); person.setContentSection(section);
person.setLifecycle(createLifecycle()); person.setLifecycle(createLifecycle(personsLifecycle));
person.save(); person.save();
personDe.setContentSection(section); personDe.setContentSection(section);
personEn.setContentSection(section); personEn.setContentSection(section);
//folder.addItem(person);
char letter; char letter;
letter = personData.getSurname().toLowerCase().charAt(0); letter = personData.getSurname().toLowerCase().charAt(0);
Map<Character, Folder> folders = null; Map<Character, Folder> folders = null;
@ -1873,22 +1899,21 @@ public class DaBInImporter extends Program {
homepage = value; homepage = value;
} }
contactDe.setContentSection(section); contactDe.setContentSection(personsSection);
contactDe.setLifecycle(createLifecycle()); contactDe.setLifecycle(createLifecycle(personsLifecycle));
contactDe.save(); contactDe.save();
contactEn.setContentSection(section); contactEn.setContentSection(personsSection);
contactEn.setLifecycle(createLifecycle()); contactEn.setLifecycle(createLifecycle(personsLifecycle));
contactEn.save(); contactEn.save();
ContentBundle contactBundle = new ContentBundle(contactDe); ContentBundle contactBundle = new ContentBundle(contactDe);
contactBundle.addInstance(contactEn); contactBundle.addInstance(contactEn);
contactBundle.setContentSection(section); contactBundle.setContentSection(personsSection);
//contacts.addItem(contactBundle);
insertIntoAZFolder(contactBundle, insertIntoAZFolder(contactBundle,
personDe.getSurname().charAt(0), personDe.getSurname().charAt(0),
contactsAlpha); contactsAlpha);
contactDe.setContentSection(section); contactDe.setContentSection(personsSection);
contactEn.setContentSection(section); contactEn.setContentSection(personsSection);
if (homepage != null) { if (homepage != null) {
@ -1938,7 +1963,7 @@ public class DaBInImporter extends Program {
replaceAll("\\s\\s+", " "). replaceAll("\\s\\s+", " ").
replace(' ', '-').toLowerCase()); replace(' ', '-').toLowerCase());
departmentDe.setLanguage("de"); departmentDe.setLanguage("de");
departmentDe.setLifecycle(createLifecycle()); departmentDe.setLifecycle(createLifecycle(lifecycle));
departmentDe.setContentSection(section); departmentDe.setContentSection(section);
departmentDe.save(); departmentDe.save();
System.out.println("OK"); System.out.println("OK");
@ -1953,7 +1978,7 @@ public class DaBInImporter extends Program {
replaceAll("\\s\\s+", " "). replaceAll("\\s\\s+", " ").
replace(' ', '-').toLowerCase()); replace(' ', '-').toLowerCase());
departmentEn.setLanguage("en"); departmentEn.setLanguage("en");
departmentEn.setLifecycle(createLifecycle()); departmentEn.setLifecycle(createLifecycle(lifecycle));
departmentEn.setContentSection(section); departmentEn.setContentSection(section);
departmentEn.save(); departmentEn.save();
System.out.println("OK"); System.out.println("OK");
@ -1962,7 +1987,7 @@ public class DaBInImporter extends Program {
department.addInstance(departmentEn); department.addInstance(departmentEn);
department.setContentSection(section); department.setContentSection(section);
department.setDefaultLanguage("de"); department.setDefaultLanguage("de");
department.setLifecycle(createLifecycle()); department.setLifecycle(createLifecycle(lifecycle));
department.setContentSection(section); department.setContentSection(section);
departmentDe.setContentSection(section); departmentDe.setContentSection(section);
@ -2067,8 +2092,8 @@ public class DaBInImporter extends Program {
projectDe.setEnd(projectData.getEnd().getTime()); projectDe.setEnd(projectData.getEnd().getTime());
} }
projectDe.setLanguage("de"); projectDe.setLanguage("de");
projectDe.setLifecycle(createLifecycle()); projectDe.setLifecycle(createLifecycle(projectsLifecycle));
projectDe.setContentSection(section); projectDe.setContentSection(projectsSection);
projectDe.save(); projectDe.save();
System.out.println("OK"); System.out.println("OK");
} else { } else {
@ -2098,8 +2123,8 @@ public class DaBInImporter extends Program {
projectEn.setEnd(projectData.getEnd().getTime()); projectEn.setEnd(projectData.getEnd().getTime());
} }
projectEn.setLanguage("en"); projectEn.setLanguage("en");
projectEn.setLifecycle(createLifecycle()); projectEn.setLifecycle(createLifecycle(projectsLifecycle));
projectEn.setContentSection(section); projectEn.setContentSection(projectsSection);
projectEn.save(); projectEn.save();
System.out.println("OK"); System.out.println("OK");
} else { } else {
@ -2114,16 +2139,16 @@ public class DaBInImporter extends Program {
project.addInstance(projectEn); project.addInstance(projectEn);
} }
} }
project.setLifecycle(createLifecycle()); project.setLifecycle(createLifecycle(projectsLifecycle));
project.setContentSection(section); project.setContentSection(projectsSection);
project.setDefaultLanguage("de"); project.setDefaultLanguage("de");
if (projectDe != null) { if (projectDe != null) {
projectDe.setContentSection(section); projectDe.setContentSection(projectsSection);
} }
if (projectEn != null) { if (projectEn != null) {
projectEn.setContentSection(section); projectEn.setContentSection(projectsSection);
} }
projectsMap.put(projectData.getDabinId(), project); projectsMap.put(projectData.getDabinId(), project);
@ -2595,12 +2620,12 @@ public class DaBInImporter extends Program {
} }
} }
publicationDe.setLifecycle(createLifecycle()); publicationDe.setLifecycle(createLifecycle(publicationsLifecycle));
publicationDe.setContentSection(section); publicationDe.setContentSection(publicationsSection);
publicationDe.setLanguage("de"); publicationDe.setLanguage("de");
publicationEn.setLanguage("en"); publicationEn.setLanguage("en");
publicationEn.setLifecycle(createLifecycle()); publicationEn.setLifecycle(createLifecycle(publicationsLifecycle));
publicationEn.setContentSection(section); publicationEn.setContentSection(publicationsSection);
System.out.println("\tAssigning authors...\n"); System.out.println("\tAssigning authors...\n");
int i = 1; int i = 1;
@ -2668,11 +2693,11 @@ public class DaBInImporter extends Program {
publication = new ContentBundle(publicationDe); publication = new ContentBundle(publicationDe);
publication.setDefaultLanguage("de"); publication.setDefaultLanguage("de");
} }
publication.setLifecycle(createLifecycle()); publication.setLifecycle(createLifecycle(publicationsLifecycle));
publication.setContentSection(section); publication.setContentSection(publicationsSection);
publicationDe.setContentSection(section); publicationDe.setContentSection(publicationsSection);
publicationEn.setContentSection(section); publicationEn.setContentSection(publicationsSection);
if ((publicationData.getAbteilungId() != null) if ((publicationData.getAbteilungId() != null)
&& !publicationData.getAbteilungId().isEmpty() && !publicationData.getAbteilungId().isEmpty()
@ -2762,8 +2787,8 @@ public class DaBInImporter extends Program {
workingPaperDe.setPlace("Bremen"); workingPaperDe.setPlace("Bremen");
extractYearOfPublication(workingPaperData, workingPaperDe); extractYearOfPublication(workingPaperData, workingPaperDe);
workingPaperDe.setLanguage("de"); workingPaperDe.setLanguage("de");
workingPaperDe.setLifecycle(createLifecycle()); workingPaperDe.setLifecycle(createLifecycle(publicationsLifecycle));
workingPaperDe.setContentSection(section); workingPaperDe.setContentSection(publicationsSection);
workingPaperDe.save(); workingPaperDe.save();
System.out.println("OK"); System.out.println("OK");
} else { } else {
@ -2800,8 +2825,8 @@ public class DaBInImporter extends Program {
workingPaperEn.setPlace("Bremen"); workingPaperEn.setPlace("Bremen");
extractYearOfPublication(workingPaperData, workingPaperEn); extractYearOfPublication(workingPaperData, workingPaperEn);
workingPaperEn.setLanguage("En"); workingPaperEn.setLanguage("En");
workingPaperEn.setLifecycle(createLifecycle()); workingPaperEn.setLifecycle(createLifecycle(publicationsLifecycle));
workingPaperEn.setContentSection(section); workingPaperEn.setContentSection(publicationsSection);
workingPaperEn.save(); workingPaperEn.save();
System.out.println("OK"); System.out.println("OK");
} else { } else {
@ -2816,11 +2841,11 @@ public class DaBInImporter extends Program {
workingPaper.addInstance(workingPaperEn); workingPaper.addInstance(workingPaperEn);
} }
} }
workingPaper.setLifecycle(createLifecycle()); workingPaper.setLifecycle(createLifecycle(publicationsLifecycle));
workingPaper.setContentSection(section); workingPaper.setContentSection(publicationsSection);
workingPaperDe.setContentSection(section); workingPaperDe.setContentSection(publicationsSection);
workingPaperEn.setContentSection(section); workingPaperEn.setContentSection(publicationsSection);
workingPaperMap.put(workingPaperData.getDabinId(), workingPaper); workingPaperMap.put(workingPaperData.getDabinId(), workingPaper);
insertIntoAZFolder(workingPaper, publicationsAlpha); insertIntoAZFolder(workingPaper, publicationsAlpha);
@ -2901,16 +2926,16 @@ public class DaBInImporter extends Program {
pdf, pdf,
"application/pdf"); "application/pdf");
fsi.setFile(file); fsi.setFile(file);
file.setContentSection(section); file.setContentSection(publicationsSection);
file.setLifecycle(createLifecycle()); file.setLifecycle(createLifecycle(publicationsLifecycle));
fsi.setLifecycle(createLifecycle()); fsi.setLifecycle(createLifecycle(publicationsLifecycle));
fsi.setContentSection(section); fsi.setContentSection(publicationsSection);
fsi.save(); fsi.save();
fsi.setLanguage("de"); fsi.setLanguage("de");
ContentBundle bundle = new ContentBundle(fsi); ContentBundle bundle = new ContentBundle(fsi);
bundle.setLifecycle(createLifecycle()); bundle.setLifecycle(createLifecycle(publicationsLifecycle));
bundle.setContentSection(section); bundle.setContentSection(publicationsSection);
bundle.setDefaultLanguage("de"); bundle.setDefaultLanguage("de");
//bundle.save(); //bundle.save();
@ -3042,8 +3067,8 @@ public class DaBInImporter extends Program {
replace(' ', '-').toLowerCase()); replace(' ', '-').toLowerCase());
publisherDe.setPlace(publisherData.getPlace()); publisherDe.setPlace(publisherData.getPlace());
publisherDe.setLanguage("de"); publisherDe.setLanguage("de");
publisherDe.setLifecycle(createLifecycle()); publisherDe.setLifecycle(createLifecycle(publicationsLifecycle));
publisherDe.setContentSection(section); publisherDe.setContentSection(publicationsSection);
publisherDe.save(); publisherDe.save();
System.out.println("OK"); System.out.println("OK");
@ -3058,19 +3083,19 @@ public class DaBInImporter extends Program {
replace(' ', '-').toLowerCase()); replace(' ', '-').toLowerCase());
publisherEn.setPlace(publisherData.getPlace()); publisherEn.setPlace(publisherData.getPlace());
publisherEn.setLanguage("en"); publisherEn.setLanguage("en");
publisherEn.setLifecycle(createLifecycle()); publisherEn.setLifecycle(createLifecycle(publicationsLifecycle));
publisherEn.setContentSection(section); publisherEn.setContentSection(publicationsSection);
publisherEn.save(); publisherEn.save();
System.out.println("OK"); System.out.println("OK");
publisher = new ContentBundle(publisherDe); publisher = new ContentBundle(publisherDe);
publisher.addInstance(publisherEn); publisher.addInstance(publisherEn);
publisher.setDefaultLanguage("de"); publisher.setDefaultLanguage("de");
publisher.setLifecycle(createLifecycle()); publisher.setLifecycle(createLifecycle(publicationsLifecycle));
publisher.setContentSection(section); publisher.setContentSection(publicationsSection);
publisherDe.setContentSection(section); publisherDe.setContentSection(publicationsSection);
publisherEn.setContentSection(section); publisherEn.setContentSection(publicationsSection);
insertIntoAZFolder(publisher, publishersAlpha); insertIntoAZFolder(publisher, publishersAlpha);
publishersMap.put(publisherData, publisher); publishersMap.put(publisherData, publisher);
@ -3461,11 +3486,11 @@ public class DaBInImporter extends Program {
return years; return years;
} }
private Lifecycle createLifecycle() { private Lifecycle createLifecycle(final LifecycleDefinition def) {
Lifecycle lifecycle; Lifecycle lifecycle;
Calendar calendarNow = new GregorianCalendar(); Calendar calendarNow = new GregorianCalendar();
Date now = calendarNow.getTime(); Date now = calendarNow.getTime();
lifecycle = this.lifecycle.createLifecycle(); lifecycle = def.createLifecycle();
lifecycle.setStartDate(now); lifecycle.setStartDate(now);
return lifecycle; return lifecycle;