List of usage examples for com.liferay.portal.kernel.util StringPool COMMA
String COMMA
To view the source code for com.liferay.portal.kernel.util StringPool COMMA.
Click Source Link
From source file:com.liferay.gs.hack.service.persistence.impl.TimesheetPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Timesheet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w . j a v a2 s. c o m Map<Serializable, Timesheet> map = new HashMap<Serializable, Timesheet>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Timesheet timesheet = fetchByPrimaryKey(primaryKey); if (timesheet != null) { map.put(primaryKey, timesheet); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TimesheetModelImpl.ENTITY_CACHE_ENABLED, TimesheetImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Timesheet) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TIMESHEET_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 (Timesheet timesheet : (List<Timesheet>) q.list()) { map.put(timesheet.getPrimaryKeyObj(), timesheet); cacheResult(timesheet); uncachedPrimaryKeys.remove(timesheet.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TimesheetModelImpl.ENTITY_CACHE_ENABLED, TimesheetImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.gs.hack.service.persistence.TimesheetTaskDurationPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(15); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("timesheetTaskDurationId"); sb.append(StringPool.EQUAL);/*from www . jav a 2s .c o m*/ sb.append(timesheetTaskDurationId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("timesheetId"); sb.append(StringPool.EQUAL); sb.append(timesheetId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("timesheetTaskId"); sb.append(StringPool.EQUAL); sb.append(timesheetTaskId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.liferay.gs.hack.service.persistence.TimesheetTaskPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(15); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("timesheetTaskId"); sb.append(StringPool.EQUAL);// www . jav a2 s . com sb.append(timesheetTaskId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("timesheetId"); sb.append(StringPool.EQUAL); sb.append(timesheetId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("projectTaskId"); sb.append(StringPool.EQUAL); sb.append(projectTaskId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.liferay.ide.utils.library.listener.service.persistence.impl.LibraryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Library> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww. ja v a2 s.c om*/ Map<Serializable, Library> map = new HashMap<Serializable, Library>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Library library = fetchByPrimaryKey(primaryKey); if (library != null) { map.put(primaryKey, library); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(LibraryModelImpl.ENTITY_CACHE_ENABLED, LibraryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Library) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_LIBRARY_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 (Library library : (List<Library>) q.list()) { map.put(library.getPrimaryKeyObj(), library); cacheResult(library); uncachedPrimaryKeys.remove(library.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(LibraryModelImpl.ENTITY_CACHE_ENABLED, LibraryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.ide.utils.library.listener.service.persistence.impl.RepositoryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Repository> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w ww. j a v a2 s . co m*/ Map<Serializable, Repository> map = new HashMap<Serializable, Repository>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Repository repository = fetchByPrimaryKey(primaryKey); if (repository != null) { map.put(primaryKey, repository); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED, RepositoryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Repository) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_REPOSITORY_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 (Repository repository : (List<Repository>) q.list()) { map.put(repository.getPrimaryKeyObj(), repository); cacheResult(repository); uncachedPrimaryKeys.remove(repository.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED, RepositoryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.image.editor.hook.action.ActionUtil.java
License:Open Source License
public static File getImageFromBlob(String blob, String formatName) throws Exception { blob = blob.substring(blob.indexOf(StringPool.COMMA) + 1); byte[] decodedBytes = Base64.decode(blob); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decodedBytes); ImageInputStream imageInputStream = ImageIO.createImageInputStream(byteArrayInputStream); Iterator<?> readerIterator = ImageIO.getImageReadersByFormatName(formatName); ImageReader reader = (ImageReader) readerIterator.next(); reader.setInput(imageInputStream, true); ImageReadParam defaultReadParam = reader.getDefaultReadParam(); BufferedImage bufferedImage = reader.read(0, defaultReadParam); File imageFile = FileUtil.createTempFile(); ImageIO.write(bufferedImage, formatName, imageFile); return imageFile; }
From source file:com.liferay.invitation.invite.members.service.persistence.impl.MemberRequestPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, MemberRequest> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w w w. j a v a 2s .com Map<Serializable, MemberRequest> map = new HashMap<Serializable, MemberRequest>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MemberRequest memberRequest = fetchByPrimaryKey(primaryKey); if (memberRequest != null) { map.put(primaryKey, memberRequest); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (MemberRequest) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MEMBERREQUEST_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 (MemberRequest memberRequest : (List<MemberRequest>) q.list()) { map.put(memberRequest.getPrimaryKeyObj(), memberRequest); cacheResult(memberRequest); uncachedPrimaryKeys.remove(memberRequest.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.jbpm.util.TaskFormElement.java
License:Open Source License
public TaskFormElement(VariableAccess variableAccess, String value) { _variableName = variableAccess.getVariableName(); String[] dataElements = StringUtil.split(_variableName, StringPool.COLON); _type = dataElements[0];//from w w w .ja v a2s. c om _displayName = dataElements[1]; if (_type.equals(TYPE_CHECKBOX) || _type.equals(TYPE_RADIO) || _type.equals(TYPE_SELECT)) { String[] values = StringUtil.split(dataElements[2], StringPool.COMMA); for (int i = 0; i < values.length; i++) { _valueList.add(values[i]); } } _value = value; _readable = variableAccess.isReadable(); _writable = variableAccess.isWritable(); _required = variableAccess.isRequired(); }
From source file:com.liferay.jira.metrics.util.graph.GraphData.java
License:Open Source License
public String getGraphSeriesStyles() { if (_series != null) { StringBundler sb = new StringBundler(19); sb.append(StringPool.BLANK);//from w w w . j a va2 s .c o m for (int i = 0; i < _series.size(); i++) { String serie = _series.get(i); concatObjectOpener(sb, serie); concatObjectOpener(sb, "area"); concatQuotedAttribute(sb, "color", _BACKGROUND_COLORS[i]); concatCloseAndContinue(sb); concatObjectOpener(sb, "marker"); concatObjectOpener(sb, "fill"); concatQuotedAttribute(sb, "color", _BACKGROUND_COLORS[i]); concatCloseAndContinue(sb); concatObjectOpener(sb, "border"); concatQuotedAttribute(sb, "color", _LINES_COLORS[i]); concatCloseAndContinue(sb); concatObjectOpener(sb, "over"); concatObjectOpener(sb, "fill"); concatQuotedAttribute(sb, "color", _LINES_COLORS[i]); concatCloseAndContinue(sb); concatObjectOpener(sb, "border"); concatQuotedAttribute(sb, "color", _LINES_COLORS[i]); concatCloseAndContinue(sb); concatAttributeAndContinue(sb, "width", "12"); concatAttribute(sb, "height", "12"); concatCloseAndContinue(sb); concatCloseAndContinue(sb); concatObjectOpener(sb, "line"); concatQuotedAttribute(sb, "color", _LINES_COLORS[i]); sb.append(StringPool.CLOSE_CURLY_BRACE); sb.append(StringPool.CLOSE_CURLY_BRACE); if (i != (_series.size() - 1)) { sb.append(StringPool.COMMA); sb.append(StringPool.NEW_LINE); } } return sb.toString(); } return null; }
From source file:com.liferay.jira.metrics.util.graph.GraphData.java
License:Open Source License
public String getStringData() { if (_data != null) { StringBundler sb = new StringBundler(23); sb.append(StringPool.BLANK);// w w w . j a v a 2 s . c o m for (Date date : _data.keySet()) { String stringDate = _formatter.format(date); if (!StringPool.BLANK.equals(sb.toString())) { sb.append(StringPool.COMMA); sb.append(StringPool.NEW_LINE); } sb.append(StringPool.OPEN_CURLY_BRACE); concatQuotedAttribute(sb, "date", stringDate); for (Values value : _data.get(date)) { sb.append(StringPool.COMMA); concatAttribute(sb, value.getSerieName(), String.valueOf(value.getValue())); } sb.append(StringPool.CLOSE_CURLY_BRACE); } return sb.toString(); } return null; }