Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:de.blizzy.documentr.page.CherryPicker.java

@Override
public SortedMap<String, List<CommitCherryPickResult>> cherryPick(String projectName, String branchName,
        String path, List<String> commits, Set<String> targetBranches,
        Set<CommitCherryPickConflictResolve> conflictResolves, boolean dryRun, User user, Locale locale)
        throws IOException {

    Assert.hasLength(projectName);//w ww .j  a v  a 2 s.co  m
    Assert.hasLength(path);
    Assert.notEmpty(commits);
    Assert.notEmpty(targetBranches);
    Assert.notNull(conflictResolves);
    Assert.notNull(user);

    // always do a dry run first and return early if it fails
    if (!dryRun) {
        SortedMap<String, List<CommitCherryPickResult>> results = cherryPick(projectName, branchName, path,
                commits, targetBranches, conflictResolves, true, user, locale);
        for (List<CommitCherryPickResult> branchResults : results.values()) {
            for (CommitCherryPickResult result : branchResults) {
                if (result.getStatus() != CommitCherryPickResult.Status.OK) {
                    return results;
                }
            }
        }
    }

    try {
        SortedMap<String, List<CommitCherryPickResult>> results = Maps.newTreeMap();
        for (String targetBranch : targetBranches) {
            List<CommitCherryPickResult> branchResults = cherryPick(projectName, branchName, path, commits,
                    targetBranch, conflictResolves, dryRun, user, locale);
            results.put(targetBranch, branchResults);
        }
        return results;
    } catch (GitAPIException e) {
        throw new IOException(e);
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ViewHomepageDA.java

public ActionForward listTeachers(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    final SortedMap<Unit, SortedSet<Homepage>> homepages = new TreeMap<Unit, SortedSet<Homepage>>(
            Unit.COMPARATOR_BY_NAME_AND_ID);
    for (final Teacher teacher : rootDomainObject.getTeachersSet()) {
        final Person person = teacher.getPerson();
        final Employee employee = person.getEmployee();
        if (employee != null) {
            final Contract contract = employee.getCurrentWorkingContract();
            if (contract != null) {
                final Unit unit = contract.getWorkingUnit();
                final SortedSet<Homepage> unitHomepages;
                if (homepages.containsKey(unit)) {
                    unitHomepages = homepages.get(unit);
                } else {
                    unitHomepages = new TreeSet<Homepage>(Homepage.HOMEPAGE_COMPARATOR_BY_NAME);
                    homepages.put(unit, unitHomepages);
                }/*  ww w  .  j  a v  a  2  s.co m*/
                final Homepage homepage = person.getHomepage();
                if (homepage != null && homepage.getActivated().booleanValue()) {
                    unitHomepages.add(homepage);
                }
            }
        }
    }
    request.setAttribute("homepages", homepages);

    final String selectedPage = request.getParameter("selectedPage");
    if (selectedPage != null) {
        request.setAttribute("selectedPage", selectedPage);
    }

    return mapping.findForward("list-homepages-teachers");
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamISOLanguageTable.java

public void updateISOLanguage(CFAccAuthorization Authorization, CFAccISOLanguageBuff Buff) {
    CFAccISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFAccISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateISOLanguage",
                "Existing record not found", "ISOLanguage", pkey);
    }//from   w  ww  .j  a v a 2  s  .  com
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateISOLanguage",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccISOLanguageByBaseIdxKey existingKeyBaseIdx = schema.getFactoryISOLanguage().newBaseIdxKey();
    existingKeyBaseIdx.setRequiredBaseLanguageCode(existing.getRequiredBaseLanguageCode());

    CFAccISOLanguageByBaseIdxKey newKeyBaseIdx = schema.getFactoryISOLanguage().newBaseIdxKey();
    newKeyBaseIdx.setRequiredBaseLanguageCode(Buff.getRequiredBaseLanguageCode());

    CFAccISOLanguageByCountryIdxKey existingKeyCountryIdx = schema.getFactoryISOLanguage().newCountryIdxKey();
    existingKeyCountryIdx.setOptionalISOCountryId(existing.getOptionalISOCountryId());

    CFAccISOLanguageByCountryIdxKey newKeyCountryIdx = schema.getFactoryISOLanguage().newCountryIdxKey();
    newKeyCountryIdx.setOptionalISOCountryId(Buff.getOptionalISOCountryId());

    CFAccISOLanguageByCodeIdxKey existingKeyCodeIdx = schema.getFactoryISOLanguage().newCodeIdxKey();
    existingKeyCodeIdx.setRequiredISOCode(existing.getRequiredISOCode());

    CFAccISOLanguageByCodeIdxKey newKeyCodeIdx = schema.getFactoryISOLanguage().newCodeIdxKey();
    newKeyCodeIdx.setRequiredISOCode(Buff.getRequiredISOCode());

    // Check unique indexes

    if (!existingKeyCodeIdx.equals(newKeyCodeIdx)) {
        if (dictByCodeIdx.containsKey(newKeyCodeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateISOLanguage", "ISOLanguageCodeIdx", newKeyCodeIdx);
        }
    }

    // Validate foreign keys

    // Update is valid

    SortedMap<CFAccISOLanguagePKey, CFAccISOLanguageBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByBaseIdx.get(existingKeyBaseIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByBaseIdx.containsKey(newKeyBaseIdx)) {
        subdict = dictByBaseIdx.get(newKeyBaseIdx);
    } else {
        subdict = new TreeMap<CFAccISOLanguagePKey, CFAccISOLanguageBuff>();
        dictByBaseIdx.put(newKeyBaseIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCountryIdx.get(existingKeyCountryIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCountryIdx.containsKey(newKeyCountryIdx)) {
        subdict = dictByCountryIdx.get(newKeyCountryIdx);
    } else {
        subdict = new TreeMap<CFAccISOLanguagePKey, CFAccISOLanguageBuff>();
        dictByCountryIdx.put(newKeyCountryIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByCodeIdx.remove(existingKeyCodeIdx);
    dictByCodeIdx.put(newKeyCodeIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamPhoneTable.java

public void createPhone(CFAccAuthorization Authorization, CFAccPhoneBuff Buff) {
    CFAccPhonePKey pkey = schema.getFactoryPhone().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredPhoneId(((CFAccRamTenantTable) schema.getTableTenant()).nextPhoneIdGen(Authorization,
            Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredPhoneId(pkey.getRequiredPhoneId());
    CFAccPhoneByTenantIdxKey keyTenantIdx = schema.getFactoryPhone().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccPhoneByContactIdxKey keyContactIdx = schema.getFactoryPhone().newContactIdxKey();
    keyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccPhoneByUDescrIdxKey keyUDescrIdx = schema.getFactoryPhone().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredContactId(Buff.getRequiredContactId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFAccPhoneByUPhoneNumberIdxKey keyUPhoneNumberIdx = schema.getFactoryPhone().newUPhoneNumberIdxKey();
    keyUPhoneNumberIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUPhoneNumberIdx.setRequiredContactId(Buff.getRequiredContactId());
    keyUPhoneNumberIdx.setRequiredPhoneNumber(Buff.getRequiredPhoneNumber());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createPhone", pkey);
    }//from   ww  w.  j a  v  a2s . c o  m

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createPhone",
                "PhoneUDescrIdx", keyUDescrIdx);
    }

    if (dictByUPhoneNumberIdx.containsKey(keyUPhoneNumberIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createPhone",
                "PhoneUPhoneNumberIdx", keyUPhoneNumberIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createPhone", "Owner", "PhoneTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;
        allNull = false;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableContact().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredContactId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createPhone", "Container", "Contact", "Contact", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccPhonePKey, CFAccPhoneBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
        subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
        subdictTenantIdx = new TreeMap<CFAccPhonePKey, CFAccPhoneBuff>();
        dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    SortedMap<CFAccPhonePKey, CFAccPhoneBuff> subdictContactIdx;
    if (dictByContactIdx.containsKey(keyContactIdx)) {
        subdictContactIdx = dictByContactIdx.get(keyContactIdx);
    } else {
        subdictContactIdx = new TreeMap<CFAccPhonePKey, CFAccPhoneBuff>();
        dictByContactIdx.put(keyContactIdx, subdictContactIdx);
    }
    subdictContactIdx.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    dictByUPhoneNumberIdx.put(keyUPhoneNumberIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamISOLanguageTable.java

public void updateISOLanguage(CFAstAuthorization Authorization, CFAstISOLanguageBuff Buff) {
    CFAstISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFAstISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateISOLanguage",
                "Existing record not found", "ISOLanguage", pkey);
    }//w ww  . j a v a  2  s.  c o  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateISOLanguage",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstISOLanguageByBaseIdxKey existingKeyBaseIdx = schema.getFactoryISOLanguage().newBaseIdxKey();
    existingKeyBaseIdx.setRequiredBaseLanguageCode(existing.getRequiredBaseLanguageCode());

    CFAstISOLanguageByBaseIdxKey newKeyBaseIdx = schema.getFactoryISOLanguage().newBaseIdxKey();
    newKeyBaseIdx.setRequiredBaseLanguageCode(Buff.getRequiredBaseLanguageCode());

    CFAstISOLanguageByCountryIdxKey existingKeyCountryIdx = schema.getFactoryISOLanguage().newCountryIdxKey();
    existingKeyCountryIdx.setOptionalISOCountryId(existing.getOptionalISOCountryId());

    CFAstISOLanguageByCountryIdxKey newKeyCountryIdx = schema.getFactoryISOLanguage().newCountryIdxKey();
    newKeyCountryIdx.setOptionalISOCountryId(Buff.getOptionalISOCountryId());

    CFAstISOLanguageByCodeIdxKey existingKeyCodeIdx = schema.getFactoryISOLanguage().newCodeIdxKey();
    existingKeyCodeIdx.setRequiredISOCode(existing.getRequiredISOCode());

    CFAstISOLanguageByCodeIdxKey newKeyCodeIdx = schema.getFactoryISOLanguage().newCodeIdxKey();
    newKeyCodeIdx.setRequiredISOCode(Buff.getRequiredISOCode());

    // Check unique indexes

    if (!existingKeyCodeIdx.equals(newKeyCodeIdx)) {
        if (dictByCodeIdx.containsKey(newKeyCodeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateISOLanguage", "ISOLanguageCodeIdx", newKeyCodeIdx);
        }
    }

    // Validate foreign keys

    // Update is valid

    SortedMap<CFAstISOLanguagePKey, CFAstISOLanguageBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByBaseIdx.get(existingKeyBaseIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByBaseIdx.containsKey(newKeyBaseIdx)) {
        subdict = dictByBaseIdx.get(newKeyBaseIdx);
    } else {
        subdict = new TreeMap<CFAstISOLanguagePKey, CFAstISOLanguageBuff>();
        dictByBaseIdx.put(newKeyBaseIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCountryIdx.get(existingKeyCountryIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCountryIdx.containsKey(newKeyCountryIdx)) {
        subdict = dictByCountryIdx.get(newKeyCountryIdx);
    } else {
        subdict = new TreeMap<CFAstISOLanguagePKey, CFAstISOLanguageBuff>();
        dictByCountryIdx.put(newKeyCountryIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByCodeIdx.remove(existingKeyCodeIdx);
    dictByCodeIdx.put(newKeyCodeIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamTenantTable.java

public void updateTenant(CFAstAuthorization Authorization, CFAstTenantBuff Buff) {
    CFAstTenantPKey pkey = schema.getFactoryTenant().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFAstTenantBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTenant",
                "Existing record not found", "Tenant", pkey);
    }// ww  w  . ja v a  2 s.co  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTenant",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstTenantByClusterIdxKey existingKeyClusterIdx = schema.getFactoryTenant().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstTenantByClusterIdxKey newKeyClusterIdx = schema.getFactoryTenant().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAstTenantByUNameIdxKey existingKeyUNameIdx = schema.getFactoryTenant().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUNameIdx.setRequiredTenantName(existing.getRequiredTenantName());

    CFAstTenantByUNameIdxKey newKeyUNameIdx = schema.getFactoryTenant().newUNameIdxKey();
    newKeyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUNameIdx.setRequiredTenantName(Buff.getRequiredTenantName());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
        if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTenant", "TenantUNameIdx", newKeyUNameIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTenant", "Container", "TenantCluster", "Cluster", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAstTenantPKey, CFAstTenantBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
        subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
        subdict = new TreeMap<CFAstTenantPKey, CFAstTenantBuff>();
        dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamURLProtocolTable.java

public void updateURLProtocol(CFAccAuthorization Authorization, CFAccURLProtocolBuff Buff) {
    CFAccURLProtocolPKey pkey = schema.getFactoryURLProtocol().newPKey();
    pkey.setRequiredURLProtocolId(Buff.getRequiredURLProtocolId());
    CFAccURLProtocolBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateURLProtocol",
                "Existing record not found", "URLProtocol", pkey);
    }//from  ww  w.ja  va  2 s.co  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateURLProtocol",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccURLProtocolByUNameIdxKey existingKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFAccURLProtocolByUNameIdxKey newKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    CFAccURLProtocolByIsSecureIdxKey existingKeyIsSecureIdx = schema.getFactoryURLProtocol()
            .newIsSecureIdxKey();
    existingKeyIsSecureIdx.setRequiredIsSecure(existing.getRequiredIsSecure());

    CFAccURLProtocolByIsSecureIdxKey newKeyIsSecureIdx = schema.getFactoryURLProtocol().newIsSecureIdxKey();
    newKeyIsSecureIdx.setRequiredIsSecure(Buff.getRequiredIsSecure());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
        if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateURLProtocol", "URLProtocolUNameIdx", newKeyUNameIdx);
        }
    }

    // Validate foreign keys

    // Update is valid

    SortedMap<CFAccURLProtocolPKey, CFAccURLProtocolBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);

    subdict = dictByIsSecureIdx.get(existingKeyIsSecureIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIsSecureIdx.containsKey(newKeyIsSecureIdx)) {
        subdict = dictByIsSecureIdx.get(newKeyIsSecureIdx);
    } else {
        subdict = new TreeMap<CFAccURLProtocolPKey, CFAccURLProtocolBuff>();
        dictByIsSecureIdx.put(newKeyIsSecureIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamURLProtocolTable.java

public void updateURLProtocol(CFAstAuthorization Authorization, CFAstURLProtocolBuff Buff) {
    CFAstURLProtocolPKey pkey = schema.getFactoryURLProtocol().newPKey();
    pkey.setRequiredURLProtocolId(Buff.getRequiredURLProtocolId());
    CFAstURLProtocolBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateURLProtocol",
                "Existing record not found", "URLProtocol", pkey);
    }/*w  w w  .  j a v a2s .c o  m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateURLProtocol",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstURLProtocolByUNameIdxKey existingKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFAstURLProtocolByUNameIdxKey newKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    CFAstURLProtocolByIsSecureIdxKey existingKeyIsSecureIdx = schema.getFactoryURLProtocol()
            .newIsSecureIdxKey();
    existingKeyIsSecureIdx.setRequiredIsSecure(existing.getRequiredIsSecure());

    CFAstURLProtocolByIsSecureIdxKey newKeyIsSecureIdx = schema.getFactoryURLProtocol().newIsSecureIdxKey();
    newKeyIsSecureIdx.setRequiredIsSecure(Buff.getRequiredIsSecure());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
        if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateURLProtocol", "URLProtocolUNameIdx", newKeyUNameIdx);
        }
    }

    // Validate foreign keys

    // Update is valid

    SortedMap<CFAstURLProtocolPKey, CFAstURLProtocolBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);

    subdict = dictByIsSecureIdx.get(existingKeyIsSecureIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIsSecureIdx.containsKey(newKeyIsSecureIdx)) {
        subdict = dictByIsSecureIdx.get(newKeyIsSecureIdx);
    } else {
        subdict = new TreeMap<CFAstURLProtocolPKey, CFAstURLProtocolBuff>();
        dictByIsSecureIdx.put(newKeyIsSecureIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

From source file:com.uber.jenkins.phabricator.coverage.CoberturaXMLParser.java

private Map<String, List<Integer>> parse(Map<NodeList, List<String>> coverageData) {
    Map<String, SortedMap<Integer, Integer>> internalCounts = new HashMap<String, SortedMap<Integer, Integer>>();

    // Each entry in the map is an XML list of classes (files) mapped to its possible source roots
    for (Map.Entry<NodeList, List<String>> entry : coverageData.entrySet()) {
        NodeList classes = entry.getKey();
        List<String> sourceDirs = entry.getValue();

        // Loop over all files in the coverage report
        for (int i = 0; i < classes.getLength(); i++) {
            Node classNode = classes.item(i);
            String fileName = classNode.getAttributes().getNamedItem(NODE_FILENAME).getTextContent();

            if (includeFileNames != null && !includeFileNames.contains(FilenameUtils.getName(fileName))) {
                continue;
            }// ww w  .  ja  v a 2s .  c o  m

            // Make a guess on which of the `sourceDirs` contains the file in question
            String detectedSourceRoot = new PathResolver(workspace, sourceDirs).choose(fileName);
            fileName = join(detectedSourceRoot, fileName);

            SortedMap<Integer, Integer> hitCounts = internalCounts.get(fileName);
            if (hitCounts == null) {
                hitCounts = new TreeMap<Integer, Integer>();
            }

            NodeList children = classNode.getChildNodes();
            for (int j = 0; j < children.getLength(); j++) {
                Node child = children.item(j);

                if (NODE_NAME_LINES.equals(child.getNodeName())) {
                    NodeList lines = child.getChildNodes();
                    for (int k = 0; k < lines.getLength(); k++) {
                        Node line = lines.item(k);
                        if (!NODE_NAME_LINE.equals(line.getNodeName())) {
                            continue;
                        }

                        Integer lineNumber = getIntValue(line, NODE_NUMBER);
                        int existingHits = hitCounts.containsKey(lineNumber) ? hitCounts.get(lineNumber) : 0;
                        hitCounts.put(lineNumber, Math.max(existingHits, getIntValue(line, NODE_HITS)));
                    }
                    internalCounts.put(fileName, hitCounts);
                }
            }
        }

    }
    return computeLineCoverage(internalCounts);
}

From source file:jp.zippyzip.web.ListServlet.java

/**
 * ????/*  w ww . j  ava 2s. c om*/
 * 
 * @return ??
 */
SortedMap<String, City> getCityMap(PersistenceManager pm, SortedMap<String, Pref> prefs) {

    SortedMap<String, City> ret = new TreeMap<String, City>();

    for (Pref pref : prefs.values()) {

        ParentChild pc = pm.getObjectById(ParentChild.class, pref.getCode());

        if (pc == null) {
            continue;
        }

        for (String json : pc.getChildren()) {

            City city = City.fromJson(json);

            ret.put(city.getCode(), city);
        }
    }

    return ret;
}