Aktuller Stand CSV Importer für Publikationen

git-svn-id: https://svn.libreccm.org/ccm/trunk@1932 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-11-15 05:57:37 +00:00
parent 20dc430d32
commit 6498c02337
9 changed files with 247 additions and 233 deletions

View File

@ -6,9 +6,6 @@ import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -18,28 +15,23 @@ import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentTypeCollection;
import com.arsdigita.cms.Folder; import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.PublicPersonalProfile; import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle; import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.LanguageWidget; import com.arsdigita.cms.ui.authoring.LanguageWidget;
import com.arsdigita.cms.ui.authoring.PageCreate; import com.arsdigita.cms.ui.authoring.PageCreate;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
@ -50,11 +42,9 @@ import java.util.TooManyListenersException;
*/ */
public class PublicPersonalProfileCreate extends PageCreate { public class PublicPersonalProfileCreate extends PageCreate {
private static final String SELECTED_PERSON = "selectedPerson"; //private static final String SELECTED_PERSON = "selectedPerson";
private static final PublicPersonalProfileConfig config = //private static final PublicPersonalProfileConfig config =
PublicPersonalProfiles. // PublicPersonalProfiles. getConfig();
getConfig();
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel, public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) { final CreationSelector parent) {
super(itemModel, parent); super(itemModel, parent);
@ -64,7 +54,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
public void addWidgets() { public void addWidgets() {
//super.addWidgets(); //super.addWidgets();
ContentType type = getItemSelectionModel().getContentType(); final ContentType type = getItemSelectionModel().getContentType();
m_workflowSection = new ApplyWorkflowFormSection(type); m_workflowSection = new ApplyWorkflowFormSection(type);
add(m_workflowSection, ColumnPanel.INSERT); add(m_workflowSection, ColumnPanel.INSERT);
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
@ -73,70 +63,69 @@ public class PublicPersonalProfileCreate extends PageCreate {
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field"))); add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
add(new LanguageWidget(LANGUAGE)); add(new LanguageWidget(LANGUAGE));
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.create.select_person")));
"publicpersonalprofile.ui.create.select_person"))); final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
ParameterModel ownerModel = final SingleSelect ownerSelect = new SingleSelect(ownerModel);
new StringParameter(PublicPersonalProfileBundle.OWNER);
SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
try { try {
ownerSelect.addPrintListener(new PrintListener() { ownerSelect.addPrintListener(new PPPOwnerSelectPrintListener());
// ownerSelect.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { //
final SingleSelect ownerSelect = (SingleSelect) event. // public void prepare(final PrintEvent event) {
getTarget(); // final SingleSelect ownerSelect = (SingleSelect) event.
// getTarget();
String personType = config.getPersonType(); //
if ((personType == null) || (personType.isEmpty())) { // String personType = config.getPersonType();
personType = // if ((personType == null) || (personType.isEmpty())) {
"com.arsdigita.cms.contenttypes.GenericPerson"; // personType =
} // "com.arsdigita.cms.contenttypes.GenericPerson";
// }
ContentTypeCollection types = //
ContentType.getAllContentTypes(); // ContentTypeCollection types =
types.addFilter( // ContentType.getAllContentTypes();
String.format("className = '%s'", personType)); // types.addFilter(
if (types.size() == 0) { // String.format("className = '%s'", personType));
personType = // if (types.size() == 0) {
"com.arsdigita.cms.contenttypes.GenericPerson"; // personType =
} // "com.arsdigita.cms.contenttypes.GenericPerson";
DataCollection persons = SessionManager.getSession(). // }
retrieve( // DataCollection persons = SessionManager.getSession().
personType); // retrieve(
//persons.addFilter("profile is null"); // personType);
persons.addFilter(String.format("version = '%s'", // //persons.addFilter("profile is null");
ContentItem.DRAFT)); // persons.addFilter(String.format("version = '%s'",
persons.addOrder("surname asc"); // ContentItem.DRAFT));
persons.addOrder("givenname asc"); // persons.addOrder("surname asc");
persons.addOrder("language asc"); // persons.addOrder("givenname asc");
ownerSelect.addOption(new Option("", "")); // persons.addOrder("language asc");
// ownerSelect.addOption(new Option("", ""));
//Store the parent ids of processed items to remove double entries. //
final List<BigDecimal> processed = // //Store the parent ids of processed items to remove double entries.
new ArrayList<BigDecimal>(); // final List<BigDecimal> processed =
while (persons.next()) { // new ArrayList<BigDecimal>();
GenericPerson person = // while (persons.next()) {
(GenericPerson) DomainObjectFactory. // GenericPerson person =
newInstance(persons.getDataObject()); // (GenericPerson) DomainObjectFactory.
if (processed.contains(person.getParent().getID())) { // newInstance(persons.getDataObject());
continue; // if (processed.contains(person.getParent().getID())) {
} else { // continue;
if (person.getGenericPersonBundle().get("profile") // } else {
== null) { // if (person.getGenericPersonBundle().get("profile")
continue; // == null) {
} else { // continue;
ownerSelect.addOption(new Option( // } else {
person.getID().toString(), // ownerSelect.addOption(new Option(
String.format("%s (%s)", // person.getID().toString(),
person.getFullName(), // String.format("%s (%s)",
person.getLanguage()))); // person.getFullName(),
processed.add(person.getParent().getID()); // person.getLanguage())));
} // processed.add(person.getParent().getID());
} // }
} // }
} // }
}); // }
// });
} catch (TooManyListenersException ex) { } catch (TooManyListenersException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
@ -146,10 +135,8 @@ public class PublicPersonalProfileCreate extends PageCreate {
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.ui.authoring.page_launch_date"))); "cms.ui.authoring.page_launch_date")));
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE); final ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
com.arsdigita.bebop.form.Date launchDate = final com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(launchDateParam);
new com.arsdigita.bebop.form.Date(
launchDateParam);
if (ContentSection.getConfig().getRequireLaunchDate()) { if (ContentSection.getConfig().getRequireLaunchDate()) {
launchDate.addValidationListener( launchDate.addValidationListener(
new LaunchDateValidationListener()); new LaunchDateValidationListener());
@ -163,32 +150,30 @@ public class PublicPersonalProfileCreate extends PageCreate {
/** /**
* Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here * Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here
* because the super method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries * because the super method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries
* to access things which on existing yet. * to access properties which are not set yet.
*
* @param fse
*/ */
@Override @Override
public void validate(FormSectionEvent fse) throws FormProcessException { public void validate(final FormSectionEvent fse) throws FormProcessException {
Folder folder = m_parent.getFolder(fse.getPageState()); final Folder folder = m_parent.getFolder(fse.getPageState());
Assert.exists(folder); Assert.exists(folder);
String id = (String) fse.getFormData().get( final String personId = (String) fse.getFormData().get(PublicPersonalProfileBundle.OWNER);
PublicPersonalProfileBundle.OWNER);
if ((id == null) || id.trim().isEmpty()) { if ((personId == null) || personId.trim().isEmpty()) {
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil. fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.globalize(
globalize("publicpersonalprofile.ui.person.required")); "publicpersonalprofile.ui.person.required"));
return; return;
} }
GenericPerson owner = new GenericPerson(new BigDecimal(id)); final GenericPerson owner = new GenericPerson(new BigDecimal(personId));
validateNameUniqueness(folder, validateNameUniqueness(folder, fse, String.format("%s-profile",
fse, GenericPerson.urlSave(owner.getFullName())));
String.format("%s-profile",
GenericPerson.urlSave(
owner.getFullName())));
} }
@Override @Override
public void process(FormSectionEvent fse) throws FormProcessException { public void process(final FormSectionEvent fse) throws FormProcessException {
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
final ContentSection section = m_parent.getContentSection(state); final ContentSection section = m_parent.getContentSection(state);
@ -196,13 +181,12 @@ public class PublicPersonalProfileCreate extends PageCreate {
Assert.exists(section, ContentSection.class); Assert.exists(section, ContentSection.class);
String id = (String) fse.getFormData().get( final String personId = (String) fse.getFormData().get(PublicPersonalProfileBundle.OWNER);
PublicPersonalProfileBundle.OWNER);
GenericPerson owner = new GenericPerson(new BigDecimal(id)); final GenericPerson owner = new GenericPerson(new BigDecimal(personId));
String name = String.format("%s-profile", final String name = String.format("%s-profile",
GenericPerson.urlSave(owner.getFullName())); GenericPerson.urlSave(owner.getFullName()));
String title = String.format("%s (Profil)", owner.getFullName()); final String title = String.format("%s (Profil)", owner.getFullName());
final ContentPage item = createContentPage(state); final ContentPage item = createContentPage(state);
item.setLanguage((String) data.get(LANGUAGE)); item.setLanguage((String) data.get(LANGUAGE));
@ -219,9 +203,8 @@ public class PublicPersonalProfileCreate extends PageCreate {
m_workflowSection.applyWorkflow(state, item); m_workflowSection.applyWorkflow(state, item);
PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID()); final PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
profile.setOwner(owner); profile.setOwner(owner);
//profile.setProfileUrl(owner.getSurname().toLowerCase());
profile.setProfileUrl(createProfileUrl(owner)); profile.setProfileUrl(createProfileUrl(owner));
profile.save(); profile.save();
@ -230,27 +213,23 @@ public class PublicPersonalProfileCreate extends PageCreate {
private String createProfileUrl(final GenericPerson owner) { private String createProfileUrl(final GenericPerson owner) {
String profileUrl = owner.getSurname().toLowerCase(); String profileUrl = owner.getSurname().toLowerCase();
int i = 1; int counter = 1;
DataCollection profiles = SessionManager.getSession().retrieve( final DataCollection profiles = SessionManager.getSession().
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE); retrieve(PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'", profileUrl));
profileUrl));
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT)); profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
while (profiles.size() > 0) { while (profiles.size() > 0) {
i++; counter++;
profileUrl = String.format("%s%d", profileUrl = String.format("%s%d", owner.getSurname().toLowerCase(), counter);
owner.getSurname().toLowerCase(),
i);
profiles.reset(); profiles.reset();
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'", profileUrl));
profileUrl)); profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
profiles.addFilter(
String.format("version = '%s'", ContentItem.DRAFT));
} }
return GenericPerson.urlSave(profileUrl).toLowerCase(); return GenericPerson.urlSave(profileUrl).toLowerCase();
} }
} }

View File

@ -3,34 +3,42 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PublicPersonalProfile; import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* *
* @author Jens Pelzetter * @author Jens Pelzetter
* @version $Id$ * @version $Id$
*/ */
public class PublicPersonalProfilePropertyForm public class PublicPersonalProfilePropertyForm extends BasicPageForm implements FormProcessListener,
extends BasicPageForm
implements FormProcessListener,
FormInitListener, FormInitListener,
FormValidationListener { FormValidationListener {
private PublicPersonalProfilePropertiesStep step; //private PublicPersonalProfilePropertiesStep step;
public static final String ID = "PublicPersonalProfile_edit"; public static final String ID = "PublicPersonalProfile_edit";
private ItemSelectionModel itemModel; private ItemSelectionModel itemModel;
@ -38,11 +46,10 @@ public class PublicPersonalProfilePropertyForm
this(itemModel, null); this(itemModel, null);
} }
public PublicPersonalProfilePropertyForm( public PublicPersonalProfilePropertyForm(final ItemSelectionModel itemModel,
ItemSelectionModel itemModel, final PublicPersonalProfilePropertiesStep step) {
PublicPersonalProfilePropertiesStep step) {
super(ID, itemModel); super(ID, itemModel);
this.step = step; //this.step = step;
this.itemModel = itemModel; this.itemModel = itemModel;
addValidationListener(this); addValidationListener(this);
} }
@ -51,53 +58,64 @@ public class PublicPersonalProfilePropertyForm
public void addWidgets() { public void addWidgets() {
super.addWidgets(); super.addWidgets();
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.create.select_person")));
"publicpersonalprofile.ui.profile.url"))); final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
ParameterModel profileUrlParam = final SingleSelect ownerSelect = new SingleSelect(ownerModel);
new StringParameter(PublicPersonalProfile.PROFILE_URL); ownerSelect.addValidationListener(new NotNullValidationListener());
TextField profileUrl = new TextField(profileUrlParam);
try {
ownerSelect.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException(ex);
}
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.profile.url")));
final ParameterModel profileUrlParam = new StringParameter(PublicPersonalProfile.PROFILE_URL);
final TextField profileUrl = new TextField(profileUrlParam);
add(profileUrl); add(profileUrl);
} }
@Override @Override
public void init(FormSectionEvent fse) throws FormProcessException { public void init(final FormSectionEvent fse) throws FormProcessException {
final PageState state = fse.getPageState(); //final PageState state = fse.getPageState();
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PublicPersonalProfile profile = final PublicPersonalProfile profile = (PublicPersonalProfile) super.initBasicWidgets(fse);
(PublicPersonalProfile) super.
initBasicWidgets(fse);
data.put(PublicPersonalProfile.PROFILE_URL, profile.getProfileUrl()); data.put(PublicPersonalProfile.PROFILE_URL, profile.getProfileUrl());
} }
@Override @Override
public void process(FormSectionEvent fse) throws FormProcessException { public void process(final FormSectionEvent fse) throws FormProcessException {
final PublicPersonalProfile profile = final PublicPersonalProfile profile = (PublicPersonalProfile) processBasicWidgets(fse);
(PublicPersonalProfile) processBasicWidgets(
fse);
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
if ((profile != null) if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) {
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
profile.setProfileUrl(((String) data.get( final String ownerId = (String)data.get(PublicPersonalProfileBundle.OWNER);
PublicPersonalProfile.PROFILE_URL)). if (!profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
toLowerCase());
}
profile.setProfileUrl(((String) data.get(PublicPersonalProfile.PROFILE_URL)).toLowerCase());
profile.save(); profile.save();
} }
} }
@Override @Override
public void validate(FormSectionEvent fse) throws FormProcessException { public void validate(final FormSectionEvent fse) throws FormProcessException {
super.validate(fse); super.validate(fse);
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final String profilesUrl = (String) data.get(PublicPersonalProfile.PROFILE_URL);
String profilesUrl =
(String) data.get(PublicPersonalProfile.PROFILE_URL);
if ((profilesUrl == null) || profilesUrl.isEmpty()) { if ((profilesUrl == null) || profilesUrl.isEmpty()) {
data.addError(PublicPersonalProfileGlobalizationUtil.globalize( data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.profile_url.required")); "publicpersonalprofile.ui.profile_url.required"));
@ -108,11 +126,9 @@ public class PublicPersonalProfilePropertyForm
"publicpersonalprofile.ui.profile_url.reserved")); "publicpersonalprofile.ui.profile_url.reserved"));
} }
DataCollection profiles = SessionManager.getSession().retrieve( final DataCollection profiles = SessionManager.getSession().retrieve(
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE); PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'", ((String) data.get(PublicPersonalProfile.PROFILE_URL)).
((String) data.get(
PublicPersonalProfile.PROFILE_URL)).
toLowerCase())); toLowerCase()));
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT)); profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
if (profiles.size() > 1) { if (profiles.size() > 1) {
@ -120,9 +136,8 @@ public class PublicPersonalProfilePropertyForm
"publicpersonalprofile.ui.profile_url.already_in_use")); "publicpersonalprofile.ui.profile_url.already_in_use"));
} else if (profiles.size() == 1) { } else if (profiles.size() == 1) {
profiles.next(); profiles.next();
PublicPersonalProfile profile = final PublicPersonalProfile profile = (PublicPersonalProfile) DomainObjectFactory.newInstance(profiles.
(PublicPersonalProfile) DomainObjectFactory. getDataObject());
newInstance(profiles.getDataObject());
if (!(profile.getID().equals( if (!(profile.getID().equals(
itemModel.getSelectedItem(state).getID()))) { itemModel.getSelectedItem(state).getID()))) {
@ -131,4 +146,5 @@ public class PublicPersonalProfilePropertyForm
} }
} }
} }
} }

View File

@ -347,9 +347,12 @@ public class Publication extends ContentPage {
@Override @Override
public String getSearchSummary() { public String getSearchSummary() {
return String.format("%s %s %s", String summary = String.format("%s %s %s", getTitle(), getAuthors(), getAbstract());
getTitle(), if (summary.length() > 4000) {
getAuthors(), summary = summary.substring(0, 4000);
getAbstract());
} }
return summary;
}
} }

View File

@ -71,7 +71,9 @@ public class CollectedVolumeImportReport {
writer.printf("%s\n", author.toString()); writer.printf("%s\n", author.toString());
} }
if (publisher != null) {
writer.append(publisher.toString()); writer.append(publisher.toString());
}
writer.append('\n'); writer.append('\n');
for (int i = 0; i < 40; i++) { for (int i = 0; i < 40; i++) {

View File

@ -245,7 +245,9 @@ public class ImporterUtil {
report.addAuthor(processAuthor(collectedVolume, author, pretend)); report.addAuthor(processAuthor(collectedVolume, author, pretend));
} }
if ((publisherName != null) && !publisherName.isEmpty()) {
report.setPublisher(processPublisher(collectedVolume, place, publisherName, pretend)); report.setPublisher(processPublisher(collectedVolume, place, publisherName, pretend));
}
collectedVolume.save(); collectedVolume.save();
article.setCollectedVolume(collectedVolume); article.setCollectedVolume(collectedVolume);
@ -330,7 +332,9 @@ public class ImporterUtil {
report.addAuthor(processAuthor(proceedings, author, pretend)); report.addAuthor(processAuthor(proceedings, author, pretend));
} }
if ((publisherName != null) && !publisherName.isEmpty()) {
report.setPublisher(processPublisher(proceedings, place, publisherName, pretend)); report.setPublisher(processPublisher(proceedings, place, publisherName, pretend));
}
proceedings.save(); proceedings.save();
inProceedings.setProceedings(proceedings); inProceedings.setProceedings(proceedings);
@ -466,6 +470,8 @@ public class ImporterUtil {
if (publish) { if (publish) {
publishItem(orga); publishItem(orga);
} }
report.setType(orga.getClass().getName());
} }
report.setCreated(true); report.setCreated(true);
@ -477,11 +483,12 @@ public class ImporterUtil {
createdOrgas.add(name); createdOrgas.add(name);
} }
} else { } else {
if (!pretend) {
collection.next(); collection.next();
final GenericOrganizationalUnit orga = new GenericOrganizationalUnit(collection.getDataObject()); final GenericOrganizationalUnit orga = new GenericOrganizationalUnit(collection.getDataObject());
if (!pretend) {
publication.setOrganization(orga); publication.setOrganization(orga);
} }
report.setType(orga.getClass().getName());
report.setCreated(false); report.setCreated(false);
} }

