OSDN Git Service

(no commit message)
authorcintake <gozilla3st@users.osdn.me>
Thu, 12 May 2016 15:35:47 +0000 (00:35 +0900)
committercintake <gozilla3st@users.osdn.me>
Thu, 12 May 2016 15:35:47 +0000 (00:35 +0900)
pom.xml
src/main/java/net/korabo/app/vaadin01/ent/Contact.java
src/main/java/net/korabo/app/vaadin01/ent/InstanceID.java [new file with mode: 0644]
src/main/java/net/korabo/app/vaadin01/ent/KBaseEntity.java [new file with mode: 0644]
src/main/java/net/korabo/app/vaadin01/srv/ContactBeanQuery.java [new file with mode: 0644]
src/main/java/net/korabo/app/vaadin01/srv/ContactService.java
src/main/webapp/VAADIN/themes/mytheme/addons.scss

diff --git a/pom.xml b/pom.xml
index 0030677..6fbdc3f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
        </dependencyManagement>
 
        <dependencies>
-      <!--<dependency org="javax.servlet.jsp" name="jsp-api" rev="2.2" />-->
+            <dependency>
+                <groupId>org.ow2.asm</groupId>
+                <artifactId>asm</artifactId>
+                <version>5.0.3</version>
+                <scope>compile</scope>
+            </dependency>
+            <!--<dependency org="javax.servlet.jsp" name="jsp-api" rev="2.2" />-->
                <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                <!--
                  Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).
                  
