Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

In this page you can find the example usage for java.util SortedMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.kuali.kfs.module.cam.batch.service.impl.AssetDepreciationServiceImpl.java

protected void populateYearEndDepreciationTransaction(AssetPaymentInfo assetPayment, String transactionType,
        String plantCOA, String plantAccount, ObjectCode deprObjectCode,
        SortedMap<String, AssetDepreciationTransaction> depreciationTransactionSummary) {
    LOG.info("\npopulateYearEndDepreciationTransaction - Asset#:" + assetPayment.getCapitalAssetNumber()
            + " amount:" + assetPayment.getTransactionAmount() + " type:" + transactionType);
    LOG.info("deprObjectCode.getFinancialObjectCode():" + deprObjectCode.getFinancialObjectCode()
            + " deprObjectCode.getFinancialObjectTypeCode():" + deprObjectCode.getFinancialObjectTypeCode());
    AssetDepreciationTransaction depreciationTransaction = new AssetDepreciationTransaction();
    depreciationTransaction.setCapitalAssetNumber(assetPayment.getCapitalAssetNumber());
    depreciationTransaction.setChartOfAccountsCode(plantCOA);
    depreciationTransaction.setAccountNumber(plantAccount);
    depreciationTransaction.setSubAccountNumber(assetPayment.getSubAccountNumber());
    depreciationTransaction.setFinancialObjectCode(deprObjectCode.getFinancialObjectCode());
    depreciationTransaction.setFinancialSubObjectCode(assetPayment.getFinancialSubObjectCode());
    depreciationTransaction.setFinancialObjectTypeCode(deprObjectCode.getFinancialObjectTypeCode());
    depreciationTransaction.setTransactionType(transactionType);
    depreciationTransaction.setProjectCode(assetPayment.getProjectCode());
    depreciationTransaction.setTransactionAmount(assetPayment.getTransactionAmount());
    depreciationTransaction.setTransactionLedgerEntryDescription(
            "Year End Depreciation Asset " + assetPayment.getCapitalAssetNumber());

    String sKey = depreciationTransaction.getKey();

    // Grouping the asset transactions by asset#, accounts, sub account, object, transaction type (C/D), etc. in order to
    // only have one credit and one credit by group.
    if (depreciationTransactionSummary.containsKey(sKey)) {
        LOG.info("depreciationTransactionSummary.containsKey(sKey) where sKey=" + sKey);
        depreciationTransaction = depreciationTransactionSummary.get(sKey);
        depreciationTransaction.setTransactionAmount(
                depreciationTransaction.getTransactionAmount().add(assetPayment.getTransactionAmount()));
    } else {//from  ww w  . j  a va2 s . c  o  m
        LOG.info("depreciationTransactionSummary DOESNT containsKey(sKey) where sKey=" + sKey);
        depreciationTransactionSummary.put(sKey, depreciationTransaction);
    }
    LOG.info("\n\n");
    //  LOG.info("populateYearEndDepreciationTransaction(AssetDepreciationTransaction depreciationTransaction, AssetPayment assetPayment, String transactionType, KualiDecimal transactionAmount, String plantCOA, String plantAccount, String accumulatedDepreciationFinancialObjectCode, String depreciationExpenseFinancialObjectCode, ObjectCode financialObject, SortedMap<String, AssetDepreciationTransaction> depreciationTransactionSummary) -  ended");
}

From source file:org.opencms.setup.CmsSetupBean.java

/** 
 * Returns a sorted list with they keys (e.g. "mysql", "generic" or "oracle") of all available
 * database server setups found in "/setup/database/" sorted by their ranking property.<p>
 *
 * @return a sorted list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups
 *//* w ww . j a v a2s  . co  m*/
public List<String> getSortedDatabases() {

    if (m_sortedDatabaseKeys == null) {
        List<String> databases = m_databaseKeys;
        List<String> sortedDatabases = new ArrayList<String>(databases.size());
        SortedMap<Integer, String> mappedDatabases = new TreeMap<Integer, String>();
        for (int i = 0; i < databases.size(); i++) {
            String key = databases.get(i);
            Integer ranking = new Integer(0);
            try {
                ranking = Integer.valueOf(getDbProperty(key + ".ranking"));
            } catch (Exception e) {
                // ignore
            }
            mappedDatabases.put(ranking, key);
        }

        while (mappedDatabases.size() > 0) {
            // get database with highest ranking 
            Integer key = mappedDatabases.lastKey();
            String database = mappedDatabases.get(key);
            sortedDatabases.add(database);
            mappedDatabases.remove(key);
        }
        m_sortedDatabaseKeys = sortedDatabases;
    }
    return m_sortedDatabaseKeys;
}

