List of usage examples for java.lang Long intValue
public int intValue()
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.standalone.ArchiveCopyStandalone.java
/** * For each given archive, create the patient uuid to file associations in both common and disease schemas. * * @param diseaseAbbreviations disease abbreviations for all archives that have successfully been copied to the public location *//*w ww . jav a 2s . c o m*/ protected void createPatientUUIDFileAssociations(final Map<String, Set<Long>> diseaseAbbreviations) { for (final String diseaseAbbreviation : diseaseAbbreviations.keySet()) { getLogger().log(Level.INFO, "Adding patient UUID and file id relationships for disease " + diseaseAbbreviation + " ..."); DiseaseContextHolder.setDisease(diseaseAbbreviation); // Get the files for each archive for (final Long archiveId : diseaseAbbreviations.get(diseaseAbbreviation)) { getLogger().log(Level.INFO, "Adding patient UUID and file id relationships for archive " + archiveId + " ..."); final FileInfoQueryRequest fileInfoQueryRequest = new FileInfoQueryRequest(); fileInfoQueryRequest.setArchiveId(archiveId.intValue()); final Collection<FileInfo> allFiles = getDccCommonFileInfoQueries() .getFilesForArchive(fileInfoQueryRequest); final Collection<FileInfo> bcrXMLFiles = filterXMLFiles(allFiles); final List<Object[]> patientUUIDData = new ArrayList<Object[]>(); for (final FileInfo fileInfo : bcrXMLFiles) { final String fileLocation = getDeployLocation(fileInfo.getFileLocation()); getLogger().log(Level.INFO, "Adding patient UUID and file id relationships for file " + new File(fileLocation).getPath() + " ..."); try { final File file = new File(fileLocation); final String patientUUID = getBcrIdProcessor().getPatientUUIDfromFile(file); if (StringUtils.isBlank(patientUUID)) { getLogger().log(Level.ERROR, "Error reading " + fileLocation + ". Patient uuid is null/empty. Archive id [" + archiveId + "," + fileInfo.getId() + "] file id relationship will not be added into the db"); } else { getLogger().log(Level.INFO, "Adding patient UUID [ " + patientUUID + "] file id [" + fileInfo.getId() + "] ..."); final Object[] data = new Object[4]; data[0] = patientUUID; data[1] = fileInfo.getId(); data[2] = patientUUID; // doing it twice because the query needs it data[3] = fileInfo.getId(); patientUUIDData.add(data); } } catch (final Exception e) { getLogger().log(Level.ERROR, "Error reading " + fileLocation + ". Archive id [" + archiveId + "," + fileInfo.getId() + "] file id relationship will not be added into the db: " + e.toString()); } } if (!isDryRun()) { getDiseaseUUIDQueries().addParticipantFileUUIDAssociation(patientUUIDData); getDccCommonUUIDQueries().addParticipantFileUUIDAssociation(patientUUIDData); } } } }
From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.AuditReportPPTData.java
/** * Add pie chart by profile//ww w . ja v a 2 s. c o m * * @param slideToSet slide to modify * @param where place to add shape * @throws IOException if error */ public void setProfilePieChart(Slide slideToSet, Rectangle where) throws IOException { log.info("AuditReturn - setProfilePieChart"); // Build volumetry map by profile HashMap profileVolMap = new HashMap(); for (int i = 0; i < projectReports.size(); i++) { log.info("AuditReturn - setProfilePieChart Project n" + i); ProjectReportDTO curProject = (ProjectReportDTO) projectReports.get(i); String profileName = curProject.getProfileName(); Long nbLinesByProfile = (Long) profileVolMap.get(profileName); if (nbLinesByProfile == null) { nbLinesByProfile = new Long(0); } profileVolMap.put(profileName, new Long(curProject.getNbLines() + nbLinesByProfile.intValue())); } // Create profilePieChart PieChartMaker pieMaker = new PieChartMaker(null, null, null); pieMaker.setValues(profileVolMap); JFreeChart pieChart = pieMaker.getChart(new HashMap(), request); // Image of pieChart addJFreeChart(slideToSet, pieChart, where); log.info("AuditReturn - setProfilePieChart done"); }
From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.AuditReportPPTData.java
/** * Add pie chart for the application/*from w ww. j av a 2s .c om*/ * * @param slideToSet slide to modify * @param where place to add shape * @throws IOException if error */ public void setPieChart(Slide slideToSet, Rectangle where) throws IOException { log.info("AuditReturn - setPieChart"); // Build volumetry map HashMap volMap = new HashMap(); for (int i = 0; i < projectReports.size(); i++) { log.info("AuditReturn - setPieChart Project n" + i); ProjectReportDTO curProject = (ProjectReportDTO) projectReports.get(i); Long nbLinesByProfile = (Long) volMap.get(curProject.getName()); if (nbLinesByProfile == null) { nbLinesByProfile = new Long(0); } volMap.put(curProject.getName(), new Long(curProject.getNbLines() + nbLinesByProfile.intValue())); } // Create profilePieChart PieChartMaker pieMaker = new PieChartMaker(null, null, null); pieMaker.setValues(volMap); JFreeChart pieChart = pieMaker.getChart(new HashMap(), request); // add graph in slide addJFreeChart(slideToSet, pieChart, where); log.info("AuditReturn - setPieChart done"); }
From source file:com.entertailion.java.caster.RampClient.java
public void onMessage(String message) { Log.d(LOG_TAG, "onMessage: message" + message); // http://code.google.com/p/json-simple/ JSONParser parser = new JSONParser(); try {/*from ww w . j a v a 2s. c o m*/ Object obj = parser.parse(new StringReader(message)); JSONArray array = (JSONArray) obj; if (array.get(0).equals(PROTOCOL_CM)) { Log.d(LOG_TAG, PROTOCOL_CM); JSONObject body = (JSONObject) array.get(1); // ["cm",{"type":"ping"}] if (body.get(TYPE).equals(PING)) { rampWebSocketClient.send("[\"cm\",{\"type\":\"pong\"}]"); } } else if (array.get(0).equals(PROTOCOL_RAMP)) { // ["ramp",{"cmd_id":0,"type":"STATUS","status":{"event_sequence":2,"state":0}}] Log.d(LOG_TAG, PROTOCOL_RAMP); JSONObject body = (JSONObject) array.get(1); if (body.get(TYPE).equals(STATUS)) { // Long cmd_id = (Long)body.get("cmd_id"); // commandId = cmd_id.intValue(); if (!gotStatus) { gotStatus = true; // rampWebSocketClient.send("[\"ramp\",{\"type\":\"LOAD\",\"cmd_id\":"+commandId+",\"autoplay\":true}] "); // commandId++; } } else if (body.get(TYPE).equals(RESPONSE)) { // ["ramp",{"cmd_id":7,"type":"RESPONSE","status":{"event_sequence":38,"state":2,"content_id":"http://192.168.0.50:8080/video.mp4","current_time":6.465110778808594, // "duration":27.37066650390625,"volume":1,"muted":false,"time_progress":true,"title":"Video"}}] JSONObject status = (JSONObject) body.get(RESPONSE_STATUS); if (status.get(RESPONSE_CURRENT_TIME) instanceof Double) { Double current_time = (Double) status.get(RESPONSE_CURRENT_TIME); if (current_time != null) { if (playbackListener != null) { playbackListener.updateTime(playback, current_time.intValue()); } } } else { Long current_time = (Long) status.get(RESPONSE_CURRENT_TIME); if (current_time != null) { if (playbackListener != null) { playbackListener.updateTime(playback, current_time.intValue()); } } } if (status.get(RESPONSE_DURATION) instanceof Double) { Double duration = (Double) status.get(RESPONSE_DURATION); if (duration != null) { if (playbackListener != null) { playbackListener.updateDuration(playback, duration.intValue()); } } } else { Long duration = (Long) status.get(RESPONSE_DURATION); if (duration != null) { if (playbackListener != null) { playbackListener.updateDuration(playback, duration.intValue()); } } } Long state = (Long) status.get(RESPONSE_STATE); if (playbackListener != null) { playbackListener.updateState(playback, state.intValue()); } } } else if (array.get(0).equals(PROTOCOL_CV)) { // ChromeCast default // receiver events Log.d(LOG_TAG, PROTOCOL_CV); JSONObject body = (JSONObject) array.get(1); if (body.get(TYPE).equals(ACTIVITY)) { // ["cv",{"type":"activity","message":{"type":"timeupdate","activityId":"d82cede3-ec23-4f73-8abc-343dd9ca6dbb","state":{"mediaUrl":"http://192.168.0.50:8087/cast.webm","videoUrl":"http://192.168.0.50:8087/cast.webm", // "currentTime":20.985000610351562,"duration":null,"pause":false,"muted":false,"volume":1,"paused":false}}}] JSONObject activityMessage = (JSONObject) body.get(ACTIVITY_MESSAGE); if (activityMessage != null) { JSONObject activityMessageType = (JSONObject) activityMessage.get(TYPE); if (activityMessageType.equals(ACTIVITY_TIME_UPDATE)) { JSONObject activityMessageTypeState = (JSONObject) activityMessage.get(ACTIVITY_STATE); if (activityMessageTypeState.get(RESPONSE_CURRENT_TIME) instanceof Double) { Double current_time = (Double) activityMessageTypeState.get(ACTIVITY_CURRENT_TIME); Double duration = (Double) activityMessageTypeState.get(ACTIVITY_DURATION); if (duration != null) { if (playbackListener != null) { playbackListener.updateDuration(playback, duration.intValue()); } } if (current_time != null) { if (playbackListener != null) { playbackListener.updateTime(playback, current_time.intValue()); } } } else { Long current_time = (Long) activityMessageTypeState.get(ACTIVITY_CURRENT_TIME); Double duration = (Double) activityMessageTypeState.get(ACTIVITY_DURATION); if (duration != null) { if (playbackListener != null) { playbackListener.updateDuration(playback, duration.intValue()); } } if (current_time != null) { if (playbackListener != null) { playbackListener.updateTime(playback, current_time.intValue()); } } } } } } } } catch (Exception e) { Log.e(LOG_TAG, "parse JSON", e); } }
From source file:com.founder.fix.fixflow.service.impl.FlowCenterServiceImpl.java
public Map<String, Object> queryTaskInitiator(Map<String, Object> filter) throws SQLException { Map<String, Object> resultMap = new HashMap<String, Object>(); String userId = StringUtil.getString(filter.get("userId")); ProcessEngine engine = getProcessEngine(userId); RuntimeService runtimeService = engine.getRuntimeService(); IdentityService identityService = engine.getIdentityService(); FlowUtilServiceImpl flowUtil = new FlowUtilServiceImpl(); String processDefinitionKey = StringUtil.getString(filter.get("processDefinitionKey")); String processInstanceId = StringUtil.getString(filter.get("processInstanceId")); String title = StringUtil.getString(filter.get("title")); // String subject = StringUtil.getString(filter.get("subject")); String bizKey = StringUtil.getString(filter.get("bizKey")); String initor = StringUtil.getString(filter.get("initor")); String status = StringUtil.getString(filter.get("status")); String processType = StringUtil.getString(filter.get("processType")); ProcessInstanceType processInstanceStatus = FlowUtilServiceImpl.getInstanceStaus(status); try {// w w w .ja v a 2s.com String pageI = StringUtil.getString(filter.get("pageIndex")); String rowI = StringUtil.getString(filter.get("pageSize")); int pageIndex = 1; int rowNum = 15; if (StringUtil.isNotEmpty(pageI)) { pageIndex = Integer.valueOf(pageI); } if (StringUtil.isNotEmpty(rowI)) { rowNum = Integer.valueOf(rowI); } ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery(); if (StringUtil.isNotEmpty(processDefinitionKey)) processInstanceQuery.processDefinitionKey(processDefinitionKey); if (StringUtil.isNotEmpty(processInstanceId)) processInstanceQuery.processInstanceId(processInstanceId); if (StringUtil.isNotEmpty(title)) processInstanceQuery.subjectLike(title); if (StringUtil.isNotEmpty(bizKey)) processInstanceQuery.processInstanceBusinessKeyLike(bizKey); if (processInstanceStatus != null) { processInstanceQuery.processInstanceStatus(processInstanceStatus); } if (StringUtil.isNotEmpty(initor)) processInstanceQuery.initiator(initor); if (StringUtil.isNotEmpty(processType)) { if (processType.equals("initor")) processInstanceQuery.initiator(userId); else processInstanceQuery.taskParticipants(userId); } String processDefinitionName = StringUtil.getString(filter.get("processDefinitionName")); if (StringUtil.isNotEmpty(processDefinitionName)) processInstanceQuery.processDefinitionNameLike(processDefinitionName); processInstanceQuery.orderByUpdateTime().desc(); Date dates = null; Date datee = null; String dss = StringUtil.getString(filter.get("startTimeS")); String dse = StringUtil.getString(filter.get("startTimeE")); if (StringUtil.isNotEmpty(dss)) { dates = DateUtil.stringToDate(dss, "yyyy-MM-dd"); } if (StringUtil.isNotEmpty(dse)) { String endTime = "235959999"; dse += endTime; datee = DateUtil.stringToDate(dse, "yyyy-MM-ddHHmmssSSS"); } if (dates != null) processInstanceQuery.startTimeBefore(dates); if (datee != null) processInstanceQuery.startTimeAfter(datee); List<ProcessInstance> processInstances = processInstanceQuery.listPagination(pageIndex, rowNum); List<Map<String, Object>> instanceMaps = new ArrayList<Map<String, Object>>(); for (ProcessInstance tmp : processInstances) { Map<String, Object> persistentState = tmp.getPersistentState(); String processDefinitionId = tmp.getProcessDefinitionId(); ProcessDefinitionBehavior processDefinitionBehavior = engine.getModelService() .getProcessDefinition(processDefinitionId); String processDefinitionName1 = processDefinitionBehavior.getName(); persistentState.put("processDefinitionName", processDefinitionName1); String nowNodeInfo = flowUtil.getShareTaskNowNodeInfo(tmp.getId()); persistentState.put("nowNodeInfo", nowNodeInfo); UserTo user = identityService.getUserTo(tmp.getStartAuthor()); if (user != null) { persistentState.put("startAuthorName", user.getUserName()); } else { persistentState.put("startAuthorName", tmp.getStartAuthor()); } instanceMaps.add(persistentState); } Long count = processInstanceQuery.count(); Pagination page = new Pagination(pageIndex, rowNum); page.setTotal(count.intValue()); resultMap.put("dataList", instanceMaps); resultMap.put("pageInfo", page); } finally { closeProcessEngine(); } return resultMap; }
From source file:org.geoserver.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java
public PagingLoadResult<RolenameModel> getRolenames(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<RolenameModel> returnList = new ArrayList<RolenameModel>(); if (full) {/*from w w w .j a v a2 s . co m*/ RolenameModel all_profile = new RolenameModel(); all_profile.setRolename("*"); returnList.add(all_profile); } long profilesCount = geofenceRemoteService.getUserGroupAdminService().getCount(null) + 1; Long t = new Long(profilesCount); int page = (start == 0) ? start : (start / limit); List<ShortGroup> profilesList = geofenceRemoteService.getUserGroupAdminService().getList(null, page, limit); if (profilesList == null) { if (logger.isErrorEnabled()) { logger.error("No profile found on server"); } throw new ApplicationException("No profile found on server"); } Iterator<ShortGroup> it = profilesList.iterator(); while (it.hasNext()) { ShortGroup role = it.next(); RolenameModel local_profile = new RolenameModel(role.getName()); returnList.add(local_profile); } return new RpcPageLoadResult<RolenameModel>(returnList, offset, t.intValue()); }
From source file:org.frontcache.FrontCacheEngine.java
private void addResponseHeaders(RequestContext context) { HttpServletResponse servletResponse = context.getResponse(); Map<String, List<String>> originResponseHeaders = context.getOriginResponseHeaders(); // process redirects if (null != originResponseHeaders.get("Location") && 0 < originResponseHeaders.get("Location").size()) { String originLocation = originResponseHeaders.remove("Location").iterator().next(); String fcLocation = FCUtils.transformRedirectURL(originLocation, context); originResponseHeaders.put("Location", Arrays.asList(new String[] { fcLocation })); }/*from w w w. j av a2s .c o m*/ servletResponse.addHeader(FCHeaders.X_FRONTCACHE_ID, fcHostId); servletResponse.addHeader(FCHeaders.X_FRONTCACHE_REQUEST_ID, context.getRequestId()); if (context.isHystrixFallback()) servletResponse.addHeader(FCHeaders.X_FRONTCACHE_FALLBACK_IS_USED, "true"); servletResponse.setStatus(context.getResponseStatusCode()); if (originResponseHeaders != null) { for (String key : originResponseHeaders.keySet()) { for (String value : originResponseHeaders.get(key)) { servletResponse.addHeader(key, value); } } } Long contentLength = context.getOriginContentLength(); // Only inserts Content-Length if origin provides it and origin response is not // gzipped // if (SET_CONTENT_LENGTH.get()) { if (contentLength != null && !context.getResponseGZipped()) { servletResponse.setContentLength(contentLength.intValue()); } // } }
From source file:classification.SentimentClassification.java
private SentimentSentence defineSentenceLevel(Document doc, Annotation sentenceLevelAnnotation, SentimentObject so, SentimentFeatureType sft, SentimentLevelDefinition sentimentLevelSentence, SentimentClassifierType classifierTypeCrisp, DocumentMetaData docMeta) { /* Extract needed sentence information */ // Start and End Node Long startNode = sentenceLevelAnnotation.getStartNode().getOffset(); Long endNode = sentenceLevelAnnotation.getEndNode().getOffset(); DocumentContent docContent = doc.getContent(); // Text// w ww . j a v a 2 s . c o m String text = docContent.toString().substring(startNode.intValue(), endNode.intValue()); // Polarity Integer sentimentScore = null; String sentimentPolarity = new String(); // Subfeature SentimentFeatureType sentimentSubFeature = null; // Indicator Type IndicatorType inditype = null; String indicatortype = new String(); // Indicator Indicator indicatorConcept = null; String indicatorname = new String(); String indicatorURI = new String(); // Sentiment Indicator SentimentIndicator sentimentIndicator = null; Long indicatorScore = null; int indicatorCorrelation = 0; SentimentSentence currentSentenceLevel = null; // Extract Information only if sentiment polarity of the sentiment is defined if (sentenceLevelAnnotation.getFeatures().containsKey("SentimentPolarity")) { sentimentScore = null; sentimentPolarity = sentenceLevelAnnotation.getFeatures().get("SentimentPolarity").toString(); sentimentScore = scoreSentiment(sentimentPolarity); // Extract Subfeature if (sentenceLevelAnnotation.getFeatures().containsKey("SubFeature")) { String subFeatureName = sentenceLevelAnnotation.getFeatures().get("SubFeature").toString(); log.debug("Feature: \"SubFeature\" in sentenceLevelAnnotation extracted: " + subFeatureName); /* * TODO: Is it possible, that the Name of a Subfeature repeatet twice in * database? yes -> change upDateSentimentFeatureType(subFeatureName) to * the combination of the OntologyURI and the Name */ String subFeatureURI = null; if (sentenceLevelAnnotation.getFeatures().containsKey("SubFeatureURI")) { subFeatureURI = sentenceLevelAnnotation.getFeatures().get("SubFeatureURI").toString(); log.debug("Feature: \"SubFeatureURI\" in sentenceLevelAnnotation extracted: " + subFeatureURI); } // Save Subfeature to the DB sentimentSubFeature = DatabaseFacade.getSingletonFacade().createOrgetSF(subFeatureName, subFeatureURI); } // Extract Indicator Type if (sentenceLevelAnnotation.getFeatures().containsKey("IndicatorType")) { indicatortype = sentenceLevelAnnotation.getFeatures().get("IndicatorType").toString(); inditype = DatabaseFacade.getSingletonFacade().createIndicatorType(indicatortype); } // Extract Indicator if (sentenceLevelAnnotation.getFeatures().containsKey("IndicatorPhrase")) { String indicatorPhraseIDString = sentenceLevelAnnotation.getFeatures().get("IndicatorPhrase") .toString(); Integer indicatorPhraseID = Integer.parseInt(indicatorPhraseIDString); Annotation indiPhraseAnnot = doc.getAnnotations("Indicator").get(indicatorPhraseID); indicatorname = indiPhraseAnnot.getFeatures().get("name").toString(); indicatorURI = indiPhraseAnnot.getFeatures().get("URI").toString(); // -> URI oder INDICATOR CONCEPT URI indicatorConcept = DatabaseFacade.getSingletonFacade().createIndicatorConcept(indicatorname, indicatorURI); } // Extract Sentiment Indicator if (sentenceLevelAnnotation.getFeatures().containsKey("IndicatorCorrelation")) { String indicatorCorrelationString = sentenceLevelAnnotation.getFeatures() .get("IndicatorCorrelation").toString(); // Value of Indicator CorrelationDefinition if (indicatorCorrelationString.equalsIgnoreCase("positive")) { indicatorCorrelation = new Integer(1); } else if (indicatorCorrelationString.equalsIgnoreCase("negative")) { indicatorCorrelation = new Integer(-1); } // Value of Indicator Score if (sentenceLevelAnnotation.getFeatures().containsKey("IndicatorPolarity")) { String indicatorPolarity = sentenceLevelAnnotation.getFeatures().get("IndicatorPolarity") .toString(); log.trace("Selected Annotation 'IndicatorPolarity' " + indicatorPolarity); if (indicatorPolarity.equalsIgnoreCase("positive")) { indicatorScore = new Long(1); } if (indicatorPolarity.equalsIgnoreCase("negative")) { indicatorScore = new Long(-1); } } sentimentIndicator = DatabaseFacade.getSingletonFacade().createOrgetSentimentIndicator( indicatorname, indicatorCorrelation, indicatorScore, inditype, indicatorConcept); } // Create Sentiment Sentence currentSentenceLevel = new SentimentSentence(startNode, endNode, so, sft, sentimentLevelSentence, classifierTypeCrisp, docMeta, sentimentScore, sentimentPolarity, sentimentSubFeature, sentimentIndicator); HibernateConstantEntities constantDBentities = databaseConn.getConstantEntites(); // extract the sentimentsentence text as phrase Phrase sentencePhrase = new Phrase(constantDBentities.getSentencePhraseType(), text, sentimentScore, startNode.intValue(), endNode.intValue()); currentSentenceLevel.setSentencePhrase(sentencePhrase); // extract sentiment phrase if (sentenceLevelAnnotation.getFeatures().containsKey("SentimentPhraseID")) { String sentimentPhraseIdStr = sentenceLevelAnnotation.getFeatures().get("SentimentPhraseID") .toString(); Integer sentimentPhraseID = new Integer(sentimentPhraseIdStr); Annotation sentimentPhraseAnnot = doc.getAnnotations("SentimentPhrase").get(sentimentPhraseID); Phrase sentimentPhrase = extractPhrase(sentimentPhraseAnnot, docContent, "SentimentPolarity", constantDBentities.getSentimentPhraseType()); currentSentenceLevel.setSentimentSentencePhrase(sentimentPhrase); } // extract orientation phrases extractOrientationTermPhrases(doc, sentenceLevelAnnotation, docContent, currentSentenceLevel); /* extract the FeaturePhrase */ if (sentenceLevelAnnotation.getFeatures().containsKey("ObjectFeaturePhrase")) { try { String featurePhraseIDString = sentenceLevelAnnotation.getFeatures().get("ObjectFeaturePhrase") .toString(); Integer featurePhraseID = Integer.parseInt(featurePhraseIDString); Phrase objectFeaturePhrase = extractPhrase(doc.getAnnotations().get(featurePhraseID), docContent, "SentimentPolarity", constantDBentities.getFeaturePhraseType()); currentSentenceLevel.setSentimentFeaturePhrase(objectFeaturePhrase); } catch (NumberFormatException nfex) { log.error("Cannot parse sentimentObjectFeaturePhrase String containing id"); } } // Define direct or indirect String typeSentimetnSentenceDirIndir = null; if (sentenceLevelAnnotation.getFeatures().containsKey("SentimentSentenceDirect")) { // String [direct | indirect] typeSentimetnSentenceDirIndir = sentenceLevelAnnotation.getFeatures().get("SentimentSentenceDirect") .toString(); // only for <result-xml> needed currentSentenceLevel.setSentimentSentenceType(typeSentimetnSentenceDirIndir); /* * * Sentiment of the sentence is direct, the sentiment object is * mentioned directly in the sentence */ if (typeSentimetnSentenceDirIndir.equalsIgnoreCase("direct")) { if (sentenceLevelAnnotation.getFeatures().containsKey("SentimentObjectPhrase")) { String sentObjectFeaturePhraseStringID = sentenceLevelAnnotation.getFeatures() .get("SentimentObjectPhrase").toString(); try { Integer sentObjectPhraseID = Integer.parseInt(sentObjectFeaturePhraseStringID); Annotation sentObjectPhraseAnnot = doc.getAnnotations("Sentiment_Object") .get(sentObjectPhraseID); Phrase sentimentObjectPhrase = extractPhrase( doc.getAnnotations("Sentiment_Object").get(sentObjectPhraseID), docContent, "", constantDBentities.getObjectPhraseType()); currentSentenceLevel.setSentimentObjectPhrase(sentimentObjectPhrase); } catch (NumberFormatException nfex) { log.error("Cannot parse sentimentObjectFeaturePhrase String containing id: " + sentObjectFeaturePhraseStringID); } } } else { /* * Sentiment of the sentence is indirect, the sentimentObject is not * mentioned directly so the sentiment is based/calculated on an * indicator */ if (typeSentimetnSentenceDirIndir.equalsIgnoreCase("indirect")) { /* * * Sentiment of the sentence is indirect, the indicator is * mentioned in the sentence */ if (sentenceLevelAnnotation.getFeatures().containsKey("IndicatorPhrase")) { String indicatorPhraseIDString = sentenceLevelAnnotation.getFeatures() .get("IndicatorPhrase").toString(); Integer indicatorPhraseID = Integer.parseInt(indicatorPhraseIDString); Annotation indiPhraseAnnot = doc.getAnnotations("Indicator").get(indicatorPhraseID); Phrase indicatorPhrase = extractPhrase( doc.getAnnotations("Indicator").get(indicatorPhraseID), docContent, "", constantDBentities.getIndicatorPhraseType()); currentSentenceLevel.setSentimentIndicatorPhrase(indicatorPhrase); } } } } currentSentenceLevel.setAllSentimentPhraseRelations(); //DatabaseFacade.getSingletonFacade().createDBSentimentEntry(currentSentenceLevel.getDbSentenceLevelSentiment(), sentimentSession); } return currentSentenceLevel; }
From source file:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java
@Override @Transactional(readOnly = true)/* w w w . j av a2 s . com*/ public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de entradas con params {}", params); if (params == null) { params = new HashMap<>(); } if (!params.containsKey("max")) { params.put("max", 10); } else { params.put("max", Math.min((Integer) params.get("max"), 100)); } if (params.containsKey("pagina")) { Long pagina = (Long) params.get("pagina"); Long offset = (pagina - 1) * (Integer) params.get("max"); params.put("offset", offset.intValue()); } if (!params.containsKey("offset")) { params.put("offset", 0); } Criteria criteria = currentSession().createCriteria(Entrada.class); Criteria countCriteria = currentSession().createCriteria(Entrada.class); criteria.createAlias("estatus", "est"); countCriteria.createAlias("estatus", "est"); if (params.containsKey("almacen")) { criteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen"))); countCriteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen"))); } if (params.containsKey("proveedorId")) { criteria.createCriteria("proveedor").add(Restrictions.idEq(params.get("proveedorId"))); countCriteria.createCriteria("proveedor").add(Restrictions.idEq(params.get("proveedorId"))); } if (params.containsKey("fechaIniciado")) { log.debug("Buscando desde {}", params.get("fechaIniciado")); criteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado"))); countCriteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado"))); } else { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 1); log.debug("Asignando busqueda desde {}", calendar.getTime()); criteria.add(Restrictions.ge("fechaCreacion", calendar.getTime())); countCriteria.add(Restrictions.ge("fechaCreacion", calendar.getTime())); } if (params.containsKey("fechaTerminado")) { log.debug("Buscando hasta {}", params.get("fechaTerminado")); criteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado"))); countCriteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado"))); } if (params.containsKey(Constantes.ABIERTA) || params.containsKey(Constantes.CERRADA) || params.containsKey(Constantes.PENDIENTE) || params.containsKey(Constantes.FACTURADA) || params.containsKey(Constantes.CANCELADA) || params.containsKey(Constantes.DEVOLUCION)) { Disjunction propiedades = Restrictions.disjunction(); if (params.containsKey(Constantes.ABIERTA)) { propiedades.add(Restrictions.eq("est.nombre", Constantes.ABIERTA)); } if (params.containsKey(Constantes.CERRADA)) { propiedades.add(Restrictions.eq("est.nombre", Constantes.CERRADA)); } if (params.containsKey(Constantes.PENDIENTE)) { propiedades.add(Restrictions.eq("est.nombre", Constantes.PENDIENTE)); } if (params.containsKey(Constantes.FACTURADA)) { propiedades.add(Restrictions.eq("est.nombre", Constantes.FACTURADA)); } if (params.containsKey(Constantes.CANCELADA)) { propiedades.add(Restrictions.eq("est.nombre", Constantes.CANCELADA)); } criteria.add(propiedades); countCriteria.add(propiedades); if (params.containsKey(Constantes.DEVOLUCION)) { criteria.add(Restrictions.eq("devolucion", Boolean.TRUE)); countCriteria.add(Restrictions.eq("devolucion", Boolean.TRUE)); } } if (params.containsKey("filtro")) { String filtro = (String) params.get("filtro"); Disjunction propiedades = Restrictions.disjunction(); propiedades.add(Restrictions.ilike("folio", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("factura", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("comentarios", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { String campo = (String) params.get("order"); if (params.get("sort").equals("desc")) { criteria.addOrder(Order.desc(campo)); } else { criteria.addOrder(Order.asc(campo)); } } else { criteria.addOrder(Order.asc("est.prioridad")); } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("entradas", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); return params; }
From source file:cn.buk.hotel.dao.HotelDaoImpl.java
@Override public List<HotelInfo> searchAvailableHotel(HotelSearchCriteria sc) { List<HotelInfo> hotelInfos = null; try {/*from w ww . j av a2 s .c o m*/ //body CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaQuery<HotelInfo> cq = cb.createQuery(HotelInfo.class); Root<HotelInfo> root = cq.from(HotelInfo.class); root.alias("h"); List<Predicate> predicates = new ArrayList<Predicate>(); Predicate predicate = cb.equal(root.get(HotelInfo_.cityId), sc.getCityId()); predicates.add(predicate); /** * ratePlanStatus-1???) yfddai 2015-1-8 */ predicate = cb.notEqual(root.get(HotelInfo_.ratePlanStatus), -1); predicates.add(predicate); if (sc.getDistrictId() > 0) { predicate = cb.equal(root.get(HotelInfo_.areaId), sc.getDistrictId()); predicates.add(predicate); } if (sc.getHotelName() != null && sc.getHotelName().trim().length() > 0) { predicate = cb.like(root.get(HotelInfo_.hotelName), "%" + sc.getHotelName() + "%"); predicates.add(predicate); } if (sc.getStar() != null && sc.getStar().length() > 0) { Join<HotelInfo, HotelAward> hotelAward = root.join("hotelAwards", JoinType.LEFT); hotelAward.alias("ha"); predicates.add(cb.equal(hotelAward.get("provider"), "HotelStarRate")); String[] stars = sc.getStar().split(","); Predicate p0 = cb.disjunction(); for (String star : stars) { if (star.length() == 0) continue; int starLevel = Integer.parseInt(star); if (starLevel == 2) p0 = cb.or(p0, cb.le(hotelAward.get(HotelAward_.rating), starLevel)); else p0 = cb.or(p0, cb.equal(hotelAward.get("rating"), starLevel)); } predicates.add(p0); } if (sc.getZoneId() > 0) { Join<HotelInfo, HotelAddressZone> hotelZone = root.join(HotelInfo_.hotelAddressZones, JoinType.LEFT); hotelZone.alias("hz"); predicate = cb.equal(hotelZone.get(HotelAddressZone_.zoneCode), sc.getZoneId()); predicates.add(predicate); } // count items CriteriaQuery<Long> cq0 = cb.createQuery(Long.class); Root<HotelInfo> root0 = cq0.from(HotelInfo.class); root0.alias("h"); if (sc.getStar() != null && sc.getStar().length() > 0) { Join<HotelInfo, HotelAward> hotelAward0 = root0.join("hotelAwards", JoinType.LEFT); hotelAward0.alias("ha"); } if (sc.getZoneId() > 0) { Join<HotelInfo, HotelAddressZone> hotelZone0 = root0.join(HotelInfo_.hotelAddressZones, JoinType.LEFT); hotelZone0.alias("hz"); } cq0.select(cb.count(root0)).where(predicates.toArray(new Predicate[0])); Long count = getEm().createQuery(cq0).getSingleResult(); sc.getPage().setRowCount(count.intValue()); int firstPosition = (sc.getPage().getPageNo() - 1) * sc.getPage().getPageSize(); cq.select(root).where(predicates.toArray(new Predicate[0])); hotelInfos = getEm().createQuery(cq).setFirstResult(firstPosition) .setMaxResults(sc.getPage().getPageSize()).getResultList(); } catch (PersistenceException e) { logger.error(e.getMessage()); } return hotelInfos == null ? new ArrayList<HotelInfo>() : hotelInfos; }