Skip to content
Browse files

Initial revision

  • Loading branch information...
1 parent 8a9f522 commit 9595370857eb56d16d8d0b110e9825b95798da35 rbelkin committed Nov 2, 2011
View
33 client/java/src/main/java/org/projectsin/client/DefaultSinClientFactory.java
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.projectsin.client;
+
+import org.projectsin.client.api.SinClient;
+import org.projectsin.client.api.SinClientFactory;
+import org.projectsin.client.api.SinConfig;
+
+/**
+ * @author ruslan
+ *
+ */
+public class DefaultSinClientFactory implements SinClientFactory
+{
+ public static SinClientFactory INSTANCE = new DefaultSinClientFactory();
+
+ public static SinClientFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinClientFactory#createClient(org.projectsin.client.api.SinConfig)
+ */
+ @Override
+ public SinClient createClient(SinConfig config)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
View
24 client/java/src/main/java/org/projectsin/client/SinClient.java
@@ -1,24 +0,0 @@
-package org.projectsin.client;
-
-public class SinClient {
-
- private SinClient(String host,int port){
-
- }
-
- public static SinClient getInstance(String host,int port){
- return new SinClient(host,port);
- }
-
- public SinStore openStore(String name){
- return null;
- }
-
- public SinStore newStore(String name){
- return null;
- }
-
- public void deleteStore(String name){
-
- }
-}
View
38 client/java/src/main/java/org/projectsin/client/SinStore.java
@@ -1,38 +0,0 @@
-package org.projectsin.client;
-
-import org.json.JSONObject;
-import org.projectsin.client.impl.SinService;
-import org.projectsin.client.search.SinSenseiRequest;
-import org.projectsin.client.search.SinSenseiResult;
-
-public class SinStore {
-
- private final String _sinHost;
- private final int _sinPort;
- private final String _senseiHost;
- private final int _senseiPort;
-
- public SinStore(String sinHost,int sinPort,String senseiHost,int senseiPort){
- _sinHost = sinHost;
- _sinPort = sinPort;
- _senseiHost = senseiHost;
- _senseiPort = senseiPort;
- }
-
- public void addDocs(JSONObject[] docs){
-
- }
-
- public void updateDoc(JSONObject doc){
-
- }
-
- public void deleteDocs(long[] deletedIds){
-
- }
-
- public SinSenseiResult search(SinSenseiRequest req){
- JSONObject resp = SinService.search(_senseiHost, _senseiPort, req);
- return null;
- }
-}
View
13 client/java/src/main/java/org/projectsin/client/api/SinClient.java
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.projectsin.client.api;
+
+/**
+ * @author ruslan
+ *
+ */
+public interface SinClient
+{
+ public SinStore openStore(SinStoreConfig storeConfig);
+}
View
14 client/java/src/main/java/org/projectsin/client/api/SinClientFactory.java
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package org.projectsin.client.api;
+
+
+/**
+ * @author ruslan
+ *
+ */
+public interface SinClientFactory
+{
+ public SinClient createClient(SinConfig config);
+}
View
37 client/java/src/main/java/org/projectsin/client/api/SinConfig.java
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.projectsin.client.api;
+
+/**
+ * @author ruslan
+ *
+ */
+public class SinConfig
+{
+ private String _host;
+ private int _port;
+
+ public String getHost()
+ {
+ return _host;
+ }
+
+ public SinConfig setHost(String host)
+ {
+ _host = host;
+ return this;
+ }
+
+ public int getPort()
+ {
+ return _port;
+ }
+
+ public SinConfig setPort(int port)
+ {
+ _port = port;
+ return this;
+ }
+
+} /*SinConfig*/
View
8 client/java/src/main/java/org/projectsin/client/api/SinIndexable.java
@@ -0,0 +1,8 @@
+package org.projectsin.client.api;
+
+public interface SinIndexable
+{
+ public long getId();
+
+ public String getAsString();
+}
View
81 client/java/src/main/java/org/projectsin/client/api/SinSearchQuery.java
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package org.projectsin.client.api;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author ruslan
+ *
+ */
+public class SinSearchQuery
+{
+ private String _query;
+
+ private int _start = 0;
+ private int _length = 10;
+
+ private Map<String,String> _facetMap = new HashMap<String,String>();
+ private Set<String> _countSet = new HashSet<String>();
+
+ public String getQuery()
+ {
+ return _query;
+ }
+
+ public SinSearchQuery setQuery(String query)
+ {
+ _query = query;
+ return this;
+ }
+
+ public int getStart()
+ {
+ return _start;
+ }
+
+ public SinSearchQuery setStart(int start)
+ {
+ _start = start;
+ return this;
+ }
+
+ public int getLength()
+ {
+ return _length;
+ }
+
+ public SinSearchQuery setLength(int length)
+ {
+ _length = length;
+ return this;
+ }
+
+ public SinSearchQuery addFacet(String facet, String value)
+ {
+ _facetMap.put(facet, value);
+ return this;
+ }
+
+ public SinSearchQuery addFacetCount(String facet)
+ {
+ _countSet.add(facet);
+ return this;
+ }
+
+ public Map<String, String> getFacetMap()
+ {
+ return Collections.unmodifiableMap(_facetMap);
+ }
+
+ public Set<String> getCountSet()
+ {
+ return Collections.unmodifiableSet(_countSet);
+ }
+
+}
View
20 client/java/src/main/java/org/projectsin/client/api/SinSearchResult.java
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.projectsin.client.api;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ruslan
+ *
+ */
+public interface SinSearchResult
+{
+ public int getNumHits();
+
+ public List<Long> getIds();
+
+ public Map<String,Map<String,Integer>> getFacetCounts();
+}
View
17 client/java/src/main/java/org/projectsin/client/api/SinStore.java
@@ -0,0 +1,17 @@
+package org.projectsin.client.api;
+
+import java.util.Collection;
+
+public interface SinStore
+{
+ public void submit(SinIndexable doc);
+
+ public void submit(Collection<SinIndexable> docs);
+
+ public void update(SinIndexable doc);
+
+ public void remove(long id);
+ public void remove(Collection<Long> ids);
+
+ public SinSearchResult search(SinSearchQuery query);
+}
View
57 client/java/src/main/java/org/projectsin/client/api/SinStoreConfig.java
@@ -0,0 +1,57 @@
+package org.projectsin.client.api;
+
+import java.net.URL;
+
+public class SinStoreConfig
+{
+ private String _name;
+ private String _apiKey;
+ private URL _senseiUrl;
+
+ private String _idField = "id";
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public SinStoreConfig setName(String name)
+ {
+ _name = name;
+ return this;
+ }
+
+ public String getApiKey()
+ {
+ return _apiKey;
+ }
+
+ public SinStoreConfig setApiKey(String apiKey)
+ {
+ _apiKey = apiKey;
+ return this;
+ }
+
+ public URL getSenseiUrl()
+ {
+ return _senseiUrl;
+ }
+
+ public SinStoreConfig setSenseiUrl(URL senseiUrl)
+ {
+ _senseiUrl = senseiUrl;
+ return this;
+ }
+
+ public String getIdField()
+ {
+ return _idField;
+ }
+
+ public SinStoreConfig setIdField(String idField)
+ {
+ _idField = idField;
+ return this;
+ }
+
+}
View
27 client/java/src/main/java/org/projectsin/client/impl/SinClientImpl.java
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.projectsin.client.impl;
+
+import org.projectsin.client.api.SinClient;
+import org.projectsin.client.api.SinStore;
+import org.projectsin.client.api.SinStoreConfig;
+
+/**
+ * @author ruslan
+ *
+ */
+public class SinClientImpl implements SinClient
+{
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinClient#openStore(org.projectsin.client.api.SinStoreConfig)
+ */
+ @Override
+ public SinStore openStore(SinStoreConfig storeConfig)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
View
40 client/java/src/main/java/org/projectsin/client/impl/SinService.java
@@ -1,40 +0,0 @@
-package org.projectsin.client.impl;
-
-import org.json.JSONObject;
-import org.projectsin.client.search.SinSenseiRequest;
-
-/**
- * Low-level rest API binding
- * @author john
- * @since 1.0.0
- */
-public class SinService {
-
- public static JSONObject newStore(String host,int port,String store){
- return null;
- }
-
- public static JSONObject openStore(String host,int port,String store){
- return null;
- }
-
- public static JSONObject deleteStore(String host,int port,String store){
- return null;
- }
-
- public static JSONObject addDocs(String host,int port,String store,JSONObject[] docs){
- return null;
- }
-
- public static JSONObject updateDoc(String host,int port,String store,JSONObject doc){
- return null;
- }
-
- public static JSONObject deleteDocs(String host,int port,String store,long[] deletedIds){
- return null;
- }
-
- public static JSONObject search(String senseiHost,int senseiPort,SinSenseiRequest req){
- return null;
- }
-}
View
80 client/java/src/main/java/org/projectsin/client/impl/SinStoreImpl.java
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package org.projectsin.client.impl;
+
+import java.util.Collection;
+
+import org.projectsin.client.api.SinIndexable;
+import org.projectsin.client.api.SinSearchQuery;
+import org.projectsin.client.api.SinSearchResult;
+import org.projectsin.client.api.SinStore;
+
+/**
+ * @author ruslan
+ *
+ */
+public class SinStoreImpl implements SinStore
+{
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#submit(org.projectsin.client.api.SinIndexable)
+ */
+ @Override
+ public void submit(SinIndexable doc)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#submit(java.util.Collection)
+ */
+ @Override
+ public void submit(Collection<SinIndexable> docs)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#update(org.projectsin.client.api.SinIndexable)
+ */
+ @Override
+ public void update(SinIndexable doc)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#remove(long)
+ */
+ @Override
+ public void remove(long id)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#remove(java.util.Collection)
+ */
+ @Override
+ public void remove(Collection<Long> ids)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.projectsin.client.api.SinStore#search(org.projectsin.client.api.SinSearchQuery)
+ */
+ @Override
+ public SinSearchResult search(SinSearchQuery query)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
View
5 client/java/src/main/java/org/projectsin/client/search/SinSenseiRequest.java
@@ -1,5 +0,0 @@
-package org.projectsin.client.search;
-
-public class SinSenseiRequest {
-
-}
View
5 client/java/src/main/java/org/projectsin/client/search/SinSenseiResult.java
@@ -1,5 +0,0 @@
-package org.projectsin.client.search;
-
-public class SinSenseiResult {
-
-}

0 comments on commit 9595370

Please sign in to comment.
Something went wrong with that request. Please try again.