From source file:org.linuxstuff.mojo.licensing.DefaultDependenciesTool.java

/**
 * {@inheritDoc}/*  www  .  j a  va 2  s .  c  o m*/
 */
@Override
public SortedMap<String, MavenProject> loadProjectDependencies(MavenProject project,
        MavenProjectDependenciesConfigurator configuration, ArtifactRepository localRepository,
        List<ArtifactRepository> remoteRepositories, SortedMap<String, MavenProject> cache) {

    boolean haveNoIncludedGroups = StringUtils.isEmpty(configuration.getIncludedGroups());
    boolean haveNoIncludedArtifacts = StringUtils.isEmpty(configuration.getIncludedArtifacts());

    boolean haveExcludedGroups = StringUtils.isNotEmpty(configuration.getExcludedGroups());
    boolean haveExcludedArtifacts = StringUtils.isNotEmpty(configuration.getExcludedArtifacts());
    boolean haveExclusions = haveExcludedGroups || haveExcludedArtifacts;

    Pattern includedGroupPattern = null;
    Pattern includedArtifactPattern = null;
    Pattern excludedGroupPattern = null;
    Pattern excludedArtifactPattern = null;

    if (!haveNoIncludedGroups) {
        includedGroupPattern = Pattern.compile(configuration.getIncludedGroups());
    }
    if (!haveNoIncludedArtifacts) {
        includedArtifactPattern = Pattern.compile(configuration.getIncludedArtifacts());
    }
    if (haveExcludedGroups) {
        excludedGroupPattern = Pattern.compile(configuration.getExcludedGroups());
    }
    if (haveExcludedArtifacts) {
        excludedArtifactPattern = Pattern.compile(configuration.getExcludedArtifacts());
    }

    Set<?> depArtifacts;

    if (configuration.isIncludeTransitiveDependencies()) {
        // All project dependencies
        depArtifacts = project.getArtifacts();
    } else {
        // Only direct project dependencies
        depArtifacts = project.getDependencyArtifacts();
    }

    List<String> includedScopes = configuration.getIncludedScopes();
    List<String> excludeScopes = configuration.getExcludedScopes();

    SortedMap<String, MavenProject> result = new TreeMap<String, MavenProject>();

    for (Object o : depArtifacts) {
        Artifact artifact = (Artifact) o;

        String scope = artifact.getScope();
        if (!includedScopes.isEmpty() && !includedScopes.contains(scope)) {

            // not in included scopes
            continue;
        }
        {
            if (excludeScopes.contains(scope)) {

                // in excluded scopes
                continue;
            }
        }

        Logger log = getLogger();

        String id = artifact.getId();

        log.debug("detected artifact " + id);

        // Check if the project should be included
        // If there is no specified artifacts and group to include, include
        // all
        boolean isToInclude = haveNoIncludedArtifacts && haveNoIncludedGroups
                || isIncludable(artifact, includedGroupPattern, includedArtifactPattern);

        // Check if the project should be excluded
        boolean isToExclude = isToInclude && haveExclusions
                && isExcludable(artifact, excludedGroupPattern, excludedArtifactPattern);

        if (!isToInclude || isToExclude) {
            log.debug("skip artifact " + id);
            continue;
        }

        MavenProject depMavenProject = null;

        if (cache != null) {

            // try to get project from cache
            depMavenProject = cache.get(id);
        }

        if (depMavenProject != null) {
            log.debug("add dependency [" + id + "] (from cache)");
        } else {

            // build project

            try {
                depMavenProject = mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories,
                        localRepository, true);
            } catch (ProjectBuildingException e) {
                log.warn("Unable to obtain POM for artifact : " + artifact, e);
                continue;
            }

            log.debug("add dependency [" + id + "]");
            if (cache != null) {

                // store it also in cache
                cache.put(id, depMavenProject);
            }
        }

        // keep the project
        result.put(id, depMavenProject);
    }

    return result;
}

