Aktueller Stand Importer CSV Importer Publikation
git-svn-id: https://svn.libreccm.org/ccm/trunk@1910 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c4ce62775f
commit
755c7ab48a
|
|
@ -53,9 +53,9 @@ public class AuthorImportReport {
|
|||
authorType = "author";
|
||||
}
|
||||
|
||||
if (created) {
|
||||
if (created) {
|
||||
return String.format("Created author '%s, %s'. Linked to publication as %s.",
|
||||
surname, givenName, authorType);
|
||||
surname, givenName, authorType);
|
||||
} else {
|
||||
return String.format("Found author '%s, %s' in database. Linked to publication as %s.",
|
||||
surname, givenName, authorType);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ public class CollectedVolumeImportReport {
|
|||
|
||||
private String collectedVolumeTitle;
|
||||
private List<AuthorImportReport> authors = new ArrayList<AuthorImportReport>();
|
||||
private boolean created;
|
||||
private PublisherImportReport publisher;
|
||||
private boolean created;
|
||||
|
||||
public String getCollectedVolumeTitle() {
|
||||
return collectedVolumeTitle;
|
||||
|
|
@ -36,6 +37,14 @@ public class CollectedVolumeImportReport {
|
|||
public void setAuthors(final List<AuthorImportReport> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public PublisherImportReport getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(final PublisherImportReport publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
|
|
@ -54,13 +63,17 @@ public class CollectedVolumeImportReport {
|
|||
for(int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
writer.append("\n");
|
||||
|
||||
writer.printf("Created collected volume '%s' and linked it with publication.\n");
|
||||
writer.print("Author of collected volume:\n");
|
||||
writer.printf("Created collected volume '%s' and linked it with publication.\n", collectedVolumeTitle);
|
||||
writer.print("Authors of collected volume:\n");
|
||||
for(AuthorImportReport author : authors) {
|
||||
writer.printf("%s\n", author.toString());
|
||||
}
|
||||
|
||||
writer.append(publisher.toString());
|
||||
writer.append('\n');
|
||||
|
||||
for(int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public class JournalImportReport {
|
|||
@Override
|
||||
public String toString() {
|
||||
if (created) {
|
||||
return String.format("Created journal '%s' and linked it to publication.");
|
||||
return String.format("Created journal '%s' and linked it to publication.", journalTitle);
|
||||
} else {
|
||||
return String.format("Found journal '%s' in database and linked it to publication.");
|
||||
return String.format("Found journal '%s' in database and linked it to publication.", journalTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public class ProceedingsImportReport {
|
|||
private Date dateFromOfConference;
|
||||
private Date dateToOfConference;
|
||||
private List<AuthorImportReport> authors = new ArrayList<AuthorImportReport>();
|
||||
private PublisherImportReport publisher;
|
||||
private boolean created;
|
||||
|
||||
public String getProceedingsTitle() {
|
||||
|
|
@ -65,6 +66,14 @@ public class ProceedingsImportReport {
|
|||
this.authors = authors;
|
||||
}
|
||||
|
||||
public PublisherImportReport getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(final PublisherImportReport publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
|
@ -82,19 +91,24 @@ public class ProceedingsImportReport {
|
|||
for (int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
writer.append('\n');
|
||||
|
||||
writer.printf("Created proceedings '%s' and linked them with publication.");
|
||||
writer.printf("Created proceedings '%s' and linked them with publication.\n", proceedingsTitle);
|
||||
writer.printf("Conference.............: %s\n", conference);
|
||||
writer.printf("Date from of conference: %s\n", dateToOfConference.toString());
|
||||
writer.printf("Date to of conference..: %s\n", dateToOfConference.toString());
|
||||
//writer.printf("Date from of conference: %s\n", dateToOfConference.toString());
|
||||
//writer.printf("Date to of conference..: %s\n", dateToOfConference.toString());
|
||||
writer.print("Authors:\n");
|
||||
for(AuthorImportReport author : authors) {
|
||||
writer.printf("%s\n", author.toString());
|
||||
}
|
||||
|
||||
writer.append(publisher.toString());
|
||||
writer.append('\n');
|
||||
|
||||
for (int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
writer.append('\n');
|
||||
|
||||
return strWriter.toString();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ import com.arsdigita.persistence.DataCollection;
|
|||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -36,12 +38,18 @@ import java.util.List;
|
|||
*/
|
||||
public class ImporterUtil {
|
||||
|
||||
private final Set<String> createdAuthors = new HashSet<String>();
|
||||
private final Set<String> createdColVols = new HashSet<String>();
|
||||
private final Set<String> createdJournals = new HashSet<String>();
|
||||
private final Set<String> createdProcs = new HashSet<String>();
|
||||
private final Set<String> createdPublishers = new HashSet<String>();
|
||||
|
||||
public AuthorImportReport processAuthor(final Publication publication,
|
||||
final AuthorData authorData,
|
||||
final boolean pretend) {
|
||||
final AuthorImportReport report = new AuthorImportReport();
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
|
||||
final DataCollection collection = session.retrieve(GenericPerson.BASE_DATA_OBJECT_TYPE);
|
||||
collection.addEqualsFilter("surname", authorData.getSurname());
|
||||
collection.addEqualsFilter("givenname", authorData.getGivenName());
|
||||
|
|
@ -78,6 +86,15 @@ public class ImporterUtil {
|
|||
|
||||
report.setCreated(true);
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdAuthors.contains(String.format("%s %s",
|
||||
authorData.getSurname(),
|
||||
authorData.getGivenName()))) {
|
||||
report.setCreated(false);
|
||||
} else {
|
||||
createdAuthors.add(String.format("%s %s", authorData.getSurname(), authorData.getGivenName()));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!pretend) {
|
||||
final GenericPerson author;
|
||||
|
|
@ -130,6 +147,13 @@ public class ImporterUtil {
|
|||
}
|
||||
|
||||
report.setCreated(true);
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdPublishers.contains(String.format("%s %s", publisherName, place))) {
|
||||
report.setCreated(false);
|
||||
} else {
|
||||
createdPublishers.add(String.format("%s %s", publisherName, place));
|
||||
}
|
||||
} else {
|
||||
if (!pretend) {
|
||||
collection.next();
|
||||
|
|
@ -145,8 +169,10 @@ public class ImporterUtil {
|
|||
|
||||
public CollectedVolumeImportReport processCollectedVolume(final ArticleInCollectedVolume article,
|
||||
final String title,
|
||||
final int year,
|
||||
final String year,
|
||||
final List<AuthorData> authors,
|
||||
final String publisherName,
|
||||
final String place,
|
||||
final boolean pretend) {
|
||||
final CollectedVolumeImportReport report = new CollectedVolumeImportReport();
|
||||
|
||||
|
|
@ -175,17 +201,38 @@ public class ImporterUtil {
|
|||
bundle.setContentSection(folder.getContentSection());
|
||||
bundle.save();
|
||||
|
||||
collectedVolume.setYearOfPublication(year);
|
||||
int yearOfPub;
|
||||
try {
|
||||
yearOfPub = Integer.parseInt(year);
|
||||
} catch (NumberFormatException ex) {
|
||||
yearOfPub = 0;
|
||||
}
|
||||
|
||||
collectedVolume.setYearOfPublication(yearOfPub);
|
||||
for (AuthorData author : authors) {
|
||||
report.addAuthor(processAuthor(collectedVolume, author, pretend));
|
||||
}
|
||||
|
||||
report.setPublisher(processPublisher(collectedVolume, place, publisherName, pretend));
|
||||
|
||||
collectedVolume.save();
|
||||
article.setCollectedVolume(collectedVolume);
|
||||
}
|
||||
|
||||
report.setCreated(true);
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdColVols.contains(String.format("%s %s", title, year))) {
|
||||
report.setCreated(false);
|
||||
} else {
|
||||
if (pretend) {
|
||||
for (AuthorData author : authors) {
|
||||
report.addAuthor(processAuthor(null, author, pretend));
|
||||
}
|
||||
report.setPublisher(processPublisher(null, place, publisherName, pretend));
|
||||
}
|
||||
createdColVols.add(String.format("%s %s", title, year));
|
||||
}
|
||||
} else {
|
||||
if (!pretend) {
|
||||
collection.next();
|
||||
|
|
@ -201,9 +248,11 @@ public class ImporterUtil {
|
|||
|
||||
public ProceedingsImportReport processProceedings(final InProceedings inProceedings,
|
||||
final String title,
|
||||
final int year,
|
||||
final String year,
|
||||
final String conference,
|
||||
final List<AuthorData> authors,
|
||||
final String publisherName,
|
||||
final String place,
|
||||
final boolean pretend) {
|
||||
final ProceedingsImportReport report = new ProceedingsImportReport();
|
||||
|
||||
|
|
@ -234,15 +283,39 @@ public class ImporterUtil {
|
|||
bundle.setParent(folder);
|
||||
bundle.save();
|
||||
|
||||
proceedings.setYearOfPublication(year);
|
||||
int yearOfPub;
|
||||
try {
|
||||
yearOfPub = Integer.parseInt(year);
|
||||
} catch(NumberFormatException ex ){
|
||||
yearOfPub = 0;
|
||||
}
|
||||
proceedings.setYearOfPublication(yearOfPub);
|
||||
for (AuthorData author : authors) {
|
||||
report.addAuthor(processAuthor(proceedings, author, pretend));
|
||||
}
|
||||
|
||||
report.setPublisher(processPublisher(proceedings, publisherName, place, pretend));
|
||||
|
||||
proceedings.save();
|
||||
inProceedings.setProceedings(proceedings);
|
||||
}
|
||||
|
||||
report.setCreated(true);
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdProcs.contains(String.format("%s %s", title, year))) {
|
||||
report.setCreated(false);
|
||||
} else {
|
||||
if (pretend) {
|
||||
for (AuthorData author : authors) {
|
||||
report.addAuthor(processAuthor(null, author, pretend));
|
||||
}
|
||||
report.setPublisher(processPublisher(null, place, publisherName, pretend));
|
||||
report.setConference(conference);
|
||||
}
|
||||
createdProcs.add(String.format("%s %s", title, year));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!pretend) {
|
||||
collection.next();
|
||||
|
|
@ -288,6 +361,13 @@ public class ImporterUtil {
|
|||
article.setJournal(newJournal);
|
||||
}
|
||||
report.setCreated(true);
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdJournals.contains(title)) {
|
||||
report.setCreated(false);
|
||||
} else {
|
||||
createdJournals.add(title);
|
||||
}
|
||||
} else {
|
||||
if (!pretend) {
|
||||
collection.next();
|
||||
|
|
|
|||
|
|
@ -32,12 +32,16 @@ abstract class AbstractPublicationImporter<T extends Publication> {
|
|||
private final CsvLine data;
|
||||
private final PublicationImportReport report;
|
||||
private final boolean pretend;
|
||||
private final ImporterUtil importerUtil = new ImporterUtil();
|
||||
private final ImporterUtil importerUtil;
|
||||
|
||||
public AbstractPublicationImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
public AbstractPublicationImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
this.data = data;
|
||||
this.report = report;
|
||||
this.pretend = pretend;
|
||||
this.importerUtil = importerUtil;
|
||||
}
|
||||
|
||||
protected CsvLine getData() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.arsdigita.cms.scipublications.importer.csv;
|
|||
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -14,8 +15,9 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
|
|||
|
||||
public AbstractPublicationWithPublisherImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.arsdigita.cms.scipublications.importer.csv;
|
|||
import com.arsdigita.cms.contenttypes.UnPublished;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -13,8 +14,9 @@ abstract class AbstractUnPublishedImporter<T extends UnPublished> extends Abstra
|
|||
|
||||
protected AbstractUnPublishedImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,13 +14,16 @@ import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
|||
*/
|
||||
class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<ArticleInCollectedVolume> {
|
||||
|
||||
public ArticleInCollectedVolumeImporter(CsvLine data, PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
public ArticleInCollectedVolumeImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleInCollectedVolume importPublication() {
|
||||
final ArticleInCollectedVolume article = importPublication();
|
||||
final ArticleInCollectedVolume article = super.importPublication();
|
||||
final CsvLine data = getData();
|
||||
final PublicationImportReport report = getReport();
|
||||
final ImporterUtil importerUtil = getImporterUtil();
|
||||
|
|
@ -38,8 +41,10 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
|
|||
report.setCollectedVolume(importerUtil.processCollectedVolume(
|
||||
article,
|
||||
data.getCollectedVolume(),
|
||||
article.getYearOfPublication(),
|
||||
data.getYear(),
|
||||
parseAuthors(data.getCollectedVolumeAuthors()),
|
||||
data.getPublisher(),
|
||||
data.getPlace(),
|
||||
isPretend()));
|
||||
|
||||
|
||||
|
|
@ -65,9 +70,9 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
|
|||
try {
|
||||
final int pagesTo = Integer.parseInt(getData().getPageTo());
|
||||
if (!isPretend()) {
|
||||
publication.setPagesFrom(pagesTo);
|
||||
publication.setPagesTo(pagesTo);
|
||||
}
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageFrom()));
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageTo()));
|
||||
} catch (NumberFormatException ex) {
|
||||
getReport().addMessage(String.format("Failed to parse pageTo data in line '%d'.",
|
||||
getData().getLineNumber()));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
|||
import com.arsdigita.cms.contenttypes.ArticleInJournalBundle;
|
||||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.JournalImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import java.text.DateFormat;
|
||||
|
|
@ -19,8 +20,9 @@ class ArticleInJournalImporter extends AbstractPublicationImporter<ArticleInJour
|
|||
|
||||
protected ArticleInJournalImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -42,7 +44,10 @@ class ArticleInJournalImporter extends AbstractPublicationImporter<ArticleInJour
|
|||
processPublicationDate(article);
|
||||
|
||||
if ((data.getJournal() != null) && !data.getJournal().isEmpty()) {
|
||||
importerUtil.processJournal(article, data.getJournal(), isPretend());
|
||||
final JournalImportReport journalReport = importerUtil.processJournal(article,
|
||||
data.getJournal(),
|
||||
isPretend());
|
||||
report.setJournal(journalReport);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -83,9 +88,9 @@ class ArticleInJournalImporter extends AbstractPublicationImporter<ArticleInJour
|
|||
try {
|
||||
final int pagesTo = Integer.parseInt(getData().getPageTo());
|
||||
if (!isPretend()) {
|
||||
publication.setPagesFrom(pagesTo);
|
||||
publication.setPagesTo(pagesTo);
|
||||
}
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageFrom()));
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageTo()));
|
||||
} catch (NumberFormatException ex) {
|
||||
getReport().addMessage(String.format("Failed to parse pageTo data in line '%d'.",
|
||||
getData().getLineNumber()));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.contenttypes.CollectedVolume;
|
|||
import com.arsdigita.cms.contenttypes.CollectedVolumeBundle;
|
||||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -14,8 +15,9 @@ class CollectedVolumeImporter extends AbstractPublicationWithPublisherImporter<C
|
|||
|
||||
protected CollectedVolumeImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.contenttypes.Expertise;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -12,8 +13,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class ExpertiseImporter extends AbstractPublicationImporter<Expertise> {
|
||||
|
||||
protected ExpertiseImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
protected ExpertiseImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.contenttypes.GreyLiterature;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -12,8 +13,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class GreyLiteratureImporter extends AbstractUnPublishedImporter<GreyLiterature> {
|
||||
|
||||
protected GreyLiteratureImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
protected GreyLiteratureImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -45,9 +49,9 @@ class GreyLiteratureImporter extends AbstractUnPublishedImporter<GreyLiterature>
|
|||
try {
|
||||
final int pagesTo = Integer.parseInt(getData().getPageTo());
|
||||
if (!isPretend()) {
|
||||
publication.setPagesFrom(pagesTo);
|
||||
publication.setPagesTo(pagesTo);
|
||||
}
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageFrom()));
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageTo()));
|
||||
} catch (NumberFormatException ex) {
|
||||
getReport().addMessage(String.format("Failed to parse pageTo data in line '%d'.",
|
||||
getData().getLineNumber()));
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
|||
*/
|
||||
class InProceedingsImporter extends AbstractPublicationImporter<InProceedings> {
|
||||
|
||||
public InProceedingsImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
public InProceedingsImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -30,9 +33,11 @@ class InProceedingsImporter extends AbstractPublicationImporter<InProceedings> {
|
|||
|
||||
report.setProceedings(importerUtil.processProceedings(inProceedings,
|
||||
data.getCollectedVolume(),
|
||||
inProceedings.getYearOfPublication(),
|
||||
data.getYear(),
|
||||
data.getConference(),
|
||||
parseAuthors(data.getCollectedVolumeAuthors()),
|
||||
data.getPublisher(),
|
||||
data.getPlace(),
|
||||
isPretend()));
|
||||
|
||||
return inProceedings;
|
||||
|
|
@ -57,9 +62,9 @@ class InProceedingsImporter extends AbstractPublicationImporter<InProceedings> {
|
|||
try {
|
||||
final int pagesTo = Integer.parseInt(getData().getPageTo());
|
||||
if (!isPretend()) {
|
||||
publication.setPagesFrom(pagesTo);
|
||||
publication.setPagesTo(pagesTo);
|
||||
}
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageFrom()));
|
||||
getReport().addField(new FieldImportReport("Pages to", getData().getPageTo()));
|
||||
} catch (NumberFormatException ex) {
|
||||
getReport().addMessage(String.format("Failed to parse pageTo data in line '%d'.",
|
||||
getData().getLineNumber()));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.arsdigita.cms.contenttypes.InternetArticleBundle;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
|
@ -16,8 +17,11 @@ import java.util.Date;
|
|||
*/
|
||||
class InternetArticleImporter extends AbstractPublicationImporter<InternetArticle> {
|
||||
|
||||
public InternetArticleImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
public InternetArticleImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.contenttypes.Monograph;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.contenttypes.PublicationWithPublisherBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -12,8 +13,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class MonographImporter extends AbstractPublicationWithPublisherImporter<Monograph> {
|
||||
|
||||
protected MonographImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
protected MonographImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.arsdigita.cms.contenttypes.ProceedingsBundle;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -13,8 +14,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class ProceedingsImporter extends AbstractPublicationWithPublisherImporter<Proceedings> {
|
||||
|
||||
public ProceedingsImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
public ProceedingsImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.arsdigita.cms.scipublications.importer.SciPublicationsImporter;
|
|||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.ImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.Filter;
|
||||
import com.arsdigita.persistence.FilterFactory;
|
||||
|
|
@ -89,6 +90,7 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
final String[] linesWithHeader = publications.split(LINE_SEP);
|
||||
final String[] lines = Arrays.copyOfRange(linesWithHeader, 1, linesWithHeader.length);
|
||||
final ImportReport report = new ImportReport();
|
||||
final ImporterUtil importerUtil = new ImporterUtil();
|
||||
|
||||
report.setImporter("CSV Importer");
|
||||
report.setPretend(pretend);
|
||||
|
|
@ -100,12 +102,16 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
try {
|
||||
int lineNumber = 2; //Because we are starting at line 2 of the CSV file (line 1 contains the column headers)
|
||||
for (String line : lines) {
|
||||
final PublicationImportReport result = importPublication(line, lineNumber, publishNewItems, pretend);
|
||||
final PublicationImportReport result = importPublication(line,
|
||||
lineNumber,
|
||||
publishNewItems,
|
||||
pretend,
|
||||
importerUtil);
|
||||
report.addPublication(result);
|
||||
lineNumber++;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
tctx.abortTxn();
|
||||
tctx.abortTxn();
|
||||
throw new SciPublicationsImportException(ex);
|
||||
}
|
||||
|
||||
|
|
@ -121,47 +127,43 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
private PublicationImportReport importPublication(final String line,
|
||||
final int lineNumber,
|
||||
final boolean publishNewItems,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
final PublicationImportReport report = new PublicationImportReport();
|
||||
|
||||
final String[] cols = line.split(COL_SEP, -30);
|
||||
//Check number of cols
|
||||
System.err.println("Checking number of cols...");
|
||||
//Check number of cols
|
||||
if (cols.length != 30) {
|
||||
report.setSuccessful(false);
|
||||
report.addMessage(String.format("!!! Wrong number of columns. Exepcted 30 columns but found %d columns. "
|
||||
+ "Skiping line %d!\n", cols.length, lineNumber));
|
||||
return report;
|
||||
}
|
||||
System.err.println("Checked number of cols...");
|
||||
|
||||
System.err.println("Creating csv object...");
|
||||
final CsvLine data = new CsvLine(cols, lineNumber);
|
||||
|
||||
System.err.println("Calling importer...");
|
||||
if (ArticleInCollectedVolume.class.getSimpleName().equals(data.getType())) {
|
||||
processArticleInCollectedVolume(publishNewItems, data, report, pretend);
|
||||
} else if (ArticleInCollectedVolume.class.getSimpleName().equals(data.getType())) {
|
||||
processArticleInJournal(publishNewItems, data, report, pretend);
|
||||
processArticleInCollectedVolume(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (ArticleInJournal.class.getSimpleName().equals(data.getType())) {
|
||||
processArticleInJournal(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (CollectedVolume.class.getSimpleName().equals(data.getType())) {
|
||||
processCollectedVolume(publishNewItems, data, report, pretend);
|
||||
processCollectedVolume(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (Expertise.class.getSimpleName().equals(data.getType())) {
|
||||
processExpertise(publishNewItems, data, report, pretend);
|
||||
processExpertise(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (GreyLiterature.class.getSimpleName().equals(data.getType())) {
|
||||
processGreyLiterature(publishNewItems, data, report, pretend);
|
||||
processGreyLiterature(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (InProceedings.class.getSimpleName().equals(data.getType())) {
|
||||
processInProceedings(publishNewItems, data, report, pretend);
|
||||
processInProceedings(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (InternetArticle.class.getSimpleName().equals(data.getType())) {
|
||||
processInternetArticle(publishNewItems, data, report, pretend);
|
||||
processInternetArticle(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (Monograph.class.getSimpleName().equals(data.getType())) {
|
||||
System.err.println("CAlling monograph importer...");
|
||||
processMonograph(publishNewItems, data, report, pretend);
|
||||
processMonograph(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (Proceedings.class.getSimpleName().equals(data.getType())) {
|
||||
processProceedings(publishNewItems, data, report, pretend);
|
||||
processProceedings(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (Review.class.getSimpleName().equals(data.getType())) {
|
||||
processReview(publishNewItems, data, report, pretend);
|
||||
processReview(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (WorkingPaper.class.getSimpleName().equals(data.getType())) {
|
||||
processWorkingPaper(publishNewItems, data, report, pretend);
|
||||
processWorkingPaper(publishNewItems, data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
return report;
|
||||
|
|
@ -170,120 +172,133 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
private void processArticleInCollectedVolume(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, ArticleInCollectedVolume.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ArticleInCollectedVolumeImporter importer = new ArticleInCollectedVolumeImporter(data, report, pretend);
|
||||
final ArticleInCollectedVolumeImporter importer = new ArticleInCollectedVolumeImporter(data,
|
||||
report,
|
||||
pretend,
|
||||
importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processArticleInJournal(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, ArticleInJournal.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ArticleInJournalImporter importer = new ArticleInJournalImporter(data, report, pretend);
|
||||
final ArticleInJournalImporter importer = new ArticleInJournalImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processCollectedVolume(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, CollectedVolume.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CollectedVolumeImporter importer = new CollectedVolumeImporter(data, report, pretend);
|
||||
final CollectedVolumeImporter importer = new CollectedVolumeImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processExpertise(final boolean publishNewItems, final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, Expertise.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ExpertiseImporter importer = new ExpertiseImporter(data, report, pretend);
|
||||
final ExpertiseImporter importer = new ExpertiseImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processGreyLiterature(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, GreyLiterature.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GreyLiteratureImporter importer = new GreyLiteratureImporter(data, report, pretend);
|
||||
final GreyLiteratureImporter importer = new GreyLiteratureImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processInProceedings(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, InProceedings.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final InProceedingsImporter importer = new InProceedingsImporter(data, report, pretend);
|
||||
final InProceedingsImporter importer = new InProceedingsImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processInternetArticle(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, InternetArticle.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final InternetArticleImporter importer = new InternetArticleImporter(data, report, pretend);
|
||||
final InternetArticleImporter importer = new InternetArticleImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processMonograph(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, Monograph.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MonographImporter importer = new MonographImporter(data, report, pretend);
|
||||
final MonographImporter importer = new MonographImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processProceedings(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, Proceedings.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
System.err.println("Publication is not in database");
|
||||
|
||||
final ProceedingsImporter importer = new ProceedingsImporter(data, report, pretend);
|
||||
final ProceedingsImporter importer = new ProceedingsImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
private void processReview(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, Review.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ReviewImporter importer = new ReviewImporter(data, report, pretend);
|
||||
final ReviewImporter importer = new ReviewImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
|
||||
}
|
||||
|
|
@ -291,12 +306,13 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
private void processWorkingPaper(final boolean publishNewItems,
|
||||
final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend) {
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
if (isPublicationAlreadyInDatabase(data, WorkingPaper.class.getSimpleName(), report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final WorkingPaperImporter importer = new WorkingPaperImporter(data, report, pretend);
|
||||
final WorkingPaperImporter importer = new WorkingPaperImporter(data, report, pretend, importerUtil);
|
||||
importer.doImport(publishNewItems);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.arsdigita.cms.scipublications.importer.csv;
|
|||
import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
||||
import com.arsdigita.cms.contenttypes.Review;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -11,8 +12,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class ReviewImporter extends ArticleInJournalImporter {
|
||||
|
||||
public ReviewImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
public ReviewImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.arsdigita.cms.scipublications.importer.csv;
|
|||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.contenttypes.WorkingPaper;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -11,8 +12,11 @@ import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport
|
|||
*/
|
||||
class WorkingPaperImporter extends AbstractUnPublishedImporter<WorkingPaper> {
|
||||
|
||||
protected WorkingPaperImporter(final CsvLine data, final PublicationImportReport report, final boolean pretend) {
|
||||
super(data, report, pretend);
|
||||
protected WorkingPaperImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue