conn.close();
        return falg;
    }

package com.dao;

import com.core.ConnDB;
import java.util.*;
import java.sql.*;
import com.actionForm.ReaderForm;

public class ReaderDAO {

    private ConnDB conn = new ConnDB();

    // 查询数据
    public Collection query(String strif) {
        ReaderForm readerForm = null;
        Collection readerColl = new ArrayList();
        String sql = "";
        if (strif != "all" && strif != null && strif != "") {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where " + strif + "";
        } else {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id";
        }
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm = new ReaderForm();
                readerForm.setId(Integer.valueOf(rs.getString(1)));
                readerForm.setName(rs.getString(2));
                readerForm.setSex(rs.getString(3));
                readerForm.setBarcode(rs.getString(4));
                readerForm.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm.setBirthday(birthday == null ? "" : birthday);
                readerForm.setPaperType(rs.getString(7));
                readerForm.setPaperNO(rs.getString(8));
                readerForm.setTel(rs.getString(9));
                readerForm.setEmail(rs.getString(10));
                readerForm.setCreateDate(rs.getString(11));
                readerForm.setOperator(rs.getString(12));
                readerForm.setRemark(rs.getString(13));
                readerForm.setTypeid(rs.getInt(14));
                readerForm.setTypename(rs.getString(15));
                readerForm.setNumber(rs.getInt(16));
                readerColl.add(readerForm);
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerColl;
    }

    // 用于修改的查询
    public ReaderForm queryM(ReaderForm readerForm) {
        ReaderForm readerForm1 = null;
        String sql = "";
        if (readerForm.getId() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.id=" + readerForm.getId() + "";
        } else if (readerForm.getBarcode() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.barcode=" + readerForm.getBarcode() + "";
        }
        System.out.println("修改读者信息时的SQL：" + sql);
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm1 = new ReaderForm();
                readerForm1.setId(Integer.valueOf(rs.getString(1)));
                readerForm1.setName(rs.getString(2));
                readerForm1.setSex(rs.getString(3));
                readerForm1.setBarcode(rs.getString(4));
                readerForm1.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm1.setBirthday(birthday == null ? "" : birthday);
                readerForm1.setPaperType(rs.getString(7));
                readerForm1.setPaperNO(rs.getString(8));
                readerForm1.setTel(rs.getString(9));
                readerForm1.setEmail(rs.getString(10));
                readerForm1.setCreateDate(rs.getString(11));
                readerForm1.setOperator(rs.getString(12));
                readerForm1.setRemark(rs.getString(13));
                readerForm1.setTypeid(rs.getInt(14));
                readerForm1.setTypename(rs.getString(15));
                readerForm1.setNumber(rs.getInt(16));
                System.out.println(rs.getString(2));
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerForm1;
    }

    // 添加数据
    public int insert(ReaderForm readerForm) {
        String sql1 = "SELECT * FROM tb_reader WHERE barcode='" + readerForm.getBarcode() + "'";
        ResultSet rs = conn.executeQuery(sql1);
        String sql = "";
        int falg = 0;
        try {
            if (rs.next()) {
                falg = 2;
            } else {
                if (readerForm.getBirthday() == "") {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                } else {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,birthday,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getBirthday() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                }
                falg = conn.executeUpdate(sql);
                System.out.println("添加读者信息的SQL：" + sql);
                conn.close();
            }
        } catch (SQLException ex) {
            falg = 0;
        }
        System.out.println("falg:" + falg);
        return falg;
    }

    // 修改数据
    public int update(ReaderForm readerForm) {
        String sql = "";
        if (readerForm.getBirthday() == "") {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday=null,paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        } else {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday='" + readerForm.getBirthday() + "',paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        }
        int falg = conn.executeUpdate(sql);
        System.out.println("修改数据时的SQL：" + sql);

    // 删除数据
    public int delete(ReaderForm readerForm) {
        String sql = "Delete from tb_reader where id=" + readerForm.getId() + "";
        int falg = conn.executeUpdate(sql);
        System.out.println("删除时的SQL：" + sql);
        return falg;
    }
}


package com.dao;

import com.core.ConnDB;
import java.util.*;
import java.sql.*;
import com.actionForm.ReaderForm;

public class ReaderDAO {

    private ConnDB conn = new ConnDB();

    // 查询数据
    public Collection query(String strif) {
        ReaderForm readerForm = null;
        Collection readerColl = new ArrayList();
        String sql = "";
        if (strif != "all" && strif != null && strif != "") {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where " + strif + "";
        } else {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id";
        }
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm = new ReaderForm();
                readerForm.setId(Integer.valueOf(rs.getString(1)));
                readerForm.setName(rs.getString(2));
                readerForm.setSex(rs.getString(3));
                readerForm.setBarcode(rs.getString(4));
                readerForm.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm.setBirthday(birthday == null ? "" : birthday);
                readerForm.setPaperType(rs.getString(7));
                readerForm.setPaperNO(rs.getString(8));
                readerForm.setTel(rs.getString(9));
                readerForm.setEmail(rs.getString(10));
                readerForm.setCreateDate(rs.getString(11));
                readerForm.setOperator(rs.getString(12));
                readerForm.setRemark(rs.getString(13));
                readerForm.setTypeid(rs.getInt(14));
                readerForm.setTypename(rs.getString(15));
                readerForm.setNumber(rs.getInt(16));
                readerColl.add(readerForm);
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerColl;
    }

    // 用于修改的查询
    public ReaderForm queryM(ReaderForm readerForm) {
        ReaderForm readerForm1 = null;
        String sql = "";
        if (readerForm.getId() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.id=" + readerForm.getId() + "";
        } else if (readerForm.getBarcode() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.barcode=" + readerForm.getBarcode() + "";
        }
        System.out.println("修改读者信息时的SQL：" + sql);
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm1 = new ReaderForm();
                readerForm1.setId(Integer.valueOf(rs.getString(1)));
                readerForm1.setName(rs.getString(2));
                readerForm1.setSex(rs.getString(3));
                readerForm1.setBarcode(rs.getString(4));
                readerForm1.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm1.setBirthday(birthday == null ? "" : birthday);
                readerForm1.setPaperType(rs.getString(7));
                readerForm1.setPaperNO(rs.getString(8));
                readerForm1.setTel(rs.getString(9));
                readerForm1.setEmail(rs.getString(10));
                readerForm1.setCreateDate(rs.getString(11));
                readerForm1.setOperator(rs.getString(12));
                readerForm1.setRemark(rs.getString(13));
                readerForm1.setTypeid(rs.getInt(14));
                readerForm1.setTypename(rs.getString(15));
                readerForm1.setNumber(rs.getInt(16));
                System.out.println(rs.getString(2));
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerForm1;
    }

    // 添加数据
    public int insert(ReaderForm readerForm) {
        String sql1 = "SELECT * FROM tb_reader WHERE barcode='" + readerForm.getBarcode() + "'";
        ResultSet rs = conn.executeQuery(sql1);
        String sql = "";
        int falg = 0;
        try {
            if (rs.next()) {
                falg = 2;
            } else {
                if (readerForm.getBirthday() == "") {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                } else {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,birthday,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getBirthday() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                }
                falg = conn.executeUpdate(sql);
                System.out.println("添加读者信息的SQL：" + sql);
                conn.close();
            }
        } catch (SQLException ex) {
            falg = 0;
        }
        System.out.println("falg:" + falg);
        return falg;
    }

    // 修改数据
    public int update(ReaderForm readerForm) {
        String sql = "";
        if (readerForm.getBirthday() == "") {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday=null,paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        } else {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday='" + readerForm.getBirthday() + "',paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        }
        int falg = conn.executeUpdate(sql);
        Sy

        conn.close();
        return falg;
    }

