Update of
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/util
In directory james.mmbase.org:/tmp/cvs-serv9790/util
Modified Files:
Tag: b1_5
NewsletterUtil.java
Log Message:
CMSC-1196 Newsletter: publications/editions are created but not visible in
overview
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/util
See also: http://www.mmbase.org/jira/browse/CMSC-1196
Index: NewsletterUtil.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/util/NewsletterUtil.java,v
retrieving revision 1.40
retrieving revision 1.40.2.1
diff -u -b -r1.40 -r1.40.2.1
--- NewsletterUtil.java 1 Aug 2008 02:16:58 -0000 1.40
+++ NewsletterUtil.java 18 Dec 2008 11:28:20 -0000 1.40.2.1
@@ -1,16 +1,31 @@
package com.finalist.newsletter.util;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.mmbase.bridge.*;
+import org.mmbase.bridge.Cloud;
+import org.mmbase.bridge.Node;
+import org.mmbase.bridge.NodeList;
+import org.mmbase.bridge.NodeManager;
+import org.mmbase.bridge.NodeQuery;
+import org.mmbase.bridge.RelationList;
+import org.mmbase.bridge.RelationManager;
import org.mmbase.bridge.util.Queries;
import org.mmbase.bridge.util.SearchUtil;
-import org.mmbase.storage.search.*;
+import org.mmbase.storage.search.FieldValueConstraint;
+import org.mmbase.storage.search.RelationStep;
+import org.mmbase.storage.search.Step;
+import org.mmbase.storage.search.StepField;
import com.finalist.cmsc.beans.MMBaseNodeMapper;
import com.finalist.cmsc.beans.om.ContentElement;
@@ -25,17 +40,29 @@
import com.finalist.portlets.newsletter.NewsletterContentPortlet;
public abstract class NewsletterUtil {
- private static Log log = LogFactory
- .getLog(NewsletterUtil.class);
+
+ private static Log log = LogFactory.getLog(NewsletterUtil.class);
+
+ public static final String DOWN = "DOWN";
+ public static final String POSREL = "posrel";
+ public static final String SCHEDULE = "schedule";
+ public static final String SYSTEM_LIVEPATH = "system.livepath";
+ public static final String PORTLETREL = "portletrel";
+ public static final String PORTLETDEFINITION = "portletdefinition";
+ public static final String PORTLET = "portlet";
+ public static final String TITLE = "title";
+ public static final String SOURCE = "source";
+ public static final String NEWSLETTERCONTENT = "newslettercontent";
+ public static final String NUMBER = "number";
+ public static final String ARTICLE = "article";
public static final String NEWSLETTER = "newsletter";
public static final String NEWSLETTERPUBLICATION = "newsletterpublication";
-
- public static final String THEMETYPE_NEWSLETTER = "newslettertheme";
- public static final String THEMETYPE_NEWSLETTERPUBLICATION =
"newsletterpublicationtheme";
+ public static final String RELATED = "related";
public static int countNewsletters() {
+
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeList newsletterList = SearchUtil.findNodeList(cloud, "newsletter");
+ NodeList newsletterList = SearchUtil.findNodeList(cloud, NEWSLETTER);
if (newsletterList != null) {
return (0 + newsletterList.size());
}
@@ -44,7 +71,7 @@
public static int countPublications() {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeList publicationList = SearchUtil.findNodeList(cloud,
"newsletterpublication");
+ NodeList publicationList = SearchUtil.findNodeList(cloud,
NEWSLETTERPUBLICATION);
if (publicationList != null) {
return (0 + publicationList.size());
}
@@ -54,7 +81,7 @@
public static int countPublications(int newsletterNumber) {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node newsletterNode = cloud.getNode(newsletterNumber);
- NodeList publicationsList =
newsletterNode.getRelatedNodes("newsletterpublication");
+ NodeList publicationsList =
newsletterNode.getRelatedNodes(NEWSLETTERPUBLICATION);
if (publicationsList != null) {
return (publicationsList.size());
@@ -77,7 +104,7 @@
NodeQuery query = cloud.createNodeQuery();
Step step = query.addStep(newsletterLogManager);
query.setNodeStep(step);
- SearchUtil.addEqualConstraint(query,
newsletterLogManager.getField("newsletter"), newsletterNumber);
+ SearchUtil.addEqualConstraint(query,
newsletterLogManager.getField(NEWSLETTER), newsletterNumber);
NodeList logs = query.getList();
if (logs != null) {
@@ -130,7 +157,7 @@
public static List<Integer> getAllPublications() {
List<Integer> publications = new ArrayList<Integer>();
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeList publicationList = SearchUtil.findNodeList(cloud,
"newsletterpublication");
+ NodeList publicationList = SearchUtil.findNodeList(cloud,
NEWSLETTERPUBLICATION);
if (publicationList != null && publicationList.size() > 0) {
for (int n = 0; n < publicationList.size(); n++) {
Node publicationNode = publicationList.getNode(n);
@@ -146,7 +173,7 @@
List<Integer> articles = new ArrayList<Integer>();
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node themeNode = cloud.getNode(themeNumber);
- NodeManager articleNodeManager = cloud.getNodeManager("article");
+ NodeManager articleNodeManager = cloud.getNodeManager(ARTICLE);
NodeList articleList = themeNode.getRelatedNodes(articleNodeManager);
if (articleList != null) {
for (int i = 0; i < articleList.size(); i++) {
@@ -160,7 +187,7 @@
return (null);
}
- public static List<ContentElement> getArticlesByNewsletter(int
itemNumber,String termNumbers, int offset, int elementsPerPage, String orderBy,
String direction) {
+ public static List<ContentElement> getArticlesByNewsletter(int itemNumber,
String termNumbers, int offset, int elementsPerPage, String orderBy, String
direction) {
String[] numbers = termNumbers.split(",");
SortedSet<Integer> sort = new TreeSet<Integer>();
@@ -170,7 +197,7 @@
if (sort.size() == 0) {
return (null);
}
- return getArticles(itemNumber,offset, elementsPerPage, orderBy,
direction, sort);
+ return getArticles(itemNumber, offset, elementsPerPage, orderBy,
direction, sort);
}
public static List<ContentElement> getArticlesByNewsletter(int
newsletterNumber, int offset, int elementsPerPage, String orderBy, String
direction) {
@@ -184,14 +211,14 @@
List<ContentElement> articles = new ArrayList<ContentElement>();
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeManager newsletterNodeManager = cloud.getNodeManager("newsletter");
- NodeManager articleNodeManager = cloud.getNodeManager("article");
+ NodeManager newsletterNodeManager = cloud.getNodeManager(NEWSLETTER);
+ NodeManager articleNodeManager = cloud.getNodeManager(ARTICLE);
NodeQuery query = cloud.createNodeQuery();
Step parameterStep = query.addStep(articleNodeManager);
query.setNodeStep(parameterStep);
RelationStep relationStep = query.addRelationStep(newsletterNodeManager,
null, null);
Step step = relationStep.getNext();
- StepField stepField = query.createStepField(step,
newsletterNodeManager.getField("number"));
+ StepField stepField = query.createStepField(step,
newsletterNodeManager.getField(NUMBER));
FieldValueConstraint constraint = query.createConstraint(stepField,
number);
SearchUtil.addConstraint(query, constraint);
Queries.addSortOrders(query, orderBy, direction);
@@ -209,22 +236,21 @@
}
- public static List<ContentElement> getArticles(int newsletterNumber,int
offset, int elementsPerPage, String orderBy, String direction,
SortedSet<Integer> sort) {
+ public static List<ContentElement> getArticles(int newsletterNumber, int
offset, int elementsPerPage, String orderBy, String direction,
SortedSet<Integer> sort) {
List<ContentElement> articles = new ArrayList<ContentElement>();
- List<Node> relatedArticles =
getArticles(newsletterNumber,sort,orderBy,direction);
- if(relatedArticles == null) {
+ List<Node> relatedArticles = getArticles(newsletterNumber, sort,
orderBy, direction);
+ if (relatedArticles == null) {
return null;
}
- if(relatedArticles.size() > offset) {
- int totalCount = 0 ;
- if(offset+elementsPerPage >= relatedArticles.size()) {
+ if (relatedArticles.size() > offset) {
+ int totalCount = 0;
+ if (offset + elementsPerPage >= relatedArticles.size()) {
totalCount = relatedArticles.size();
+ } else {
+ totalCount = offset + elementsPerPage;
}
- else {
- totalCount = offset+elementsPerPage;
- }
- for(int i = offset ; i < totalCount ; i++) {
+ for (int i = offset; i < totalCount; i++) {
Node articleNode = relatedArticles.get(i);
ContentElement element = MMBaseNodeMapper.copyNode(articleNode,
ContentElement.class);
articles.add(element);
@@ -233,23 +259,24 @@
return (articles);
}
- public static int countArticles(int newsletterNumber,SortedSet<Integer>
sort) {
- List<Node> articles = getArticles(newsletterNumber,sort,null,null);
- return articles == null?0:articles.size();
+ public static int countArticles(int newsletterNumber, SortedSet<Integer>
sort) {
+
+ List<Node> articles = getArticles(newsletterNumber, sort, null, null);
+ return articles == null ? 0 : articles.size();
}
- public static List<Node> getArticles(int
newsletterNumber,SortedSet<Integer> sort,String orderBy, String direction){
+ public static List<Node> getArticles(int newsletterNumber,
SortedSet<Integer> sort, String orderBy, String direction) {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeManager articleNodeManager = cloud.getNodeManager("article");
+ NodeManager articleNodeManager = cloud.getNodeManager(ARTICLE);
- NodeManager newsletterNodeManager = cloud.getNodeManager("newsletter");
+ NodeManager newsletterNodeManager = cloud.getNodeManager(NEWSLETTER);
NodeQuery articleQuery = cloud.createNodeQuery();
Step articleStep = articleQuery.addStep(articleNodeManager);
articleQuery.setNodeStep(articleStep);
RelationStep relationStep =
articleQuery.addRelationStep(newsletterNodeManager, null, null);
Step step = relationStep.getNext();
- StepField stepField = articleQuery.createStepField(step,
newsletterNodeManager.getField("number"));
+ StepField stepField = articleQuery.createStepField(step,
newsletterNodeManager.getField(NUMBER));
FieldValueConstraint constraint =
articleQuery.createConstraint(stepField, newsletterNumber);
SearchUtil.addConstraint(articleQuery, constraint);
Queries.addSortOrders(articleQuery, orderBy, direction);
@@ -260,21 +287,21 @@
NodeQuery query = cloud.createNodeQuery();
Step parameterStep = query.addStep(articleNodeManager);
query.setNodeStep(parameterStep);
- query.addRelationStep(termNodeManager, "newslettercontent",
SearchUtil.DESTINATION);
- SearchUtil.addInConstraint(query, termNodeManager.getField("number"),
sort);
+ query.addRelationStep(termNodeManager, NEWSLETTERCONTENT,
SearchUtil.DESTINATION);
+ SearchUtil.addInConstraint(query, termNodeManager.getField(NUMBER),
sort);
NodeList termRelatedArticles = query.getList();
List<Node> articles = new ArrayList<Node>();
- if(articleNodes != null ){
- for(int i = 0 ; i < articleNodes.size() ; i++) {
+ if (articleNodes != null) {
+ for (int i = 0; i < articleNodes.size(); i++) {
Node article = articleNodes.getNode(i);
- if(termRelatedArticles == null){
+ if (termRelatedArticles == null) {
return null;
}
- for(int j = 0 ; j < termRelatedArticles.size() ; j++) {
+ for (int j = 0; j < termRelatedArticles.size(); j++) {
Node termRelatedArticle = termRelatedArticles.getNode(j);
- if(termRelatedArticle.getNumber() == article.getNumber()) {
+ if (termRelatedArticle.getNumber() == article.getNumber()) {
articles.add(article);
break;
}
@@ -287,13 +314,14 @@
public static int countArticles(int number) {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
- NodeManager articleNodeManager = cloud.getNodeManager("article");
+ NodeManager articleNodeManager = cloud.getNodeManager(ARTICLE);
Node newsletterNode = cloud.getNode(number);
- int count =
newsletterNode.countRelatedNodes(articleNodeManager,"newslettercontent",
"source");
+ int count = newsletterNode.countRelatedNodes(articleNodeManager,
NEWSLETTERCONTENT, SOURCE);
return count;
}
- public static int countArticlesByNewsletter(int itemNumber,String
termNumbers) {
+
+ public static int countArticlesByNewsletter(int itemNumber, String
termNumbers) {
String[] numbers = termNumbers.split(",");
SortedSet<Integer> sort = new TreeSet<Integer>();
@@ -303,7 +331,7 @@
if (sort.size() == 0) {
return (0);
}
- return countArticles(itemNumber,sort);
+ return countArticles(itemNumber, sort);
}
public static int countArticlesByNewsletter(int newsletterNumber) {
@@ -317,7 +345,7 @@
public static String getTitle(int newsletterNumber) {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node newsletterNode = cloud.getNode(newsletterNumber);
- String title = newsletterNode.getStringValue("title");
+ String title = newsletterNode.getStringValue(TITLE);
return (title);
}
@@ -325,7 +353,7 @@
boolean result = false;
if (number > 0) {
String key = "" + determineNodeType(number);
- if (key.equals("newsletter")) {
+ if (key.equals(NEWSLETTER)) {
result = true;
}
}
@@ -346,7 +374,7 @@
boolean result = false;
if (number > 0) {
String key = "" + determineNodeType(number);
- if (key.equals("newsletterpublication")) {
+ if (key.equals(NEWSLETTERPUBLICATION)) {
result = true;
}
}
@@ -418,7 +446,7 @@
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node publicationNode = cloud.getNode(publicationId);
- List<Node> relatedportlets =
publicationNode.getRelatedNodes("portlet");
+ List<Node> relatedportlets = publicationNode.getRelatedNodes(PORTLET);
String termIds = "";
for (Term term : terms) {
@@ -428,10 +456,10 @@
termIds = termIds.substring(0, termIds.length() - 1);
}
for (Node portlet : relatedportlets) {
- List<Node> portletdefNodes =
portlet.getRelatedNodes("portletdefinition");
+ List<Node> portletdefNodes =
portlet.getRelatedNodes(PORTLETDEFINITION);
String portletDefinition =
portletdefNodes.get(0).getStringValue("definition");
if (portletDefinition.equals(NewsletterContentPortlet.DEFINITION))
{
- RelationList relations = portlet.getRelations("portletrel",
publicationNode.getNodeManager());
+ RelationList relations = portlet.getRelations(PORTLETREL,
publicationNode.getNodeManager());
String name = relations.getRelation(0).getStringValue("name");
url +=
"/_rp_".concat(name).concat("_").concat(NewsletterContentPortlet.NEWSLETTER_TERMS_PARAM).concat("/1_").concat(termIds);
}
@@ -442,7 +470,7 @@
public static String getServerURL() {
- String hostUrl = PropertiesUtil.getProperty("system.livepath");
+ String hostUrl = PropertiesUtil.getProperty(SYSTEM_LIVEPATH);
if (StringUtils.isEmpty(hostUrl)) {
throw new NewsletterSendFailException("get property <system.livepath>
from system property and get nothing");
@@ -489,88 +517,84 @@
}
public static void addScheduleForNewsletter(Node newsletterNode) {
- NodeManager scheduleNodeManager =
newsletterNode.getCloud().getNodeManager("schedule");
- NodeList schedules
=SearchUtil.findRelatedOrderedNodeList(newsletterNode, "schedule", "posrel",
"createdatetime","DOWN");
- if(schedules.size() == 0) {
- addScheduleNode(newsletterNode,scheduleNodeManager);
- }
- else {
+ NodeManager scheduleNodeManager =
newsletterNode.getCloud().getNodeManager(SCHEDULE);
+ NodeList schedules =
SearchUtil.findRelatedOrderedNodeList(newsletterNode, SCHEDULE, POSREL,
"createdatetime", DOWN);
+ if (schedules.size() == 0) {
+ addScheduleNode(newsletterNode, scheduleNodeManager);
+ } else {
Node firstScheduleNode = schedules.getNode(0);
-
if(firstScheduleNode.getStringValue("expression").equals(newsletterNode.getStringValue("schedule"))){
+ if
(firstScheduleNode.getStringValue("expression").equals(newsletterNode.getStringValue(SCHEDULE)))
{
return;
}
- for(int i = 0; i < schedules.size(); i ++) {
+ for (int i = 0; i < schedules.size(); i++) {
Node scheduleNode = schedules.getNode(i);
-
if(scheduleNode.getStringValue("expression").equals(newsletterNode.getStringValue("schedule")))
{
+ if
(scheduleNode.getStringValue("expression").equals(newsletterNode.getStringValue(SCHEDULE)))
{
scheduleNode.setLongValue("createdatetime",
System.currentTimeMillis());
scheduleNode.commit();
return;
}
}
- addScheduleNode(newsletterNode,scheduleNodeManager);
+ addScheduleNode(newsletterNode, scheduleNodeManager);
}
}
public static void addScheduleNode(Node newsletterNode, NodeManager
scheduleNodeManager) {
- if(StringUtils.isEmpty(newsletterNode.getStringValue("schedule"))) {
+ if (StringUtils.isEmpty(newsletterNode.getStringValue(SCHEDULE))) {
return;
}
Node scheduleNode = scheduleNodeManager.createNode();
-
scheduleNode.setStringValue("expression",newsletterNode.getStringValue("schedule"));
- scheduleNode.setLongValue("createdatetime",System.currentTimeMillis());
+ scheduleNode.setStringValue("expression",
newsletterNode.getStringValue(SCHEDULE));
+ scheduleNode.setLongValue("createdatetime", System.currentTimeMillis());
scheduleNode.commit();
- RelationUtil.createRelation(newsletterNode, scheduleNode, "posrel");
+ RelationUtil.createRelation(newsletterNode, scheduleNode, POSREL);
}
public static List<Schedule> getSchedulesBynewsletterId(int id) {
List<Schedule> schedules = new ArrayList<Schedule>();
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node newsletterNode = cloud.getNode(id);
- NodeList scheduleList
=SearchUtil.findRelatedOrderedNodeList(newsletterNode, "schedule", "posrel",
"createdatetime","DOWN");
- for(int i = 1 ; i < scheduleList.size() ;i++) {
+ NodeList scheduleList =
SearchUtil.findRelatedOrderedNodeList(newsletterNode, SCHEDULE, POSREL,
"createdatetime", DOWN);
+ for (int i = 1; i < scheduleList.size(); i++) {
Node scheduleNode = scheduleList.getNode(i);
Schedule schedule = new Schedule();
- schedule.setId(scheduleNode.getIntValue("number"));
+ schedule.setId(scheduleNode.getIntValue(NUMBER));
schedule.setExpression(scheduleNode.getStringValue("expression"));
schedule.setScheduleDescription(getScheduleMessageByExpression(scheduleNode.getStringValue("expression")));
schedules.add(schedule);
}
return schedules;
}
- public static String getScheduleMessageByExpression(String expression){
- if(StringUtils.isEmpty(expression)) {
+
+ public static String getScheduleMessageByExpression(String expression) {
+ if (StringUtils.isEmpty(expression)) {
return "";
}
StringBuilder scheduleMessage = null;
ResourceBundle rb = ResourceBundle.getBundle("cmsc-calendar");
String[] expressions = expression.split("\\|");
String type;
- if(expressions == null || expressions.length ==0) {
+ if (expressions == null || expressions.length == 0) {
return null;
}
scheduleMessage = new StringBuilder();
type = expressions[0];
- if(type.equals("1")) {
- scheduleMessage.append(rb.getString("calendar.once")+",");
+ if (type.equals("1")) {
+ scheduleMessage.append(rb.getString("calendar.once") + ",");
scheduleMessage.append(rb.getString("calendar.start.datetime"));
scheduleMessage.append(expressions[1]).append("
").append(expressions[2]).append(":").append(expressions[3]);
- }
- else if(type.equals("2")) {
- scheduleMessage.append(rb.getString("calendar.daily")+",");
+ } else if (type.equals("2")) {
+ scheduleMessage.append(rb.getString("calendar.daily") + ",");
scheduleMessage.append(rb.getString("calendar.start.datetime"));
scheduleMessage.append(expressions[1]).append("
").append(expressions[2]).append(":").append(expressions[3]);
scheduleMessage.append("<br/>");
- if(expressions[4].equals("0")) {
+ if (expressions[4].equals("0")) {
scheduleMessage.append(rb.getString("calendar.approach.interval.pre")).append(rb.getString("calendar.approach.interval.day"));
- }
- else if(expressions[4].equals("1")){
+ } else if (expressions[4].equals("1")) {
scheduleMessage.append(rb.getString("calendar.approach.interval.pre")).append(rb.getString("calendar.approach.weekday"));
- }
- else if(expressions[4].equals("2")) {
+ } else if (expressions[4].equals("2")) {
scheduleMessage.append(rb.getString("calendar.approach.interval.pre")).append("
").append(expressions[5]).append("
").append(rb.getString("calendar.approach.interval.day"));
}
- }
- else if(type.equals("3")) {
+ } else if (type.equals("3")) {
scheduleMessage.append(rb.getString("calendar.weekly")).append(",").append(rb.getString("calendar.start.datetime"));
scheduleMessage.append(expressions[1]).append(":").append(expressions[2]);
scheduleMessage.append("<br/>").append(rb.getString("calendar.approach.interval.pre")).append(expressions[3]).append(rb.getString("calendar.approach.interval.week"));
@@ -594,105 +618,82 @@
tempWeek += rb.getString("calendar.week.sunday") + ",";
}
}
- if(StringUtils.isNotEmpty(tempWeek)){
- if(tempWeek.endsWith(",")){
- tempWeek = tempWeek.substring(0,tempWeek.length()-1) ;
+ if (StringUtils.isNotEmpty(tempWeek)) {
+ if (tempWeek.endsWith(",")) {
+ tempWeek = tempWeek.substring(0, tempWeek.length() - 1);
}
}
scheduleMessage.append("<br/>").append(rb.getString("calendar.approach.interval.week")).append(":").append(tempWeek);
- }
- else {
+ } else {
scheduleMessage.append(rb.getString("calendar.monthly")).append(",").append(rb.getString("calendar.start.datetime")).append(expressions[1]).append(":").append(expressions[2]);
String months = "";
- if(expressions[3].equals("0")) {
+ if (expressions[3].equals("0")) {
scheduleMessage.append("<br/>").append(rb.getString("calendar.approach.interval.pre")).append("
").append(expressions[4]).append("
").append(rb.getString("calendar.approach.interval.day"));
months = expressions[5];
- }
- else if(expressions[3].equals("1")) {
+ } else if (expressions[3].equals("1")) {
scheduleMessage.append("<br/>").append(rb.getString("calendar.week"));
- if(expressions[4].equals("1")) {
+ if (expressions[4].equals("1")) {
scheduleMessage.append("
").append(rb.getString("calendar.which.week.first")).append("
").append(rb.getString("calendar.approach.interval.week")).append(",");
- }
- else if (expressions[4].equals("2")) {
+ } else if (expressions[4].equals("2")) {
scheduleMessage.append("
").append(rb.getString("calendar.which.week.second")).append("
").append(rb.getString("calendar.approach.interval.week")).append(",");
- }
- else if (expressions[4].equals("3")) {
+ } else if (expressions[4].equals("3")) {
scheduleMessage.append("
").append(rb.getString("calendar.which.week.third")).append("
").append(rb.getString("calendar.approach.interval.week")).append(",");
- }
- else if (expressions[4].equals("4")) {
+ } else if (expressions[4].equals("4")) {
scheduleMessage.append("
").append(rb.getString("calendar.which.week.forth")).append("
").append(rb.getString("calendar.approach.interval.week")).append(",");
- }
- else if (expressions[4].equals("5")) {
+ } else if (expressions[4].equals("5")) {
scheduleMessage.append("
").append(rb.getString("calendar.which.week.last")).append("
").append(rb.getString("calendar.approach.interval.week")).append(",");
}
- if(expressions[5].equals("1")) {
+ if (expressions[5].equals("1")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.monday")).append(".");
- }
- else if (expressions[5].equals("2")) {
+ } else if (expressions[5].equals("2")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.tuesday")).append(".");
- }
- else if (expressions[5].equals("3")) {
+ } else if (expressions[5].equals("3")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.wednesday")).append(".");
- }
- else if (expressions[5].equals("4")) {
+ } else if (expressions[5].equals("4")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.thursday")).append(".");
- }
- else if (expressions[5].equals("5")) {
+ } else if (expressions[5].equals("5")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.friday")).append(".");
- }
- else if (expressions[5].equals("6")) {
+ } else if (expressions[5].equals("6")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.saturday")).append(".");
- }
- else if (expressions[5].equals("7")) {
+ } else if (expressions[5].equals("7")) {
scheduleMessage.append("
").append(rb.getString("calendar.week.sunday")).append(".");
}
months = expressions[6];
}
String temp = "";
- for(int i = 0 ; i < months.length();i++) {
- String month = months.substring(i,i+1);
- if(month.equals("0")) {
- temp += rb.getString("calendar.month.january")+",";
- }
- else if(month.equals("1")) {
- temp += rb.getString("calendar.month.february")+",";
- }
- else if(month.equals("2")) {
- temp += rb.getString("calendar.month.march")+",";
- }
- else if(month.equals("3")) {
- temp += rb.getString("calendar.month.april")+",";
- }
- else if(month.equals("4")) {
- temp += rb.getString("calendar.month.may")+",";
- }
- else if(month.equals("5")) {
- temp += rb.getString("calendar.month.june")+",";
- }
- else if(month.equals("6")) {
- temp += rb.getString("calendar.month.july")+",";
- }
- else if(month.equals("7")) {
- temp += rb.getString("calendar.month.august")+",";
- }
- else if(month.equals("8")) {
- temp += rb.getString("calendar.month.september")+",";
- }
- else if(month.equals("9")) {
- temp += rb.getString("calendar.month.october")+",";
- }
- else if(month.equals("a")) {
- temp += rb.getString("calendar.month.november")+",";
- }
- else if(month.equals("b")) {
- temp += rb.getString("calendar.month.december")+",";
+ for (int i = 0; i < months.length(); i++) {
+ String month = months.substring(i, i + 1);
+ if (month.equals("0")) {
+ temp += rb.getString("calendar.month.january") + ",";
+ } else if (month.equals("1")) {
+ temp += rb.getString("calendar.month.february") + ",";
+ } else if (month.equals("2")) {
+ temp += rb.getString("calendar.month.march") + ",";
+ } else if (month.equals("3")) {
+ temp += rb.getString("calendar.month.april") + ",";
+ } else if (month.equals("4")) {
+ temp += rb.getString("calendar.month.may") + ",";
+ } else if (month.equals("5")) {
+ temp += rb.getString("calendar.month.june") + ",";
+ } else if (month.equals("6")) {
+ temp += rb.getString("calendar.month.july") + ",";
+ } else if (month.equals("7")) {
+ temp += rb.getString("calendar.month.august") + ",";
+ } else if (month.equals("8")) {
+ temp += rb.getString("calendar.month.september") + ",";
+ } else if (month.equals("9")) {
+ temp += rb.getString("calendar.month.october") + ",";
+ } else if (month.equals("a")) {
+ temp += rb.getString("calendar.month.november") + ",";
+ } else if (month.equals("b")) {
+ temp += rb.getString("calendar.month.december") + ",";
}
}
- if(StringUtils.isNotEmpty(temp)){
- if(temp.endsWith(",")){
- temp = temp.substring(0,temp.length()-1) ;
+ if (StringUtils.isNotEmpty(temp)) {
+ if (temp.endsWith(",")) {
+ temp = temp.substring(0, temp.length() - 1);
}
}
scheduleMessage.append("<br/>").append(rb.getString("calendar.month")).append("
").append(temp);
@@ -710,13 +711,19 @@
public static void restoreSchedule(int scheduleId) {
Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
Node scheduleNode = cloud.getNode(scheduleId);
- Node newsletterNode = SearchUtil.findRelatedNode(scheduleNode,
"newsletter", "posrel");
- if(newsletterNode != null) {
- newsletterNode.setStringValue("schedule",
scheduleNode.getStringValue("expression"));
+ Node newsletterNode = SearchUtil.findRelatedNode(scheduleNode,
NEWSLETTER, POSREL);
+ if (newsletterNode != null) {
+ newsletterNode.setStringValue(SCHEDULE,
scheduleNode.getStringValue("expression"));
newsletterNode.setStringValue("scheduledescription",
getScheduleMessageByExpression(scheduleNode.getStringValue("expression")));
newsletterNode.commit();
}
scheduleNode.setLongValue("createdatetime", System.currentTimeMillis());
scheduleNode.commit();
}
+
+ public static void addNewsletterCreationChannel(int newsletterId ,int
editionId) {
+ Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
+ RelationManager relManager = cloud.getRelationManager(NEWSLETTER,
NEWSLETTERPUBLICATION, RELATED);
+ relManager.createRelation(cloud.getNode(newsletterId),
cloud.getNode(editionId)).commit();
+ }
}
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs