Skip to content
This repository has been archived by the owner on Oct 25, 2018. It is now read-only.

Commit

Permalink
CriteriaBuilder approach
Browse files Browse the repository at this point in the history
  • Loading branch information
evlach committed Oct 2, 2015
1 parent fb65b8a commit 98dc563
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 401 deletions.
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"use strict";
module.exports = {
MetaModel: require("./lib/MetaModel"),
Criterion: require("./lib/Criterion"),
CriterionType: require("./lib/CriterionType"),
JPAConfiguration: require("./lib/JPAConfiguration"),
QueryBuilder: require("./lib/QueryBuilder"),
CriteriaBuilder: require("./lib/CriteriaBuilder"),
PersistenceUtils: require("./lib/PersistenceUtils"),
Persistence: require("./lib/Persistence"),
EntityManager: require("./lib/EntityManager"),
Expand Down
73 changes: 0 additions & 73 deletions lib/Criterion.js

This file was deleted.

6 changes: 0 additions & 6 deletions lib/CriterionType.js

This file was deleted.

56 changes: 7 additions & 49 deletions lib/DefaultRowInterceptor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
let typly = require("typly").instance();
let err = require("./errors");
let PersistenceUtils = require("./PersistenceUtils");
let TimeUuid = require('cassandra-driver').types.TimeUuid;
Expand All @@ -10,15 +11,15 @@ module.exports = class DefaultRowInterceptor {
this.fieldTypes.set("timeuuid", DefaultRowInterceptor.toUuid);
this.fieldTypes.set("text", DefaultRowInterceptor.toText);
this.fieldTypes.set("varchar", DefaultRowInterceptor.toText);
//this.fieldTypes.set("map<text,bigint>", DefaultRowInterceptor.toMapText);
//this.fieldTypes.set("map<text,text>", DefaultRowInterceptor.toMapText);
this.fieldTypes.set("list<text>", DefaultRowInterceptor.toListText);
this.fieldTypes.set("list<timeuuid>", DefaultRowInterceptor.toListTimeUuid);
this.validate();
}

toRow(type, propertyValue, entityClass)
{
typly.assertString(type);
typly.assertObject(entityClass);
type = type.replace(/\s+/g, '').toLowerCase();
let row = null;
if (propertyValue === null)
Expand All @@ -40,49 +41,7 @@ module.exports = class DefaultRowInterceptor {
}
return row;
}
/*
static toMapText(propertyValue, entityClass)
{
let row = new Map();
if (propertyValue instanceof Map === false)
{
throw new TypeError("Expecting Map type");
}
propertyValue.forEach((value, key, map) =>
{
if (typeof value === "object")
{
row.set(key, JSON.stringify(value));
}
else
{
row.set(key, value);
}
});
return row;
}

static toMapTextNative(propertyValue, entityClass)
{
let row = new Map();
if (propertyValue instanceof Map === false)
{
throw new TypeError("Expecting Map type");
}
propertyValue.forEach((value, key, map) =>
{
if (typeof value === "object")
{
row.set(key, JSON.stringify(value));
}
else
{
row.set(key, value);
}
});
return row;
}
*/
static toListTimeUuid(propertyValue, entityClass)
{
if (Array.isArray(propertyValue))
Expand All @@ -96,11 +55,11 @@ module.exports = class DefaultRowInterceptor {
}
}

static toListText(propertyValue, entityClass)
static toListText(propertyValue)
{
let properties = [];
if (Array.isArray(propertyValue))
{
let properties = [];
propertyValue.forEach((pro) =>
{
if (typeof pro === "object")
Expand All @@ -112,8 +71,8 @@ module.exports = class DefaultRowInterceptor {
properties.push(pro);
}
});
return properties;
}
return properties;
}

static toUuid(propertyValue)
Expand Down Expand Up @@ -143,5 +102,4 @@ module.exports = class DefaultRowInterceptor {
}
});
}
};

};
Loading

0 comments on commit 98dc563

Please sign in to comment.