From source file:org.slc.sli.dashboard.manager.impl.StudentProgressManagerImpl.java

@Override
@SuppressWarnings("unchecked")
@LogExecutionTime/*w  ww.  j  a v  a2s . c om*/
public GenericEntity getTranscript(String token, Object studentIdObj, Config.Data config) {

    SortedMap<GenericEntity, List<GenericEntity>> transcripts = new TreeMap<GenericEntity, List<GenericEntity>>(
            new SessionComparator());

    String studentId = studentIdObj.toString();
    List<String> optionalFields = new LinkedList<String>();
    optionalFields.add(Constants.ATTR_TRANSCRIPT);

    GenericEntity studentWithTranscript = entityManager.getStudentWithOptionalFields(token, studentId,
            optionalFields);
    if (studentWithTranscript == null) {
        return new GenericEntity();
    }

    Map<String, Object> studentTranscript = (Map<String, Object>) studentWithTranscript
            .get(Constants.ATTR_TRANSCRIPT);
    if (studentTranscript == null) {
        return new GenericEntity();
    }

    List<Map<String, Object>> courseTranscripts = (List<Map<String, Object>>) studentTranscript
            .get(Constants.ATTR_COURSE_TRANSCRIPTS);
    List<Map<String, Object>> studentSectionAssociations = (List<Map<String, Object>>) studentTranscript
            .get(Constants.ATTR_STUDENT_SECTION_ASSOC);

    if (studentSectionAssociations == null || courseTranscripts == null) {
        return new GenericEntity();
    }

    Map<String, GenericEntity> cache = new HashMap<String, GenericEntity>();
    cacheStudent(studentId, token, studentSectionAssociations, cache, courseTranscripts);

    for (Map<String, Object> studentSectionAssociation : studentSectionAssociations) {
        Map<String, Object> courseTranscript = getCourseTranscriptForSection(studentSectionAssociation,
                courseTranscripts);

        // skip this course if we can't find previous info
        if (courseTranscript == null) {
            continue;
        }

        Map<String, Object> section = getGenericEntity(studentSectionAssociation, Constants.ATTR_SECTIONS);
        Map<String, Object> course = getGenericEntity(section, Constants.ATTR_COURSES);
        Map<String, Object> session = getGenericEntity(section, Constants.ATTR_SESSIONS);

        GenericEntity term = new GenericEntity();

        term.put(Constants.ATTR_TERM, getValue(session, Constants.ATTR_TERM));
        term.put(Constants.ATTR_GRADE_LEVEL, getValue(courseTranscript, Constants.ATTR_GRADE_LEVEL_WHEN_TAKEN));
        term.put(Constants.ATTR_SCHOOL, getSchoolName(section, token, cache));
        term.put(Constants.ATTR_SCHOOL_YEAR, getValue(session, Constants.ATTR_SCHOOL_YEAR));
        term.put(Constants.ATTR_CUMULATIVE_GPA, getGPA(session, studentId, token, cache));
        term.put(Constants.ATTR_SESSION_BEGIN_DATE, getValue(session, Constants.ATTR_SESSION_BEGIN_DATE));

        GenericEntityEnhancer.convertGradeLevel(term, Constants.ATTR_GRADE_LEVEL);

        // This isn't a new term
        if (transcripts.containsKey(term)) {
            List<GenericEntity> courses = transcripts.get(term);
            GenericEntity courseData = getCourseData(courseTranscript, course);
            courses.add(courseData);
        } else { // this is the first time the term has been encountered
            List<GenericEntity> courses = new ArrayList<GenericEntity>();
            GenericEntity courseData = getCourseData(courseTranscript, course);
            courses.add(courseData);
            transcripts.put(term, courses);
        }
    }

    List<GenericEntity> transcriptData = new ArrayList<GenericEntity>();

    for (Map.Entry<GenericEntity, List<GenericEntity>> entry : transcripts.entrySet()) {
        GenericEntity term = new GenericEntity();
        term.putAll(entry.getKey());
        term.put(Constants.ATTR_COURSES, entry.getValue());
        transcriptData.add(term);
    }

    GenericEntity ret = new GenericEntity();
    ret.put(TRANSCRIPT_HISTORY, transcriptData);
    return ret;
}