    // 删除数据
    public int delete(ReaderForm readerForm) {
        String sql = "Delete from tb_reader where id=" + readerForm.getId() + "";
        int falg = conn.executeUpdate(sql);
        System.out.println("删除时的SQL：" + sql);
        return falg;
    }
}


if (readerForm.getId() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.id=" + readerForm.getId() + "";
        } else if (readerForm.getBarcode() != null) {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.barcode=" + readerForm.getBarcode() + "";
        }

package com.dao;

import com.core.ConnDB;
import java.util.*;
import java.sql.*;
import com.actionForm.ReaderForm;

public class ReaderDAO {

    private ConnDB conn = new ConnDB();

    // 查询数据
    public Collection query(String strif) {
        ReaderForm readerForm = null;
        Collection readerColl = new ArrayList();
        String sql = "";
        if (strif != "all" && strif != null && strif != "") {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where " + strif + "";
        } else {
            sql = "select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id";
        }
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm = new ReaderForm();
                readerForm.setId(Integer.valueOf(rs.getString(1)));
                readerForm.setName(rs.getString(2));
                readerForm.setSex(rs.getString(3));
                readerForm.setBarcode(rs.getString(4));
                readerForm.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm.setBirthday(birthday == null ? "" : birthday);
                readerForm.setPaperType(rs.getString(7));
                readerForm.setPaperNO(rs.getString(8));
                readerForm.setTel(rs.getString(9));
                readerForm.setEmail(rs.getString(10));
                readerForm.setCreateDate(rs.getString(11));
                readerForm.setOperator(rs.getString(12));
                readerForm.setRemark(rs.getString(13));
                readerForm.setTypeid(rs.getInt(14));
                readerForm.setTypename(rs.getString(15));
                readerForm.setNumber(rs.getInt(16));
                readerColl.add(readerForm);
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerColl;
    }

    // 用于修改的查询
    public ReaderForm queryM(ReaderForm readerForm) {
        ReaderForm readerForm1 = null;
        String sql = "";

        System.out.println("修改读者信息时的SQL：" + sql);
        ResultSet rs = conn.executeQuery(sql);
        String birthday = "";
        try {
            while (rs.next()) {
                readerForm1 = new ReaderForm();
                readerForm1.setId(Integer.valueOf(rs.getString(1)));
                readerForm1.setName(rs.getString(2));
                readerForm1.setSex(rs.getString(3));
                readerForm1.setBarcode(rs.getString(4));
                readerForm1.setVocation(rs.getString(5));
                birthday = rs.getString(6);
                readerForm1.setBirthday(birthday == null ? "" : birthday);
                readerForm1.setPaperType(rs.getString(7));
                readerForm1.setPaperNO(rs.getString(8));
                readerForm1.setTel(rs.getString(9));
                readerForm1.setEmail(rs.getString(10));
                readerForm1.setCreateDate(rs.getString(11));
                readerForm1.setOperator(rs.getString(12));
                readerForm1.setRemark(rs.getString(13));
                readerForm1.setTypeid(rs.getInt(14));
                readerForm1.setTypename(rs.getString(15));
                readerForm1.setNumber(rs.getInt(16));
                System.out.println(rs.getString(2));
            }
        } catch (SQLException ex) {
        }
        conn.close();
        return readerForm1;
    }

    // 添加数据
    public int insert(ReaderForm readerForm) {
        String sql1 = "SELECT * FROM tb_reader WHERE barcode='" + readerForm.getBarcode() + "'";
        ResultSet rs = conn.executeQuery(sql1);
        String sql = "";
        int falg = 0;
        try {
            if (rs.next()) {
                falg = 2;
            } else {
                if (readerForm.getBirthday() == "") {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                } else {
                    sql = "Insert into tb_reader (name,sex,barcode,vocation,birthday,paperType,paperNO,tel,email,createDate,operator,remark,typeid) values('" + readerForm.getName() + "','" + readerForm.getSex() + "','" + readerForm.getBarcode() + "','" + readerForm.getVocation() + "','" + readerForm.getBirthday() + "','" + readerForm.getPaperType() + "','" + readerForm.getPaperNO() + "','" + readerForm.getTel() + "','" + readerForm.getEmail() + "','" + readerForm.getCreateDate() + "','" + readerForm.getOperator() + "','" + readerForm.getRemark() + "'," + readerForm.getTypeid() + ")";
                }
                falg = conn.executeUpdate(sql);
                System.out.println("添加读者信息的SQL：" + sql);
                conn.close();
            }
        } catch (SQLException ex) {
            falg = 0;
        }
        System.out.println("falg:" + falg);
        return falg;
    }

