Example usage for java.lang Enum equals

List of usage examples for java.lang Enum equals

Introduction

In this page you can find the example usage for java.lang Enum equals.

Prototype

public final boolean equals(Object other) 

Source Link

Document

Returns true if the specified object is equal to this enum constant.

Usage

From source file:com.apatar.rss.RssNode.java

private static RDBTable getTableAccordingToVersion(RssNode node, boolean createNew)
        throws HttpException, IOException, JDOMException {
    LoadParams loadParams = null;/*from w  w  w . j a  v a2 s . c o  m*/
    CreateNewParams createParams = null;

    Object data = ApplicationData.getProject().getProjectData(node.getConnectionDataID()).getData();
    if (data == null) {
        return null;
    }

    if (createNew) {
        createParams = (CreateNewParams) data;
    } else {
        loadParams = (LoadParams) data;
    }

    if (createNew) {
        return new RDBTable(createParams.getVersion().equals(Version.ATOM_1_0) ? "entry" : "item",
                ETableMode.ReadWrite);
    } else {
        Document doc = getDocument(loadParams);
        if (doc == null) {
            return null;
        }
        Enum version = determinationVersion(doc.getRootElement());
        return new RDBTable(version.equals(Version.ATOM_1_0) ? "entry" : "item", ETableMode.ReadWrite);
    }
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_0Generator.java

/**
 *
 * This method is used to get ApplicationType for the form RRSF424
 *
 * @return ApplicationType corresponding to the proposal type code.
 *///w  ww . j  av  a 2s  .  co m
private ApplicationType getApplicationType() {
    ApplicationType applicationType = ApplicationType.Factory.newInstance();
    String proposalTypeCode = pdDoc.getDevelopmentProposal().getProposalType().getCode();
    if (s2SConfigurationService
            .getValuesFromCommaSeparatedParam(ConfigurationConstants.PROPOSAL_TYPE_CODE_REVISION)
            .contains(proposalTypeCode)) {
        ApplicationTypeCodeDataType.Enum applicationTypeCodeDataType = ApplicationTypeCodeDataType.Enum
                .forInt(Integer.parseInt(proposalTypeCode));
        applicationType.setApplicationTypeCode(applicationTypeCodeDataType);
        Map<String, String> submissionInfo = getSubmissionType(pdDoc);
        String revisionCode;
        if (submissionInfo.get(KEY_REVISION_CODE) != null) {
            revisionCode = submissionInfo.get(KEY_REVISION_CODE);
            RevisionCode revisionCodeApplication = RevisionCode.Factory.newInstance();
            revisionCodeApplication.setStringValue(revisionCode);
            applicationType.setRevisionCode(revisionCodeApplication);
        }
        String revisionCodeOtherDesc;
        if (submissionInfo.get(KEY_REVISION_OTHER_DESCRIPTION) != null) {
            revisionCodeOtherDesc = submissionInfo.get(KEY_REVISION_OTHER_DESCRIPTION);
            RevisionCodeOtherExplanation revisionCodeOtherExplanation = RevisionCodeOtherExplanation.Factory
                    .newInstance();
            revisionCodeOtherExplanation.setStringValue(revisionCodeOtherDesc);
            applicationType.setRevisionCodeOtherExplanation(revisionCodeOtherExplanation);
        }
    }
    if (pdDoc.getDevelopmentProposal().getProposalType() != null) {
        setProposalApplicationType(proposalTypeCode, applicationType);
    }
    ProposalYnqContract proposalYnq = getAnswer(PROPOSAL_YNQ_OTHER_AGENCY_SUBMISSION, pdDoc);
    Enum answer = YesNoDataType.NO;
    if (proposalYnq != null && proposalYnq.getAnswer() != null) {
        answer = (proposalYnq.getAnswer().equals(YnqConstant.YES.code()) ? YesNoDataType.YES
                : YesNoDataType.NO);
    }
    applicationType.setIsOtherAgencySubmission(answer);
    if (answer.equals(YesNoDataType.YES)) {
        OtherAgencySubmissionExplanation otherAgencySubmissionExplanation = OtherAgencySubmissionExplanation.Factory
                .newInstance();
        otherAgencySubmissionExplanation.setIsOtherAgencySubmission(answer);
        String answerExplanation = proposalYnq.getExplanation();
        if (answerExplanation != null) {
            if (answerExplanation.length() > ANSWER_EXPLANATION_MAX_LENGTH) {
                otherAgencySubmissionExplanation
                        .setStringValue(answerExplanation.substring(0, ANSWER_EXPLANATION_MAX_LENGTH));
            } else {
                otherAgencySubmissionExplanation.setStringValue(answerExplanation);
            }
        }
        applicationType.setOtherAgencySubmissionExplanation(otherAgencySubmissionExplanation);
    }
    return applicationType;
}

From source file:com.apatar.rss.RssNode.java

private Element getParentForItem(Document doc, Enum version) {
    Element root = doc.getRootElement();
    if (version.equals(Version.RSS_1_0)) {
        return root;
    } else {/*  w w  w.j a  v  a2  s. c o  m*/
        if (version.equals(Version.RSS_2_0)) {
            return getChildElement(root, "channel");
        } else if (version.equals(Version.ATOM_1_0)) {
            return root;
        }
    }
    return null;
}

From source file:com.apatar.rss.RssNode.java

public List<Element> getItems(Document doc) throws JDOMException, IOException {
    Element root = doc.getRootElement();
    Enum version = determinationVersion(root);
    List list = null;/*  w ww .j  ava2  s . co m*/
    List<Element> result = new ArrayList<Element>();
    if (version.equals(Version.RSS_1_0)) {
        list = root.getChildren();
    } else {
        if (version.equals(Version.RSS_2_0)) {
            return getElementsByTagName("item", doc);
        } else if (version.equals(Version.ATOM_1_0)) {
            list = root.getChildren();
        }
    }

    if (list == null) {
        return null;
    }

    String tagName = getTableName();

    for (Object obj : list) {
        Element elem = (Element) obj;
        if (elem.getName().equalsIgnoreCase(tagName)) {
            result.add(elem);
        }
    }
    return result;
}

From source file:com.apatar.rss.RssNode.java

@Override
protected void TransformTDBtoRDB(int mode) {
    try {//from  w  ww .  j  a v  a  2  s  .c o m
        DataBaseTools.completeTransfer();
        LoadParams loadParams = null;
        CreateNewParams createParams = null;

        if (createNew) {
            createParams = (CreateNewParams) ApplicationData.getProject().getProjectData(getConnectionDataID())
                    .getData();
        } else {
            loadParams = (LoadParams) ApplicationData.getProject().getProjectData(getConnectionDataID())
                    .getData();
        }

        File file;

        Element channelElem = generateElement(channel);

        rssTitle = channel.getChild("title").getValue();
        RssElement rsselemDescr = channel.getChild("description");
        if (rsselemDescr != null) {
            description = rsselemDescr.getValue();
        } else {
            description = rssTitle;
        }

        if (createNew) {
            Enum version = createParams.getVersion();

            Element root = null;

            if (version.equals(Version.RSS_2_0)) {
                root = new Element("rss");
                root.setAttribute("version", "2.0");
                root.addContent(channelElem);
            } else {
                if (version.equals(Version.RSS_1_0)) {
                    root = new Element("RDF");
                    root.addNamespaceDeclaration(RDF_NS);
                    root.setNamespace(RDF_NS);
                    root.addContent(channelElem);
                    Element items = new Element("items");
                    Element seq = new Element("Seq");
                    seq.setNamespace(RDF_NS);
                    items.addContent(seq);
                    channelElem.addContent(items);
                } else {
                    if (version.equals(Version.ATOM_1_0)) {
                        root = channelElem;
                        root.setNamespace(ATOM_NS);
                    }
                }

            }
            if (root == null) {
                return;
            }
            doc = new Document(root);
            file = createParams.getFile();

        } else {
            file = loadParams.getSourceFile();
            doc = ReadWriteXMLData.loadDocument(file);
        }

        TableInfo iTI = getTiForConnection(IN_CONN_POINT_NAME);

        ResultSet rs = DataBaseTools.getRSWithAllFields(iTI.getTableName(), ApplicationData.getTempJDBC(),
                ApplicationData.getTempDataBaseInfo());

        insertData(rs, doc, iTI, createNew);

        FileWriter writer = new FileWriter(file);
        // TODO decide to use ReadWriteXMLDataUi instead of ReadWriteXMLData
        // TODO decide to use or not this encoding
        ReadWriteXMLData rwXMLdata = new ReadWriteXMLData();
        rwXMLdata.saveDocumentToFile(doc, writer, "windows-1251");

        if (publish) {
            publishing();
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DataBaseTools.completeTransfer();
    }
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RROtherProjectInfoV1_1Generator.java

/**
 * /*from w w w  . j  a  v a  2 s  .co m*/
 * This method gives information about RROtherProjectInfo of proposal special reviews based on the data in the proposal
 * development document.
 * 
 * @return rrOtherProjectInfoDocument(RROtherProjectInfoDocument)
 */
private RROtherProjectInfoDocument getRROtherProjectInfo() {

    LOG.info("Inside RROtherProjectInfo");
    RROtherProjectInfoDocument rrOtherProjectInfoDocument = RROtherProjectInfoDocument.Factory.newInstance();
    RROtherProjectInfoDocument.RROtherProjectInfo rrOtherProjectInfo = RROtherProjectInfoDocument.RROtherProjectInfo.Factory
            .newInstance();
    rrOtherProjectInfo.setFormVersion(FormVersion.v1_1.getVersion());
    answerHeaders = getPropDevQuestionAnswerService()
            .getQuestionnaireAnswerHeaders(pdDoc.getDevelopmentProposal().getProposalNumber());
    setHumanSubjAndVertebrateAnimals(rrOtherProjectInfo);
    Enum answer = YesNoDataType.N_NO;
    String answerExplanation = " ";

    /**
     * ProprietaryInformationIndicator is of YnQ type
     */
    EnvironmentalImpact environmentalImpact = EnvironmentalImpact.Factory.newInstance();
    InternationalActivities internationalActivities = InternationalActivities.Factory.newInstance();
    String propertyInformationAnswer = getAnswer(PROPRIETARY_INFORMATION_INDICATOR, answerHeaders);
    if (propertyInformationAnswer != null && !propertyInformationAnswer.equals(NOT_ANSWERED)) {
        answer = (YnqConstant.YES.code().equals(propertyInformationAnswer) ? YesNoDataType.Y_YES
                : YesNoDataType.N_NO);
        rrOtherProjectInfo.setProprietaryInformationIndicator(answer);
    } else {
        rrOtherProjectInfo.setProprietaryInformationIndicator(null);
    }
    /**
     * EnvironmentalImpact is of YnQ type
     */
    String environmentalImpactAnswer = getAnswer(ENVIRONMENTAL_IMPACT_YNQ, answerHeaders);
    answer = (YnqConstant.YES.code().equals(environmentalImpactAnswer) ? YesNoDataType.Y_YES
            : YesNoDataType.N_NO);
    answerExplanation = getChildQuestionAnswer(ENVIRONMENTAL_IMPACT_YNQ, EXPLANATION, answerHeaders);
    environmentalImpact.setEnvironmentalImpactIndicator(answer);
    if (environmentalImpactAnswer != null && !environmentalImpactAnswer.equals(NOT_ANSWERED)) {
        if (answerExplanation != null) {
            environmentalImpact.setEnvironmentalImpactExplanation(answerExplanation);
        } else {
            environmentalImpact.setEnvironmentalImpactIndicator(YesNoDataType.N_NO);
        }
    } else {
        environmentalImpact.setEnvironmentalImpactIndicator(null);
    }
    if (YnqConstant.YES.code().equals(environmentalImpactAnswer) && answerExplanation == null) {
        environmentalImpact.setEnvironmentalImpactExplanation(answerExplanation);
    }
    if (answer.equals(YesNoDataType.Y_YES)) {
        answerExplanation = getChildQuestionAnswer(ENVIRONMENTAL_EXEMPTION_YNQ, EXPLANATION, answerHeaders);
        String ynqAnswer = getAnswer(ENVIRONMENTAL_EXEMPTION_YNQ, answerHeaders);
        if (YnqConstant.YES.code().equals(ynqAnswer)) {
            answer = YesNoDataType.Y_YES;
        } else {
            answer = YesNoDataType.N_NO;
        }
        EnvironmentalImpact.EnvironmentalExemption environmentalExemption = EnvironmentalImpact.EnvironmentalExemption.Factory
                .newInstance();
        if (ynqAnswer != null && !ynqAnswer.equals(NOT_ANSWERED)) {
            if (!YnqConstant.NA.code().equals(ynqAnswer)) {
                // Answer not equal to X (not-applicable)
                environmentalExemption.setEnvironmentalExemptionIndicator(answer);
                if (YnqConstant.YES.code().equals(ynqAnswer)) {
                    environmentalExemption.setEnvironmentalExemptionExplanation(answerExplanation);
                }
            }
        } else {
            environmentalExemption.setEnvironmentalExemptionIndicator(null);
        }
        environmentalImpact.setEnvironmentalExemption(environmentalExemption);
    }
    rrOtherProjectInfo.setEnvironmentalImpact(environmentalImpact);

    /**
     * InternationalActivities is of YnQ type
     */
    String internationalActivitiesAnswer = getAnswer(INTERNATIONAL_ACTIVITIES_YNQ, answerHeaders);
    if (internationalActivitiesAnswer != null && !internationalActivitiesAnswer.equals(NOT_ANSWERED)) {
        answer = YnqConstant.YES.code().equals(internationalActivitiesAnswer) ? YesNoDataType.Y_YES
                : YesNoDataType.N_NO;
        answerExplanation = getAnswer(INTERNATIONAL_ACTIVITIES_EXPL, answerHeaders);
        internationalActivities.setInternationalActivitiesIndicator(answer);
        if (answerExplanation != null && !answerExplanation.equals(NOT_ANSWERED)) {
            internationalActivities.setActivitiesPartnershipsCountries(answerExplanation);
            if (getChildQuestionAnswer(INTERNATIONAL_ACTIVITIES_YNQ, EXPLANATION, answerHeaders) != null) {
                internationalActivities.setInternationalActivitiesExplanation(
                        getChildQuestionAnswer(INTERNATIONAL_ACTIVITIES_YNQ, EXPLANATION, answerHeaders));
            }
        }
        if (YnqConstant.YES.code().equals(internationalActivitiesAnswer) && answerExplanation == null) {
            internationalActivities.setActivitiesPartnershipsCountries(answerExplanation);
        }
    } else {
        internationalActivities.setInternationalActivitiesIndicator(null);
    }
    rrOtherProjectInfo.setInternationalActivities(internationalActivities);
    /**
     * Attachments
     */
    setAttachments(rrOtherProjectInfo);
    rrOtherProjectInfoDocument.setRROtherProjectInfo(rrOtherProjectInfo);
    return rrOtherProjectInfoDocument;
}

From source file:com.apatar.rss.RssNode.java

private void insertElement(ResultSet rs, Element parent, Document doc, List<Record> records, Enum version,
        boolean createNew) throws SQLException {
    for (Record rec : records) {
        String name = rec.getFieldName();

        RssElement rssElement = rssElementsByName.get(name);

        String value = rs.getString(name);
        if (value == null || value.equals("")) {
            continue;
        }/* w ww  .ja  v  a  2  s  .  co m*/

        if (rssElement.isAttribute() && rssElement.getParent() == null) {
            parent.setAttribute(name, value, rssElement.getNamespace());
            continue;
        }

        String[] chain = RssElement.getChain(name);
        Element childItem = getParentElement(chain, parent);
        if (rssElement.isAttribute()) {
            childItem.setAttribute(rssElement.getName(), value);
        } else {
            if (rssElement.parent != null) {
                Element child = new Element(rssElement.getName());
                child.setText(value);
                childItem.addContent(child);
            } else {
                childItem.setText(value);
            }
        }
    }
    if (version.equals(Version.RSS_1_0)) {
        Element root = doc.getRootElement();
        Namespace rootNs = root.getNamespace();
        String aboutValue = getAttributeValue(parent, "about");
        Element eSeq = getChildElement(getChildElement(getChildElement(root, "channel"), "items"), "Seq");
        Element eLi = new Element("li", rootNs);
        eLi.setAttribute("resource", aboutValue);
        eSeq.addContent(eLi);
        System.out.println(eSeq);
    }

}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RROtherProjectInfoV1_0Generator.java

/**
 * /*from w w w  . j  a v  a  2  s. c o m*/
 * This method gives information about RROtherProjectInfo of proposal special reviews based on the data in the proposal
 * development document.
 * 
 * @return rrOtherProjectInfoDocument {@link XmlObject} of type RRKeyPersonExpandedDocument.
 */
private RROtherProjectInfoDocument getRROtherProjectInfo() {

    RROtherProjectInfoDocument rrOtherProjectInfoDocument = RROtherProjectInfoDocument.Factory.newInstance();
    RROtherProjectInfo rrOtherProjectInfo = RROtherProjectInfo.Factory.newInstance();
    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    rrOtherProjectInfo.setFormVersion(FormVersion.v1_0.getVersion());

    answerHeaders = getPropDevQuestionAnswerService()
            .getQuestionnaireAnswerHeaders(pdDoc.getDevelopmentProposal().getProposalNumber());
    rrOtherProjectInfo.setHumanSubjectsIndicator(YesNoDataType.NO);
    rrOtherProjectInfo.setVertebrateAnimalsIndicator(YesNoDataType.NO);
    for (ProposalSpecialReviewContract proposalSpecialReview : pdDoc.getDevelopmentProposal()
            .getPropSpecialReviews()) {
        if (proposalSpecialReview.getSpecialReviewType() != null) {
            switch (Integer.parseInt(proposalSpecialReview.getSpecialReviewType().getCode())) {
            case HUMAN_SUBJECT_SUPPLEMENT:
                rrOtherProjectInfo.setHumanSubjectsIndicator(YesNoDataType.YES);
                HumanSubjectsSupplement huSubjectsSupplement = HumanSubjectsSupplement.Factory.newInstance();
                HumanSubjectsSupplement.ExemptionNumbers exemptionNumbers = HumanSubjectsSupplement.ExemptionNumbers.Factory
                        .newInstance();
                HumanSubjectsSupplement.HumanSubjectIRBReviewDate huSubjectIRBReviewDate = HumanSubjectsSupplement.HumanSubjectIRBReviewDate.Factory
                        .newInstance();
                if (proposalSpecialReview.getApprovalType() != null && Integer
                        .parseInt(proposalSpecialReview.getApprovalType().getCode()) == APPROVAL_TYPE_EXCEMPT) {
                    if (proposalSpecialReview.getSpecialReviewExemptions() != null) {
                        List<HumanSubjectsSupplement.ExemptionNumbers.ExemptionNumber.Enum> exemptionNumberList = new ArrayList<>();
                        HumanSubjectsSupplement.ExemptionNumbers.ExemptionNumber.Enum exemptionNumberEnum = null;
                        for (ProposalSpecialReviewExemptionContract exemption : proposalSpecialReview
                                .getSpecialReviewExemptions()) {
                            exemptionNumberEnum = HumanSubjectsSupplement.ExemptionNumbers.ExemptionNumber.Enum
                                    .forInt(Integer.parseInt(exemption.getExemptionType().getCode()));
                            exemptionNumberList.add(exemptionNumberEnum);
                        }
                        exemptionNumbers.setExemptionNumberArray(exemptionNumberList
                                .toArray(new HumanSubjectsSupplement.ExemptionNumbers.ExemptionNumber.Enum[1]));
                        huSubjectsSupplement.setExemptionNumbers(exemptionNumbers);
                    }
                }
                if (SPECIAL_REVIEW_HUMAN_SUBJECTS.equals(proposalSpecialReview.getApprovalType().getCode())) {
                    huSubjectsSupplement.setHumanSubjectIRBReviewIndicator(YesNoDataType.YES);
                } else {
                    huSubjectsSupplement.setHumanSubjectIRBReviewIndicator(YesNoDataType.NO);
                    if (proposalSpecialReview.getApprovalDate() != null) {
                        huSubjectIRBReviewDate.setCalendarValue(s2SDateTimeService
                                .convertDateToCalendar(proposalSpecialReview.getApprovalDate()));
                        huSubjectIRBReviewDate.setHumanSubjectIRBReviewIndicator(YesNoDataType.NO);
                        huSubjectsSupplement.setHumanSubjectIRBReviewDate(huSubjectIRBReviewDate);
                    }
                }
                if (organization != null && organization.getHumanSubAssurance() != null) {
                    huSubjectsSupplement
                            .setHumanSubjectAssuranceNumber(organization.getHumanSubAssurance().substring(3));
                }

                rrOtherProjectInfo.setHumanSubjectsSupplement(huSubjectsSupplement);
                break;

            case VERTEBRATE_ANIMALS_SUPPLEMENT:
                rrOtherProjectInfo.setVertebrateAnimalsIndicator(YesNoDataType.YES);
                VertebrateAnimalsSupplement vertebrateAnimalsSupplement = VertebrateAnimalsSupplement.Factory
                        .newInstance();
                VertebrateAnimalsSupplement.VertebrateAnimalsIACUCApprovalDateReviewDate veApprovalDateReviewDate = VertebrateAnimalsSupplement.VertebrateAnimalsIACUCApprovalDateReviewDate.Factory
                        .newInstance();

                if (SPECIAL_REVIEW_ANIMAL_USAGE.equals(proposalSpecialReview.getApprovalType().getCode())) {
                    vertebrateAnimalsSupplement.setVertebrateAnimalsIACUCReviewIndicator(YesNoDataType.YES);
                } else {
                    vertebrateAnimalsSupplement.setVertebrateAnimalsIACUCReviewIndicator(YesNoDataType.NO);
                    if (proposalSpecialReview.getApprovalDate() != null) {
                        veApprovalDateReviewDate.setCalendarValue(s2SDateTimeService
                                .convertDateToCalendar(proposalSpecialReview.getApprovalDate()));
                        veApprovalDateReviewDate.setVertebrateAnimalsIACUCReviewIndicator(YesNoDataType.NO);
                        vertebrateAnimalsSupplement
                                .setVertebrateAnimalsIACUCApprovalDateReviewDate(veApprovalDateReviewDate);
                    }
                }
                if (organization != null && organization.getHumanSubAssurance() != null) {
                    vertebrateAnimalsSupplement
                            .setAssuranceNumber(organization.getHumanSubAssurance().substring(3));
                }
                rrOtherProjectInfo.setVertebrateAnimalsSupplement(vertebrateAnimalsSupplement);
                break;
            default:
                break;
            }
        }
    }

    Enum answer = YesNoDataType.NO;
    String answerExplanation = "";
    /**
     * ProprietaryInformationIndicator is of YnQ type
     */
    EnvironmentalImpact environmentalImpact = EnvironmentalImpact.Factory.newInstance();
    InternationalActivities internationalActivities = InternationalActivities.Factory.newInstance();
    // Set default values for mandatory fields
    rrOtherProjectInfo.setProprietaryInformationIndicator(YesNoDataType.NO);
    environmentalImpact.setEnvironmentalImpactIndicator(YesNoDataType.NO);
    internationalActivities.setInternationalActivitiesIndicator(YesNoDataType.NO);
    String propertyInformationAnswer = getAnswer(PROPRIETARY_INFORMATION_INDICATOR, answerHeaders);
    if (propertyInformationAnswer != null && !propertyInformationAnswer.equals(NOT_ANSWERED)) {
        answer = YnqConstant.YES.code().equals(propertyInformationAnswer) ? YesNoDataType.YES
                : YesNoDataType.NO;
        rrOtherProjectInfo.setProprietaryInformationIndicator(answer);
    } else {
        rrOtherProjectInfo.setProprietaryInformationIndicator(null);
    }
    /**
     * EnvironmentalImpact is of YnQ type
     */
    String environmentalImpactAnswer = getAnswer(ENVIRONMENTAL_IMPACT_YNQ, answerHeaders);

    answer = YnqConstant.YES.code().equals(environmentalImpactAnswer) ? YesNoDataType.YES : YesNoDataType.NO;
    answerExplanation = getChildQuestionAnswer(ENVIRONMENTAL_IMPACT_YNQ, EXPLANATION, answerHeaders);
    if (environmentalImpactAnswer != null && !environmentalImpactAnswer.equals(NOT_ANSWERED)) {
        environmentalImpact.setEnvironmentalImpactIndicator(answer);
        if (YesNoDataType.YES.equals(answer) && answerExplanation != null) {
            EnvironmentalImpact.EnvironmentalImpactExplanation environmentalImpactExplanation = EnvironmentalImpact.EnvironmentalImpactExplanation.Factory
                    .newInstance();
            environmentalImpactExplanation.setStringValue(answerExplanation);
            environmentalImpactExplanation.setEnvironmentalImpactIndicator(answer);
            environmentalImpact.setEnvironmentalImpactExplanation(environmentalImpactExplanation);
        } else {
            environmentalImpact.setEnvironmentalImpactIndicator(YesNoDataType.NO);
        }
        if (YesNoDataType.YES.equals(answer) && answerExplanation == null) {
            environmentalImpact.setEnvironmentalImpactExplanation(null);
        }
    } else {
        environmentalImpact.setEnvironmentalImpactIndicator(null);
    }
    if (answer.equals(YesNoDataType.YES)) {
        answerExplanation = getChildQuestionAnswer(ENVIRONMENTAL_EXEMPTION_YNQ, EXPLANATION, answerHeaders);
        String ynqAnswer = getAnswer(ENVIRONMENTAL_EXEMPTION_YNQ, answerHeaders);
        String environmentalExemptionAnswer = getAnswer(ENVIRONMENTAL_IMPACT_YNQ, answerHeaders);
        if (YnqConstant.YES.code().equals(ynqAnswer)) {
            answer = YesNoDataType.YES;
        } else {
            answer = YesNoDataType.NO;
        }
        EnvironmentalImpact.EnvironmentalExemption environmentalExemption = EnvironmentalImpact.EnvironmentalExemption.Factory
                .newInstance();
        if (ynqAnswer != null && !ynqAnswer.equals(NOT_ANSWERED)) {
            if (!YnqConstant.NA.code().equals(ynqAnswer)) {
                // Answer not equal to X (not-applicable)

                environmentalExemption.setEnvironmentalExemptionIndicator(answer);
                if (answerExplanation != null) {
                    EnvironmentalImpact.EnvironmentalExemption.EnvironmentalExemptionExplanation environmentalExemptionExplanation = EnvironmentalImpact.EnvironmentalExemption.EnvironmentalExemptionExplanation.Factory
                            .newInstance();
                    environmentalExemptionExplanation.setEnvironmentalExemptionIndicator(answer);
                    environmentalExemptionExplanation.setStringValue(answerExplanation);
                    environmentalExemption
                            .setEnvironmentalExemptionExplanation(environmentalExemptionExplanation);
                }
                if (YnqConstant.YES.code().equals(ynqAnswer) && answerExplanation == null) {
                    environmentalExemption.setEnvironmentalExemptionExplanation(null);
                }
                environmentalImpact.setEnvironmentalExemption(environmentalExemption);
            }
        } else {
            environmentalExemption.setEnvironmentalExemptionIndicator(null);
        }
    }
    if (environmentalImpactAnswer == null || environmentalImpactAnswer.equals(NOT_ANSWERED)) {
        environmentalImpact = EnvironmentalImpact.Factory.newInstance();
    }
    rrOtherProjectInfo.setEnvironmentalImpact(environmentalImpact);
    /**
     * InternationalActivities is of YnQ type
     */
    String internationalActivitiesAnswer = getAnswer(INTERNATIONAL_ACTIVITIES_YNQ, answerHeaders);
    answer = YnqConstant.YES.code().equals(internationalActivitiesAnswer) ? YesNoDataType.YES
            : YesNoDataType.NO;
    answerExplanation = getAnswer(INTERNATIONAL_ACTIVITIES_EXPL, answerHeaders);
    if (internationalActivitiesAnswer != null && !internationalActivities.equals(NOT_ANSWERED)) {
        internationalActivities.setInternationalActivitiesIndicator(answer);
    } else {
        internationalActivities.setInternationalActivitiesIndicator(null);
    }
    if (answerExplanation != null && !answerExplanation.equals(NOT_ANSWERED)) {
        InternationalActivities.ActivitiesPartnershipsCountries activitiesPartnershipsCountries = InternationalActivities.ActivitiesPartnershipsCountries.Factory
                .newInstance();

        activitiesPartnershipsCountries.setInternationalActivitiesIndicator(answer);
        activitiesPartnershipsCountries.setStringValue(answerExplanation);
        internationalActivities.setActivitiesPartnershipsCountries(activitiesPartnershipsCountries);
        if (getChildQuestionAnswer(INTERNATIONAL_ACTIVITIES_YNQ, EXPLANATION, answerHeaders) != null) {
            internationalActivities.setInternationalActivitiesExplanation(
                    getChildQuestionAnswer(INTERNATIONAL_ACTIVITIES_YNQ, EXPLANATION, answerHeaders));
        }
    }
    if (YnqConstant.YES.code().equals(internationalActivitiesAnswer) && answerExplanation == null) {
        internationalActivities.setActivitiesPartnershipsCountries(null);
    }
    if (internationalActivitiesAnswer == null) {
        internationalActivities = InternationalActivities.Factory.newInstance();
    }
    rrOtherProjectInfo.setInternationalActivities(internationalActivities);
    /**
     * Attachments
     */
    AttachedFileDataType attachedFileDataType;
    ProjectNarrativeAttachments projectNarrativeAttachments = ProjectNarrativeAttachments.Factory.newInstance();
    AbstractAttachments abstractAttachments = AbstractAttachments.Factory.newInstance();
    for (NarrativeContract narrative : pdDoc.getDevelopmentProposal().getNarratives()) {
        if (narrative.getNarrativeType().getCode() != null) {
            if (Integer.parseInt(narrative.getNarrativeType().getCode()) == EQUIPMENT_ATTACHMENT) {
                // EQUIPMENT
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType == null) {
                    continue;
                }
                EquipmentAttachments equipmentAttachments = EquipmentAttachments.Factory.newInstance();
                equipmentAttachments.setEquipmentAttachment(attachedFileDataType);
                rrOtherProjectInfo.setEquipmentAttachments(equipmentAttachments);
            } else if (Integer.parseInt(narrative.getNarrativeType().getCode()) == FACILITIES_ATTACHMENT) {
                // facilities
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType == null) {
                    continue;
                }
                FacilitiesAttachments facilitiesAttachments = FacilitiesAttachments.Factory.newInstance();
                facilitiesAttachments.setFacilitiesAttachment(attachedFileDataType);
                rrOtherProjectInfo.setFacilitiesAttachments(facilitiesAttachments);
            } else if (Integer.parseInt(narrative.getNarrativeType().getCode()) == NARRATIVE_ATTACHMENT) {
                // NARRATIVE
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType != null) {
                    projectNarrativeAttachments.setProjectNarrativeAttachment(attachedFileDataType);
                }
            } else if (Integer.parseInt(narrative.getNarrativeType().getCode()) == BIBLIOGRAPHY_ATTACHMENT) {
                // BIBLIOGRAPHY
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType == null) {
                    continue;
                }
                BibliographyAttachments bibliographyAttachments = BibliographyAttachments.Factory.newInstance();
                bibliographyAttachments.setBibliographyAttachment(attachedFileDataType);
                rrOtherProjectInfo.setBibliographyAttachments(bibliographyAttachments);
            } else if (Integer
                    .parseInt(narrative.getNarrativeType().getCode()) == ABSTRACT_PROJECT_SUMMARY_ATTACHMENT) {
                // ABSTRACT - PROJECT SUMMARY
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType != null) {
                    abstractAttachments.setAbstractAttachment(attachedFileDataType);
                }
            }
        }
    }
    rrOtherProjectInfo.setProjectNarrativeAttachments(projectNarrativeAttachments);
    rrOtherProjectInfo.setAbstractAttachments(abstractAttachments);

    OtherAttachments otherAttachments = OtherAttachments.Factory.newInstance();
    otherAttachments.setOtherAttachmentArray(getAttachedFileDataTypes());
    rrOtherProjectInfo.setOtherAttachments(otherAttachments);

    rrOtherProjectInfoDocument.setRROtherProjectInfo(rrOtherProjectInfo);
    return rrOtherProjectInfoDocument;
}

From source file:org.kuali.kra.s2s.generator.impl.RRSF424V1_0Generator.java

/**
 *
 * This method is used to get ApplicationType for the form RRSF424
 *
 * @return ApplicationType corresponding to the proposal type code.
 *///from   ww  w .j av a2  s.co  m
private ApplicationType getApplicationType() {
    ApplicationType applicationType = ApplicationType.Factory.newInstance();

    if (pdDoc.getDevelopmentProposal().getProposalTypeCode() != null
            && Integer.parseInt(pdDoc.getDevelopmentProposal().getProposalTypeCode()) < PROPOSAL_TYPE_CODE_6) {
        // Check <6 to ensure that if proposalType='TASk ORDER", it must not
        // set. THis is because enum ApplicationType has no
        // entry for TASK ORDER
        ApplicationTypeCodeDataType.Enum applicationTypeCodeDataType = ApplicationTypeCodeDataType.Enum
                .forInt(Integer.parseInt(pdDoc.getDevelopmentProposal().getProposalTypeCode()));
        applicationType.setApplicationTypeCode(applicationTypeCodeDataType);

        Map<String, String> submissionInfo = s2sUtilService.getSubmissionType(pdDoc);
        if (Integer.parseInt(pdDoc.getDevelopmentProposal()
                .getProposalTypeCode()) == ApplicationTypeCodeDataType.INT_REVISION) {
            String revisionCode = null;
            if (submissionInfo.get(S2SConstants.KEY_REVISION_CODE) != null) {
                revisionCode = submissionInfo.get(S2SConstants.KEY_REVISION_CODE);
                RevisionCode revisionCodeApplication = RevisionCode.Factory.newInstance();
                revisionCodeApplication.setStringValue(revisionCode);
                applicationType.setRevisionCode(revisionCodeApplication);
            }
            String revisionCodeOtherDesc = null;
            if (submissionInfo.get(S2SConstants.KEY_REVISION_OTHER_DESCRIPTION) != null) {
                revisionCodeOtherDesc = submissionInfo.get(S2SConstants.KEY_REVISION_OTHER_DESCRIPTION);
                RevisionCodeOtherExplanation revisionCodeOtherExplanation = RevisionCodeOtherExplanation.Factory
                        .newInstance();
                revisionCodeOtherExplanation.setStringValue(revisionCodeOtherDesc);
                applicationType.setRevisionCodeOtherExplanation(revisionCodeOtherExplanation);
            }
        }
    }
    ProposalYnq proposalYnq = getAnswer(PROPOSAL_YNQ_OTHER_AGENCY_SUBMISSION, pdDoc);
    Enum answer = YesNoDataType.NO;
    if (proposalYnq != null && proposalYnq.getAnswer() != null) {
        answer = (proposalYnq.getAnswer().equals(S2SConstants.PROPOSAL_YNQ_ANSWER_Y) ? YesNoDataType.YES
                : YesNoDataType.NO);
    }

    applicationType.setIsOtherAgencySubmission(answer);
    if (answer.equals(YesNoDataType.YES)) {
        OtherAgencySubmissionExplanation otherAgencySubmissionExplanation = OtherAgencySubmissionExplanation.Factory
                .newInstance();
        otherAgencySubmissionExplanation.setIsOtherAgencySubmission(answer);
        String answerExplanation = proposalYnq.getExplanation();
        if (answerExplanation != null) {
            if (answerExplanation.length() > ANSWER_EXPLANATION_MAX_LENGTH) {
                otherAgencySubmissionExplanation
                        .setStringValue(answerExplanation.substring(0, ANSWER_EXPLANATION_MAX_LENGTH));
            } else {
                otherAgencySubmissionExplanation.setStringValue(answerExplanation);
            }
        }
        applicationType.setOtherAgencySubmissionExplanation(otherAgencySubmissionExplanation);
    }
    return applicationType;
}