void OfertaLaboral::AltaAsignacionCargo(Date* fechaEfectivizacion, int sueldo) { EstudianteController* ec = EstudianteController::getInstance(); Estudiante* e = ec->getEstudiante(); IIterator * it = e->getInscripciones()->getIterator(); bool noEncontrada = true; while((it->hasCurrent())&&(noEncontrada)) { Inscripcion* insc; if ((insc = dynamic_cast<Inscripcion*> (it->getCurrent())) != NULL ) { if (insc->EstInscripto(this->numExpediente)) { Efectivizacion* efe = new Efectivizacion(sueldo, fechaEfectivizacion); insc->setEfectivizacion(efe); noEncontrada = false; } } else { throw "OfertaLaboral-> El objeto no es de la clase Inscripcion."; } it->next(); } delete it; }
RequestResponse AlbumRequest::invoke(const QStringList &arguments, const QString &who, const RequestInvocationContext &context) { Q_UNUSED(who); const QString &id = arguments.join(QChar::Space); InformationResourceRepository &repository = context.informationResourceRepository(); IdGenerator &idGenerator = context.idGenerator(); IInformationResource *resource = repository.get(id); if (resource) { IIterator<Album> *iterator = resource->iterator<Album>(); if (iterator) { Album *album = iterator->next(resource, repository, idGenerator); if (album) { return RequestResponse("templates/Album.qml", album); } return RequestResponse("templates/NoMoreData.qml", nullptr); } } return RequestResponse(); }
void List::addAll(const IList* list){ IIterator* iter = list->iterator(); assert(iter != nullptr); while(iter->hasNext()){ addBack(iter->next()); } delete iter; // don't forget to delete your iterator }
void ImportsList::initialise( IList<IPosition<SourceToken> >& importPositions ) { IIterator<IPosition<SourceToken> >* it = importPositions.elements(); while ( it->hasNext() ) { this->imports->insertLast( new Import( this->cu, it->next() ) ); } delete it; this->addBlank(); }
RequestResponse ArtistRequest::invoke(const QStringList &arguments, const QString &who, const RequestInvocationContext &context) { const QString &id = arguments.join(QChar::Space); InformationResourceRepository &repository = context.informationResourceRepository(); IdGenerator &idGenerator = context.idGenerator(); IInformationResource *resource = repository.get(id); if (resource) { IIterator<Artist> *iterator = resource->iterator<Artist>(); if (iterator) { Artist *artist = iterator->next(resource, repository, idGenerator); if (artist) { return RequestResponse("templates/Artist.qml", artist); } return RequestResponse("templates/NoMoreData.qml", nullptr); } } else { RequestHandler requestHandler(repository, idGenerator); Artist *artist = requestHandler .get<Artist>("artist.getInfo" , as::artist = arguments.join(QChar::Space) , as::username = who ); if (artist) { return RequestResponse("templates/Artist.qml", artist); } NotFound *notFound = new NotFound(); notFound->setTypeName("Artist"); return RequestResponse("templates/NotFound.qml", notFound); } return RequestResponse(); }
RequestResponse TagsRequest::invoke(const QStringList &arguments, const QString &who, const RequestInvocationContext &context) { Q_UNUSED(who); const QString &id = arguments.join(QChar::Space); InformationResourceRepository &repository = context.informationResourceRepository(); IdGenerator &idGenerator = context.idGenerator(); IInformationResource *resource = repository.get(id); if (resource) { IIterator<Tag> *iterator = resource->iterator<Tag>(); if (iterator) { QList<QObject *> tags; for (int i = 0; i < 10; i++) { Tag *tag = iterator->next(resource, repository, idGenerator); if (!tag) { if (!i) { return RequestResponse("templates/NoMoreData.qml", nullptr); } break; } else { tags << tag; } } Tags *envelope = new Tags(); envelope->setTags(tags); return RequestResponse("templates/Tags.qml", envelope); } } return RequestResponse(); }
// DarDeBajaLlamado void cmdDarDeBajaLlamado::ejecutarComando() { string numExpediente; Fabrica* fab = Fabrica::getInstance(); IOfertaLaboralController *ctrlOL = fab->getIOfertaLaboralController(); try { // muestro las ofertas IDictionary* dataOfertas = ctrlOL->ListarOfertas(); cout << "Lista de Ofertas Laborales:\n"; IIterator *it = dataOfertas->getIterator(); while (it->hasCurrent()) { DataOfertaLaboral *dOferta; if ( (dOferta = dynamic_cast<DataOfertaLaboral*> (it->getCurrent())) != NULL ) { cout << "NRO. EXPEDIENTE: " << dOferta->getNumExpediente() << ", TITULO:" << dOferta->getTitulo() << "\n"; } else { throw "cmdDarDeBajaLlamado -> El objeto no es de la clase DataOfertaLaboral."; } it->next(); } delete it; // selecciono el llamado cout<< "Seleccione una Oferta Laboral indicando el Nro. Expediente: \n> "; cin >> numExpediente; ctrlOL->SeleccionarOferta(numExpediente, dataOfertas); // borro el llamado ctrlOL->DarBajaLlamado(); cout << "\n- El Llamado se ha dado de baja correctamente.\n\n"; } catch (const char* e) { throw; } }
ICollection *Empresa::getDataSucursales() { List* result = new List(); IIterator * it = this->sucursales->getIterator(); while(it->hasCurrent()) { Sucursal *suc; if ((suc = dynamic_cast<Sucursal*> (it->getCurrent())) != NULL ) { result->add(suc->getDataSucursal()); } else { throw "Empresa -> El objeto no es de la clase Sucursal."; } it->next(); } delete it; return result; }
std::string List::toString() const { bool start = true; std::string strOut = ""; IIterator* iter = iterator(); if(!iter->hasNext()){ // empty list strOut += "[]"; } else{ while(iter->hasNext()){ if(start){ strOut += '['; } else{ strOut += ','; } start = false; strOut += std::to_string(iter->next()); } strOut += ']'; } delete iter; return strOut; }
void cmdAnotarBorrarNotificaciones::ejecutarComando() { string cedEstudiante; Fabrica* fab = Fabrica::getInstance(); IEstudianteController* cEstudiante = fab->getIEstudianteController(); IEmpresaController* cEmpresa = fab->getIEmpresaController(); try { //LISTAR ESTUDIANTES IDictionary *dataEstudiantes = cEstudiante->ListarEstudiantesRegistrados(); cout << "Lista de Estudiantes registrados en el Sistema:\n"; IIterator *it = dataEstudiantes->getIterator(); while(it->hasCurrent()) { DataEstudiante* dEstudiante; if ((dEstudiante = dynamic_cast<DataEstudiante*> (it->getCurrent())) != NULL) { cout << "Cedula: " + dEstudiante->getCedula() + ", Apellido: " + dEstudiante->getApellido() + "\n"; } else { throw "cmdListarNotificacionesEstudiante -> El objeto no es de la clase DataEstudiante."; } it->next(); } delete it; //SELECCIONA ESTUDIANTE cout<< "Seleccione un Estudiante indicando la cedula: \n"; cin >> cedEstudiante; cEstudiante->SeleccionarEstudiante(cedEstudiante, dataEstudiantes); //ANOTAR O BORRAR ESTUDIANTE DE NOTIFICACIONES Estudiante* estRecordado =cEstudiante->getEstudiante(); char opcion; cout<< "Indique si desea anotar (A) o borrar (B) a el estudiante seleccionado de las notificaciones: \n"; cin >> opcion; IDictionary* empresas = cEmpresa->getEmpresas(); IIterator *it2 = empresas->getIterator(); while (it2->hasCurrent()) { Empresa* emp; if ((emp = dynamic_cast<Empresa*> (it2->getCurrent())) != NULL) { IDictionary* sucursales = emp->getSucursales(); IIterator *it3 = sucursales->getIterator(); while(it3->hasCurrent()) { Sucursal* suc; if ((suc = dynamic_cast<Sucursal*> (it3->getCurrent())) != NULL) { IDictionary* secciones = suc->getSecciones(); IIterator *it4 = secciones->getIterator(); while (it4->hasCurrent()) { Seccion* secc; if ((secc = dynamic_cast<Seccion*> (it4->getCurrent())) != NULL) { //IObserver *iobs = dynamic_cast<IObserver*> (estRecordado); IObserver *iobs = estRecordado; switch (opcion) { case 'A': secc->addObserver(iobs); break; case 'B': secc->removeObserver(iobs); break; } } else { throw "cmdAnotarBorrarNotificaciones -> El objeto no es de la clase Seccion."; } it4->next(); } delete it4; } else { throw "cmdAnotarBorrarNotificaciones -> El objeto no es de la clase Sucursal."; } it3->next(); } delete it3; } else { throw "cmdAnotarBorrarNotificaciones -> El objeto no es de la clase Empresa."; } it2->next(); } delete it2; switch (opcion) { case 'A': cout << "\n- El Estudiante se ha Anotado a las Notificaciones.\n\n"; break; case 'B': cout << "\n- El Estudiante se ha Borrado de las Notificaciones.\n\n"; break; } } catch (const char* e) { throw; } }
// Sugiere una materia de las asignaturas seleccionadas tal que algun Estudiante haya aprobada. // En caso que no exista se retorna un ICollection vacio (List). IDictionary *Criterio2::devolverListaAsignatura(IDictionary* asigsUsuario) { // pedimos los estudiantes al manejador y vamos recorriendo uno a uno hasta encontrar alguno que tenga materias // aprobadas, en ese caso retornamos esa lista ManejadorEstudiante *eMgr = ManejadorEstudiante::getInstance(); IDictionary *e = eMgr->getEstudiantes(); bool found = false; ICollection *aprobadas; IDictionary *asignaturasNuevas = new OrderedDictionary(); IIterator * it = e->getIterator(); Estudiante *est; ICollectible *col; ICollectible *col2; ICollectible *col3; while(it->hasCurrent() && !found) { col = it->getCurrent(); if ((est = dynamic_cast<Estudiante*> (col)) != NULL) { if(est->getAprobadas() != NULL) { aprobadas = est->getAprobadas(); IIterator * it2 = aprobadas->getIterator(); while(it2->hasCurrent() && !found) { col2 = it2->getCurrent(); Aprobacion* apro; if ((apro = dynamic_cast<Aprobacion*> (col2)) != NULL) { Asignatura* asig = apro->getAsignatura(); IIterator * it3 = asigsUsuario->getIterator(); while(it3->hasCurrent() && !found) { col3 = it3->getCurrent(); Asignatura* asigUsu; if ((asigUsu = dynamic_cast<Asignatura*> (col3)) != NULL) { if(asig->getCodigo() == asigUsu->getCodigo()) { Integer* cod = new Integer(asig->getCodigo()); asignaturasNuevas->add(cod, asigUsu); found = true; } } else { throw "Criterio1: el parametro no es del tipo Asignatura"; } it3->next(); } delete it3; } else { throw "Criterio1: el parametro no es del tipo Aprobacion"; } it2->next(); } delete it2; } } else { throw "Criterio1: el parametro no es del tipo Estudiante"; } it->next(); } delete it; //if(!found) //asignaturas = new OrderedDictionary(); return asignaturasNuevas; }