From 056e856c0d0dfaece0d9fb819984a7704b177ec6 Mon Sep 17 00:00:00 2001 From: cintake Date: Fri, 13 May 2016 00:35:47 +0900 Subject: [PATCH] --- pom.xml | 420 +++++++++++---------- .../java/net/korabo/app/vaadin01/ent/Contact.java | 11 +- .../net/korabo/app/vaadin01/ent/InstanceID.java | 32 ++ .../net/korabo/app/vaadin01/ent/KBaseEntity.java | 31 ++ .../korabo/app/vaadin01/srv/ContactBeanQuery.java | 71 ++++ .../korabo/app/vaadin01/srv/ContactService.java | 34 +- src/main/webapp/VAADIN/themes/mytheme/addons.scss | 14 +- 7 files changed, 381 insertions(+), 232 deletions(-) create mode 100644 src/main/java/net/korabo/app/vaadin01/ent/InstanceID.java create mode 100644 src/main/java/net/korabo/app/vaadin01/ent/KBaseEntity.java create mode 100644 src/main/java/net/korabo/app/vaadin01/srv/ContactBeanQuery.java diff --git a/pom.xml b/pom.xml index 0030677..6fbdc3f 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,13 @@ - + + org.ow2.asm + asm + 5.0.3 + compile + + javax.servlet javax.servlet-api @@ -74,214 +80,224 @@ - - - com.vaadin - vaadin-themes - - - com.orientechnologies - orientdb-server - 2.1.7 - - - com.orientechnologies - orientdb-enterprise - 2.1.7 - - - com.orientechnologies - orientdb-graphdb - 2.1.7 - - - com.orientechnologies - orientdb-object - 2.1.7 - - - net.korabo.lib - korabolib - 1.2.4 - - - org.vaadin.addons - dcharts-widget - 1.7.0 - compile - - - org.vaadin.addons.lazyquerycontainer - vaadin-lazyquerycontainer - 7.6.1.3 - - + 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. + --> + + + com.vaadin + vaadin-themes + + + org.vaadin.addons.lazyquerycontainer + vaadin-lazyquerycontainer + 7.6.1.3 + + + org.tylproject.vaadin.addon.fieldbinder + field-binder + 1.4 + + + com.orientechnologies + orientdb-server + 2.1.7 + + + com.orientechnologies + orientdb-enterprise + 2.1.7 + + + com.orientechnologies + orientdb-graphdb + 2.1.7 + + + com.orientechnologies + orientdb-object + 2.1.7 + + + net.korabo.lib + korabolib + 1.2.4 + + + org.vaadin.addons + dcharts-widget + 1.7.0 + compile + + + org.vaadin.addons.lazyquerycontainer + vaadin-lazyquerycontainer + 7.6.1.3 + + - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - ${project.encoding} - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - ${project.encoding} - - - - org.apache.maven.plugins - maven-war-plugin - 2.3 - - false - - WEB-INF/classes/VAADIN/gwt-unitCache/**, - WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.plugin.version} - - -Xmx512M -Xss1024k - ${basedir}/target/classes/VAADIN/widgetsets - false - false - - true - http://localhost:8888/vaadin01 - - - - - update-theme - update-widgetset - compile - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - - - org.apache.maven.plugins - maven-clean-plugin - 2.6.1 - - - - - src/main/webapp/VAADIN/themes - - **/styles.css - **/styles.scss.cache - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + ${project.encoding} + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + ${project.encoding} + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + WEB-INF/classes/VAADIN/gwt-unitCache/**, + WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + -Xmx512M -Xss1024k + ${basedir}/target/classes/VAADIN/widgetsets + false + false + + true + http://localhost:8888/vaadin01 + + + + + update-theme + update-widgetset + compile + + + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + org.apache.maven.plugins + maven-clean-plugin + 2.6.1 + + + + + src/main/webapp/VAADIN/themes + + **/styles.css + **/styles.scss.cache + + + + + - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.plugin.version} - - 2 - - - + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.plugin.version} + + 2 + + + - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - com.vaadin - - vaadin-maven-plugin - - [7.1.11,) - - resources - update-widgetset - compile - compile-theme - update-theme - - - - - - - - - - - - + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + com.vaadin + + vaadin-maven-plugin + + [7.1.11,) + + resources + update-widgetset + compile + compile-theme + update-theme + + + + + + + + + + + + - + - - - - vaadin-prerelease - - false - + + + + vaadin-prerelease + + false + - - - vaadin-prereleases - http://maven.vaadin.com/vaadin-prereleases - + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + - vaadin-addons - http://maven.vaadin.com/vaadin-addons + vaadin-addons + http://maven.vaadin.com/vaadin-addons - - - - vaadin-prereleases - http://maven.vaadin.com/vaadin-prereleases - - - - + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + + diff --git a/src/main/java/net/korabo/app/vaadin01/ent/Contact.java b/src/main/java/net/korabo/app/vaadin01/ent/Contact.java index 0b8b7f0..269653a 100644 --- a/src/main/java/net/korabo/app/vaadin01/ent/Contact.java +++ b/src/main/java/net/korabo/app/vaadin01/ent/Contact.java @@ -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 index 0000000..a2f9cbf --- /dev/null +++ b/src/main/java/net/korabo/app/vaadin01/ent/InstanceID.java @@ -0,0 +1,32 @@ +/* + * 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; + +/** + * + * @author manager + */ +public class InstanceID { + private String ClassID; + private Long ID; + + public String getClassID() { + return ClassID; + } + + public void setClassID(String ClassID) { + this.ClassID = ClassID; + } + + public Long getID() { + return ID; + } + + public void setID(Long ID) { + this.ID = ID; + } + +} 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 index 0000000..fcfcb39 --- /dev/null +++ b/src/main/java/net/korabo/app/vaadin01/ent/KBaseEntity.java @@ -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 index 0000000..895ce1e --- /dev/null +++ b/src/main/java/net/korabo/app/vaadin01/srv/ContactBeanQuery.java @@ -0,0 +1,71 @@ +/* + * 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.srv; + +import com.orientechnologies.orient.core.db.OPartitionedDatabasePool; +import com.orientechnologies.orient.object.db.OObjectDatabaseTx; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import net.korabo.app.vaadin01.ent.Contact; +import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; +import org.vaadin.addons.lazyquerycontainer.QueryDefinition; + +/** + * + * @author manager + */ +public class ContactBeanQuery extends AbstractBeanQuery{ + + private final OPartitionedDatabasePool pool; + + public ContactBeanQuery(QueryDefinition definition, + Map queryConfiguration, Object[] sortPropertyIds, + boolean[] sortStates) { + super(definition, queryConfiguration, sortPropertyIds, sortStates); + this.pool = (OPartitionedDatabasePool)queryConfiguration.get("OPartitionedDatabasePool"); + } + + + @Override + protected Contact constructBean() { + return new Contact(); + } + + @Override + public int size() { + try ( + OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) { + db.getEntityManager().registerEntityClass(Contact.class); + return (int) db.countClass(Contact.class); + } + } + + @Override + protected List loadBeans(int i, int i1) { + ArrayList arrayList = new ArrayList(); + try ( + 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(db.detach(contact, true)); + } + } + + } + } + + @Override + protected void saveBeans(List list, List list1, List list2) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java b/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java index 7533df5..048ce3b 100644 --- a/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java +++ b/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java @@ -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++); // } diff --git a/src/main/webapp/VAADIN/themes/mytheme/addons.scss b/src/main/webapp/VAADIN/themes/mytheme/addons.scss index a5670b7..754ba4b 100644 --- a/src/main/webapp/VAADIN/themes/mytheme/addons.scss +++ b/src/main/webapp/VAADIN/themes/mytheme/addons.scss @@ -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. */ +/* Do not manually edit this file. */ + +/* Import and include this mixin into your project theme to include the addon themes */ +@mixin addons { +} + -- 2.11.0