List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:com.linkedin.pinot.integration.tests.DefaultColumnsClusterIntegrationTest.java
@Test public void testNewAddedColumns() throws Exception { String pqlQuery;/*from ww w . j ava2s .co m*/ String sqlQuery; // Test queries with each new added columns. pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedIntMetric = 1"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedLongMetric = 1"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedFloatMetric = 0.0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedDoubleMetric = 0.0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedIntDimension < 0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedLongDimension < 0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedFloatDimension < 0.0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedDoubleDimension < 0.0"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT COUNT(*) FROM mytable WHERE NewAddedStringDimension = 'newAdded'"; sqlQuery = "SELECT COUNT(*) FROM mytable"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); // Test queries with new added metric column in aggregation function. pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable WHERE DaysSinceEpoch <= 16312"; sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch <= 16312"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable WHERE DaysSinceEpoch > 16312"; sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch > 16312"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT SUM(NewAddedLongMetric) FROM mytable WHERE DaysSinceEpoch <= 16312"; sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch <= 16312"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); pqlQuery = "SELECT SUM(NewAddedLongMetric) FROM mytable WHERE DaysSinceEpoch > 16312"; sqlQuery = "SELECT COUNT(*) FROM mytable WHERE DaysSinceEpoch > 16312"; runQuery(pqlQuery, Collections.singletonList(sqlQuery)); // Test other query forms with new added columns. JSONObject response; JSONObject groupByResult; pqlQuery = "SELECT SUM(NewAddedFloatMetric) FROM mytable GROUP BY NewAddedStringDimension"; response = postQuery(pqlQuery); groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult") .getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), 0); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), "newAdded"); pqlQuery = "SELECT SUM(NewAddedDoubleMetric) FROM mytable GROUP BY NewAddedIntDimension"; response = postQuery(pqlQuery); groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult") .getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), 0); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE)); pqlQuery = "SELECT SUM(NewAddedIntMetric) FROM mytable GROUP BY NewAddedLongDimension"; response = postQuery(pqlQuery); groupByResult = response.getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult") .getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Long.MIN_VALUE)); pqlQuery = "SELECT SUM(NewAddedIntMetric), SUM(NewAddedLongMetric), SUM(NewAddedFloatMetric), SUM(NewAddedDoubleMetric) " + "FROM mytable GROUP BY NewAddedIntDimension, NewAddedLongDimension, NewAddedFloatDimension, " + "NewAddedDoubleDimension, NewAddedStringDimension"; response = postQuery(pqlQuery); JSONArray groupByResultArray = response.getJSONArray("aggregationResults"); groupByResult = groupByResultArray.getJSONObject(0).getJSONArray("groupByResult").getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(2), String.valueOf(Float.NEGATIVE_INFINITY)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(3), String.valueOf(Double.NEGATIVE_INFINITY)); groupByResult = groupByResultArray.getJSONObject(1).getJSONArray("groupByResult").getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), TOTAL_DOCS); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(2), String.valueOf(Float.NEGATIVE_INFINITY)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(3), String.valueOf(Double.NEGATIVE_INFINITY)); groupByResult = groupByResultArray.getJSONObject(2).getJSONArray("groupByResult").getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), 0); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(2), String.valueOf(Float.NEGATIVE_INFINITY)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(3), String.valueOf(Double.NEGATIVE_INFINITY)); groupByResult = groupByResultArray.getJSONObject(3).getJSONArray("groupByResult").getJSONObject(0); Assert.assertEquals(groupByResult.getInt("value"), 0); Assert.assertEquals(groupByResult.getJSONArray("group").getString(0), String.valueOf(Integer.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(1), String.valueOf(Long.MIN_VALUE)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(2), String.valueOf(Float.NEGATIVE_INFINITY)); Assert.assertEquals(groupByResult.getJSONArray("group").getString(3), String.valueOf(Double.NEGATIVE_INFINITY)); pqlQuery = "SELECT * FROM mytable"; runQuery(pqlQuery, null); }
From source file:org.amanzi.awe.charts.ui.ChartsView.java
@Override public void chartMouseClicked(final ChartMouseEvent event) { if (event == null) { return;/*w w w. ja va 2 s . c o m*/ } Collection<String> groups = null; long startDate = Long.MIN_VALUE; long endDate = Long.MAX_VALUE; String cellName = StringUtils.EMPTY; if (event.getEntity() instanceof CategoryItemEntity) { CategoryItemEntity entity = (CategoryItemEntity) event.getEntity(); IColumn period = (IColumn) entity.getColumnKey(); ICategoryRow column = period.getItemByName((String) entity.getRowKey()); groups = column.getGroupsNames(); startDate = period.getStartDate(); endDate = period.getEndDate(); cellName = column.getName(); } else if (event.getEntity() instanceof XYItemEntity) { XYItemEntity entity = (XYItemEntity) event.getEntity(); TimeSeriesCollection dataset = (TimeSeriesCollection) entity.getDataset(); TimeSeries ts = dataset.getSeries(entity.getSeriesIndex()); ITimeRow row = (ITimeRow) ts.getKey(); RegularTimePeriod period = ts.getTimePeriod(entity.getItem()); startDate = period.getStart().getTime(); endDate = container.getPeriod().addPeriod(startDate); groups = row.getGroupsForTime(startDate); cellName = row.getName(); } else { return; } AWEEventManager.getManager().fireShowInViewEvent(model, new StatisticsFilter(container.getPeriod(), startDate, endDate, groups, cellName), this); }
From source file:com.fullmeadalchemist.mustwatch.ui.batch.form.BatchFormFragment.java
@Nullable @Override/* w ww . j ava 2 s .co m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { dataBinding = DataBindingUtil.inflate(inflater, R.layout.batch_form_fragment, container, false); // FIXME: Mess. This should be moved somewhere else so other classes can use it abbreviationMap.put(getResources().getString(R.string.DEGREES_C), unitToTextAbbr(CELSIUS)); abbreviationMap.put(getResources().getString(R.string.DEGREES_F), unitToTextAbbr(FAHRENHEIT)); abbreviationMap.put(getResources().getString(R.string.LITER), unitToTextAbbr(LITER)); abbreviationMap.put(getResources().getString(R.string.GALLON_LIQUID_US), unitToTextAbbr(GALLON_LIQUID)); abbreviationMap.put(getResources().getString(R.string.GALLON_DRY_US), unitToTextAbbr(GALLON_DRY)); abbreviationMap.put(getResources().getString(R.string.GALLON_LIQUID_UK), unitToTextAbbr(GALLON_UK)); abbreviationMap.put(getResources().getString(R.string.OUNCE_LIQUID_US), unitToTextAbbr(FLUID_OUNCE)); abbreviationMap.put(getResources().getString(R.string.OUNCE_LIQUID_UK), unitToTextAbbr(OUNCE_LIQUID)); abbreviationMap.put(getResources().getString(R.string.TEASPOON), unitToTextAbbr(TEASPOON)); abbreviationMap.put(getResources().getString(R.string.GRAM), unitToTextAbbr(GRAM)); abbreviationMap.put(getResources().getString(R.string.KILOGRAM), unitToTextAbbr(KILOGRAM)); abbreviationMap.put(getResources().getString(R.string.OUNCE), unitToTextAbbr(OUNCE)); abbreviationMap.put(getResources().getString(R.string.POUND), unitToTextAbbr(POUND)); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BatchFormViewModel.class); Bundle bundle = this.getArguments(); if (bundle != null) { Timber.i("Got Batch ID %d from the NavigationController. Acting as a Batch Editor."); long batchId = bundle.getLong(BATCH_ID, Long.MIN_VALUE); long recipeId = bundle.getLong(RECIPE_ID, Long.MIN_VALUE); if (batchId != Long.MIN_VALUE) { viewModel.getBatch(batchId).observe(this, batch -> { if (batch != null) { viewModel.batch = batch; dataBinding.setBatch(batch); if (batch.status != null) { dataBinding.status.setText(batch.status.toString()); } else { dataBinding.status.setText(PLANNING.toString()); } updateUiDateTime(); viewModel.getBatchIngredients(batchId).observe(this, batchIngredients -> { if (batchIngredients != null) { Timber.v("Loaded %s Batch ingredients", batchIngredients.size()); viewModel.batch.ingredients = batchIngredients; updateUiIngredientsTable(); } else { Timber.w( "Received nothing from the RecipeRepository when trying to get ingredients for Batch %s", batchId); } Timber.i("Loaded Batch with ID %d:\n%s", batch.id, batch); }); updateSpinners(viewModel.batch); } else { Timber.e("Got a null Batch!"); } }); } else if (recipeId != Long.MIN_VALUE) { viewModel.getRecipe(recipeId).observe(this, recipe -> { if (recipe != null) { viewModel.batch = new Batch(); viewModel.batch.name = recipe.name; viewModel.batch.outputVolume = recipe.outputVol; viewModel.batch.targetSgStarting = recipe.startingSG; viewModel.batch.targetSgFinal = recipe.finalSG; viewModel.batch.status = PLANNING; viewModel.batch.createDate = Calendar.getInstance(); viewModel.getCurrentUserId().observe(this, userId -> { if (userId == null) { Timber.e("Could not set the Batch User ID, since it's null?!"); return; } Timber.d("Setting batch user ID to %s", userId); viewModel.batch.userId = userId; }); dataBinding.setBatch(viewModel.batch); dataBinding.status.setText(viewModel.batch.status.toString()); updateUiDateTime(); viewModel.getRecipeIngredients(recipeId).observe(this, recipeIngredients -> { if (recipeIngredients != null) { Timber.v("Loaded %s Recipe ingredients", recipeIngredients.size()); viewModel.batch.ingredients = recipeIngredients; updateUiIngredientsTable(); } else { Timber.w( "Received nothing from the RecipeRepository when trying to get ingredients for Batch %s", batchId); } Timber.i("Loaded Recipe with ID %d:\n%s", recipe.id, recipe); }); updateSpinners(viewModel.batch); } else { Timber.e("Got a null Recipe!"); } }); } } else { Timber.i("No Batch ID was received. Acting as a Batch Creation form."); viewModel.batch = new Batch(); viewModel.batch.createDate = Calendar.getInstance(); viewModel.getCurrentUserId().observe(this, userId -> { if (userId == null) { Timber.e("Could not set the Batch User ID, since it's null?!"); return; } Timber.d("Setting batch user ID to %s", userId); viewModel.batch.userId = userId; }); dataBinding.setBatch(viewModel.batch); } return dataBinding.getRoot(); }
From source file:com.netbase.insightapi.clientlib.InsightAPIQuery.java
/** * Utility routine that converts a NetBase timestamp value into a java time * (milliseconds since the java epoch). Preserves MIN_VALUE and MAX_VALUE * conventions./*w ww . j a v a2 s . co m*/ * * @param timestamp * @return */ public static long timestampToLongTime(int timestamp) { switch (timestamp) { case Integer.MIN_VALUE: return (Long.MIN_VALUE); case Integer.MAX_VALUE: return (Long.MAX_VALUE); default: return (((long) timestamp) * 100 + NETBASE_EPOCH_TIMESTAMP); } }
From source file:main.java.cluster.Cluster.java
private WorkloadBatch setupConsistentHash(Database db, Workload wrl) { // Will only be used for SWORD WorkloadBatch wb = null;//from w ww . j a va 2 s .c o m Global.LOGGER.info("Setting up Cluster ..."); // Add Partitions Global.LOGGER.info("-----------------------------------------------------------------------------"); Global.LOGGER.info("Creating " + Global.partitions + " fixed number of logical Partitions ..."); for (int i = 1; i <= Global.partitions; i++) this.getPartitions().add(new Partition(i)); // Add Servers and fixed amount of Partitions Global.LOGGER.info("-----------------------------------------------------------------------------"); Global.LOGGER.info("Adding " + Global.servers + " physical Servers in the Cluster ..."); for (int i = 1; i <= Global.servers; i++) this.addServer(new Server(i), true); // New - mutually exclusive pairwise server sets Metric.initServerSet(this); // Assign Partitions into Servers Global.LOGGER.info("-----------------------------------------------------------------------------"); Global.LOGGER.info("Assigning logical Partitions into physical Servers ..."); long p_uid = -1; long p_min = Long.MIN_VALUE; long p_max = Long.MAX_VALUE; //Long.MAX_VALUE; //1048576L; // 2^20 //1073741824; // 2^30 long p_size = (long) ((p_max / Global.partitions) + 1) * 2; ArrayList<Long> p_keyRange = null; Global.partitionCapacity = p_size; Global.LOGGER.info("Define a partition size of " + p_size); // Define Partition range for (Partition p : this.getPartitions()) { // Assign a Server id to the Partition Global.LOGGER.info("-----------------------------------------------------------------------------"); Global.LOGGER.info("Assigning Partition " + p.getPartition_label() + " in a Server ..."); this.assignPartitionConsistentHash(p); // Calculate Key Range values for individual Partition Global.LOGGER.info("............................................................................."); Global.LOGGER.info("Defining Key range for " + p.getPartition_label() + " ..."); p_keyRange = new ArrayList<Long>(); p.setPartition_start_key(p_min); p_keyRange.add(p_min); p_min += p_size; p_uid = p_min - 1; p.setPartition_end_key(p_uid); p.set_uid(p_uid); p_keyRange.add(p_uid); // Added in the Consistent Ring this.getRing().add(p_uid); this.getRing_map().put(p_uid, p.getPartition_id()); this.getPartition_keyRange().put(p.getPartition_id(), p_keyRange); Global.LOGGER.info("Key range for " + p.getPartition_label() + ": " + "Start[" + p.getPartition_start_key() + "], " + "End[" + p.getPartition_end_key() + "]"); } // Determine the number of compressed data nodes to be created if (Global.compressionEnabled) Global.compressedVertices = ((int) db.getDb_tuple_counts() / (int) Global.compressionRatio); // Physical Data Distribution this.physicalDataDistribution(db); // Update server-level load statistic and show this.updateLoad(); this.show(); Global.LOGGER.info("-----------------------------------------------------------------------------"); Global.LOGGER.info("Total data within the Cluster: " + Global.global_dataCount); Global.LOGGER.info("Cluster setup has finished."); return wb; }
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 v a 2 s . c o m 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:com.willwinder.universalgcodesender.model.GUIBackend.java
public void autoconnect() { if (!autoconnect) { return;// w w w . j av a2 s . c o m } if (!isConnected()) { if (settings == null || streamFailed) { return; } if (lastResponse == Long.MIN_VALUE && autoconnect) { logger.log(Level.INFO, "Attempting auto connect."); } else if (lastResponse > Long.MIN_VALUE && settings.isAutoReconnect()) { logger.log(Level.INFO, "Attempting auto reconnect."); } else { return; } try { List<String> portList = ConnectionFactory.getPortNames(getSettings().getConnectionDriver()); boolean portMatch = false; for (String port : portList) { if (port.equals(settings.getPort())) { portMatch = true; break; } } if (portMatch) { connect(settings.getFirmwareVersion(), settings.getPort(), Integer.parseInt(settings.getPortRate())); } } catch (Exception e) { logger.log(Level.WARNING, "Auto connect failed", e); } } }
From source file:com.netbase.insightapi.clientlib.InsightAPIQuery.java
/** * Utility routine that converts a java time to a NetBase timestamp. * Preserves MIN_VALUE and MAX_VALUE conventions. * //from www .jav a2s. co m * @param time * @return */ public static int longTimeToTimestamp(long time) { if (time == Long.MIN_VALUE) return (Integer.MIN_VALUE); if (time == Long.MAX_VALUE) return (Integer.MAX_VALUE); return ((int) ((time - NETBASE_EPOCH_TIMESTAMP) / 100L)); }
From source file:dk.netarkivet.harvester.harvesting.frontier.FrontierReportLine.java
/** * Parses the token.//www. j ava 2s. c om * * @param longToken token to parse. * @return parsed value or default value if value is empty or unparsable. */ private static long parseLong(String longToken) { if (EMPTY_VALUE_TOKEN.equals(longToken)) { return Long.MIN_VALUE; } try { return Long.parseLong(longToken); } catch (NumberFormatException e) { // Strange data my occur here, but it's harmless return Long.MIN_VALUE; } }
From source file:com.jefftharris.passwdsafe.NotificationMgr.java
/** Load the expiration entries from the database */ private void loadEntries(SQLiteDatabase db) throws SQLException { long expiration; if (itsExpiryFilter != null) { expiration = itsExpiryFilter.getExpiryFromNow(null); } else {// w w w . ja v a2 s . c o m expiration = Long.MIN_VALUE; } LongReference nextExpiration = new LongReference(Long.MAX_VALUE); itsNotifUris.clear(); HashSet<Long> uris = new HashSet<>(); ArrayList<Long> removeUriIds = new ArrayList<>(); Cursor uriCursor = db.query(DB_TABLE_URIS, new String[] { DB_COL_URIS_ID, DB_COL_URIS_URI }, null, null, null, null, null); try { while (uriCursor.moveToNext()) { long id = uriCursor.getLong(0); Uri uri = Uri.parse(uriCursor.getString(1)); boolean exists = loadUri(id, uri, uris, expiration, nextExpiration, db); if (!exists) { removeUriIds.add(id); } } } finally { uriCursor.close(); } Iterator<HashMap.Entry<Long, UriNotifInfo>> iter = itsUriNotifs.entrySet().iterator(); while (iter.hasNext()) { HashMap.Entry<Long, UriNotifInfo> entry = iter.next(); if (!uris.contains(entry.getKey())) { itsNotifyMgr.cancel(entry.getValue().getNotifId()); iter.remove(); } } for (Long removeId : removeUriIds) { removeUri(removeId, db); } PasswdSafeUtil.dbginfo(TAG, "nextExpiration: %tc", nextExpiration.itsValue); if ((nextExpiration.itsValue != Long.MAX_VALUE) && (itsExpiryFilter != null)) { if (itsTimerIntent == null) { Intent intent = new Intent(PasswdSafeApp.EXPIRATION_TIMEOUT_INTENT); itsTimerIntent = PendingIntent.getBroadcast(itsCtx, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } long nextTimer = System.currentTimeMillis() + (nextExpiration.itsValue - expiration); PasswdSafeUtil.dbginfo(TAG, "nextTimer: %tc", nextTimer); itsAlarmMgr.set(AlarmManager.RTC, nextTimer, itsTimerIntent); } else if (itsTimerIntent != null) { PasswdSafeUtil.dbginfo(TAG, "cancel expiration timer"); itsAlarmMgr.cancel(itsTimerIntent); } }