View File

@ -127,21 +127,23 @@ abstract class AbstractPublicationImporter<T extends Publication> {
bundle.save(); bundle.save();
if (data.getAbstract().length() < 4096) { if (data.getAbstract().length() < 3975) {
publication.setAbstract(data.getAbstract()); publication.setAbstract(data.getAbstract());
} else { } else {
publication.setAbstract(data.getAbstract().substring(0, 4096)); publication.setAbstract(data.getAbstract().substring(0, 3975));
} }
if (data.getMisc().length() < 4096) { if (data.getMisc().length() < 3975) {
publication.setMisc(data.getMisc()); publication.setMisc(data.getMisc());
} else { } else {
publication.setMisc(data.getMisc().substring(0, 4096)); publication.setMisc(data.getMisc().substring(0, 3975));
} }
publication.save(); publication.save();
} }
if ((data.getAuthors() != null) && !data.getAuthors().isEmpty()) {
processAuthors(publication); processAuthors(publication);
}
return publication; return publication;
} }

View File

@ -47,7 +47,9 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
getReport().addField(new FieldImportReport("edition", data.getEdition())); getReport().addField(new FieldImportReport("edition", data.getEdition()));
} }
if ((data.getPublisher() != null) && !data.getPublisher().isEmpty()) {
getImporterUtil().processPublisher(publication, getData().getPlace(), getData().getPublisher(), isPretend()); getImporterUtil().processPublisher(publication, getData().getPlace(), getData().getPublisher(), isPretend());
}
return publication; return publication;
} }
@ -96,4 +98,5 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
} }
} }
} }
} }

