Example usage for com.liferay.portal.kernel.util StringPool COMMA

List of usage examples for com.liferay.portal.kernel.util StringPool COMMA

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool COMMA.

Prototype

String COMMA

To view the source code for com.liferay.portal.kernel.util StringPool COMMA.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, DDLRecordSet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//  ww w.  ja  v a2  s .co  m

    Map<Serializable, DDLRecordSet> map = new HashMap<Serializable, DDLRecordSet>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        DDLRecordSet ddlRecordSet = fetchByPrimaryKey(primaryKey);

        if (ddlRecordSet != null) {
            map.put(primaryKey, ddlRecordSet);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
                DDLRecordSetImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (DDLRecordSet) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_DDLRECORDSET_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (DDLRecordSet ddlRecordSet : (List<DDLRecordSet>) q.list()) {
            map.put(ddlRecordSet.getPrimaryKeyObj(), ddlRecordSet);

            cacheResult(ddlRecordSet);

            uncachedPrimaryKeys.remove(ddlRecordSet.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED, DDLRecordSetImpl.class,
                    primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetVersionPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, DDLRecordSetVersion> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//  w w w .  j ava 2  s . c o  m

    Map<Serializable, DDLRecordSetVersion> map = new HashMap<Serializable, DDLRecordSetVersion>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        DDLRecordSetVersion ddlRecordSetVersion = fetchByPrimaryKey(primaryKey);

        if (ddlRecordSetVersion != null) {
            map.put(primaryKey, ddlRecordSetVersion);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(DDLRecordSetVersionModelImpl.ENTITY_CACHE_ENABLED,
                DDLRecordSetVersionImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (DDLRecordSetVersion) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_DDLRECORDSETVERSION_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (DDLRecordSetVersion ddlRecordSetVersion : (List<DDLRecordSetVersion>) q.list()) {
            map.put(ddlRecordSetVersion.getPrimaryKeyObj(), ddlRecordSetVersion);

            cacheResult(ddlRecordSetVersion);

            uncachedPrimaryKeys.remove(ddlRecordSetVersion.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(DDLRecordSetVersionModelImpl.ENTITY_CACHE_ENABLED,
                    DDLRecordSetVersionImpl.class, primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordVersionPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, DDLRecordVersion> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from www.j a v  a2s  .  c  o  m*/

    Map<Serializable, DDLRecordVersion> map = new HashMap<Serializable, DDLRecordVersion>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        DDLRecordVersion ddlRecordVersion = fetchByPrimaryKey(primaryKey);

        if (ddlRecordVersion != null) {
            map.put(primaryKey, ddlRecordVersion);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
                DDLRecordVersionImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (DDLRecordVersion) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (DDLRecordVersion ddlRecordVersion : (List<DDLRecordVersion>) q.list()) {
            map.put(ddlRecordVersion.getPrimaryKeyObj(), ddlRecordVersion);

            cacheResult(ddlRecordVersion);

            uncachedPrimaryKeys.remove(ddlRecordVersion.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED, DDLRecordVersionImpl.class,
                    primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.dynamic.data.mapping.form.builder.internal.converter.visitor.ConditionExpressionVisitor.java

License:Open Source License

protected DDMFormRuleCondition createBelongsToCondition(String belongsToFunctionName, List<Operand> operands) {

    List<Operand> belongsToOperands = new ArrayList<>();

    Stream<Operand> operandsStream = operands.stream();

    Stream<String> valuesStream = operandsStream.map(operand -> operand.getValue());

    belongsToOperands.add(new Operand("list", valuesStream.collect(Collectors.joining(StringPool.COMMA))));

    return new DDMFormRuleCondition(belongsToFunctionName, belongsToOperands);
}

From source file:com.liferay.events.global.mobile.service.impl.EventContactLocalServiceImpl.java

License:Open Source License

public EventContact recordInterest(long userId, long groupId, ServiceContext serviceContext, String eventId,
        long contactId, long targetContactId) throws PortalException, SystemException {

    EventContact contact, targetContact;

    try {/*from   ww  w.  j  av  a2  s  .  c  o m*/
        contact = EventContactLocalServiceUtil.getVerifiedContact(contactId, true);
        targetContact = EventContactLocalServiceUtil.getVerifiedContact(targetContactId, true);
    } catch (PortalException ex) {
        throw new NoSuchEventContactException(ex);
    }

    long[] ints = StringUtil.split(contact.getInterestedIds(), StringPool.COMMA, 0L);
    long[] targetInts = StringUtil.split(targetContact.getInterestedIds(), StringPool.COMMA, 0L);

    Set<Long> intSet = new HashSet<Long>(ints.length);
    for (Long l : ints) {
        intSet.add(l);
    }

    Set<Long> targetIntSet = new HashSet<Long>(targetInts.length);
    for (Long l : targetInts) {
        targetIntSet.add(l);
    }

    if (intSet.contains(targetContactId)) {
        // already recorded
        return targetContact;
    }

    intSet.add(targetContactId);
    contact.setInterestedIds(StringUtil.merge(intSet, StringPool.COMMA));
    EventContactLocalServiceUtil.updateEventContact(contact);

    if (targetIntSet.contains(contactId)) {
        MatchLocalServiceUtil.addMatch(groupId, userId, serviceContext, eventId, contactId, targetContactId);
        // its a match; send PN to target to targetContact
        JSONObject payloadObj = JSONFactoryUtil.createJSONObject();
        payloadObj.put("screen", "");
        payloadObj.put("eventId", eventId);
        payloadObj.put("body", "You are matched with " + contact.getFullName());
        payloadObj.put("sound", "default");
        payloadObj.put("title", "Liferay Events");
        payloadObj.put("smallIcon", "ic_stat_lrlogo.png");
        payloadObj.put("ticker", "New Notification from Liferay Events");
        payloadObj.put("badge", 1);
        payloadObj.put("vibrate", true);
        payloadObj.put("screen", "connectConnections");

        JSONArray nameArgs = JSONFactoryUtil.createJSONArray();
        nameArgs.put(contact.getFullName());

        payloadObj.put("localizedKey", "ITS_A_MATCH");
        payloadObj.put("localizedArgs", nameArgs.toString());

        try {

            Map<String, String> args = new HashMap<String, String>();
            final PostMethod postMethod = new PostMethod(
                    "http://localhost:8080/api/jsonws/push-notifications-portlet.pushnotificationsdevice/send-push-notification");

            args.put("channel", eventId);
            args.put("emailAddress", targetContact.getEmailAddress());
            args.put("payload", payloadObj.toString());
            String sig = Utils.generateSig(args);

            postMethod.addParameter("channel", eventId);
            postMethod.addParameter("emailAddress", targetContact.getEmailAddress());
            postMethod.addParameter("payload", payloadObj.toString());
            postMethod.addParameter("signature", sig);
            final HttpClient httpClient = new HttpClient();
            httpClient.executeMethod(postMethod);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return targetContact;
    }

    return null;
}

From source file:com.liferay.events.global.mobile.service.impl.EventContactServiceImpl.java

License:Open Source License

private static String getJSONInterestsFromString(String interestStr, String existing, String source,
        Map<String, String> eventConfig) throws IOException, JSONException {

    String newStr = Utils.removeStopWords(interestStr);

    // remove newlines and other junk, make sure one space, lower case, etc
    newStr = newStr.replaceAll("[!\"#$%&'()*+,\\\\\\-./:;<=>?@\\[\\]^_`{|}~]", " ").replaceAll("\t", " ")
            .replaceAll(" {2,} ", " ").replaceAll("\n + $ ", "").replaceAll(" ^\n +", "")
            .replaceAll(" \n {2,}", " ").trim().toLowerCase();

    List<String> phrases = new ArrayList<String>();

    String weightStr = eventConfig.get("interest_weights");
    if (weightStr != null) {
        JSONArray weightArr = JSONFactoryUtil.createJSONArray(weightStr);
        int len = weightArr.length();
        for (int i = 0; i < len; i++) {
            String str = weightArr.getJSONObject(i).getString("word");
            phrases.add(str);/*from w w w  .  j  a v a  2  s  .  co m*/
            newStr = newStr.replaceAll(str, "");
        }
    }

    List<String> words = new ArrayList<String>();

    words.addAll(Arrays.asList(newStr.split("\\s+")));
    //words.addAll(phrases);

    final Map<String, Integer> profileWordsMap = new TreeMap<String, Integer>() {
        @Override
        public Integer put(final String key, final Integer value) {
            if (containsKey(key)) {
                return super.put(key, get(key) + value);
            } else {
                return super.put(key, value);
            }
        }
    };

    for (String word : words) {
        if (word.length() < INTERESTS_MIN_WORD_LENGTH || word.length() >= INTERESTS_MAX_WORD_LENGTH) {
            continue;
        }
        profileWordsMap.put(word, 1);
    }

    // subtract one
    for (String phrase : phrases) {
        if (profileWordsMap.containsKey(phrase)) {

            int count = profileWordsMap.get(phrase);
            if (count <= 1) {
                profileWordsMap.remove(phrase);
            } else {
                profileWordsMap.put(phrase, -1);
            }
        }
    }

    JSONArray existArr = null;

    // put existing words in if any
    if (Validator.isNotNull(existing)) {
        existArr = JSONFactoryUtil.createJSONArray(existing);
    }

    JSONArray weightArr = JSONFactoryUtil.createJSONArray(eventConfig.get("interest_weights"));

    Map<String, Double> configuredWeights = new HashMap<String, Double>();
    for (int i = 0; i < weightArr.length(); i++) {
        JSONObject obj = weightArr.getJSONObject(i);
        configuredWeights.put(obj.getString("word"), obj.getDouble("weight"));
    }

    JSONArray arr = JSONFactoryUtil.createJSONArray();

    for (String s : profileWordsMap.keySet()) {
        JSONObject existingObj;
        Set<String> existingSrcs;

        if (Validator.isNotNull(existArr)
                && Validator.isNotNull((existingObj = getExistingWordRecord(s, existArr)))) {
            if (Validator.isNotNull(existingObj)) {
                existingSrcs = new HashSet<String>(
                        Arrays.asList(StringUtils.split(existingObj.getString("source"), StringPool.COMMA)));
                existingSrcs.add(source);
                JSONObject obj = JSONFactoryUtil.createJSONObject();
                obj.put("word", s);
                obj.put("source", StringUtils.join(existingSrcs, StringPool.COMMA));
                obj.put("count", profileWordsMap.get(s) + existingObj.getInt(s));
                obj.put("weight", existingObj.getDouble("weight"));
                arr.put(obj);
            }
        } else {
            JSONObject obj = JSONFactoryUtil.createJSONObject();
            obj.put("word", s);
            obj.put("source", source);
            obj.put("count", profileWordsMap.get(s));
            obj.put("weight", configuredWeights.containsKey(s) ? configuredWeights.get(s) : 1.0);
            arr.put(obj);
        }
    }

    // put existing words that didn't show up in the profile
    if (Validator.isNotNull(existArr)) {
        for (int i = 0; i < existArr.length(); i++) {
            JSONObject existingObj = existArr.getJSONObject(i);
            if (!profileWordsMap.containsKey(existingObj.getString("word"))) {
                arr.put(existingObj);
            }
        }
    }
    return arr.toString();
}

From source file:com.liferay.events.global.mobile.service.impl.MatchLocalServiceImpl.java

License:Open Source License

public boolean unlink(final String eventId, final long contactId, final long targetContactId) throws Exception {
    List<Match> matches = getMatch(eventId, contactId, targetContactId);
    if ((matches == null) || matches.size() < 1) {
        return true;
    }/*www .j  av  a2s .  co  m*/

    EventContact contact = eventContactLocalService.getEventContact(contactId);

    String[] ids = StringUtil.split(contact.getInterestedIds(), StringPool.COMMA);

    List<String> idList = new ArrayList<String>(ids.length);

    for (Match match : matches) {
        matchLocalService.deleteMatch(match.getMatchId());
        idList.remove(String.valueOf(targetContactId));
    }

    contact.setInterestedIds(StringUtil.merge(idList, StringPool.COMMA));
    eventContactLocalService.updateEventContact(contact);

    return true;
}

From source file:com.liferay.events.global.mobile.service.impl.MatchServiceImpl.java

License:Open Source License

@AccessControlled(guestAccessEnabled = true)
@Override/*from   ww  w.ja  va  2 s . c om*/
public List<Candidate> getCandidates(final String eventId, final long contactId, final int max,
        final List<Long> uninterestedIds, String signature) throws Exception {
    Map<String, String> args = new HashMap<String, String>() {
        {
            put("eventId", StringUtil.valueOf(eventId));
            put("contactId", StringUtil.valueOf(contactId));
            put("max", StringUtil.valueOf(max));
            put("uninterestedIds", StringUtil.merge(uninterestedIds, StringPool.COMMA));
        }
    };

    if (!Utils.isValidSignature(args, signature)) {
        throw new InvalidSignatureException("invalid signature");
    }
    try {
        Set<Long> finalUninterestedIds = new HashSet<Long>();
        finalUninterestedIds.addAll(uninterestedIds);
        finalUninterestedIds.add(contactId);
        List<Match> alreadyMatched = MatchLocalServiceUtil.getMatches(eventId, contactId);
        for (Match m : alreadyMatched) {
            finalUninterestedIds.add(m.getContactId1());
            finalUninterestedIds.add(m.getContactId2());
        }

        List<EventContact> possibles = eventContactLocalService.getInterested(eventId, finalUninterestedIds);

        EventContact me = EventContactLocalServiceUtil.getVerifiedContact(contactId, true);

        final List<Long> hasInterest = new ArrayList<Long>();

        Map<String, String> eventConfig = Utils.getEventConfig(eventId);

        List<Candidate> result = new ArrayList<Candidate>();
        if (Validator.isNotNull(possibles)) {
            for (EventContact contact : possibles) {
                Candidate c = new Candidate();
                c.setPicUrl(contact.getPicUrl());
                c.setIndustry(contact.getIndustry());
                c.setJobTitle(contact.getJobTitle());
                c.setCity(contact.getCity());
                c.setCountry(contact.getCountry());
                c.setName(contact.getGivenName());
                c.setAttendeeType(contact.getAttendeeType());
                c.setEventContactId(contact.getEventContactId());
                c.setDistance(
                        Utils.getDistanceBetween(contact.getLat(), me.getLat(), contact.getLng(), me.getLng()));
                c.setLikeness(Utils.getLikeness(me, contact, eventConfig));
                c.setLikenessDescription(Utils.getJSONLikenessDescription(me, contact));
                result.add(c);

                for (long interestedId : StringUtil.split(contact.getInterestedIds(), StringPool.COMMA, 0L)) {
                    if (Validator.equals(interestedId, contactId)) {
                        hasInterest.add(contact.getEventContactId());
                    }
                }
            }
        }

        // favor people that have already said they like me, or those that have higher likeness to me
        Collections.sort(result, new Comparator<Candidate>() {
            @Override
            public int compare(Candidate c1, Candidate c2) {
                boolean has1 = hasInterest.contains(c1.getEventContactId());
                boolean has2 = hasInterest.contains(c2.getEventContactId());
                if (has1 && !has2) {
                    return -1;
                } else if (!has1 && has2) {
                    return 1;
                } else {
                    if (c1.getLikeness() > c2.getLikeness()) {
                        return -1;
                    } else if (c1.getLikeness() < c2.getLikeness()) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            }
        });

        return (max <= result.size() ? result.subList(0, max) : result);
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:com.liferay.evp.admin.service.persistence.impl.FundPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Fund> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//from   w  ww  .j a  v a 2  s  . c  om

    Map<Serializable, Fund> map = new HashMap<Serializable, Fund>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Fund fund = fetchByPrimaryKey(primaryKey);

        if (fund != null) {
            map.put(primaryKey, fund);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Fund fund = (Fund) EntityCacheUtil.getResult(FundModelImpl.ENTITY_CACHE_ENABLED, FundImpl.class,
                primaryKey);

        if (fund == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, fund);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_FUND_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Fund fund : (List<Fund>) q.list()) {
            map.put(fund.getPrimaryKeyObj(), fund);

            cacheResult(fund);

            uncachedPrimaryKeys.remove(fund.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(FundModelImpl.ENTITY_CACHE_ENABLED, FundImpl.class, primaryKey,
                    _nullFund);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.evp.admin.service.persistence.impl.ProjectPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Project> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//from   w ww . j  a  v  a2s  . co  m

    Map<Serializable, Project> map = new HashMap<Serializable, Project>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Project project = fetchByPrimaryKey(primaryKey);

        if (project != null) {
            map.put(primaryKey, project);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Project project = (Project) EntityCacheUtil.getResult(ProjectModelImpl.ENTITY_CACHE_ENABLED,
                ProjectImpl.class, primaryKey);

        if (project == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, project);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_PROJECT_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Project project : (List<Project>) q.list()) {
            map.put(project.getPrimaryKeyObj(), project);

            cacheResult(project);

            uncachedPrimaryKeys.remove(project.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(ProjectModelImpl.ENTITY_CACHE_ENABLED, ProjectImpl.class, primaryKey,
                    _nullProject);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}