    // 修改数据
    public int update(ReaderForm readerForm) {
        String sql = "";
        if (readerForm.getBirthday() == "") {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday=null,paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        } else {
            sql = "Update tb_reader set sex='" + readerForm.getSex() + "',barcode='" + readerForm.getBarcode() + "',vocation='" + readerForm.getVocation() + "',birthday='" + readerForm.getBirthday() + "',paperType='" + readerForm.getPaperType() + "',paperNO='" + readerForm.getPaperNO() + "',tel='" + readerForm.getTel() + "',email='" + readerForm.getEmail() + "',remark='" + readerForm.getRemark() + "',typeid=" + readerForm.getTypeid() + " where id=" + readerForm.getId() + "";
        }
        int falg = conn.executeUpdate(sql);
        System.out.println("修改数据时的SQL：" + sql);
        conn.close();
        return falg;
    }

    // 删除数据
    public int delete(ReaderForm readerForm) {
        String sql = "Delete from tb_reader where id=" + readerForm.getId() + "";
        int falg = conn.executeUpdate(sql);
        System.out.println("删除时的SQL：" + sql);
        return falg;
    }
}


package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            nameField.setValue(value);
        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));
            if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));
            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

{
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


{
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            nameField.setValue(value);
        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));
            if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));
            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId)

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));

package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            nameField.setValue(value);
        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {

            if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));
            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));

package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            nameField.setValue(value);
        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));

            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }

package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            nameField.setValue(value);
        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));
            if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));

    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


package com.mycollab.module.project.view.reports;

import com.google.common.collect.Sets;
import com.mycollab.common.i18n.GenericI18Enum;
import com.mycollab.db.arguments.SearchField;
import com.mycollab.db.query.ConstantValueInjector;
import com.mycollab.db.query.Param;
import com.mycollab.db.query.SearchFieldInfo;
import com.mycollab.module.project.ProjectTypeConstants;
import com.mycollab.module.project.domain.criteria.ProjectTicketSearchCriteria;
import com.mycollab.module.project.i18n.ProjectReportI18nEnum;
import com.mycollab.module.project.ui.components.UserProjectListSelect;
import com.mycollab.shell.event.ShellEvent;
import com.mycollab.vaadin.EventBusFactory;
import com.mycollab.vaadin.UserUIContext;
import com.mycollab.vaadin.ui.ELabel;
import com.mycollab.vaadin.web.ui.*;
import com.vaadin.event.ShortcutAction;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;
import org.vaadin.viritin.button.MButton;
import org.vaadin.viritin.fields.MTextField;
import org.vaadin.viritin.layouts.MHorizontalLayout;
import java.util.ArrayList;
import java.util.List;
import static com.mycollab.common.i18n.QueryI18nEnum.CONTAINS;
import static com.mycollab.common.i18n.QueryI18nEnum.IN;

/**
 * @author MyCollab Ltd
 * @since 7.0.0
 */
public class TicketCrossProjectsSearchPanel extends DefaultGenericSearchPanel<ProjectTicketSearchCriteria> {

    private ProjectTicketSearchCriteria searchCriteria;

    private static Param[] paramFields = new Param[] { ProjectTicketSearchCriteria.p_name, ProjectTicketSearchCriteria.p_startDate, ProjectTicketSearchCriteria.p_endDate, ProjectTicketSearchCriteria.p_dueDate };

    protected ComponentContainer buildSearchTitle() {
        return new MHorizontalLayout(ELabel.html(VaadinIcons.CALENDAR_CLOCK.getHtml() + " " + UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT)).withStyleName(ValoTheme.LABEL_H2, ValoTheme.LABEL_NO_MARGIN));
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createBasicSearchLayout() {
        return new TicketBasicSearchLayout();
    }

