Skip to content

Commit

Permalink
RESKC-1604: supporting RR Subaward Budget 10 10 version 1.4. Fixing v…
Browse files Browse the repository at this point in the history
…ersion 1.2 and 1.3 of the RR Subaward Budget 10 10 forms' stylesheets when there is no equipment present.
  • Loading branch information
leoherbie committed Oct 25, 2016
1 parent 37eae42 commit 372ba6d
Show file tree
Hide file tree
Showing 6 changed files with 3,324 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/*
* Kuali Coeus, a comprehensive research administration system for higher education.
*
* Copyright 2005-2016 Kuali, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.coeus.s2sgen.impl.generate.support;

import gov.grants.apply.forms.rrBudget1014V14.RRBudget1014Document;
import gov.grants.apply.forms.rrBudget1014V14.RRBudget1014Document.RRBudget1014;
import gov.grants.apply.forms.rrSubawardBudget101014V14.RRSubawardBudget101014Document;
import gov.grants.apply.forms.rrSubawardBudget101014V14.RRSubawardBudget101014Document.RRSubawardBudget101014;
import gov.grants.apply.forms.rrSubawardBudget101014V14.RRSubawardBudget101014Document.RRSubawardBudget101014.BudgetAttachments;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.kuali.coeus.propdev.api.budget.subaward.BudgetSubAwardsContract;
import org.kuali.coeus.propdev.api.core.ProposalDevelopmentDocumentContract;

import org.kuali.coeus.s2sgen.impl.generate.FormGenerator;
import org.kuali.coeus.s2sgen.impl.generate.FormVersion;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import java.util.List;

@FormGenerator("RRSubAwardBudget10_10V1_4Generator")
public class RRSubAwardBudget10_10V1_4Generator extends S2SAdobeFormAttachmentBaseGenerator {

private static final String RR_BUDGET_10_1_4_NAMESPACE_URI = "http://apply.grants.gov/forms/RR_Budget10_1_4-V1.4";
private static final String RR_BUDGET_10_1_4_LOCAL_NAME = "RR_Budget10_1_4";

@Value("http://apply.grants.gov/forms/RR_SubawardBudget10_10_1_4-V1.4")
private String namespace;

@Value("RR_SubawardBudget10_10_1_4")
private String formName;

@Value("classpath:org/kuali/coeus/s2sgen/impl/generate/support/stylesheet/RR_SubawardBudget10_10-V1.4.fo.xsl")
private Resource stylesheet;

@Value("gov.grants.apply.forms.rrSubawardBudget101014V14")
private String packageName;

@Value("178")
private int sortIndex;

private RRSubawardBudget101014Document getRRSubawardBudgetDocument() {

RRSubawardBudget101014Document rrSubawardBudgetDocument = RRSubawardBudget101014Document.Factory.newInstance();
RRSubawardBudget101014 rrSubawardBudget = RRSubawardBudget101014.Factory.newInstance();
BudgetAttachments budgetAttachments = BudgetAttachments.Factory.newInstance();
List<BudgetSubAwardsContract> budgetSubAwardsList = getBudgetSubAwards(pdDoc,RR_BUDGET_10_1_4_NAMESPACE_URI,false);
RRBudget1014[] budgetList = new RRBudget1014[budgetSubAwardsList.size()];
rrSubawardBudget.setFormVersion(FormVersion.v1_4.getVersion());

int attIndex = 1;
for (BudgetSubAwardsContract budgetSubAwards : budgetSubAwardsList) {
final RRBudget1014Document rrBudgetDocument = getRRBudget(budgetSubAwards);
if (rrBudgetDocument != null) {
RRBudget1014 rrBudget = rrBudgetDocument.getRRBudget1014();
switch (attIndex) {
case 1:
rrSubawardBudget.setATT1(prepareAttName(budgetSubAwards));
budgetList[0] = rrBudget;
break;
case 2:
rrSubawardBudget.setATT2(prepareAttName(budgetSubAwards));
budgetList[1] = rrBudget;
break;
case 3:
rrSubawardBudget.setATT3(prepareAttName(budgetSubAwards));
budgetList[2] = rrBudget;
break;
case 4:
rrSubawardBudget.setATT4(prepareAttName(budgetSubAwards));
budgetList[3] = rrBudget;
break;
case 5:
rrSubawardBudget.setATT5(prepareAttName(budgetSubAwards));
budgetList[4] = rrBudget;
break;
case 6:
rrSubawardBudget.setATT6(prepareAttName(budgetSubAwards));
budgetList[5] = rrBudget;
break;
case 7:
rrSubawardBudget.setATT7(prepareAttName(budgetSubAwards));
budgetList[6] = rrBudget;
break;
case 8:
rrSubawardBudget.setATT8(prepareAttName(budgetSubAwards));
budgetList[7] = rrBudget;
break;
case 9:
rrSubawardBudget.setATT9(prepareAttName(budgetSubAwards));
budgetList[8] = rrBudget;
break;
case 10:
rrSubawardBudget.setATT10(prepareAttName(budgetSubAwards));
budgetList[9] = rrBudget;
break;
}
addSubAwdAttachments(budgetSubAwards);
attIndex++;
}
}
budgetAttachments.setRRBudget1014Array(budgetList);
rrSubawardBudget.setBudgetAttachments(budgetAttachments);
rrSubawardBudgetDocument.setRRSubawardBudget101014(rrSubawardBudget);
return rrSubawardBudgetDocument;
}

private RRBudget1014Document getRRBudget(BudgetSubAwardsContract budgetSubAwards) {
String subAwdXML = budgetSubAwards.getSubAwardXmlFileData();
Document subAwdFormsDoc = stringToDom(subAwdXML);
Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement();
NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET_10_1_4_NAMESPACE_URI, RR_BUDGET_10_1_4_LOCAL_NAME);
Node subAwdNode = null;
if (subAwdNodeList != null){
if(subAwdNodeList.getLength() == 0) {
return null;
}
subAwdNode = subAwdNodeList.item(0);
}
byte[] subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode));
try {
return (RRBudget1014Document) XmlObject.Factory.parse(new ByteArrayInputStream(subAwdNodeBytes));
} catch (XmlException|IOException e) {
throw new RuntimeException(e);
}
}

@Override
public XmlObject getFormObject(ProposalDevelopmentDocumentContract proposalDevelopmentDocument) {
pdDoc=proposalDevelopmentDocument;
return getRRSubawardBudgetDocument();
}

@Override
public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

@Override
public String getFormName() {
return formName;
}

public void setFormName(String formName) {
this.formName = formName;
}

@Override
public Resource getStylesheet() {
return stylesheet;
}

public void setStylesheet(Resource stylesheet) {
this.stylesheet = stylesheet;
}

@Override
public String getPackageName() {
return packageName;
}

public void setPackageName(String packageName) {
this.packageName = packageName;
}

@Override
public int getSortIndex() {
return sortIndex;
}

public void setSortIndex(int sortIndex) {
this.sortIndex = sortIndex;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:RR_SubawardBudget10_10_1_4="http://apply.grants.gov/forms/RR_SubawardBudget10_10_1_4-V1.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:glob="http://apply.grants.gov/system/Global-V1.0" xmlns:globLib="http://apply.grants.gov/system/GlobalLibrary-V2.0" xmlns:RR_Budget10_1_4="http://apply.grants.gov/forms/RR_Budget10_1_4-V1.4" xmlns:att="http://apply.grants.gov/system/Attachments-V1.0" targetNamespace="http://apply.grants.gov/forms/RR_SubawardBudget10_10_1_4-V1.4" elementFormDefault="qualified" attributeFormDefault="qualified" version="1.4">
<xs:import namespace="http://apply.grants.gov/system/Global-V1.0" schemaLocation="http://trainingapply.grants.gov/apply/system/schemas/Global-V1.0.xsd"/>
<xs:import namespace="http://apply.grants.gov/system/GlobalLibrary-V2.0" schemaLocation="http://trainingapply.grants.gov/apply/system/schemas/GlobalLibrary-V2.0.xsd"/>
<xs:import namespace="http://apply.grants.gov/system/Attachments-V1.0" schemaLocation="http://trainingapply.grants.gov/apply/system/schemas/Attachments-V1.0.xsd"/>
<xs:import namespace="http://apply.grants.gov/forms/RR_Budget10_1_4-V1.4" schemaLocation="http://trainingapply.grants.gov/apply/forms/schemas/RR_Budget10_1_4-V1.4.xsd"/>
<xs:element name="RR_SubawardBudget10_10_1_4">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="ATT1" type="xs:string" minOccurs="0"/>
<xs:element name="ATT2" type="xs:string" minOccurs="0"/>
<xs:element name="ATT3" type="xs:string" minOccurs="0"/>
<xs:element name="ATT4" type="xs:string" minOccurs="0"/>
<xs:element name="ATT5" type="xs:string" minOccurs="0"/>
<xs:element name="ATT6" type="xs:string" minOccurs="0"/>
<xs:element name="ATT7" type="xs:string" minOccurs="0"/>
<xs:element name="ATT8" type="xs:string" minOccurs="0"/>
<xs:element name="ATT9" type="xs:string" minOccurs="0"/>
<xs:element name="ATT10" type="xs:string" minOccurs="0"/>
<xs:element name="BudgetAttachments" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="RR_Budget10_1_4:RR_Budget10_1_4" minOccurs="0" maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="FormVersion" type="globLib:FormVersionDataType" use="required" fixed="1.4"/>
</xs:complexType>
</xs:element>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,11 @@
<group prefer="public">
<public publicId="http://apply.grants.gov/forms/RR_SubawardBudget10_10_1_3-V1.3" uri="RR_SubawardBudget10_10_1_3-V1.3.xsd"/>
</group>


<group prefer="public">
<public publicId="http://apply.grants.gov/forms/RR_SubawardBudget10_10_1_4-V1.4" uri="RR_SubawardBudget10_10_1_4-V1.4.xsd"/>
</group>

<group prefer="public">
<public publicId="http://apply.grants.gov/forms/RR_SubawardBudget10_30-V1.2" uri="RR_SubawardBudget10_30-V1.2.xsd"/>
</group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,13 @@
</fo:table-row>
</xsl:if>
<xsl:for-each select="RR_Budget10:Equipment">
<xsl:if test="string-length(RR_Budget10:EquipmentList)=0">
<fo:table-row>
<fo:table-cell>
<fo:block/>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:for-each select="RR_Budget10:EquipmentList">
<fo:table-row>
<fo:table-cell hyphenate="true" language="en" line-height="9pt" padding-start="1pt" padding-end="1pt" padding-before="1pt" padding-after="1pt" display-align="before" text-align="start">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,7 @@
<fo:block>
<fo:inline font-size="8pt" font-weight="bold">C. Equipment Description</fo:inline>
<fo:block>

</fo:block>
<fo:inline font-size="8pt" font-weight="bold">List items and dollar amount for each item exceeding $5,000</fo:inline>
<fo:table width="100%" space-before.optimum="1pt" space-after.optimum="2pt" table-layout="fixed">
Expand All @@ -2161,7 +2161,6 @@
</fo:table-row>
</fo:table-header>
<fo:table-body>

<xsl:if test="string-length(RR_Budget10_1_3:Equipment)=0">
<fo:table-row>
<fo:table-cell >
Expand All @@ -2170,6 +2169,13 @@
</fo:table-row>
</xsl:if>
<xsl:for-each select="RR_Budget10_1_3:Equipment">
<xsl:if test="string-length(RR_Budget10_1_3:EquipmentList)=0">
<fo:table-row>
<fo:table-cell>
<fo:block/>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:for-each select="RR_Budget10_1_3:EquipmentList">
<fo:table-row>
<fo:table-cell hyphenate="true" language="en" line-height="9pt" padding-start="1pt" padding-end="1pt" padding-before="1pt" padding-after="1pt" display-align="before" text-align="start">
Expand Down
Loading

0 comments on commit 372ba6d

Please sign in to comment.