001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kew.routeheader;
017
018 import org.kuali.rice.core.api.util.xml.XmlException;
019 import org.kuali.rice.kew.rule.WorkflowRuleAttribute;
020 import org.kuali.rice.kew.rule.web.RoutingReportAction;
021 import org.kuali.rice.kew.api.KewApiConstants;
022
023 import java.util.Iterator;
024 import java.util.List;
025
026
027 /**
028 * {@link DocumentContent} which is generated from a List of attributes.
029 * Used by the {@link RoutingReportAction} to aid in generation of
030 * document content when running routing reports.
031 *
032 * @see org.kuali.rice.kew.rule.WorkflowRuleAttribute
033 * @see RoutingReportAction
034 *
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 */
037 public class AttributeDocumentContent extends StandardDocumentContent {
038
039 private static final long serialVersionUID = 6789132279492877000L;
040
041 public AttributeDocumentContent(List attributes) throws XmlException {
042 super(generateDocContent(attributes));
043 }
044
045 private static String generateDocContent(List attributes) {
046 StringBuffer buffer = new StringBuffer();
047 buffer.append("<").append(KewApiConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
048 buffer.append("<").append(KewApiConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
049 for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
050 WorkflowRuleAttribute attribute = (WorkflowRuleAttribute) iterator.next();
051 buffer.append(attribute.getDocContent());
052 }
053 buffer.append("</").append(KewApiConstants.ATTRIBUTE_CONTENT_ELEMENT).append(">");
054 buffer.append("</").append(KewApiConstants.DOCUMENT_CONTENT_ELEMENT).append(">");
055 return buffer.toString();
056 }
057
058 }