View Javadoc

1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.kew.routeheader;
17  
18  import org.kuali.rice.core.api.util.xml.XmlException;
19  import org.kuali.rice.kew.rule.WorkflowRuleAttribute;
20  import org.kuali.rice.kew.rule.web.RoutingReportAction;
21  import org.kuali.rice.kew.api.KewApiConstants;
22  
23  import java.util.Iterator;
24  import java.util.List;
25  
26  
27  /**
28   * {@link DocumentContent} which is generated from a List of attributes.
29   * Used by the {@link RoutingReportAction} to aid in generation of 
30   * document content when running routing reports.
31   * 
32   * @see org.kuali.rice.kew.rule.WorkflowRuleAttribute
33   * @see RoutingReportAction
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public class AttributeDocumentContent extends StandardDocumentContent {
38      
39  	private static final long serialVersionUID = 6789132279492877000L;
40  
41  	public AttributeDocumentContent(List attributes) throws XmlException {
42          super(generateDocContent(attributes));
43      }
44      
45      private static String generateDocContent(List attributes) {
46          StringBuffer buffer = new StringBuffer();
47          buffer.append("<").append(KewApiConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
48          buffer.append("<").append(KewApiConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
49          for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
50              WorkflowRuleAttribute attribute = (WorkflowRuleAttribute) iterator.next();
51              buffer.append(attribute.getDocContent());
52          }
53          buffer.append("</").append(KewApiConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
54          buffer.append("</").append(KewApiConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
55          return buffer.toString();
56      }
57  
58  }