From source file:com.aurel.track.report.dashboard.BurnDownChart.java

public SortedMap<Integer, SortedMap<Integer, Double>> calculateEarnedValuesDependingOnEffortType(
        SortedMap<Integer, SortedMap<Integer, Double>> yearToIntervalToPlannedValue, Integer timeInterval,
        Set<Integer> finalStates, Integer selectedEffortType) {

    SortedMap<Integer, SortedMap<Integer, Double>> yearToIntervalToEarnedValue = new TreeMap<Integer, SortedMap<Integer, Double>>();

    if (reportBeanWithHistoryList != null) {
        Calendar calendarStartDate = Calendar.getInstance();
        Calendar calendarEndDate = Calendar.getInstance();
        Calendar calendar = Calendar.getInstance();
        //to avoid that the last days of the year to be taken as the first
        //week of the now year but the year remains the old one
        int calendarInterval = EarnedValueDatasource.getCalendarInterval(timeInterval);
        for (ReportBeanWithHistory reportBeanWithHistory : reportBeanWithHistoryList) {
            TWorkItemBean workItemBean = reportBeanWithHistory.getWorkItemBean();
            Date startDate = workItemBean.getStartDate();
            Date endDate = workItemBean.getEndDate();
            if (startDate == null || endDate == null) {
                continue;
            }//from   w  w  w . j a va 2s  .  c om
            calendarStartDate.setTime(dateFrom);
            calendarEndDate.setTime(dateTo);

            Map<Integer, Map<Integer, HistoryValues>> historyMap = reportBeanWithHistory.getHistoryValuesMap();
            List<HistoryValues> historyValuesList = HistoryLoaderBL.getHistoryValuesList(historyMap, false);
            if (historyValuesList == null || historyValuesList.isEmpty()) {
                continue;
            }
            //the first HistoryValue should be the most recent because of sorting in HistoryLoaderBL.getHistoryValuesList()
            HistoryValues historyValues = historyValuesList.get(0);
            if (!SystemFields.INTEGER_STATE.equals(historyValues.getFieldID())) {
                //should never happen
                continue;
            }
            Integer stateID = (Integer) historyValues.getNewValue();
            if (stateID == null) {
                continue;
            }
            Date lastStateChangeDate = historyValues.getLastEdit();
            calendar.setTime(dateFrom);
            int yearValue = calendarStartDate.get(Calendar.YEAR);
            int intervalValue = calendarStartDate.get(calendarInterval);
            boolean isFirst = true;
            while (calendar.before(calendarEndDate) || isFirst) {
                if (isFirst) {
                    isFirst = false;
                } else {
                    calendar.add(calendarInterval, 1);
                }
                yearValue = calendar.get(Calendar.YEAR);

                intervalValue = calendar.get(calendarInterval);
                SortedMap<Integer, Double> intervalToPlannedValues = yearToIntervalToEarnedValue
                        .get(Integer.valueOf(yearValue));
                if (intervalToPlannedValues == null) {
                    yearToIntervalToEarnedValue.put(new Integer(yearValue), new TreeMap<Integer, Double>());
                    intervalToPlannedValues = yearToIntervalToEarnedValue.get(Integer.valueOf(yearValue));
                }
                Double totalPlannedValueForInterval = intervalToPlannedValues
                        .get(Integer.valueOf(intervalValue));
                if (totalPlannedValueForInterval == null) {
                    SortedMap<Integer, Double> firstIntervalToPlannedvalues = yearToIntervalToPlannedValue
                            .get(yearToIntervalToPlannedValue.firstKey());
                    totalPlannedValueForInterval = firstIntervalToPlannedvalues
                            .get(firstIntervalToPlannedvalues.firstKey());
                }
                if (DateTimeUtils.less(lastStateChangeDate, calendar.getTime())) {
                    if (finalStates.contains(stateID)) {
                        if (selectedEffortType == EFFORT_TYPE.NR_OF_ITEMS_IN_INTERVAL) {
                            totalPlannedValueForInterval -= 1.0;
                        } else {
                            Integer storyPointValueID = getStoryPointValueID(workItemBean,
                                    customFieldIDForStoryPoint);
                            if (storyPointValueID != null) {
                                Integer storyPointValue = storyPointValueIDToValueMap.get(storyPointValueID);
                                if (storyPointValue != null) {
                                    totalPlannedValueForInterval -= (double) storyPointValue;
                                }
                            }
                        }
                    }
                }
                intervalToPlannedValues.put(Integer.valueOf(intervalValue), totalPlannedValueForInterval);
            }
        }
    }
    return yearToIntervalToEarnedValue;
}

From source file:com.google.gwt.emultest.java.util.TreeMapTest.java

public void testSubMap_NullTolerableComparator() {
    if (!useNullKey()) {
        return;/*www.ja  va2  s . com*/
    }

    // JDK < 7 does not handle null keys correctly.
    if (TestUtils.isJvm() && TestUtils.getJdkVersion() < 7) {
        return;
    }

    K[] keys = getSortedKeys();
    V[] values = getSortedValues();
    NavigableMap<K, V> map = createNavigableMap();
    map.put(keys[1], values[1]);
    map.put(null, values[2]);

    SortedMap<K, V> subMapWithNull = map.subMap(null, true, keys[1], true);
    assertEquals(2, subMapWithNull.size());
    assertEquals(values[1], subMapWithNull.get(keys[1]));
    assertEquals(values[2], subMapWithNull.get(null));

    map.put(keys[0], values[0]);
    assertEquals(3, subMapWithNull.size());
    subMapWithNull = map.subMap(null, false, keys[0], true);
    assertEquals(1, subMapWithNull.size());
}

From source file:org.kuali.kpme.tklm.leave.summary.service.LeaveSummaryServiceImpl.java

private void assignApprovedValuesToRow(LeaveSummaryRow lsr, String accrualCategory,
        List<LeaveBlock> approvedLeaveBlocks, LeavePlan lp, LocalDate ytdEarnedEffectiveDate,
        LocalDate effectiveDate) {

    SortedMap<String, BigDecimal> yearlyAccrued = new TreeMap<String, BigDecimal>();
    SortedMap<String, BigDecimal> yearlyUsage = new TreeMap<String, BigDecimal>();
    BigDecimal accrualedBalance = BigDecimal.ZERO.setScale(2);
    BigDecimal approvedUsage = BigDecimal.ZERO.setScale(2);
    BigDecimal fmlaUsage = BigDecimal.ZERO.setScale(2);

    LocalDate cutOffDateToCheck = ytdEarnedEffectiveDate != null ? ytdEarnedEffectiveDate : effectiveDate;
    DateTime cutOffDate = HrServiceLocator.getLeavePlanService()
            .getFirstDayOfLeavePlan(lp.getLeavePlan(), cutOffDateToCheck).minus(1);

    if (CollectionUtils.isNotEmpty(approvedLeaveBlocks)) {
        // create it here so we don't need to get instance every loop iteration
        for (LeaveBlock aLeaveBlock : approvedLeaveBlocks) {
            // check if leave date is before the next calendar start.
            if (!aLeaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.CARRY_OVER)
                    && aLeaveBlock.getLeaveDateTime().getMillis() < effectiveDate.toDate().getTime()) {
                if ((StringUtils.isBlank(accrualCategory)
                        && StringUtils.isBlank(aLeaveBlock.getAccrualCategory()))
                        || (StringUtils.isNotBlank(aLeaveBlock.getAccrualCategory())
                                && StringUtils.equals(aLeaveBlock.getAccrualCategory(), accrualCategory))) {
                    // disapproved/deferred leave blocks should not be calculated into the approved values
                    if (!(StringUtils.equals(HrConstants.REQUEST_STATUS.DISAPPROVED,
                            aLeaveBlock.getRequestStatus())
                            || StringUtils.equals(HrConstants.REQUEST_STATUS.DEFERRED,
                                    aLeaveBlock.getRequestStatus()))) {

                        String leveBlockType = aLeaveBlock.getLeaveBlockType();
                        EarnCodeContract ec = HrServiceLocator.getEarnCodeService()
                                .getEarnCode(aLeaveBlock.getEarnCode(), aLeaveBlock.getLeaveLocalDate());
                        boolean adjustmentYtd = ec != null
                                && StringUtils.equals(ec.getAccrualBalanceAction(),
                                        HrConstants.ACCRUAL_BALANCE_ACTION.ADJUSTMENT)
                                && LMConstants.ADJUSTMENT_YTD_EARNED_LEAVE_BLOCK_TYPES.contains(leveBlockType);

                        // YTD earned
                        if (LMConstants.YTD_EARNED_LEAVE_BLOCK_TYPES.contains(leveBlockType) || adjustmentYtd) {
                            if (aLeaveBlock.getLeaveLocalDate().toDate().getTime() <= cutOffDate.toDate()
                                    .getTime()) {
                                String yearKey = getYearKey(aLeaveBlock.getLeaveLocalDate(), lp);
                                BigDecimal co = yearlyAccrued.get(yearKey);
                                if (co == null) {
                                    co = BigDecimal.ZERO.setScale(2);
                                }/*from  w ww  .j  av  a2  s . c  o  m*/
                                co = co.add(aLeaveBlock.getLeaveAmount());
                                yearlyAccrued.put(yearKey, co);
                            } else if (aLeaveBlock.getLeaveDateTime().getMillis() < ytdEarnedEffectiveDate
                                    .toDate().getTime()) {
                                accrualedBalance = accrualedBalance.add(aLeaveBlock.getLeaveAmount());
                            }
                        }

                        // YTD usage
                        if (ec != null
                                && StringUtils.equals(ec.getAccrualBalanceAction(),
                                        HrConstants.ACCRUAL_BALANCE_ACTION.USAGE)
                                && LMConstants.USAGE_LEAVE_BLOCK_TYPES.contains(leveBlockType)) {
                            if (aLeaveBlock.getLeaveDateTime().getMillis() > cutOffDate.toDate().getTime()) {
                                approvedUsage = approvedUsage.add(aLeaveBlock.getLeaveAmount());
                                if (ec.getFmla().equals("Y")) {
                                    fmlaUsage = fmlaUsage.add(aLeaveBlock.getLeaveAmount());
                                }
                            } else {
                                //these usages are for previous years, to help figure out correct carry over values
                                String yearKey = getYearKey(aLeaveBlock.getLeaveLocalDate(), lp);
                                BigDecimal use = yearlyUsage.get(yearKey);
                                if (use == null) {
                                    use = BigDecimal.ZERO.setScale(2);
                                }
                                use = use.add(aLeaveBlock.getLeaveAmount());
                                yearlyUsage.put(yearKey, use);
                            }
                        }
                    }
                }
            } else {
                //we can actually use the carry over block!!

            }
        }
    }

    lsr.setPriorYearsTotalAccrued(yearlyAccrued);
    lsr.setPriorYearsUsage(yearlyUsage);
    lsr.setYtdAccruedBalance(accrualedBalance);
    lsr.setYtdApprovedUsage(approvedUsage.negate());
    lsr.setFmlaUsage(fmlaUsage.negate());

    //lsr.setLeaveBalance(lsr.getYtdAccruedBalance().add(approvedUsage));
}

