Search in sources :

Example 1 with InquirySectionDefinition

use of org.kuali.kfs.kns.datadictionary.InquirySectionDefinition in project cu-kfs by CU-CommunityApps.

the class PersonInquirableImpl method getSections.

/**
 * Add Role Qualifier Attributes to Roles section of Person Inquiry.
 */
@Override
public List<Section> getSections(BusinessObject businessObject) {
    List<Section> sections = new ArrayList<>();
    if (getBusinessObjectClass() == null) {
        LOG.error("Business object class not set in inquirable.");
        throw new RuntimeException("Business object class not set in inquirable.");
    }
    InquiryRestrictions inquiryRestrictions = KNSServiceLocator.getBusinessObjectAuthorizationService().getInquiryRestrictions(businessObject, GlobalVariables.getUserSession().getPerson());
    Collection<InquirySectionDefinition> inquirySections = getBusinessObjectDictionaryService().getInquirySections(getBusinessObjectClass());
    for (InquirySectionDefinition inquirySection : inquirySections) {
        String sectionId = inquirySection.getId();
        if (!inquiryRestrictions.isHiddenSectionId(sectionId)) {
            Section section = SectionBridge.toSection(this, inquirySection, businessObject, inquiryRestrictions);
            if (StringUtils.equals(sectionId, "rolesSection") || StringUtils.equals(sectionId, "delegationsSection")) {
                int memberIndex = 0;
                for (Row containerRow : section.getRows()) {
                    List<Row> containerRows = containerRow.getFields().get(0).getContainerRows();
                    Row lastRow = containerRows.get(containerRows.size() - 1);
                    // we want the new fields added before any sub-sections (i.e. container fields)
                    if (Field.CONTAINER.equals(lastRow.getField(0).getFieldType())) {
                        containerRows.addAll(containerRows.size() - 1, buildRowsWithQualifierFields(sectionId, (PersonImpl) businessObject, memberIndex));
                    } else {
                        containerRows.addAll(buildRowsWithQualifierFields(sectionId, (PersonImpl) businessObject, memberIndex));
                    }
                    memberIndex++;
                }
            }
            sections.add(section);
        }
    }
    return sections;
}
Also used : InquirySectionDefinition(org.kuali.kfs.kns.datadictionary.InquirySectionDefinition) PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) ArrayList(java.util.ArrayList) InquiryRestrictions(org.kuali.kfs.kns.inquiry.InquiryRestrictions) Row(org.kuali.kfs.kns.web.ui.Row) Section(org.kuali.kfs.kns.web.ui.Section)

Aggregations

ArrayList (java.util.ArrayList)1 PersonImpl (org.kuali.kfs.kim.impl.identity.PersonImpl)1 InquirySectionDefinition (org.kuali.kfs.kns.datadictionary.InquirySectionDefinition)1 InquiryRestrictions (org.kuali.kfs.kns.inquiry.InquiryRestrictions)1 Row (org.kuali.kfs.kns.web.ui.Row)1 Section (org.kuali.kfs.kns.web.ui.Section)1