Full text
Annexos de la memòria del PFC Integració d'un sistema de videoconferència en una plataforma socio–sanitària amb entorn web Autor: Marc Antoni Bajet i Mena Director del projecte: Lluís Solanell Banegas Ponent: Juan Luís Gorricho Moreno UPC, Desembre 2009
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annexos de la memòria del Projecte Final de Carrera Marc Antoni Bajet i Mena marc.ba[email protected] Desembre 2009
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Índex dels annexos Annex A: Lleis i normatives.................................................................................................................4 A.i Llei general de sanitat................................................................................................................4 A.ii Codi de deontologia mèdica.....................................................................................................4 A.iii Llei orgànica de protecció de dades.........................................................................................6 A.iv Arxius de titularitat public i privat...........................................................................................9 Annex B: Codi Javascript: .................................................................................................................15 B.i Script Login.js..........................................................................................................................15 B.ii Script Video.js.........................................................................................................................17 B.ii.1Detall de l'etiqueta per encastar l'aplicació Flash client...................................................22 Annex C: Codi Java............................................................................................................................23 C.i Package appl/core/videoconferencia........................................................................................23 C.i.1 Classe Room.java..............................................................................................................23 C.i.2 Classe RoomDic.java........................................................................................................25 C.ii Package appl/persistent/videoconferencia...............................................................................29 C.ii.1 Classe Person.java...........................................................................................................29 C.ii.2 Classe PersonWiz.java.....................................................................................................29 C.ii.3 Classe PersonDic.java.....................................................................................................33 C.ii.4 Classe PersonDicWiz.java...............................................................................................33 C.ii.5 Classe User.java...............................................................................................................41 C.ii.6 Classe UserWiz.java........................................................................................................41 C.ii.7 Classe UserDic.java.........................................................................................................44 C.ii.8 Classe UserDicWiz.java..................................................................................................44 C.ii.9 Classe VidSesParticipanType.java...................................................................................52 C.ii.10 Classe VidSesParticipanTypeWiz.java..........................................................................52 C.ii.11 Classe VidSesParticipanTypeDic.java...........................................................................54 C.ii.12 Classe VidSesParticipanTypeDicWiz.java.....................................................................54 C.ii.13 Classe VidSession.java..................................................................................................61 C.ii.14 Classe VidSessionWiz.java............................................................................................62 C.ii.15 Classe VidSessionDic.java............................................................................................65 Marc Antoni Bajet i Mena -1-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web C.ii.16 Classe VidSessionDicWiz.java......................................................................................65 C.ii.17 Classe VidSessionParticipant.........................................................................................73 C.ii.18 Classe VidSessionParticipantWiz.java..........................................................................73 C.ii.19 Classe VidSessionParticipantDic.java...........................................................................75 C.ii.20 Classe VidSessionParticipantDicWiz.java....................................................................76 C.iii Package appl/struts/videoconferencia....................................................................................83 C.iii.1 Classe ControladorGeneral.java.....................................................................................83 C.iii.1.a Detall d'ús dels mètodes d'ActionContext per guardar la sessió.............................87 C.iii.1.b Detall d'ús dels mètodes d'ActionContext per recuperar la sessió..........................88 C.iv Package appl/DAO/................................................................................................................88 C.iv.1 Classe BD.java................................................................................................................88 Annex D: Arxius XML de configuració...........................................................................................105 D.i Configuració del Struts2: videoconferencia.xml....................................................................105 D.ii Configuració de la sala de videoconferència: Telem.xml.....................................................106 D.iii Configuració del servidor de videoconferència: Adaptor.xml.............................................106 Annex E: Documents de disseny.......................................................................................................111 E.i Casos d'ús................................................................................................................................111 E.ii Models...................................................................................................................................112 E.ii.1 Model Conceptual..........................................................................................................112 E.ii.2 Model de Dades.............................................................................................................113 E.ii.3 Model de Disseny...........................................................................................................114 E.iii Seqüències............................................................................................................................115 E.iii.1 Seqüència getUsuaris....................................................................................................115 E.iii.2 Seqüència getRooms.....................................................................................................116 E.iii.3 Seqüència creaRoom.....................................................................................................117 E.iii.4 Seqüència eliminaRoom...............................................................................................118 E.iii.5 Seqüència entraRoom...................................................................................................119 E.iii.6 Seqüència surtRoom.....................................................................................................120 E.iii.7 Seqüència login.............................................................................................................121 Annex F: Patrons i principis.............................................................................................................122 F.i Patrons creacionals..................................................................................................................122 Marc Antoni Bajet i Mena -2-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives F.i.1 Factory Method...............................................................................................................122 F.i.2 Builder.............................................................................................................................125 F.iiPatrons estructurals.................................................................................................................128 F.ii.1Composite........................................................................................................................128 F.ii.2 Facade.............................................................................................................................131 F.iiiPatrons o principis GRASP...................................................................................................134 F.iii.1 Information Expert........................................................................................................134 F.iii.2 Baix acoblament............................................................................................................136 F.iii.3 Alta cohesió..................................................................................................................138 Annex G: Documents d'avaluació.....................................................................................................140 G.i Extracte del RFC 3550...........................................................................................................140 G.ii Captures de Wireshark..........................................................................................................141 G.ii.1 Captures del servidor.....................................................................................................142 G.ii.1.a Captura de l'inici de la seqüència...........................................................................142 G.ii.1.b Captura del final de la seqüència...........................................................................143 G.ii.1.c Captura del resum...................................................................................................144 G.ii.2 Captures del client.........................................................................................................145 G.ii.2.a Captura de l'inici de la seqüència...........................................................................145 G.ii.2.b Captura del final de la seqüència...........................................................................146 G.ii.2.c Captura del resum..................................................................................................147 G.iii Raonament del càlcul del temps mig de retard....................................................................148 G.iv Qüestionari d'avaluació........................................................................................................149 G.iv.1Questionari respostos:....................................................................................................150 Annex H:Manual d'usuari.................................................................................................................154 Annex I:Calendaris de previsió.........................................................................................................157 Annex J:Carta d'intencions d'ús........................................................................................................158 Marc Antoni Bajet i Mena -3-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives Annex A: Lleis i normatives A.i Llei general de sanitat Ley 14/1986, de 25 de abril, General de Sanidad. Artículo 10.3 Todos tienen los siguientes derechos con respecto a las distintas administraciones públicas sanitarias: 3)A la confidencialidad de toda la información relacionada con su proceso y con su estancia en instituciones sanitarias públicas y privadas que colaboren con el sistema público. A.ii Codi de deontologia mèdica CÓDIGO DE DEONTOLOGÍA MÉDICA SECRETO PROFESIONAL DEL MÉDICO Artículo 16.- 1. El secreto del médico es inherente al ejercicio de la profesión y se establece como un derecho del paciente para su seguridad. 2. El secreto profesional obliga a todos los médicos cualquiera que sea la modalidad de su ejercicio. 3. El médico guardará secreto de todo lo que el paciente le haya confiado y de lo que haya conocido en su ejercicio profesional. 4. La muerte del enfermo no exime al médico del deber del secreto. Artículo 17.- 1. El médico tiene el deber de exigir a sus colaboradores absoluta discreción y observancia escrupulosa del secreto profesional. Ha de hacérseles saber que ellos también están obligados a guardarlo. 2. En el ejercicio de la medicina en equipo, cada médico es responsable de la totalidad del secreto. Los directivos de la institución tienen el deber de poner todos los medios necesarios para que esto sea posible. Marc Antoni Bajet i Mena -4-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives Artículo 18.- Con discreción, exclusivamente ante quien tenga que hacerlo y en sus justos y restringidos límites, el médico revelará el secreto en los siguientes casos: 1. Por imperativo legal. Si bien en sus declaraciones ante los Tribunales de Justicia deberá apreciar si, a pesar de todo, el secreto profesional le obliga a reservar ciertos datos. Si fuera necesario pedirá asesoramiento al Colegio. 2. Cuando el médico se vea injustamente perjudicado por causa del mantenimiento del secreto de un paciente y éste sea el autor voluntario del perjuicio. 3. Si con el silencio se diera lugar a un perjuicio al propio paciente u otras personas o un peligro colectivo. 4. En las enfermedades de declaración obligatoria. 5. Cuando el médico comparezca como acusado ante el Colegio o sea llamado a testimoniar en materia disciplinaria. No obstante, tendrá derecho a no revelar las confidencias del paciente. Artículo 19.- 1. Los sistemas de informatización médica no comprometerán el derecho del paciente a la intimidad. 2. Todo banco de datos que ha sido extraído de historias clínicas estará bajo la responsabilidad de un médico. 3. Un banco de datos médicos no debe conectarse a una red informática ni médica. Artículo 20.- Cuando un médico cesa en su trabajo privado, su archivo podrá ser transferido al colega que le suceda, salvo que los pacientes manifiesten su voluntad en contra. Cuando no tenga lugar tal sucesión el archivo deberá ser destruido, sin perjuicio de lo dispuesto en el artículo 16.2 de este Código. Marc Antoni Bajet i Mena -5-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives A.iii Llei orgànica de protecció de dades Ley Orgánica 15/1999, de 13 de diciembre, de Protección de Datos de Carácter Personal. PRINCIPIOS DE PROTECCIÓN DE DATOS: Artículo 8. Datos relativos a la salud. Sin perjuicio de lo que se dispone en el artículo 11 respecto de la cesión, las instituciones y los centros sanitarios públicos y privados y los profesionales correspondientes podrán proceder al tratamiento de los datos de carácter personal relativos a la salud de las personas que a ellos acudan o hayan de ser tratados en los mismos, de acuerdo con lo dispuesto en la legislación estatal o autonómica sobre sanidad. Artículo 9. Seguridad de los datos. 1. El responsable del fichero, y, en su caso, el encargado del tratamiento deberán adoptar las medidas de índole técnica y organizativas necesarias que garanticen la seguridad de los datos de carácter personal y eviten su alteración, pérdida, tratamiento o acceso no autorizado, habida cuenta del estado de la tecnología, la naturaleza de los datos almacenados y los riesgos a que esten expuestos, ya provengan de la acción humana o del medio físico o natural. 2. No se registrarán datos de carácter personal en ficheros que no reúnan las condiciones que se determinen por vía reglamentaria con respecto a su integridad y seguridad y a las de los centros de tratamiento, locales, equipos, sistemas y programas. 3. Reglamentariamente se establecerán los requisitos y condiciones que deban reunir los ficheros y las personas que intervengan en el tratamiento de los datos a que se refiere el artículo 7 de esta Ley. Artículo 10. Deber de secreto. El responsable del fichero y quienes intervengan en cualquier fase del tratamiento de los datos de carácter personal esten obligados al secreto profesional respecto de los mismos y al deber de guardarlos, obligaciones que subsistirán aun después de finalizar sus relaciones con el titular del fichero o, en su caso, con el responsable del mismo. Marc Antoni Bajet i Mena -6-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives Ley. 3. En los supuestos a que se refieren los dos apartados anteriores, cuando el interesado lo solicite, el responsable del tratamiento le comunicará los datos, así como las evaluaciones y apreciaciones que sobre el mismo hayan sido comunicadas durante los últimos seis meses y el nombre y dirección de la persona o entidad a quien se hayan revelado los datos. 4. Sólo se podrán registrar y ceder los datos de carácter personal que sean determinantes para enjuiciar la solvencia económica de los interesados y que no se refieran, cuando sean adversos, a más de seis años, siempre que respondan con veracidad a la situación actual de aquéllos. Artículo 30. Tratamientos con fines de publicidad y de prospección comercial 1. Quienes se dediquen a la recopilación de direcciones, reparto de documentos, publicidad, venta a distancia, prospección comercial y otras actividades análogas, utilizarán nombres y direcciones u otros datos de carácter personal cuando los mismos figuren en fuentes accesibles al público o cuando hayan sido facilitados por los propios interesados u obtenidos con su consentimiento. 2. Cuando los datos procedan de fuentes accesibles al público, de conformidad con lo establecido en el párrafo segundo del artículo 5.5 de esta Ley, en cada comunicación que se dirija al interesado se informará del origen de los datos y de la identidad del responsable del tratamiento, así como de los derechos que le asisten. 3. En el ejercicio del derecho de acceso los interesados tendrán derecho a conocer el origen de sus datos de carácter personal, así como del resto de información a que se refiere el artículo 15. 4. Los interesados tendrán derecho a oponerse, previa petición y sin gastos, al tratamiento de los datos que les conciernan, en cuyo caso serán dados de baja del tratamiento, cancelándose las informaciones que sobre ellos figuren en aquél, a su simple solicitud. Artículo 31. Censo promocional 1. Quienes pretendan realizar permanente o esporádicamente la actividad de recopilación de direcciones, reparto de documentos, publicidad, venta a distancia, prospección comercial u otras actividades análogas, podrán solicitar del Instituto Nacional de Estadística o de los órganos equivalentes de las Comunidades Autónomas una copia del censo promocional, formado con los datos de nombre, apellidos y domicilio que constan en el censo electoral. 2. El uso de cada lista de censo promocional tendrá un plazo de vigencia de un año. Transcurrido el plazo citado, la lista perderá su carácter de fuente de acceso público. 3. Los procedimientos mediante los que los interesados podrán solicitar no aparecer en el censo promocional se regularán reglamentariamente. Entre estos procedimientos, que serán Marc Antoni Bajet i Mena -13-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex A: Lleis i normatives gratuitos para los interesados, se incluirá el documento de empadronamiento. Trimestralmente se editará una lista actualizada del censo promocional, excluyendo los nombres y domicilios de los que así lo hayan solicitado. 4. Se podrá exigir una contraprestación por la facilitación de la citada lista en soporte informático. Artículo 32. Códigos tipo. 1. Mediante acuerdos sectoriales, convenios administrativos o decisiones de empresa, los responsables de tratamientos de titularidad pública y privada, así como las organizaciones en que se agrupen, podrán formular códigos tipo que establezcan las condiciones de organización, régimen de funcionamiento, procedimientos aplicables, normas de seguridad del entorno, programas o equipos, obligaciones de los implicados en el tratamiento y uso de la información personal, así como las garantías, en su ámbito, para el ejercicio de los derechos de las personas con pleno respeto a los principios y disposiciones de la presente Ley y sus normas de desarrollo. 2. Los citados códigos podrán contener o no reglas operacionales detalladas de cada sistema particular y estándares técnicos de aplicación. En el supuesto de que tales reglas o estándares no se incorporen directamente al código, las instrucciones u órdenes que los establecieran deberán respetar los principios fijados en aquél. 3. Los códigos tipo tendrán el carácter de códigos deontológicos o de buena práctica profesional, debiendo ser depositados o inscritos en el Registro General de Protección de Datos y, cuando corresponda, en los creados a estos efectos por las Comunidades Autónomas, de acuerdo con el artículo 41. El Registro General de Protección de Datos podrá denegar la inscripción cuando considere que no se ajusta a las disposiciones legales y reglamentarias sobre la materia, debiendo, en este caso, el Director de la Agencia Española de Protección de Datos requerir a los solicitantes para que efectúen las correcciones oportunas. Marc Antoni Bajet i Mena -14-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: Annex B: Codi Javascript: B.i Script Login.js Ext.onReady(function(){ Ext.QuickTips.init(); // Create a variable to hold our EXT Form Panel. // Assign various config options as seen. var login = new Ext.FormPanel({ labelWidth:80, url:'loginUser.action', frame:true, title:'Introdueix el teu usuari i password', defaultType:'textfield', monitorValid:true, // Specific attributes for the text fields for username / password. // The "name" attribute defines the name of variables sent to the server. items:[{ fieldLabel:'Usuari', name:'loginUsername', allowBlank:false },{ fieldLabel:'Password', name:'loginPassword', inputType:'password', allowBlank:false }], // All the magic happens after the user clicks the button buttons:[{ text:'Login', formBind: true, // Function that fires when user clicks the button handler:function(){ login.getForm().submit({ method:'POST', waitTitle:'Connectant', waitMsg:'Verificant dades...', success:function(){ var redirect = 'videoconferencia.html'; window.location = redirect; }, failure:function(form, action){ if(action.failureType == 'server'){ obj = Ext.util.JSON.decode(action.response.responseText); Ext.Msg.alert('Login Failed!', obj.errors.reason); }else{ Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText); } Marc Antoni Bajet i Mena -15-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: login.getForm().reset(); } }); } }] }); // This just creates a window to wrap the login form. // The login object is passed to the items collection. var win = new Ext.Window({ layout:'fit', width:300, height:150, closable: false, resizable: false, plain: true, border: false, items: [login] }); win.show(); }); Marc Antoni Bajet i Mena -16-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: B.ii Script Video.js Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif'; Ext.ns('Videoconferencia'); // application main entry point Ext.onReady(function() { Ext.QuickTips.init(); // codi del la part de la llista d'usuaris var smUsers = new Ext.grid.CheckboxSelectionModel({ singleSelect: true, listeners: { selectionchange: function(sm) { if (sm.getCount()) { gridUsers.callButton.enable(); } else { gridUsers.callButton.disable(); } } } }); var idUsr = new Ext.form.TextField({ xtype:"textfield", name:"idUser2", value:"0" }); var formUsers = new Ext.form.FormPanel({ id:'formUsers', url:'formUsersPost.action', hidden:true, items: idUsr }); var gridUsers = new Ext.grid.GridPanel({ id:'usersGrid', url: 'gridUsersPost.action', store: storeUsers, cm: new Ext.grid.ColumnModel([ smUsers, {header: "Nom", dataIndex: 'txname', sortable: true}, {header: "Primer Cognom", dataIndex: 'txfirstsurname', sortable: true}, {header: "Segon Cognom", dataIndex: 'txsecondsurname', sortable: true} ]), sm: smUsers, viewConfig: {border:false, forceFit:true}, columnLines: true, stripeRows: true, height: 350, Marc Antoni Bajet i Mena -17-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: frame:true, title:"Llistat d'usuaris del sistema", iconCls:'icon-grid', loadMask:true, tbar:[{ text:'Videoconferencia', tooltip:'Convida als usuaris a fer una videoconferencia', iconCls:'options', // Place a reference in the GridPanel ref: '../callButton', disabled: true, handler: function(){ var m = smUsers.getSelections(); idUsr.setValue(m[0].get('iidgnrperson')); formUsers.getForm().submit({ success: function(f,a){ formUsers.getForm().setValues(a.result.data); storeRooms.load(); }, failure: function(f,a){ Ext.Msg.alert('Warning', a.result.errormsg); } }); } }] }); // Codi de la part de les sales de videoconferencia var session = new Ext.form.TextField({ xtype:"textfield", name:"session", value:"null" }); var idUser = new Ext.form.TextField({ xtype:"textfield", name:"idUser", value:"null" }); var idRoom = new Ext.form.TextField({ xtype:"textfield", name:"idRoom", value:"0" }); var opRoom = new Ext.form.TextField({ xtype:"textfield", name:"opRoom", value:"null" }); Marc Antoni Bajet i Mena -18-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: var formRooms = new Ext.form.FormPanel({ id:'formRooms', url:'formRoomsPost.action', hidden:true, items: [ session, idRoom,opRoom ] }); var smRooms = new Ext.grid.RowSelectionModel({ singleSelect:true, grid: gridRooms, listeners: { selectionchange: function(sm) { if (sm.getCount()) { if(sm.getSelected().get('nomPonent')!='Llista de Sales buida') gridRooms.inButton.enable(); Ext.Ajax.request({ url: 'listRooms.action', success: function(response){ var jsonRes = eval("(" + response.responseText + ")"); if(sm.getSelected().get('idPonent')==jsonRes.idUser){ gridRooms.delButton.enable(); } }, failure: function () { alert('Ooops !!');} }); } else { gridRooms.inButton.disable(); gridRooms.delButton.disable(); } } } }); var gridRooms = new Ext.grid.GridPanel({ id:'usersRooms', viewConfig: {border:false, forceFit:true }, columnLines: true, stripeRows: true, height: 325, frame:true, title:"Llistat d'usuaris del sistema", iconCls:'icon-grid', store: storeRooms, sm: smRooms, columns: [ {header: "Sala", dataIndex: 'iidvidsession',id:'s1'}, {header: "Assistents", dataIndex: 'nomPonent',renderer:ponent_participant,id:'s2'}, {header: "Participant", dataIndex: 'nomParticipant0',id:'s3',hidden:true} ], tbar:[{ text:'Entra a la sala', tooltip:'Entra a la sala de videoconferencia', iconCls:'options', Marc Antoni Bajet i Mena -19-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: ref: '../inButton', disabled: true, handler: function(){ var record = smRooms.getSelected(); idRoom.setValue(record.get('iidvidsession')); opRoom.setValue("in"); formRooms.getForm().submit({ success: function(f,a){ session.setValue(a.result.session); idUser.setValue(a.result.idUser); formRooms.getForm().setValues(a.result.data); var win = new Ext.Window({ layout:'fit', width:900, height:600, closable: true, resizable: true, plain: true, border: false, items: [{ layout:'fit', border: false, html:'<embed height="100%" width="100%" name="plugin" src="http://172.21.102.32:8080/videoconferencia/Telemedicina.swf? roomId='+idRoom.getValue() +'&userId='+ session.getValue() +' " type="application/x-shockwave-flash"/>'}] }); win.show(); }, failure: function(f,a){ Ext.Msg.alert('Atencio', 'Hi ha hagut un problema, torna-ho a intentar'); } }); storeRooms.load(); } }], bbar:[{ text:'Tanca la sala', tooltip:'Tanca la sala de videoconferencia', iconCls:'options', ref: '../delButton', disabled: true, handler: function(){ var record = smRooms.getSelected(); idRoom.setValue(record.get('iidvidsession')); opRoom.setValue("del"); formRooms.getForm().submit({ success: function(f,a){ formRooms.getForm().setValues(a.result.data); storeRooms.load(); }, failure: function(f,a){ Ext.Msg.alert( 'Atencio', "Has de ser el ponent de la sala per poder-la eliminar"); Marc Antoni Bajet i Mena -20-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: storeRooms.load(); } }); } }] }); // Codi de la pantalla principal var userList = new Ext.Panel({ layout:"fit", items: [ gridUsers,formUsers] }); var window = new Ext.Viewport( { xtype:"panel", layout:"fit", title:"", items:[{ layout:"border", items:[{ region:"center", items:[ userList ] },{ region:"east", width:300, collapsible:false, title: 'Sales actives', items: [{ layout:"fit", items:[gridRooms, formRooms] }] }] }] }); }); // eo function onReady var storeRooms = new Ext.data.JsonStore({ autoDestroy:true, totalProperty: 'totalRooms', url:"listRooms.action", idProperty: 'iidvidsession', root:"rooms", fields:['iidvidsession','nomPonent','nomParticipant0','idPonent'] }); storeRooms.setDefaultSort('iidvidsession', 'desc'); storeRooms.load(); var storeUsers = new Ext.data.Store({ url:"listUsers.action", autoLoad:{params:{start:0, limit:10}}, totalProperty: 'totalUsers', Marc Antoni Bajet i Mena -21-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex B: Codi Javascript: reader: new Ext.data.JsonReader({root:"users",id:'iidgnrperson'}, [ 'iidgnrperson', 'txname', 'txfirstsurname', 'txsecondsurname' ]) }); storeUsers.setDefaultSort('txname', 'asc'); function ponent_participant(ponent,x,store){ return '<b>'+ponent+'</b><br>'+store.data.nomParticipant0; } B.ii.1 Detall de l'etiqueta per encastar l'aplicació Flash client '<embed height="100%" width="100%" name="plugin" src="http://172.21.102.32:8080/videoconferencia/Telemedicina.swf? roomId='+idRoom.getValue() +'&userId='+ session.getValue() +' " type="application/x-shockwave-flash"/>' Cal notar que tant session.getValue( ) com idRoom.getValue( ) són paràmetres que venen del servidor i que es recuperen mitjançant una crida AJAX. Marc Antoni Bajet i Mena -22-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii Package appl/persistent/videoconferencia En aquest paquet hi ha totes les classes que implementen la persistència. S'hi pot trobar les classes següents: La classe Person.java, recolzada per PersonWiz.java, i el seu diccionari PersonDic.java, recolzada per PersonDicWiz.java. La classe User.java (recolzada per UserWiz.java, i el seu diccionari UserDic.java, recolzada per UserDicWiz.java. La classe VidSesParticipant.java, recolzada per VidSesParticipantWiz.java, i el seu diccionari VidSesParticipantDic.java, recolzada per VidSesParticipantDicWiz.java. La classe VidSessionParticipanType.java, recolzada per VidSessionParticipanTypeWiz.java, i el seu diccionari VidSessionParticipanTypeDic.java, recolzada per VidSessionParticipanTypeDicWiz.java. La classe VidSession.java, recolzada per VidSessionWiz.java, i el seu diccionari VidSessionDic.java, recolzada per VidSessionDicWiz.java. La classe VidSessionParticipant.java, recolzada per VidSessionParticipantWiz.java, i el seu diccionari VidSessionParticipantDic.java, recolzada per VidSessionParticipantDicWiz.java. C.ii.1 Classe Person.java package appl.persistent.videoconferencia; import java.util.List; import appl.DAO.BD; public class Person extends PersonWiz { public List<Person> getListVideoparticipants(int id){ PersonDic cd = PersonDic.getInstance(); List<Person> person = cd.findAll(); //TODO: modificar si es vol limitar el llistat segons l'usuari System.out.println("getListParticipants"); return person; } } C.ii.2 Classe PersonWiz.java package appl.persistent.videoconferencia; import java.util.*; Marc Antoni Bajet i Mena -29-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java import appl.DAO.*; public class PersonWiz { public static final String oidPrefix = "TBGN"; protected int iidgnrperson; protected String txname; protected String txfirstsurname; protected String txsecondsurname; protected String txinitials; protected String csex; protected java.sql.Date dtbirthday; protected int iidgnridentitydoctype; protected String txidentitydoc; protected int iidgnrnationality; public int getIdInt() { return getIidgnrperson(); } public String getId() { return oidPrefix + BD.strZero("" + getIidgnrperson(), 8); } public void setIdInt(int valor) { setIidgnrperson(valor); } public void setIidgnrperson(int valor) { iidgnrperson = valor; } public int getIidgnrperson() { return iidgnrperson; } public void setTxname(String valor) { txname = valor; } public String getTxname() { return txname; } Marc Antoni Bajet i Mena -30-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public void setTxfirstsurname(String valor) { txfirstsurname = valor; } public String getTxfirstsurname() { return txfirstsurname; } public void setTxsecondsurname(String valor) { txsecondsurname = valor; } public String getTxsecondsurname() { return txsecondsurname; } public void setTxinitials(String valor) { txinitials = valor; } public String getTxinitials() { return txinitials; } public void setCsex(String valor) { csex = valor; } public String getCsex() { return csex; } public void setDtbirthday(java.sql.Date valor) { dtbirthday = valor; } public java.sql.Date getDtbirthday() { return dtbirthday; } Marc Antoni Bajet i Mena -31-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public void setIidgnridentitydoctype(int valor) { iidgnridentitydoctype = valor; } public int getIidgnridentitydoctype() { return iidgnridentitydoctype; } public void setTxidentitydoc(String valor) { txidentitydoc = valor; } public String getTxidentitydoc() { return txidentitydoc; } public void setIidgnrnationality(int valor) { iidgnrnationality = valor; } public int getIidgnrnationality() { return iidgnrnationality; } } Marc Antoni Bajet i Mena -32-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii.3 Classe PersonDic.java package appl.persistent.videoconferencia; import java.util.*; public class PersonDic extends PersonDicWiz { public List<Person> listUsersForId(int idPerson){ List<Person> lp = findAll(); for(int i=0;i<lp.size();i++){ Person p=lp.get(i); if(p.getIdInt()==idPerson){ lp.remove(p); break; } } return lp; } public static PersonDic getInstance() { return new PersonDic(); } } C.ii.4 Classe PersonDicWiz.java package appl.persistent.videoconferencia; import java.sql.*; import java.util.*; import appl.DAO.*; /** Params gene: Driver JDBC = oracle.jdbc.driver.OracleDriver DSN = jdbc:oracle:thin:@172.18.4.8:1521:LCPROD TABLE = TBGNRPERSON OID_WIDTH = 12 OID_PREFIX_WIDTH = 4 package = appl.core.videoconferencia class = Videoparticipant username = linkcare_pre2 password = XXXX Out path wiz = src_wiz Marc Antoni Bajet i Mena -33-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java Out path nowiz = src_nowiz ts crea = 11-ago-2009 18:34:01 */ public class PersonDicWiz { private PreparedStatement prepAlta = null; private PreparedStatement prepModif = null; private PreparedStatement prepBaja = null; private PreparedStatement prepBajaLogica = null; private PreparedStatement prepFindByPk = null; public final String queryAlta = "INSERT INTO TBGNRPERSON(" + " IIDGNRPERSON, " + " TXNAME, " + " TXFIRSTSURNAME, " + " TXSECONDSURNAME, " + " TXINITIALS, " + " CSEX, " + " DTBIRTHDAY, " + " IIDGNRIDENTITYDOCTYPE, " + " TXIDENTITYDOC, " + " IIDGNRNATIONALITY) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; public final String queryModif = "UPDATE TBGNRPERSON SET " + " TXNAME = ?, " + " TXFIRSTSURNAME = ?, " + " TXSECONDSURNAME = ?, " + " TXINITIALS = ?, " + " CSEX = ?, " + " DTBIRTHDAY = ?, " + " IIDGNRIDENTITYDOCTYPE = ?, " + " TXIDENTITYDOC = ?, " + " IIDGNRNATIONALITY = ? " + " WHERE IIDGNRPERSON = ?"; public final String queryBaja = " DELETE FROM TBGNRPERSON WHERE IIDGNRPERSON = ? "; public final String queryBajaLogica = " UPDATE TBGNRPERSON SET DEL = 'Y' WHERE IIDGNRPERSON = ? "; public final String queryFindByPk = " SELECT IIDGNRPERSON, TXNAME, TXFIRSTSURNAME, TXSECONDSURNAME, TXINITIALS, CSEX, DTBIRTHDAY, IIDGNRIDENTITYDOCTYPE, TXIDENTITYDOC, IIDGNRNATIONALITY " + " FROM TBGNRPERSON " + " WHERE IIDGNRPERSON = ? "; Marc Antoni Bajet i Mena -34-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public PreparedStatement getPrepAlta() { try { BD bd = BD.getInstance(); if (prepAlta == null) prepAlta = bd.prepareStatement(queryAlta); return prepAlta; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepModif() { try { BD bd = BD.getInstance(); if (prepModif == null) prepModif = bd.prepareStatement(queryModif); return prepModif; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBaja() { try { BD bd = BD.getInstance(); if (prepBaja == null) prepBaja = bd.prepareStatement(queryBaja); return prepBaja; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBajaLogica() { try { BD bd = BD.getInstance(); if (prepBajaLogica == null) Marc Antoni Bajet i Mena -35-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java prepBajaLogica = bd.prepareStatement(queryBajaLogica); return prepBajaLogica; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepFindByPk() { try { BD bd = BD.getInstance(); if (prepFindByPk == null) prepFindByPk = bd.prepareStatement(queryFindByPk); return prepFindByPk; } catch (SQLException e) { throw new RuntimeException(e); } } public Person crearVideoparticipant() { return crearVideoparticipant(true); } public Person crearVideoparticipant(boolean persisted) { PersonDic vObj = PersonDic.getInstance(); Person obj = new Person(); if (persisted) vObj.save(obj); return obj; } public int alta(Person dto) { int lastId = 0; try { Person obj = (Person) dto; prepAlta = getPrepAlta(); prepAlta.clearParameters(); prepAlta.setObject(1, obj.getIidgnrperson()); prepAlta.setObject(2, obj.getTxname()); prepAlta.setObject(3, obj.getTxfirstsurname()); prepAlta.setObject(4, obj.getTxsecondsurname()); Marc Antoni Bajet i Mena -36-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java prepAlta.setObject(5, obj.getTxinitials()); prepAlta.setObject(6, obj.getCsex()); prepAlta.setObject(7, obj.getDtbirthday()); prepAlta.setObject(8, obj.getIidgnridentitydoctype()); prepAlta.setObject(9, obj.getTxidentitydoc()); prepAlta.setObject(10, obj.getIidgnrnationality()); prepAlta.executeUpdate(); ResultSet rs = prepAlta.getGeneratedKeys(); if (rs.next()) lastId = rs.getInt(1); dto.setIdInt(lastId); } catch (SQLException e) { throw new RuntimeException(e); } return lastId; } public int baja(Person obj) { int idInt = obj.getIdInt(); return baja(idInt); } public int remove(Person obj) { return baja(obj); } public int removeById(String id) { PersonDic objd = PersonDic.getInstance(); Person obj = objd.findById(id); if (obj != null) return baja(obj); else return 0; } public int baja(int id) { int res = 0; try { prepBaja = getPrepBaja(); prepBaja.setInt(1, id); res = prepBaja.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); Marc Antoni Bajet i Mena -37-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } return res; } public int bajaLogica(Person obj) { int idInt = obj.getIdInt(); return bajaLogica(idInt); } public int bajaLogica(int id) { int res = 0; try { prepBajaLogica = getPrepBajaLogica(); prepBajaLogica.setInt(1, id); res = prepBajaLogica.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int save(Person dto) { int res; if (dto.getIdInt() == 0) res = alta(dto); else res = modif(dto); return res; } public int saveAndFlush(Person dto) { return save(dto); } public int modif(Person dto) { int res = 0; try { BD bd = BD.getInstance(); Person obj = (Person) dto; prepModif = getPrepModif(); prepModif.clearParameters(); Marc Antoni Bajet i Mena -38-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java import appl.DAO.*;; /** Params gene: Driver JDBC = oracle.jdbc.driver.OracleDriver DSN = jdbc:oracle:thin:@172.18.4.8:1521:LCPROD TABLE = TBGNRUSER OID_WIDTH = 12 OID_PREFIX_WIDTH = 4 package = appl.persistent class = User username = linkcare_pre2 password = XXXX Out path wiz = src_wiz Out path nowiz = src_nowiz ts crea = 10-sep-2009 10:24:21 */ public class UserDicWiz { private PreparedStatement prepAlta = null; private PreparedStatement prepModif = null; private PreparedStatement prepBaja = null; private PreparedStatement prepBajaLogica = null; private PreparedStatement prepFindByPk = null; public final String queryAlta = "INSERT INTO TBGNRUSER(" + " IIDGNRUSER, " + " IIDGNRPERSON, " + " TXLOGIN, " + " TXPASSWORD, " + " DTLASTACCESSDATE, " + " DTLASTFAILUREDATE, " + " BACTIVE, " + " IACCESSFAILURENUMBER, " + " IIDDEFAULTLANGUAGE) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; public final String queryModif = "UPDATE TBGNRUSER SET " + " IIDGNRPERSON = ?, " + " TXLOGIN = ?, " + " TXPASSWORD = ?, " + " DTLASTACCESSDATE = ?, " + " DTLASTFAILUREDATE = ?, " + " BACTIVE = ?, " + " IACCESSFAILURENUMBER = ?, " + " IIDDEFAULTLANGUAGE = ? " + " WHERE IIDGNRUSER = ?"; public final String queryBaja = " DELETE FROM TBGNRUSER WHERE IIDGNRUSER = ? "; Marc Antoni Bajet i Mena -45-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public final String queryBajaLogica = " UPDATE TBGNRUSER SET DEL = 'Y' WHERE IIDGNRUSER = ? "; public final String queryFindByPk = " SELECT IIDGNRUSER, IIDGNRPERSON, TXLOGIN, TXPASSWORD, DTLASTACCESSDATE, DTLASTFAILUREDATE, BACTIVE, IACCESSFAILURENUMBER, IIDDEFAULTLANGUAGE " + " FROM TBGNRUSER " + " WHERE IIDGNRUSER = ? "; public PreparedStatement getPrepAlta() { try { BD bd = BD.getInstance(); if (prepAlta == null) prepAlta = bd.prepareStatement(queryAlta); return prepAlta; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepModif() { try { BD bd = BD.getInstance(); if (prepModif == null) prepModif = bd.prepareStatement(queryModif); return prepModif; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBaja() { try { BD bd = BD.getInstance(); if (prepBaja == null) prepBaja = bd.prepareStatement(queryBaja); return prepBaja; } Marc Antoni Bajet i Mena -46-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBajaLogica() { try { BD bd = BD.getInstance(); if (prepBajaLogica == null) prepBajaLogica = bd.prepareStatement(queryBajaLogica); return prepBajaLogica; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepFindByPk() { try { BD bd = BD.getInstance(); if (prepFindByPk == null) prepFindByPk = bd.prepareStatement(queryFindByPk); return prepFindByPk; } catch (SQLException e) { throw new RuntimeException(e); } } public User crearUser() { return crearUser(true); } public User crearUser(boolean persisted) { UserDic vObj = UserDic.getInstance(); User obj = new User(); if (persisted) vObj.save(obj); return obj; } public int alta(User dto) { int lastId = 0; Marc Antoni Bajet i Mena -47-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java try { User obj = (User) dto; prepAlta = getPrepAlta(); prepAlta.clearParameters(); prepAlta.setObject(1, obj.getIidgnruser()); prepAlta.setObject(2, obj.getIidgnrperson()); prepAlta.setObject(3, obj.getTxlogin()); prepAlta.setObject(4, obj.getTxpassword()); prepAlta.setObject(5, obj.getDtlastaccessdate()); prepAlta.setObject(6, obj.getDtlastfailuredate()); prepAlta.setObject(7, obj.getBactive()); prepAlta.setObject(8, obj.getIaccessfailurenumber()); prepAlta.setObject(9, obj.getIiddefaultlanguage()); prepAlta.executeUpdate(); ResultSet rs = prepAlta.getGeneratedKeys(); if (rs.next()) lastId = rs.getInt(1); dto.setIdInt(lastId); } catch (SQLException e) { throw new RuntimeException(e); } return lastId; } public int baja(User obj) { int idInt = obj.getIdInt(); return baja(idInt); } public int remove(User obj) { return baja(obj); } public int removeById(String id) { UserDic objd = UserDic.getInstance(); User obj = objd.findById(id); if (obj != null) return baja(obj); else return 0; } public int baja(int id) { Marc Antoni Bajet i Mena -48-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java int res = 0; try { prepBaja = getPrepBaja(); prepBaja.setInt(1, id); res = prepBaja.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int bajaLogica(User obj) { int idInt = obj.getIdInt(); return bajaLogica(idInt); } public int bajaLogica(int id) { int res = 0; try { prepBajaLogica = getPrepBajaLogica(); prepBajaLogica.setInt(1, id); res = prepBajaLogica.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int save(User dto) { int res; if (dto.getIdInt() == 0) res = alta(dto); else res = modif(dto); return res; } public int saveAndFlush(User dto) { return save(dto); } Marc Antoni Bajet i Mena -49-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public int modif(User dto) { int res = 0; try { BD bd = BD.getInstance(); User obj = (User) dto; prepModif = getPrepModif(); prepModif.clearParameters(); prepModif.setObject(1, obj.getIidgnrperson()); prepModif.setObject(2, obj.getTxlogin()); prepModif.setObject(3, obj.getTxpassword()); prepModif.setObject(4, obj.getDtlastaccessdate()); prepModif.setObject(5, obj.getDtlastfailuredate()); prepModif.setObject(6, obj.getBactive()); prepModif.setObject(7, obj.getIaccessfailurenumber()); prepModif.setObject(8, obj.getIiddefaultlanguage()); prepModif.setInt(9, obj.getIidgnruser()); res = prepModif.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public User findByPrimaryKey(int id) { User obj = null; try { prepFindByPk = getPrepFindByPk(); prepFindByPk.setInt(1, id); ResultSet rs = prepFindByPk.executeQuery(); BD bd = BD.getInstance(); obj = (User) bd.getDTO(User.class, rs); rs.close(); } catch (SQLException e) { throw new RuntimeException(e); } return obj; } public User findById(String id) Marc Antoni Bajet i Mena -50-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java { try { int pk = Integer.parseInt(id.substring(4, 12)); return findByPrimaryKey(pk); } catch(Exception e){} { return null; } } public void resetPreps() { prepAlta = null; prepModif = null; prepBaja = null; prepBajaLogica = null; prepFindByPk = null; } public String getTabla() { return "TBGNRUSER"; } public String getCampoId() { return "IIDGNRUSER"; } public String getOidPrefix() { return "USER"; } public List<User> findAll(){ BD bd = BD.getInstance(); List<User> la = bd.getDTOs(User.class, "SELECT * FROM "+this.getTabla()); return la; } } Marc Antoni Bajet i Mena -51-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii.9 Classe VidSesParticipanType.java package appl.persistent.videoconferencia; public class VidSesParticipanType extends VidSesParticipanTypeWiz { } C.ii.10 Classe VidSesParticipanTypeWiz.java package appl.persistent.videoconferencia; import java.util.*; import appl.*; import appl.DAO.*;; public class VidSesParticipanTypeWiz { public static final String oidPrefix = "TBVI"; protected int iid; protected String txmlname; protected String txmlshortname; protected String bactive; public int getIdInt() { return getIid(); } public String getId() { return oidPrefix + BD.strZero("" + getIid(), 8); } public void setIdInt(int valor) { setIid(valor); } public void setIid(int valor) { iid = valor; } public int getIid() { return iid; Marc Antoni Bajet i Mena -52-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } public void setTxmlname(String valor) { txmlname = valor; } public String getTxmlname() { return txmlname; } public void setTxmlshortname(String valor) { txmlshortname = valor; } public String getTxmlshortname() { return txmlshortname; } public void setBactive(String valor) { bactive = valor; } public String getBactive() { return bactive; } } Marc Antoni Bajet i Mena -53-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii.11 Classe VidSesParticipanTypeDic.java package appl.persistent.videoconferencia; import java.util.ArrayList; public class VidSesParticipanTypeDic extends VidSesParticipanTypeDicWiz { public static VidSesParticipanTypeDic getInstance() { return new VidSesParticipanTypeDic(); } } C.ii.12 Classe VidSesParticipanTypeDicWiz.java package appl.persistent.videoconferencia; import java.sql.*; import java.util.*; import appl.*; import appl.DAO.*;; /** Params gene: Driver JDBC = oracle.jdbc.driver.OracleDriver DSN = jdbc:oracle:thin:@172.18.4.8:1521:LCPROD TABLE = TBVIDSESPARTICIPANTYPE OID_WIDTH = 12 OID_PREFIX_WIDTH = 4 package = appl.persistent.videoconferencia class = VidSesParticipanType username = linkcare_pre2 password = XXXX Out path wiz = src_wiz Out path nowiz = src_nowiz ts crea = 14-ago-2009 11:08:26 */ public class VidSesParticipanTypeDicWiz { private PreparedStatement prepAlta = null; private PreparedStatement prepModif = null; private PreparedStatement prepBaja = null; private PreparedStatement prepBajaLogica = null; private PreparedStatement prepFindByPk = null; public final String queryAlta = Marc Antoni Bajet i Mena -54-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii.13 Classe VidSession.java package appl.persistent.videoconferencia; import appl.DAO.BD; public class VidSession extends VidSessionWiz { public void addParticipant(Person persona){ BD bd = BD.getInstance(); bd.beginTrans(); VidSessionParticipantDic dc_sesPart = VidSessionParticipantDic.getInstance(); VidSessionParticipant sesPart2; int maxIdSesPart=dc_sesPart.getMaxId(); sesPart2=dc_sesPart.crearVidSessionParticipant(false); maxIdSesPart++; sesPart2.setIidvidsesparticipant(maxIdSesPart); sesPart2.setBaccepted("T"); sesPart2.setIdvidparticipantype(2); // 1 ponent 2 participant sesPart2.setIidgnrperson(persona.getIidgnrperson()); sesPart2.setIidvidsession(this.getIidvidsession()); System.out.println("sesPart2 "+sesPart2.getIidvidsesparticipant()); dc_sesPart.alta(sesPart2); bd.commitTrans(); } public void addPonent(Person persona){ BD bd = BD.getInstance(); bd.beginTrans(); VidSessionParticipantDic dc_sesPart = VidSessionParticipantDic.getInstance(); VidSessionParticipant sesPart1; int maxIdSesPart=dc_sesPart.getMaxId(); sesPart1=dc_sesPart.crearVidSessionParticipant(false); maxIdSesPart++; sesPart1.setIidvidsesparticipant(maxIdSesPart); sesPart1.setBaccepted("T"); sesPart1.setIdvidparticipantype(1); // 1 ponent 2 participant sesPart1.setIidgnrperson(persona.getIidgnrperson()); sesPart1.setIidvidsession(this.getIidvidsession()); Marc Antoni Bajet i Mena -61-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java System.out.println("sesPart1 "+sesPart1.getIidvidsesparticipant()); dc_sesPart.alta(sesPart1); bd.commitTrans(); } } C.ii.14 Classe VidSessionWiz.java package appl.persistent.videoconferencia; import java.util.*; import appl.*; import appl.DAO.*;; public class VidSessionWiz { public static final String oidPrefix = "TBVI"; protected int iidvidsession; protected java.sql.Date dtdatestart; protected java.sql.Date dtdaterelease; protected int iemptyslots; protected int inumusers; protected String txtopic; protected String txdescription; protected String bactive; protected int iidroomtype; public int getIdInt() { return getIidvidsession(); } public String getId() { return oidPrefix + BD.strZero("" + getIidvidsession(), 8); } public void setIdInt(int valor) { setIidvidsession(valor); } public void setIidvidsession(int valor) { Marc Antoni Bajet i Mena -62-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java iidvidsession = valor; } public int getIidvidsession() { return iidvidsession; } public void setDtdatestart(java.sql.Date valor) { dtdatestart = valor; } public java.sql.Date getDtdatestart() { return dtdatestart; } public void setDtdaterelease(java.sql.Date valor) { dtdaterelease = valor; } public java.sql.Date getDtdaterelease() { return dtdaterelease; } public void setIemptyslots(int valor) { iemptyslots = valor; } public int getIemptyslots() { return iemptyslots; } public void setInumusers(int valor) { inumusers = valor; } public int getInumusers() { return inumusers; } public void setTxtopic(String valor) { Marc Antoni Bajet i Mena -63-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java txtopic = valor; } public String getTxtopic() { return txtopic; } public void setTxdescription(String valor) { txdescription = valor; } public String getTxdescription() { return txdescription; } public void setBactive(String valor) { bactive = valor; } public String getBactive() { return bactive; } public void setIidroomtype(int valor) { iidroomtype = valor; } public int getIidroomtype() { return iidroomtype; } } Marc Antoni Bajet i Mena -64-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.ii.15 Classe VidSessionDic.java package appl.persistent.videoconferencia; import java.util.List; public class VidSessionDic extends VidSessionDicWiz { public int getMaxId(){ List<VidSession> sesA; sesA=findAll(); VidSession ses; int maxIdses = 0; if(!sesA.isEmpty()){ for(int i=0;i<sesA.size();i++){ ses=sesA.get(i); if(ses.getIdInt()>maxIdses){ maxIdses=ses.getIidvidsession(); } } } System.out.println(maxIdses); return maxIdses; } public static VidSessionDic getInstance() { return new VidSessionDic(); } } C.ii.16 Classe VidSessionDicWiz.java package appl.persistent.videoconferencia; import java.sql.*; import java.util.*; import appl.*; import appl.DAO.*;; /** Params gene: Driver JDBC = oracle.jdbc.driver.OracleDriver DSN = jdbc:oracle:thin:@172.18.4.8:1521:LCPROD Marc Antoni Bajet i Mena -65-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java TABLE = TBVIDSESSION OID_WIDTH = 12 OID_PREFIX_WIDTH = 4 package = appl.persistent.videoconferencia class = VidSession username = linkcare_pre2 password = XXXX Out path wiz = src_wiz Out path nowiz = src_nowiz ts crea = 14-ago-2009 11:07:44 */ public class VidSessionDicWiz { private PreparedStatement prepAlta = null; private PreparedStatement prepModif = null; private PreparedStatement prepBaja = null; private PreparedStatement prepBajaLogica = null; private PreparedStatement prepFindByPk = null; public final String queryAlta = "INSERT INTO TBVIDSESSION(" + " IIDVIDSESSION, " + " DTDATESTART, " + " DTDATERELEASE, " + " IEMPTYSLOTS, " + " INUMUSERS, " + " TXTOPIC, " + " TXDESCRIPTION, " + " BACTIVE, " + " IIDROOMTYPE) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; public final String queryModif = "UPDATE TBVIDSESSION SET " + " DTDATESTART = ?, " + " DTDATERELEASE = ?, " + " IEMPTYSLOTS = ?, " + " INUMUSERS = ?, " + " TXTOPIC = ?, " + " TXDESCRIPTION = ?, " + " BACTIVE = ?, " + " IIDROOMTYPE = ? " + " WHERE IIDVIDSESSION = ?"; public final String queryBaja = " DELETE FROM TBVIDSESSION WHERE IIDVIDSESSION = ? "; public final String queryBajaLogica = " UPDATE TBVIDSESSION SET DEL = 'Y' WHERE IIDVIDSESSION = ? "; public final String queryFindByPk = " SELECT IIDVIDSESSION, DTDATESTART, DTDATERELEASE, IEMPTYSLOTS, INUMUSERS, Marc Antoni Bajet i Mena -66-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java TXTOPIC, TXDESCRIPTION, BACTIVE, IIDROOMTYPE " + " FROM TBVIDSESSION " + " WHERE IIDVIDSESSION = ? "; public PreparedStatement getPrepAlta() { try { BD bd = BD.getInstance(); if (prepAlta == null) prepAlta = bd.prepareStatement(queryAlta); return prepAlta; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepModif() { try { BD bd = BD.getInstance(); if (prepModif == null) prepModif = bd.prepareStatement(queryModif); return prepModif; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBaja() { try { BD bd = BD.getInstance(); if (prepBaja == null) prepBaja = bd.prepareStatement(queryBaja); return prepBaja; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBajaLogica() Marc Antoni Bajet i Mena -67-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java { try { BD bd = BD.getInstance(); if (prepBajaLogica == null) prepBajaLogica = bd.prepareStatement(queryBajaLogica); return prepBajaLogica; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepFindByPk() { try { BD bd = BD.getInstance(); if (prepFindByPk == null) prepFindByPk = bd.prepareStatement(queryFindByPk); return prepFindByPk; } catch (SQLException e) { throw new RuntimeException(e); } } public VidSession crearVidSession() { return crearVidSession(true); } public VidSession crearVidSession(boolean persisted) { VidSessionDic vObj = VidSessionDic.getInstance(); VidSession obj = new VidSession(); if (persisted) vObj.save(obj); return obj; } public int alta(VidSession dto) { int lastId = 0; try { VidSession obj = (VidSession) dto; prepAlta = getPrepAlta(); prepAlta.clearParameters(); Marc Antoni Bajet i Mena -68-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java prepAlta.setObject(1, obj.getIidvidsession()); prepAlta.setObject(2, obj.getDtdatestart()); prepAlta.setObject(3, obj.getDtdaterelease()); prepAlta.setObject(4, obj.getIemptyslots()); prepAlta.setObject(5, obj.getInumusers()); prepAlta.setObject(6, obj.getTxtopic()); prepAlta.setObject(7, obj.getTxdescription()); prepAlta.setObject(8, obj.getBactive()); prepAlta.setObject(9, obj.getIidroomtype()); prepAlta.executeUpdate(); ResultSet rs = prepAlta.getGeneratedKeys(); // if (rs.next()) // lastId = rs.getInt(1); // dto.setIdInt(lastId); } catch (SQLException e) { throw new RuntimeException(e); } return lastId; } public int baja(VidSession obj) { int idInt = obj.getIdInt(); return baja(idInt); } public int remove(VidSession obj) { return baja(obj); } public int removeById(String id) { VidSessionDic objd = VidSessionDic.getInstance(); VidSession obj = objd.findById(id); if (obj != null) return baja(obj); else return 0; } public int baja(int id) { int res = 0; try { prepBaja = getPrepBaja(); prepBaja.setInt(1, id); res = prepBaja.executeUpdate(); Marc Antoni Bajet i Mena -69-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int bajaLogica(VidSession obj) { int idInt = obj.getIdInt(); return bajaLogica(idInt); } public int bajaLogica(int id) { int res = 0; try { prepBajaLogica = getPrepBajaLogica(); prepBajaLogica.setInt(1, id); res = prepBajaLogica.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int save(VidSession dto) { int res; if (dto.getIdInt() == 0) res = alta(dto); else res = modif(dto); return res; } public int saveAndFlush(VidSession dto) { return save(dto); } public int modif(VidSession dto) { int res = 0; try { BD bd = BD.getInstance(); Marc Antoni Bajet i Mena -70-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public final String queryBajaLogica = " UPDATE TBVIDSESSIONPARTICIPANT SET DEL = 'Y' WHERE IIDVIDSESPARTICIPANT = ? "; public final String queryFindByPk = " SELECT IIDVIDSESPARTICIPANT, IIDGNRPERSON, IIDVIDSESSION, BACCEPTED, IDVIDPARTICIPANTYPE " + " FROM TBVIDSESSIONPARTICIPANT " + " WHERE IIDVIDSESPARTICIPANT = ? "; public PreparedStatement getPrepAlta() { try { BD bd = BD.getInstance(); if (prepAlta == null) prepAlta = bd.prepareStatement(queryAlta); return prepAlta; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepModif() { try { BD bd = BD.getInstance(); if (prepModif == null) prepModif = bd.prepareStatement(queryModif); return prepModif; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBaja() { try { BD bd = BD.getInstance(); if (prepBaja == null) prepBaja = bd.prepareStatement(queryBaja); return prepBaja; } Marc Antoni Bajet i Mena -77-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepBajaLogica() { try { BD bd = BD.getInstance(); if (prepBajaLogica == null) prepBajaLogica = bd.prepareStatement(queryBajaLogica); return prepBajaLogica; } catch (SQLException e) { throw new RuntimeException(e); } } public PreparedStatement getPrepFindByPk() { try { BD bd = BD.getInstance(); if (prepFindByPk == null) prepFindByPk = bd.prepareStatement(queryFindByPk); return prepFindByPk; } catch (SQLException e) { throw new RuntimeException(e); } } public VidSessionParticipant crearVidSessionParticipant() { return crearVidSessionParticipant(true); } public VidSessionParticipant crearVidSessionParticipant(boolean persisted) { VidSessionParticipantDic vObj = VidSessionParticipantDic.getInstance(); VidSessionParticipant obj = new VidSessionParticipant(); if (persisted) vObj.save(obj); return obj; } public int alta(VidSessionParticipant dto) { int lastId = 0; Marc Antoni Bajet i Mena -78-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java try { VidSessionParticipant obj = (VidSessionParticipant) dto; prepAlta = getPrepAlta(); prepAlta.clearParameters(); prepAlta.setObject(1, obj.getIidvidsesparticipant()); prepAlta.setObject(2, obj.getIidgnrperson()); prepAlta.setObject(3, obj.getIidvidsession()); prepAlta.setObject(4, obj.getBaccepted()); prepAlta.setObject(5, obj.getIdvidparticipantype()); prepAlta.executeUpdate(); ResultSet rs = prepAlta.getGeneratedKeys(); /* if (rs.next()) lastId = rs.getInt(1); dto.setIdInt(lastId);*/ } catch (SQLException e) { throw new RuntimeException(e); } return lastId; } public int baja(VidSessionParticipant obj) { int idInt = obj.getIdInt(); return baja(idInt); } public int remove(VidSessionParticipant obj) { return baja(obj); } public int removeById(String id) { VidSessionParticipantDic objd = VidSessionParticipantDic.getInstance(); VidSessionParticipant obj = objd.findById(id); if (obj != null) return baja(obj); else return 0; } public int baja(int id) { int res = 0; try { Marc Antoni Bajet i Mena -79-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java prepBaja = getPrepBaja(); prepBaja.setInt(1, id); res = prepBaja.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int bajaLogica(VidSessionParticipant obj) { int idInt = obj.getIdInt(); return bajaLogica(idInt); } public int bajaLogica(int id) { int res = 0; try { prepBajaLogica = getPrepBajaLogica(); prepBajaLogica.setInt(1, id); res = prepBajaLogica.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public int save(VidSessionParticipant dto) { int res; if (dto.getIdInt() == 0) res = alta(dto); else res = modif(dto); return res; } public int saveAndFlush(VidSessionParticipant dto) { return save(dto); } public int modif(VidSessionParticipant dto) { int res = 0; Marc Antoni Bajet i Mena -80-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java try { BD bd = BD.getInstance(); VidSessionParticipant obj = (VidSessionParticipant) dto; prepModif = getPrepModif(); prepModif.clearParameters(); prepModif.setObject(1, obj.getIidgnrperson()); prepModif.setObject(2, obj.getIidvidsession()); prepModif.setObject(3, obj.getBaccepted()); prepModif.setObject(4, obj.getIdvidparticipantype()); prepModif.setInt(5, obj.getIidvidsesparticipant()); res = prepModif.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } return res; } public VidSessionParticipant findByPrimaryKey(int id) { VidSessionParticipant obj = null; try { prepFindByPk = getPrepFindByPk(); prepFindByPk.setInt(1, id); ResultSet rs = prepFindByPk.executeQuery(); BD bd = BD.getInstance(); obj = (VidSessionParticipant) bd.getDTO(VidSessionParticipant.class, rs); rs.close(); } catch (SQLException e) { throw new RuntimeException(e); } return obj; } public VidSessionParticipant findById(String id) { try { int pk = Integer.parseInt(id.substring(4, 12)); return findByPrimaryKey(pk); } catch(Exception e){} { Marc Antoni Bajet i Mena -81-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java return null; } } public void resetPreps() { prepAlta = null; prepModif = null; prepBaja = null; prepBajaLogica = null; prepFindByPk = null; } public String getTabla() { return "TBVIDSESSIONPARTICIPANT"; } public String getCampoId() { return "IIDVIDSESPARTICIPANT"; } public String getOidPrefix() { return "TBVI"; } public List<VidSessionParticipant> findAll(){ BD bd = BD.getInstance(); List<VidSessionParticipant> la = bd.getDTOs(VidSessionParticipant.class, "SELECT * FROM "+this.getTabla()); return la; } } Marc Antoni Bajet i Mena -82-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java C.iii Package appl/struts/videoconferencia En aquest paquet hi haurà totes aquelles classes que hagin de recollir les crides de l'entorn gràfic. En el cas d'aquest projecte només hi haurà la classe ControladorGeneral.java. C.iii.1 Classe ControladorGeneral.java package appl.struts.videoconferencia; import java.util.*; import com.opensymphony.xwork2.*; import appl.core.videoconferencia.*; import appl.persistent.videoconferencia.*; public class ControladorGeneral { // in private int idRoom; private String opRoom; private int idUser; private int idUser2; private String loginUsername; private String loginPassword; // out private List<Room> rooms; private int totalRooms; private List<Person> users; private boolean success=false; private int totalUsers; private String session; // geters i seters public int getIdRoom() { return idRoom; } public void setIdRoom(int idRoom) { this.idRoom = idRoom; } public String getOpRoom() { return opRoom; } public void setOpRoom(String opRoom) { this.opRoom = opRoom; } public int getIdUser() { User u; Map ses = ActionContext.getContext().getSession(); u=(User)ses.get("logged-in"); idUser=u.getIidgnrperson(); Marc Antoni Bajet i Mena -83-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java return idUser; } public int getIdUser2() { return idUser2; } public void setIdUser2(int idUser2) { this.idUser2 = idUser2; } public List<Room> getRooms() { return rooms; } public void setRooms(List<Room> rooms) { this.rooms = rooms; } public List<Person> getUsers() { return users; } public void setUsers(List<Person> users) { this.users = users; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public int getTotalRooms() { if(rooms == null) totalRooms=0; else totalRooms=rooms.size(); return totalRooms; } public void setTotalRooms(int totalRooms) { this.totalRooms = totalRooms; } public int getTotalUsers() { if(users==null) totalUsers=0; else totalUsers=2*users.size(); return totalUsers; } public void setTotalUsers(int totalUsers) { this.totalUsers = totalUsers; } public String getSession() { UserDic ud = UserDic.getInstance(); session = ud.findByIdPerson(idUser).getTxlogin(); return session; } public String getLoginUsername() { return loginUsername; Marc Antoni Bajet i Mena -84-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } public void setLoginUsername(String loginUsername) { this.loginUsername = loginUsername; } public String getLoginPassword() { return loginPassword; } public void setLoginPassword(String loginPassword) { this.loginPassword = loginPassword; } // metodes dels actions public String listUsers(){ PersonDic cd = PersonDic.getInstance(); List<Person> lp = cd.listUsersForId(getIdUser()); this.setUsers(lp); this.setSuccess(true); return Action.SUCCESS; } public String listRooms() { RoomDic roomDC = RoomDic.getInstance(); ArrayList<Room> lr = roomDC.findRoomsByIdPerson(getIdUser()); if(lr.isEmpty()){ System.out.println("llista de rooms buida"); Room r = new Room(); r.setNomPonent("Llista de Sales buida"); r.setNomParticipant0("Per crear una Sala sel·lecciona un usuari i clica sobre el botó [videoconferencia]"); lr.add(r); } this.setRooms(lr); this.setSuccess(true); return Action.SUCCESS; } public String createRoom() { System.out.println("CREA ROOM comença amb "+getIdUser()+" "+idUser2); RoomDic roomDC = RoomDic.getInstance(); roomDC.createRoom2u(getIdUser(), idUser2); System.out.println("CREA ROOM "+getIdUser()+" "+idUser2); this.setSuccess(true); Marc Antoni Bajet i Mena -85-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java return Action.SUCCESS; } public String formRooms() { boolean exitValue=false; System.out.println("Sala "+idRoom+" "+opRoom+" "+getIdUser()); RoomDic roomDC = RoomDic.getInstance(); Room r = roomDC.getRoom(idRoom); System.out.println(r.getPonent().getIidgnrperson()); if(opRoom.matches("del")){ if(r.getPonent().getIdInt()==getIdUser()){ exitValue=roomDC.deleteRoom(idRoom); } }else if(opRoom.matches("in")){ System.out.println("l'usuari de nick "+session+" vol entrar a la sala "+ idRoom); if(r.getPonent().getIdInt()==getIdUser()){ exitValue=r.enterRoom(getIdUser()); } else{ for(int i=0;i<r.getParticipants().size();i++){ if(r.getParticipants().get(i).getIdInt()==getIdUser()){ exitValue=r.enterRoom(getIdUser()); } } } } if (exitValue){ this.setSuccess(true); return Action.SUCCESS; } else{ this.success=false; return Action.SUCCESS; } } public String enterRoom(){ System.out.println("usuari " + getIdUser() +" ha entrat a la sala "+idRoom); RoomDic r_dic = RoomDic.getInstance(); Room r = r_dic.getRoom(idRoom); this.setSuccess(r.enterRoom(getIdUser())); return Action.SUCCESS; } public String loginUser() { System.out.println("loginUser: Usuari "+loginUsername+" Password "+loginPassword); UserDic ud = UserDic.getInstance(); Marc Antoni Bajet i Mena -86-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java catch (Exception ex) { } try { stmt.close(); } catch (Exception ex) { } } return vDtos; } public int ejecutarSQL(String query) { int res = 0; Statement stmt = null; try { stmt = getConnection().createStatement(); stmt.executeUpdate(query); } catch (Exception e) { throw new RuntimeException(e + " |" + query + "|", e); } finally { try { stmt.close(); } catch (Exception ex) { } } return res; } public int ejecutarInsertSQL(String query) { int res = 0; ResultSet rs = null; Statement stmt = null; try { stmt = getConnection().createStatement(); stmt.executeUpdate(query, Statement.RETURN_GENERATED_KEYS); rs = stmt.getGeneratedKeys(); if (rs.next()) res = rs.getInt(1); } Marc Antoni Bajet i Mena -93-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java catch (Exception ex) { ex.printStackTrace(); } finally { try { stmt.close(); } catch (Exception ex) { } } return res; } public String getLastQuery() { return lastQuery; } public int getLastNtot() { return getNumFilasTot(lastQuery); } public int getNumFilasTot(String query) { int numFilasTot = 0; Statement stmt = null; ResultSet rs = null; try { query = "SELECT COUNT(*) FROM (" + tailOrderBy(query) + ") AS T"; stmt = createStatement(); rs = stmt.executeQuery(query); rs.next(); numFilasTot = rs.getInt(1); } catch (Exception e) { throw new RuntimeException("Error: " + e.getMessage() + " |" + query + "|", e); } finally { try { rs.close(); } catch (Exception ex) { } try Marc Antoni Bajet i Mena -94-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java { stmt.close(); } catch (Exception ex) { } } return numFilasTot; } public static String tailOrderBy(String query) { int pos = query.toUpperCase().indexOf(" ORDER BY "); int posParentesi = query.indexOf(")", pos + 1); String result = query; if (pos > 0) { if (posParentesi > 0) result = query.substring(0, pos) + " " + query.substring(posParentesi); else result = query.substring(0, pos); } return result; } public static String getWhere(String query) { String where = ""; int pos = query.toUpperCase().indexOf("WHERE"); if (pos < 0) where = ""; else where = query.substring(pos + 5); return where; } // //////////////////////////////////////////////////////////////////////////// // INICI getDTOs i getDTO // //////////////////////////////////////////////////////////////////////////// public List getDTOs(Class dtoClass, String query) { return getDTOs(dtoClass, query, 0, 9999); } public List getDTOs(Class dtoClass, String query, int from, int offset) { List vDtos = new ArrayList(); Statement stmt = null; ResultSet rs = null; try { lastQuery = query; stmt = createStatement(); Marc Antoni Bajet i Mena -95-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java rs = stmt.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); int numCols = rsmd.getColumnCount(); List cols = new ArrayList(); int i = 0; while (i < from && rs.next()) // rs.absolute(from); { i++; } int j = 0; while (i < (from + offset) && rs.next()) { i++; Object dto = dtoClass.newInstance(); for (int k = 1; k <= numCols; k++) { try { String attr = rsmd.getColumnName(k).toLowerCase(); Object valor = rs.getObject(k); String attrHung = Util.primMinusHung(attr); Util.setAtributo(dto, attrHung, valor); } catch (Exception e) { e.getMessage(); } } vDtos.add(dto); j++; } } catch (Exception e) { throw new RuntimeException(e + " |" + query + "|", e); } finally { try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex) { } Marc Antoni Bajet i Mena -96-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } return vDtos; } public Object getDTO(Class dtoClass, ResultSet rs) { Object result = null; // String query = BD.noDel(query0); try { ResultSetMetaData rsmd = rs.getMetaData(); int numCols = rsmd.getColumnCount(); Object dto = null; if (rs.next()) { dto = dtoClass.newInstance(); for (int k = 1; k <= numCols; k++) { try { String attr = rsmd.getColumnName(k).toLowerCase(); Object valor = rs.getObject(k); String attrHung = Util.primMinusHung(attr); Util.setAtributo(dto, attrHung, valor); } catch (Exception e) { e.getMessage(); } } } result = dto; } catch (Exception e2) { throw new RuntimeException(e2); } return result; } public Object getDTO(Class dtoClass, String query) { Object result = null; Statement stmt = null; ResultSet rs = null; // String query = BD.noDel(query0); try { stmt = createStatement(); Marc Antoni Bajet i Mena -97-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java rs = stmt.executeQuery(query); result = getDTO(dtoClass, rs); rs.close(); stmt.close(); } catch (SQLException e1) { throw new RuntimeException(e1); } return result; } // //////////////////////////////////////////////////////////////////////////// // FI getDTO // //////////////////////////////////////////////////////////////////////////// public int getCount(String query) { String queryCount = " SELECT COUNT(*) FROM (" + query + ") AS T"; int n = 0; try { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery(queryCount); if (rs.next()) { n = rs.getInt(1); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return n; } public boolean pingRecord(String where, String table) { boolean res = false; try { Statement stmt = createStatement(); String query = "SELECT 'X' FROM " + table + " WHERE " + where; ResultSet rs = stmt.executeQuery(query); if (rs.next()) { res = true; } } catch (Exception e) Marc Antoni Bajet i Mena -98-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java { } return res; } public String getCampo(String query) { String res = ""; try { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery(query); if (rs.next()) { res = rs.getString(1); } } catch (Exception e) { } return res; } public java.util.Date getCampoDate(String query) { java.util.Date res = null; try { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery(query); if (rs.next()) { res = rs.getDate(1); } } catch (Exception e) { } return res; } public int getCampoInt(String query) { int res = 0; try { Statement stmt = createStatement(); ResultSet rs = stmt.executeQuery(query); if (rs.next()) { res = rs.getInt(1); } Marc Antoni Bajet i Mena -99-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java } catch (Exception e) { } return res; } public double getCampoDouble(String query) { double res = 0; Statement stmt = null; ResultSet rs = null; try { stmt = createStatement(); rs = stmt.executeQuery(query); if (rs.next()) { res = rs.getDouble(1); } } catch (Exception e) { } finally { try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex) { } } return res; } public static String nvl(Object s) { return nvl(s, ""); } public static String nvl(Object s, String defaultValue) { return s == null ? defaultValue : s.toString().trim(); } Marc Antoni Bajet i Mena -100-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java public static String fixComillas(String s) { String s2 = replace(s, "'", " "); Ž s2 = replace(s2, "\"", " "); ŽŽ return s2; } // http://webxadmin.free.fr/article/string-replace-40.php public static String replace(String source, String pattern, String replace) { if (source != null) { final int len = pattern.length(); StringBuffer sb = new StringBuffer(); int found = -1; int start = 0; while ((found = source.indexOf(pattern, start)) != -1) { sb.append(source.substring(start, found)); sb.append(replace); start = found + len; } sb.append(source.substring(start)); return sb.toString(); } else return ""; } public static String strZero(String s, int i) { if (s == null) s = ""; String retorn = ""; int longString = s.length(); int dif = i - longString; for (i = 0; i < dif; i++) { retorn += "0"; } retorn += s; return retorn; } public String getTaula(String prefix) Marc Antoni Bajet i Mena -101-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex C: Codi Java { String res = ""; res = getCampo("SELECT TABLA FROM DAOWIZFULL WHERE PREFIX = '" + prefix.substring(0, OID_PREFIX_WIDTH) + "'"); return res; } public String getTaulaFromDTO(String dtoClassName) { String res = ""; res = getCampo("SELECT TABLA FROM DAOWIZFULL WHERE PACKAGE + '.' + CLASE = '" + dtoClassName + "'"); return res; } public String getPrefix(String taula) { String res = ""; res = getCampo("SELECT PREFIX FROM DAOWIZFULL WHERE TABLA = '" + taula + "'"); return res; } public void renterToRsADO(String query, PrintWriter out) { renterToRsADO(query, out, 0, 9999); } public void renterToRsADO(String query, PrintWriter out, int from, int offset) { Statement stmt = null; ResultSet rs = null; try { lastQuery = query; stmt = createStatement(); rs = stmt.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); int numCols = rsmd.getColumnCount(); Object valor = null; List cols = new ArrayList(); int i = 0; while (i < from && rs.next()) // rs.absolute(from); { i++; } out.println( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'\n" + " xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'\n" + " xmlns:rs='urn:schemas-microsoft-com:rowset'\n" + " xmlns:z='#RowsetSchema'>\n" Marc Antoni Bajet i Mena -102-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn webAnnex D: Arxius XML de configuració <!-- corresponding to one net connection are always sent to the --> <!-- same server. The cookie does add to the http header size so --> <!-- will result in a higher bandwidth overhead. --> <SetCookie>false</SetCookie> <!-- This specifies whether we are redirecting unknown requests --> <!-- to an external server. An unknown request may come in only --> <!-- as the first request on a newly accepted connection, at any --> <!-- other time it is considered an error, and the connection is --> <!-- closed. Unknown requests are redirected by byte proxying to --> <!-- the specified redirect host. For redirection to work http --> <!-- tunneling must be enabled. --> <!-- Request redirection to a specific host can be further --> <!-- controlled based upon port on which the request arrived. --> <!-- The maxbuf attribute determines how big the io buffers are. --> <!-- Flow control kicks in when the buffer in either direction --> <!-- fills up, automatically handling the case when producers --> <!-- and consumers differ widely in bandwidth. --> <Redirect enable="false" maxbuf="16384"> <Host port="80">:8080</Host> <Host port="443">:8443</Host> </Redirect> <!-- This specifies whether HTTP 1.0 non-keepalive connections --> <!-- are to be closed once the response is written, the default --> <!-- is to close them, which is also the behavior as per spec. --> <NeedClose>true</NeedClose> <!-- The tunneling protocol ensures that a server will be able --> <!-- to write every 4 seconds. Sometimes when the connections --> <!-- close under abnormal conditions, the notification does not --> <!-- reach the server, the server will continue to queue writes --> <!-- forever. Such connections will be closed after waiting for --> <!-- at most the specified time below. The default is 40 secs. --> <MaxWriteDelay>40</MaxWriteDelay> <!-- The above configuration can be specifically tailored on an --> <!-- edge by edge basis in the following sections. --> <Edge name="Edge1"> <Enable>true</Enable> <IdlePostInterval>512</IdlePostInterval> <IdleAckInterval>512</IdleAckInterval> <MimeType>application/x-fcs</MimeType> <WriteBufferSize>16</WriteBufferSize> <SetCookie>false</SetCookie> <RedirectHost secure="false">:8080</RedirectHost> <NeedClose>true</NeedClose> <MaxWriteDelay>40</MaxWriteDelay> </Edge> </HTTPTunnel> <!-- The following section determines how to configure secure connections via --> <!-- Secure Sockets Layer protocol known as SSL (and now as TLS). --> <SSL> <!-- Controls SSL configurations for this adaptor (IP-based virtual host) --> Marc Antoni Bajet i Mena -109-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn webAnnex D: Arxius XML de configuració <SSLServerCtx> <!-- Specifies location of certificate file to send to client. If an --> <!-- absolute path is not specified, the certificate is assumed to be --> <!-- relative to the adaptor directory. --> <SSLCertificateFile></SSLCertificateFile> <!-- Specifies location of private key file for the certificate. If --> <!-- an absolute path is not specified, the key file is assumed to be --> <!-- relative to the adaptor directory. If the key file is encrypted, --> <!-- the pass phrase must be specified in the SSLPassPhrase tag. --> <!-- The type attribute specifies the type of encoding used for the --> <!-- certificate key file. This can be either "PEM" or "ASN1". By --> <!-- default, this is "PEM". --> <SSLCertificateKeyFile type="PEM"></SSLCertificateKeyFile> <!-- Specifies the passphrase to use for decrypting the private key --> <!-- file. If the private key file is not encrypted, leave this tag --> <!-- empty. --> <SSLPassPhrase></SSLPassPhrase> <!-- Specifies the ciphers to use. This ia a list of colon delimited --> <!-- components. A component can be a key exchange algorithm, --> <!-- authentication method, encryption method, digest type, or one of --> <!-- a selected number of aliases for common groupings. For a list of --> <!-- components, please refer to the FMS documentation. Do not change --> <!-- the default settings unless you know what you are doing. --> <SSLCipherSuite>ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH</SSLCipherSuite> <!-- Specifies how long (in minutes) a session remains valid. Any --> <!-- attempt to set this less than 1 minute will result in timeout --> <!-- being set to 1 minute. --> <SSLSessionTimeout>5</SSLSessionTimeout> </SSLServerCtx> </SSL> <!-- Whether the server should respond to an HTTP identification request --> <!-- from a client. If enabled all the tags within the HTTPIdent section --> <!-- will be returned as a response. The entire response will be --> <!-- enclosed in <fcs></fcs> tags, which are automatically added and do --> <!-- not need to be specified below. If it is enabled but no content is --> <!-- specified then an empty <fcs></fcs> response is returned. --> <!-- --> <!-- For an ident response to be returned, HTTPIdent must be enabled and --> <!-- the client must specifically do a POST or GET for "/fcs/ident" --> <!-- resource. --> <HTTPIdent enable="false"> <!-- Insert xml identification section here. --> </HTTPIdent> <!-- Whether an alternate vhost may be specified as a part of the rtmp --> <!-- url as query parameter - rtmp://host1/app/?_fcs_vhost=host2. This --> <!-- does not apply to admin connections which are always on by default. --> <!-- The default value is false. --> <EnableAltVhost></EnableAltVhost> </Adaptor> Marc Antoni Bajet i Mena -110-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny Annex E: Documents de disseny Aquí s'hi poden trobar els documents generats durant la fase de disseny. E.i Casos d'ús Marc Antoni Bajet i Mena -111-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.ii Models S'han realitzat tres documents de models: •El conceptual ha estat l'inicial i serveix per entendre quins actors calien per realitzar els casos d'ús. •El de dades ha servit per crear les bases de dades que faran possible la persistència dels objectes. •El de disseny és el que s'ha utilitzat durant la fase de desenvolupament per realitzar les classes. E.ii.1 Model Conceptual Marc Antoni Bajet i Mena -112-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.ii.2 Model de Dades Marc Antoni Bajet i Mena -113-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.ii.3 Model de Disseny Marc Antoni Bajet i Mena -114-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.iii Seqüències S'han realitzat set documents amb set seqüències en total. Aquestes serveixen per satisfer les accions a realitzar descrites en els casos d'ús. E.iii.1 Seqüència getUsuaris Marc Antoni Bajet i Mena -115-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.iii.2 Seqüència getRooms Marc Antoni Bajet i Mena -116-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.iii.3 Seqüència creaRoom Marc Antoni Bajet i Mena -117-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex E: Documents de disseny E.iii.4 Seqüència eliminaRoom Marc Antoni Bajet i Mena -118-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis F.i.2 Builder Pattern: Builder Author: Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Intent: "Separate the construction of a complex object from its representation so that the same construction process can create different representations." (Gamma, E., R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Reading, MA: Addison-Wesley, 1995). Motivation: A reader for the RTF (Rich Text Format) document exchange format should be able to convert RTF to many text formats. The reader might convert RTF documents into plain ASCII text or into a text widget that can be edited interactively. The problem, however is that the number of possible conversions is open-ended. So it should be easy to add a new conversion without modifying the reader. A solution is to configure the RTFReader class (Director in the thumbnail) with a TextConverter object (Builder in the thumbnail) that converts RTF to another textual representation. As the RTFReader parses the RTF document, it uses the TextConverter to perform the conversion. Whenever the RTFReader recognizes an RTF token (either plain text or an RTF control word), it issues a request to the TextConverter to convert the token. TextConverter objects are responsible both for performing the data conversion and for representing the token in a particular format. Subclasses of TextConverter specialize in different conversions and formats. For example, an ASCIIConverter (ConcreteBuilder in the thumbnail) ignores requests to convert anything except plain text. Each kind of converter class takes the mechanism for creating and assembling a complex object and puts it behind an abstract interface. The converter is separate from the reader, which is responsible for parsing an RTF document. The Builder pattern captures all these relationships. Each converter class is called a "builder" in the pattern, and the reader is called the "director." Applied to this example, the Builder pattern separates the algorithm for interpreting a textual format (that is, the parser for RTF documents) from how a converted format gets created and represented. This lets us reuse the RTFReaders parsing algorithm to create different text representations from RTF documents--just configure the RTFReader with different subclasses of TextConverter. Known Uses: Marc Antoni Bajet i Mena -125-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis This pattern has been used on the following systems: RTF converter application from ET++ uses a builder to process text stored in the RTF format. (Weinand, A., E. Gamma, and R. Marty. ET++--An object-oriented application framework in C++. In Object-Oriented Programming Systems, Languages, and Applications Conference Proceedings, pages 46-57, San Diego, CA, September 1988. ACM Press.) Builder is a common pattern in Smalltalk-80. (ParcPlace Systems, Mountain View, CA. ObjectWorks\Smalltalk Release 4 Users Guide, 1990.) The Service Configurator framework from the Adaptive Communications Environment uses a builder to construct network service components that are linked into a server at runtime. (Schmidt, D.C. and T. Suda. The Service Configurator Framework: An extensible architecture for dynamically configuring concurrent, multi-service network daemons. In Proceedings of the Second International Workshop on Configurable Distributed Systems, pages 190-201, Pittsburgh, PA, March 1994. IEEE Computer Society.) See Also: Abstract Factory and Composite patterns. Thumbnail: Keywords: Abstract Factory pattern, Builder pattern, Composite pattern, creational patterns, Gamma patterns, object creation, system parameterization, objects (complex), product build (step-by- Marc Antoni Bajet i Mena -126-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis step). Business Domains: Any system requiring abstraction for object creation. Prblem Forces: Need flexibility in creating various complex objectsneed to create complex, aggregate objects. Benefits: Allows variance in a products internal representationgives finer control over the construction processisolates code for construction and representation. Implementation Files: Test driver Test.javaProduct class Product.javaPart class Part.javaDirector class Director.javaConcreteBuilder class ConcreteBuilder.javaBuilder class Builder.javaTest driver. testbuilder.cppSimple implementation of the pattern. builder.h. Marc Antoni Bajet i Mena -127-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis F.ii Patrons estructurals F.ii.1 Composite Pattern: Composite Author: Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Intent: "Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly." (Gamma, E., R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Reading, MA: Addison-Wesley, 1995). Motivation: Graphics applications like drawing editors and schematic capture systems let users build complex diagrams out of simple components. The user can group components to form larger components, which in turn can be grouped to form still larger components. The key to the Composite pattern is an abstract class that represents both primitives and their containers. For the graphics system, this class is Graphic (Component in the thumbnail). Graphic declares operations like Draw (Operation in thumbnail) that are specific to graphical objects. It also declares operations that all composite objects share, such as operations for accessing and managing its children. Subclasses Line, Rectangle, and Text (Leaf in thumbnail) define primitive graphical objects. These classes implement Draw to draw lines, rectangles, and text, respectively. Since primitive graphics have no child graphics, none of these subclasses implements child-related operations. The Picture class (Composite in thumbnail) defines an aggregate of Graphic objects. Picture implements Draw to call Draw on its children, and it implements child-related operations accordingly. Because the Picture interface conforms to the graphic interface, Picture objects can compose other Pictures recursively. Known Uses: This pattern has been used on the following systems: Almost all object-oriented systems use this pattern. The original View class of Smalltalk Model/View/Controller used it as well as almost all user interface toolkits or frameworks, for example, ET++ (used in Vobjects) and InterViews (used in Styles, Graphics, and Glyphs). RTL Smalltalk compiler framework uses this pattern extensively. RTLExpression, a Component class for parse trees, has subclasses (i.e. Marc Antoni Bajet i Mena -128-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis BinaryExpression) that contain child RTLExpression objects. These classes define a composite structure for parse trees. RegisterTransfer is the Component class for a programs intermediate Single Static Assignment form. Also, RegisterTransferSet is a Composite class for representing assignments that change several registers at once. (Johnson, R.E., C. McConnell, J.M. Lake. The RTL system: A framework for code optimization. In Rogert Giegerich and Susan L. Graham, editors, Code Generation-Concepts, Tools, Techniques. Proceedings of the International Workshop on Code Generation, pp. 255-274, Dagstuhl, Germany, 1992. Springer- Verlag.) This pattern also occurs in the financial domain, where a portfolio aggregates individual assets. Complex aggregations of assets can be supported by implementing a portfolio as a Composite that conforms to the interface of an individual asset. (Birrer, A. and T. Eggenschwiler. Frameworks in the financial engineering domain: An experience report. In European Conference on Object-Oriented Programming, pp. 21-35, Kaiserslautern, Germany, July 1993. Springer-Verlag.) See Also: Chain of Responsibility, Decorator, Flyweight, Iterator, and Visitor patterns. Thumbnail: Keywords: Composite pattern, Decorator pattern, Flyweight pattern, Chain of Responsibility pattern, Iterator pattern, Visitor pattern, structural patterns, Gamma patterns, uniformly treated objects, recursive composition, tree structure, part-whole hierarchies, explicit parent references. Business Domains: Marc Antoni Bajet i Mena -129-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis Any system with large number of whole-part object relationships. Prblem Forces: Need to protect clients from knowing if an object is a whole or a part. Benefits: Simplifies adding new parts in whole-part relationshipssimplifies the client - permitting the client to treat whole or part objects generically. Liabilities: May make the design too general by minimizing type safety. Implementation Files: Test driver Test.javaSimple implementation of the pattern - Leaf class. Leaf.javaSimple implementation of the pattern - Composite class. Composite.javaSimple implementation of the pattern - Component class. Component.javaTest driver testcomposite.cppSimple implementation of the pattern. composite.h. Marc Antoni Bajet i Mena -130-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis F.ii.2 Facade Pattern: Facade Author: Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Intent: "Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to user." (Gamma, E., R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Reading, MA: Addison-Wesley, 1995) Motivation: Structuring a system into subsystems helps reduce complexity. A common design goal is to minimize the communication and dependencies between subsystems. One way to achieve this goal is to introduce a façade object that provides a single, simplified interface to the more general facilities of a subsystem. Consider for example a programming environment that gives applications access to its compiler subsystem. This subsystem contains classes such as Scanner, Parser, ProgramNode, BytecodeStream, and ProgramNodeBuilder (Subsystem Class in the thumbnail) that implement the compiler. Some specialized applications might need to access these classes directly. But most clients of a compiler generally dont care about details like parsing and code generation; they merely want to compile some code. For them, the powerful but low-level interfaces in the compiler subsystem only complicate their task. To provide a higher-level interface that can shield clients from these classes, the compiler subsystem also includes a Compiler class (Façade in the thumbnail). This class defines a unified interface to the compilers functionality. The Compiler class acts as a façade: It offers clients a single, simple interface to the compiler subsystem. It glues together the classes that implement compiler functionality without hiding them completely. The compiler façade makes life easier for most programmers without hiding the lower-level functionality from the few that need it. Known Uses: This pattern has been used on the following systems: The ET++ application framework allows an application to have built-in browsing tools for inspecting its objects at run-time. The browsing tools are implemented in a separate subsystem that includes a Façade class called "ProgrammingEnvironment." This façade defines operations such as InspectObject and Marc Antoni Bajet i Mena -131-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis InspectClass for accessing the browsers. If the application does not use built-in browsing support, ProgrammingEnvironment will implement the requests as null operations. (Weinand, A., E. Gamma, and R. Marty. ET++--An object-oriented application framework in C++. In Object-Oriented Programming Systems, Languages, and Applications Conference Proceedings, pp. 46-57, San Diego, CA, September 1988, ACM Press.) Facades are used in the Choices operating system to compose many frameworks into one. Choices has as key abstractions: processes, storage, and address spaces. Each abstraction has a corresponding subsystem, implemented as a framework, that supports porting Choices to a variety of different hardware platforms. (Campbell, R.H., N. Islam, D. Raila, and P. Madeany. Designing and implementing Choices: An object-oriented system in C++. Communications of the ACM, 36(9):117-126, September 1993.) See Also: Abstract Factory, Mediator, and Singleton patterns. Thumbnail: Keywords: Abstract Factory pattern, Singleton pattern, Facade pattern, Mediator pattern, structural patterns, Gamma patterns, forward requests, interface (high-level), subsystem (entire), subsystem (complex) Business Domains: Any system integrated with multiple, disparate systemsany system providing layers to abstract complexity. Prblem Forces: Need to layer subsystemsneed to provide abstraction between subsystem and client. Marc Antoni Bajet i Mena -132-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis Benefits: May reduce compilation dependenciespermits clients of various skills to access the appropriate layer of the systempromotes layering of systemsprovides weak coupling between clients and subsystems. Implementation Files: Test driver Test.javaSimple implementation of the pattern - Subsystem3 class. Subsystem3.javaSimple implementation of the pattern - Subsystem2 class. Subsystem2.javaSimple implementation of the pattern - Subsystem1 class. Subsystem1.javaSimple implementation of the pattern - Facade class. Facade.javaTest driver testfacade.cppSimple implementation of the pattern. facade.h. Marc Antoni Bajet i Mena -133-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex F: Patrons i principis F.iii Patrons o principis GRASP F.iii.1 Information Expert The Information Expert pattern is a solution to the problem of determining which object should assume a particular responsibility. During design, we make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task. Information Expert says: Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility. You need to consider how using Information Expert affects coupling and cohesion to determine if the pattern is a good choice. Exemple: Consider a simple part of a POS system as shown in the following class diagram: Marc Antoni Bajet i Mena -134-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació The jitter calculation MUST conform to the formula specified here in order to allow profile-independent monitors to make valid interpretations of reports coming from different implementations. This algorithm is the optimal first-order estimator and the gain parameter 1/16 gives a good noise reduction ratio while maintaining a reasonable rate of convergence [22]. A sample implementation is shown in Appendix A.8. See Section 6.4.4 for a discussion of the effects of varying packet duration and delay before transmission. last SR timestamp (LSR): 32 bits The middle 32 bits out of 64 in the NTP timestamp (as explained in Section 4) received as part of the most recent RTCP sender report (SR) packet from source SSRC_n. If no SR has been received yet, the field is set to zero. delay since last SR (DLSR): 32 bits The delay, expressed in units of 1/65536 seconds, between receiving the last SR packet from source SSRC_n and sending this reception report block. If no SR packet has been received yet from SSRC_n, the DLSR field is set to zero. Let SSRC_r denote the receiver issuing this receiver report. Source SSRC_n can compute the round-trip propagation delay to SSRC_r by recording the time A when this reception report block is received. It calculates the total round-trip time A-LSR using the last SR timestamp (LSR) field, and then subtracting this field to leave the round-trip propagation delay as (A - LSR - DLSR). This G.ii Captures de Wireshark En aquest capítol es poden trobar els documents resultants de les captures de paquets realitzats amb el programa Wireshark durant l'ús de l'eina de videoconferència Miralia. Es poden trobar tant les captures realitzades des del servidor com les realitzades des del client per tenir una imatge clara del que succeeix entre l'emissor i el receptor. Marc Antoni Bajet i Mena -141-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.1 Captures del servidor En aquest apartat hi ha les captures d'inici i final obtingudes en el servidor. G.ii.1.a Captura de l'inici de la seqüència Marc Antoni Bajet i Mena -142-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.1.b Captura del final de la seqüència Marc Antoni Bajet i Mena -143-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.1.c Captura del resum Marc Antoni Bajet i Mena -144-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.2 Captures del client En aquest apartat hi ha les captures d'inici i final obtingudes en el servidor. G.ii.2.a Captura de l'inici de la seqüència Marc Antoni Bajet i Mena -145-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.2.b Captura del final de la seqüència Marc Antoni Bajet i Mena -146-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.ii.2.c Captura del resum Marc Antoni Bajet i Mena -147-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.iii Raonament del càlcul del temps mig de retard Plantejament: El problema plantejat és que es disposa de dos captures de paquets realitzats en una màquina client i una màquina servidor respectivament. Aquests disposen d'un camp de marca de temps però tot i utilitzar la mateixa escala de temps per totes dues captures hi ha un error en el zero entre les marques de temps de la primera captura i la segona degut a la desincronització entre els rellotges de les dues màquines. Es desitja calcular el temps de retard mig. Resolució: Es pot dir que si s'agafa com a zero absolut el zero de l'escala de temps del client, als temps del servidor se'ls haurà d'afegir un error. Si R és el temps de recepció dels paquets, S el temps d'enviament dels paquets i td és una variable aleatòria que representa el temps de retard aleshores: Pels paquets enviats des del client i rebuts en el servidor: tdclient servidor=Rservidorerror−Sclient Pels paquets enviats des del servidor i rebuts en el client: tdservidor client=Rclient−Sservidorerror L'error és un paràmetre determinista mentre que la resta de paràmetres dependran del procés i del temps. E{ tdclient servidor }=E{Rservidor }error−E{Sclient } E{ tdservidor client }=E{Rclient }−E{Sservidor}−error Per una banda: E{ tdclient servidor }E{ tdservidor client }=E{Rservidor }error−E{Sclient }E{Rclient}−E{Sservidor }−error E{ tdclient servidor }E{ tdservidor client }=E{Rservidor }−E{Sclient}E{Rclient }−E{Sservidor} I per l'altre banda: E{ td}=E{Rservidor }−E{Sclient}E{Rclient }−E{Sservidor} Pel que es pot dir que el temps de retard mig serà la suma dels temps mig calculats: E{ td}=E{ tdclient servidor }E{ tdservidor client } Marc Antoni Bajet i Mena -148-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.iv Qüestionari d'avaluació Qüestionari d'avaluació de l'eina de videoconferència integrada a la Plataforma Linkcare Nom i cognom: Càrrec o lloc ocupat: Marca la franja d'edat a la que corresponguis: 21 – 35 36 – 50 50 + Localització del lloc de treball (des d'on s'ha realitzat la prova): Amb quina freqüència utilitzes eines de videoconferència? Mai (menys d'un cop l'any) Ocasionalment (menys d'un cop al mes) Habitualment (menys d'un cop a la setmana) Amb freqüència (més d'un cop a la setmana) Puntua de l'1(dolent) al 10 (bò) els diferents factors referents a l'aplicació provada: 1. Qualitat del video: 2. Qualitat del so: 3. Facilitat d'accedir a una videoconferència: 4. Facilitat d'organitzar una videoconferència: 5. Satisfacció general: Utilitzaries aquesta eina per comunicar-te amb companys de feina? SI / NO Utilitzaries aquesta eina per comunicar-te amb pacients? SI / NO Millores, suggerències o altrs comentaris que vulguis fer: Marc Antoni Bajet i Mena -149-
Integració d'un sistema de videoconferència en una plataforma socio – sanitària amb entorn web Annex G: Documents d'avaluació G.iv.1 Questionari respostos: Marc Antoni Bajet i Mena -150-