Aktueller Stand des CSV-Importers
git-svn-id: https://svn.libreccm.org/ccm/trunk@1927 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
d0ab7f6de5
commit
f24f85597b
|
|
@ -218,7 +218,12 @@ public class ImporterUtil {
|
|||
|
||||
final CollectedVolume collectedVolume = new CollectedVolume();
|
||||
collectedVolume.setTitle(title);
|
||||
collectedVolume.setName(normalizeString(title));
|
||||
final String name = normalizeString(title);
|
||||
if (name.length() < 200) {
|
||||
collectedVolume.setName(name);
|
||||
} else {
|
||||
collectedVolume.setName(name.substring(0, 200));
|
||||
}
|
||||
collectedVolume.setContentSection(folder.getContentSection());
|
||||
collectedVolume.setLanguage(Kernel.getConfig().getLanguagesIndependentCode());
|
||||
collectedVolume.save();
|
||||
|
|
@ -450,19 +455,21 @@ public class ImporterUtil {
|
|||
getConfig().getOrganizationBundleType());
|
||||
bundle.setDefaultLanguage(orga.getLanguage());
|
||||
bundle.setContentType(orga.getContentType());
|
||||
bundle.addInstance(orga);
|
||||
bundle.addInstance(orga);
|
||||
bundle.setName(orga.getName());
|
||||
bundle.setParent(folder);
|
||||
bundle.setContentSection(folder.getContentSection());
|
||||
bundle.save();
|
||||
|
||||
|
||||
publication.setOrganization(orga);
|
||||
|
||||
|
||||
if (publish) {
|
||||
publishItem(orga);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
report.setCreated(true);
|
||||
|
||||
|
||||
//Special handling for pretend mode
|
||||
if (pretend && createdOrgas.contains(name)) {
|
||||
report.setCreated(false);
|
||||
|
|
@ -477,8 +484,8 @@ public class ImporterUtil {
|
|||
}
|
||||
report.setCreated(false);
|
||||
}
|
||||
|
||||
collection.close();
|
||||
|
||||
collection.close();
|
||||
return report;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ abstract class AbstractPublicationImporter<T extends Publication> {
|
|||
private final boolean pretend;
|
||||
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;
|
||||
|
|
@ -127,12 +127,20 @@ abstract class AbstractPublicationImporter<T extends Publication> {
|
|||
|
||||
bundle.save();
|
||||
|
||||
publication.setAbstract(data.getAbstract());
|
||||
publication.setMisc(data.getMisc());
|
||||
|
||||
if (data.getAbstract().length() < 4096) {
|
||||
publication.setAbstract(data.getAbstract());
|
||||
} else {
|
||||
publication.setAbstract(data.getAbstract().substring(0, 4096));
|
||||
}
|
||||
if (data.getMisc().length() < 4096) {
|
||||
publication.setMisc(data.getMisc());
|
||||
} else {
|
||||
publication.setMisc(data.getMisc().substring(0, 4096));
|
||||
}
|
||||
|
||||
publication.save();
|
||||
}
|
||||
|
||||
|
||||
processAuthors(publication);
|
||||
|
||||
return publication;
|
||||
|
|
@ -150,7 +158,11 @@ abstract class AbstractPublicationImporter<T extends Publication> {
|
|||
private void processTitleAndName(final T publication) {
|
||||
if (!pretend) {
|
||||
publication.setTitle(data.getTitle());
|
||||
publication.setName(normalizeString(data.getTitle()));
|
||||
String name = normalizeString(data.getTitle());
|
||||
if (name.length() > 200) {
|
||||
name = name.substring(0, 200);
|
||||
}
|
||||
publication.setName(name);
|
||||
}
|
||||
report.setTitle(data.getTitle());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,17 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
|
|||
protected T importPublication() {
|
||||
final T publication = super.importPublication();
|
||||
final CsvLine data = getData();
|
||||
|
||||
|
||||
if ((data.getIsbn() != null) && !data.getIsbn().isEmpty()) {
|
||||
if (!isPretend()) {
|
||||
final String isbn = data.getIsbn().replace("-", "");
|
||||
if (!isPretend() && isbn.length() == 13) {
|
||||
publication.setISBN(data.getIsbn());
|
||||
}
|
||||
getReport().addField(new FieldImportReport("isbn", data.getIsbn()));
|
||||
if (isbn.length() == 13) {
|
||||
getReport().addField(new FieldImportReport("isbn", isbn));
|
||||
} else {
|
||||
getReport().addMessage(String.format("Invalid ISBN at line %d.", data.getLineNumber()));
|
||||
}
|
||||
}
|
||||
|
||||
processVolume(publication);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
|||
*/
|
||||
class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<ArticleInCollectedVolume> {
|
||||
|
||||
public ArticleInCollectedVolumeImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
public ArticleInCollectedVolumeImporter(final CsvLine data,
|
||||
final PublicationImportReport report,
|
||||
final boolean pretend,
|
||||
final ImporterUtil importerUtil) {
|
||||
super(data, report, pretend, importerUtil);
|
||||
|
|
@ -38,14 +38,16 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
|
|||
report.addField(new FieldImportReport("Chapter", data.getChapter()));
|
||||
}
|
||||
|
||||
report.setCollectedVolume(importerUtil.processCollectedVolume(
|
||||
article,
|
||||
data.getCollectedVolume(),
|
||||
data.getYear(),
|
||||
parseAuthors(data.getCollectedVolumeAuthors()),
|
||||
data.getPublisher(),
|
||||
data.getPlace(),
|
||||
isPretend()));
|
||||
if ((data.getCollectedVolume() != null) && !data.getCollectedVolume().isEmpty()) {
|
||||
report.setCollectedVolume(importerUtil.processCollectedVolume(
|
||||
article,
|
||||
data.getCollectedVolume(),
|
||||
data.getYear(),
|
||||
parseAuthors(data.getCollectedVolumeAuthors()),
|
||||
data.getPublisher(),
|
||||
data.getPlace(),
|
||||
isPretend()));
|
||||
}
|
||||
|
||||
|
||||
return article;
|
||||
|
|
|
|||
Loading…
Reference in New Issue