    @Override
    protected SearchLayout<ProjectTicketSearchCriteria> createAdvancedSearchLayout() {
        return new TicketAdvancedSearchLayout();
    }

    private class TicketBasicSearchLayout extends BasicSearchLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TextField nameField;

        private CheckBox myItemCheckbox;

        private TicketBasicSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this);
        }

        public void setNameField(String value) {
            na

        }

        @Override
        public ComponentContainer constructBody() {
            MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);
            Label nameLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_NAME) + ":");
            basicSearchBody.with(nameLbl).withAlign(nameLbl, Alignment.MIDDLE_LEFT);
            nameField = new MTextField().withPlaceholder(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT)).withWidth(WebUIConstants.DEFAULT_CONTROL_WIDTH);
            basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);
            myItemCheckbox = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
            basicSearchBody.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);
            MButton searchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH), clickEvent -> callSearchAction()).withIcon(VaadinIcons.SEARCH).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
            basicSearchBody.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);
            MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> nameField.setValue("")).withStyleName(WebThemes.BUTTON_OPTION);
            basicSearchBody.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
            if (canSwitchToAdvanceLayout) {
                MButton advancedSearchBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), clickEvent -> moveToAdvancedSearchLayout()).withStyleName(WebThemes.BUTTON_LINK);
                basicSearchBody.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
            }
            return basicSearchBody;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            List<SearchFieldInfo<ProjectTicketSearchCriteria>> searchFieldInfos = new ArrayList<>();
            searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_name, CONTAINS.name(), ConstantValueInjector.valueOf(nameField.getValue().trim())));
            if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }
            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));
            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


if (myItemCheckbox.getValue()) {
                searchFieldInfos.add(new SearchFieldInfo(SearchField.AND, ProjectTicketSearchCriteria.p_assignee, IN.name(), ConstantValueInjector.valueOf(Sets.newHashSet(UserUIContext.getUsername()))));
            }

            EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, searchFieldInfos));
            searchCriteria = SearchFieldInfo.buildSearchCriteria(ProjectTicketSearchCriteria.class, searchFieldInfos);
            return searchCriteria;
        }
    }

    private class TicketAdvancedSearchLayout extends DynamicQueryParamLayout<ProjectTicketSearchCriteria> {

        private static final long serialVersionUID = 1L;

        private TicketAdvancedSearchLayout() {
            super(TicketCrossProjectsSearchPanel.this, ProjectTypeConstants.TICKET);
        }

        @Override
        protected Class<ProjectTicketSearchCriteria> getType() {
            return ProjectTicketSearchCriteria.class;
        }

        @Override
        public Param[] getParamFields() {
            return paramFields;
        }

        @Override
        protected Component buildSelectionComp(String fieldId) {
            if ("projectid".equals(fieldId)) {
                return new UserProjectListSelect();
            }
            return null;
        }

        @Override
        protected ProjectTicketSearchCriteria fillUpSearchCriteria() {
            searchCriteria = super.fillUpSearchCriteria();
            return searchCriteria;
        }
    }
}


public static BiomeLookup getBiome(String data)

package me.eccentric_nz.TARDIS.enumeration;

import com.google.common.collect.Maps;
import java.util.Map;

/**
 * @author eccentric_nz
 */
public enum BiomeLookup {