-                 For widgetset compilation, vaadin-client-compiler is automatically added on the
-                 compilation classpath by vaadin-maven-plugin so normally there is no need for an
-                 explicit dependency.
-               -->
-               <!--
-               <dependency>
-                       <groupId>com.vaadin</groupId>
-                       <artifactId>vaadin-client-compiler</artifactId>
-                       <scope>provided</scope>
-               </dependency>
-               -->
-               <dependency>
-                       <groupId>com.vaadin</groupId>
-                       <artifactId>vaadin-themes</artifactId>
-               </dependency>
-        <dependency>
-         <groupId>com.orientechnologies</groupId>
-         <artifactId>orientdb-server</artifactId>
-         <version>2.1.7</version>
-        </dependency>
-        <dependency>
-         <groupId>com.orientechnologies</groupId>
-         <artifactId>orientdb-enterprise</artifactId>
-         <version>2.1.7</version>
-        </dependency>
-        <dependency>
-         <groupId>com.orientechnologies</groupId>
-         <artifactId>orientdb-graphdb</artifactId>
-         <version>2.1.7</version>
-        </dependency>
-        <dependency>
-         <groupId>com.orientechnologies</groupId>
-         <artifactId>orientdb-object</artifactId>
-         <version>2.1.7</version>
-        </dependency>
-        <dependency>
-         <groupId>net.korabo.lib</groupId>
-         <artifactId>korabolib</artifactId>
-         <version>1.2.4</version>
-        </dependency>
-        <dependency>
-         <groupId>org.vaadin.addons</groupId>
-         <artifactId>dcharts-widget</artifactId>
-         <version>1.7.0</version>
-         <scope>compile</scope>
-        </dependency>
-      <dependency>
-         <groupId>org.vaadin.addons.lazyquerycontainer</groupId>
-         <artifactId>vaadin-lazyquerycontainer</artifactId>
-         <version>7.6.1.3</version>
-      </dependency>
-       </dependencies>
+          For widgetset compilation, vaadin-client-compiler is automatically added on the
+          compilation classpath by vaadin-maven-plugin so normally there is no need for an
+          explicit dependency.
+        -->
+        <!--
+        <dependency>
+                <groupId>com.vaadin</groupId>
+                <artifactId>vaadin-client-compiler</artifactId>
+                <scope>provided</scope>
+        </dependency>
+        -->
+        <dependency>
+            <groupId>com.vaadin</groupId>
+            <artifactId>vaadin-themes</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.vaadin.addons.lazyquerycontainer</groupId>
+            <artifactId>vaadin-lazyquerycontainer</artifactId>
+            <version>7.6.1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.tylproject.vaadin.addon.fieldbinder</groupId>
+            <artifactId>field-binder</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.orientechnologies</groupId>
+            <artifactId>orientdb-server</artifactId>
+            <version>2.1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.orientechnologies</groupId>
+            <artifactId>orientdb-enterprise</artifactId>
+            <version>2.1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.orientechnologies</groupId>
+            <artifactId>orientdb-graphdb</artifactId>
+            <version>2.1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.orientechnologies</groupId>
+            <artifactId>orientdb-object</artifactId>
+            <version>2.1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>net.korabo.lib</groupId>
+            <artifactId>korabolib</artifactId>
+            <version>1.2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.vaadin.addons</groupId>
+            <artifactId>dcharts-widget</artifactId>
+            <version>1.7.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.vaadin.addons.lazyquerycontainer</groupId>
+            <artifactId>vaadin-lazyquerycontainer</artifactId>
+            <version>7.6.1.3</version>
+        </dependency>
+    </dependencies>
 
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <version>3.3</version>
-                               <configuration>
-                                       <encoding>${project.encoding}</encoding>
-                                       <source>1.8</source>
-                                       <target>1.8</target>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-resources-plugin</artifactId>
-                               <version>2.6</version>
-                               <configuration>
-                                       <encoding>${project.encoding}</encoding>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-war-plugin</artifactId>
-                               <version>2.3</version>
-                               <configuration>
-                                       <failOnMissingWebXml>false</failOnMissingWebXml>
-                                       <!-- Exclude some unnecessary files generated by the GWT compiler. -->
-                                       <packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**,
-                                               WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>com.vaadin</groupId>
-                               <artifactId>vaadin-maven-plugin</artifactId>
-                               <version>${vaadin.plugin.version}</version>
-                               <configuration>
-                                       <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
-                                       <webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
-                                       <draftCompile>false</draftCompile>
-                                       <compileReport>false</compileReport>
-                                       <style>OBF</style>
-                                       <strict>true</strict>
-                                <runTarget>http://localhost:8888/vaadin01</runTarget>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <goals>
-                                                       <goal>update-theme</goal>
-                                                       <goal>update-widgetset</goal>
-                                                       <goal>compile</goal>
-                                                       <!-- disabled by default to use on-the-fly theme compilation -->
-                                                       <!-- <goal>compile-theme</goal> -->
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                               <version>2.4</version>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-clean-plugin</artifactId>
-                               <version>2.6.1</version>
-                               <!-- Clean up also any pre-compiled themes -->
-                               <configuration>
-                                       <filesets>
-                                               <fileset>
-                                                       <directory>src/main/webapp/VAADIN/themes</directory>
-                                                       <includes>
-                                                               <include>**/styles.css</include>
-                                                               <include>**/styles.scss.cache</include>
-                                                       </includes>
-                                               </fileset>
-                                       </filesets>
-                               </configuration>
-                       </plugin>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <encoding>${project.encoding}</encoding>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+                <configuration>
+                    <encoding>${project.encoding}</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>2.3</version>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <!-- Exclude some unnecessary files generated by the GWT compiler. -->
+                    <packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**,
+                        WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>com.vaadin</groupId>
+                <artifactId>vaadin-maven-plugin</artifactId>
+                <version>${vaadin.plugin.version}</version>
+                <configuration>
+                    <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
+                    <webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
+                    <draftCompile>false</draftCompile>
+                    <compileReport>false</compileReport>
+                    <style>OBF</style>
+                    <strict>true</strict>
+                    <runTarget>http://localhost:8888/vaadin01</runTarget>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>update-theme</goal>
+                            <goal>update-widgetset</goal>
+                            <goal>compile</goal>
+                            <!-- disabled by default to use on-the-fly theme compilation -->
+                            <!-- <goal>compile-theme</goal> -->
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.4</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>2.6.1</version>
+                <!-- Clean up also any pre-compiled themes -->
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>src/main/webapp/VAADIN/themes</directory>
+                            <includes>
+                                <include>**/styles.css</include>
+                                <include>**/styles.scss.cache</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
 
-                       <!-- The Jetty plugin allows us to easily test the development build by
-                               running jetty:run on the command line. -->
-                       <plugin>
-                               <groupId>org.eclipse.jetty</groupId>
-                               <artifactId>jetty-maven-plugin</artifactId>
-                               <version>${jetty.plugin.version}</version>
-                               <configuration>
-                                   <scanIntervalSeconds>2</scanIntervalSeconds>
-                               </configuration>
-                       </plugin>
-               </plugins>
+            <!-- The Jetty plugin allows us to easily test the development build by
+            running jetty:run on the command line. -->
+            <plugin>
+                <groupId>org.eclipse.jetty</groupId>
+                <artifactId>jetty-maven-plugin</artifactId>
+                <version>${jetty.plugin.version}</version>
+                <configuration>
+                    <scanIntervalSeconds>2</scanIntervalSeconds>
+                </configuration>
+            </plugin>
+        </plugins>
 
