- Publikationslisten-Generator für persönliche Profile: Funktioniert soweit, Unterstützung in Mandalay fehlt noch

- Einige kleinere Bug-Fixes und Formatierungen


git-svn-id: https://svn.libreccm.org/ccm/trunk@1127 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-10-01 18:17:04 +00:00
parent d7752138dc
commit b6f6ad9127
11 changed files with 174 additions and 31 deletions

View File

@ -77,8 +77,9 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
final ContentGenerator generator =
(ContentGenerator) generatorObj;
generator.generateContent(profileContent, profile.
getOwner());
generator.generateContent(profileContent,
profile.getOwner(),
state);
} else {
throw new UncheckedWrapperException(String.format(

View File

@ -1,5 +1,6 @@
package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.xml.Element;
@ -10,6 +11,6 @@ import com.arsdigita.xml.Element;
*/
public interface ContentGenerator {
void generateContent(Element parent, GenericPerson person);
void generateContent(Element parent, GenericPerson person, PageState state);
}

View File

@ -1,5 +1,6 @@
package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.xml.Element;
@ -12,7 +13,8 @@ import com.arsdigita.xml.Element;
public class ExampleGenerator implements ContentGenerator {
public void generateContent(final Element parent,
final GenericPerson person) {
final GenericPerson person,
final PageState state) {
Element message = parent.newChildElement("message");
message.setText("Hello World!");

View File

@ -37,7 +37,6 @@ import com.arsdigita.xml.Element;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.rmi.ServerException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -179,10 +178,11 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
Element profileOwnerName = profileElem.newChildElement(
"ppp:ownerName", PPP_NS);
profileOwnerName.setText(owner.getFullName());
final PublicPersonalProfileXmlUtil util =
new PublicPersonalProfileXmlUtil();
String prefix = DispatcherHelper.getDispatcherPrefix(request);
String prefix =
DispatcherHelper.getDispatcherPrefix(request);
if (prefix == null) {
prefix = "";
}
@ -246,7 +246,9 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final ContentGenerator generator =
(ContentGenerator) generatorObj;
generator.generateContent(root, owner);
generator.generateContent(root,
owner,
state);
} else {
throw new ServletException(String.format(

View File

@ -1,6 +1,5 @@
package com.arsdigita.cms.contenttypes.ui.panels;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.xml.Element;
import java.util.Comparator;
@ -9,7 +8,7 @@ import java.util.Comparator;
* @param <T>
* @author Jens Pelzetter
*/
public class SortField<T extends ContentItem> {
public class SortField<T> {
private String label;
private Comparator<T> comparator;

View File

@ -11,9 +11,7 @@
<ccm:requires name="ccm-cms-publicpersonalprofile" version="6.6.0" release="ge"/>
<ccm:requires name="ccm-sci-publications" version="6.6.0" release="ge"/>
</ccm:dependencies>
<ccm:directories>
<ccm:directory name="pdl"/>
<ccm:directory name="sql"/>
<ccm:directories>
<ccm:directory name="src"/>
</ccm:directories>
<ccm:contacts>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry>
<config class="com.arsdigita.cms.publicpersonalprofile.PersonalPublicationsConfig"
storage="ccm-sci-personalpublications/personalpublications.properties/>"
storage="ccm-sci-personalpublications/personalpublications.properties"/>
</registry>

View File

@ -1,5 +1,6 @@
package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication;
@ -14,6 +15,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
@ -34,7 +36,8 @@ public class PersonalPublications implements ContentGenerator {
}
public void generateContent(final Element parent,
final GenericPerson person) {
final GenericPerson person,
final PageState state) {
DataCollection publications = (DataCollection) person.get("publication");
if ((publications == null) || publications.size() == 0) {
@ -47,9 +50,9 @@ public class PersonalPublications implements ContentGenerator {
final Map<String, List<Publication>> groupedPublications =
processPublications(
publications);
generateGroupsXml(parent, groupedPublications);
generatePublicationsXml(parent, groupedPublications);
generatePublicationsXml(parent, groupedPublications, state);
}
}
@ -127,14 +130,102 @@ public class PersonalPublications implements ContentGenerator {
private void generateGroupsXml(final Element parent,
final Map<String, List<Publication>> publications) {
final Element availableGroups = parent.newChildElement(
"availablePublicationGroups");
for (Map.Entry<String, List<Publication>> entry :
publications.entrySet()) {
if (!entry.getValue().isEmpty()) {
createAvailablePublicationGroupXml(availableGroups,
entry.getKey());
}
}
}
private void generatePublicationsXml(final Element parent,
final Map<String, List<Publication>> publications) {
private void createAvailablePublicationGroupXml(final Element parent,
final String name) {
final Element group =
parent.newChildElement("availablePublicationGroup");
group.addAttribute("name", name);
}
private void generatePublicationXml(final Element publicationsElem,
final Publication publication) {
private void generatePublicationsXml(
final Element parent,
final Map<String, List<Publication>> publications,
final PageState state) {
final Element publicationsElem = parent.newChildElement("publications");
int numberOfPubs = 0;
int groupSplit = config.getGroupSplit();
for (List<Publication> list : publications.values()) {
numberOfPubs += list.size();
}
if (numberOfPubs < groupSplit) {
publicationsElem.addAttribute("all", "all");
for (Map.Entry<String, List<Publication>> entry : publications.
entrySet()) {
if (entry.getValue().size() > 0) {
generatePublicationGroupXml(publicationsElem,
entry.getKey(),
entry.getValue(),
state);
}
}
} else {
final HttpServletRequest request = state.getRequest();
final String[] defaultGroup = config.getDefaultGroup().split(",");
String groupToShow = request.getParameter("group");
if ((groupToShow == null)
|| groupToShow.isEmpty()
|| !(publications.containsKey(groupToShow))) {
int i = 0;
groupToShow = defaultGroup[i];
while ((publications.get(groupToShow).isEmpty())
&& i < defaultGroup.length) {
groupToShow = defaultGroup[i];
i++;
}
}
if (groupToShow == null) {
groupToShow = MISC;
}
generatePublicationGroupXml(publicationsElem,
groupToShow,
publications.get(groupToShow),
state);
}
}
private void generatePublicationGroupXml(final Element publicationsElem,
final String groupName,
final List<Publication> publications,
final PageState state) {
if (publications == null) {
return;
}
final Element groupElem = publicationsElem.newChildElement(
"publicationGroup");
groupElem.addAttribute("name", groupName);
for (Publication publication : publications) {
generatePublicationXml(groupElem, publication, state);
}
}
private void generatePublicationXml(final Element publicationGroupElem,
final Publication publication,
final PageState state) {
final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator(
publication);
generator.generateXML(state, publicationGroupElem, "");
}
/**
@ -167,7 +258,7 @@ public class PersonalPublications implements ContentGenerator {
for (String groupToken : groupTokens) {
groupTokenSplit = groupToken.split(":");
if (groupTokenSplit.length != 2) {
logger.debug(String.format(
logger.warn(String.format(
"Invalid entry in publication group config: '%s'. "
+ "Ignoring.",
groupToken));
@ -213,7 +304,7 @@ public class PersonalPublications implements ContentGenerator {
}
authors2 = publication2.getAuthors();
while (authors2.next()) {
author = authors1.getAuthor();
author = authors2.getAuthor();
authors2Buffer.append(author.getSurname());
authors2Buffer.append(author.getGivenName());
}

View File

@ -1,6 +1,7 @@
package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.IntegerParameter;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.StringParameter;
@ -16,6 +17,24 @@ public class PersonalPublicationsConfig extends AbstractConfig {
* explanation.
*/
private final Parameter publicationGroups;
/**
* If a person has more ({@code >=}) publications then this number, only one
* group of publications will be shown. If a person has less publications,
* all groups are shown.
*/
private final Parameter groupSplit;
/**
* The group of publications to show if no group has been requested or the
* requested group is invalid. The values of this parameter
* <strong>must be</strong> a group defined in the {@code publicationGroups}
* parameter. Otherwise, the {@link PersonalPublications} generator may
* crashes! The parameter accepts a comma separated list of groups which
* will used in order. If a person has no publications of the first group,
* the {@link PersonalPublications} generator will try the next entry in
* this list, then the third etc. The predefined group {@code misc} can also
* be used here.
*/
private final Parameter defaultGroup;
public PersonalPublicationsConfig() {
publicationGroups =
@ -25,15 +44,35 @@ public class PersonalPublicationsConfig extends AbstractConfig {
"monographs:com.arsdigita.cms.contenttypes.Monograph;"
+ "collectedVolumeArticles:com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;"
+ "journalArticles:com.arsdigita.cms.contenttypes.ArticleInJournal;"
+ "journalArticlesRef:com.arsdigita.cms.contenttypes.ArticleInJournal_ref"
+ "journalArticlesRef:com.arsdigita.cms.contenttypes.ArticleInJournal_ref;"
+ "collectedVolumes:com.arsdigita.cms.contenttypes.CollectedVolume");
groupSplit = new IntegerParameter(
"com.arsdigita.cms.publicpersonlprofile.publications.groupSplit",
Parameter.REQUIRED,
32);
defaultGroup = new StringParameter(
"com.arsdigita.cms.publicpersonalprofile.publications.defaultGroup",
Parameter.REQUIRED,
"monographs,journalArticlesRef,journalArticles,misc");
register(publicationGroups);
register(groupSplit);
register(defaultGroup);
loadInfo();
}
public final String getPublictionGroups() {
return (String) get(publicationGroups);
}
public final Integer getGroupSplit() {
return (Integer) get(groupSplit);
}
public final String getDefaultGroup() {
return (String) get(defaultGroup);
}
}

View File

@ -0,0 +1,14 @@
com.arsdigita.cms.publicpersonalprofile.publications.groups.title = Groups of publications
com.arsdigita.cms.publicpersonalprofile.publications.groups.purpose = Groups the publications of a person by their Type and optional the Property "Referenced". See the JavaDoc of com.arsdigita.cms.publicpersonalprofile.PersonalPublications for a detailed explanation of the syntax of this parameter
com.arsdigita.cms.publicpersonalprofile.publications.groups.example = monographs:com.arsdigita.cms.contenttypes.Monograph;collectedVolumeArticles:com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;journalArticles:com.arsdigita.cms.contenttypes.ArticleInJournal;journalArticlesRef:com.arsdigita.cms.contenttypes.ArticleInJournal_ref;collectedVolumes:com.arsdigita.cms.contenttypes.CollectedVolume
com.arsdigita.cms.publicpersonalprofile.publications.groups.format = [String]
com.arsdigita.cms.publicpersonlprofile.publications.groupSplit.title = Group Split
com.arsdigita.cms.publicpersonlprofile.publications.groupSplit.purpose = If a person has more ({@code >=}) publications then this number, only one group of publications will be shown. If a person has less publications, all groups are shown.
com.arsdigita.cms.publicpersonlprofile.publications.groupSplit.example = 32
com.arsdigita.cms.publicpersonlprofile.publications.groupSplit.format = [Integer]
com.arsdigita.cms.publicpersonlprofile.publications.defaultGroup.title = Default Group
com.arsdigita.cms.publicpersonlprofile.publications.defaultGroup.purpose = Default group to show
com.arsdigita.cms.publicpersonlprofile.publications.defaultGroup.example = monographs,journalArticlesRef,journalArticles,misc
com.arsdigita.cms.publicpersonlprofile.publications.defaultGroup.format = [String]

View File

@ -1,4 +0,0 @@
com.arsdigita.cms.publicpersonalprofile.publications.groups.title = Groups of publications
com.arsdigita.cms.publicpersonalprofile.publications.groups.purpose = Groups the publications of a person by their Type and optional the Property "Referenced". See the JavaDoc of com.arsdigita.cms.publicpersonalprofile.PersonalPublications for a detailed explanation of the syntax of this parameter
com.arsdigita.cms.publicpersonalprofile.publications.groups.example = monographs:com.arsdigita.cms.contenttypes.Monograph;collectedVolumeArticles:com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;journalArticles:com.arsdigita.cms.contenttypes.ArticleInJournal;journalArticlesRef:com.arsdigita.cms.contenttypes.ArticleInJournal_ref;collectedVolumes:com.arsdigita.cms.contenttypes.CollectedVolume
com.arsdigita.cms.publicpersonalprofile.publications.groups.format = [String]