    CACTUS_B("DESERT", "DESERT_HILLS"),
    DIRT_B("MOUNTAINS", "MODIFIED_GRAVELLY_MOUNTAINS"),
    PODZOL_B("GIANT_TREE_TAIGA", "GIANT_TREE_TAIGA_HILLS"),
    RED_SAND_B("BADLANDS", "BADLANDS_PLATEAU"),
    ACACIA_LOG_B("SAVANNA", "SHATTERED_SAVANNA"),
    DARK_OAK_LOG_B("DARK_FOREST", "DARK_FOREST_HILLS"),
    OAK_LOG_B("FOREST", "WOODED_HILLS"),
    SPRUCE_LOG_B("TAIGA", "TAIGA_HILLS"),
    BIRCH_LOG_B("BIRCH_FOREST", "BIRCH_FOREST_HILLS"),
    JUNGLE_LOG_B("JUNGLE", "JUNGLE_HILLS"),
    SAND_B("BEACH", "SNOWY_BEACH"),
    SNOW_BLOCK_B("SNOWY_TAIGA", "SNOWY_TAIGA_HILLS"),
    WATER_BUCKET_B("OCEAN", "DEEP_OCEAN"),
    RED_TULIP_B("FLOWER_FOREST", "TALL_BIRCH_HILLS"),
    SUNFLOWER_B("PLAINS", "SUNFLOWER_PLAINS"),
    ICE_B("SNOWY_TUNDRA", "ICE_SPIKES"),
    MYCELIUM_B("MUSHROOM_FIELDS", "MUSHROOM_FIELD_SHORE"),
    LILY_PAD_B("SWAMP", "SWAMP_HILLS"),
    BAMBOO_B("BAMBOO_JUNGLE", "BAMBOO_JUNGLE_HILLS");

    public final static Map<String, BiomeLookup> BY_REG = Maps.newHashMap();

    static {
        for (BiomeLookup bm : values()) {
            BY_REG.put(bm.getRegular(), bm);
        }
    }

    String regular;

    String upper;

    BiomeLookup(String regular, String upper) {
        this.regular = regular;
        this.upper = upper;
    }

{
        return BY_REG.get(data);
    }

    public String getRegular() {
        return regular;
    }

    public String getUpper() {
        return upper;
    }
}


{
        return BY_REG.get(data);
    }

package me.eccentric_nz.TARDIS.enumeration;

import com.google.common.collect.Maps;
import java.util.Map;

/**
 * @author eccentric_nz
 */
public enum BiomeLookup {

    CACTUS_B("DESERT", "DESERT_HILLS"),
    DIRT_B("MOUNTAINS", "MODIFIED_GRAVELLY_MOUNTAINS"),
    PODZOL_B("GIANT_TREE_TAIGA", "GIANT_TREE_TAIGA_HILLS"),
    RED_SAND_B("BADLANDS", "BADLANDS_PLATEAU"),
    ACACIA_LOG_B("SAVANNA", "SHATTERED_SAVANNA"),
    DARK_OAK_LOG_B("DARK_FOREST", "DARK_FOREST_HILLS"),
    OAK_LOG_B("FOREST", "WOODED_HILLS"),
    SPRUCE_LOG_B("TAIGA", "TAIGA_HILLS"),
    BIRCH_LOG_B("BIRCH_FOREST", "BIRCH_FOREST_HILLS"),
    JUNGLE_LOG_B("JUNGLE", "JUNGLE_HILLS"),
    SAND_B("BEACH", "SNOWY_BEACH"),
    SNOW_BLOCK_B("SNOWY_TAIGA", "SNOWY_TAIGA_HILLS"),
    WATER_BUCKET_B("OCEAN", "DEEP_OCEAN"),
    RED_TULIP_B("FLOWER_FOREST", "TALL_BIRCH_HILLS"),
    SUNFLOWER_B("PLAINS", "SUNFLOWER_PLAINS"),
    ICE_B("SNOWY_TUNDRA", "ICE_SPIKES"),
    MYCELIUM_B("MUSHROOM_FIELDS", "MUSHROOM_FIELD_SHORE"),
    LILY_PAD_B("SWAMP", "SWAMP_HILLS"),
    BAMBOO_B("BAMBOO_JUNGLE", "BAMBOO_JUNGLE_HILLS");

    public final static Map<String, BiomeLookup> BY_REG = Maps.newHashMap();

    static {
        for (BiomeLookup bm : values()) {
            BY_REG.put(bm.getRegular(), bm);
        }
    }

    String regular;

    String upper;

    BiomeLookup(String regular, String upper) {
        this.regular = regular;
        this.upper = upper;
    }

