Logo Search packages:      
Sourcecode: facturalux version File versions  Download package

void FLManager::metadataField ( QDomElement *  field,
FLTableMetaData::FLFieldMetaDataList fl,
FLCompoundKey ckl 
) [static]

Crea un objeto FLFieldMetaData a partir de un elemento XML.

Dado un elemento XML, que contiene la descripción de un campo de una tabla construye y agrega a una lista de descripciones de campos el objeto FLFieldMetaData correspondiente, que contiene dicha definición del campo. Tambien lo agrega a una lista de claves compuesta, si el campo construido pertenece a una clave compuesta. NO SE HACEN CHEQUEOS DE ERRORES SINTÁCTICOS EN EL XML.

Parameters:
field Elemento XML con la descripción del campo.
fl Lista de descripciones de campos, a la que agregar el campo construido.
ckl Lista de claves compuestas.

Definition at line 478 of file FLManager.cpp.

References FLCompoundKey::addFieldMD(), metadataRelation(), FLFieldMetaData::name(), FLFieldMetaData::Serial, FLFieldMetaData::setAssociatedField(), and FLFieldMetaData::setRelationList().

Referenced by metadata().

{
  if (!field || !fl || !ckl)
      return;

  bool ck = false;
  QString n, a;
  bool aN = true, iPK = true, c = false, v = true, ed = false, iNX = false, uNI = false, coun = false;
  int t = QVariant::Int, l = 0, pI = 4, pD = 0;
  QVariant dV = QVariant();
  
  FLFieldMetaData::FLRelationMetaDataList * relationList = 0;
  FLFieldMetaData *assocWith = 0;
  QString assocBy = QString::null;

  QDomNode no = field->firstChild ();

  while (!no.isNull ())
      {
        QDomElement e = no.toElement ();

        if (!e.isNull ())
            {
              if (e.tagName () == "name")
                  {
                    n = e.text ();
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "alias")
                  {
                    QString s = e.text ().left (e.text ().length () - 2);

                    a = s.right (s.length () - 30);
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "null")
                  {
                    aN = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "pk")
                  {
                    iPK = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "type")
                  {
                    if (e.text () == "int")
                        t = QVariant::Int;
                    else if (e.text () == "uint")
                        t = QVariant::UInt;
                    else if (e.text () == "bool")
                        t = QVariant::Bool;
                    else if (e.text () == "double")
                        t = QVariant::Double;
                    else if (e.text () == "time")
                        t = QVariant::Time;
                    else if (e.text () == "date")
                        t = QVariant::Date;
                    else if (e.text () == "pixmap")
                        t = QVariant::Pixmap;
                    else if (e.text () == "string")
                        t = QVariant::String;
                    else if (e.text () == "stringlist")
                        t = QVariant::StringList;
                    else if (e.text () == "unlock")   // Tipo añadido por Andrés Otón Urbano
                        t = FLFieldMetaData::Unlock;
                    else if (e.text () == "serial")
                        t = FLFieldMetaData::Serial;
                    else if (e.text () == "sequence") // Tipo de datos, añadida por Raúl A. Betancort Santana
                        t = FLFieldMetaData::Sequence;
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "length")
                  {
                    l = e.text ().toInt ();
                    no = no.nextSibling ();
                    continue;
                  }
        if (e.tagName () == "default")
                  {
                    dV = QVariant(e.text ());
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "counter")    // Propiedad añadida por Andrés Otón Urbano
                  {
                    coun = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "calculated")
                  {
                    c = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "visible")
                  {
                    v = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "editable")   // Propiedad definible para edición directa
                  {                             // Añadido por Raúl A. Betancort Santana
                    ed = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "partI")
                  {
                    pI = e.text ().toInt ();
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "partD")
                  {
                    pD = e.text ().toInt ();
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "index")
                  {
                    iNX = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "unique")
                  {
                    uNI = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "ck")
                  {
                    ck = (e.text () == "true");
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "relation")
                  {
                    if (!relationList)
                        relationList = new FLFieldMetaData::FLRelationMetaDataList;
                    relationList->append (metadataRelation (&e));
                    no = no.nextSibling ();
                    continue;
                  }
              if (e.tagName () == "associated")
                  {
                    QDomNode noas = e.firstChild ();

                    while (!noas.isNull ())
                        {
                          QDomElement eas = noas.toElement ();

                          if (!eas.isNull ())
                              {
                                if (eas.tagName () == "with")
                                    {
                                      if (fl)
                                          {
                                            FLFieldMetaData *field;

                                            for (unsigned int i = 0; i < fl->count (); i++)
                                                {
                                                  field = fl->at (i);
                                                  if (field->name () == eas.text ())
                                                      {
                                                        assocWith = field;
                                                        break;
                                                      }
                                                }
                                          }
                                      noas = noas.nextSibling ();
                                      continue;
                                    }
                                if (eas.tagName () == "by")
                                    {
                                      assocBy = eas.text ();
                                      noas = noas.nextSibling ();
                                      continue;
                                    }
                              }
                          noas = noas.nextSibling ();
                        }
                    no = no.nextSibling ();
                    continue;
                  }
            }
        no = no.nextSibling ();
      }

  FLFieldMetaData *f = new FLFieldMetaData (n, qApp->translate ("MetaData", a), aN, iPK, t, l, c, v, ed, pI, pD, iNX, uNI, coun, dV);

  f->setRelationList (relationList);

  if (assocWith && !assocBy.isNull ())
      f->setAssociatedField (assocWith, assocBy);

  if (fl)
      fl->append (f);

  if (ck)
      ckl->addFieldMD (f);
}


Generated by  Doxygen 1.6.0   Back to index