Erste Check-In für den ContentGenerator für eine Liste der eigenen Publikationen auf der persönlichen Homepage. Unterstützt die Gruppierung der Publikationen in Gruppen, über Konfiguration ist einstellbar welcher Publikationstyp
zu welcher Gruppe gehören soll. Das ganze ist als eigenes Modul augeführt, mit Abhängigkeit von ccm-cms-publicationpersonalprofile und ccm-sci-publications. Achtung: Implementierung noch nicht abgeschlossen, derzeit erfolgt noch keine Ausgabe. git-svn-id: https://svn.libreccm.org/ccm/trunk@1123 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e21b192ba1
commit
516c7b1250
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||
name="ccm-sci-personalpublications"
|
||||
prettyName="OpenCCM PublicPersonalProfile Content generator"
|
||||
version="6.6.1"
|
||||
release="1"
|
||||
webapp="ROOT">
|
||||
<ccm:dependencies>
|
||||
<ccm:requires name="ccm-core" version="6.6.0" release="ge"/>
|
||||
<ccm:requires name="ccm-cms" version="6.6.0" release="ge"/>
|
||||
<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:directory name="src"/>
|
||||
</ccm:directories>
|
||||
<ccm:contacts>
|
||||
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
|
||||
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
|
||||
</ccm:contacts>
|
||||
<ccm:description>
|
||||
Content generator creating a list of the publications of a person.
|
||||
</ccm:description>
|
||||
</ccm:application>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<registry>
|
||||
<config class="com.arsdigita.cms.publicpersonalprofile.PersonalPublicationsConfig"
|
||||
storage="ccm-sci-personalpublications/personalpublications.properties/>"
|
||||
</registry>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<load>
|
||||
<requires>
|
||||
<table name="inits"/>
|
||||
<table name="acs_objects"/>
|
||||
<table name="cms_items"/>
|
||||
<table name="ct_publications"/>
|
||||
<table name="publicpersonalprofile"/>
|
||||
<table name="ct_public_personal_profiles"/>
|
||||
<initalizer class="com.arsdigita.cms.Initializer"/>
|
||||
<initalizer class="com.arsdigita.cms.contenttypes.PublicationInitalizer"/>
|
||||
<initalizer class="com.arsdigita.cms.scipublications.SciPublicationsInitalizer"/>
|
||||
<initalizer class="com.arsdigita.cms.contenttypes.PublicPersonalProfileInitalizer"/>
|
||||
<initalizer class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfilesInitalizer"/>
|
||||
</requires>
|
||||
<provides>
|
||||
<initalizer class="com.arsdigita.cms.publicpersonalprofile.PersonalPublicationsInitalizer"/>
|
||||
</provides>
|
||||
</load>
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PersonalPublications implements ContentGenerator {
|
||||
|
||||
private final static String MISC = "misc";
|
||||
private final static PersonalPublicationsConfig config =
|
||||
new PersonalPublicationsConfig();
|
||||
private final static Logger logger = Logger.getLogger(
|
||||
PersonalPublications.class);
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void generateContent(final Element parent,
|
||||
final GenericPerson person) {
|
||||
DataCollection publications = (DataCollection) person.get("publication");
|
||||
|
||||
if ((publications == null) || publications.size() == 0) {
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
publicationsElem.newChildElement("noPublications");
|
||||
|
||||
return;
|
||||
} else {
|
||||
final Map<String, List<Publication>> groupedPublications =
|
||||
processPublications(
|
||||
publications);
|
||||
|
||||
generateGroupsXml(parent, groupedPublications);
|
||||
generatePublicationsXml(parent, groupedPublications);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the publications and puts them into the groups.
|
||||
*
|
||||
* @param publications The publications to process
|
||||
* @param typeGroupMap The group-type map
|
||||
* @return A map with the group names as keys and a list of publications
|
||||
* as value.
|
||||
*/
|
||||
private Map<String, List<Publication>> processPublications(
|
||||
final DataCollection publications) {
|
||||
|
||||
final GroupConfig groupConfig = new GroupConfig(config.
|
||||
getPublictionGroups());
|
||||
final Map<String, List<Publication>> pubGroups =
|
||||
new LinkedHashMap<String, List<Publication>>();
|
||||
|
||||
for (String group : groupConfig.getGroups()) {
|
||||
initalizePubGroupMap(pubGroups, group);
|
||||
}
|
||||
initalizePubGroupMap(pubGroups, MISC);
|
||||
|
||||
DataObject dobj;
|
||||
Publication publication;
|
||||
String type;
|
||||
String groupName;
|
||||
Boolean reviewed;
|
||||
List<Publication> group;
|
||||
while (publications.next()) {
|
||||
dobj = publications.getDataObject();
|
||||
publication = (Publication) DomainObjectFactory.newInstance(dobj);
|
||||
type = publication.getClass().getName();
|
||||
|
||||
if (dobj.getObjectType().hasProperty("reviewed")) {
|
||||
reviewed = (Boolean) dobj.get("reviewed");
|
||||
if (reviewed) {
|
||||
groupName = groupConfig.getTypeGroupMap().get(String.format(
|
||||
"%s_ref", type));
|
||||
} else {
|
||||
groupName = groupConfig.getTypeGroupMap().get(String.format(
|
||||
"%s_noref", type));
|
||||
}
|
||||
|
||||
if (groupName == null) {
|
||||
groupName = groupConfig.getTypeGroupMap().get(type);
|
||||
}
|
||||
} else {
|
||||
groupName = groupConfig.getTypeGroupMap().get(type);
|
||||
}
|
||||
|
||||
if (groupName == null) {
|
||||
groupName = MISC;
|
||||
}
|
||||
|
||||
group = pubGroups.get(groupName);
|
||||
group.add(publication);
|
||||
}
|
||||
|
||||
final PublicationGroupComparator comparator =
|
||||
new PublicationGroupComparator();
|
||||
for (List<Publication> currentGroup : pubGroups.values()) {
|
||||
Collections.sort(currentGroup, comparator);
|
||||
}
|
||||
|
||||
return pubGroups;
|
||||
}
|
||||
|
||||
private void initalizePubGroupMap(
|
||||
final Map<String, List<Publication>> pubGroups,
|
||||
final String groupName) {
|
||||
pubGroups.put(groupName, new ArrayList<Publication>());
|
||||
}
|
||||
|
||||
private void generateGroupsXml(final Element parent,
|
||||
final Map<String, List<Publication>> publications) {
|
||||
}
|
||||
|
||||
private void generatePublicationsXml(final Element parent,
|
||||
final Map<String, List<Publication>> publications) {
|
||||
}
|
||||
|
||||
private void generatePublicationXml(final Element publicationsElem,
|
||||
final Publication publication) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the publications and puts them into the groups.
|
||||
*
|
||||
* @param publications The publications to process
|
||||
* @param typeGroupMap The group-type map
|
||||
* @return A map with the group names as keys and a list of publications
|
||||
* as value.
|
||||
*/
|
||||
private class GroupConfig {
|
||||
|
||||
private final Map<String, String> typeGroupMap =
|
||||
new HashMap<String, String>();
|
||||
private final List<String> groups = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Processes the configuration string and puts the result into the
|
||||
* collections.
|
||||
*
|
||||
* @param groupStr
|
||||
*/
|
||||
public GroupConfig(final String groupStr) {
|
||||
final String[] groupTokens = groupStr.split(";");
|
||||
String[] groupTokenSplit;
|
||||
String groupName;
|
||||
String publicationTypeTokens;
|
||||
String[] publicationTypeTokensSplit;
|
||||
List<String> types;
|
||||
for (String groupToken : groupTokens) {
|
||||
groupTokenSplit = groupToken.split(":");
|
||||
if (groupTokenSplit.length != 2) {
|
||||
logger.debug(String.format(
|
||||
"Invalid entry in publication group config: '%s'. "
|
||||
+ "Ignoring.",
|
||||
groupToken));
|
||||
continue;
|
||||
}
|
||||
|
||||
groupName = groupTokenSplit[0];
|
||||
groups.add(groupName);
|
||||
publicationTypeTokens = groupTokenSplit[1];
|
||||
publicationTypeTokensSplit = publicationTypeTokens.split(",");
|
||||
for (String publicationTypeToken : publicationTypeTokensSplit) {
|
||||
typeGroupMap.put(publicationTypeToken, groupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getTypeGroupMap() {
|
||||
return Collections.unmodifiableMap(typeGroupMap);
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
return Collections.unmodifiableList(groups);
|
||||
}
|
||||
}
|
||||
|
||||
private class PublicationGroupComparator implements Comparator<Publication> {
|
||||
|
||||
public int compare(final Publication publication1,
|
||||
final Publication publication2) {
|
||||
AuthorshipCollection authors1;
|
||||
AuthorshipCollection authors2;
|
||||
GenericPerson author;
|
||||
String authorsStr1;
|
||||
String authorsStr2;
|
||||
final StringBuffer authors1Buffer = new StringBuffer();
|
||||
final StringBuffer authors2Buffer = new StringBuffer();
|
||||
|
||||
authors1 = publication1.getAuthors();
|
||||
while (authors1.next()) {
|
||||
author = authors1.getAuthor();
|
||||
authors1Buffer.append(author.getSurname());
|
||||
authors1Buffer.append(author.getGivenName());
|
||||
}
|
||||
authors2 = publication2.getAuthors();
|
||||
while (authors2.next()) {
|
||||
author = authors1.getAuthor();
|
||||
authors2Buffer.append(author.getSurname());
|
||||
authors2Buffer.append(author.getGivenName());
|
||||
}
|
||||
|
||||
authorsStr1 = authors1Buffer.toString();
|
||||
authorsStr2 = authors2Buffer.toString();
|
||||
|
||||
return authorsStr1.compareTo(authorsStr2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.runtime.AbstractConfig;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.StringParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PersonalPublicationsConfig extends AbstractConfig {
|
||||
|
||||
/**
|
||||
* Groups of publications. See {@link PersonalPublications} for a detailed
|
||||
* explanation.
|
||||
*/
|
||||
private final Parameter publicationGroups;
|
||||
|
||||
public PersonalPublicationsConfig() {
|
||||
publicationGroups =
|
||||
new StringParameter(
|
||||
"com.arsdigita.cms.publicpersonalprofile.publications.groups",
|
||||
Parameter.REQUIRED,
|
||||
"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");
|
||||
|
||||
register(publicationGroups);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
public final String getPublictionGroups() {
|
||||
return (String) get(publicationGroups);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
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]
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.db.DbHelper;
|
||||
import com.arsdigita.persistence.pdl.ManifestSource;
|
||||
import com.arsdigita.persistence.pdl.NameFilter;
|
||||
import com.arsdigita.runtime.CompoundInitializer;
|
||||
import com.arsdigita.runtime.DomainInitEvent;
|
||||
import com.arsdigita.runtime.PDLInitializer;
|
||||
import com.arsdigita.runtime.RuntimeConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PersonalPublicationsInitializer extends CompoundInitializer {
|
||||
|
||||
public PersonalPublicationsInitializer() {
|
||||
|
||||
final String jdbcUrl = RuntimeConfig.getConfig().getJDBCURL();
|
||||
final int database = DbHelper.getDatabaseFromURL(jdbcUrl);
|
||||
|
||||
add(new PDLInitializer(new ManifestSource("empty.pdl.mf",
|
||||
new NameFilter(DbHelper.
|
||||
getDatabaseSuffix(database), "pdl"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final DomainInitEvent event) {
|
||||
super.init(event);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.loader.PackageLoader;
|
||||
import com.arsdigita.runtime.ScriptContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PersonalPublicationsLoader extends PackageLoader {
|
||||
|
||||
@Override
|
||||
public void run(final ScriptContext ctx) {
|
||||
//Nothing to do.
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue