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.bookmark.service.persistence.impl.companyBookmarkPersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        companyBookmark companyBookmark = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_COMPANYBOOKMARK_WHERE_PKS_IN);

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

        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 (companyBookmark companyBookmark : (List<companyBookmark>) q.list()) {
            map.put(companyBookmark.getPrimaryKeyObj(), companyBookmark);

            cacheResult(companyBookmark);

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

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

    return map;
}

From source file:com.clavisit.clavisit.poc.ddl.images.service.persistence.impl.ImagePersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Image image = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_IMAGE_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 (Image image : (List<Image>) q.list()) {
            map.put(image.getPrimaryKeyObj(), image);

            cacheResult(image);

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

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

    return map;
}

From source file:com.cmcti.cmts.domain.service.persistence.CableModemHistoryPK.java

License:Open Source License

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

    sb.append(StringPool.OPEN_CURLY_BRACE);

    sb.append("macAddress");
    sb.append(StringPool.EQUAL);/*from ww w .  j  a v a  2s  . com*/
    sb.append(macAddress);

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

    sb.append(StringPool.CLOSE_CURLY_BRACE);

    return sb.toString();
}

From source file:com.cmcti.cmts.domain.service.persistence.CableModemPK.java

License:Open Source License

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

    sb.append(StringPool.OPEN_CURLY_BRACE);

    sb.append("cmtsId");
    sb.append(StringPool.EQUAL);/*from   w ww  . j a v a 2  s .c  o m*/
    sb.append(cmtsId);

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

    sb.append(StringPool.CLOSE_CURLY_BRACE);

    return sb.toString();
}

From source file:com.cmcti.cmts.domain.service.persistence.UpstreamChannelHistoryPK.java

License:Open Source License

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

    sb.append(StringPool.OPEN_CURLY_BRACE);

    sb.append("cmtsId");
    sb.append(StringPool.EQUAL);/*  w ww.j  ava  2s.  c  o  m*/
    sb.append(cmtsId);

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

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

    sb.append(StringPool.CLOSE_CURLY_BRACE);

    return sb.toString();
}

From source file:com.cmcti.cmts.domain.service.persistence.UpstreamChannelPK.java

License:Open Source License

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

    sb.append(StringPool.OPEN_CURLY_BRACE);

    sb.append("ifIndex");
    sb.append(StringPool.EQUAL);/*from   w  w w  .ja v a  2s .c  o m*/
    sb.append(ifIndex);

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

    sb.append(StringPool.CLOSE_CURLY_BRACE);

    return sb.toString();
}

From source file:com.employee.service.persistence.impl.EmployeeePersistenceImpl.java

License:Open Source License

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

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

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

        Serializable primaryKey = iterator.next();

        Employeee employeee = fetchByPrimaryKey(primaryKey);

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

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

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

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

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

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

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

    query.append(_SQL_SELECT_EMPLOYEEE_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 (Employeee employeee : (List<Employeee>) q.list()) {
            map.put(employeee.getPrimaryKeyObj(), employeee);

            cacheResult(employeee);

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

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

    return map;
}

From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java

private static List<FamilyMember> getChildrenFromRequest(PortletRequest actionRequest)
        throws PortalException, SystemException {
    List<FamilyMember> children = new ArrayList<FamilyMember>();

    String[] indexesArray = ParamUtil.getString(actionRequest, "childrenIndexes").split(StringPool.COMMA);
    List<String> indexes = Arrays.asList(indexesArray);
    long userBelongsToId = PortalUtil.getUserId(actionRequest);

    int memberIndex = 0;
    for (int i = 0; i < indexes.size(); i++) {
        String index = indexes.get(i);

        FamilyMember child = new FamilyMemberClp();
        child.setFirstName(/*from  w w  w.  ja  va  2  s . com*/
                ParamUtil.getString(actionRequest, "childFirstName" + index, StringPool.BLANK).trim());
        child.setLastName(ParamUtil.getString(actionRequest, "childLastName" + index, StringPool.BLANK).trim());
        child.setCNP(ParamUtil.getString(actionRequest, "childCNP" + index, StringPool.BLANK));
        child.setType(MyAccountConstants.CHILD);
        child.setUserBelongsId(userBelongsToId);
        child.setSeries(StringPool.BLANK);
        child.setNumar(StringPool.BLANK);

        if (!UserFamilyHandler.isFamilyMemberEmpty(child)) {
            String idStr = ParamUtil.getString(actionRequest, "childId" + index, StringPool.BLANK);
            long memberId = (StringPool.BLANK.equals(idStr)) ? Long.valueOf(memberIndex++)
                    : Long.valueOf(idStr);

            child.setMemberId(memberId);
            children.add(child);
        }
    }
    return children;
}

From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java

private static List<EvoAddressModel> getAddressesFromRequest(ActionRequest actionRequest) {
    List<EvoAddressModel> addresses = new ArrayList<EvoAddressModel>();

    String primaryIndexAddress = ParamUtil.getString(actionRequest, "addressPrimary", "0");

    String addressesIndexes = ParamUtil.getString(actionRequest, ADDRESSES_INDEXES);
    String[] indexes = addressesIndexes.split(StringPool.COMMA);

    for (String idx : indexes) {
        EvoAddressModel addressModel = new EvoAddressModel();

        String streetName = ParamUtil.getString(actionRequest, "addressStreet1_" + idx, StringPool.BLANK);
        String streetNo = ParamUtil.getString(actionRequest, "addressStreet2_" + idx, StringPool.BLANK);
        String city = ParamUtil.getString(actionRequest, "addressCity" + idx, StringPool.BLANK);

        if (streetName.isEmpty() && streetNo.isEmpty() && city.isEmpty()) {
            continue;
        }//from  w  ww. ja va  2s. c  o m

        String zip = ParamUtil.getString(actionRequest, "addressZip" + idx);
        long regionId = ParamUtil.getLong(actionRequest, "addressRegionId" + idx, 0L);
        long typeId = ParamUtil.getLong(actionRequest, "addressTypeId" + idx, 0L);
        boolean mailing = ParamUtil.getBoolean(actionRequest, "addressMailing" + idx, false);

        addressModel.setStreetName(streetName);
        addressModel.setStreetNumber(streetNo);
        addressModel.setPostalCode(zip);
        addressModel.setRegion(regionId);
        addressModel.setType(typeId);
        addressModel.setCity(city);
        addressModel.setMailing(mailing);
        addressModel.setPrimary(primaryIndexAddress.equals(idx));

        try {
            int countryId = ParamUtil.getInteger(actionRequest, "addressCountryId" + idx);
            if (countryId != 0) {
                Country country = CountryUtil.fetchByPrimaryKey(countryId);
                addressModel.setCountryCode(country.getA2());
            }
        } catch (SystemException e) {
            logger.error("Error fetching address model from request: " + e.getMessage(), e);
        }
        addresses.add(addressModel);
    }

    return addresses;
}

From source file:com.example.service.persistence.impl.FooPersistenceImpl.java

License:Open Source License

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

    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) {
        Serializable serializable = entityCache.getResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class,
                primaryKey);

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

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

    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, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}