Example usage for org.apache.commons.collections MapUtils getString

List of usage examples for org.apache.commons.collections MapUtils getString

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getString.

Prototype

public static String getString(final Map map, final Object key) 

Source Link

Document

Gets a String from a Map in a null-safe manner.

Usage

From source file:org.kuali.kpme.core.location.service.LocationRoleTypeServiceImpl.java

@Override
public boolean performMatch(Map<String, String> inputAttributes, Map<String, String> storedAttributes) {
    boolean matches = false;

    String inputLocation = MapUtils.getString(inputAttributes,
            KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName());
    String storedLocation = MapUtils.getString(storedAttributes,
            KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName());

    if (storedLocation != null) {
        matches = ObjectUtils.equals(inputLocation, storedLocation) || ObjectUtils.equals(inputLocation, "%");
    }// w w w  .j a  v a2  s  . c  o m

    return matches;
}

From source file:org.kuali.kpme.core.permission.service.DocumentTypeAndMaintenanceActionServiceImpl.java

@Override
protected boolean performMatch(Map<String, String> inputMap, Map<String, String> storedMap) {
    String requestedDocumentType = MapUtils.getString(inputMap,
            KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME);
    String permissionDocumentType = MapUtils.getString(storedMap,
            KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME);

    if (requestedDocumentType == null || permissionDocumentType == null) {
        return false;
    }//from w w  w .  j  a va 2 s .c  o m

    if (!requestedDocumentType.equals(permissionDocumentType)) {
        return false;
    }

    String existingRecordsOnly = MapUtils.getString(storedMap,
            KimConstants.AttributeConstants.EXISTING_RECORDS_ONLY);

    if (existingRecordsOnly == null) {
        return true;
    }

    if (!Boolean.parseBoolean(existingRecordsOnly)) {
        return StringUtils.equals(inputMap.get(KRADConstants.MAINTENANCE_ACTN),
                KRADConstants.MAINTENANCE_NEW_ACTION);
    } else {
        return StringUtils.equals(inputMap.get(KRADConstants.MAINTENANCE_ACTN),
                KRADConstants.MAINTENANCE_EDIT_ACTION);
    }
}

From source file:org.kuali.kpme.core.role.PositionRoleMemberBo.java

public String getPositionNumber() {
    String positionNumber = MapUtils.getString(getAttributes(),
            KPMERoleMemberAttribute.POSITION.getRoleMemberAttributeName());

    return StringUtils.defaultString(positionNumber);
}

From source file:org.kuali.kpme.core.role.proxy.service.WorkAreaProxyDerivedRoleTypeServiceImpl.java

@Override
public boolean performMatch(Map<String, String> inputAttributes, Map<String, String> storedAttributes) {
    boolean matches = false;

    Long inputWorkArea;//  w w w  . j a v  a 2  s . co  m
    if (StringUtils.equals(
            MapUtils.getString(inputAttributes, KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName()),
            "%")) {
        inputWorkArea = HrConstants.WILDCARD_LONG;
    } else {
        inputWorkArea = MapUtils.getLong(inputAttributes,
                KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName());
    }
    Long storedWorkArea = MapUtils.getLong(storedAttributes,
            KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName());

    if (storedWorkArea != null) {
        matches = ObjectUtils.equals(inputWorkArea, storedWorkArea)
                || ObjectUtils.equals(inputWorkArea, HrConstants.WILDCARD_LONG);
    }

    return matches;
}

From source file:org.kuali.kpme.core.service.role.KPMERoleServiceImpl.java

public List<String> getDepartmentsForPrincipalInRoles(String principalId, List<String> roleIds,
        DateTime asOfDate, boolean isActiveOnly) {
    Set<String> departments = new HashSet<String>();

    Map<String, String> qualifiers = new HashMap<String, String>();
    qualifiers.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), "%");
    List<Map<String, String>> roleQualifiers = getRoleQualifiers(principalId, roleIds, qualifiers, asOfDate,
            isActiveOnly);/*from  www  .  ja  v a 2 s  . c  o m*/

    for (Map<String, String> roleQualifier : roleQualifiers) {
        String department = MapUtils.getString(roleQualifier,
                KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName());
        String groupKeyCode = MapUtils.getString(roleQualifier,
                KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName());
        if (department != null && groupKeyCode != null) {
            departments.add(groupKeyCode + "|" + department);
        }
    }

    List<String> locations = getLocationsForPrincipalInRoles(principalId, roleIds, asOfDate, isActiveOnly);
    departments
            .addAll(getDepartmentService().getDepartmentValuesWithLocations(locations, asOfDate.toLocalDate()));

    return new ArrayList<String>(departments);
}

From source file:org.kuali.kpme.core.service.role.KPMERoleServiceImpl.java

public List<String> getLocationsForPrincipalInRoles(String principalId, List<String> roleIds, DateTime asOfDate,
        boolean isActiveOnly) {
    Set<String> locations = new HashSet<String>();

    Map<String, String> qualifiers = new HashMap<String, String>();
    qualifiers.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), "%");
    List<Map<String, String>> roleQualifiers = getRoleQualifiers(principalId, roleIds, qualifiers, asOfDate,
            isActiveOnly);//from ww w  . j  a v  a 2s  . c  o  m

    for (Map<String, String> roleQualifier : roleQualifiers) {
        String location = MapUtils.getString(roleQualifier,
                KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName());

        if (location != null) {
            locations.add(location);
        }
    }

    return new ArrayList<String>(locations);
}

From source file:org.kuali.kpme.tklm.time.approval.web.TimeApprovalWSAction.java

public ActionForward getTimeSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    TimeApprovalActionForm taaf = (TimeApprovalActionForm) form;
    TimesheetDocument td = TkServiceLocator.getTimesheetService().getTimesheetDocument(taaf.getDocumentId());
    TimeSummary ts = td.getTimeSummary();
    //TimeSummary ts = (TimeSummary)TkServiceLocator.getTimeSummaryService().getTimeSummaryForDocument(taaf.getDocumentId());

    List<Assignment> assignments = td.getAllAssignments();
    List<String> assignmentKeys = new ArrayList<String>();
    for (Assignment assignment : assignments) {
        assignmentKeys.add(assignment.getAssignmentKey());
    }//from   ww w .  j  a  va  2 s  .c o  m
    List<TimeBlock> timeBlocks = td.getTimeBlocks();
    List<LeaveBlock> leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForTimeCalendar(
            td.getPrincipalId(), td.getAsOfDate(), td.getDocEndDate(), assignmentKeys);
    Map<String, String> aMap = ActionFormUtils.buildAssignmentStyleClassMap(timeBlocks, leaveBlocks);
    // set css classes for each assignment row
    for (EarnGroupSection earnGroupSection : ts.getSections()) {
        for (EarnCodeSection section : earnGroupSection.getEarnCodeSections()) {
            for (AssignmentRow assignRow : section.getAssignmentsRows()) {
                String assignmentCssStyle = MapUtils.getString(aMap, assignRow.getAssignmentKey());
                assignRow.setCssClass(assignmentCssStyle);
                for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns().values()) {
                    assignmentColumn.setCssClass(assignmentCssStyle);
                }
            }
        }
    }

    //reverse sections for javascripts $parent.after (always inserting directly after parent element, which reverses order)

    ts.setSections(Lists.reverse(ts.getSections()));
    taaf.setOutputString(ts.toJsonString());
    return mapping.findForward("ws");
}

From source file:org.kuali.kpme.tklm.time.detail.web.TimeDetailAction.java

private void assignStyleClassMapForTimeSummary(TimeDetailActionForm tdaf,
        List<? extends TimeBlockContract> timeBlocks, List<? extends LeaveBlockContract> leaveBlocks)
        throws Exception {
    TimesheetDocument td = tdaf.getTimesheetDocument();
    TimeSummary ts = (TimeSummary) TkServiceLocator.getTimeSummaryService().getTimeSummary(td.getPrincipalId(),
            td.getTimeBlocks(), td.getCalendarEntry(), td.getAssignmentMap());

    tdaf.setAssignStyleClassMap(ActionFormUtils.buildAssignmentStyleClassMap(timeBlocks, leaveBlocks));
    Map<String, String> aMap = tdaf.getAssignStyleClassMap();
    // set css classes for each assignment row
    for (EarnGroupSection earnGroupSection : ts.getSections()) {
        for (EarnCodeSection section : earnGroupSection.getEarnCodeSections()) {
            for (AssignmentRow assignRow : section.getAssignmentsRows()) {
                String assignmentCssStyle = MapUtils.getString(aMap, assignRow.getAssignmentKey());
                assignRow.setCssClass(assignmentCssStyle);
                for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns().values()) {
                    assignmentColumn.setCssClass(assignmentCssStyle);
                }/*from www  .  ja  v a2  s  .  c o m*/
            }
        }

    }
    tdaf.setTimeSummary(ts);
    //ActionFormUtils.validateHourLimit(tdaf);
    ActionFormUtils.addWarningTextFromEarnGroup(tdaf);
    ActionFormUtils.addUnapprovedIPWarningFromClockLog(tdaf);
}

From source file:org.kuali.kpme.tklm.time.timesummary.service.TimeSummaryServiceImpl.java

@Override
public TimeSummary getTimeSummary(String principalId, List<TimeBlock> timeBlocks, CalendarEntry calendarEntry,
        Map<LocalDate, List<Assignment>> assignments) {
    TimeSummary timeSummary = new TimeSummary();

    //if(principalId == null || CollectionUtils.isEmpty(timeBlocks)) { KPME-3340
    if (principalId == null || timeBlocks == null) {
        return timeSummary;
    }/* w  ww.  ja  va2 s  .  co  m*/

    List<Boolean> dayArrangements = new ArrayList<Boolean>();

    timeSummary.setTimeSummaryHeader(getHeaderForSummary(calendarEntry, timeSummary));

    String userTZ = HrServiceLocator.getTimezoneService().getUserTimezone(principalId);
    DateTimeZone userTimeZone = DateTimeZone.forID(userTZ);
    TkTimeBlockAggregate tkTimeBlockAggregate = new TkTimeBlockAggregate(timeBlocks, calendarEntry,
            HrServiceLocator.getCalendarService().getCalendar(calendarEntry.getHrCalendarId()), true,
            userTimeZone);

    if (userTimeZone == null) {
        userTimeZone = HrServiceLocator.getTimezoneService().getTargetUserTimezoneWithFallback();
    }

    List<String> tAssignmentKeys = new ArrayList<String>();
    Set<Assignment> allAssignments = new HashSet<Assignment>();
    for (List<Assignment> assignmentList : assignments.values()) {
        allAssignments.addAll(assignmentList);
    }
    Set<String> regularEarnCodes = new HashSet<String>();
    for (Assignment assign : allAssignments) {
        tAssignmentKeys.add(assign.getAssignmentKey());
        regularEarnCodes.add(assign.getJob().getPayTypeObj().getRegEarnCode());
    }
    List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();
    leaveBlocks.addAll(LmServiceLocator.getLeaveBlockService().getLeaveBlocksForTimeCalendar(principalId,
            calendarEntry.getBeginPeriodFullDateTime().toLocalDate(),
            calendarEntry.getEndPeriodFullDateTime().toLocalDate(), tAssignmentKeys));
    LeaveBlockAggregate leaveBlockAggregate = new LeaveBlockAggregate(leaveBlocks, calendarEntry);
    tkTimeBlockAggregate = TkTimeBlockAggregate.combineTimeAndLeaveAggregates(tkTimeBlockAggregate,
            leaveBlockAggregate);

    timeSummary.setWorkedHours(
            getWorkedHours(principalId, tkTimeBlockAggregate, regularEarnCodes, timeSummary, userTimeZone));

    // Set Flsa week total map
    Map<String, BigDecimal> flsaWeekTotal = getHoursToFlsaWeekMap(tkTimeBlockAggregate, principalId, null,
            regularEarnCodes, userTimeZone);
    timeSummary.setFlsaWeekTotalMap(flsaWeekTotal);

    Map<String, List<EarnGroupSection>> earnGroupSections = getEarnGroupSections(principalId,
            tkTimeBlockAggregate, timeSummary.getTimeSummaryHeader().size() + 1, dayArrangements,
            calendarEntry.getEndPeriodFullDateTime().toLocalDate(),
            calendarEntry.getEndPeriodFullDateTime().toLocalDate());
    timeSummary.setWeeklySections(earnGroupSections);

    for (String key : timeSummary.getWeeklySections().keySet()) {
        timeSummary.getWeeklySections().put(key,
                sortEarnGroupSections(timeSummary.getWeeklySections().get(key), regularEarnCodes));
    }

    //        timeSummary.setSections(sortEarnGroupSections(earnGroupSections, regularEarnCodes));

    Map<String, String> aMap = ActionFormUtils.buildAssignmentStyleClassMap(timeBlocks, leaveBlocks);
    // set css classes for each assignment row
    for (String week : timeSummary.getWeeklySections().keySet()) {
        for (EarnGroupSection earnGroupSection : timeSummary.getWeeklySections().get(week)) {
            for (EarnCodeSection section : earnGroupSection.getEarnCodeSections()) {
                for (AssignmentRow assignRow : section.getAssignmentsRows()) {
                    String assignmentCssStyle = MapUtils.getString(aMap, assignRow.getAssignmentKey());
                    assignRow.setCssClass(assignmentCssStyle);
                    for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns().values()) {
                        assignmentColumn.setCssClass(assignmentCssStyle);
                    }
                }
            }
        }
    }
    try {
        List<LeaveSummaryRow> maxedLeaveRows = getMaxedLeaveRows(calendarEntry, principalId);
        timeSummary.setMaxedLeaveRows(maxedLeaveRows);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        LOG.error("error retreiving maxed leave rows", e);
    }

    return timeSummary;
}

From source file:org.kuali.rice.krad.demo.uif.lookup.UIRoleMemberLookupableImpl.java

@Override
public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
    // removed blank search values and decrypt any encrypted search values
    Map<String, String> nonBlankSearchCriteria = processSearchCriteria(form, searchCriteria);
    List<String> wildcardAsLiteralSearchCriteria = identifyWildcardDisabledFields(form, nonBlankSearchCriteria);

    Integer searchResultsLimit = null;

    if (bounded) {
        searchResultsLimit = LookupUtils.getSearchResultsLimit(getDataObjectClass(), form);
    }/*  ww w . j  a  v  a 2 s  . co m*/

    Class<?> dataObjectClass = null;

    if ("P".equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
        dataObjectClass = PrincipalBo.class;
    } else if ("G"
            .equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
        dataObjectClass = GroupBo.class;
    } else if ("R"
            .equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
        dataObjectClass = RoleBo.class;
    }

    return getLookupService().findCollectionBySearchHelper(dataObjectClass, nonBlankSearchCriteria,
            wildcardAsLiteralSearchCriteria, !bounded, searchResultsLimit);
}