com.eywa.impl.app.mongo.entities.items.jobs.payments.ItemJobPayment.java Source code

Java tutorial

Introduction

Here is the source code for com.eywa.impl.app.mongo.entities.items.jobs.payments.ItemJobPayment.java

Source

/*
 * 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.payments;

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 Payment job
 */
public class ItemJobPayment extends BasicDBObject {

    public static final String TYPE_GENERIC = "job-generic";

    // ------------------------------------------------------------------------
    //                      f i e l d s
    // ------------------------------------------------------------------------

    public static final String TYPE = IAppConstants.TYPE; // data type

    public static final String PAYMENT_ID = IAppConstants.PAYMENT_ID;
    public static final String TRANSACTIONS = IAppConstants.TRANSACTIONS;

    // ------------------------------------------------------------------------
    //                      c o n s t r u c t o r
    // ------------------------------------------------------------------------

    public ItemJobPayment(final String type) {
        MongoUtils.put(this, TYPE, type);
    }

    public ItemJobPayment() {
        MongoUtils.put(this, TYPE, TYPE_GENERIC);
    }

    // ------------------------------------------------------------------------
    //                      p r i v a t e
    // ------------------------------------------------------------------------

    // ------------------------------------------------------------------------
    //                      S T A T I C
    // ------------------------------------------------------------------------

    public static boolean isGeneric(final DBObject item) {
        return isGeneric(getType(item));
    }

    public static boolean isGeneric(final String type) {
        return StringUtils.hasText(type) && type.equalsIgnoreCase(TYPE_GENERIC);
    }

    public static String getType(final DBObject item) {
        return MongoUtils.getString(item, TYPE);
    }

    public static String getPaymentId(final DBObject item) {
        return MongoUtils.getString(item, PAYMENT_ID);
    }

    public static void setPaymentId(final DBObject item, final String value) {
        MongoUtils.put(item, PAYMENT_ID, value);
    }

    public static List<DBObject> getTransactions(final DBObject item) {
        return MongoUtils.getList(item, TRANSACTIONS);
    }

    public static void setTransactions(final DBObject item, final List<DBObject> value) {
        MongoUtils.put(item, TRANSACTIONS, value);
    }

}