Java tutorial
/* * EYWA.COM (Eywa Commerce) * This program is an integrated platform with E-Commerce and Configurator system. * Support: Please, contact the Author on http://www.smartfeeling.org. * Copyright (C) 2014 Gian Angelo Geminiani * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.eywa.impl.app.mongo.entities.items.jobs.documents; import com.eywa.impl.app.IAppConstants; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import org.ly.commons.util.StringUtils; import org.ly.packages.mongo.impl.util.MongoUtils; import java.util.List; /** * Item for Scheduler DATA field. * Contains information about Document job */ public class ItemJobDocument extends BasicDBObject { public static final String TYPE_ORDER = "job-order"; // ------------------------------------------------------------------------ // f i e l d s // ------------------------------------------------------------------------ public static final String TYPE = IAppConstants.TYPE; // data type public static final String DOCUMENT_ID = IAppConstants.DOCUMENT_ID; public static final String SELLER_ID = IAppConstants.SELLER_ID; public static final String CUSTOMER_ID = IAppConstants.CUSTOMER_ID; public static final String ITEMS = IAppConstants.ITEMS; // products // ------------------------------------------------------------------------ // c o n s t r u c t o r // ------------------------------------------------------------------------ public ItemJobDocument(final String type) { MongoUtils.put(this, TYPE, type); } public ItemJobDocument() { MongoUtils.put(this, TYPE, TYPE_ORDER); } // ------------------------------------------------------------------------ // p r i v a t e // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // S T A T I C // ------------------------------------------------------------------------ public static boolean isOrder(final DBObject item) { return isOrder(getType(item)); } public static boolean isOrder(final String type) { return StringUtils.hasText(type) && type.equalsIgnoreCase(TYPE_ORDER); } public static String getType(final DBObject item) { return MongoUtils.getString(item, TYPE); } public static void setType(final DBObject item, final String value) { MongoUtils.put(item, TYPE, value); } public static String getDocumentId(final DBObject item) { return MongoUtils.getString(item, DOCUMENT_ID); } public static void setDocumentId(final DBObject item, final String value) { MongoUtils.put(item, DOCUMENT_ID, value); } public static String getSellerId(final DBObject item) { return MongoUtils.getString(item, SELLER_ID); } public static void setSellerId(final DBObject item, final String value) { MongoUtils.put(item, SELLER_ID, value); } public static String getCustomerId(final DBObject item) { return MongoUtils.getString(item, CUSTOMER_ID); } public static void setCustomerId(final DBObject item, final String value) { MongoUtils.put(item, CUSTOMER_ID, value); } public static List<DBObject> getItems(final DBObject item) { return MongoUtils.getList(item, ITEMS); } public static void setItems(final DBObject item, final List<DBObject> value) { MongoUtils.put(item, ITEMS, value); } }