diff --git a/ccm-sci-publications/pdl/com/arsdigita/content-types/ArticleInJournal.pdl b/ccm-sci-publications/pdl/com/arsdigita/content-types/ArticleInJournal.pdl
index 84db3ff09..26c932dc0 100644
--- a/ccm-sci-publications/pdl/com/arsdigita/content-types/ArticleInJournal.pdl
+++ b/ccm-sci-publications/pdl/com/arsdigita/content-types/ArticleInJournal.pdl
@@ -24,13 +24,11 @@ import com.arsdigita.cms.ContentPage;
// PDL definition for an article in a journal
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;
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] 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;
reference key (ct_article_in_journal.article_in_journal_id);
diff --git a/ccm-sci-publications/pdl/com/arsdigita/content-types/PublicationList.pdl b/ccm-sci-publications/pdl/com/arsdigita/content-types/Journal.pdl
similarity index 52%
rename from ccm-sci-publications/pdl/com/arsdigita/content-types/PublicationList.pdl
rename to ccm-sci-publications/pdl/com/arsdigita/content-types/Journal.pdl
index 66f6d5b5c..22b91a4a1 100644
--- a/ccm-sci-publications/pdl/com/arsdigita/content-types/PublicationList.pdl
+++ b/ccm-sci-publications/pdl/com/arsdigita/content-types/Journal.pdl
@@ -22,24 +22,25 @@ model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage;
-//PDL definition for the basic attributes of publication.
-object type PublicationList extends ContentPage {
+//PDL definition for a journal
+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 {
- PublicationList[0..n] publicationLists = join ct_publications.publication_id
- to ct_publicationlists_map.publication_id,
- join ct_publicationlists_map.publicationlist_id
- to ct_publicationlists.publicationlist_id;
-
- Publication[0..n] publications = join ct_publicationlists.publicationlist_id
- to ct_publicationlists_map.publicationlist_id,
- join ct_publicationlists_map.publication_id
- to ct_publications.publication_id;
+ Journal[0..n] journal = join ct_article_in_journal.article_in_journal_id
+ to ct_journal_article_map.article_in_journal_id,
+ join ct_journal_article_map.journal_id
+ to ct_journal.journal_id;
+
+ ArticleInJournal[0..n] articles = join ct_journal.journal_id
+ to ct_journal_article_map.journal_id,
+ join ct_journal.article_map.article_in_journal_id
+ to ct_article_in_journal.article_in_journal_id;
+
+ Integer[0..1] articleOrder = ct_journal_article_map.article_order INTEGER;
}
\ No newline at end of file
diff --git a/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Journal.xml b/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Journal.xml
new file mode 100644
index 000000000..c0d0b26e7
--- /dev/null
+++ b/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Journal.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/PublicationList.xml b/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/PublicationList.xml
deleted file mode 100644
index 73d8476c0..000000000
--- a/ccm-sci-publications/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/PublicationList.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/ArticleInJournal.xml b/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/ArticleInJournal.xml
new file mode 100644
index 000000000..68b2ff94c
--- /dev/null
+++ b/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/ArticleInJournal.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Journal.xml b/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Journal.xml
new file mode 100644
index 000000000..b9c294a67
--- /dev/null
+++ b/ccm-sci-publications/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Journal.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ccm-sci-publications/src/ccm-sci-publications.load b/ccm-sci-publications/src/ccm-sci-publications.load
index 0d243acb4..480252506 100644
--- a/ccm-sci-publications/src/ccm-sci-publications.load
+++ b/ccm-sci-publications/src/ccm-sci-publications.load
@@ -16,13 +16,13 @@
+
-
-
+
@@ -33,13 +33,13 @@
+
-
-
+
@@ -53,12 +53,12 @@
+
-
-
+
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java
index fb12e9fdb..97885950f 100644
--- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java
@@ -20,8 +20,11 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.domain.DomainObjectFactory;
+import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
+import com.arsdigita.util.Assert;
import java.math.BigDecimal;
/**
@@ -85,10 +88,36 @@ public class ArticleInCollectedVolume extends Publication {
}
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) {
- 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();
+ }
}
}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournal.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournal.java
index ec735fc9c..b0b35109c 100644
--- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournal.java
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournal.java
@@ -1,8 +1,11 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.domain.DomainObjectFactory;
+import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
+import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.util.Date;
@@ -11,13 +14,12 @@ import java.util.Date;
* @author Jens Pelzetter
*/
public class ArticleInJournal extends Publication {
-
- public static final String JOURNAL = "journal";
+
public static final String VOLUME = "volume";
public static final String ISSUE = "issue";
public static final String PAGES_FROM = "pagesFrom";
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 BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.ArticleInJournal";
@@ -41,15 +43,7 @@ public class ArticleInJournal extends Publication {
public ArticleInJournal(String type) {
super(type);
}
-
- public String getJournal() {
- return (String) get(JOURNAL);
- }
-
- public void setJournal(String journal) {
- set(JOURNAL, journal);
- }
-
+
public Integer getVolume() {
return (Integer) get(VOLUME);
}
@@ -81,15 +75,7 @@ public class ArticleInJournal extends Publication {
public void setPagesTo(Integer pagesTo) {
set(PAGES_TO, pagesTo);
}
-
- public String getISSN() {
- return (String) get(ISSN);
- }
-
- public void setISSN(String issn) {
- set(ISSN, issn);
- }
-
+
public Date getPublicationDate() {
return (Date) get(PUBLICATION_DATE);
}
@@ -97,4 +83,38 @@ public class ArticleInJournal extends Publication {
public void setPublicationDate(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();
+ }
+ }
}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalCollection.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalCollection.java
new file mode 100644
index 000000000..8c0895668
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalCollection.java
@@ -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());
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalInitializer.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalInitializer.java
index 9abbdbdae..98cfbca32 100644
--- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalInitializer.java
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInJournalInitializer.java
@@ -23,7 +23,7 @@ public class ArticleInJournalInitializer extends ContentTypeInitializer {
@Override
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";
}
}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Journal.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Journal.java
new file mode 100644
index 000000000..97bfeaba9
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Journal.java
@@ -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();
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalInitializer.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalInitializer.java
new file mode 100644
index 000000000..4a2872a94
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalInitializer.java
@@ -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";
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalLoader.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalLoader.java
new file mode 100644
index 000000000..9f3fc70bf
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/JournalLoader.java
@@ -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;
+ }
+
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java
index 83768ff35..83b46680f 100644
--- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java
@@ -26,10 +26,6 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
DomainObjectPropertySheet sheet = (DomainObjectPropertySheet) PublicationPropertiesStep.
getPublicationPropertySheet(itemModel);
- sheet.add(PublicationGlobalizationUtil.globalize(
- "publications.ui.articleinjournal.journal"),
- ArticleInJournal.JOURNAL);
-
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.articleinjournal.volume"),
ArticleInJournal.VOLUME);
@@ -45,11 +41,7 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.articleinjournal.pages_to"),
ArticleInJournal.PAGES_TO);
-
- sheet.add(PublicationGlobalizationUtil.globalize(
- "publications.ui.articleinjournal.issn"),
- ArticleInJournal.ISSN);
-
+
sheet.add(PublicationGlobalizationUtil.globalize(
"publications.ui.articleinjournal.publication_date"),
ArticleInJournal.PUBLICATION_DATE);
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java
index 642f72b88..b8723195a 100644
--- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java
@@ -44,14 +44,7 @@ public class ArticleInJournalPropertyForm
@Override
protected void 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);
+ super.addWidgets();
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.articleinjournal.volume").localize()));
@@ -80,13 +73,6 @@ public class ArticleInJournalPropertyForm
TextField pagesTo = new TextField(pagesToParam);
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();
add(new Label((String) PublicationGlobalizationUtil.globalize(
"publications.ui.articleinjournal.publicationDate").
@@ -106,13 +92,11 @@ public class ArticleInJournalPropertyForm
FormData data = fse.getFormData();
ArticleInJournal article = (ArticleInJournal) initBasicWidgets(fse);
-
- data.put(ArticleInJournal.JOURNAL, article.getJournal());
+
data.put(ArticleInJournal.VOLUME, article.getVolume());
data.put(ArticleInJournal.ISSUE, article.getIssue());
data.put(ArticleInJournal.PAGES_FROM, article.getPagesFrom());
- data.put(ArticleInJournal.PAGES_TO, article.getPagesTo());
- data.put(ArticleInJournal.ISSN, article.getISSN());
+ data.put(ArticleInJournal.PAGES_TO, article.getPagesTo());
data.put(ArticleInJournal.PUBLICATION_DATE,
article.getPublicationDate());
}
@@ -125,16 +109,13 @@ public class ArticleInJournalPropertyForm
ArticleInJournal article = (ArticleInJournal) initBasicWidgets(fse);
if ((article != null) && getSaveCancelSection().getSaveButton().
- isSelected(fse.getPageState())) {
- article.setJournal((String) data.get(ArticleInJournal.JOURNAL));
+ isSelected(fse.getPageState())) {
article.setVolume((Integer) data.get(ArticleInJournal.VOLUME));
article.setIssue((String) data.get(ArticleInJournal.ISSUE));
article.setPagesFrom(
(Integer) data.get(ArticleInJournal.PAGES_FROM));
article.setPagesTo(
- (Integer) data.get(ArticleInJournal.PAGES_TO));
- article.setISSN(
- (String) data.get(ArticleInJournal.ISSN));
+ (Integer) data.get(ArticleInJournal.PAGES_TO));
article.setPublicationDate(
(Date) data.get(ArticleInJournal.PUBLICATION_DATE));
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java
new file mode 100644
index 000000000..67cbd88e8
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticleAddForm.java
@@ -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);
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesStep.java
new file mode 100644
index 000000000..60213899c
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesStep.java
@@ -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);
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesTable.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesTable.java
new file mode 100644
index 000000000..892e8b85b
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalArticlesTable.java
@@ -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
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertiesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertiesStep.java
new file mode 100644
index 000000000..6153a5507
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertiesStep.java
@@ -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");
+ }
+}
diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertyForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertyForm.java
new file mode 100644
index 000000000..952d1d737
--- /dev/null
+++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/JournalPropertyForm.java
@@ -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();;
+ }
+ }
+}