001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/api/src/java/org/theospi/portfolio/workflow/model/Workflow.java $
003: * $Id: Workflow.java 29139 2007-04-18 23:27:24Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.workflow.model;
021:
022: import java.util.Comparator;
023: import java.util.HashSet;
024: import java.util.Set;
025:
026: import org.sakaiproject.metaobj.shared.model.IdentifiableObject;
027: import org.theospi.portfolio.shared.model.ObjectWithWorkflow;
028:
029: public class Workflow extends IdentifiableObject {
030:
031: private String title;
032: private Set<WorkflowItem> items = new HashSet<WorkflowItem>();
033: private boolean newObject = false;
034: private ObjectWithWorkflow parentObject;
035:
036: public Workflow() {
037: }
038:
039: public Workflow(String title, ObjectWithWorkflow parentObject) {
040: this .title = title;
041: this .parentObject = parentObject;
042: }
043:
044: /**
045: * @return Returns the title.
046: */
047: public String getTitle() {
048: return title;
049: }
050:
051: /**
052: * @param title The title to set.
053: */
054: public void setTitle(String title) {
055: this .title = title;
056: }
057:
058: /**
059: * @return Returns the items.
060: */
061: public Set<WorkflowItem> getItems() {
062: return items;
063: }
064:
065: /**
066: * @param items The items to set.
067: */
068: public void setItems(Set<WorkflowItem> items) {
069: this .items = items;
070: }
071:
072: /**
073: * @return Returns the newObject.
074: */
075: public boolean isNewObject() {
076: return newObject;
077: }
078:
079: /**
080: * @param newObject The newObject to set.
081: */
082: public void setNewObject(boolean newObject) {
083: this .newObject = newObject;
084: }
085:
086: public void add(WorkflowItem item) {
087: item.setWorkflow(this );
088: getItems().add(item);
089: }
090:
091: /* (non-Javadoc)
092: * @see org.sakaiproject.metaobj.shared.model.IdentifiableObject#equals(java.lang.Object)
093: */
094: public boolean equals(Object in) {
095: // TODO Auto-generated method stub
096: //return super.equals(in);
097:
098: if (this == in)
099: return true;
100: if (in == null && this == null)
101: return true;
102: if (in == null && this != null)
103: return false;
104: if (this == null && in != null)
105: return false;
106: if (this .getId() == null && ((Workflow) in).getId() != null)
107: return false;
108: if (this .getId() != null && ((Workflow) in).getId() == null)
109: return false;
110: if (this .getId() == null && ((Workflow) in).getId() == null
111: && !this .getTitle().equals(((Workflow) in).getTitle()))
112: return false;
113: return this .getId().equals(((Workflow) in).getId());
114:
115: }
116:
117: /**
118: * @return Returns the parentObject.
119: */
120: public ObjectWithWorkflow getParentObject() {
121: return parentObject;
122: }
123:
124: /**
125: * @param parentObject The parentObject to set.
126: */
127: public void setParentObject(ObjectWithWorkflow parentObject) {
128: this .parentObject = parentObject;
129: }
130:
131: public static class WorkflowComparator implements Comparator {
132: public int compare(Object o1, Object o2) {
133: return ((Workflow) o1).getTitle().toLowerCase().compareTo(
134: ((Workflow) o2).getTitle().toLowerCase());
135: }
136: }
137:
138: public static WorkflowComparator getComparator() {
139: return new WorkflowComparator();
140: }
141:
142: }
|