Query Nesnesinden veri okuma

Query Nesnesinden veri okuma
public void getpictures_onClick(JLbsXUIControlEvent event)
{
    IClientContext clientContext = event.getClientContext();
    IQueryFactory queryFactory = clientContext.getQueryFactory();
    
    QueryParams queryParameters = new QueryParams();
    queryParameters.setCustomization(ProjectGlobals.getM_ProjectGUID());
    queryParameters.getEnabledTerms().enable("T2");
    queryParameters.getParameters().put("P_INFOREF", 3);
    QueryBusinessObjects queryBusinessObjects = new QueryBusinessObjects();
    
    
    JLbsImage imageComponent = (JLbsImage) event.getContainer().getComponentByTag(2000013);
    
    try {
        boolean first = queryFactory.first("CQFirmDoc", queryParameters, queryBusinessObjects, 1, false);
        if (first) {
            for (int i = 0; i < queryBusinessObjects.size(); i++) {
                QueryBusinessObject queryBusinessObject = queryBusinessObjects.get(i);
                ObjectPropertyValues properties = queryBusinessObject.getProperties();
                byte[] byteArrProp = QueryUtil.getByteArrProp(properties, "LDATA");
                
                ImageIcon icon = new ImageIcon(byteArrProp);
                imageComponent.setIcon(icon);
            }
        }
        
    } catch (QueryFactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SessionTimeoutException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SessionReestablishedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

Veri tabanında kaydedilmiş malzeme resimlerini okuyup kullanmak için;

Resim bilgileri firma bağımlı COMPANYDOCS tablosunda tutuluyor.

Veri tabanındaki kayıt şekli aşağıdaki gibidir. InfoRef ilişkili malzeme referansı, DOCNR ise hangi resim olduğu bilgisidir. Çünkü birden fazla resim saklanabilmektedir.

 select DOCNR, LDATA from U_001_COMPANYDOCS where INFOTYPE = 20 AND INFOREF=10 AND DOCTYPE = 0

Malzemenin ilk resmini aşağıdaki gibi okuyup bir image nesnesinde gösterebiliriz.

Malzeme resmi oku
public void readDbimage_onClick(JLbsXUIControlEvent event)
{
    
    int itemRef= 10;
    IClientContext clientContext = event.getClientContext();
    JLbsXUIPane container = event.getContainer();
    
    MMBOItem item = (MMBOItem) UnityHelper.getBOByReference(clientContext, MMBOItem.class, itemRef, true);
    if (item != null)
    {
        if (item.getMainImages().size() > 0)
        {
            GOBOAttachedDocument imageObject = item.getMainImages().get(0);
            byte[] document = imageObject.getDocument();
            
            ILbsImage imageComponent = (ILbsImage) container.getComponentByTag(2000030);
            ImageIcon icon = new ImageIcon(document);
            imageComponent.setIcon(icon);
        }
    }
 }

Aşağıda malzeme kartının eventhandler kaynak kodunı inceleyebilrsiniz. Burda silmek ve update etmek ile ilgili bir çok örnek bulunuyor.

malzeme kartı eventhandler kodu
package com.lbs.unity.mm.forms;
/**
* <p>Title: MMXEItem </p>
* <p>Description: MMXEItem : XUI event handler for material item </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: LBS</p>
* @author Turgay Ayta?
* @version 1.0
*/
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.swing.InputVerifier;
import com.lbs.console.LbsConsole;
import com.lbs.control.interfaces.ILbsComboBox;
import com.lbs.control.interfaces.ILbsComboEdit;
import com.lbs.control.interfaces.ILbsComponent;
import com.lbs.control.interfaces.ILbsImage;
import com.lbs.control.interfaces.ILbsMaskedEdit;
import com.lbs.control.interfaces.ILbsMultiColGroupBox;
import com.lbs.control.interfaces.ILbsNumericEdit;
import com.lbs.control.interfaces.ILbsPopupMenuItem;
import com.lbs.control.interfaces.ILbsRadioButtonGroup;
import com.lbs.controls.JLbsImage;
import com.lbs.data.factory.FactoryParams;
import com.lbs.data.factory.IFactorySearchConstants;
import com.lbs.data.factory.IObjectFactory;
import com.lbs.data.objects.BusinessObjects;
import com.lbs.data.query.IQueryFactory;
import com.lbs.data.query.QueryBusinessObject;
import com.lbs.data.query.QueryBusinessObjects;
import com.lbs.data.query.QueryParams;
import com.lbs.doc.client.ClientDocumentServices;
import com.lbs.globalization.ILbsCultureInfo;
import com.lbs.globalization.JLbsCultureInfoTRTR;
import com.lbs.globalization.JLbsCurrenciesBase;
import com.lbs.grid.interfaces.ILbsGridBase;
import com.lbs.grid.interfaces.ILbsInplaceEditor;
import com.lbs.grid.interfaces.ILbsObjectListGrid;
import com.lbs.grids.GridColumn;
import com.lbs.grids.InplaceComboBoxOptions;
import com.lbs.grids.InplaceDateOptions;
import com.lbs.grids.InplaceEditorInfo;
import com.lbs.grids.InplaceTextOptions;
import com.lbs.grids.event.IGridInplaceSelectBoxListener;
import com.lbs.platform.interfaces.ILbsValidationError;
import com.lbs.platform.interfaces.ILbsValidationResult;
import com.lbs.remoteclient.IClientContext;
import com.lbs.unity.ILbsValidationErrorConstants;
import com.lbs.unity.UnityConstants;
import com.lbs.unity.UnityHelper;
import com.lbs.unity.UnityLanguageHelper;
import com.lbs.unity.am.bo.AMEOObjectTemp;
import com.lbs.unity.bo.GOBOAttachedDocument;
import com.lbs.unity.dialogs.IUODMessageConstants;
import com.lbs.unity.lo.LOHelper;
import com.lbs.unity.mm.MMHelper;
import com.lbs.unity.mm.bo.MMBOAssortConfigAsgs;
import com.lbs.unity.mm.bo.MMBOItem;
import com.lbs.unity.mm.bo.MMBOItemAttribute;
import com.lbs.unity.mm.bo.MMBOItemCardAttributeAsgs;
import com.lbs.unity.mm.bo.MMBOItemConfigForReferences;
import com.lbs.unity.mm.bo.MMBOItemForAssortConfigAsgs;
import com.lbs.unity.mm.bo.MMBOItemForSetItemAssignments;
import com.lbs.unity.mm.bo.MMBOItemLinkForItemConfig;
import com.lbs.unity.mm.bo.MMBOItemUnitAssignment;
import com.lbs.unity.mm.bo.MMBOSetItemAssignments;
import com.lbs.unity.mm.bo.MMBOUnitBarCode;
import com.lbs.unity.mm.bo.MMBOUnitSet;
import com.lbs.unity.mm.bo.MMBOUnitSetInfo;
import com.lbs.unity.mm.bo.MMBOUomDefinition;
import com.lbs.unity.mm.bo.MMBOUomLink;
import com.lbs.unity.mm.bo.MMEOItem;
import com.lbs.unity.mm.bo.MMEOItemImage;
import com.lbs.unity.mm.data.ILbsItemAttributeConstants;
import com.lbs.unity.mm.data.JLbsItemAttributeUtil;
import com.lbs.unity.mm.data.JLbsItemAttributeUtil.Caption;
import com.lbs.unity.mm.data.JLbsLocalizableListEntry;
import com.lbs.util.JLbsStringList;
import com.lbs.util.JLbsStringUtil;
import com.lbs.util.ObjectUtil;
import com.lbs.util.QueryUtil;
import com.lbs.validation.LbsValidationEvent;
import com.lbs.xui.ILbsXUIPane;
import com.lbs.xui.JLbsXUIAdapter;
import com.lbs.xui.JLbsXUIControl;
import com.lbs.xui.JLbsXUIDefinition;
import com.lbs.xui.JLbsXUIEntityRights;
import com.lbs.xui.JLbsXUILookupInfo;
import com.lbs.xui.JLbsXUIPane;
import com.lbs.xui.JLbsXUITypes;
public class MMXEItem extends JLbsXUIAdapter
{
    public static final int MODE_ITEM = 0;
    public static final int MODE_CLASS = 1;
    public static final int MODE_FIXASS = 2;
    public static final int MODE_SERVICE = 3;
    public static final int MODE_SET = 4;
    public static int AUTH_MODE;
    public static final int DBERROR_UNITSETCHANGE = -1;
    public static final int DBERROR_UNITMODULEASGS = -2;
    private static String mainUnitCode = "";
    private MMBOItem cloned;
    // private boolean generalModified = false;
    private boolean unitSetModified = false;
    // private boolean optionsModified = false;
    // private boolean trackingModified = false;
    // private boolean intraStatModified = false;
    private ILbsObjectListGrid m_UnitAsgGrid;
    private IGridInplaceSelectBoxListener selectBoxListener = null;
    private InputVerifier verifier = null;
    private BigDecimal volumeTotal = new BigDecimal(0);
    private BigDecimal weightTotal = new BigDecimal(0);
    private int volumeMainUnitReference = 0;
    private int weightMainUnitReference = 0;
    private String volumeMainUnitCode = "";
    private String weightMainUnitCode = "";
    private int imageIndex = 0;
    private boolean firstImage = false;
    private Integer moduleFlags(MMBOItemUnitAssignment uAsg)
    {
        int flags = 0;
        flags = (uAsg.getMM_Flag() == 0) ? flags : flags + 1;
        flags = (uAsg.getPC_Flag() == 0) ? flags : flags + 2;
        flags = (uAsg.getSD_Flag() == 0) ? flags : flags + 4;
        return new Integer(flags);
    }
    private String firstBarCode(MMBOItemUnitAssignment uAsg)
    {
        String barCode = "";
        if (uAsg.getBarCodes().size() != 0)
        {
            MMBOUnitBarCode firstBar = uAsg.getBarCodes().get(0);
            barCode = firstBar.getBarCode();
        }
        return barCode;
    }
    public ILbsComponent getComponentInstance(JLbsXUIDefinition xuidef, JLbsXUIDefinition rootdef, int mode,
    ILbsCultureInfo culture, JLbsCurrenciesBase currencies, IClientContext context, JLbsXUIEntityRights rights, int authMode)
    {
        if (xuidef.getTag() == 1000044)
        return new JLbsImage(false);
        return null;
    }
    public Object gridGetCellValue(ILbsGridBase grid, int row, int column, int columnTag, Object rowData, ILbsXUIPane container,
    IClientContext context)
    {
        if (container.getControl(grid).getTag() == 300)
        {
            switch (columnTag)
            {
            case 3103:
                return "=";
            case 3105:
                return mainUnitCode;
            case 3107:
                return firstBarCode((MMBOItemUnitAssignment) rowData);
            case 3109:
                return moduleFlags((MMBOItemUnitAssignment) rowData);
            }
        }
        if (container.getControl(grid).getTag() == 2710)
        {
            MMBOItemCardAttributeAsgs attrAssignment = (MMBOItemCardAttributeAsgs) rowData;
            AMEOObjectTemp attributeEO = (AMEOObjectTemp) attrAssignment.getAttributeEO();
            switch (columnTag)
            {
            case 2713:
                switch (attributeEO.getType())
                {
                case ILbsItemAttributeConstants.ATTR_VALUE_TEXT:
                    return attrAssignment.getValueStr();
                case ILbsItemAttributeConstants.ATTR_VALUE_LIST:
                    if (attributeEO.getCode() == null)
                    return null;
                    return attributeEO.getValue();
                    /*
                                * case ILbsItemAttributeConstants.ATTR_VALUE_NUMERIC:
                                * return attrAssignment.getValueNumeric();
                                */
                case ILbsItemAttributeConstants.ATTR_VALUE_DATE:
                    return attrAssignment.getValueDate();
                }
                break;
            case 2714:
                switch (attributeEO.getType())
                {
                case ILbsItemAttributeConstants.ATTR_VALUE_TEXT:
                    // case ILbsItemAttributeConstants.ATTR_VALUE_NUMERIC:
                case ILbsItemAttributeConstants.ATTR_VALUE_DATE:
                    return attrAssignment.getDescription();
                case ILbsItemAttributeConstants.ATTR_VALUE_LIST:
                    if (attributeEO.getCode() == null)
                    return null;
                    return attributeEO.getValueDesc();
                }
                break;
            }
        }
        return null;
    }
    /**
    * @see com.lbs.xui.ILbsXUIEvents#gridSetCellEditValue(ILbsGridBase, int,
    *      int, Object, ILbsXUIPane, IClientContext)
    */
    public boolean gridSetCellEditValue(ILbsGridBase grid, int row, int column, int columnTag, Object value, ILbsXUIPane container,
    IClientContext context)
    {
        if (container.getControl(grid).getTag() == 300)
        {
            MMBOItem item = (MMBOItem) container.getData();
            BusinessObjects uomList = item.getUOMList();
            switch (columnTag)
            {
            case 3109:
                if (value instanceof Integer)
                {
                    int flags = ((Integer) value).intValue();
                    MMBOItemUnitAssignment rowData = (MMBOItemUnitAssignment) uomList.get(row);
                    rowData.setMM_Flag((flags & 1) != 0 ? 1 : 0);
                    rowData.setPC_Flag((flags & 2) != 0 ? 1 : 0);
                    rowData.setSD_Flag((flags & 4) != 0 ? 1 : 0);
                    return true;
                }
            }
        }
        return false;
    }
    private static void setMainUnitCode(MMBOItem item)
    {
        BusinessObjects uomList = item.getUOMList();
        if (uomList != null)
        {
            for (int i = 0; i < uomList.size(); i++)
            {
                MMBOItemUnitAssignment asg = (MMBOItemUnitAssignment) uomList.get(i);
                MMBOUomLink def = asg.getUOMDef();
                if (def != null && def.getMainUnit() != 0)
                {
                    mainUnitCode = def.getCode();
                    return;
                }
            }
        }
    }
    private static MMBOUomLink getUOMLink(IObjectFactory factory, int ref)
    {
        MMBOUomLink link = null;
        if (ref != 0)
        link = (MMBOUomLink) UnityHelper.getBOByReference(factory, MMBOUomLink.class, ref);
        return (link != null) ? link : new MMBOUomLink();
    }
    public static boolean recreateUnitsOfItem(Object data, IObjectFactory factory)
    {
        MMBOItem item = (MMBOItem) data;
        MMBOUnitSetInfo uSet = item.getUnitSetInfo();
        BusinessObjects uomList = item.getUOMList();
        if (uomList == null)
        uomList = new Bus

...

Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım