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:au.com.permeance.liferay.portal.documentlibrary.servlet.FolderActionsMenuHookListener.java

License:Open Source License

public static void startApplication() {

    System.out.println("startApplication");

    String[] newMenuItems = HookPropsValues.DL_FOLDER_ACTIONS_MENU_EXT;
    String newMenuItemsStr = StringUtil.merge(newMenuItems);
    if (LOG.isDebugEnabled()) {
        LOG.debug("newMenuItems: " + newMenuItems);
        LOG.debug("newMenuItemsStr: " + newMenuItemsStr);
    }//from ww w  .j  a v  a 2 s  .c om

    String[] curMenuItems = StringUtil
            .splitLines(System.getProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT));
    String curMenuItemsStr = StringUtil.merge(curMenuItems);
    if (LOG.isDebugEnabled()) {
        LOG.debug("curMenuItems: " + curMenuItems);
        LOG.debug("curMenuItemsStr: " + curMenuItemsStr);
    }

    String mergedMenuItemsStr = StringUtilHelper.addDelimItems(curMenuItemsStr, newMenuItemsStr,
            StringPool.COMMA);
    LOG.debug("mergedMenuItemsStr: " + mergedMenuItemsStr);

    System.setProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT, mergedMenuItemsStr);
    LOG.info(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT + ": "
            + System.getProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT));
}

From source file:au.com.permeance.liferay.portal.documentlibrary.servlet.FolderActionsMenuHookListener.java

License:Open Source License

public static void stopApplication() {

    System.out.println("stopApplication");

    String[] newMenuItems = HookPropsValues.DL_FOLDER_ACTIONS_MENU_EXT;
    String newMenuItemsStr = StringUtil.merge(newMenuItems);
    if (LOG.isDebugEnabled()) {
        LOG.debug("newMenuItems: " + newMenuItems);
        LOG.debug("newMenuItemsStr: " + newMenuItemsStr);
    }/*from  w  w  w.j a  v  a2 s .  co m*/

    String[] curMenuItems = StringUtil
            .splitLines(System.getProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT));
    String curMenuItemsStr = StringUtil.merge(curMenuItems);
    if (LOG.isDebugEnabled()) {
        LOG.debug("curMenuItems: " + curMenuItems);
        LOG.debug("curMenuItemsStr: " + curMenuItemsStr);
    }

    String mergedMenuItemsStr = StringUtilHelper.removeDelimItems(curMenuItemsStr, newMenuItemsStr,
            StringPool.COMMA);
    LOG.debug("mergedMenuItemsStr: " + mergedMenuItemsStr);

    System.setProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT, mergedMenuItemsStr);
    LOG.info(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT + ": "
            + System.getProperty(HookSysPropsKeys.LIFERAY_DL_FOLDER_ACTIONS_MENU_EXT));
}

From source file:au.com.permeance.liferay.portlet.util.StringUtilHelper.java

License:Open Source License

public static String addDelimItems(String str, String delimItems) {
    return addDelimItems(str, delimItems, StringPool.COMMA);
}

From source file:au.com.permeance.liferay.portlet.util.StringUtilHelper.java

License:Open Source License

public static String addArrayItems(String str, String[] items) {
    return addArrayItems(str, items, StringPool.COMMA);
}

From source file:au.com.permeance.liferay.portlet.util.StringUtilHelper.java

License:Open Source License

public static String removeDelimItems(String str, String delimItems) {
    return removeDelimItems(str, delimItems, StringPool.COMMA);
}

From source file:au.com.permeance.liferay.portlet.util.StringUtilHelper.java

License:Open Source License

public static String removeArrayItems(String str, String[] items) {
    return removeArrayItems(str, items, StringPool.COMMA);
}

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();
    }//from w  w  w.j  a va  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) {
        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: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();
    }/*from  ww  w .  j  a v a  2  s .  co  m*/

    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();
    }//from  w  w  w . j  a va 2  s.com

    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;
}

From source file:ch.inofix.referencemanager.model.impl.ReferenceImpl.java

License:Open Source License

private String getNameFormatted(String[] nameParts) {

    // names[0] = first;
    // names[1] = von;
    // names[2] = last;
    // names[3] = jr;

    StringBuilder sb = new StringBuilder();

    if (Validator.isNotNull(nameParts[2])) {
        sb.append(nameParts[2]);/* w w  w .  j av a  2s  .  c o  m*/
    }

    if (Validator.isNotNull(nameParts[0])) {

        sb.append(StringPool.COMMA);
        sb.append(StringPool.SPACE);
        sb.append(nameParts[0].trim().substring(0, 1));
        sb.append(StringPool.PERIOD);

        if (Validator.isNotNull(nameParts[1])) {
            sb.append(StringPool.SPACE);
            sb.append(nameParts[1]);
        }
    }

    if (Validator.isNotNull(nameParts[3])) {
        // TODO: how do we handle the jr part?
        // sb.append(nameParts[3]);
    }

    return sb.toString();

}