Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2014 Effektif GmbH.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.effektif.mongo;
import com.effektif.workflow.api.model.Id;
import com.effektif.workflow.api.model.WorkflowId;
import com.effektif.workflow.api.model.WorkflowInstanceId;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.bson.types.ObjectId;
import org.joda.time.LocalDateTime;
import java.util.*;
public abstract class MongoHelper {
public static void writeId(Map o, String fieldName, String value) {
o.put(fieldName, new ObjectId(value));
}
public static void writeId(Map o, String fieldName, Id value) {
o.put(fieldName, new ObjectId(value.toString()));
}
public static void writeIdOpt(Map o, String fieldName, String value) {
if (value!=null) {
o.put(fieldName, new ObjectId(value));
}
}
public static void writeIdOptNew(Map o, String fieldName, Id id) {
if (id!=null) {
o.put(fieldName, new ObjectId(id.getInternal()));
}
}
public static void writeString(Map o, String fieldName, Object value) {
writeObject(o, fieldName, value);
}
public static void writeStringOpt(Map o, String fieldName, String value) {
writeObjectOpt(o, fieldName, value);
}
public static void writeLongOpt(Map o, String fieldName, Long value) {
writeObjectOpt(o, fieldName, value);
}
public static void writeBooleanOpt(Map o, String fieldName, Object value) {
writeObjectOpt(o, fieldName, value);
}
public static void writeObject(Map o, String fieldName, Object value) {
o.put(fieldName, value);
}
public static void writeObjectOpt(Map o, String fieldName, Object value) {
if (value!=null) {
o.put(fieldName, value);
}
}
public static void writeTimeOpt(Map o, String fieldName, LocalDateTime value) {
if (value!=null) {
o.put(fieldName, value.toDate());
}
}
public static void writeListElementOpt(Map o, String fieldName, Object element) {
if (element!=null) {
@SuppressWarnings("unchecked")
List