Package Express.services

Examples of Express.services.BusinessClass


     * @param invokedByChildWindow Type: boolean (Input) (default in Forte: FALSE)
     */
    public void copyForeignKeysFromParentRecord(BusinessClass record, boolean invokedByChildWindow) {
        if (this.getWindowInfo() != null && (this.getWindowInfo().getLinkType() == ExpressContainerWindow.LT_COMMAND || this.getWindowInfo().getLinkType() == ExpressContainerWindow.LT_DRILLDOWN || invokedByChildWindow)) {
            if (this.getWindowInfo().getAssocNum() != 0) {
                BusinessClass currec = null;
                if (this.getWindowInfo().getParentWindow() != null) {
                    currec = this.getWindowInfo().getParentWindow().getCurRec();
                }

                if ((this.getWindowInfo().getDataToDisplay() == ExpressClassWindow.DD_ASSOCIATED_RECORD) && currec != null) {
                    BusinessQuery qry = currec.newQuery();
                    Array_Of_QueryAttrMap<QueryAttrMap> fks = qry.getForeignAttrMap(this.getWindowInfo().getAssocNum());
                    if (fks != null && fks.size() > 0 && fks.get(0).getLocal() == 1) {
                        //
                        // Record class contains a foreign key that references primary key
                        // in 'currec' class (Primary keys always begin at ATTR_ number=1).
                        //
                        int recStat = record.getInstanceStatus();
                        if (fks != null) {
                            for (QueryAttrMap fk : fks) {
                                record.setAttr(fk.getForeign(), currec.getAttr(fk.getLocal()));
                                if (this.getBusinessClient() != null) {
                                    this.getBusinessClient().logAttr(record, fk.getForeign());
                                }
                            }
                        }
View Full Code Here


     * @param confirm Type: boolean (Input) (default in Forte: FALSE)
     * @return boolean
     */
    @SuppressWarnings("unchecked")
  public boolean deleteRecordFromResultSet(boolean confirm) {
        BusinessClass theCurrentRecord = this.getCurRec();

        this.getStatusLine().setStatus(new TextData(this.getAppBroker().getLocalString(ApplicationBroker.MS_MESSAGE_SET, ApplicationBroker.MN_WORKING_DELETE)), (DataValue)null);

        if (confirm == true) {
            int answer = 0;
            //
            // request confirmation
            //
            answer = this.getAppBroker().confirmationDialog(new TextData(this.getAppBroker().getLocalString(ApplicationBroker.MS_MESSAGE_SET, ApplicationBroker.MN_CONFIRM_DELETE)), this.getWindowName(), JOptionPane.YES_NO_OPTION, JOptionPane.NO_OPTION, 50, this.getAppBroker().getPreferences().getConfirmDelete());
            if (answer == JOptionPane.NO_OPTION) {
                this.getStatusText().setValue( this.getAppBroker().getLocalString(ApplicationBroker.MS_MESSAGE_SET, ApplicationBroker.MN_ABORTED_DELETE) );
                return false;
            }
        }

        //
        // if this record is empty or is marked for insert,
        // we delete it from both result sets.
        //
        if (theCurrentRecord.getInstanceStatus() == BusinessClass.ST_INSERT || theCurrentRecord.getInstanceStatus() == BusinessClass.ST_EMPTY) {
            //
            // the index does not necessarily represent the index of
            // this record in the full result set, so locate it using
            // the DisplayResultSet's pointer, which we can find with
            // the index.
            //
            this.getResultSet().deleteRow(theCurrentRecord);

            //
            // otherwise, the record must be deleted from the
            // database, so we delete it from the displayed result
            // set after marking it for deletion.  The full
            // result set will retain it's pointer so that it
            // may delete the record when the user commits.
            //
        }
        else {
            //
            // Mark the record for deletion
            //
            this.getBusinessClient().delete(theCurrentRecord);

            //
            // Notify anyone who's listening that this window's
            // result set has changed
            //
            this.setIsResultSetModified(true);
            EventManager.postEvent( this, ExpressClassWindow.cEVENT_AFTER_RESULT_SET_CHANGE );

        }

        //
        // delete the row from the displayed result set.
        //
        this.deleteRec(this.getRecordIndex().getValue());

        //
        // Clear out any associated records
        //
        for (int i = 1; i <= this.getRecordTemplate().getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
            if (this.getRecordTemplate().hasAttr(i+10000) && (this.getRecordTemplate().getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) <= 0) {
                BusinessClass x = null;
                // ------------------------------
                // Parameters for call to GetAttr
                // ------------------------------
                ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                theCurrentRecord.getAttr(i+10000, qq_value);
                x = (BusinessClass)qq_value.getObject();
                if (x != null) {
                    x.reset(false);
                }
            }
            if (this.getRecordTemplate().hasAttr(i+10000) && (this.getRecordTemplate().getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                Array_Of_BusinessClass<BusinessClass> x = null;
                // ------------------------------
View Full Code Here

                                    //
                                    // handle to-one cases (assumes to one data is read only).
                                    //
                                    for (int i = 1; i <= template.getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
                                        if (template.hasAttr(i+10000) && (template.getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) <= 0) {
                                            BusinessClass newrec = null;
                                            // ------------------------------
                                            // Parameters for call to GetAttr
                                            // ------------------------------
                                            ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                                            newRecord.getAttr(i+10000, qq_value);
                                            newrec = (BusinessClass)qq_value.getObject();
                                            if (newrec != null) {
                                                record.setAttr(i+10000, newrec);
                                            }
                                        }
                                    }
                                    //
                                    // handle to-many cases
                                    //
                                    for (int i = 1; i <= template.getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
                                        if (template.hasAttr(i+10000) && (template.getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                                            Array_Of_BusinessClass<BusinessClass> newassoc = null;
                                            Array_Of_BusinessClass<BusinessClass> oldassoc = null;
                                            // ------------------------------
                                            // Parameters for call to GetAttr
                                            // ------------------------------
                                            ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                                            record.getAttr(i+10000, qq_value);
                                            oldassoc = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
                                            if (oldassoc != null) {
                                                oldassoc.clear();
                                            }
                                            // ------------------------------
                                            // Parameters for call to GetAttr
                                            // ------------------------------
                                            ParameterHolder_BusinessClass_Array qq_value1 = new ParameterHolder_BusinessClass_Array();
                                            newRecord.getAttr(i+10000, qq_value1);
                                            newassoc = (Array_Of_BusinessClass<BusinessClass>)qq_value1.getObject();
                                            if (newassoc != null && oldassoc != null) {
                                                //
                                                // Insert these associated records in existing array for that
                                                // association in 'record' (don't want to disconnect this result
                                                // set with one known to child window).
                                                //
                                                if (newassoc != null) {
                                                    for (BusinessClass rec : newassoc) {
                                                        oldassoc.add(rec);
                                                    }
                                                }
                                            }
                                            else if (newassoc != null && oldassoc == null) {
                                                record.setAttr(i+10000, newassoc);
                                            }
                                        }
                                    }
                                    // handle to-many cases
                                }
                            }
                            // Merge the new columns in with the old columns
                        }
                        // If this record is not a newly inserted record...
                    }
                }
                // Search for missing columns in all the given records.

                //
                // if the child window is requesting more information on
                // associated records, requery this window's selected
                // record to get the required associated columns.
                //
            }
            else {
                //
                // get a record template for the current window.
                //
                BusinessQuery criteria = this.getRecordTemplate();
                criteria.clearConstraints(false);

                //
                // store original criteria before changing it.
                //
                BusinessQuery previousCriteria = criteria.getQuery(assocNum);

                //
                // Minimize the number of queries we need to run.
                // Temporarily remove the old criteria from other associations.
                //
                Array_Of_BusinessQuery<BusinessQuery> tmpForeignClasses = criteria.getForeignClasses();
                criteria.setForeignClasses(null);

                //
                // Request the linked window's data. Merge the current criteria
                // for businessClass 'AssocNum' with that found in 'template'.
                //
                criteria.addAttr(assocNum, template);
                if (previousCriteria != null) {
                    criteria.addAttr(assocNum, previousCriteria);
                    // merge
                }

                if (this.getRecordIndex() != null && this.getCurRec() != null && this.getCurRec().getInstanceKey() != null) {
                    //
                    // Add keys for current record so will reselect this record.
                    //
                    for (int i = 1; i <= this.getRecordTemplate().getNumKeyAttrs(); i++) {
                        criteria.addConstraint(i, ConstraintOperation.OP_EQ, this.getCurRec().getInstanceKey().getValues().get(i-1));
                    }

                    //
                    // find the record (and it's associated records)
                    //
                    try {
                        if (this.getBusinessClient().transActive()) {
                            newData = this.getBusinessClient().select(criteria, ConcurrencyMgr.TR_CONTINUE);
                        }
                        else {
                            newData = this.getBusinessClient().select(criteria, ConcurrencyMgr.TR_START);
                        }
                        //
                        // restore original criteria for foreign classes
                        //
                    }
                    catch (Throwable qq_ElseException) {
                        criteria.setForeignClasses(tmpForeignClasses);
                       
                        throw (RuntimeException)qq_ElseException;
                    }
                }

                //
                // replace the given records with the fully fetched records
                //
                data.clear();
                if (newData != null && newData.get(0) != null) {
                    if ((criteria.getForeignAttrMult(assocNum)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                        Array_Of_BusinessClass<BusinessClass> a = null;
                        // ------------------------------
                        // Parameters for call to GetAttr
                        // ------------------------------
                        ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                        newData.get(0).getAttr(assocNum, qq_value);
                        a = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
                        if (a != null) {
                            for (BusinessClass rec : a) {
                                data.add(rec);
                            }
                        }

                    }
                    else {
                        BusinessClass b = null;
                        // ------------------------------
                        // Parameters for call to GetAttr
                        // ------------------------------
                        ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                        newData.get(0).getAttr(assocNum, qq_value);
                        b = (BusinessClass)qq_value.getObject();
                        // bug 37299 c : BusinessClass;
                        // bug 37299 GetCurRec().GetAttr(AssocNum, c );
                        // bug 37299 if c = NIL then
                        this.getCurRec().setAttr(assocNum, b);
                        // bug 37299 end if;
                        data.add(b);
                    }
                }

                //
                // restore original criteria
                //
                criteria.setForeignClasses(tmpForeignClasses);
            }

            //
            // if this window does not have access to a manager, pass
            // this request for dependent data to its parent.
            //
        }
        else {
            if (assocNum == 0) {
                if (LogMgr.getInstance().test(Framework.Constants.SP_MT_DEBUG, Framework.Constants.SP_ST_EX, 30, 110)) {
                    Logger.getLogger("task.part.logmgr").info(this.getWindowName());
                    Logger.getLogger("task.part.logmgr").info(".GetDependentData2: calling ");
                    Logger.getLogger("task.part.logmgr").info(this.getWindowInfo().getParentWindow().getWindowName());
                    Logger.getLogger("task.part.logmgr").info(".GetDependentData");
                }
                data = this.getWindowInfo().getParentWindow().getDependentData(data, template, this.getWindowInfo().getAssocNum());
            }
            else {
                newData = new Array_Of_BusinessClass<BusinessClass>();
                newData.set(0, this.getCurRec());
                //
                // Clone this window's current record so we don't modify the
                // actual current record when it gets passed to GetDependentData
                // below.
                //
                if (newData.get(0) != null) {
                    if (LogMgr.getInstance().test(Framework.Constants.SP_MT_DEBUG, Framework.Constants.SP_ST_EX, 30, 110)) {
                        Logger.getLogger("task.part.logmgr").info(this.getWindowName());
                        Logger.getLogger("task.part.logmgr").info(".GetDependentData: doing newData[1].Clone()");
                    }

                    newData.set(0, CloneHelper.clone(newData.get(0), false));
                    //
                    // Also clone the to-many (array) reference attributes.
                    //
                    for (int i = 1; i <= this.getRecordTemplate().getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
                        if ((this.getRecordTemplate().getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                            Array_Of_BusinessClass<BusinessClass> tmpAry = null;
                            // ------------------------------
                            // Parameters for call to GetAttr
                            // ------------------------------
                            ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                            newData.get(0).getAttr(i+10000, qq_value);
                            tmpAry = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
                            if (tmpAry != null) {
                                tmpAry = CloneHelper.clone(tmpAry, false);
                                newData.get(0).setAttr(i+10000, tmpAry);
                            }
                        }
                    }
                }

                //
                // As long as the current record in this window has not been
                // recently inserted, pass it to its parent to see if the
                // parent can find the missing columns.
                //
                if (newData.get(0) != null && newData.get(0).getInstanceStatus() != BusinessClass.ST_INSERT && newData.get(0).getInstanceStatus() != BusinessClass.ST_EMPTY) {
                    BusinessQuery criteria = this.getRecordTemplate();
                    criteria.clearConstraints(false);
                    BusinessClass curRec = newData.get(0);

                    //
                    // store original criteria before changing it.
                    //
                    BusinessQuery previousCriteria = criteria.getQuery(assocNum);

                    //
                    // Minimize the number of queries we need to run.
                    // Temporarily remove the old criteria from other associations.
                    //
                    Array_Of_BusinessQuery<BusinessQuery> tmpForeignClasses = criteria.getForeignClasses();
                    criteria.setForeignClasses(null);

                    //
                    // Request the linked window's data.  Merge the current
                    // criteria for 'AssocNum' with that found in 'template'.
                    //
                    criteria.addAttr(assocNum, template);
                    if (previousCriteria != null) {
                        criteria.addAttr(assocNum, previousCriteria);
                        // merge
                    }

                    if (LogMgr.getInstance().test(Framework.Constants.SP_MT_DEBUG, Framework.Constants.SP_ST_EX, 30, 110)) {
                        Logger.getLogger("task.part.logmgr").info(this.getWindowName());
                        Logger.getLogger("task.part.logmgr").info(".GetDependentData2: calling ");
                        Logger.getLogger("task.part.logmgr").info(this.getWindowInfo().getParentWindow().getWindowName());
                        Logger.getLogger("task.part.logmgr").info(".GetDependentData");
                    }
                    try {
                        newData = this.getWindowInfo().getParentWindow().getDependentData(newData, criteria, this.getWindowInfo().getAssocNum());
                        //
                        // restore original criteria for foreign classes
                        //
                    }
                    catch (Throwable qq_ElseException) {
                        criteria.setForeignClasses(tmpForeignClasses);
                       
                        throw (RuntimeException)qq_ElseException;
                    }

                    if (newData != null) {
                        //
                        // Compare record keys to make sure we update correct record in
                        // window (fetched records may be in different order from those in window).
                        //
                        int updrecno = this.getRecordIndex().getValue();
                        if (curRec.getInstanceKey() != null) {
                            if (newData.get(this.getRecordIndex().getValue()-1) == null || curRec.getInstanceKey().compare(newData.get(this.getRecordIndex().getValue()-1).getInstanceKey()) != BusinessKey.CMP_EQ) {
                                //
                                // search result set for row with same key value as current
                                // row in window.
                                //
                                for (int i = 1; i <= newData.size(); i++) {
                                    if (newData.get(i-1) != null && newData.get(i-1).getInstanceKey().compare(curRec.getInstanceKey()) == BusinessKey.CMP_EQ) {
                                        updrecno = i;
                                        break;
                                    }
                                }
                            }
                        }

                        if ((criteria.getForeignAttrMult(assocNum)&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
                            Array_Of_BusinessClass<BusinessClass> a = null;
                            if (newData.get(updrecno-1) != null) {
                                // ------------------------------
                                // Parameters for call to GetAttr
                                // ------------------------------
                                ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
                                newData.get(updrecno-1).getAttr(assocNum, qq_value);
                                a = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
                            }
                            if (a != data) {
                                data.clear();
                                if (a != null) {
                                    for (BusinessClass rec : a) {
                                        data.add(rec);
                                    }
                                }
                            }
                            else {
                                // Nothing to do. ParentWindow.GetDependentData must
                                // have already done the above appends.
                            }
                        }
                        else {
                            BusinessClass b = null;
                            if (newData.get(updrecno-1) != null) {
                                // ------------------------------
                                // Parameters for call to GetAttr
                                // ------------------------------
                                ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
View Full Code Here

        //
        // Check x to One Foreign attributes
        //
        for (int i = 1; i <= template.getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
            if (template.hasAttr(i+10000) && (template.getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) <= 0) {
                BusinessClass rec = null;
                // ------------------------------
                // Parameters for call to GetAttr
                // ------------------------------
                ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                record.getAttr(i+10000, qq_value);
View Full Code Here

        // have the default (this will avoid errors on
        // Microsoft SQL Server)
        //
        for (int i = 1; i <= template.getNumAttrs(BusinessQuery.ATTR_FOREIGN); i++) {
            if (template.hasAttr(i+10000) && (template.getForeignAttrMult(i+10000)&BusinessQuery.ASSOC_MULT_TO_MANY) <= 0) {
                BusinessClass rec = null;
                // ------------------------------
                // Parameters for call to GetAttr
                // ------------------------------
                ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
                record.getAttr(i+10000, qq_value);
View Full Code Here

            this.getResultSet().set(0, record);
            //
            // Make sure parent window's current record references the
            // same record as this window's result set.
            //
            BusinessClass rec = this.getParentCurrentRecord();
            if (rec != null) {
                rec.setAttr(this.getWindowInfo().getAssocNum(), record);
            }
        }
        else {
            this.getResultSet().add(record);
        }
View Full Code Here

                // added in custom code.
                //
                if (extraRecords != null) {
          for (Iterator<BusinessClass> iterator = extraRecords
              .iterator(); iterator.hasNext();) {
            BusinessClass r = iterator.next();
            this.getResultSet().deleteRow(r);
          }
        }
   
                //
                // remove any extra records the developer has
                // added in custom code.
                //
            }
            catch (Throwable qq_ElseException) {
                if (extraRecords != null) {
          for (Iterator<BusinessClass> iterator = extraRecords
              .iterator(); iterator.hasNext();) {
            BusinessClass r = iterator.next();
            this.getResultSet().deleteRow(r);
          }
        }
                // ----------------------------------------
                // Parameters for call to IsSaveAppropriate
View Full Code Here

    public ExpressClassWindow getParentWindow() {
        return this.parentWindow;
    }

    public void setParentWindowCurrentRecord(BusinessClass parentWindowCurrentRecord) {
        BusinessClass oldValue = this.parentWindowCurrentRecord;
        this.parentWindowCurrentRecord = parentWindowCurrentRecord;
        this.qq_Listeners.firePropertyChange("parentWindowCurrentRecord", oldValue, this.parentWindowCurrentRecord);
    }
View Full Code Here

     * @param attrNumber Type: int
     * @param attrValue Type: DataValue
     */
    public void handleValueChange(int attrNumber, DataValue attrValue) {
        try {
            BusinessClass theCurrentRecord = this.getCurRec();
   
            //
            // Ignore the change if the user is in search mode.
            //
            if (this.getWindowMode().intValue() == ExpressContainerWindow.WM_EDIT) {
                //
                // Call any user provided validation.  If any errors
                // occur, this method will raise an exception and abort
                // the value change.
                //
                this.validateField(attrNumber, attrValue);
   
                //
                // Mark the field as changed.
                //
                if (this.getBusinessClient() != null) {
                    this.getBusinessClient().logAttr(theCurrentRecord, attrNumber);
                }
   
                //
                // Change the field in the selected record.
                //
                if (theCurrentRecord != null) {
                    theCurrentRecord.setAttrValue(attrNumber, attrValue);
                }
   
                //
                // Mark the result set as modified.
                //
View Full Code Here

     * @param invokedByChildWindow Type: boolean (Input) (default in Forte: FALSE)
     */
    public void copyForeignKeysFromParentRecord(BusinessClass record, boolean invokedByChildWindow) {
        if (this.getWindowInfo() != null && (this.getWindowInfo().getLinkType() == ExpressContainerWindow.LT_COMMAND || this.getWindowInfo().getLinkType() == ExpressContainerWindow.LT_DRILLDOWN || invokedByChildWindow)) {
            if (this.getWindowInfo().getAssocNum() != 0) {
                BusinessClass currec = null;
                if (this.getWindowInfo().getParentWindow() != null) {
                    currec = this.getWindowInfo().getParentWindow().getCurRec();
                }

                if ((this.getWindowInfo().getDataToDisplay() == ExpressClassWindow.DD_ASSOCIATED_RECORD) && currec != null) {
                    BusinessQuery qry = currec.newQuery();
                    Array_Of_QueryAttrMap<QueryAttrMap> fks = qry.getForeignAttrMap(this.getWindowInfo().getAssocNum());
                    if (fks != null && fks.size() > 0 && fks.get(0).getLocal() == 1) {
                        //
                        // Record class contains a foreign key that references primary key
                        // in 'currec' class (Primary keys always begin at ATTR_ number=1).
                        //
                        int recStat = record.getInstanceStatus();
                        if (fks != null) {
                            for (QueryAttrMap fk : fks) {
                                record.setAttr(fk.getForeign(), currec.getAttr(fk.getLocal()));
                                if (this.getBusinessClient() != null) {
                                    this.getBusinessClient().logAttr(record, fk.getForeign());
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of Express.services.BusinessClass

Copyright © 2018 www.massapicom. 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.