DaBInImporter:
Fehler bei der Zuweisung der ContentSection korrigiert. Aus unbekannten Gründen wurde der nicht-primären Instanz des ContentBundles beim Anlegen des Bundles entfernt. Gelöst durch erneute Zuweisung der ContentSection an die Instanzen nach dem Anlegen des Bundles BulkPublish: Bisher wurde das Item zwar publiziert, der Lifecycle wurde aber nicht gestartet, was dazu führte, dass die Items im Status 'Pending' verblieben. Durch einfügen von lifecycle.start() behoben. Template SciProject.jsp: Diese Template ruft die Methode com.arsdigita.london.navigation.DataCollectionRenderer#setSpecializeObjects(true) auf. Dies führt dazu, dass die ItemList in der XML-Ausgaben zusätzlich zu den <nav:attribute>-Elementen das komplette Objekt, wie es auch in der Detailansicht enthalten ist, enthält. Dies sollte das Erstellen komplexer Listen, z.B. für Projekte oder Publikationen erleichtern. git-svn-id: https://svn.libreccm.org/ccm/trunk@666 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9c9c63166c
commit
418965d150
|
|
@ -45,6 +45,9 @@ import com.arsdigita.cms.contenttypes.SciMember;
|
||||||
import com.arsdigita.cms.contenttypes.SciOrganization;
|
import com.arsdigita.cms.contenttypes.SciOrganization;
|
||||||
import com.arsdigita.cms.contenttypes.SciProject;
|
import com.arsdigita.cms.contenttypes.SciProject;
|
||||||
import com.arsdigita.cms.contenttypes.WorkingPaper;
|
import com.arsdigita.cms.contenttypes.WorkingPaper;
|
||||||
|
import com.arsdigita.cms.lifecycle.Lifecycle;
|
||||||
|
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||||
|
import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.london.terms.Domain;
|
import com.arsdigita.london.terms.Domain;
|
||||||
import com.arsdigita.london.terms.Term;
|
import com.arsdigita.london.terms.Term;
|
||||||
|
|
@ -63,6 +66,7 @@ import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -77,14 +81,25 @@ import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This CLI program for CCM is used to import data from the DaBIn application
|
||||||
|
* used by the ZeS and other institutes into CCM. The applications works
|
||||||
|
* directly on the MySQL database of DaBIn, and creates new objects for CCM
|
||||||
|
* with this informations. Some aspects of the importer can be controlled by
|
||||||
|
* the configurations file passed as command line argument. For a explanations
|
||||||
|
* of the available options please read the comments in the example
|
||||||
|
* configuration file.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
*/
|
*/
|
||||||
public class DaBInImporter extends Program {
|
public class DaBInImporter extends Program {
|
||||||
|
|
||||||
|
/*Many variables to store objects, especially objects which are needed
|
||||||
|
* for associations.
|
||||||
|
*/
|
||||||
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 LifecycleDefinition lifecycle;
|
||||||
private Connection connection = null;
|
private Connection connection = null;
|
||||||
private Folder root;
|
private Folder root;
|
||||||
private Folder authors;
|
private Folder authors;
|
||||||
|
|
@ -193,6 +208,11 @@ 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"));
|
||||||
|
LifecycleDefinitionCollection lifecycles =
|
||||||
|
section.getLifecycleDefinitions();
|
||||||
|
while (lifecycles.next()) {
|
||||||
|
lifecycle = 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 "
|
||||||
|
|
@ -220,6 +240,7 @@ public class DaBInImporter extends Program {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Create folders for storing the created objects, if they exist already.
|
||||||
Folder folder;
|
Folder folder;
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"\nCreating CCM folders (if they do not exist already)...");
|
"\nCreating CCM folders (if they do not exist already)...");
|
||||||
|
|
@ -621,6 +642,9 @@ public class DaBInImporter extends Program {
|
||||||
folder = createFolder(files, "z", "Z");
|
folder = createFolder(files, "z", "Z");
|
||||||
filesAlpha.put('z', folder);
|
filesAlpha.put('z', folder);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the catgories/terms for publications and projects.
|
||||||
|
*/
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"\nRetrieving terms/categories and creating them if necsseary...");
|
"\nRetrieving terms/categories and creating them if necsseary...");
|
||||||
try {
|
try {
|
||||||
|
|
@ -654,6 +678,11 @@ public class DaBInImporter extends Program {
|
||||||
ex.printStackTrace(System.err);
|
ex.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the item for the organization. This item can be configured in
|
||||||
|
* the configuration file, since this informations does not exist in the
|
||||||
|
* DaBIn configuration file.
|
||||||
|
*/
|
||||||
System.out.print("Creating organization item and "
|
System.out.print("Creating organization item and "
|
||||||
+ "postal and office address items...");
|
+ "postal and office address items...");
|
||||||
Transaction transaction = new Transaction() {
|
Transaction transaction = new Transaction() {
|
||||||
|
|
@ -777,6 +806,7 @@ public class DaBInImporter extends Program {
|
||||||
transaction.run();
|
transaction.run();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
||||||
|
// Import the persons.
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"\nImporting persons (members) from DaBIn into CCM...");
|
"\nImporting persons (members) from DaBIn into CCM...");
|
||||||
try {
|
try {
|
||||||
|
|
@ -1707,20 +1737,29 @@ public class DaBInImporter extends Program {
|
||||||
personDe.setSurname(personData.getSurname());
|
personDe.setSurname(personData.getSurname());
|
||||||
personDe.setGivenName(personData.getGivenname());
|
personDe.setGivenName(personData.getGivenname());
|
||||||
personDe.setTitlePre(personData.getTitlePre());
|
personDe.setTitlePre(personData.getTitlePre());
|
||||||
|
personDe.setContentSection(section);
|
||||||
|
personDe.setLifecycle(createLifecycle());
|
||||||
personDe.save();
|
personDe.save();
|
||||||
personDe.setLanguage("de");
|
personDe.setLanguage("de");
|
||||||
|
|
||||||
personEn.setSurname(personData.getSurname());
|
personEn.setSurname(personData.getSurname());
|
||||||
personEn.setGivenName(personData.getGivenname());
|
|
||||||
personEn.setTitlePre(personData.getTitlePre());
|
personEn.setTitlePre(personData.getTitlePre());
|
||||||
|
personEn.setGivenName(personData.getGivenname());
|
||||||
|
personEn.setContentSection(section);
|
||||||
|
personEn.setLifecycle(createLifecycle());
|
||||||
personEn.save();
|
personEn.save();
|
||||||
personEn.setLanguage("en");
|
personEn.setLanguage("en");
|
||||||
|
|
||||||
ContentBundle person;
|
ContentBundle person;
|
||||||
person = new ContentBundle(personDe);
|
person = new ContentBundle(personDe);
|
||||||
person.addInstance(personEn);
|
person.addInstance(personEn);
|
||||||
|
person.setDefaultLanguage("de");
|
||||||
|
person.setContentSection(section);
|
||||||
|
person.setLifecycle(createLifecycle());
|
||||||
|
person.save();
|
||||||
|
|
||||||
|
personDe.setContentSection(section);
|
||||||
|
personEn.setContentSection(section);
|
||||||
|
|
||||||
//folder.addItem(person);
|
//folder.addItem(person);
|
||||||
char letter;
|
char letter;
|
||||||
|
|
@ -1835,16 +1874,22 @@ public class DaBInImporter extends Program {
|
||||||
}
|
}
|
||||||
|
|
||||||
contactDe.setContentSection(section);
|
contactDe.setContentSection(section);
|
||||||
|
contactDe.setLifecycle(createLifecycle());
|
||||||
contactDe.save();
|
contactDe.save();
|
||||||
contactEn.setContentSection(section);
|
contactEn.setContentSection(section);
|
||||||
|
contactEn.setLifecycle(createLifecycle());
|
||||||
contactEn.save();
|
contactEn.save();
|
||||||
ContentBundle contactBundle = new ContentBundle(contactDe);
|
ContentBundle contactBundle = new ContentBundle(contactDe);
|
||||||
contactBundle.addInstance(contactEn);
|
contactBundle.addInstance(contactEn);
|
||||||
|
contactBundle.setContentSection(section);
|
||||||
//contacts.addItem(contactBundle);
|
//contacts.addItem(contactBundle);
|
||||||
insertIntoAZFolder(contactBundle,
|
insertIntoAZFolder(contactBundle,
|
||||||
personDe.getSurname().charAt(0),
|
personDe.getSurname().charAt(0),
|
||||||
contactsAlpha);
|
contactsAlpha);
|
||||||
personDe.save();
|
|
||||||
|
contactDe.setContentSection(section);
|
||||||
|
contactEn.setContentSection(section);
|
||||||
|
|
||||||
|
|
||||||
if (homepage != null) {
|
if (homepage != null) {
|
||||||
RelatedLink homepageLinkDe;
|
RelatedLink homepageLinkDe;
|
||||||
|
|
@ -1893,6 +1938,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.setContentSection(section);
|
departmentDe.setContentSection(section);
|
||||||
departmentDe.save();
|
departmentDe.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -1907,6 +1953,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.setContentSection(section);
|
departmentEn.setContentSection(section);
|
||||||
departmentEn.save();
|
departmentEn.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -1915,8 +1962,13 @@ 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.setContentSection(section);
|
department.setContentSection(section);
|
||||||
department.save();
|
|
||||||
|
departmentDe.setContentSection(section);
|
||||||
|
departmentEn.setContentSection(section);
|
||||||
|
|
||||||
|
//department.save();
|
||||||
departments.addItem(department);
|
departments.addItem(department);
|
||||||
departmentsMap.put(departmentData.getDabinId(), department);
|
departmentsMap.put(departmentData.getDabinId(), department);
|
||||||
//departmentDe.save();
|
//departmentDe.save();
|
||||||
|
|
@ -2015,6 +2067,7 @@ 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.setContentSection(section);
|
projectDe.setContentSection(section);
|
||||||
projectDe.save();
|
projectDe.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -2045,6 +2098,7 @@ 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.setContentSection(section);
|
projectEn.setContentSection(section);
|
||||||
projectEn.save();
|
projectEn.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -2060,9 +2114,18 @@ public class DaBInImporter extends Program {
|
||||||
project.addInstance(projectEn);
|
project.addInstance(projectEn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
project.setLifecycle(createLifecycle());
|
||||||
project.setContentSection(section);
|
project.setContentSection(section);
|
||||||
project.save();
|
project.setDefaultLanguage("de");
|
||||||
//projects.addItem(project);
|
|
||||||
|
if (projectDe != null) {
|
||||||
|
projectDe.setContentSection(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectEn != null) {
|
||||||
|
projectEn.setContentSection(section);
|
||||||
|
}
|
||||||
|
|
||||||
projectsMap.put(projectData.getDabinId(), project);
|
projectsMap.put(projectData.getDabinId(), project);
|
||||||
|
|
||||||
System.out.print("\tAssigning project to department... ");
|
System.out.print("\tAssigning project to department... ");
|
||||||
|
|
@ -2532,8 +2595,12 @@ public class DaBInImporter extends Program {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicationDe.setLifecycle(createLifecycle());
|
||||||
|
publicationDe.setContentSection(section);
|
||||||
publicationDe.setLanguage("de");
|
publicationDe.setLanguage("de");
|
||||||
publicationEn.setLanguage("en");
|
publicationEn.setLanguage("en");
|
||||||
|
publicationEn.setLifecycle(createLifecycle());
|
||||||
|
publicationEn.setContentSection(section);
|
||||||
|
|
||||||
System.out.println("\tAssigning authors...\n");
|
System.out.println("\tAssigning authors...\n");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
@ -2598,12 +2665,14 @@ public class DaBInImporter extends Program {
|
||||||
publication = new ContentBundle(publicationEn);
|
publication = new ContentBundle(publicationEn);
|
||||||
publication.setDefaultLanguage("en");
|
publication.setDefaultLanguage("en");
|
||||||
} else {
|
} else {
|
||||||
publication = new ContentBundle(publicationDe);
|
|
||||||
publication = new ContentBundle(publicationDe);
|
publication = new ContentBundle(publicationDe);
|
||||||
publication.setDefaultLanguage("de");
|
publication.setDefaultLanguage("de");
|
||||||
}
|
}
|
||||||
|
publication.setLifecycle(createLifecycle());
|
||||||
publication.setContentSection(section);
|
publication.setContentSection(section);
|
||||||
//publications.addItem(publication);
|
|
||||||
|
publicationDe.setContentSection(section);
|
||||||
|
publicationEn.setContentSection(section);
|
||||||
|
|
||||||
if ((publicationData.getAbteilungId() != null)
|
if ((publicationData.getAbteilungId() != null)
|
||||||
&& !publicationData.getAbteilungId().isEmpty()
|
&& !publicationData.getAbteilungId().isEmpty()
|
||||||
|
|
@ -2693,6 +2762,7 @@ 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.setContentSection(section);
|
workingPaperDe.setContentSection(section);
|
||||||
workingPaperDe.save();
|
workingPaperDe.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -2730,6 +2800,7 @@ 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.setContentSection(section);
|
workingPaperEn.setContentSection(section);
|
||||||
workingPaperEn.save();
|
workingPaperEn.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -2745,8 +2816,12 @@ public class DaBInImporter extends Program {
|
||||||
workingPaper.addInstance(workingPaperEn);
|
workingPaper.addInstance(workingPaperEn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
workingPaper.setLifecycle(createLifecycle());
|
||||||
workingPaper.setContentSection(section);
|
workingPaper.setContentSection(section);
|
||||||
//publications.addItem(workingPaper);
|
|
||||||
|
workingPaperDe.setContentSection(section);
|
||||||
|
workingPaperEn.setContentSection(section);
|
||||||
|
|
||||||
workingPaperMap.put(workingPaperData.getDabinId(), workingPaper);
|
workingPaperMap.put(workingPaperData.getDabinId(), workingPaper);
|
||||||
insertIntoAZFolder(workingPaper, publicationsAlpha);
|
insertIntoAZFolder(workingPaper, publicationsAlpha);
|
||||||
WorkingPaper primary = (WorkingPaper) workingPaper.
|
WorkingPaper primary = (WorkingPaper) workingPaper.
|
||||||
|
|
@ -2802,7 +2877,6 @@ public class DaBInImporter extends Program {
|
||||||
unzip.close();
|
unzip.close();
|
||||||
pdfFileStream.close();
|
pdfFileStream.close();
|
||||||
|
|
||||||
|
|
||||||
FileStorageItem fsi = new FileStorageItem();
|
FileStorageItem fsi = new FileStorageItem();
|
||||||
String title = String.format("Datei %s",
|
String title = String.format("Datei %s",
|
||||||
((WorkingPaper) workingPaper.
|
((WorkingPaper) workingPaper.
|
||||||
|
|
@ -2828,12 +2902,17 @@ public class DaBInImporter extends Program {
|
||||||
"application/pdf");
|
"application/pdf");
|
||||||
fsi.setFile(file);
|
fsi.setFile(file);
|
||||||
file.setContentSection(section);
|
file.setContentSection(section);
|
||||||
|
file.setLifecycle(createLifecycle());
|
||||||
|
fsi.setLifecycle(createLifecycle());
|
||||||
fsi.setContentSection(section);
|
fsi.setContentSection(section);
|
||||||
|
fsi.save();
|
||||||
|
|
||||||
fsi.setLanguage("de");
|
fsi.setLanguage("de");
|
||||||
ContentBundle bundle = new ContentBundle(fsi);
|
ContentBundle bundle = new ContentBundle(fsi);
|
||||||
|
bundle.setLifecycle(createLifecycle());
|
||||||
bundle.setContentSection(section);
|
bundle.setContentSection(section);
|
||||||
bundle.setDefaultLanguage("de");
|
bundle.setDefaultLanguage("de");
|
||||||
|
//bundle.save();
|
||||||
|
|
||||||
RelatedLink download = new RelatedLink();
|
RelatedLink download = new RelatedLink();
|
||||||
download.setTitle("Download");
|
download.setTitle("Download");
|
||||||
|
|
@ -2959,6 +3038,8 @@ public class DaBInImporter extends Program {
|
||||||
publisherDe.setName(publisherData.getName().toLowerCase());
|
publisherDe.setName(publisherData.getName().toLowerCase());
|
||||||
publisherDe.setPlace(publisherData.getPlace());
|
publisherDe.setPlace(publisherData.getPlace());
|
||||||
publisherDe.setLanguage("de");
|
publisherDe.setLanguage("de");
|
||||||
|
publisherDe.setLifecycle(createLifecycle());
|
||||||
|
publisherDe.setContentSection(section);
|
||||||
publisherDe.save();
|
publisherDe.save();
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
||||||
|
|
@ -2969,14 +3050,20 @@ public class DaBInImporter extends Program {
|
||||||
publisherEn.setName(publisherData.getName().toLowerCase());
|
publisherEn.setName(publisherData.getName().toLowerCase());
|
||||||
publisherEn.setPlace(publisherData.getPlace());
|
publisherEn.setPlace(publisherData.getPlace());
|
||||||
publisherEn.setLanguage("en");
|
publisherEn.setLanguage("en");
|
||||||
|
publisherEn.setLifecycle(createLifecycle());
|
||||||
|
publisherEn.setContentSection(section);
|
||||||
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.setContentSection(section);
|
publisher.setContentSection(section);
|
||||||
//publishers.addItem(publisher);
|
|
||||||
|
publisherDe.setContentSection(section);
|
||||||
|
publisherEn.setContentSection(section);
|
||||||
|
|
||||||
insertIntoAZFolder(publisher, publishersAlpha);
|
insertIntoAZFolder(publisher, publishersAlpha);
|
||||||
publishersMap.put(publisherData, publisher);
|
publishersMap.put(publisherData, publisher);
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
|
@ -3358,6 +3445,16 @@ public class DaBInImporter extends Program {
|
||||||
return years;
|
return years;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Lifecycle createLifecycle() {
|
||||||
|
Lifecycle lifecycle;
|
||||||
|
Calendar calendarNow = new GregorianCalendar();
|
||||||
|
Date now = calendarNow.getTime();
|
||||||
|
lifecycle = this.lifecycle.createLifecycle();
|
||||||
|
lifecycle.setStartDate(now);
|
||||||
|
|
||||||
|
return lifecycle;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new DaBInImporter().run(args);
|
new DaBInImporter().run(args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,4 +64,5 @@ log4j.logger.com.arsdigita.packaging.Loader=INFO
|
||||||
#log4j.logger.com.arsdigita.cms.search.ContentPageMetadataProvider=DEBUG
|
#log4j.logger.com.arsdigita.cms.search.ContentPageMetadataProvider=DEBUG
|
||||||
#log4j.logger.com.arsdigita.london.importer=DEBUG
|
#log4j.logger.com.arsdigita.london.importer=DEBUG
|
||||||
#log4j.logger.com.arsdigita.london.terms.importer.TermItemBuilder=DEBUG
|
#log4j.logger.com.arsdigita.london.terms.importer.TermItemBuilder=DEBUG
|
||||||
log4j.logger.com.arsdigita.categorization.Category=DEBUG
|
#log4j.logger.com.arsdigita.categorization.Category=DEBUG
|
||||||
|
log4j.logger.com.arsdigita.london.util.cmd.BulkPublish=DEBUG
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.london.util.cmd;
|
package com.arsdigita.london.util.cmd;
|
||||||
|
|
||||||
import com.arsdigita.london.util.Program;
|
import com.arsdigita.london.util.Program;
|
||||||
|
|
@ -47,8 +46,6 @@ import java.util.Date;
|
||||||
public class BulkPublish extends Program {
|
public class BulkPublish extends Program {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(BulkPublish.class);
|
private static final Logger s_log = Logger.getLogger(BulkPublish.class);
|
||||||
|
|
||||||
|
|
||||||
private static final String SPACE = " ";
|
private static final String SPACE = " ";
|
||||||
|
|
||||||
public BulkPublish() {
|
public BulkPublish() {
|
||||||
|
|
@ -59,33 +56,25 @@ public class BulkPublish extends Program {
|
||||||
Options options = getOptions();
|
Options options = getOptions();
|
||||||
|
|
||||||
options.addOption(
|
options.addOption(
|
||||||
OptionBuilder
|
OptionBuilder.hasArgs().withLongOpt("types").withDescription(
|
||||||
.hasArgs()
|
"Restrict publishing to items of the specified content types").
|
||||||
.withLongOpt( "types" )
|
create("t"));
|
||||||
.withDescription( "Restrict publishing to items of the specified content types" )
|
|
||||||
.create( "t" ) );
|
|
||||||
|
|
||||||
options.addOption(
|
options.addOption(
|
||||||
OptionBuilder
|
OptionBuilder.hasArg().withLongOpt("restrictToFolderId").
|
||||||
.hasArg()
|
withDescription(
|
||||||
.withLongOpt( "restrictToFolderId" )
|
"Restrict publishing to items within the folder with the specified id").
|
||||||
.withDescription( "Restrict publishing to items within the folder with the specified id" )
|
create("f"));
|
||||||
.create( "f" ) );
|
|
||||||
|
|
||||||
options.addOption(
|
options.addOption(
|
||||||
OptionBuilder
|
OptionBuilder.hasArgs().withLongOpt("exceptionIds").
|
||||||
.hasArgs()
|
withDescription("The ids of items that shouldn't be published").
|
||||||
.withLongOpt( "exceptionIds" )
|
create("e"));
|
||||||
.withDescription( "The ids of items that shouldn't be published" )
|
|
||||||
.create( "e" ) );
|
|
||||||
|
|
||||||
|
|
||||||
options.addOption
|
options.addOption(
|
||||||
(OptionBuilder
|
OptionBuilder.hasArg(false).withLongOpt("ignore-errors").
|
||||||
.hasArg(false)
|
withDescription("Ignore any errors").create('i'));
|
||||||
.withLongOpt("ignore-errors")
|
|
||||||
.withDescription("Ignore any errors")
|
|
||||||
.create('i'));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,71 +84,77 @@ public class BulkPublish extends Program {
|
||||||
*/
|
*/
|
||||||
protected void doRun(CommandLine cmdLine) {
|
protected void doRun(CommandLine cmdLine) {
|
||||||
final String[] types;
|
final String[] types;
|
||||||
final String[] exceptions;
|
final String[] exceptions;
|
||||||
final int folderId;
|
final int folderId;
|
||||||
final boolean ignoreErrors = cmdLine.hasOption("i");
|
final boolean ignoreErrors = cmdLine.hasOption("i");
|
||||||
|
|
||||||
if( cmdLine.hasOption( "t" ) ) {
|
if (cmdLine.hasOption("t")) {
|
||||||
types = cmdLine.getOptionValues( "t" );
|
types = cmdLine.getOptionValues("t");
|
||||||
|
|
||||||
System.out.println( "Publishing items of types:" );
|
System.out.println("Publishing items of types:");
|
||||||
for( int i = 0; i < types.length; i++ ) {
|
for (int i = 0; i < types.length; i++) {
|
||||||
System.out.println( types[i] );
|
System.out.println(types[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
types = null;
|
types = null;
|
||||||
System.out.println( "Publishing all items" );
|
System.out.println("Publishing all items");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdLine.hasOption("f")) {
|
if (cmdLine.hasOption("f")) {
|
||||||
folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
folderId = Integer.parseInt(cmdLine.getOptionValue("f"));
|
||||||
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE, folderId));
|
Folder folder = new Folder(new OID(Folder.BASE_DATA_OBJECT_TYPE,
|
||||||
System.out.println( "Publishing items in folder: " + folder.getDisplayName());
|
folderId));
|
||||||
} else {
|
System.out.println("Publishing items in folder: " + folder.
|
||||||
folderId = -1;
|
getDisplayName());
|
||||||
}
|
} else {
|
||||||
|
folderId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmdLine.hasOption("e")) {
|
if (cmdLine.hasOption("e")) {
|
||||||
exceptions = cmdLine.getOptionValues("e");
|
exceptions = cmdLine.getOptionValues("e");
|
||||||
System.out.print( "Not publishing items with id: ");
|
System.out.print("Not publishing items with id: ");
|
||||||
for( int i = 0; i < exceptions.length; i++ ) {
|
for (int i = 0; i < exceptions.length; i++) {
|
||||||
System.out.print(exceptions[i] + SPACE);
|
System.out.print(exceptions[i] + SPACE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
exceptions = null;
|
exceptions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List toPublish = new ArrayList();
|
final List toPublish = new ArrayList();
|
||||||
new Transaction() {
|
new Transaction() {
|
||||||
|
|
||||||
public void doRun() {
|
public void doRun() {
|
||||||
DataCollection items = SessionManager.getSession()
|
DataCollection items = SessionManager.getSession().retrieve(
|
||||||
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
ContentPage.BASE_DATA_OBJECT_TYPE);
|
||||||
items.addNotEqualsFilter("type.id", null);
|
items.addNotEqualsFilter("type.id", null);
|
||||||
items.addEqualsFilter("version", ContentItem.DRAFT);
|
items.addEqualsFilter("version", ContentItem.DRAFT);
|
||||||
items.addOrder("title");
|
items.addOrder("title");
|
||||||
|
|
||||||
FilterFactory filterFactory = items.getFilterFactory();
|
FilterFactory filterFactory = items.getFilterFactory();
|
||||||
|
|
||||||
if (folderId >= 0) {
|
if (folderId >= 0) {
|
||||||
Filter filter = filterFactory.simple(" ancestors like '%/" + folderId + "/%'");
|
Filter filter = filterFactory.simple(" ancestors like '%/"
|
||||||
items.addFilter(filter);
|
+ folderId + "/%'");
|
||||||
}
|
items.addFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
if (null != exceptions) {
|
if (null != exceptions) {
|
||||||
for (int n = 0; n < exceptions.length; n++) {
|
for (int n = 0; n < exceptions.length; n++) {
|
||||||
items.addFilter(filterFactory.notEquals("id", exceptions[n]));
|
items.addFilter(filterFactory.notEquals("id",
|
||||||
}
|
exceptions[n]));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( null != types ) {
|
if (null != types) {
|
||||||
|
|
||||||
CompoundFilter or = filterFactory.or();
|
CompoundFilter or = filterFactory.or();
|
||||||
|
|
||||||
for( int i = 0; i < types.length; i++ ) {
|
for (int i = 0; i < types.length; i++) {
|
||||||
or.addFilter( filterFactory.equals( "objectType", types[i] ) );
|
or.addFilter(
|
||||||
|
filterFactory.equals("objectType", types[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
items.addFilter( or );
|
items.addFilter(or);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (items.next()) {
|
while (items.next()) {
|
||||||
|
|
@ -172,13 +167,15 @@ public class BulkPublish extends Program {
|
||||||
while (items.hasNext()) {
|
while (items.hasNext()) {
|
||||||
final OID oid = (OID) items.next();
|
final OID oid = (OID) items.next();
|
||||||
Transaction txn = new Transaction() {
|
Transaction txn = new Transaction() {
|
||||||
|
|
||||||
public void doRun() {
|
public void doRun() {
|
||||||
|
|
||||||
ContentPage item = (ContentPage)
|
ContentPage item = (ContentPage) DomainObjectFactory.
|
||||||
DomainObjectFactory.newInstance(oid);
|
newInstance(oid);
|
||||||
|
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("Processing item " + oid + " " + item.getPath());
|
s_log.info("Processing item " + oid + " "
|
||||||
|
+ item.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isLive()) {
|
if (item.isLive()) {
|
||||||
|
|
@ -186,20 +183,30 @@ public class BulkPublish extends Program {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getContentSection() == null) {
|
||||||
|
s_log.warn(String.format(
|
||||||
|
"Content section of item "
|
||||||
|
+ "'%s' (OID: %s') is null",
|
||||||
|
item.getPath(),
|
||||||
|
oid.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
LifecycleDefinition def =
|
LifecycleDefinition def =
|
||||||
ContentTypeLifecycleDefinition.getLifecycleDefinition(
|
ContentTypeLifecycleDefinition.
|
||||||
|
getLifecycleDefinition(
|
||||||
item.getContentSection(),
|
item.getContentSection(),
|
||||||
item.getContentType());
|
item.getContentType());
|
||||||
|
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
s_log.warn("Cannot publish item " + oid +
|
s_log.warn("Cannot publish item " + oid
|
||||||
" because it has no default lifecycle");
|
+ " because it has no default lifecycle");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.publish(def, new Date());
|
ContentItem pending = item.publish(def, new Date());
|
||||||
|
pending.getLifecycle().start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
txn.run();
|
txn.run();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
|
@ -214,5 +221,4 @@ public class BulkPublish extends Program {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new BulkPublish().run(args);
|
new BulkPublish().run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,7 @@
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getDefinition().addOrder("parent.categories.link.sortKey");
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getDefinition().addOrder("parent.categories.link.sortKey");
|
||||||
|
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().setPageSize(20);
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().setPageSize(20);
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("objectType");
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().setSpecializeObjects(true);
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("persons");
|
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("projectbegin");
|
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("projectend");
|
|
||||||
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("projectShortDesc");
|
|
||||||
</jsp:scriptlet>
|
</jsp:scriptlet>
|
||||||
|
|
||||||
<define:component name="assignedTerms"
|
<define:component name="assignedTerms"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue