Daten für die Zeitschrift aus ArticleInJournal in neuen CT Journal ausgelagert, Journal und Article werden verknüpft (wie CollectedVolume und ArticleInCollectedVolume).
git-svn-id: https://svn.libreccm.org/ccm/trunk@610 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1bebba7cd2
commit
66cf0be88c
|
|
@ -25,12 +25,10 @@ import com.arsdigita.cms.ContentPage;
|
||||||
// PDL definition for an article in a journal
|
// PDL definition for an article in a journal
|
||||||
object type ArticleInJournal extends Publication {
|
object type ArticleInJournal extends Publication {
|
||||||
|
|
||||||
String[0..1] journal = ct_article_in_journal.journal VARCHAR(512);
|
|
||||||
Integer[0..1] volume = ct_article_in_journal.volume INTEGER;
|
Integer[0..1] volume = ct_article_in_journal.volume INTEGER;
|
||||||
String[0..1] issue = ct_article_in_journal.issue VARCHAR(512);
|
String[0..1] issue = ct_article_in_journal.issue VARCHAR(512);
|
||||||
Integer[0..1] pagesFrom = ct_article_in_journal.pages_from INTEGER;
|
Integer[0..1] pagesFrom = ct_article_in_journal.pages_from INTEGER;
|
||||||
Integer[0..1] pagesTo = ct_article_in_journal.pages_to INTEGER;
|
Integer[0..1] pagesTo = ct_article_in_journal.pages_to INTEGER;
|
||||||
String[0..1] issn = ct_article_in_journal.issn VARCHAR(9);
|
|
||||||
Date[0..1] publicationDate = ct_article_in_journal.publication_date DATE;
|
Date[0..1] publicationDate = ct_article_in_journal.publication_date DATE;
|
||||||
|
|
||||||
reference key (ct_article_in_journal.article_in_journal_id);
|
reference key (ct_article_in_journal.article_in_journal_id);
|
||||||
|
|
|
||||||
|
|
@ -22,24 +22,25 @@ model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
|
||||||
//PDL definition for the basic attributes of publication.
|
//PDL definition for a journal
|
||||||
object type PublicationList extends ContentPage {
|
object type Journal extends Publication {
|
||||||
|
|
||||||
String[0..1] description = ct_publicationlists.description VARCHAR(2048);
|
String[0..1] issn = ct_journal.issn VARCHAR(9);
|
||||||
|
|
||||||
reference key (ct_publicationlists.publicationlist_id);
|
reference key (ct_journal.journal_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Association which links the publication list(s) and the publications
|
|
||||||
association {
|
association {
|
||||||
|
|
||||||
PublicationList[0..n] publicationLists = join ct_publications.publication_id
|
Journal[0..n] journal = join ct_article_in_journal.article_in_journal_id
|
||||||
to ct_publicationlists_map.publication_id,
|
to ct_journal_article_map.article_in_journal_id,
|
||||||
join ct_publicationlists_map.publicationlist_id
|
join ct_journal_article_map.journal_id
|
||||||
to ct_publicationlists.publicationlist_id;
|
to ct_journal.journal_id;
|
||||||
|
|
||||||
Publication[0..n] publications = join ct_publicationlists.publicationlist_id
|
ArticleInJournal[0..n] articles = join ct_journal.journal_id
|
||||||
to ct_publicationlists_map.publicationlist_id,
|
to ct_journal_article_map.journal_id,
|
||||||
join ct_publicationlists_map.publication_id
|
join ct_journal.article_map.article_in_journal_id
|
||||||
to ct_publications.publication_id;
|
to ct_article_in_journal.article_in_journal_id;
|
||||||
|
|
||||||
|
Integer[0..1] articleOrder = ct_journal_article_map.article_order INTEGER;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
|
<ctd:content-type
|
||||||
|
label="SciPublications/Journal"
|
||||||
|
description="Base type for articleInJournals"
|
||||||
|
objectType="com.arsdigita.cms.contenttypes.Journal"
|
||||||
|
classname="com.arsdigita.cms.contenttypes.Journal">
|
||||||
|
|
||||||
|
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||||
|
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="publications.ui.articleInJournal_properties.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||||
|
descriptionKey="publications.ui.articleInJournal.basic_properties.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.JournalPropertiesStep"
|
||||||
|
ordering="1"/>
|
||||||
|
|
||||||
|
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||||
|
|
||||||
|
</ctd:authoring-kit>
|
||||||
|
|
||||||
|
</ctd:content-type>
|
||||||
|
|
||||||
|
|
||||||
|
</ctd:content-types>
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
|
||||||
|
|
||||||
<ctd:content-type
|
|
||||||
label="SciPublications/PublicationList"
|
|
||||||
description="A list of publications"
|
|
||||||
objectType="com.arsdigita.cms.contenttypes.PublicationList"
|
|
||||||
classname="com.arsdigita.cms.contenttypes.PublicationList">
|
|
||||||
|
|
||||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
|
||||||
|
|
||||||
<ctd:authoring-step
|
|
||||||
labelKey="publications.ui.publicationlist_properties.title"
|
|
||||||
labelBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
|
||||||
descriptionKey="publications.ui.publicationlist_properties.title.description"
|
|
||||||
descriptionBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
|
||||||
component="com.arsdigita.cms.contenttypes.ui.PublicationListPropertiesStep"
|
|
||||||
ordering="1"/>
|
|
||||||
|
|
||||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
|
||||||
|
|
||||||
</ctd:authoring-kit>
|
|
||||||
|
|
||||||
</ctd:content-type>
|
|
||||||
|
|
||||||
|
|
||||||
</ctd:content-types>
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xrd:adapters
|
||||||
|
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||||
|
|
||||||
|
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
|
||||||
|
|
||||||
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.ArticleInJournal"
|
||||||
|
extends="com.arsdigita.cms.contenttypes.PublicationWithPublisher">
|
||||||
|
<xrd:associations rule="include">
|
||||||
|
<xrd:property name="/object/journal"/>
|
||||||
|
</xrd:associations>
|
||||||
|
</xrd:adapter>
|
||||||
|
|
||||||
|
</xrd:context>
|
||||||
|
|
||||||
|
</xrd:adapters>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xrd:adapters
|
||||||
|
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||||
|
|
||||||
|
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
|
||||||
|
|
||||||
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.Journal"
|
||||||
|
extends="com.arsdigita.cms.contenttypes.PublicationWithPublisher">
|
||||||
|
<xrd:associations rule="include">
|
||||||
|
<xrd:property name="/object/articles"/>
|
||||||
|
</xrd:associations>
|
||||||
|
</xrd:adapter>
|
||||||
|
|
||||||
|
</xrd:context>
|
||||||
|
|
||||||
|
</xrd:adapters>
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
<table name="ct_proceedings"/>
|
<table name="ct_proceedings"/>
|
||||||
<table name="ct_inproceedings"/>
|
<table name="ct_inproceedings"/>
|
||||||
<table name="ct_internet_article"/>
|
<table name="ct_internet_article"/>
|
||||||
|
<table name="ct_journal"/>
|
||||||
<table name="ct_article_in_journal"/>
|
<table name="ct_article_in_journal"/>
|
||||||
<table name="ct_unpublished"/>
|
<table name="ct_unpublished"/>
|
||||||
<table name="ct_grey_literature"/>
|
<table name="ct_grey_literature"/>
|
||||||
<table name="ct_working_paper"/>
|
<table name="ct_working_paper"/>
|
||||||
<table name="ct_expertise"/>
|
<table name="ct_expertise"/>
|
||||||
<table name="ct_review"/>
|
<table name="ct_review"/>
|
||||||
<table name="ct_publicationlists"/>
|
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.PublicationWithPublisherInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.PublicationWithPublisherInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.SeriesInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.SeriesInitializer"/>
|
||||||
|
|
@ -33,13 +33,13 @@
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.ProceedingsInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.ProceedingsInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.InProceedingsInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.InProceedingsInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.InternetArticleInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.InternetArticleInitializer"/>
|
||||||
|
<initializer class="com.arsdigita.cms.contenttypes.JournalInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.ArticleInJournalInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.ArticleInJournalInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.UnPublishedInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.UnPublishedInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.GreyLiteratureInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.GreyLiteratureInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.WorkingPaperInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.WorkingPaperInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.ExpertiseInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.ExpertiseInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.ReviewInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.ReviewInitializer"/>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.PublicationListInitializer"/>
|
|
||||||
</provides>
|
</provides>
|
||||||
<scripts>
|
<scripts>
|
||||||
<schema directory="ccm-sci-publications"/>
|
<schema directory="ccm-sci-publications"/>
|
||||||
|
|
@ -53,12 +53,12 @@
|
||||||
<data class="com.arsdigita.cms.contenttypes.ProceedingsLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.ProceedingsLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.InProceedingsLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.InProceedingsLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.InternetArticleLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.InternetArticleLoader"/>
|
||||||
|
<data class="com.arsdigita.cms.contenttypes.JournalLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.ArticleInJournalLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.ArticleInJournalLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.UnPublishedLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.UnPublishedLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.GreyLiteratureLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.GreyLiteratureLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.WorkingPaperLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.WorkingPaperLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.ExpertiseLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.ExpertiseLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.ReviewLoader"/>
|
<data class="com.arsdigita.cms.contenttypes.ReviewLoader"/>
|
||||||
<data class="com.arsdigita.cms.contenttypes.PublicationListLoader"/>
|
|
||||||
</scripts>
|
</scripts>
|
||||||
</load>
|
</load>
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,11 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -85,10 +88,36 @@ public class ArticleInCollectedVolume extends Publication {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollectedVolume getCollectedVolume() {
|
public CollectedVolume getCollectedVolume() {
|
||||||
return (CollectedVolume) get(COLLECTED_VOLUME);
|
DataCollection collection;
|
||||||
|
|
||||||
|
collection = (DataCollection) get(COLLECTED_VOLUME);
|
||||||
|
|
||||||
|
if (collection.size() == 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
DataObject dobj;
|
||||||
|
|
||||||
|
collection.next();
|
||||||
|
dobj = collection.getDataObject();
|
||||||
|
|
||||||
|
return (CollectedVolume)DomainObjectFactory.newInstance(dobj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollectedVolume(CollectedVolume collectedVolume) {
|
public void setCollectedVolume(CollectedVolume collectedVolume) {
|
||||||
set(COLLECTED_VOLUME, collectedVolume);
|
CollectedVolume oldCollectedVolume;
|
||||||
|
|
||||||
|
oldCollectedVolume = getCollectedVolume();
|
||||||
|
if (oldCollectedVolume != null) {
|
||||||
|
remove(COLLECTED_VOLUME, oldCollectedVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectedVolume != null) {
|
||||||
|
Assert.exists(collectedVolume, CollectedVolume.class);
|
||||||
|
DataObject link = add(COLLECTED_VOLUME, collectedVolume);
|
||||||
|
link.set(CollectedVolume.ARTICLE_ORDER,
|
||||||
|
Integer.valueOf((int) collectedVolume.getArticles().size()));
|
||||||
|
link.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
@ -12,12 +15,11 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public class ArticleInJournal extends Publication {
|
public class ArticleInJournal extends Publication {
|
||||||
|
|
||||||
public static final String JOURNAL = "journal";
|
|
||||||
public static final String VOLUME = "volume";
|
public static final String VOLUME = "volume";
|
||||||
public static final String ISSUE = "issue";
|
public static final String ISSUE = "issue";
|
||||||
public static final String PAGES_FROM = "pagesFrom";
|
public static final String PAGES_FROM = "pagesFrom";
|
||||||
public static final String PAGES_TO = "pagesTo";
|
public static final String PAGES_TO = "pagesTo";
|
||||||
public static final String ISSN = "issn";
|
public static final String JOURNAL = "journal";
|
||||||
public static final String PUBLICATION_DATE = "publicationDate";
|
public static final String PUBLICATION_DATE = "publicationDate";
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.contenttypes.ArticleInJournal";
|
"com.arsdigita.cms.contenttypes.ArticleInJournal";
|
||||||
|
|
@ -42,14 +44,6 @@ public class ArticleInJournal extends Publication {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJournal() {
|
|
||||||
return (String) get(JOURNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJournal(String journal) {
|
|
||||||
set(JOURNAL, journal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVolume() {
|
public Integer getVolume() {
|
||||||
return (Integer) get(VOLUME);
|
return (Integer) get(VOLUME);
|
||||||
}
|
}
|
||||||
|
|
@ -82,14 +76,6 @@ public class ArticleInJournal extends Publication {
|
||||||
set(PAGES_TO, pagesTo);
|
set(PAGES_TO, pagesTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getISSN() {
|
|
||||||
return (String) get(ISSN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setISSN(String issn) {
|
|
||||||
set(ISSN, issn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPublicationDate() {
|
public Date getPublicationDate() {
|
||||||
return (Date) get(PUBLICATION_DATE);
|
return (Date) get(PUBLICATION_DATE);
|
||||||
}
|
}
|
||||||
|
|
@ -97,4 +83,38 @@ public class ArticleInJournal extends Publication {
|
||||||
public void setPublicationDate(Date publicationDate) {
|
public void setPublicationDate(Date publicationDate) {
|
||||||
set(PUBLICATION_DATE, publicationDate);
|
set(PUBLICATION_DATE, publicationDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Journal getJournal() {
|
||||||
|
DataCollection collection;
|
||||||
|
|
||||||
|
collection = (DataCollection) get(JOURNAL);
|
||||||
|
|
||||||
|
if (collection.size() == 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
DataObject dobj;
|
||||||
|
|
||||||
|
collection.next();
|
||||||
|
dobj = collection.getDataObject();
|
||||||
|
|
||||||
|
return (Journal) DomainObjectFactory.newInstance(dobj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournal(Journal journal) {
|
||||||
|
Journal oldJournal;
|
||||||
|
|
||||||
|
oldJournal = getJournal();
|
||||||
|
if (oldJournal != null) {
|
||||||
|
remove(JOURNAL, oldJournal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (journal != null) {
|
||||||
|
Assert.exists(journal, Journal.class);
|
||||||
|
DataObject link = add(JOURNAL, journal);
|
||||||
|
link.set(Journal.ARTICLE_ORDER,
|
||||||
|
Integer.valueOf((int) journal.getArticles().size()));
|
||||||
|
link.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* 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.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class ArticleInJournalCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public static final String LINKORDER = "link.articleOrder";
|
||||||
|
public static final String ORDER = "articleOrder";
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(
|
||||||
|
ArticleInJournalCollection.class);
|
||||||
|
|
||||||
|
public ArticleInJournalCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
|
||||||
|
m_dataCollection.addOrder(LINKORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getArticleOrder() {
|
||||||
|
return (Integer) m_dataCollection.get(LINKORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArticleOrder(Integer order) {
|
||||||
|
DataObject link = (DataObject) this.get("link");
|
||||||
|
|
||||||
|
link.set(ORDER, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNext(ArticleInJournal article) {
|
||||||
|
int currentPosition = 0;
|
||||||
|
int currentIndex = 0;
|
||||||
|
int nextIndex = 0;
|
||||||
|
|
||||||
|
s_log.debug("Searching article...");
|
||||||
|
this.rewind();
|
||||||
|
while (this.next()) {
|
||||||
|
currentPosition = this.getPosition();
|
||||||
|
currentIndex = this.getArticleOrder();
|
||||||
|
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||||
|
currentIndex, this.size()));
|
||||||
|
s_log.debug(String.format("getArticleOrder(): %d",
|
||||||
|
getArticleOrder()));
|
||||||
|
if (this.getArticle().equals(article)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"The provided article is not "
|
||||||
|
+ "part of this collection."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.next()) {
|
||||||
|
nextIndex = this.getArticleOrder();
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The provided article is the last "
|
||||||
|
+ "in the collection, so there is no next object "
|
||||||
|
+ "to swap with.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rewind();
|
||||||
|
|
||||||
|
while (this.getPosition() != currentPosition) {
|
||||||
|
this.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setArticleOrder(nextIndex);
|
||||||
|
this.next();
|
||||||
|
this.setArticleOrder(currentIndex);
|
||||||
|
this.rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious(ArticleInJournal article) {
|
||||||
|
int previousPosition = 0;
|
||||||
|
int previousIndex = 0;
|
||||||
|
int currentPosition = 0;
|
||||||
|
int currentIndex = 0;
|
||||||
|
|
||||||
|
s_log.debug("Searching article...");
|
||||||
|
this.rewind();
|
||||||
|
while (this.next()) {
|
||||||
|
currentPosition = this.getPosition();
|
||||||
|
currentIndex = this.getArticleOrder();
|
||||||
|
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||||
|
currentIndex, this.size()));
|
||||||
|
s_log.debug(String.format("getArticleOrder(): %d",
|
||||||
|
getArticleOrder()));
|
||||||
|
if (this.getArticle().equals(article)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousPosition = currentPosition;
|
||||||
|
previousIndex = currentIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"The provided article is not "
|
||||||
|
+ "part of this collection."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousPosition == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"The provided article is the first one in this "
|
||||||
|
+ "collection, so there is no previous one to switch "
|
||||||
|
+ "with."));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rewind();
|
||||||
|
while (this.getPosition() != previousPosition) {
|
||||||
|
this.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setArticleOrder(currentIndex);
|
||||||
|
this.next();
|
||||||
|
this.setArticleOrder(previousIndex);
|
||||||
|
this.rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticleInJournal getArticle() {
|
||||||
|
return (ArticleInJournal) DomainObjectFactory.newInstance(m_dataCollection.
|
||||||
|
getDataObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ public class ArticleInJournalInitializer extends ContentTypeInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTraversalXML() {
|
public String getTraversalXML() {
|
||||||
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Publication.xml";
|
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/ArticleInJournal.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class Journal extends Publication {
|
||||||
|
|
||||||
|
public static final String ISSN = "issn";
|
||||||
|
public static final String ARTICLES = "articles";
|
||||||
|
public static final String ARTICLE_ORDER = "articleOrder";
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
"com.arsdigita.cms.contenttypes.Journal";
|
||||||
|
|
||||||
|
public Journal() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Journal(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Journal(OID oid) throws DataObjectNotFoundException {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Journal(DataObject dobj) {
|
||||||
|
super(dobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Journal(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getISSN() {
|
||||||
|
return (String) get(ISSN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setISSN(String issn) {
|
||||||
|
set(ISSN, issn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticleInJournalCollection getArticles() {
|
||||||
|
return new ArticleInJournalCollection((DataCollection) get(ARTICLES));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArticle(ArticleInJournal article) {
|
||||||
|
Assert.exists(article, ArticleInJournal.class);
|
||||||
|
|
||||||
|
DataObject link = add(ARTICLES, article);
|
||||||
|
|
||||||
|
link.set(ARTICLE_ORDER, Integer.valueOf((int) getArticles().size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeArticle(ArticleInJournal article) {
|
||||||
|
Assert.exists(article, ArticleInCollectedVolume.class);
|
||||||
|
remove(ARTICLES, article);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasArticles() {
|
||||||
|
return !this.getArticles().isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalInitializer extends ContentTypeInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pdl.mf file used here is empty, since the
|
||||||
|
* {@link PublicationInitializer} loads all things using the pdl.mf file
|
||||||
|
* of the module. Also, it may causes on silly errors in the load-bundle
|
||||||
|
* step if the same pdl.mf file is used in more than one initializer.
|
||||||
|
*/
|
||||||
|
public JournalInitializer() {
|
||||||
|
super("empty.pdl.mf", Journal.BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getStylesheets() {
|
||||||
|
return new String[]{
|
||||||
|
"/static/content-types/com/arsdigita/cms/contenttypes/Journal.xsl"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTraversalXML() {
|
||||||
|
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Journal.xml";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalLoader extends AbstractContentTypeLoader {
|
||||||
|
|
||||||
|
private static final String[] TYPES = {"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Journal.xml"};
|
||||||
|
|
||||||
|
public JournalLoader() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getTypes() {
|
||||||
|
return TYPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -26,10 +26,6 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
||||||
DomainObjectPropertySheet sheet = (DomainObjectPropertySheet) PublicationPropertiesStep.
|
DomainObjectPropertySheet sheet = (DomainObjectPropertySheet) PublicationPropertiesStep.
|
||||||
getPublicationPropertySheet(itemModel);
|
getPublicationPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
|
||||||
"publications.ui.articleinjournal.journal"),
|
|
||||||
ArticleInJournal.JOURNAL);
|
|
||||||
|
|
||||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.articleinjournal.volume"),
|
"publications.ui.articleinjournal.volume"),
|
||||||
ArticleInJournal.VOLUME);
|
ArticleInJournal.VOLUME);
|
||||||
|
|
@ -46,10 +42,6 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
||||||
"publications.ui.articleinjournal.pages_to"),
|
"publications.ui.articleinjournal.pages_to"),
|
||||||
ArticleInJournal.PAGES_TO);
|
ArticleInJournal.PAGES_TO);
|
||||||
|
|
||||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
|
||||||
"publications.ui.articleinjournal.issn"),
|
|
||||||
ArticleInJournal.ISSN);
|
|
||||||
|
|
||||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.articleinjournal.publication_date"),
|
"publications.ui.articleinjournal.publication_date"),
|
||||||
ArticleInJournal.PUBLICATION_DATE);
|
ArticleInJournal.PUBLICATION_DATE);
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,6 @@ public class ArticleInJournalPropertyForm
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
|
||||||
"publications.ui.articleinjournal.journal").localize()));
|
|
||||||
ParameterModel journalParam =
|
|
||||||
new StringParameter(ArticleInJournal.JOURNAL);
|
|
||||||
TextField journal = new TextField(journalParam);
|
|
||||||
add(journal);
|
|
||||||
|
|
||||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.articleinjournal.volume").localize()));
|
"publications.ui.articleinjournal.volume").localize()));
|
||||||
ParameterModel volumeParam =
|
ParameterModel volumeParam =
|
||||||
|
|
@ -80,13 +73,6 @@ public class ArticleInJournalPropertyForm
|
||||||
TextField pagesTo = new TextField(pagesToParam);
|
TextField pagesTo = new TextField(pagesToParam);
|
||||||
add(pagesTo);
|
add(pagesTo);
|
||||||
|
|
||||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
|
||||||
"publications.ui.articleinjournal.issn").localize()));
|
|
||||||
ParameterModel issnParam = new StringParameter(ArticleInJournal.ISSN);
|
|
||||||
TextField issn = new TextField(issnParam);
|
|
||||||
issn.setMaxLength(9);
|
|
||||||
add(issn);
|
|
||||||
|
|
||||||
Calendar today = new GregorianCalendar();
|
Calendar today = new GregorianCalendar();
|
||||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.articleinjournal.publicationDate").
|
"publications.ui.articleinjournal.publicationDate").
|
||||||
|
|
@ -107,12 +93,10 @@ public class ArticleInJournalPropertyForm
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
ArticleInJournal article = (ArticleInJournal) initBasicWidgets(fse);
|
ArticleInJournal article = (ArticleInJournal) initBasicWidgets(fse);
|
||||||
|
|
||||||
data.put(ArticleInJournal.JOURNAL, article.getJournal());
|
|
||||||
data.put(ArticleInJournal.VOLUME, article.getVolume());
|
data.put(ArticleInJournal.VOLUME, article.getVolume());
|
||||||
data.put(ArticleInJournal.ISSUE, article.getIssue());
|
data.put(ArticleInJournal.ISSUE, article.getIssue());
|
||||||
data.put(ArticleInJournal.PAGES_FROM, article.getPagesFrom());
|
data.put(ArticleInJournal.PAGES_FROM, article.getPagesFrom());
|
||||||
data.put(ArticleInJournal.PAGES_TO, article.getPagesTo());
|
data.put(ArticleInJournal.PAGES_TO, article.getPagesTo());
|
||||||
data.put(ArticleInJournal.ISSN, article.getISSN());
|
|
||||||
data.put(ArticleInJournal.PUBLICATION_DATE,
|
data.put(ArticleInJournal.PUBLICATION_DATE,
|
||||||
article.getPublicationDate());
|
article.getPublicationDate());
|
||||||
}
|
}
|
||||||
|
|
@ -126,15 +110,12 @@ public class ArticleInJournalPropertyForm
|
||||||
|
|
||||||
if ((article != null) && getSaveCancelSection().getSaveButton().
|
if ((article != null) && getSaveCancelSection().getSaveButton().
|
||||||
isSelected(fse.getPageState())) {
|
isSelected(fse.getPageState())) {
|
||||||
article.setJournal((String) data.get(ArticleInJournal.JOURNAL));
|
|
||||||
article.setVolume((Integer) data.get(ArticleInJournal.VOLUME));
|
article.setVolume((Integer) data.get(ArticleInJournal.VOLUME));
|
||||||
article.setIssue((String) data.get(ArticleInJournal.ISSUE));
|
article.setIssue((String) data.get(ArticleInJournal.ISSUE));
|
||||||
article.setPagesFrom(
|
article.setPagesFrom(
|
||||||
(Integer) data.get(ArticleInJournal.PAGES_FROM));
|
(Integer) data.get(ArticleInJournal.PAGES_FROM));
|
||||||
article.setPagesTo(
|
article.setPagesTo(
|
||||||
(Integer) data.get(ArticleInJournal.PAGES_TO));
|
(Integer) data.get(ArticleInJournal.PAGES_TO));
|
||||||
article.setISSN(
|
|
||||||
(String) data.get(ArticleInJournal.ISSN));
|
|
||||||
article.setPublicationDate(
|
article.setPublicationDate(
|
||||||
(Date) data.get(ArticleInJournal.PUBLICATION_DATE));
|
(Date) data.get(ArticleInJournal.PUBLICATION_DATE));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
||||||
|
import com.arsdigita.cms.contenttypes.Journal;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalArticleAddForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
JournalArticleAddForm.class);
|
||||||
|
private JournalPropertiesStep m_step;
|
||||||
|
private ItemSearchWidget m_itemSearchWidget;
|
||||||
|
private final String ITEM_SEARCH = "articles";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public JournalArticleAddForm(ItemSelectionModel itemModel) {
|
||||||
|
super("ArticlesAddForm", itemModel);
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
Journal journal = (Journal) getItemSelectionModel().getSelectedObject(
|
||||||
|
state);
|
||||||
|
|
||||||
|
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
journal.addArticle((ArticleInJournal) data.get(ITEM_SEARCH));
|
||||||
|
}
|
||||||
|
|
||||||
|
init(fse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalArticlesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_ARTICLE_SHEET_NAME = "addArticle";
|
||||||
|
|
||||||
|
public JournalArticlesStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
this(itemModel, parent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JournalArticlesStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent,
|
||||||
|
String prefix) {
|
||||||
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addArticleSheet =
|
||||||
|
new JournalArticleAddForm(itemModel);
|
||||||
|
add(ADD_ARTICLE_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize("publications.ui.journal.add_article").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(addArticleSheet, itemModel),
|
||||||
|
addArticleSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
JournalArticlesTable articlesTable =
|
||||||
|
new JournalArticlesTable(itemModel);
|
||||||
|
setDisplayComponent(articlesTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,330 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Link;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournalCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.Journal;
|
||||||
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalArticlesTable
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
JournalArticlesTable.class);
|
||||||
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
private final String TABLE_COL_UP = "table_col_up";
|
||||||
|
private final String TABLE_COL_DOWN = "table_col_down";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public JournalArticlesTable(ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.no_articles")));
|
||||||
|
|
||||||
|
TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.article").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.article.remove").localize(),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
2,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.article.up").localize(),
|
||||||
|
TABLE_COL_UP));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
3,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.article.down").localize(),
|
||||||
|
TABLE_COL_DOWN));
|
||||||
|
|
||||||
|
setModelBuilder(new JournalArticlesTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
columnModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||||
|
columnModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class JournalArticlesTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public JournalArticlesTableModelBuilder(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
Journal collectedVolume =
|
||||||
|
(Journal) m_itemModel.getSelectedObject(
|
||||||
|
state);
|
||||||
|
return new JournalArticlesTableModel(table,
|
||||||
|
state,
|
||||||
|
collectedVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class JournalArticlesTableModel implements TableModel {
|
||||||
|
|
||||||
|
private Table m_table;
|
||||||
|
private ArticleInJournalCollection m_articles;
|
||||||
|
private ArticleInJournal m_article;
|
||||||
|
|
||||||
|
private JournalArticlesTableModel(Table table,
|
||||||
|
PageState state,
|
||||||
|
Journal journal) {
|
||||||
|
m_table = table;
|
||||||
|
m_articles = journal.getArticles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if ((m_articles != null) && m_articles.next()) {
|
||||||
|
m_article = m_articles.getArticle();
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return m_article.getTitle();
|
||||||
|
case 1:
|
||||||
|
return PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.article.remove").
|
||||||
|
localize();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_article.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
com.arsdigita.cms.SecurityManager securityManager =
|
||||||
|
Utilities.getSecurityManager(state);
|
||||||
|
Journal journal = (Journal) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||||
|
journal);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
ArticleInJournal article;
|
||||||
|
try {
|
||||||
|
article = new ArticleInJournal((BigDecimal) key);
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
s_log.warn(String.format("No object with key '%s' found.",
|
||||||
|
key),
|
||||||
|
ex);
|
||||||
|
return new Label(value.toString());
|
||||||
|
}
|
||||||
|
ContentSection section = CMS.getContext().getContentSection();
|
||||||
|
ItemResolver resolver = section.getItemResolver();
|
||||||
|
Link link =
|
||||||
|
new Link(value.toString(),
|
||||||
|
resolver.generateItemURL(state,
|
||||||
|
article,
|
||||||
|
section,
|
||||||
|
article.getVersion()));
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
Label label = new Label(value.toString());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer extends LockableImpl implements
|
||||||
|
TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
||||||
|
getSecurityManager(state);
|
||||||
|
Journal journal = (Journal) m_itemModel.getSelectedObject(
|
||||||
|
state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||||
|
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
|
||||||
|
journal);
|
||||||
|
if (canEdit) {
|
||||||
|
ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||||
|
globalize(
|
||||||
|
"cms.contenttypes.ui.journal.articles.confirm_delete").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Label(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UpCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
|
||||||
|
if (0 == row) {
|
||||||
|
Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
ControlLink link = new ControlLink(
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"cms.contenttypes.ui.journal.articles.up").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DownCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
|
||||||
|
Journal journal = (Journal) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
ArticleInJournalCollection articles = journal.getArticles();
|
||||||
|
|
||||||
|
if ((articles.size() - 1) == row) {
|
||||||
|
Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
ControlLink link = new ControlLink(
|
||||||
|
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||||
|
"cms.contenttypes.ui.journal.articles.down").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(TableActionEvent event) {
|
||||||
|
s_log.debug("Cell selected.");
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
s_log.debug(String.format("RowKey = %s", event.getRowKey().toString()));
|
||||||
|
s_log.debug(String.format("Selected column: %d", event.getColumn().
|
||||||
|
intValue()));
|
||||||
|
|
||||||
|
ArticleInJournal article = new ArticleInJournal(new BigDecimal(event.
|
||||||
|
getRowKey().
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
Journal journal = (Journal) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
ArticleInJournalCollection articles = journal.getArticles();
|
||||||
|
|
||||||
|
TableColumn col = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
|
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
} else if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
s_log.debug("Removing article assoc...");
|
||||||
|
journal.removeArticle(article);
|
||||||
|
} else if(col.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||||
|
articles.swapWithPrevious(article);
|
||||||
|
} else if(col.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||||
|
articles.swapWithNext(article);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalPropertiesStep extends PublicationPropertiesStep {
|
||||||
|
|
||||||
|
public JournalPropertiesStep(
|
||||||
|
ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
super(itemModel, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getJournalPropertySheet(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
DomainObjectPropertySheet sheet = (DomainObjectPropertySheet) PublicationPropertiesStep.
|
||||||
|
getPublicationPropertySheet(itemModel);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addBasicProperties(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
|
||||||
|
parent,
|
||||||
|
EDIT_SHEET_NAME);
|
||||||
|
|
||||||
|
BasicPageForm editBasicSheet = new JournalPropertyForm(itemModel,
|
||||||
|
this);
|
||||||
|
|
||||||
|
basicProperties.add(EDIT_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.collected_volume.edit_basic_sheet").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(editBasicSheet,
|
||||||
|
itemModel),
|
||||||
|
editBasicSheet.getSaveCancelSection().
|
||||||
|
getCancelButton());
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(getJournalPropertySheet(itemModel));
|
||||||
|
|
||||||
|
getSegmentedPanel().addSegment(
|
||||||
|
new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publication.basic_properties").
|
||||||
|
localize()),
|
||||||
|
basicProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSteps(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
super.addSteps(itemModel, parent);
|
||||||
|
|
||||||
|
addStep(new JournalArticlesStep(itemModel, parent),
|
||||||
|
"publications.ui.journal.articles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Journal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class JournalPropertyForm
|
||||||
|
extends PublicationPropertyForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(JournalPropertyForm.class);
|
||||||
|
private JournalPropertiesStep m_step;
|
||||||
|
public static final String ID = "JournalEdit";
|
||||||
|
|
||||||
|
public JournalPropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JournalPropertyForm(ItemSelectionModel itemModel,
|
||||||
|
JournalPropertiesStep step) {
|
||||||
|
super(itemModel, step);
|
||||||
|
m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.journal.issn").localize()));
|
||||||
|
ParameterModel issnParam = new StringParameter(Journal.ISSN);
|
||||||
|
TextField issn = new TextField(issnParam);
|
||||||
|
add(issn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
super.init(fse);
|
||||||
|
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
Journal journal = (Journal) super.initBasicWidgets(fse);
|
||||||
|
|
||||||
|
data.put(Journal.ISSN, journal.getISSN());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
super.process(fse);
|
||||||
|
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
Journal journal = (Journal) super.initBasicWidgets(fse);
|
||||||
|
|
||||||
|
if ((journal != null) && getSaveCancelSection().getSaveButton().
|
||||||
|
isSelected(fse.getPageState())) {
|
||||||
|
journal.setISSN((String) data.get(Journal.ISSN));
|
||||||
|
|
||||||
|
journal.save();;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue