Aktuller Stand CSV Importer für Publikationen
git-svn-id: https://svn.libreccm.org/ccm/trunk@1932 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
20dc430d32
commit
6498c02337
|
|
@ -6,9 +6,6 @@ import com.arsdigita.bebop.FormProcessException;
|
|||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
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.parameters.DateParameter;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
|
|
@ -18,28 +15,23 @@ import com.arsdigita.cms.ContentItem;
|
|||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentTypeCollection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||
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.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||
import com.arsdigita.cms.ui.authoring.LanguageWidget;
|
||||
import com.arsdigita.cms.ui.authoring.PageCreate;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
|
|
@ -50,11 +42,9 @@ import java.util.TooManyListenersException;
|
|||
*/
|
||||
public class PublicPersonalProfileCreate extends PageCreate {
|
||||
|
||||
private static final String SELECTED_PERSON = "selectedPerson";
|
||||
private static final PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfiles.
|
||||
getConfig();
|
||||
|
||||
//private static final String SELECTED_PERSON = "selectedPerson";
|
||||
//private static final PublicPersonalProfileConfig config =
|
||||
// PublicPersonalProfiles. getConfig();
|
||||
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
super(itemModel, parent);
|
||||
|
|
@ -64,7 +54,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
public void addWidgets() {
|
||||
//super.addWidgets();
|
||||
|
||||
ContentType type = getItemSelectionModel().getContentType();
|
||||
final ContentType type = getItemSelectionModel().getContentType();
|
||||
m_workflowSection = new ApplyWorkflowFormSection(type);
|
||||
add(m_workflowSection, ColumnPanel.INSERT);
|
||||
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 LanguageWidget(LANGUAGE));
|
||||
|
||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||
"publicpersonalprofile.ui.create.select_person")));
|
||||
ParameterModel ownerModel =
|
||||
new StringParameter(PublicPersonalProfileBundle.OWNER);
|
||||
SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.create.select_person")));
|
||||
final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
|
||||
final SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||
|
||||
try {
|
||||
ownerSelect.addPrintListener(new PrintListener() {
|
||||
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect ownerSelect = (SingleSelect) event.
|
||||
getTarget();
|
||||
|
||||
String personType = config.getPersonType();
|
||||
if ((personType == null) || (personType.isEmpty())) {
|
||||
personType =
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
}
|
||||
|
||||
ContentTypeCollection types =
|
||||
ContentType.getAllContentTypes();
|
||||
types.addFilter(
|
||||
String.format("className = '%s'", personType));
|
||||
if (types.size() == 0) {
|
||||
personType =
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
}
|
||||
DataCollection persons = SessionManager.getSession().
|
||||
retrieve(
|
||||
personType);
|
||||
//persons.addFilter("profile is null");
|
||||
persons.addFilter(String.format("version = '%s'",
|
||||
ContentItem.DRAFT));
|
||||
persons.addOrder("surname asc");
|
||||
persons.addOrder("givenname asc");
|
||||
persons.addOrder("language asc");
|
||||
ownerSelect.addOption(new Option("", ""));
|
||||
|
||||
//Store the parent ids of processed items to remove double entries.
|
||||
final List<BigDecimal> processed =
|
||||
new ArrayList<BigDecimal>();
|
||||
while (persons.next()) {
|
||||
GenericPerson person =
|
||||
(GenericPerson) DomainObjectFactory.
|
||||
newInstance(persons.getDataObject());
|
||||
if (processed.contains(person.getParent().getID())) {
|
||||
continue;
|
||||
} else {
|
||||
if (person.getGenericPersonBundle().get("profile")
|
||||
== null) {
|
||||
continue;
|
||||
} else {
|
||||
ownerSelect.addOption(new Option(
|
||||
person.getID().toString(),
|
||||
String.format("%s (%s)",
|
||||
person.getFullName(),
|
||||
person.getLanguage())));
|
||||
processed.add(person.getParent().getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
ownerSelect.addPrintListener(new PPPOwnerSelectPrintListener());
|
||||
// ownerSelect.addPrintListener(new PrintListener() {
|
||||
//
|
||||
// public void prepare(final PrintEvent event) {
|
||||
// final SingleSelect ownerSelect = (SingleSelect) event.
|
||||
// getTarget();
|
||||
//
|
||||
// String personType = config.getPersonType();
|
||||
// if ((personType == null) || (personType.isEmpty())) {
|
||||
// personType =
|
||||
// "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
// }
|
||||
//
|
||||
// ContentTypeCollection types =
|
||||
// ContentType.getAllContentTypes();
|
||||
// types.addFilter(
|
||||
// String.format("className = '%s'", personType));
|
||||
// if (types.size() == 0) {
|
||||
// personType =
|
||||
// "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
// }
|
||||
// DataCollection persons = SessionManager.getSession().
|
||||
// retrieve(
|
||||
// personType);
|
||||
// //persons.addFilter("profile is null");
|
||||
// persons.addFilter(String.format("version = '%s'",
|
||||
// ContentItem.DRAFT));
|
||||
// persons.addOrder("surname asc");
|
||||
// persons.addOrder("givenname asc");
|
||||
// persons.addOrder("language asc");
|
||||
// ownerSelect.addOption(new Option("", ""));
|
||||
//
|
||||
// //Store the parent ids of processed items to remove double entries.
|
||||
// final List<BigDecimal> processed =
|
||||
// new ArrayList<BigDecimal>();
|
||||
// while (persons.next()) {
|
||||
// GenericPerson person =
|
||||
// (GenericPerson) DomainObjectFactory.
|
||||
// newInstance(persons.getDataObject());
|
||||
// if (processed.contains(person.getParent().getID())) {
|
||||
// continue;
|
||||
// } else {
|
||||
// if (person.getGenericPersonBundle().get("profile")
|
||||
// == null) {
|
||||
// continue;
|
||||
// } else {
|
||||
// ownerSelect.addOption(new Option(
|
||||
// person.getID().toString(),
|
||||
// String.format("%s (%s)",
|
||||
// person.getFullName(),
|
||||
// person.getLanguage())));
|
||||
// processed.add(person.getParent().getID());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
|
@ -146,10 +135,8 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.page_launch_date")));
|
||||
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
||||
com.arsdigita.bebop.form.Date launchDate =
|
||||
new com.arsdigita.bebop.form.Date(
|
||||
launchDateParam);
|
||||
final ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
||||
final com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(launchDateParam);
|
||||
if (ContentSection.getConfig().getRequireLaunchDate()) {
|
||||
launchDate.addValidationListener(
|
||||
new LaunchDateValidationListener());
|
||||
|
|
@ -163,32 +150,30 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
/**
|
||||
* 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
|
||||
* to access things which on existing yet.
|
||||
* to access properties which are not set yet.
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
@Override
|
||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||
Folder folder = m_parent.getFolder(fse.getPageState());
|
||||
public void validate(final FormSectionEvent fse) throws FormProcessException {
|
||||
final Folder folder = m_parent.getFolder(fse.getPageState());
|
||||
Assert.exists(folder);
|
||||
String id = (String) fse.getFormData().get(
|
||||
PublicPersonalProfileBundle.OWNER);
|
||||
final String personId = (String) fse.getFormData().get(PublicPersonalProfileBundle.OWNER);
|
||||
|
||||
if ((id == null) || id.trim().isEmpty()) {
|
||||
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.
|
||||
globalize("publicpersonalprofile.ui.person.required"));
|
||||
if ((personId == null) || personId.trim().isEmpty()) {
|
||||
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||
"publicpersonalprofile.ui.person.required"));
|
||||
return;
|
||||
}
|
||||
|
||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||
final GenericPerson owner = new GenericPerson(new BigDecimal(personId));
|
||||
|
||||
validateNameUniqueness(folder,
|
||||
fse,
|
||||
String.format("%s-profile",
|
||||
GenericPerson.urlSave(
|
||||
owner.getFullName())));
|
||||
validateNameUniqueness(folder, fse, String.format("%s-profile",
|
||||
GenericPerson.urlSave(owner.getFullName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final ContentSection section = m_parent.getContentSection(state);
|
||||
|
|
@ -196,13 +181,12 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
|
||||
Assert.exists(section, ContentSection.class);
|
||||
|
||||
String id = (String) fse.getFormData().get(
|
||||
PublicPersonalProfileBundle.OWNER);
|
||||
final String personId = (String) fse.getFormData().get(PublicPersonalProfileBundle.OWNER);
|
||||
|
||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||
String name = String.format("%s-profile",
|
||||
final GenericPerson owner = new GenericPerson(new BigDecimal(personId));
|
||||
final String name = String.format("%s-profile",
|
||||
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);
|
||||
item.setLanguage((String) data.get(LANGUAGE));
|
||||
|
|
@ -219,9 +203,8 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
|
||||
m_workflowSection.applyWorkflow(state, item);
|
||||
|
||||
PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
|
||||
final PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
|
||||
profile.setOwner(owner);
|
||||
//profile.setProfileUrl(owner.getSurname().toLowerCase());
|
||||
profile.setProfileUrl(createProfileUrl(owner));
|
||||
profile.save();
|
||||
|
||||
|
|
@ -230,27 +213,23 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
|
||||
private String createProfileUrl(final GenericPerson owner) {
|
||||
String profileUrl = owner.getSurname().toLowerCase();
|
||||
int i = 1;
|
||||
int counter = 1;
|
||||
|
||||
DataCollection profiles = SessionManager.getSession().retrieve(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
profileUrl));
|
||||
final DataCollection profiles = SessionManager.getSession().
|
||||
retrieve(PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'", profileUrl));
|
||||
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||
|
||||
while (profiles.size() > 0) {
|
||||
i++;
|
||||
counter++;
|
||||
|
||||
profileUrl = String.format("%s%d",
|
||||
owner.getSurname().toLowerCase(),
|
||||
i);
|
||||
profileUrl = String.format("%s%d", owner.getSurname().toLowerCase(), counter);
|
||||
profiles.reset();
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
profileUrl));
|
||||
profiles.addFilter(
|
||||
String.format("version = '%s'", ContentItem.DRAFT));
|
||||
profiles.addFilter(String.format("profileUrl = '%s'", profileUrl));
|
||||
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||
}
|
||||
|
||||
return GenericPerson.urlSave(profileUrl).toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,34 +3,42 @@ package com.arsdigita.cms.contenttypes.ui;
|
|||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
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.StringParameter;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileBundle;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
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
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfilePropertyForm
|
||||
extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
public class PublicPersonalProfilePropertyForm extends BasicPageForm implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormValidationListener {
|
||||
|
||||
private PublicPersonalProfilePropertiesStep step;
|
||||
//private PublicPersonalProfilePropertiesStep step;
|
||||
public static final String ID = "PublicPersonalProfile_edit";
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
|
|
@ -38,11 +46,10 @@ public class PublicPersonalProfilePropertyForm
|
|||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public PublicPersonalProfilePropertyForm(
|
||||
ItemSelectionModel itemModel,
|
||||
PublicPersonalProfilePropertiesStep step) {
|
||||
public PublicPersonalProfilePropertyForm(final ItemSelectionModel itemModel,
|
||||
final PublicPersonalProfilePropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
this.step = step;
|
||||
//this.step = step;
|
||||
this.itemModel = itemModel;
|
||||
addValidationListener(this);
|
||||
}
|
||||
|
|
@ -51,53 +58,64 @@ public class PublicPersonalProfilePropertyForm
|
|||
public void addWidgets() {
|
||||
super.addWidgets();
|
||||
|
||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||
"publicpersonalprofile.ui.profile.url")));
|
||||
ParameterModel profileUrlParam =
|
||||
new StringParameter(PublicPersonalProfile.PROFILE_URL);
|
||||
TextField profileUrl = new TextField(profileUrlParam);
|
||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.create.select_person")));
|
||||
final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER);
|
||||
final SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
final PageState state = fse.getPageState();
|
||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||
//final PageState state = fse.getPageState();
|
||||
final FormData data = fse.getFormData();
|
||||
final PublicPersonalProfile profile =
|
||||
(PublicPersonalProfile) super.
|
||||
initBasicWidgets(fse);
|
||||
final PublicPersonalProfile profile = (PublicPersonalProfile) super.initBasicWidgets(fse);
|
||||
|
||||
data.put(PublicPersonalProfile.PROFILE_URL, profile.getProfileUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
final PublicPersonalProfile profile =
|
||||
(PublicPersonalProfile) processBasicWidgets(
|
||||
fse);
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final PublicPersonalProfile profile = (PublicPersonalProfile) processBasicWidgets(fse);
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
|
||||
if ((profile != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
profile.setProfileUrl(((String) data.get(
|
||||
PublicPersonalProfile.PROFILE_URL)).
|
||||
toLowerCase());
|
||||
if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
|
||||
final String ownerId = (String)data.get(PublicPersonalProfileBundle.OWNER);
|
||||
if (!profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
|
||||
|
||||
}
|
||||
|
||||
profile.setProfileUrl(((String) data.get(PublicPersonalProfile.PROFILE_URL)).toLowerCase());
|
||||
|
||||
profile.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||
public void validate(final FormSectionEvent fse) throws FormProcessException {
|
||||
super.validate(fse);
|
||||
|
||||
final PageState state = fse.getPageState();
|
||||
final FormData data = fse.getFormData();
|
||||
|
||||
|
||||
String profilesUrl =
|
||||
(String) data.get(PublicPersonalProfile.PROFILE_URL);
|
||||
final String profilesUrl = (String) data.get(PublicPersonalProfile.PROFILE_URL);
|
||||
if ((profilesUrl == null) || profilesUrl.isEmpty()) {
|
||||
data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||
"publicpersonalprofile.ui.profile_url.required"));
|
||||
|
|
@ -108,11 +126,9 @@ public class PublicPersonalProfilePropertyForm
|
|||
"publicpersonalprofile.ui.profile_url.reserved"));
|
||||
}
|
||||
|
||||
DataCollection profiles = SessionManager.getSession().retrieve(
|
||||
final DataCollection profiles = SessionManager.getSession().retrieve(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
((String) data.get(
|
||||
PublicPersonalProfile.PROFILE_URL)).
|
||||
profiles.addFilter(String.format("profileUrl = '%s'", ((String) data.get(PublicPersonalProfile.PROFILE_URL)).
|
||||
toLowerCase()));
|
||||
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||
if (profiles.size() > 1) {
|
||||
|
|
@ -120,9 +136,8 @@ public class PublicPersonalProfilePropertyForm
|
|||
"publicpersonalprofile.ui.profile_url.already_in_use"));
|
||||
} else if (profiles.size() == 1) {
|
||||
profiles.next();
|
||||
PublicPersonalProfile profile =
|
||||
(PublicPersonalProfile) DomainObjectFactory.
|
||||
newInstance(profiles.getDataObject());
|
||||
final PublicPersonalProfile profile = (PublicPersonalProfile) DomainObjectFactory.newInstance(profiles.
|
||||
getDataObject());
|
||||
|
||||
if (!(profile.getID().equals(
|
||||
itemModel.getSelectedItem(state).getID()))) {
|
||||
|
|
@ -131,4 +146,5 @@ public class PublicPersonalProfilePropertyForm
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,9 +347,12 @@ public class Publication extends ContentPage {
|
|||
|
||||
@Override
|
||||
public String getSearchSummary() {
|
||||
return String.format("%s %s %s",
|
||||
getTitle(),
|
||||
getAuthors(),
|
||||
getAbstract());
|
||||
String summary = String.format("%s %s %s", getTitle(), getAuthors(), getAbstract());
|
||||
if (summary.length() > 4000) {
|
||||
summary = summary.substring(0, 4000);
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,21 +60,23 @@ public class CollectedVolumeImportReport {
|
|||
final StringWriter strWriter = new StringWriter();
|
||||
final PrintWriter writer = new PrintWriter(strWriter);
|
||||
|
||||
for(int i = 0; i < 40; i++) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
writer.append("\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) {
|
||||
for (AuthorImportReport author : authors) {
|
||||
writer.printf("%s\n", author.toString());
|
||||
}
|
||||
|
||||
if (publisher != null) {
|
||||
writer.append(publisher.toString());
|
||||
}
|
||||
writer.append('\n');
|
||||
|
||||
for(int i = 0; i < 40; i++) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
writer.append("- ");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,9 @@ public class ImporterUtil {
|
|||
report.addAuthor(processAuthor(collectedVolume, author, pretend));
|
||||
}
|
||||
|
||||
if ((publisherName != null) && !publisherName.isEmpty()) {
|
||||
report.setPublisher(processPublisher(collectedVolume, place, publisherName, pretend));
|
||||
}
|
||||
|
||||
collectedVolume.save();
|
||||
article.setCollectedVolume(collectedVolume);
|
||||
|
|
@ -330,7 +332,9 @@ public class ImporterUtil {
|
|||
report.addAuthor(processAuthor(proceedings, author, pretend));
|
||||
}
|
||||
|
||||
if ((publisherName != null) && !publisherName.isEmpty()) {
|
||||
report.setPublisher(processPublisher(proceedings, place, publisherName, pretend));
|
||||
}
|
||||
|
||||
proceedings.save();
|
||||
inProceedings.setProceedings(proceedings);
|
||||
|
|
@ -466,6 +470,8 @@ public class ImporterUtil {
|
|||
if (publish) {
|
||||
publishItem(orga);
|
||||
}
|
||||
|
||||
report.setType(orga.getClass().getName());
|
||||
}
|
||||
|
||||
report.setCreated(true);
|
||||
|
|
@ -477,11 +483,12 @@ public class ImporterUtil {
|
|||
createdOrgas.add(name);
|
||||
}
|
||||
} else {
|
||||
if (!pretend) {
|
||||
collection.next();
|
||||
final GenericOrganizationalUnit orga = new GenericOrganizationalUnit(collection.getDataObject());
|
||||
if (!pretend) {
|
||||
publication.setOrganization(orga);
|
||||
}
|
||||
report.setType(orga.getClass().getName());
|
||||
report.setCreated(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,21 +127,23 @@ abstract class AbstractPublicationImporter<T extends Publication> {
|
|||
|
||||
bundle.save();
|
||||
|
||||
if (data.getAbstract().length() < 4096) {
|
||||
if (data.getAbstract().length() < 3975) {
|
||||
publication.setAbstract(data.getAbstract());
|
||||
} 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());
|
||||
} else {
|
||||
publication.setMisc(data.getMisc().substring(0, 4096));
|
||||
publication.setMisc(data.getMisc().substring(0, 3975));
|
||||
}
|
||||
|
||||
publication.save();
|
||||
}
|
||||
|
||||
if ((data.getAuthors() != null) && !data.getAuthors().isEmpty()) {
|
||||
processAuthors(publication);
|
||||
}
|
||||
|
||||
return publication;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
|
|||
getReport().addField(new FieldImportReport("edition", data.getEdition()));
|
||||
}
|
||||
|
||||
if ((data.getPublisher() != null) && !data.getPublisher().isEmpty()) {
|
||||
getImporterUtil().processPublisher(publication, getData().getPlace(), getData().getPublisher(), isPretend());
|
||||
}
|
||||
|
||||
return publication;
|
||||
}
|
||||
|
|
@ -96,4 +98,5 @@ abstract class AbstractPublicationWithPublisherImporter<T extends PublicationWit
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
|
|||
}
|
||||
|
||||
private void processPagesTo(final ArticleInCollectedVolume publication) {
|
||||
if ((getData().getPageFrom() != null) && !getData().getPageFrom().isEmpty()) {
|
||||
try {
|
||||
final int pagesTo = Integer.parseInt(getData().getPageTo());
|
||||
if (!isPretend()) {
|
||||
|
|
@ -80,6 +81,7 @@ class ArticleInCollectedVolumeImporter extends AbstractPublicationImporter<Artic
|
|||
getData().getLineNumber()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArticleInCollectedVolume createPublication() {
|
||||
|
|
|
|||
|
|
@ -98,28 +98,28 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
|
||||
final Session session = SessionManager.getSession();
|
||||
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();
|
||||
|
||||
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) {
|
||||
System.out.printf("Processing publication %d...\n", lineNumber);
|
||||
final PublicationImportReport result = importPublication(line,
|
||||
lineNumber,
|
||||
publishNewItems,
|
||||
pretend,
|
||||
importerUtil);
|
||||
report.addPublication(result);
|
||||
lineNumber++;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
tctx.abortTxn();
|
||||
throw new SciPublicationsImportException(ex);
|
||||
}
|
||||
|
||||
if (pretend) {
|
||||
tctx.abortTxn();
|
||||
} else {
|
||||
tctx.commitTxn();
|
||||
|
||||
lineNumber++;
|
||||
}
|
||||
|
||||
return report;
|
||||
|
|
@ -163,7 +163,7 @@ public class PublicationsImporter implements SciPublicationsImporter {
|
|||
processProceedings(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (Review.class.getSimpleName().equals(data.getType())) {
|
||||
processReview(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if(ResearchReport.class.getSimpleName().equals(data.getType()) || "Report".equals(data.getType())) {
|
||||
} else if (ResearchReport.class.getSimpleName().equals(data.getType()) || "Report".equals(data.getType())) {
|
||||
processResearchReport(publishNewItems, data, report, pretend, importerUtil);
|
||||
} else if (WorkingPaper.class.getSimpleName().equals(data.getType())) {
|
||||
processWorkingPaper(publishNewItems, data, report, pretend, importerUtil);
|
||||
|
|
|
|||
Loading…
Reference in New Issue