Package Express.services

Source Code of Express.services.BusinessClass

/*
Copyright (c) 2003-2009 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package Express.services;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Iterator;

import DisplayProject.binding.beans.ExtendedPropertyChangeSupport;
import DisplayProject.binding.beans.Observable;
import Framework.Array_Of_DataValue;
import Framework.BinaryData;
import Framework.DataValue;
import Framework.DecimalData;
import Framework.DoubleData;
import Framework.ImageData;
import Framework.IntegerData;
import Framework.NumericFormat;
import Framework.RuntimeProperties;
import Framework.TextData;

/**
* BusinessClass is the superclass for all classes generated from a business class in an Express business model.
* <p>
* @author ITerative Consulting
* @since  26-Feb-2008
*/
@RuntimeProperties(isDistributed=false, isAnchored=false, isShared=false, isTransactional=false)
@SuppressWarnings("serial")
public class BusinessClass
        implements Serializable, Observable
{

    // ---------
    // Constants
    // ---------
    public static final int ST_DELETE = 32;
    public static final int ST_EMPTY = 1;
    public static final int ST_INSERT = 16;
    public static final int ST_READONLY = 2;
    public static final int ST_READWRITE = 4;
    public static final int ST_UPDATE = 8;

    // ----------
    // Attributes
    // ----------
    public PropertyChangeSupport qq_Listeners = new ExtendedPropertyChangeSupport(this, true);
    private BusinessKey instanceKey;
    private int instanceStatus;
    private BusinessQuery updateQuery;

    // ------------
    // Constructors
    // ------------
    public BusinessClass() {
        // Explicitly call the superclass constructor to prevent the implicit call
        super();

        this.setInstanceStatus(BusinessClass.ST_EMPTY);

    }

    // ----------------------
    // Accessors and Mutators
    // ----------------------
    public void setInstanceKey(BusinessKey instanceKey) {
        BusinessKey oldValue = this.instanceKey;
        this.instanceKey = instanceKey;
        this.qq_Listeners.firePropertyChange("instanceKey", oldValue, this.instanceKey);
    }

    public BusinessKey getInstanceKey() {
        return this.instanceKey;
    }

    public void setInstanceStatus(int instanceStatus) {
        int oldValue = this.instanceStatus;
        this.instanceStatus = instanceStatus;
        this.qq_Listeners.firePropertyChange("instanceStatus", oldValue, this.instanceStatus);
    }

    public int getInstanceStatus() {
        return this.instanceStatus;
    }

    public void setUpdateQuery(BusinessQuery updateQuery) {
        BusinessQuery oldValue = this.updateQuery;
        this.updateQuery = updateQuery;
        this.qq_Listeners.firePropertyChange("updateQuery", oldValue, this.updateQuery);
    }

    public BusinessQuery getUpdateQuery() {
        return this.updateQuery;
    }

    // -------
    // Methods
    // -------
    public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(property, listener);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(property, listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(listener);
    }

    /**
     * fillString<p>
     * FillString<br>
     *     The FillString method returns a formatted string describing the<br>
     *     BusinessClasses in the source array.  Each attribute of each<br>
     *     BusinessClass in the array is listed along with its present value.<br>
     * <p>
     *     source<br>
     *       Specifies the array of BusinessClasses to format.<br>
     * <p>
     *     level<br>
     *       Specifies how many levels of tabs to indent the text.<br>
     * <p>
     * @param source Type: Array_Of_BusinessClass<BusinessClass>
     * @param level Type: int (Input) (default in Forte: 0)
     * @return TextData
     */
    public TextData fillString(Array_Of_BusinessClass<BusinessClass> source, int level) {
        TextData indent = new TextData("\n");
        TextData result = new TextData();

        for (int i = 1; i <= level; i++) {
            indent.concat("   ");
        }

        if (source == null) {

            result.concat("BusinessClass array is NIL.");

        }
        else if (source.size() == 0) {

            result.concat("BusinessClass array of 0 items.");

        }
        else {

            result.concat(source.get(0).getClass().getSimpleName());
            result.concat(" array of ");
            result.concat(source.size());
            if (source.size() == 1) {
                result.concat(" item:");
            }
            else {
                result.concat(" items:");
            }

            int i = 1;
            if (source != null) {
                for (BusinessClass e : source) {
                    result.concat(indent);
                    result.concat("[");
                    result.concat(i);
                    result.concat("]:\n");
                    result.concat(e.fillString(level+1));
                    i = i+1;
                }
            }

        }

        return result;
    }
    /**
     * Overload with default value
     * @param source
     * @return
     */
    public TextData fillString(Array_Of_BusinessClass<BusinessClass> source) {
      return this.fillString(source, 0);
    }

    /**
     * fillString<p>
     * FillString<br>
     *     The FillString method returns a formatted string describing the<br>
     *     BusinessClass.  Each attribute of the BusinessClass is listed along<br>
     *     with its present value.<br>
     * <p>
     *     level<br>
     *       Specifies how many levels of tabs to indent the text.<br>
     * <p>
     * @param level Type: int (Input) (default in Forte: 0)
     * @return TextData
     */
    @SuppressWarnings("unchecked")
  public TextData fillString(int level) {
        DataValue attr = null;
        BusinessQuery query = null;
        TextData indent = new TextData("\n");
        TextData result = new TextData();

        for (int i = 1; i <= level; i++) {
            indent.concat("   ");
            result.concat("   ");
        }

        query = this.newQuery();
        query.setOperation(BusinessQuery.OP_INSERT, (BusinessKey)null);
        SqlQuery sqlQuery = new SqlQuery(BusinessQuery.OP_INSERT);
        query.describeTables(sqlQuery);
        result.concat(this.getClass().getSimpleName());
        result.concat(": Status = ");
        result.concat(this.statusAsTextData());
        result.concat(", Key = ");
        if (this.getInstanceKey() == null) {
            result.concat("<NIL>");
        }
        else {
            result.concat(this.getInstanceKey().asTextData());
        }

        for (int j = 1; j <= query.getNumAttrs(); j++) {
            result.concat(indent);
            attr = this.getAttr(j);
            result.concat("Attribute ");
            result.concat(j);
            result.concat(" (");
            result.concat(query.getAttrName(j));
            result.concat(") = ");
            if (attr == null) {
                result.concat("<NIL>");
            }
            else if (attr.getIsNull()) {
                result.concat("<NULL>");
            }
            else if (attr instanceof DoubleData && ((DoubleData)attr).getValue() < 1e+012 && ((DoubleData)attr).getValue() > 1e-012) {
                result.concat(new NumericFormat(new TextData("#.############"), NumericFormat.qq_Resolver.cTEMPLATE).formatNumeric((DoubleData)attr));
            }
            else if (attr instanceof DecimalData) {
                result.concat(new NumericFormat(new TextData("#.############"), NumericFormat.qq_Resolver.cTEMPLATE).formatNumeric((DecimalData)attr));
            }
            else if (attr instanceof TextData) {
                result.concat("\"");
                result.concat(attr);
                result.concat("\"");
            }
            else if (attr instanceof BinaryData || attr instanceof ImageData) {
                BinaryData a = null;
                if (attr instanceof ImageData) {
                    a = new BinaryData();
                    a.setValue(attr);
                }
                else {
                    a = (BinaryData)attr;
                }
                byte[] p = a.getValue();
                int n = ((BinaryData)a).getActualSize();
                int sum = 0;
                result.concat("0x");
                if (n > 16) {
                    n = 16;
                }
                for (int i = 0; i <= n-1; i++) {
                    result.concat(p[i] / 16);
                    result.concat(p[i] & 15);
                }
                n = ((BinaryData)a).getActualSize();
                if (attr instanceof ImageData) {
                    result.concat(":ImageData(length=");
                }
                else {
                    result.concat(":BinaryData(length=");
                }
                result.concat(n);
                result.concat(",checkSum=");
                if (n > 1000000) {
                    n = 1000000;
                }
                for (int i = 0; i <= n; i++) {
                    sum = sum + p[i];
                }
                result.concat(sum);
                result.concat(")");
            }
            else {
                result.concat(attr);
            }
        }

        for (int j = 1; j <= query.getNumForeignAttrs(); j++) {
            if ((query.getForeignAttrMult(BusinessQuery.ATTR_FOREIGN+j)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                Array_Of_BusinessClass<BusinessClass> de = null;
                // ------------------------------
                // Parameters for call to GetAttr
                // ------------------------------
                ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                this.getAttr(BusinessQuery.ATTR_FOREIGN+j, qq_value);
                de = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
                if (de != null) {
                    result.concat(indent);
                    result.concat("Foreign Attribute ");
                    result.concat(j);
                    result.concat(" (");
                    result.concat(query.getAttrName(BusinessQuery.ATTR_FOREIGN+j));
                    result.concat("):  ");
                    result.concat(this.fillString(de, level));
                }
            }
            else {
                BusinessClass fe = null;
                // ------------------------------
                // Parameters for call to GetAttr
                // ------------------------------
                ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                this.getAttr(BusinessQuery.ATTR_FOREIGN+j, qq_value);
                fe = (BusinessClass)qq_value.getObject();
                if (fe != null) {
                    result.concat(indent);
                    result.concat("Foreign Attribute ");
                    result.concat(j);
                    result.concat(" (");
                    result.concat(query.getAttrName(BusinessQuery.ATTR_FOREIGN+j));
                    result.concat("):\n");
                    result.concat(fe.fillString(level+1));
                }
            }
        }

        return result;
    }
    /**
     * Overload with default value
     * @return
     */
    public TextData fillString() {
      return this.fillString(0);
    }
    /**
     * getAttr<p>
     * GetAttr<br>
     *     Use GetAttr when you want to retrieve an attribute which is a foreign<br>
     *     BusinessClass in a one to many relationship from a BusinessClass based<br>
     *     upon the attribute's attribute index.<br>
     * <p>
     *     This method will be overridden by the classes generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to return.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       Returns the array of foreign BusinessClasses.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: Array_Of_BusinessClass<BusinessClass>
     */
    public void getAttr(int attr, ParameterHolder_BusinessClass_Array value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "GetAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * getAttr<p>
     * GetAttr<br>
     *     Use GetAttr when you want to retrieve an attribute which is a foreign<br>
     *     BusinessClass in a one to one relationship from a BusinessClass based<br>
     *     upon the attribute's attribute index.<br>
     * <p>
     *     This method will be overridden by the classes generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to return.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       Returns the requested foreign BusinessClass.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: BusinessClass
     */
    public void getAttr(int attr, ParameterHolder_BusinessClass value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "GetAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * getAttr<p>
     * GetAttr<br>
     *     Use GetAttr when you want to retrieve a simple attribute from a<br>
     *     BusinessClass based upon the attribute's attribute index.  A simple<br>
     *     attribute is one that is a DataValue and not a reference to a foreign<br>
     *     BusinessClass.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to return.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the entity's Query class.<br>
     * <p>
     * @param attr Type: int
     * @return DataValue
     */
    public DataValue getAttr(int attr) {
        throw new Error(Error.B_ILLEGAL_ATTR, "GetAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * newAttr<p>
     * NewAttr<br>
     *     Use NewAttr when you want to instantiate an attribute which is a<br>
     *     foreign BusinessClass in a one to many relationship based upon the<br>
     *     attribute's attribute index.  Normally you would do this when you want<br>
     *     to insert BusinessClasses in aggregate relationships to a<br>
     *     BusinessClass that you are inserting.  The BusinessMgr will also use<br>
     *     NewAttr when it is creating the BusinessClasses to return from a Select.<br>
     * <p>
     *     NewAttr instantiates a new array of the appropriate subclass of<br>
     *     BusinessClass for the attribute indicated by the attr parameter and as<br>
     *     a side effect returns it as the functional result.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to create.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       Returns the BusinessClass array.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: Array_Of_BusinessClass<BusinessClass>
     */
    public void newAttr(int attr, ParameterHolder_BusinessClass_Array value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "NewAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * newAttr<p>
     * NewAttr<br>
     *     NewAttr instantiates a new BusinessClass of the appropriate subclass of<br>
     *     BusinessClass for the attribute indicated by the attr parameter and as<br>
     *     a side effect returns it as the functional result.  The attribute<br>
     *     should be for a foreign BusinessClass.  Normally this method is only<br>
     *     used by the entity's manager when creating BusinessClasses to return<br>
     *     from a Select call.<br>
     * <p>
     *     This method will be overridden by the classes generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to create.  There is a<br>
     *       constant for each attribute of the BusinessClass.  These constants<br>
     *       are defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       Returns the BusinessClass for the foreign attribute.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: BusinessClass
     */
    public void newAttr(int attr, ParameterHolder_BusinessClass value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "NewAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * newAttr<p>
     * NewAttr<br>
     *     Use NewAttr when you want to instantiate a simple attribute for a<br>
     *     BusinessClass based upon the attribute's attribute index.  A simple<br>
     *     attribute is one that is a DataValue and not a reference to a foreign<br>
     *     BusinessClass.<br>
     * <p>
     *     NewAttr instantiates a new object of the appropriate subclass of<br>
     *     DataValue for the attribute indicated by the attr parameter and as a<br>
     *     side effect returns it as the functional result.  No initialization of<br>
     *     the value of the attribute is performed thus it has the default<br>
     *     initial value for its class.  For text attributes the value will zero<br>
     *     length, for numeric attributes the value will be 0.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to create.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the entity's Query class.<br>
     * <p>
     * @param attr Type: int
     * @return DataValue
     */
    public DataValue newAttr(int attr) {
        throw new Error(Error.B_ILLEGAL_ATTR, "NewAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * newQuery<p>
     * NewQuery<br>
     *     NewQuery creates a query of the classes subclass of BusinessQuery<br>
     *     and sets the Query attribute to it.  It is not normally called directly<br>
     *     but is done by LogAttr or Delete.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.<br>
     * <p>
     * @return BusinessQuery
     */
    public BusinessQuery newQuery() {
        throw new Error(Error.GEN_UNIMPLEMENTED, "NewQuery", this).getException();
    }

    /**
     * reset<p>
     * Reset<br>
     *     Reset is not normally invoked directly.  It is used by the classes<br>
     *     BusinessClient to reset the state of the entity after an Update has<br>
     *     been performed.<br>
     * <p>
     *     Reset removes any deleted BusinessClasses from the array and performs<br>
     *     a reset on the remaining objects.<br>
     * <p>
     *     classes<br>
     *       The classes parameter provides a list of BusinessClasses which<br>
     *       are to be reset.<br>
     * <p>
     * @param classes Type: Array_Of_BusinessClass<BusinessClass>
     * @param resetKey Type: boolean (Input) (default in Forte: FALSE)
     */
    public void reset(Array_Of_BusinessClass<BusinessClass> classes, boolean resetKey) {
        BusinessClass e = null;

        if (classes != null) {
         
          Iterator<BusinessClass> it = classes.iterator();
          while (it.hasNext()){
              e = it.next();

                e.reset(resetKey);

                if (e.getInstanceStatus() == BusinessClass.ST_EMPTY) {
                    it.remove();
                }

            }

        }
    }

    /**
     * reset<p>
     * Reset<br>
     *     Reset is not normally invoked directly.  It is used by the classes<br>
     *     BusinessClient to reset the state of the entity after an Update has<br>
     *     been performed.<br>
     * <p>
     *     Reset sets the Key, clears the Query, and performs a Reset on all<br>
     *     foreign BusinessClasses.<br>
     * <p>
     * @param resetKey Type: boolean (Input) (default in Forte: FALSE)
     */
    @SuppressWarnings("unchecked")
  public void reset(boolean resetKey) {
        if (this.getUpdateQuery() == null) {

            if ((this.getInstanceStatus()&(BusinessClass.ST_UPDATE|BusinessClass.ST_INSERT|BusinessClass.ST_DELETE)) > 0) {
                //
                //  There is no Query but the Status indicates a LogAttr has been
                //  performed.  That is inconsistent.
                //
                throw new Error(Error.B_INCONSISTENT_STATE, "Reset", this, this, Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
            }

        }
        else if (this.getInstanceStatus() == BusinessClass.ST_DELETE) {
            //
            //  By now the delete should have been performed so we essentially do away
            //  with this entity by putting it into the empty state.
            //
            this.setInstanceStatus(BusinessClass.ST_EMPTY);

        }
        else if (this.getInstanceStatus() != BusinessClass.ST_EMPTY) {

            if (resetKey) {
                //
                //  An update might have modified the key so we need to set it again.
                //
                this.setKey(true);
            }

            //
            //  If any dependent entities were modified they need to be reset as well
            //
            if (this.getUpdateQuery().getForeignClasses() != null) {

                Array_Of_BusinessClass<BusinessClass> foreignClasses = null;
                BusinessClass foreignClass = null;

                Array_Of_BusinessQuery<BusinessQuery> qq_localVector = this.getUpdateQuery().getForeignClasses();
                if (qq_localVector != null) {
                    for (BusinessQuery q : qq_localVector) {

                        if ((q.getParentMult()&BusinessQuery.ASSOC_MULT_ONE_MASK) > 0) {

                            // ------------------------------
                            // Parameters for call to GetAttr
                            // ------------------------------
                            ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                            this.getAttr(q.getParentAttr(), qq_value);
                            foreignClass = (BusinessClass)qq_value.getObject();

                            foreignClass.reset(false);
                            if (foreignClass.getInstanceStatus() == BusinessClass.ST_EMPTY) {
                                this.setAttr(q.getParentAttr(), (BusinessClass)(null));
                            }

                        }
                        else {

                            // ------------------------------
                            // Parameters for call to GetAttr
                            // ------------------------------
                            ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                            this.getAttr(q.getParentAttr(), qq_value);
                            foreignClasses = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();

                            this.reset(foreignClasses, false);

                        }

                    }
                }

            }

            //
            //  Reset the status.
            //
            this.setInstanceStatus(BusinessClass.ST_READWRITE);

        }

        //
        //  And finally clear the Query.
        //
        this.setUpdateQuery(null);
    }
    public void reset() {
      this.reset(false);
    }
    /**
     * setAttr<p>
     * SetAttrRef<br>
     *     Use SetAttrRef when you want to set the attribute pointer of a simple<br>
     *     attribute for a BusinessClass based upon the attribute's attribute<br>
     *     index.  A simple attribute is one that is a DataValue and not a<br>
     *     reference to a foreign BusinessClass.<br>
     * <p>
     *     This method will be overridden by the classes generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to set.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       The object to which to point the attribute.  Note that the value<br>
     *       of the value parameter is not copied.  This means that subsequent<br>
     *       changes to the value parameter will affect the attribute's value.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: DataValue
     */
    public void setAttr(int attr, DataValue value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "SetAttr", this).getException();
    }

    /**
     * setAttr<p>
     * SetAttr<br>
     *     Use SetAttr when you want to set the value of an attribute which is a<br>
     *     foreign BusinessClass in a one to one relationship based upon the<br>
     *     attribute's attribute index.<br>
     * <p>
     *     This method will be overridden by the classes generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to return.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the entity's Query class.<br>
     * <p>
     *     value<br>
     *       The foreign entity to which to point the attribute.  Note that the<br>
     *       values are not copied.  This means that subsequent changes to value<br>
     *       will be seen through this entity's attribute as they both point to<br>
     *       the same object.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: BusinessClass
     */
    public void setAttr(int attr, BusinessClass value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "SetAttr", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
    }

    /**
     * setAttr<p>
     * SetAttr<br>
     *     Use SetAttr when you want to set the value of an attribute which is a<br>
     *     foreign BusinessClass in a one to many relationship based upon<br>
     *     the attribute's attribute index.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to return.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the entity's Query class.<br>
     * <p>
     *     value<br>
     *       The dependent entity array to which to point the attribute.  Note<br>
     *       that the values are not copied.  This means that subsequent changes<br>
     *       to value will be seen through this entity's attribute as they both<br>
     *       point to the same objects.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: Array_Of_BusinessClass<BusinessClass>
     */
    public void setAttr(int attr, Array_Of_BusinessClass<BusinessClass> value) {
        throw new Error(Error.B_ILLEGAL_ATTR, "SetAttr", this).getException();
    }

    /**
     * setAttrValue<p>
     * SetAttrValue<br>
     *     Use SetAttrValue when you want to set the value of a simple attribute<br>
     *     for a BusinessClass based upon the attribute's attribute index.  A<br>
     *     simple attribute is one that is a DataValue and not a reference to a<br>
     *     foreign  BusinessClass.<br>
     * <p>
     *     attr<br>
     *       An index identifying which attribute to set.  There is a<br>
     *       constant for each attribute of the entity.  These constants are<br>
     *       defined in the classes Query class.<br>
     * <p>
     *     value<br>
     *       The value to which to set the attribute.  Note that the attribute's<br>
     *       value is set to the value of the value parameter.  The attribute<br>
     *       itself is not set.  This means that subsequent changes to the<br>
     *       value parameter will not affect the attribute's value.  If the<br>
     *       attribute hasn't been created yet (NewAttr has never been invoked<br>
     *       for it) then it will be created implicitly.<br>
     * <p>
     * @param attr Type: int
     * @param value Type: DataValue
     */
    public void setAttrValue(int attr, DataValue value) {
        DataValue attrVal = null;

        attrVal = this.getAttr(attr);

        if (attrVal == null) {
            attrVal = this.newAttr(attr);
        }

        attrVal.setValue(value);
    }

    /**
     * setKey<p>
     * SetKey<br>
     *     SetKey is not normally invoked directly.  The Reset method and the<br>
     *     Select method on the BusinessMgr use it when a key has changed<br>
     *     because of an update or when the BusinessClass is initially created<br>
     *     during Select.<br>
     * <p>
     *     This method will be overridden by the entity's generated class.  The<br>
     *     generated method will invoke the super class method (this method)<br>
     *     which will instantiate or clear the InstanceKey attribute and then the<br>
     *     generated method will append the attributes of the entity which<br>
     *     comprise the key to the InstanceKey attribute.<br>
     * <p>
     *     deep<br>
     *       If set to TRUE then foreign BusinessClasses will also have<br>
     *       their keys set.<br>
     * <p>
     * @param deep Type: boolean (Input) (default in Forte: TRUE)
     */
    public void setKey(boolean deep) {
        if (this.getInstanceKey() == null) {
            this.setInstanceKey(new BusinessKey());
        }
        else {
            this.getInstanceKey().setValues(new Array_Of_DataValue<DataValue>());
        }
    }

    /**
     * statusAsTextData<p>
     * StatusAsTextData<br>
     *     Returns as its functional result a text representation of the Status<br>
     *     attribute.  It is used in error reporting.<br>
     * <p>
     * @return TextData
     */
    public TextData statusAsTextData() {
        switch (this.getInstanceStatus()) {

            case BusinessClass.ST_EMPTY: {
                return new TextData("ST_EMPTY");

            }
            case BusinessClass.ST_READONLY: {
                return new TextData("ST_READONLY");

            }
            case BusinessClass.ST_READWRITE: {
                return new TextData("ST_READWRITE");

            }
            case BusinessClass.ST_UPDATE: {
                return new TextData("ST_UPDATE");

            }
            case BusinessClass.ST_INSERT: {
                return new TextData("ST_INSERT");

            }
            case BusinessClass.ST_DELETE: {
                return new TextData("ST_DELETE");

            }

            default: {
                return new TextData("UNKNOWN");

            }
        }
    }

    /**
     * validateInstance<p>
     * ValidateInstance<br>
     *     The ValidateInstance method is provided as a customization point to<br>
     *     perform validations and implement business rules that take effect<br>
     *     when a BusinessClass object is modified.  ValidateInstance is invoked<br>
     *     automatically whenever the BusinessClass is modified via the Update<br>
     *     method of the BusinessClient.  Additionally it may be invoked by the<br>
     *     user whenever desired.<br>
     * <p>
     *     client<br>
     *       The client parameter identifies the BusinessClient object that<br>
     *       will be used to modify this object.<br>
     * <p>
     * @param client Type: BusinessClient
     */
    public void validateInstance(BusinessClient client) {
        if (client == null) {
            throw new Error(Error.GEN_NIL_PARAMETER, "ValidateInstance", this, new TextData("client"), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM2).getException();
        }
    }
// end class BusinessClass
// c Pass 2 Conversion Time: 1750 milliseconds
TOP

Related Classes of Express.services.BusinessClass

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.