/*
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 org.apache.log4j.Logger;
import DisplayProject.binding.beans.ExtendedPropertyChangeSupport;
import DisplayProject.binding.beans.Observable;
import Express.domains.LongTextDomain;
import Express.services.interfaces.IBusinessServiceMgr;
import Framework.Array_Of_DataValue;
import Framework.DataValue;
import Framework.IntegerData;
import Framework.RuntimeProperties;
import GenericDBMS.Constants;
/**
* This class appears in the project, but is for internal use only and is not documented.
* <p>
* @author ITerative Consulting
* @since 26-Feb-2008
*/
@RuntimeProperties(isDistributed=false, isAnchored=false, isShared=false, isTransactional=false)
@SuppressWarnings("serial")
public class ServiceConcurrency
implements Serializable, Observable
{
// ----------
// Attributes
// ----------
public PropertyChangeSupport qq_Listeners = new ExtendedPropertyChangeSupport(this, true);
private int cacheMode;
private ConcurrencyMgr concurrencyMgr;
private int concurrencyMode;
private IBusinessServiceMgr parentService;
// ------------
// Constructors
// ------------
public ServiceConcurrency() {
// Explicitly call the superclass constructor to prevent the implicit call
super();
}
// ----------------------
// Accessors and Mutators
// ----------------------
public void setConcurrencyMode(int concurrencyMode) {
int oldValue = this.concurrencyMode;
this.concurrencyMode = concurrencyMode;
this.qq_Listeners.firePropertyChange("concurrencyMode", oldValue, this.concurrencyMode);
}
public int getConcurrencyMode() {
return this.concurrencyMode;
}
public void setParentService(IBusinessServiceMgr parentService) {
IBusinessServiceMgr oldValue = this.parentService;
this.parentService = parentService;
this.qq_Listeners.firePropertyChange("parentService", oldValue, this.parentService);
}
public IBusinessServiceMgr getParentService() {
return this.parentService;
}
// -------
// 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);
}
/**
* addAggregateInfo<p>
* <p>
* @param source Type: BusinessClass
* @param query Type: BusinessQuery
* @param attr Type: int
*/
@SuppressWarnings("unchecked")
public void addAggregateInfo(BusinessClass source, BusinessQuery query, int attr) {
BusinessClass foreignClass = null;
Array_Of_BusinessClass<BusinessClass> foreignClasses = null;
BusinessQuery dependentQuery = null;
int mult = 0;
mult = query.getForeignAttrMult(attr);
if ((mult&BusinessQuery.ASSOC_AGGREGATION) == 0) {
return;
}
if ((mult&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
source.getAttr(attr, qq_value);
foreignClasses = (Array_Of_BusinessClass<BusinessClass>)qq_value.getObject();
if (foreignClasses == null) {
return;
}
if (foreignClasses.size() > 0) {
foreignClass = foreignClasses.get(0);
}
}
else {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
source.getAttr(attr, qq_value);
foreignClass = (BusinessClass)qq_value.getObject();
if (foreignClass == null) {
return;
}
}
dependentQuery = query.newQuery(attr);
dependentQuery.addConstraint(ConstraintOperation.OP_FOR_UPDATE, (DataValue)null);
if (foreignClass == null) {
//
// We have to try to get something just to check that there isn't
// anything there.
//
dependentQuery.addAttr(1, (BusinessQuery)null);
}
else {
for (int j = 1; j <= dependentQuery.getNumAttrs(); j++) {
if (foreignClass.getAttr(j) != null) {
dependentQuery.addAttr(j, (BusinessQuery)null);
}
}
}
query.addAttr(attr, dependentQuery);
for (int j = BusinessQuery.ATTR_FOREIGN+1; j <= BusinessQuery.ATTR_FOREIGN+dependentQuery.getNumForeignAttrs(); j++) {
this.addAggregateInfo(foreignClass, dependentQuery, j);
}
}
/**
* addConstraints<p>
* AddConstraints<br>
* The AddConstraints method adds constraints onto the constraint stack<br>
* of the query parameter for each non-key attribute of the source<br>
* parameter. This has the effect of constraining the query to affect<br>
* only a class matching the source parameter.<br>
* <p>
* query<br>
* The query parameter specificies the BusinessQuery to which<br>
* constraints are to be added.<br>
* <p>
* source<br>
* The source parameter specifies the BusinessClass from which the<br>
* constraints are to be taken.<br>
* <p>
* @param query Type: BusinessQuery
* @param source Type: BusinessClass
*/
private void addConstraints(BusinessQuery query, BusinessClass source) {
DataValue value = null;
for (int j = query.getNumKeyAttrs()+1; j <= query.getNumAttrs(); j++) {
value = source.getAttr(j);
if (value != null) {
if (query.getConstraint() == null) {
query.setConstraint(new QueryConstraint());
}
query.getConstraint().addValue(value);
query.getConstraint().addAttr(query, j, 1);
query.getConstraint().addOperation(ConstraintOperation.OP_APPROX);
}
}
}
/**
* commitTrans<p>
* <p>
* @param clientID Type: int
* @param transactionMode Type: int
* @param queries Type: Array_Of_BusinessQuery<BusinessQuery>
*/
public void commitTrans(int clientID, int transactionMode, Array_Of_BusinessQuery<BusinessQuery> queries) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_COMMIT, this, "CommitTrans")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(clientID));
Logger.getLogger("task.part.logmgr").info(", transactionMode = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(transactionMode));
}
if (this.concurrencyMgr != null) {
this.concurrencyMgr.commitTrans(clientID, transactionMode);
}
}
/**
* getClientConcurrency<p>
* <p>
* @return ClientConcurrency
*/
public ClientConcurrency getClientConcurrency() {
ClientConcurrency client = new ClientConcurrency();
client.setConcurrencyMode(this.getConcurrencyMode());
client.setConcurrencyMgr(this.concurrencyMgr);
if (client.getConcurrencyMgr() != null) {
client.setClientID(client.getConcurrencyMgr().getClientID());
}
return client;
}
/**
* getClientID<p>
* <p>
* @return int
*/
public int getClientID() {
int id = 0;
if (this.concurrencyMgr == null) {
id = 0;
}
else {
id = this.concurrencyMgr.getClientID();
}
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_ID, this, "Load")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(id));
}
return id;
}
/**
* hasAggregates<p>
* HasAggregates<br>
* The HasAggregates method checks if the original class for the query<br>
* had any aggregate information attached to it. If it does HasAggregates<br>
* returns the attribute index of the first aggregate. If it doesn't<br>
* HasAggregates returns 0.<br>
* <p>
* query<br>
* The query whose originally returned class is to be checked.<br>
* Note if the query.OriginalClass attribute is NIL we will get a run-time<br>
* error as we don't check for that.<br>
* <p>
* @param query Type: BusinessQuery
* @return int
*/
private int hasAggregates(BusinessQuery query) {
BusinessClass foreignClass = null;
Array_Of_BusinessClass<BusinessClass> foreignClasses = null;
int mult = 0;
for (int attr = BusinessQuery.ATTR_FOREIGN+1; attr <= BusinessQuery.ATTR_FOREIGN+query.getNumForeignAttrs(); attr++) {
mult = query.getForeignAttrMult(attr);
if ((mult&BusinessQuery.ASSOC_AGGREGATION) == 0) {
continue;
}
if ((mult&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
query.getOriginalClass().getAttr(attr, qq_value);
foreignClasses = qq_value.get();
if (foreignClasses != null && foreignClasses.size() > 0) {
return attr;
}
}
else {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
query.getOriginalClass().getAttr(attr, qq_value);
foreignClass = (BusinessClass)qq_value.getObject();
if (foreignClass != null) {
return attr;
}
}
}
return 0;
}
/**
* load<p>
* <p>
* @param clientID Type: int
* @param transactionMode Type: int
* @param source Type: Array_Of_BusinessClass<BusinessClass>
*/
public void load(int clientID, int transactionMode, Array_Of_BusinessClass<BusinessClass> source) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_LOAD, this, "Load")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(clientID));
}
if (this.cacheMode > ConcurrencyMgr.CA_NONE) {
this.concurrencyMgr.load(clientID, transactionMode, source);
}
}
/**
* readyToCommit<p>
* <p>
* @param clientID Type: int
* @param transactionMode Type: int
* @param queries Type: Array_Of_BusinessQuery<BusinessQuery>
*/
public void readyToCommit(int clientID, int transactionMode, Array_Of_BusinessQuery<BusinessQuery> queries) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_READY, this, "ReadyToCommit")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(clientID));
}
if (this.concurrencyMgr != null) {
Array_Of_BusinessKey<BusinessKey> keys = new Array_Of_BusinessKey<BusinessKey>();
if (queries != null) {
for (BusinessQuery q : queries) {
if (q.getOperation() != BusinessQuery.OP_INSERT) {
keys.add(q.getKey());
}
}
}
this.concurrencyMgr.readyToCommit(clientID, transactionMode, keys);
}
else if (this.getConcurrencyMode() == ConcurrencyMgr.CO_OPT_VERIFY) {
if (queries != null) {
for (BusinessQuery q : queries) {
if (q.getOperation() != BusinessQuery.OP_INSERT) {
if (q.getOriginalClass() == null) {
throw new Error(Error.CM_NO_ORIGINAL, "ReadyToCommit", this, q, Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
else {
this.verifyClass(q, true);
}
}
}
}
}
}
/**
* relClientID<p>
* <p>
* @param clientID Type: int
*/
public void relClientID(int clientID) {
if (this.concurrencyMgr != null) {
this.concurrencyMgr.relClientID(clientID);
}
else if (clientID != 0) {
throw new Error(Error.CC_ILLEGAL_CLIENTID, "RelClientID", this, new IntegerData(clientID), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
}
/**
* rollback<p>
* <p>
* @param clientID Type: int
* @param transactionMode Type: int
* @param queries Type: Array_Of_BusinessQuery<BusinessQuery>
*/
public void rollback(int clientID, int transactionMode, Array_Of_BusinessQuery<BusinessQuery> queries) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_ROLLBACK, this, "Rollback")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(clientID));
Logger.getLogger("task.part.logmgr").info(", transactionMode = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(transactionMode));
}
if (this.concurrencyMgr != null) {
this.concurrencyMgr.rollback(clientID, transactionMode);
}
}
/**
* setConcurrency<p>
* <p>
* @param parentService Type: BusinessServiceMgr
* @param concurrencyMode Type: int
* @param concurrencyMgr Type: ConcurrencyMgr (Input) (default in Forte: NIL)
* @param cacheMode Type: int (Input) (default in Forte: 0)
*/
public void setConcurrency(IBusinessServiceMgr parentService, int concurrencyMode, ConcurrencyMgr concurrencyMgr, int cacheMode) {
if ((this.getParentService() != null && parentService != this.getParentService()) || (this.concurrencyMgr != null && concurrencyMgr != this.concurrencyMgr)) {
throw new Error(Error.CC_HAS_MGR, "SetConcurrency", this, new IntegerData(concurrencyMode), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
else if (concurrencyMode == ConcurrencyMgr.CO_OPT_EXPRESS && concurrencyMgr == null) {
throw new Error(Error.CC_NEEDS_MGR, "SetConcurrency", this, new IntegerData(concurrencyMode), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
else if (cacheMode != ConcurrencyMgr.CA_NONE && concurrencyMode != ConcurrencyMgr.CO_OPT_EXPRESS) {
throw new Error(Error.CC_CACHE_ILLEGAL, "SetConcurrency", this).getException();
}
else {
this.setParentService(parentService);
this.setConcurrencyMode(concurrencyMode);
this.concurrencyMgr = concurrencyMgr;
this.cacheMode = cacheMode;
}
}
public void setConcurrency(IBusinessServiceMgr parentService, int concurrencyMode){
this.setConcurrency(parentService, concurrencyMode, null, 0);
}
/**
* startTrans<p>
* <p>
* @param clientID Type: int
* @param transactionMode Type: int
*/
public void startTrans(int clientID, int transactionMode) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_START, this, "StartTrans")) {
Logger.getLogger("task.part.logmgr").info("clientID = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(clientID));
}
if (this.concurrencyMgr != null) {
this.concurrencyMgr.startTrans(clientID, transactionMode);
}
}
/**
* verifyAggregate<p>
* <p>
* @param source Type: BusinessClass
* @param reference Type: BusinessClass
* @param referenceQuery Type: BusinessQuery
* @param attr Type: int
*/
public void verifyAggregate(BusinessClass source, BusinessClass reference, BusinessQuery referenceQuery, int attr) {
if (this.getParentService().getTrace().getOn() && this.getParentService().getTrace().test(0, 0, Trace.ES_TRANS, ConcurrencyMgr.TRACE_READY, this, "VerifyAggregate")) {
Logger.getLogger("task.part.logmgr").info("attr = ");
Logger.getLogger("task.part.logmgr").info( Integer.toString(attr));
}
BusinessClass foreignClass = null;
Array_Of_BusinessClass<BusinessClass> foreignClasses = null;
int mult = 0;
Array_Of_BusinessClass<BusinessClass> referenceClasses = null;
DataValue value = null;
mult = referenceQuery.getForeignAttrMult(attr);
if ((mult&BusinessQuery.ASSOC_AGGREGATION) == 0) {
return;
}
else if ((mult&BusinessQuery.ASSOC_MULT_TO_MANY) > 0) {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass_Array qq_value = new ParameterHolder_BusinessClass_Array();
source.getAttr(attr, qq_value);
foreignClasses = qq_value.get();
if (foreignClasses == null || foreignClasses.size() < 1) {
return;
}
foreignClass = foreignClasses.get(0);
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass_Array qq_value1 = new ParameterHolder_BusinessClass_Array();
reference.getAttr(attr, qq_value1);
referenceClasses = qq_value1.get();
foreignClass = null;
if (referenceClasses.size() > 0) {
foreignClass = referenceClasses.get(0);
}
}
else {
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass qq_value = new ParameterHolder_BusinessClass();
source.getAttr(attr, qq_value);
foreignClass = (BusinessClass)qq_value.getObject();
if (foreignClass == null) {
return;
}
foreignClasses = new Array_Of_BusinessClass<BusinessClass>();
foreignClasses.add(foreignClass);
// ------------------------------
// Parameters for call to GetAttr
// ------------------------------
ParameterHolder_BusinessClass qq_value1 = new ParameterHolder_BusinessClass();
reference.getAttr(attr, qq_value1);
foreignClass = (BusinessClass)qq_value1.getObject();
referenceClasses = new Array_Of_BusinessClass<BusinessClass>();
referenceClasses.add(foreignClass);
}
int count = 0;
if (foreignClasses != null) {
for (BusinessClass i : foreignClasses) {
if ((i.getInstanceStatus()&(BusinessClass.ST_INSERT|BusinessClass.ST_EMPTY)) == 0) {
count = count+1;
}
}
}
if (referenceClasses.size() != count) {
throw new Error(Error.CM_AGGREGATES_INSERTED, "VerifyAggregate", this, foreignClass, source).getException();
}
BusinessKey sourceClass = new BusinessKey();
BusinessKey referenceClass = new BusinessKey();
int ix = 0;
boolean hasAggregates = false;
BusinessQuery dependentQuery = null;
Array_Of_BusinessQuery<BusinessQuery> qq_localVector = referenceQuery.getForeignClasses();
if (qq_localVector != null) {
for (BusinessQuery query : qq_localVector) {
if (query.getParentAttr() == attr) {
dependentQuery = query;
break;
}
}
}
for (int j = BusinessQuery.ATTR_FOREIGN+1; j <= BusinessQuery.ATTR_FOREIGN+dependentQuery.getNumForeignAttrs(); j++) {
if ((dependentQuery.getForeignAttrMult(j)&BusinessQuery.ASSOC_AGGREGATION) > 0) {
hasAggregates = true;
break;
}
}
if (foreignClasses != null) {
for (BusinessClass i : foreignClasses) {
if ((i.getInstanceStatus()&(BusinessClass.ST_INSERT|BusinessClass.ST_EMPTY)) == 0) {
ix = ix+1;
sourceClass.setValues(new Array_Of_DataValue<DataValue>());
referenceClass.setValues(new Array_Of_DataValue<DataValue>());
for (int j = 1; j <= dependentQuery.getNumAttrs(); j++) {
value = i.getAttr(j);
if (value != null) {
sourceClass.getValues().add(value);
referenceClass.getValues().add(referenceClasses.get(ix-1).getAttr(j));
}
}
if (sourceClass.compare(referenceClass) != BusinessKey.CMP_EQ) {
throw new Error(Error.CM_AGGREGATE_CHANGED, "VerifyAggregate", this, i, referenceClasses.get(ix-1)).getException();
}
if (hasAggregates) {
for (int j = BusinessQuery.ATTR_FOREIGN+1; j <= BusinessQuery.ATTR_FOREIGN+dependentQuery.getNumForeignAttrs(); j++) {
this.verifyAggregate(i, referenceClasses.get(ix-1), dependentQuery, j);
}
}
}
}
}
}
/**
* verifyClass<p>
* <p>
* @param query Type: BusinessQuery
* @param verifyUpdatedClasses Type: boolean (Input) (default in Forte: TRUE)
*/
public void verifyClass(BusinessQuery query, boolean verifyUpdatedClasses) {
BusinessQuery referenceQuery = null;
Array_Of_BusinessClass<BusinessClass> reference = null;
int firstAggregate = 0;
int op = 0;
boolean verifyByQuery = false;
if (verifyUpdatedClasses) {
//
// For Sybase we cannot verify the class by adding constraints if there
// are any BLOB columns.
//
if (((BusinessDBMgr)this.getParentService().getMgr(query)).getDB().getDBVendorType() == Constants.DB_VT_SYBASE) {
DataValue value1 = null;
int dtype = 0;
for (int j = query.getNumKeyAttrs()+1; j <= query.getNumAttrs(); j++) {
value1 = query.getOriginalClass().getAttr(j);
if (value1 != null) {
dtype = value1.dataType()&127;
if (dtype == 8 || dtype == 9 || (dtype == 6 && value1 instanceof LongTextDomain)) {
verifyByQuery = true;
break;
}
}
}
}
if (verifyByQuery) {
this.verifyClassByQuery(query);
Array_Of_BusinessQuery<BusinessQuery> qq_localVector = query.getForeignClasses();
if (qq_localVector != null) {
for (BusinessQuery f : qq_localVector) {
op = f.getOperation();
if (op == BusinessQuery.OP_UPDATE || op == BusinessQuery.OP_DELETE) {
this.verifyClassByQuery(f);
}
}
}
}
else {
this.addConstraints(query, query.getOriginalClass());
Array_Of_BusinessQuery<BusinessQuery> qq_localVector = query.getForeignClasses();
if (qq_localVector != null) {
for (BusinessQuery f : qq_localVector) {
op = f.getOperation();
if (op == BusinessQuery.OP_UPDATE || op == BusinessQuery.OP_DELETE) {
this.addConstraints(f, f.getOriginalClass());
}
}
}
}
return;
}
firstAggregate = this.hasAggregates(query);
if (firstAggregate <= 0 && query.getNumTables() == 1) {
referenceQuery = query;
}
else {
referenceQuery = query.getOriginalClass().newQuery();
referenceQuery.addConstraint(ConstraintOperation.OP_FOR_UPDATE, (DataValue)null);
referenceQuery.addAttr(1, (BusinessQuery)null);
for (int j = 1; j <= referenceQuery.getNumKeyAttrs(); j++) {
referenceQuery.addConstraint(j, ConstraintOperation.OP_EQ, query.getOriginalClass().getInstanceKey().getValues().get(j-1));
}
}
this.addConstraints(referenceQuery, query.getOriginalClass());
if (firstAggregate == 0) {
return;
}
for (int j = firstAggregate; j <= BusinessQuery.ATTR_FOREIGN+referenceQuery.getNumForeignAttrs(); j++) {
this.addAggregateInfo(query.getOriginalClass(), referenceQuery, j);
}
reference = this.getParentService().getMgr(referenceQuery).select(referenceQuery);
if (reference.size() < 1) {
throw new Error(Error.CM_CLASS_CHANGED, "VerifyClass", this, query.getOriginalClass().getInstanceKey(), referenceQuery.newClass()).getException();
}
else if (reference.size() > 1) {
throw new Error(Error.CM_KEY_NOT_UNIQUE, "VerifyClass", this, query.getOriginalClass().getInstanceKey(), reference.get(0)).getException();
}
for (int j = BusinessQuery.ATTR_FOREIGN+1; j <= BusinessQuery.ATTR_FOREIGN+referenceQuery.getNumForeignAttrs(); j++) {
this.verifyAggregate(query.getOriginalClass(), reference.get(0), referenceQuery, j);
}
}
/**
* verifyClassByQuery<p>
* <p>
* @param query Type: BusinessQuery
*/
public void verifyClassByQuery(BusinessQuery query) {
BusinessQuery referenceQuery = null;
Array_Of_BusinessClass<BusinessClass> reference = null;
referenceQuery = query.getOriginalClass().newQuery();
referenceQuery.addConstraint(ConstraintOperation.OP_FOR_UPDATE, (DataValue)null);
referenceQuery.addAttr(1, (BusinessQuery)null);
for (int j = 0; j < referenceQuery.getNumKeyAttrs(); j++) {
referenceQuery.addConstraint(j, ConstraintOperation.OP_EQ, query.getOriginalClass().getInstanceKey().getValues().get(j));
}
this.addConstraints(referenceQuery, query.getOriginalClass());
reference = this.getParentService().getMgr(referenceQuery).select(referenceQuery);
if (reference.size() < 1) {
throw new Error(Error.CM_CLASS_CHANGED, "VerifyClassByQuery", this, query.getOriginalClass().getInstanceKey(), referenceQuery.newClass()).getException();
}
else if (reference.size() > 1) {
throw new Error(Error.CM_KEY_NOT_UNIQUE, "VerifyClassByQuery", this, query.getOriginalClass().getInstanceKey(), reference.get(0)).getException();
}
}
} // end class ServiceConcurrency
// c Pass 2 Conversion Time: 2250 milliseconds