changed attributes to enum and did some performance optimazations with database access
This commit is contained in:
@@ -57,9 +57,8 @@ dependencies {
|
|||||||
compile group: 'org.jboss.weld.se', name: 'weld-se', version: '2.2.0.Final'
|
compile group: 'org.jboss.weld.se', name: 'weld-se', version: '2.2.0.Final'
|
||||||
compile group: 'com.orientechnologies', name: 'orient-commons', version: '2.0-SNAPSHOT'
|
compile group: 'com.orientechnologies', name: 'orient-commons', version: '2.0-SNAPSHOT'
|
||||||
compile group: 'com.orientechnologies', name: 'orientdb-core', version: '2.0-SNAPSHOT'
|
compile group: 'com.orientechnologies', name: 'orientdb-core', version: '2.0-SNAPSHOT'
|
||||||
compile group: 'com.orientechnologies', name: 'orient-server', version: '2.0-SNAPSHOT'
|
compile group: 'com.orientechnologies', name: 'orientdb-server', version: '2.0-SNAPSHOT'
|
||||||
compile group: 'com.orientechnologies', name: 'orientdb-object', version: '2.0-SNAPSHOT'
|
compile group: 'com.orientechnologies', name: 'orientdb-object', version: '2.0-SNAPSHOT'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -25,12 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.fx.cachedetails;
|
package de.geofroggerfx.fx.cachedetails;
|
||||||
|
|
||||||
import de.geofroggerfx.application.SessionConstants;
|
|
||||||
import de.geofroggerfx.application.SessionContext;
|
import de.geofroggerfx.application.SessionContext;
|
||||||
import de.geofroggerfx.application.SessionContextListener;
|
import de.geofroggerfx.application.SessionContextListener;
|
||||||
import de.geofroggerfx.fx.components.MapPaneWrapper;
|
|
||||||
import de.geofroggerfx.fx.components.GeocachingIcons;
|
import de.geofroggerfx.fx.components.GeocachingIcons;
|
||||||
import de.geofroggerfx.fx.components.IconManager;
|
import de.geofroggerfx.fx.components.IconManager;
|
||||||
|
import de.geofroggerfx.fx.components.MapPaneWrapper;
|
||||||
import de.geofroggerfx.model.Cache;
|
import de.geofroggerfx.model.Cache;
|
||||||
import de.geofroggerfx.model.CacheList;
|
import de.geofroggerfx.model.CacheList;
|
||||||
import de.geofroggerfx.service.CacheService;
|
import de.geofroggerfx.service.CacheService;
|
||||||
@@ -117,12 +116,6 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
@Inject
|
@Inject
|
||||||
private CacheService cacheService;
|
private CacheService cacheService;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the controller class.
|
|
||||||
*
|
|
||||||
* @param url
|
|
||||||
* @param rb
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
setSessionListener();
|
setSessionListener();
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.fx.cachelist;
|
package de.geofroggerfx.fx.cachelist;
|
||||||
|
|
||||||
import de.geofroggerfx.application.SessionConstants;
|
|
||||||
import de.geofroggerfx.application.SessionContext;
|
import de.geofroggerfx.application.SessionContext;
|
||||||
import de.geofroggerfx.fx.components.CacheListCell;
|
import de.geofroggerfx.fx.components.CacheListCell;
|
||||||
import de.geofroggerfx.fx.components.IconManager;
|
import de.geofroggerfx.fx.components.IconManager;
|
||||||
@@ -35,14 +34,10 @@ import de.geofroggerfx.model.CacheList;
|
|||||||
import de.geofroggerfx.service.CacheService;
|
import de.geofroggerfx.service.CacheService;
|
||||||
import de.geofroggerfx.service.CacheSortField;
|
import de.geofroggerfx.service.CacheSortField;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.util.Callback;
|
|
||||||
import org.scenicview.ScenicView;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -84,12 +79,6 @@ public class CacheListController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private ComboBox cacheListComboBox;
|
private ComboBox cacheListComboBox;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the controller class.
|
|
||||||
*
|
|
||||||
* @param url
|
|
||||||
* @param rb
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
@@ -99,10 +88,10 @@ public class CacheListController implements Initializable {
|
|||||||
setCellFactory();
|
setCellFactory();
|
||||||
|
|
||||||
cacheListView.getSelectionModel().selectedItemProperty().addListener(
|
cacheListView.getSelectionModel().selectedItemProperty().addListener(
|
||||||
(ChangeListener<Cache>) (ObservableValue<? extends Cache> ov, Cache oldValue, Cache newValue) ->
|
observable -> sessionContext.setData(CURRENT_CACHE, cacheListView.getSelectionModel().getSelectedItem())
|
||||||
sessionContext.setData(CURRENT_CACHE, newValue)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
initCacheListComboBox();
|
initCacheListComboBox();
|
||||||
initListMenuButton();
|
initListMenuButton();
|
||||||
}
|
}
|
||||||
@@ -110,8 +99,8 @@ public class CacheListController implements Initializable {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void setCellFactory() {
|
private void setCellFactory() {
|
||||||
cacheListView.setCellFactory(
|
cacheListView.setCellFactory(
|
||||||
(Callback<ListView<Cache>, CacheListCell>)
|
param -> new CacheListCell()
|
||||||
(ListView<Cache> p) -> new CacheListCell());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSessionListener() {
|
private void setSessionListener() {
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
package de.geofroggerfx.fx.components;
|
package de.geofroggerfx.fx.components;
|
||||||
|
|
||||||
import de.geofroggerfx.fx.utils.JavaFXUtils;
|
import de.geofroggerfx.fx.utils.JavaFXUtils;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import jfxtras.labs.map.MapPane;
|
import jfxtras.labs.map.MapPane;
|
||||||
import jfxtras.labs.map.render.MapMarkable;
|
import jfxtras.labs.map.render.MapMarkable;
|
||||||
@@ -63,20 +61,14 @@ public class MapPaneWrapper extends Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSizeListener() {
|
private void setSizeListener() {
|
||||||
this.widthProperty().addListener(new ChangeListener() {
|
this.widthProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
@Override
|
Double width = (Double) newValue;
|
||||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
mapPane.setMapWidth(width);
|
||||||
Double width = (Double) newValue;
|
|
||||||
mapPane.setMapWidth(width);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.heightProperty().addListener(new ChangeListener() {
|
this.heightProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
@Override
|
Double height = (Double) newValue;
|
||||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
mapPane.setMapHeight(height);
|
||||||
Double height = (Double) newValue;
|
|
||||||
mapPane.setMapHeight(height);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: describe the class
|
|
||||||
*
|
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
public class GroundspeakGPXReader implements GPXReader {
|
public class GroundspeakGPXReader implements GPXReader {
|
||||||
@@ -347,27 +345,19 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
final List attributes = new ArrayList<>();
|
final List attributes = new ArrayList<>();
|
||||||
cache.setAttributes(attributes);
|
cache.setAttributes(attributes);
|
||||||
for (Element attributeElement : attributesElement.getChildren()) {
|
for (Element attributeElement : attributesElement.getChildren()) {
|
||||||
final Attribute attribute = new Attribute();
|
try {
|
||||||
attributes.add(attribute);
|
final Attribute attribute = Attribute.groundspeakAttributeToAttribute(
|
||||||
setId(attributeElement, attribute);
|
attributeElement.getAttribute(ID).getLongValue(),
|
||||||
setInc(attributeElement, attribute);
|
attributeElement.getAttribute(INC).getBooleanValue(),
|
||||||
setText(attributeElement, attribute);
|
attributeElement.getTextTrim());
|
||||||
|
attributes.add(attribute);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText(Element attributeElement, Attribute attribute) {
|
|
||||||
attribute.setText(attributeElement.getTextTrim());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setInc(Element attributeElement, Attribute attribute) throws DataConversionException {
|
|
||||||
attribute.setInc(attributeElement.getAttribute(INC).getBooleanValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setId(Element attributeElement, Attribute attribute) throws DataConversionException {
|
|
||||||
attribute.setId(attributeElement.getAttribute(ID).getLongValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setContainer(Element cacheElement, Cache cache) {
|
private void setContainer(Element cacheElement, Cache cache) {
|
||||||
cache.setContainer(cacheElement.getChild(CONTAINER, groundspeakNamespace).getTextTrim());
|
cache.setContainer(cacheElement.getChild(CONTAINER, groundspeakNamespace).getTextTrim());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,36 +25,319 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
public class Attribute {
|
public enum Attribute {
|
||||||
|
|
||||||
private Long id;
|
// id:1 text:Dogs
|
||||||
private boolean inc;
|
DOGS_TRUE(1),
|
||||||
private String text;
|
DOGS_FALSE(-1),
|
||||||
|
|
||||||
public Long getId() {
|
// id:2 text:Access or parking fee
|
||||||
return id;
|
ACCESS_OR_PARKING_FEE_TRUE(2),
|
||||||
}
|
ACCESS_OR_PARKING_FEE_FALSE(-2),
|
||||||
|
|
||||||
public void setId(Long id) {
|
// id:3 text:Climbing gear
|
||||||
|
CLIMBING_GEAR_TRUE(3),
|
||||||
|
CLIMBING_GEAR_FALSE(-3),
|
||||||
|
|
||||||
|
// id:4 text:Boat
|
||||||
|
BOAT_TRUE(4),
|
||||||
|
BOAT_FALSE(-4),
|
||||||
|
|
||||||
|
// id:5 text:Scuba gear
|
||||||
|
SCUBA_GEAR_TRUE(5),
|
||||||
|
SCUBA_GEAR_FALSE(-5),
|
||||||
|
|
||||||
|
// id:6 text:Recommended for kids
|
||||||
|
RECOMMENDED_FOR_KIDS_TRUE(6),
|
||||||
|
RECOMMENDED_FOR_KIDS_FALSE(-6),
|
||||||
|
|
||||||
|
// id:7 text:Takes less than an hour
|
||||||
|
TAKES_LESS_THAN_AN_HOUR_TRUE(7),
|
||||||
|
TAKES_LESS_THAN_AN_HOUR_FALSE(-7),
|
||||||
|
|
||||||
|
// id:8 text:Scenic view
|
||||||
|
SCENIC_VIEW_TRUE(8),
|
||||||
|
SCENIC_VIEW_FALSE(-8),
|
||||||
|
|
||||||
|
// id:9 text:Significant Hike
|
||||||
|
SIGNIFICANT_HIKE_TRUE(9),
|
||||||
|
SIGNIFICANT_HIKE_FALSE(-9),
|
||||||
|
|
||||||
|
// id:10 text:Difficult climbing
|
||||||
|
DIFFICULT_CLIMBING_TRUE(10),
|
||||||
|
DIFFICULT_CLIMBING_FALSE(-10),
|
||||||
|
|
||||||
|
// id:11 text:May require wading
|
||||||
|
MAY_REQUIRE_WADING_TRUE(11),
|
||||||
|
MAY_REQUIRE_WADING_FALSE(-11),
|
||||||
|
|
||||||
|
// id:12 text:May require swimming
|
||||||
|
MAY_REQUIRE_SWIMMING_TRUE(12),
|
||||||
|
MAY_REQUIRE_SWIMMING_FALSE(-12),
|
||||||
|
|
||||||
|
// id:13 text:Available at all times
|
||||||
|
AVAILABLE_AT_ALL_TIMES_TRUE(13),
|
||||||
|
AVAILABLE_AT_ALL_TIMES_FALSE(-13),
|
||||||
|
|
||||||
|
// id:14 text:Recommended at night
|
||||||
|
RECOMMENDED_AT_NIGHT_TRUE(14),
|
||||||
|
RECOMMENDED_AT_NIGHT_FALSE(-14),
|
||||||
|
|
||||||
|
// id:15 text:Available during winter
|
||||||
|
AVAILABLE_DURING_WINTER_TRUE(15),
|
||||||
|
AVAILABLE_DURING_WINTER_FALSE(-15),
|
||||||
|
|
||||||
|
// id:17 text:Poison plants
|
||||||
|
POISON_PLANTS_TRUE(17),
|
||||||
|
POISON_PLANTS_FALSE(-17),
|
||||||
|
|
||||||
|
// id:18 text:Dangerous Animals
|
||||||
|
DANGEROUS_ANIMALS_TRUE(18),
|
||||||
|
DANGEROUS_ANIMALS_FALSE(-18),
|
||||||
|
|
||||||
|
// id:19 text:Ticks
|
||||||
|
TICKS_TRUE(19),
|
||||||
|
TICKS_FALSE(-19),
|
||||||
|
|
||||||
|
// id:20 text:Abandoned mines
|
||||||
|
ABANDONED_MINES_TRUE(20),
|
||||||
|
ABANDONED_MINES_FALSE(-20),
|
||||||
|
|
||||||
|
// id:21 text:Cliff / falling rocks
|
||||||
|
CLIFF_FALLING_ROCKS_TRUE(21),
|
||||||
|
CLIFF_FALLING_ROCKS_FALSE(-21),
|
||||||
|
|
||||||
|
// id:22 text:Hunting
|
||||||
|
HUNTING_TRUE(22),
|
||||||
|
HUNTING_FALSE(-22),
|
||||||
|
|
||||||
|
// id:23 text:Dangerous area
|
||||||
|
DANGEROUS_AREA_TRUE(23),
|
||||||
|
DANGEROUS_AREA_FALSE(-23),
|
||||||
|
|
||||||
|
// id:24 text:Wheelchair accessible
|
||||||
|
WHEELCHAIR_ACCESSIBLE_TRUE(24),
|
||||||
|
WHEELCHAIR_ACCESSIBLE_FALSE(-24),
|
||||||
|
|
||||||
|
// id:25 text:Parking available
|
||||||
|
PARKING_AVAILABLE_TRUE(25),
|
||||||
|
PARKING_AVAILABLE_FALSE(-25),
|
||||||
|
|
||||||
|
// id:26 text:Public transportation
|
||||||
|
PUBLIC_TRANSPORTATION_TRUE(26),
|
||||||
|
PUBLIC_TRANSPORTATION_FALSE(-26),
|
||||||
|
|
||||||
|
// id:27 text:Drinking water nearby
|
||||||
|
DRINKING_WATER_NEARBY_TRUE(27),
|
||||||
|
DRINKING_WATER_NEARBY_FALSE(-27),
|
||||||
|
|
||||||
|
// id:28 text:Public restrooms nearby
|
||||||
|
PUBLIC_RESTROOMS_NEARBY_TRUE(28),
|
||||||
|
PUBLIC_RESTROOMS_NEARBY_FALSE(-28),
|
||||||
|
|
||||||
|
// id:29 text:Telephone nearby
|
||||||
|
TELEPHONE_NEARBY_TRUE(29),
|
||||||
|
TELEPHONE_NEARBY_FALSE(-29),
|
||||||
|
|
||||||
|
// id:30 text:Picnic tables nearby
|
||||||
|
PICNIC_TABLES_NEARBY_TRUE(30),
|
||||||
|
PICNIC_TABLES_NEARBY_FALSE(-30),
|
||||||
|
|
||||||
|
// id:31 text:Camping available
|
||||||
|
CAMPING_AVAILABLE_TRUE(31),
|
||||||
|
CAMPING_AVAILABLE_FALSE(-31),
|
||||||
|
|
||||||
|
// id:32 text:Bicycles
|
||||||
|
BICYCLES_TRUE(32),
|
||||||
|
BICYCLES_FALSE(-32),
|
||||||
|
|
||||||
|
// id:33 text:Motorcycles
|
||||||
|
MOTORCYCLES_TRUE(33),
|
||||||
|
MOTORCYCLES_FALSE(-33),
|
||||||
|
|
||||||
|
// id:34 text:Quads
|
||||||
|
QUADS_TRUE(34),
|
||||||
|
QUADS_FALSE(-34),
|
||||||
|
|
||||||
|
// id:35 text:Off-road vehicles
|
||||||
|
OFF_ROAD_VEHICLES_TRUE(35),
|
||||||
|
OFF_ROAD_VEHICLES_FALSE(-35),
|
||||||
|
|
||||||
|
// id:36 text:Snowmobiles
|
||||||
|
SNOWMOBILES_TRUE(36),
|
||||||
|
SNOWMOBILES_FALSE(-36),
|
||||||
|
|
||||||
|
// id:37 text:Horses
|
||||||
|
HORSES_TRUE(37),
|
||||||
|
HORSES_FALSE(-37),
|
||||||
|
|
||||||
|
// id:38 text:Campfires
|
||||||
|
CAMPFIRES_TRUE(38),
|
||||||
|
CAMPFIRES_FALSE(-38),
|
||||||
|
|
||||||
|
// id:39 text:Thorns
|
||||||
|
THORNS_TRUE(39),
|
||||||
|
THORNS_FALSE(-39),
|
||||||
|
|
||||||
|
// id:40 text:Stealth required
|
||||||
|
STEALTH_REQUIRED_TRUE(40),
|
||||||
|
STEALTH_REQUIRED_FALSE(-40),
|
||||||
|
|
||||||
|
// id:41 text:Stroller accessible
|
||||||
|
STROLLER_ACCESSIBLE_TRUE(41),
|
||||||
|
STROLLER_ACCESSIBLE_FALSE(-41),
|
||||||
|
|
||||||
|
// id:43 text:Watch for livestock
|
||||||
|
WATCH_FOR_LIVESTOCK_TRUE(43),
|
||||||
|
WATCH_FOR_LIVESTOCK_FALSE(-43),
|
||||||
|
|
||||||
|
// id:42 text:Needs maintenance
|
||||||
|
NEEDS_MAINTENANCE_TRUE(42),
|
||||||
|
NEEDS_MAINTENANCE_FALSE(-42),
|
||||||
|
|
||||||
|
// id:44 text:Flashlight required
|
||||||
|
FLASHLIGHT_REQUIRED_TRUE(44),
|
||||||
|
FLASHLIGHT_REQUIRED_FALSE(-44),
|
||||||
|
|
||||||
|
// id:45 text:Lost and Found Tour
|
||||||
|
LOST_AND_FOUND_TOUR_TRUE(45),
|
||||||
|
LOST_AND_FOUND_TOUR_FALSE(-45),
|
||||||
|
|
||||||
|
// id:46 text:Truck Driver/RV
|
||||||
|
TRUCK_DRIVER_RV_TRUE(46),
|
||||||
|
TRUCK_DRIVER_RV_FALSE(-46),
|
||||||
|
|
||||||
|
// id:47 text:Field Puzzle
|
||||||
|
FIELD_PUZZLE_TRUE(47),
|
||||||
|
FIELD_PUZZLE_FALSE(-47),
|
||||||
|
|
||||||
|
// id:48 text:UV Light Required
|
||||||
|
UV_LIGHT_REQUIRED_TRUE(48),
|
||||||
|
UV_LIGHT_REQUIRED_FALSE(-48),
|
||||||
|
|
||||||
|
// id:49 text:Snowshoes
|
||||||
|
SNOWSHOES_TRUE(49),
|
||||||
|
SNOWSHOES_FALSE(-49),
|
||||||
|
|
||||||
|
// id:50 text:Cross Country Skis
|
||||||
|
CROSS_COUNTRY_SKIS_TRUE(50),
|
||||||
|
CROSS_COUNTRY_SKIS_FALSE(-50),
|
||||||
|
|
||||||
|
// id:51 text:Special Tool Required
|
||||||
|
SPECIAL_TOOL_REQUIRED_TRUE(51),
|
||||||
|
SPECIAL_TOOL_REQUIRED_FALSE(-51),
|
||||||
|
|
||||||
|
// id:52 text:Night Cache
|
||||||
|
NIGHT_CACHE_TRUE(52),
|
||||||
|
NIGHT_CACHE_FALSE(-52),
|
||||||
|
|
||||||
|
// id:53 text:Park and Grab
|
||||||
|
PARK_AND_GRAB_TRUE(53),
|
||||||
|
PARK_AND_GRAB_FALSE(-53),
|
||||||
|
|
||||||
|
// id:54 text:Abandoned Structure
|
||||||
|
ABANDONED_STRUCTURE_TRUE(54),
|
||||||
|
ABANDONED_STRUCTURE_FALSE(-54),
|
||||||
|
|
||||||
|
// id:55 text:Short hike (less than 1km)
|
||||||
|
SHORT_HIKE_LESS_THAN_1KM_TRUE(55),
|
||||||
|
SHORT_HIKE_LESS_THAN_1KM_FALSE(-55),
|
||||||
|
|
||||||
|
// id:56 text:Medium hike (1km-10km)
|
||||||
|
MEDIUM_HIKE_1KM_10KM_TRUE(56),
|
||||||
|
MEDIUM_HIKE_1KM_10KM_FALSE(-56),
|
||||||
|
|
||||||
|
// id:57 text:Long Hike (+10km)
|
||||||
|
LONG_HIKE_10KM_TRUE(57),
|
||||||
|
LONG_HIKE_10KM_FALSE(-57),
|
||||||
|
|
||||||
|
// id:58 text:Fuel Nearby
|
||||||
|
FUEL_NEARBY_TRUE(58),
|
||||||
|
FUEL_NEARBY_FALSE(-58),
|
||||||
|
|
||||||
|
// id:59 text:Food Nearby
|
||||||
|
FOOD_NEARBY_TRUE(59),
|
||||||
|
FOOD_NEARBY_FALSE(-59),
|
||||||
|
|
||||||
|
// id:60 text:Wireless Beacon
|
||||||
|
WIRELESS_BEACON_TRUE(60),
|
||||||
|
WIRELESS_BEACON_FALSE(-60),
|
||||||
|
|
||||||
|
// id:61 text:Partnership cache
|
||||||
|
PARTNERSHIP_CACHE_TRUE(61),
|
||||||
|
PARTNERSHIP_CACHE_FALSE(-61),
|
||||||
|
|
||||||
|
// id:62 text:Seasonal Access
|
||||||
|
SEASONAL_ACCESS_TRUE(62),
|
||||||
|
SEASONAL_ACCESS_FALSE(-62),
|
||||||
|
|
||||||
|
// id:63 text:Tourist Friendly
|
||||||
|
TOURIST_FRIENDLY_TRUE(63),
|
||||||
|
TOURIST_FRIENDLY_FALSE(-63),
|
||||||
|
|
||||||
|
// id:64 text:Tree Climbing
|
||||||
|
TREE_CLIMBING_TRUE(64),
|
||||||
|
TREE_CLIMBING_FALSE(-64),
|
||||||
|
|
||||||
|
// id:65 text:Front Yard (Private Residence)
|
||||||
|
FRONT_YARD_PRIVATE_RESIDENCE_TRUE(65),
|
||||||
|
FRONT_YARD_PRIVATE_RESIDENCE_FALSE(-65),
|
||||||
|
|
||||||
|
// id:66 text:Teamwork Required
|
||||||
|
TEAMWORK_REQUIRED_TRUE(66),
|
||||||
|
TEAMWORK_REQUIRED_FALSE(-66),
|
||||||
|
|
||||||
|
// id:67 text:geotour
|
||||||
|
GEOTOUR_TRUE(67),
|
||||||
|
GEOTOUR_FALSE(-67);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private final static List<Long> attributes = new ArrayList<>();
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private Attribute(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInc() {
|
public int getId() {
|
||||||
return inc;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInc(boolean inc) {
|
public void setId(int id) {
|
||||||
this.inc = inc;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public static Attribute groundspeakAttributeToAttribute(Long id, boolean inc, String text) {
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text) {
|
int idToCompare = id.intValue();
|
||||||
this.text = text;
|
|
||||||
|
if (!inc) {
|
||||||
|
idToCompare = -idToCompare;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Attribute t: Attribute.values()) {
|
||||||
|
if (t.getId() == idToCompare) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attributes.contains(id)) {
|
||||||
|
attributes.add(id);
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("// id:"+id+" text:"+text);
|
||||||
|
System.out.println(text.toUpperCase().replace(' ','_') + "_TRUE" + "(" + id + "),");
|
||||||
|
System.out.println(text.toUpperCase().replace(' ','_') + "_FALSE" + "(-" + id + "),");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("unknown attribute id:"+id+" inc:"+inc+" text:"+text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ public class Cache {
|
|||||||
private String placedBy;
|
private String placedBy;
|
||||||
@OneToOne(orphanRemoval = true)
|
@OneToOne(orphanRemoval = true)
|
||||||
private User owner;
|
private User owner;
|
||||||
@OneToOne(orphanRemoval = true)
|
|
||||||
private Type type;
|
private Type type;
|
||||||
private String container;
|
private String container;
|
||||||
@OneToMany(orphanRemoval = true)
|
|
||||||
private List<Attribute> attributes;
|
private List<Attribute> attributes;
|
||||||
private String difficulty;
|
private String difficulty;
|
||||||
private String terrain;
|
private String terrain;
|
||||||
|
|||||||
@@ -1,10 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright (c) 2013, Andreas Billmann <abi@geofroggerfx.de>
|
||||||
* To change this template file, choose Tools | Templates
|
* All rights reserved.
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package de.geofroggerfx.service;
|
package de.geofroggerfx.service;
|
||||||
|
|
||||||
|
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
|
||||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||||
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
|
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
|
||||||
import de.geofroggerfx.application.ProgressEvent;
|
import de.geofroggerfx.application.ProgressEvent;
|
||||||
@@ -37,31 +58,44 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
OObjectDatabaseTx database = dbService.getDatabase();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int currentCacheNumber = 0;
|
long start = System.currentTimeMillis();
|
||||||
int numberOfCaches = caches.size();
|
|
||||||
for (Cache cache : caches) {
|
for (Cache cache : caches) {
|
||||||
currentCacheNumber++;
|
|
||||||
fireEvent(new ProgressEvent("Database",
|
|
||||||
ProgressEvent.State.RUNNING,
|
|
||||||
"Save caches to Database " + currentCacheNumber + " / " + numberOfCaches,
|
|
||||||
(double) currentCacheNumber / (double) numberOfCaches));
|
|
||||||
|
|
||||||
Cache existingCache = findCacheById(cache.getId());
|
Cache existingCache = findCacheById(cache.getId());
|
||||||
if (existingCache != null) {
|
if (existingCache != null) {
|
||||||
database.delete(existingCache);
|
database.delete(existingCache);
|
||||||
}
|
}
|
||||||
database.save(cache);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long deletes = System.currentTimeMillis();
|
||||||
|
|
||||||
|
int currentCacheNumber = 0;
|
||||||
|
int numberOfCaches = caches.size();
|
||||||
|
database.declareIntent( new OIntentMassiveInsert() );
|
||||||
|
for (Cache cache : caches) {
|
||||||
|
currentCacheNumber++;
|
||||||
|
fireEvent(new ProgressEvent("Database",
|
||||||
|
ProgressEvent.State.RUNNING,
|
||||||
|
"Save caches to Database " + currentCacheNumber + " / " + numberOfCaches,
|
||||||
|
(double) currentCacheNumber / (double) numberOfCaches));
|
||||||
|
database.save(cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long saves = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.out.println("Time to delete: "+(deletes-start));
|
||||||
|
System.out.println("Time to save: "+(saves-deletes));
|
||||||
|
System.out.println("Time total: "+(saves-start));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
database.declareIntent( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("cache count: " + database.countClass(Cache.class));
|
System.out.println("cache count: " + database.countClass(Cache.class));
|
||||||
System.out.println("Log count: "+ database.countClass(Log.class));
|
System.out.println("Log count: "+ database.countClass(Log.class));
|
||||||
System.out.println("Waypoint count: "+ database.countClass(Waypoint.class));
|
System.out.println("Waypoint count: "+ database.countClass(Waypoint.class));
|
||||||
System.out.println("Attribute count: "+ database.countClass(Attribute.class));
|
|
||||||
|
|
||||||
fireEvent(new ProgressEvent("Database",
|
fireEvent(new ProgressEvent("Database",
|
||||||
ProgressEvent.State.FINISHED,
|
ProgressEvent.State.FINISHED,
|
||||||
|
|||||||
Reference in New Issue
Block a user