Some Bugfixes for Publication Export

git-svn-id: https://svn.libreccm.org/ccm/trunk@5817 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-01-30 17:42:54 +00:00
parent 234c11af0f
commit 8d2060ec0e
6 changed files with 126 additions and 91 deletions

View File

@ -1,21 +1,22 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-pages" name="ccm-pages"
prettyName="Pages" prettyName="Pages"
version="6.0.0" version="6.0.0"
release="2" release="2"
webapp="ROOT"> webapp="ROOT">
<ccm:dependencies> <ccm:dependencies>
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/> <ccm:requires name="ccm-cms" version="6.6.0" relation="ge" />
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/> <ccm:requires name="ccm-core" version="6.6.0" relation="ge" />
<ccm:requires name="ccm-subsite" version="6.6.0" relation="ge"/> <ccm:requires name="ccm-ldn-terms" version="6.6.0" relation="ge" />
<ccm:requires name="ccm-ldn-terms" version="6.6.0" relation="ge"/> <ccm:requires name="ccm-subsite" version="6.6.0" relation="ge" />
<ccm:requires name="ccm-themedirector" version="6.6.0" relation="ge" />
</ccm:dependencies> </ccm:dependencies>
<ccm:contacts> <ccm:contacts>
<ccm:contact uri="https://www.scientificcms.org" type="website"/> <ccm:contact uri="https://www.scientificcms.org" type="website"/>
<ccm:contact uri="mailto:info@scentificcms.org" type="support"/> <ccm:contact uri="mailto:info@scentificcms.org" type="support"/>
</ccm:contacts> </ccm:contacts>
<ccm:description> <ccm:description>

View File

@ -29,33 +29,33 @@ import java.util.List;
/** /**
* <p> * <p>
* This is the base class for all other Publication Content types. The * This is the base class for all other Publication Content types. The following
* following UML class diagram shows an overview of the classes of the * UML class diagram shows an overview of the classes of the Publications
* Publications module. Please note that the UML diagram shown an general * module. Please note that the UML diagram shown an general overview of the
* overview of the classes/object types of the publications module. It shows * classes/object types of the publications module. It shows the attributes of
* the attributes of the content types and theirs associations between them. Not * the content types and theirs associations between them. Not all classes shown
* all classes shown in the UML have a Java counterpart. These classes are * in the UML have a Java counterpart. These classes are representing
* representing associations <em>with</em> extra attributes. The associations * associations <em>with</em> extra attributes. The associations are defined in
* are defined in the PDL files of this module. * the PDL files of this module.
* </p> * </p>
* <p> * <p>
* <img src="doc-files/PublicationModule.png" width="100%"> * <img src="doc-files/PublicationModule.png" width="100%">
* </p> * </p>
* <p> * <p>
* This class is not a directly usable Content type. Its is only used to * This class is not a directly usable Content type. Its is only used to define
* define some common attributes needed for all kinds of publications. * some common attributes needed for all kinds of publications.
* </p> * </p>
* <p> * <p>
* As of version 6.6.1 of this module, the reviewed property has been moved * As of version 6.6.1 of this module, the reviewed property has been moved from
* from the types {@link ArticleInCollectedVolume}, {@link ArticleInJournal}, * the types {@link ArticleInCollectedVolume}, {@link ArticleInJournal},
* {@link CollectedVolume}, {@link Monograph} and {@link WorkingPaper} to this * {@link CollectedVolume}, {@link Monograph} and {@link WorkingPaper} to this
* class. This has been done for performance reasons. Several use cases demanded * class. This has been done for performance reasons. Several use cases demanded
* the use of a data query (for performance reasons) over all publications with * the use of a data query (for performance reasons) over all publications with
* the option to filter for reviewed publications. Since the reviewed property * the option to filter for reviewed publications. Since the reviewed property
* was only available for some types this was not possible, even with joins. * was only available for some types this was not possible, even with joins. The
* The publications types which do not need the reviewed property will not show * publications types which do not need the reviewed property will not show this
* this property in their forms. Also, the reviewed property was excluded from * property in their forms. Also, the reviewed property was excluded from the
* the XML of these types using their traversal adapters. * XML of these types using their traversal adapters.
* </p> * </p>
* *
* *
@ -76,8 +76,8 @@ public class Publication extends ContentPage {
public static final String REVIEWED = "reviewed"; public static final String REVIEWED = "reviewed";
public static final String FIRST_PUBLISHED = "yearFirstPublished"; public static final String FIRST_PUBLISHED = "yearFirstPublished";
public static final String LANG = "languageOfPublication"; public static final String LANG = "languageOfPublication";
public final static String BASE_DATA_OBJECT_TYPE = public final static String BASE_DATA_OBJECT_TYPE
"com.arsdigita.cms.contenttypes.Publication"; = "com.arsdigita.cms.contenttypes.Publication";
private final static PublicationsConfig config = new PublicationsConfig(); private final static PublicationsConfig config = new PublicationsConfig();
static { static {
@ -89,7 +89,7 @@ public class Publication extends ContentPage {
} }
public Publication(final BigDecimal id) throws public Publication(final BigDecimal id) throws
DataObjectNotFoundException { DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id)); this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
@ -151,8 +151,8 @@ public class Publication extends ContentPage {
} }
/** /**
* Retrieves the contents of the misc field. This field can be used for * Retrieves the contents of the misc field. This field can be used for all
* all sorts of remarks etc. which do not fit in the other fields. * sorts of remarks etc. which do not fit in the other fields.
* *
* @return Contents of the misc field. * @return Contents of the misc field.
*/ */
@ -170,7 +170,12 @@ public class Publication extends ContentPage {
} }
public Boolean getReviewed() { public Boolean getReviewed() {
return (Boolean) get(REVIEWED); final Object value = get(REVIEWED);
if (value == null) {
return null;
} else {
return (Boolean) get(REVIEWED);
}
} }
public void setReviewed(final Boolean reviewed) { public void setReviewed(final Boolean reviewed) {
@ -191,19 +196,16 @@ public class Publication extends ContentPage {
* Adds an author to the publication * Adds an author to the publication
* *
* @param author The author to add. This can an instance of any content type * @param author The author to add. This can an instance of any content type
* which is derivated from the {@link GenericPerson} type. * which is derivated from the {@link GenericPerson} type.
* @param editor Is the author an editor? * @param editor Is the author an editor?
*/ */
public void addAuthor(final GenericPerson author, final Boolean editor) { public void addAuthor(final GenericPerson author, final Boolean editor) {
//Assert.exists(author, GenericPerson.class); //Assert.exists(author, GenericPerson.class);
//DataObject link = add(AUTHORS, author); //DataObject link = add(AUTHORS, author);
//link.set(EDITOR, editor); //link.set(EDITOR, editor);
//link.set(AUTHOR_ORDER, Integer.valueOf((int) getAuthors().size())); //link.set(AUTHOR_ORDER, Integer.valueOf((int) getAuthors().size()));
//updateAuthorsStr(); //updateAuthorsStr();
getPublicationBundle().addAuthor(author, editor); getPublicationBundle().addAuthor(author, editor);
} }
@ -249,7 +251,7 @@ public class Publication extends ContentPage {
* Method to check if the publication has authors. * Method to check if the publication has authors.
* *
* @return {@code true} if the publications has authors, {@code false} * @return {@code true} if the publications has authors, {@code false}
* otherwise. * otherwise.
*/ */
public boolean hasAuthors() { public boolean hasAuthors() {
return !getAuthors().isEmpty(); return !getAuthors().isEmpty();
@ -271,7 +273,6 @@ public class Publication extends ContentPage {
//Assert.exists(series, Series.class); //Assert.exists(series, Series.class);
//remove(SERIES, series); //remove(SERIES, series);
getPublicationBundle().removeSeries(series); getPublicationBundle().removeSeries(series);
} }
@ -289,12 +290,11 @@ public class Publication extends ContentPage {
//Assert.exists(orgaunit, GenericOrganizationalUnit.class); //Assert.exists(orgaunit, GenericOrganizationalUnit.class);
//add(ORGAUNITS, orgaunit); //add(ORGAUNITS, orgaunit);
getPublicationBundle().addOrganizationalUnit(orgaunit); getPublicationBundle().addOrganizationalUnit(orgaunit);
} }
public void removeOrganizationalUnit( public void removeOrganizationalUnit(
final GenericOrganizationalUnit orgaunit) { final GenericOrganizationalUnit orgaunit) {
//Assert.exists(orgaunit, GenericOrganizationalUnit.class); //Assert.exists(orgaunit, GenericOrganizationalUnit.class);
//remove(ORGAUNITS, orgaunit); //remove(ORGAUNITS, orgaunit);
@ -305,18 +305,18 @@ public class Publication extends ContentPage {
return !getOrganizationalUnits().isEmpty(); return !getOrganizationalUnits().isEmpty();
} }
public static PublicationBundleCollection getPublications(final GenericPerson person) { public static PublicationBundleCollection getPublications(
final GenericPerson person) {
return PublicationBundle.getPublications(person); return PublicationBundle.getPublications(person);
} }
public static GenericOrganizationalUnitPublicationsCollection getPublications( public static GenericOrganizationalUnitPublicationsCollection getPublications(
final GenericOrganizationalUnit orgaunit) { final GenericOrganizationalUnit orgaunit) {
//final DataCollection dataCollection = (DataCollection) orgaunit.get( //final DataCollection dataCollection = (DataCollection) orgaunit.get(
// ORGAUNIT_PUBLICATIONS); // ORGAUNIT_PUBLICATIONS);
//return new GenericOrganizationalUnitPublicationsCollection( //return new GenericOrganizationalUnitPublicationsCollection(
// dataCollection); // dataCollection);
return PublicationBundle.getPublications(orgaunit); return PublicationBundle.getPublications(orgaunit);
} }
@ -329,8 +329,8 @@ public class Publication extends ContentPage {
} }
public static void removePublication( public static void removePublication(
final GenericOrganizationalUnit orgaunit, final GenericOrganizationalUnit orgaunit,
final Publication publication) { final Publication publication) {
//Assert.exists(publication); //Assert.exists(publication);
//orgaunit.remove(ORGAUNIT_PUBLICATIONS, publication); //orgaunit.remove(ORGAUNIT_PUBLICATIONS, publication);
@ -372,14 +372,16 @@ public class Publication extends ContentPage {
@Override @Override
public List<ExtraXMLGenerator> getExtraListXMLGenerators() { public List<ExtraXMLGenerator> getExtraListXMLGenerators() {
final List<ExtraXMLGenerator> generators = super.getExtraListXMLGenerators(); final List<ExtraXMLGenerator> generators = super
.getExtraListXMLGenerators();
generators.add(new PublicationExtraXmlGenerator()); generators.add(new PublicationExtraXmlGenerator());
return generators; return generators;
} }
@Override @Override
public String getSearchSummary() { public String getSearchSummary() {
String summary = String.format("%s %s %s", getTitle(), (String)get(AUTHORS_STR), getAbstract()); String summary = String.format("%s %s %s", getTitle(), (String) get(
AUTHORS_STR), getAbstract());
if (summary.length() > 4000) { if (summary.length() > 4000) {
summary = summary.substring(0, 4000); summary = summary.substring(0, 4000);
} }

View File

@ -79,6 +79,8 @@ public class ExportAllPublications extends Program {
getNegotiatedLocale().getLanguage()); getNegotiatedLocale().getLanguage());
} }
publications.addEqualsFilter("version", "live");
publications.addOrder("yearOfPublication desc"); publications.addOrder("yearOfPublication desc");
publications.addOrder("authorsStr"); publications.addOrder("authorsStr");
publications.addOrder("title"); publications.addOrder("title");
@ -109,13 +111,18 @@ public class ExportAllPublications extends Program {
long index = 1; long index = 1;
while (publications.next()) { while (publications.next()) {
System.out.printf("Exporting publication %d of %d...%n", System.out.printf("Exporting publication %d of %d... ",
index, index,
publications.size()); publications.size());
final Publication publication final Publication publication
= (Publication) DomainObjectFactory = (Publication) DomainObjectFactory
.newInstance(publications.getDataObject()); .newInstance(publications.getDataObject());
System.out.printf("oid = \"%s\", name = \"%s\"%n",
publication.getOID().toString(),
publication.getName());
writer.append(exporter.exportPublication(publication)); writer.append(exporter.exportPublication(publication));
index++; index++;
} }

View File

@ -56,7 +56,9 @@ public abstract class AbstractRisConverter implements RisConverter {
} }
protected void convertYear(final Publication publication) { protected void convertYear(final Publication publication) {
getRisBuilder().addField(RisField.PY, String.format("%d///", publication.getYearOfPublication())); if (publication.getYearOfPublication() != null) {
getRisBuilder().addField(RisField.PY, String.format("%d", publication.getYearOfPublication()));
}
} }
protected void convertPublisher(final PublicationWithPublisher publication) { protected void convertPublisher(final PublicationWithPublisher publication) {

View File

@ -23,6 +23,8 @@ import com.arsdigita.cms.scipublications.imexporter.ris.RisField;
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 java.util.Objects;
/** /**
* Converts a {@link InternetArticle} to a RIS reference. * Converts a {@link InternetArticle} to a RIS reference.
* *
@ -35,6 +37,9 @@ public class InternetArticleConverter extends AbstractRisConverter {
public String convert(final Publication publication) { public String convert(final Publication publication) {
InternetArticle article; InternetArticle article;
System.err.printf("Converting publication %s as InternetArticle to RIS...%n",
Objects.toString(publication));
if (!(publication instanceof InternetArticle)) { if (!(publication instanceof InternetArticle)) {
throw new UnsupportedCcmTypeException( throw new UnsupportedCcmTypeException(
String.format("The InternetArticleConverter only " String.format("The InternetArticleConverter only "
@ -49,21 +54,29 @@ public class InternetArticleConverter extends AbstractRisConverter {
publication.getClass().getName())); publication.getClass().getName()));
} }
System.err.printf("Casting to InternetArticle%n");
article = (InternetArticle) publication; article = (InternetArticle) publication;
System.err.printf("Setting RIS type to EJOUR...%n");
getRisBuilder().setType(RisType.EJOUR); getRisBuilder().setType(RisType.EJOUR);
System.err.printf("Converting authors...%n");
convertAuthors(publication); convertAuthors(publication);
System.err.printf("Converting title...%n");
convertTitle(publication); convertTitle(publication);
System.err.printf("Converting year...%n");
convertYear(publication); convertYear(publication);
if (article.getReviewed()) { System.err.printf("Converting reviewed...%n");
if (article.getReviewed() != null && article.getReviewed()) {
getRisBuilder().addField(RisField.RI, ""); getRisBuilder().addField(RisField.RI, "");
} }
System.err.printf("Converting URL...%n");
if (article.getUrl() != null) { if (article.getUrl() != null) {
getRisBuilder().addField(RisField.UR, article.getUrl()); getRisBuilder().addField(RisField.UR, article.getUrl());
} }
System.err.printf("Building String%n");
return getRisBuilder().toRis(); return getRisBuilder().toRis();
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.subsite; package com.arsdigita.subsite;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
@ -38,16 +37,24 @@ import java.math.BigDecimal;
*/ */
public class Site extends ACSObject { public class Site extends ACSObject {
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE
"com.arsdigita.subsite.Site"; = "com.arsdigita.subsite.Site";
/** Title for a subsite, text field. */ /**
* Title for a subsite, text field.
*/
public static final String TITLE = "title"; public static final String TITLE = "title";
/** Description for a subsite, text field. */ /**
* Description for a subsite, text field.
*/
public static final String DESCRIPTION = "description"; public static final String DESCRIPTION = "description";
/** Subsite host name, text field, must be unique. */ /**
* Subsite host name, text field, must be unique.
*/
public static final String HOSTNAME = "hostname"; public static final String HOSTNAME = "hostname";
/** Directory containin the theme to be used for the subsite. */ /**
* Directory containin the theme to be used for the subsite.
*/
public static final String STYLE_DIRECTORY = "styleDirectory"; public static final String STYLE_DIRECTORY = "styleDirectory";
public static final String FRONT_PAGE = "frontPage"; public static final String FRONT_PAGE = "frontPage";
public static final String TEMPLATE_CONTEXT = "templateContext"; public static final String TEMPLATE_CONTEXT = "templateContext";
@ -61,6 +68,7 @@ public class Site extends ACSObject {
/** /**
* Constructor * Constructor
*
* @param type * @param type
*/ */
public Site(String type) { public Site(String type) {
@ -141,19 +149,21 @@ public class Site extends ACSObject {
public static Site retrieve(BigDecimal id) public static Site retrieve(BigDecimal id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
return (Site)DomainObjectFactory.newInstance( return (Site) DomainObjectFactory.newInstance(
new OID(BASE_DATA_OBJECT_TYPE, id) new OID(BASE_DATA_OBJECT_TYPE, id)
); );
} }
public static Site retrieve(DataObject obj) { public static Site retrieve(DataObject obj) {
return (Site)DomainObjectFactory.newInstance(obj); return (Site) DomainObjectFactory.newInstance(obj);
} }
/** /**
* *
* @param hostname * @param hostname
*
* @return * @return
*
* @throws DataObjectNotFoundException * @throws DataObjectNotFoundException
*/ */
public static Site findByHostname(String hostname) public static Site findByHostname(String hostname)
@ -178,8 +188,8 @@ public class Site extends ACSObject {
} }
public TemplateContext getTemplateContext() { public TemplateContext getTemplateContext() {
return (TemplateContext)DomainObjectFactory return (TemplateContext) DomainObjectFactory
.newInstance((DataObject)get(TEMPLATE_CONTEXT)); .newInstance((DataObject) get(TEMPLATE_CONTEXT));
} }
public void setTitle(String title) { public void setTitle(String title) {
@ -188,7 +198,7 @@ public class Site extends ACSObject {
} }
public String getTitle() { public String getTitle() {
return(String)get(TITLE); return (String) get(TITLE);
} }
public void setDescription(String description) { public void setDescription(String description) {
@ -197,7 +207,7 @@ public class Site extends ACSObject {
} }
public String getDescription() { public String getDescription() {
return(String)get(DESCRIPTION); return (String) get(DESCRIPTION);
} }
public void setHostname(String hostname) { public void setHostname(String hostname) {
@ -205,7 +215,7 @@ public class Site extends ACSObject {
} }
public String getHostname() { public String getHostname() {
return(String)get(HOSTNAME); return (String) get(HOSTNAME);
} }
public void setStyleDirectory(String styleDirectory) { public void setStyleDirectory(String styleDirectory) {
@ -213,7 +223,7 @@ public class Site extends ACSObject {
} }
public String getStyleDirectory() { public String getStyleDirectory() {
return(String)get(STYLE_DIRECTORY); return (String) get(STYLE_DIRECTORY);
} }
public void setRootCategory(Category rootCategory) { public void setRootCategory(Category rootCategory) {
@ -229,8 +239,8 @@ public class Site extends ACSObject {
} }
public Application getFrontPage() { public Application getFrontPage() {
return (Application)DomainObjectFactory return (Application) DomainObjectFactory
.newInstance((DataObject)get(FRONT_PAGE)); .newInstance((DataObject) get(FRONT_PAGE));
} }
} }