KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > workflow > WorkflowDocumentSet


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: WorkflowDocumentSet.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.workflow;
21
22 import org.apache.lenya.cms.publication.Document;
23 import org.apache.lenya.cms.publication.DocumentSet;
24 import org.apache.lenya.workflow.WorkflowException;
25 import org.apache.lenya.workflow.WorkflowInstance;
26 import org.apache.lenya.workflow.impl.SynchronizedWorkflowInstancesImpl;
27
28 /**
29  * A synchronized workflow instance representing a set of documents.
30  */

31 public class WorkflowDocumentSet extends SynchronizedWorkflowInstancesImpl {
32
33     /**
34      * Ctor.
35      * @param documentSet The document set.
36      * @param mainDocument The main document of the set, i.e. the document to
37      * invoke the workflow on if the transition is not synchronized.
38      * @throws WorkflowException when something went wrong.
39      */

40     public WorkflowDocumentSet(DocumentSet documentSet, Document mainDocument) throws WorkflowException {
41         Document[] documents = documentSet.getDocuments();
42         WorkflowInstance[] instances = new WorkflowInstance[documents.length];
43         WorkflowFactory factory = WorkflowFactory.newInstance();
44         for (int i = 0; i < documents.length; i++) {
45             instances[i] = factory.buildInstance(documents[i]);
46         }
47         setInstances(instances);
48         setMainInstance(factory.buildInstance(mainDocument));
49     }
50
51 }
52
Popular Tags