// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)

package psdi.app.workorder;

import java.rmi.RemoteException;
import psdi.app.location.LocationRemote;
import psdi.mbo.*;
import psdi.util.MXApplicationException;
import psdi.util.MXException;

// Referenced classes of package psdi.app.ticket:
//            Ticket, TicketSet, TicketAssetSet

public class FldSWOLoc extends MAXTableDomain
{

    public FldSWOLoc(MboValue mbovalue)
        throws MXException
    {
      super(mbovalue);
      try
      {
        criteria = null;
        tempcriteria = null;
        String sSiteid = getMboValue().getMbo().getInsertSite();
        getMboValue("swositeid").setValue(sSiteid);
        String s = getMboValue().getAttributeName();
        setRelationship("LOCATIONS", "location = :" + s);
        addConditionalListWhere("swositeid", "1", "siteid=:swositeid");
        criteria = " disabled = :no";
        String as[] = {
            "STOREROOM","COURIER","LABOR"
        };
        String s1 = getTranslator().toExternalList("LOCTYPE", as);
        criteria = criteria + " and type not in (" + s1 + ")";
        setListCriteria(criteria);
        tempcriteria = criteria;
        Mbo mbo = getMboValue().getMbo();
        if (!mbo.isZombie()) {
          String s2 = getTranslator().toExternalList("LOCASSETSTATUS","DECOMMISSIONED", mbo);
          tempcriteria = criteria + "and status not in (" + s2 + ")";
          setListCriteria(tempcriteria);
        }
        String as1[] = {
            "swositeid", "location"
        };
        String as2[] = {
            "siteid", "location"
        };
        setLookupKeyMapInOrder(as1, as2);
        setErrorMessage("locations", "NotValidNonInventoryLoc");
      }catch(Exception exception) { }
    }

    public void validate()
        throws MXException, RemoteException
    {
        setListCriteria(criteria);
        super.validate();
    }
    /**
    public MboSetRemote getList()
        throws MXException, RemoteException
    {
        Mbo mbo = getMboValue().getMbo();
        if(mbo.isZombie())
        {
            setListCriteria(criteria);
        } else
        {
            String s = mbo.getString("ASSETUSER");
            String s2 = mbo.getString("ASSETCUST");
            String s3 = mbo.getTranslator().toInternalString("ASSETFILTERBY", mbo.getString("assetfilterby"));
            if(s3.equals("PUBLIC"))
                tempcriteria = criteria + " and not exists (select location from locationusercust where siteid=:assetsiteid and locationusercust.location=locations.location)";
            else
            if(s3.equals("USERCUST"))
            {
                if((s == null || s.equals("")) && (s2 == null || s2.equals("")))
                    tempcriteria = "1=2";
                else
                if(s == null || s.equals(""))
                    tempcriteria = criteria + " and (location in (select location from locationusercust where personid=:assetcust and iscustodian=:yes) )";
                else
                if(s2 == null || s2.equals(""))
                    tempcriteria = criteria + " and (location in (select location from locationusercust where personid=:assetuser and isuser=:yes) )";
                else
                if(s.equals(s2))
                    tempcriteria = criteria + " and (location in (select location from locationusercust where personid=:assetuser))";
                else
                    tempcriteria = criteria + " and (location in (select location from locationusercust where personid=:assetuser and isuser=:yes) or " + "location in (select location from locationusercust where personid=:assetcust and iscustodian=:yes) )";
            } else
            {
                tempcriteria = criteria;
            }
            setListCriteria(tempcriteria);
        }
        if(mbo.isNull("assetsiteid") && !mbo.isNull("assetorgid"))
        {
            String s1 = getListCriteria();
            setListCriteria("(" + s1 + " and orgid=:assetorgid )");
        }
        return super.getList();
    }
     */
    public void action()
        throws MXException, RemoteException
    {
        super.action();
        getMboValue().setReadOnly(false);
    }

    private String criteria;
    private String tempcriteria;
}
