- 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-94f89814c4dfmaster
parent
fc02385f72
commit
14ab384925
|
|
@ -1 +1,2 @@
|
|||
com.arsdigita.cms.scipublications.exporter.bibtex.BibTeXExporter
|
||||
com.arsdigita.cms.scipublications.exporter.ris.RisExporter
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
|
|
@ -7,12 +26,19 @@ import com.arsdigita.web.Application;
|
|||
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
|
||||
*/
|
||||
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) {
|
||||
super(dobj);
|
||||
|
|
@ -30,5 +56,4 @@ public class SciPublications extends Application {
|
|||
public String getServletPath() {
|
||||
return "/scipublications/";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public class SciPublicationsLoader extends PackageLoader {
|
|||
ApplicationType type = setup.run();
|
||||
type.save();
|
||||
|
||||
//Install the application and mount the app at 'scipublications'.
|
||||
if (!Application.isInstalled(
|
||||
SciPublications.BASE_DATA_OBJECT_TYPE, "/scipublications/")) {
|
||||
Application app = Application.createApplication(type,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.categorization.Categorization;
|
||||
import com.arsdigita.categorization.CategorizedCollection;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
|
|
@ -24,6 +42,43 @@ import javax.servlet.http.HttpServletResponse;
|
|||
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
|
||||
*/
|
||||
|
|
@ -64,12 +119,9 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
|
||||
logger.debug(String.format("path = %s", path));
|
||||
|
||||
//Displays a text/plain page with a message.
|
||||
if (path.isEmpty()) {
|
||||
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.getWriter().append("Please choose an application.");
|
||||
|
|
@ -83,6 +135,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
|
||||
parameters = request.getParameterMap();
|
||||
|
||||
//Get the format parameter
|
||||
if (parameters.containsKey("format")) {
|
||||
if (parameters.get("format").length == 1) {
|
||||
format = parameters.get("format")[0];
|
||||
|
|
@ -105,6 +158,9 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
}
|
||||
|
||||
if (parameters.containsKey("category")) {
|
||||
/* If the category parameter is present, retrieve the
|
||||
* specified category and exports all publications in it.
|
||||
*/
|
||||
Publication publication;
|
||||
SciPublicationsExporter exporter;
|
||||
String categoryIdStr;
|
||||
|
|
@ -151,6 +207,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
|
||||
logger.debug(String.format("Category: %s", category.getName()));
|
||||
|
||||
//Get the exporter for the specified format.
|
||||
exporter = SciPublicationsExporters.getInstance().
|
||||
getExporterForFormat(
|
||||
format);
|
||||
|
|
@ -165,6 +222,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
//Get the category.
|
||||
objects = category.getObjects(ACSObject.BASE_DATA_OBJECT_TYPE);
|
||||
logger.debug(String.format("Category contains %d objects.",
|
||||
objects.size()));
|
||||
|
|
@ -172,9 +230,12 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
ACSObject object;
|
||||
while (objects.next()) {
|
||||
|
||||
//Get the bundle
|
||||
bundle = (ContentBundle) objects.getACSObject();
|
||||
//Get the default instance of the bundle
|
||||
object = bundle.getInstance(bundle.getDefaultLanguage());
|
||||
|
||||
//Ignore object if it is not an publication
|
||||
if (object instanceof Publication) {
|
||||
publication = (Publication) object;
|
||||
} else {
|
||||
|
|
@ -182,22 +243,30 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
continue;
|
||||
}
|
||||
|
||||
//Ignore none live versions.
|
||||
if (!publication.isLiveVersion()) {
|
||||
logger.debug("Object is no a published version, "
|
||||
+ "ignoring it.");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Write the exported publication to the response.
|
||||
response.getWriter().append(exporter.exportPublication(
|
||||
publication));
|
||||
response.getWriter().append('\n');
|
||||
//response.getWriter().append('\n');
|
||||
}
|
||||
|
||||
//Set the MimeType of the response
|
||||
response.setContentType(exporter.getSupportedFormat().
|
||||
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",
|
||||
String.format("attachment; filename=%s.bib",
|
||||
category.getName()));
|
||||
String.format("attachment; filename=%s.%s",
|
||||
category.getName(),
|
||||
exporter.getSupportedFormat().
|
||||
getFileExtension()));
|
||||
|
||||
return;
|
||||
} else if (parameters.containsKey("publication")) {
|
||||
|
|
@ -215,6 +284,8 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
//Retrieve the ids of the publication(s) to export from the
|
||||
//request.
|
||||
BigDecimal publicationId;
|
||||
publicationIds = new ArrayList<BigDecimal>();
|
||||
for (int i = 0; i < publications.length; i++) {
|
||||
|
|
@ -234,6 +305,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
publicationIds.add(publicationId);
|
||||
}
|
||||
|
||||
//Export the publictions.
|
||||
exportPublications(format, publicationIds, response);
|
||||
|
||||
} else {
|
||||
|
|
@ -247,6 +319,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
}
|
||||
|
||||
} else {
|
||||
//Respond with 404 when the requested action is unknown.
|
||||
logger.warn(String.format("Unknown pathinfo '%s', "
|
||||
+ "responding with 404...",
|
||||
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,
|
||||
final List<BigDecimal> publicationIds,
|
||||
final HttpServletResponse response)
|
||||
throws IOException {
|
||||
SciPublicationsExporter exporter;
|
||||
|
||||
//Get the exporter for the specified format.
|
||||
exporter = SciPublicationsExporters.getInstance().getExporterForFormat(
|
||||
format);
|
||||
|
||||
|
|
@ -276,26 +358,24 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Set the MimeType type of the response.
|
||||
response.setContentType(exporter.getSupportedFormat().getMimeType().
|
||||
getBaseType());
|
||||
|
||||
Publication publication = null;
|
||||
String publicationName = "publication";
|
||||
|
||||
|
||||
for (BigDecimal publicationId : publicationIds) {
|
||||
try {
|
||||
//Get the publication
|
||||
publication = new Publication(publicationId);
|
||||
logger.debug(String.format("OID of publication: %s",
|
||||
publication.getOID()));
|
||||
//Specialize the publication
|
||||
publication = (Publication) DomainObjectFactory.newInstance(publication.
|
||||
getOID());
|
||||
|
||||
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
logger.warn(String.format("No publication found for id '%s'.",
|
||||
publicationId.toPlainString()), ex);
|
||||
|
|
@ -310,23 +390,31 @@ public class SciPublicationsServlet extends BaseApplicationServlet {
|
|||
logger.debug(String.format("Publication is of type: %s",
|
||||
publication.getClass().getName()));
|
||||
|
||||
//Write the exported publication data to the response.
|
||||
response.getWriter().append(exporter.exportPublication(publication));
|
||||
response.getWriter().append('\n');
|
||||
//response.getWriter().append('\n');
|
||||
publicationName = publication.getName();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Force the browser to show a download dialog.
|
||||
if (publicationIds.size() == 1) {
|
||||
//If only one publication is exported, use the name (URL) of the
|
||||
//publication as filename.
|
||||
response.setHeader("Content-Disposition",
|
||||
String.format("attachment; filename=%s.bib",
|
||||
publicationName));
|
||||
|
||||
|
||||
String.format("attachment; filename=%s.%s",
|
||||
publicationName,
|
||||
exporter.getSupportedFormat().
|
||||
getFileExtension()));
|
||||
} else {
|
||||
//If more than one publication is exported, use 'publications' as
|
||||
//filename.
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=publications.bib");
|
||||
String.format(
|
||||
"attachment; filename=publications.%s",
|
||||
exporter.getSupportedFormat().
|
||||
getFileExtension()));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import javax.activation.MimeType;
|
||||
|
||||
/**
|
||||
* Describes the format provided by an implementation of
|
||||
* {@link SciPublicationsExporter}.
|
||||
*
|
||||
* @author jensp
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationFormat {
|
||||
|
||||
/**
|
||||
* Name of the format.
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* MimeType to use for files of the format.
|
||||
*/
|
||||
private MimeType mimeType;
|
||||
/**
|
||||
* File extension for files of the format.
|
||||
*/
|
||||
private String fileExtension;
|
||||
|
||||
public PublicationFormat() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
|
||||
/**
|
||||
* This interface describes the methods provided by all publication exporters.
|
||||
*
|
||||
* @author jensp
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public interface SciPublicationsExporter {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A description of the export format provided by this exporter.
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -8,22 +27,36 @@ import java.util.ServiceLoader;
|
|||
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 {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
SciPublicationsExporters.class);
|
||||
/**
|
||||
* Association of the format and the responsible exporters.
|
||||
*/
|
||||
private Map<String, SciPublicationsExporter> exporters =
|
||||
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 final SciPublicationsExporters INSTANCE =
|
||||
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() {
|
||||
logger.debug("Creating SciPublicationsExporter instance...");
|
||||
ServiceLoader<SciPublicationsExporter> exporterServices;
|
||||
|
|
@ -42,14 +75,28 @@ public final class SciPublicationsExporters {
|
|||
logger.debug(String.format("Found %d exporters.", exporters.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The instance of this class.
|
||||
*/
|
||||
public static SciPublicationsExporters getInstance() {
|
||||
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) {
|
||||
return exporters.get(format);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A list of all supported export formats.
|
||||
*/
|
||||
public List<PublicationFormat> getSupportedFormats() {
|
||||
List<PublicationFormat> supportedFormats;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.scipublications.exporter.PublicationFormat;
|
||||
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 javax.activation.MimeType;
|
||||
import javax.activation.MimeTypeParseException;
|
||||
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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public abstract class AbstractBibTeXBuilder implements BibTeXBuilder {
|
|||
builder);
|
||||
}
|
||||
|
||||
builder.append('}');
|
||||
builder.append("}\n");
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
private BibTeXBuilder bibTeXBuilder;
|
||||
|
||||
/**
|
||||
* Convert the authors of a publication to BibTeX.
|
||||
*
|
||||
* @param publication The publication to use.
|
||||
*/
|
||||
protected void convertAuthors(final Publication publication) {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
getBibTeXBuilder().setField(BibTeXField.TITLE, publication.getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the year of publication to BibTeX.
|
||||
*
|
||||
* @param publication
|
||||
* @throws UnsupportedFieldException
|
||||
*/
|
||||
protected void convertYear(final Publication publication)
|
||||
throws UnsupportedFieldException {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
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)
|
||||
throws UnsupportedFieldException {
|
||||
SeriesCollection seriesColl =
|
||||
publication.getSeries();
|
||||
SeriesCollection seriesColl = publication.getSeries();
|
||||
if ((seriesColl != null) && (seriesColl.size() > 0)) {
|
||||
|
||||
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() {
|
||||
if (bibTeXBuilder == null) {
|
||||
bibTeXBuilder = BibTeXBuilders.getInstance().
|
||||
|
|
@ -114,5 +189,9 @@ public abstract class AbstractBibTeXConverter implements BibTeXConverter {
|
|||
return bibTeXBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The BibTeX type to use for building the BibTeX data.
|
||||
*/
|
||||
protected abstract String getBibTeXType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
|
|||
|
||||
if (article.getCollectedVolume().getPublisher() == null) {
|
||||
builder.setField(BibTeXField.PUBLISHER, "");
|
||||
} else {
|
||||
builder.setField(BibTeXField.PUBLISHER,
|
||||
article.getCollectedVolume().getPublisher().
|
||||
getTitle());
|
||||
}
|
||||
|
||||
if (article.getCollectedVolume().getVolume() != null) {
|
||||
|
|
@ -61,6 +65,12 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
|
|||
article.getCollectedVolume().getVolume().
|
||||
toString());
|
||||
}
|
||||
|
||||
if (article.getCollectedVolume().getEdition() != null) {
|
||||
builder.setField(BibTeXField.EDITION,
|
||||
article.getCollectedVolume().getEdition());
|
||||
}
|
||||
|
||||
SeriesCollection seriesColl =
|
||||
article.getCollectedVolume().getSeries();
|
||||
if ((seriesColl != null) && (seriesColl.size() > 0)) {
|
||||
|
|
@ -72,13 +82,8 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
|
|||
|
||||
seriesColl.close();
|
||||
}
|
||||
} else {
|
||||
builder.setField(BibTeXField.PUBLISHER,
|
||||
article.getCollectedVolume().getPublisher().
|
||||
getTitle());
|
||||
}
|
||||
|
||||
|
||||
if (article.getChapter() != null) {
|
||||
builder.setField(BibTeXField.CHAPTER, article.getChapter());
|
||||
}
|
||||
|
|
@ -90,10 +95,7 @@ public class ArticleInCollectedVolumeConverter extends AbstractBibTeXConverter {
|
|||
article.getPagesTo()));
|
||||
}
|
||||
|
||||
if (article.getCollectedVolume().getEdition() != null) {
|
||||
builder.setField(BibTeXField.EDITION,
|
||||
article.getCollectedVolume().getEdition());
|
||||
}
|
||||
|
||||
} catch (UnsupportedFieldException ex) {
|
||||
logger.warn("Tried to set unsupported BibTeX field while "
|
||||
+ "converting a publication");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
|
||||
/**
|
||||
* Interface for the BibTeX converters.
|
||||
*
|
||||
* @param <T>
|
||||
* @author jensp
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @return The CCM publication type supported by this converter.
|
||||
*/
|
||||
String getCcmType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
|
|
@ -5,20 +24,27 @@ import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Provides easy access to all available BibTeX converters.
|
||||
*
|
||||
* @author jensp
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
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 =
|
||||
new HashMap<String, BibTeXConverter>();
|
||||
|
||||
/**
|
||||
* Finds all available {@link BibTeXConverter}s and puts them into the
|
||||
* map.
|
||||
*/
|
||||
private BibTeXConverters() {
|
||||
logger.debug("Loading BibTeX converters...");
|
||||
ServiceLoader<BibTeXConverter> converterServices;
|
||||
|
|
@ -38,33 +64,48 @@ public class BibTeXConverters {
|
|||
private static BibTeXConverters INSTANCE = new BibTeXConverters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The instance of this class.
|
||||
*/
|
||||
public static BibTeXConverters getInstance() {
|
||||
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) {
|
||||
try {
|
||||
BibTeXConverter 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.");
|
||||
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.");
|
||||
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 BibTeX converter.", ex);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ExpertiseConverter extends AbstractBibTeXConverter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ExpertiseConverter.class);
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
ExpertiseConverter.class);
|
||||
|
||||
@Override
|
||||
protected String getBibTeXType() {
|
||||
|
|
@ -55,5 +56,4 @@ public class ExpertiseConverter extends AbstractBibTeXConverter {
|
|||
public String getCcmType() {
|
||||
return Expertise.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class GreyLiteratureConverter extends AbstractBibTeXConverter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(GreyLiteratureConverter.class);
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
GreyLiteratureConverter.class);
|
||||
|
||||
@Override
|
||||
protected String getBibTeXType() {
|
||||
|
|
@ -55,5 +56,4 @@ public class GreyLiteratureConverter extends AbstractBibTeXConverter {
|
|||
public String getCcmType() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
|
|||
import com.arsdigita.cms.contenttypes.InProceedings;
|
||||
import com.arsdigita.cms.contenttypes.Proceedings;
|
||||
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.BibTeXField;
|
||||
import com.arsdigita.cms.scipublications.exporter.bibtex.builders.UnsupportedFieldException;
|
||||
|
|
@ -67,7 +66,7 @@ public class InProceedingsConverter extends AbstractBibTeXConverter {
|
|||
proceedings.getTitle());
|
||||
|
||||
convertVolume(proceedings);
|
||||
convertSeries(publication);
|
||||
convertSeries(proceedings);
|
||||
|
||||
if (proceedings.getOrganizerOfConference() != null) {
|
||||
builder.setField(BibTeXField.ORGANIZATION,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.arsdigita.cms.scipublications.exporter.bibtex.converters;
|
|||
import com.arsdigita.cms.contenttypes.InternetArticle;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
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 org.apache.log4j.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class MonographConverter extends AbstractBibTeXConverter {
|
|||
convertEdition(monograph);
|
||||
} catch (UnsupportedFieldException ex) {
|
||||
logger.warn("Tried to set unsupported BibTeX field while "
|
||||
+ "converting a publication");
|
||||
+ "converting a publication", ex);
|
||||
}
|
||||
|
||||
return getBibTeXBuilder().toBibTeX();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class PublicationConverter extends AbstractBibTeXConverter {
|
|||
convertYear(publication);
|
||||
} catch (UnsupportedFieldException ex) {
|
||||
logger.warn("Tried to set unsupported BibTeX field while "
|
||||
+ "converting a publication");
|
||||
+ "converting a publication", ex);
|
||||
}
|
||||
|
||||
return getBibTeXBuilder().toBibTeX();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 author’s 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 C—RIS
|
||||
* 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 User’s 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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
Loading…
Reference in New Issue