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.xtivia.book.portlet.service.persistence.impl.EntryPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Entry entry = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_ENTRY_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 (Entry entry : (List<Entry>) q.list()) {
            map.put(entry.getPrimaryKeyObj(), entry);

            cacheResult(entry);

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

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

    return map;
}

From source file:com.xtivia.boostcamp.service.persistence.impl.ProductPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Product product = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_PRODUCT_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 (Product product : (List<Product>) q.list()) {
            map.put(product.getPrimaryKeyObj(), product);

            cacheResult(product);

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

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

    return map;
}

From source file:com.ys.liferay.cert.service.persistence.InventoryPK.java

License:Open Source License

@Override
public String toString() {
    StringBundler sb = new StringBundler(10);

    sb.append(StringPool.OPEN_CURLY_BRACE);

    sb.append("productId");
    sb.append(StringPool.EQUAL);//from   w  w w .  j a  v  a2 s . c o  m
    sb.append(productId);

    sb.append(StringPool.COMMA);
    sb.append(StringPool.SPACE);
    sb.append("productCode");
    sb.append(StringPool.EQUAL);
    sb.append(productCode);

    sb.append(StringPool.CLOSE_CURLY_BRACE);

    return sb.toString();
}

From source file:de.iisys.service.persistence.impl.CamundaPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Camunda> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*w  w  w  .  j  a  v a2 s. c  o m*/

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

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

        Serializable primaryKey = iterator.next();

        Camunda camunda = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_CAMUNDA_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 (Camunda camunda : (List<Camunda>) q.list()) {
            map.put(camunda.getPrimaryKeyObj(), camunda);

            cacheResult(camunda);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.CategoryPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Category category = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Category category = (Category) entityCache.getResult(CategoryModelImpl.ENTITY_CACHE_ENABLED,
                CategoryImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_CATEGORY_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 (Category category : (List<Category>) q.list()) {
            map.put(category.getPrimaryKeyObj(), category);

            cacheResult(category);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.DifficultyPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Difficulty difficulty = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Difficulty difficulty = (Difficulty) entityCache.getResult(DifficultyModelImpl.ENTITY_CACHE_ENABLED,
                DifficultyImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_DIFFICULTY_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 (Difficulty difficulty : (List<Difficulty>) q.list()) {
            map.put(difficulty.getPrimaryKeyObj(), difficulty);

            cacheResult(difficulty);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.HighscorePersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Highscore> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//from w  ww  . jav  a  2s .com

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

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

        Serializable primaryKey = iterator.next();

        Highscore highscore = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Highscore highscore = (Highscore) entityCache.getResult(HighscoreModelImpl.ENTITY_CACHE_ENABLED,
                HighscoreImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_HIGHSCORE_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 (Highscore highscore : (List<Highscore>) q.list()) {
            map.put(highscore.getPrimaryKeyObj(), highscore);

            cacheResult(highscore);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.QuestionPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Question question = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Question question = (Question) entityCache.getResult(QuestionModelImpl.ENTITY_CACHE_ENABLED,
                QuestionImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_QUESTION_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 (Question question : (List<Question>) q.list()) {
            map.put(question.getPrimaryKeyObj(), question);

            cacheResult(question);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.QuestionStatisticsPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        QuestionStatistics questionStatistics = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        QuestionStatistics questionStatistics = (QuestionStatistics) entityCache.getResult(
                QuestionStatisticsModelImpl.ENTITY_CACHE_ENABLED, QuestionStatisticsImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_QUESTIONSTATISTICS_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 (QuestionStatistics questionStatistics : (List<QuestionStatistics>) q.list()) {
            map.put(questionStatistics.getPrimaryKeyObj(), questionStatistics);

            cacheResult(questionStatistics);

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

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

    return map;
}

From source file:de.ki.sbam.service.persistence.impl.UserStatisticsPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, UserStatistics> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*  w  w w.  jav a  2  s .  com*/

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

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

        Serializable primaryKey = iterator.next();

        UserStatistics userStatistics = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        UserStatistics userStatistics = (UserStatistics) entityCache
                .getResult(UserStatisticsModelImpl.ENTITY_CACHE_ENABLED, UserStatisticsImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_USERSTATISTICS_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 (UserStatistics userStatistics : (List<UserStatistics>) q.list()) {
            map.put(userStatistics.getPrimaryKeyObj(), userStatistics);

            cacheResult(userStatistics);

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

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

    return map;
}