• R/O
  • HTTP
  • SSH
  • HTTPS

vaadin: Commit

sample


Commit MetaInfo

Revision47669e506d3f49d40a42435e39c49586644eb570 (tree)
Time2016-05-05 15:38:36
Authormanager <manager@YOUR...>
Commitermanager

Log Message

(empty log message)

Change Summary

Incremental Difference

--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
1+/target/
\ No newline at end of file
--- a/pom.xml
+++ b/pom.xml
@@ -100,6 +100,16 @@
100100 <version>2.1.7</version>
101101 </dependency>
102102 <dependency>
103+ <groupId>com.orientechnologies</groupId>
104+ <artifactId>orientdb-graphdb</artifactId>
105+ <version>2.1.7</version>
106+ </dependency>
107+ <dependency>
108+ <groupId>com.orientechnologies</groupId>
109+ <artifactId>orientdb-object</artifactId>
110+ <version>2.1.7</version>
111+ </dependency>
112+ <dependency>
103113 <groupId>net.korabo.lib</groupId>
104114 <artifactId>korabolib</artifactId>
105115 <version>1.2.4</version>
--- a/src/main/java/net/korabo/app/orientdb/AppServletContextListener.java
+++ b/src/main/java/net/korabo/app/orientdb/AppServletContextListener.java
@@ -8,10 +8,13 @@ package net.korabo.app.orientdb;
88 import com.orientechnologies.orient.server.OServer;
99 import com.orientechnologies.orient.server.OServerMain;
1010 import java.io.File;
11+import java.io.FileOutputStream;
12+import java.net.URI;
1113 import java.util.Properties;
1214 import javax.servlet.ServletContextEvent;
1315 import javax.servlet.ServletContextListener;
1416 import javax.servlet.annotation.WebListener;
17+import net.korabo.lib.KConstant;
1518 import net.korabo.lib.StreamUtil;
1619 import net.korabo.lib.UriUtil;
1720 import net.korabo.lib.file.FileUriUtil;
@@ -40,21 +43,21 @@ public class AppServletContextListener implements ServletContextListener{
4043 String orientDB = UriUtil.concatPath(home, "OrientDB");
4144 String orientDBcfg = UriUtil.concatPath(orientDB, "config", "orientdb-server-config.xml");
4245 String orientDBwww = UriUtil.concatPath(orientDB, "www");
43- Properties props = System.getProperties();
44- props.setProperty("ORIENTDB_HOME", orientDB);
46+ Properties props = System.getProperties();
47+ props.setProperty("ORIENTDB_HOME", orientDB);
4548 props.setProperty("orientdb.www.path", orientDBwww);
4649
4750 try {
48- File cfgFile = FileUriUtil.getFileFor(orientDBcfg);
49- SysFilesUtil.chkAndMake(cfgFile);
50- if (cfgFile.length() == 0){
51- // initialize
52-
53-
54- }
55- OServer server = OServerMain.create();
56- server.startup(FileUriUtil.getFileFor(orientDBcfg));
57- server.activate();
51+ File cfgFile = FileUriUtil.getFileFor(orientDBcfg);
52+ SysFilesUtil.chkAndMake(cfgFile);
53+ if (cfgFile.length() == 0){
54+ // initialize
55+ String rp = ResourceFilesUtil.findPathFromClasspath("net.korabo.app.orientdb.smplconfig.xml");
56+ StreamUtil.copy(FileUriUtil.getUriFor(rp).toURL().openStream(), new FileOutputStream(cfgFile),true);
57+ }
58+ OServer server = OServerMain.create();
59+ server.startup(FileUriUtil.getFileFor(orientDBcfg));
60+ server.activate();
5861 } catch (Exception e) {
5962 System.out.println(e.getMessage() + e.getStackTrace());
6063 }
--- a/src/main/java/net/korabo/app/vaadin01/ent/Contact.java
+++ b/src/main/java/net/korabo/app/vaadin01/ent/Contact.java
@@ -7,6 +7,7 @@ package net.korabo.app.vaadin01.ent;
77
88 import java.io.Serializable;
99 import java.util.Date;
10+import javax.persistence.Id;
1011 import net.korabo.lib.beans.InstanceUtil;
1112
1213 /**
--- a/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java
+++ b/src/main/java/net/korabo/app/vaadin01/srv/ContactService.java
@@ -5,6 +5,10 @@
55 */
66 package net.korabo.app.vaadin01.srv;
77
8+import com.orientechnologies.orient.client.remote.OServerAdmin;
9+import com.orientechnologies.orient.core.db.OPartitionedDatabasePool;
10+import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
11+import java.io.IOException;
812 import java.util.ArrayList;
913 import java.util.Calendar;
1014 import java.util.Collections;
@@ -22,37 +26,73 @@ import net.korabo.lib.beans.InstanceUtil;
2226 * @author cintake
2327 */
2428 public class ContactService {
25-
26- // Create dummy data by randomly combining first and last names
27- static String[] fnames = { "Peter", "Alice", "John", "Mike", "Olivia",
28- "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", "Lisa",
29- "Linda", "Timothy", "Daniel", "Brian", "George", "Scott",
30- "Jennifer" };
31- static String[] lnames = { "Smith", "Johnson", "Williams", "Jones",
32- "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor",
33- "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin",
34- "Thompson", "Young", "King", "Robinson" };
29+
30+ // Create dummy data by randomly combining first and last names
31+ static String[] fnames = {"Peter", "Alice", "John", "Mike", "Olivia",
32+ "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", "Lisa",
33+ "Linda", "Timothy", "Daniel", "Brian", "George", "Scott",
34+ "Jennifer"};
35+ static String[] lnames = {"Smith", "Johnson", "Williams", "Jones",
36+ "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor",
37+ "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin",
38+ "Thompson", "Young", "King", "Robinson"};
3539
3640 private static ContactService instance;
41+ private static OPartitionedDatabasePool pool;
3742
38- public static ContactService createDemoService() {
43+ public static ContactService createDemoService(){
44+ try {
45+ return createService0();
46+ } catch (IOException ex) {
47+ Logger.getLogger(ContactService.class.getName()).log(Level.SEVERE, null, ex);
48+ }
49+ return null;
50+ }
51+
52+ private static ContactService createService0() throws IOException {
3953 if (instance == null) {
4054
4155 final ContactService contactService = new ContactService();
56+ // OrientDB
57+// ODatabaseDocumentTx db =
58+// new ODatabaseDocumentTx("remote:127.0.0.1/DocumentTest")
59+// .open("root", "korabo");
60+// OPartitionedDatabasePool pool = new OPartitionedDatabasePool("remote:127.0.0.1/dbtest","root","korabo");
61+// pool.
62+// OObjectDatabaseTx db = new OObjectDatabaseTx("remote:127.0.0.1/dbtest");
63+ String remote = "remote:127.0.0.1/";
64+ String nameDB = "TestPartitioned2";
65+ String url = remote + nameDB;
4266
43- Random r = new Random(0);
44- Calendar cal = Calendar.getInstance();
45- for (int i = 0; i < 100; i++) {
46- Contact contact = new Contact();
47- contact.setFirstName(fnames[r.nextInt(fnames.length)]);
48- contact.setLastName(lnames[r.nextInt(fnames.length)]);
49- contact.setEmail(contact.getFirstName().toLowerCase() + "@"
50- + contact.getLastName().toLowerCase() + ".com");
51- contact.setPhone("+ 358 555 " + (100 + r.nextInt(900)));
52- cal.set(1930 + r.nextInt(70),
53- r.nextInt(11), r.nextInt(28));
54- contact.setBirthDate(cal.getTime());
55- contactService.save(contact);
67+ OServerAdmin serverAdmin = new OServerAdmin(url).connect("root", "korabo");
68+ if (!serverAdmin.listDatabases().containsKey(nameDB)){
69+ serverAdmin.createDatabase(nameDB, "object", "plocal");
70+ System.out.println(" Database '" + nameDB + "' created!..");
71+ }
72+// OPartitionedDatabasePool pool = new OPartitionedDatabasePool(url, "admin", "admin");
73+ pool = new OPartitionedDatabasePool(url, "admin", "admin");
74+
75+ try (
76+ OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
77+ db.getEntityManager().registerEntityClass(Contact.class);
78+ if (db.countClass(Contact.class) == 0) {
79+ // init
80+ Random r = new Random(0);
81+ Calendar cal = Calendar.getInstance();
82+ for (int i = 0; i < 100; i++) {
83+ Contact contact = db.newInstance(Contact.class);
84+ contact.setFirstName(fnames[r.nextInt(fnames.length)]);
85+ contact.setLastName(lnames[r.nextInt(fnames.length)]);
86+ contact.setEmail(contact.getFirstName().toLowerCase() + "@"
87+ + contact.getLastName().toLowerCase() + ".com");
88+ contact.setPhone("+ 358 555 " + (100 + r.nextInt(900)));
89+ cal.set(1930 + r.nextInt(70),
90+ r.nextInt(11), r.nextInt(28));
91+ contact.setBirthDate(cal.getTime());
92+ db.save(contact);
93+ }
94+ db.commit();
95+ }
5696 }
5797 instance = contactService;
5898 }
@@ -60,53 +100,75 @@ public class ContactService {
60100 return instance;
61101 }
62102
63- private HashMap<Long, Contact> contacts = new HashMap<>();
64- private long nextId = 0;
65-
103+// private HashMap<Long, Contact> contacts = new HashMap<>();
104+// private long nextId = 0;
66105 public synchronized List<Contact> findAll(String stringFilter) {
106+
67107 ArrayList arrayList = new ArrayList();
68- for (Contact contact : contacts.values()) {
69- try {
70- boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
71- || contact.toString().toLowerCase()
72- .contains(stringFilter.toLowerCase());
73- if (passesFilter) {
74- arrayList.add(contact.clone());
108+ try (
109+ OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
110+ db.getEntityManager().registerEntityClass(Contact.class);
111+ for (Contact contact : db.browseClass(Contact.class)) {
112+ try {
113+ boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
114+ || contact.toString().toLowerCase()
115+ .contains(stringFilter.toLowerCase());
116+ if (passesFilter) {
117+ arrayList.add(contact.clone());
118+ }
119+ } catch (CloneNotSupportedException ex) {
120+ Logger.getLogger(ContactService.class.getName()).log(
121+ Level.SEVERE, null, ex);
75122 }
76- } catch (CloneNotSupportedException ex) {
77- Logger.getLogger(ContactService.class.getName()).log(
78- Level.SEVERE, null, ex);
79123 }
80- }
81- Collections.sort(arrayList, new Comparator<Contact>() {
82124
83- @Override
84- public int compare(Contact o1, Contact o2) {
85- return (int) (o2.getId() - o1.getId());
86- }
87- });
125+ }
126+// for (Contact contact : contacts.values()) {
127+// try {
128+// boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
129+// || contact.toString().toLowerCase()
130+// .contains(stringFilter.toLowerCase());
131+// if (passesFilter) {
132+// arrayList.add(contact.clone());
133+// }
134+// } catch (CloneNotSupportedException ex) {
135+// Logger.getLogger(ContactService.class.getName()).log(
136+// Level.SEVERE, null, ex);
137+// }
138+// }
139+// Collections.sort(arrayList, new Comparator<Contact>() {
140+//
141+// @Override
142+// public int compare(Contact o1, Contact o2) {
143+// return (int) (o2.getId() - o1.getId());
144+// }
145+// });
88146 return arrayList;
89147 }
90148
91149 public synchronized long count() {
92- return contacts.size();
150+// return contacts.size();
151+ try (
152+ OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
153+ db.getEntityManager().registerEntityClass(Contact.class);
154+ return db.countClass(Contact.class);
155+ }
93156 }
94157
95158 public synchronized void delete(Contact value) {
96- contacts.remove(value.getId());
159+// contacts.remove(value.getId());
97160 }
98161
99162 public synchronized void save(Contact entry) {
100- if (entry.getId() == null) {
101- entry.setId(nextId++);
102- }
103- try {
104- entry = (Contact) InstanceUtil.dupObj(entry);
105- } catch (Exception ex) {
106- throw new RuntimeException(ex);
107- }
108- contacts.put(entry.getId(), entry);
163+// if (entry.getId() == null) {
164+// entry.setId(nextId++);
165+// }
166+// try {
167+// entry = (Contact) InstanceUtil.dupObj(entry);
168+// } catch (Exception ex) {
169+// throw new RuntimeException(ex);
170+// }
171+// contacts.put(entry.getId(), entry);
109172 }
110173
111-
112174 }
--- a/src/main/webapp/VAADIN/themes/mytheme/addons.scss
+++ b/src/main/webapp/VAADIN/themes/mytheme/addons.scss
@@ -1,7 +1,7 @@
1-/* This file is automatically managed and will be overwritten from time to time. */
2-/* Do not manually edit this file. */
3-
4-/* Import and include this mixin into your project theme to include the addon themes */
5-@mixin addons {
6-}
7-
1+/* This file is automatically managed and will be overwritten from time to time. */
2+/* Do not manually edit this file. */
3+
4+/* Import and include this mixin into your project theme to include the addon themes */
5+@mixin addons {
6+}
7+
Show on old repository browser