From source file:org.codehaus.mojo.license.DefaultDependenciesTool.java

/**
 * {@inheritDoc}//from w  w w .j av a2s. c o  m
 */
@Override
public SortedMap<String, MavenProject> loadProjectDependencies(MavenProject project,
        MavenProjectDependenciesConfigurator configuration, ArtifactRepository localRepository,
        List<ArtifactRepository> remoteRepositories, SortedMap<String, MavenProject> cache) {

    boolean haveNoIncludedGroups = StringUtils.isEmpty(configuration.getIncludedGroups());
    boolean haveNoIncludedArtifacts = StringUtils.isEmpty(configuration.getIncludedArtifacts());

    boolean haveExcludedGroups = StringUtils.isNotEmpty(configuration.getExcludedGroups());
    boolean haveExcludedArtifacts = StringUtils.isNotEmpty(configuration.getExcludedArtifacts());
    boolean haveExclusions = haveExcludedGroups || haveExcludedArtifacts;

    Pattern includedGroupPattern = null;
    Pattern includedArtifactPattern = null;
    Pattern excludedGroupPattern = null;
    Pattern excludedArtifactPattern = null;

    if (!haveNoIncludedGroups) {
        includedGroupPattern = Pattern.compile(configuration.getIncludedGroups());
    }
    if (!haveNoIncludedArtifacts) {
        includedArtifactPattern = Pattern.compile(configuration.getIncludedArtifacts());
    }
    if (haveExcludedGroups) {
        excludedGroupPattern = Pattern.compile(configuration.getExcludedGroups());
    }
    if (haveExcludedArtifacts) {
        excludedArtifactPattern = Pattern.compile(configuration.getExcludedArtifacts());
    }

    Set<?> depArtifacts;

    if (configuration.isIncludeTransitiveDependencies()) {
        // All project dependencies
        depArtifacts = project.getArtifacts();
    } else {
        // Only direct project dependencies
        depArtifacts = project.getDependencyArtifacts();
    }

    List<String> includedScopes = configuration.getIncludedScopes();
    List<String> excludeScopes = configuration.getExcludedScopes();

    boolean verbose = configuration.isVerbose();

    SortedMap<String, MavenProject> result = new TreeMap<String, MavenProject>();

    for (Object o : depArtifacts) {
        Artifact artifact = (Artifact) o;

        String scope = artifact.getScope();
        if (CollectionUtils.isNotEmpty(includedScopes) && !includedScopes.contains(scope)) {
            // not in included scopes
            continue;
        }
        if (excludeScopes.contains(scope)) {
            // in excluded scopes
            continue;
        }

        Logger log = getLogger();

        String id = MojoHelper.getArtifactId(artifact);

        if (verbose) {
            log.info("detected artifact " + id);
        }

        // Check if the project should be included
        // If there is no specified artifacts and group to include, include all
        boolean isToInclude = haveNoIncludedArtifacts && haveNoIncludedGroups
                || isIncludable(artifact, includedGroupPattern, includedArtifactPattern);

        // Check if the project should be excluded
        boolean isToExclude = isToInclude && haveExclusions
                && isExcludable(artifact, excludedGroupPattern, excludedArtifactPattern);

        if (!isToInclude || isToExclude) {
            if (verbose) {
                log.info("skip artifact " + id);
            }
            continue;
        }

        MavenProject depMavenProject = null;

        if (cache != null) {

            // try to get project from cache
            depMavenProject = cache.get(id);
        }

        if (depMavenProject != null) {
            if (verbose) {
                log.info("add dependency [" + id + "] (from cache)");
            }
        } else {
            // build project
            try {
                depMavenProject = mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories,
                        localRepository, true);
            } catch (Exception e) {
                log.warn("Unable to obtain POM for artifact : " + artifact, e);
                continue;
            }

            if (verbose) {
                log.info("add dependency [" + id + "]");
            }
            if (cache != null) {
                // store it also in cache
                cache.put(id, depMavenProject);
            }
        }

        // keep the project
        result.put(id, depMavenProject);
    }

    return result;
}