-               <pluginManagement>
-                       <plugins>
-                               <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
-                               <!-- TODO Remove when http://dev.vaadin.com/ticket/14924 is resolved -->
-                               <plugin>
-                                       <groupId>org.eclipse.m2e</groupId>
-                                       <artifactId>lifecycle-mapping</artifactId>
-                                       <version>1.0.0</version>
-                                       <configuration>
-                                               <lifecycleMappingMetadata>
-                                                       <pluginExecutions>
-                                                               <pluginExecution>
-                                                                       <pluginExecutionFilter>
-                                                                               <groupId>com.vaadin</groupId>
-                                                                               <artifactId>
-                                                                                       vaadin-maven-plugin
-                                                                               </artifactId>
-                                                                               <versionRange>[7.1.11,)</versionRange>
-                                                                               <goals>
-                                                                                       <goal>resources</goal>
-                                                                                       <goal>update-widgetset</goal>
-                                                                                       <goal>compile</goal>
-                                                                                       <goal>compile-theme</goal>
-                                                                                       <goal>update-theme</goal>
-                                                                               </goals>
-                                                                       </pluginExecutionFilter>
-                                                                       <action>
-                                                                               <ignore></ignore>
-                                                                       </action>
-                                                               </pluginExecution>
-                                                       </pluginExecutions>
-                                               </lifecycleMappingMetadata>
-                                       </configuration>
-                               </plugin>
-                       </plugins>
-               </pluginManagement>
+        <pluginManagement>
+            <plugins>
+                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+                <!-- TODO Remove when http://dev.vaadin.com/ticket/14924 is resolved -->
+                <plugin>
+                    <groupId>org.eclipse.m2e</groupId>
+                    <artifactId>lifecycle-mapping</artifactId>
+                    <version>1.0.0</version>
+                    <configuration>
+                        <lifecycleMappingMetadata>
+                            <pluginExecutions>
+                                <pluginExecution>
+                                    <pluginExecutionFilter>
+                                        <groupId>com.vaadin</groupId>
+                                        <artifactId>
+                                            vaadin-maven-plugin
+                                        </artifactId>
+                                        <versionRange>[7.1.11,)</versionRange>
+                                        <goals>
+                                            <goal>resources</goal>
+                                            <goal>update-widgetset</goal>
+                                            <goal>compile</goal>
+                                            <goal>compile-theme</goal>
+                                            <goal>update-theme</goal>
+                                        </goals>
+                                    </pluginExecutionFilter>
+                                    <action>
+                                        <ignore></ignore>
+                                    </action>
+                                </pluginExecution>
+                            </pluginExecutions>
+                        </lifecycleMappingMetadata>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
 
-       </build>
+    </build>
 
-       <profiles>
-               <profile>
-                       <!-- Vaadin pre-release repositories -->
-                       <id>vaadin-prerelease</id>
-                       <activation>
-                               <activeByDefault>false</activeByDefault>
-                       </activation>
+    <profiles>
+        <profile>
+            <!-- Vaadin pre-release repositories -->
+            <id>vaadin-prerelease</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
                        
-                       <repositories>
-                               <repository>
-                                       <id>vaadin-prereleases</id>
-                                       <url>http://maven.vaadin.com/vaadin-prereleases</url>
-                               </repository>
+            <repositories>
+                <repository>
+                    <id>vaadin-prereleases</id>
+                    <url>http://maven.vaadin.com/vaadin-prereleases</url>
+                </repository>
                 <repository>
-                   <id>vaadin-addons</id>
-                   <url>http://maven.vaadin.com/vaadin-addons</url>
+                    <id>vaadin-addons</id>
+                    <url>http://maven.vaadin.com/vaadin-addons</url>
                 </repository>
-                       </repositories>
-                       <pluginRepositories>
-                               <pluginRepository>
-                                       <id>vaadin-prereleases</id>
-                                       <url>http://maven.vaadin.com/vaadin-prereleases</url>
-                               </pluginRepository>
-                       </pluginRepositories>
-               </profile>
-       </profiles>
+            </repositories>
+            <pluginRepositories>
+                <pluginRepository>
+                    <id>vaadin-prereleases</id>
+                    <url>http://maven.vaadin.com/vaadin-prereleases</url>
+                </pluginRepository>
+            </pluginRepositories>
+        </profile>
+    </profiles>
 
 </project>