View File

@ -69,6 +69,7 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
} }
private void processPagesTo(final ArticleInCollectedVolume publication) { private void processPagesTo(final ArticleInCollectedVolume publication) {
if ((getData().getPageFrom() != null) && !getData().getPageFrom().isEmpty()) {
try { try {
final int pagesTo = Integer.parseInt(getData().getPageTo()); final int pagesTo = Integer.parseInt(getData().getPageTo());
if (!isPretend()) { if (!isPretend()) {
@ -80,6 +81,7 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
getData().getLineNumber())); getData().getLineNumber()));
} }
} }
}
@Override @Override
protected ArticleInCollectedVolume createPublication() { protected ArticleInCollectedVolume createPublication() {

View File

@ -98,28 +98,28 @@ public class PublicationsImporter implements SciPublicationsImporter {
final Session session = SessionManager.getSession(); final Session session = SessionManager.getSession();
final TransactionContext tctx = session.getTransactionContext(); final TransactionContext tctx = session.getTransactionContext();
System.out.printf("Import publications...\n");
int lineNumber = 2; //Because we are starting at line 2 of the CSV file (line 1 contains the column headers)
for (String line : lines) {
tctx.beginTxn(); tctx.beginTxn();
try { try {
int lineNumber = 2; //Because we are starting at line 2 of the CSV file (line 1 contains the column headers) System.out.printf("Processing publication %d...\n", lineNumber);
for (String line : lines) {
final PublicationImportReport result = importPublication(line, final PublicationImportReport result = importPublication(line,
lineNumber, lineNumber,
publishNewItems, publishNewItems,
pretend, pretend,
importerUtil); importerUtil);
report.addPublication(result); report.addPublication(result);
lineNumber++;
}
} catch (Exception ex) { } catch (Exception ex) {
tctx.abortTxn(); tctx.abortTxn();
throw new SciPublicationsImportException(ex); throw new SciPublicationsImportException(ex);
} }
if (pretend) {
tctx.abortTxn();
} else {
tctx.commitTxn(); tctx.commitTxn();
lineNumber++;
} }
return report; return report;