├── .gitignore
├── COPYRIGHT
├── README.md
├── epl-v10.html
├── pom.xml
├── script
└── ci_build
└── src
├── PrintSchema.java
├── java
├── datomic
│ └── samples
│ │ ├── Aggregates.java
│ │ ├── BuildingQueries.java
│ │ ├── CompareAndSwap.java
│ │ ├── ComponentAttributes.java
│ │ ├── DatabaseFiltering.java
│ │ ├── Fns.java
│ │ ├── IO.java
│ │ ├── MaybeQuery.java
│ │ ├── PrettyPrint.java
│ │ ├── Pull.java
│ │ ├── Query.java
│ │ ├── QueryAsData.java
│ │ ├── Schema.java
│ │ ├── Trust.java
│ │ ├── TxFunctions.java
│ │ ├── TxReportWatcher.java
│ │ └── With.java
└── hornet
│ └── samples
│ ├── PingConsumer.java
│ └── PingProducer.java
└── resources
├── datomic-java-examples
├── accounts.edn
├── bigger-than-pluto.edn
├── seattle-data0.edn
├── seattle-data1.edn
├── seattle-schema.edn
├── social-news.edn
├── story-with-comments.edn
└── stuarts.edn
└── logback.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | target/*
2 | .idea/*
3 | log/
4 | *.swp
5 |
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | Copyright (c) Metadata Partners, LLC. All rights reserved.
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Datomic Java Examples
2 |
3 | Code examples for [Datomic's Java API](https://docs.datomic.com/on-prem/javadoc/index.html).
4 |
5 | ## Questions, Feedback?
6 |
7 | For specific feedback on the examples, please create an
8 | [issue](https://github.com/Datomic/datomic-java-examples/issues).
9 |
10 | For questions about Datomic, try the [public mailing
11 | list](http://groups.google.com/group/datomic).
12 |
13 | ## Contributing
14 |
15 | This library is developed internally by Cognitect. Issues can be filed using
16 | [Github Issues](https://github.com/Datomic/datomic-java-examples/issues). We do
17 | not accept pull request or patches.
18 |
19 | ## License
20 |
21 | EPL. See epl-v10.html at the project root.
22 |
--------------------------------------------------------------------------------
/epl-v10.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Eclipse Public License - Version 1.0
8 |
25 |
26 |
27 |
28 |
29 |
30 | Eclipse Public License - v 1.0
31 |
32 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
33 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
34 | DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
35 | AGREEMENT.
36 |
37 | 1. DEFINITIONS
38 |
39 | "Contribution" means:
40 |
41 | a) in the case of the initial Contributor, the initial
42 | code and documentation distributed under this Agreement, and
43 | b) in the case of each subsequent Contributor:
44 | i) changes to the Program, and
45 | ii) additions to the Program;
46 | where such changes and/or additions to the Program
47 | originate from and are distributed by that particular Contributor. A
48 | Contribution 'originates' from a Contributor if it was added to the
49 | Program by such Contributor itself or anyone acting on such
50 | Contributor's behalf. Contributions do not include additions to the
51 | Program which: (i) are separate modules of software distributed in
52 | conjunction with the Program under their own license agreement, and (ii)
53 | are not derivative works of the Program.
54 |
55 | "Contributor" means any person or entity that distributes
56 | the Program.
57 |
58 | "Licensed Patents" mean patent claims licensable by a
59 | Contributor which are necessarily infringed by the use or sale of its
60 | Contribution alone or when combined with the Program.
61 |
62 | "Program" means the Contributions distributed in accordance
63 | with this Agreement.
64 |
65 | "Recipient" means anyone who receives the Program under
66 | this Agreement, including all Contributors.
67 |
68 | 2. GRANT OF RIGHTS
69 |
70 | a) Subject to the terms of this Agreement, each
71 | Contributor hereby grants Recipient a non-exclusive, worldwide,
72 | royalty-free copyright license to reproduce, prepare derivative works
73 | of, publicly display, publicly perform, distribute and sublicense the
74 | Contribution of such Contributor, if any, and such derivative works, in
75 | source code and object code form.
76 |
77 | b) Subject to the terms of this Agreement, each
78 | Contributor hereby grants Recipient a non-exclusive, worldwide,
79 | royalty-free patent license under Licensed Patents to make, use, sell,
80 | offer to sell, import and otherwise transfer the Contribution of such
81 | Contributor, if any, in source code and object code form. This patent
82 | license shall apply to the combination of the Contribution and the
83 | Program if, at the time the Contribution is added by the Contributor,
84 | such addition of the Contribution causes such combination to be covered
85 | by the Licensed Patents. The patent license shall not apply to any other
86 | combinations which include the Contribution. No hardware per se is
87 | licensed hereunder.
88 |
89 | c) Recipient understands that although each Contributor
90 | grants the licenses to its Contributions set forth herein, no assurances
91 | are provided by any Contributor that the Program does not infringe the
92 | patent or other intellectual property rights of any other entity. Each
93 | Contributor disclaims any liability to Recipient for claims brought by
94 | any other entity based on infringement of intellectual property rights
95 | or otherwise. As a condition to exercising the rights and licenses
96 | granted hereunder, each Recipient hereby assumes sole responsibility to
97 | secure any other intellectual property rights needed, if any. For
98 | example, if a third party patent license is required to allow Recipient
99 | to distribute the Program, it is Recipient's responsibility to acquire
100 | that license before distributing the Program.
101 |
102 | d) Each Contributor represents that to its knowledge it
103 | has sufficient copyright rights in its Contribution, if any, to grant
104 | the copyright license set forth in this Agreement.
105 |
106 | 3. REQUIREMENTS
107 |
108 | A Contributor may choose to distribute the Program in object code
109 | form under its own license agreement, provided that:
110 |
111 | a) it complies with the terms and conditions of this
112 | Agreement; and
113 |
114 | b) its license agreement:
115 |
116 | i) effectively disclaims on behalf of all Contributors
117 | all warranties and conditions, express and implied, including warranties
118 | or conditions of title and non-infringement, and implied warranties or
119 | conditions of merchantability and fitness for a particular purpose;
120 |
121 | ii) effectively excludes on behalf of all Contributors
122 | all liability for damages, including direct, indirect, special,
123 | incidental and consequential damages, such as lost profits;
124 |
125 | iii) states that any provisions which differ from this
126 | Agreement are offered by that Contributor alone and not by any other
127 | party; and
128 |
129 | iv) states that source code for the Program is available
130 | from such Contributor, and informs licensees how to obtain it in a
131 | reasonable manner on or through a medium customarily used for software
132 | exchange.
133 |
134 | When the Program is made available in source code form:
135 |
136 | a) it must be made available under this Agreement; and
137 |
138 | b) a copy of this Agreement must be included with each
139 | copy of the Program.
140 |
141 | Contributors may not remove or alter any copyright notices contained
142 | within the Program.
143 |
144 | Each Contributor must identify itself as the originator of its
145 | Contribution, if any, in a manner that reasonably allows subsequent
146 | Recipients to identify the originator of the Contribution.
147 |
148 | 4. COMMERCIAL DISTRIBUTION
149 |
150 | Commercial distributors of software may accept certain
151 | responsibilities with respect to end users, business partners and the
152 | like. While this license is intended to facilitate the commercial use of
153 | the Program, the Contributor who includes the Program in a commercial
154 | product offering should do so in a manner which does not create
155 | potential liability for other Contributors. Therefore, if a Contributor
156 | includes the Program in a commercial product offering, such Contributor
157 | ("Commercial Contributor") hereby agrees to defend and
158 | indemnify every other Contributor ("Indemnified Contributor")
159 | against any losses, damages and costs (collectively "Losses")
160 | arising from claims, lawsuits and other legal actions brought by a third
161 | party against the Indemnified Contributor to the extent caused by the
162 | acts or omissions of such Commercial Contributor in connection with its
163 | distribution of the Program in a commercial product offering. The
164 | obligations in this section do not apply to any claims or Losses
165 | relating to any actual or alleged intellectual property infringement. In
166 | order to qualify, an Indemnified Contributor must: a) promptly notify
167 | the Commercial Contributor in writing of such claim, and b) allow the
168 | Commercial Contributor to control, and cooperate with the Commercial
169 | Contributor in, the defense and any related settlement negotiations. The
170 | Indemnified Contributor may participate in any such claim at its own
171 | expense.
172 |
173 | For example, a Contributor might include the Program in a commercial
174 | product offering, Product X. That Contributor is then a Commercial
175 | Contributor. If that Commercial Contributor then makes performance
176 | claims, or offers warranties related to Product X, those performance
177 | claims and warranties are such Commercial Contributor's responsibility
178 | alone. Under this section, the Commercial Contributor would have to
179 | defend claims against the other Contributors related to those
180 | performance claims and warranties, and if a court requires any other
181 | Contributor to pay any damages as a result, the Commercial Contributor
182 | must pay those damages.
183 |
184 | 5. NO WARRANTY
185 |
186 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
187 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
188 | OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
189 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
190 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
191 | responsible for determining the appropriateness of using and
192 | distributing the Program and assumes all risks associated with its
193 | exercise of rights under this Agreement , including but not limited to
194 | the risks and costs of program errors, compliance with applicable laws,
195 | damage to or loss of data, programs or equipment, and unavailability or
196 | interruption of operations.
197 |
198 | 6. DISCLAIMER OF LIABILITY
199 |
200 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
201 | NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
202 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
203 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
204 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
205 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
206 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
207 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
208 |
209 | 7. GENERAL
210 |
211 | If any provision of this Agreement is invalid or unenforceable under
212 | applicable law, it shall not affect the validity or enforceability of
213 | the remainder of the terms of this Agreement, and without further action
214 | by the parties hereto, such provision shall be reformed to the minimum
215 | extent necessary to make such provision valid and enforceable.
216 |
217 | If Recipient institutes patent litigation against any entity
218 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
219 | Program itself (excluding combinations of the Program with other
220 | software or hardware) infringes such Recipient's patent(s), then such
221 | Recipient's rights granted under Section 2(b) shall terminate as of the
222 | date such litigation is filed.
223 |
224 | All Recipient's rights under this Agreement shall terminate if it
225 | fails to comply with any of the material terms or conditions of this
226 | Agreement and does not cure such failure in a reasonable period of time
227 | after becoming aware of such noncompliance. If all Recipient's rights
228 | under this Agreement terminate, Recipient agrees to cease use and
229 | distribution of the Program as soon as reasonably practicable. However,
230 | Recipient's obligations under this Agreement and any licenses granted by
231 | Recipient relating to the Program shall continue and survive.
232 |
233 | Everyone is permitted to copy and distribute copies of this
234 | Agreement, but in order to avoid inconsistency the Agreement is
235 | copyrighted and may only be modified in the following manner. The
236 | Agreement Steward reserves the right to publish new versions (including
237 | revisions) of this Agreement from time to time. No one other than the
238 | Agreement Steward has the right to modify this Agreement. The Eclipse
239 | Foundation is the initial Agreement Steward. The Eclipse Foundation may
240 | assign the responsibility to serve as the Agreement Steward to a
241 | suitable separate entity. Each new version of the Agreement will be
242 | given a distinguishing version number. The Program (including
243 | Contributions) may always be distributed subject to the version of the
244 | Agreement under which it was received. In addition, after a new version
245 | of the Agreement is published, Contributor may elect to distribute the
246 | Program (including its Contributions) under the new version. Except as
247 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
248 | rights or licenses to the intellectual property of any Contributor under
249 | this Agreement, whether expressly, by implication, estoppel or
250 | otherwise. All rights in the Program not expressly granted under this
251 | Agreement are reserved.
252 |
253 | This Agreement is governed by the laws of the State of New York and
254 | the intellectual property laws of the United States of America. No party
255 | to this Agreement will bring a legal action under this Agreement more
256 | than one year after the cause of action arose. Each party waives its
257 | rights to a jury trial in any resulting litigation.
258 |
259 |
260 |
261 |
262 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.datomic
7 | datomic-free
8 | 0.9.5350
9 |
10 |
11 | org.slf4j
12 | slf4j-log4j12
13 |
14 |
15 | org.slf4j
16 | slf4j-nop
17 |
18 |
19 |
20 |
21 | ch.qos.logback
22 | logback-classic
23 | 1.0.1
24 |
25 |
26 | 0.0
27 | com.datomic
28 | datomic-java-examples
29 | datomic-java-examples
30 |
31 | UTF-8
32 |
33 | 4.0.0
34 |
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-compiler-plugin
40 | 3.0
41 |
42 |
43 |
44 |
45 |
46 |
47 | src/java
48 |
49 |
50 | src/resources
51 |
52 |
53 |
54 |
55 |
56 | Datomic
57 | Datomic
58 | http://files.datomic.com/maven
59 |
60 | true
61 |
62 |
63 | false
64 |
65 |
66 |
67 | Sonatype
68 | Sonatype Release
69 | http://oss.sonatype.org/content/repositories/releases
70 |
71 | true
72 |
73 |
74 | false
75 |
76 |
77 |
78 | jboss
79 | https://repository.jboss.org/nexus/content/groups/public
80 |
81 | true
82 |
83 |
84 | false
85 |
86 |
87 |
88 | clojars.org
89 | http://clojars.org/repo
90 |
91 |
92 | clojure-releases
93 | http://build.clojure.org/releases
94 |
95 | true
96 |
97 |
98 | false
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/script/ci_build:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | set -e
4 |
5 | classes=(
6 | Aggregates
7 | BuildingQueries
8 | CompareAndSwap
9 | ComponentAttributes
10 | DatabaseFiltering
11 | Query
12 | QueryAsData
13 | Trust
14 | With
15 | )
16 |
17 | mvn package
18 |
19 | for class in "${classes[@]}"
20 | do
21 | mvn exec:java -Dexec.mainClass="datomic.samples.${class}"
22 | done
23 |
--------------------------------------------------------------------------------
/src/PrintSchema.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Datomic example code
3 | */
4 |
5 | import datomic.Entity;
6 | import datomic.Connection;
7 | import datomic.Database;
8 |
9 | import java.util.Collection;
10 | import java.util.Iterator;
11 | import java.util.List;
12 | import java.util.Set;
13 | import java.util.Map;
14 |
15 | import static datomic.Peer.connect;
16 | import static datomic.Peer.createDatabase;
17 | import static datomic.Peer.q;
18 |
19 | public class PrintSchema {
20 | /**
21 | * Print an entity
22 | */
23 | public static void printEntity(Entity e) {
24 | Set keys = e.keySet();
25 | for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
26 | Object key = iterator.next();
27 | System.out.println(key + " = " + e.get(key));
28 | }
29 | }
30 |
31 | /**
32 | * Print results from a query that returns entities in 1-tuples.
33 | * @param tuples
34 | */
35 | public static void printEntities(Collection> tuples) {
36 | for (Iterator> iterator = tuples.iterator(); iterator.hasNext();) {
37 | System.out.println();
38 | printEntity((Entity) iterator.next().get(0));
39 | }
40 | }
41 |
42 | /**
43 | * Schemas are plain data, like everything else. Values of
44 | * :db.install/attribute are the attributes defined in the schema.
45 | * @param db
46 | */
47 | public static void printAttributeSchema(Database db) {
48 | Collection> tuples = q("[:find ?entity" +
49 | " :where [_ :db.install/attribute ?v]" +
50 | "[(.entity $ ?v) ?entity]]",
51 | db);
52 | printEntities(tuples);
53 | }
54 |
55 | public static void main(String[] args) {
56 | String uri = "datomic:mem://db";
57 | createDatabase(uri);
58 | Connection conn = connect(uri);
59 |
60 | String query = "[:find ?entity " +
61 | ":in $ ?s " +
62 | ":where [?e :db/valueType]" +
63 | "[?e :db/ident ?a]" +
64 | "[(namespace ?a) ?ns]" +
65 | "[(= ?ns ?s)]" +
66 | "[(.entity $ ?e) ?entity]]";
67 | Collection> results = q(query,conn.db(),"db");
68 | printEntities(results);
69 | // printAttributeSchema(conn.db());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Aggregates.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 |
6 | import java.io.IOException;
7 |
8 | import static datomic.Peer.query;
9 | import static datomic.samples.Fns.scratchConnection;
10 | import static datomic.samples.IO.transactAllFromResource;
11 | import static datomic.samples.PrettyPrint.print;
12 |
13 | public class Aggregates {
14 |
15 | public static void main(String[] args) throws IOException {
16 | Connection conn = scratchConnection();
17 | transactAllFromResource(conn, "datomic-java-examples/bigger-than-pluto.edn");
18 | Database db = conn.db();
19 |
20 | print(biggestObjectRadius(db));
21 | print(randomObject(db));
22 | print(sampleFiveObjects(db));
23 |
24 | }
25 |
26 | public static Object biggestObjectRadius(Database db) {
27 | return query("[:find (max ?radius) ." +
28 | " :where [_ :object/meanRadius ?radius]]", db);
29 | }
30 |
31 | public static Object randomObject(Database db) {
32 | return query("[:find (rand ?name) ." +
33 | " :where [?e :object/name ?name]]", db);
34 | }
35 |
36 | public static Object sampleFiveObjects(Database db) {
37 | return query("[:find (sample 5 ?name) ." +
38 | " :with ?e" +
39 | " :where [?e :object/name ?name]]", db);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/BuildingQueries.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 |
6 | import java.io.IOException;
7 | import java.io.InputStreamReader;
8 | import java.net.URL;
9 | import java.util.Collection;
10 | import java.util.List;
11 |
12 | import static datomic.Peer.query;
13 | import static datomic.Util.list;
14 | import static datomic.samples.Fns.scratchConnection;
15 | import static datomic.samples.IO.resource;
16 | import static datomic.samples.IO.transactAll;
17 | import static datomic.samples.IO.transactAllFromResource;
18 | import static datomic.samples.PrettyPrint.print;
19 |
20 | public class BuildingQueries {
21 |
22 | public static void queryWithVariableBinding(Database db) {
23 | print(query("[:find [?e ...]" +
24 | " :in $ ?name" +
25 | " :where [?e :user/firstName ?name]]",
26 | db, "Stewart"));
27 | }
28 |
29 | public static void queryWithCollectionBinding(Database db) {
30 | print(query("[:find [?e ...]" +
31 | " :in $ [?name ...]" +
32 | " :where [?e :user/firstName ?name]]",
33 | db, list("Stewart", "Stuart")));
34 | }
35 |
36 | public static void queryWithMultipleCollectionBindings(Database db) {
37 | print(query("[:find [?e ...]" +
38 | " :in $ [?name ...] [?attr ...]" +
39 | " :where [?e ?attr ?name]]",
40 | db, list("Stuart", "Stewart"), list(":user/firstName", ":user/lastName")));
41 | }
42 |
43 | public static void queryWithMapForm(Database db) {
44 | print(query("{:find [[?e ...]]" +
45 | " :in [$ ?fname ?lname]" +
46 | " :where [[?e :user/firstName ?fname]" +
47 | " [?e :user/lastName ?lname]]}",
48 | db, "Stuart", "Smalley"));
49 | }
50 |
51 | public static void main(String[] args) throws IOException {
52 | Connection conn = scratchConnection();
53 | transactAllFromResource(conn, "datomic-java-examples/social-news.edn");
54 | transactAllFromResource(conn, "datomic-java-examples/stuarts.edn");
55 | Database db = conn.db();
56 |
57 | queryWithVariableBinding(db);
58 | queryWithCollectionBinding(db);
59 | queryWithMultipleCollectionBindings(db);
60 | queryWithMapForm(db);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/CompareAndSwap.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import static datomic.Connection.*;
5 |
6 | import datomic.Database;
7 | import datomic.ListenableFuture;
8 | import datomic.Peer;
9 |
10 | import java.io.IOException;
11 | import java.io.InputStreamReader;
12 | import java.net.URL;
13 | import java.util.Map;
14 | import java.util.concurrent.ExecutionException;
15 |
16 | import static datomic.Util.*;
17 |
18 | import static datomic.samples.Fns.scratchConnection;
19 | import static datomic.samples.IO.resource;
20 | import static datomic.samples.IO.transactAll;
21 | import static datomic.Peer.tempid;
22 |
23 | public class CompareAndSwap {
24 | public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
25 | Connection conn = scratchConnection();
26 | URL url = resource("datomic-java-examples/accounts.edn");
27 | transactAll(conn, new InputStreamReader(url.openStream()));
28 |
29 | Object account = tempid(":db.part/user");
30 | Map txResult = conn.transact(list(map(":db/id", account, ":account/balance", 100))).get();
31 | account = Peer.resolveTempid((Database)txResult.get(DB_AFTER), txResult.get(TEMPIDS), account);
32 |
33 | System.out.println("CAS from 100->110 should succeed");
34 | conn.transact(list(list(":db.fn/cas", account, ":account/balance", 100, 110))).get();
35 |
36 | System.out.println("CAS from 100->120 should fail");
37 | try {
38 | conn.transact(list(list(":db.fn/cas", account, ":account/balance", 100, 120))).get();
39 | } catch (Throwable t) {
40 | System.out.println("Failed with " + t.getMessage());
41 | }
42 |
43 | System.out.println("Balance is " + conn.db().entity(account).get(":account/balance"));
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/ComponentAttributes.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 |
4 | import datomic.Connection;
5 | import datomic.Database;
6 | import datomic.Datom;
7 |
8 | import java.io.IOException;
9 | import java.util.*;
10 | import java.util.concurrent.ExecutionException;
11 |
12 | import static datomic.Util.list;
13 | import static datomic.Connection.TX_DATA;
14 | import static datomic.samples.Fns.scratchConnection;
15 | import static datomic.samples.IO.transactAllFromResource;
16 |
17 | public class ComponentAttributes {
18 | public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
19 | Connection conn = scratchConnection();
20 | transactAllFromResource(conn, "datomic-java-examples/social-news.edn");
21 | transactAllFromResource(conn, "datomic-java-examples/story-with-comments.edn");
22 | Database db = conn.db();
23 |
24 | System.out.println("\nTouch an entity with componeont attributes...");
25 | System.out.println(db.entity(":storyWithComments").touch());
26 |
27 | System.out.println("\nDoc string for :db.fn/retractEntity...");
28 | System.out.println(db.entity(":db.fn/retractEntity").touch());
29 |
30 | Collection datoms =
31 | (Collection) conn.transact(list(list(":db.fn/retractEntity", ":storyWithComments")))
32 | .get()
33 | .get(TX_DATA);
34 | Set retractedEs = new HashSet();
35 | for (Iterator iterator = datoms.iterator(); iterator.hasNext(); ) {
36 | Datom datom = iterator.next();
37 | if (!datom.added()) retractedEs.add(datom.e());
38 | }
39 |
40 | System.out.println("\nRetracted entities " + retractedEs);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/DatabaseFiltering.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.*;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStreamReader;
7 | import java.net.URL;
8 | import java.util.concurrent.ExecutionException;
9 |
10 | import static datomic.Util.list;
11 | import static datomic.Util.map;
12 | import static datomic.samples.Fns.scratchConnection;
13 | import static datomic.samples.IO.resource;
14 | import static datomic.samples.IO.transactAll;
15 |
16 | import static datomic.Peer.*;
17 |
18 | public class DatabaseFiltering {
19 | public static Object tempid() {
20 | return Peer.tempid(":db.part/user");
21 | }
22 |
23 | public static final String storyQuery = "[:find (count ?e) :where [?e :story/url]]";
24 |
25 | public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
26 | Connection conn = scratchConnection();
27 | URL url = resource("datomic-java-examples/social-news.edn");
28 | transactAll(conn, new InputStreamReader(url.openStream()));
29 | Database db = conn.db();
30 |
31 | System.out.print("\nTotal number of stories: ");
32 | System.out.println(q(storyQuery, db));
33 |
34 | System.out.print("\nTotal number of published stories: ");
35 | System.out.println(q(storyQuery, db.filter(new Database.Predicate() {
36 | public boolean apply(Database db, Datom datom) {
37 | return db.entity(datom.tx()).get(":publish/at") != null;
38 | }
39 | })));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Fns.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 |
4 | import datomic.Peer;
5 |
6 | import datomic.Connection;
7 | import java.util.Collection;
8 | import java.util.Iterator;
9 | import java.util.UUID;
10 |
11 | public class Fns {
12 | /**
13 | * Connection to a fresh in-memory Datomic database.
14 | * @return
15 | */
16 | public static Connection scratchConnection() {
17 | String uri = "datomic:mem://" + UUID.randomUUID();
18 | Peer.createDatabase(uri);
19 | return Peer.connect(uri);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/IO.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Util;
5 |
6 | import java.io.IOException;
7 | import java.io.InputStreamReader;
8 | import java.io.Reader;
9 | import java.net.URI;
10 | import java.net.URL;
11 | import java.util.Iterator;
12 | import java.util.List;
13 | import java.util.concurrent.ExecutionException;
14 |
15 | public class IO {
16 | public static void transactAll(Connection conn, Reader reader) {
17 | List txes = Util.readAll(reader);
18 | for (java.util.Iterator it = txes.iterator(); it.hasNext(); ) {
19 | List tx = it.next();
20 | try {
21 | conn.transact(tx).get();
22 | } catch (Exception e) {
23 | throw new RuntimeException(e);
24 | }
25 | }
26 | }
27 |
28 | public static URL resource(String name) {
29 | return Thread.currentThread().getContextClassLoader().getResource(name);
30 | }
31 |
32 | public static void transactAllFromResource(Connection conn, String resource) {
33 | URL url = resource(resource);
34 | try {
35 | transactAll(conn, new InputStreamReader(url.openStream()));
36 | } catch (Exception e) {
37 | throw new RuntimeException(e);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/MaybeQuery.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 |
6 | import java.util.*;
7 |
8 | import static datomic.Peer.*;
9 | import static datomic.Util.read;
10 | import static datomic.samples.Fns.scratchConnection;
11 | import static datomic.samples.Schema.CARDINALITY_MANY;
12 | import static datomic.samples.Schema.CARDINALITY_ONE;
13 | import static datomic.samples.Schema.cardinality;
14 |
15 | public class MaybeQuery {
16 |
17 | /**
18 | * Function intended for use inside a Datomic query
19 | *
20 | * @param db a database value
21 | * @param e an entity id
22 | * @param attr an attribute
23 | * @param ifNot value to return if attribute absent
24 | * @return attribute value, set of attribute values, or ifNot, depending
25 | * on cardinality of the attribute, and whether any values are present
26 | */
27 | public static Object maybe(Object db, Object e, Object attr, Object ifNot) {
28 | Collection> result = query("[:find ?v " +
29 | ":in $ ?e ?a " +
30 | ":where [?e ?a ?v]]", db, e, attr);
31 | if (result.isEmpty()) {
32 | return ifNot;
33 | } else {
34 | Object card = cardinality(db, attr);
35 | if (card.equals(CARDINALITY_ONE)) return result.iterator().next(); // only one in list
36 | Set acc = new HashSet();
37 | for (Iterator> iterator = result.iterator(); iterator.hasNext(); ) {
38 | acc.add(iterator.next());
39 | }
40 | return Collections.unmodifiableSet(acc);
41 | }
42 | }
43 |
44 | public static String rules =
45 | "[[[attr-in-namespace ?e ?ns2]\n" +
46 | " [?e :db/ident ?a]\n" +
47 | " [?e :db/valueType]\n" +
48 | " [(namespace ?a) ?ns1]\n" +
49 | " [(= ?ns1 ?ns2)]]]";
50 |
51 | public static void main(String[] args) {
52 | Connection conn = scratchConnection();
53 | Database db = conn.db();
54 |
55 | System.out.println("Maybe entity zero has a docstring...");
56 | System.out.println(maybe(db, 0, read(":db/doc"), ""));
57 |
58 | System.out.println("\nMaybe entity zero has installed some atttributes");
59 | System.out.println(maybe(db, 0, read(":db.install/attribute"), ""));
60 |
61 | System.out.println("\nMaybe entity one has installed some attributes");
62 | System.out.println(maybe(db, 1, read(":db.install/attribute"), ""));
63 |
64 | System.out.println("\nMaybe we can call maybe from inside a query");
65 | System.out.println(q("[:find ?ident ?card" +
66 | " :where [?e :db/ident ?ident]" +
67 | " [(datomic.samples.MaybeQuery/maybe $ ?e :db/cardinality \"\") ?card]]",
68 | db));
69 |
70 | System.out.println("Look up attributes in the db namespace:");
71 | System.out.println(q(
72 | "[:find ?e ?ident\n" +
73 | " :in $ %\n" +
74 | " :where\n" +
75 | " (attr-in-namespace ?e \"db\")\n" +
76 | " [?e :db/ident ?ident]]",
77 | db, rules));
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/PrettyPrint.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import clojure.java.api.Clojure;
4 | import clojure.lang.IFn;
5 |
6 | public class PrettyPrint {
7 | public static final IFn prettyPrint = Clojure.var("clojure.pprint", "pprint");
8 | public static void print(Object o) {
9 | prettyPrint.invoke(o);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Pull.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 | import datomic.Peer;
6 |
7 | import java.util.UUID;
8 |
9 | import static datomic.Util.list;
10 | import static datomic.samples.PrettyPrint.print;
11 |
12 | public class Pull {
13 | public static final Object ledZeppelin = list(":artist/gid", UUID.fromString("678d88b2-87b0-403b-b63d-5da7465aecc3"));
14 | public static final Object mccartney = list(":artist/gid", UUID.fromString("ba550d0e-adac-4864-b88b-407cab5e76af"));
15 | public static final Object darkSideOfTheMoon = list(":release/gid", UUID.fromString("24824319-9bb8-3d1e-a2c5-b8b864dafd1b"));
16 | public static final Object dylanHarrisonSessions = list(":release/gid", UUID.fromString("67bbc160-ac45-4caf-baae-a7e9f5180429"));
17 | public static final Object concertForBanglaDesh = list(":release/gid", UUID.fromString("f3bdff34-9a85-4adc-a014-922eef9cdaa5"));
18 |
19 | public static void main(String[] args) {
20 | Connection conn = Peer.connect("datomic:free://localhost:4334/mbrainz-1968-1973");
21 | Database db = conn.db();
22 |
23 | System.out.println("\nPull attribute name");
24 | print(db.pull("[:artist/name :artist/startYear]", ledZeppelin));
25 |
26 | System.out.println("\nReverse lookup");
27 | print(db.pull("[:artist/_country]", ":country/GB"));
28 |
29 | System.out.println("\nComponent Defaults");
30 | print(db.pull("[:release/media]", darkSideOfTheMoon));
31 |
32 | Object dylanHarrisonCD = Peer.query(
33 | "[:find ?medium ." +
34 | " :in $ ?release" +
35 | " :where [?release :release/media ?medium]]",
36 | db, dylanHarrisonSessions);
37 |
38 | System.out.println("\nReverse Component Lookup");
39 | print(db.pull("[:release/_media]", dylanHarrisonCD));
40 |
41 | long ghostRiders = (Long) Peer.query(
42 | "[:find ?track ." +
43 | " :in $ ?release ?trackno" +
44 | " :where" +
45 | " [?release :release/media ?medium]" +
46 | " [?medium :medium/tracks ?track]" +
47 | " [?track :track/position ?trackno]]",
48 | db, dylanHarrisonSessions, 11);
49 |
50 | System.out.println("\nMap specifications");
51 | print(db.pull("[:track/name {:track/artists [:db/id :artist/name]}]", ghostRiders));
52 |
53 | System.out.println("\nNested Map specifications");
54 | print(db.pull(
55 | "[{:release/media" +
56 | " [{:medium/tracks" +
57 | " [:track/name {:track/artists [:artist/name]}]}]}]",
58 | concertForBanglaDesh));
59 |
60 | System.out.println("\nWildcard specification");
61 | print(db.pull("[*]",concertForBanglaDesh));
62 |
63 | System.out.println("\nWildcard + map specification");
64 | print(db.pull("[* {:track/artists [:artist/name]}]",ghostRiders));
65 |
66 | System.out.println("\nDefault expression");
67 | print(db.pull("[:artist/name (default :artist/endYear 0)]",mccartney));
68 |
69 | System.out.println("\nDefault expression with different type");
70 | print(db.pull("[:artist/name (default :artist/endYear \"N/A\")]",mccartney));
71 |
72 | System.out.println("\nAbsent attributes are omitted from results");
73 | print(db.pull("[:artist/name :died-in-1966?]",mccartney));
74 |
75 | System.out.println("\nLimit plus subspec");
76 | print(db.pull("[{(limit :track/_artists 10) [:track/name]}]",ledZeppelin));
77 |
78 | System.out.println("\nNo limit");
79 | print(db.pull("[{(limit :track/_artists nil) [:track/name]}]",ledZeppelin));
80 |
81 | System.out.println("\nPull expression in query");
82 | print(Peer.query(
83 | "[:find [(pull ?e [:release/name]) ...]" +
84 | " :in $ ?artist" +
85 | " :where [?e :release/artists ?artist]]",
86 | db, ledZeppelin));
87 |
88 | System.out.println("\nDynamic pattern input");
89 | print(Peer.query(
90 | "[:find [(pull ?e pattern) ...]" +
91 | " :in $ ?artist pattern" +
92 | " :where [?e :release/artists ?artist]]",
93 | db, ledZeppelin, "[:release/name]"));
94 | Peer.shutdown(true);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Query.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.*;
4 |
5 | import java.util.List;
6 | import java.util.Scanner;
7 | import java.util.Collection;
8 |
9 | import static datomic.Util.read;
10 | import static datomic.samples.Fns.scratchConnection;
11 | import static datomic.samples.Schema.CARDINALITY_MANY;
12 | import static datomic.samples.Schema.CARDINALITY_ONE;
13 | import static datomic.samples.Schema.cardinality;
14 |
15 | public class Query {
16 |
17 | public static void main(String[] args) {
18 |
19 | // Your connection information for local mbrainz 1968-1973 subset goes here.
20 | String uri = "datomic:free://localhost:4334/mbrainz-1968-1973";
21 |
22 | // Connect to transactor, get latest database value from storage.
23 | Connection conn = Peer.connect(uri);
24 | Database db = conn.db();
25 |
26 | System.out.println("All releases in the database with release names.");
27 | Collection results = Peer.query("[:find ?release-name :where [_ :release/name ?release-name]]", db);
28 | System.out.println(results);
29 | pause();
30 |
31 | System.out.println("Same as previous query, but with explicit db-var ($).");
32 | results = Peer.query("[:find ?release-name :in $ :where [$ _ :release/name ?release-name]]", db);
33 | System.out.println(results);
34 | pause();
35 |
36 | System.out.println("Query that finds releases by artist. Parameterized to accept artist name as an argument.");
37 | results = Peer.query("[:find ?release-name " +
38 | ":in $ ?artist-name " +
39 | ":where [?artist :artist/name ?artist-name] " +
40 | "[?release :release/artists ?artist] " +
41 | "[?release :release/name ?release-name]]",
42 | db, "John Lennon");
43 | System.out.println(results);
44 | pause();
45 |
46 | System.out.println("This query accepts a relation argument as a vector and destructures it within the :in.");
47 | results = Peer.query("[:find ?release " +
48 | " :in $ [?artist-name ?release-name] " +
49 | " :where [?artist :artist/name ?artist-name] " +
50 | " [?release :release/artists ?artist] " +
51 | " [?release :release/name ?release-name]]",
52 | db, Util.list("John Lennon", "Mind Games"));
53 | System.out.println(results);
54 | pause();
55 |
56 |
57 | System.out.println("This query accepts a list of artist arguments and uses destructuring to satisfy the " +
58 | "query for each of them (union of results).");
59 | results = Peer.query("[:find ?release-name " +
60 | ":in $ [?artist-name ...] " +
61 | ":where [?artist :artist/name ?artist-name] " +
62 | " [?release :release/artists ?artist] " +
63 | " [?release :release/name ?release-name]]",
64 | db, Util.list("Paul McCartney", "George Harrison"));
65 | pause();
66 |
67 | System.out.println("This query accepts a list of relations, also a list, and destructures the arguments in " +
68 | "the :in clause.");
69 | results = Peer.query("[:find ?release " +
70 | ":in $ [[?artist-name ?release-name]] " +
71 | ":where [?artist :artist/name ?artist-name] " +
72 | " [?release :release/artists ?artist] " +
73 | " [?release :release/name ?release-name]]",
74 | db, Util.list(Util.list("John Lennon", "Mind Games"),
75 | Util.list("Paul McCartney", "Ram")));
76 | System.out.println(results);
77 | pause();
78 |
79 | System.out.println("This query returns a collection of relations, all artists and their releases.");
80 | results = Peer.query("[:find ?artist-name ?release-name " +
81 | ":where [?release :release/name ?release-name] " +
82 | " [?release :release/artists ?artist] " +
83 | " [?artist :artist/name ?artist-name]]",
84 | db);
85 | System.out.println(results);
86 | pause();
87 |
88 | System.out.println("This query returns a list of releases by using a find specification.");
89 | results = Peer.query("[:find [?release-name ...]" +
90 | " :in $ ?artist-name " +
91 | " :where [?artist :artist/name ?artist-name] " +
92 | " [?release :release/artists ?artist] " +
93 | " [?release :release/name ?release-name]]",
94 | db, "John Lennon");
95 | System.out.println(results);
96 | pause();
97 |
98 | System.out.println("This query returns values from multiple attributes to provide artist's start date.");
99 | results = Peer.query("[:find [?year ?month ?day] " +
100 | " :in $ ?name " +
101 | " :where [?artist :artist/name ?name] " +
102 | " [?artist :artist/startDay ?day] " +
103 | " [?artist :artist/startMonth ?month] " +
104 | " [?artist :artist/startYear ?year]]",
105 | db, "John Lennon");
106 | System.out.println(results);
107 | pause();
108 |
109 | System.out.println("Return just the year of start date using a scalar find specification.");
110 | Long year = Peer.query("[:find ?year . " +
111 | " :in $ ?name " +
112 | " :where [?artist :artist/name ?name] " +
113 | " [?artist :artist/startYear ?year]]",
114 | db, "John Lennon");
115 | System.out.println(year);
116 | pause();
117 |
118 | System.out.println("Total number of artists who aren't Canadian.");
119 | Integer res = Peer.query("[:find (count ?eid) . " +
120 | ":where [?eid :artist/name] " +
121 | "(not [?eid :artist/country :country/CA])]",
122 | db);
123 | System.out.println(res);
124 | pause();
125 |
126 | System.out.println("Use not-join to bind variable in subquery. Artists w/o releases in 1970.");
127 | res = Peer.query("[:find (count ?artist) . " +
128 | ":where [?artist :artist/name] " +
129 | "(not-join [?artist] " +
130 | " [?release :release/artists ?artist] " +
131 | " [?release :release/year 1970])]",
132 | db);
133 | System.out.println(res);
134 | pause();
135 |
136 | System.out.println("Number of 'Live at Carnegie Hall' releases not by Bill Withers");
137 | res = Peer.query("[:find (count ?r) . " +
138 | ":where [?r :release/name \"Live at Carnegie Hall\"] " +
139 | "(not-join [?r] " +
140 | "[?r :release/artists ?a] " +
141 | "[?a :artist/name \"Bill Withers\"])]",
142 | db);
143 | System.out.println(res);
144 | pause();
145 |
146 | System.out.println("Total of artists who are a group or female by use of 'or'.");
147 | res = Peer.query("[:find (count ?artist) . " +
148 | " :where (or [?artist :artist/type :artist.type/group] " +
149 | " (and [?artist :artist/type :artist.type/person] " +
150 | " [?artist :artist/gender :artist.gender/female]))]",
151 | db);
152 | System.out.println(res);
153 | pause();
154 |
155 | System.out.println("Count of releases from Canadian artists or the year 1970 using 'or-join'");
156 | res = Peer.query("[:find (count ?release) . " +
157 | " :where [?release :release/name] " +
158 | " (or-join [?release] " +
159 | " (and [?release :release/artists ?artist] " +
160 | " [?artist :artist/country :country/CA]) " +
161 | " [?release :release/year 1970])]",
162 | db);
163 | System.out.println(res);
164 | pause();
165 |
166 |
167 | System.out.println("Track name and duration in minutes using function call in query.");
168 | results = Peer.query("[:find ?track-name ?minutes " +
169 | ":in $ ?artist-name " +
170 | ":where [?artist :artist/name ?artist-name] " +
171 | " [?track :track/artists ?artist] " +
172 | " [?track :track/duration ?millis] " +
173 | " [(quot ?millis 60000) ?minutes] " +
174 | " [?track :track/name ?track-name]]",
175 | db, "John Lennon");
176 | System.out.println(results);
177 | pause();
178 |
179 | // Can't nest expression clauses
180 | String QueryFail = "[:find ?celsius . " +
181 | " :in ?fahrenheit " +
182 | " :where [(/ (- ?fahrenheit 32) 1.8) ?celsius]]";
183 | Integer QueryFailInput = 212;
184 |
185 | System.out.println("Function calls without nesting:");
186 | Double celsius = Peer.query("[:find ?celsius . " +
187 | " :in ?fahrenheit " +
188 | " :where [(- ?fahrenheit 32) ?f-32] " +
189 | " [(/ ?f-32 1.8) ?celsius]]",
190 | 212);
191 | System.out.println(celsius);
192 | pause();
193 |
194 | System.out.println("get-else example:");
195 | results = Peer.query("[:find ?artist-name ?year " +
196 | " :in $ [?artist-name ...] " +
197 | " :where [?artist :artist/name ?artist-name] " +
198 | " [(get-else $ ?artist :artist/startYear \"N/A\") ?year]]",
199 | db, Util.list("Crosby, Stills & Nash", "Crosby & Nash"));
200 | System.out.println(results);
201 | pause();
202 |
203 | System.out.println("get-some example:");
204 | results = Peer.query("[:find [?e ?attr ?name] " +
205 | ":in $ ?e " +
206 | ":where [(get-some $ ?e :country/name :artist/name) [?attr ?name]]]",
207 | db, Util.read(":country/US"));
208 | System.out.println(results);
209 | pause();
210 |
211 | System.out.println("fulltext example returns info for songs with 'Jane' in the title.");
212 | results = Peer.query("[:find ?entity ?name ?tx ?score " +
213 | " :in $ ?search " +
214 | " :where [(fulltext $ :artist/name ?search) [[?entity ?name ?tx ?score]]]]",
215 | db, "Jane");
216 | System.out.println(results);
217 | pause();
218 |
219 | System.out.println("'missing' query finds artists without start year.");
220 | results = Peer.query("[:find ?name " +
221 | " :where [?artist :artist/name ?name] " +
222 | " [(missing? $ ?artist :artist/startYear)]]",
223 | db);
224 | System.out.println(results);
225 | pause();
226 |
227 | System.out.println("This query finds transactions using the Log API.");
228 | results = Peer.query("[:find [?tx ...] " +
229 | " :in ?log " +
230 | " :where [(tx-ids ?log 1000 1050) [?tx ...]]]",
231 | conn.log());
232 | System.out.println(results);
233 | pause();
234 |
235 | System.out.println("This query finds information about a transaction using the Log API.");
236 | results = Peer.query("[:find [?e ...] " +
237 | " :in ?log ?tx " +
238 | " :where [(tx-data ?log ?tx) [[?e]]]]",
239 | conn.log(), 13194139534312L);
240 | System.out.println(results);
241 | pause();
242 |
243 |
244 | System.out.println("Calling a Java static method in a query.");
245 | results = Peer.query("[:find ?k ?v " +
246 | " :where [(System/getProperties) [[?k ?v]]]]");
247 | System.out.println(results);
248 | pause();
249 |
250 | System.out.println("Calling a Java instance method in a query.");
251 | results = Peer.query("[:find ?k ?v " +
252 | " :where [(System/getProperties) [[?k ?v]]]" +
253 | " [(.endsWith ?k \"version\")]]");
254 | System.out.println(results);
255 | pause();
256 |
257 | System.out.println("Calling Clojure functions");
258 | results = Peer.query("[:find [?prefix ...] " +
259 | " :in [?word ...] " +
260 | " :where [(subs ?word 0 5) ?prefix]]",
261 | Util.list("hello", "antidisestablishmentarianism"));
262 | System.out.println(results);
263 | pause();
264 |
265 |
266 | System.out.println("Attr bound by entity ID, query for ident.");
267 | results = Peer.query("[:find [?aname ...] " +
268 | " :where [?attr 42 _] " +
269 | " [?attr :db/ident ?aname]]",
270 | db);
271 | System.out.println(results);
272 | pause();
273 |
274 | System.out.println("Avoid dynamic attr. specs unless you really need them.");
275 | // results = Peer.query("[:find [?aname ...] " +
276 | // " :in $ [?property ...] " +
277 | // " :where [?attr ?property _] " +
278 | // " [?attr :db/ident ?aname]]",
279 | // db, Util.read(":db/unique"));
280 | // System.out.println(results);
281 | // pause();
282 |
283 | System.out.println("The following three queries are equivalent...");
284 | System.out.println("This one retrieves an entity by lookup ref.");
285 | results = Peer.query("[:find [?artist-name ...] " +
286 | " :in $ ?country" +
287 | " :where [?artist :artist/name ?artist-name] " +
288 | " [?artist :artist/country ?country]]",
289 | db, Util.list(Util.read(":country/name"), "Belgium"));
290 | System.out.println(results);
291 | pause();
292 |
293 | System.out.println("This one retrieves the same entity by ident.");
294 | results = Peer.query("[:find [?artist-name ...] " +
295 | " :in $ ?country" +
296 | " :where [?artist :artist/name ?artist-name] " +
297 | " [?artist :artist/country ?country]]",
298 | db, Util.read(":country/BE"));
299 | System.out.println(results);
300 | pause();
301 |
302 | System.out.println("This one retrieves the same entity by its entity ID (Long)");
303 | results = Peer.query("[:find [?artist-name ...] " +
304 | " :in $ ?country" +
305 | " :where [?artist :artist/name ?artist-name] " +
306 | " [?artist :artist/country ?country]]",
307 | db, 17592186045438L);
308 | System.out.println(results);
309 | pause();
310 |
311 | System.out.println("This query doesn't work as intended.");
312 | results = Peer.query("[:find [?artist-name ...] " +
313 | " :in $ ?country [?reference ...] " +
314 | " :where [?artist :artist/name ?artist-name] " +
315 | " [?artist ?reference ?country]]",
316 | db, Util.read(":country/BE"), Util.list(Util.read(":artist/country")));
317 |
318 | System.out.println(results);
319 | pause();
320 |
321 | System.out.println("We fix it by manually resolving the ident to its entity id.");
322 | // results = Peer.query("[:find [?artist-name ...] " +
323 | // " :in $ ?country [?reference ...] " +
324 | // " :where [(datomic.api/entid $ ?country) ?country-id] " +
325 | // " [?artist :artist/name ?artist-name] " +
326 | // " [?artist ?reference ?country-id]]",
327 | // db, Util.read(":country/BE"), Util.list(Util.read(":artist/country")));
328 | // System.out.println(results);
329 | // pause();
330 |
331 | System.out.println("We have to use ':with' to get duplicate values as Datomic query returns sets by default.");
332 | Long heads = Peer.query("[:find (sum ?heads) . " +
333 | " :in [[_ ?heads]]]",
334 | Util.list(Util.list("Cerberus", 3),
335 | Util.list("Cyclops", 1),
336 | Util.list("Medusa", 1),
337 | Util.list("Chimera", 1)));
338 | System.out.println("First, incorrect results: ");
339 | System.out.println(heads);
340 | pause();
341 |
342 | System.out.println("This time, fixed with ':with': ");
343 | heads = Peer.query("[:find (sum ?heads) . " +
344 | " :with ?monster " +
345 | " :in [[?monster ?heads]]]",
346 | Util.list(Util.list("Cerberus", 3),
347 | Util.list("Cyclops", 1),
348 | Util.list("Medusa", 1),
349 | Util.list("Chimera", 1)));
350 | System.out.println(heads);
351 | pause();
352 |
353 | // Aggregate examples
354 | System.out.println("Using 'max' and 'min' aggregates to get shortest and longest durations.");
355 | results = Peer.query("[:find [(min ?dur) (max ?dur)] " +
356 | " :where [_ :track/duration ?dur]]",
357 | db);
358 | System.out.println(results);
359 | pause();
360 |
361 | System.out.println("Sum of all track counts.");
362 | Long sum = Peer.query("[:find (sum ?count) . " +
363 | " :with ?medium " +
364 | " :where [?medium :medium/trackCount ?count]]",
365 | db);
366 | System.out.println(sum);
367 | pause();
368 |
369 | System.out.println("Counting with and without count-distinct: ");
370 | results = Peer.query("[:find [(count ?name) (count-distinct ?name)] " +
371 | " :with ?artist " +
372 | " :where [?artist :artist/name ?name]]",
373 | db);
374 | System.out.println(results);
375 | pause();
376 |
377 | System.out.println("Count of tracks.");
378 | results = Peer.query("[:find (count ?track) " +
379 | " :where [?track :track/name]]",
380 | db);
381 | System.out.println(results);
382 | pause();
383 |
384 | System.out.println("Some basic stats...");
385 | results = Peer.query("[:find ?year (median ?namelen) (avg ?namelen) (stddev ?namelen) " +
386 | " :with ?track " +
387 | " :where [?track :track/name ?name] " +
388 | " [(count ?name) ?namelen] " +
389 | " [?medium :medium/tracks ?track] " +
390 | " [?release :release/media ?medium] " +
391 | " [?release :release/year ?year]]",
392 | db);
393 | System.out.println(results);
394 | pause();
395 |
396 |
397 | System.out.println("Set of distinct values...");
398 | results = Peer.query("[:find (distinct ?v) . " +
399 | " :in [?v ...]] ",
400 | Util.list(1, 1, 2, 2, 2, 3));
401 | System.out.println(results);
402 | pause();
403 |
404 | System.out.println("Five shortest and five longest track durations in milliseconds.");
405 | results = Peer.query("[:find [(min 5 ?millis) (max 5 ?millis)] " +
406 | " :where [?track :track/duration ?millis]]",
407 | db);
408 | System.out.println(results);
409 | pause();
410 |
411 | System.out.println("Two random names using rand (duplicates tolerated) and sample (only distinct)");
412 | results = Peer.query("[:find [(rand 2 ?name) (sample 2 ?name)] " +
413 | " :where [_ :artist/name ?name]]",
414 | db);
415 | System.out.println(results);
416 | pause();
417 |
418 | System.out.println("Using a QueryRequest to return a relation");
419 | QueryRequest queryRequest = QueryRequest.create("[:find ?artist-name ?release-name " +
420 | " :in $ ?artist-name " +
421 | " :where [?artist :artist/name ?artist-name] " +
422 | " [?release :release/artists ?artist] " +
423 | " [?release :release/name ?release-name]]",
424 | db, "John Lennon");
425 | Collection> queryResultRelation = Peer.query(queryRequest);
426 |
427 | System.out.println(queryResultRelation);
428 | pause();
429 |
430 | System.out.println("Using a QueryRequest to return a collection");
431 | queryRequest = QueryRequest.create("[:find [?release-name ...]" +
432 | " :in $ ?artist-name " +
433 | " :where [?artist :artist/name ?artist-name] " +
434 | " [?release :release/artists ?artist] " +
435 | " [?release :release/name ?release-name]]",
436 | db, "John Lennon");
437 | Collection queryResultCollection = Peer.query(queryRequest);
438 |
439 | System.out.println(queryResultCollection);
440 | pause();
441 |
442 | System.out.println("Using a QueryRequest to return a single tuple");
443 | queryRequest = QueryRequest.create("[:find [?year ?month ?day]" +
444 | " :in $ ?name" +
445 | " :where [?artist :artist/name ?name] " +
446 | " [?artist :artist/startDay ?day] " +
447 | " [?artist :artist/startMonth ?month] " +
448 | " [?artist :artist/startYear ?year]]",
449 | db, "John Lennon");
450 | List queryResultSingleTuple = Peer.query(queryRequest);
451 |
452 | System.out.println(queryResultSingleTuple);
453 | pause();
454 |
455 |
456 | System.out.println("Using a QueryRequest to return a single scalar");
457 | queryRequest = QueryRequest.create("[:find ?year . " +
458 | " :in $ ?name " +
459 | " :where [?artist :artist/name ?name] " +
460 | " [?artist :artist/startYear ?year]]",
461 | db, "John Lennon");
462 | Long queryResultSingleScalar = Peer.query(queryRequest);
463 |
464 | System.out.println(queryResultSingleScalar);
465 | pause();
466 |
467 |
468 | System.out.println("Timeout a long running query.");
469 | queryRequest = QueryRequest.create("[:find ?track-name " +
470 | " :in $ ?artist-name " +
471 | " :where [?track :track/artists ?artist] " +
472 | " [?track :track/name ?track-name] " +
473 | " [?artist :artist/name ?artist-name]]",
474 | db, "John Lennon").timeout(100);
475 |
476 | Exception error = null;
477 | try {
478 | Peer.query(queryRequest);
479 | } catch (Exception e) {
480 | error = e;
481 | if (error.getMessage().contains("Query canceled")) {
482 | System.out.println("Caught expected timeout exception: " + error.getMessage());
483 | } else {
484 | throw new RuntimeException(e);
485 | }
486 | }
487 | if (error == null) {
488 | System.out.println("Expected query to timeout.");
489 | }
490 | }
491 |
492 | private static final Scanner scanner = new Scanner(System.in);
493 |
494 | private static void pause() {
495 | if (System.getProperty("NOPAUSE") == null) {
496 | System.out.println("\nPress enter to continue...");
497 | scanner.nextLine();
498 |
499 | }
500 | }
501 | }
502 |
503 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/QueryAsData.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 | import datomic.Peer;
6 |
7 | import java.io.IOException;
8 | import java.io.InputStreamReader;
9 | import java.io.Reader;
10 | import java.net.URI;
11 | import java.net.URL;
12 | import java.util.List;
13 |
14 | import static datomic.Peer.q;
15 | import static datomic.Util.*;
16 | import static datomic.samples.IO.*;
17 | import static datomic.samples.Fns.scratchConnection;
18 |
19 | public class QueryAsData {
20 | public static Object tempid() {
21 | return Peer.tempid(":db.part/user");
22 | }
23 | public static void main(String[] args) throws IOException {
24 | Connection conn = scratchConnection();
25 |
26 | URL url = resource("datomic-java-examples/social-news.edn");
27 |
28 | transactAll(conn, new InputStreamReader(url.openStream()));
29 |
30 | // tx data is plain lists and maps
31 | conn.transact(
32 | list(map(":db/id", tempid(), ":user/firstName", "Stewart", ":user/lastName", "Brand"),
33 | map(":db/id", tempid(), ":user/firstName", "Stuart", ":user/lastName", "Smalley"),
34 | map(":db/id", tempid(), ":user/firstName", "John", ":user/lastName", "Stewart")));
35 |
36 | Database db = conn.db();
37 |
38 | // Find all Stewart first names (should return 1 tuple)
39 | System.out.println(q("[:find ?e :in $ ?name :where [?e :user/firstName ?name]]", db, "Stewart"));
40 |
41 | // Find all Stewart or Stuart first names (should return 2 tuples)
42 | List names = list("Stewart", "Stuart");
43 | System.out.println(q("[:find ?e :in $ [?name ...] :where [?e :user/firstName ?name]]", db, names));
44 |
45 | // Find all [Stewart|Stuart] [first|last] names (should return 3 tuples)
46 | List nameAttributes = list(read(":user/firstName"), read(":user/lastName"));
47 | System.out.println(q("[:find ?e :in $ [?name ...] [?attr ...] :where [?e ?attr ?name]]", db, names, nameAttributes));
48 |
49 | // Build a query out of data. You might need this if e.g. writing a query optimizer.
50 | // Do *not* do this if parameterizing inputs (as shown above) is sufficient!
51 | List firstNameQuery = list(read(":find"), read("?e"),
52 | read(":in"), read("$"), read("?name"),
53 | read(":where"), list(read("?e"), read(":user/firstName"), read("?name")));
54 |
55 | // Find all Stewart first names (should return 1 tuple)
56 | System.out.println(q(firstNameQuery, db, "Stewart"));
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Schema.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Database;
4 |
5 | import static datomic.Peer.query;
6 | import static datomic.Util.read;
7 |
8 | public class Schema {
9 | public static final Object CARDINALITY_ONE = read(":db.cardinality/one");
10 | public static final Object CARDINALITY_MANY = read(":db.cardinality/many");
11 |
12 | public static Object cardinality(Object db, Object attr) {
13 | return query("[:find ?v . " +
14 | ":in $ ?attr " +
15 | ":where " +
16 | "[?attr :db/cardinality ?card] " +
17 | "[?card :db/ident ?v]]", db, attr);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/Trust.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 | import datomic.Datom;
6 |
7 | import java.io.IOException;
8 | import java.io.InputStreamReader;
9 | import java.net.URL;
10 | import java.util.concurrent.ExecutionException;
11 |
12 | import static datomic.Peer.query;
13 | import static datomic.Peer.tempid;
14 | import static datomic.Util.list;
15 | import static datomic.Util.map;
16 | import static datomic.samples.Fns.scratchConnection;
17 | import static datomic.samples.IO.resource;
18 | import static datomic.samples.IO.transactAll;
19 | import static datomic.samples.PrettyPrint.print;
20 |
21 | public class Trust {
22 | public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
23 | Connection conn = scratchConnection();
24 | URL url = resource("datomic-java-examples/social-news.edn");
25 | transactAll(conn, new InputStreamReader(url.openStream()));
26 |
27 | conn.transact(list(map(":db/id", tempid(":db.part/user"),
28 | ":story/title", "ElastiCache in 6 minutes",
29 | ":story/url", "http://blog.datomic.com/2012/09/elasticache-in-5-minutes.html"),
30 | map(":db/id", tempid(":db.part/tx"),
31 | ":source/confidence", 95L))).get();
32 |
33 | conn.transact(list(map(":db/id", tempid(":db.part/user"),
34 | ":story/title", "Request for Urgent Business Relationship",
35 | ":story/url", "http://example.com/bogus-url"),
36 | map(":db/id", tempid(":db.part/tx"),
37 | ":source/confidence", 40L))).get();
38 |
39 | Database db = conn.db();
40 |
41 | System.out.println("\nAll stories...");
42 | print(allStories(db));
43 |
44 | System.out.println("\nStories with 90% confidence, by query...");
45 | print(storiesWithHighConfidenceByQuery(db));
46 |
47 | System.out.println("\nStories with 90% confidence, by filter...");
48 | print(storiesWithHighConfidenceByFilter(db));
49 | }
50 |
51 | public static Object allStories(Database db) {
52 | return query("[:find [?title ...]" +
53 | " :where [_ :story/title ?title]]", db);
54 | }
55 |
56 | public static Object storiesWithHighConfidenceByQuery(Database db) {
57 | return query("[:find [?title ...]" +
58 | " :where [_ :story/title ?title ?tx]" +
59 | " [?tx :source/confidence ?conf]" +
60 | " [(<= 90 ?conf)]]", db);
61 | }
62 |
63 | /**
64 | * Returns database filtered to only facts whose transactions have
65 | * :source/confidence level of 90% or higher
66 | */
67 | public static Database filterByConfidence(Database db, final long conf) {
68 | return db.filter(new Database.Predicate() {
69 | public boolean apply(Database db, Datom datom) {
70 | Long confidence = (Long) db.entity(datom.tx()).get(":source/confidence");
71 | return (confidence != null) && (confidence > conf);
72 | }
73 | });
74 | }
75 |
76 | public static Object storiesWithHighConfidenceByFilter(Database db) {
77 | return query("[:find [?title ...]" +
78 | " :where [_ :story/title ?title]]", filterByConfidence(db, 90L));
79 | }
80 |
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/TxFunctions.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Database;
5 |
6 | import java.io.IOException;
7 | import java.util.concurrent.Future;
8 | import java.util.concurrent.ExecutionException;
9 | import java.lang.IllegalStateException;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | import static datomic.Peer.query;
14 | import static datomic.Peer.tempid;
15 | import static datomic.Peer.toT;
16 | import static datomic.Peer.function;
17 | import static datomic.Util.list;
18 | import static datomic.samples.Fns.scratchConnection;
19 | import static datomic.Util.map;
20 | import static datomic.Util.read;
21 |
22 | public class TxFunctions {
23 |
24 | /*
25 | * Function intended for use as a Datomic transaction function. ensureComposite will fail to transact if the
26 | * existing two key/value combinations specified in parameters are already set for an entity in the database.
27 | *
28 | * The resulting exception will report the entity and the tx value.
29 | *
30 | * @param db a database value
31 | * @param k1 first key of composite uniqueness constraint
32 | * @param v1 value corresponding to first key
33 | * @param k2 second key
34 | * @param v2 second value
35 | * @return transaction data to create entity with attr/value pairs k1:v1, k2:v2.
36 | */
37 | public static List ensureComposite(Database db, Object k1, Object v1, Object k2, Object v2) {
38 | String compositeQuery = "[:find [?e ?t1 ?t2] " +
39 | ":in $ ?k1 ?v1 ?k2 ?v2 " +
40 | ":where " +
41 | "[?e ?k1 ?v1 ?t1] " +
42 | "[?e ?k2 ?v2 ?t2]]";
43 | List conflict = query(compositeQuery, db, k1, v1, k2, v2);
44 | if (conflict != null && !conflict.isEmpty()) {
45 | Long entId = (Long) conflict.get(0);
46 | Long t1 = (Long) conflict.get(1);
47 | Long t2 = (Long) conflict.get(2);
48 | Long tMax = toT(Math.max(t1, t2));
49 | throw new IllegalStateException("Composite key exists: " + entId + " at t: " + tMax);
50 | } else {
51 | return list(map(read(":db/id"), tempid(read(":db.part/user")),
52 | k1, v1, k2, v2));
53 | }
54 | }
55 |
56 | /*
57 | * Installs the ensureComposite function using a string literal representation of its source code.
58 | */
59 | public static Map ensureCompositeInstall(Connection conn) throws InterruptedException, ExecutionException {
60 | String source = "import java.util.List;\nimport static datomic.Peer.query;\nimport static datomic.Peer.toT;\n" +
61 | "import static datomic.Util.list;\nimport static datomic.Util.map;\nimport static datomic.Util.read;\n" +
62 | "String compositeQuery = \"[:find [?e ?t1 ?t2] \" +\n" +
63 | " \":in $ ?k1 ?v1 ?k2 ?v2 \" +\n" +
64 | " \":where \" +\n" +
65 | " \"[?e ?k1 ?v1 ?t1] \" +\n" +
66 | " \"[?e ?k2 ?v2 ?t2]]\";\n" +
67 | " List conflict = query(compositeQuery, db, k1, v1, k2, v2);\n" +
68 | " if (conflict != null && !conflict.isEmpty()) {\n" +
69 | " Long entId = (Long) conflict.get(0);\n" +
70 | " Long t1 = (Long) conflict.get(1);\n" +
71 | " Long t2 = (Long) conflict.get(2);\n" +
72 | " Long tMax = toT(Math.max(t1, t2));\n" +
73 | " throw new IllegalStateException(\"Composite key exists: \" + entId + \" at t: \" + tMax);\n" +
74 | " } else {\n" +
75 | " return list(map(read(\":db/id\"), tempid(read(\":db.part/user\")),\n" +
76 | " k1, v1, k2, v2));\n" +
77 | " }\n";
78 | datomic.functions.Fn ensureComposite =
79 | function(map(read(":lang"), "java",
80 | read(":params"), list(read("db"),read("k1"),read("v1"),read("k2"),read("v2")),
81 | read(":code"), source));
82 | Future txResult =
83 | conn.transact(list(map(read(":db/id"), tempid(read(":db.part/user")),
84 | read(":db/fn"), ensureComposite,
85 | read(":db/ident"), read(":examples/ensure-composite"),
86 | read(":db/doc"), "Create an entity with k1=v1, k2=v2, throwing if such an entity already exists")));
87 | return txResult.get();
88 | }
89 |
90 |
91 | public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
92 | // get a connection to a new scratch db and install transactor function
93 | Connection conn = scratchConnection();
94 | Map installResult = ensureCompositeInstall(conn);
95 | // work with database after txFunction has been installed
96 | Database dbAfter = (Database) installResult.get(read(":db-after"));
97 |
98 | // invoke locally to test
99 | dbAfter.invoke(read(":examples/ensure-composite"), dbAfter, read(":db/ident"), read(":examples/test"), read(":db/doc"), "This one works");
100 | // commented line below will throw (key/value pairs exist)
101 | // dbAfter.invoke(read(":examples/ensure-composite"), dbAfter, read(":db/ident"), read(":db/txInstant"), read(":db/index"), read("true"));
102 |
103 | // now invoke in a transaction function
104 | Future fnInvokeResultConflict =
105 | conn.transact(list(list(read(":examples/ensure-composite"), read(":db/ident"), read(":db/txInstant"), read(":db/index"), read("true"))));
106 | Future fnInvokeResultOK =
107 | conn.transact(list(list(read(":examples/ensure-composite"), read(":db/ident"),read(":examples/test"), read(":db/doc"), "No conflict.")));
108 | System.out.println(fnInvokeResultOK.get());
109 | try {
110 | fnInvokeResultConflict.get();
111 | } catch (ExecutionException e) {
112 | // transaction future throws an execution exception when we retrieve it, but IllegalStateException is
113 | // displayed in the resulting message with the error message we set in function.
114 | System.out.println("Transaction function failed with:\n" + e.getMessage());
115 | }
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/TxReportWatcher.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Connection;
4 | import datomic.Datom;
5 |
6 | import java.util.*;
7 | import java.util.concurrent.BlockingQueue;
8 |
9 | import static datomic.Connection.DB_AFTER;
10 | import static datomic.Peer.connect;
11 | import static datomic.Connection.TX_DATA;
12 | import static datomic.Peer.q;
13 |
14 | public class TxReportWatcher {
15 | public static void main(String[] args) {
16 | if (args.length != 2) {
17 | System.out.println("Usage: TxReortWatcher datomic-uri datomic-attr");
18 | System.exit(-1);
19 | }
20 | watchTxReports(args[0], args[1]);
21 | }
22 |
23 | public static final String byAttribute = "[:find ?entity ?value" +
24 | " :in $ ?attribute" +
25 | " :where [?entity ?attribute ?value]]";
26 |
27 | private static void watchTxReports(String url, String attr) {
28 | final Connection conn = connect(url);
29 | final Object attrid = conn.db().entid(attr);
30 | if (attrid == null) {
31 | throw new IllegalArgumentException("No attribute named " + attr);
32 | }
33 | final BlockingQueue queue = conn.txReportQueue();
34 | new Thread(new Runnable() {
35 | @Override
36 | public void run() {
37 | while (true) {
38 | try {
39 | final Map tx = queue.take();
40 | Collection> results = q(byAttribute, tx.get(TX_DATA), attrid);
41 | for (Iterator> iterator = results.iterator(); iterator.hasNext(); ) {
42 | printList(iterator.next());
43 | }
44 | } catch (InterruptedException e) {
45 | e.printStackTrace();
46 | }
47 | }
48 | }
49 | }).run();
50 | }
51 |
52 | private static void printList(List next) {
53 | for (java.util.Iterator iterator = next.iterator(); iterator.hasNext(); ) {
54 | System.out.print(iterator.next());
55 | System.out.print(" ");
56 | }
57 | System.out.println("");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/java/datomic/samples/With.java:
--------------------------------------------------------------------------------
1 | package datomic.samples;
2 |
3 | import datomic.Peer;
4 |
5 | import java.util.Collection;
6 | import java.util.List;
7 |
8 | import static datomic.Peer.query;
9 | import static datomic.Util.list;
10 | import static datomic.samples.PrettyPrint.print;
11 |
12 | public class With {
13 | public static Object incorrectHeadCount() {
14 | return query("[:find (sum ?heads) ." +
15 | " :in [[_ ?heads]]]", monsters);
16 | }
17 |
18 | public static Object correctHeadCount() {
19 | return query("[:find (sum ?heads) ." +
20 | " :with ?monster" +
21 | " :in [[?monster ?heads]]]", monsters);
22 | }
23 |
24 | public static final Collection monsters = list(list("Cerberus", 3),
25 | list("Medusa", 1),
26 | list("Cyclops", 1),
27 | list("Chimera", 1));
28 | public static void main(String[] args) {
29 | print(incorrectHeadCount());
30 | print(correctHeadCount());
31 | Peer.shutdown(true);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/java/hornet/samples/PingConsumer.java:
--------------------------------------------------------------------------------
1 | package hornet.samples;
2 |
3 | import datomic.samples.IO;
4 | import org.hornetq.api.core.TransportConfiguration;
5 | import org.hornetq.api.core.client.ClientConsumer;
6 | import org.hornetq.api.core.client.ClientMessage;
7 | import org.hornetq.api.core.client.ClientProducer;
8 | import org.hornetq.api.core.client.ClientSession;
9 | import org.hornetq.api.core.client.ClientSessionFactory;
10 | import org.hornetq.api.core.client.HornetQClient;
11 | import org.hornetq.api.core.client.ServerLocator;
12 | import org.hornetq.core.config.Configuration;
13 | import org.hornetq.core.config.impl.ConfigurationImpl;
14 | import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
15 | import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
16 | import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
17 | import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
18 | import org.hornetq.core.server.HornetQServer;
19 | import org.hornetq.core.server.HornetQServers;
20 | import org.slf4j.LoggerFactory;
21 | import org.slf4j.bridge.SLF4JBridgeHandler;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 | import java.util.logging.LogManager;
26 |
27 | public class PingConsumer {
28 | public static Map nettyOpts() {
29 | Map m = new HashMap();
30 | m.put("port", 5000);
31 | m.put("host", "localhost");
32 | m.put("ssl-enabled", true);
33 | m.put("key-store-path", "datomic/transactor-key.jks");
34 | m.put("key-store-password", "transactor");
35 | m.put("trust-store-path", "datomic/transactor-trust.jks");
36 | m.put("trust-store-password", "transactor");
37 | return m;
38 | }
39 | public static void main(String[] args) {
40 | SLF4JBridgeHandler.install();
41 | LogManager.getLogManager().getLogger("").info("Ping Consumer Starting");
42 |
43 | try
44 | {
45 |
46 | // Step 1. Create the Configuration, and set the properties accordingly
47 | Configuration configuration = new ConfigurationImpl();
48 | configuration.setPersistenceEnabled(false);
49 | configuration.setSecurityEnabled(false);
50 | configuration.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
51 | configuration.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), nettyOpts()));
52 |
53 | // Step 2. Create and start the server
54 | HornetQServer server = HornetQServers.newHornetQServer(configuration);
55 | server.start();
56 |
57 | // Step 3. As we are not using a JNDI environment we instantiate the objects directly
58 | ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
59 | ClientSessionFactory sf = serverLocator.createSessionFactory();
60 |
61 | // Step 4. Create a core queue
62 | ClientSession coreSession = sf.createSession(false, false, false);
63 |
64 | final String queueName = "queue.exampleQueue";
65 |
66 | coreSession.createQueue(queueName, queueName, true);
67 |
68 | coreSession.close();
69 |
70 | ClientSession session = null;
71 |
72 | try
73 | {
74 | // Step 5. Create the session, and producer
75 | session = sf.createSession();
76 |
77 | // Step 7. Create the message consumer and start the connection
78 | ClientConsumer messageConsumer = session.createConsumer(queueName);
79 | session.start();
80 |
81 | System.out.println("Waiting for messages...");
82 | while (true) {
83 |
84 | // Step 8. Receive the message.
85 | ClientMessage messageReceived = messageConsumer.receive();
86 | if (messageReceived == null) {
87 | System.out.println("Received a null message");
88 | } else {
89 | messageReceived.acknowledge();
90 | System.out.println("Received TextMessage:" + messageReceived.getStringProperty("prop"));
91 | }
92 | }
93 | }
94 | finally
95 | {
96 | if (session != null) {
97 | session.close();
98 | }
99 |
100 | // Step 9. Be sure to close our resources!
101 | if (sf != null)
102 | {
103 | sf.close();
104 | }
105 |
106 | // Step 10. Stop the server
107 | server.stop();
108 | }
109 | }
110 | catch (Exception e)
111 | {
112 | e.printStackTrace();
113 | System.exit(-1);
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/java/hornet/samples/PingProducer.java:
--------------------------------------------------------------------------------
1 | package hornet.samples;
2 |
3 | import org.hornetq.api.core.TransportConfiguration;
4 | import org.hornetq.api.core.client.ClientConsumer;
5 | import org.hornetq.api.core.client.ClientMessage;
6 | import org.hornetq.api.core.client.ClientProducer;
7 | import org.hornetq.api.core.client.ClientSession;
8 | import org.hornetq.api.core.client.ClientSessionFactory;
9 | import org.hornetq.api.core.client.HornetQClient;
10 | import org.hornetq.api.core.client.ServerLocator;
11 | import org.hornetq.core.config.Configuration;
12 | import org.hornetq.core.config.impl.ConfigurationImpl;
13 | import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
14 | import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
15 | import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
16 | import org.hornetq.core.server.HornetQServer;
17 | import org.hornetq.core.server.HornetQServers;
18 | import org.slf4j.bridge.SLF4JBridgeHandler;
19 |
20 | import java.util.HashMap;
21 | import java.util.Map;
22 | import java.util.logging.ConsoleHandler;
23 | import java.util.logging.Level;
24 | import java.util.logging.LogManager;
25 | import java.util.logging.Logger;
26 |
27 | public class PingProducer {
28 | public static Map nettyOpts() {
29 | Map m = new HashMap();
30 | m.put("port", 5000);
31 | m.put("host", "localhost");
32 | m.put("ssl-enabled", true);
33 | m.put("key-store-path", "datomic/transactor-key.jks");
34 | m.put("key-store-password", "transactor");
35 | return m;
36 | }
37 |
38 | public static void main(final String[] args) throws InterruptedException {
39 | SLF4JBridgeHandler.install();
40 | LogManager.getLogManager().getLogger("").info("Ping Producer Starting");
41 | try
42 | {
43 | // Step 3. As we are not using a JNDI environment we instantiate the objects directly
44 | final String queueName = "queue.exampleQueue";
45 |
46 | ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), nettyOpts()));
47 | for (int n=0; true; n++) {
48 | ClientSessionFactory sf = serverLocator.createSessionFactory();
49 |
50 | // Step 5. Create the session, and producer
51 | ClientSession session = sf.createSession();
52 |
53 | ClientProducer producer = session.createProducer(queueName);
54 |
55 | // Step 6. Create and send a message
56 | ClientMessage message = session.createMessage(false);
57 |
58 | message.putStringProperty("prop", "ping " + n);
59 |
60 | System.out.println("Sending the message " + n);
61 |
62 | producer.send(message);
63 |
64 | System.out.println("Close the session");
65 | session.close();
66 | sf.close();
67 | // serverLocator.close();
68 | }
69 | }
70 | catch (Exception e)
71 | {
72 | e.printStackTrace();
73 | System.exit(-1);
74 | }
75 | System.out.println("The end");
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/accounts.edn:
--------------------------------------------------------------------------------
1 | ;; accounts
2 | [{:db/id #db/id[:db.part/db]
3 | :db/ident :account/balance
4 | :db/valueType :db.type/long
5 | :db/cardinality :db.cardinality/one
6 | :db.install/_attribute :db.part/db}]
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/bigger-than-pluto.edn:
--------------------------------------------------------------------------------
1 | [{:db/id #db/id [db.part/db]
2 | :db/ident :object/name
3 | :db/doc "Name of a Solar System object."
4 | :db/valueType :db.type/string
5 | :db/index true
6 | :db/cardinality :db.cardinality/one
7 | :db.install/_attribute :db.part/db}
8 | {:db/id #db/id [db.part/db]
9 | :db/ident :object/meanRadius
10 | :db/doc "Mean radius of an object."
11 | :db/index true
12 | :db/valueType :db.type/double
13 | :db/cardinality :db.cardinality/one
14 | :db.install/_attribute :db.part/db}
15 | {:db/id #db/id [db.part/db]
16 | :db/ident :data/source
17 | :db/doc "Source of the data in a transaction."
18 | :db/valueType :db.type/string
19 | :db/index true
20 | :db/cardinality :db.cardinality/one
21 | :db.install/_attribute :db.part/db}]
22 | [{:db/id #db/id [db.part/tx]
23 | :db/doc "Solar system objects bigger than Pluto."}
24 | {:db/id #db/id [db.part/tx]
25 | :data/source "http://en.wikipedia.org/wiki/List_of_Solar_System_objects_by_size"}
26 | {:db/id #db/id [db.part/user]
27 | :object/name "Sun"
28 | :object/meanRadius 696000.0}
29 | {:db/id #db/id [db.part/user]
30 | :object/name "Jupiter"
31 | :object/meanRadius 69911.0}
32 | {:db/id #db/id [db.part/user]
33 | :object/name "Saturn"
34 | :object/meanRadius 58232.0}
35 | {:db/id #db/id [db.part/user]
36 | :object/name "Uranus"
37 | :object/meanRadius 25362.0}
38 | {:db/id #db/id [db.part/user]
39 | :object/name "Neptune"
40 | :object/meanRadius 24622.0}
41 | {:db/id #db/id [db.part/user]
42 | :object/name "Earth"
43 | :object/meanRadius 6371.0}
44 | {:db/id #db/id [db.part/user]
45 | :object/name "Venus"
46 | :object/meanRadius 6051.8}
47 | {:db/id #db/id [db.part/user]
48 | :object/name "Mars"
49 | :object/meanRadius 3390.0}
50 | {:db/id #db/id [db.part/user]
51 | :object/name "Ganymede"
52 | :object/meanRadius 2631.2}
53 | {:db/id #db/id [db.part/user]
54 | :object/name "Titan"
55 | :object/meanRadius 2576.0}
56 | {:db/id #db/id [db.part/user]
57 | :object/name "Mercury"
58 | :object/meanRadius 2439.7}
59 | {:db/id #db/id [db.part/user]
60 | :object/name "Callisto"
61 | :object/meanRadius 2410.3}
62 | {:db/id #db/id [db.part/user]
63 | :object/name "Io"
64 | :object/meanRadius 1821.5}
65 | {:db/id #db/id [db.part/user]
66 | :object/name "Moon"
67 | :object/meanRadius 1737.1}
68 | {:db/id #db/id [db.part/user]
69 | :object/name "Europa"
70 | :object/meanRadius 1561.0}
71 | {:db/id #db/id [db.part/user]
72 | :object/name "Triton"
73 | :object/meanRadius 1353.4}
74 | {:db/id #db/id [db.part/user]
75 | :object/name "Eris"
76 | :object/meanRadius 1163.0}]
77 |
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/seattle-data1.edn:
--------------------------------------------------------------------------------
1 | [
2 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000451], :district/name "Greater Duwamish"}
3 | {:db/id #db/id[:db.part/user -1000452], :neighborhood/name "Beacon Hill", :neighborhood/district #db/id[:db.part/user -1000451]}
4 | {:community/category ["community members"], :community/orgtype :community.orgtype/community, :community/type :community.type/email-list, :db/id #db/id[:db.part/user -1000453], :community/name "nbeaconhillneighbors", :community/url "http://groups.yahoo.com/group/nbeaconhillneighbors/", :community/neighborhood #db/id[:db.part/user -1000452]}
5 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000454], :district/name "Southeast"}
6 | {:db/id #db/id[:db.part/user -1000455], :neighborhood/name "Rainier Valley", :neighborhood/district #db/id[:db.part/user -1000454]}
7 | {:community/category ["services portal"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000456], :community/name "New Holly Neighborhood Campus", :community/url "http://www.newholly.org/", :community/neighborhood #db/id[:db.part/user -1000455]}
8 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000457], :district/name "Southeast"}
9 | {:db/id #db/id[:db.part/user -1000458], :neighborhood/name "Rainier Beach", :neighborhood/district #db/id[:db.part/user -1000457]}
10 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000459], :community/name "New Rainier Vista", :community/url "http://newrainiervista.com/public/about/", :community/neighborhood #db/id[:db.part/user -1000458]}
11 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000460], :district/name "Greater Duwamish"}
12 | {:db/id #db/id[:db.part/user -1000461], :neighborhood/name "Beacon Hill", :neighborhood/district #db/id[:db.part/user -1000460]}
13 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000462], :community/name "North Beacon Hill", :community/url "http://north-beacon-hill.blogspot.com/", :community/neighborhood #db/id[:db.part/user -1000461]}
14 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000463], :district/name "Greater Duwamish"}
15 | {:db/id #db/id[:db.part/user -1000464], :neighborhood/name "Beacon Hill", :neighborhood/district #db/id[:db.part/user -1000463]}
16 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000465], :community/name "North Beacon Hill Council", :community/url "http://www.cityofseattle.net/commnty/Beacon/groups/nbhc/", :community/neighborhood #db/id[:db.part/user -1000464]}
17 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000466], :district/name "East"}
18 | {:db/id #db/id[:db.part/user -1000467], :neighborhood/name "Capitol Hill", :neighborhood/district #db/id[:db.part/user -1000466]}
19 | {:community/category ["meeting notes" "relevant news"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000468], :community/name "North Capitol Hill Neighborhood Association", :community/url "http://www.nchna.com/", :community/neighborhood #db/id[:db.part/user -1000467]}
20 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000469], :district/name "Delridge"}
21 | {:db/id #db/id[:db.part/user -1000470], :neighborhood/name "Delridge", :neighborhood/district #db/id[:db.part/user -1000469]}
22 | {:community/category ["events calendar"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000471], :community/name "North Delridge Neighborhood Council", :community/url "http://ndnc.org/", :community/neighborhood #db/id[:db.part/user -1000470]}
23 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000472], :district/name "North"}
24 | {:db/id #db/id[:db.part/user -1000473], :neighborhood/name "Northgate", :neighborhood/district #db/id[:db.part/user -1000472]}
25 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000474], :community/name "Northgate Chamber of Commerce", :community/url "http://www.northgatechamber.com/", :community/neighborhood #db/id[:db.part/user -1000473]}
26 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000475], :district/name "Northwest"}
27 | {:db/id #db/id[:db.part/user -1000476], :neighborhood/name "Northwest", :neighborhood/district #db/id[:db.part/user -1000475]}
28 | {:community/category ["district council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000477], :community/name "Northwest District Council", :community/url "http://www.nwdistrictcouncil.org/", :community/neighborhood #db/id[:db.part/user -1000476]}
29 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000478], :district/name "Southwest"}
30 | {:db/id #db/id[:db.part/user -1000479], :neighborhood/name "High Point", :neighborhood/district #db/id[:db.part/user -1000478]}
31 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000480], :community/name "Official Website of the High Point Neighborhood", :community/url "http://www.highpointneighborhood.org/", :community/neighborhood #db/id[:db.part/user -1000479]}
32 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000481], :district/name "Southeast"}
33 | {:db/id #db/id[:db.part/user -1000482], :neighborhood/name "Othello", :neighborhood/district #db/id[:db.part/user -1000481]}
34 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000483], :community/name "Othello Neighborhood Association", :community/url "http://othello.talkspot.com/", :community/neighborhood #db/id[:db.part/user -1000482]}
35 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000484], :district/name "Northwest"}
36 | {:db/id #db/id[:db.part/user -1000485], :neighborhood/name "Phinney Ridge", :neighborhood/district #db/id[:db.part/user -1000484]}
37 | {:community/category ["association news and events"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000486], :community/name "Phinney Neighborhood Association", :community/url "http://phinneycenter.blogspot.com/", :community/neighborhood #db/id[:db.part/user -1000485]}
38 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000487], :district/name "Northwest"}
39 | {:db/id #db/id[:db.part/user -1000488], :neighborhood/name "Phinney Ridge", :neighborhood/district #db/id[:db.part/user -1000487]}
40 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000489], :community/name "Phinney Neighborhood Association", :community/url "http://www.facebook.com/group.php?gid=42314991794", :community/neighborhood #db/id[:db.part/user -1000488]}
41 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000490], :district/name "Northwest"}
42 | {:db/id #db/id[:db.part/user -1000491], :neighborhood/name "Phinney Ridge", :neighborhood/district #db/id[:db.part/user -1000490]}
43 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000492], :community/name "Phinney Neighborhood Association", :community/url "http://www.phinneycenter.org/", :community/neighborhood #db/id[:db.part/user -1000491]}
44 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000493], :district/name "Northwest"}
45 | {:db/id #db/id[:db.part/user -1000494], :neighborhood/name "Phinney Ridge", :neighborhood/district #db/id[:db.part/user -1000493]}
46 | {:community/category ["news" "events" "food" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000495], :community/name "PhinneyWood", :community/url "http://www.phinneywood.com/", :community/neighborhood #db/id[:db.part/user -1000494]}
47 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000496], :district/name "North"}
48 | {:db/id #db/id[:db.part/user -1000497], :neighborhood/name "Pinehurst", :neighborhood/district #db/id[:db.part/user -1000496]}
49 | {:community/category ["news" "events" "issues"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000498], :community/name "Pinehurst Seattle", :community/url "http://pinehurstseattle.org", :community/neighborhood #db/id[:db.part/user -1000497]}
50 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000499], :district/name "North"}
51 | {:db/id #db/id[:db.part/user -1000500], :neighborhood/name "Pinehurst", :neighborhood/district #db/id[:db.part/user -1000499]}
52 | {:community/category ["news" "events" "issues"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000501], :community/name "Pinehurst Seattle", :community/url "http://twitter.com/pinehurstsea", :community/neighborhood #db/id[:db.part/user -1000500]}
53 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000502], :district/name "North"}
54 | {:db/id #db/id[:db.part/user -1000503], :neighborhood/name "Pinehurst", :neighborhood/district #db/id[:db.part/user -1000502]}
55 | {:community/category ["news" "events" "issues"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000504], :community/name "Pinehurst Seattle", :community/url "http://www.facebook.com/#!/group.php?gid=53590206898&v=wall&ref=search", :community/neighborhood #db/id[:db.part/user -1000503]}
56 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000505], :district/name "Downtown"}
57 | {:db/id #db/id[:db.part/user -1000506], :neighborhood/name "Pioneer Square", :neighborhood/district #db/id[:db.part/user -1000505]}
58 | {:community/category ["community organization"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000507], :community/name "Pioneer Square Community Association", :community/url "http://www.pioneersquare.org/", :community/neighborhood #db/id[:db.part/user -1000506]}
59 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000508], :district/name "Magnolia/Queen Anne"}
60 | {:db/id #db/id[:db.part/user -1000509], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000508]}
61 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000510], :community/name "Queen Anne Chamber of Commerce", :community/url "http://qachamber.org/", :community/neighborhood #db/id[:db.part/user -1000509]}
62 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000511], :district/name "Magnolia/Queen Anne"}
63 | {:db/id #db/id[:db.part/user -1000512], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000511]}
64 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000513], :community/name "Queen Anne Community Council", :community/url "http://www.qacc.net/", :community/neighborhood #db/id[:db.part/user -1000512]}
65 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000514], :district/name "Magnolia/Queen Anne"}
66 | {:db/id #db/id[:db.part/user -1000515], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000514]}
67 | {:community/category ["news" "local issues"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000516], :community/name "Queen Anne Examiner", :community/url "http://www.examiner.com/x-8856-Seattle-Queen-Anne-Hill-Examiner", :community/neighborhood #db/id[:db.part/user -1000515]}
68 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000517], :district/name "Magnolia/Queen Anne"}
69 | {:db/id #db/id[:db.part/user -1000518], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000517]}
70 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000519], :community/name "Queen Anne Helpline", :community/url "http://queenannehelpline.org/index.php", :community/neighborhood #db/id[:db.part/user -1000518]}
71 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000520], :district/name "Magnolia/Queen Anne"}
72 | {:db/id #db/id[:db.part/user -1000521], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000520]}
73 | {:community/category ["historical society"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000522], :community/name "Queen Anne Historical Society", :community/url "http://www.qahistory.org/", :community/neighborhood #db/id[:db.part/user -1000521]}
74 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000523], :district/name "Magnolia/Queen Anne"}
75 | {:db/id #db/id[:db.part/user -1000524], :neighborhood/name "Queen Anne", :neighborhood/district #db/id[:db.part/user -1000523]}
76 | {:community/category ["news" "events" "reviews"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000525], :community/name "Queen Anne View", :community/url "http://www.queenanneview.com/", :community/neighborhood #db/id[:db.part/user -1000524]}
77 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000526], :district/name "Southeast"}
78 | {:db/id #db/id[:db.part/user -1000527], :neighborhood/name "Rainier Beach", :neighborhood/district #db/id[:db.part/user -1000526]}
79 | {:community/category ["news" "events" "issues"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000528], :community/name "Rainier Beach Community Empowerment Coalition", :community/url "http://twitter.com/rainierbeach", :community/neighborhood #db/id[:db.part/user -1000527]}
80 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000529], :district/name "Southeast"}
81 | {:db/id #db/id[:db.part/user -1000530], :neighborhood/name "Rainier Beach", :neighborhood/district #db/id[:db.part/user -1000529]}
82 | {:community/category ["news" "events" "issues"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000531], :community/name "Rainier Beach Community Empowerment Coalition", :community/url "http://www.rbcoalition.org/", :community/neighborhood #db/id[:db.part/user -1000530]}
83 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000532], :district/name "Southeast"}
84 | {:db/id #db/id[:db.part/user -1000533], :neighborhood/name "Rainier Valley", :neighborhood/district #db/id[:db.part/user -1000532]}
85 | {:community/category ["historical society"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000534], :community/name "Rainier Valley Historical Society", :community/url "http://www.rainiervalleyhistory.org/", :community/neighborhood #db/id[:db.part/user -1000533]}
86 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000535], :district/name "Southeast"}
87 | {:db/id #db/id[:db.part/user -1000536], :neighborhood/name "Rainier Valley", :neighborhood/district #db/id[:db.part/user -1000535]}
88 | {:community/category ["news" "events" "911 blotter" "food" "reviews"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000537], :community/name "Rainier Valley Post", :community/url "http://www.rainiervalleypost.com/", :community/neighborhood #db/id[:db.part/user -1000536]}
89 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000538], :district/name "Northeast"}
90 | {:db/id #db/id[:db.part/user -1000539], :neighborhood/name "Ravenna", :neighborhood/district #db/id[:db.part/user -1000538]}
91 | {:community/category ["news" "events" "human interest" "criminal activity" "food" "shopping"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000540], :community/name "Ravenna Blog", :community/url "http://twitter.com/ravennablog", :community/neighborhood #db/id[:db.part/user -1000539]}
92 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000541], :district/name "Northeast"}
93 | {:db/id #db/id[:db.part/user -1000542], :neighborhood/name "Ravenna", :neighborhood/district #db/id[:db.part/user -1000541]}
94 | {:community/category ["news" "events" "human interest" "criminal activity" "food" "shopping"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000543], :community/name "Ravenna Blog", :community/url "http://www.facebook.com/pages/Ravenna-Blog/116280421718247", :community/neighborhood #db/id[:db.part/user -1000542]}
95 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000544], :district/name "Northeast"}
96 | {:db/id #db/id[:db.part/user -1000545], :neighborhood/name "Ravenna", :neighborhood/district #db/id[:db.part/user -1000544]}
97 | {:community/category ["news" "events" "human interest" "criminal activity" "food" "shopping"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000546], :community/name "Ravenna Blog", :community/url "http://www.ravennablog.com/", :community/neighborhood #db/id[:db.part/user -1000545]}
98 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000547], :district/name "Northeast"}
99 | {:db/id #db/id[:db.part/user -1000548], :neighborhood/name "Ravenna", :neighborhood/district #db/id[:db.part/user -1000547]}
100 | {:community/category ["community association"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000549], :community/name "Ravenna-Bryant Community Association", :community/url "http://www.facebook.com/pages/Ravenna-Bryant-Community-Association/153638664651035", :community/neighborhood #db/id[:db.part/user -1000548]}
101 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000550], :district/name "Northeast"}
102 | {:db/id #db/id[:db.part/user -1000551], :neighborhood/name "Ravenna", :neighborhood/district #db/id[:db.part/user -1000550]}
103 | {:community/category ["community association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000552], :community/name "Ravenna-Bryant Community Association", :community/url "http://www.ravennabryant.org/", :community/neighborhood #db/id[:db.part/user -1000551]}
104 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000553], :district/name "Northeast"}
105 | {:db/id #db/id[:db.part/user -1000554], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000553]}
106 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000555], :community/name "Roosevelt Neighborhood Association", :community/url "http://rooseveltseattle.org/default.aspx", :community/neighborhood #db/id[:db.part/user -1000554]}
107 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000556], :district/name "Northeast"}
108 | {:db/id #db/id[:db.part/user -1000557], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000556]}
109 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000558], :community/name "Roosevelt Neighborhood Association", :community/url "http://www.facebook.com/group.php?gid=178766520060", :community/neighborhood #db/id[:db.part/user -1000557]}
110 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000559], :district/name "Northeast"}
111 | {:db/id #db/id[:db.part/user -1000560], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000559]}
112 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000561], :community/name "Roosevelt Neighbors' Alliance", :community/url "http://www.rooseveltneighborsalliance.org/main/Roosevelt_Neighbors_Alliance.html", :community/neighborhood #db/id[:db.part/user -1000560]}
113 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000562], :district/name "Northeast"}
114 | {:db/id #db/id[:db.part/user -1000563], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000562]}
115 | {:community/category ["news" "events"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000564], :community/name "Roosevelt Seattle", :community/url "http://twitter.com/roosieseattle", :community/neighborhood #db/id[:db.part/user -1000563]}
116 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000565], :district/name "Northeast"}
117 | {:db/id #db/id[:db.part/user -1000566], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000565]}
118 | {:community/category ["news" "events" "human interest" "criminal activity"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000567], :community/name "Rosiehood", :community/url "http://twitter.com/Roosiehood", :community/neighborhood #db/id[:db.part/user -1000566]}
119 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000568], :district/name "Northeast"}
120 | {:db/id #db/id[:db.part/user -1000569], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000568]}
121 | {:community/category ["news" "events" "human interest" "criminal activity"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000570], :community/name "Rosiehood", :community/url "http://www.facebook.com/pages/Roosevelt-Neighborhood-Blog/133948283288085", :community/neighborhood #db/id[:db.part/user -1000569]}
122 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000571], :district/name "Northeast"}
123 | {:db/id #db/id[:db.part/user -1000572], :neighborhood/name "Roosevelt", :neighborhood/district #db/id[:db.part/user -1000571]}
124 | {:community/category ["news" "events" "human interest" "criminal activity"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000573], :community/name "Rosiehood", :community/url "http://www.roosiehood.com/", :community/neighborhood #db/id[:db.part/user -1000572]}
125 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000574], :district/name "Lake Union"}
126 | {:db/id #db/id[:db.part/user -1000575], :neighborhood/name "South Lake Union", :neighborhood/district #db/id[:db.part/user -1000574]}
127 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000576], :community/name "S Lake Union Friends and Neighbors Community Council", :community/url "http://www.slufan.org/", :community/neighborhood #db/id[:db.part/user -1000575]}
128 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000577], :district/name "Downtown"}
129 | {:db/id #db/id[:db.part/user -1000578], :neighborhood/name "International District", :neighborhood/district #db/id[:db.part/user -1000577]}
130 | {:community/category ["public development authority"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000579], :community/name "SCIPDA", :community/url "http://www.scidpda.org/", :community/neighborhood #db/id[:db.part/user -1000578]}
131 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000580], :district/name "East"}
132 | {:db/id #db/id[:db.part/user -1000581], :neighborhood/name "Capitol Hill", :neighborhood/district #db/id[:db.part/user -1000580]}
133 | {:community/category ["college"], :community/type :community.type/website, :db/id #db/id[:db.part/user -1000582], :community/name "Seattle Central Community College", :community/url "http://seattlecentral.edu/", :community/neighborhood #db/id[:db.part/user -1000581]}
134 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000583], :district/name "Downtown"}
135 | {:db/id #db/id[:db.part/user -1000584], :neighborhood/name "International District", :neighborhood/district #db/id[:db.part/user -1000583]}
136 | {:community/category ["food" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000585], :community/name "Seattle Chinatown Guide", :community/url "http://www.chinatownconnection.com/seattle-chinatown-international-district.htm", :community/neighborhood #db/id[:db.part/user -1000584]}
137 | {:district/region :region/s, :db/id #db/id[:db.part/user -1000586], :district/name "Greater Duwamish"}
138 | {:db/id #db/id[:db.part/user -1000587], :neighborhood/name "Industrial District", :neighborhood/district #db/id[:db.part/user -1000586]}
139 | {:community/category ["seattle industry"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000588], :community/name "Seattle Industry", :community/url "http://www.seattleindustry.org/", :community/neighborhood #db/id[:db.part/user -1000587]}
140 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000589], :district/name "Southeast"}
141 | {:db/id #db/id[:db.part/user -1000590], :neighborhood/name "Othello", :neighborhood/district #db/id[:db.part/user -1000589]}
142 | {:community/category ["shared community group website"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000591], :community/name "Seattle's Othello Neighborhood", :community/url "http://othelloneighborhood.org/default.aspx", :community/neighborhood #db/id[:db.part/user -1000590]}
143 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000592], :district/name "Southwest"}
144 | {:db/id #db/id[:db.part/user -1000593], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000592]}
145 | {:community/category ["senior center"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000594], :community/name "Senior Center West Seattle", :community/url "http://www.sc-ws.org/", :community/neighborhood #db/id[:db.part/user -1000593]}
146 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000595], :district/name "Southwest"}
147 | {:db/id #db/id[:db.part/user -1000596], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000595]}
148 | {:community/category ["senior sevices"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000597], :community/name "Senior Services", :community/url "http://www.seniorservices.org/", :community/neighborhood #db/id[:db.part/user -1000596]}
149 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000598], :district/name "Ballard"}
150 | {:db/id #db/id[:db.part/user -1000599], :neighborhood/name "Ballard", :neighborhood/district #db/id[:db.part/user -1000598]}
151 | {:community/category ["news" "weather" "events" "criminal activity"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000600], :community/name "Shilshole Blog", :community/url "http://shilsholecommunity.org/", :community/neighborhood #db/id[:db.part/user -1000599]}
152 | {:district/region :region/s, :db/id #db/id[:db.part/user -1000601], :district/name "Downtown"}
153 | {:db/id #db/id[:db.part/user -1000602], :neighborhood/name "SoDo", :neighborhood/district #db/id[:db.part/user -1000601]}
154 | {:community/category ["business association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000603], :community/name "SoDo Business Association", :community/url "http://www.sodobusinessassociation.org/", :community/neighborhood #db/id[:db.part/user -1000602]}
155 | {:district/region :region/s, :db/id #db/id[:db.part/user -1000604], :district/name "Greater Duwamish"}
156 | {:db/id #db/id[:db.part/user -1000605], :neighborhood/name "Industrial District", :neighborhood/district #db/id[:db.part/user -1000604]}
157 | {:community/category ["business association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000606], :community/name "SoDo Business Association", :community/url "http://www.sodobusinessassociation.org/", :community/neighborhood #db/id[:db.part/user -1000605]}
158 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000607], :district/name "Northwest"}
159 | {:db/id #db/id[:db.part/user -1000608], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000607]}
160 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000609], :community/name "Solid Ground", :community/url "http://www.facebook.com/pages/Solid-Ground/20665239656", :community/neighborhood #db/id[:db.part/user -1000608]}
161 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000610], :district/name "Northwest"}
162 | {:db/id #db/id[:db.part/user -1000611], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000610]}
163 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000612], :community/name "Solid Ground", :community/url "http://www.solid-ground.org/Pages/Default.aspx", :community/neighborhood #db/id[:db.part/user -1000611]}
164 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000613], :district/name "Lake Union"}
165 | {:db/id #db/id[:db.part/user -1000614], :neighborhood/name "South Lake Union", :neighborhood/district #db/id[:db.part/user -1000613]}
166 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000615], :community/name "South Lake Union Chamber of Commerce", :community/url "http://www.sluchamber.org/", :community/neighborhood #db/id[:db.part/user -1000614]}
167 | {:district/region :region/s, :db/id #db/id[:db.part/user -1000616], :district/name "Greater Duwamish"}
168 | {:db/id #db/id[:db.part/user -1000617], :neighborhood/name "South Park", :neighborhood/district #db/id[:db.part/user -1000616]}
169 | {:community/category ["neighborhood info"], :community/orgtype :community.orgtype/community, :community/type :community.type/myspace, :db/id #db/id[:db.part/user -1000618], :community/name "South Park Seattle", :community/url "http://www.myspace.com/southparkseattle", :community/neighborhood #db/id[:db.part/user -1000617]}
170 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000619], :district/name "Southeast"}
171 | {:db/id #db/id[:db.part/user -1000620], :neighborhood/name "Rainier Valley", :neighborhood/district #db/id[:db.part/user -1000619]}
172 | {:community/category ["district council"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000621], :community/name "Southeast District Council", :community/url "http://sedcseattle.wordpress.com/", :community/neighborhood #db/id[:db.part/user -1000620]}
173 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000622], :district/name "Central"}
174 | {:db/id #db/id[:db.part/user -1000623], :neighborhood/name "Central District", :neighborhood/district #db/id[:db.part/user -1000622]}
175 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/email-list, :db/id #db/id[:db.part/user -1000624], :community/name "Squire Park Community Council", :community/url "http://groups.yahoo.com/group/squirepark/", :community/neighborhood #db/id[:db.part/user -1000623]}
176 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000625], :district/name "Central"}
177 | {:db/id #db/id[:db.part/user -1000626], :neighborhood/name "Central District", :neighborhood/district #db/id[:db.part/user -1000625]}
178 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000627], :community/name "Squire Park Community Council", :community/url "http://www.squireparkseattle.com/", :community/neighborhood #db/id[:db.part/user -1000626]}
179 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000628], :district/name "Ballard"}
180 | {:db/id #db/id[:db.part/user -1000629], :neighborhood/name "Ballard", :neighborhood/district #db/id[:db.part/user -1000628]}
181 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/wiki, :db/id #db/id[:db.part/user -1000630], :community/name "Sustainable Ballard", :community/url "http://sustainableballard.org/wiki/index.php?title=Welcome_to_Sustainable_Ballard!", :community/neighborhood #db/id[:db.part/user -1000629]}
182 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000631], :district/name "Ballard"}
183 | {:db/id #db/id[:db.part/user -1000632], :neighborhood/name "Crown Hill", :neighborhood/district #db/id[:db.part/user -1000631]}
184 | {:community/category ["community group" "has mailing list"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000633], :community/name "Sustainable Crown Hill", :community/url "http://sustainablecrownhill.org/wp/", :community/neighborhood #db/id[:db.part/user -1000632]}
185 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000634], :district/name "Northwest"}
186 | {:db/id #db/id[:db.part/user -1000635], :neighborhood/name "Phinney Ridge", :neighborhood/district #db/id[:db.part/user -1000634]}
187 | {:community/category ["susainability"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000636], :community/name "Sustainable Greenwood/Phinney", :community/url "http://web.me.com/annecann1/iWeb/Site/Home.html", :community/neighborhood #db/id[:db.part/user -1000635]}
188 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000637], :district/name "Northeast"}
189 | {:db/id #db/id[:db.part/user -1000638], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000637]}
190 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/ning, :db/id #db/id[:db.part/user -1000639], :community/name "Sustainable Northeast Seattle", :community/url "http://sustainableneseattle.ning.com/", :community/neighborhood #db/id[:db.part/user -1000638]}
191 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000640], :district/name "Southwest"}
192 | {:db/id #db/id[:db.part/user -1000641], :neighborhood/name "Junction", :neighborhood/district #db/id[:db.part/user -1000640]}
193 | {:community/category ["neighborhood association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000642], :community/name "The Junction: Downtown West Seattle", :community/url "http://www.wsjunction.com/", :community/neighborhood #db/id[:db.part/user -1000641]}
194 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000643], :district/name "Northeast"}
195 | {:db/id #db/id[:db.part/user -1000644], :neighborhood/name "Laurelhurst", :neighborhood/district #db/id[:db.part/user -1000643]}
196 | {:community/category ["news" "events"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000645], :community/name "The Laurelhurst Blog", :community/url "http://thelaurelhurstblog.blogspot.com/", :community/neighborhood #db/id[:db.part/user -1000644]}
197 | {:district/region :region/n, :db/id #db/id[:db.part/user -1000646], :district/name "North"}
198 | {:db/id #db/id[:db.part/user -1000647], :neighborhood/name "Maple Leaf", :neighborhood/district #db/id[:db.part/user -1000646]}
199 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000648], :community/name "The Maple Leafer", :community/url "http://twitter.com/themapleleafer", :community/neighborhood #db/id[:db.part/user -1000647]}
200 | {:district/region :region/n, :db/id #db/id[:db.part/user -1000649], :district/name "North"}
201 | {:db/id #db/id[:db.part/user -1000650], :neighborhood/name "Maple Leaf", :neighborhood/district #db/id[:db.part/user -1000649]}
202 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000651], :community/name "The Maple Leafer", :community/url "http://www.facebook.com/pages/The-Maple-Leafer/110782042284727", :community/neighborhood #db/id[:db.part/user -1000650]}
203 | {:district/region :region/n, :db/id #db/id[:db.part/user -1000652], :district/name "North"}
204 | {:db/id #db/id[:db.part/user -1000653], :neighborhood/name "Maple Leaf", :neighborhood/district #db/id[:db.part/user -1000652]}
205 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000654], :community/name "The Maple Leafer", :community/url "http://www.themapleleafer.com/", :community/neighborhood #db/id[:db.part/user -1000653]}
206 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000655], :district/name "Lake Union"}
207 | {:db/id #db/id[:db.part/user -1000656], :neighborhood/name "South Lake Union", :neighborhood/district #db/id[:db.part/user -1000655]}
208 | {:community/category ["news" "events" "personalized profile pages"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000657], :community/name "The South Lake Union Community Blog", :community/url "http://www.thesouthlake.com/", :community/neighborhood #db/id[:db.part/user -1000656]}
209 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000658], :district/name "Northeast"}
210 | {:db/id #db/id[:db.part/user -1000659], :neighborhood/name "Thornton Creek", :neighborhood/district #db/id[:db.part/user -1000658]}
211 | {:community/category ["community group"], :community/type :community.type/website, :db/id #db/id[:db.part/user -1000660], :community/name "Thornton Creek Alliance", :community/url "http://www.scn.org/tca/", :community/neighborhood #db/id[:db.part/user -1000659]}
212 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000661], :district/name "Northeast"}
213 | {:db/id #db/id[:db.part/user -1000662], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000661]}
214 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000663], :community/name "U District Daily", :community/url "http://www.udistrictdaily.com/", :community/neighborhood #db/id[:db.part/user -1000662]}
215 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000664], :district/name "Northeast"}
216 | {:db/id #db/id[:db.part/user -1000665], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000664]}
217 | {:community/category ["business association"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000666], :community/name "University District Business Improvement Area", :community/url "http://www.udistrictchamber.org/UDBIA/index.html", :community/neighborhood #db/id[:db.part/user -1000665]}
218 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000667], :district/name "Northeast"}
219 | {:db/id #db/id[:db.part/user -1000668], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000667]}
220 | {:community/category ["food bank"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000669], :community/name "University District Food Bank", :community/url "http://www.facebook.com/pages/Seattle-WA/University-District-Food-Bank/47523824407", :community/neighborhood #db/id[:db.part/user -1000668]}
221 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000670], :district/name "Northeast"}
222 | {:db/id #db/id[:db.part/user -1000671], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000670]}
223 | {:community/category ["food bank"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000672], :community/name "University District Food Bank", :community/url "http://www.udistrictfoodbank.org/", :community/neighborhood #db/id[:db.part/user -1000671]}
224 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000673], :district/name "Northeast"}
225 | {:db/id #db/id[:db.part/user -1000674], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000673]}
226 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000675], :community/name "University District Seattle", :community/url "http://www.udistrictchamber.org/GUCC/GUCC.html", :community/neighborhood #db/id[:db.part/user -1000674]}
227 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000676], :district/name "Northeast"}
228 | {:db/id #db/id[:db.part/user -1000677], :neighborhood/name "University District", :neighborhood/district #db/id[:db.part/user -1000676]}
229 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000678], :community/name "University District Service Fund", :community/url "http://www.udistrictchamber.org/udistrictservicefund/index.html", :community/neighborhood #db/id[:db.part/user -1000677]}
230 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000679], :district/name "Northwest"}
231 | {:db/id #db/id[:db.part/user -1000680], :neighborhood/name "Greenwood", :neighborhood/district #db/id[:db.part/user -1000679]}
232 | {:community/category ["park issues" "events" "neighborhood-issues" "neighborhood-planning"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000681], :community/name "Vision Greenwood Park Seattle", :community/url "http://www.facebook.com/pages/Vision-Greenwood-Park-Seattle/165995713450762", :community/neighborhood #db/id[:db.part/user -1000680]}
233 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000682], :district/name "Ballard"}
234 | {:db/id #db/id[:db.part/user -1000683], :neighborhood/name "Crown Hill", :neighborhood/district #db/id[:db.part/user -1000682]}
235 | {:community/category ["neighborhood group"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000684], :community/name "Walkable Crown Hill", :community/url "http://walkablecrownhill.org/", :community/neighborhood #db/id[:db.part/user -1000683]}
236 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000685], :district/name "Northwest"}
237 | {:db/id #db/id[:db.part/user -1000686], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000685]}
238 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000687], :community/name "Wallingford Chamber of Commerce", :community/url "http://wallingfordchamber.org/", :community/neighborhood #db/id[:db.part/user -1000686]}
239 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000688], :district/name "Northwest"}
240 | {:db/id #db/id[:db.part/user -1000689], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000688]}
241 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000690], :community/name "Wallingford Community Council", :community/url "http://wallingford.org/get-involved/community-council/", :community/neighborhood #db/id[:db.part/user -1000689]}
242 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000691], :district/name "Northwest"}
243 | {:db/id #db/id[:db.part/user -1000692], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000691]}
244 | {:community/category ["news" "events" "advice"], :community/orgtype :community.orgtype/community, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000693], :community/name "Wallingford Seattle Blog", :community/url "http://twitter.com/wallingford", :community/neighborhood #db/id[:db.part/user -1000692]}
245 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000694], :district/name "Northwest"}
246 | {:db/id #db/id[:db.part/user -1000695], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000694]}
247 | {:community/category ["news" "events" "advice"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000696], :community/name "Wallingford Seattle Blog", :community/url "http://wallingfordseattle.tumblr.com/", :community/neighborhood #db/id[:db.part/user -1000695]}
248 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000697], :district/name "Northwest"}
249 | {:db/id #db/id[:db.part/user -1000698], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000697]}
250 | {:community/category ["neighborhood group"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000699], :community/name "Wallingford.org", :community/url "http://www.wallingford.org/", :community/neighborhood #db/id[:db.part/user -1000698]}
251 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000700], :district/name "Northwest"}
252 | {:db/id #db/id[:db.part/user -1000701], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000700]}
253 | {:community/category ["news" "events"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000702], :community/name "Wallyhood - Wallingford Seattle Blog", :community/url "http://twitter.com/wallyhood", :community/neighborhood #db/id[:db.part/user -1000701]}
254 | {:district/region :region/nw, :db/id #db/id[:db.part/user -1000703], :district/name "Northwest"}
255 | {:db/id #db/id[:db.part/user -1000704], :neighborhood/name "Wallingford", :neighborhood/district #db/id[:db.part/user -1000703]}
256 | {:community/category ["news" "events"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000705], :community/name "Wallyhood - Wallingford Seattle Blog", :community/url "http://www.wallyhood.org/", :community/neighborhood #db/id[:db.part/user -1000704]}
257 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000706], :district/name "Northeast"}
258 | {:db/id #db/id[:db.part/user -1000707], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000706]}
259 | {:community/category ["block watch"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000708], :community/name "Wedgwood Block Watch", :community/url "http://www.wedgwoodcc.org/wwbw/", :community/neighborhood #db/id[:db.part/user -1000707]}
260 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000709], :district/name "Northeast"}
261 | {:db/id #db/id[:db.part/user -1000710], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000709]}
262 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000711], :community/name "Wedgwood Community Council", :community/url "http://www.wedgwoodcc.org/", :community/neighborhood #db/id[:db.part/user -1000710]}
263 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000712], :district/name "Northeast"}
264 | {:db/id #db/id[:db.part/user -1000713], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000712]}
265 | {:community/category ["community council"], :community/orgtype :community.orgtype/community, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000714], :community/name "Wedgwood Community Council", :community/url "http://www.facebook.com/pages/Wedgwood-Community-Council/146730522040662", :community/neighborhood #db/id[:db.part/user -1000713]}
266 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000715], :district/name "Northeast"}
267 | {:db/id #db/id[:db.part/user -1000716], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000715]}
268 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000717], :community/name "Wedgwood View", :community/url "http://twitter.com/wedgwoodview", :community/neighborhood #db/id[:db.part/user -1000716]}
269 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000718], :district/name "Northeast"}
270 | {:db/id #db/id[:db.part/user -1000719], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000718]}
271 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000720], :community/name "Wedgwood View", :community/url "http://www.facebook.com/pages/Wedgwood-View/331236446338", :community/neighborhood #db/id[:db.part/user -1000719]}
272 | {:district/region :region/ne, :db/id #db/id[:db.part/user -1000721], :district/name "Northeast"}
273 | {:db/id #db/id[:db.part/user -1000722], :neighborhood/name "Wedgwood", :neighborhood/district #db/id[:db.part/user -1000721]}
274 | {:community/category ["news" "events" "human interest" "criminal activity" "shopping"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000723], :community/name "Wedgwood View", :community/url "http://www.wedgwoodview.com/", :community/neighborhood #db/id[:db.part/user -1000722]}
275 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000724], :district/name "Southwest"}
276 | {:db/id #db/id[:db.part/user -1000725], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000724]}
277 | {:community/category ["profile page for West Seattle Blog"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000726], :community/name "West Seattle Blog", :community/url "http://www.facebook.com/westseattleblog", :community/neighborhood #db/id[:db.part/user -1000725]}
278 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000727], :district/name "Southwest"}
279 | {:db/id #db/id[:db.part/user -1000728], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000727]}
280 | {:community/category ["chamber of commerce"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000729], :community/name "West Seattle Chamber of Commerce", :community/url "http://www.wschamber.com/", :community/neighborhood #db/id[:db.part/user -1000728]}
281 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000730], :district/name "Southwest"}
282 | {:db/id #db/id[:db.part/user -1000731], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000730]}
283 | {:community/category ["online newspaper"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/twitter, :db/id #db/id[:db.part/user -1000732], :community/name "West Seattle Herald", :community/url "http://twitter.com/westseattleher", :community/neighborhood #db/id[:db.part/user -1000731]}
284 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000733], :district/name "Southwest"}
285 | {:db/id #db/id[:db.part/user -1000734], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000733]}
286 | {:community/category ["online newspaper"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/facebook-page, :db/id #db/id[:db.part/user -1000735], :community/name "West Seattle Herald", :community/url "http://www.facebook.com/wsherald", :community/neighborhood #db/id[:db.part/user -1000734]}
287 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000736], :district/name "Southwest"}
288 | {:db/id #db/id[:db.part/user -1000737], :neighborhood/name "West Seattle", :neighborhood/district #db/id[:db.part/user -1000736]}
289 | {:community/category ["online newspaper"], :community/orgtype :community.orgtype/commercial, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000738], :community/name "West Seattle Herald", :community/url "http://www.westseattleherald.com/", :community/neighborhood #db/id[:db.part/user -1000737]}
290 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000739], :district/name "Delridge"}
291 | {:db/id #db/id[:db.part/user -1000740], :neighborhood/name "Westwood", :neighborhood/district #db/id[:db.part/user -1000739]}
292 | {:community/category ["neighborhood council"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000741], :community/name "Westwood Neighborhood Council", :community/url "http://www.scn.org/neighbors/westwood/", :community/neighborhood #db/id[:db.part/user -1000740]}
293 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000742], :district/name "Delridge"}
294 | {:db/id #db/id[:db.part/user -1000743], :neighborhood/name "White Center", :neighborhood/district #db/id[:db.part/user -1000742]}
295 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000744], :community/name "White Center Community Development Association", :community/url "http://www.wccda.org/home", :community/neighborhood #db/id[:db.part/user -1000743]}
296 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000745], :district/name "Delridge"}
297 | {:db/id #db/id[:db.part/user -1000746], :neighborhood/name "White Center", :neighborhood/district #db/id[:db.part/user -1000745]}
298 | {:community/category ["nonprofit"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000747], :community/name "White Center Community Development Association blog", :community/url "http://twitter.com/whitecentercda", :community/neighborhood #db/id[:db.part/user -1000746]}
299 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000748], :district/name "Delridge"}
300 | {:db/id #db/id[:db.part/user -1000749], :neighborhood/name "White Center", :neighborhood/district #db/id[:db.part/user -1000748]}
301 | {:community/category ["news" "events" "food"], :community/orgtype :community.orgtype/community, :community/type :community.type/blog, :db/id #db/id[:db.part/user -1000750], :community/name "White Center Now", :community/url "http://whitecenternow.com/", :community/neighborhood #db/id[:db.part/user -1000749]}
302 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000751], :district/name "Southwest"}
303 | {:db/id #db/id[:db.part/user -1000752], :neighborhood/name "White Center", :neighborhood/district #db/id[:db.part/user -1000751]}
304 | {:community/category ["tech resources"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000753], :community/name "White Center Technology Programs", :community/url "http://technology.program.googlepages.com/", :community/neighborhood #db/id[:db.part/user -1000752]}
305 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000754], :district/name "Downtown"}
306 | {:db/id #db/id[:db.part/user -1000755], :neighborhood/name "International District", :neighborhood/district #db/id[:db.part/user -1000754]}
307 | {:community/category ["museum"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000756], :community/name "Wing Luke Asian Museum", :community/url "http://www.wingluke.org/", :community/neighborhood #db/id[:db.part/user -1000755]}
308 | {:district/region :region/sw, :db/id #db/id[:db.part/user -1000757], :district/name "Delridge"}
309 | {:db/id #db/id[:db.part/user -1000758], :neighborhood/name "Delridge", :neighborhood/district #db/id[:db.part/user -1000757]}
310 | {:community/category ["arts"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000759], :community/name "Youngstown Cultural Arts Center", :community/url "http://youngstownarts.org", :community/neighborhood #db/id[:db.part/user -1000758]}
311 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000760], :district/name "East"}
312 | {:db/id #db/id[:db.part/user -1000761], :neighborhood/name "Capitol Hill", :neighborhood/district #db/id[:db.part/user -1000760]}
313 | {:community/category ["dining" "events" "nightlife" "shopping"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000762], :community/name "Your Capitol Hill", :community/url "http://www.yourcapitolhill.com/", :community/neighborhood #db/id[:db.part/user -1000761]}
314 | {:district/region :region/s, :db/id #db/id[:db.part/user -1000763], :district/name "Greater Duwamish"}
315 | {:db/id #db/id[:db.part/user -1000764], :neighborhood/name "South Park", :neighborhood/district #db/id[:db.part/user -1000763]}
316 | {:community/category ["community members"], :community/orgtype :community.orgtype/community, :community/type :community.type/email-list, :db/id #db/id[:db.part/user -1000765], :community/name "yoursouthpark", :community/url "http://groups.yahoo.com/group/yoursouthpark/", :community/neighborhood #db/id[:db.part/user -1000764]}
317 | {:district/region :region/w, :db/id #db/id[:db.part/user -1000766], :district/name "Downtown"}
318 | {:db/id #db/id[:db.part/user -1000767], :neighborhood/name "International District", :neighborhood/district #db/id[:db.part/user -1000766]}
319 | {:community/category ["ethnic/cultural-interest" "seniors" "youth"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000768], :community/name "Helping Link", :community/url "http://www.helpinglink.org/", :community/neighborhood #db/id[:db.part/user -1000767]}
320 | {:district/region :region/e, :db/id #db/id[:db.part/user -1000769], :district/name "East"}
321 | {:db/id #db/id[:db.part/user -1000770], :neighborhood/name "Madison Park", :neighborhood/district #db/id[:db.part/user -1000769]}
322 | {:community/category ["community group"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000771], :community/name "MLK FAME Community Center", :community/url "http://www.mlkfame.com/", :community/neighborhood #db/id[:db.part/user -1000770]}
323 | {:district/region :region/se, :db/id #db/id[:db.part/user -1000772], :district/name "Southeast"}
324 | {:db/id #db/id[:db.part/user -1000773], :neighborhood/name "Jackson Place", :neighborhood/district #db/id[:db.part/user -1000772]}
325 | {:community/category ["neighborhood-issues" "neighborhood-planning"], :community/orgtype :community.orgtype/community, :community/type :community.type/website, :db/id #db/id[:db.part/user -1000774], :community/name "Jackson Place Community Council", :community/url "http://www.jacksonplace.org", :community/neighborhood #db/id[:db.part/user -1000773]}
326 | ]
327 |
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/seattle-schema.edn:
--------------------------------------------------------------------------------
1 | [
2 | ;; community
3 |
4 | {:db/id #db/id[:db.part/db]
5 | :db/ident :community/name
6 | :db/valueType :db.type/string
7 | :db/cardinality :db.cardinality/one
8 | :db/fulltext true
9 | :db/doc "A community's name"
10 | :db.install/_attribute :db.part/db}
11 |
12 | {:db/id #db/id[:db.part/db]
13 | :db/ident :community/url
14 | :db/valueType :db.type/string
15 | :db/cardinality :db.cardinality/one
16 | :db/doc "A community's url"
17 | :db.install/_attribute :db.part/db}
18 |
19 | {:db/id #db/id[:db.part/db]
20 | :db/ident :community/neighborhood
21 | :db/valueType :db.type/ref
22 | :db/cardinality :db.cardinality/one
23 | :db/doc "A community's neighborhood"
24 | :db.install/_attribute :db.part/db}
25 |
26 | {:db/id #db/id[:db.part/db]
27 | :db/ident :community/category
28 | :db/valueType :db.type/string
29 | :db/cardinality :db.cardinality/many
30 | :db/fulltext true
31 | :db/doc "All community categories"
32 | :db.install/_attribute :db.part/db}
33 |
34 | {:db/id #db/id[:db.part/db]
35 | :db/ident :community/orgtype
36 | :db/valueType :db.type/ref
37 | :db/cardinality :db.cardinality/one
38 | :db/doc "A community orgtype enum value"
39 | :db.install/_attribute :db.part/db}
40 |
41 | {:db/id #db/id[:db.part/db]
42 | :db/ident :community/type
43 | :db/valueType :db.type/ref
44 | :db/cardinality :db.cardinality/one
45 | :db/doc "A community type enum value"
46 | :db.install/_attribute :db.part/db}
47 |
48 | ;; community/org-type enum values
49 | [:db/add #db/id[:db.part/user] :db/ident :community.orgtype/community]
50 | [:db/add #db/id[:db.part/user] :db/ident :community.orgtype/commercial]
51 | [:db/add #db/id[:db.part/user] :db/ident :community.orgtype/nonprofit]
52 | [:db/add #db/id[:db.part/user] :db/ident :community.orgtype/personal]
53 |
54 | ;; community/type enum values
55 | [:db/add #db/id[:db.part/user] :db/ident :community.type/email-list]
56 | [:db/add #db/id[:db.part/user] :db/ident :community.type/twitter]
57 | [:db/add #db/id[:db.part/user] :db/ident :community.type/facebook-page]
58 | [:db/add #db/id[:db.part/user] :db/ident :community.type/blog]
59 | [:db/add #db/id[:db.part/user] :db/ident :community.type/website]
60 | [:db/add #db/id[:db.part/user] :db/ident :community.type/wiki]
61 | [:db/add #db/id[:db.part/user] :db/ident :community.type/myspace]
62 | [:db/add #db/id[:db.part/user] :db/ident :community.type/ning]
63 |
64 | ;; neighborhood
65 | {:db/id #db/id[:db.part/db]
66 | :db/ident :neighborhood/name
67 | :db/valueType :db.type/string
68 | :db/cardinality :db.cardinality/one
69 | :db/unique :db.unique/identity
70 | :db/doc "A unique neighborhood name (upsertable)"
71 | :db.install/_attribute :db.part/db}
72 |
73 | {:db/id #db/id[:db.part/db]
74 | :db/ident :neighborhood/district
75 | :db/valueType :db.type/ref
76 | :db/cardinality :db.cardinality/one
77 | :db/doc "A neighborhood's district"
78 | :db.install/_attribute :db.part/db}
79 |
80 | ;; district
81 | {:db/id #db/id[:db.part/db]
82 | :db/ident :district/name
83 | :db/valueType :db.type/string
84 | :db/cardinality :db.cardinality/one
85 | :db/unique :db.unique/identity
86 | :db/doc "A unique district name (upsertable)"
87 | :db.install/_attribute :db.part/db}
88 |
89 | {:db/id #db/id[:db.part/db]
90 | :db/ident :district/region
91 | :db/valueType :db.type/ref
92 | :db/cardinality :db.cardinality/one
93 | :db/doc "A district region enum value"
94 | :db.install/_attribute :db.part/db}
95 |
96 | ;; district/region enum values
97 | [:db/add #db/id[:db.part/user] :db/ident :region/n]
98 | [:db/add #db/id[:db.part/user] :db/ident :region/ne]
99 | [:db/add #db/id[:db.part/user] :db/ident :region/e]
100 | [:db/add #db/id[:db.part/user] :db/ident :region/se]
101 | [:db/add #db/id[:db.part/user] :db/ident :region/s]
102 | [:db/add #db/id[:db.part/user] :db/ident :region/sw]
103 | [:db/add #db/id[:db.part/user] :db/ident :region/w]
104 | [:db/add #db/id[:db.part/user] :db/ident :region/nw]
105 | ]
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/social-news.edn:
--------------------------------------------------------------------------------
1 | ;; stories
2 | [{:db/id #db/id[:db.part/db]
3 | :db/ident :story/title
4 | :db/valueType :db.type/string
5 | :db/cardinality :db.cardinality/one
6 | :db/fulltext true
7 | :db/index true
8 | :db.install/_attribute :db.part/db}
9 | {:db/id #db/id[:db.part/db]
10 | :db/ident :story/url
11 | :db/valueType :db.type/string
12 | :db/cardinality :db.cardinality/one
13 | :db/unique :db.unique/identity
14 | :db.install/_attribute :db.part/db}
15 | {:db/id #db/id[:db.part/db]
16 | :db/ident :story/slug
17 | :db/valueType :db.type/string
18 | :db/cardinality :db.cardinality/one
19 | :db.install/_attribute :db.part/db}]
20 |
21 | ;; comments
22 | [{:db/id #db/id[:db.part/db]
23 | :db/ident :comments
24 | :db/valueType :db.type/ref
25 | :db/cardinality :db.cardinality/many
26 | :db/isComponent true
27 | :db.install/_attribute :db.part/db}
28 | {:db/id #db/id[:db.part/db]
29 | :db/ident :comment/body
30 | :db/valueType :db.type/string
31 | :db/cardinality :db.cardinality/one
32 | :db.install/_attribute :db.part/db}
33 | {:db/id #db/id[:db.part/db]
34 | :db/ident :comment/author
35 | :db/valueType :db.type/ref
36 | :db/cardinality :db.cardinality/one
37 | :db.install/_attribute :db.part/db}]
38 |
39 | ;; users
40 | [{:db/id #db/id[:db.part/db]
41 | :db/ident :user/firstName
42 | :db/index true
43 | :db/valueType :db.type/string
44 | :db/cardinality :db.cardinality/one
45 | :db.install/_attribute :db.part/db}
46 | {:db/id #db/id[:db.part/db]
47 | :db/ident :user/lastName
48 | :db/index true
49 | :db/valueType :db.type/string
50 | :db/cardinality :db.cardinality/one
51 | :db.install/_attribute :db.part/db}
52 | {:db/id #db/id[:db.part/db]
53 | :db/ident :user/email
54 | :db/index true
55 | :db/unique :db.unique/identity
56 | :db/valueType :db.type/string
57 | :db/cardinality :db.cardinality/one
58 | :db.install/_attribute :db.part/db}
59 | {:db/id #db/id[:db.part/db]
60 | :db/ident :user/upVotes
61 | :db/valueType :db.type/ref
62 | :db/cardinality :db.cardinality/many
63 | :db.install/_attribute :db.part/db}
64 |
65 | ;; publish time
66 | {:db/id #db/id[:db.part/db]
67 | :db/ident :publish/at
68 | :db/valueType :db.type/instant
69 | :db/cardinality :db.cardinality/one
70 | :db/index true
71 | :db.install/_attribute :db.part/db}]
72 |
73 | ;; stories
74 | [{:db/id #db/id [:db.part/user]
75 | :story/title "Teach Yourself Programming in Ten Years"
76 | :story/url "http://norvig.com/21-days.html"}
77 | {:db/id #db/id [:db.part/user]
78 | :story/title "Clojure Rationale"
79 | :story/url "http://clojure.org/rationale"}
80 | {:db/id #db/id [:db.part/user]
81 | :story/title "Beating the Averages"
82 | :story/url "http://www.paulgraham.com/avg.html"}]
83 |
84 | ;; published stories
85 | [{:db/id #db/id [:db.part/user]
86 | :story/title "codeq"
87 | :story/url "http://blog.datomic.com/2012/10/codeq.html"}
88 | {:db/id #db/id [:db.part/tx]
89 | :publish/at #inst "2012-11-11"}]
90 |
91 | ;; users
92 | [{:db/id #db/id [:db.part/user]
93 | :user/firstName "Stu"
94 | :user/lastName "Halloway"
95 | :user/email "stuarthalloway@datomic.com"}
96 | {:db/id #db/id [:db.part/user]
97 | :user/firstName "Ed"
98 | :user/lastName "Itor"
99 | :user/email "editor@example.com"}]
100 |
101 | ;; provenance
102 | [{:db/id #db/id[:db.part/db]
103 | :db/ident :source/user
104 | :db/valueType :db.type/ref
105 | :db/cardinality :db.cardinality/one
106 | :db.install/_attribute :db.part/db}
107 | {:db/id #db/id[:db.part/db]
108 | :db/ident :source/confidence
109 | :db/valueType :db.type/long
110 | :db/cardinality :db.cardinality/one
111 | :db/doc "Confidence in the source of this information, from 0 to 100"
112 | :db.install/_attribute :db.part/db}]
113 |
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/story-with-comments.edn:
--------------------------------------------------------------------------------
1 | [{:db/id #db/id[:db.part/user -1]
2 | :db/ident :storyWithComments
3 | :story/title "Getting Started"
4 | :story/url "http://docs.datomic.com/getting-started.html"}
5 | {:db/id #db/id[:db.part/user -2]
6 | :comment/body "It woud be great to learn about component attributes."
7 | :_comments #db/id[:db.part/user -1]}
8 | {:db/id #db/id[:db.part/user -3]
9 | :comment/body "I agree."
10 | :_comments #db/id[:db.part/user -2]}]
11 |
12 |
--------------------------------------------------------------------------------
/src/resources/datomic-java-examples/stuarts.edn:
--------------------------------------------------------------------------------
1 | [{:db/id #db/id [:db.part/user]
2 | :user/firstName "Stewart"
3 | :user/lastName "Brand"}
4 | {:db/id #db/id [:db.part/user]
5 | :user/firstName "John"
6 | :user/lastName "Stewart"}
7 | {:db/id #db/id [:db.part/user]
8 | :user/firstName "Stuart"
9 | :user/lastName "Smalley"}
10 | {:db/id #db/id [:db.part/user]
11 | :user/firstName "Stuart"
12 | :user/lastName "Halloway"}]
13 |
--------------------------------------------------------------------------------
/src/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 |
9 |
10 | ${DATOMIC_LOG_DIR:-log}/%d{yyyy-MM-dd}.log
11 | 72
12 |
13 | true
14 |
15 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-10contextName %logger{36} - %msg%n
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------