Commit 87e13f01 authored by Peter Harrison's avatar Peter Harrison

* Adding Indexes for Jcr Repository

* Different Handling of Numbers - Integer to Double.
parent ff08d726
......@@ -26,6 +26,8 @@ import java.util.Map;
import javax.annotation.Resource;
import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -35,6 +37,8 @@ import nz.net.orcon.kanban.tools.OcmMapperFactory;
@Service
public class RuleCache extends CacheImpl<Rule> {
private static final Logger LOG = LoggerFactory.getLogger(RuleCache.class);
@Resource(name="ocmFactory")
OcmMapperFactory ocmFactory;
......@@ -44,6 +48,9 @@ public class RuleCache extends CacheImpl<Rule> {
@Override
protected Rule getFromStore(String... itemIds) throws Exception {
LOG.info("Get Rule Store: "+ getStringFromArray(itemIds));
ObjectContentManager ocm = ocmFactory.getOcm();
Rule rule;
try{
......@@ -56,6 +63,9 @@ public class RuleCache extends CacheImpl<Rule> {
@Override
protected Map<String, String> getListFromStore(String... prefixes) throws Exception {
LOG.info("Get Rule List Store: "+ getStringFromArray(prefixes));
ObjectContentManager ocm = ocmFactory.getOcm();
Map<String,String> result = null;
try{
......@@ -65,5 +75,16 @@ public class RuleCache extends CacheImpl<Rule> {
}
return result;
}
private String getStringFromArray( String[] stringArray){
StringBuilder builder = new StringBuilder();
for( int a=0; a<stringArray.length; a++){
builder.append("[");
builder.append(stringArray[a]);
builder.append("] ");
}
return builder.toString();
}
}
......@@ -96,7 +96,7 @@ public class TemplateCache extends CacheImpl<Template>{
case STRING:
return value.toString();
case NUMBER:
return Integer.parseInt(value.toString());
return Double.valueOf(value.toString());
case BOOLEAN:
return Boolean.parseBoolean(value.toString());
case DATE:
......
......@@ -45,7 +45,6 @@ import org.apache.jackrabbit.ocm.mapper.Mapper;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
import com.mongodb.DB;
import com.mongodb.MongoClient;
......@@ -53,7 +52,7 @@ import com.mongodb.MongoClient;
public class OcmMapperFactory {
private static final Logger logger = LoggerFactory.getLogger(OcmMapperFactory.class);
private Repository repository;
private String domainPackage;
......@@ -86,8 +85,12 @@ public class OcmMapperFactory {
DB db = new MongoClient(host, 27017).getDB("gravity");
DocumentNodeStore ns = new DocumentMK.Builder().
setMongoDB(db).getNodeStore();
this.repository = new Jcr(new Oak(ns)).createRepository();
setMongoDB(db).getNodeStore();
this.repository = new Jcr(new Oak(ns))
.with(new RepositoryIndexInitializer())
.withAsyncIndexing()
.createRepository();
}
if(this.mapper==null){
......@@ -134,7 +137,7 @@ public class OcmMapperFactory {
*
* @param session
*/
private void setupListener(Session session){
private void setupListener(){
//session.getWorkspace().getObservationManager().addEventListener(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
......
package nz.net.orcon.kanban.tools;
import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import com.google.common.collect.ImmutableList;
public class RepositoryIndexInitializer implements RepositoryInitializer{
@Override
public void initialize(NodeBuilder builder) {
NodeBuilder root = builder.getBaseState().builder();
NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
ImmutableList fields =
ImmutableList.builder().add( "id","name" ).build();
NodeBuilder indexNodebuilder =
IndexUtils.createIndexDefinition(index, "gravityIndexes", true, false, fields, null);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment