List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:edu.utah.further.fqe.ds.api.domain.AbstractQueryContext.java
/** * Return a search query with a specified QID (unique SQ identifier within this QC). * //from w w w .j av a 2s . c o m * @param qid * search query ID within this QC * @return the query */ @Override public final SearchQuery getQueryByQid(final Long qid) { if (qid == null) { return null; } // Slow implementation; may use a Map in the future if query list becomes large for (final SearchQuery query : getQueries()) { if (qid.equals(query.getId())) { return query; } } return null; }
From source file:org.energyos.espi.common.service.impl.ExportServiceImpl.java
@SuppressWarnings({ "rawtypes", "unchecked" }) // TODO: need to make RetailCustomer inherit from IdentifiedObject to remove // the above @Suppress private EntryTypeIterator findEntryTypeIteratorXPath(Long subscriptionId, Long id1, Long id2, Long id3, Class clazz) {/*from www.j a v a2 s . co m*/ EntryTypeIterator result = null; List<Long> temp = new ArrayList<Long>(); Subscription subscription = null; boolean valid = false; try { if (!(subscriptionId.equals(0L))) { subscription = resourceService.findById(subscriptionId, Subscription.class); Authorization authorization = subscription.getAuthorization(); if (!(authorization.getThirdParty().contentEquals("third_party"))) { // a special case (client credentials base) access. So the // retailCustomerId is not // correct if (id2 != 0) { // we have a request for (at least) a usagePoint // so use the relevant retail customer Id to get the ID // collection UsagePoint usagePoint = resourceService.findById(id2, UsagePoint.class); id1 = usagePoint.getRetailCustomer().getId(); } } } // do we have a usagepointId? if (!(id2.equals(0L))) { // is it in the subscription? for (UsagePoint up : subscription.getUsagePoints()) { if (up.getId().equals(id2)) { valid = true; } } } else { // we don't have a usagePoint, so it is all usage points in the // subscription valid = true; } if (valid) { if (!(id3.equals(0L))) { temp = resourceService.findAllIdsByXPath(id1, id2, id3, clazz); } else { if (!(id2.equals(0L))) { temp = resourceService.findAllIdsByXPath(id1, id2, clazz); } else { if (!(id1.equals(0L))) { // temp = resourceService.findAllIdsByXPath(id1, // clazz); // we just want the UsagePoints in the Subscription for (UsagePoint up : subscription.getUsagePoints()) { temp.add(up.getId()); } } else { // otherwise, just get all the RetailCustomers temp = resourceService.findAllIdsByXPath(RetailCustomer.class); } } } } result = (new EntryTypeIterator(resourceService, temp, clazz)); } catch (Exception e) { System.out.printf("**** Error in Query: %s\n", e.toString()); result = null; } return result; }
From source file:annis.visualizers.iframe.CorefVisualizer.java
private List<Node> outputSingleText(EList<SToken> token, VisualizerInput input) throws IOException { List<Node> result = new LinkedList<Node>(); List<Long> prevpositions, listpositions; List<Long> finalpositions = null; int maxlinkcount = 0; String lastId, currentId = null; for (SToken tok : token) { prevpositions = finalpositions;/*from w w w. j av a 2 s .co m*/ if (prevpositions != null && prevpositions.size() < 1) { prevpositions = null; } lastId = currentId; currentId = tok.getId(); listpositions = componentOfToken.get(currentId); List<Boolean> checklist = null; if (prevpositions == null && listpositions != null) { finalpositions = listpositions; } else if (listpositions == null) { finalpositions = new LinkedList<Long>(); } else { checklist = new LinkedList<Boolean>(); for (int i = 0; prevpositions != null && i < prevpositions.size(); i++) { if (listpositions.contains(prevpositions.get(i))) { checklist.add(true); } else { checklist.add(false); } } List<Long> remains = new LinkedList<Long>(); for (int i = 0; i < listpositions.size(); i++) { if (prevpositions != null && !prevpositions.contains(listpositions.get(i))) { remains.add(listpositions.get(i)); } } int minsize = checklist.size() + remains.size(); int number = 0; finalpositions = new LinkedList<Long>(); for (int i = 0; i < minsize; i++) { if (prevpositions != null && checklist.size() > i && checklist.get(i).booleanValue()) { finalpositions.add(prevpositions.get(i)); } else { if (remains.size() > number) { Long ll = remains.get(number); finalpositions.add(ll); number++; minsize--; } else { finalpositions.add(Long.MIN_VALUE); } } } } String onclick = ""; String style = ""; if (input.getMarkedAndCovered().containsKey(tok)) { MatchedNodeColors[] vals = MatchedNodeColors.values(); long match = Math.min(input.getMarkedAndCovered().get(tok) - 1, vals.length - 1); style += ("color: " + vals[(int) match].getHTMLColor() + ";"); } boolean underline = false; if (!finalpositions.isEmpty()) { style += "cursor:pointer;"; underline = true; onclick = "togglePRAuto(this);"; } Table tableSingleTok = new Table(); result.add(tableSingleTok); tableSingleTok.setCSSClass("token"); int currentlinkcount = 0; if (underline) { boolean firstone = true; int index = -1; String tooltip; if (!finalpositions.isEmpty()) { for (Long currentPositionComponent : finalpositions) { index++; String left = "", right = ""; TComponent currentWriteComponent = null;// == pir String currentType = ""; if (!currentPositionComponent.equals(Long.MIN_VALUE) && komponent.size() > currentPositionComponent) { currentWriteComponent = komponent.get((int) (long) currentPositionComponent); List<String> pi = currentWriteComponent.tokenList; List<String> preparedPi = new LinkedList<String>(); for (String s : pi) { preparedPi.add(prepareID(s)); } currentType = currentWriteComponent.type; left = StringUtils.join(preparedPi, ","); right = "" + currentPositionComponent + 1; } String annotations = getAnnotations(tok.getId(), currentPositionComponent); if (firstone) { firstone = false; if (currentWriteComponent == null) { String left2 = "", right2 = ""; long pr = 0; TComponent currentWriteComponent2;// == pir String currentType2 = ""; String annotations2 = ""; for (Long currentPositionComponent2 : finalpositions) { if (!currentPositionComponent2.equals(Long.MIN_VALUE) && komponent.size() > currentPositionComponent2) { currentWriteComponent2 = komponent .get((int) (long) currentPositionComponent2); List<String> pi2 = currentWriteComponent2.tokenList; // prepare each single ID List<String> preparedPi2 = new LinkedList<String>(); for (String s : pi2) { preparedPi2.add(prepareID(s)); } currentType2 = currentWriteComponent2.type; left2 = StringUtils.join(preparedPi2, ","); right2 = "" + currentPositionComponent2 + 1; annotations2 = getAnnotations(tok.getId(), currentPositionComponent2); pr = currentPositionComponent2; break; } } tooltip = "<b>Component</b>: " + (pr + 1) + ", <b>Type</b>: " + currentType2 + annotations2; Tr trTok = new Tr(); tableSingleTok.appendChild(trTok); Td tdTok = new Td(); trTok.appendChild(tdTok); tdTok.setId("tok_" + prepareID(tok.getSId())); tdTok.setTitle(tooltip); tdTok.setStyle(style); tdTok.setAttribute("onclick", onclick); tdTok.setAttribute("annis:pr_left", left2); tdTok.setAttribute("annis:pr_right", right2); Text textTok = new Text(" " + CommonHelper.getSpannedText(tok) + " "); tdTok.appendChild(textTok); } else {//easier tooltip = "<b>Component</b>: " + (currentPositionComponent + 1) + ", <b>Type</b> " + currentType + annotations; Tr trTok = new Tr(); tableSingleTok.appendChild(trTok); Td tdTok = new Td(); trTok.appendChild(tdTok); tdTok.setId("tok_" + prepareID(tok.getSId())); tdTok.setTitle(tooltip); tdTok.setStyle(style); tdTok.setAttribute("onclick", onclick); tdTok.setAttribute("annis:pr_left", left); tdTok.setAttribute("annis:pr_right", right); Text textTok = new Text(" " + CommonHelper.getSpannedText(tok) + " "); tdTok.appendChild(textTok); } } currentlinkcount++; //while we've got underlines if (currentPositionComponent.equals(Long.MIN_VALUE)) { Tr trBlank = new Tr(); tableSingleTok.appendChild(trBlank); Td tdBlank = new Td(); trBlank.appendChild(tdBlank); tdBlank.setCSSClass("blank"); } else { int color; if (colorlist.containsKey((int) (long) currentPositionComponent)) { color = colorlist.get((int) (long) currentPositionComponent); } else { color = getNewColor((int) (long) currentPositionComponent); colorlist.put((int) (long) currentPositionComponent, color); } if (color > 16777215) { color = 16777215; } String addition = ";border-style: solid; border-width: 0px 0px 0px 2px; border-color: white "; if (lastId != null && currentId != null && checklist != null && checklist.size() > index && checklist.get(index).booleanValue() == true) { if (connectionOf(lastId, currentId, currentPositionComponent)) { addition = ""; } } tooltip = "<b>Component</b>: " + (currentPositionComponent + 1) + ", <b>Type</b>: " + currentType + annotations; Tr trLineContainer = new Tr(); tableSingleTok.appendChild(trLineContainer); Td tdLineContainer = new Td(); trLineContainer.appendChild(tdLineContainer); Table tableLineContainer = new Table(); tdLineContainer.appendChild(tableLineContainer); tableLineContainer.setCSSClass("linecontainer"); Tr trLine = new Tr(); tableLineContainer.appendChild(trLine); Td tdLine = new Td(); trLine.appendChild(tdLine); tdLine.setCSSClass("line"); tdLine.setStyle( "background-color: #" + Integer.toHexString(color) + "; " + style + addition); tdLine.setAttribute("onclick", onclick); tdLine.setAttribute("annis:pr_left", left); tdLine.setAttribute("annis:pr_right", right); tdLine.setTitle(tooltip); Tr trSpace = new Tr(); tableLineContainer.appendChild(trSpace); Td tdSpace = new Td(); trSpace.appendChild(tdSpace); tdSpace.setCSSClass("space"); } } } if (currentlinkcount > maxlinkcount) { maxlinkcount = currentlinkcount; } else { if (currentlinkcount < maxlinkcount) { Tr trSpace = new Tr(); tableSingleTok.appendChild(trSpace); Td tdSpace = new Td(); trSpace.appendChild(tdSpace); tdSpace.setStyle("height: " + (maxlinkcount - currentlinkcount) * 5 + "px;"); } } } else { // print a token without lines Tr trTok = new Tr(); tableSingleTok.appendChild(trTok); Td tdTok = new Td(); trTok.appendChild(tdTok); tdTok.setId("tok_" + prepareID(tok.getSId())); tdTok.setStyle(style); Text textTok = new Text(" " + CommonHelper.getSpannedText(tok) + " "); tdTok.appendChild(textTok); if (maxlinkcount > 0) { Tr trSpace = new Tr(); tableSingleTok.appendChild(trSpace); Td tdSpace = new Td(); trSpace.appendChild(tdSpace); tdSpace.setStyle("height: " + maxlinkcount * 5 + "px;"); } } } // end for each token return result; }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }/*from w w w.j a va 2 s . c om*/ optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:org.openmrs.module.appointmentscheduling.web.controller.AppointmentBlockCalendarController.java
@RequestMapping(method = RequestMethod.POST) public String loadForm(HttpServletRequest request, ModelMap model, @RequestParam(value = "action", required = false) String action, @RequestParam(value = "locationId", required = false) Location location, @RequestParam(value = "chosenType", required = false) Integer appointmentTypeId, @RequestParam(value = "chosenProvider", required = false) Integer providerId, @RequestParam(value = "fromDate", required = false) Long fromDate, @RequestParam(value = "toDate", required = false) Long toDate, @RequestParam(value = "appointmentBlockId", required = false) Integer appointmentBlockId) { if (Context.isAuthenticated()) { //Updating session variables Calendar cal = OpenmrsUtil.getDateTimeFormat(Context.getLocale()).getCalendar(); cal.setTimeInMillis(fromDate);// www. j a v a 2s . co m Date fromDateAsDate = cal.getTime(); cal.setTimeInMillis(toDate); Date toDateAsDate = cal.getTime(); HttpSession httpSession = request.getSession(); httpSession.setAttribute("chosenLocation", location); httpSession.setAttribute("lastLocale", Context.getLocale()); httpSession.setAttribute("chosenProvider", providerId); httpSession.setAttribute("chosenType", appointmentTypeId); //If the user wants to add new appointment block (clicked on a day) if (action != null && action.equals("addNewAppointmentBlock")) { String getRequest = ""; //Fill the request from the user with selected date and forward it to appointmentBlockForm getRequest += "fromDate=" + Context.getDateTimeFormat().format(fromDateAsDate); if (toDate != null && !toDate.equals(fromDate)) { //If the fromDate is not the same as toDate (not a day click on month view) getRequest += "&toDate=" + Context.getDateTimeFormat().format(toDateAsDate); } getRequest += "&redirectedFrom=appointmentBlockCalendar.list"; return "redirect:appointmentBlockForm.form?" + getRequest; } //If the user wants to change the view to table view else if (action != null && action.equals("changeToTableView")) { return "redirect:appointmentBlockList.list"; } //If the user wants to edit an existing appointment block (clicked on an event) else if (action != null && action.equals("editAppointmentBlock")) { return "redirect:appointmentBlockForm.form?appointmentBlockId=" + appointmentBlockId + "&redirectedFrom=appointmentBlockCalendar.list"; } } return null; }
From source file:ips1ap101.web.recurso.pages.Recurso3.java
private void setPropiedadesDataProvider() { this.getGestor().track("setPropiedadesDataProvider"); Long funcion = this.getContextoPeticion().getIdentificacionFuncionReferencia(); if (funcion != null) { String dominioRetorno = this.getContextoSesion().getDominioRetorno(); if (StringUtils.isNotBlank(dominioRetorno)) { try { Long dominioSelect = new Long(dominioRetorno); String criterios1 = this.getContextoPeticion().getCriteriosBusqueda(); String criterios2 = this.getListaRecursoDataProvider().getCriteriosBusqueda(); boolean todoIgual = false; if (funcion.equals(this.getListaRecursoDataProvider().getFuncionSelect())) { if (dominioSelect.equals(this.getListaRecursoDataProvider().getDominioSelect())) { if (criterios1 == null && criterios2 == null) { todoIgual = true; } else if (criterios1 == null || criterios2 == null) { todoIgual = false; } else { todoIgual = criterios1.equals(criterios2); }/*w w w . j a v a2s. co m*/ } } if (!todoIgual) { this.getListaRecursoDataProvider().setFilaEscogida(null); this.getListaRecursoDataProvider().setSoloReferencia(true); this.getListaRecursoDataProvider().setDominioSelect(dominioSelect); this.getListaRecursoDataProvider().setFuncionSelect(funcion); this.getListaRecursoDataProvider().setCriteriosBusqueda(criterios1); } if (this.getContextoPeticion().getFragmentoFiltroActual() != null) { this.getContextoPeticion().getFragmentoFiltroActual().reiniciar(); } } catch (NumberFormatException | ExcepcionAplicacion ex) { this.getGestor().handle(ex); } } } }
From source file:org.apache.hadoop.hdfs.server.datanode.TestBlockReport2.java
private void matchDNandNNState(int nnId, int numDataNodes, MiniDFSCluster cluster, int tolerance, int numBuckets) throws IOException { int mismatchCount = 0; for (int i = 0; i < numDataNodes; i++) { LOG.debug("DataNode Index: " + i); DataNode dn = cluster.getDataNodes().get(i); Map<DatanodeStorage, BlockReport> storageReports = getDNBR(cluster, dn, numBuckets); for (Map.Entry<DatanodeStorage, BlockReport> entry : storageReports.entrySet()) { BlockReport value = entry.getValue(); List<Long> dnHashes = new ArrayList<>(); for (long hash : value.getHashes()) { dnHashes.add(hash);//from ww w .j a v a 2 s. c o m } DatanodeStorageInfo storage = cluster.getNamesystem().getBlockManager().getDatanodeManager() .getDatanode(dn.getDatanodeId()).getStorageInfo(entry.getKey().getStorageID()); List<HashBucket> storageHashes = getStorageHashes(storage); assertFalse("More buckets on NN than on DN. might indicate configuration issue.", storageHashes.size() > dnHashes.size()); if (storageHashes.size() != dnHashes.size()) { LOG.debug( "Number of hashes on NN doesn't match DN. This should only be the case before first report."); } List<Long> nnHashes = new ArrayList<>(numBuckets); for (HashBucket storageHash : storageHashes) { nnHashes.add(storageHash.getBucketId(), storageHash.getHash()); } LOG.debug("DN Hash: " + Arrays.toString(dnHashes.toArray())); LOG.debug("NN Hash: " + Arrays.toString(nnHashes.toArray())); for (int j = 0; j < numBuckets; j++) { Long dnHash = dnHashes.get(j); Long nnHash = nnHashes.get(j); if (!dnHash.equals(nnHash)) { mismatchCount++; } } } } if (mismatchCount > tolerance) { String msg = "The Hashes Did not match. Mismatched Hashes: " + mismatchCount + " " + "Tolerance: " + tolerance; LOG.debug(msg); fail(msg); } }
From source file:com.selfsoft.baseinformation.dao.impl.TbPartInfoDaoImpl.java
public List<TbPartInfo> checkHousePartInfo(Map<Long, Long> paramMap) { StringBuilder hql = new StringBuilder(); hql.append(" from TbPartInfo t where 1=1 "); String whereStr = ""; if (null != paramMap) { hql.append(" and "); int idx = 0; for (Long houseId : paramMap.keySet()) { Long checkType = paramMap.get(houseId); whereStr += " (t.tmStoreHouse.id = " + houseId; if (checkType.equals(Constants.GREATERZERO)) { whereStr += " and t.storeQuantity > 0)"; } else if (checkType.equals(Constants.EQUALZERO)) { whereStr += " and t.storeQuantity = 0)"; } else if (checkType.equals(Constants.LESSZERO)) { whereStr += " and t.storeQuantity < 0)"; }//from w w w . j a v a2 s. co m if ((idx + 1) != paramMap.keySet().size()) whereStr += " or "; idx++; } } hql.append(whereStr); return this.getHibernateTemplate().find(hql.toString()); }
From source file:com.square.adherent.noyau.service.implementations.AdherentServiceImpl.java
/** * {@inheritDoc}//w ww.j av a 2 s.c o m */ @Override public BeneficiaireDto ajouterBeneficiaire(Long idAdherent, BeneficiaireDto beneficiaireDto) { // Vrification paramtres if (idAdherent == null) { throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_ID_ADHERENT)); } // On rcupre l'adhrent final PersonneSimpleDto adherent = personnePhysiqueService .rechercherPersonneSimpleParIdentifiant(idAdherent); if (adherent == null) { throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_ADHERENT_INTROUVABLE)); } if (beneficiaireDto == null) { throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_BENEFICIAIRE_DTO)); } if (beneficiaireDto.getCivilite() == null || beneficiaireDto.getCivilite().getIdentifiant() == null) { throw new BusinessException(messageSourceUtil .get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_CIVILITE_BENEFICIAIRE)); } if (StringUtils.isBlank(beneficiaireDto.getNom())) { throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_NOM_BENEFICIAIRE)); } if (StringUtils.isBlank(beneficiaireDto.getPrenom())) { throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_PRENOM_BENEFICIAIRE)); } if (beneficiaireDto.getDateNaissance() == null) { throw new BusinessException(messageSourceUtil .get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_DATE_NAISSANCE_BENEFICIAIRE)); } if (beneficiaireDto.getTypeRelation() == null || beneficiaireDto.getTypeRelation().getIdentifiant() == null) { throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_ID_TYPE_RELATION)); } if (beneficiaireDto.getIdCreateur() == null) { throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_ID_CREATEUR)); } final Long idTypeRelationConjoint = squareMappingService.getIdTypeRelationConjoint(); // Si le bnficiaire ajouter est de type conjoint if (idTypeRelationConjoint.equals(beneficiaireDto.getTypeRelation().getIdentifiant())) { // On vrifie au pralable que l'adhrent n'a pas dj un conjoint final RelationCriteresRechercheDto criterias = new RelationCriteresRechercheDto(); criterias.setIdPersonne(adherent.getId()); criterias.setActif(true); final List<Long> types = new ArrayList<Long>(); types.add(idTypeRelationConjoint); criterias.setTypes(types); final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criteres = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>( criterias, 0, Integer.MAX_VALUE); final RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> result = personneService .rechercherRelationsParCritreres(criteres); if (!result.getListResults().isEmpty()) { throw new BusinessException(messageSourceUtil .get(MessageKeyUtil.ERROR_AJOUTER_BENEFICIAIRE_PREREQUIS_RELATION_CONJOINT_EXISTANTE)); } } // On cr le bnficiaire dans Square final Calendar maintenant = Calendar.getInstance(); final PersonnePhysiqueCopieDto infosCopie = mapperDozerBean.map(beneficiaireDto, PersonnePhysiqueCopieDto.class); infosCopie.setIdPersonneSource(adherent.getId()); final PersonneDto beneficiaireCree = personnePhysiqueService.creerUneCopiePersonne(infosCopie); // On cr la relation entre l'adhrent et le bnficiaire final RelationDto relation = new RelationDto(); relation.setIdPersonnePrincipale(adherent.getId()); relation.setIdPersonne(beneficiaireCree.getIdentifiant()); relation.setType(beneficiaireDto.getTypeRelation()); relation.setDateDebut(maintenant); personneService.creerRelation(relation); // On cr l'action final ActionCreationDto action = new ActionCreationDto(); final Calendar now = Calendar.getInstance(); action.setIdPersonne(adherent.getId()); action.setIdStatut(squareMappingService.getIdStatutActionAFaire()); action.setIdPriorite(squareMappingService.getIdActionPrioriteParDefaut()); action.setDateAction(now); action.setDateAffichageAction(now); action.setIdAgence(squareMappingService.getIdAgencePoleFidelisation()); // Mantis 8458 : on affecte plus de commercial // if (adherent.getCommercial() != null && adherent.getCommercial().getIdentifiant() != null) { // action.setIdCommercial(adherent.getCommercial().getIdentifiant()); // } action.setIdNatureAction(squareMappingService.getIdNatureActionInternet()); action.setIdType(squareMappingService.getIdTypeActionOpportunite()); action.setIdObjet(squareMappingService.getIdObjetActionChgtCompoFamiliale()); action.setIdCreateur(beneficiaireDto.getIdCreateur()); action.setReclamation(false); final StringBuffer descriptif = new StringBuffer(messageSourceUtil.get( MessageKeyUtil.MESSAGE_DESCRIPTIF_BENEFICIAIRE, new String[] { beneficiaireDto.getTypeRelation() != null ? beneficiaireDto.getTypeRelation().getLibelle() : "", beneficiaireDto.getCivilite() != null ? beneficiaireDto.getCivilite().getLibelle() : " ", beneficiaireDto.getNom(), beneficiaireDto.getPrenom(), beneficiaireDto.getDateNaissance() != null ? sdf.format(beneficiaireDto.getDateNaissance().getTime()) : "" })); final List<HistoriqueCommentaireDto> commentaires = new ArrayList<HistoriqueCommentaireDto>(); final HistoriqueCommentaireDto commentaire = new HistoriqueCommentaireDto(); commentaire.setDescriptif(descriptif.toString()); commentaires.add(commentaire); action.setCommentaires(commentaires); actionService.creerAction(action); // On retourne le bnficiaire cr return mapperDozerBean.map(beneficiaireCree, BeneficiaireDto.class); }
From source file:com.bigdata.dastor.db.ColumnFamilyStore.java
public double getBloomFilterFalseRatio() { Long falseCount = 0L; Long trueCount = 0L;//from www . ja v a 2s . c om for (SSTableReader sstable : getSSTables()) { falseCount += sstable.getBloomFilterFalsePositiveCount(); trueCount += sstable.getBloomFilterTruePositiveCount(); } if (falseCount.equals(0L) && trueCount.equals(0L)) return 0d; return falseCount.doubleValue() / (trueCount.doubleValue() + falseCount.doubleValue()); }