Example usage for com.mongodb BasicDBList BasicDBList

List of usage examples for com.mongodb BasicDBList BasicDBList

Introduction

In this page you can find the example usage for com.mongodb BasicDBList BasicDBList.

Prototype

BasicDBList

Source Link

Usage

From source file:com.edgytech.umongo.UserDialog.java

License:Apache License

BasicDBObject getUser(BasicDBObject userObj) {
    final String user = getStringFieldValue(Item.user);
    if (userObj == null)
        userObj = new BasicDBObject("user", user);

    // do not overwrite password if not set
    final String pass = getStringFieldValue(Item.password);
    if (!pass.isEmpty())
        userObj.put("pwd", _hash(user, pass.toCharArray()));

    String userSrc = getStringFieldValue(Item.userSource);
    if (!userSrc.trim().isEmpty()) {
        userObj.put(Item.userSource.name(), userSrc);
        // cant have pwd
        userObj.removeField("pwd");
    }//  w w  w .  jav a  2s. c o m

    if (!getBooleanFieldValue(Item.version22)) {
        // format from 2.4
        BasicDBList roles = new BasicDBList();
        for (Role role : Role.values()) {
            if (getBooleanFieldValue(role.item))
                roles.add(role.name());
        }
        userObj.put("roles", roles);

        // readOnly flag must be dropped
        userObj.removeField("readOnly");
    } else {
        // keep it simple: if readWrite is not checked, then readOnly
        if (!getBooleanFieldValue(Item.readWrite))
            userObj.put("readOnly", true);

        // remove roles
        userObj.removeField("roles");

        // all other flags should still be accepted
    }

    return userObj;
}

From source file:com.effektif.mongo.MongoObjectMapper.java

License:Apache License

@Override
public List<Object> newArray() {
    return new BasicDBList();
}

From source file:com.effektif.mongo.MongoWorkflowInstanceStore.java

License:Apache License

/** writes the given activityInstances to db format, preserving the hierarchy and including the workState. */
protected BasicDBList writeActiveActivityInstances(List<ActivityInstanceImpl> activityInstances) {
    if (activityInstances == null || activityInstances.isEmpty()) {
        return null;
    }/*from  w ww .java 2 s. c o m*/
    BasicDBList dbActivityInstances = new BasicDBList();
    for (ActivityInstanceImpl activityInstance : activityInstances) {
        BasicDBObject dbActivityInstance = mongoMapper.write(activityInstance.toActivityInstance(true));
        dbActivityInstances.add(dbActivityInstance);
    }
    return dbActivityInstances;
}

From source file:com.effektif.mongo.Query.java

License:Apache License

/**
 * Adds a list of clauses to the query as disjunction (logical OR).
 *//*from   ww w  .  j  a va 2 s.c  o m*/
public Query or(BasicDBObject... orClauses) {
    BasicDBList clauses = new BasicDBList();
    for (BasicDBObject orClause : orClauses) {
        if (orClause != null) {
            clauses.add(orClause);
        }
    }
    return or(clauses);
}

From source file:com.effektif.mongo.Query.java

License:Apache License

public Query or(Query... orClauses) {
    BasicDBList clauses = new BasicDBList();
    for (Query orClause : orClauses) {
        if (orClause != null) {
            clauses.add(orClause.get());
        }/*from  ww  w .j  a  va  2s.  c  o  m*/
    }
    return or(clauses);
}

From source file:com.effektif.mongo.Query.java

License:Apache License

/**
 * Adds a list of clauses to the query as disjunction (logical OR).
 */// w  w w.j  a v  a2  s .c  o  m
public Query or(BasicDBList clauses) {
    if (clauses == null || clauses.size() == 0) {
        return this;
    }
    if (query.containsField("$or")) {
        BasicDBList andClauses = new BasicDBList();
        andClauses.add(new BasicDBObject("$or", query.remove("$or")));
        andClauses.add(new BasicDBObject("$or", clauses));
        and(andClauses);
    } else if (query.containsField("$and")) {
        BasicDBList andClauses = (BasicDBList) query.get("$and");
        andClauses.add(new BasicDBObject("$or", clauses));
    } else {
        query.append("$or", clauses);
    }
    return this;
}

From source file:com.effektif.mongo.Query.java

License:Apache License

/**
 * Adds a list of clauses to the query as disjunction (logical OR).
 *///from w w w . ja  va 2s . c  om
public Query or(List<? extends Query> clauses) {
    BasicDBList dbClauses = new BasicDBList();
    for (Query orClause : clauses) {
        if (orClause != null) {
            dbClauses.add(orClause.get());
        }
    }
    return or(dbClauses);
}

From source file:com.effektif.mongo.Query.java

License:Apache License

/**
 * Adds a list of clauses to the query as conjunction (logical AND).
 *//*from   w ww  .  j a  v  a 2 s  . c  o  m*/
public Query and(BasicDBObject... andClauses) {
    BasicDBList clauses = new BasicDBList();
    for (BasicDBObject andClause : andClauses) {
        if (andClause != null) {
            clauses.add(andClause);
        }
    }
    return and(clauses);
}

From source file:com.effektif.mongo.Query.java

License:Apache License

public Query and(Query... andClauses) {
    BasicDBList clauses = new BasicDBList();
    for (Query andClause : andClauses) {
        if (andClause != null) {
            clauses.add(andClause.get());
        }//  w w w . j  av a2 s  . c  om
    }
    return and(clauses);
}

From source file:com.effektif.mongo.Query.java

License:Apache License

public Query and(List<? extends Query> andClauses) {
    BasicDBList clauses = new BasicDBList();
    for (Query andClause : andClauses) {
        if (andClause != null) {
            clauses.add(andClause.get());
        }//from   w  ww .  j  a v  a  2 s  .c  o  m
    }
    return and(clauses);
}