    public static BiomeLookup getBiome(String data)

    public String getRegular() {
        return regular;
    }

    public String getUpper() {
        return upper;
    }
}


package me.eccentric_nz.TARDIS.enumeration;

import com.google.common.collect.Maps;
import java.util.Map;

/**
 * @author eccentric_nz
 */
public enum BiomeLookup {

    CACTUS_B("DESERT", "DESERT_HILLS"),
    DIRT_B("MOUNTAINS", "MODIFIED_GRAVELLY_MOUNTAINS"),
    PODZOL_B("GIANT_TREE_TAIGA", "GIANT_TREE_TAIGA_HILLS"),
    RED_SAND_B("BADLANDS", "BADLANDS_PLATEAU"),
    ACACIA_LOG_B("SAVANNA", "SHATTERED_SAVANNA"),
    DARK_OAK_LOG_B("DARK_FOREST", "DARK_FOREST_HILLS"),
    OAK_LOG_B("FOREST", "WOODED_HILLS"),
    SPRUCE_LOG_B("TAIGA", "TAIGA_HILLS"),
    BIRCH_LOG_B("BIRCH_FOREST", "BIRCH_FOREST_HILLS"),
    JUNGLE_LOG_B("JUNGLE", "JUNGLE_HILLS"),
    SAND_B("BEACH", "SNOWY_BEACH"),
    SNOW_BLOCK_B("SNOWY_TAIGA", "SNOWY_TAIGA_HILLS"),
    WATER_BUCKET_B("OCEAN", "DEEP_OCEAN"),
    RED_TULIP_B("FLOWER_FOREST", "TALL_BIRCH_HILLS"),
    SUNFLOWER_B("PLAINS", "SUNFLOWER_PLAINS"),
    ICE_B("SNOWY_TUNDRA", "ICE_SPIKES"),
    MYCELIUM_B("MUSHROOM_FIELDS", "MUSHROOM_FIELD_SHORE"),
    LILY_PAD_B("SWAMP", "SWAMP_HILLS"),
    BAMBOO_B("BAMBOO_JUNGLE", "BAMBOO_JUNGLE_HILLS");

    public final static Map<String, BiomeLookup> BY_REG = Maps.newHashMap();

    static {
        for (BiomeLookup bm : values()) {
            BY_REG.put(bm.getRegular(), bm);
        }
    }

    String regular;

    String upper;

    BiomeLookup(String regular, String upper) {
        this.regular = regular;
        this.upper = upper;
    }

    public static BiomeLookup getBiome(String data) {
        return BY_REG.get(data

    }

    public String getRegular() {
        return regular;
    }

    public String getUpper() {
        return upper;
    }
}


static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u)

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

{
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


{
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v)

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {

        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));

        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);


package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u)

        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);

            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


while (curEdge[u] < graph[u].size()) {
            int v = graph[u].get(curEdge[u]++);
            if (usedEdges.add(((long) Math.min(u, v) << 32) + Math.max(u, v)))
                dfs(graph, curEdge, usedEdges, res, v);
        }

package graphs.dfs;

import java.util.*;
import java.util.stream.Stream;

public class EulerCycle {

    public static List<Integer> eulerCycleUndirected(List<Integer>[] graph, int u) {
        Set<Long> usedEdges = new HashSet<>();
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, usedEdges, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, Set<Long> usedEdges, List<Integer> res, int u) {

        res.add(u);
    }

