001: /*
002: * Copyright 2005 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Oct 7, 2005
014: * @author James Dixon
015: */
016:
017: package com.pentaho.repository.subscribe;
018:
019: import java.util.*;
020:
021: /**
022: * This class defines an action sequence (e.g. a report) that users can create subscriptions to. This class contains a reference
023: * to the action sequence that will be executed when the subscription is viewed online or scheduled. Parameters to the action
024: * sequence can be defined here. These parameters will be applied to every subscription to the action sequence. These parameter
025: * values can be overriden by the individual subscriptions if the user interface allows.
026: *
027: * @author James Dixon
028: *
029: */
030: public class SubscribeContent {
031: protected static final int ClassVersionNumber = 2;
032:
033: public static final String TYPE_REPORT = "report"; //$NON-NLS-1$
034:
035: public static final String TYPE_VIEW = "view"; //$NON-NLS-1$
036:
037: public static final String TYPE_DASHBOARD = "dashboard"; //$NON-NLS-1$
038:
039: private int revision = -1; // Hibernate Revision
040:
041: private String id;
042:
043: private String actionReference;
044:
045: private Map parameters;
046:
047: private String type;
048:
049: private List schedules;
050:
051: protected SubscribeContent() {
052: // Needed for Hibernate to construct and re-load.
053: }
054:
055: public SubscribeContent(String subContId, String actionReference,
056: String type) {
057: this .actionReference = actionReference;
058: this .id = subContId;
059: this .type = type;
060: parameters = new HashMap();
061: schedules = new ArrayList();
062: }
063:
064: public SubscribeContent(String subContId, String actionReference,
065: String type, Map parameters) {
066: this .actionReference = actionReference;
067: this .id = subContId;
068: this .type = type;
069: this .parameters = parameters;
070: schedules = new ArrayList();
071: }
072:
073: public boolean equals(Object other) {
074: if (this == other) {
075: return true;
076: }
077: if (!(other instanceof SubscribeContent)) {
078: return false;
079: }
080: final SubscribeContent that = (SubscribeContent) other;
081: return this .getId().equals(that.getId());
082: }
083:
084: public int hashCode() {
085: return getId().hashCode();
086: }
087:
088: /**
089: * @return Returns the revision.
090: */
091: public int getRevision() {
092: return revision;
093: }
094:
095: /**
096: * @param revision
097: * The revision to set. This is set by Hibernate.
098: */
099: protected void setRevision(int revision) {
100: this .revision = revision;
101: }
102:
103: /**
104: * Gets the reference to the action sequence used by subscriptions to this content
105: *
106: * @return Action sequence reference
107: */
108: public String getActionReference() {
109: return actionReference;
110: }
111:
112: public void addSchedule(Schedule schedule) {
113: schedules.add(schedule);
114: }
115:
116: public List getSchedules() {
117: return schedules;
118: }
119:
120: public boolean hasSchedule(Schedule schedule) {
121: return (schedules.contains(schedule));
122: }
123:
124: public boolean removeSchedule(Schedule schedule) {
125: return (schedules.remove(schedule));
126: }
127:
128: /**
129: * Sets the parameters that will be provided to the action sequence when it is executed as part of a subscription
130: *
131: * @param parameters
132: * The parameters to pass to the action sequence
133: */
134: public void setParameters(Map parameters) {
135: this .parameters = parameters;
136: }
137:
138: /**
139: * Gets the parameters for the content
140: *
141: * @return Parameter HashMap
142: */
143: public Map getParameters() {
144: return parameters;
145: }
146:
147: /**
148: * Gets the id of this content
149: *
150: * @return
151: */
152: public String getId() {
153: return id;
154: }
155:
156: public String getType() {
157: return type;
158: }
159:
160: protected void setId(String value) {
161: this .id = value;
162: }
163:
164: /**
165: * Sets a reference to the action sequence that will be executed as part of a subscription
166: *
167: * @param actionReference
168: */
169: protected void setActionReference(String actionReference) {
170: this .actionReference = actionReference;
171: }
172:
173: protected void setSchedules(List schedules) {
174: this .schedules = schedules;
175: }
176:
177: protected void setType(String type) {
178: this.type = type;
179: }
180:
181: }
|