- JavaDoc für SciPublications, SciPublicationsExporter und BibTeX Exporter (noch nicht komplett)

- RIS Exporter


git-svn-id: https://svn.libreccm.org/ccm/trunk@736 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-02-06 12:31:47 +00:00
parent fc02385f72
commit 14ab384925
44 changed files with 2034 additions and 69 deletions

View File

@ -1 +1,2 @@
com.arsdigita.cms.scipublications.exporter.bibtex.BibTeXExporter com.arsdigita.cms.scipublications.exporter.bibtex.BibTeXExporter
com.arsdigita.cms.scipublications.exporter.ris.RisExporter

View File

@ -0,0 +1,13 @@
com.arsdigita.cms.scipublications.exporter.ris.ArticleInCollectedVolumeConverter
com.arsdigita.cms.scipublications.exporter.ris.ArticleInJournalConverter
com.arsdigita.cms.scipublications.exporter.ris.CollectedVolumeConverter
com.arsdigita.cms.scipublications.exporter.ris.ExpertiseConverter
com.arsdigita.cms.scipublications.exporter.ris.GreyLiteratureConverter
com.arsdigita.cms.scipublications.exporter.ris.InProceedingsConverter
com.arsdigita.cms.scipublications.exporter.ris.InternetArticleConverter
com.arsdigita.cms.scipublications.exporter.ris.MonographConverter
com.arsdigita.cms.scipublications.exporter.ris.ProceedingsConverter
com.arsdigita.cms.scipublications.exporter.ris.PublicationConverter
com.arsdigita.cms.scipublications.exporter.ris.PublicationWithPublisherConverter
com.arsdigita.cms.scipublications.exporter.ris.ReviewConverter
com.arsdigita.cms.scipublications.exporter.ris.WorkingPaperConverter

View File

@ -1,3 +1,22 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications; package com.arsdigita.cms.scipublications;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
@ -7,18 +26,25 @@ import com.arsdigita.web.Application;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* This application provides the main entry point for all functions of
* the SciPublications module. The application will be mounted at
* <code>/ccm/scipubliations/</code>. The functions are accessed using
* an additional URL fragment. For example, if you want to access the
* export function, you will use the URL
* <code>/ccm/scipublications/export/</code>.
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class SciPublications extends Application { public class SciPublications extends Application {
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.scipublications.SciPublications"; public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.scipublications.SciPublications";
public SciPublications(DataObject dobj) { public SciPublications(DataObject dobj) {
super(dobj); super(dobj);
} }
public SciPublications(OID oid) throws DataObjectNotFoundException{ public SciPublications(OID oid) throws DataObjectNotFoundException {
super(oid); super(oid);
} }
@ -30,5 +56,4 @@ public class SciPublications extends Application {
public String getServletPath() { public String getServletPath() {
return "/scipublications/"; return "/scipublications/";
} }
} }

View File

@ -49,6 +49,7 @@ public class SciPublicationsLoader extends PackageLoader {
ApplicationType type = setup.run(); ApplicationType type = setup.run();
type.save(); type.save();
//Install the application and mount the app at 'scipublications'.
if (!Application.isInstalled( if (!Application.isInstalled(
SciPublications.BASE_DATA_OBJECT_TYPE, "/scipublications/")) { SciPublications.BASE_DATA_OBJECT_TYPE, "/scipublications/")) {
Application app = Application.createApplication(type, Application app = Application.createApplication(type,

View File

@ -1,6 +1,24 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications; package com.arsdigita.cms.scipublications;
import com.arsdigita.categorization.Categorization;
import com.arsdigita.categorization.CategorizedCollection; import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
@ -24,6 +42,43 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* <p>
* The <code>SciPublicationsServlet</code> processes the
* {@link HttpServletRequest} and calls the requested actions.
* The available actions are:
* </p>
* <dl>
* <dt><code>export</code></dt>
* <dd>
* <p>
* The <code>export</code> action exports content items of the type
* {@link Publication} in several formats, like <em>BibTeX</em> or <em>RIS</em>.
* The export action has the following query parameters:
* </p>
* <dl>
* <dt><code>format</code></dt>
* <dd>Specifies the format which is used to export the publications.</dd>
* <dt><code>publication</code></dt>
* <dd>Specifies the publication(s) to export using the ID(s) of the
* publications.
* This parameter can occur more
* than one time. In this case, all publications specified by the parameters
* will be exported as a single file in specified format</dd>
* <dt><code>category</code></dt>
* <dd>Specifies a category using the OID of the category. If this
* parameter is present, all publications in the category and the subcategories
* of the category will exported as a single file in the specified format.</dd>
* </dl>
* <p>
* The <code>format</code> argument is mandatory. Also their must be either one
* or more <code>publication</code> parameters or a <code>category</code>
* parameter. If the URL is not valid, the Servlet will respond with the
* BAD_REQUEST (400) HTTP status code. If one of the specified publications or
* the specified category can't be found, the Servlet will respond with the
* NOT_FOUND (404) HTTP status code.
* </p>
* </dd>
* </dl>
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
@ -64,12 +119,9 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
logger.debug(String.format("path = %s", path)); logger.debug(String.format("path = %s", path));
//Displays a text/plain page with a message.
if (path.isEmpty()) { if (path.isEmpty()) {
logger.debug("pathInfo is null, responding with default..."); logger.debug("pathInfo is null, responding with default...");
/*response.setContentType("application/text");
response.setHeader("Content-Disposition",
"attachment; filename=ccm-publication-exporter.txt");
response.getWriter().append("This is the sci-publication-exporter");*/
response.setContentType("text/plain"); response.setContentType("text/plain");
response.getWriter().append("Please choose an application."); response.getWriter().append("Please choose an application.");
@ -83,6 +135,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
parameters = request.getParameterMap(); parameters = request.getParameterMap();
//Get the format parameter
if (parameters.containsKey("format")) { if (parameters.containsKey("format")) {
if (parameters.get("format").length == 1) { if (parameters.get("format").length == 1) {
format = parameters.get("format")[0]; format = parameters.get("format")[0];
@ -105,6 +158,9 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
} }
if (parameters.containsKey("category")) { if (parameters.containsKey("category")) {
/* If the category parameter is present, retrieve the
* specified category and exports all publications in it.
*/
Publication publication; Publication publication;
SciPublicationsExporter exporter; SciPublicationsExporter exporter;
String categoryIdStr; String categoryIdStr;
@ -151,6 +207,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
logger.debug(String.format("Category: %s", category.getName())); logger.debug(String.format("Category: %s", category.getName()));
//Get the exporter for the specified format.
exporter = SciPublicationsExporters.getInstance(). exporter = SciPublicationsExporters.getInstance().
getExporterForFormat( getExporterForFormat(
format); format);
@ -165,6 +222,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
return; return;
} }
//Get the category.
objects = category.getObjects(ACSObject.BASE_DATA_OBJECT_TYPE); objects = category.getObjects(ACSObject.BASE_DATA_OBJECT_TYPE);
logger.debug(String.format("Category contains %d objects.", logger.debug(String.format("Category contains %d objects.",
objects.size())); objects.size()));
@ -172,9 +230,12 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
ACSObject object; ACSObject object;
while (objects.next()) { while (objects.next()) {
//Get the bundle
bundle = (ContentBundle) objects.getACSObject(); bundle = (ContentBundle) objects.getACSObject();
//Get the default instance of the bundle
object = bundle.getInstance(bundle.getDefaultLanguage()); object = bundle.getInstance(bundle.getDefaultLanguage());
//Ignore object if it is not an publication
if (object instanceof Publication) { if (object instanceof Publication) {
publication = (Publication) object; publication = (Publication) object;
} else { } else {
@ -182,22 +243,30 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
continue; continue;
} }
//Ignore none live versions.
if (!publication.isLiveVersion()) { if (!publication.isLiveVersion()) {
logger.debug("Object is no a published version, " logger.debug("Object is no a published version, "
+ "ignoring it."); + "ignoring it.");
continue; continue;
} }
//Write the exported publication to the response.
response.getWriter().append(exporter.exportPublication( response.getWriter().append(exporter.exportPublication(
publication)); publication));
response.getWriter().append('\n'); //response.getWriter().append('\n');
} }
//Set the MimeType of the response
response.setContentType(exporter.getSupportedFormat(). response.setContentType(exporter.getSupportedFormat().
getMimeType().getBaseType()); getMimeType().getBaseType());
//Force the browser to display an download dialog, and set
//the filename for the downloaded file to the name of the
//selected category.
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
String.format("attachment; filename=%s.bib", String.format("attachment; filename=%s.%s",
category.getName())); category.getName(),
exporter.getSupportedFormat().
getFileExtension()));
return; return;
} else if (parameters.containsKey("publication")) { } else if (parameters.containsKey("publication")) {
@ -215,6 +284,8 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
return; return;
} }
//Retrieve the ids of the publication(s) to export from the
//request.
BigDecimal publicationId; BigDecimal publicationId;
publicationIds = new ArrayList<BigDecimal>(); publicationIds = new ArrayList<BigDecimal>();
for (int i = 0; i < publications.length; i++) { for (int i = 0; i < publications.length; i++) {
@ -234,6 +305,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
publicationIds.add(publicationId); publicationIds.add(publicationId);
} }
//Export the publictions.
exportPublications(format, publicationIds, response); exportPublications(format, publicationIds, response);
} else { } else {
@ -247,6 +319,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
} }
} else { } else {
//Respond with 404 when the requested action is unknown.
logger.warn(String.format("Unknown pathinfo '%s', " logger.warn(String.format("Unknown pathinfo '%s', "
+ "responding with 404...", + "responding with 404...",
path)); path));
@ -255,12 +328,21 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
} }
} }
/**
* Helper method for exporting publications specified by a list of IDs.
*
* @param format The format to use.
* @param publicationIds The IDs of the publications to export
* @param response The {@link HttpServletResponse} to use
* @throws IOException Thrown by some methods called by this method.
*/
private void exportPublications(final String format, private void exportPublications(final String format,
final List<BigDecimal> publicationIds, final List<BigDecimal> publicationIds,
final HttpServletResponse response) final HttpServletResponse response)
throws IOException { throws IOException {
SciPublicationsExporter exporter; SciPublicationsExporter exporter;
//Get the exporter for the specified format.
exporter = SciPublicationsExporters.getInstance().getExporterForFormat( exporter = SciPublicationsExporters.getInstance().getExporterForFormat(
format); format);
@ -276,26 +358,24 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
return; return;
} }
//Set the MimeType type of the response.
response.setContentType(exporter.getSupportedFormat().getMimeType(). response.setContentType(exporter.getSupportedFormat().getMimeType().
getBaseType()); getBaseType());
Publication publication = null; Publication publication = null;
String publicationName = "publication"; String publicationName = "publication";
for (BigDecimal publicationId : publicationIds) { for (BigDecimal publicationId : publicationIds) {
try { try {
//Get the publication
publication = new Publication(publicationId); publication = new Publication(publicationId);
logger.debug(String.format("OID of publication: %s", logger.debug(String.format("OID of publication: %s",
publication.getOID())); publication.getOID()));
//Specialize the publication
publication = (Publication) DomainObjectFactory.newInstance(publication. publication = (Publication) DomainObjectFactory.newInstance(publication.
getOID()); getOID());
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
logger.warn(String.format("No publication found for id '%s'.", logger.warn(String.format("No publication found for id '%s'.",
publicationId.toPlainString()), ex); publicationId.toPlainString()), ex);
@ -310,23 +390,31 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
logger.debug(String.format("Publication is of type: %s", logger.debug(String.format("Publication is of type: %s",
publication.getClass().getName())); publication.getClass().getName()));
//Write the exported publication data to the response.
response.getWriter().append(exporter.exportPublication(publication)); response.getWriter().append(exporter.exportPublication(publication));
response.getWriter().append('\n'); //response.getWriter().append('\n');
publicationName = publication.getName(); publicationName = publication.getName();
} }
//Force the browser to show a download dialog.
if (publicationIds.size() == 1) { if (publicationIds.size() == 1) {
//If only one publication is exported, use the name (URL) of the
//publication as filename.
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
String.format("attachment; filename=%s.bib", String.format("attachment; filename=%s.%s",
publicationName)); publicationName,
exporter.getSupportedFormat().
getFileExtension()));
} else { } else {
//If more than one publication is exported, use 'publications' as
//filename.
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
"attachment; filename=publications.bib"); String.format(
"attachment; filename=publications.%s",
exporter.getSupportedFormat().
getFileExtension()));
} }
} }

View File

@ -1,15 +1,45 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter; package com.arsdigita.cms.scipublications.exporter;
import javax.activation.MimeType; import javax.activation.MimeType;
/** /**
* Describes the format provided by an implementation of
* {@link SciPublicationsExporter}.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public class PublicationFormat { public class PublicationFormat {
/**
* Name of the format.
*/
private String name; private String name;
/**
* MimeType to use for files of the format.
*/
private MimeType mimeType; private MimeType mimeType;
/**
* File extension for files of the format.
*/
private String fileExtension; private String fileExtension;
public PublicationFormat() { public PublicationFormat() {

View File

@ -1,15 +1,45 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter; package com.arsdigita.cms.scipublications.exporter;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
/** /**
* This interface describes the methods provided by all publication exporters.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public interface SciPublicationsExporter { public interface SciPublicationsExporter {
/**
*
* @return A description of the export format provided by this exporter.
*/
PublicationFormat getSupportedFormat(); PublicationFormat getSupportedFormat();
/**
* Exports an publication to the format provided by this exporter.
*
* @param publication The publication to export.
* @return The data of the publication in the provided export format.
*/
String exportPublication(Publication publication); String exportPublication(Publication publication);
} }

View File

@ -1,3 +1,22 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter; package com.arsdigita.cms.scipublications.exporter;
import java.util.ArrayList; import java.util.ArrayList;
@ -8,22 +27,36 @@ import java.util.ServiceLoader;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* This class provides access to implementations of the
* {@link SciPublicationsExporter} interface. It is implemented as a Singleton.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public final class SciPublicationsExporters { public final class SciPublicationsExporters {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
SciPublicationsExporters.class); SciPublicationsExporters.class);
/**
* Association of the format and the responsible exporters.
*/
private Map<String, SciPublicationsExporter> exporters = private Map<String, SciPublicationsExporter> exporters =
new HashMap<String, SciPublicationsExporter>(); new HashMap<String, SciPublicationsExporter>();
/**
* The one and only instance of this class. The pattern here ensures that
* the instance is created at the first access, but not earlier.
*/
private static class Instance { private static class Instance {
private static final SciPublicationsExporters INSTANCE = private static final SciPublicationsExporters INSTANCE =
new SciPublicationsExporters(); new SciPublicationsExporters();
} }
/**
* Creates the instance. Uses the {@link ServiceLoader} to find all available
* implementations of {@link SciPublicationsExporter} and puts them into
* the {@link #exporters} map.
*/
private SciPublicationsExporters() { private SciPublicationsExporters() {
logger.debug("Creating SciPublicationsExporter instance..."); logger.debug("Creating SciPublicationsExporter instance...");
ServiceLoader<SciPublicationsExporter> exporterServices; ServiceLoader<SciPublicationsExporter> exporterServices;
@ -42,14 +75,28 @@ public final class SciPublicationsExporters {
logger.debug(String.format("Found %d exporters.", exporters.size())); logger.debug(String.format("Found %d exporters.", exporters.size()));
} }
/**
* @return The instance of this class.
*/
public static SciPublicationsExporters getInstance() { public static SciPublicationsExporters getInstance() {
return Instance.INSTANCE; return Instance.INSTANCE;
} }
/**
* Retrieves the exporter for the specified format.
*
* @param format The format which should be supported by the exporter.
* @return The exporter for the specified format, or <code>null</code>, if
* there is no exporter which supports the specified format.
*/
public SciPublicationsExporter getExporterForFormat(final String format) { public SciPublicationsExporter getExporterForFormat(final String format) {
return exporters.get(format); return exporters.get(format);
} }
/**
*
* @return A list of all supported export formats.
*/
public List<PublicationFormat> getSupportedFormats() { public List<PublicationFormat> getSupportedFormats() {
List<PublicationFormat> supportedFormats; List<PublicationFormat> supportedFormats;

View File

@ -1,16 +1,40 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.bibtex; package com.arsdigita.cms.scipublications.exporter.bibtex;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.scipublications.exporter.PublicationFormat; import com.arsdigita.cms.scipublications.exporter.PublicationFormat;
import com.arsdigita.cms.scipublications.exporter.SciPublicationsExporter; import com.arsdigita.cms.scipublications.exporter.SciPublicationsExporter;
import com.arsdigita.cms.scipublications.exporter.bibtex.converters.BibTeXConverter;
import com.arsdigita.cms.scipublications.exporter.bibtex.converters.BibTeXConverters; import com.arsdigita.cms.scipublications.exporter.bibtex.converters.BibTeXConverters;
import javax.activation.MimeType; import javax.activation.MimeType;
import javax.activation.MimeTypeParseException; import javax.activation.MimeTypeParseException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* An exporter for the BibTeX format. The actual conversion between the CCM
* publication content types and the BibTeX format is done by the converters
* in the <code>com.arsdigita.cms.scipublications.exporter.bibtex</code> which
* are implementation the {@link BibTeXConverter} interface.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public class BibTeXExporter implements SciPublicationsExporter { public class BibTeXExporter implements SciPublicationsExporter {

View File

@ -81,7 +81,7 @@ public abstract class AbstractBibTeXBuilder implements BibTeXBuilder {
builder); builder);
} }
builder.append('}'); builder.append("}\n");
return builder.toString(); return builder.toString();
} }

View File

@ -1,3 +1,22 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.bibtex.converters; package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
import com.arsdigita.cms.contenttypes.AuthorshipCollection; import com.arsdigita.cms.contenttypes.AuthorshipCollection;
@ -10,13 +29,21 @@ import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXField;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException;
/** /**
* An abstract implementation of the {@link BibTeXConverter} providing common
* functionality for all converters. To create the BibTeX data, implementations
* of the {@link BibTeXBuilder} interface are used.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public abstract class AbstractBibTeXConverter implements BibTeXConverter { public abstract class AbstractBibTeXConverter implements BibTeXConverter {
private BibTeXBuilder bibTeXBuilder; private BibTeXBuilder bibTeXBuilder;
/**
* Convert the authors of a publication to BibTeX.
*
* @param publication The publication to use.
*/
protected void convertAuthors(final Publication publication) { protected void convertAuthors(final Publication publication) {
AuthorshipCollection authors; AuthorshipCollection authors;
@ -32,11 +59,24 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Convert the title of a publication to BibTeX.
*
* @param publication The publication to use.
* @throws UnsupportedFieldException If the title field is not supported by
* the BibTeX type.
*/
protected void convertTitle(final Publication publication) protected void convertTitle(final Publication publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
getBibTeXBuilder().setField(BibTeXField.TITLE, publication.getTitle()); getBibTeXBuilder().setField(BibTeXField.TITLE, publication.getTitle());
} }
/**
* Converts the year of publication to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertYear(final Publication publication) protected void convertYear(final Publication publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
if (publication.getYearOfPublication() != null) { if (publication.getYearOfPublication() != null) {
@ -46,6 +86,12 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Converts the publisher to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertPublisher(final PublicationWithPublisher publication) protected void convertPublisher(final PublicationWithPublisher publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
if (publication.getPublisher() != null) { if (publication.getPublisher() != null) {
@ -66,6 +112,12 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Convert the ISBN to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertISBN(final PublicationWithPublisher publication) protected void convertISBN(final PublicationWithPublisher publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
if (publication.getISBN() != null) { if (publication.getISBN() != null) {
@ -74,6 +126,12 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Convert the volume to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertVolume(final PublicationWithPublisher publication) protected void convertVolume(final PublicationWithPublisher publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
if (publication.getVolume() != null) { if (publication.getVolume() != null) {
@ -82,6 +140,12 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Convert the edition to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertEdition(final PublicationWithPublisher publication) protected void convertEdition(final PublicationWithPublisher publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
if (publication.getEdition() != null) { if (publication.getEdition() != null) {
@ -90,10 +154,15 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Convert the series to BibTeX.
*
* @param publication
* @throws UnsupportedFieldException
*/
protected void convertSeries(final Publication publication) protected void convertSeries(final Publication publication)
throws UnsupportedFieldException { throws UnsupportedFieldException {
SeriesCollection seriesColl = SeriesCollection seriesColl = publication.getSeries();
publication.getSeries();
if ((seriesColl != null) && (seriesColl.size() > 0)) { if ((seriesColl != null) && (seriesColl.size() > 0)) {
seriesColl.next(); seriesColl.next();
@ -105,6 +174,12 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
} }
} }
/**
* Retrieves to BibTeX builder for the converter. Uses the implementation
* of {@link #getBibTeXType()} for get the BibTeX type.
*
* @return The BibTeX builder for the converter.
*/
protected BibTeXBuilder getBibTeXBuilder() { protected BibTeXBuilder getBibTeXBuilder() {
if (bibTeXBuilder == null) { if (bibTeXBuilder == null) {
bibTeXBuilder = BibTeXBuilders.getInstance(). bibTeXBuilder = BibTeXBuilders.getInstance().
@ -114,5 +189,9 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
return bibTeXBuilder; return bibTeXBuilder;
} }
/**
*
* @return The BibTeX type to use for building the BibTeX data.
*/
protected abstract String getBibTeXType(); protected abstract String getBibTeXType();
} }

View File

@ -54,6 +54,10 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
if (article.getCollectedVolume().getPublisher() == null) { if (article.getCollectedVolume().getPublisher() == null) {
builder.setField(BibTeXField.PUBLISHER, ""); builder.setField(BibTeXField.PUBLISHER, "");
} else {
builder.setField(BibTeXField.PUBLISHER,
article.getCollectedVolume().getPublisher().
getTitle());
} }
if (article.getCollectedVolume().getVolume() != null) { if (article.getCollectedVolume().getVolume() != null) {
@ -61,6 +65,12 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
article.getCollectedVolume().getVolume(). article.getCollectedVolume().getVolume().
toString()); toString());
} }
if (article.getCollectedVolume().getEdition() != null) {
builder.setField(BibTeXField.EDITION,
article.getCollectedVolume().getEdition());
}
SeriesCollection seriesColl = SeriesCollection seriesColl =
article.getCollectedVolume().getSeries(); article.getCollectedVolume().getSeries();
if ((seriesColl != null) && (seriesColl.size() > 0)) { if ((seriesColl != null) && (seriesColl.size() > 0)) {
@ -72,13 +82,8 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
seriesColl.close(); seriesColl.close();
} }
} else {
builder.setField(BibTeXField.PUBLISHER,
article.getCollectedVolume().getPublisher().
getTitle());
} }
if (article.getChapter() != null) { if (article.getChapter() != null) {
builder.setField(BibTeXField.CHAPTER, article.getChapter()); builder.setField(BibTeXField.CHAPTER, article.getChapter());
} }
@ -90,10 +95,7 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
article.getPagesTo())); article.getPagesTo()));
} }
if (article.getCollectedVolume().getEdition() != null) {
builder.setField(BibTeXField.EDITION,
article.getCollectedVolume().getEdition());
}
} catch (UnsupportedFieldException ex) { } catch (UnsupportedFieldException ex) {
logger.warn("Tried to set unsupported BibTeX field while " logger.warn("Tried to set unsupported BibTeX field while "
+ "converting a publication"); + "converting a publication");

View File

@ -1,15 +1,45 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.bibtex.converters; package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
/** /**
* Interface for the BibTeX converters.
* *
* @param <T> * @author Jens Pelzetter
* @author jensp
*/ */
public interface BibTeXConverter { public interface BibTeXConverter {
/**
* Converts a publication.
*
* @param publication The publication to convert.
* @return The data of the publication converted to BibTeX.
* @throws UnsupportedCcmTypeException If the provided publication is of
* a type which is not supported by this converter.
*/
String convert(Publication publication); String convert(Publication publication);
/**
* @return The CCM publication type supported by this converter.
*/
String getCcmType(); String getCcmType();
} }

View File

@ -1,3 +1,22 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.bibtex.converters; package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
@ -5,29 +24,36 @@ import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Provides easy access to all available BibTeX converters.
* *
* @author jensp * @author Jens Pelzetter
*/ */
public class BibTeXConverters { public class BibTeXConverters {
private static final Logger logger = Logger.getLogger(BibTeXConverters.class); private static final Logger logger =
Logger.getLogger(BibTeXConverters.class);
/**
* Associates the available converters with their supported CCM types.
*/
private Map<String, BibTeXConverter> converters = private Map<String, BibTeXConverter> converters =
new HashMap<String, BibTeXConverter>(); new HashMap<String, BibTeXConverter>();
/**
* Finds all available {@link BibTeXConverter}s and puts them into the
* map.
*/
private BibTeXConverters() { private BibTeXConverters() {
logger.debug("Loading BibTeX converters..."); logger.debug("Loading BibTeX converters...");
ServiceLoader<BibTeXConverter> converterServices; ServiceLoader<BibTeXConverter> converterServices;
converterServices = ServiceLoader.load(BibTeXConverter.class); converterServices = ServiceLoader.load(BibTeXConverter.class);
for(BibTeXConverter converter : converterServices) { for (BibTeXConverter converter : converterServices) {
logger.debug(String.format("Found converter for CCM type '%s'...", logger.debug(String.format("Found converter for CCM type '%s'...",
converter.getCcmType())); converter.getCcmType()));
converters.put(converter.getCcmType(), converter); converters.put(converter.getCcmType(), converter);
} }
logger.debug(String.format("Found %d converters.", converters.size())); logger.debug(String.format("Found %d converters.", converters.size()));
@ -38,33 +64,48 @@ public class BibTeXConverters {
private static BibTeXConverters INSTANCE = new BibTeXConverters(); private static BibTeXConverters INSTANCE = new BibTeXConverters();
} }
/**
* @return The instance of this class.
*/
public static BibTeXConverters getInstance() { public static BibTeXConverters getInstance() {
return Instance.INSTANCE; return Instance.INSTANCE;
} }
/**
* Converts the provided publication to BibTeX using the responsible
* converter. If no converter is found, the
* {@link PublicationWithPublisherConverter} or the
* {@link PublicationConverter} are used, depending one the base type of
* the publication.
*
* @param publication The publication to convert.
* @return The publication converted to BibTeX.
*/
public String convert(final Publication publication) { public String convert(final Publication publication) {
try { try {
BibTeXConverter converter; BibTeXConverter converter;
logger.debug(String.format("Trying to find converter for type '%s'.", logger.debug(String.format("Trying to find converter for type '%s'.",
publication.getClass().getName())); publication.getClass().getName()));
//Get the responsible converter
converter = converters.get(publication.getClass().getName()); converter = converters.get(publication.getClass().getName());
if (converter == null) { if (converter == null) {
logger.debug("No converter found..."); logger.debug("No converter found...");
if (publication instanceof PublicationWithPublisher) { if (publication instanceof PublicationWithPublisher) {
logger.debug("Publication is a PublicationWithPublisher, using" + logger.debug("Publication is a PublicationWithPublisher, using"
"converter for this type."); + "converter for this type.");
converter = converter =
converters.get(PublicationWithPublisher.class.getName()); converters.get(PublicationWithPublisher.class.getName());
} else { } else {
logger.debug("Publication is a Publication, using" + logger.debug("Publication is a Publication, using"
"converter for this type."); + "converter for this type.");
converter = converter =
converters.get(Publication.class.getName()); converters.get(Publication.class.getName());
} }
} }
//Create an new instance of this converter.
converter = converter.getClass().newInstance(); converter = converter.getClass().newInstance();
//Run the converter.
return converter.convert(publication); return converter.convert(publication);
} catch (InstantiationException ex) { } catch (InstantiationException ex) {
logger.warn("Failed to instaniate BibTeX converter.", ex); logger.warn("Failed to instaniate BibTeX converter.", ex);
return null; return null;

View File

@ -12,7 +12,8 @@ import org.apache.log4j.Logger;
*/ */
public class ExpertiseConverter extends AbstractBibTeXConverter { public class ExpertiseConverter extends AbstractBibTeXConverter {
private static final Logger logger = Logger.getLogger(ExpertiseConverter.class); private static final Logger logger = Logger.getLogger(
ExpertiseConverter.class);
@Override @Override
protected String getBibTeXType() { protected String getBibTeXType() {
@ -23,7 +24,7 @@ public class ExpertiseConverter extends AbstractBibTeXConverter {
BibTeXBuilder builder; BibTeXBuilder builder;
Expertise expertise; Expertise expertise;
if (!(publication instanceof Expertise)) { if (!(publication instanceof Expertise)) {
throw new UnsupportedCcmTypeException( throw new UnsupportedCcmTypeException(
String.format("The ExpertiseConverter only " String.format("The ExpertiseConverter only "
+ "supports publication types which are of the" + "supports publication types which are of the"
@ -39,11 +40,11 @@ public class ExpertiseConverter extends AbstractBibTeXConverter {
expertise = (Expertise) publication; expertise = (Expertise) publication;
convertAuthors(publication); convertAuthors(publication);
builder = getBibTeXBuilder(); builder = getBibTeXBuilder();
try { try {
convertTitle(publication); convertTitle(publication);
convertYear(publication); convertYear(publication);
} catch (UnsupportedFieldException ex) { } catch (UnsupportedFieldException ex) {
logger.warn("Tried to set unsupported BibTeX field while " logger.warn("Tried to set unsupported BibTeX field while "
+ "converting a publication"); + "converting a publication");
@ -55,5 +56,4 @@ public class ExpertiseConverter extends AbstractBibTeXConverter {
public String getCcmType() { public String getCcmType() {
return Expertise.class.getName(); return Expertise.class.getName();
} }
} }

View File

@ -12,7 +12,8 @@ import org.apache.log4j.Logger;
*/ */
public class GreyLiteratureConverter extends AbstractBibTeXConverter { public class GreyLiteratureConverter extends AbstractBibTeXConverter {
private static final Logger logger = Logger.getLogger(GreyLiteratureConverter.class); private static final Logger logger = Logger.getLogger(
GreyLiteratureConverter.class);
@Override @Override
protected String getBibTeXType() { protected String getBibTeXType() {
@ -23,7 +24,7 @@ public class GreyLiteratureConverter extends AbstractBibTeXConverter {
BibTeXBuilder builder; BibTeXBuilder builder;
GreyLiterature greyLiterature; GreyLiterature greyLiterature;
if (!(publication instanceof GreyLiterature)) { if (!(publication instanceof GreyLiterature)) {
throw new UnsupportedCcmTypeException( throw new UnsupportedCcmTypeException(
String.format("The GreyLiteratureConverter only " String.format("The GreyLiteratureConverter only "
+ "supports publication types which are of the" + "supports publication types which are of the"
@ -39,7 +40,7 @@ public class GreyLiteratureConverter extends AbstractBibTeXConverter {
greyLiterature = (GreyLiterature) publication; greyLiterature = (GreyLiterature) publication;
convertAuthors(publication); convertAuthors(publication);
builder = getBibTeXBuilder(); builder = getBibTeXBuilder();
try { try {
convertTitle(publication); convertTitle(publication);
@ -55,5 +56,4 @@ public class GreyLiteratureConverter extends AbstractBibTeXConverter {
public String getCcmType() { public String getCcmType() {
return GreyLiterature.class.getName(); return GreyLiterature.class.getName();
} }
} }

View File

@ -3,7 +3,6 @@ package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
import com.arsdigita.cms.contenttypes.InProceedings; import com.arsdigita.cms.contenttypes.InProceedings;
import com.arsdigita.cms.contenttypes.Proceedings; import com.arsdigita.cms.contenttypes.Proceedings;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.SeriesCollection;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXBuilder; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXBuilder;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXField; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXField;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException;
@ -67,7 +66,7 @@ public class InProceedingsConverter extends AbstractBibTeXConverter {
proceedings.getTitle()); proceedings.getTitle());
convertVolume(proceedings); convertVolume(proceedings);
convertSeries(publication); convertSeries(proceedings);
if (proceedings.getOrganizerOfConference() != null) { if (proceedings.getOrganizerOfConference() != null) {
builder.setField(BibTeXField.ORGANIZATION, builder.setField(BibTeXField.ORGANIZATION,

View File

@ -3,7 +3,6 @@ package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
import com.arsdigita.cms.contenttypes.InternetArticle; import com.arsdigita.cms.contenttypes.InternetArticle;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXBuilder; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXBuilder;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.BibTeXField;
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException; import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;

View File

@ -46,7 +46,7 @@ public class MonographConverter extends AbstractBibTeXConverter {
convertEdition(monograph); convertEdition(monograph);
} catch (UnsupportedFieldException ex) { } catch (UnsupportedFieldException ex) {
logger.warn("Tried to set unsupported BibTeX field while " logger.warn("Tried to set unsupported BibTeX field while "
+ "converting a publication"); + "converting a publication", ex);
} }
return getBibTeXBuilder().toBibTeX(); return getBibTeXBuilder().toBibTeX();

View File

@ -21,7 +21,7 @@ public class PublicationConverter extends AbstractBibTeXConverter {
convertYear(publication); convertYear(publication);
} catch (UnsupportedFieldException ex) { } catch (UnsupportedFieldException ex) {
logger.warn("Tried to set unsupported BibTeX field while " logger.warn("Tried to set unsupported BibTeX field while "
+ "converting a publication"); + "converting a publication", ex);
} }
return getBibTeXBuilder().toBibTeX(); return getBibTeXBuilder().toBibTeX();

View File

@ -0,0 +1,5 @@
/**
* Provides the converters for are converting the CCM publication content types
* to BibTeX.
*/
package com.arsdigita.cms.scipublications.exporter.bibtex.converters;

View File

@ -0,0 +1,5 @@
/**
* The <code>com.arsdigita.cms.scipublications.exporter.bibtex</code> package
* provides an exporter for the BibTeX format.
*/
package com.arsdigita.cms.scipublications.exporter.bibtex;

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
import com.arsdigita.cms.contenttypes.SeriesCollection;
/**
* An abstract base implementation of the {@link RisConverter} interface
* providing common functionality.
*
* @author Jens Pelzetter
*/
public abstract class AbstractRisConverter implements RisConverter {
private RisBuilder risBuilder = new RisBuilder();
protected void convertAuthors(final Publication publication) {
AuthorshipCollection authors;
authors = publication.getAuthors();
if (authors != null) {
while (authors.next()) {
if (authors.isEditor()) {
getRisBuilder().addField(RisFields.AU,
String.format("%s,%s",
authors.getAuthor().
getSurname(),
authors.getAuthor().
getGivenName()));
} else {
getRisBuilder().addField(RisFields.ED,
String.format("%s,%s",
authors.getAuthor().
getSurname(),
authors.getAuthor().
getGivenName()));
}
}
}
}
protected void convertTitle(final Publication publication) {
getRisBuilder().addField(RisFields.TI,
publication.getTitle());
}
protected void convertYear(final Publication publication) {
getRisBuilder().addField(RisFields.PY,
String.format("%d///", publication.
getYearOfPublication()));
}
protected void convertPublisher(final PublicationWithPublisher publication) {
if (publication.getPublisher() != null) {
if ((publication.getPublisher().getPlace() != null)
&& !(publication.getPublisher().getPlace().isEmpty())) {
getRisBuilder().addField(RisFields.CY,
publication.getPublisher().getPlace());
}
getRisBuilder().addField(RisFields.PB,
publication.getPublisher().getTitle());
}
}
protected void convertISBN(final PublicationWithPublisher publication) {
if (publication.getISBN() != null) {
getRisBuilder().addField(RisFields.SN,
publication.getISBN());
}
}
protected void convertVolume(final PublicationWithPublisher publication) {
if (publication.getVolume() != null) {
getRisBuilder().addField(RisFields.VL,
publication.getVolume().toString());
}
}
protected void convertEdition(final PublicationWithPublisher publication) {
if (publication.getEdition() != null) {
getRisBuilder().addField(RisFields.ET,
publication.getEdition());
}
}
protected void convertSeries(final Publication publication) {
SeriesCollection seriesColl = publication.getSeries();
if ((seriesColl != null) && (seriesColl.size() > 0)) {
seriesColl.next();
getRisBuilder().addField(RisFields.T3,
seriesColl.getSeries().getTitle());
seriesColl.close();
}
}
protected RisBuilder getRisBuilder() {
return risBuilder;
}
}

View File

@ -0,0 +1,55 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author jensp
*/
public class ArticleInCollectedVolumeConverter extends AbstractRisConverter {
public String convert(final Publication publication) {
ArticleInCollectedVolume article;
if (!(publication instanceof ArticleInCollectedVolume)) {
throw new UnsupportedCcmTypeException(
String.format("The ArticleInCollectedVolumeConverter only "
+ "supports publication types which are of the"
+ "type ArticleInCollectedVolume or which are "
+ "extending "
+ "ArticleInCollectedVolume. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "ArticleInCollectedVolume and does not "
+ "extends ArticleInCollectedVolume.",
publication.getClass().getName()));
}
article = (ArticleInCollectedVolume) publication;
getRisBuilder().setType(RisTypes.CHAP);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
if (article.getCollectedVolume() != null) {
getRisBuilder().addField(RisFields.BT,
article.getCollectedVolume().getTitle());
}
if (article.getPagesFrom() != null) {
getRisBuilder().addField(RisFields.SP,
article.getPagesFrom().toString());
getRisBuilder().addField(RisFields.EP,
article.getPagesTo().toString());
}
return getRisBuilder().toRis();
}
public String getCcmType() {
return ArticleInCollectedVolume.class.getName();
}
}

View File

@ -0,0 +1,61 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.ArticleInJournal;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class ArticleInJournalConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
ArticleInJournal article;
if (!(publication instanceof ArticleInJournal)) {
throw new UnsupportedCcmTypeException(
String.format("The ArticleInJournalConverter only "
+ "supports publication types which are of the"
+ "type ArticleInJournal or which are "
+ "extending "
+ "ArticleInJournal. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "ArticleInJournal and does not "
+ "extends ArticleInJournal.",
publication.getClass().getName()));
}
article = (ArticleInJournal) publication;
getRisBuilder().setType(RisTypes.MGZN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
if (article.getJournal() != null) {
getRisBuilder().addField(RisFields.JF,
article.getJournal().getTitle());
}
if (article.getVolume() != null) {
getRisBuilder().addField(RisFields.VL,
article.getVolume().toString());
}
if (article.getPagesFrom() != null) {
getRisBuilder().addField(RisFields.SP,
article.getPagesFrom().toString());
getRisBuilder().addField(RisFields.EP,
article.getPagesTo().toString());
}
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return ArticleInJournalConverter.class.getName();
}
}

View File

@ -0,0 +1,46 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.CollectedVolume;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class CollectedVolumeConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
CollectedVolume collectedVolume;
if (!(publication instanceof CollectedVolume)) {
throw new UnsupportedCcmTypeException(
String.format("The PublicationWithPublicationConverter only "
+ "supports publication types which are "
+ "extending CollectedVolume. The "
+ "provided publication is of type '%s' which "
+ "does not extends "
+ "CollectedVolume.",
publication.getClass().getName()));
}
collectedVolume = (CollectedVolume) publication;
getRisBuilder().setType(RisTypes.BOOK);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
convertPublisher(collectedVolume);
convertISBN(collectedVolume);
convertEdition(collectedVolume);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return CollectedVolume.class.getName();
}
}

View File

@ -0,0 +1,44 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Expertise;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class ExpertiseConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
Expertise expertise;
if (!(publication instanceof Expertise)) {
throw new UnsupportedCcmTypeException(
String.format("The ExpertiseConverter only "
+ "supports publication types which are of the"
+ "type Expertise or which are "
+ "extending "
+ "Expertise. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "Expertise and does not "
+ "extends Expertise.",
publication.getClass().getName()));
}
expertise = (Expertise) publication;
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return Expertise.class.getName();
}
}

View File

@ -0,0 +1,44 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.GreyLiterature;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class GreyLiteratureConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
GreyLiterature greyLiterature;
if (!(publication instanceof GreyLiterature)) {
throw new UnsupportedCcmTypeException(
String.format("The GreyLiteratureConverter only "
+ "supports publication types which are of the"
+ "type GreyLiterature or which are "
+ "extending "
+ "GreyLiterature. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "GreyLiterature and does not "
+ "extends GreyLiterature.",
publication.getClass().getName()));
}
greyLiterature = (GreyLiterature) publication;
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return GreyLiterature.class.getName();
}
}

View File

@ -0,0 +1,65 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.InProceedings;
import com.arsdigita.cms.contenttypes.Proceedings;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class InProceedingsConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
InProceedings inProceedings;
if (!(publication instanceof InProceedings)) {
throw new UnsupportedCcmTypeException(
String.format("The InProceedingsConverter only "
+ "supports publication types which are of the"
+ "type InProceedings or which are "
+ "extending "
+ "InProceedings. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "InProceedings and does not "
+ "extends InProceedings.",
publication.getClass().getName()));
}
inProceedings = (InProceedings) publication;
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
if (inProceedings.getPagesFrom() != null) {
getRisBuilder().addField(RisFields.SP,
inProceedings.getPagesFrom().toString());
getRisBuilder().addField(RisFields.EP,
inProceedings.getPagesTo().toString());
}
if(inProceedings.getProceedings() != null) {
Proceedings proceedings;
proceedings = inProceedings.getProceedings();
getRisBuilder().addField(RisFields.BT,
proceedings.getTitle());
convertVolume(proceedings);
convertSeries(proceedings);
convertPublisher(proceedings);
}
return getRisBuilder().toString();
}
@Override
public String getCcmType() {
return InProceedings.class.getName();
}
}

View File

@ -0,0 +1,44 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.InternetArticle;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class InternetArticleConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
InternetArticle article;
if (!(publication instanceof InternetArticle)) {
throw new UnsupportedCcmTypeException(
String.format("The InternetArticleConverter only "
+ "supports publication types which are of the"
+ "type InternetArticle or which are "
+ "extending "
+ "InternetArticle. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "InternetArticle and does not "
+ "extends InternetArticle.",
publication.getClass().getName()));
}
article = (InternetArticle) publication;
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return InternetArticle.class.getName();
}
}

View File

@ -0,0 +1,46 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Monograph;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class MonographConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
Monograph monograph;
if (!(publication instanceof Monograph)) {
throw new UnsupportedCcmTypeException(
String.format("The MonographConverter only "
+ "supports publication types which are of the"
+ "type Monograph or which are extending "
+ "Monograh. The "
+ "provided publication is of type '%s' which "
+ "is not of type Monograph and does not "
+ "extends Monograph.",
publication.getClass().getName()));
}
monograph = (Monograph) publication;
getRisBuilder().setType(RisTypes.BOOK);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
convertPublisher(monograph);
convertISBN(monograph);
convertEdition(monograph);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return Monograph.class.getName();
}
}

View File

@ -0,0 +1,49 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Proceedings;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author jensp
*/
public class ProceedingsConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
Proceedings proceedings;
if (!(publication instanceof Proceedings)) {
throw new UnsupportedCcmTypeException(
String.format("The ProceedingsConverter only "
+ "supports publication types which are of the"
+ "type Proceedings or which are "
+ "extending "
+ "Proceedings. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "Proceedings and does not "
+ "extends Proceedings.",
publication.getClass().getName()));
}
proceedings = (Proceedings) publication;
getRisBuilder().setType(RisTypes.CONF);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
convertVolume(proceedings);
convertSeries(publication);
convertPublisher(proceedings);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return Proceedings.class.getName();
}
}

View File

@ -0,0 +1,23 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
/**
*
* @author Jens Pelzetter
*/
public class PublicationConverter extends AbstractRisConverter {
public String convert(final Publication publication) {
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
return getRisBuilder().toRis();
}
public String getCcmType() {
return Publication.class.getName();
}
}

View File

@ -0,0 +1,43 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
/**
*
* @author Jens Pelzetter
*/
public class PublicationWithPublisherConverter extends AbstractRisConverter {
public String convert(final Publication publication) {
PublicationWithPublisher _publication;
if (!(publication instanceof PublicationWithPublisher)) {
throw new UnsupportedCcmTypeException(
String.format("The PublicationWithPublicationConverter only "
+ "supports publication types which are "
+ "extending PublicationWithPublisher. The "
+ "provided publication is of type '%s' which "
+ "does not extends "
+ "PublicationWithPublisher.",
publication.getClass().getName()));
}
_publication = (PublicationWithPublisher) publication;
getRisBuilder().setType(RisTypes.GEN);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
convertPublisher(_publication);
convertISBN(_publication);
convertEdition(_publication);
return getRisBuilder().toRis();
}
public String getCcmType() {
return PublicationWithPublisher.class.getName();
}
}

View File

@ -0,0 +1,15 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Review;
/**
*
* @author Jens Pelzetter
*/
public class ReviewConverter extends ArticleInJournalConverter {
@Override
public String getCcmType() {
return Review.class.getName();
}
}

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
import java.util.EnumMap;
import java.util.Map;
/**
* Build an reference in RIS format.
*
* @author Jens Pelzetter
*/
public class RisBuilder {
/**
* Type of the reference
*/
private RisTypes type;
/**
* Fields of the reference.
*/
private Map<RisFields, String> fields = new EnumMap<RisFields, String>(
RisFields.class);
public RisBuilder() {
}
/**
* Sets the type of the reference.
*
* @param type Valid RIS type
*/
public void setType(final RisTypes type) {
this.type = type;
}
/**
* Adds a field to the reference.
*
* @param field The name of the field.
* @param value The value of the field.
*/
public void addField(final RisFields field, final String value) {
fields.put(field, value);
}
/**
* Creates the RIS string.
*
* @return The reference in the RIS format.
*/
public String toRis() {
StringBuilder builder;
builder = new StringBuilder();
appendField("TY", type.name(), builder);
for (Map.Entry<RisFields, String> field : fields.entrySet()) {
appendField(field.getKey().name(),
field.getValue(),
builder);
}
appendField("ER", "", builder);
return builder.toString();
}
/**
* Helper method for adding a field.
*
* @param name The name of the field.
* @param value The value of the field.
* @param builder The {@link StringBuilder} to use.
*/
private void appendField(final String name,
final String value,
final StringBuilder builder) {
builder.append(name);
builder.append(" - ");
builder.append(value);
builder.append("\r\n");
}
@Override
public String toString() {
return toRis();
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
/**
* Interface for the RIS converters
*
* @author Jens Pelzetter
*/
public interface RisConverter {
/**
* Converts a publication.
*
* @param publication The publication to convert.
* @return The data of the publication converted to RIS.
* @throws UnsupportedCcmTypeException If the provided publication is of
* a type which is not supported by this converter.
*/
String convert(Publication publication);
/**
* @return The CCM publication type supported by this converter.
*/
String getCcmType();
}

View File

@ -0,0 +1,80 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
*/
public class RisConverters {
private static final Logger logger = Logger.getLogger(RisConverters.class);
/**
* Associates the available converters with their supported CCM types.
*/
private Map<String, RisConverter> converters =
new HashMap<String, RisConverter>();
private RisConverters() {
logger.debug("Loading RIS converters...");
ServiceLoader<RisConverter> converterServices;
converterServices = ServiceLoader.load(RisConverter.class);
for (RisConverter converter : converterServices) {
logger.debug(String.format("Found converter for CCM type '%s'...",
converter.getCcmType()));
converters.put(converter.getCcmType(), converter);
}
logger.debug(String.format("Found %d converters.", converters.size()));
}
private static class Instance {
private static RisConverters INSTANCE = new RisConverters();
}
public static RisConverters getInstance() {
return Instance.INSTANCE;
}
public String convert(final Publication publication) {
try {
RisConverter converter;
logger.debug(String.format("Trying to find converter for type '%s'.",
publication.getClass().getName()));
//Get the responsible converter
converter = converters.get(publication.getClass().getName());
if (converter == null) {
logger.debug("No converter found...");
if (publication instanceof PublicationWithPublisher) {
logger.debug("Publication is a PublicationWithPublisher, using"
+ "converter for this type.");
converter =
converters.get(PublicationWithPublisher.class.getName());
} else {
logger.debug("Publication is a Publication, using"
+ "converter for this type.");
converter =
converters.get(Publication.class.getName());
}
}
//Create an new instance of this converter.
converter = converter.getClass().newInstance();
//Run the converter.
return converter.convert(publication);
} catch (InstantiationException ex) {
logger.warn("Failed to instaniate RIS converter.", ex);
return null;
} catch (IllegalAccessException ex) {
logger.warn("Failed to instaniate RIS converter.", ex);
return null;
}
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.scipublications.exporter.PublicationFormat;
import com.arsdigita.cms.scipublications.exporter.SciPublicationsExporter;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
*/
public class RisExporter implements SciPublicationsExporter {
private static final Logger logger = Logger.getLogger(RisExporter.class);
public PublicationFormat getSupportedFormat() {
try {
return new PublicationFormat("RIS",
new MimeType("text", "x-ris"),
"ris");
} catch(MimeTypeParseException ex) {
logger.warn("Failed to create MimeType for PublicationFormat."
+ "Using null mimetype instead. Cause: ", ex);
return new PublicationFormat("RIS",
null,
"ris");
}
}
public String exportPublication(final Publication publication) {
return RisConverters.getInstance().convert(publication);
}
}

View File

@ -0,0 +1,335 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
/**
* <p>
* Fields supported by RIS for describing a publication, excluding the
* fields <code>TY</code> (type of reference) and <code>ER</code> (end of
* reference). These fields are automatically set by the converters.
* </p>
* <p>
* The descriptions of the fields or tags as they are called in the RIS
* specification are copied from the specification
* </p>
*
* @author Jens Pelzetter
*/
public enum RisFields {
/**
* Reference ID. According to the specification not used by reference
* managers.
*/
ID,
/**
* Title Primary. Note that the BT tag maps to this field only for
* Whole Book and Unpublished Work references. This field can contain
* alphanumeric characters; there is no practical length limit to this
* field.
*/
T1,
/**
* @see #T1
*/
TI,
/**
* @see #T1
* @see #T2
*/
CT,
/**
* @see #T1
* @see #T2
*/
BT,
/**
* <p>
* Author Primary. Each author must be on a separate line, preceded by this
* tag. Each reference can contain
* unlimited author fields, and can contain up to 255 characters for each
* field. The author name must be in the following syntax:
* </p>
* <pre>
* Lastname,Firstname,Suffix
* </pre>
* <p>
* For Firstname, you can use full names, initials, or both. The format for
* the authors first name is as follows:
* </p>
* <pre>
* Phillips,A.J.
* Phillips,Albert John
* Phillips,Albert
* </pre>
* <dl>
* <dt><code>Lastname</code></dt>
* <dd>Any string of letters, spaces, and hyphens</dd>
* <dt><code>Firstname</code></dt>
* <dd>Any string of letters, spaces, and hyphens</dd>
* <dt><code>Initial</code></dt>
* <dd>Any single letter followed by a period</dd>
* <dt><code>Full Name</code></dt>
* <dd>Any string of letters, spaces, and hyphens</dd>
* <dt><code>Suffix</code></dt>
* <dd>Jr/Sr/II/III/MD etc. (Phillips,A.J.,Sr.); use of the suffix is
* optional</dd>
* </dl>
*/
A1,
/**
* @see #A1
*/
AU,
/**
* <p>
* Date Primary. This date must be in the following format:
* </p>
* <pre>
* YYYY/MM/DD/other info
* </pre>
* <p>
* The year, month and day fields are all numeric. The other info field can
* be any string of letters, spaces and hyphens. Note that each specific
* date information is optional, however the slashes (/) are not. For
* example, if you just had the <code>year</code> and
* <code>other info</code>, then the output
* would look like:
* </p>
* <pre>
* 1993///Spring.”
* </pre>
*/
Y1,
/**
* @see #Y1
*/
PY,
/**
* Notes. These are free text fields and can contain
* alphanumeric characters; there is no practical length limit to this
* field.
*/
N1,
/**
* @see #N1
*/
AB,
/**
* Keywords. Each keyword or phrase must be on its own line, preceded by
* this tag. A keyword can consist of multiple words (phrases) and can be
* up to
* 255 characters long. There can unlimited keywords in a reference.
*/
KW,
/**
* <p>
* Reprint status. This optional field can contain one of three status
* notes. Each must be in uppercase, and the date after ON REQUEST must
* be in
* USA format, in parentheses: (MM/DD/YY). If this field is blank in your
* downloaded text file, the Import function assumes the reprint status is
* NOT IN FILE.
* </p>
* <p>The three options are:</p>
* <dl>
* <dt><code>IN FILE</code></dt>
* <dd>This is for references that you have a physical copy of in your
* files.</dd>
* <dt><code>NOT IN FILE</code></dt>
* <dd>This is for references that you do not have physical copies of in
* your files.</dd>
* <dt><code>ON REQUEST (mm/dd/yy)</code></dt>
* <dd>This means that you have sent for a reprint of the reference;
* the date is the date on which the reprint was requested (in mm/dd/yy
* format).</dd>
* </dl>
*/
RP,
/**
* Start page number; an alphanumeric string, there is no practical length
* limit to this field.
*/
SP,
/**
* Ending page number, as above.
* @see #SP
*/
EP,
/**
* Periodical name: full format. This is an alphanumeric field of up to
* 255 characters.
*/
JF,
/**
* Periodical name: standard abbreviation. This is the 362 Appendix CRIS
* Format Specifications
*/
JO,
/**
* periodical in which the article was (or is to be, in the case of in-
* press references) published. This is an alphanumeric field of up to 255
* characters. If possible, periodical names should be abbreviated in the
* Index Medicus style, with periods after the abbreviations. If this is
* not possible (your large bibliography file in your wordprocessor has no
* periods after abbreviations), you can use the RIS Format (Adds periods)
* Import filter definition. This definition uses the Periodical Word
* Dictionary.
*/
JA,
/**
* Periodical name: user abbreviation 1. This is an alphanumeric field of
* up to 255 characters.
*/
J1,
/**
* Periodical name: user abbreviation 2. This is an alphanumeric field of
* up to 255 characters.
*/
J2,
/**
* Volume number. This is an optional field, there is no practical length
* limit to this field.
*/
VL,
/**
* Title Secondary. Note that the BT tag maps to this field for all
* reference types except for Whole Book and Unpublished Work
* references. This field can contain alphanumeric characters; there is no
* practical length limit to this field.
*/
T2,
/**
* Author Secondary. Each author must be on a separate line, preceded by
* this tag. Each reference can contain unlimited author
* fields. The author name must be in the correct syntax (refer to A1 and AU
* fields). This author name can be up to 255 characters long.
* @see #A1
*/
A2,
/**
* @see #A2
*/
ED,
/**
* Issue. This is an alphanumeric field, there is no practical
* length limit to this field.
*/
IS,
/**
* @see #IS
*/
CP,
/**
* City of publication; this is an alphanumeric field; there is no
* practical length limit to this field.
*/
CY,
/**
* Publisher; this is an alphanumeric field; there is no practical length
* limit to this field.
*/
PB,
/**
* Title Series. This field can contain alphanumeric characters; there is
* no practical length limit to this field.
*/
T3,
/**
* Author Series. Each author must be on a separate line, preceded by
* this tag. Each reference can unlimited author fields. The author name must be
* in the correct syntax (refer to A1 and AU fields). Each author name can be up
* to 255 characters long.
*/
A3,
/**
* Abstract. This is a free text field and can contain alphanumeric
* characters; there is no practical length limit to this field.
*/
N2,
/**
* ISSN/ISBN. This field can contain alphanumeric characters. There is no
* practical length limit to this field.
*/
SN,
/**
* Availability. This field can contain alphanumeric characters. There is
* no practical length limit to this field.
*/
AV,
/**
* Date Secondary. (Refer to Y1 and PY fields).
* @see #Y1
* @see #PY
*/
Y2,
/**
* Miscellaneous 1. This field can contain alphanumeric characters. There
* is no practical length limit to this field.
*/
M1,
/**
* Miscellaneous 2. This field can contain alphanumeric characters. There
is no practical length limit to this field.
*/
M2,
/**
* Miscellaneous 3. This field can contain alphanumeric characters. There
* is no practical length limit to this field.
*/
M3,
/**
* Address. This is a free text field and contain alphanumeric
* characters; there is no practical length limit to this field.
*/
AD,
/**
* Web/URL. There is no practical length limit to this field. URL
* addresses can be entered individually, one per tag or multiple addresses can
* be entered on one line using a semi-colon as a separator.
*/
UR,
/**
* Link to PDF. There is no practical length limit to this field. URL
* addresses can be entered individually, one per tag or multiple addresses can
* be entered on one line using a semi-colon as a separator.
*/
L1,
/**
* Link to Full-text. There is no practical length limit to this field.
* URL addresses can be entered Reference Manager Users Guide 365 individually,
* one per tag or multiple addresses can be entered on one line using a semi-
* colon as a separator.
*/
L2,
/**
* Related Records. There is no practical length limit to this field.
*/
L3,
/**
* Images. There is no practical length limit to this field.
*/
L4,
/**
* Edition. Not found in the specification, but used but by some other
* exports.
*/
ET
}

View File

@ -0,0 +1,169 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.scipublications.exporter.ris;
/**
* Reference types supported by the RIS format.
*
* @author Jens Pelzetter
*/
public enum RisTypes {
/**
* Abstract
*/
ABST,
/**
* Audiovisual material
*/
ADVS,
/**
* Art Work
*/
ART,
/**
* Bill/Resolution
*/
BILL,
/**
* Book, Whole
*/
BOOK,
/**
* Case
*/
CASE,
/**
* Book chapter
*/
CHAP,
/**
* Computer program
*/
COMP,
/**
* Conference proceedings
*/
CONF,
/**
* Catalog
*/
CTLG,
/**
* Data file
*/
DATA,
/**
* Electronic citation
*/
ELEC,
/**
* Generic
*/
GEN,
/**
* Hearing
*/
HEAR,
/**
* Internet Communication
*/
ICOMM,
/**
* In Press
*/
INPR,
/**
* Journal (full)
*/
JFULL,
/**
* Journal
*/
JOUR,
/**
* Map
*/
MAP,
/**
* Magazine article
*/
MGZN,
/**
* Motion picture
*/
MPCT,
/**
* Music score
*/
MUSIC,
/**
* Newspaper
*/
NEWS,
/**
* Pamphlet
*/
PAMP,
/**
* Patent
*/
PAT,
/**
* Personal communication
*/
PCOMM,
/**
* Report
*/
RPRT,
/**
* Serial (Book, Monograph)
*/
SER,
/**
* Slide
*/
SLIDE,
/**
* Sound recording
*/
SOUND,
/**
* Statute
*/
STAT,
/**
* Thesis/Dissertation
*/
THES,
/**
* Unenacted bill/resoution
*/
UNBILL,
/**
* Unpublished work
*/
UNPB,
/**
* Video recording
*/
VIDEO
}

View File

@ -0,0 +1,34 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.scipublications.exporter.bibtex.converters.*;
/**
*
* @author jensp
*/
public class UnsupportedCcmTypeException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Creates a new instance of <code>UnsupportedCcmType</code> without detail message.
*/
public UnsupportedCcmTypeException() {
}
/**
* Constructs an instance of <code>UnsupportedCcmType</code> with the specified detail message.
* @param msg the detail message.
*/
public UnsupportedCcmTypeException(final String msg) {
super(msg);
}
public UnsupportedCcmTypeException(final Throwable cause) {
super(cause);
}
public UnsupportedCcmTypeException(final String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -0,0 +1,45 @@
package com.arsdigita.cms.scipublications.exporter.ris;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.WorkingPaper;
/**
*
* @author Jens Pelzetter
*/
public class WorkingPaperConverter extends AbstractRisConverter {
@Override
public String convert(final Publication publication) {
WorkingPaper workingPaper;
if (!(publication instanceof WorkingPaper)) {
throw new UnsupportedCcmTypeException(
String.format("The WorkingPaperConverter only "
+ "supports publication types which are of the"
+ "type WorkingPaper or which are "
+ "extending "
+ "WorkingPaper. The "
+ "provided publication is of type '%s' which "
+ "is not of type "
+ "WorkingPaper and does not "
+ "extends WorkingPaper.",
publication.getClass().getName()));
}
workingPaper = (WorkingPaper) publication;
getRisBuilder().setType(RisTypes.UNPB);
convertAuthors(publication);
convertTitle(publication);
convertYear(publication);
return getRisBuilder().toRis();
}
@Override
public String getCcmType() {
return WorkingPaper.class.getName();
}
}

View File

@ -0,0 +1,20 @@
/**
* <p>
* The SciPublications package provides several functions for working
* with the Publication content types provided by the ccm-sci-publications
* module.
* </p>
* <p>
* This includes exporters for reference management software and imports
* from such formats. Examples are BibTeX and RIS.
* </p>
* <p>
* The entry point for all functions is provided by the
* <code>SciPublications</code>
* application and the <code>SciPublicationsServlet</code>. The application
* makes heavy use of the {@link ServiceLoader} class which was introduced in
* Java 1.6.
* </p>
*
*/
package com.arsdigita.cms.scipublications;