From source file:org.kuali.kfs.module.cam.batch.service.impl.AssetDepreciationServiceImpl.java

/**
 * This method stores in a collection of business objects the depreciation transaction that later on will be passed to the
 * processGeneralLedgerPendingEntry method in order to store the records in gl pending entry table
 *
 * @param assetPayment asset payment/*from   www .  j a v a2  s  . c  om*/
 * @param transactionType which can be [C]redit or [D]ebit
 * @param plantCOA plant fund char of account code
 * @param plantAccount plant fund char of account code
 * @param financialObject char of account object code linked to the payment
 * @param depreciationTransactionSummary
 * @return none
 */
protected void populateDepreciationTransaction(AssetPaymentInfo assetPayment, String transactionType,
        String plantCOA, String plantAccount, ObjectCode deprObjectCode,
        SortedMap<String, AssetDepreciationTransaction> depreciationTransactionSummary) {
    LOG.debug(
            "populateDepreciationTransaction(AssetDepreciationTransaction depreciationTransaction, AssetPayment assetPayment, String transactionType, KualiDecimal transactionAmount, String plantCOA, String plantAccount, String accumulatedDepreciationFinancialObjectCode, String depreciationExpenseFinancialObjectCode, ObjectCode financialObject, SortedMap<String, AssetDepreciationTransaction> depreciationTransactionSummary) -  started");
    LOG.debug(CamsConstants.Depreciation.DEPRECIATION_BATCH
            + "populateDepreciationTransaction(): populating AssetDepreciationTransaction pojo - Asset#:"
            + assetPayment.getCapitalAssetNumber());
    AssetDepreciationTransaction depreciationTransaction = new AssetDepreciationTransaction();
    depreciationTransaction.setCapitalAssetNumber(assetPayment.getCapitalAssetNumber());
    depreciationTransaction.setChartOfAccountsCode(plantCOA);
    depreciationTransaction.setAccountNumber(plantAccount);
    depreciationTransaction.setSubAccountNumber(assetPayment.getSubAccountNumber());
    depreciationTransaction.setFinancialObjectCode(deprObjectCode.getFinancialObjectCode());
    depreciationTransaction.setFinancialSubObjectCode(assetPayment.getFinancialSubObjectCode());
    depreciationTransaction.setFinancialObjectTypeCode(deprObjectCode.getFinancialObjectTypeCode());
    depreciationTransaction.setTransactionType(transactionType);
    depreciationTransaction.setProjectCode(assetPayment.getProjectCode());
    depreciationTransaction.setTransactionAmount(assetPayment.getTransactionAmount());
    depreciationTransaction.setTransactionLedgerEntryDescription(
            CamsConstants.Depreciation.TRANSACTION_DESCRIPTION + assetPayment.getCapitalAssetNumber());

    String sKey = depreciationTransaction.getKey();

    // Grouping the asset transactions by asset#, accounts, sub account, object, transaction type (C/D), etc. in order to
    // only have one credit and one credit by group.
    if (depreciationTransactionSummary.containsKey(sKey)) {
        depreciationTransaction = depreciationTransactionSummary.get(sKey);
        depreciationTransaction.setTransactionAmount(
                depreciationTransaction.getTransactionAmount().add(assetPayment.getTransactionAmount()));
    } else {
        depreciationTransactionSummary.put(sKey, depreciationTransaction);
    }
    LOG.debug(
            "populateDepreciationTransaction(AssetDepreciationTransaction depreciationTransaction, AssetPayment assetPayment, String transactionType, KualiDecimal transactionAmount, String plantCOA, String plantAccount, String accumulatedDepreciationFinancialObjectCode, String depreciationExpenseFinancialObjectCode, ObjectCode financialObject, SortedMap<String, AssetDepreciationTransaction> depreciationTransactionSummary) -  ended");
}

