Merge branch 'nosql'
This commit is contained in:
@@ -53,10 +53,12 @@ dependencies {
|
|||||||
compile files('lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar', 'lib/ScenicView/ScenicView.jar')
|
compile files('lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar', 'lib/ScenicView/ScenicView.jar')
|
||||||
compile group: 'org.jdom', name: 'jdom2', version: '2.0.5'
|
compile group: 'org.jdom', name: 'jdom2', version: '2.0.5'
|
||||||
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.0.6'
|
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.0.6'
|
||||||
compile group: 'com.h2database', name: 'h2', version: '1.4.178'
|
|
||||||
compile group: 'org.eclipse.persistence', name: 'eclipselink', version: '2.5.0'
|
|
||||||
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.2.1'
|
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.2.1'
|
||||||
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: 'orientdb-core', 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'
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sun Sep 22 11:48:27 CEST 2013
|
#Fri Aug 15 19:56:32 CEST 2014
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
|
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-all.zip
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
|
|
||||||
|
|
||||||
<persistence-unit name="geocaches" transaction-type="RESOURCE_LOCAL">
|
|
||||||
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
|
|
||||||
|
|
||||||
<class>de.geofroggerfx.model.Attribute</class>
|
|
||||||
<class>de.geofroggerfx.model.Cache</class>
|
|
||||||
<class>de.geofroggerfx.model.Log</class>
|
|
||||||
<class>de.geofroggerfx.model.TravelBug</class>
|
|
||||||
<class>de.geofroggerfx.model.Type</class>
|
|
||||||
<class>de.geofroggerfx.model.User</class>
|
|
||||||
<class>de.geofroggerfx.model.Waypoint</class>
|
|
||||||
<class>de.geofroggerfx.model.CacheList</class>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
|
|
||||||
<property name="javax.persistence.jdbc.url" value="jdbc:h2:./geofroggerfxdb"/>
|
|
||||||
<property name="javax.persistence.jdbc.user" value="sa"/>
|
|
||||||
<property name="javax.persistence.jdbc.password" value="sa"/>
|
|
||||||
<!--<property name="eclipselink.logging.level" value="FINEST"/>-->
|
|
||||||
<property name="eclipselink.ddl-generation" value="create-tables" />
|
|
||||||
<property name="eclipselink.ddl-generation.output-mode" value="database" />
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</persistence-unit>
|
|
||||||
</persistence>
|
|
||||||
@@ -75,10 +75,10 @@ public class SessionContext {
|
|||||||
|
|
||||||
private void fireSessionEvent(String key) {
|
private void fireSessionEvent(String key) {
|
||||||
if (sessionListeners.containsKey(key)) {
|
if (sessionListeners.containsKey(key)) {
|
||||||
final List<SessionContextListener> listenerList = sessionListeners.get(key);
|
sessionListeners.
|
||||||
for (final SessionContextListener listener : listenerList) {
|
get(key).
|
||||||
listener.sessionContextChanged();
|
stream().
|
||||||
}
|
forEach(SessionContextListener::sessionContextChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class GeoFroggerFXMain extends Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() throws Exception {
|
public void stop() throws Exception {
|
||||||
weldContainer.instance().select(DatabaseService.class).get().getEntityManager().close();
|
weldContainer.instance().select(DatabaseService.class).get().close();
|
||||||
weld.shutdown();
|
weld.shutdown();
|
||||||
super.stop();
|
super.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -53,6 +52,7 @@ import jfxtras.labs.map.render.MapMarkable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@@ -116,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();
|
||||||
@@ -227,7 +221,7 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
icon.setImage(GeocachingIcons.getIcon(currentCache));
|
icon.setImage(GeocachingIcons.getIcon(currentCache));
|
||||||
placedByTextfield.setText(currentCache.getPlacedBy());
|
placedByTextfield.setText(currentCache.getPlacedBy());
|
||||||
ownerTextfield.setText(currentCache.getOwner().getName());
|
ownerTextfield.setText(currentCache.getOwner().getName());
|
||||||
date.setValue(currentCache.getMainWayPoint().getTime().toLocalDate());
|
date.setValue(currentCache.getMainWayPoint().getTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||||
typeTextfield.setText(currentCache.getType().toGroundspeakString());
|
typeTextfield.setText(currentCache.getType().toGroundspeakString());
|
||||||
containerTextfield.setText(currentCache.getContainer());
|
containerTextfield.setText(currentCache.getContainer());
|
||||||
fillShortDescription(currentCache);
|
fillShortDescription(currentCache);
|
||||||
|
|||||||
@@ -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
|
|
||||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
|
||||||
Double width = (Double) newValue;
|
Double width = (Double) newValue;
|
||||||
mapPane.setMapWidth(width);
|
mapPane.setMapWidth(width);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.heightProperty().addListener(new ChangeListener() {
|
this.heightProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
|
||||||
Double height = (Double) newValue;
|
Double height = (Double) newValue;
|
||||||
mapPane.setMapHeight(height);
|
mapPane.setMapHeight(height);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,20 +36,13 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.time.LocalDateTime;
|
import java.text.ParseException;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: describe the class
|
|
||||||
*
|
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
public class GroundspeakGPXReader implements GPXReader {
|
public class GroundspeakGPXReader implements GPXReader {
|
||||||
@@ -95,6 +88,9 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
public static final String DEFAULT_NAMESPACE_URL = "http://www.topografix.com/GPX/1/0";
|
public static final String DEFAULT_NAMESPACE_URL = "http://www.topografix.com/GPX/1/0";
|
||||||
public static final String GROUNDSPEAK_NAMESPACE_URL = "http://www.groundspeak.com/cache/1/0/1";
|
public static final String GROUNDSPEAK_NAMESPACE_URL = "http://www.groundspeak.com/cache/1/0/1";
|
||||||
|
|
||||||
|
// 2011-12-03T10:15:30+01:00
|
||||||
|
private final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
|
||||||
private final List<ProgressListener> listeners = new ArrayList<>();
|
private final List<ProgressListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
private final Map<Long, User> userCache = new HashMap<>();
|
private final Map<Long, User> userCache = new HashMap<>();
|
||||||
@@ -204,14 +200,14 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
final Element cacheElement = waypointElement.getChild(CACHE, groundspeakNamespace);
|
final Element cacheElement = waypointElement.getChild(CACHE, groundspeakNamespace);
|
||||||
setId(cacheElement, mainWaypoint);
|
setId(cacheElement, mainWaypoint);
|
||||||
parseCacheElement(cacheElement, cache);
|
parseCacheElement(cacheElement, cache);
|
||||||
} catch (DataConversionException | MalformedURLException e) {
|
} catch (DataConversionException | ParseException e) {
|
||||||
// TODO: do some batch error handling
|
// TODO: do some batch error handling
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseCacheElement(Element cacheElement, Cache cache) throws DataConversionException {
|
private void parseCacheElement(Element cacheElement, Cache cache) throws DataConversionException, ParseException {
|
||||||
setId(cacheElement, cache);
|
setId(cacheElement, cache);
|
||||||
setAvailable(cacheElement, cache);
|
setAvailable(cacheElement, cache);
|
||||||
setArchived(cacheElement, cache);
|
setArchived(cacheElement, cache);
|
||||||
@@ -259,7 +255,7 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
travelBug.setId(travelBugElement.getAttribute(ID).getLongValue());
|
travelBug.setId(travelBugElement.getAttribute(ID).getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLogs(Element cacheElement, Cache cache) throws DataConversionException {
|
private void setLogs(Element cacheElement, Cache cache) throws DataConversionException, ParseException {
|
||||||
final Element logsElement = cacheElement.getChild(LOGS, groundspeakNamespace);
|
final Element logsElement = cacheElement.getChild(LOGS, groundspeakNamespace);
|
||||||
if (logsElement != null) {
|
if (logsElement != null) {
|
||||||
final List<Log> logs = new ArrayList<>();
|
final List<Log> logs = new ArrayList<>();
|
||||||
@@ -305,9 +301,9 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
log.setId(logElement.getAttribute(ID).getLongValue());
|
log.setId(logElement.getAttribute(ID).getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDate(Element logElement, Log log) {
|
private void setDate(Element logElement, Log log) throws ParseException {
|
||||||
final String dateText = logElement.getChild(DATE, groundspeakNamespace).getTextTrim();
|
final String dateText = logElement.getChild(DATE, groundspeakNamespace).getTextTrim();
|
||||||
final LocalDateTime date = LocalDateTime.parse(dateText, DateTimeFormatter.ISO_DATE_TIME);
|
final Date date = DATE_FORMAT.parse(dateText);
|
||||||
log.setDate(date);
|
log.setDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,25 +345,17 @@ 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 {
|
||||||
|
final Attribute attribute = Attribute.groundspeakAttributeToAttribute(
|
||||||
|
attributeElement.getAttribute(ID).getLongValue(),
|
||||||
|
attributeElement.getAttribute(INC).getBooleanValue(),
|
||||||
|
attributeElement.getTextTrim());
|
||||||
attributes.add(attribute);
|
attributes.add(attribute);
|
||||||
setId(attributeElement, attribute);
|
} catch (Exception e) {
|
||||||
setInc(attributeElement, attribute);
|
e.printStackTrace();
|
||||||
setText(attributeElement, attribute);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -424,12 +412,12 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
waypoint.setSymbol(cacheElement.getChild(SYM, defaultNamespace).getTextTrim());
|
waypoint.setSymbol(cacheElement.getChild(SYM, defaultNamespace).getTextTrim());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrlName(Element cacheElement, Waypoint waypoint) throws MalformedURLException {
|
private void setUrlName(Element cacheElement, Waypoint waypoint) {
|
||||||
waypoint.setUrlName(cacheElement.getChild(URLNAME, defaultNamespace).getTextTrim());
|
waypoint.setUrlName(cacheElement.getChild(URLNAME, defaultNamespace).getTextTrim());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrl(Element cacheElement, Waypoint waypoint) throws MalformedURLException {
|
private void setUrl(Element cacheElement, Waypoint waypoint) {
|
||||||
waypoint.setUrl(new URL(cacheElement.getChild(URL, defaultNamespace).getTextTrim()));
|
waypoint.setUrl(cacheElement.getChild(URL, defaultNamespace).getTextTrim());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDescription(Element cacheElement, Waypoint waypoint) {
|
private void setDescription(Element cacheElement, Waypoint waypoint) {
|
||||||
@@ -445,9 +433,9 @@ public class GroundspeakGPXReader implements GPXReader {
|
|||||||
waypoint.setLongitude(cacheElement.getAttribute(LON).getDoubleValue());
|
waypoint.setLongitude(cacheElement.getAttribute(LON).getDoubleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTime(Element cacheElement, Waypoint waypoint) {
|
private void setTime(Element cacheElement, Waypoint waypoint) throws ParseException {
|
||||||
final String timeText = cacheElement.getChild(TIME, defaultNamespace).getTextTrim();
|
final String timeText = cacheElement.getChild(TIME, defaultNamespace).getTextTrim();
|
||||||
final LocalDateTime date = LocalDateTime.parse(timeText, DateTimeFormatter.ISO_DATE_TIME);
|
final Date date = DATE_FORMAT.parse(timeText);
|
||||||
waypoint.setTime(date);
|
waypoint.setTime(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,41 +25,319 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import java.util.ArrayList;
|
||||||
import javax.persistence.Id;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
public enum Attribute {
|
||||||
public class Attribute {
|
|
||||||
|
|
||||||
@Id
|
// id:1 text:Dogs
|
||||||
private Long id;
|
DOGS_TRUE(1),
|
||||||
private boolean inc;
|
DOGS_FALSE(-1),
|
||||||
private String text;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
int idToCompare = id.intValue();
|
||||||
|
|
||||||
|
if (!inc) {
|
||||||
|
idToCompare = -idToCompare;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String text) {
|
for (Attribute t: Attribute.values()) {
|
||||||
this.text = text;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,22 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class Cache {
|
public class Cache {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private boolean available;
|
private boolean available;
|
||||||
private boolean archived;
|
private boolean archived;
|
||||||
private boolean found;
|
private boolean found;
|
||||||
private String name;
|
private String name;
|
||||||
private String placedBy;
|
private String placedBy;
|
||||||
|
@OneToOne(orphanRemoval = true)
|
||||||
private User owner;
|
private User owner;
|
||||||
private Type type;
|
private Type type;
|
||||||
private String container;
|
private String container;
|
||||||
@@ -54,11 +54,13 @@ public class Cache {
|
|||||||
private String longDescription;
|
private String longDescription;
|
||||||
private boolean longDescriptionHtml;
|
private boolean longDescriptionHtml;
|
||||||
private String encodedHints;
|
private String encodedHints;
|
||||||
|
@OneToMany(orphanRemoval = true)
|
||||||
private List<Log> logs;
|
private List<Log> logs;
|
||||||
|
@OneToMany(orphanRemoval = true)
|
||||||
private List<TravelBug> travelBugs;
|
private List<TravelBug> travelBugs;
|
||||||
|
@OneToOne(orphanRemoval = true)
|
||||||
private Waypoint mainWayPoint;
|
private Waypoint mainWayPoint;
|
||||||
|
|
||||||
@OneToOne(fetch=FetchType.LAZY)
|
|
||||||
public Waypoint getMainWayPoint() {
|
public Waypoint getMainWayPoint() {
|
||||||
return mainWayPoint;
|
return mainWayPoint;
|
||||||
}
|
}
|
||||||
@@ -107,7 +109,6 @@ public class Cache {
|
|||||||
this.placedBy = placedBy;
|
this.placedBy = placedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToOne(fetch=FetchType.LAZY)
|
|
||||||
public User getOwner() {
|
public User getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,6 @@ public class Cache {
|
|||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,6 @@ public class Cache {
|
|||||||
this.container = container;
|
this.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ManyToMany(fetch=FetchType.LAZY)
|
|
||||||
public List<Attribute> getAttributes() {
|
public List<Attribute> getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
@@ -214,7 +213,6 @@ public class Cache {
|
|||||||
this.encodedHints = encodedHints;
|
this.encodedHints = encodedHints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToMany(fetch=FetchType.LAZY)
|
|
||||||
public List<Log> getLogs() {
|
public List<Log> getLogs() {
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@@ -223,7 +221,6 @@ public class Cache {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToMany(fetch=FetchType.LAZY)
|
|
||||||
public List<TravelBug> getTravelBugs() {
|
public List<TravelBug> getTravelBugs() {
|
||||||
return travelBugs;
|
return travelBugs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class CacheList {
|
public class CacheList {
|
||||||
|
|
||||||
@Id
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private List<Cache> caches;
|
private List<Cache> caches;
|
||||||
@@ -50,7 +44,6 @@ public class CacheList {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToMany(fetch= FetchType.LAZY)
|
|
||||||
public List<Cache> getCaches() {
|
public List<Cache> getCaches() {
|
||||||
return caches;
|
return caches;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,19 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.OneToOne;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class Log {
|
public class Log {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private LocalDateTime date;
|
private Date date;
|
||||||
private String type;
|
private String type;
|
||||||
|
@OneToOne(orphanRemoval = true)
|
||||||
private User finder;
|
private User finder;
|
||||||
private boolean textEncoded;
|
private boolean textEncoded;
|
||||||
private String text;
|
private String text;
|
||||||
@@ -50,11 +50,11 @@ public class Log {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDate(LocalDateTime date) {
|
public void setDate(Date date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,6 @@ public class Log {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.PERSIST)
|
|
||||||
public User getFinder() {
|
public User getFinder() {
|
||||||
return finder;
|
return finder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the application settings, like current user, etc.
|
* This class represents the application settings, like current user, etc.
|
||||||
*
|
*
|
||||||
* @author abi
|
* @author abi
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Long currentUserID = new Long(3906456);
|
private Long currentUserID = new Long(3906456);
|
||||||
|
|||||||
@@ -25,16 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class TravelBug {
|
public class TravelBug {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String ref;
|
private String ref;
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -25,16 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|||||||
@@ -25,25 +25,22 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.model;
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Billmann
|
* @author Andreas Billmann
|
||||||
*/
|
*/
|
||||||
@Entity
|
|
||||||
public class Waypoint {
|
public class Waypoint {
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private double latitude;
|
private double latitude;
|
||||||
private double longitude;
|
private double longitude;
|
||||||
private String name;
|
private String name;
|
||||||
private LocalDateTime time;
|
private Date time;
|
||||||
private String description;
|
private String description;
|
||||||
private URL url;
|
private String url;
|
||||||
private String urlName;
|
private String urlName;
|
||||||
private String symbol;
|
private String symbol;
|
||||||
private String type;
|
private String type;
|
||||||
@@ -72,11 +69,11 @@ public class Waypoint {
|
|||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTime(LocalDateTime time) {
|
public void setTime(Date time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getTime() {
|
public Date getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +93,11 @@ public class Waypoint {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(URL url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ public interface CacheService {
|
|||||||
*/
|
*/
|
||||||
void storeCaches(List<Cache> caches);
|
void storeCaches(List<Cache> caches);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find a single cache by id
|
||||||
|
* @param id id of the cache
|
||||||
|
* @return single cache
|
||||||
|
*/
|
||||||
|
Cache findCacheById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive all caches from the database
|
* Receive all caches from the database
|
||||||
* @param sortField sort the list based on the field
|
* @param sortField sort the list based on the field
|
||||||
|
|||||||
@@ -1,17 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
* 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.object.db.OObjectDatabaseTx;
|
||||||
import de.geofroggerfx.application.ProgressEvent;
|
import de.geofroggerfx.application.ProgressEvent;
|
||||||
import de.geofroggerfx.application.ProgressListener;
|
import de.geofroggerfx.application.ProgressListener;
|
||||||
import de.geofroggerfx.model.*;
|
import de.geofroggerfx.model.*;
|
||||||
import de.geofroggerfx.sql.DatabaseService;
|
import de.geofroggerfx.sql.DatabaseService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -20,8 +42,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class CacheServiceImpl implements CacheService {
|
public class CacheServiceImpl implements CacheService {
|
||||||
|
|
||||||
private static final int TRANSACTION_SIZE = 100;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DatabaseService dbService;
|
private DatabaseService dbService;
|
||||||
private final List<ProgressListener> listeners = new ArrayList<>();
|
private final List<ProgressListener> listeners = new ArrayList<>();
|
||||||
@@ -35,72 +55,79 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeCaches(List<Cache> caches) {
|
public void storeCaches(List<Cache> caches) {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int transactionNumber = 0;
|
long start = System.currentTimeMillis();
|
||||||
|
for (Cache cache : caches) {
|
||||||
|
Cache existingCache = findCacheById(cache.getId());
|
||||||
|
if (existingCache != null) {
|
||||||
|
database.delete(existingCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long deletes = System.currentTimeMillis();
|
||||||
|
|
||||||
int currentCacheNumber = 0;
|
int currentCacheNumber = 0;
|
||||||
int numberOfCaches = caches.size();
|
int numberOfCaches = caches.size();
|
||||||
|
database.declareIntent( new OIntentMassiveInsert() );
|
||||||
for (Cache cache : caches) {
|
for (Cache cache : caches) {
|
||||||
currentCacheNumber++;
|
currentCacheNumber++;
|
||||||
fireEvent(new ProgressEvent("Database",
|
fireEvent(new ProgressEvent("Database",
|
||||||
ProgressEvent.State.RUNNING,
|
ProgressEvent.State.RUNNING,
|
||||||
"Save caches to Database " + currentCacheNumber + " / " + numberOfCaches,
|
"Save caches to Database " + currentCacheNumber + " / " + numberOfCaches,
|
||||||
(double) currentCacheNumber / (double) numberOfCaches));
|
(double) currentCacheNumber / (double) numberOfCaches));
|
||||||
|
database.save(cache);
|
||||||
// begin transaction if the transaction counter is set to zero
|
|
||||||
if (transactionNumber == 0) { em.getTransaction().begin(); }
|
|
||||||
transactionNumber++;
|
|
||||||
|
|
||||||
em.merge(cache.getOwner());
|
|
||||||
em.merge(cache.getMainWayPoint());
|
|
||||||
|
|
||||||
for (Log log: cache.getLogs()) {
|
|
||||||
em.merge(log);
|
|
||||||
em.merge(log.getFinder());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Attribute attribute: cache.getAttributes()) {
|
|
||||||
em.merge(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TravelBug bug: cache.getTravelBugs()) {
|
long saves = System.currentTimeMillis();
|
||||||
em.merge(bug);
|
|
||||||
}
|
|
||||||
|
|
||||||
em.merge(cache);
|
System.out.println("Time to delete: "+(deletes-start));
|
||||||
|
System.out.println("Time to save: "+(saves-deletes));
|
||||||
|
System.out.println("Time total: "+(saves-start));
|
||||||
|
|
||||||
// comit every X caches
|
|
||||||
if (transactionNumber == TRANSACTION_SIZE) {
|
|
||||||
em.getTransaction().commit();
|
|
||||||
transactionNumber = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if there wasn?t a commit right before, commit the rest
|
|
||||||
if (transactionNumber != 0) {
|
|
||||||
em.getTransaction().commit();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
em.getTransaction().rollback();
|
} finally {
|
||||||
|
database.declareIntent( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("cache count: " + database.countClass(Cache.class));
|
||||||
|
System.out.println("Log count: "+ database.countClass(Log.class));
|
||||||
|
System.out.println("Waypoint count: "+ database.countClass(Waypoint.class));
|
||||||
|
|
||||||
fireEvent(new ProgressEvent("Database",
|
fireEvent(new ProgressEvent("Database",
|
||||||
ProgressEvent.State.FINISHED,
|
ProgressEvent.State.FINISHED,
|
||||||
"Caches are saved to Database"));
|
"Caches are saved to Database"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
public Cache findCacheById(Long id) {
|
||||||
|
Cache foundCache = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
|
String query = "select * from Cache where id="+id;
|
||||||
|
List<Cache> result = database.query(new OSQLSynchQuery<Cache>(query));
|
||||||
|
if (result != null && result.size() > 0) {
|
||||||
|
foundCache = result.get(0);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return foundCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction) {
|
public List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction) {
|
||||||
|
|
||||||
List<Cache> caches = new ArrayList<>();
|
List<Cache> caches = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
String query = "select c from Cache c order by c."+sortField.getFieldName()+" "+direction.toString();
|
String query = "select * from Cache order by "+sortField.getFieldName()+" "+direction.toString();
|
||||||
List<Cache> result = em.createQuery(query).getResultList();
|
List<Cache> result = database.query(new OSQLSynchQuery<Cache>(query));
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
caches = result;
|
caches = result;
|
||||||
}
|
}
|
||||||
@@ -122,9 +149,9 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
public List<CacheList> getAllCacheLists() {
|
public List<CacheList> getAllCacheLists() {
|
||||||
List<CacheList> lists = new ArrayList<>();
|
List<CacheList> lists = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
String query = "select l from CacheList l order by l.name";
|
String query = "select * from CacheList order by name";
|
||||||
List<CacheList> result = em.createQuery(query).getResultList();
|
List<CacheList> result = database.query(new OSQLSynchQuery<CacheList>(query));
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
lists = result;
|
lists = result;
|
||||||
}
|
}
|
||||||
@@ -139,10 +166,12 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
public boolean doesCacheListNameExist(String name) {
|
public boolean doesCacheListNameExist(String name) {
|
||||||
boolean doesExist = false;
|
boolean doesExist = false;
|
||||||
try {
|
try {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
String query = "select count(l) from CacheList l where l.name = :name";
|
String query = "select * from CacheList l where l.name = :name";
|
||||||
Long result = (Long)em.createQuery(query).setParameter("name", name).getSingleResult();
|
List<CacheList> result = database.query(new OSQLSynchQuery<CacheList>(query));
|
||||||
doesExist = result > 0;
|
if (result != null) {
|
||||||
|
doesExist = result.size() > 0;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -151,30 +180,21 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteCacheList(CacheList cacheList) {
|
public void deleteCacheList(CacheList cacheList) {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
try {
|
try {
|
||||||
em.getTransaction().begin();
|
database.delete(cacheList);
|
||||||
em.remove(cacheList);
|
|
||||||
em.getTransaction().commit();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
em.getTransaction().rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void storeCacheList(CacheList list) {
|
public void storeCacheList(CacheList list) {
|
||||||
EntityManager em = dbService.getEntityManager();
|
OObjectDatabaseTx database = dbService.getDatabase();
|
||||||
try {
|
try {
|
||||||
em.getTransaction().begin();
|
database.save(list);
|
||||||
em.merge(list);
|
|
||||||
em.getTransaction().commit();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
em.getTransaction().rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.sql;
|
package de.geofroggerfx.sql;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas
|
* @author Andreas
|
||||||
*/
|
*/
|
||||||
public interface DatabaseService {
|
public interface DatabaseService {
|
||||||
EntityManager getEntityManager();
|
OObjectDatabaseTx getDatabase();
|
||||||
|
void close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package de.geofroggerfx.sql;
|
package de.geofroggerfx.sql;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import com.orientechnologies.orient.core.db.record.ODatabaseRecord;
|
||||||
import javax.persistence.Persistence;
|
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas
|
* @author Andreas
|
||||||
@@ -35,18 +35,34 @@ import javax.persistence.Persistence;
|
|||||||
public class DatabaseServiceImpl implements DatabaseService {
|
public class DatabaseServiceImpl implements DatabaseService {
|
||||||
|
|
||||||
private static final String PERSISTENCE_UNIT_NAME = "geocaches";
|
private static final String PERSISTENCE_UNIT_NAME = "geocaches";
|
||||||
private EntityManagerFactory factory;
|
private OObjectDatabaseTx db ;
|
||||||
private EntityManager em;
|
|
||||||
|
|
||||||
public DatabaseServiceImpl() {
|
public DatabaseServiceImpl() {
|
||||||
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
|
db = new OObjectDatabaseTx("plocal:./"+PERSISTENCE_UNIT_NAME);
|
||||||
em = factory.createEntityManager();
|
if (!db.exists()) {
|
||||||
|
db.create();
|
||||||
|
} else {
|
||||||
|
db.open("admin", "admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
db.getEntityManager().registerEntityClasses("de.geofroggerfx.model");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OObjectDatabaseTx getDatabase() {
|
||||||
|
assert (db != null) : "no database available";
|
||||||
|
ODatabaseRecordThreadLocal.INSTANCE.set(db.getUnderlying().getUnderlying());
|
||||||
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityManager getEntityManager() {
|
public void close() {
|
||||||
assert (em != null) : "no entity manager available";
|
assert (db != null) : "no database available";
|
||||||
return em;
|
if (!db.isClosed()) {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user