/** get the acceleration value of the MarkersReference */
void MarkersReference::getAccelerationValues(const SimTK::State &s, SimTK::Array_<Vec3> &accValues) const
{
throw Exception("MarkersReference: getAccelerationValues not implemented.");
}
void __fastcall TformEnterResults::btnOKClick(TObject *Sender)
{
// TODO
pResult result = new Result;
VecpResult results;
if (NULL == lines) {
Application->MessageBox("No file loaded", "Error", MB_OK);
return;
}
// parse
// int patientID;
// String barcode;
// TDateTime startDate;
// String sampleType;
// int testID;
// String unit;
// String result;
// TDateTime dateAnalysed;
// String cuvetteType;
// int reagentID;
// String reagentLot;
// String notes;
// following code copied from EditFormat - needs adapting or merging
LQuery qc(frmBuddyLogin->qCentral);
qc.setSQL("SELECT"
" field_cid,"
" filetype_cid,"
" tag,"
" tagcol,"
" valcol,"
" subcol,"
" type,"
" pos"
" FROM g_comms_field WHERE id_filetype = :idfiletype"
" AND status = 0"
" ORDER BY pos"); // XXX
qc.setParam("idfiletype", format->id);
int count = qc.open();
if (!MYDEBUG) {
assert(count > 1);
}
VecpDatum vecpDatum;
while (!qc.eof()) {
Datum *newdatum = new Datum;
newdatum->datumType = (Datum::DatumType)qc.readInt("type");
newdatum->id = qc.readInt("field_cid");
newdatum->id_filetype = qc.readInt("filetype_cid");
//newdatum->name = qc.readString("name");
newdatum->tag = qc.readString("tag");
newdatum->tagCol = qc.readInt("tagcol");
newdatum->valCol = qc.readInt("valcol");
newdatum->valSubCol = qc.readInt("subcol");
newdatum->pos = qc.readInt("pos");
vecpDatum.push_back(newdatum);
qc.next();
}
// TTreeNode * rootNode = NULL;
// TTreeNode * resultNode = NULL;
// TTreeNode * reagentNode = NULL;
Datum * curdatum = new Datum;
for (VecpDatum::const_iterator it = vecpDatum.begin(); it != vecpDatum.end(); it++) {
// save the current node if it is a container node
Datum * datum = *it;
switch (datum->datumType) {
case Datum::DATUM_ROOT:
//rootNode = curNode;
break;
case Datum::DATUM_RESULT:
//resultNode = curNode;
break;
case Datum::DATUM_REAGENT:
//reagentNode = curNode;
break;
case Datum::DATUM_PID:
case Datum::DATUM_BARCODE:
case Datum::DATUM_STARTDATE:
case Datum::DATUM_SAMPLETYPE:
case Datum::DATUM_TID:
case Datum::DATUM_UNIT:
case Datum::DATUM_RESULTSTRING:
case Datum::DATUM_DATEANALYSED:
case Datum::DATUM_CUVETTE:
case Datum::DATUM_REAGENTID:
case Datum::DATUM_REAGENTLOT:
case Datum::DATUM_NOTES:
// do nothing
break;
default:
throw Exception("Invalid datum type");
}
// and add next it to appropriate saved node
curdatum = *it;
switch (curdatum->datumType) {
case Datum::DATUM_ROOT:
throw "DATUM_ROOT should not be stored in database";
//.........这里部分代码省略.........
void FunctionWidget::validateConfiguredFunction(void)
{
vector<BaseObject *>::iterator itr, itr_end;
vector<BaseObject *> obj_list;
Conversion *conv=nullptr;
Cast *cast=nullptr;
Aggregate *aggr=nullptr;
Language *lang=nullptr;
Operator *oper=nullptr;
Type *type=nullptr;
Function *func=nullptr;
BaseObject *object=nullptr;
ObjectType obj_type;
unsigned i1=0;
func=dynamic_cast<Function *>(this->object);
try
{
model->getObjectReferences(func, obj_list);
itr=obj_list.begin();
itr_end=obj_list.end();
while(itr!=itr_end)
{
object=(*itr);
obj_type=object->getObjectType();
itr++;
/* The validation of the function happens as follows:
For each type of object in vector 'types' is obtained the list of objects.
If there are elements in this list, the function is assigned for each element
and these elements internally validates the function according to required by the
each class rules.
If the function is invalid the instances raises exceptions accusing the error
that is enough to check the validity of the function in relation to objects that reference it. */
if(obj_type==OBJ_CONVERSION)
{
conv=dynamic_cast<Conversion *>(object);
if(conv->getConversionFunction()==func)
conv->setConversionFunction(func);
}
else if(obj_type==OBJ_CAST)
{
cast=dynamic_cast<Cast *>(object);
if(cast->getCastFunction()==func)
cast->setCastFunction(func);
}
else if(obj_type==OBJ_AGGREGATE)
{
aggr=dynamic_cast<Aggregate *>(object);
if(aggr->getFunction(Aggregate::FINAL_FUNC)==func)
aggr->setFunction(Aggregate::FINAL_FUNC, func);
else if(aggr->getFunction(Aggregate::TRANSITION_FUNC)==func)
aggr->setFunction(Aggregate::TRANSITION_FUNC, func);
}
else if(obj_type==OBJ_TRIGGER)
{
dynamic_cast<Trigger *>(object)->setFunction(func);
}
else if(obj_type==OBJ_LANGUAGE)
{
lang=dynamic_cast<Language *>(object);
for(i1=Language::VALIDATOR_FUNC; i1 <= Language::INLINE_FUNC; i1++)
{
if(lang->getFunction(i1)==func)
lang->setFunction(func, i1);
}
}
else if(obj_type==OBJ_OPERATOR)
{
oper=dynamic_cast<Operator *>(object);
for(i1=Operator::FUNC_OPERATOR; i1 <= Operator::FUNC_RESTRICT; i1++)
{
if(oper->getFunction(i1)==func)
oper->setFunction(func, i1);
}
}
else if(obj_type==OBJ_TYPE)
{
type=dynamic_cast<Type *>(object);
if(type->getConfiguration()==Type::BASE_TYPE)
{
for(i1=Type::INPUT_FUNC; i1 <=Type::ANALYZE_FUNC; i1++)
{
if(type->getFunction(i1)==func)
type->setFunction(i1, func);
}
}
}
else if(obj_type==OBJ_EVENT_TRIGGER)
{
dynamic_cast<EventTrigger *>(object)->setFunction(func);
}
}
}
catch(Exception &e)
//.........这里部分代码省略.........
//.........这里部分代码省略.........
{
//For commom broken reference, check if the object id is greater than the reference id
if(obj_id > refs.back()->getObjectId())
{
obj=refs.back();
obj_id=obj->getObjectId();
}
refs.pop_back();
}
}
//Swap the id of the validation object and the found object (minor id)
if(obj)
{
BaseObject::swapObjectsIds(info_obj, obj, true);
aux_obj=obj;
}
else
{
BaseObject::updateObjectId(info_obj);
aux_obj=info_obj;
}
if(aux_obj->getObjectType()==OBJ_VIEW)
{
vector<BaseRelationship *> base_rels=db_model->getRelationships(dynamic_cast<BaseTable *>(aux_obj));
for(auto rel : base_rels)
BaseObject::updateObjectId(rel);
}
sleepThread(5);
}
//Resolving no unique name by renaming the constraints/indexes
else if(info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME)
{
unsigned suffix=1;
QString new_name;
Table *table=nullptr;
ObjectType obj_type;
BaseObject *obj=info.getObject();
TableObject *tab_obj=nullptr;
/* If the last element of the referrer objects is a table or view the
info object itself need to be renamed since tables and views will not be renamed */
bool rename_obj=(refs.back()->getObjectType()==OBJ_TABLE ||
refs.back()->getObjectType()==OBJ_VIEW);
if(rename_obj)
{
table=dynamic_cast<Table *>(dynamic_cast<TableObject *>(obj)->getParentTable());
obj_type=obj->getObjectType();
do
{
//Configures a new name for the object [name]_[suffix]
new_name=QString("%1_%2").arg(obj->getName()).arg(suffix);
suffix++;
}
//Generates a new name until no object is found on parent table
while(table->getObjectIndex(new_name, obj_type) >= 0);
//Renames the object
obj->setName(new_name);
}
//Renaming the referrer objects
while(!refs.empty() && !valid_canceled)
{
obj_type=refs.back()->getObjectType();
tab_obj=dynamic_cast<TableObject *>(refs.back());
//Tables and view aren't renamed only table child objects (constraints, indexes)
if(tab_obj && !tab_obj->isAddedByRelationship())
{
table=dynamic_cast<Table *>(tab_obj->getParentTable());
do
{
//Configures a new name for the object [name]_[suffix]
new_name=QString("%1_%2").arg(refs.back()->getName()).arg(suffix);
suffix++;
}
//Generates a new name until no object is found on parent table
while(table->getObjectIndex(new_name, obj_type) >= 0);
//Renames the referrer object
refs.back()->setName(new_name);
}
refs.pop_back();
sleepThread(5);
}
}
}
catch(Exception &e)
{
throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
}
}
void ModelValidationHelper::validateModel(void)
{
if(!db_model)
throw Exception(ERR_OPR_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);
try
{
ObjectType types[]={ OBJ_ROLE, OBJ_TABLESPACE, OBJ_SCHEMA, OBJ_LANGUAGE, OBJ_FUNCTION,
OBJ_TYPE, OBJ_DOMAIN, OBJ_SEQUENCE, OBJ_OPERATOR, OBJ_OPFAMILY,
OBJ_OPCLASS, OBJ_COLLATION, OBJ_TABLE, OBJ_EXTENSION, OBJ_VIEW, OBJ_RELATIONSHIP },
aux_types[]={ OBJ_TABLE, OBJ_VIEW },
tab_obj_types[]={ OBJ_CONSTRAINT, OBJ_INDEX },
obj_type;
unsigned i, i1, cnt, aux_cnt=sizeof(aux_types)/sizeof(ObjectType),
count=sizeof(types)/sizeof(ObjectType), count1=sizeof(tab_obj_types)/sizeof(ObjectType);
BaseObject *object=nullptr, *refer_obj=nullptr;
vector<BaseObject *> refs, refs_aux, *obj_list=nullptr;
vector<BaseObject *>::iterator itr;
TableObject *tab_obj=nullptr;
Table *table=nullptr, *ref_tab=nullptr, *recv_tab=nullptr;
Constraint *constr=nullptr;
Relationship *rel=nullptr;
map<QString, vector<BaseObject *> > dup_objects;
map<QString, vector<BaseObject *> >::iterator mitr;
QString name, signal_msg="`%1' (%2)";
warn_count=error_count=progress=0;
val_infos.clear();
valid_canceled=false;
/* Step 1: Validating broken references. This situation happens when a object references another
whose id is smaller than the id of the first one. */
for(i=0; i < count && !valid_canceled; i++)
{
obj_list=db_model->getObjectList(types[i]);
itr=obj_list->begin();
while(itr!=obj_list->end()&& !valid_canceled)
{
object=(*itr);
obj_type=object->getObjectType();
itr++;
//Excluding the validation of system objects (created automatically)
if(!object->isSystemObject())
{
emit s_objectProcessed(signal_msg.arg(object->getName()).arg(object->getTypeName()), object->getObjectType());
/* Special validation case: For generalization and copy relationships validates the ids of participant tables.
* Reference table cannot own an id greater thant receiver table */
if(obj_type==OBJ_RELATIONSHIP)
{
rel=dynamic_cast<Relationship *>(object);
if(rel->getRelationshipType()==Relationship::RELATIONSHIP_GEN ||
rel->getRelationshipType()==Relationship::RELATIONSHIP_DEP)
{
recv_tab=rel->getReceiverTable();
ref_tab=rel->getReferenceTable();
if(ref_tab->getObjectId() > recv_tab->getObjectId())
{
object=ref_tab;
refs_aux.push_back(recv_tab);
}
}
}
else
{
db_model->getObjectReferences(object, refs);
refs_aux.clear();
while(!refs.empty() && !valid_canceled)
{
//Checking if the referrer object is a table object. In this case its parent table is considered
tab_obj=dynamic_cast<TableObject *>(refs.back());
constr=dynamic_cast<Constraint *>(tab_obj);
/* If the current referrer object has an id less than reference object's id
then it will be pushed into the list of invalid references. The only exception is
for foreign keys that are discarded from any validation since they are always created
at end of code defintion being free of any reference breaking. */
if(object != refs.back() &&
(!constr || (constr && constr->getConstraintType()!=ConstraintType::foreign_key)) &&
((!tab_obj && refs.back()->getObjectId() <= object->getObjectId()) ||
(tab_obj && !tab_obj->isAddedByRelationship() &&
tab_obj->getParentTable()->getObjectId() <= object->getObjectId())))
{
if(tab_obj)
refer_obj=tab_obj->getParentTable();
else
refer_obj=refs.back();
//Push the referrer object only if not exists on the list
if(std::find(refs_aux.begin(), refs_aux.end(), refer_obj)==refs_aux.end())
refs_aux.push_back(refer_obj);
}
refs.pop_back();
}
//.........这里部分代码省略.........
请发表评论