List of usage examples for java.lang Long intValue
public int intValue()
From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.java
public Integer getBehindTheWheelTime() throws Exception { List list = (List) getBehindTheWheelList(); Long totalTime = 1L; // Set greater than 0 for (int i = 0; i < list.size(); i++) { CommercialTimes time = (CommercialTimes) list.get(i); Long startTime = time.getStartTime().getTime(); Long endTime = time.getEndTime().getTime(); totalTime = totalTime + (endTime - startTime); }//from w w w. j av a 2 s . c om Long hours = (totalTime / 3600000L); return hours.intValue(); }
From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.java
public Integer getObservationTime() throws Exception { List list = (List) getObservationList(); Long totalTime = 1L; // Set greater than 0 for (int i = 0; i < list.size(); i++) { CommercialTimes time = (CommercialTimes) list.get(i); Long startTime = time.getStartTime().getTime(); Long endTime = time.getEndTime().getTime(); totalTime = totalTime + (endTime - startTime); }/*from w w w . ja v a 2s. com*/ Long hours = (totalTime / 3600000L); return hours.intValue(); }
From source file:es.emergya.bbdd.dao.RoutingHome.java
/** * Devuelve la lista de ids de la ruta desde vertice_origen a * vertice_destino.//from w ww.j a v a 2 s. c o m * * Utiliza la funcion shooting_star * * @param origin * @param goal * @return */ @Transactional(readOnly = true, rollbackFor = Throwable.class) private List<Long> shortest_path_shooting_star(final Long origin, final Long goal) { final List<Long> lista = new ArrayList<Long>(); try { Session currentSession = getSession(); CallableStatement consulta = currentSession.connection() .prepareCall("{call shortest_path_shooting_star(?,?,?,?,?)}"); consulta.setString(1, "SELECT " + id + "::integer as id, " + source + "::integer as source, " + target + "::integer as target, " + cost + " as cost," + reverse_cost + " as reverse_cost, " + "ST_X(ST_StartPoint(" + the_geom + ")) as x1," + "ST_Y(ST_StartPoint(" + the_geom + ")) as y1," + "ST_X(ST_EndPoint(" + the_geom + ")) as x2," + "ST_Y(ST_EndPoint(" + the_geom + ")) as y2," + rule + " as rule, " + to_cost + " as to_cost FROM " + table // + " order by " + id ); consulta.setInt(2, origin.intValue()); consulta.setInt(3, goal.intValue()); consulta.setBoolean(4, true); consulta.setBoolean(5, true); log.trace(consulta); ResultSet resultado = consulta.executeQuery(); while (resultado.next()) lista.add(resultado.getLong("edge_id")); } catch (Exception e) { log.error("No se pudo calcular la ruta", e); } return lista; }
From source file:pl.psnc.synat.wrdz.zmkd.plan.execution.PlanExecutionParserBean.java
/** * Finds all service outcomes./* w ww . j a v a 2 s . c om*/ * * Result can have many optional representation but we assume in our functionality that all representation can have * the same (semantic) type. * * @param serviceMethodNode * node in WADL file where to look for data * @param wadlLocation * location of WADL - prefix for id of WADL nodes * @param wadlOutcomes * mapping of id nodes in WADL file to names of OWL-S outcomes * @param owlsOutcomes * list of all OWL-S outcomes * @return List of potential outcomes * @throws InconsistentServiceDescriptionException * when some missing or ambiguous values between OWL-S and WADL description occur */ private List<ServiceOutcomeInfo> findServiceOutcomes(Method serviceMethodNode, String wadlLocation, Map<String, String> wadlOutcomes, List<ServiceOutcome> owlsOutcomes) throws InconsistentServiceDescriptionException { String prefixId = wadlLocation + "#"; List<ServiceOutcomeInfo> result = new ArrayList<ServiceOutcomeInfo>(); for (Response response : serviceMethodNode.getResponse()) { Set<Integer> statuses = new HashSet<Integer>(); for (Long status : response.getStatus()) { statuses.add(status.intValue()); } for (Param param : response.getParam()) { if (param.getStyle().equals(ParamStyle.HEADER)) { String name = null; if (param.getId() != null) { name = wadlOutcomes.get(prefixId + param.getId()); } if (name == null && param.getName() != null) { name = wadlOutcomes.get(prefixId + param.getName()); } if (name != null) { result.add(parseParamAsHeaderOutcome(param, name, statuses, owlsOutcomes)); } else { if (statuses.contains(new Integer(200))) { logger.debug("There is no mapping in OWL-S grounding for header outcome " + param + ", but it is optional since status code is not 200."); } else { throw new InconsistentServiceDescriptionException( "There is no mapping in OWL-S grounding for header outcome " + param); } } } } String name = null; Representation representation = getFirstResponseRepresentation(response); if (representation != null) { name = wadlOutcomes.get(prefixId + representation.getId()); if (name == null && representation.getParam() != null && representation.getParam().get(0) != null) { name = wadlOutcomes.get(prefixId + representation.getParam().get(0).getId()); } if (name == null) { name = wadlOutcomes.get(prefixId + representation.getParam().get(0).getName()); } if (name != null) { result.add(parseRepresentationsAsBodyOutcome(response.getRepresentation(), name, statuses, owlsOutcomes)); } else { throw new InconsistentServiceDescriptionException( "There is no mapping in OWL-S grounding for " + WadlToStringUtils.toString(representation) + (representation.getParam() != null && representation.getParam().get(0) != null ? " or its parameter " + WadlToStringUtils.toString(representation.getParam().get(0)) : "")); } } } return result; }
From source file:com.oltpbenchmark.benchmarks.auctionmark.util.UserIdGenerator.java
private UserId findNextUserId() { // Find the next id for this size level Long found = null; while (this.currentItemCount <= this.maxItemCount) { while (this.currentOffset > 0) { long nextCtr = this.currentOffset--; this.currentPosition++; // If we weren't given a clientId, then we'll generate UserIds // for all users in a given size level if (this.clientId == null) { found = nextCtr;//from ww w . j a v a 2 s . c om break; } // Otherwise we have to spin through and find one for our client else if (this.currentPosition % this.numClients == this.clientId.intValue()) { found = nextCtr; break; } } // WHILE if (found != null) break; this.currentItemCount++; this.currentOffset = this.usersPerItemCounts[this.currentItemCount]; } // WHILE if (found == null) return (null); return (new UserId((int) this.currentItemCount, found.intValue())); }
From source file:info.jtrac.repository.HibernateJtracDao.java
@Override @Transactional(propagation = Propagation.SUPPORTS) public int loadCountOfHistoryInvolvingUser(User user) { Long count = entityManager .createQuery("select count(history) from History history where " + " history.loggedBy = ? or history.assignedTo = ?", Long.class) .setParameter(1, user).setParameter(2, user).getResultList().get(0); return count.intValue(); }
From source file:com.tesora.dve.sql.schema.PETable.java
private boolean isDuplicateFKSymbol(SchemaContext sc, String symbol) { boolean ret = false; try {//w ww .ja v a2s .c o m Long tenid = sc.getPolicyContext().getTenantID(false); Integer tenantID = (tenid == null ? null : tenid.intValue()); PEKey fKey = sc.findForeignKey(hasDatabase(sc) ? getDatabase(sc) : null, tenantID, null, symbol); if (fKey != null) { PETable t = fKey.getTable(sc); if (t != null && !t.equals(this)) ret = true; } } catch (Exception e) { ret = false; } return ret; }
From source file:com.maestrodev.maestrocontinuumplugin.ContinuumWorker.java
@SuppressWarnings("unchecked") public void build() { try {//www . j a va 2 s . c o m client = getClient(); JSONObject context = getContext(); ProjectSummary project = getProjectSummary(context); String goals = getGoals(); String arguments = getArguments(); String buildFile = getBuildFile(); Profile profile = null; if (isMatchBuildAgents()) { profile = setupBuildAgent(); } Long taskId = getTaskId(); writeOutput("Searching For Build Definition for task ID " + taskId + "\n"); writeOutput("And arguments " + arguments + "\n"); BuildDefinition buildDefinition = null; JSONObject previousContext = (JSONObject) getFields().get(PREVIOUS_CONTEXT_OUTPUTS); Long buildDefinitionId; if (previousContext != null && (buildDefinitionId = (Long) previousContext.get(BUILD_DEFINITION_ID)) != null) { try { buildDefinition = getBuildDefinitionFromId(buildDefinitionId.intValue(), goals, arguments, buildFile, project.getId(), profile); } catch (Exception e) { logger.log(Level.FINE, "Build definition not found by ID, trying project: " + e.getLocalizedMessage(), e); buildDefinition = getBuildDefinitionFromProject(goals, arguments, buildFile, project.getId(), profile); } } if (buildDefinition == null) { buildDefinition = getBuildDefinitionFromProject(goals, arguments, buildFile, project.getId(), profile); } int previousBuildId = project.getLatestBuildId(); writeOutput("Retrieved Build Definition " + buildDefinition.getId() + "\n"); writeOutput("Triggering Build " + goals + "\n"); triggerBuild(project, buildDefinition); writeOutput("The Build Has Started\n"); BuildResult result = waitForBuild(project.getId()); context.put(BUILD_DEFINITION_ID, buildDefinition.getId()); context.put(BUILD_ID, result.getId()); setField(CONTEXT_OUTPUTS, context); if (result.getId() == previousBuildId) { notNeeded(); writeOutput("No SCM changes detected, build not required - previous build was #" + result.getBuildNumber() + "\n"); } else { writeOutput("Completed build #" + result.getBuildNumber() + "\n"); writeOutput(client.getBuildOutput(project.getId(), result.getId())); } addLinkToBuildResult(result); } catch (Exception e) { logger.log(Level.WARNING, e.getLocalizedMessage(), e); setError("Continuum Build Failed: " + e.getMessage()); } }
From source file:classification.SentimentClassification.java
private Phrase extractPhrase(Annotation ann, DocumentContent docContent, String polarityFeature, PhraseType phraseType) {/*w w w . j a va 2 s . c om*/ Phrase phrase = null; Long startNode = ann.getStartNode().getOffset(); Long endNode = ann.getEndNode().getOffset(); String text = null; try { text = docContent.getContent(startNode, endNode).toString(); String sentimentPolarity = null; Integer sentimentScore = null; if (polarityFeature != null) { if (ann.getFeatures().containsKey(polarityFeature)) { sentimentPolarity = ann.getFeatures().get(polarityFeature).toString(); sentimentScore = scoreSentiment(sentimentPolarity); } } phrase = new Phrase(phraseType, text, sentimentScore, startNode.intValue(), endNode.intValue()); } catch (InvalidOffsetException e) { log.error("Cannot extract text from sentimentphrase from sentimentsentence "); } // currentSentenceLevel = extractSentimentPhrase(doc, currentSentenceLevel, // sentimentPhraseID); return phrase; }
From source file:com.mobileman.projecth.web.controller.ArztController.java
@Transactional @RequestMapping(method = RequestMethod.POST, value = "/arzt/save_fragebogen_anpassen") public @ResponseBody String saveFragebogenAnnpassen(HttpServletRequest request, Model model) { String result = ""; // save into session FragebogenAnnpasenData fragebogenAnnpasendata = new FragebogenAnnpasenData(request.getSession()); fragebogenAnnpasendata.storeData(request); FragebogenAnnpasenDataHolder holder = fragebogenAnnpasendata.getData(); Map<Long, Map<String, Object>> fragebogenAnnpasenDataHolderdata = holder.getData(); DataHolder dataHolder = new DataHolder(request); Doctor doctor = dataHolder.getDoctor(); Patient patient = dataHolder.getPatient(); Disease disease = dataHolder.getDisease(); Long doctorId = doctor.getId(); Long patientId = patient.getId(); Long diseaseId = disease.getId(); Iterator it = fragebogenAnnpasenDataHolderdata.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Map<String, Object> question = (Map<String, Object>) entry.getValue(); String questionIdString = (String) question.get("question_id"); String questionTypeString = (String) question.get("type"); String questionActionString = (String) question.get("action"); String questionTextString = (String) question.get("question"); String questionExplanationString = (String) question.get("explanation"); Map<Long, String> questionOptions = (Map<Long, String>) question.get("option"); QuestionType questionType = null; boolean editQuestionType = false; // yes/no question if (questionTypeString.equals("0")) { //find standart yes/no question type questionType = findQuestionType(Type.SINGLE_CHOICE_LIST, AnswerDataType.BOOLEAN); }/* ww w . ja va 2s .com*/ // multiple choice question if (questionTypeString.equals("1")) { editQuestionType = true; //new question type questionType = new QuestionType(); questionType.setUser(doctor); questionType.setType(Type.SINGLE_CHOICE_LIST); questionType.setAnswerDataType(AnswerDataType.TEXT); List<Answer> answers = new ArrayList<Answer>(); Answer answer = null; //NO ANSWER answer = new Answer(); answer.setAnswer("Kaine Angabe"); answer.setSortOrder(answers.size()); answer.setKind(Kind.NO_ANSWER); answer.setQuestionType(questionType); answers.add(answer); Iterator optionIt = questionOptions.entrySet().iterator(); while (optionIt.hasNext()) { Map.Entry optionEntry = (Map.Entry) optionIt.next(); Long optionOrder = (Long) optionEntry.getKey(); String option = (String) optionEntry.getValue(); answer = new Answer(); answer.setAnswer(option); answer.setSortOrder(optionOrder.intValue()); answer.setKind(Kind.DEFAULT); answer.setQuestionType(questionType); answers.add(answer); } questionType.setAnswers(answers); } // text question if (questionTypeString.equals("2")) { //find standart text question type questionType = findQuestionType(Type.SINGLE_ANSWER_ENTER, AnswerDataType.TEXT); } String explanationText = null; if (!questionExplanationString.isEmpty()) { explanationText = questionExplanationString; } if (!questionIdString.isEmpty()) { if (questionActionString.equals("EDIT")) { Question customQuestion = questionService.findById(Long.valueOf(questionIdString)); customQuestion.setExplanation(explanationText); customQuestion.setText(questionTextString); if (editQuestionType) { questionType.getAnswers().remove(0); List<Answer> customQuestionAnswers = customQuestion.getQuestionType().getAnswers(); for (int index = 0; index < customQuestionAnswers.size(); index++) { Answer customQuestionAnswer = customQuestionAnswers.get(index); customQuestionAnswer.setAnswer(questionType.getAnswers().get(index).getAnswer()); } } questionService.update(customQuestion); result = "ok"; } if (questionActionString.equals("DELETE")) { try { questionService.deleteCustomQuestion(Long.valueOf(questionIdString)); result = "ok"; } catch (Exception e) { result = "error"; } } } else { Long newId = null; if (questionType.getId() != null) { newId = doctorService.addCustomQuestion(doctor.getId(), patientId, diseaseId, questionTextString, explanationText, questionType.getId()); } else { newId = doctorService.addCustomQuestion(doctor.getId(), patientId, diseaseId, questionTextString, explanationText, questionType); } result = newId.toString(); } } return result; }