Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated copyrights

added readme and examples
  • Loading branch information...
commit af95dbe5422e70d4de7c95c9cd7ddc04dfa7eaa4 1 parent 56cc3d3
@jacum jacum authored
Showing with 869 additions and 288 deletions.
  1. +25 −0 LICENSE
  2. +101 −0 README.md
  3. +31 −12 src/main/java/net/karmafiles/ff/core/tool/Assert.java
  4. +31 −18 src/main/java/net/karmafiles/ff/core/tool/IdGenerator.java
  5. +32 −13 src/main/java/net/karmafiles/ff/core/tool/dbutil/ConnectionImpl.java
  6. +31 −0 src/main/java/net/karmafiles/ff/core/tool/dbutil/MongoConnection.java
  7. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/BaseProxy.java
  8. +40 −18 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/BeanDescription.java
  9. +34 −13 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/Converter.java
  10. +31 −3 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/MapClasses.java
  11. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/bean/BeanEnhancer.java
  12. +33 −18 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/bean/BeanMethodInterceptor.java
  13. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectArrayProxy.java
  14. +36 −19 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectIterableProxy.java
  15. +32 −13 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectMapProxy.java
  16. +36 −24 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectProxy.java
  17. +33 −14 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/BaseDaoHelper.java
  18. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoException.java
  19. +32 −14 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelper.java
  20. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelperFilter.java
  21. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelperTemplate.java
  22. +31 −0 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/EntityFilter.java
  23. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/FieldValueChecker.java
  24. +31 −12 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/FieldValueProvider.java
  25. +32 −13 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/SimpleCriteria.java
