Beispiel #1
0
        /** Actualiza un atributo*/
        public void modificaAtributo(string nameEnt, string nameAtri, CNodoAtributo nuevo)
        {
            CNodoEntidad nodoVert = null;
            CNodoAtributo nodoAtri;

            if (nameAtri.CompareTo(nuevo.getNombre()) != 0)
            {
                BajaAtributo(nameEnt, nameAtri);
                AltaAtributo(nuevo, nameEnt);
            }
            else
            {
                buscaEntidad(ref nodoVert, nameEnt);
                if (nodoVert != null)
                {
                    AbrirArchivo();

                    nodoAtri = nodoVert.getCabListAtri();
                    while (nodoAtri != null && nodoAtri.getNombre().CompareTo(nameAtri) != 0)
                        nodoAtri = nodoAtri.getSigAtri();

                    if (nodoAtri != null)
                    {
                        nodoAtri.setClavePrimaria(nuevo.getClave());
                        nodoAtri.setTipo(nuevo.getTipo());
                        nodoAtri.setNameTipo(nuevo.getNameTipo());
                        nodoAtri.setTamaño(nuevo.getTamaño());
                        nodoAtri.setEntRel(nuevo.getEntRel());
                        nodoAtri.setApEntRel(nuevo.getApEntRel());
                        nuevo.setDir(nodoAtri.getDir());
                        nuevo.setApSigAtri(nodoAtri.getApSigAtri());
                        escribeAtributo(nuevo, nuevo.getDir());
                    }

                    CerrarArchivo();
                }
            }
        }
Beispiel #2
0
        /**\brief Inserta un atributo */
        public void AltaAtributo(CNodoAtributo nuevo, string nameEnt)
        {
            /**
             * \details
             * \param nuevo Atributo a insertar
             * \param nameEnt Nombre de la entidad a la pertenece el atributo
             * */
             
            CNodoEntidad nodoEnt = null;
            long ptrAux, ptrAnt = 0;
            CNodoAtributo aux, ant = null;
            bool band = false;

            AbrirArchivo();

            buscaEntidad(ref nodoEnt, nameEnt);

            aux = nodoEnt.getCabListAtri();
            ptrAux = nodoEnt.getApCabListAtri();

            while (aux != null)//Busqueda dell atributo
                if (aux.getNombre().CompareTo(nuevo.getNombre()) < 0)
                {
                    ant = aux;
                    ptrAnt = ptrAux;
                    ptrAux = aux.getApSigAtri();
                    aux = aux.getSigAtri();
                }
                else
                {
                    if (aux.getNombre().CompareTo(nuevo.getNombre()) == 0)
                        band = true;

                    break;
                }

            if (aux == nodoEnt.getCabListAtri())
            {
                if (band == false)
                {
                    nodoEnt.setApCabListAtri(fs.Length);
                    nodoEnt.setCabListAtri(nuevo);
                    escribeEntidad(nodoEnt, nodoEnt.getDir());
                }
            }
            else
                if (band == false)
                {
                    ant.setApSigAtri(fs.Length);
                    ant.setSigAtri(nuevo);
                    escribeAtributo(ant, ptrAnt);
                }

            if (band == false)
            {
                nuevo.setSigAtri(aux);
                nuevo.setApSigAtri(ptrAux);
                nuevo.setDir(fs.Length);
                escribeAtributo(nuevo, fs.Length);
            }

            CerrarArchivo();
        }