From source file:edu.cmu.tetrad.search.Lofs2.java

private void ruleR1(Graph skeleton, Graph graph, List<Node> nodes) {
    List<DataSet> centeredData = DataUtils.center(this.dataSets);
    setDataSets(centeredData);/*  www . j a va 2 s  . c  o m*/

    for (Node node : nodes) {
        SortedMap<Double, String> scoreReports = new TreeMap<Double, String>();

        List<Node> adj = new ArrayList<Node>();

        for (Node _node : skeleton.getAdjacentNodes(node)) {
            if (knowledge.isForbidden(_node.getName(), node.getName())) {
                continue;
            }

            adj.add(_node);
        }

        DepthChoiceGenerator gen = new DepthChoiceGenerator(adj.size(), adj.size());
        int[] choice;
        double maxScore = Double.NEGATIVE_INFINITY;
        List<Node> parents = null;

        while ((choice = gen.next()) != null) {
            List<Node> _parents = GraphUtils.asList(choice, adj);

            double score = score(node, _parents);
            scoreReports.put(-score, _parents.toString());

            if (score > maxScore) {
                maxScore = score;
                parents = _parents;
            }
        }

        double p = pValue(node, parents);

        if (p > alpha) {
            continue;
        }

        for (double score : scoreReports.keySet()) {
            TetradLogger.getInstance().log("score",
                    "For " + node + " parents = " + scoreReports.get(score) + " score = " + -score);
        }

        TetradLogger.getInstance().log("score", "");

        if (parents == null) {
            continue;
        }

        for (Node _node : adj) {
            if (parents.contains(_node)) {
                Edge parentEdge = Edges.directedEdge(_node, node);

                if (!graph.containsEdge(parentEdge)) {
                    graph.addEdge(parentEdge);
                }
            }
        }
    }

    for (Edge edge : skeleton.getEdges()) {
        if (!graph.isAdjacentTo(edge.getNode1(), edge.getNode2())) {
            graph.addUndirectedEdge(edge.getNode1(), edge.getNode2());
        }
    }
}