index 0b8b7f0..269653a 100644 (file)
@@ -5,18 +5,19 @@
  */
 package net.korabo.app.vaadin01.ent;
 
+import com.orientechnologies.orient.core.id.ORID;
 import java.io.Serializable;
 import java.util.Date;
 import javax.persistence.Id;
+import javax.persistence.Version;
 import net.korabo.lib.beans.InstanceUtil;
 
 /**
  *
  * @author cintake
  */
-public class Contact implements Serializable, Cloneable {
+public class Contact extends KBaseEntity implements Serializable, Cloneable {
 
-    private Long id;
 
     private String firstName = "";
     private String lastName = "";
@@ -24,13 +25,7 @@ public class Contact implements Serializable, Cloneable {
     private String email = "";
     private Date birthDate;
 
-    public Long getId() {
-        return id;
-    }
 
-    public void setId(Long id) {
-        this.id = id;
-    }
 
     public String getFirstName() {
         return firstName;
diff --git a/src/main/java/net/korabo/app/vaadin01/ent/InstanceID.java b/src/main/java/net/korabo/app/vaadin01/ent/InstanceID.java
new file mode 100644 (file)
index 0000000..a2f9cbf
--- /dev/null
@@ -0,0 +1,32 @@
+/*\r
+ * To change this license header, choose License Headers in Project Properties.\r
+ * To change this template file, choose Tools | Templates\r
+ * and open the template in the editor.\r
+ */\r
+package net.korabo.app.vaadin01.ent;\r
+\r
+/**\r
+ *\r
+ * @author manager\r
+ */\r
+public class InstanceID {\r
+    private String ClassID;\r
+    private Long ID;\r
+\r
+    public String getClassID() {\r
+        return ClassID;\r
+    }\r
+\r
+    public void setClassID(String ClassID) {\r
+        this.ClassID = ClassID;\r
+    }\r
+\r
+    public Long getID() {\r
+        return ID;\r
+    }\r
+\r
+    public void setID(Long ID) {\r
+        this.ID = ID;\r
+    }\r
+    \r
+}\r
diff --git a/src/main/java/net/korabo/app/vaadin01/ent/KBaseEntity.java b/src/main/java/net/korabo/app/vaadin01/ent/KBaseEntity.java
new file mode 100644 (file)
index 0000000..fcfcb39
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.vaadin01.ent;
+
+import com.orientechnologies.orient.core.id.ORID;
+import javax.persistence.Id;
+import javax.persistence.Version;
+
+/**
+ *
+ * @author manager
+ */
+public abstract class KBaseEntity {
+    
+    @Id
+    protected ORID id;
+    @Version
+    protected Long version;
+
+    public ORID getId() {
+        return id;
+    }
+
+    public Long getVersion() {
+        return version;
+    }
+    
+}
diff --git a/src/main/java/net/korabo/app/vaadin01/srv/ContactBeanQuery.java b/src/main/java/net/korabo/app/vaadin01/srv/ContactBeanQuery.java
new file mode 100644 (file)
index 0000000..895ce1e
--- /dev/null
@@ -0,0 +1,71 @@
+/*\r
+ * To change this license header, choose License Headers in Project Properties.\r
+ * To change this template file, choose Tools | Templates\r
+ * and open the template in the editor.\r
+ */\r
+package net.korabo.app.vaadin01.srv;\r
+\r
+import com.orientechnologies.orient.core.db.OPartitionedDatabasePool;\r
+import com.orientechnologies.orient.object.db.OObjectDatabaseTx;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import net.korabo.app.vaadin01.ent.Contact;\r
+import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;\r
+import org.vaadin.addons.lazyquerycontainer.QueryDefinition;\r
+\r
+/**\r
+ *\r
+ * @author manager\r
+ */\r
+public class ContactBeanQuery extends AbstractBeanQuery<Contact>{\r
+\r
+    private final OPartitionedDatabasePool pool;\r
+\r
+    public ContactBeanQuery(QueryDefinition definition,\r
+                       Map<String, Object> queryConfiguration, Object[] sortPropertyIds,\r
+                       boolean[] sortStates) {\r
+               super(definition, queryConfiguration, sortPropertyIds, sortStates);\r
+                this.pool = (OPartitionedDatabasePool)queryConfiguration.get("OPartitionedDatabasePool");\r
+       }\r
+\r
+    \r
+    @Override\r
+    protected Contact constructBean() {\r
+        return new Contact();\r
+    }\r
+\r
+    @Override\r
+    public int size() {\r
+        try (\r
+                OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {\r
+            db.getEntityManager().registerEntityClass(Contact.class);\r
+            return (int) db.countClass(Contact.class);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected List<Contact> loadBeans(int i, int i1) {\r
+        ArrayList arrayList = new ArrayList();\r
+        try (\r
+                OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {\r
+            db.getEntityManager().registerEntityClass(Contact.class);\r
+            for (Contact contact : db.browseClass(Contact.class).) {\r
+                boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())\r
+                        || contact.toString().toLowerCase()\r
+                        .contains(stringFilter.toLowerCase());\r
+                if (passesFilter) {\r
+//                contact = db.detach(contact);\r
+                    arrayList.add(db.detach(contact, true));\r
+                }\r
+            }\r
+\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected void saveBeans(List<Contact> list, List<Contact> list1, List<Contact> list2) {\r
+        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
+    }\r
+    \r
+}\r
index 7533df5..048ce3b 100644 (file)
@@ -11,15 +11,11 @@ import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Random;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import net.korabo.app.vaadin01.ent.Contact;
-import net.korabo.lib.beans.InstanceUtil;
 
 /**
  *
@@ -40,7 +36,7 @@ public class ContactService {
     private static ContactService instance;
     private static OPartitionedDatabasePool pool;
 
-    public static ContactService createDemoService(){
+    public static ContactService createDemoService() {
         try {
             return createService0();
         } catch (IOException ex) {
@@ -48,7 +44,7 @@ public class ContactService {
         }
         return null;
     }
-    
+
     private static ContactService createService0() throws IOException {
         if (instance == null) {
 
@@ -65,7 +61,7 @@ public class ContactService {
             String url = remote + nameDB;
 
             OServerAdmin serverAdmin = new OServerAdmin(url).connect("root", "korabo");
-            if (!serverAdmin.listDatabases().containsKey(nameDB)){
+            if (!serverAdmin.listDatabases().containsKey(nameDB)) {
                 serverAdmin.createDatabase(nameDB, "object", "plocal");
                 System.out.println(" Database '" + nameDB + "' created!..");
             }
@@ -75,6 +71,7 @@ public class ContactService {
             try (
                     OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
                 db.getEntityManager().registerEntityClass(Contact.class);
+                
                 if (db.countClass(Contact.class) == 0) {
                     // init
                     Random r = new Random(0);
@@ -89,7 +86,7 @@ public class ContactService {
                         cal.set(1930 + r.nextInt(70),
                                 r.nextInt(11), r.nextInt(28));
                         contact.setBirthDate(cal.getTime());
-                        db.save(contact);
+                        db.attachAndSave(contact);
                     }
                     db.commit();
                 }
@@ -109,13 +106,13 @@ public class ContactService {
                 OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
             db.getEntityManager().registerEntityClass(Contact.class);
             for (Contact contact : db.browseClass(Contact.class)) {
-              boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
-                || contact.toString().toLowerCase()
-                  .contains(stringFilter.toLowerCase());
-              if (passesFilter) {
-                contact = db.detach(contact);
-                arrayList.add(contact);
-              }
+                boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
+                        || contact.toString().toLowerCase()
+                        .contains(stringFilter.toLowerCase());
+                if (passesFilter) {
+//                contact = db.detach(contact);
+                    arrayList.add(db.detach(contact, true));
+                }
             }
 
         }
@@ -156,6 +153,13 @@ public class ContactService {
     }
 
     public synchronized void save(Contact entry) {
+        try (
+                OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
+            db.getEntityManager().registerEntityClass(Contact.class);
+            db.begin();
+            db.attachAndSave(entry);
+            db.commit();
+        }
 //        if (entry.getId() == null) {
 //            entry.setId(nextId++);
 //        }
index a5670b7..754ba4b 100644 (file)
@@ -1,7 +1,7 @@
-/* This file is automatically managed and will be overwritten from time to time. */
-/* Do not manually edit this file. */
-
-/* Import and include this mixin into your project theme to include the addon themes */
-@mixin addons {
-}
-
+/* This file is automatically managed and will be overwritten from time to time. */\r
+/* Do not manually edit this file. */\r
+\r
+/* Import and include this mixin into your project theme to include the addon themes */\r
+@mixin addons {\r
+}\r
+\r