List of usage examples for java.lang Integer longValue
public long longValue()
From source file:org.kafka.event.microaggregator.dao.CounterDetailsDAOCassandraImpl.java
private long iterateAndFindSum(String key) { Integer columns = null; try {//from w w w . ja va 2 s. c o m columns = getKeyspace().prepareQuery(microAggregator).setConsistencyLevel(DEFAULT_CONSISTENCY_LEVEL) .getKey(key).getCount().execute().getResult(); } catch (ConnectionException e) { logger.error("Exception:" + e); } return columns.longValue(); }
From source file:org.egov.egf.web.actions.budget.BaseBudgetDetailAction.java
protected Position getPositionByUserId(final Integer userId) { return eisCommonService.getPositionByUserId(userId.longValue()); }
From source file:org.betaconceptframework.astroboa.engine.jcr.util.PopulateComplexCmsProperty.java
private void populateComplexChildProperty(String childPropertyName, ComplexCmsPropertyDefinition childPropertyDefinition) throws Exception { //Retrieve all complex child properties List<CmsProperty<?, ?>> childComplexProperties = new ArrayList<CmsProperty<?, ?>>(); boolean childComplexCmsPropertyLoaded = false; if (((ComplexCmsPropertyImpl) complexProperty).cmsPropertyHasBeenLoadedAndRemoved(childPropertyName)) { childComplexCmsPropertyLoaded = true; } else if (childPropertyDefinition.isMultiple()) { List<CmsProperty<?, ?>> childPropertyList = complexProperty.getChildPropertyList(childPropertyName); //A not null list specifies that child complex cms property has been loaded if (childPropertyList != null) { childComplexCmsPropertyLoaded = true; if (CollectionUtils.isNotEmpty(childPropertyList)) { childComplexProperties.addAll(childPropertyList); }//from w ww .jav a 2s. c o m } } else { CmsProperty<?, ?> childProperty = complexProperty.getChildProperty(childPropertyName); if (childProperty != null) { childComplexCmsPropertyLoaded = true; childComplexProperties.add(childProperty); } } Map<String, Node> existingChildComplexNodes = retrieveExistingChildComplexNodesWithPath(childPropertyName); Map<Node, Integer> indicesForNodesToBePersisted = new HashMap<Node, Integer>(); if (CollectionUtils.isNotEmpty(childComplexProperties)) { for (CmsProperty<?, ?> childComplexContentObjectProperty : childComplexProperties) { String childComplexContentObjectPropertyId = childComplexContentObjectProperty.getId(); Node childComplexPropertyNode = null; //Complex Cms Property is considered new if no id is found or //an id is provided but not found here if (StringUtils.isBlank(childComplexContentObjectPropertyId)) { //Special case //if complex child property is single valued, user did not provide any id //and there is one node already existing (that is an update is taking place //use that node in order to update it and do not create a new one. This way //no node removal will take place if (!childPropertyDefinition.isMultiple() && existingChildComplexNodes.size() == 1) { childComplexContentObjectPropertyId = existingChildComplexNodes.keySet().iterator().next(); childComplexPropertyNode = existingChildComplexNodes .get(childComplexContentObjectPropertyId); childComplexContentObjectProperty.setId(childComplexContentObjectPropertyId); ((LazyCmsProperty) childComplexContentObjectProperty) .setPropertyContainerNodeUUID(childComplexPropertyNode.getIdentifier()); ((LazyCmsProperty) childComplexContentObjectProperty) .setContentObjectNodeUUID(contentObjectNodeUUID); } else { childComplexPropertyNode = createNewNodeForChildComplexCmsProperty(childPropertyName, childPropertyDefinition, existingChildComplexNodes, childComplexContentObjectProperty, false); } } else { childComplexPropertyNode = existingChildComplexNodes.get(childComplexContentObjectPropertyId); if (childComplexPropertyNode == null) { //It may a complex cms property with provided id childComplexPropertyNode = createNewNodeForChildComplexCmsProperty(childPropertyName, childPropertyDefinition, existingChildComplexNodes, childComplexContentObjectProperty, true); if (childComplexPropertyNode == null) { throw new CmsException("Complex content object property " + childComplexContentObjectProperty.getFullPath() + " does not exist in repository"); } } } //Create a new PopulateTask PopulateComplexCmsProperty childComplexCmsPropertyPopulateTask = populateChildComplexCmsProperty( childPropertyDefinition, (ComplexCmsProperty) childComplexContentObjectProperty, childComplexPropertyNode); //In case child property has no child on its own saved, node must be removed as well String childComplexPropertyNodeIdentifier = context.getCmsRepositoryEntityUtils() .getCmsIdentifier(childComplexPropertyNode); //If no child has been saved remove it if (!childComplexCmsPropertyPopulateTask.atLeastOneChildPropertySaved()) { existingChildComplexNodes.put(childComplexPropertyNodeIdentifier, childComplexPropertyNode); childComplexContentObjectProperty.setId(null); if (childComplexContentObjectProperty instanceof LazyCmsProperty) { ((LazyCmsProperty) childComplexContentObjectProperty).setPropertyContainerNodeUUID(null); } //Tree may contain empty nodes and properties but there are some exception messages //Keep them if child is mandatory if (complexPropertyDefinition.isMandatory() && CollectionUtils.isNotEmpty( childComplexCmsPropertyPopulateTask.getExceptionsForMandatoryProperties())) { this.exceptionsForMandatoryProperties .addAll(childComplexCmsPropertyPopulateTask.getExceptionsForMandatoryProperties()); } } else { //Remove from cache so that this node will not be deleted if (StringUtils.isNotBlank(childComplexContentObjectPropertyId)) { existingChildComplexNodes.remove(childComplexContentObjectPropertyId); } if (childComplexContentObjectProperty instanceof CmsPropertyIndexable) { indicesForNodesToBePersisted.put(childComplexPropertyNode, ((CmsPropertyIndexable) childComplexContentObjectProperty).getIndex()); //Index is zero based } } } } //Remove all nodes that had not been found only if properties have been loaded if (!existingChildComplexNodes.isEmpty() && childComplexCmsPropertyLoaded) { removeNodesThatCorrespondToUnmatchComplexCmsProperties(existingChildComplexNodes, childPropertyDefinition); } //only meaningful for multi valued complex properties where we want to keep insertion order if (!indicesForNodesToBePersisted.isEmpty() && indicesForNodesToBePersisted.size() > 1) { for (Entry<Node, Integer> indexPerNode : indicesForNodesToBePersisted.entrySet()) { Node childNode = indexPerNode.getKey(); Integer newIndex = indexPerNode.getValue(); childNode.setProperty(CmsBuiltInItem.Order.getJcrName(), newIndex.longValue()); } } }
From source file:com.ewcms.component.query.dao.QueryDAO.java
@Override public List<Article> findArtilce(String title, Integer channelId, String beginDate, String endDate, Boolean isContent) {/*w w w . ja va2 s . co m*/ Boolean isIf = false; String sql = "Select r.id, a.title, a.author, a.published, a.url, s.name From content_article_main As r Left Join site_channel As s On r.channel_id = s.id Left Join content_article As a On r.article_id = a.id Left Join content_content As c On a.id=c.article_id Where @isIf@ And a.status='RELEASE' "; List<Object> params = new ArrayList<Object>(); if (title != null && !title.trim().equals("")) { isIf = true; sql += " And a.title Like ? "; params.add("%" + title + "%"); } if (isContent != null && isContent) { isIf = true; sql += " And c.detail Like ? "; params.add("%" + title + "%"); } if (channelId != null && channelId.longValue() > 0) { isIf = true; sql += " And s.id=? "; params.add(channelId); } if (beginDate != null && !beginDate.trim().equals("")) { Date _beginDate; try { _beginDate = DATE_FORMAT.parse(beginDate); sql += " And a.published >= ?"; isIf = true; params.add(_beginDate); } catch (ParseException e) { e.printStackTrace(); } } if (endDate != null && !endDate.trim().equals("")) { try { Date _endDate = DATE_FORMAT.parse(endDate); sql += " And a.published <= ? "; isIf = true; params.add(_endDate); } catch (ParseException e) { e.printStackTrace(); } } if (isIf) { sql = sql.replace("@isIf@", "1=1"); } else { sql = sql.replace("@isIf@", "1<>1"); } sql += " Order By a.published Desc"; return jdbcTemplate.query(sql, params.toArray(), new RowMapper<Article>() { @Override public Article mapRow(ResultSet rs, int rowNum) throws SQLException { return articleRowMapper(rs); } }); }
From source file:su.vistar.drivers.web.api.DriversController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public @ResponseBody List<DriverDTO> getDriversList( @RequestParam(value = "query", required = false) String query, @RequestParam(value = "limit", required = false) Integer limit) { logger.info("? ?? "); Stream<Driver> stream = driversService.getDriversList().stream(); if (query != null) { String[] parts = query.toLowerCase().split(" "); stream = stream.filter((_d) -> { String lowerName = _d.getName().toLowerCase(), lowerSurname = _d.getSurname().toLowerCase(), lowerPatronimyc = _d.getPatronimyc().toLowerCase(); int score = 0; for (String part : parts) { if (lowerName.contains(part) || lowerSurname.contains(part) || lowerPatronimyc.contains(part)) score++;//from w ww .j a v a 2 s. c o m } return score >= parts.length; }); } if (limit != null) { stream = stream.limit(limit.longValue()); } return stream.map(_d -> new DriverDTO(_d)).collect(Collectors.toList()); }
From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.MapConfigServiceBean.java
private VisibilitySettingsDto getVisibilitySettings(ConfigurationDto configurationDto, Integer reportId) throws ServiceException { if (reportId != null) { ReportConnectSpatialEntity entity = repository.findReportConnectSpatialByReportId(reportId.longValue()); if (entity != null && entity.getVisibilitySettings() != null) { VisibilitySettingsDto visibilitySettingsDto = MapConfigHelper .getVisibilitySettings(entity.getVisibilitySettings()); if (MapConfigHelper.isVisibilitySettingsOverriddenByReport(visibilitySettingsDto)) { return visibilitySettingsDto; // VisibilitySettings is overridden by Report. Return the report configured visibility settings }//from w ww . j ava 2 s. c o m } } return configurationDto.getVisibilitySettings(); // Return merged visibility settings from Admin and User Config }
From source file:org.mifosplatform.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
@Override public PreviewCampaignMessage previewMessage(final JsonQuery query) { PreviewCampaignMessage campaignMessage = null; final AppUser currentUser = this.context.authenticatedUser(); this.emailCampaignValidator.validatePreviewMessage(query.json()); final String emailParams = this.fromJsonHelper.extractStringNamed("paramValue", query.parsedJson()); final String textMessageTemplate = this.fromJsonHelper.extractStringNamed("emailMessage", query.parsedJson());// w w w . ja va 2 s .c o m final Long campaignId = this.fromJsonHelper.extractLongNamed("campaignId", query.parsedJson()); EmailCampaign emailCampaign = null; HashMap<String, String> reportStretchyParams = null; if (campaignId != null) { emailCampaign = this.emailCampaignRepository.findOne(campaignId); reportStretchyParams = this.validateStretchyReportParamMap(emailCampaign.getStretchyReportParamMap()); } try { HashMap<String, String> campaignParams = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String, String>>() { }); HashMap<String, String> queryParamForRunReport = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String, String>>() { }); List<HashMap<String, Object>> runReportObject = this .getRunReportByServiceImpl(campaignParams.get("reportName"), queryParamForRunReport); // preview attachment report params if (runReportObject != null) { for (HashMap<String, Object> entry : runReportObject) { // add string object to campaignParam object String textMessage = this.compileEmailTemplate(textMessageTemplate, "EmailCampaign", entry); if (!textMessage.isEmpty()) { final Integer totalMessage = runReportObject.size(); String reportStretchyParam = null; Object var = "id"; Integer clientId = (Integer) entry.get(var); final Client client = this.clientRepository.findOne(clientId.longValue()); if (reportStretchyParams != null) { HashMap<String, String> reportParams = this .replaceStretchyParamsWithActualClientParams(reportStretchyParams, client); this.replaceStretchyParamsWithActualLoansOrSavingsParam(reportStretchyParams, client); // add loans or savings id to report params only one object if (reportParams != null) { reportStretchyParam = reportParams.toString(); } } campaignMessage = new PreviewCampaignMessage(textMessage, totalMessage, reportStretchyParam); break; } } } } catch (final IOException e) { // TODO throw something here } return campaignMessage; }
From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.MapConfigServiceBean.java
private VectorStylesDto getVectorStyles(ConfigurationDto configurationDto, Integer reportId) throws ServiceException { if (reportId != null) { ReportConnectSpatialEntity entity = repository.findReportConnectSpatialByReportId(reportId.longValue()); if (entity != null && entity.getStyleSettings() != null) { StyleSettingsDto styleSettingsDto = MapConfigHelper.getStyleSettings(entity.getStyleSettings()); if ((styleSettingsDto.getPositions() != null && styleSettingsDto.getPositions().getStyle() != null) || (styleSettingsDto.getSegments() != null && styleSettingsDto.getSegments().getStyle() != null) || (styleSettingsDto.getAlarms() != null)) { return MapConfigMapper.INSTANCE.getStyleDtos(styleSettingsDto); // Style Settings is overridden by Report. Return the report configured style settings }//w ww . j a v a 2 s .c o m } } return MapConfigMapper.INSTANCE.getStyleDtos(configurationDto.getStylesSettings()); // Return merged style settings from Admin and User config }
From source file:net.sf.sze.model.zeugnis.Zeugnis.java
/** * Wandelt die Anzahl an Tage in Textform. * @param day die Anzahl an Tage./*from w ww . j a va2 s. co m*/ * @return die Anzahl an Tage in Textform. */ private String dayToString(final Integer day) { if (day == null || day.intValue() == 0) { return VariableUtility.PLATZHALTER_LEER; } else if (day.longValue() == 1) { return "1 Tag"; } else { return day + " Tage"; } }
From source file:org.mifos.framework.ApplicationInitializer.java
@SuppressWarnings("unused") private void applyMifos5632() throws PersistenceException { Session session = StaticHibernateUtil.getSessionTL(); @SuppressWarnings("unused") Query lookup_value_query, lookup_value_locale_query, activity_query, roles_activity_query, min_activity_id, question_activity;//from w w w . j a va 2s .c o m Query count_query = session.createSQLQuery("select max(id) from question_group where activity_id is null;"); Integer count = (Integer) count_query.uniqueResult(); Long iterator = count.longValue() + 1; min_activity_id = session.createSQLQuery("select min(activity_id) from activity;"); Integer activity_id = ((Short) min_activity_id.uniqueResult()).intValue(); if (activity_id == 1) { activity_id = activity_id - 2; } StaticHibernateUtil.clearSession(); logger.info("Started Mifos-5632"); while (iterator > 0) { try { StaticHibernateUtil.startTransaction(); iterator--; activity_id--; lookup_value_query = session .createSQLQuery("insert into lookup_value(lookup_id,entity_id,lookup_name) " + "values((select max(lv.lookup_id)+1 from lookup_value lv), 87," + "concat(concat('QuestionGroup.',(select title from question_group where id=" + iterator + ")),'" + iterator + "'))"); lookup_value_query.executeUpdate(); lookup_value_locale_query = session .createSQLQuery("insert into lookup_value_locale(locale_id,lookup_id,lookup_value) values" + "(1,(select lookup_id from lookup_value where entity_id =87 and " + "lookup_name=concat(concat('QuestionGroup.',(select title from question_group where id=" + iterator + ")),'" + iterator + "')),concat('Can edit ', (select title from question_group where id=" + iterator + ")))"); lookup_value_locale_query.executeUpdate(); activity_query = session.createSQLQuery( "insert into activity(activity_id,parent_id, activity_name_lookup_id, DESCRIPTION_lookup_id)" + "values(" + activity_id + ",294,(select lookup_id from lookup_value where entity_id =87 and " + "lookup_name=concat(concat('QuestionGroup.',(select title from question_group where id=" + iterator + ")),'" + iterator + "'))," + "(select lookup_id from lookup_value where entity_id =87 and " + "lookup_name=concat(concat('QuestionGroup.',(select title from question_group where id=" + iterator + ")),'" + iterator + "')))"); activity_query.executeUpdate(); question_activity = session.createSQLQuery( "update question_group set activity_id =" + activity_id + " where id = " + iterator); question_activity.executeUpdate(); roles_activity_query = session.createSQLQuery( "insert into roles_activity(activity_id, role_id) values(" + activity_id + ", 1)"); roles_activity_query.executeUpdate(); StaticHibernateUtil.commitTransaction(); } catch (Exception e) { logger.info("Failed add permission for existing Question groups"); StaticHibernateUtil.rollbackTransaction(); } finally { StaticHibernateUtil.clearSession(); } } logger.info("Success, permission has been added."); }