public static void on(String message, Throwable error) {
        on(message, null, error);
    }

package org.openlca.app.util;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.openlca.app.App;
import org.openlca.app.rcp.images.Icon;
import org.openlca.julia.Julia;
import org.slf4j.LoggerFactory;

public class ErrorReporter extends FormDialog {

    private final String message;

    private final String details;

    private final Throwable error;

    public static void on(String message) {
        on(message, null, null);
    }

    public static void on(String message, String details) {
        on(message, details, null);
    }

    /**
     * Opens the error reporter for the given message and error. It also writes the
     * error to the log. So no need to log an error when you later want to open it
     * in the reporter. It is save to call this method from non-UI threads.
     */

public static void on(String message, String details, Throwable error) {
        var log = LoggerFactory.getLogger(ErrorReporter.class);
        log.error(message, error);
        App.runInUI("Show error reporter", () -> new ErrorReporter(message, details, error).open());
    }

    private ErrorReporter(String message, String details, Throwable error) {
        super(UI.shell());
        this.message = message == null ? "No error message" : message;
        this.details = details;
        this.error = error;
        setBlockOnOpen(true);
    }

    @Override
    protected void configureShell(Shell shell) {
        super.configureShell(shell);
        shell.setImage(Icon.ERROR.get());
        shell.setText("An error occurred");
    }

    @Override
    protected void createButtonsForButtonBar(Composite parent) {
        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    }

    @Override
    protected Point getInitialSize() {
        return new Point(600, 400);
    }

    @Override
    protected void createFormContent(IManagedForm mform) {
        var tk = mform.getToolkit();
        var body = UI.formBody(mform.getForm(), tk);
        body.setLayout(new FillLayout());
        var comp = tk.createComposite(body);
        UI.gridLayout(comp, 1);
        var formText = tk.createFormText(comp, true);
        formText.setText(formMessage(), true, true);
        UI.gridData(formText, true, false).widthHint = 560;
        var text = tk.createText(comp, "", SWT.MULTI | SWT.V_SCROLL);
        UI.gridData(text, true, true);
        mform.reflow(true);
        var message = details != null ? "# Error details: \n" + details + "\n\n" + reportTemplate() : reportTemplate();
        text.setText(message);
        formText.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                var href = e.getHref();
                if (href == null)
                    return;
                var uri = href.toString();
                if (uri.startsWith("mailto:")) {
                    uri += "?subject=openLCA%20error&body=";
                    uri += URLEncoder.encode(text.getText(), StandardCharsets.US_ASCII).replace("+", "%20");
                }
                Desktop.browse(uri);
            }
        });
    }

    private String formMessage() {
        return "" + "
" + message + "
" + "
 If you think this should not happen or if there is " + "something that we should improve please open an issue " + "on our " + "openLCA Github repository or send us an " + "email. For " + "reporting the issue, you can use the template below. " + "Thanks!
" + "";
    }

    private String reportTemplate() {
        return "If you want to report this error to us, please replace the\n" + "question marks in the template below (if possible).\n" + "Thanks a lot!\n\n" + "# Error description\n" + "\n" + "I tried to ??? but openLCA threw an error.\n" + "\n" + "# Steps to reproduce\n" + "\n" + "1. ?\n" + "2. ?\n" + "3. ?\n" + "\n" + "# Attached files\n" + "\n" + "* example database ?\n" + "* screen shots ?\n" + "* ...\n" + "\n" + "# openLCA error message\n" + "\n" + message + "\n\n" + "# Installation details\n" + "\n" + "* openLCA version: " + App.getVersion() + "\n" + "* operating system: " + System.getProperty("os.name") + "\n" + "* os architecture: " + System.getProperty("os.arch") + "\n" + "* os version: " + System.getProperty("os.version") + "\n" + "* native libraries loaded: " + Julia.isLoaded() + "\n" + "* with sparse matrix support: " + Julia.hasSparseLibraries() + "\n" + "\n" + "# Full error stack trace\n" + "\n" + "```\n" + stackTrace() + "\n```";
    }

    private String stackTrace() {
        if (error == null)
            return "not available";
        var writer = new StringWriter();
        var printer = new PrintWriter(writer);
        error.printStackTrace(printer);
        return writer.toString();
    }
}