View
25 LICENSE
@@ -0,0 +1,25 @@
+Copyright 2011 Dadastream. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this list of
+ conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ of conditions and the following disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of Dadastream.
View
101 README.md
@@ -0,0 +1,101 @@
+MongoMapper
+===========
+
+This library provides clean and powerful mapping between Java POJOs and MongoDB DBObject.
+
+Features
+--------
+
+* Just 2 methods of API for mapping to and from
+* No annotations, no factories, just POJOs all the way
+* Full support of Java collections: Maps, Lists, Sets
+* Full support of polymorphism: generified collections containing different subclasses, complex beans containing polymorphic attributes
+* Convenient template for DAO classes
+
+Using raw converter API
+-----------------------
+
+ import com.mongodb.*;
+ import net.karmafiles.ff.core.tool.dbutil.converter.Converter;
+
+ ...
+
+ MyTopLevelEntity entity = ...
+ // here the graph of objects is created, starting from top-level entity
+
+ Mongo m = new Mongo("localhost", 27017);
+ DB db = m.getDB("mydb1");
+ DBCollection coll = db.getCollection("testCollection");
+
+ // convert entitiy to MongoDB DBObject
+
+ DBObject dbObject = Converter.toDBObject(entity);
+ coll.save(dbObject);
+
+ // restore entity from MongoDB DBObject
+ DBObject newDbObject = coll.findOne();
+ MyTopLevelEntity newEntity = Converter.toObject(MyTopLevelEntity.class, newDbObject);
+
+More examples in test directory under ...converter.test package.
+
+Using DAO template
+------------------
+
+ import net.karmafiles.ff.core.tool.dbutil.ConnectionImpl;
+ import net.karmafiles.ff.core.tool.dbutil.daohelper.DaoHelper;
+
+ import java.util.Date;
+
+ public class JobDao<T> extends DaoHelper<T> {
+
+ // provide some method of getting a connection to MongoDB
+ // e.g. Spring @Autowire
+
+ private ConnectionImpl connection;
+
+ public ConnectionImpl getConnection() {
+ return connection;
+ }
+
+ public void setConnection(ConnectionImpl connection) {
+ this.connection = connection;
+ }
+
+
+ // custom find method
+ public List<Job> findNewJobs() {
+
+ BasicDBObject query = new BasicDBObject();
+ query.put("state", JobState.NOT_STARTED.toString());
+ DBCursor c = getDbCollection().find(query);
+
+ List<Job> jobs = new ArrayList<Job>();
+ while (c.hasNext()) {
+ jobs.add(Converter.toObject(Job.class, c.next()));
+ }
+ return jobs;
+
+ }
+
+ // custom update method
+ public Job update(Job entity) {
+ Job oldJob = get(entity.get_id());
+ if (oldJob.getModified().after(entity.getModified())) {
+ throw new IllegalStateException("Job " + entity.get_id() + " copy in the database is newer than in request, can't update");
+ }
+ return super.update(entity);
+ }
+
+
+ }
+
+More examples in TestEntityDaoTest.
+
+Caveats
+-------
+
+In order to prevent endless looping in some polymorhpic cases, Converter.toObject() creates a clean bean copy:
+
+ PropertyUtils.copyProperties(copyObject, newObject);
+
+This is rather a kludge than a proper solution.
View
43 src/main/java/net/karmafiles/ff/core/tool/Assert.java
@@ -1,19 +1,38 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool;
import java.util.Collection;
-/**
- * Created by Ilya Brodotsky
- * Date: 14.10.2010
- * Time: 19:19:17
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public final class Assert {
private Assert() {
View
49 src/main/java/net/karmafiles/ff/core/tool/IdGenerator.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool;
import org.apache.commons.codec.binary.Base64;
@@ -5,8 +36,6 @@
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.concurrent.atomic.AtomicLong;
@@ -16,17 +45,10 @@
private static SecureRandom mySecureRand;
- private static String s_id;
-
static {
atomicLong = new AtomicLong();
mySecureRand = new SecureRandom();
- try {
- s_id = InetAddress.getLocalHost().toString();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
}
@@ -35,15 +57,6 @@ private IdGenerator() {
}
private String getRandomGUID() {
- MessageDigest md5 = null;
- StringBuffer sbValueBeforeMD5 = new StringBuffer();
-
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- System.out.println("Error: " + e);
- }
-
try {
long time = System.currentTimeMillis();
long rand = mySecureRand.nextLong();
View
45 src/main/java/net/karmafiles/ff/core/tool/dbutil/ConnectionImpl.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil;
import com.mongodb.DB;
@@ -11,21 +42,8 @@
import java.util.ArrayList;
import java.util.List;
-/**
- * Created by Ilya Brodotsky
- * Date: 16.10.2010
- * Time: 3:12:06
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class ConnectionImpl implements MongoConnection {
- private Mongo mongo;
private DB db;
private String connectionHost;
@@ -56,6 +74,7 @@ public void setConnectionDescriptor(String connectionDescriptor) {
@PostConstruct
public void connect() {
try {
+ Mongo mongo;
if (connectionDescriptor != null) {
String[] hosts = connectionDescriptor.split(",");
List<ServerAddress> addr = new ArrayList<ServerAddress>();
View
31 src/main/java/net/karmafiles/ff/core/tool/dbutil/MongoConnection.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil;
import com.mongodb.DBCollection;
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/BaseProxy.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter;
import net.karmafiles.ff.core.tool.dbutil.converter.dbobject.DBObjectArrayProxy;
@@ -15,18 +46,6 @@
import java.util.UUID;
import java.util.regex.Pattern;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 15:42:59
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class BaseProxy {
private static Class<?> matchType = (new byte[]{}).getClass().getComponentType();
View
58 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/BeanDescription.java
@@ -1,3 +1,35 @@
+
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter;
import org.apache.commons.beanutils.PropertyUtils;
@@ -8,29 +40,19 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 14:24:51
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
+
public class BeanDescription {
- private Map<String, PropertyDescriptor> description = new HashMap();
- private Map<String, PropertyDescriptor> writeMethodToDescriptor = new HashMap();
- private Map<String, PropertyDescriptor> readMethodToDescriptor = new HashMap();
- private Map<String, String> writeMethodToPropertyName = new HashMap();
- private Map<String, String> readMethodToPropertyName = new HashMap();
+ private Map<String, PropertyDescriptor> description = new HashMap<String, PropertyDescriptor>();
+ private Map<String, PropertyDescriptor> writeMethodToDescriptor = new HashMap<String, PropertyDescriptor>();
+ private Map<String, PropertyDescriptor> readMethodToDescriptor = new HashMap<String, PropertyDescriptor>();
+ private Map<String, String> writeMethodToPropertyName = new HashMap<String, String>();
+ private Map<String, String> readMethodToPropertyName = new HashMap<String, String>();
private BeanDescription() {
}
- private static Map<String, BeanDescription> knownBeanDescriptions = new ConcurrentHashMap();
+ private static Map<String, BeanDescription> knownBeanDescriptions = new ConcurrentHashMap<String, BeanDescription>();
public static BeanDescription describe(Class beanClass) {
BeanDescription beanDescription = knownBeanDescriptions.get(beanClass.getName());
@@ -61,7 +83,7 @@ public static BeanDescription describe(Class beanClass) {
beanDescription.writeMethodToPropertyName.put(
descriptor.getWriteMethod().getName(), descriptor.getName());
}
-
+ knownBeanDescriptions.put(beanClass.getName(), beanDescription);
return beanDescription;
} catch(Throwable t) {
throw new RuntimeException(t);
View
47 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/Converter.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter;
import com.mongodb.DBObject;
@@ -6,18 +37,6 @@
import java.util.Map;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 14:20:11
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class Converter {
@@ -26,7 +45,7 @@ public static DBObject toDBObject(Object obj) {
if (val instanceof DBObject) {
return (DBObject) val;
} else {
- throw new RuntimeException("Converted object is not instance of DBObject.");
+ throw new RuntimeException("Converted object is not instance of DBObject");
}
}
@@ -35,6 +54,8 @@ public static DBObject toDBObject(Object obj) {
T newObject = (T) BeanEnhancer.create(clazz, source);
try {
T copyObject = clazz.newInstance();
+ // todo maybe other way of solving this?
+ // if no complex entities with polymorphism are used, it should be safe to just "return newObject" and skip bean copying
PropertyUtils.copyProperties(copyObject, newObject);
return copyObject;
} catch (Exception e) {
View
34 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/MapClasses.java
@@ -1,8 +1,36 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter;
-/**
-* @author timur
-*/
public class MapClasses {
public Class classA;
public Class classB;
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/bean/BeanEnhancer.java
@@ -1,21 +1,40 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.bean;
import com.mongodb.DBObject;
import net.karmafiles.ff.core.tool.dbutil.converter.BeanDescription;
import net.sf.cglib.proxy.Enhancer;
-/**
- * Created by Ilya Brodotsky
- * Date: 09.10.2010
- * Time: 17:34:59
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class BeanEnhancer {
public static Object create(Class clazz, final DBObject source) {
if(clazz == null || source == null) {
View
51 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/bean/BeanMethodInterceptor.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.bean;
import com.mongodb.BasicDBList;
@@ -11,31 +42,18 @@
import java.lang.reflect.*;
import java.util.*;
-/**
- * Created by Ilya Brodotsky
- * Date: 09.10.2010
- * Time: 17:38:22
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public abstract class BeanMethodInterceptor implements MethodInterceptor {
protected abstract DBObject getSource();
protected abstract BeanDescription getBeanDescription();
- private Set<String> fieldsSet = new HashSet();
+ private Set<String> fieldsSet = new HashSet<String>();
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
String property;
property = getBeanDescription().getPropertyNameByReadMethod(method.getName());
if (property != null) { // we've intercepted getter met hod
if(fieldsSet.contains(property)) { // value was retrieved and already set, passing to original getter
- Object valToReturn = proxy.invokeSuper(obj, args); // invoking the original getter
- return valToReturn;
+ return proxy.invokeSuper(obj, args);
}
if (getSource().containsField(property)) { // we have such field in source
PropertyDescriptor propertyDescriptor = getBeanDescription().getPropertyDescriptor(property);
@@ -58,7 +76,6 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
} else if (c.isEnum() && o instanceof String) {
set.add(Enum.valueOf(c, (String) o));
} else {
- // TODO: bugs are here! rework
set.add(createInstance(c, o));
}
}
@@ -93,7 +110,6 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
} else if (mapClasses.classB.isEnum() && value instanceof String) {
map.put(key, Enum.valueOf(mapClasses.classB, (String) value));
} else {
- // TODO: bugs are here! rework
map.put(key, createInstance(mapClasses.classB, value));
}
}
@@ -113,7 +129,6 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
if(isStandardClass) {
list.add(o);
} else {
- // TODO: bugs are here! rework
list.add(createInstance(c, o));
}
}
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectArrayProxy.java
@@ -1,20 +1,39 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.dbobject;
import com.mongodb.BasicDBList;
import net.karmafiles.ff.core.tool.dbutil.converter.BaseProxy;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 17:47:31
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class DBObjectArrayProxy extends BasicDBList {
public static DBObjectArrayProxy create(Object[] array) {
if(array == null) {
View
55 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectIterableProxy.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.dbobject;
import com.mongodb.BasicDBList;
@@ -8,18 +39,6 @@
import java.util.Iterator;
import java.util.Map;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 16:08:15
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class DBObjectIterableProxy extends BasicDBList {
@@ -34,18 +53,16 @@ public static DBObjectIterableProxy create(Iterable iterable, PropertyDescriptor
genericClass = BaseProxy.getGenericListClass(propertyDescriptor.getReadMethod().getGenericReturnType());
}
- Iterator iterator = iterable.iterator();
- while(iterator.hasNext()) {
+ for (Object nextObj : iterable) {
- Object nextObj = iterator.next();
Object obj = BaseProxy.passValue(nextObj);
- if(obj instanceof DBObjectProxy) { // we have converted POJO
+ if (obj instanceof DBObjectProxy) { // we have converted POJO
// and generic field list class doesnt match POJO's class
- if(genericClass != null && !BaseProxy.getClassName(nextObj).equals(genericClass.getName())) {
- Map<String, String> genericInfo = new HashMap();
+ if (genericClass != null && !BaseProxy.getClassName(nextObj).equals(genericClass.getName())) {
+ Map<String, String> genericInfo = new HashMap<String, String>();
genericInfo.put("implementation", BaseProxy.getClassName(nextObj));
- ((DBObjectProxy)obj).addGenericInfo(genericInfo);
+ ((DBObjectProxy) obj).addGenericInfo(genericInfo);
}
}
View
45 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectMapProxy.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.dbobject;
import com.mongodb.DBObject;
@@ -10,18 +41,6 @@
import java.util.Map;
import java.util.Set;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 15:41:57
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class DBObjectMapProxy extends BaseProxy implements DBObject {
private Map<String, Object> map;
@@ -57,7 +76,7 @@ private Object convertAndEnhance(Object value) {
if(obj instanceof DBObjectProxy) { // we have converted POJO
// and generic field list class doesnt match POJO's class
if(!BaseProxy.getClassName(value).equals(genericClass.getName())) {
- Map<String, String> genericInfo = new HashMap();
+ Map<String, String> genericInfo = new HashMap<String, String>();
genericInfo.put("implementation", BaseProxy.getClassName(value));
((DBObjectProxy)obj).addGenericInfo(genericInfo);
}
View
60 src/main/java/net/karmafiles/ff/core/tool/dbutil/converter/dbobject/DBObjectProxy.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.converter.dbobject;
import com.mongodb.DBObject;
@@ -8,18 +39,6 @@
import java.util.*;
-/**
- * Created by Ilya Brodotsky
- * Date: 08.10.2010
- * Time: 14:26:33
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class DBObjectProxy extends BaseProxy implements DBObject {
private Object bean;
@@ -84,17 +103,13 @@ public Object get(String key) {
public Map toMap() {
Map m = new HashMap();
- Iterator<String> i = beanDescription.getPropertyNames().iterator();
- while(i.hasNext()) {
- String key = i.next();
+ for (String key : beanDescription.getPropertyNames()) {
m.put(key, get(key));
}
if(genericValues != null) {
- i = genericValues.keySet().iterator();
- while(i.hasNext()) {
- String key = i.next();
+ for (String key : genericValues.keySet()) {
m.put(key, genericValues.get(key));
}
}
@@ -107,11 +122,8 @@ public Object removeField(String key) {
}
public boolean containsKey(String s) {
- if(genericValues != null && genericValues.containsKey(s)) {
- return true;
- }
-
- return beanDescription.getPropertyDescriptor(s) != null;
+ return genericValues != null && genericValues.containsKey(s) || beanDescription.getPropertyDescriptor(s) != null;
+
}
public boolean containsField(String s) {
@@ -119,7 +131,7 @@ public boolean containsField(String s) {
}
public Set<String> keySet() {
- Set<String> set = new HashSet();
+ Set<String> set = new HashSet<String>();
set.addAll(beanDescription.getPropertyNames());
if(genericValues != null) {
set.addAll(genericValues.keySet());
View
47 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/BaseDaoHelper.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
@@ -7,18 +38,6 @@
import java.util.*;
-/**
- * Created by Ilya Brodotsky
- * Date: 14.10.2010
- * Time: 19:09:22
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public abstract class BaseDaoHelper<T> extends DaoHelperTemplate<T> {
private Set<DaoHelperFilter> creationFilters;
private Set<DaoHelperFilter> updateFilters;
@@ -134,14 +153,14 @@ public DBObject doFilter(DBCollection dbCollection, DBObject entity) {
QueryBuilder queryBuilder = QueryBuilder.start();
queryBuilder.put("_id").notEquals(entity.get("_id"));
- List<DBObject> fieldQueries = new ArrayList();
+ List<DBObject> fieldQueries = new ArrayList<DBObject>();
for(String field : fields) {
if(!entity.containsField(field)) {
throw new DaoException("Can't check for field uniqueness: field doesn't exist.");
}
fieldQueries.add(QueryBuilder.start(field).is(entity.get(field)).get());
}
- DBObject[] arr = fieldQueries.toArray(new DBObject[]{});
+ DBObject[] arr = fieldQueries.toArray(new DBObject[fieldQueries.size()]);
queryBuilder.or(arr);
long count = dbCollection.count(queryBuilder.get());
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoException.java
@@ -1,17 +1,36 @@
-package net.karmafiles.ff.core.tool.dbutil.daohelper;
-
-/**
- * Created by Ilya Brodotsky
- * Date: 16.10.2010
- * Time: 3:20:39
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
*/
+package net.karmafiles.ff.core.tool.dbutil.daohelper;
+
public class DaoException extends RuntimeException {
public DaoException() {
}
View
46 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelper.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
@@ -11,18 +42,6 @@
import java.util.Date;
import java.util.List;
-/**
- * Created by Ilya Brodotsky
- * Date: 17.10.2010
- * Time: 19:35:30
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public abstract class DaoHelper<T> extends BaseDaoHelper<T> {
private static final int MAX_NUMBER_AS_LIST = 10000;
@@ -122,8 +141,7 @@ public String generateNewId() {
public T create() {
try {
- T t = getType().newInstance();
- return t;
+ return getType().newInstance();
} catch (Exception e) {
throw new IllegalStateException("Can't instantiate " + getType(), e);
}
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelperFilter.java
@@ -1,20 +1,39 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
-/**
- * Created by Ilya Brodotsky
- * Date: 17.10.2010
- * Time: 17:26:55
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public interface DaoHelperFilter {
public DBObject doFilter(DBCollection dbCollection, DBObject entity);
}
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/DaoHelperTemplate.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
@@ -7,18 +38,6 @@
import net.karmafiles.ff.core.tool.dbutil.converter.Converter;
import org.bson.types.ObjectId;
-/**
- * Created by Ilya Brodotsky
- * Date: 17.10.2010
- * Time: 17:49:06
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public abstract class DaoHelperTemplate<T> {
private Class<T> type;
View
31 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/EntityFilter.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
/**
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/FieldValueChecker.java
@@ -1,20 +1,39 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
-/**
- * Created by Ilya Brodotsky
- * Date: 17.10.2010
- * Time: 18:24:09
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public interface FieldValueChecker {
public void check(DBCollection dbCollection, DBObject dbObject, String fieldName);
}
View
43 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/FieldValueProvider.java
@@ -1,20 +1,39 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
-/**
- * Created by Ilya Brodotsky
- * Date: 17.10.2010
- * Time: 19:10:17
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public interface FieldValueProvider {
public Object provide(DBCollection dbCollection, DBObject dbObject, String fieldName);
}
View
45 src/main/java/net/karmafiles/ff/core/tool/dbutil/daohelper/SimpleCriteria.java
@@ -1,3 +1,34 @@
+/*
+ * Copyright 2011 Dadastream. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DADASTREAM ''AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DADASTREAM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Dadastream.
+ *
+ * @author Ilya Brodotsky
+ * @author Timur Evdokimov
+ */
+
package net.karmafiles.ff.core.tool.dbutil.daohelper;
import com.mongodb.BasicDBObject;
@@ -7,20 +38,8 @@
import java.util.HashMap;
import java.util.Map;
-/**
- * Created by Ilya Brodotsky
- * Date: 16.10.2010
- * Time: 3:32:09
- * <p/>
- * All rights reserved.
- * <p/>
- * Contact me:
- * email, jabber: ilya.brodotsky@gmail.com
- * skype: ilya.brodotsky
- */
-
public class SimpleCriteria {
- private Map<Object, Object> params;
+ private HashMap params;
private SimpleCriteria() {
params = new HashMap();
Please sign in to comment.
Something went wrong with that request. Please try again.