Added entities regarding virtual corpus.

Change-Id: Ib5536e551308d3f7f6fe9e249feb60f59fa730e6
diff --git a/full/src/main/java/de/ids_mannheim/korap/entity/UserGroup.java b/full/src/main/java/de/ids_mannheim/korap/entity/UserGroup.java
new file mode 100644
index 0000000..91cf76f
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/entity/UserGroup.java
@@ -0,0 +1,32 @@
+package de.ids_mannheim.korap.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "user_group")
+public class UserGroup {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int id;
+    @Column(name = "name")
+    private String name;
+    @Column(name = "owner_id")
+    private int ownerId;
+    
+    @Override
+    public String toString () {
+        return "id=" + id + ", name= " + name + ", ownerId= "
+                + ownerId;
+    }
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/entity/UserGroupMember.java b/full/src/main/java/de/ids_mannheim/korap/entity/UserGroupMember.java
new file mode 100644
index 0000000..9f1389f
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/entity/UserGroupMember.java
@@ -0,0 +1,33 @@
+package de.ids_mannheim.korap.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "user_group_member")
+public class UserGroupMember {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int id;
+    @Column(name = "group_id")
+    private int groupId;
+    @Column(name = "user_id")
+    private int userId;
+    private String status;
+    
+    @Override
+    public String toString () {
+        return "id=" + id + ", groupId= " + groupId + ", userId= "
+                + userId;
+    }
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpus.java b/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpus.java
new file mode 100644
index 0000000..dd050fc
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpus.java
@@ -0,0 +1,42 @@
+package de.ids_mannheim.korap.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "virtual_corpus")
+public class VirtualCorpus {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int id;
+    private String name;
+    private String type;
+    private String status;
+    private String description;
+    @Column(name = "required_access")
+    private String requiredAccess;
+    @Column(name = "collection_query")
+    private String collectionQuery;
+    private String definition;
+    @Column(name = "owner_id")
+    private String ownerId;
+
+
+    @Override
+    public String toString () {
+        return "id=" + id + ", name= " + name + ", type= " + type + ", status= "
+                + status + ", description=" + description + ", requiredAccess="
+                + requiredAccess + ", collectionQuery= " + collectionQuery
+                + ", definition= " + definition + ", ownerId= " + ownerId;
+    }
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpusAccessGroup.java b/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpusAccessGroup.java
new file mode 100644
index 0000000..9b4ba9a
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/entity/VirtualCorpusAccessGroup.java
@@ -0,0 +1,33 @@
+package de.ids_mannheim.korap.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "vc_access_group")
+public class VirtualCorpusAccessGroup {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int id;
+    @Column(name = "vc_id")
+    private int virtualCorpusId;
+    @Column(name = "group_id")
+    private int groupId;
+
+
+    @Override
+    public String toString () {
+        return "id=" + id + ", virtualCorpusId= " + virtualCorpusId + ", groupId= "
+                + groupId;
+    }
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
index 8dde18a..b6e23e3 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
@@ -112,6 +112,7 @@
      * @param type
      * @return valid resources in json format
      */
+    @Deprecated
     @GET
     @Path("{type}")
     public Response getResources (@Context Locale locale,
@@ -502,7 +503,6 @@
     }
 
 
-    @SuppressWarnings("unchecked")
     @GET
     @Path("search")
     public Response search (
@@ -664,65 +664,6 @@
         }
     }
 
-    
-
-    // EM: what is child?
-    @GET
-    @Path("{type}/{id}/{child}/statistics")
-    @Deprecated
-    public Response getStatisticsbyIdChild (@Context SecurityContext context,
-            @Context Locale locale, @PathParam("type") String type,
-            @PathParam("id") String id, @PathParam("child") String child) {
-        return getStatisticsbyId(context, locale, type,
-                StringUtils.joinResources(id, child));
-    }
-
-
-    @GET
-    @Path("{type}/{id}/stats")
-    @Deprecated
-    public Response getStatisticsbyId (@Context SecurityContext context,
-            @Context Locale locale, @PathParam("type") String type,
-            @PathParam("id") String id) {
-        TokenContext ctx = (TokenContext) context.getUserPrincipal();
-        type = StringUtils.normalize(type);
-        id = StringUtils.decodeHTML(id);
-
-        try {
-            Class sl = ResourceFactory.getResourceClass(type);
-            if (!VirtualCollection.class.equals(sl) & !Corpus.class.equals(sl))
-                throw KustvaktResponseHandler.throwit(
-                        StatusCodes.ILLEGAL_ARGUMENT,
-                        "Requested Resource type not supported", type);
-
-            User user = controller.getUser(ctx.getUsername());
-            KustvaktResource resource;
-            if (StringUtils.isInteger(id))
-                resource = this.resourceHandler.findbyIntId(Integer.valueOf(id),
-                        user);
-            else
-                resource = this.resourceHandler.findbyStrId(id, user,
-                        ResourceFactory.getResourceClass(type));
-
-            // todo ?!
-            KoralCollectionQueryBuilder query = new KoralCollectionQueryBuilder();
-            if (resource instanceof VirtualCollection) {
-                query.setBaseQuery(resource.getData());
-            }
-            else if (resource instanceof Corpus) {
-                query.with(Attributes.CORPUS_SIGLE + "=" + resource.getName());
-            }
-            String res = query.toJSON();
-            String qstr = processor.processQuery(res, user);
-            return Response.ok(searchKrill.getStatistics(qstr)).build();
-        }
-        catch (KustvaktException e) {
-            jlog.error("Exception encountered: {}", e.string());
-            throw KustvaktResponseHandler.throwit(e);
-        }
-    }
-
-
     /**
      * @param context
      * @param locale
@@ -771,6 +712,7 @@
 
     // EM: this handles layer id containing a slash. 
     // Probably better to restrict the id not to contain any slash instead.
+    @Deprecated
     @POST
     @Path("{type}/{id}/{child}")
     public Response updateResource (@Context SecurityContext context,
@@ -783,6 +725,7 @@
     }
 
 
+    @Deprecated
     @POST
     @Path("{type}/{id}")
     public Response updateResource (@Context SecurityContext context,
@@ -832,7 +775,7 @@
         return Response.ok().build();
     }
 
-
+    @Deprecated
     // todo: change or deprecate
     @POST
     @Path("nv/{type}")
@@ -927,6 +870,7 @@
      * @return
      * @throws KustvaktException
      */
+    @Deprecated
     @POST
     @Path("{type}")
     public Response storeResource (@Context SecurityContext context,
@@ -1022,7 +966,7 @@
                 StringUtils.joinResources(id, child));
     }
 
-
+    @Deprecated
     @DELETE
     @Path("{type}/{id}")
     public Response deleteResource (@Context SecurityContext context,
@@ -1046,32 +990,6 @@
         return Response.ok().build();
     }
 
-    // EM: legacy support
-    // should be deprecated after a while
-    /*
-    @GET
-    @Path("/corpus/{corpusId}/{docId}/{matchId}/matchInfo")
-    public Response getMatchInfo (@Context SecurityContext ctx,
-            @Context Locale locale, @PathParam("corpusId") String corpusId,
-            @PathParam("docId") String docId,
-            @PathParam("matchId") String matchId,
-            @QueryParam("foundry") Set<String> foundries,
-            @QueryParam("layer") Set<String> layers,
-            @QueryParam("spans") Boolean spans) throws KustvaktException {
-    	
-    	String[] ids = docId.split("\\.");
-    	if (ids.length !=2){
-    		throw KustvaktResponseHandler.throwit(
-    				new KustvaktException(StatusCodes.PARAMETER_VALIDATION_ERROR, 
-    				docId + " format is wrong. Expected a fullstop between doc id "
-					+ "and text id"));
-    	}		
-    	return getMatchInfo(ctx, locale, corpusId, ids[0], ids[1], matchId, foundries, layers, spans);
-    	
-    }
-    */
-    
-    // fixme: only allowed for corpus?!
     @GET
     @Path("/corpus/{corpusId}/{docId}/{textId}/{matchId}/matchInfo")
     public Response getMatchInfo (
diff --git a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
index e86279d..546e1b4 100644
--- a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
+++ b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
@@ -32,7 +32,6 @@
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
 import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
 import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
-import de.ids_mannheim.korap.utils.KustvaktLogger;
 import de.ids_mannheim.korap.web.ClientsHandler;
 import de.ids_mannheim.korap.web.SearchKrill;
 import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
@@ -68,12 +67,14 @@
 
 
     public LightService () {
+        // Karang URI
         UriBuilder builder = UriBuilder.fromUri("http://10.0.10.13").port(9997);
         this.graphDBhandler = new ClientsHandler(builder.build());
     }
 
 
-    /**
+    /** Requires Karang (Neo4j search engine)
+     *  
      * @param query
      * @return response
      */
@@ -206,7 +207,7 @@
         }
         else
             result = searchKrill.search(query);
-        KustvaktLogger.QUERY_LOGGER.trace("The result set: {}", result);
+        jlog.debug("The result set: {}", result);
         return Response.ok(result).build();
     }
 
@@ -287,7 +288,7 @@
             throw KustvaktResponseHandler.throwit(500, e.getMessage(), null);
         }
 
-        KustvaktLogger.QUERY_LOGGER.trace("The result set: {}", result);
+        jlog.debug("The result set: {}", result);
         return Response.ok(result).build();
     }