for (int i = 0; i < K; i++) {
            st = new StringTokenizer(br.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            int C = Integer.parseInt(st.nextToken());
            rules[i] = new Rule(A, B, C);
        }

/*
 * Author: Minho Kim (ISKU)
 * Date: May 20, 2018
 * E-mail: example@nnthink.com
 *
 * http://example.com
 * http://example.com
 */
import java.util.*;
import java.io.*;

public class Main {

    private static Rule[] rules;

    public static void main(String... args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        long D = Long.parseLong(st.nextToken());
        rules = new Rule[K];

        int l = 1;
        int r = N;
        while (l < r) {
            int mid = (l + r) / 2;
            if (D <= sum(mid))
                r = mid;
            else
                l = mid + 1;
        }
        System.out.print(l);
    }

    private static long sum(int X) {
        long sum = 0;
        for (Rule rule : rules) {
            if (rule.A <= X && X <= rule.B)
                sum += ((X - rule.A) / rule.C) + 1;
            else if (rule.B <= X)
                sum += ((rule.B - rule.A) / rule.C) + 1;
        }
        return sum;
    }

    private static class Rule {

        public int A, B, C;

        public Rule(int A, int B, int C) {
            this.A = A;
            this.B = B;
            this.C = C;
        }
    }
}


while (l < r) {
            int mid = (l + r) / 2;
            if (D <= sum(mid))
                r = mid;
            else
                l = mid + 1;
        }

/*
 * Author: Minho Kim (ISKU)
 * Date: May 20, 2018
 * E-mail: example@nnthink.com
 *
 * http://example.com
 * http://example.com
 */
import java.util.*;
import java.io.*;

public class Main {

    private static Rule[] rules;

    public static void main(String... args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        long D = Long.parseLong(st.nextToken());
        rules = new Rule[K];
        for (int i = 0; i < K; i++) {
            st = new StringTokenizer(br.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            int C = Integer.parseInt(st.nextToken());
            rules[i] = new Rule(A, B, C);
        }
        int l = 1;
        int r = N;

        System.out.print(l);
    }

    private static long sum(int X) {
        long sum = 0;
        for (Rule rule : rules) {
            if (rule.A <= X && X <= rule.B)
                sum += ((X - rule.A) / rule.C) + 1;
            else if (rule.B <= X)
                sum += ((rule.B - rule.A) / rule.C) + 1;
        }
        return sum;
    }

    private static class Rule {

        public int A, B, C;

        public Rule(int A, int B, int C) {
            this.A = A;
            this.B = B;
            this.C = C;
        }
    }
}


while (enums.hasMoreElements()) {
            CacheChangedListener listener = enums.nextElement();
            try {
                info("触发事件：{}，执行监听业务：{}，数据：{}", event.getAction(), listener.getListenerName(), event.getSource());
                listener.handleChangedEvent(event);
            } catch (Exception e) {
                throw e;
            }
        }

package com.cnblogs.hoojo.sensitivewords.event;

import java.util.Enumeration;
import java.util.Vector;
import com.cnblogs.hoojo.sensitivewords.cache.JvmWordsCache;
import com.cnblogs.hoojo.sensitivewords.cache.RedisWordsCache;
import com.cnblogs.hoojo.sensitivewords.log.ApplicationLogging;

/**
 * 目标事件源对象上下文
 * @author hoojo
 * @createDate 2018年2月5日 下午5:22:47
 * @file TargetEventSource.java
 * @package com.cnblogs.hoojo.sensitivewords.event
 * @project fengkong-service-provider
 * @blog http://hoojo.cnblogs.com
 * @email example@nnthink.com
 * @version 1.0
 */
public final class WordsCacheContext extends ApplicationLogging {

    private Vector<CacheChangedListener> listeners = new Vector<CacheChangedListener>();

    private static class SingleFactory {

        private static final WordsCacheContext INSTANCE = new WordsCacheContext();
    }

    public static final WordsCacheContext getInstance() {
        return SingleFactory.INSTANCE;
    }

    private WordsCacheContext() {
        try {
            register(RedisWordsCache.getInstance());
            register(JvmWordsCache.getInstance());
        } catch (Exception e) {
            error(e);
            throw e;
        }
    }

    public void register(CacheChangedListener listener) {
        if (!this.listeners.contains(listener)) {
            this.listeners.add(listener);
        }
    }

    public void dispatchChanged(CacheChangedEvent event) throws Exception {
        event.doEvent();
        Enumeration<CacheChangedListener> enums = listeners.elements();

    }

    public interface CacheChangedListener extends java.util.EventListener {

        public void handleChangedEvent(CacheChangedEvent event) throws Exception;

        public String getListenerName();
    }
}


try {
                info("触发事件：{}，执行监听业务：{}，数据：{}", event.getAction(), listener.getListenerName(), event.getSource());
                listener.handleChangedEvent(event);
            } catch (Exception e) {
                throw e;
            }

package com.cnblogs.hoojo.sensitivewords.event;

import java.util.Enumeration;
import java.util.Vector;
import com.cnblogs.hoojo.sensitivewords.cache.JvmWordsCache;
import com.cnblogs.hoojo.sensitivewords.cache.RedisWordsCache;
import com.cnblogs.hoojo.sensitivewords.log.ApplicationLogging;

/**
 * 目标事件源对象上下文
 * @author hoojo
 * @createDate 2018年2月5日 下午5:22:47
 * @file TargetEventSource.java
 * @package com.cnblogs.hoojo.sensitivewords.event
 * @project fengkong-service-provider
 * @blog http://hoojo.cnblogs.com
 * @email example@nnthink.com
 * @version 1.0
 */
public final class WordsCacheContext extends ApplicationLogging {

    private Vector<CacheChangedListener> listeners = new Vector<CacheChangedListener>();

    private static class SingleFactory {

        private static final WordsCacheContext INSTANCE = new WordsCacheContext();
    }

    public static final WordsCacheContext getInstance() {
        return SingleFactory.INSTANCE;
    }

    private WordsCacheContext() {
        try {
            register(RedisWordsCache.getInstance());
            register(JvmWordsCache.getInstance());
        } catch (Exception e) {
            error(e);
            throw e;
        }
    }

    public void register(CacheChangedListener listener) {
        if (!this.listeners.contains(listener)) {
            this.listeners.add(listener);
        }
    }

    public void dispatchChanged(CacheChangedEvent event) throws Exception {
        event.doEvent();
        Enumeration<CacheChangedListener> enums = listeners.elements();
        while (enums.hasMoreElements()) {
            CacheChangedListener listener = enums.nextElement();

        }
    }

    public interface CacheChangedListener extends java.util.EventListener {

        public void handleChangedEvent(CacheChangedEvent event) throws Exception;

        public String getListenerName();
    }
}


while (entries.hasMoreElements()) {
                final ZipEntry entry = entries.nextElement();
                if (!entry.isDirectory()) {
                    final String relPath = entry.getName();
                    if (relPath.startsWith(rootDirName)) {
                        paths.add(relPath.substring(rootDirName.length()));
                    }
                }
            }

package com.weirddev.testme.intellij.ui.template;

import com.intellij.ide.fileTemplates.FileTemplate;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.io.URLUtil;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class UrlUtil {

    private static final String JAR_SEPARATOR = URLUtil.JAR_SEPARATOR;

    private static final String URL_PATH_SEPARATOR = "/";

    private static final String FILE_PROTOCOL = URLUtil.FILE_PROTOCOL;

    private static final String FILE_PROTOCOL_PREFIX = FILE_PROTOCOL + ":";

    @NotNull
    public static String loadText(@NotNull URL url) throws IOException {
        try (InputStream stream = new BufferedInputStream(URLUtil.openStream(url))) {
            return new String(FileUtil.loadBytes(stream), FileTemplate.ourEncoding);
        }
    }

    @NotNull
    public static List<String> getChildrenRelativePaths(@NotNull URL root) throws IOException {
        final String protocol = root.getProtocol();
        if ("jar".equalsIgnoreCase(protocol)) {
            return getChildPathsFromJar(root);
        }
        if (FILE_PROTOCOL.equalsIgnoreCase(protocol)) {
            return getChildPathsFromFile(root);
        }
        return Collections.emptyList();
    }

    @NotNull
    private static List<String> getChildPathsFromFile(@NotNull URL root) {
        final List<String> paths = new ArrayList<>();
        final File rootFile = new File(FileUtil.unquote(root.getPath()));
        new Object() {

            void collectFiles(File fromFile, String prefix) {
                final File[] list = fromFile.listFiles();
                if (list != null) {
                    for (File file : list) {
                        final String childRelativePath = prefix.isEmpty() ? file.getName() : prefix + URL_PATH_SEPARATOR + file.getName();
                        if (file.isDirectory()) {
                            collectFiles(file, childRelativePath);
                        } else {
                            paths.add(childRelativePath);
                        }
                    }
                }
            }
        }.collectFiles(rootFile, "");
        return paths;
    }

    @NotNull
    private static List<String> getChildPathsFromJar(@NotNull URL root) throws IOException {
        String file = root.getFile();
        file = StringUtil.trimStart(file, FILE_PROTOCOL_PREFIX);
        final int jarSeparatorIndex = file.indexOf(JAR_SEPARATOR);
        assert jarSeparatorIndex > 0;
        String rootDirName = file.substring(jarSeparatorIndex + 2);
        if (!rootDirName.endsWith(URL_PATH_SEPARATOR)) {
            rootDirName += URL_PATH_SEPARATOR;
        }
        try (ZipFile zipFile = new ZipFile(FileUtil.unquote(file.substring(0, jarSeparatorIndex)))) {
            final Enumeration<? extends ZipEntry> entries = zipFile.entries();
            final List<String> paths = new ArrayList<>();

            return paths;
        }
    }
}


public void addDescription(String description) {
        String desc = getDescription();
        if (desc == null)
            setDescription(description);
        else
            setDescription(desc + " | " + description);
    }

/**
 * ***************************************************************************
 *  Product: Adempiere ERP & CRM Smart Business Solution                       *
 *  For the text or an alternative of this public license, you may reach us    *
 *  Contributor(s): Victor Perez www.e-evolution.com                           *
 *                  Teo Sarca, www.arhipac.ro                                  *
 * ***************************************************************************
 */
package org.eevolution.model;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.compiere.model.MLocator;
import org.compiere.model.MProduct;
import org.compiere.model.MStorage;
import org.compiere.model.MUOM;
import org.compiere.model.MUOMConversion;
import org.compiere.model.MWarehouse;
import org.compiere.model.Query;
import org.compiere.util.DB;
import org.compiere.util.Env;

/**
 * PP Order BOM Line Model.
 *
 * @author Victor Perez www.e-evolution.com
 * @author Teo Sarca, www.arhipac.ro
 */
public class MPPOrderBOMLine extends X_PP_Order_BOMLine {

    private static final long serialVersionUID = -201479481618586562L;

    public static MPPOrderBOMLine forM_Product_ID(Properties ctx, int PP_Order_ID, int M_Product_ID, String trxName) {
        // TODO: vpj-cd What happen when a product it more the time in Order
        final String whereClause = COLUMNNAME_PP_Order_ID + "=? AND " + COLUMNNAME_M_Product_ID + "=?";
        return new Query(ctx, Table_Name, whereClause, trxName).setParameters(new Object[] { PP_Order_ID, M_Product_ID }).firstOnly();
    }

    public MPPOrderBOMLine(Properties ctx, int PP_Order_BOMLine_ID, String trxName) {
        super(ctx, PP_Order_BOMLine_ID, trxName);
        if (PP_Order_BOMLine_ID == 0) {
            setDefault();
        }
    }

    // PP_Order_BOMLine_ID
    /**
     * Constructor
     * @param ctx
     * @param rs
     * @param trxName
     */
    public MPPOrderBOMLine(Properties ctx, ResultSet rs, String trxName) {
        super(ctx, rs, trxName);
    }

    // MOrderLine
    /**
     * Peer constructor
     * @param bomLine
     * @param PP_Order_ID
     * @param PP_Order_BOM_ID
     * @param M_Warehouse_ID
     * @param trxName
     */
    public MPPOrderBOMLine(MPPProductBOMLine bomLine, int PP_Order_ID, int PP_Order_BOM_ID, int M_Warehouse_ID, String trxName) {
        this(bomLine.getCtx(), 0, trxName);
        setPP_Order_BOM_ID(PP_Order_BOM_ID);
        setPP_Order_ID(PP_Order_ID);
        setM_Warehouse_ID(M_Warehouse_ID);
        setM_ChangeNotice_ID(bomLine.getM_ChangeNotice_ID());
        setDescription(bomLine.getDescription());
        setHelp(bomLine.getHelp());
        setAssay(bomLine.getAssay());
        setQtyBatch(bomLine.getQtyBatch());
        setQtyBOM(bomLine.getQtyBOM());
        setIsQtyPercentage(bomLine.isQtyPercentage());
        setComponentType(bomLine.getComponentType());
        setC_UOM_ID(bomLine.getC_UOM_ID());
        setForecast(bomLine.getForecast());
        setIsCritical(bomLine.isCritical());
        setIssueMethod(bomLine.getIssueMethod());
        setLeadTimeOffset(bomLine.getLeadTimeOffset());
        setM_AttributeSetInstance_ID(bomLine.getM_AttributeSetInstance_ID());
        setM_Product_ID(bomLine.getM_Product_ID());
        setScrap(bomLine.getScrap());
        setValidFrom(bomLine.getValidFrom());
        setValidTo(bomLine.getValidTo());
        setBackflushGroup(bomLine.getBackflushGroup());
    }

    private MPPOrder m_parent = null;

    /**
     * Do we need to explode this BOM line. Set when ComponentType is Phantom and m_qtyRequiredPhantom != null.
     * If set, the line is exploded on after save
     */
    private boolean m_isExplodePhantom = false;

    /**
     * Qty used for exploding this BOM Line.
     */
    private BigDecimal m_qtyRequiredPhantom = null;

    @Override
    protected boolean beforeSave(boolean newRecord) {
        // Victor Perez: The best practice in this case you do should change the component you need
        // adding a new line in Order BOM Line with new component so do not is right
        // delete or change a component because this information is use to calculate
        // the variances cost ( http://example.com )
        if (!isActive()) {
            // TODO: translate
            throw new AdempiereException("De-Activating an BOM Line is not allowed");
        }
        if (!newRecord && is_ValueChanged(COLUMNNAME_M_Product_ID)) {
            // TODO: translate
            throw new AdempiereException("Changing Product is not allowed");
        }
        // Get Line No
        if (getLine() == 0) {
            String sql = "SELECT COALESCE(MAX(" + COLUMNNAME_Line + "),0)+10 FROM " + Table_Name + " WHERE " + COLUMNNAME_PP_Order_ID + "=?";
            int ii = DB.getSQLValueEx(get_TrxName(), sql, getPP_Order_ID());
            setLine(ii);
        }
        // If Phantom, we need to explode this line (see afterSave):
        if (newRecord && COMPONENTTYPE_Phantom.equals(getComponentType())) {
            m_qtyRequiredPhantom = getQtyRequired();
            m_isExplodePhantom = true;
            setQtyRequired(Env.ZERO);
        }
        if (newRecord || is_ValueChanged(COLUMNNAME_C_UOM_ID) || is_ValueChanged(COLUMNNAME_QtyEntered) || is_ValueChanged(COLUMNNAME_QtyRequired)) {
            int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID());
            setQtyEntered(getQtyEntered().setScale(precision, RoundingMode.UP));
            setQtyRequired(getQtyRequired().setScale(precision, RoundingMode.UP));
        }
        if (is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_QtyDelivered) || is_ValueChanged(MPPOrderBOMLine.COLUMNNAME_QtyRequired)) {
            reservedStock();
        }
        return true;
    }

    @Override
    protected boolean afterSave(boolean newRecord, boolean success) {
        if (!success)
            return false;
        explodePhantom();
        return true;
    }

    @Override
    protected boolean beforeDelete() {
        // Release Reservation
        setQtyRequired(Env.ZERO);
        reservedStock();
        return true;
    }

    /**
     * Explode Phantom Items
     * TODO: check if BOM and BOM Lines are valid
     */
    private void explodePhantom() {
        if (m_isExplodePhantom && m_qtyRequiredPhantom != null) {
            MProduct parent = MProduct.get(getCtx(), getM_Product_ID());
            int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(parent);
            if (PP_Product_BOM_ID <= 0) {
                return;
            }
            MPPProductBOM bom = MPPProductBOM.get(getCtx(), PP_Product_BOM_ID);
            if (bom != null) {
                for (MPPProductBOMLine PP_Product_BOMline : bom.getLines()) {
                    MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline, getPP_Order_ID(), getPP_Order_BOM_ID(), getM_Warehouse_ID(), get_TrxName());
                    PP_Order_BOMLine.setAD_Org_ID(getAD_Org_ID());
                    PP_Order_BOMLine.setQtyOrdered(m_qtyRequiredPhantom);
                    PP_Order_BOMLine.saveEx();
                }
            }
            m_isExplodePhantom = false;
        }
    }

    @Override
    public MProduct getM_Product() {
        return MProduct.get(getCtx(), getM_Product_ID());
    }

    @Override
    public MUOM getC_UOM() {
        return MUOM.get(getCtx(), getC_UOM_ID());
    }

    @Override
    public MWarehouse getM_Warehouse() {
        return MWarehouse.get(getCtx(), getM_Warehouse_ID());
    }

    /**
     * Qty Required for a Phantom Component. The Qty that will be exploded after line is saved.
     * @return
     */
    public BigDecimal getQtyRequiredPhantom() {
        return m_qtyRequiredPhantom != null ? m_qtyRequiredPhantom : Env.ZERO;
    }

    /**
     *  	Get Parent
     * 	@return PP_Order
     */
    public MPPOrder getParent() {
        int id = getPP_Order_ID();
        if (id <= 0) {
            m_parent = null;
            return null;
        }
        if (m_parent == null || m_parent.get_ID() != id) {
            m_parent = new MPPOrder(getCtx(), id, get_TrxName());
        }
        return m_parent;
    }

    // getParent
    /**
     * @return UOM precision
     */
    public int getPrecision() {
        return MUOM.getPrecision(getCtx(), getC_UOM_ID());
    }

    /**
     * Return Unified BOM Qty Multiplier
     * @return If is percentage then QtyBatch / 100 will be returned, else QtyBOM.
     */
    public BigDecimal getQtyMultiplier() {
        BigDecimal qty;
        if (isQtyPercentage()) {
            qty = getQtyBatch().divide(Env.ONEHUNDRED, 8, RoundingMode.HALF_UP);
        } else {
            qty = getQtyBOM();
        }
        return qty;
    }

    public void setQtyOrdered(BigDecimal QtyOrdered) {
        BigDecimal multiplier = getQtyMultiplier();
        BigDecimal qty = QtyOrdered.multiply(multiplier).setScale(8, RoundingMode.UP);
        if (isComponentType(COMPONENTTYPE_Component, COMPONENTTYPE_Phantom, COMPONENTTYPE_By_Product, COMPONENTTYPE_Co_Product)) {
            BigDecimal qtyrequired = qty;
            if (getM_Product().getC_UOM_ID() != getC_UOM_ID()) {
                BigDecimal rate = MUOMConversion.getProductRateFrom(getCtx(), getM_Product_ID(), getC_UOM_ID());
                if (rate == null)
                    throw new AdempiereException("@PP_Product_BOMLine_ID@ @C_UOM_Conversion_ID@ @NotFound@  @M_Product_ID@ " + getM_Product().getName() + " @C_UOM_To_ID@ " + getC_UOM().getName());
                qtyrequired = qty.multiply(rate);
            }
            setQtyRequired(qtyrequired);
            setQtyEntered(qty);
        } else if (isComponentType(COMPONENTTYPE_Tools)) {
            setQtyRequired(multiplier);
            setQtyEntered(multiplier);
        } else if (isComponentType(COMPONENTTYPE_Packing)) {
            setQtyRequired(multiplier.multiply(getParent().getQtyBatchs()));
            setQtyEntered(multiplier.multiply(getParent().getQtyBatchs()));
        } else {
            throw new AdempiereException("@NotSupported@ @ComponentType@ " + getComponentType());
        }
        // Set Scrap of Component
        BigDecimal qtyScrap = getScrap();
        if (qtyScrap.signum() != 0) {
            qtyScrap = qtyScrap.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP);
            setQtyRequired(getQtyRequired().divide(Env.ONE.subtract(qtyScrap), 8, BigDecimal.ROUND_HALF_UP));
            setQtyEntered(getQtyEntered().divide(Env.ONE.subtract(qtyScrap), 8, BigDecimal.ROUND_HALF_UP));
        }
    }

    @Override
    public void setQtyRequired(BigDecimal QtyRequired) {
        if (QtyRequired != null && getC_UOM_ID() != 0) {
            int precision = getPrecision();
            QtyRequired = QtyRequired.setScale(precision, RoundingMode.HALF_UP);
        }
        super.setQtyRequired(QtyRequired);
    }

    // setQtyRequired
    @Override
    public void setQtyReserved(BigDecimal QtyReserved) {
        if (QtyReserved != null && getC_UOM_ID() != 0) {
            int precision = getPrecision();
            QtyReserved = QtyReserved.setScale(precision, RoundingMode.HALF_UP);
        }
        super.setQtyReserved(QtyReserved);
    }

    // setQtyReserved
    public BigDecimal getQtyOpen() {
        return getQtyEntered().subtract(getQtyDelivered());
    }

    /**
     * Storage Qty On Hand
     */
    private BigDecimal m_qtyOnHand = null;

    /**
     * Storage Qty Available
     */
    private BigDecimal m_qtyAvailable = null;

    /**
     * Load Storage Info
     * @param reload
     */
    private void loadStorage(boolean reload) {
        if (!reload && m_qtyOnHand != null && m_qtyAvailable != null) {
            return;
        }
        final String sql = "SELECT " + " bomQtyAvailable(" + COLUMNNAME_M_Product_ID + ", " + COLUMNNAME_M_Warehouse_ID + ", 0)" + ",bomQtyOnHand(" + COLUMNNAME_M_Product_ID + ", " + COLUMNNAME_M_Warehouse_ID + ", 0)" + " FROM " + Table_Name + " WHERE " + COLUMNNAME_PP_Order_BOMLine_ID + "=?";
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            pstmt = DB.prepareStatement(sql, get_TrxName());
            DB.setParameters(pstmt, new Object[] { get_ID() });
            rs = pstmt.executeQuery();
            if (rs.next()) {
                m_qtyAvailable = rs.getBigDecimal(1);
                m_qtyOnHand = rs.getBigDecimal(2);
            }
        } catch (SQLException e) {
            throw new DBException(e, sql);
        } finally {
            DB.close(rs, pstmt);
            rs = null;
            pstmt = null;
        }
    }

    /**
     * @return storage Available Qty
     */
    public BigDecimal getQtyAvailable() {
        loadStorage(false);
        return m_qtyAvailable;
    }

    /**
     * @return recorded Qty Usage Variance so far
     */
    public BigDecimal getQtyVariance() {
        final String whereClause = I_PP_Cost_Collector.COLUMNNAME_PP_Order_BOMLine_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_PP_Order_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_DocStatus + " IN (?,?)" + " AND " + I_PP_Cost_Collector.COLUMNNAME_CostCollectorType + "=?";
        BigDecimal qtyUsageVariance = new Query(getCtx(), I_PP_Cost_Collector.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Order_BOMLine_ID(), getPP_Order_ID(), X_PP_Cost_Collector.DOCSTATUS_Completed, X_PP_Cost_Collector.DOCSTATUS_Closed, X_PP_Cost_Collector.COSTCOLLECTORTYPE_UsegeVariance }).sum(I_PP_Cost_Collector.COLUMNNAME_MovementQty);
        return qtyUsageVariance;
    }

    /**
     * @return recorded Qty Method Change Variance so far
     */
    public BigDecimal getQtyMethodChangeVariance() {
        final String whereClause = I_PP_Cost_Collector.COLUMNNAME_PP_Order_BOMLine_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_PP_Order_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_DocStatus + " IN (?,?)" + " AND " + I_PP_Cost_Collector.COLUMNNAME_CostCollectorType + "=?";
        BigDecimal qtyMethodChangeVariance = new Query(getCtx(), I_PP_Cost_Collector.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Order_BOMLine_ID(), getPP_Order_ID(), X_PP_Cost_Collector.DOCSTATUS_Completed, X_PP_Cost_Collector.DOCSTATUS_Closed, X_PP_Cost_Collector.COSTCOLLECTORTYPE_MethodChangeVariance }).sum(I_PP_Cost_Collector.COLUMNNAME_MovementQty);
        return qtyMethodChangeVariance;
    }

    /**
     * @return storage Qty On Hand
     */
    public BigDecimal getQtyOnHand() {
        loadStorage(false);
        return m_qtyOnHand;
    }

    /**
     * @param componentTypes one or more component types
     * @return true of Component Type is any of following types
     */
    public boolean isComponentType(String... componentTypes) {
        String currentType = getComponentType();
        for (String type : componentTypes) {
            if (currentType.equals(type)) {
                return true;
            }
        }
        return false;
    }

    public boolean isCoProduct() {
        return isComponentType(COMPONENTTYPE_Co_Product);
    }

    public boolean isByProduct() {
        return isComponentType(COMPONENTTYPE_By_Product);
    }

    public boolean isComponent() {
        return isComponentType(COMPONENTTYPE_Component, COMPONENTTYPE_Packing);
    }

    /**
     *  	Add to Description
     * 	@param description text
     */

    // addDescription
    private void setDefault() {
        setDescription("");
        setQtyDelivered(Env.ZERO);
        setQtyPost(Env.ZERO);
        setQtyReject(Env.ZERO);
        setQtyRequired(Env.ZERO);
        setQtyReserved(Env.ZERO);
        setQtyScrap(Env.ZERO);
    }

    /**
     * Reserve Inventory for this BOM Line
     */
    public void reservedStock() {
        final int header_M_Warehouse_ID = getParent().getM_Warehouse_ID();
        // Check/set WH/Org
        if (// enforce WH
        header_M_Warehouse_ID != 0) {
            if (header_M_Warehouse_ID != getM_Warehouse_ID())
                setM_Warehouse_ID(header_M_Warehouse_ID);
            if (getAD_Org_ID() != getAD_Org_ID())
                setAD_Org_ID(getAD_Org_ID());
        }
        final BigDecimal target = getQtyRequired();
        final BigDecimal difference = target.subtract(getQtyReserved()).subtract(getQtyDelivered());
        log.fine("Line=" + getLine() + " - Target=" + target + ",Difference=" + difference + " - Requiered=" + getQtyRequired() + ",Reserved=" + getQtyReserved() + ",Delivered=" + getQtyDelivered());
        if (difference.signum() == 0) {
            return;
        }
        // Check Product - Stocked and Item
        MProduct product = getM_Product();
        if (!product.isStocked()) {
            return;
        }
        BigDecimal reserved = difference;
        // The Reserved Quantity is create in default location and ASI 0
        int locatorId = getM_Locator_ID();
        if (locatorId == 0)
            locatorId = getReservedLocatorId(reserved);
        // Update Storage
        if (!MStorage.add(getCtx(), getM_Warehouse_ID(), locatorId, getM_Product_ID(), getM_AttributeSetInstance_ID(), getM_AttributeSetInstance_ID(), Env.ZERO, reserved, Env.ZERO, get_TrxName())) {
            throw new AdempiereException();
        }
        // update line
        setQtyReserved(getQtyReserved().add(difference));
    }

    // reserveStock
    /**
     * @param qty
     * @return Storage locator for current product/asi/warehouse and qty
     * @see MStorage#getM_Locator_ID(int, int, int, BigDecimal, String)
     */
    private int getReservedLocatorId(BigDecimal qty) {
        MWarehouse warehouse = getM_Warehouse();
        int locatorId = 0;
        locatorId = getM_Product().getM_Locator_ID();
        if (locatorId != 0) {
            MLocator locator = new MLocator(getCtx(), locatorId, get_TrxName());
            // product has default locator defined but is not from the order warehouse
            if (locator.getM_Warehouse_ID() != warehouse.getM_Warehouse_ID()) {
                locatorId = warehouse.getDefaultLocator().getM_Locator_ID();
            }
        } else {
            locatorId = warehouse.getDefaultLocator().getM_Locator_ID();
        }
        return locatorId;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() + "[" + get_ID() + ", Product=" + getM_Product_ID() + ", ComponentType=" + getComponentType() + ",QtyBatch=" + getQtyBatch() + ",QtyRequired=" + getQtyRequired() + ",QtyScrap=" + getQtyScrap() + "]";
    }
}


public long add(long instant, int value) {
        return getDurationField().add(instant, value);
    }

package org.joda.time.field;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Locale;
import org.joda.time.DateTimeField;
import org.joda.time.DateTimeFieldType;
import org.joda.time.DurationField;
import org.joda.time.ReadablePartial;

/**
 * A placeholder implementation to use when a datetime field is not supported.
 * <p>
 * UnsupportedDateTimeField is thread-safe and immutable.
 *
 * @author Brian S O'Neill
 * @since 1.0
 */
public final class UnsupportedDateTimeField extends DateTimeField implements Serializable {

    /**
     * Serialilzation version
     */
    private static final long serialVersionUID = -1934618396111902255L;

    /**
     * The cache of unsupported datetime field instances
     */
    private static HashMap<DateTimeFieldType, UnsupportedDateTimeField> cCache;

    /**
     * Gets an instance of UnsupportedDateTimeField for a specific named field.
     * Names should be of standard format, such as 'monthOfYear' or 'hourOfDay'.
     * The returned instance is cached.
     *
     * @param type  the type to obtain
     * @return the instance
     * @throws IllegalArgumentException if durationField is null
     */
    public static synchronized UnsupportedDateTimeField getInstance(DateTimeFieldType type, DurationField durationField) {
        UnsupportedDateTimeField field;
        if (cCache == null) {
            cCache = new HashMap<DateTimeFieldType, UnsupportedDateTimeField>(7);
            field = null;
        } else {
            field = cCache.get(type);
            if (field != null && field.getDurationField() != durationField) {
                field = null;
            }
        }
        if (field == null) {
            field = new UnsupportedDateTimeField(type, durationField);
            cCache.put(type, field);
        }
        return field;
    }

    /**
     * The field type
     */
    private final DateTimeFieldType iType;

    /**
     * The duration of the datetime field
     */
    private final DurationField iDurationField;

    /**
     * Constructor.
     *
     * @param type  the field type
     * @param durationField  the duration to use
     */
    private UnsupportedDateTimeField(DateTimeFieldType type, DurationField durationField) {
        // start of generated patch
        if (type == null || durationField == null) {
            throw new IllegalArgumentException("The type must not be null");
        }
        // end of generated patch
        /* start of original code
        if (type == null || durationField == null) {
            throw new IllegalArgumentException();
        }
 end of original code*/
        iType = type;
        iDurationField = durationField;
    }

    // Design note: Simple accessors return a suitable value, but methods
    // intended to perform calculations throw an UnsupportedOperationException.
    public DateTimeFieldType getType() {
        return iType;
    }

    public String getName() {
        return iType.getName();
    }

    /**
     * This field is not supported.
     *
     * @return false always
     */
    public boolean isSupported() {
        return false;
    }

    /**
     * This field is not lenient.
     *
     * @return false always
     */
    public boolean isLenient() {
        return false;
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int get(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsText(long instant, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsText(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsText(ReadablePartial partial, int fieldValue, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsText(ReadablePartial partial, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsText(int fieldValue, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsShortText(long instant, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsShortText(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsShortText(ReadablePartial partial, int fieldValue, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsShortText(ReadablePartial partial, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public String getAsShortText(int fieldValue, Locale locale) {
        throw unsupported();
    }

    /**
     * Delegates to the duration field.
     *
     * @throws UnsupportedOperationException if the duration is unsupported
     */

    /**
     * Delegates to the duration field.
     *
     * @throws UnsupportedOperationException if the duration is unsupported
     */
    public long add(long instant, long value) {
        return getDurationField().add(instant, value);
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int[] add(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int[] addWrapPartial(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long addWrapField(long instant, int value) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) {
        throw unsupported();
    }

    /**
     * Delegates to the duration field.
     *
     * @throws UnsupportedOperationException if the duration is unsupported
     */
    public int getDifference(long minuendInstant, long subtrahendInstant) {
        return getDurationField().getDifference(minuendInstant, subtrahendInstant);
    }

    /**
     * Delegates to the duration field.
     *
     * @throws UnsupportedOperationException if the duration is unsupported
     */
    public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) {
        return getDurationField().getDifferenceAsLong(minuendInstant, subtrahendInstant);
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long set(long instant, int value) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int[] set(ReadablePartial instant, int fieldIndex, int[] values, int newValue) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long set(long instant, String text, Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long set(long instant, String text) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int[] set(ReadablePartial instant, int fieldIndex, int[] values, String text, Locale locale) {
        throw unsupported();
    }

    /**
     * Even though this DateTimeField is unsupported, the duration field might
     * be supported.
     *
     * @return a possibly supported DurationField
     */
    public DurationField getDurationField() {
        return iDurationField;
    }

    public DurationField getRangeDurationField() {
        return null;
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public boolean isLeap(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getLeapAmount(long instant) {
        throw unsupported();
    }

    public DurationField getLeapDurationField() {
        return null;
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMinimumValue() {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMinimumValue(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMinimumValue(ReadablePartial instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMinimumValue(ReadablePartial instant, int[] values) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumValue() {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumValue(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumValue(ReadablePartial instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumValue(ReadablePartial instant, int[] values) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumTextLength(Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public int getMaximumShortTextLength(Locale locale) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long roundFloor(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long roundCeiling(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long roundHalfFloor(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long roundHalfCeiling(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long roundHalfEven(long instant) {
        throw unsupported();
    }

    /**
     * Always throws UnsupportedOperationException
     *
     * @throws UnsupportedOperationException
     */
    public long remainder(long instant) {
        throw unsupported();
    }

    /**
     * Get a suitable debug string.
     *
     * @return debug string
     */
    public String toString() {
        return "UnsupportedDateTimeField";
    }

    /**
     * Ensure proper singleton serialization
     */
    private Object readResolve() {
        return getInstance(iType, iDurationField);
    }

    private UnsupportedOperationException unsupported() {
        return new UnsupportedOperationException(iType + " field is unsupported");
    }
}


@Override
    public AAction duplicate() {
        MouseHoverAction newAction = new MouseHoverAction();
        newAction.copyState(this);
        return newAction;
    }

/**
 * ****************************************************************************
 *  CogTool Copyright Notice and Distribution Terms
 *
 *  CogTool is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  CogTool 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CogTool; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  CogTool makes use of several third-party components, with the
 *  following notices:
 *
 *  Eclipse SWT version 3.448
 *  Eclipse GEF Draw2D version 3.2.1
 *
 *  Unless otherwise indicated, all Content made available by the Eclipse
 *
 *  CLISP version 2.38
 *
 *  See COPYRIGHT file in clisp installation folder for more information.
 *
 *  ACT-R 6.0
 *
 *  Apache Jakarta Commons-Lang 2.1
 *
 *  This product contains software developed by the Apache Software Foundation
 *  (http://example.com)
 *
 *  jopt-simple version 1.0
 *
 *  Mozilla XULRunner 1.9.0.5
 *
 *  rights reserved. U.S.
 *  See the LICENSE file in the jre folder for more information.
 * ****************************************************************************
 */
/**
 * DEPRECATED!  KEPT ONLY TO SUPPORT LOADING OLD .cgt FILES!
 */
package edu.cmu.cs.hcii.cogtool.model;

import org.apache.commons.lang.builder.HashCodeBuilder;
import edu.cmu.cs.hcii.cogtool.util.L10N;
import edu.cmu.cs.hcii.cogtool.util.ObjectLoader;
import edu.cmu.cs.hcii.cogtool.util.ObjectSaver;

/**
 * @author alexeiser
 */
public class MouseHoverAction extends AAction {

    public static final int edu_cmu_cs_hcii_cogtool_model_MouseHoverAction_version = 0;

    private int myHashCode = hashCode();

    private static ObjectSaver.IDataSaver<MouseHoverAction> SAVER = new ObjectSaver.ADataSaver<MouseHoverAction>() {

        @Override
        public int getVersion() {
            return edu_cmu_cs_hcii_cogtool_model_MouseHoverAction_version;
        }

        @Override
        public void saveData(MouseHoverAction v, ObjectSaver saver) throws java.io.IOException {
        }
    };

    public static void registerSaver() {
        ObjectSaver.registerSaver(MouseHoverAction.class.getName(), SAVER);
    }

    private static ObjectLoader.IObjectLoader<AAction> LOADER = new ObjectLoader.AObjectLoader<AAction>() {

        @Override
        public AAction createObject(ObjectLoader l) {
            // No longer return MouseHoverAction; determine what to
            // return based on whether there is a containing Design
            // and whether that design contains a Mouse device type.
            Design d = l.getPendingObject(Design.class);
            if ((d == null) || d.getDeviceTypes().contains(DeviceType.Mouse)) {
                return new ButtonAction(null, MousePressType.Hover, AAction.NONE);
            }
            return new TapAction(TapPressType.Hover);
        }
    };

    public static void registerLoader() {
        ObjectLoader.registerLoader(MouseHoverAction.class.getName(), edu_cmu_cs_hcii_cogtool_model_MouseHoverAction_version, LOADER);
    }

    private MouseHoverAction() {
        super(ActionType.MouseOver);
    }

    public MouseOverType getMouseOverType() {
        return MouseOverType.Hover;
    }

    // Currently, the only constant is Hover; ignore for now
    public void setMouseOverType(MouseOverType t) {
    }

    /**
     * Create a copy of this action.
     * <p>
     * It is the responsibility of the caller to "place" the copy
     * (usually by setting it as the action of an Transition).
     *
     * @return the action copy
     * @author mlh
     */

    @Override
    public void accept(AAction.ActionVisitor visitor) {
    }

    @Override
    public String getLocalizedString() {
        return L10N.get("MHA.MouseHover", "Mouse Hover");
    }

    /**
     * Indicate that this action does require a widget target
     */
    @Override
    public boolean requiresTarget() {
        return true;
    }

    // Actions must implement equals and hashCode
    @Override
    public boolean equals(Object other) {
        return (other != null) && (other.getClass() == MouseHoverAction.class) && valueEquals((MouseHoverAction) other);
    }

    @Override
    public int hashCode() {
        if (myHashCode == 0) {
            // Must have a unique ODD number for each class which uses
            myHashCode = new HashCodeBuilder(53657, 9331).appendSuper(super.hashCode()).toHashCode();
        }
        return myHashCode;
    }
}


for (int i = 1; i <= size; i++) {
                TreeNode x = queue.poll();
                if (x.left != null) {
                    queue.offer(x.left);
                }
                if (x.right != null) {
                    queue.offer(x.right);
                }
            }

/**
 * @author Farheen Bano
 *
 * Reference-
 * http://example.com
 */
import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {

    public int findBottomLeftValue(TreeNode root) {
        int result = -1;
        if (root == null)
            return result;
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        while (!queue.isEmpty()) {
            result = queue.peek().val;
            int size = queue.size();

        }
        return result;
    }
}


while (!queue.isEmpty()) {
            result = queue.peek().val;
            int size = queue.size();
            for (int i = 1; i <= size; i++) {
                TreeNode x = queue.poll();
                if (x.left != null) {
                    queue.offer(x.left);
                }
                if (x.right != null) {
                    queue.offer(x.right);
                }
            }
        }

/**
 * @author Farheen Bano
 *
 * Reference-
 * http://example.com
 */
import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {

    public int findBottomLeftValue(TreeNode root) {
        int result = -1;
        if (root == null)
            return result;
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);


public void setScaleinParams(VsScaleinParams scaleinParams) {
        this.scaleinParams = scaleinParams;
    }

package com.vmware.avi.sdk.model;

import java.util.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * The SeUpgradeScaleinEventDetails is a POJO class extends AviRestResource that used for creating
 * SeUpgradeScaleinEventDetails.
 *
 * @version 1.0
 * @since
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SeUpgradeScaleinEventDetails {

    @JsonProperty("scalein_params")
    private VsScaleinParams scaleinParams = null;

    @JsonProperty("vs_uuid")
    private String vsUuid = null;

    /**
     * This is the getter method this will return the attribute value.
     * Placeholder for description of property scalein_params of obj type seupgradescaleineventdetails field type str  type ref.
     * Default value when not specified in API or module is interpreted by Avi Controller as null.
     * @return scaleinParams
     */
    public VsScaleinParams getScaleinParams() {
        return scaleinParams;
    }

    /**
     * This is the setter method to the attribute.
     * Placeholder for description of property scalein_params of obj type seupgradescaleineventdetails field type str  type ref.
     * Default value when not specified in API or module is interpreted by Avi Controller as null.
     * @param scaleinParams set the scaleinParams.
     */

    /**
     * This is the getter method this will return the attribute value.
     * Unique object identifier of vs.
     * Default value when not specified in API or module is interpreted by Avi Controller as null.
     * @return vsUuid
     */
    public String getVsUuid() {
        return vsUuid;
    }

    /**
     * This is the setter method to the attribute.
     * Unique object identifier of vs.
     * Default value when not specified in API or module is interpreted by Avi Controller as null.
     * @param vsUuid set the vsUuid.
     */
    public void setVsUuid(String vsUuid) {
        this.vsUuid = vsUuid;
    }

    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SeUpgradeScaleinEventDetails objSeUpgradeScaleinEventDetails = (SeUpgradeScaleinEventDetails) o;
        return Objects.equals(this.vsUuid, objSeUpgradeScaleinEventDetails.vsUuid) && Objects.equals(this.scaleinParams, objSeUpgradeScaleinEventDetails.scaleinParams);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class SeUpgradeScaleinEventDetails {\n");
        sb.append("    scaleinParams: ").append(toIndentedString(scaleinParams)).append("\n");
        sb.append("    vsUuid: ").append(toIndentedString(vsUuid)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(java.lang.Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}


for (int j = 0; deployPolicyBeans != null && j < deployPolicyBeans.size(); j++) {
                DeployPolicyBean pro = deployPolicyBeans.get(j);
                if (pro.getUpgradeCallback() != null) {
                    pro.getUpgradeCallback().delete(procdef);
                }
            }

package org.activiti.engine.impl.db.upgrade;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.cfg.BeansConfigurationHelper;
import org.activiti.engine.repository.Deployment;
import org.frameworkset.spi.BaseApplicationContext;
import org.frameworkset.spi.assemble.Pro;
import org.frameworkset.spi.assemble.ProList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.frameworkset.common.poolman.ConfigSQLExecutor;
import com.frameworkset.common.poolman.Record;
import com.frameworkset.common.poolman.SQLExecutor;
import com.frameworkset.common.poolman.handle.RowHandler;
import com.frameworkset.orm.transaction.TransactionManager;

/**
 *
Title: InstanceUpgrade.java

 *
 *
Description: 流程实例和任务升级组件

 *
 *
bboss workgroup

 * @Date 2013-6-13
 * @author biaoping.yin
 * @version 1.0
 */
public class InstanceUpgrade {

    private ConfigSQLExecutor executor;

    private TaskService taskService;

    private RuntimeService runtimeService;

    private List<DeployPolicyBean> deployPolicyBeans;

    private static Logger log = LoggerFactory.getLogger(InstanceUpgrade.class);

    /**
     * 流程实例版本升级
     * @param processKey 要升级的流程
     * @param oldversions 旧的流程实例版本 号数组
     * @param toversion 要升级到的流程版本号
     * @throws Exception
     */
    public void upgradeInstances(String processKey) throws Exception {
        TransactionManager tm = new TransactionManager();
        try {
            tm.begin();
            HashMap procdef = executor.queryObjectByRowHandler(new RowHandler<HashMap>() {

                @Override
                public void handleRow(HashMap arg0, Record arg1) throws Exception {
                    arg0.put("ID_", arg1.getString("ID_"));
                    arg0.put("KEY_", arg1.getString("KEY_"));
                    arg0.put("VERSION_", arg1.getInt("VERSION_"));
                    arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
                }
            }, HashMap.class, "queryLastVersionProcdefByKey", processKey);
            _upgradeProcessInstances(procdef);
            tm.commit();
        } finally {
            tm.release();
        }
    }

    private void _upgradeProcessInstances(HashMap procdef) throws Exception {
        String KEY_ = (String) procdef.get("KEY_");
        int ver = (Integer) procdef.get("VERSION_");
        String DEPLOYMENT_ID_ = (String) procdef.get("DEPLOYMENT_ID_");
        String ID_ = (String) procdef.get("ID_");
        executor.update("updateRunTasks", ID_, KEY_, ver);
        executor.update("updateExecutes", ID_, KEY_, ver);
        executor.update("updateJobs", ID_, KEY_, ver);
        executor.update("updateIdentitylinks", ID_, KEY_, ver);
        executor.update("updateTaskinsts", ID_, KEY_, ver);
        executor.update("updateProcinsts", ID_, KEY_, ver);
        executor.update("updateActinsts", ID_, KEY_, ver);
        String likekey = KEY_ + ":%";
        // 更新业务表中记录的流程定义id的记录为最新版本
        for (int j = 0; deployPolicyBeans != null && j < deployPolicyBeans.size(); j++) {
            DeployPolicyBean pro = deployPolicyBeans.get(j);
            if (pro.getUpdatesql() != null) {
                SQLExecutor.update(pro.getUpdatesql(), ID_, likekey);
            }
            if (pro.getUpgradeCallback() != null) {
                pro.getUpgradeCallback().update(procdef);
            }
        }
    }

    /**
     * 升级对应部署包中对应的流程旧版本任务实例
     * @param deployment
     * @throws Exception
     */
    public void instanceUpgrade(Deployment deployment) throws Exception {
        String deploymentId = deployment.getId();
        List<HashMap> procdefs = executor.queryListByRowHandler(new RowHandler<HashMap>() {

            @Override
            public void handleRow(HashMap arg0, Record arg1) throws Exception {
                arg0.put("ID_", arg1.getString("ID_"));
                arg0.put("KEY_", arg1.getString("KEY_"));
                arg0.put("VERSION_", arg1.getInt("VERSION_"));
                arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
            }
        }, HashMap.class, "queryProcdefsByDeployment", deploymentId);
        for (int i = 0; procdefs != null && i < procdefs.size(); i++) {
            HashMap procdef = procdefs.get(i);
            _upgradeProcessInstances(procdef);
        }
        /**
         *  act_ru_task
         * act_ru_job
         * act_ru_identitylink
         * act_ru_execution
         * act_hi_taskinst
         * act_hi_procinst
         * act_hi_actinst
         */
    }

    /**
     * 删除应部署包中对应的流程旧版本任务实例,删除其实采用的是
     * @param deployment
     */
    public void instanceDelete(Deployment deployment) throws Exception {
        String deploymentId = deployment.getId();
        List<HashMap> procdefs = executor.queryListByRowHandler(new RowHandler<HashMap>() {

            @Override
            public void handleRow(HashMap arg0, Record arg1) throws Exception {
                arg0.put("ID_", arg1.getString("ID_"));
                arg0.put("KEY_", arg1.getString("KEY_"));
                arg0.put("VERSION_", arg1.getInt("VERSION_"));
                arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
            }
        }, HashMap.class, "queryProcdefsByDeployment", deploymentId);
        for (int i = 0; procdefs != null && i < procdefs.size(); i++) {
            HashMap procdef = procdefs.get(i);
            String KEY_ = (String) procdef.get("KEY_");
            int ver = (Integer) procdef.get("VERSION_");
            String DEPLOYMENT_ID_ = (String) procdef.get("DEPLOYMENT_ID_");
            String ID_ = (String) procdef.get("ID_");
            List<HashMap> procinsts = executor.queryList(HashMap.class, "queryProcinsts", KEY_, ver);
            for (int j = 0; procinsts != null && j < procinsts.size(); j++) {
                HashMap procinst = procinsts.get(j);
                runtimeService.deleteProcessInstance((String) procinst.get("PROC_INST_ID_"), "流程部署" + deployment.getName() + "使用删除历史版本未完成任务策略.", "部署删除", "部署流程时选择删除旧版本实例");
            }

        }
    }

    public ConfigSQLExecutor getExecutor() {
        return executor;
    }

    public void setExecutor(ConfigSQLExecutor executor) {
        this.executor = executor;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }

    public void setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
    }

    public void init() {
        BaseApplicationContext context = BeansConfigurationHelper.getConfigBeanFactory();
        deployPolicyBeans = new ArrayList<DeployPolicyBean>();
        ProList proList = null;
        try {
            proList = context.getListProperty("deployPolicy");
        } catch (Exception e1) {
            log.error("流程配置文件部署策略配置信息加载失败：", e1);
        }
        StringBuffer sql = new StringBuffer();
        for (int j = 0; proList != null && j < proList.size(); j++) {
            DeployPolicyBean policyBean = new DeployPolicyBean();
            Pro pro = (Pro) proList.get(j);
            String table = pro.getStringExtendAttribute("table");
            policyBean.setTable(table);
            String processdefcolumn = pro.getStringExtendAttribute("processdefcolumn");
            policyBean.setProdefcolumn(processdefcolumn);
            if (table != null && processdefcolumn != null) {
                sql.append("update ").append(table).append(" set ").append(processdefcolumn).append("=?").append(" where ").append(processdefcolumn).append(" like ?");
                policyBean.setUpdatesql(sql.toString());
                sql.setLength(0);
            }
            String callback = pro.getStringExtendAttribute("upgradecallback");
            if (callback != null) {
                try {
                    Class<UpgradeCallback> clazz = (Class<UpgradeCallback>) Class.forName(callback);
                    UpgradeCallback upgradeCallback = clazz.newInstance();
                    policyBean.setUpgradeCallback(upgradeCallback);
                } catch (Exception e) {
                    log.error("", e);
                }
            }
            deployPolicyBeans.add(policyBean);
        }
    }
}


try {
                    Class<UpgradeCallback> clazz = (Class<UpgradeCallback>) Class.forName(callback);
                    UpgradeCallback upgradeCallback = clazz.newInstance();
                    policyBean.setUpgradeCallback(upgradeCallback);
                } catch (Exception e) {
                    log.error("", e);
                }

package org.activiti.engine.impl.db.upgrade;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.cfg.BeansConfigurationHelper;
import org.activiti.engine.repository.Deployment;
import org.frameworkset.spi.BaseApplicationContext;
import org.frameworkset.spi.assemble.Pro;
import org.frameworkset.spi.assemble.ProList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.frameworkset.common.poolman.ConfigSQLExecutor;
import com.frameworkset.common.poolman.Record;
import com.frameworkset.common.poolman.SQLExecutor;
import com.frameworkset.common.poolman.handle.RowHandler;
import com.frameworkset.orm.transaction.TransactionManager;

/**
 *
Title: InstanceUpgrade.java

 *
 *
Description: 流程实例和任务升级组件

 *
 *
bboss workgroup

 * @Date 2013-6-13
 * @author biaoping.yin
 * @version 1.0
 */
public class InstanceUpgrade {

    private ConfigSQLExecutor executor;

    private TaskService taskService;

    private RuntimeService runtimeService;

    private List<DeployPolicyBean> deployPolicyBeans;

    private static Logger log = LoggerFactory.getLogger(InstanceUpgrade.class);

    /**
     * 流程实例版本升级
     * @param processKey 要升级的流程
     * @param oldversions 旧的流程实例版本 号数组
     * @param toversion 要升级到的流程版本号
     * @throws Exception
     */
    public void upgradeInstances(String processKey) throws Exception {
        TransactionManager tm = new TransactionManager();
        try {
            tm.begin();
            HashMap procdef = executor.queryObjectByRowHandler(new RowHandler<HashMap>() {

                @Override
                public void handleRow(HashMap arg0, Record arg1) throws Exception {
                    arg0.put("ID_", arg1.getString("ID_"));
                    arg0.put("KEY_", arg1.getString("KEY_"));
                    arg0.put("VERSION_", arg1.getInt("VERSION_"));
                    arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
                }
            }, HashMap.class, "queryLastVersionProcdefByKey", processKey);
            _upgradeProcessInstances(procdef);
            tm.commit();
        } finally {
            tm.release();
        }
    }

    private void _upgradeProcessInstances(HashMap procdef) throws Exception {
        String KEY_ = (String) procdef.get("KEY_");
        int ver = (Integer) procdef.get("VERSION_");
        String DEPLOYMENT_ID_ = (String) procdef.get("DEPLOYMENT_ID_");
        String ID_ = (String) procdef.get("ID_");
        executor.update("updateRunTasks", ID_, KEY_, ver);
        executor.update("updateExecutes", ID_, KEY_, ver);
        executor.update("updateJobs", ID_, KEY_, ver);
        executor.update("updateIdentitylinks", ID_, KEY_, ver);
        executor.update("updateTaskinsts", ID_, KEY_, ver);
        executor.update("updateProcinsts", ID_, KEY_, ver);
        executor.update("updateActinsts", ID_, KEY_, ver);
        String likekey = KEY_ + ":%";
        // 更新业务表中记录的流程定义id的记录为最新版本
        for (int j = 0; deployPolicyBeans != null && j < deployPolicyBeans.size(); j++) {
            DeployPolicyBean pro = deployPolicyBeans.get(j);
            if (pro.getUpdatesql() != null) {
                SQLExecutor.update(pro.getUpdatesql(), ID_, likekey);
            }
            if (pro.getUpgradeCallback() != null) {
                pro.getUpgradeCallback().update(procdef);
            }
        }
    }

    /**
     * 升级对应部署包中对应的流程旧版本任务实例
     * @param deployment
     * @throws Exception
     */
    public void instanceUpgrade(Deployment deployment) throws Exception {
        String deploymentId = deployment.getId();
        List<HashMap> procdefs = executor.queryListByRowHandler(new RowHandler<HashMap>() {

            @Override
            public void handleRow(HashMap arg0, Record arg1) throws Exception {
                arg0.put("ID_", arg1.getString("ID_"));
                arg0.put("KEY_", arg1.getString("KEY_"));
                arg0.put("VERSION_", arg1.getInt("VERSION_"));
                arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
            }
        }, HashMap.class, "queryProcdefsByDeployment", deploymentId);
        for (int i = 0; procdefs != null && i < procdefs.size(); i++) {
            HashMap procdef = procdefs.get(i);
            _upgradeProcessInstances(procdef);
        }
        /**
         *  act_ru_task
         * act_ru_job
         * act_ru_identitylink
         * act_ru_execution
         * act_hi_taskinst
         * act_hi_procinst
         * act_hi_actinst
         */
    }

    /**
     * 删除应部署包中对应的流程旧版本任务实例,删除其实采用的是
     * @param deployment
     */
    public void instanceDelete(Deployment deployment) throws Exception {
        String deploymentId = deployment.getId();
        List<HashMap> procdefs = executor.queryListByRowHandler(new RowHandler<HashMap>() {

            @Override
            public void handleRow(HashMap arg0, Record arg1) throws Exception {
                arg0.put("ID_", arg1.getString("ID_"));
                arg0.put("KEY_", arg1.getString("KEY_"));
                arg0.put("VERSION_", arg1.getInt("VERSION_"));
                arg0.put("DEPLOYMENT_ID_", arg1.getString("DEPLOYMENT_ID_"));
            }
        }, HashMap.class, "queryProcdefsByDeployment", deploymentId);
        for (int i = 0; procdefs != null && i < procdefs.size(); i++) {
            HashMap procdef = procdefs.get(i);
            String KEY_ = (String) procdef.get("KEY_");
            int ver = (Integer) procdef.get("VERSION_");
            String DEPLOYMENT_ID_ = (String) procdef.get("DEPLOYMENT_ID_");
            String ID_ = (String) procdef.get("ID_");
            List<HashMap> procinsts = executor.queryList(HashMap.class, "queryProcinsts", KEY_, ver);
            for (int j = 0; procinsts != null && j < procinsts.size(); j++) {
                HashMap procinst = procinsts.get(j);
                runtimeService.deleteProcessInstance((String) procinst.get("PROC_INST_ID_"), "流程部署" + deployment.getName() + "使用删除历史版本未完成任务策略.", "部署删除", "部署流程时选择删除旧版本实例");
            }
            for (int j = 0; deployPolicyBeans != null && j < deployPolicyBeans.size(); j++) {
                DeployPolicyBean pro = deployPolicyBeans.get(j);
                if (pro.getUpgradeCallback() != null) {
                    pro.getUpgradeCallback().delete(procdef);
                }
            }
        }
    }

    public ConfigSQLExecutor getExecutor() {
        return executor;
    }

    public void setExecutor(ConfigSQLExecutor executor) {
        this.executor = executor;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }

    public void setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
    }

    public void init() {
        BaseApplicationContext context = BeansConfigurationHelper.getConfigBeanFactory();
        deployPolicyBeans = new ArrayList<DeployPolicyBean>();
        ProList proList = null;
        try {
            proList = context.getListProperty("deployPolicy");
        } catch (Exception e1) {
            log.error("流程配置文件部署策略配置信息加载失败：", e1);
        }
        StringBuffer sql = new StringBuffer();
        for (int j = 0; proList != null && j < proList.size(); j++) {
            DeployPolicyBean policyBean = new DeployPolicyBean();
            Pro pro = (Pro) proList.get(j);
            String table = pro.getStringExtendAttribute("table");
            policyBean.setTable(table);
            String processdefcolumn = pro.getStringExtendAttribute("processdefcolumn");
            policyBean.setProdefcolumn(processdefcolumn);
            if (table != null && processdefcolumn != null) {
                sql.append("update ").append(table).append(" set ").append(processdefcolumn).append("=?").append(" where ").append(processdefcolumn).append(" like ?");
                policyBean.setUpdatesql(sql.toString());
                sql.setLength(0);
            }
            String callback = pro.getStringExtendAttribute("upgradecallback");
            if (callback != null) {

            }
            deployPolicyBeans.add(policyBean);
        }
    }
}


for (int x = 0; x < Chunk.BLOCKS.SIZE; x++) {
            for (int z = 0; z < Chunk.BLOCKS.SIZE; z++) {
                heights[x][z] = height;
            }
        }

/*
 * This file is part of Vanilla.
 *
 *
 * License and see <http://example.com> for the full license, including
 */
package org.spout.vanilla.world.generator.nether;

import java.util.Random;
import net.royawesome.jlibnoise.NoiseQuality;
import net.royawesome.jlibnoise.module.modifier.ScalePoint;
import net.royawesome.jlibnoise.module.source.Perlin;
import org.spout.api.generator.WorldGeneratorUtils;
import org.spout.api.generator.biome.BiomeManager;
import org.spout.api.generator.biome.BiomePopulator;
import org.spout.api.geo.World;
import org.spout.api.geo.cuboid.Chunk;
import org.spout.api.geo.discrete.Point;
import org.spout.api.util.cuboid.CuboidBlockMaterialBuffer;
import org.spout.math.vector.Vector3f;
import org.spout.vanilla.component.entity.player.VanillaPlayerNetworkComponent;
import org.spout.vanilla.material.VanillaMaterials;
import org.spout.vanilla.material.block.Liquid;
import org.spout.vanilla.world.generator.biome.VanillaBiomes;
import org.spout.vanilla.world.generator.biome.VanillaSingleBiomeGenerator;
import org.spout.vanilla.world.generator.nether.populator.BlockPatchPopulator;
import org.spout.vanilla.world.generator.nether.populator.FortressPopulator;
import org.spout.vanilla.world.generator.nether.populator.NetherCavePopulator;
import org.spout.vanilla.world.generator.normal.populator.BedrockBoundPopulator;
import org.spout.vanilla.world.generator.normal.populator.BedrockBoundPopulator.BedrockBound;

public class NetherGenerator extends VanillaSingleBiomeGenerator {

    // numeric constants
    public static final int HEIGHT = 128;

    public static final int SEA_LEVEL = 31;

    private static final byte BEDROCK_DEPTH = 4;

    // noise for generation
    private static final Perlin PERLIN = new Perlin();

    private static final ScalePoint NOISE = new ScalePoint();

    // smooth stuff
    private static final int SMOOTH_HEIGHT = 16;

    private static final int LOW_SMOOTH_START = BEDROCK_DEPTH + SMOOTH_HEIGHT;

    private static final int HIGH_SMOOTH_START = HEIGHT - 1 - BEDROCK_DEPTH - SMOOTH_HEIGHT;

    static {
        PERLIN.setFrequency(0.01);
        PERLIN.setLacunarity(2);
        PERLIN.setNoiseQuality(NoiseQuality.BEST);
        PERLIN.setPersistence(0.5);
        PERLIN.setOctaveCount(16);
        NOISE.SetSourceModule(0, PERLIN);
        NOISE.setxScale(0.5);
        NOISE.setyScale(1);
        NOISE.setzScale(0.5);
    }

    public NetherGenerator() {
        super(VanillaBiomes.NETHERRACK);
    }

    @Override
    public void registerBiomes() {
        super.registerBiomes();
        register(VanillaBiomes.NETHERRACK);
        final BedrockBoundPopulator bedrock = new BedrockBoundPopulator();
        bedrock.addBound(0, 1, BEDROCK_DEPTH);
        final BedrockBound top = new BedrockBound(HEIGHT - BEDROCK_DEPTH, 1, BEDROCK_DEPTH);
        top.setFlipped(true);
        bedrock.addBound(top);
        addGeneratorPopulators(bedrock, new NetherCavePopulator(), new BlockPatchPopulator(VanillaMaterials.SOUL_SAND), new BlockPatchPopulator(VanillaMaterials.GRAVEL));
        addPopulators(new FortressPopulator(), new BiomePopulator());
    }

    @Override
    public String getName() {
        return "VanillaNether";
    }

    @Override
    protected void generateTerrain(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomeManager, long seed) {
        PERLIN.setSeed((int) seed * 17);
        final Vector3f size = blockData.getSize();
        final int sizeX = size.getFloorX();
        final int sizeY = Math.min(size.getFloorY(), HEIGHT);
        final int sizeZ = size.getFloorZ();
        final double[][][] noise = WorldGeneratorUtils.fastNoise(NOISE, sizeX, sizeY, sizeZ, 4, x, y, z);
        for (int xx = 0; xx < sizeX; xx++) {
            for (int zz = 0; zz < sizeZ; zz++) {
                for (int yy = 0; yy < sizeY; yy++) {
                    double value = noise[xx][yy][zz];
                    if (SMOOTH_HEIGHT > 0) {
                        if (yy + y < LOW_SMOOTH_START) {
                            value -= cubic(1d / SMOOTH_HEIGHT * (y + yy - LOW_SMOOTH_START));
                        } else if (yy + y > HIGH_SMOOTH_START) {
                            value += cubic(1d / SMOOTH_HEIGHT * (y + yy - HIGH_SMOOTH_START));
                        }
                    }
                    if (value >= 0) {
                        blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.NETHERRACK);
                    } else {
                        if (y + yy <= SEA_LEVEL) {
                            blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.STATIONARY_LAVA);
                        } else {
                            blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.AIR);
                        }
                    }
                }
            }
        }
    }

    private static double cubic(double x) {
        return x * x * x;
    }

    @Override
    public Point getSafeSpawn(World world) {
        final Random random = new Random();
        for (byte attempts = 0; attempts < 32; attempts++) {
            final int x = random.nextInt(256) - 127;
            final int z = random.nextInt(256) - 127;
            final int y = getHighestSolidBlock(world, x, z);
            if (y != -1) {
                return new Point(world, x, y + 0.5f, z);
            }
        }
        return new Point(world, 0, 80, 0);
    }

    private int getHighestSolidBlock(World world, int x, int z) {
        int y = HEIGHT / 2;
        if (!world.getBlockMaterial(x, y, z).isInvisible()) {
            return -1;
        }
        while (world.getBlockMaterial(x, y, z).isInvisible()) {
            if (--y == 0 || world.getBlockMaterial(x, y, z) instanceof Liquid) {
                return -1;
            }
        }
        return ++y;
    }

    @Override
    public int[][] getSurfaceHeight(World world, int chunkX, int chunkZ) {
        int height = VanillaPlayerNetworkComponent.WORLD_HEIGHT - 1;
        int[][] heights = new int[Chunk.BLOCKS.SIZE][Chunk.BLOCKS.SIZE];


while (world.getBlockMaterial(x, y, z).isInvisible()) {
            if (--y == 0 || world.getBlockMaterial(x, y, z) instanceof Liquid) {
                return -1;
            }
        }

/*
 * This file is part of Vanilla.
 *
 *
 * License and see <http://example.com> for the full license, including
 */
package org.spout.vanilla.world.generator.nether;

import java.util.Random;
import net.royawesome.jlibnoise.NoiseQuality;
import net.royawesome.jlibnoise.module.modifier.ScalePoint;
import net.royawesome.jlibnoise.module.source.Perlin;
import org.spout.api.generator.WorldGeneratorUtils;
import org.spout.api.generator.biome.BiomeManager;
import org.spout.api.generator.biome.BiomePopulator;
import org.spout.api.geo.World;
import org.spout.api.geo.cuboid.Chunk;
import org.spout.api.geo.discrete.Point;
import org.spout.api.util.cuboid.CuboidBlockMaterialBuffer;
import org.spout.math.vector.Vector3f;
import org.spout.vanilla.component.entity.player.VanillaPlayerNetworkComponent;
import org.spout.vanilla.material.VanillaMaterials;
import org.spout.vanilla.material.block.Liquid;
import org.spout.vanilla.world.generator.biome.VanillaBiomes;
import org.spout.vanilla.world.generator.biome.VanillaSingleBiomeGenerator;
import org.spout.vanilla.world.generator.nether.populator.BlockPatchPopulator;
import org.spout.vanilla.world.generator.nether.populator.FortressPopulator;
import org.spout.vanilla.world.generator.nether.populator.NetherCavePopulator;
import org.spout.vanilla.world.generator.normal.populator.BedrockBoundPopulator;
import org.spout.vanilla.world.generator.normal.populator.BedrockBoundPopulator.BedrockBound;

public class NetherGenerator extends VanillaSingleBiomeGenerator {

    // numeric constants
    public static final int HEIGHT = 128;

    public static final int SEA_LEVEL = 31;

    private static final byte BEDROCK_DEPTH = 4;

    // noise for generation
    private static final Perlin PERLIN = new Perlin();

    private static final ScalePoint NOISE = new ScalePoint();

    // smooth stuff
    private static final int SMOOTH_HEIGHT = 16;

    private static final int LOW_SMOOTH_START = BEDROCK_DEPTH + SMOOTH_HEIGHT;

    private static final int HIGH_SMOOTH_START = HEIGHT - 1 - BEDROCK_DEPTH - SMOOTH_HEIGHT;

    static {
        PERLIN.setFrequency(0.01);
        PERLIN.setLacunarity(2);
        PERLIN.setNoiseQuality(NoiseQuality.BEST);
        PERLIN.setPersistence(0.5);
        PERLIN.setOctaveCount(16);
        NOISE.SetSourceModule(0, PERLIN);
        NOISE.setxScale(0.5);
        NOISE.setyScale(1);
        NOISE.setzScale(0.5);
    }

    public NetherGenerator() {
        super(VanillaBiomes.NETHERRACK);
    }

    @Override
    public void registerBiomes() {
        super.registerBiomes();
        register(VanillaBiomes.NETHERRACK);
        final BedrockBoundPopulator bedrock = new BedrockBoundPopulator();
        bedrock.addBound(0, 1, BEDROCK_DEPTH);
        final BedrockBound top = new BedrockBound(HEIGHT - BEDROCK_DEPTH, 1, BEDROCK_DEPTH);
        top.setFlipped(true);
        bedrock.addBound(top);
        addGeneratorPopulators(bedrock, new NetherCavePopulator(), new BlockPatchPopulator(VanillaMaterials.SOUL_SAND), new BlockPatchPopulator(VanillaMaterials.GRAVEL));
        addPopulators(new FortressPopulator(), new BiomePopulator());
    }

    @Override
    public String getName() {
        return "VanillaNether";
    }

    @Override
    protected void generateTerrain(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomeManager, long seed) {
        PERLIN.setSeed((int) seed * 17);
        final Vector3f size = blockData.getSize();
        final int sizeX = size.getFloorX();
        final int sizeY = Math.min(size.getFloorY(), HEIGHT);
        final int sizeZ = size.getFloorZ();
        final double[][][] noise = WorldGeneratorUtils.fastNoise(NOISE, sizeX, sizeY, sizeZ, 4, x, y, z);
        for (int xx = 0; xx < sizeX; xx++) {
            for (int zz = 0; zz < sizeZ; zz++) {
                for (int yy = 0; yy < sizeY; yy++) {
                    double value = noise[xx][yy][zz];
                    if (SMOOTH_HEIGHT > 0) {
                        if (yy + y < LOW_SMOOTH_START) {
                            value -= cubic(1d / SMOOTH_HEIGHT * (y + yy - LOW_SMOOTH_START));
                        } else if (yy + y > HIGH_SMOOTH_START) {
                            value += cubic(1d / SMOOTH_HEIGHT * (y + yy - HIGH_SMOOTH_START));
                        }
                    }
                    if (value >= 0) {
                        blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.NETHERRACK);
                    } else {
                        if (y + yy <= SEA_LEVEL) {
                            blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.STATIONARY_LAVA);
                        } else {
                            blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.AIR);
                        }
                    }
                }
            }
        }
    }

    private static double cubic(double x) {
        return x * x * x;
    }

    @Override
    public Point getSafeSpawn(World world) {
        final Random random = new Random();
        for (byte attempts = 0; attempts < 32; attempts++) {
            final int x = random.nextInt(256) - 127;
            final int z = random.nextInt(256) - 127;
            final int y = getHighestSolidBlock(world, x, z);
            if (y != -1) {
                return new Point(world, x, y + 0.5f, z);
            }
        }
        return new Point(world, 0, 80, 0);
    }

    private int getHighestSolidBlock(World world, int x, int z) {
        int y = HEIGHT / 2;
        if (!world.getBlockMaterial(x, y, z).isInvisible()) {
            return -1;
        }

        return ++y;
    }

    @Override
    public int[][] getSurfaceHeight(World world, int chunkX, int chunkZ) {
        int height = VanillaPlayerNetworkComponent.WORLD_HEIGHT - 1;
        int[][] heights = new int[Chunk.BLOCKS.SIZE][Chunk.BLOCKS.SIZE];
        for (int x = 0; x < Chunk.BLOCKS.SIZE; x++) {
            for (int z = 0; z < Chunk.BLOCKS.SIZE; z++) {
                heights[x][z] = height;
            }
        }
        return heights;
    }
}