    public static List<Integer> eulerCycleUndirected2(List<Integer>[] graph, int u) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        Set<Long> usedEdges = new HashSet<>();
        stack.add(u);
        while (!stack.isEmpty()) {
            u = stack.pop();
            while (curEdge[u] < graph[u].size()) {
                int v = graph[u].get(curEdge[u]++);
                if (usedEdges.add((((long) Math.min(u, v) << 32) + Math.max(u, v)))) {
                    stack.push(u);
                    u = v;
                }
            }
            res.add(u);
        }
        Collections.reverse(res);
        return res;
    }

    public static List<Integer> eulerCycleDirected(List<Integer>[] graph, int u) {
        int n = graph.length;
        int[] curEdge = new int[n];
        List<Integer> res = new ArrayList<>();
        dfs(graph, curEdge, res, u);
        Collections.reverse(res);
        return res;
    }

    static void dfs(List<Integer>[] graph, int[] curEdge, List<Integer> res, int u) {
        while (curEdge[u] < graph[u].size()) {
            dfs(graph, curEdge, res, graph[u].get(curEdge[u]++));
        }
        res.add(u);
    }

    public static List<Integer> eulerCycleDirected2(List<Integer>[] graph, int v) {
        int[] curEdge = new int[graph.length];
        List<Integer> res = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        stack.add(v);
        while (!stack.isEmpty()) {
            v = stack.pop();
            while (curEdge[v] < graph[v].size()) {
                stack.push(v);
                v = graph[v].get(curEdge[v]++);
            }
            res.add(v);
        }
        Collections.reverse(res);
        return res;
    }

    // Usage example
    public static void main(String[] args) {
        int n = 5;
        List<Integer>[] g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(4);
        g[4].add(1);
        System.out.println(eulerCycleDirected(g, 0));
        System.out.println(eulerCycleDirected2(g, 0));
        n = 5;
        g = Stream.generate(ArrayList::new).limit(n).toArray(List[]::new);
        g[0].add(1);
        g[1].add(0);
        g[1].add(2);
        g[2].add(1);
        g[2].add(3);
        g[3].add(2);
        g[0].add(3);
        g[3].add(0);
        g[0].add(4);
        g[4].add(0);
        g[1].add(4);
        g[4].add(1);
        g[0].add(2);
        g[2].add(0);
        g[1].add(3);
        g[3].add(1);
        System.out.println(eulerCycleUndirected(g, 2));
        System.out.println(eulerCycleUndirected2(g, 2));
    }
}


package gov.nist.toolkit.testenginelogging.logrepository;

import gov.nist.toolkit.results.client.TestInstance;
import gov.nist.toolkit.testenginelogging.client.LogMapDTO;
import gov.nist.toolkit.xdsexception.client.XdsException;
import gov.nist.toolkit.xdsexception.client.XdsInternalException;
import org.apache.log4j.Logger;
import java.io.*;

/**
 * A LogRepository is a directory where log files can be stored
 * for an event.  This class creates the directory and returns
 * a File handle to the directory.  What goes into the directory
 * @author bill
 */
abstract public class LogRepository1 {

    File logDir = null;

    // must initialize logDir
    abstract public LogRepository1 getNewLogRepository(String user) throws IOException;

    abstract protected Logger getLogger();

    protected LogRepository1() {
    }

    public void logOut(TestInstance id, LogMapDTO log) throws XdsException {
        getLogger().debug("Writing log " + log.getKeys() + " to " + logDir);
        FileOutputStream fos = null;
        ObjectOutputStream out = null;
        try {
            fos = new FileOutputStream(logFile(id));
            out = new ObjectOutputStream(fos);
            out.writeObject(log);
        } catch (IOException e) {
            throw new XdsInternalException("Cannot write transaction log file", e);
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                throw new XdsInternalException("Cannot write transaction log file", e);
            }
        }
    }

    public LogMapDTO logIn(TestInstance id) throws Exception {
        FileInputStream fis = null;
        ObjectInputStream in = null;
        try {
            fis = new FileInputStream(logFile(id));
            in = new ObjectInputStream(fis);
            LogMapDTO map = (LogMapDTO) in.readObject();
            getLogger().debug("restoring log " + map.getKeys() + " from " + logDir);
            return map;
        } catch (ClassNotFoundException e) {
            getLogger().debug("attempting to restore log " + "from " + logDir);
            throw new XdsInternalException("Cannot create model of type LogMapDTO - class not found", e);
        } finally {
            in.close();
        }
    }

    String logFile(TestInstance id) throws IOException {
        return logDir().toString() + File.separator + id.getId();
    }