Example usage for com.liferay.portal.kernel.util StringBundler setIndex

List of usage examples for com.liferay.portal.kernel.util StringBundler setIndex

Introduction

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

Prototype

public void setIndex(int newIndex) 

Source Link

Usage

From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceContainerPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        ApplicationInstanceContainer applicationInstanceContainer = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        ApplicationInstanceContainer applicationInstanceContainer = (ApplicationInstanceContainer) entityCache
                .getResult(ApplicationInstanceContainerModelImpl.ENTITY_CACHE_ENABLED,
                        ApplicationInstanceContainerImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_APPLICATIONINSTANCECONTAINER_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 (ApplicationInstanceContainer applicationInstanceContainer : (List<ApplicationInstanceContainer>) q
                .list()) {
            map.put(applicationInstanceContainer.getPrimaryKeyObj(), applicationInstanceContainer);

            cacheResult(applicationInstanceContainer);

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

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

    return map;
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        ApplicationInstance applicationInstance = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        ApplicationInstance applicationInstance = (ApplicationInstance) entityCache.getResult(
                ApplicationInstanceModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_APPLICATIONINSTANCE_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 (ApplicationInstance applicationInstance : (List<ApplicationInstance>) q.list()) {
            map.put(applicationInstance.getPrimaryKeyObj(), applicationInstance);

            cacheResult(applicationInstance);

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

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

    return map;
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePortPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        ApplicationInstancePort applicationInstancePort = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        ApplicationInstancePort applicationInstancePort = (ApplicationInstancePort) entityCache.getResult(
                ApplicationInstancePortModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstancePortImpl.class,
                primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_APPLICATIONINSTANCEPORT_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 (ApplicationInstancePort applicationInstancePort : (List<ApplicationInstancePort>) q.list()) {
            map.put(applicationInstancePort.getPrimaryKeyObj(), applicationInstancePort);

            cacheResult(applicationInstancePort);

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

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

    return map;
}

From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceStatusPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        ApplicationInstanceStatus applicationInstanceStatus = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        ApplicationInstanceStatus applicationInstanceStatus = (ApplicationInstanceStatus) entityCache.getResult(
                ApplicationInstanceStatusModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceStatusImpl.class,
                primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_APPLICATIONINSTANCESTATUS_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 (ApplicationInstanceStatus applicationInstanceStatus : (List<ApplicationInstanceStatus>) q.list()) {
            map.put(applicationInstanceStatus.getPrimaryKeyObj(), applicationInstanceStatus);

            cacheResult(applicationInstanceStatus);

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

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

    return map;
}

From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryDictionaryLinkPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        DictionaryDictionaryLink dictionaryDictionaryLink = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        DictionaryDictionaryLink dictionaryDictionaryLink = (DictionaryDictionaryLink) entityCache.getResult(
                DictionaryDictionaryLinkModelImpl.ENTITY_CACHE_ENABLED, DictionaryDictionaryLinkImpl.class,
                primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_DICTIONARYDICTIONARYLINK_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 (DictionaryDictionaryLink dictionaryDictionaryLink : (List<DictionaryDictionaryLink>) q.list()) {
            map.put(dictionaryDictionaryLink.getPrimaryKeyObj(), dictionaryDictionaryLink);

            cacheResult(dictionaryDictionaryLink);

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

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

    return map;
}

From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Dictionary dictionary = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Dictionary dictionary = (Dictionary) entityCache.getResult(DictionaryModelImpl.ENTITY_CACHE_ENABLED,
                DictionaryImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_DICTIONARY_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 (Dictionary dictionary : (List<Dictionary>) q.list()) {
            map.put(dictionary.getPrimaryKeyObj(), dictionary);

            cacheResult(dictionary);

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

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

    return map;
}

From source file:blade.servicebuilder.service.persistence.impl.FooPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Foo foo = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Foo foo = (Foo) entityCache.getResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey);

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

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

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

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

    query.append(_SQL_SELECT_FOO_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 (Foo foo : (List<Foo>) q.list()) {
            map.put(foo.getPrimaryKeyObj(), foo);

            cacheResult(foo);

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

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

    return map;
}

From source file:br.com.petrobras.ddm.type.region.internal.RegionDDMFormFieldValueRenderer.java

License:Open Source License

@Override
public String render(DDMFormFieldValue ddmFormFieldValue, Locale locale) {
    System.out.println(this);
    JSONArray optionsValuesJSONArray = regionDDMFormFieldValueAccessor.getValue(ddmFormFieldValue, locale);

    DDMFormFieldOptions ddmFormFieldOptions = getDDMFormFieldOptions(ddmFormFieldValue);

    if (optionsValuesJSONArray.length() == 0) {
        return StringPool.BLANK;
    }//from   w w w.j ava  2 s  .  co  m

    StringBundler sb = new StringBundler(optionsValuesJSONArray.length() * 2 - 1);

    for (int i = 0; i < optionsValuesJSONArray.length(); i++) {
        String optionValue = optionsValuesJSONArray.getString(i);

        if (isManualDataSourceType(ddmFormFieldValue.getDDMFormField())) {
            LocalizedValue optionLabel = ddmFormFieldOptions.getOptionLabels(optionValue);

            sb.append(optionLabel.getString(locale));
        } else {
            sb.append(optionValue);
        }

        sb.append(StringPool.COMMA_AND_SPACE);
    }

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

    return sb.toString();
}

From source file:ca.efendi.datafeeds.service.persistence.impl.CJProductPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        CJProduct cjProduct = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_CJPRODUCT_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 (CJProduct cjProduct : (List<CJProduct>) q.list()) {
            map.put(cjProduct.getPrimaryKeyObj(), cjProduct);

            cacheResult(cjProduct);

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

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

    return map;
}

From source file:ca.efendi.datafeeds.service.persistence.impl.FtpSubscriptionPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, FtpSubscription> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//  www. ja va  2 s.c o m

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

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

        Serializable primaryKey = iterator.next();

        FtpSubscription ftpSubscription = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_FTPSUBSCRIPTION_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 (FtpSubscription ftpSubscription : (List<FtpSubscription>) q.list()) {
            map.put(ftpSubscription.getPrimaryKeyObj(), ftpSubscription);

            cacheResult(ftpSubscription);

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

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

    return map;
}